From b0aa11e116311d3858d834325567d184afbcb584 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Fri, 1 Nov 2024 14:33:52 -0400 Subject: [PATCH 01/19] Reserved.once specification. --- spec.bs | 96 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 28 deletions(-) diff --git a/spec.bs b/spec.bs index 08ddabc42..3e2ba7b0d 100644 --- a/spec.bs +++ b/spec.bs @@ -2365,10 +2365,11 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a contributions, and some special handling of private aggregation requests involving reject-reason); as it would be problematic to report a winner that didn't actually win. - 1. If |reportingContext|'s [=reporting context/debug reporting info=][|generatedBid|'s [=generated - bid/reporting id=]] does not [=map/exist=], set it to a new [=bid debug reporting info=]. + 1. Let |reportingId| be |generatedBid|'s [=generated bid/reporting id=]. + 1. If |reportingContext|'s [=reporting context/debug reporting info=][|reportingId|] does not + [=map/exist=], set it to a new [=bid debug reporting info=]. 1. Let |bidDebugReportInfo| be |reportingContext|'s [=reporting context/debug reporting info=] - [|generatedBid|'s [=generated bid/reporting id=]]. + [|reportingId|]. 1. If |auctionLevel| is "top-level-auction": 1. Set |bidDebugReportInfo|'s [=bid debug reporting info/top level seller debug loss report url=] to |debugLossReportUrl|. @@ -2384,8 +2385,10 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a 1. If |auctionConfig|'s [=auction config/seller real time reporting config=] is "`default-local-reporting`", then [=insert entries to map=] given |realTimeContributionsMap|, |seller|, and |realTimeContributions|. - 1. [=Commit private aggregation contributions=] given |paContributions|, |generatedBid|'s - [=generated bid/reporting id=] and |reportingContext|. + 1. [=set/Insert=] |reportingId| into |reportingContext|'s [=reporting context/bidder + participants=]. + 1. [=Commit private aggregation contributions=] given |paContributions|, |reportingId|, and + |reportingContext|. 1. Let |scoreAdOutput| be result of [=processing scoreAd output=] with |scoreAdResult|. 1. Return if any of the following conditions hold: * |scoreAdOutput| is failure; @@ -2895,10 +2898,10 @@ and a [=global object=] |global|: 1. Let |sellerReportingScript| be the result of [=waiting for script body from a fetcher=] given |sellerReportingScriptFetcher|. 1. Let « |sellerSignals|, |reportUrl|, |reportingBeaconMap|, ignored, |paContributions| » be the - result of [=evaluating a reporting script=] with |sellerReportingScript|, "`reportResult`", - |reportingContext|, |config|'s [=auction config/seller=], |config|'s [=auction config/seller - Private Aggregation coordinator=], |config|'s [=auction config/config idl=]'s - {{AuctionAdConfig/reportingTimeout}}, and + result of [=evaluating a reporting script=] with |sellerReportingScript|, [=worklet function/ + report-result=], |reportingContext|, |config|'s [=auction config/seller=], |config|'s + [=auction config/seller Private Aggregation coordinator=], |config|'s [=auction config/ + config idl=]'s {{AuctionAdConfig/reportingTimeout}}, and « |config|'s [=auction config/config idl=], |browserSignals|, |directFromSellerSignals| ». 1. Let |reportingResult| be a [=reporting result=] with the following [=struct/items=]: : [=reporting result/report url=] @@ -2994,10 +2997,10 @@ a {{ReportingBrowserSignals}} |browserSignals|, a [=direct from seller signals=] 1. If |winner|'s [=generated bid/provided as additional bid=] is true: 1. Set |reportFunctionName| be "`reportAdditionalBidWin`". 1. Let « ignored, |resultUrl|, |reportingBeaconMap|, |reportingMacroMap|, |paContributions| » be - the result of [=evaluating a reporting script=] with |buyerReportingScript|, "`reportWin`", - |reportingContext|, |ig|'s [=interest group/owner=], |ig|'s [=interest group/Private Aggregation - coordinator=], |leadingBidInfo|'s [=leading bid info/auction config=]'s [=auction config/config - idl=]'s {{AuctionAdConfig/reportingTimeout}}, and + the result of [=evaluating a reporting script=] with |buyerReportingScript|, [=worklet function/ + report-win=], |reportingContext|, |ig|'s [=interest group/owner=], |ig|'s [=interest group/ + Private Aggregation coordinator=], |leadingBidInfo|'s [=leading bid info/auction config=]'s + [=auction config/config idl=]'s {{AuctionAdConfig/reportingTimeout}}, and « |leadingBidInfo|'s [=leading bid info/auction config=]'s [=auction config/config idl=]'s {{AuctionAdConfig/auctionSignals}}, |perBuyerSignalsForBuyer|, |sellerSignals|, |reportWinBrowserSignals|, |directFromSellerSignals| ». @@ -3626,6 +3629,15 @@ A reporting context is a [=struct=] with the following [=struct/items :: A [=reporting bid key=] or null, initially null. This can be null even if [=reporting context/ local leader info=] has a leader set, in case this context is for a component auction that lost at top-level. + : bidder participants + :: A [=set=] of [=reporting bid keys=], representing interest groups that got a chance to generate + bids for the auction. This will be empty in top-level auctions, as the relevant state will be + in the component auctions. + : seller participants + :: A [=set=] of [=reporting bid keys=], representing various `scoreAd()` executions. Note that + some of these may be based on bids that started as additional bids or from component auctions + run by Bidding and Auction services, and not interest groups, so this list may be quite + different from [=reporting context/bidder participants=]. A reporting context map is a [=map=] from [=auction config=] to [=reporting context=]. @@ -3665,6 +3677,7 @@ auction in a multi-party auction). :: |ig|'s [=interest group/name=] 1. [=map/Set=] |reportingContext|'s [=reporting context/debug reporting info=][|id|] to |bidDebugReportInfo|. + 1. [=set/Insert=] |id| into |reportingContext|'s [=reporting context/bidder participants=]. 1. [=Commit private aggregation contributions=] given |paContributions|, |id| and |reportingContext|. 1. [=list/For each=] |generatedBid| of |generatedBids|: @@ -4074,6 +4087,8 @@ An on event contribution entry is a [=struct=] with the following items: :: A [=debug scope=] : debug details :: A [=debug details=] or null (default null) +: worklet function +:: A [=worklet function=]. @@ -4099,9 +4114,10 @@ contribution entries=].
To prepare for private aggregation given a -{{InterestGroupScriptRunnerGlobalScope}} |global|, a [=reporting context=] |reportingContext|, -and [=origins=] |origin| and |aggregationCoordinator|: +{{InterestGroupScriptRunnerGlobalScope}} |global|, a [=worklet function=] |workletFunction|, +a [=reporting context=] |reportingContext|, and [=origins=] |origin| and |aggregationCoordinator|: 1. Let |debugScope| be a new [=debug scope=]. +1. Set |global|'s [=InterestGroupScriptRunnerGlobalScope/worklet function=] to |workletFunction|. 1. Set |global|'s [=InterestGroupScriptRunnerGlobalScope/private aggregation=] to a new [=PrivateAggregation=] with the following [=struct/items=]: : allowed to use @@ -4191,12 +4207,24 @@ an [=auction config=] |auctionConfig| and a [=reporting context=] |reportingCont 1. If |auctionConfig|'s [=auction config/aborted=] is true, return. 1. Let |winnerId| be |reportingContext|'s [=reporting context/winner reporting id=] 1. Let |leadingBidInfo| be |reportingContext|'s [=reporting context/local leader info=]. +1. Let |bidderOnceRep| be null. +1. If |reportingContext|'s [=reporting context/bidder participants=] [=set/is not empty=], + set |bidderOnceRep| to a random member of [=reporting context/bidder participants=]. +1. Let |sellerOnceRep| be null. +1. If |reportingContext|'s [=reporting context/seller participants=] [=set/is not empty=], + set |sellerOnceRep| to a random member of [=reporting context/seller participants=]. 1. [=map/For each=] (|bidId|, |event|) → |contributions| of |reportingContext|'s [=reporting context/private aggregation on event contributions=]: 1. If |event| is "`reserved.win`" or does not [=string/start with=] "`reserved.`": 1. If |bidId| is not |winnerId|, [=iteration/continue=]. 1. If |event| is "`reserved.loss`" and |bidId| is |winnerId|, [=iteration/continue=]. 1. [=list/For each=] |onEventEntry| of |contributions|: + 1. If |event| is "`reserved.once`": + 1. If |onEventEntry|'s [=on event contribution entry/worklet function=] is [=worklet function/ + generate-bid=]: + 1. If |bidId| ≠ |bidderOnceRep|, [=iteration/continue=]. + 1. Otherwise: + 1. If |bidId| ≠ |sellerOnceRep|, [=iteration/continue=]. 1. Let |filledInContribution| be the result of [=filling in the contribution=] given |onEventEntry|'s [=on event contribution entry/contribution=] and |leadingBidInfo|. @@ -5318,8 +5346,9 @@ of the following global objects: [=InterestGroupBiddingScriptRunnerGlobalScope/group has ad components=] to true if |ig|'s [=interest group/ad components=] is not null, or false otherwise. 1. Set |global|'s [=InterestGroupBiddingScriptRunnerGlobalScope/expected currency=] to |expectedCurrency|. - 1. [=Prepare for private aggregation=] given |global|, |reportingContext|, |ig|'s [=interest - group/owner=] and |ig|'s [=interest group/Private Aggregation coordinator=]. + 1. [=Prepare for private aggregation=] given |global|, [=worklet function/generate-bid=], + |reportingContext|, |ig|'s [=interest group/owner=] and |ig|'s [=interest group/Private + Aggregation coordinator=]. 1. Let |isComponentAuction| be true if |browserSignals|["{{BiddingBrowserSignals/topLevelSeller}}"] is not null, or false otherwise. 1. Set |global|'s [=InterestGroupBiddingScriptRunnerGlobalScope/is component auction=] to @@ -5410,9 +5439,9 @@ of the following global objects: {{InterestGroupScoringScriptRunnerGlobalScope}}. 1. Let |global| be |realm|'s [=realm/global object=]. 1. Let |settings| be |realm|'s [=realm/settings object=]. - 1. [=Prepare for private aggregation=] given |global|, |reportingContext|, |auctionConfig|'s - [=auction config/seller=] and |auctionConfig|'s [=auction config/seller Private Aggregation - coordinator=]. + 1. [=Prepare for private aggregation=] given |global|, [=worklet function/score-ad=], + |reportingContext|, |auctionConfig|'s [=auction config/seller=] and |auctionConfig|'s + [=auction config/seller Private Aggregation coordinator=]. 1. Let |browserSignalsJS| be |browserSignals| [=converted to ECMAScript values=]. 1. Let |auctionConfigJS| be |auctionConfig|'s [=auction config/config idl=] [=converted to ECMAScript values=]. @@ -5449,16 +5478,18 @@ of the following global objects:
- To evaluate a reporting script given a [=string=] |script|, a [=string=] - |functionName|, a [=reporting context=] |reportingContext|, an [=origin=] |origin|, an - [=origin=] |privateAggregationCoordinator|, an integer millisecond [=duration=] |timeout|, - and a [=list=] of arguments |arguments|: + To evaluate a reporting script given a [=string=] |script|, a [=worklet function=] + |function|, a [=reporting context=] |reportingContext|, an [=origin=] |origin|, an [=origin=] + |privateAggregationCoordinator|, an integer millisecond [=duration=] |timeout|, and a [=list=] + of arguments |arguments|: 1. Let |realm| be the result of [=creating a new script runner realm=] given {{InterestGroupReportingScriptRunnerGlobalScope}}. 1. Let |global| be |realm|'s [=realm/global object=]. - 1. [=Prepare for private aggregation=] given |global|, |reportingContext|, |origin|, and - |privateAggregationCoordinator|. + 1. Let |functionName| be `"reportWin"`. + 1. If |function| is [=worklet function/report-result=], set |functionName| to `"reportResult"`. + 1. [=Prepare for private aggregation=] given |global|, |function|, |reportingContext|, |origin|, + and |privateAggregationCoordinator|. 1. Let |argumentsJS| be the result of [=converting a Web IDL arguments list to an ECMAScript arguments list|converting=] |arguments| to an ECMAScript arguments list. If this [=exception/throws=] an exception, return « "null", null, null, null ». @@ -5576,6 +5607,10 @@ Each {{InterestGroupScriptRunnerGlobalScope}} has a :: Null, or a [=PrivateAggregation=]. Initially null. : on event contribution map :: A [=map=] from [=string=] to a [=list=] of [=on event contribution entries=]. + : worklet function + :: A [=worklet function=]. Affects some + [Private Aggregation API](https://github.com/patcg-individual-drafts/private-aggregation-api) + functionality.
@@ -5589,16 +5624,20 @@ The privateAggregation The contributeToHistogramOnEvent(DOMString event, PAExtendedHistogramContribution contribution) method steps are: +1. Let |global| be [=this=]'s [=relevant global object=]. +1. Let |function| be |global|'s [=InterestGroupScriptRunnerGlobalScope/worklet function=]. 1. If [=this=]'s allowed to use is false, [=exception/throw=] a {{TypeError}}. 1. Let |scopingDetails| be [=this=]'s scoping details 1. If |event| [=string/starts with=] "`reserved.`" and « "`reserved.always`", - "`reserved.loss`", "`reserved.win`" » does not [=list/contain=] |event|, + "`reserved.loss`", "`reserved.win`", "`reserved.once`" » does not [=list/contain=] |event|, return. Note: No error is thrown to allow forward compatibility if additional reserved event types are added later. +1. If |event| is "`reserved.once`" and |function| is [=worklet function/report-result=] or + [=worklet function/report-win=], [=exception/throw=] a {{TypeError}}. 1. Let |bucket| be |contribution|["{{PAExtendedHistogramContribution/bucket}}"]. 1. If |bucket| is a {{PASignalValue}}: 1. If |bucket|["{{PASignalValue/baseValue}}"] is not a valid [=signal base @@ -5644,8 +5683,9 @@ event, PAExtendedHistogramContribution contribution) method steps are: : [=on event contribution entry/debug scope=] :: The result of running |scopingDetails|' get debug scope steps. + : [=on event contribution entry/worklet function=] + :: |function| -1. Let |global| be [=this=]'s [=relevant global object=]. 1. Let |onEventContributionMap| be |global|'s [=InterestGroupScriptRunnerGlobalScope/on event contribution map=]. 1. If |onEventContributionMap|[|event|] does not [=map/exist=], set From 633def453c2e06d03c5016a40ef281f5a8736de8 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 30 Oct 2024 13:27:13 -0400 Subject: [PATCH 02/19] Some metrics stuff, but it's a bit off for re-run, so need to think some more. Actually implement the get. --- spec.bs | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 126 insertions(+), 10 deletions(-) diff --git a/spec.bs b/spec.bs index 3e2ba7b0d..081eef514 100644 --- a/spec.bs +++ b/spec.bs @@ -1779,14 +1779,20 @@ following steps. They return a failure if failing to fetch the script or wasm, o 1. Let |prevWinElement| be the [=sequence=]<{{PreviousWinElement}}> «|timeDelta|, |prevWinAdIDL|». 1. [=list/Append=] |prevWinElement| to |prevWins|. 1. [=map/Set=] |browserSignals|["{{BiddingBrowserSignals/prevWinsMs}}"] to |prevWins|. + 1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, + |ig|'s [=interest group/owner=], [=worklet function/generate-bid=]. 1. Let |biddingScriptFetcher| be the result of [=creating a new script fetcher=] with |ig|'s [=interest group/bidding url=], and |settings|. 1. Let |biddingScript| be the result of [=waiting for script body from a fetcher=] given |biddingScriptFetcher|. + 1. [=Add a sample to an averager=] |metrics|'s [=per participant metrics/average code fetch time=] + saying how long this took, in milliseconds (TODO: how?). 1. If |biddingScript| is failure, return failure. 1. If |ig|'s [=interest group/bidding wasm helper url=] is not null: 1. Let |wasmModuleObject| be the result of [=fetching WebAssembly=] with |ig|'s [=interest group/bidding wasm helper url=] and |settings|. + 1. [=Add a sample to an averager=] |metrics|'s [=per participant metrics/average code fetch + time=] saying how long this took, in milliseconds (TODO: how?). 1. If |wasmModuleObject| is not failure, then [=map/set=] |browserSignals|["{{BiddingBrowserSignals/wasmHelper}}"] to |wasmModuleObject|. 1. Otherwise, return failure. @@ -1981,6 +1987,10 @@ and a [=real time reporting contributions map=] |realTimeContributionsMap|: 1. [=map/For each=] slotSizeQueryParam → |perSignalsUrlGenerator| of |perSlotSizeQueryParam|: 1. [=map/For each=] joiningOrigin → |groups| of |perSignalsUrlGenerator|: 1. [=list/Remove=] from |groups| any [=interest group=] [=list/contained=] in |igs|. + 1. Let |metrics| be the result of [=accessing per-participant metrics] for |reportingContext|, + |buyer|, [=worket function/generated-bid]. + 1. Set |metrics|'s [=per participant metrics/participating interest group count=] to the + [=list/size=] of |groups|. 1. Let |perBuyerSignals| be null. 1. If |auctionConfig|'s [=auction config/per buyer signals=] is not null and [=auction config/per buyer signals=][|buyer|] [=map/exists=], then set |perBuyerSignals| to @@ -2309,6 +2319,8 @@ a {{DirectFromSellerSignalsForSeller}} |directFromSellerSignalsForSeller|, an {{ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, an [=origin=] |topLevelOrigin|, and a [=real time reporting contributions map=] |realTimeContributionsMap|: +1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, + |auctionConfig|'s [=auction config/seller=], [=worklet function/score-ad=]. 1. Let «|trustedScoringSignalsAreCrossOrigin|, |sameOriginTrustedScoringSignals|, |crossOriginTrustedScoringSignals|, |scoringDataVersion|» be the result of [=fetch and decode trusted scoring signals=] given |trustedScoringSignalsBatcher|, |auctionConfig|, @@ -2349,6 +2361,8 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a 1. Let |decisionLogicScript| be the result of [=wait for script body from a fetcher=] given |decisionLogicFetcher|. +1. [=Add a sample to an averager=] |metrics|'s [=per participant metrics/average code fetch time=] + saying how long the fetch |decisionLogicFetcher| performed took, in milliseconds. 1. If |decisionLogicScript| is failure, then: 1. If |auctionConfig|'s [=auction config/seller real time reporting config=] is "`default-local-reporting`", then [=add a platform contribution=] with @@ -2893,10 +2907,14 @@ and a [=global object=] |global|: [=generated bid/interest group=], |igAd|, and null is true: 1. If |igAd|'s [=interest group ad/buyer and seller reporting ID=] is not null, [=map/set=] |browserSignals|["{{ReportingBrowserSignals/buyerAndSellerReportingId}}"] to it. + 1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, + |config|'s [=auction config/seller=], [=worklet function/report-result=]. 1. Let |sellerReportingScriptFetcher| be the result of [=creating a new script fetcher=] with |config|'s [=auction config/decision logic url=] and |global|'s [=relevant settings object=]. 1. Let |sellerReportingScript| be the result of [=waiting for script body from a fetcher=] given |sellerReportingScriptFetcher|. + 1. [=Add a sample to an averager=] |metrics|'s [=per participant metrics/average code fetch time=] + saying how long the fetch |sellerReportingScriptFetcher| performed took, in milliseconds. 1. Let « |sellerSignals|, |reportUrl|, |reportingBeaconMap|, ignored, |paContributions| » be the result of [=evaluating a reporting script=] with |sellerReportingScript|, [=worklet function/ report-result=], |reportingContext|, |config|'s [=auction config/seller=], |config|'s @@ -2958,6 +2976,8 @@ a {{ReportingBrowserSignals}} |browserSignals|, a [=direct from seller signals=] (TODO: noise and bucket this signal) 1. Let |ig| be |winner|'s [=generated bid/interest group=]. + 1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, + |ig|'s [=interest group/owner=], [=worklet function/report-win=]. 1. Let |igAd| be the [=interest group ad=] from ig's [=interest group/ads=] whose [=interest group ad/render url=] is |winner|'s [=generated bid/ad descriptor=]'s [=ad descriptor/url=]. @@ -2993,6 +3013,8 @@ a {{ReportingBrowserSignals}} |browserSignals|, a [=direct from seller signals=] |winner|'s [=generated bid/interest group=]'s [=interest group/bidding url=] and |settings|. 1. Let |buyerReportingScript| be the result of [=waiting for script body from a fetcher=] given |buyerReportingScriptFetcher|. + 1. [=Add a sample to an averager=] |metrics|'s [=per participant metrics/average code fetch time=] + saying how long the fetch |buyerReportingScriptFetcher| performed took, in milliseconds. 1. Let |reportFunctionName| be "`reportWin`". 1. If |winner|'s [=generated bid/provided as additional bid=] is true: 1. Set |reportFunctionName| be "`reportAdditionalBidWin`". @@ -3638,8 +3660,21 @@ A reporting context is a [=struct=] with the following [=struct/items some of these may be based on bids that started as additional bids or from component auctions run by Bidding and Auction services, and not interest groups, so this list may be quite different from [=reporting context/bidder participants=]. + : participant metrics + :: A [=map=] from a pair ([=origin=], [=worklet function=]) to [=per participant metrics=]. +
+To access per-participant metrics given a [=reporting context=] |reportingContext|, +an [=origin=] |origin| and [=worklet function=] |workletFunction|: +1. Let |key| be (|origin|, |workletFunction|). +1. If |reportingContext|'s [=reporting context/participant metrics=][|key|] does not [=map/exist=], + set |reportingContext|'s [=reporting context/participant metrics=][|key|] to a new [=per participant + metrics=]. +1. Return |reportingContext|'s [=reporting context/participant metrics=][|key|]. + +
+ A reporting context map is a [=map=] from [=auction config=] to [=reporting context=]. Here the keys are configurations for auctions that actually produce bids (e.g. not the top-level auction in a multi-party auction). @@ -4074,6 +4109,13 @@ A signal base value is one of the following: Note: this mapping to an integer is defined in [=determine a signal's numeric value=]. +: "average-code-fetch-time" +:: The numeric value is the average time it took to fetch code resources (JavaScript or WebAssembly) + for this particular worklet function, for this participant. +: "participating-ig-count" +:: The numeric value is the number of interest groups for the buyer actually participating in the + auction, after considering prioritization and capabilities. +

On event contribution entry

@@ -4089,6 +4131,8 @@ An on event contribution entry is a [=struct=] with the following items: :: A [=debug details=] or null (default null) : worklet function :: A [=worklet function=]. +: origin +:: The [=origin=] of the script that contributed the entry. @@ -4106,6 +4150,55 @@ A worklet function is one of the following: +
+To find corresponding bid and score phase function given a [=worklet function=] |fn|: + + 1.Switch on on |fn|: +
+ : [=worklet function/generate-bid=] + :: Return [=worklet function/generate-bid=]. + : [=worklet function/score-ad=] + :: Return [=worklet function/score-ad=]. + : [=worklet function/report-result=] + :: Return [=worklet function/score-ad=]. + : [=worklet function/report-win=] + :: Return [=worklet function/generate-bid=]. + +
+
+ +### Averager ### {#private-aggregation-averager} +An averager is a a [=struct=] with the following [=struct/items=]: +
+ : count + :: A {{long}}, initially 0. + : sum + :: A {{double}}, initially 0. +
+ +
+To add a sample to an averager given an [=averager=] |averager|, a {{double}} |sample|: +1. Set |averager|'s [=averager/count=] to |averager|'s [=averager/count=] + 1. +1. Set |averager|'s [=averager/sum=] to |averager|'s [=averager/sum=] + |sample|. + +
+ +
+To get the value to report from an averager given an [=averager=] |averager|: +1. If |averager|'s [=averager/count=] = 0, return 0. +1. Return |averager|'s [=averager/sum=] / [=averager/count=]. + +
+ +### Per-participant metrics ### {#private-aggregation-per-participant-metrics} +A per participant metrics is a [=struct=] with the following [=struct/items=]: +
+ : participating interest group count + :: A {{long}}, initially 0. + : average code fetch time + :: An [=averager=]. +
+

Private Aggregation contributions

Private Aggregation contributions is a [=map=] from [=string=] to a [=list=] of [=on event contribution entries=]. @@ -4118,6 +4211,7 @@ To prepare for private aggregation given a a [=reporting context=] |reportingContext|, and [=origins=] |origin| and |aggregationCoordinator|: 1. Let |debugScope| be a new [=debug scope=]. 1. Set |global|'s [=InterestGroupScriptRunnerGlobalScope/worklet function=] to |workletFunction|. +1. Set |global|'s [=InterestGroupScriptRunnerGlobalScope/origin=] to |origin|. 1. Set |global|'s [=InterestGroupScriptRunnerGlobalScope/private aggregation=] to a new [=PrivateAggregation=] with the following [=struct/items=]: : allowed to use @@ -4226,7 +4320,7 @@ an [=auction config=] |auctionConfig| and a [=reporting context=] |reportingCont 1. Otherwise: 1. If |bidId| ≠ |sellerOnceRep|, [=iteration/continue=]. 1. Let |filledInContribution| be the result of [=filling in the contribution=] given - |onEventEntry|'s [=on event contribution entry/contribution=] and |leadingBidInfo|. + |reportingContext|, |onEventEntry| and |leadingBidInfo|. Issue: Once WICG/turtledove#627 is resolved, align 'filling in' logic with `forDebuggingOnly`. @@ -4338,15 +4432,18 @@ an [=auction config=] |auctionConfig| and a [=reporting context=] |reportingCont
-To fill in the contribution given a {{PAExtendedHistogramContribution}} |contribution| -and a [=leading bid info=] |leadingBidInfo|, perform the following steps. They return a -{{PAHistogramContribution}}: +To fill in the contribution given a [=reporting context=] |reportingContext|, +an [=on event contribution entry=] |onEventEntry| and a [=leading bid info=] |leadingBidInfo|, +perform the following steps. They return a {{PAHistogramContribution}}: +1. Let |contribution| be |onEventEntry|'s [=on event contribution entry/contribution=]. 1. Let |bucket| be |contribution|["{{PAExtendedHistogramContribution/bucket}}"]. 1. If |bucket| is a {{PASignalValue}}, set |bucket| to the result of [=filling - in the signal value=] given |bucket|, 2128−1 and |leadingBidInfo|. + in the signal value=] given |reportingContext|, |onEventEntry|, |bucket|, 2128−1 + and |leadingBidInfo|. 1. Let |value| be |contribution|["{{PAExtendedHistogramContribution/value}}"]. 1. If |value| is a {{PASignalValue}}, set |value| to the result of [=filling in - the signal value=] given |value|, 231−1 and |leadingBidInfo|. + the signal value=] given |reportingContext|, |onEventEntry|, |value|, 231−1 and + |leadingBidInfo|. 1. Let |filledInContribution| be a new {{PAHistogramContribution}} with the items: : {{PAHistogramContribution/bucket}} @@ -4360,13 +4457,15 @@ and a [=leading bid info=] |leadingBidInfo|, perform the following steps. They r
-To fill in the signal value given a {{PASignalValue}} |value|, an +To fill in the signal value given a [=reporting context=] |reportingContext|, +an [=on event contribution entry=] |onEventEntry|, a {{PASignalValue}} |value|, an integer |maxAllowed| and a [=leading bid info=] |leadingBidInfo|, perform the following steps. They return an integer. 1. [=Assert=]: |value|["{{PASignalValue/baseValue}}"] is a valid [=signal base value=]. 1. Let |returnValue| be the result of [=determining a signal's numeric value=] - given |value|["{{PASignalValue/baseValue}}"] and |leadingBidInfo|. + given |reportingContext|, |onEventEntry|, |value|["{{PASignalValue/baseValue}}"] and + |leadingBidInfo|. 1. If |value|["{{PASignalValue/scale}}"] [=map/exists=], set |returnValue| to the result of multiplying |value|["{{PASignalValue/scale}}"] with |returnValue|. @@ -4381,9 +4480,17 @@ They return an integer.
-To determine a signal's numeric value given a [=signal base value=] +To determine a signal's numeric value given a [=reporting context=] |reportingContext|, +an [=on event contribution entry=] |onEventEntry|, a [=signal base value=] |signalBaseValue| and a [=leading bid info=] |leadingBidInfo|, perform the following steps. They return a {{double}}. +1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, + |onEventEntry|'s [=on event contribution entry/origin=], [=on event contribution entry/ + worklet function=]. +1. Let |bidAndScoreMetrics| be the result of [=access per-participant metrics=] given + |reportingContext|, |onEventEntry|'s [=on event contribution entry/origin=], and the result of + [=find corresponding bid and score phase function=] given [=on event contribution entry/worklet + function=]. 1. If |signalBaseValue| is "[=signal base value/winning-bid=]": 1. If |leadingBidInfo|'s [=leading bid info/leading bid=] is null, return 0. 1. Otherwise, return |leadingBidInfo|'s [=leading bid info/leading bid=]'s [=generated bid/bid=]. @@ -4446,6 +4553,11 @@ They return a {{double}}. Issue: Verify handling when the bid was not rejected. +1. If |signalBaseValue| is "[=signal base value/average-code-fetch-time=]": + 1. Return the result of [=getting the value to report from an averager=] given |metrics|'s [=per + participant metrics/average code fetch time=]. +1. If |signalBaseValue| is "[=signal base value/participating-ig-count=]": + 1. Return |bidAndScoreMetrics|'s [=per participant metrics/participating interest group count=].
@@ -5611,6 +5723,8 @@ Each {{InterestGroupScriptRunnerGlobalScope}} has a :: A [=worklet function=]. Affects some [Private Aggregation API](https://github.com/patcg-individual-drafts/private-aggregation-api) functionality. + : origin + :: The [=origin=] of the script being executed.
@@ -5626,6 +5740,7 @@ The contributeToHistogramOnEvent(DOMString event, PAExtendedHistogramContribution contribution) method steps are: 1. Let |global| be [=this=]'s [=relevant global object=]. 1. Let |function| be |global|'s [=InterestGroupScriptRunnerGlobalScope/worklet function=]. +1. Let |origin| be |global|'s [=InterestGroupScriptRunnerGlobalScope/origin=]. 1. If [=this=]'s allowed to use is false, [=exception/throw=] a {{TypeError}}. 1. Let |scopingDetails| be [=this=]'s @@ -5685,7 +5800,8 @@ event, PAExtendedHistogramContribution contribution) method steps are: for="scoping details">get debug scope steps. : [=on event contribution entry/worklet function=] :: |function| - + : [=on event contribution entry/origin=] + :: |origin| 1. Let |onEventContributionMap| be |global|'s [=InterestGroupScriptRunnerGlobalScope/on event contribution map=]. 1. If |onEventContributionMap|[|event|] does not [=map/exist=], set From 055b0f5765161cd4ca21aa4520a037f8cf12d96c Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Tue, 5 Nov 2024 10:29:37 -0500 Subject: [PATCH 03/19] Fix handwaveyness of fetch metrics. --- spec.bs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/spec.bs b/spec.bs index 081eef514..9162381d0 100644 --- a/spec.bs +++ b/spec.bs @@ -1785,14 +1785,17 @@ following steps. They return a failure if failing to fetch the script or wasm, o |ig|'s [=interest group/bidding url=], and |settings|. 1. Let |biddingScript| be the result of [=waiting for script body from a fetcher=] given |biddingScriptFetcher|. - 1. [=Add a sample to an averager=] |metrics|'s [=per participant metrics/average code fetch time=] - saying how long this took, in milliseconds (TODO: how?). + 1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code + fetch time=] and |biddingScriptFetcher|'s [=script fetcher/fetch duration=]. 1. If |biddingScript| is failure, return failure. 1. If |ig|'s [=interest group/bidding wasm helper url=] is not null: + 1. Let |wasmFetchStart| be |settings|'s [=environment settings object/current monotonic time=]. 1. Let |wasmModuleObject| be the result of [=fetching WebAssembly=] with |ig|'s [=interest group/bidding wasm helper url=] and |settings|. - 1. [=Add a sample to an averager=] |metrics|'s [=per participant metrics/average code fetch - time=] saying how long this took, in milliseconds (TODO: how?). + 1. Let |wasmFetchDuration| be the [=duration from=] |wasmFetchStart| to + |settings|'s [=environment settings object/current monotonic time=], in milliseconds. + 1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code + fetch time=] and |wasmFetchDuration|. 1. If |wasmModuleObject| is not failure, then [=map/set=] |browserSignals|["{{BiddingBrowserSignals/wasmHelper}}"] to |wasmModuleObject|. 1. Otherwise, return failure. @@ -2361,8 +2364,8 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a 1. Let |decisionLogicScript| be the result of [=wait for script body from a fetcher=] given |decisionLogicFetcher|. -1. [=Add a sample to an averager=] |metrics|'s [=per participant metrics/average code fetch time=] - saying how long the fetch |decisionLogicFetcher| performed took, in milliseconds. +1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code fetch time=] + and |decisionLogicFetcher|'s [=script fetcher/fetch duration=]. 1. If |decisionLogicScript| is failure, then: 1. If |auctionConfig|'s [=auction config/seller real time reporting config=] is "`default-local-reporting`", then [=add a platform contribution=] with @@ -2913,8 +2916,8 @@ and a [=global object=] |global|: |config|'s [=auction config/decision logic url=] and |global|'s [=relevant settings object=]. 1. Let |sellerReportingScript| be the result of [=waiting for script body from a fetcher=] given |sellerReportingScriptFetcher|. - 1. [=Add a sample to an averager=] |metrics|'s [=per participant metrics/average code fetch time=] - saying how long the fetch |sellerReportingScriptFetcher| performed took, in milliseconds. + 1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code fetch + time=] and |sellerReportingScriptFetcher|'s [=script fetcher/fetch duration=]. 1. Let « |sellerSignals|, |reportUrl|, |reportingBeaconMap|, ignored, |paContributions| » be the result of [=evaluating a reporting script=] with |sellerReportingScript|, [=worklet function/ report-result=], |reportingContext|, |config|'s [=auction config/seller=], |config|'s @@ -3013,8 +3016,8 @@ a {{ReportingBrowserSignals}} |browserSignals|, a [=direct from seller signals=] |winner|'s [=generated bid/interest group=]'s [=interest group/bidding url=] and |settings|. 1. Let |buyerReportingScript| be the result of [=waiting for script body from a fetcher=] given |buyerReportingScriptFetcher|. - 1. [=Add a sample to an averager=] |metrics|'s [=per participant metrics/average code fetch time=] - saying how long the fetch |buyerReportingScriptFetcher| performed took, in milliseconds. + 1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code fetch + time=] and |buyerReportingScriptFetcher|'s [=script fetcher/fetch duration=]. 1. Let |reportFunctionName| be "`reportWin`". 1. If |winner|'s [=generated bid/provided as additional bid=] is true: 1. Set |reportFunctionName| be "`reportAdditionalBidWin`". @@ -7975,6 +7978,8 @@ headers. It's a [=struct=] with the following [=struct/items=]: : origins authorized for cross origin trusted signals :: A [=list=] of [=origins=] or null. Initially null. Parsed value of [:Ad-Auction-Allow-Trusted-Scoring-Signals-From:]. + : fetch duration + :: A [=duration=] in milliseconds, denoting how long it took the fetch to complete.
@@ -8052,6 +8057,8 @@ a [=script fetcher=] |fetcher|: Issue: Stop using "`no-cors`" mode where possible (WICG/turtledove#667). + + 1. Let |fetchStart| be |settings|'s [=environment settings object/current monotonic time=]. 1. Let |fetchController| be the result of [=fetching=] |request| with [=fetch/useParallelQueue=] set to true, and [=fetch/processResponse=] set to the following steps given a [=response=] |response|: @@ -8059,6 +8066,8 @@ a [=script fetcher=] |fetcher|: 1. [=fetch controller/Abort=] |fetchController|. 1. Set |fetcher|'s [=script fetcher/origins authorized for cross origin trusted signals=] to an empty [=list=] of [=origins=]. + 1. Set |fetcher|'s [=script fetcher/fetch duration=] to the [=duration from=] |fetchStart| to + |settings|'s [=environment settings object/current monotonic time=], in milliseconds. 1. Set |fetcher|'s [=script fetcher/script body=] to failure. 1. Set |fetcher|'s [=script fetcher/origins authorized for cross origin trusted signals=] to the result of [=parsing allowed trusted scoring signals origins=] given |response|'s [=response/ @@ -8067,6 +8076,8 @@ a [=script fetcher=] |fetcher|: 1. Let |bodyReader| be result of [=ReadableStream/getting a reader=] from |bodyStream|. 1. Let |successSteps| be a set of steps that take a [=byte sequence=] |responseBody|, and perform the following: + 1. Set |fetcher|'s [=script fetcher/fetch duration=] to the [=duration from=] |fetchStart| to + |settings|'s [=environment settings object/current monotonic time=], in milliseconds. 1. If [=validate fetching response mime and body=] with |response|, |responseBody| and "`text/javascript`" returns false, set |fetcher|'s [=script fetcher/script body=] to failure. From 0ed6ce30dc6fccbd0c2c209d62ce65d0ee069afe Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Tue, 5 Nov 2024 12:44:27 -0500 Subject: [PATCH 04/19] Fix the re-run thing, and a bit of prep for later. --- spec.bs | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/spec.bs b/spec.bs index 9162381d0..94df9281d 100644 --- a/spec.bs +++ b/spec.bs @@ -1779,14 +1779,13 @@ following steps. They return a failure if failing to fetch the script or wasm, o 1. Let |prevWinElement| be the [=sequence=]<{{PreviousWinElement}}> «|timeDelta|, |prevWinAdIDL|». 1. [=list/Append=] |prevWinElement| to |prevWins|. 1. [=map/Set=] |browserSignals|["{{BiddingBrowserSignals/prevWinsMs}}"] to |prevWins|. - 1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, - |ig|'s [=interest group/owner=], [=worklet function/generate-bid=]. + 1. Let |metrics| be a new [=execution metrics=]. 1. Let |biddingScriptFetcher| be the result of [=creating a new script fetcher=] with |ig|'s [=interest group/bidding url=], and |settings|. 1. Let |biddingScript| be the result of [=waiting for script body from a fetcher=] given |biddingScriptFetcher|. - 1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code - fetch time=] and |biddingScriptFetcher|'s [=script fetcher/fetch duration=]. + 1. [=Add a sample to an averager=] given |metrics|'s [=execution metrics/average code fetch + time=] and |biddingScriptFetcher|'s [=script fetcher/fetch duration=]. 1. If |biddingScript| is failure, return failure. 1. If |ig|'s [=interest group/bidding wasm helper url=] is not null: 1. Let |wasmFetchStart| be |settings|'s [=environment settings object/current monotonic time=]. @@ -1794,8 +1793,8 @@ following steps. They return a failure if failing to fetch the script or wasm, o [=interest group/bidding wasm helper url=] and |settings|. 1. Let |wasmFetchDuration| be the [=duration from=] |wasmFetchStart| to |settings|'s [=environment settings object/current monotonic time=], in milliseconds. - 1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code - fetch time=] and |wasmFetchDuration|. + 1. [=Add a sample to an averager=] given |metrics|'s [=execution metrics/average code fetch + time=] and |wasmFetchDuration|. 1. If |wasmModuleObject| is not failure, then [=map/set=] |browserSignals|["{{BiddingBrowserSignals/wasmHelper}}"] to |wasmModuleObject|. 1. Otherwise, return failure. @@ -1819,7 +1818,7 @@ following steps. They return a failure if failing to fetch the script or wasm, o |crossOriginTrustedBiddingSignalsOrigin|. 1. [=map/Set=] |crossOriginTrustedBiddingSignalsOrigin|[|originKey|] to |trustedBiddingSignals|. 1. Return the result of [=evaluating a bidding script=] with |biddingScript|, |multiBidLimit|, - |ig|, |reportingContext|, |expectedCurrency|, |igGenerateBid|, |auctionSignals|, + |ig|, |reportingContext|, |metrics|, |expectedCurrency|, |igGenerateBid|, |auctionSignals|, |perBuyerSignals|, |sameOriginTrustedBiddingSignals|, |crossOriginTrustedBiddingSignals|, |browserSignals|, |directFromSellerSignalsForBuyer| and |perBuyerTimeout|.
@@ -2070,8 +2069,8 @@ and a [=real time reporting contributions map=] |realTimeContributionsMap|: 1. If |optedInForRealTimeReporting| is true, then [=add a platform contribution=] with [=bidding script failure bucket=], |realTimeContributionsMap| and |buyer|. 1. [=iteration/Continue=]. - 1. Let (|bidsBatch|, |bidDebugReportInfo|, |realTimeContributions|, |paContributions|) be - |generateBidResult|. + 1. Let (|bidsBatch|, |bidDebugReportInfo|, |realTimeContributions|, |paContributions|, + |executionMetrics|) be |generateBidResult|. 1. Let |generateBidDuration| be the [=duration from=] |generateBidStartTime| to |settings|'s [=environment settings object/current monotonic time=], in milliseconds. 1. If |perBuyerCumulativeTimeout| is not null, decrement |perBuyerCumulativeTimeout| by @@ -2096,8 +2095,8 @@ and a [=real time reporting contributions map=] |realTimeContributionsMap|: 1. Let |generateBidStartTime| be |settings|'s [=environment settings object/current monotonic time=]. 1. Set (|generatedBids|, |bidDebugReportInfo|, |realTimeContributions|, - |paContributions|) to the result of running [=generate potentially multiple bids=] - with |allTrustedBiddingSignals|, + |paContributions|, |executionMetrics|) to the result of running [=generate potentially + multiple bids=] with |allTrustedBiddingSignals|, |crossOriginTrustedBiddingSignalsOrigin|, |auctionSignals|, a [=map/clone=] of |browserSignals|, |perBuyerSignals|, |directFromSellerSignalsForBuyer|, |perBuyerTimeout|, |expectedCurrency|, 1 (for multiBidLimit), |kAnonRestrictedIG|, |reportingContext|, |auctionStartTime|, @@ -2115,7 +2114,7 @@ and a [=real time reporting contributions map=] |realTimeContributionsMap|: 1. [=Apply any component ads target to a bid=] given |generatedBid|. 1. [=list/Append=] |generatedBid| to |bidsToScore|. 1. [=Register bids for reporting=] given |bidsToScore|, |ig|, |bidDebugReportInfo|, - |paContributions|, and |reportingContext|. + |paContributions|, |executionMetrics|, and |reportingContext|. 1. If |auctionConfig|'s [=auction config/per buyer real time reporting config=][|buyer|] is "`default-local-reporting`", then [=insert entries to map=] given |realTimeContributionsMap|, |buyer|, and |realTimeContributions|. @@ -3699,8 +3698,8 @@ auction in a multi-party auction).
To register bids for reporting given a [=list=] of [=generated bids=] |generatedBids|, [=interest group=] |ig|, [=bid debug reporting info=] - |bidDebugReportInfo|, a [=Private Aggregation contributions=] |paContributions| and a [=reporting - context=] |reportingContext|: + |bidDebugReportInfo|, a [=Private Aggregation contributions=] |paContributions|, + [=execution metrics=] |executionMetrics| and a [=reporting context=] |reportingContext|: 1. Let |id| be a new [=reporting bid key=] with the following [=struct/items=]: : [=reporting bid key/context=] :: |reportingContext| @@ -3715,6 +3714,10 @@ auction in a multi-party auction). :: |ig|'s [=interest group/name=] 1. [=map/Set=] |reportingContext|'s [=reporting context/debug reporting info=][|id|] to |bidDebugReportInfo|. + 1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, + |ig|'s [=interest group/owner=], [=worklet function/generate-bid=]. + 1. [=Merge samples to an averager=] given |metrics|'s [=per participant metrics/average code fetch + time=] and |executionMetrics|'s [=execution metrics/average code fetch time=]. 1. [=set/Insert=] |id| into |reportingContext|'s [=reporting context/bidder participants=]. 1. [=Commit private aggregation contributions=] given |paContributions|, |id| and |reportingContext|. @@ -4186,6 +4189,13 @@ To add a sample to an averager given an [=averager=] |averager|, a {{
+
+To merge samples to an averager given [=averagers=] |dest| and |source|: +1. Set |dest|'s [=averager/count=] to |dest|'s [=averager/count=] + |source|'s [averager/count=]. +1. Set |dest|'s [=averager/sum=] to |dest|'s [=averager/sum=] + |source|'s [averager/sum=]. + +
+
To get the value to report from an averager given an [=averager=] |averager|: 1. If |averager|'s [=averager/count=] = 0, return 0. @@ -4193,7 +4203,13 @@ To get the value to report from an averager given an [=averager=] |av
-### Per-participant metrics ### {#private-aggregation-per-participant-metrics} +### Metrics structures ### {#private-aggregation-metrics-structures} +An execution metrics is a [=struct=] with the following [=struct/items=]: +
+ : average code fetch time + :: An [=averager=]. +
+ A per participant metrics is a [=struct=] with the following [=struct/items=]:
: participating interest group count @@ -5441,6 +5457,7 @@ of the following global objects:
To evaluate a bidding script given a [=string=] |script|, an {{unsigned short}} |multiBidLimit|, an [=interest group=] |ig|, a [=reporting context=] |reportingContext|, + an [=execution metrics=] |executionMetrics|, a [=currency tag=] |expectedCurrency|, a {{GenerateBidInterestGroup}} |igGenerateBid|, a [=string=]-or-null |auctionSignals|, a [=string=]-or-null |perBuyerSignals|, an [=ordered map=]-or-null |sameOriginTrustedBiddingSignals|, an [=ordered map=]-or-null @@ -5539,7 +5556,7 @@ of the following global objects: 1. Let |paContributions| be the result of [=extracting private aggregation contributions=] given |global|. 1. Return a [=tuple=] (|generatedBids|, |bidDebugReportInfo|, |realTimeContributions|, - |paContributions|). + |paContributions|, |executionMetrics|).
From 0a71b5b1bdc853138f55bbcd29ac5a9e9ada85fb Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Tue, 5 Nov 2024 14:30:41 -0500 Subject: [PATCH 05/19] Fix formatting. --- spec.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.bs b/spec.bs index 94df9281d..4b74b1a62 100644 --- a/spec.bs +++ b/spec.bs @@ -1989,8 +1989,8 @@ and a [=real time reporting contributions map=] |realTimeContributionsMap|: 1. [=map/For each=] slotSizeQueryParam → |perSignalsUrlGenerator| of |perSlotSizeQueryParam|: 1. [=map/For each=] joiningOrigin → |groups| of |perSignalsUrlGenerator|: 1. [=list/Remove=] from |groups| any [=interest group=] [=list/contained=] in |igs|. - 1. Let |metrics| be the result of [=accessing per-participant metrics] for |reportingContext|, - |buyer|, [=worket function/generated-bid]. + 1. Let |metrics| be the result of [=accessing per-participant metrics=] for |reportingContext|, + |buyer|, [=worket function/generate-bid=]. 1. Set |metrics|'s [=per participant metrics/participating interest group count=] to the [=list/size=] of |groups|. 1. Let |perBuyerSignals| be null. From 5167149fb11c9c1ffcc326ffae66634a26132d31 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 09:41:23 -0500 Subject: [PATCH 06/19] Fix bug + misc found in feedback. --- spec.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.bs b/spec.bs index 3e2ba7b0d..c9ba5a600 100644 --- a/spec.bs +++ b/spec.bs @@ -2385,7 +2385,7 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a 1. If |auctionConfig|'s [=auction config/seller real time reporting config=] is "`default-local-reporting`", then [=insert entries to map=] given |realTimeContributionsMap|, |seller|, and |realTimeContributions|. - 1. [=set/Insert=] |reportingId| into |reportingContext|'s [=reporting context/bidder + 1. [=set/Insert=] |reportingId| into |reportingContext|'s [=reporting context/seller participants=]. 1. [=Commit private aggregation contributions=] given |paContributions|, |reportingId|, and |reportingContext|. @@ -4209,10 +4209,10 @@ an [=auction config=] |auctionConfig| and a [=reporting context=] |reportingCont 1. Let |leadingBidInfo| be |reportingContext|'s [=reporting context/local leader info=]. 1. Let |bidderOnceRep| be null. 1. If |reportingContext|'s [=reporting context/bidder participants=] [=set/is not empty=], - set |bidderOnceRep| to a random member of [=reporting context/bidder participants=]. + set |bidderOnceRep| to a random [=set/item=] of [=reporting context/bidder participants=]. 1. Let |sellerOnceRep| be null. 1. If |reportingContext|'s [=reporting context/seller participants=] [=set/is not empty=], - set |sellerOnceRep| to a random member of [=reporting context/seller participants=]. + set |sellerOnceRep| to a random [=set/item=] of [=reporting context/seller participants=]. 1. [=map/For each=] (|bidId|, |event|) → |contributions| of |reportingContext|'s [=reporting context/private aggregation on event contributions=]: 1. If |event| is "`reserved.win`" or does not [=string/start with=] "`reserved.`": From 3cbf3f99152374e830d82b4899bb2195b5d88e3d Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 09:51:16 -0500 Subject: [PATCH 07/19] Typo fix. --- spec.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.bs b/spec.bs index b8328558b..fc080e7bb 100644 --- a/spec.bs +++ b/spec.bs @@ -1990,7 +1990,7 @@ and a [=real time reporting contributions map=] |realTimeContributionsMap|: 1. [=map/For each=] joiningOrigin → |groups| of |perSignalsUrlGenerator|: 1. [=list/Remove=] from |groups| any [=interest group=] [=list/contained=] in |igs|. 1. Let |metrics| be the result of [=accessing per-participant metrics=] for |reportingContext|, - |buyer|, [=worket function/generate-bid=]. + |buyer|, [=worklet function/generate-bid=]. 1. Set |metrics|'s [=per participant metrics/participating interest group count=] to the [=list/size=] of |groups|. 1. Let |perBuyerSignals| be null. From 22426a147f0dbf2131c636671d3980c500eb8184 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 11:10:23 -0500 Subject: [PATCH 08/19] Wire timeout from most script helpers. --- spec.bs | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/spec.bs b/spec.bs index fc080e7bb..49d7c3c0e 100644 --- a/spec.bs +++ b/spec.bs @@ -4208,6 +4208,8 @@ An execution metrics is a [=struct=] with the following [=struct/item
: average code fetch time :: An [=averager=]. + : script timeout occurred + :: A [=boolean=], initially false.
A per participant metrics is a [=struct=] with the following [=struct/items=]: @@ -5501,7 +5503,8 @@ of the following global objects: 1. Let |crossOriginTrustedBiddingSignalsJS| be |crossOriginTrustedBiddingSignals| [=converted to ECMAScript values=]. 1. Let |startTime| be |settings|'s [=environment settings object/current monotonic time=]. - 1. Let |result| be the result of [=evaluating a script=] with |realm|, |script|, "`generateBid`", + 1. Let (|result|, |executionMetrics|'s [=execution metrics/script timeout occurred=]) be the + result of [=evaluating a script=] with |realm|, |script|, "`generateBid`", « |igJS|, |auctionSignalsJS|, |perBuyerSignalsJS|, |sameOriginTrustedBiddingSignalsJS|, |browserSignalsJS|, |directFromSellerSignalsJS|, |crossOriginTrustedBiddingSignalsJS| », and |timeout|. @@ -5584,7 +5587,9 @@ of the following global objects: 1. Let |directFromSellerSignalsJs| be |directFromSellerSignalsForSeller| [=converted to ECMAScript values=]. 1. Let |startTime| be |settings|'s [=environment settings object/current monotonic time=]. - 1. Let |scoreAdResult| be the result of [=evaluating a script=] with |realm|, |script|, "`scoreAd`", + 1. Let |executionMetrics| be a new [=execution metrics=]. + 1. Let (|scoreAdResult|, |executionMetrics|'s [=execution metrics/script timeout occurred=]) be + the result of [=evaluating a script=] with |realm|, |script|, "`scoreAd`", «|adMetadata|, |bidValue|, |auctionConfigJS|, |sameOriginTrustedScoringSignalsJS|, |browserSignalsJS|, |directFromSellerSignalsJs|, |crossOriginTrustedScoringSignalsJS|», and |timeout|. @@ -5606,7 +5611,7 @@ of the following global objects: 1. Let |paContributions| be the result of [=extracting private aggregation contributions=] given |global|. 1. Return « |scoreAdResult|, |debugWinReportUrl|, |debugLossReportUrl|, |realTimeContributions|, - |paContributions| ». + |paContributions|, |executionMetrics| ».
@@ -5625,8 +5630,10 @@ of the following global objects: 1. Let |argumentsJS| be the result of [=converting a Web IDL arguments list to an ECMAScript arguments list|converting=] |arguments| to an ECMAScript arguments list. If this [=exception/throws=] an exception, return « "null", null, null, null ». - 1. Let |result| be the result of [=evaluating a script=] with |realm|, |script|, - |functionName|, |argumentsJS|, and |timeout|. + 1. Let |executionMetrics| be a new [=execution metrics=]. + 1. Let (|result|, |executionMetrics|'s [=execution metrics/script timeout occurred=]) be the + result of [=evaluating a script=] with |realm|, |script|, |functionName|, |argumentsJS|, + and |timeout|. 1. If |result| is an [=ECMAScript/abrupt completion=], return « "null", null, null, null ». 1. Let |resultJSON| be "null". 1. If |functionName| is "`reportResult`", then set |resultJSON| to the result of @@ -5643,20 +5650,23 @@ of the following global objects: |global|. 1. Return « |resultJSON|, |reportURL|, |global|'s [=InterestGroupReportingScriptRunnerGlobalScope/reporting beacon map=], |macroMap|, - |paContributions| ». + |paContributions|, |executionMetrics| ».
To evaluate a script with a [=ECMAScript/realm=] |realm|, [=string=] |script|, [=string=] |functionName|, a [=list=] |arguments|, and an integer millisecond [=duration=] |timeout|, run these steps. - They return a [=ECMAScript/Completion Record=], which is either an [=ECMAScript/abrupt completion=] (in - the case of a parse failure or execution error), or a [=ECMAScript/normal completion=] populated with the - [=ECMAScript/ECMAScript language value=] result of invoking |functionName|. + They return a tuple of a [=ECMAScript/Completion Record=], which is either an [=ECMAScript/abrupt + completion=] (in the case of a parse failure or execution error), or a [=ECMAScript/normal + completion=] populated with the [=ECMAScript/ECMAScript language value=] result of invoking + |functionName|, and a [=boolean=] stating whether the script was interrupted due to reaching + |timeout|. 1. [=Assert=] that these steps are running [=in parallel=]. - 1. If |timeout| ≤ 0, [=immediately=] interrupt the execution and set |finalCompletion| to a - new [=ECMAScript/throw completion=] given null. + 1. If |timeout| ≤ 0, return (new [=ECMAScript/throw completion=] given null, true). + + 1. Let |timeoutOccurred| be false. 1. Let |global| be |realm|'s [=realm/global object=], and run these steps in |realm|'s [=realm/agent=]: @@ -5687,8 +5697,8 @@ of the following global objects: |arguments|)). In |timeout| milliseconds, if the invocation of [$Call$] has not completed, - [=immediately=] interrupt the execution and set |finalCompletion| to a new - [=ECMAScript/throw completion=] given null. + [=immediately=] interrupt the execution, set |finalCompletion| to a new + [=ECMAScript/throw completion=] given null, and set |timeoutOccurred| to true. 1. Return: at this point |finalCompletion| will be set to a [=ECMAScript/Completion Record=]. @@ -5697,7 +5707,7 @@ of the following global objects: execution context|running JavaScript execution context=], and remove it from the [=ECMAScript/execution context stack|JavaScript execution context stack=]. - 1. Return |finalCompletion|. + 1. Return (|finalCompletion|, timeoutOccurred).
## Global scopes ## {#global-scopes} From 98197a90aee82817723bde8a8ce99f8b1aa59594 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 12:25:10 -0500 Subject: [PATCH 09/19] Start on actual computation. --- spec.bs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec.bs b/spec.bs index 49d7c3c0e..dce53d6a4 100644 --- a/spec.bs +++ b/spec.bs @@ -2371,10 +2371,11 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a [=scoring script failure bucket=], |realTimeContributionsMap| and |seller|. 1. Return. 1. Let « |scoreAdResult|, |debugWinReportUrl|, |debugLossReportUrl|, |realTimeContributions|, - |paContributions| » be the result of [=evaluating a scoring script=] with |decisionLogicScript|, - |adMetadata|, |bidValue|'s [=bid with currency/value=], |auctionConfig|, |reportingContext|, - |sameOriginTrustedScoringSignals|, |crossOriginTrustedScoringSignals|, |browserSignals|, - |directFromSellerSignalsForSeller|, and |auctionConfig|'s [=auction config/seller timeout=]. + |paContributions|, |executionMetrics| » be the result of [=evaluating a scoring script=] with + |decisionLogicScript|, |adMetadata|, |bidValue|'s [=bid with currency/value=], |auctionConfig|, + |reportingContext|, |sameOriginTrustedScoringSignals|, |crossOriginTrustedScoringSignals|, + |browserSignals|, |directFromSellerSignalsForSeller|, and |auctionConfig|'s [=auction config/ + seller timeout=]. 1. If |generatedBid|'s [=generated bid/for k-anon auction=] is true: Note: Non-k-anonymous bids do not participate in reporting (except for platform real-time @@ -2403,6 +2404,7 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a |seller|, and |realTimeContributions|. 1. [=set/Insert=] |reportingId| into |reportingContext|'s [=reporting context/seller participants=]. + 1. 1. [=Commit private aggregation contributions=] given |paContributions|, |reportingId|, and |reportingContext|. 1. Let |scoreAdOutput| be result of [=processing scoreAd output=] with |scoreAdResult|. @@ -4218,6 +4220,10 @@ A per participant metrics is a [=struct=] with the following [=struct :: A {{long}}, initially 0. : average code fetch time :: An [=averager=]. + : script timeouts occurred + :: A {{long}}, initially 0. + : script executions attempted + :: A {{long}}, initially 0.

Private Aggregation contributions

From 36c79a271f3c2fa87d9f549d7471d1ca166355a7 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 12:27:26 -0500 Subject: [PATCH 10/19] k-anon only. The impl gets it wrong. --- spec.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec.bs b/spec.bs index fc080e7bb..3d024e03e 100644 --- a/spec.bs +++ b/spec.bs @@ -2321,8 +2321,6 @@ a {{DirectFromSellerSignalsForSeller}} |directFromSellerSignalsForSeller|, an {{ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, an [=origin=] |topLevelOrigin|, and a [=real time reporting contributions map=] |realTimeContributionsMap|: -1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, - |auctionConfig|'s [=auction config/seller=], [=worklet function/score-ad=]. 1. Let «|trustedScoringSignalsAreCrossOrigin|, |sameOriginTrustedScoringSignals|, |crossOriginTrustedScoringSignals|, |scoringDataVersion|» be the result of [=fetch and decode trusted scoring signals=] given |trustedScoringSignalsBatcher|, |auctionConfig|, @@ -2363,8 +2361,6 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a 1. Let |decisionLogicScript| be the result of [=wait for script body from a fetcher=] given |decisionLogicFetcher|. -1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code fetch time=] - and |decisionLogicFetcher|'s [=script fetcher/fetch duration=]. 1. If |decisionLogicScript| is failure, then: 1. If |auctionConfig|'s [=auction config/seller real time reporting config=] is "`default-local-reporting`", then [=add a platform contribution=] with @@ -2382,6 +2378,10 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a as it would be problematic to report a winner that didn't actually win. 1. Let |reportingId| be |generatedBid|'s [=generated bid/reporting id=]. + 1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, + |auctionConfig|'s [=auction config/seller=], [=worklet function/score-ad=]. + 1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code fetch + time=] and |decisionLogicFetcher|'s [=script fetcher/fetch duration=]. 1. If |reportingContext|'s [=reporting context/debug reporting info=][|reportingId|] does not [=map/exist=], set it to a new [=bid debug reporting info=]. 1. Let |bidDebugReportInfo| be |reportingContext|'s [=reporting context/debug reporting info=] From 0e4697f99e4b009c7acfc35543d987f8ce50ecaf Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 12:34:46 -0500 Subject: [PATCH 11/19] generateBid computation. --- spec.bs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec.bs b/spec.bs index 92945c6f5..3685b58ea 100644 --- a/spec.bs +++ b/spec.bs @@ -2383,6 +2383,11 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a |auctionConfig|'s [=auction config/seller=], [=worklet function/score-ad=]. 1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code fetch time=] and |decisionLogicFetcher|'s [=script fetcher/fetch duration=]. + 1. Set |metrics|'s [=per participant metrics/script executions attempted=] to |metrics|'s [=per + participant metrics/script executions attempted=] + 1. + 1. If |executionMetrics|'s [=execution metrics/script timeout occurred=] is true, set |metrics|'s + [=per participant metrics/script timeouts occurred=] to |metrics|'s [=per participant metrics/ + script timeouts occurred=] + 1. 1. If |reportingContext|'s [=reporting context/debug reporting info=][|reportingId|] does not [=map/exist=], set it to a new [=bid debug reporting info=]. 1. Let |bidDebugReportInfo| be |reportingContext|'s [=reporting context/debug reporting info=] @@ -3720,6 +3725,11 @@ auction in a multi-party auction). |ig|'s [=interest group/owner=], [=worklet function/generate-bid=]. 1. [=Merge samples to an averager=] given |metrics|'s [=per participant metrics/average code fetch time=] and |executionMetrics|'s [=execution metrics/average code fetch time=]. + 1. Set |metrics|'s [=per participant metrics/script executions attempted=] to + |metrics|'s [=per participant metrics/participating interest group count=]. + 1. If |executionMetrics|'s [=execution metrics/script timeout occurred=] is true, set |metrics|'s + [=per participant metrics/script timeouts occurred=] to |metrics|'s [=per participant metrics/ + script timeouts occurred=] + 1. 1. [=set/Insert=] |id| into |reportingContext|'s [=reporting context/bidder participants=]. 1. [=Commit private aggregation contributions=] given |paContributions|, |id| and |reportingContext|. From 03fc7aba01a01004b89cb7bdbe900bc389e810ed Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 12:53:19 -0500 Subject: [PATCH 12/19] report* --- spec.bs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/spec.bs b/spec.bs index 3685b58ea..87345fdb4 100644 --- a/spec.bs +++ b/spec.bs @@ -2924,13 +2924,17 @@ and a [=global object=] |global|: |sellerReportingScriptFetcher|. 1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code fetch time=] and |sellerReportingScriptFetcher|'s [=script fetcher/fetch duration=]. - 1. Let « |sellerSignals|, |reportUrl|, |reportingBeaconMap|, ignored, |paContributions| » be the - result of [=evaluating a reporting script=] with |sellerReportingScript|, [=worklet function/ - report-result=], |reportingContext|, |config|'s [=auction config/seller=], |config|'s + 1. Let « |sellerSignals|, |reportUrl|, |reportingBeaconMap|, ignored, |paContributions|, + |executionMetrics| » be the result of [=evaluating a reporting script=] with + |sellerReportingScript|, [=worklet function/report-result=], |reportingContext|, + |config|'s [=auction config/seller=], |config|'s [=auction config/seller Private Aggregation coordinator=], |config|'s [=auction config/ config idl=]'s {{AuctionAdConfig/reportingTimeout}}, and « |config|'s [=auction config/config idl=], |browserSignals|, |directFromSellerSignals| ». - 1. Let |reportingResult| be a [=reporting result=] with the following [=struct/items=]: + 1. Set |metrics|'s [=per participant metrics/script executions attempted=] to 1. + 1. If |executionMetrics|'s [=execution metrics/script timeout occurred=] is true, set |metrics|'s + [=per participant metrics/script timeouts occurred=] to 1. + 1. Let |reportingResult| be a [=reporting result=] with the following [=struct/items=]: : [=reporting result/report url=] :: |reportUrl| : [=reporting result/reporting beacon map=] @@ -3027,14 +3031,18 @@ a {{ReportingBrowserSignals}} |browserSignals|, a [=direct from seller signals=] 1. Let |reportFunctionName| be "`reportWin`". 1. If |winner|'s [=generated bid/provided as additional bid=] is true: 1. Set |reportFunctionName| be "`reportAdditionalBidWin`". - 1. Let « ignored, |resultUrl|, |reportingBeaconMap|, |reportingMacroMap|, |paContributions| » be - the result of [=evaluating a reporting script=] with |buyerReportingScript|, [=worklet function/ - report-win=], |reportingContext|, |ig|'s [=interest group/owner=], |ig|'s [=interest group/ + 1. Let « ignored, |resultUrl|, |reportingBeaconMap|, |reportingMacroMap|, |paContributions|, + |executionMetrics| » be the result of [=evaluating a reporting script=] with + |buyerReportingScript|, [=worklet function/report-win=], |reportingContext|, |ig|'s + [=interest group/owner=], |ig|'s [=interest group/ Private Aggregation coordinator=], |leadingBidInfo|'s [=leading bid info/auction config=]'s [=auction config/config idl=]'s {{AuctionAdConfig/reportingTimeout}}, and « |leadingBidInfo|'s [=leading bid info/auction config=]'s [=auction config/config idl=]'s {{AuctionAdConfig/auctionSignals}}, |perBuyerSignalsForBuyer|, |sellerSignals|, |reportWinBrowserSignals|, |directFromSellerSignals| ». + 1. Set |metrics|'s [=per participant metrics/script executions attempted=] to 1. + 1. If |executionMetrics|'s [=execution metrics/script timeout occurred=] is true, set |metrics|'s + [=per participant metrics/script timeouts occurred=] to 1. 1. [=Commit private aggregation contributions=] given |paContributions|, |winner|'s [=generated bid/reporting id=] and |reportingContext|. 1. Set |leadingBidInfo|'s [=leading bid info/buyer reporting result=] to a [=reporting result=] From a427a2b42ad5da14e6ecffb22f8e535f567af746 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 13:03:55 -0500 Subject: [PATCH 13/19] And add the base value itself. --- spec.bs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec.bs b/spec.bs index 87345fdb4..07f6c1bb3 100644 --- a/spec.bs +++ b/spec.bs @@ -4141,6 +4141,9 @@ A signal base value is one of the following: : "participating-ig-count" :: The numeric value is the number of interest groups for the buyer actually participating in the auction, after considering prioritization and capabilities. +: "percent-scripts-timeout" +:: The numeric value is percentage of executions of this script that hit their individual timeout, + out of all executions that were expected to happen. @@ -4603,6 +4606,20 @@ They return a {{double}}. participant metrics/average code fetch time=]. 1. If |signalBaseValue| is "[=signal base value/participating-ig-count=]": 1. Return |bidAndScoreMetrics|'s [=per participant metrics/participating interest group count=]. +1. If |signalBaseValue| is "[=signal base value/percent-scripts-timeout=]": + 1. Return the result of [=computing a percentage metric=] given |metrics|'s [=per participant + metrics/script timeouts occurred=] and |metrics|'s [=per participant metrics/script executions + attempted=]. + +
+ +
+To compute a percentage metric given {{long}}s |numerator| and |denominator|: +1. If |denominator| is 0, return 0. +1. Let |result| be 100.0 * |numerator| / |denominator|, performing the computation with + {{double}}s. +1. If |result| > 110.0, set |result| to 110.0 +1. Return |result|.
From 89f62b90374ae99a935a1efbf7d8204f23cef280 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 13:23:24 -0500 Subject: [PATCH 14/19] Fix participating IG count computation. --- spec.bs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec.bs b/spec.bs index 3d024e03e..2b849759f 100644 --- a/spec.bs +++ b/spec.bs @@ -1972,6 +1972,8 @@ and a [=real time reporting contributions map=] |realTimeContributionsMap|: 1. If |perBuyerExperimentGroupIds| is not null and |perBuyerExperimentGroupIds|[|buyer|] [=map/exists=], then set |buyerExperimentGroupId| to |perBuyerExperimentGroupIds|[|buyer|]. 1. Apply interest groups limits to prioritized list: + 1. Let |metrics| be the result of [=accessing per-participant metrics=] for |reportingContext|, + |buyer|, [=worklet function/generate-bid=]. 1. Let |buyerGroupLimit| be |allBuyersGroupLimit|. 1. Let |perBuyerGroupLimits| be |auctionConfig|'s [=auction config/per buyer group limits=]. @@ -1989,10 +1991,9 @@ and a [=real time reporting contributions map=] |realTimeContributionsMap|: 1. [=map/For each=] slotSizeQueryParam → |perSignalsUrlGenerator| of |perSlotSizeQueryParam|: 1. [=map/For each=] joiningOrigin → |groups| of |perSignalsUrlGenerator|: 1. [=list/Remove=] from |groups| any [=interest group=] [=list/contained=] in |igs|. - 1. Let |metrics| be the result of [=accessing per-participant metrics=] for |reportingContext|, - |buyer|, [=worklet function/generate-bid=]. - 1. Set |metrics|'s [=per participant metrics/participating interest group count=] to the - [=list/size=] of |groups|. + 1. Set |metrics|'s [=per participant metrics/participating interest group count=] to + |metrics|'s [=per participant metrics/participating interest group count=] + [=list/ + size=] of |groups|. 1. Let |perBuyerSignals| be null. 1. If |auctionConfig|'s [=auction config/per buyer signals=] is not null and [=auction config/per buyer signals=][|buyer|] [=map/exists=], then set |perBuyerSignals| to From f5a32498db09768d5934a8da16bd8d7dbf10653b Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 13:53:28 -0500 Subject: [PATCH 15/19] Back to always. --- spec.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec.bs b/spec.bs index 2b849759f..b76796ebe 100644 --- a/spec.bs +++ b/spec.bs @@ -2367,6 +2367,10 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a "`default-local-reporting`", then [=add a platform contribution=] with [=scoring script failure bucket=], |realTimeContributionsMap| and |seller|. 1. Return. +1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, + |auctionConfig|'s [=auction config/seller=], [=worklet function/score-ad=]. +1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code fetch + time=] and |decisionLogicFetcher|'s [=script fetcher/fetch duration=]. 1. Let « |scoreAdResult|, |debugWinReportUrl|, |debugLossReportUrl|, |realTimeContributions|, |paContributions| » be the result of [=evaluating a scoring script=] with |decisionLogicScript|, |adMetadata|, |bidValue|'s [=bid with currency/value=], |auctionConfig|, |reportingContext|, @@ -2379,10 +2383,6 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a as it would be problematic to report a winner that didn't actually win. 1. Let |reportingId| be |generatedBid|'s [=generated bid/reporting id=]. - 1. Let |metrics| be the result of [=access per-participant metrics=] given |reportingContext|, - |auctionConfig|'s [=auction config/seller=], [=worklet function/score-ad=]. - 1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/average code fetch - time=] and |decisionLogicFetcher|'s [=script fetcher/fetch duration=]. 1. If |reportingContext|'s [=reporting context/debug reporting info=][|reportingId|] does not [=map/exist=], set it to a new [=bid debug reporting info=]. 1. Let |bidDebugReportInfo| be |reportingContext|'s [=reporting context/debug reporting info=] From 0b1b2c373faed2234c4e053c5df064501c79352c Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 14:04:04 -0500 Subject: [PATCH 16/19] Fix the reportAdditionalWin case. --- spec.bs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec.bs b/spec.bs index c9ba5a600..3587dd2d7 100644 --- a/spec.bs +++ b/spec.bs @@ -2898,8 +2898,8 @@ and a [=global object=] |global|: 1. Let |sellerReportingScript| be the result of [=waiting for script body from a fetcher=] given |sellerReportingScriptFetcher|. 1. Let « |sellerSignals|, |reportUrl|, |reportingBeaconMap|, ignored, |paContributions| » be the - result of [=evaluating a reporting script=] with |sellerReportingScript|, [=worklet function/ - report-result=], |reportingContext|, |config|'s [=auction config/seller=], |config|'s + result of [=evaluating a reporting script=] with |sellerReportingScript|, "`reportResult`", + |reportingContext|, |config|'s [=auction config/seller=], |config|'s [=auction config/seller Private Aggregation coordinator=], |config|'s [=auction config/ config idl=]'s {{AuctionAdConfig/reportingTimeout}}, and « |config|'s [=auction config/config idl=], |browserSignals|, |directFromSellerSignals| ». @@ -2997,9 +2997,9 @@ a {{ReportingBrowserSignals}} |browserSignals|, a [=direct from seller signals=] 1. If |winner|'s [=generated bid/provided as additional bid=] is true: 1. Set |reportFunctionName| be "`reportAdditionalBidWin`". 1. Let « ignored, |resultUrl|, |reportingBeaconMap|, |reportingMacroMap|, |paContributions| » be - the result of [=evaluating a reporting script=] with |buyerReportingScript|, [=worklet function/ - report-win=], |reportingContext|, |ig|'s [=interest group/owner=], |ig|'s [=interest group/ - Private Aggregation coordinator=], |leadingBidInfo|'s [=leading bid info/auction config=]'s + the result of [=evaluating a reporting script=] with |buyerReportingScript|, + |reportFunctionName|, |reportingContext|, |ig|'s [=interest group/owner=], |ig|'s [=interest + group/Private Aggregation coordinator=], |leadingBidInfo|'s [=leading bid info/auction config=]'s [=auction config/config idl=]'s {{AuctionAdConfig/reportingTimeout}}, and « |leadingBidInfo|'s [=leading bid info/auction config=]'s [=auction config/config idl=]'s {{AuctionAdConfig/auctionSignals}}, |perBuyerSignalsForBuyer|, |sellerSignals|, @@ -5478,16 +5478,16 @@ of the following global objects:
- To evaluate a reporting script given a [=string=] |script|, a [=worklet function=] - |function|, a [=reporting context=] |reportingContext|, an [=origin=] |origin|, an [=origin=] - |privateAggregationCoordinator|, an integer millisecond [=duration=] |timeout|, and a [=list=] - of arguments |arguments|: + To evaluate a reporting script given a [=string=] |script|, a [=string=] + |functionName|, a [=reporting context=] |reportingContext|, an [=origin=] |origin|, an + [=origin=] |privateAggregationCoordinator|, an integer millisecond [=duration=] |timeout|, + and a [=list=] of arguments |arguments|: 1. Let |realm| be the result of [=creating a new script runner realm=] given {{InterestGroupReportingScriptRunnerGlobalScope}}. 1. Let |global| be |realm|'s [=realm/global object=]. - 1. Let |functionName| be `"reportWin"`. - 1. If |function| is [=worklet function/report-result=], set |functionName| to `"reportResult"`. + 1. Let |function| be [=worklet function/report-win=] + 1. If |functionName| is `"reportResult"`, set |function| to [=worklet function/report-result=]. 1. [=Prepare for private aggregation=] given |global|, |function|, |reportingContext|, |origin|, and |privateAggregationCoordinator|. 1. Let |argumentsJS| be the result of [=converting a Web IDL arguments list to an ECMAScript From 4caa43ac334b053b634996a3c1481dd57b96c691 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Wed, 6 Nov 2024 14:38:29 -0500 Subject: [PATCH 17/19] Improve report-win enum at suggestion. --- spec.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.bs b/spec.bs index 3587dd2d7..deb92df0d 100644 --- a/spec.bs +++ b/spec.bs @@ -4102,7 +4102,7 @@ A worklet function is one of the following: : "report-result" :: The `reportResult()` function. : "report-win" -:: The `reportWin()` function. +:: The `reportWin()` function, or `reportAdditionalBidWin()` for additional bids. From 0f5a97b8c002ab084fcb708528b8856440633bcd Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Thu, 7 Nov 2024 09:55:50 -0500 Subject: [PATCH 18/19] Fix edit mishap --- spec.bs | 1 - 1 file changed, 1 deletion(-) diff --git a/spec.bs b/spec.bs index 4b36f04ce..b8b448bb7 100644 --- a/spec.bs +++ b/spec.bs @@ -2410,7 +2410,6 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a |seller|, and |realTimeContributions|. 1. [=set/Insert=] |reportingId| into |reportingContext|'s [=reporting context/seller participants=]. - 1. 1. [=Commit private aggregation contributions=] given |paContributions|, |reportingId|, and |reportingContext|. 1. Let |scoreAdOutput| be result of [=processing scoreAd output=] with |scoreAdResult|. From 8274dfbbae835169f38d1a16cba1bc66f8423966 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Thu, 7 Nov 2024 10:56:49 -0500 Subject: [PATCH 19/19] Spec various P.Agg. storage usage base values. --- spec.bs | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/spec.bs b/spec.bs index b8b448bb7..79c823d8c 100644 --- a/spec.bs +++ b/spec.bs @@ -1984,6 +1984,10 @@ and a [=real time reporting contributions map=] |realTimeContributionsMap|: 1. [=map/For each=] slotSizeQueryParam → |perSignalsUrlGenerator| of |perSlotSizeQueryParam|: 1. [=map/For each=] joiningOrigin → |groups| of |perSignalsUrlGenerator|: 1. [=list/Extend=] |igs| with |groups|. + 1. [=Update storage metrics=] given |metrics| and |igs|. + + Note: This is done before any filtering, since it represents storage resource usage. + 1. [=list/Sort in descending order=] |igs|, with |a| being less than |b| if |a|'s [=interest group/priority=] is less than |b|'s [=interest group/priority=]. 1. [=list/Remove=] the first |buyerGroupLimit| items from |igs|. @@ -4144,6 +4148,18 @@ A signal base value is one of the following: : "percent-scripts-timeout" :: The numeric value is percentage of executions of this script that hit their individual timeout, out of all executions that were expected to happen. +: "regular-igs-count" +:: Number of [=regular interest groups=] for the given buyer. (0 if this is used by a seller). +: "percent-regular-ig-count-quota-used" +:: +: "negative-igs-count" +:: Number of [=negative interest groups=] for the given buyer. (0 if this is used by a seller). +: "percent-negative-ig-count-quota-used" +:: +: "ig-storage-used" +:: Bytes of storage used by the given buyer. (0 if this is used by a seller). +: "percent-ig-storage-quota-used" +:: @@ -4245,6 +4261,12 @@ A per participant metrics is a [=struct=] with the following [=struct :: A {{long}}, initially 0. : script executions attempted :: A {{long}}, initially 0. + : regular interest group count + :: A {{long}}, initially 0. + : negative interest group count + :: A {{long}}, initially 0. + : storage quota used + :: A {{long}}, initially 0.

Private Aggregation contributions

@@ -4610,6 +4632,22 @@ They return a {{double}}. 1. Return the result of [=computing a percentage metric=] given |metrics|'s [=per participant metrics/script timeouts occurred=] and |metrics|'s [=per participant metrics/script executions attempted=]. +1. If |signalBaseValue| is "[=signal base value/regular-igs-count=]": + 1. Return |bidAndScoreMetrics|'s [=per participant metrics/regular interest group count=]. +1. If |signalBaseValue| is "[=signal base value/percent-regular-ig-count-quota-used=]": + 1. Return the result of [=computing a percentage metric=] given |bidAndScoreMetrics|'s [=per + participant metrics/regular interest group count=] and [=Max regular interest groups per owner=]. +1. If |signalBaseValue| is "[=signal base value/negative-igs-count=]": + 1. Return |bidAndScoreMetrics|'s [=per participant metrics/negative interest group count=]. +1. If |signalBaseValue| is "[=signal base value/percent-negative-ig-count-quota-used=]": + 1. Return the result of [=computing a percentage metric=] given |bidAndScoreMetrics|'s [=per + participant metrics/negative interest group count=] and [=Max negative interest groups per + owner=]. +1. If |signalBaseValue| is "[=signal base value/ig-storage-used=]": + 1. Return |bidAndScoreMetrics|'s [=per participant metrics/storage quota used=]. +1. If |signalBaseValue| is "[=signal base value/percent-ig-storage-quota-used=]": + 1. Return the result of [=computing a percentage metric=] given |bidAndScoreMetrics|'s [=per + participant metrics/storage quota used=] and [=Max interest groups total size per owner=].
@@ -4623,6 +4661,19 @@ To compute a percentage metric given {{long}}s |numerator| and |denom
+
+To update storage metrics given [=per participant metrics=] |metrics| and a [=list=] of +[=interest groups=] |igs|: +1. [=list/For each=] |ig| of |igs|: + 1. If [=interest group/additional bid key=] is null, increment |metrics|'s [=per participant + metrics/regular interest group count=] by 1. + 1. Otherwise, increment |metrics|'s [=per participant metrics/negative interest group count=] + by 1. + 1. Increment |metrics|'s [=per participant metrics/storage quota used=] by |ig|'s [=interest + group/estimated size=] + +
+ ## Get storage interest groups for owner ## {#get-storage-interest-groups-for-owner-header} *This first introductory paragraph is non-normative.*