Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly spec out how non-k-anon auction works. #1080

Merged
merged 10 commits into from
Mar 18, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 82 additions & 35 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -666,12 +666,12 @@ The <dfn for=Navigator method>runAdAuction(|config|)</dfn> method steps are:
[=auction config/interest group buyers=].
1. Let |queue| be the result of [=starting a new parallel queue=].
1. [=parallel queue/enqueue steps|Enqueue the following steps=] to |queue|:
1. Let |generatedBids| be a new [=list=] of [=generated bids=].
1. Let |generatedBidsForDebuggingReports| be a new [=list=] of [=generated bids=].
1. Let |winnerInfo| be the result of running [=generate and score bids=] with |auctionConfig|,
null, |global|, |settings|'s [=environment/top-level origin=], |bidIgs|, and |generatedBids|.
null, |global|, |settings|'s [=environment/top-level origin=], |bidIgs|, and |generatedBidsForDebuggingReports|.
1. Let |auctionReportInfo| be a new [=auction report info=].
1. If |winnerInfo| is not failure, then set |auctionReportInfo| to the result of running
[=collect forDebuggingOnly reports=] with |generatedBids| and |winnerInfo|.
[=collect forDebuggingOnly reports=] with |generatedBidsForDebuggingReports| and |winnerInfo|.
1. If |winnerInfo| is failure, then [=queue a global task=] on [=DOM manipulation task source=],
given |global|, to [=reject=] |p| with a "{{TypeError}}".
1. Otherwise if |winnerInfo| is null or |winnerInfo|'s [=leading bid info/leading bid=] is null:
Expand Down Expand Up @@ -852,17 +852,9 @@ To <dfn>fill in a pending fenced frame config</dfn> given a [=fenced frame confi
To <dfn>asynchronously finish reporting</dfn> given a
[=fencedframetype/fenced frame reporting map=] |reportingMap|, [=leading bid info=] |leadingBidInfo|,
and [=auction report info=] |auctionReportInfo|.
1. Let |winner| be |leadingBidInfo|'s [=leading bid info/leading bid=].
1. [=Increment ad k-anonymity count=] given |winner|'s [=generated bid/interest group=] and
|winner|'s [=generated bid/ad descriptor=]'s [=ad descriptor/url=].
1. If |winner|'s [=generated bid/ad component descriptors=] is not null:
1. [=set/For each=] |adComponentDescriptor| in |winner|'s
[=generated bid/ad component descriptors=]:
1. [=Increment component ad k-anonymity count=] given |adComponentDescriptor|'s
[=ad descriptor/url=].
1. [=Increment reporting ID k-anonymity count=] given |winner|'s
[=generated bid/interest group=] and |winner|'s [=generated bid/ad descriptor=]'s
[=ad descriptor/url=].
1. [=Increment a winning bid's k-anonymity count=] given |leadingBidInfo|'s [=leading bid info/leading bid=].
1. If |leadingBidInfo|'s [=leading bid info/leading non-k-anon bid=] is not null:
morlovich marked this conversation as resolved.
Show resolved Hide resolved
1. [=Increment a winning bid's k-anonymity count=] given |leadingBidInfo|'s [=leading bid info/leading non-k-anon bid=].
1. Let |buyerDone|, |sellerDone|, and |componentSellerDone| be [=booleans=], initially false.
1. If |leadingBidInfo|'s [=leading bid info/component seller=] is null, set |componentSellerDone|
to true.
Expand Down Expand Up @@ -1412,7 +1404,7 @@ and a [=moment=] |auctionStartTime|:
To <dfn>generate and score bids</dfn> given an [=auction config=] |auctionConfig|, an
[=auction config=]-or-null |topLevelAuctionConfig|, a [=global object=] |global|, an [=origin=]
|topLevelOrigin|, a [=list=] of [=interest groups=] |bidIgs|, and a [=list=] of [=generated bids=]
|generatedBids|:
|generatedBidsForDebuggingReports|:
1. [=Assert=] that these steps are running [=in parallel=].
1. Let |auctionStartTime| be the [=current wall time=].
1. Let |decisionLogicScript| be the result of [=fetching script=] with |auctionConfig|'s
Expand All @@ -1434,7 +1426,7 @@ To <dfn>generate and score bids</dfn> given an [=auction config=] |auctionConfig
1. [=list/For each=] |component| in |auctionConfig|'s [=auction config/component auctions=],
[=parallel queue/enqueue steps|enqueue the following steps=] to |queue|:
1. Let |compWinnerInfo| be the result of running [=generate and score bids=] with |component|,
|auctionConfig|, |global|, |topLevelOrigin|, |bidIgs|, and |generatedBids|.
|auctionConfig|, |global|, |topLevelOrigin|, |bidIgs|, and |generatedBidsForDebuggingReports|.
1. If |compWinnerInfo| is failure, return failure.
1. If [=recursively wait until configuration input promises resolve=] given |auctionConfig| returns
failure, return failure.
Expand All @@ -1449,6 +1441,10 @@ To <dfn>generate and score bids</dfn> given an [=auction config=] |auctionConfig
[=score and rank a bid=] with |auctionConfig|, |compWinnerInfo|'s
[=leading bid info/leading bid=], |leadingBidInfo|, |decisionLogicScript|, null,
"top-level-auction", null, and |topLevelOrigin|.
1. If |compWinnerInfo|'s [=leading bid info/leading non-k-anon bid=] is not null, then run
[=score and rank a bid=] with |auctionConfig|, |compWinnerInfo|'s
[=leading bid info/leading non-k-anon bid=], |leadingBidInfo|, |decisionLogicScript|, null,
"top-level-auction", null, and |topLevelOrigin|.
1. Decrement |pendingComponentAuctions| by 1.
1. Wait until |pendingComponentAuctions| is 0.
1. If |leadingBidInfo|'s [=leading bid info/leading bid=] is null, return null.
Expand Down Expand Up @@ -1593,29 +1589,37 @@ To <dfn>generate and score bids</dfn> given an [=auction config=] |auctionConfig
|auctionSignals|, a [=map/clone=] of |browserSignals|, |perBuyerSignals|,
|directFromSellerSignalsForBuyer|, |perBuyerTimeout|, |expectedCurrency|, |ig|, and
|auctionStartTime|.
1. Set |generatedBid|'s [=generated bid/id=] to |generatedBids|'s [=list/size=].
1. [=list/Append=] |generatedBid| to |generatedBids|.

Issue: Instead of inserting to |generatedBids| in each component auction that runs in
parallel, create a strucure InterestGroupAuction that holds data for each auction
separately (<a href="https://github.com/WICG/turtledove/issues/1021">WICG/turtledove#1021</a>).
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
|generateBidDuration|.
1. If |generatedBid|'s [=generated bid/no bid=] is true, [=iteration/continue=].
1. If [=query generated bid k-anonymity count=] given |generatedBid| returns false:
1. If |generatedBid|'s [=generated bid/no bid=] is true:
1. [=Register a bid for forDebuggingOnly reports=] given |generatedBid| and
|generatedBidsForDebuggingReports|.
1. [=iteration/continue=].
1. Let |bidsToScore| be a new [=list=] of [=generated bids=]
1. If [=query generated bid k-anonymity count=] given |generatedBid| returns true:
1. Let |bidCopy| be a copy of |generatedBid|.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "copy" -> "clone".
@domfarolino Is there a [=clone=] to link to for struct? I saw lists/sets/maps have one, but didn't find one for struct .

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah infra doesn't seem to have a definition for this and it probably should. Could you use the word "clone" manually, and then file a bug against the Infra Standard?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1. Set |bidCopy|'s [=generated bid/for k-anon auction=] to false.
1. [=list/Append=] |bidCopy| to |bidsToScore|.
1. [=list/Append=] |generatedBid| to |bidsToScore|.

Note: Conceptually, a bid that's already k-anonymous is considered for both
the k-anonymous and non-k-anonymous leadership.

1. [=Register a bid for forDebuggingOnly reports=] given |generatedBid| and
|generatedBidsForDebuggingReports|.
1. Otherwise:

Note: [=Generate a bid=] is now rerun with only k-anonymous [=interest group/ads=] to give
the buyer a chance to [=generate a bid=] for k-anonymous [=interest group/ads=]. Allowing
the buyer to first [=generate a bid=] for non-k-anonymous [=interest group/ads=] provides a
mechanism to bootstrap the k-anonymity count, otherwise no [=interest group/ads=] would
ever trigger [=increment k-anonymity count=] and all ads would fail
[=query k-anonymity count=].
1. TODO: Run [=score and rank a bid=] on |generatedBid| to find the highest scoring bid
that isn't k-anonymous. After the auction, if the highest scoring bid that isn't
k-anonymous has a higher score than the highest scoring k-anonymous bid, then call
[=increment ad k-anonymity count=] on it.

1. Set |generatedBid|'s [=generated bid/for k-anon auction=] to false.
1. [=list/Append=] |generatedBid| to |bidsToScore|.
1. Let |originalAds| be |ig|'s [=interest group/ads=].
1. If |originalAds| is not null:
1. Set |ig|'s [=interest group/ads=] to a new [=list=] of [=interest group ad=].
Expand Down Expand Up @@ -1644,11 +1648,17 @@ To <dfn>generate and score bids</dfn> given an [=auction config=] |auctionConfig
|settings|'s [=environment settings object/current monotonic time=], in milliseconds.
1. If |perBuyerCumulativeTimeout| is not null, then decrement |perBuyerCumulativeTimeout|
by |generateBidDuration|.
1. If |generatedBid| is failure, [=iteration/continue=].
1. [=list/Insert=] |generatedBid|'s [=generated bid/interest group=] in |bidIgs|.
1. [=Score and rank a bid=] with |auctionConfig|, |generatedBid|, |leadingBidInfo|,
|decisionLogicScript|, |directFromSellerSignalsForSeller|, |dataVersion|, |auctionLevel|,
|componentAuctionExpectedCurrency|, and |topLevelOrigin|.
1. If |generatedBid| is not a failure:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, might need to register the original generatedBid for debugging if this one is a failure to get the reject reason = below threshold stuff out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though this appears that it may only work for PA, not for forDebuggingOnly?

https://source.chromium.org/chromium/chromium/src/+/main:content/browser/interest_group/interest_group_auction.cc;drc=3afa53375890e7144673d8e9e6356868295c2873;l=490

... which may make my pull request to the explainer a bit off :(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, seems like a bug, that we may want to report this k-anon reject reason to forDebuggingOnly as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably. And I think my next refactors of this make us better suited for speccing it, so maybe don't need to worry about this for a moment.

1. [=Assert=] that [=query generated bid k-anonymity count=] given |generatedBid| returns true.
1. [=list/Append=] |generatedBid| to |bidsToScore|.
1. [=Register a bid for forDebuggingOnly reports=] given |generatedBid| and
|generatedBidsForDebuggingReports|.
1. [=list/For each=] |bidToScore| of |bidsToScore|:
1. If |bidToScore|'s [=generated bid/for k-anon auction=] is true,
[=list/insert=] |bidToScore|'s [=generated bid/interest group=] in |bidIgs|.
morlovich marked this conversation as resolved.
Show resolved Hide resolved
1. [=Score and rank a bid=] with |auctionConfig|, |bidToScore|, |leadingBidInfo|,
|decisionLogicScript|, |directFromSellerSignalsForSeller|, |dataVersion|, |auctionLevel|,
|componentAuctionExpectedCurrency|, and |topLevelOrigin|.
1. Decrement |pendingBuyers| by 1.
1. Wait until both |pendingBuyers| and |pendingAdditionalBids| are 0.
1. If |leadingBidInfo|'s [=leading bid info/leading bid=] is null, return null.
Expand Down Expand Up @@ -1847,8 +1857,14 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a
then set |generatedBid|'s [=generated bid/bid in seller currency=] to
|scoreAdOutput|["{{ScoreAdOutput/incomingBidInSellerCurrency}}"].
1. Let |score| be |scoreAdOutput|["{{ScoreAdOutput/desirability}}"].
1. If |generatedBid|'s [=generated bid/for k-anon auction=] is false:
1. If |leadingBidInfo|'s [=leading bid info/leading non-k-anon bid=] is null, or
|score| > |leadingBidInfo|'s [=leading bid info/top non-k-anon score=]:
morlovich marked this conversation as resolved.
Show resolved Hide resolved
1. Set |leadingBidInfo|'s [=leading bid info/top non-k-anon score=] to |score|
morlovich marked this conversation as resolved.
Show resolved Hide resolved
1. Set |leadingBidInfo|'s [=leading bid info/leading non-k-anon bid=] to |generatedBid|
1. Return.
1. Let |updateLeadingBid| be false.
1. If |leadingBidInfo|'s [=leading bid info/leading bid=] is null, or |score| is greater than
1. If |leadingBidInfo|'s [=leading bid info/leading bid=] is null, or |score| >
morlovich marked this conversation as resolved.
Show resolved Hide resolved
|leadingBidInfo|'s [=leading bid info/top score=]:
1. Set |updateLeadingBid| to true.
1. Set |leadingBidInfo|'s [=leading bid info/top bids count=] to 1.
Expand Down Expand Up @@ -2499,6 +2515,17 @@ methods for event-level <dfn>forDebuggingOnly reports</dfn> for winning and losi
1. Return |auctionReportInfo|.
</div>

<div>
To <dfn>register a bid for forDebuggingOnly reports</dfn> given a [=generated bid=]
|generatedBid| and a [=list=] of [=generated bids=] |generatedBidsForDebuggingReports|:
1. Set |generatedBid|'s [=generated bid/id=] to |generatedBidsForDebuggingReports|'s [=list/size=].
1. [=list/Append=] |generatedBid| to |generatedBidsForDebuggingReports|.

Issue: Instead of inserting to |generatedBidsForDebuggingReports| in each component auction that runs in
parallel, create a structure InterestGroupAuction that holds data for each auction
separately (<a href="https://github.com/WICG/turtledove/issues/1021">WICG/turtledove#1021</a>).
</div>

### Downsampling ### {#downsampling-header}

*This first introductory paragraph is non-normative.*
Expand Down Expand Up @@ -3106,6 +3133,19 @@ threshold when responding to [=query k-anonymity count=].
1. [=Increment k-anonymity count=] given |keyHash|.
</div>

<div algorithm>
To <dfn>increment a winning bid's k-anonymity count</dfn> given a [=generated bid=] |winner|:
1. [=Increment ad k-anonymity count=] given |winner|'s [=generated bid/interest group=] and
|winner|'s [=generated bid/ad descriptor=]'s [=ad descriptor/url=].
1. If |winner|'s [=generated bid/ad component descriptors=] is not null:
1. [=list/For each=] |adComponentDescriptor| in |winner|'s [=generated bid/ad component descriptors=]:
1. [=Increment component ad k-anonymity count=] given |adComponentDescriptor|'s
[=ad descriptor/url=].
1. [=Increment reporting ID k-anonymity count=] given |winner|'s
[=generated bid/interest group=] and |winner|'s [=generated bid/ad descriptor=]'s
[=ad descriptor/url=].
</div>

# Script Runners # {#script-runners}

*This introduction sub-section is non-normative*.
Expand Down Expand Up @@ -5088,6 +5128,9 @@ result of [=evaluating a bidding script=], or an [=additional bid=] provided by
: <dfn>no bid</dfn>
:: A [=boolean=], initially false. True if there was a failure generating a bid, or the bidder
chose not to bid. When true, [=generated bid/bidder debug loss report url=] is still considered.
: <dfn>for k-anon auction</dfn>
:: A [=boolean=], initially true. If this is false, the bid is only used to determine the hypothetical
winner with no k-anonymity constraints, which would be used to update k-anonymity counts only.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we link "update k-anonymity counts" to an algorithm, maybe [=Increment a winning bid's k-anonymity count=]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the syntax for linking to an algorithm with text that's not just its name?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dominic; done. (Though maybe I will want to tweak the name further)

: <dfn>bid</dfn>
:: A [=bid with currency=]. If the [=bid with currency/value=] is zero or negative, then this
[=interest group=] will not participate in the auction.
Expand Down Expand Up @@ -5309,13 +5352,17 @@ scored bids. It's a [=struct=] with the following [=struct/items=]:
<dl dfn-for="leading bid info">
: <dfn>top score</dfn>
:: A {{double}}, initially 0.0. The highest score so far.
: <dfn>top non-k-anon score</dfn>
:: A {{double}}, initially 0.0. The highest score so far when disregarding k-anonymity.
: <dfn>top bids count</dfn>
:: An integer, initially 0. The number of bids with the same `top score`.
: <dfn>at most one top bid owner</dfn>
:: A [=boolean=], initially true. Whether all bids of `top score` are from the same interest
group owner.
: <dfn>leading bid</dfn>
:: Null or a [=generate bid=], initially null. The leading bid of the auction so far.
:: Null or a [=generated bid=], initially null. The leading bid of the auction so far.
: <dfn>leading non-k-anon bid</dfn>
qingxinwu marked this conversation as resolved.
Show resolved Hide resolved
:: Null or a [=generated bid=], initially null. The leading bid of the auction disregarding k-anonymity so far.
: <dfn>auction config</dfn>
:: An [=auction config=]. The auction config of the auction which generated this
[=leading bid info/leading bid=].
Expand Down
Loading