Skip to content

Commit e03bedb

Browse files
authored
Spec: Wrap context IDs in a "pre-specified report parameters" object (#128)
This new struct will be used for the filtering ID handling in a follow-up spec change. This PR also factors out the determination of whether a report should be sent deterministically into its own algorithm to simplify the future change. This PR should be a no-op.
1 parent d94d9e8 commit e03bedb

File tree

1 file changed

+115
-74
lines changed

1 file changed

+115
-74
lines changed

spec.bs

+115-74
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,17 @@ A context type is a [=string=] indicating what kind of global scope the
371371
{{PrivateAggregation}} object was exposed in. Each API exposing Private
372372
Aggregation should pick a unique string (or multiple) for this.
373373

374+
Pre-specified report parameters {#pre-specified-report-parameters-structure}
375+
----------------------------------------------------------------------------
376+
377+
A <dfn>pre-specified report parameters</dfn> is a [=struct=] with the following
378+
items:
379+
<dl dfn-for="pre-specified report parameters">
380+
: <dfn>context ID</dfn> (default: null)
381+
:: A [=string=] or null
382+
383+
</dl>
384+
374385
Storage {#storage}
375386
==================
376387

@@ -380,8 +391,8 @@ A [=user agent=] holds an <dfn>aggregatable report cache</dfn>, which is a
380391
A [=user agent=] holds an <dfn>aggregation coordinator map</dfn>, which is a
381392
[=map=] from [=batching scopes=] to [=aggregation coordinators=].
382393

383-
A [=user agent=] holds a <dfn>context ID map</dfn>, which is a [=map=] from
384-
[=batching scopes=] to [=strings=].
394+
A [=user agent=] holds a <dfn>pre-specified report parameters map</dfn>, which
395+
is a [=map=] from [=batching scopes=] to [=pre-specified report parameters=].
385396

386397
A [=user agent=] holds a <dfn>contribution cache</dfn>, which is a [=list=] of
387398
[=contribution cache entries=].
@@ -399,7 +410,8 @@ the [=aggregatable report cache=] as well as any contribution history data
399410
stored for the [=consume budget if permitted=] algorithm.
400411

401412
The user agent may expose controls that allow the user to delete data from the
402-
[=context ID map=], the [=contribution cache=] and the [=debug scope map=].
413+
[=contribution cache=], the [=debug scope map=] and the [=pre-specified report
414+
parameters map=].
403415

404416
[=Implementation-defined=] values {#implementation-defined-values}
405417
==================================================================
@@ -493,6 +505,18 @@ scope=] |debugScope| and an optional [=debug details=] or null
493505
set |entry|'s [=contribution cache entry/debug details=] to
494506
|debugDetails|.
495507

508+
To <dfn>determine if a report should be sent deterministically</dfn> given a
509+
[=pre-specified report parameters=] |preSpecifiedParams|, perform the following
510+
steps. They return a [=boolean=]:
511+
1. If |preSpecifiedParams|' [=pre-specified report parameters/context ID=] is
512+
not null, return true.
513+
1. Return false.
514+
515+
Note: If a context ID was specified, a report is sent, even if there are no
516+
contributions or there is insufficent budget for the requested
517+
contributions. See [Protecting against leaks via the number of
518+
reports](#protecting-against-leaks-via-the-number-of-reports).
519+
496520
To <dfn algorithm export>process contributions for a batching scope</dfn> given
497521
a [=batching scope=] |batchingScope|, an [=origin=] |reportingOrigin|, a
498522
[=context type=] |contextType| and a [=moment=] or null |timeout|:
@@ -513,18 +537,18 @@ a [=batching scope=] |batchingScope|, an [=origin=] |reportingOrigin|, a
513537
1. Set |aggregationCoordinator| to [=aggregation coordinator
514538
map=][|batchingScope|].
515539
1. [=map/Remove=] [=aggregation coordinator map=][|batchingScope|].
516-
1. Let |contextId| be null.
517-
1. If [=context ID map=][|batchingScope|] [=map/exists=]:
518-
1. Set |contextId| to [=context ID map=][|batchingScope|].
519-
1. [=map/Remove=] [=context ID map=][|batchingScope|].
520-
1. Otherwise, [=assert=]: |timeout| is null.
540+
1. Let |preSpecifiedParams| be a new [=pre-specified report parameters=].
541+
1. If [=pre-specified report parameters map=][|batchingScope|] [=map/exists=]:
542+
1. Set |preSpecifiedParams| to [=pre-specified report parameters
543+
map=][|batchingScope|].
544+
1. [=map/Remove=] [=pre-specified report parameters map=][|batchingScope|].
545+
1. Let |isDeterministicReport| be the result of [=determining if a report should
546+
be sent deterministically=] given |preSpecifiedParams|.
547+
1. If |isDeterministicReport| is false, [=assert=]: |timeout| is null.
521548

522549
Note: Timeouts can only be used for deterministic reports.
523-
1. If |batchEntries| [=list/is empty=] and |contextId| is null, return.
524-
525-
Note: If a context ID was specified, a report is sent, even if there are no
526-
contributions. See [Protecting against leaks via the number of
527-
reports](#protecting-against-leaks-via-the-number-of-reports).
550+
1. If |batchEntries| [=list/is empty=] and |isDeterministicReport| is false,
551+
return.
528552
1. Let |batchedContributions| be a new [=ordered map=].
529553
1. [=list/iterate|For each=] |entry| of |batchEntries|:
530554
1. [=list/Remove=] |entry| from the [=contribution cache=].
@@ -541,7 +565,7 @@ a [=batching scope=] |batchingScope|, an [=origin=] |reportingOrigin|, a
541565
|batchedContributions|:
542566
1. Perform the [=report creation and scheduling steps=] with
543567
|reportingOrigin|, |contextType|, |contributions|, |debugDetails|,
544-
|aggregationCoordinator|, |contextId| and |timeout|.
568+
|aggregationCoordinator|, |preSpecifiedParams| and |timeout|.
545569

546570
Note: These steps break up the contributions based on their [=debug details=] as
547571
each report can only have one set of metadata.
@@ -567,11 +591,15 @@ Issue: Elsewhere, surround algorithms in a `<div algorithm>` block to match, and
567591
add styling for all algorithms per
568592
[bikeshed/1472](https://github.com/speced/bikeshed/issues/1472).
569593

570-
To <dfn algorithm export>set the context ID for a batching scope</dfn> given
571-
a [=string=] |contextId| and a [=batching scope=] |batchingScope|:
594+
To <dfn algorithm export>set the pre-specified report parameters for a batching
595+
scope</dfn> given a [=pre-specified report parameters=] |params| and a
596+
[=batching scope=] |batchingScope|:
572597

573-
1. [=Assert=]: |contextId|'s [=string/length=] is not larger than 64.
574-
1. [=map/Set=] [=context ID map=][|batchingScope|] to |contextId|.
598+
1. Let |contextId| be |params|' [=pre-specified report parameters/context ID=].
599+
1. [=Assert=]: |contextId| is null or |contextId|'s [=string/length=] is not
600+
larger than 64.
601+
1. [=map/Set=] [=pre-specified report parameters map=][|batchingScope|] to
602+
|params|.
575603

576604
Scheduling reports {#scheduling-reports}
577605
----------------------------------------
@@ -580,7 +608,8 @@ To perform the <dfn algorithm>report creation and scheduling steps</dfn> with an
580608
[=origin=] |reportingOrigin|, a [=context type=] |api|, a [=list=] of
581609
{{PAHistogramContribution}}s |contributions|, a [=debug details=]
582610
|debugDetails|, an [=aggregation coordinator=] |aggregationCoordinator|, a
583-
[=string=] or null |contextId| and a [=moment=] or null |timeout|:
611+
[=pre-specified report parameters=] |preSpecifiedParams| and a [=moment=] or
612+
null |timeout|:
584613
1. [=Assert=]: |reportingOrigin| is a [=potentially trustworthy origin=].
585614
1. Optionally, return.
586615

@@ -603,17 +632,14 @@ To perform the <dfn algorithm>report creation and scheduling steps</dfn> with an
603632
1. Let |sufficientBudget| be the result of [=consuming budget if permitted=]
604633
given |contributionSum|, |reportingOrigin|, |api| and |currentWallTime|.
605634
1. If |sufficientBudget| is false:
606-
1. If |contextId| is null, return.
635+
1. Let |isDeterministicReport| be the result of [=determining if a report
636+
should be sent deterministically=] given |preSpecifiedParams|.
637+
1. If |isDeterministicReport| is false, return.
607638
1. [=list/Empty=] |truncatedContributions|.
608-
609-
Note: If a context ID was specified, a report is sent, even if there is
610-
insufficent budget for the requested contributions. In this case,
611-
the contributions are dropped. See
612-
[Protecting against leaks via the number of
613-
reports](#protecting-against-leaks-via-the-number-of-reports).
614639
1. Let |report| be the result of [=obtaining an aggregatable report=] given
615640
|reportingOrigin|, |api|, |truncatedContributions|, |debugDetails|,
616-
|aggregationCoordinator|, |contextId|, |timeout| and |currentWallTime|.
641+
|aggregationCoordinator|, |preSpecifiedParams|, |timeout| and
642+
|currentWallTime|.
617643
1. [=set/Append=] |report| to the user agent's [=aggregatable report cache=].
618644

619645
To <dfn algorithm>consume budget if permitted</dfn> given a {{long}} |value|, an
@@ -630,8 +656,8 @@ To <dfn>obtain an aggregatable report</dfn> given an [=origin=]
630656
|reportingOrigin|, a [=context type=] |api|, a [=list=] of
631657
{{PAHistogramContribution}}s |contributions|, a [=debug details=]
632658
|debugDetails|, an [=aggregation coordinator=] |aggregationCoordinator|, a
633-
[=string=] or null |contextId|, a [=moment] or null |timeout| and a [=moment=]
634-
|currentTime|,
659+
[=pre-specified report parameters=] |preSpecifiedParams|, a [=moment] or null
660+
|timeout| and a [=moment=] |currentTime|,
635661
perform the following steps. They return an [=aggregatable report=].
636662
1. [=Assert=]: |reportingOrigin| is a [=potentially trustworthy origin=].
637663
1. Let |reportTime| be the result of running [=obtain a report delivery time=]
@@ -654,7 +680,7 @@ perform the following steps. They return an [=aggregatable report=].
654680
: [=aggregatable report/aggregation coordinator=]
655681
:: |aggregationCoordinator|
656682
: [=aggregatable report/context ID=]
657-
:: |contextId|
683+
:: |preSpecifiedParams|' [=pre-specified report parameters/context ID=]
658684
: [=aggregatable report/queued=]
659685
:: false
660686
1. Return |report|.
@@ -1046,28 +1072,31 @@ steps. They return an [=aggregation coordinator=], null or a {{DOMException}}:
10461072
"`DataError`".
10471073
1. Return |origin|.
10481074

1049-
To <dfn algorithm>obtain the context ID</dfn> given a
1075+
To <dfn algorithm>obtain the pre-specified report parameters</dfn> given a
10501076
{{SharedStorageRunOperationMethodOptions}} |options|, perform the following
1051-
steps. They return a [=string=], null, or a {{DOMException}}:
1077+
steps. They return a [=pre-specified report parameters=], null, or a
1078+
{{DOMException}}:
10521079
1. If |options|["{{SharedStorageRunOperationMethodOptions/privateAggregationConfig}}"]
10531080
does not [=map/exist=], return null.
1081+
1. Let |contextId| be null.
10541082
1. If |options|["{{SharedStorageRunOperationMethodOptions/privateAggregationConfig}}"]["{{SharedStoragePrivateAggregationConfig/contextId}}"]
1055-
does not [=map/exist=], return null.
1056-
1. Let |contextId| be
1083+
[=map/exists=], set |contextId| to
10571084
|options|["{{SharedStorageRunOperationMethodOptions/privateAggregationConfig}}"]["{{SharedStoragePrivateAggregationConfig/contextId}}"].
10581085
1. If |contextId|'s [=string/length=] is greater than 64, return a new
10591086
{{DOMException}} with name "`DataError`".
1060-
1. Return |contextId|.
1087+
1. Return a new [=pre-specified report parameters=] with the items:
1088+
: [=pre-specified report parameters/context ID=]
1089+
:: |contextId|
10611090

10621091
The {{WindowSharedStorage}}'s {{WindowSharedStorage/run()}} method steps are
10631092
modified in four ways. First, add the following steps just after step 2 ("If
10641093
{{Worklet/addModule()}} has not yet been called, ..."), renumbering later steps
10651094
as appropriate:
10661095
<div algorithm="shared-storage-run-monkey-patch-1">
1067-
3. Let |contextId| be the result of [=obtaining the context ID=] given
1068-
|options|.
1069-
1. If |contextId| is a {{DOMException}}, return [=a promise rejected with=]
1070-
|contextId|.
1096+
3. Let |preSpecifiedParams| be the result of [=obtaining the pre-specified
1097+
report parameters=] given |options|.
1098+
1. If |preSpecifiedParams| is a {{DOMException}}, return [=a promise rejected
1099+
with=] |preSpecifiedParams|.
10711100
1. Let |aggregationCoordinator| be the result of [=obtaining the aggregation
10721101
coordinator=] given |options|.
10731102
1. If |aggregationCoordinator| is a {{DOMException}}, return [=a promise
@@ -1080,19 +1109,23 @@ be |operationMap|[|name|]." (renumbering later steps as appropriate):
10801109
2. Let |batchingScope| be a new [=batching scope=].
10811110
1. Let <var ignore>debugScope</var> be a new [=debug scope=].
10821111
1. Let |privateAggregationTimeout| be null.
1083-
1. If |contextId| is not null:
1084-
1. Set |privateAggregationTimeout| to the [=current wall time=] plus a
1085-
non-negative [=implementation-defined=] [=duration=].
1086-
1. [=Set the context ID for a batching scope=] given |contextId| and
1087-
|batchingScope|.
1112+
1. Let |isDeterministicReport| be false.
1113+
1. If |preSpecifiedParams| is not null:
1114+
1. Set |isDeterministicReport| to the result of [=determining if a report
1115+
should be sent deterministically=] given |preSpecifiedParams|.
1116+
1. If |isDeterministicReport|:
1117+
1. Set |privateAggregationTimeout| to the [=current wall time=] plus the
1118+
[=deterministic operation timeout duration=].
1119+
1. [=Set the pre-specified report parameters for a batching scope=] given
1120+
|preSpecifiedParams| and |batchingScope|.
10881121
1. If |aggregationCoordinator| is not null, [=set the aggregation coordinator
10891122
for a batching scope=] given |aggregationCoordinator| and |batchingScope|.
10901123

10911124
</div>
10921125

10931126
Third, add the following steps in the same nested scope just before the current
1094-
last step ("Otherwise, [=call=] operation without any arguments list",
1095-
renumbering the last step as appropriate):
1127+
penultimate step ("If |options| [=map/contains=] |data|", renumbering the last
1128+
step as appropriate):
10961129
<div algorithm="shared-storage-run-monkey-patch-3">
10971130
1. Let |hasRunPrivateAggregationCompletionTask| be false.
10981131
1. Let |privateAggregationCompletionTask| be an algorithm to perform the
@@ -1101,17 +1134,13 @@ renumbering the last step as appropriate):
11011134
1. Set |hasRunPrivateAggregationCompletionTask| to true.
11021135
1. [=Mark a debug scope complete=] given <var ignore>debugScope</var>.
11031136
1. [=Process contributions for a batching scope=] given
1104-
|batchingScope|, <var ignore>outsideSettings</var>' [=environment
1105-
settings object/origin=], "<code>shared-storage</code>" and
1106-
|privateAggregationTimeout|.
1107-
1. If |contextId| is not null:
1108-
1. Set |privateAggregationTimeout| to the [=current wall time=] plus a
1109-
non-negative [=implementation-defined=] [=duration=].
1110-
1. [=Set the context ID for a batching scope=] given |contextId| and
1111-
|batchingScope|.
1112-
1. Run the following steps [=in parallel=]:
1113-
1. Wait until |privateAggregationTimeout|.
1114-
1. Run |privateAggregationCompletionTask|.
1137+
<var ignore>batchingScope</var>, <var ignore>outsideSettings</var>'
1138+
[=environment settings object/origin=], "<code>shared-storage</code>"
1139+
and |privateAggregationTimeout|.
1140+
1. If <var ignore>isDeterministicReport</var>>, run the following steps [=in
1141+
parallel=]:
1142+
1. Wait until |privateAggregationTimeout|.
1143+
1. Run |privateAggregationCompletionTask|.
11151144

11161145
</div>
11171146

@@ -1127,10 +1156,10 @@ are modified in three ways. First, add the following steps just after step 5
11271156
("If {{Worklet/addModule()}} has not yet been called, ..."), renumbering later
11281157
steps:
11291158
<div algorithm="shared-storage-selecturl-monkey-patch-1">
1130-
6. Let |contextId| be the result of [=obtaining the context ID=] given
1131-
|options|.
1132-
1. If |contextId| is a {{DOMException}}, return [=a promise rejected with=]
1133-
|contextId|.
1159+
6. Let |preSpecifiedParams| be the result of [=obtaining the pre-specified
1160+
report parameters=] given |options|.
1161+
1. If |preSpecifiedParams| is a {{DOMException}}, return [=a promise rejected
1162+
with=] |preSpecifiedParams|.
11341163
1. Let |aggregationCoordinator| be the result of [=obtaining the aggregation
11351164
coordinator=] given |options|.
11361165
1. If |aggregationCoordinator| is a {{DOMException}}, return [=a promise
@@ -1155,12 +1184,15 @@ be |operationMap|[|name|]." (renumbering later steps as appropriate):
11551184
and |privateAggregationTimeout|.
11561185
1. If |aggregationCoordinator| is not null, [=set the aggregation coordinator
11571186
for a batching scope=] given |aggregationCoordinator| and |batchingScope|.
1158-
1. If |contextId| is not null:
1159-
1. Set |privateAggregationTimeout| to the [=current wall time=] plus a
1160-
non-negative [=implementation-defined=] [=duration=].
1161-
1. [=Set the context ID for a batching scope=] given |contextId| and
1162-
|batchingScope|.
1163-
1. Run the following steps [=in parallel=]:
1187+
1. If |preSpecifiedParams| is not null:
1188+
1. Let |isDeterministicReport| be the result of [=determining if a report
1189+
should be sent deterministically=] given |preSpecifiedParams|.
1190+
1. If |isDeterministicReport|:
1191+
1. Set |privateAggregationTimeout| to the [=current wall time=] plus the
1192+
[=deterministic operation timeout duration=].
1193+
1. [=Set the pre-specified report parameters for a batching scope=] given
1194+
|preSpecifiedParams| and |batchingScope|.
1195+
1. If |isDeterministicReport|, run the following steps [=in parallel=]:
11641196
1. Wait until |privateAggregationTimeout|.
11651197
1. Run |privateAggregationCompletionTask|.
11661198

@@ -1219,6 +1251,14 @@ Note: This extends Shared Storage's existing {{Worklet/addModule()}}
12191251
<a href="https://wicg.github.io/shared-storage/#worklet-monkey-patch">
12201252
monkey patch</a>.
12211253

1254+
[=Implementation-defined=] values {#shared-storage-implementation-defined-values}
1255+
---------------------------------------------------------------------------------
1256+
1257+
<dfn>Deterministic operation timeout duration</dfn> is a non-negative
1258+
[=duration=] that controls how long a Shared Storage operation may make Private
1259+
Aggregation contributions if it is triggering a deterministic report and,
1260+
equivalently, when that report should be sent after the operation begins.
1261+
12221262
Protected Audience API monkey patches {#protected-audience-api-monkey-patches}
12231263
==============================================================================
12241264

@@ -2220,9 +2260,10 @@ stored for the [=consume budget if permitted=] algorithm contain data about a
22202260
user’s web activity. As such, user controls to delete this data are required,
22212261
see [clearing storage](#clearing-storage).
22222262

2223-
On the other hand, the [=context ID map=], the [=contribution cache=] and the
2224-
[=debug scope map=] only contain short-lived data tied to particular [=batching
2225-
scopes=] and [=debug scopes=], so controls are not required.
2263+
On the other hand, the [=contribution cache=], the [=debug scope map=] and the
2264+
[=pre-specified report parameters map=] only contain short-lived data tied to
2265+
particular [=batching scopes=] and [=debug scopes=], so controls are not
2266+
required.
22262267

22272268
Reporting delay concerns {#reporting-delay-concerns}
22282269
----------------------------------------------------
@@ -2304,10 +2345,10 @@ Security considerations {#security-considerations}
23042345
Same-origin policy {#same-origin-policy}
23052346
----------------------------------------
23062347

2307-
Writes to the [=aggregatable report cache=], [=context ID map=], [=contribution
2308-
cache=] and [=debug scope map=] are separated by the reporting [=origin=] and
2309-
the data included in any report with a given reporting [=origin=] are generated
2310-
with only data from that [=origin=].
2348+
Writes to the [=aggregatable report cache=], [=contribution cache=], [=debug
2349+
scope map=] and [=pre-specified report parameters map=] are attributed to the
2350+
reporting [=origin=] and the data included in any report with a given reporting
2351+
[=origin=] are generated with only data from that [=origin=].
23112352

23122353
One notable exception is the [=consume budget if permitted=] algorithm which is
23132354
[=implementation-defined=] and can consider contribution history from other

0 commit comments

Comments
 (0)