Skip to content

Commit e6bc809

Browse files
authored
Spec: client-side contribution merging (#136)
Adds support for merging contributions with the same bucket and filtering ID before truncating to the contribution limit.
1 parent 513d2fb commit e6bc809

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

spec.bs

+22-3
Original file line numberDiff line numberDiff line change
@@ -651,13 +651,27 @@ null |timeout|:
651651
agents=] to drop reports for a number of reasons, for example user
652652
opt-out or an origin not being
653653
<a href="https://github.com/privacysandbox/attestation">enrolled</a>.
654+
1. Let |mergedContributions| be a new [=list=].
655+
1. [=list/For each=] |contribution| of |contributions|:
656+
1. Let |hasProcessedContribution| be false.
657+
1. [=list/For each=] |mergedContribution| of |mergedContributions|:
658+
1. If |contribution| and |mergedContribution| have both the same
659+
{{PAHistogramContribution/bucket}} and the same
660+
{{PAHistogramContribution/filteringId}}:
661+
1. Add |contribution|'s {{PAHistogramContribution/value}} to
662+
|mergedContribution|'s {{PAHistogramContribution/value}}.
663+
1. Set |hasProcessedContribution| to true.
664+
1. [=iteration/Break=].
665+
1. If |hasProcessedContribution| is false, [=list/append=] |contribution| to
666+
|mergedContributions|.
654667
1. Let |truncatedContributions| be a new [=list=].
655-
1. If |contributions| has a [=list/size=] greater than [=maximum report
668+
1. If |mergedContributions| has a [=list/size=] greater than [=maximum report
656669
contributions=]:
657670
1. [=set/For each=] |n| of [=the exclusive range|the range=] 0 to [=maximum
658671
report contributions=], exclusive:
659-
1. [=set/Append=] |contributions|[|n|] to |truncatedContributions|.
660-
1. Otherwise, set |truncatedContributions| to |contributions|.
672+
1. [=set/Append=] |mergedContributions|[|n|] to
673+
|truncatedContributions|.
674+
1. Otherwise, set |truncatedContributions| to |mergedContributions|.
661675
1. Let |contributionSum| be 0.
662676
1. [=set/iterate|For each=] |contribution| of |truncatedContributions|:
663677
1. [=Assert=]: |contribution|["{{PAHistogramContribution/value}}"] is
@@ -667,6 +681,11 @@ null |timeout|:
667681
1. Let |currentWallTime| be the [=current wall time=].
668682
1. Let |sufficientBudget| be the result of [=consuming budget if permitted=]
669683
given |contributionSum|, |reportingOrigin|, |api| and |currentWallTime|.
684+
685+
Issue: Allow for some of the contributions to still be approved even if
686+
there isn't enough budget for the entire report. Note that this change
687+
would require the merging step to be postponed until after budgeting and
688+
the truncation step modified to account for the later merging.
670689
1. If |sufficientBudget| is false:
671690
1. Let |isDeterministicReport| be the result of [=determining if a report
672691
should be sent deterministically=] given |preSpecifiedParams|.

0 commit comments

Comments
 (0)