-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change API layering in spec #51
Conversation
@yoavweiss could you take a quick look? I wasn't sure if this was the best direction towards fixing the layering, but I'm trying to allow each implementing API to define its own 'batching scope'. Specifically, I wasn't really sure whether functions being 'overridden' was a well-supported spec concept. Thanks! |
I've reworked this to separate out the parts that will (eventually) be moved to other specs into separate sections at the end as well as moved from 'overrides' to having a field that gets set by implementing specs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. A few comments
1. [=list/Append=] |contribution| to the [=contributions cache=]. | ||
1. Let |batchingScopeSteps| be the {{PrivateAggregation}} object's | ||
[=PrivateAggregation/get batching scope steps=]. | ||
1. If |batchingScopeSteps| is null, throw a new {{DOMException}} with name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can that happen? If not, it's better to assert it doesn't, rather than throwing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a note here -- below we say "The global scope may wait to set the field to indicate that the API is not yet available."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the behavior expected from developers here? Is there a way for them to check availability before hitting an exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really just to prevent the API being available during the initial execution of a script (e.g. while addModule()
runs). We only want the API to be available after that point. Definitely open to suggestions for better structuring this, but for now I've updated the description slightly to clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an example to better illustrate this, lmk if you think it's clear enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine as far as the spec go, but worthwhile thinking about the developer ergonomics here:
- How would developers know when it's fine to run this API call and when it isn't? Is that part of our developer documentation?
- If I'm a library provider enabling folks to send reports, how should I write my code so that it never runs too early? (regardless of when callers may call it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, makes sense. Added an issue to think about this a bit further/follow up.
spec.bs
Outdated
|
||
Structures {#structures} | ||
======================== | ||
|
||
General {#general-structures} | ||
----------------------------- | ||
|
||
<h4 dfn-type=dfn>Aggregatable report</h3> | ||
<h4 dfn-type=dfn>Batching scope</h4> | ||
A batching scope is a unique internal value that identifies which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/unique internal value/implementation-defined value/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this, I was trying to emulate the "opaque origin" kind of concept. I saw "unique internal value" in the HTML spec (https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#unique-values), but I don't think it's exported, so I might need to move that definition in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@domenic - thoughts? Should we try to export "unique internal value"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh I didn't realize that we made that into a whole concept with a definition. Probably we should move that to Infra and make it exported.
In the meantime, you could do <a spec=HTML>unique internal value</a>
to link to the concept despite it not being exported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, moved to the tag as suggested. Also added an issue and filed whatwg/infra#583 to track this.
@linnan-github, could you PTAL? Thanks! |
1. [=list/Append=] |contribution| to the [=contributions cache=]. | ||
1. Let |batchingScopeSteps| be the {{PrivateAggregation}} object's | ||
[=PrivateAggregation/get batching scope steps=]. | ||
1. If |batchingScopeSteps| is null, throw a new {{DOMException}} with name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine as far as the spec go, but worthwhile thinking about the developer ergonomics here:
- How would developers know when it's fine to run this API call and when it isn't? Is that part of our developer documentation?
- If I'm a library provider enabling folks to send reports, how should I write my code so that it never runs too early? (regardless of when callers may call it)
39ead42
to
af27a6d
Compare
spec.bs
Outdated
`run()` or to `selectURL()`), create a new [=batching scope=] and associate it | ||
with that invocation. | ||
|
||
When a {{PrivateAggregation}} object is exposed on a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "when..." here doesn't make sense, as you're defining that exposure above, with the partial interface. It'd be better to actually find algorithmic hooks that indicate that the addModule execution is done, and set the algorithm there.
spec.bs
Outdated
Note: Multiple operation invocations can be in-progress at the same time, each | ||
with a different batching scope. However, only one can be currently executing. | ||
|
||
When an operation invocation completes, [=mark a batching scope complete=] given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - is there an algorithm that runs the operation invocation, that can call this logic?
spec.bs
Outdated
Issue: Do we want to align naming with implementation? | ||
|
||
At the start of each Protected Audience auction (i.e. a call to | ||
`runAdAuction()`), create a new [=batching scope=] for each unique origin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you state that in terms of an algorithm step? (e.g. before step 1 of https://wicg.github.io/turtledove/#dom-navigator-runadauction)
spec.bs
Outdated
`runAdAuction()`), create a new [=batching scope=] for each unique origin | ||
participating in the auction (including both bidders and the seller). | ||
|
||
When a {{PrivateAggregation}} object is exposed on a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as for SharedStorage
spec.bs
Outdated
1. Return the [=batching scope=] associated with the auction and the |scope|'s | ||
[=relevant settings object=]'s [=environment settings object/origin=]. | ||
|
||
When an auction completes, perform the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, would be better to hook onto a specific algorithm.
@yoavweiss Thanks for the feedback! Had a go reworking to better integrate with the specs. Ran into a few issues with the other specs, so opened issues and noted those in this spec too where relevant. Some of the integrations I've put here are a little more handwavy than I'd like, but that should be fixable once those issues are resolved. |
|
||
Note: This last requirement means that global scopes with different origins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably can mention or link to the Same-Origin policy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment (and an issue to actually link the section in the security considerations once that PR lands)
See infra/201 | ||
See <a href="https://github.com/whatwg/infra/issues/201">infra/201</a>. | ||
|
||
To <dfn algorithm export>append an entry to the contribution cache</dfn> given a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this is only one step, does it need to be a standalone algorithm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it this way to allow other APIs to integrate, e.g. for the Protected Audience extensions. I put these under a new heading "Exported algorithms" to make this clearer
Creates new exported algorithms and one algorithm to be overriden. This cl doesn't actually move any content to other specs, but is a step to making that simpler. This change also addresses batching, by defining the batching scopes more completely.
3a54c0e
to
ada0439
Compare
Thanks for all the improvements! |
SHA: 3d32307 Reason: push, by alexmturner Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Creates new exported algorithms and one algorithm to be overriden. This cl doesn't actually move any content to other specs, but is a step to making that simpler. This change also addresses batching, by defining the batching scopes more completely.
Preview | Diff