Skip to content

Commit b09c9c4

Browse files
authored
Spec: auctionBuyerKeys reporting (#117)
Adds spec handling for the per-buyer latency and statistics reporting for Protected Audience, see https://github.com/WICG/turtledove/blob/main/FLEDGE_extended_PA_reporting.md. Some follow-up work remains and has been tracked in issues added.
1 parent 23d4eb4 commit b09c9c4

File tree

1 file changed

+180
-16
lines changed

1 file changed

+180
-16
lines changed

spec.bs

+180-16
Original file line numberDiff line numberDiff line change
@@ -1243,8 +1243,22 @@ partial interface PrivateAggregation {
12431243
undefined contributeToHistogramOnEvent(
12441244
DOMString event, PAExtendedHistogramContribution contribution);
12451245
};
1246+
1247+
dictionary AuctionReportBuyersConfig {
1248+
required bigint bucket;
1249+
required double scale;
1250+
};
1251+
1252+
partial dictionary AuctionAdConfig {
1253+
sequence<bigint> auctionReportBuyerKeys;
1254+
record<DOMString, AuctionReportBuyersConfig> auctionReportBuyers;
1255+
};
12461256
</xmp>
12471257

1258+
Note: `requiredSellerCapabilities` is defined in the <a
1259+
href="https://wicg.github.io/turtledove/#dictdef-auctionadconfig">Protected
1260+
Audience spec</a>.
1261+
12481262
Issue: Do we want to align naming with implementation?
12491263

12501264
The {{InterestGroupScriptRunnerGlobalScope/privateAggregation}} [=getter steps=]
@@ -1329,6 +1343,10 @@ partial dictionary AuctionAdInterestGroup {
13291343
};
13301344
</xmp>
13311345

1346+
Note: `sellerCapabilities` is defined in the <a
1347+
href="https://wicg.github.io/turtledove#dictdef-generatebidinterestgroup">Protected
1348+
Audience spec</a>
1349+
13321350
Structures {#protected-audience-api-specific-structures}
13331351
--------------------------------------------------------
13341352

@@ -1344,14 +1362,21 @@ Extend the <a spec="turtledove">auction config</a> [=struct=] to add new fields:
13441362
: <dfn>batching scope map</dfn>
13451363
:: A [=map=] from a [=tuple=] consisting of an <dfn ignore>origin</dfn> (an
13461364
[=origin=]) and a <dfn ignore>coordinator</dfn> (an [=aggregation
1347-
coordinator=] or null) to a [=batching scope=].
1365+
coordinator=]) to a [=batching scope=].
13481366

13491367
Note: Does not include [=batching scopes=] for contributions conditional on
13501368
non-reserved events.
13511369
: <dfn>permissions policy state</dfn>
13521370
:: A [=permissions policy state=].
1353-
: <dfn>seller Private Aggregation coordinator</dfn> (default null)
1354-
:: An [=aggregation coordinator=] or null.
1371+
: <dfn>seller Private Aggregation coordinator</dfn>
1372+
:: An [=aggregation coordinator=]. Defaults to the [=default aggregation
1373+
coordinator=].
1374+
: <dfn>auction report buyer keys</dfn>
1375+
:: A [=map=] from buyer [=origins=] to {{bigint}}s.
1376+
: <dfn>auction report buyers</dfn>
1377+
:: A [=map=] from [=strings=] to {{AuctionReportBuyersConfig}}s.
1378+
1379+
Issue: Consider replacing the strings above with specific enum types.
13551380

13561381
</dl>
13571382

@@ -1502,7 +1527,57 @@ The <a spec="turtledove">validate and convert auction ad config</a> steps are
15021527
modified to add the following steps just before the last step ("Return
15031528
<var ignore>auctionConfig</var>"), renumbering the later step as appropriate:
15041529
<div algorithm="protected-audience-validate-config-monkey-patch">
1505-
7. If |config|[{{AuctionAdConfig/privateAggregationConfig}}] [=map/exists=]:
1530+
31. If |config|["<code>{{AuctionAdConfig/auctionReportBuyerKeys}}</code>"]
1531+
[=map/exists=]:
1532+
1. Let |interestGroupBuyers| be |auctionConfig|'s <a spec="turtledove"
1533+
for="auction config">interest group buyers</a>.
1534+
1. If |interestGroupBuyers| is null, set |interestGroupBuyers| to a new
1535+
[=list=].
1536+
1. [=list/For each=] |index| of [=the exclusive range|the range=] 0 to
1537+
|config|["<code>{{AuctionAdConfig/auctionReportBuyerKeys}}</code>"]'s
1538+
[=list/size=], exclusive:
1539+
1. Let |key| be
1540+
|config|["<code>{{AuctionAdConfig/auctionReportBuyerKeys}}</code>"][|index|].
1541+
1. If |key| is not in the range [0, 2<sup>128</sup>−1],
1542+
[=exception/throw=] a {{TypeError}}.
1543+
1. If |index| is equal to or greater than |interestGroupBuyers|' [=list/
1544+
size=], [=iteration/continue=].
1545+
1546+
Note: [=iteration/Continue=] is used (instead of [=iteration/
1547+
break=]) to match validation logic for all given buyer keys.
1548+
1. Let |origin| be |interestGroupBuyers|[|index|].
1549+
1. [=map/Set=] |auctionConfig|'s [=auction config/auction report buyer
1550+
keys=][|origin|] to |key|.
1551+
1552+
Issue: Check behavior when an origin is repeated in
1553+
{{AuctionAdConfig/interestGroupBuyers}}.
1554+
1. If |config|["<code>{{AuctionAdConfig/auctionReportBuyers}}</code>"] [=map/
1555+
exists=]:
1556+
1. [=map/For each=] |reportType| → |reportBuyerConfig| of
1557+
|config|["<code>{{AuctionAdConfig/auctionReportBuyers}}</code>"]:
1558+
1. If « "`interestGroupCount`", "`bidCount`",
1559+
"`totalGenerateBidLatency`", "`totalSignalsFetchLatency`" » does not
1560+
[=list/contain=] |reportType|, [=iteration/continue=].
1561+
1562+
Note: No error is thrown to allow forward compatibility if
1563+
additional report types are added later.
1564+
1565+
Issue: Should these strings be dash delimited?
1566+
1567+
1. If |reportBuyerConfig|["<code>{{AuctionReportBuyersConfig
1568+
/bucket}}</code>"] is not in the range [0, 2<sup>128</sup>−1],
1569+
[=exception/throw=] a {{TypeError}}.
1570+
1571+
Issue: Consider validating the case where the bucket used (after
1572+
summing) is too large. Currently, the implementation appears to
1573+
overflow. See <a
1574+
href="https://github.com/WICG/turtledove/issues/1040">
1575+
protected-audience/1040</a>.
1576+
1. [=map/Set=] |auctionConfig|'s [=auction config/auction report
1577+
buyers=][|reportType|] to |reportBuyerConfig|.
1578+
1579+
Issue: Handle `auctionReportBuyerDebugModeConfig` here.
1580+
1. If |config|[{{AuctionAdConfig/privateAggregationConfig}}] [=map/exists=]:
15061581
1. Let |aggregationCoordinator| be the result of [=obtaining the Private
15071582
Aggregation coordinator=] given
15081583
|config|[{{AuctionAdConfig/privateAggregationConfig}}].
@@ -1525,9 +1600,6 @@ nested scope), renumbering this and later steps as necessary.
15251600

15261601
</div>
15271602

1528-
Issue: Need to handle `auctionReportBuyers` and `auctionReportBuyerKeys` here or
1529-
in the Protected Audience API spec.
1530-
15311603
The <a spec="turtledove">evaluate a script</a> steps are modified in two ways.
15321604
First, we add the following steps after step 11 ("If
15331605
<var ignore>evaluationStatus</var> is an [=ECMAScript/abrupt completion=]..."),
@@ -1553,15 +1625,10 @@ renumbering later steps as appropriate:
15531625
[=interest group/Private Aggregation coordinator=].
15541626
1. Otherwise, set |aggregationCoordinator| to |auctionConfig|'s
15551627
[=auction config/seller Private Aggregation coordinator=].
1556-
1. Let |batchingScopeMap| be |auctionConfig|'s [=auction config/batching
1557-
scope map=].
1558-
1. Let |mapTuple| = (|origin|, |aggregationCoordinator|).
1559-
1. If |batchingScopeMap|[|mapTuple|] does not [=map/exist=]:
1560-
1. Set |batchingScopeMap|[|mapTuple|] to a new [=batching scope=].
1561-
1. If |aggregationCoordinator| is not null, [=set the aggregation
1562-
coordinator for a batching scope=] given
1563-
|aggregationCoordinator| and |batchingScopeMap|[|mapTuple|].
1564-
1. Return |batchingScopeMap|[|mapTuple|].
1628+
1. If |aggregationCoordinator| is null, set |aggregationCoordinator| to
1629+
the [=default aggregation coordinator=].
1630+
1. Return the result of running [=get or create a batching scope=] given
1631+
|origin|, |aggregationCoordinator| and |auctionConfig|.
15651632
: [=scoping details/get debug scope steps=]
15661633
:: An algorithm that returns |debugScope|.
15671634

@@ -1762,7 +1829,90 @@ an <a spec="turtledove">auction config</a> |auctionConfig| and a
17621829
details=]
17631830
1. [=Append an entry to the contribution cache|Append=] |entry| to
17641831
the [=contribution cache=].
1832+
1. Let |sellerBatchingScope| be the result of [=get or create a batching
1833+
scope|getting or creating a batching scope=] given |auctionConfig|'s <a
1834+
spec="turtledove" for="auction config">seller</a>, |auctionConfig|'s
1835+
[=auction config/seller Private Aggregation coordinator=], and
1836+
|auctionConfig|.
1837+
1. Let |auctionReportBuyersDebugScope| be a new [=debug scope=].
1838+
1. [=map/For each=] |reportType| → |reportBuyerConfig| of |auctionConfig|'s
1839+
[=auction config/auction report buyers=]:
1840+
1. [=map/For each=] |buyerOrigin| → |buyerOffset| of |auctionConfig|'s
1841+
[=auction config/auction report buyer keys=]:
1842+
1. Let |bucket| be the sum of |buyerOffset| and |reportBuyerConfig|'s
1843+
{{AuctionReportBuyersConfig/bucket}}.
1844+
1845+
Issue: Handle overflow here or in validation. See <a
1846+
href="https://github.com/WICG/turtledove/issues/1040">
1847+
protected-audience/1040</a>.
1848+
1. Let |value| be the result (a {{double}}) of switching on
1849+
|reportType|:
1850+
<dl class="switch">
1851+
: "`interestGroupCount`"
1852+
:: The number of interest groups in the [=user agent=]'s <a
1853+
spec="turtledove">interest group set</a> whose <a
1854+
spec="turtledove" for="interest group">owner</a> is
1855+
|buyerOrigin|.
1856+
: "`bidCount`"
1857+
:: The number of valid bids generated by interest groups whose <a
1858+
spec="turtledove" for="interest group">owner</a> is
1859+
|buyerOrigin|.
1860+
: "`totalGenerateBidLatency`"
1861+
:: The sum of execution time in milliseconds for all `generateBid()`
1862+
calls in the auction for interest groups whose <a
1863+
spec="turtledove" for="interest group">owner</a> is
1864+
|buyerOrigin|.
1865+
: "`totalSignalsFetchLatency`"
1866+
:: The total time spent fetching trusted buyer signals in
1867+
milliseconds, or 0 if the interest group didn't fetch any
1868+
trusted signals.
1869+
: None of the above values
1870+
:: [=Assert=]: false
1871+
1872+
Note: This enum value is validated in <a
1873+
spec="turtledove">validate and convert auction ad
1874+
config</a>.
1875+
1876+
</dl>
1877+
1878+
Issue: More formally spec the values here.
1879+
1. Set |value| to the result of multiplying |reportBuyerConfig|'s
1880+
{{AuctionReportBuyersConfig/scale}} with |value|.
1881+
1. Set |value| to the maximum of 0.0 and |value|.
1882+
1. Set |value| to the result of converting |value| to an integer by
1883+
truncating its fractional part.
1884+
1. Set |value| to the minimum of |value| and 2<sup>31</sup>−1.
1885+
1. Let |contribution| be a new {{PAHistogramContribution}} with the
1886+
items:
1887+
: {{PAHistogramContribution/bucket}}
1888+
:: |bucket|
1889+
: {{PAHistogramContribution/value}}
1890+
:: |value|
1891+
1892+
1. [=map/For each=] |ig| of the [=user agent=]'s <a spec="turtledove">
1893+
interest group set</a> whose
1894+
<a spec="turtledove" for="interest group">owner</a> is
1895+
|buyerOrigin|:
1896+
1. If seller capabilities don't allow this reporting, [=iteration/
1897+
continue=].
1898+
1899+
Issue: Align behavior with seller capabilities handling once <a
1900+
href="https://github.com/WICG/turtledove/issues/966">
1901+
protected-audience/966</a> is resolved.
1902+
1. Let |entry| be a new [=contribution cache entry=] with the items:
1903+
: [=contribution cache entry/contribution=]
1904+
:: |contribution|
1905+
: [=contribution cache entry/batching scope=]
1906+
:: |sellerBatchingScope|
1907+
: [=contribution cache entry/debug scope=]
1908+
:: |auctionReportBuyersDebugScope|
1909+
1. [=Append an entry to the contribution cache|Append=] |entry| to
1910+
the [=contribution cache=].
17651911

1912+
Issue: Handle `auctionReportBuyerDebugModeConfig` here, may need to pass an
1913+
override to [=mark a debug scope complete=] and possibly refactor to merge
1914+
handling with {{PrivateAggregation/enableDebugMode()}}.
1915+
1. [=Mark a debug scope complete=] given |auctionReportBuyersDebugScope|.
17661916
1. [=map/For each=] (|origin|, |aggregationCoordinator|) → |batchingScope| of
17671917
|auctionConfig|'s [=auction config/batching scope map=]:
17681918
1. [=Process contributions for a batching scope=] given |batchingScope|,
@@ -1772,6 +1922,20 @@ Issue: Verify interaction with component auctions.
17721922

17731923
Issue: Use `[=map/For each=]` where possible.
17741924

1925+
To <dfn>get or create a batching scope</dfn> given an [=origin=] |origin|, an
1926+
[=aggregation coordinator=] |aggregationCoordinator| and an <a
1927+
spec="turtledove">auction config</a> |auctionConfig|, perform the following
1928+
steps. They return a [=batching scope=].
1929+
1. Let |batchingScopeMap| be |auctionConfig|'s [=auction config/batching scope
1930+
map=].
1931+
1. Let |tuple| be (|origin|, |aggregationCoordinator|).
1932+
1. If |batchingScopeMap|[|tuple|] does not [=map/exist=]:
1933+
1. Set |batchingScopeMap|[|tuple|] to a new [=batching scope=].
1934+
1. If |aggregationCoordinator| is not null, [=set the aggregation
1935+
coordinator for a batching scope=] given |aggregationCoordinator| and
1936+
|batchingScopeMap|[|tuple|].
1937+
1. Return |batchingScopeMap|[|tuple|].
1938+
17751939
To <dfn>fill in the contribution</dfn> given a
17761940
{{PAExtendedHistogramContribution}} |contribution| and a
17771941
<a spec="turtledove">leading bid info</a> |leadingBidInfo|, perform the

0 commit comments

Comments
 (0)