Skip to content

Commit

Permalink
Replace single-spec with top-level trigger data
Browse files Browse the repository at this point in the history
  • Loading branch information
apasel422 committed Jan 23, 2024
1 parent d2c9e31 commit ff2fc6c
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 195 deletions.
43 changes: 19 additions & 24 deletions EVENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,24 +346,23 @@ cardinality):
```jsonc
{
// Specifies how the 64-bit unsigned trigger_data from the trigger is matched
// against the source's trigger_specs trigger_data, which is 32-bit. Defaults
// to "modulus".
// against the source's trigger_data, which is 32-bit. Defaults to "modulus".
//
// If "exact", the trigger_data must exactly match a value contained in the
// source's trigger_specs; if there is no such match, no event-level
// source's trigger_data; if there is no such match, no event-level
// attribution takes place.
//
// If "modulus", the set of all trigger_data values across all trigger_specs
// for the source must be a contiguous sequence of integers starting at 0.
// The trigger's trigger_data is taken modulus the cardinality of this
// sequence and then matched against the trigger specs. See below for an
// example. It is an error to use "modulus" if the trigger specs do not
// contain such a sequence.
// If "modulus", the source's trigger_data must form a contiguous sequence of
// integers starting at 0. The trigger's trigger_data is taken modulus the
// cardinality of this sequence and then matched against the trigger data.
// See below for an example. It is an error to use "modulus" if the trigger
// data does not form such a sequence.
"trigger_data_matching": <one of "exact" or "modulus">,
"trigger_specs": {
"trigger_data": [<32-bit unsigned integer>, ...]
}
// Size must be in the range [0, 32], inclusive.
// If omitted, defaults to [0, 1, 2, 3, 4, 5, 6, 7] for navigation sources and
// [0, 1] for event sources.
"trigger_data": [<32-bit unsigned integer>, ...]
}
```
Expand All @@ -374,12 +373,10 @@ navigation source (by limiting the number of distinct trigger data values) or
```jsonc
{
...,
"trigger_specs": {
// The effective cardinality is 5, so the trigger's trigger_data will be
// taken modulus 5. Likewise, noise will be applied using the effective
// cardinality of 5, instead of the default for the source type.
"trigger_data": [0, 1, 2, 3, 4]
}
// The effective cardinality is 5, so the trigger's trigger_data will be taken
// modulus 5. Likewise, noise will be applied using the effective cardinality
// of 5, instead of the default for the source type.
"trigger_data": [0, 1, 2, 3, 4]
}
```
Expand All @@ -390,12 +387,10 @@ contain the exact value, e.g.
```jsonc
{
"trigger_data_matching": "exact",
"trigger_specs": {
// If this list does not contain the trigger's trigger_data value,
// attribution will fail and no report will be generated.
// Noise will be applied using an effective cardinality of 2.
"trigger_data": [123, 456]
}
// If this list does not contain the trigger's trigger_data value, attribution
// will fail and no report will be generated. Noise will be applied using an
// effective cardinality of 2.
"trigger_data": [123, 456]
}
```
Expand Down
4 changes: 0 additions & 4 deletions flexible_event_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ In addition to the parameters that were added in Phase 1, we will add one additi
// triggers within the specified event_report_window.
// There will be a limit on the number of specs possible to define for a source.
// MAX_UINT32 is 2^32 - 1 (4294967295).
//
// Lists containing a single spec dictionary may be replaced with the
// dictionary itself for brevity: `{"trigger_specs": [{...}]}` is equivalent
// to `{"trigger_specs": {...}}`.
"trigger_specs": [{
// This spec will only apply to registrations that set one of the given
// trigger data values (integers in the range [0, MAX_UINT32]) in the list.
Expand Down
89 changes: 54 additions & 35 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,23 @@ To <dfn>parse summary buckets</dfn> given a [=map=] |map| and an integer |maxEve
1. Set |prev| to |item|.
1. Return |summaryBuckets|.

To <dfn>parse trigger data into a trigger spec map</dfn> given a
|triggerDataList|, a [=trigger spec=] |spec|, a [=trigger spec map=]
|specs|, and a [=boolean=] |allowEmpty|:

1. If |triggerDataList| is not a [=list=] or its [=list/size=] is greater than
[=max distinct trigger data per source=], return false.
1. If |allowEmpty| is false and |triggerDataList| [=list/is empty=], return
false.
1. [=list/iterate|For each=] |triggerData| of |triggerDataList|:
1. If |triggerData| is not an integer or cannot be represented by an
unsigned 32-bit integer, or |specs|[|triggerData|] [=map/exists=],
return false.
1. [=map/Set=] |specs|[|triggerData|] to |spec|.
1. If |specs|'s [=map/size=] is greater than
[=max distinct trigger data per source=], return false.
1. Return true.

To <dfn>parse trigger specs</dfn> given a [=map=] |map|, a [=moment=]
|sourceTime|, a [=source type=] |sourceType|, a [=duration=] |expiry|, and a
[=trigger-data matching mode=] |matchingMode|:
Expand All @@ -1973,44 +1990,46 @@ To <dfn>parse trigger specs</dfn> given a [=map=] |map|, a [=moment=]
[=parsing top-level report windows=] with |map|, |sourceTime|, |sourceType|,
and |expiry|.
1. If |defaultReportWindows| is an error, return an error.
1. Let |specs| be a new [=map=].
1. If |map|["`trigger_specs`"] does not [=map/exist=]:
1. Let |spec| be a new [=trigger spec=] with the following items:
: [=trigger spec/event-level report windows=]
:: |defaultReportWindows|
1. [=set/iterate|For each=] integer |triggerData| of [=the exclusive range|the range=] 0 to
[=default trigger data cardinality=][|sourceType|], exclusive:
1. [=map/Set=] |specs|[|triggerData|] to |spec|.
1. Return |specs|.
1. Let |val| be |map|["`trigger_specs`"].
1. If [=experimental Flexible Event support=] is false and |val| is not a
[=map=], return an error.
1. If |val| is a [=map=], set |val| to « |val| ».
1. If |val| is not a [=list=] or its
[=list/size=] is greater than [=max distinct trigger data per source=],
return an error.
1. [=list/iterate|For each=] |item| of |val|:
1. If |item| is not a [=map=], return an error.
1. Let |specs| be a new [=trigger spec map=].
1. If [=experimental Flexible Event support=] is true and
|map|["`trigger_specs`"] [=map/exists=]:
1. If |map|["`trigger_data`"] [=map/exists=], return an error.
1. If |map|["`trigger_specs`"] is not a [=list=] or its
[=list/size=] is greater than [=max distinct trigger data per source=],
return an error.
1. [=list/iterate|For each=] |item| of |map|["`trigger_specs`"]:
1. If |item| is not a [=map=], return an error.
1. Let |spec| be a new [=trigger spec=] with the following items:
: [=trigger spec/event-level report windows=]
:: |defaultReportWindows|
1. If |item|["`event_report_windows`"] [=map/exists=]:
1. Let |reportWindows| be the result of
[=parsing report windows=] with |item|["`event_report_windows`"],
|sourceTime|, and |expiry|.
1. If |reportWindows| is an error, return it.
1. Set |spec|'s [=trigger spec/event-level report windows=] to
|reportWindows|.
1. If |item|["`trigger_data`"] does not [=map/exist=], return an error.
1. Let |allowEmpty| be false.
1. If the result of running
[=parse trigger data into a trigger spec map=] with
|item|["`trigger_data`"], |spec|, |specs|, and |allowEmpty| is
false, return an error.
1. Otherwise:
1. Let |spec| be a new [=trigger spec=] with the following items:
: [=trigger spec/event-level report windows=]
:: |defaultReportWindows|
1. If [=experimental Flexible Event support=] is true and |item|["`event_report_windows`"] [=map/exists=]:
1. Let |reportWindows| be the result of
[=parsing report windows=] with |item|["`event_report_windows`"],
|sourceTime|, and |expiry|.
1. If |reportWindows| is an error, return it.
1. Set |spec|'s [=trigger spec/event-level report windows=] to
|reportWindows|.
1. If |item|["`trigger_data`"] does not [=map/exist=], is not a [=list=],
[=list/is empty=], or its [=list/size=] is greater than
[=max distinct trigger data per source=], return an error.
1. [=list/iterate|For each=] |triggerData| of |item|["`trigger_data`"]:
1. If |triggerData| is not an integer or cannot be represented by an
unsigned 32-bit integer, or |specs|[|triggerData|] [=map/exists=],
1. If |map|["`trigger_data`"] [=map/exists=]:
1. Let |allowEmpty| be true.
1. If the result of running
[=parse trigger data into a trigger spec map=] with
|map|["`trigger_data`"], |spec|, |specs|, and |allowEmpty| is false,
return an error.
1. [=map/Set=] |specs|[|triggerData|] to |spec|.
1. If |specs|'s [=map/size=] is greater than
[=max distinct trigger data per source=], return an error.
1. Otherwise:
1. [=set/iterate|For each=] integer |triggerData| of
[=the exclusive range|the range=] 0 to
[=default trigger data cardinality=][|sourceType|], exclusive:
1. [=map/Set=] |specs|[|triggerData|] to |spec|.
1. If |matchingMode| is "<code>[=trigger-data matching mode/modulus=]</code>":
1. Let |i| be 0.
1. [=map/iterate|For each=] |triggerData| of |specs|'s [=map/get the keys|keys=]:
Expand All @@ -2019,7 +2038,7 @@ To <dfn>parse trigger specs</dfn> given a [=map=] |map|, a [=moment=]
1. Return |specs|.

Issue: Invoke [=parse summary buckets=] and [=parse summary window operator=]
from this algorithm when [=experimental Flexible Event support=] is true.
from this algorithm.

To <dfn noexport>parse source-registration JSON</dfn> given a [=byte sequence=]
|json|, a [=suitable origin=] |sourceOrigin|, a [=suitable origin=] |reportingOrigin|, a
Expand Down
Loading

0 comments on commit ff2fc6c

Please sign in to comment.