@reventlessdev/trait-address-geocoding 1.0.0-alpha.8 → 1.0.0-alpha.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,7 +19,7 @@ Most of this graft is not emitted at all. The four facts and the two `@noApi` re
19
19
  commands are real constructors the host **splices** — `...AddressGeocoding.events` and
20
20
  `...AddressGeocoding.reportCommands` — so the compiler carries them, annotations and
21
21
  schema included. The emitter writes the outbound slice, which the host does not have
22
- yet, and prints the arms that belong inside the aggregate, its behavior and the
22
+ yet, and prints the arms that belong inside the aggregate, its decision and the
23
23
  projection: those interleave with the host's own state machine, and placing an arm in
24
24
  an ordered `switch` is an AST operation a text splice gets silently wrong.
25
25
 
@@ -54,7 +54,7 @@ pnpm exec graft-trait @reventlessdev/trait-address-geocoding \
54
54
  the suite below needs no hand-written file — and prints three patches.
55
55
 
56
56
  2. Paste the three patches. The aggregate's is two spread lines plus the arms for
57
- `commandTransition`; the behavior's is the state fields and the `evolve` / `decide`
57
+ `commandTransition`; the decision's is the state fields and the `evolve` / `decide`
58
58
  arms; the projection's is the view's `geolocation` field and its arms.
59
59
 
60
60
  Policy is yours and is not config. Which states an address may change in goes in
@@ -62,7 +62,8 @@ pnpm exec graft-trait @reventlessdev/trait-address-geocoding \
62
62
  you declare beside it — the compiler resolves the constructors, the switch is
63
63
  exhaustive so it names any spliced command you have not answered for, and every
64
64
  arm has to draw on that one lifecycle. Who may send the commands goes in
65
- `commandAuthorization` the same way.
65
+ `@@reventless.authorize`, or in an `authorizationOf` switch on their names for a
66
+ rule per command.
66
67
 
67
68
  A host whose subject is not called `address`, or is not a `string`, gets the same
68
69
  graft with the constructors spelled out instead of spliced — pass `--subject`, and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/trait-address-geocoding",
3
- "version": "1.0.0-alpha.8",
3
+ "version": "1.0.0-alpha.81",
4
4
  "description": "Address-geocoding domain trait: rules, host contract, conformance suite and emitter for grafting geocoding onto an aggregate",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
@@ -11,18 +11,18 @@
11
11
  "README.md"
12
12
  ],
13
13
  "dependencies": {
14
- "sury": "11.0.0-rc.2",
15
- "sury-ppx": "11.0.0-rc.2",
16
- "@reventlessdev/reventless-infra": "3.0.0-alpha.160",
17
- "@reventlessdev/reventless-ppx": "1.0.0-alpha.78",
18
- "@reventlessdev/reventless-gwt": "1.0.0-alpha.206",
19
- "@reventlessdev/reventless-spec": "3.0.0-alpha.132"
14
+ "sury": "11.0.0",
15
+ "sury-ppx": "11.0.0",
16
+ "@reventlessdev/reventless-gwt": "1.0.0-alpha.279",
17
+ "@reventlessdev/reventless-ppx": "1.0.0-alpha.111",
18
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.194",
19
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.223"
20
20
  },
21
21
  "devDependencies": {
22
- "rescript": "12.3.0"
22
+ "rescript": "12.3.1"
23
23
  },
24
24
  "peerDependencies": {
25
- "rescript": "12.3.0"
25
+ "rescript": "^12.3.1"
26
26
  },
27
27
  "publishConfig": {
28
28
  "registry": "https://registry.npmjs.org"
@@ -6,10 +6,9 @@ staleness, redelivery, an outage is not a verdict, the stand-down — live in
6
6
  host by `AddressGeocoding_Conformance`; the confidence rule stays core's
7
7
  (`Reventless.Geocoding`). The spec surface is written by `AddressGeocoding_Scaffold`.
8
8
  */
9
-
10
9
  /** Whether the graft reports back into its host. This trait does — the two `@noApi`
11
10
  commands — and the runner accepts nothing else yet; the flag is here so a
12
- competency that only observes is not mis-modelled as one that writes. */
11
+ competency that only observes is not mis-modeled as one that writes. */
13
12
  type posture = WritesBack | Observes
14
13
 
15
14
  /**
@@ -38,6 +37,11 @@ no error. A host that spells this reaches a deploy-time refusal instead.
38
37
  */
39
38
  let capabilityNeeds: array<Reventless.CapabilityNeed.t> = [Geocoding]
40
39
 
40
+ // The address is personal data, about the entity the host's aggregate is: each
41
+ // field is marked by hand (this is not a spec file, so no PPX pass runs), with the
42
+ // aggregate as its subject, sealed under the stream id the event log passes. The
43
+ // events read `Pii.t<string>`; the commands keep their type and stay out of logs.
44
+
41
45
  /**
42
46
  The four facts the graft appends, as real constructors a host splices into its own
43
47
  event type:
@@ -68,18 +72,35 @@ record inside it would turn every reshaping release into a migration.
68
72
  type events =
69
73
  /** A new address invalidates what was resolved, which is what puts the row back
70
74
  in front of the slice. */
71
- | AddressUpdated({address: string})
75
+ | AddressUpdated({
76
+ address: @s.matches(Reventless.Pii.marked(~subject=Reventless.Pii.streamSubject, S.string))
77
+ Reventless.Pii.t<string>,
78
+ })
72
79
  /** `resolvedFrom` is provenance, not the address of record; it is what makes "is
73
80
  the pin still current?" decidable rather than assumed. */
74
- | LocationSet({location: Reventless.GeoPoint.t, resolvedFrom: string})
81
+ | LocationSet({
82
+ location: Reventless.GeoPoint.t,
83
+ resolvedFrom: @s.matches(
84
+ Reventless.Pii.marked(~subject=Reventless.Pii.streamSubject, S.string)
85
+ )
86
+ Reventless.Pii.t<string>,
87
+ })
75
88
  /** Both halves from a client. Deliberately not `AddressUpdated` + `LocationSet`:
76
89
  the slice collects the former, so emitting it here would spend a request
77
90
  re-geocoding an address a human just pinned, then race the machine's answer
78
91
  against theirs. This event is not in the slice's consumed set — the stand-down. */
79
- | AddressLocated({address: string, location: Reventless.GeoPoint.t})
92
+ | AddressLocated({
93
+ address: @s.matches(Reventless.Pii.marked(~subject=Reventless.Pii.streamSubject, S.string))
94
+ Reventless.Pii.t<string>,
95
+ location: Reventless.GeoPoint.t,
96
+ })
80
97
  /** A fact, not an absence: `location: None` already means "not looked up yet",
81
98
  and one state meaning two things is one nobody can act on. */
82
- | AddressUnresolvable({address: string, reason: string})
99
+ | AddressUnresolvable({
100
+ address: @s.matches(Reventless.Pii.marked(~subject=Reventless.Pii.streamSubject, S.string))
101
+ Reventless.Pii.t<string>,
102
+ reason: string,
103
+ })
83
104
 
84
105
  /**
85
106
  The two commands the outbound slice reports its answer through, as constructors a
@@ -94,8 +115,18 @@ on this union — so a host that splices these does not publish them.
94
115
  */
95
116
  @schema
96
117
  type reportCommands =
97
- | @noApi SetLocation({location: Reventless.GeoPoint.t, resolvedFrom: string})
98
- | @noApi MarkAddressUnresolvable({address: string, reason: string})
118
+ | @noApi
119
+ SetLocation({
120
+ location: Reventless.GeoPoint.t,
121
+ resolvedFrom: @s.matches(Reventless.Pii.mark(~subject=Reventless.Pii.streamSubject, S.string))
122
+ string,
123
+ })
124
+ | @noApi
125
+ MarkAddressUnresolvable({
126
+ address: @s.matches(Reventless.Pii.mark(~subject=Reventless.Pii.streamSubject, S.string))
127
+ string,
128
+ reason: string,
129
+ })
99
130
 
100
131
  /**
101
132
  The two commands a caller changes the address through, as constructors a host
@@ -121,11 +152,18 @@ correction too, as the same address with a new point.
121
152
  @schema
122
153
  type addressCommands =
123
154
  /** Change the address and let the geocoder find the point. */
124
- | UpdateAddress({address: string})
155
+ | UpdateAddress({
156
+ address: @s.matches(Reventless.Pii.mark(~subject=Reventless.Pii.streamSubject, S.string))
157
+ string,
158
+ })
125
159
  /** Change the address *and* say where it is — a client that already has a
126
160
  point, because it geocoded or a human dragged the pin. Suppresses the
127
161
  geocoder for this address, there being nothing left to look up. */
128
- | SetAddressLocation({address: string, location: Reventless.GeoPoint.t})
162
+ | SetAddressLocation({
163
+ address: @s.matches(Reventless.Pii.mark(~subject=Reventless.Pii.streamSubject, S.string))
164
+ string,
165
+ location: Reventless.GeoPoint.t,
166
+ })
129
167
 
130
168
  /** One host, bound. Written over an abstract `subject` (the address) so retyping it
131
169
  is a re-instantiation of this module, not a break in the trait. */
@@ -139,8 +177,8 @@ module type Binding = {
139
177
 
140
178
  let posture: posture
141
179
 
142
- module Spec: ReventlessGwt.Behavior_GWT.AggregateSpec
143
- module Behavior: Reventless.Behavior.T with module Spec = Spec
180
+ module Spec: ReventlessGwt.Decision_GWT.AggregateSpec
181
+ module Decision: Reventless.Decision.T with module Spec = Spec
144
182
 
145
183
  /** History leaving the entity active at `subject` with nothing resolved. */
146
184
  let created: subject => array<Spec.event>
@@ -1,6 +1,7 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Sury from "sury";
4
+ import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
4
5
  import * as Api$ReventlessInfra from "@reventlessdev/reventless-infra/src/components/Api.res.mjs";
5
6
  import * as GeoPoint$Reventless from "@reventlessdev/reventless-spec/src/semantic/GeoPoint.res.mjs";
6
7
  import * as PackageVersion$Reventless from "@reventlessdev/reventless-spec/src/PackageVersion.res.mjs";
@@ -18,21 +19,21 @@ let capabilityNeeds = ["Geocoding"];
18
19
  let eventsSchema = Sury.union([
19
20
  Sury.$schema(s => ({
20
21
  TAG: "AddressUpdated",
21
- address: s.m(Sury.string)
22
+ address: s.m(Pii$Reventless.marked(Pii$Reventless.streamSubject, undefined, Sury.string))
22
23
  })),
23
24
  Sury.$schema(s => ({
24
25
  TAG: "LocationSet",
25
26
  location: s.m(GeoPoint$Reventless.schema),
26
- resolvedFrom: s.m(Sury.string)
27
+ resolvedFrom: s.m(Pii$Reventless.marked(Pii$Reventless.streamSubject, undefined, Sury.string))
27
28
  })),
28
29
  Sury.$schema(s => ({
29
30
  TAG: "AddressLocated",
30
- address: s.m(Sury.string),
31
+ address: s.m(Pii$Reventless.marked(Pii$Reventless.streamSubject, undefined, Sury.string)),
31
32
  location: s.m(GeoPoint$Reventless.schema)
32
33
  })),
33
34
  Sury.$schema(s => ({
34
35
  TAG: "AddressUnresolvable",
35
- address: s.m(Sury.string),
36
+ address: s.m(Pii$Reventless.marked(Pii$Reventless.streamSubject, undefined, Sury.string)),
36
37
  reason: s.m(Sury.string)
37
38
  }))
38
39
  ]);
@@ -41,11 +42,11 @@ let reportCommandsSchema = Sury.union([
41
42
  Sury.$schema(s => ({
42
43
  TAG: "SetLocation",
43
44
  location: s.m(GeoPoint$Reventless.schema),
44
- resolvedFrom: s.m(Sury.string)
45
+ resolvedFrom: s.m(Pii$Reventless.mark(Pii$Reventless.streamSubject, undefined, Sury.string))
45
46
  })),
46
47
  Sury.$schema(s => ({
47
48
  TAG: "MarkAddressUnresolvable",
48
- address: s.m(Sury.string),
49
+ address: s.m(Pii$Reventless.mark(Pii$Reventless.streamSubject, undefined, Sury.string)),
49
50
  reason: s.m(Sury.string)
50
51
  }))
51
52
  ]);
@@ -53,11 +54,11 @@ let reportCommandsSchema = Sury.union([
53
54
  let addressCommandsSchema = Sury.union([
54
55
  Sury.$schema(s => ({
55
56
  TAG: "UpdateAddress",
56
- address: s.m(Sury.string)
57
+ address: s.m(Pii$Reventless.mark(Pii$Reventless.streamSubject, undefined, Sury.string))
57
58
  })),
58
59
  Sury.$schema(s => ({
59
60
  TAG: "SetAddressLocation",
60
- address: s.m(Sury.string),
61
+ address: s.m(Pii$Reventless.mark(Pii$Reventless.streamSubject, undefined, Sury.string)),
61
62
  location: s.m(GeoPoint$Reventless.schema)
62
63
  }))
63
64
  ]);
@@ -1,11 +1,3 @@
1
- /**
2
- The conformance suite, run by a host against its own graft. `Make(Binding).register()`
3
- inside a Jest test file registers one `describe` block; every assertion is written
4
- over the binding, never over a host's constructors.
5
- */
6
-
7
- // Warning 23 flags the spread in `geocoder` as redundant today; it is there for
8
- // the day `Capabilities.t` grows a field.
9
1
  @@warning("-23")
10
2
 
11
3
  module Outcome = ReventlessGwt.Outcome
@@ -17,7 +9,7 @@ module Outcome = ReventlessGwt.Outcome
17
9
  let suiteName = (host: string) => `${host} conforms to the address-geocoding trait`
18
10
 
19
11
  module Make = (B: AddressGeocoding.Binding) => {
20
- module A = ReventlessGwt.Behavior_GWT.MakeFromAggregate(B.Spec, B.Behavior)
12
+ module A = ReventlessGwt.Decision_GWT.MakeFromAggregate(B.Spec, B.Decision)
21
13
  module S = ReventlessGwt.OutboundTranslation_GWT.Make(B.Slice)
22
14
 
23
15
  let vienna: Reventless.GeoPoint.t = {lat: 48.2082, lng: 16.3738}
@@ -53,7 +45,9 @@ module Make = (B: AddressGeocoding.Binding) => {
53
45
  let triggers =
54
46
  B.triggers(B.subjectA)
55
47
  ->Array.map(e =>
56
- e->Reventless.Message.encode(B.Slice.consumedEventSchema)->Reventless.Message.variantNameOfJson
48
+ e
49
+ ->Reventless.Message.encode(B.Slice.consumedEventSchema)
50
+ ->Reventless.Message.variantNameOfJson
57
51
  )
58
52
  ->sorted
59
53
  // Encoded through the aggregate's own schema, so a stand-down event is a
@@ -124,7 +118,10 @@ module Make = (B: AddressGeocoding.Binding) => {
124
118
 
125
119
  A.test("a redelivered verdict is a no-op", () =>
126
120
  A.givenEvents(
127
- Array.concat(B.created(B.subjectA), [B.unresolvable(~subject=B.subjectA, ~reason="no match")]),
121
+ Array.concat(
122
+ B.created(B.subjectA),
123
+ [B.unresolvable(~subject=B.subjectA, ~reason="no match")],
124
+ ),
128
125
  )
129
126
  ->A.whenCmd(B.markUnresolvable(~subject=B.subjectA, ~reason="no match"))
130
127
  ->A.thenNoEvent
@@ -147,10 +144,12 @@ module Make = (B: AddressGeocoding.Binding) => {
147
144
  )
148
145
 
149
146
  B.triggers(B.subjectA)->Array.forEachWithIndex((trigger, i) =>
150
- S.testSync(`trigger ${Int.toString(i + 1)} queues one TODO keyed by entity and subject`, () =>
151
- S.givenEvent(trigger)
152
- ->S.whenCollect(~sourceId=entityId)
153
- ->S.thenTodos([(todoKey(B.subjectA), B.item(~entityId, ~subject=B.subjectA))])
147
+ S.testSync(
148
+ `trigger ${Int.toString(i + 1)} queues one TODO keyed by entity and subject`,
149
+ () =>
150
+ S.givenEvent(trigger)
151
+ ->S.whenCollect(~sourceId=entityId)
152
+ ->S.thenTodos([(todoKey(B.subjectA), B.item(~entityId, ~subject=B.subjectA))]),
154
153
  )
155
154
  )
156
155
 
@@ -162,7 +161,7 @@ module Make = (B: AddressGeocoding.Binding) => {
162
161
  {
163
162
  Reventless.Geocoding.label: B.subjectText(B.subjectA),
164
163
  point: vienna,
165
- relevance: Some(0.995),
164
+ relevance: 0.995,
166
165
  },
167
166
  ]),
168
167
  ),
@@ -6,7 +6,7 @@ import * as Message$Reventless from "@reventlessdev/reventless-spec/src/types/Me
6
6
  import * as DcbDecode$Reventless from "@reventlessdev/reventless-spec/src/components/DcbDecode.res.mjs";
7
7
  import * as Outcome$ReventlessGwt from "@reventlessdev/reventless-gwt/src/Outcome.res.mjs";
8
8
  import * as Capabilities$Reventless from "@reventlessdev/reventless-spec/src/semantic/Capabilities.res.mjs";
9
- import * as Behavior_GWT$ReventlessGwt from "@reventlessdev/reventless-gwt/src/Behavior_GWT.res.mjs";
9
+ import * as Decision_GWT$ReventlessGwt from "@reventlessdev/reventless-gwt/src/Decision_GWT.res.mjs";
10
10
  import * as OutboundTranslation_GWT$ReventlessGwt from "@reventlessdev/reventless-gwt/src/OutboundTranslation_GWT.res.mjs";
11
11
 
12
12
  function suiteName(host) {
@@ -14,7 +14,7 @@ function suiteName(host) {
14
14
  }
15
15
 
16
16
  function Make(B) {
17
- let A = Behavior_GWT$ReventlessGwt.MakeFromAggregate(B.Spec)(B.Behavior);
17
+ let A = Decision_GWT$ReventlessGwt.MakeFromAggregate(B.Spec)(B.Decision);
18
18
  let S = OutboundTranslation_GWT$ReventlessGwt.Make(B.Slice);
19
19
  let vienna = {
20
20
  lat: 48.2082,
@@ -28,7 +28,10 @@ function Make(B) {
28
28
  let todoKey = subject => entityId + `:` + B.subjectText(subject);
29
29
  let geocoder = answer => ({
30
30
  geocode: param => Promise.resolve(answer),
31
- messaging: Capabilities$Reventless.none.messaging
31
+ messaging: Capabilities$Reventless.none.messaging,
32
+ identityProvider: Capabilities$Reventless.none.identityProvider,
33
+ secrets: Capabilities$Reventless.none.secrets,
34
+ stash: Capabilities$Reventless.none.stash
32
35
  });
33
36
  let translateWith = answer => ((id, item) => B.translate(id, item, geocoder(answer)));
34
37
  let describeCommand = cmd => JSON.stringify(Message$Reventless.encode(cmd, B.Slice.inboundCommandSchema));
@@ -110,23 +113,17 @@ function Make(B) {
110
113
  relevance: 0.995
111
114
  }]
112
115
  })), "a location", B.isLocation));
113
- S.test("a no-match completes the TODO with a verdict", undefined, () => thenReports(S.whenTranslateMocked(S.givenTodo(todoKey(B.subjectA), B.item(entityId, B.subjectA)), (id, item) => B.translate(id, item, {
114
- geocode: param => Promise.resolve({
115
- TAG: "Error",
116
- _0: "NoMatch"
117
- }),
118
- messaging: Capabilities$Reventless.none.messaging
119
- })), "a verdict", B.isVerdict));
120
- S.test("an outage leaves the TODO pending", undefined, () => S.thenTodoStatus(S.whenTranslateMocked(S.givenTodo(todoKey(B.subjectA), B.item(entityId, B.subjectA)), (id, item) => B.translate(id, item, {
121
- geocode: param => Promise.resolve({
122
- TAG: "Error",
123
- _0: {
124
- TAG: "Unavailable",
125
- _0: "502"
126
- }
127
- }),
128
- messaging: Capabilities$Reventless.none.messaging
129
- })), todoKey(B.subjectA), "Pending"));
116
+ S.test("a no-match completes the TODO with a verdict", undefined, () => thenReports(S.whenTranslateMocked(S.givenTodo(todoKey(B.subjectA), B.item(entityId, B.subjectA)), (id, item) => B.translate(id, item, geocoder({
117
+ TAG: "Error",
118
+ _0: "NoMatch"
119
+ }))), "a verdict", B.isVerdict));
120
+ S.test("an outage leaves the TODO pending", undefined, () => S.thenTodoStatus(S.whenTranslateMocked(S.givenTodo(todoKey(B.subjectA), B.item(entityId, B.subjectA)), (id, item) => B.translate(id, item, geocoder({
121
+ TAG: "Error",
122
+ _0: {
123
+ TAG: "Unavailable",
124
+ _0: "502"
125
+ }
126
+ }))), todoKey(B.subjectA), "Pending"));
130
127
  });
131
128
  return {
132
129
  A: A,
@@ -8,7 +8,6 @@ record in it would make every release that reshapes it a migration — and build
8
8
  `resolution` per call from the fields it already holds. What comes back is a
9
9
  verdict on one command, which the host names in its own event.
10
10
  */
11
-
12
11
  /** The three fields the rules read, as the host holds them. Its invariant, which
13
12
  every host arm must preserve: `resolvedFrom` is `None` or equal to `subject`. */
14
13
  type resolution = {
@@ -28,7 +28,6 @@ address may be changed in, who may change it, what a host's own commands refuse
28
28
  which a trait cannot know. They are config when the host supplies them and absent
29
29
  when it does not.
30
30
  */
31
-
32
31
  /**
33
32
  The names a graft needs, and nothing else.
34
33
 
@@ -46,7 +45,6 @@ type config = {
46
45
  one of the slice's two triggers, because an entity created with an address
47
46
  has never been geocoded. */
48
47
  created: string,
49
-
50
48
  /**
51
49
  What this host calls the thing being geocoded, lowercase: `"address"`.
52
50
 
@@ -58,7 +56,6 @@ type config = {
58
56
  spelled out. The emitted patch says which of the two you are getting.
59
57
  */
60
58
  subject?: string,
61
-
62
59
  /**
63
60
  The creation event's payload *beyond* the subject, as declarations:
64
61
  `["email: string"]`.
@@ -72,7 +69,6 @@ type config = {
72
69
  conformance binding's histories. Omitted ⇒ omitted from the fixtures, which
73
70
  only compiles when `createdFields` is omitted too. */
74
71
  createdValues?: array<string>,
75
-
76
72
  /** The slice component's name. Defaults to `Geocode<Entity><Subject>`. */
77
73
  slice?: string,
78
74
  /** The external box the Event Graph draws. Defaults to `"Geocoder"`; a host on
@@ -81,7 +77,6 @@ type config = {
81
77
  /** The read model the projection patch is addressed to. Defaults to
82
78
  `<Entity>s`. */
83
79
  view?: string,
84
-
85
80
  /** Two subjects that differ, for the histories in which the address changes.
86
81
  Defaulted when absent — they are test data, not a decision. */
87
82
  subjectA?: string,
@@ -150,7 +145,9 @@ let lines = (ls: array<string>) => ls->Array.join("\n")
150
145
  One helper for both so the two can never fall out of step. */
151
146
  let createdPayload = (c: config, ~n: names, ~values: bool) => {
152
147
  let extra = values ? c.createdValues->Option.getOr([]) : c.createdFields->Option.getOr([])
153
- let own = values ? n.subject : n.subject ++ ": string"
148
+ let own = values
149
+ ? n.subject ++ ": Value(" ++ n.subject ++ ")"
150
+ : "@pii " ++ n.subject ++ ": string"
154
151
  Array.concat(extra, [own])->Array.join(", ")
155
152
  }
156
153
 
@@ -174,10 +171,10 @@ let sliceSpec = (c: config): string => {
174
171
  `@schema`,
175
172
  `type consumedEvent =`,
176
173
  ` | ${c.created}({${createdPayload(c, ~n, ~values=false)}})`,
177
- ` | ${n.updated}({${n.subject}: string})`,
174
+ ` | ${n.updated}({@pii ${n.subject}: string})`,
178
175
  ``,
179
176
  `@schema`,
180
- `type outboundItem = {${c.entityId}: string, ${n.subject}: string}`,
177
+ `type outboundItem = {${c.entityId}: string, @pii("${c.entityId}") ${n.subject}: string}`,
181
178
  ``,
182
179
  `@schema`,
183
180
  `type inboundCommand =`,
@@ -186,7 +183,6 @@ let sliceSpec = (c: config): string => {
186
183
  ``,
187
184
  `// Retries are for a geocoder that is down, not one that has answered.`,
188
185
  `let maxRetries = 3`,
189
- `let heartbeatInterval = 60`,
190
186
  `let targetName = Some("${c.entity}")`,
191
187
  ``,
192
188
  `// The ${c.entity} aggregate by its Spec.name; an outbound slice could once only`,
@@ -222,13 +218,14 @@ let sliceTranslation = (c: config): string => {
222
218
  event ++
223
219
  "({" ++
224
220
  n.subject ++
225
- "}) => [(" ++
221
+ ": Value(" ++
222
+ n.subject ++
223
+ ")}) => [(" ++
226
224
  key ++
227
225
  ", {" ++
228
226
  c.entityId ++
229
227
  ": sourceId, " ++
230
- n.subject ++
231
- "})]"
228
+ n.subject ++ "})]"
232
229
  lines([
233
230
  `@@reventless.translation`,
234
231
  ``,
@@ -239,6 +236,8 @@ let sliceTranslation = (c: config): string => {
239
236
  ` switch event {`,
240
237
  collectArm(c.created),
241
238
  collectArm(n.updated),
239
+ ` // An erased entity is owed nothing.`,
240
+ ` | ${c.created}(_) | ${n.updated}(_) => []`,
242
241
  ` }`,
243
242
  ``,
244
243
  `// Asking the geocoder and reading its answer are the trait's — including the`,
@@ -297,14 +296,14 @@ let conformanceBinding = (c: config): string => {
297
296
  ` let posture = TraitAddressGeocoding.AddressGeocoding.WritesBack`,
298
297
  ``,
299
298
  ` module Spec = ${c.entity}`,
300
- ` module Behavior = ${c.entity}_Behavior`,
299
+ ` module Decision = ${c.entity}_Decision`,
301
300
  ``,
302
301
  ` let created = ${n.subject} => [${c.entity}.${createdValue}]`,
303
- ` let subjectChanged = ${n.subject} => ${c.entity}.${n.updated}({${n.subject}: ${n.subject}})`,
302
+ ` let subjectChanged = ${n.subject} => ${c.entity}.${n.updated}({${n.subject}: Value(${n.subject})})`,
304
303
  ` let located = (~point, ~resolvedFrom) =>`,
305
- ` ${c.entity}.LocationSet({location: point, resolvedFrom})`,
304
+ ` ${c.entity}.LocationSet({location: point, resolvedFrom: Value(resolvedFrom)})`,
306
305
  ` let unresolvable = (~subject, ~reason) =>`,
307
- ` ${c.entity}.${n.unresolvable}({${n.subject}: subject, reason})`,
306
+ ` ${c.entity}.${n.unresolvable}({${n.subject}: Value(subject), reason})`,
308
307
  ` let setLocation = (~point, ~resolvedFrom) =>`,
309
308
  ` ${c.entity}.SetLocation({location: point, resolvedFrom})`,
310
309
  ` let markUnresolvable = (~subject, ~reason) =>`,
@@ -323,12 +322,12 @@ let conformanceBinding = (c: config): string => {
323
322
  ` // not be wider than its triggers, and the suite checks exactly that.`,
324
323
  ` let triggers = ${n.subject} => [`,
325
324
  ` ${n.slice}.${createdValue},`,
326
- ` ${n.slice}.${n.updated}({${n.subject}: ${n.subject}}),`,
325
+ ` ${n.slice}.${n.updated}({${n.subject}: Value(${n.subject})}),`,
327
326
  ` ]`,
328
327
  ` // The stand-down, as a real constructor rather than a type name: a`,
329
328
  ` // misspelled name would pass the assertion for the wrong reason.`,
330
329
  ` let standsDownOn = [`,
331
- ` ${c.entity}.${n.located}({${n.subject}: subjectA, location: {lat: 0.0, lng: 0.0}}),`,
330
+ ` ${c.entity}.${n.located}({${n.subject}: Value(subjectA), location: {lat: 0.0, lng: 0.0}}),`,
332
331
  ` ]`,
333
332
  ` let isLocation = (cmd: ${n.slice}.inboundCommand) =>`,
334
333
  ` switch cmd {`,
@@ -392,12 +391,12 @@ let aggregatePatch = (c: config): patch => {
392
391
  : [
393
392
  ` // Spelled out rather than spliced: this host calls the subject`,
394
393
  ` // "${n.subject}", and a spread cannot rename what it splices.`,
395
- ` | ${n.updateCmd}({${n.subject}: string})`,
396
- ` | ${n.suppliedPairCmd}({${n.subject}: string, location: Reventless.GeoPoint.t})`,
394
+ ` | ${n.updateCmd}({@pii ${n.subject}: string})`,
395
+ ` | ${n.suppliedPairCmd}({@pii ${n.subject}: string, location: Reventless.GeoPoint.t})`,
397
396
  ` // Deliberately unguarded — legal in every state, \`Ok([])\` on a retired`,
398
397
  ` // entity, so an in-flight answer never parks a TODO row forever.`,
399
- ` | @noApi SetLocation({location: Reventless.GeoPoint.t, resolvedFrom: string})`,
400
- ` | @noApi ${n.markUnresolvableCmd}({${n.subject}: string, reason: string})`,
398
+ ` | @noApi SetLocation({location: Reventless.GeoPoint.t, @pii resolvedFrom: string})`,
399
+ ` | @noApi ${n.markUnresolvableCmd}({@pii ${n.subject}: string, reason: string})`,
401
400
  ]
402
401
  let eventArms = n.spreadable
403
402
  ? [
@@ -408,16 +407,16 @@ let aggregatePatch = (c: config): patch => {
408
407
  ` | ...TraitAddressGeocoding.AddressGeocoding.events`,
409
408
  ]
410
409
  : [
411
- ` | ${n.updated}({${n.subject}: string})`,
410
+ ` | ${n.updated}({@pii ${n.subject}: string})`,
412
411
  ` // \`resolvedFrom\` is provenance, not the ${n.subject} of record; it is what`,
413
412
  ` // makes "is the pin still current?" decidable.`,
414
- ` | LocationSet({location: Reventless.GeoPoint.t, resolvedFrom: string})`,
413
+ ` | LocationSet({location: Reventless.GeoPoint.t, @pii resolvedFrom: string})`,
415
414
  ` // Both halves from a client. Not \`${n.updated}\` + \`LocationSet\`: the slice`,
416
415
  ` // collects the former, and this event is not in its consumed set — the`,
417
416
  ` // stand-down.`,
418
- ` | ${n.located}({${n.subject}: string, location: Reventless.GeoPoint.t})`,
417
+ ` | ${n.located}({@pii ${n.subject}: string, location: Reventless.GeoPoint.t})`,
419
418
  ` // A fact, not an absence: \`location: None\` already means "not looked up yet".`,
420
- ` | ${n.unresolvable}({${n.subject}: string, reason: string})`,
419
+ ` | ${n.unresolvable}({@pii ${n.subject}: string, reason: string})`,
421
420
  ]
422
421
  {
423
422
  into: `Aggregate/${c.entity}.res`,
@@ -439,12 +438,12 @@ let aggregatePatch = (c: config): patch => {
439
438
  }
440
439
  }
441
440
 
442
- // ── The aggregate behavior patch ─────────────────────────────────────────────
441
+ // ── The aggregate decision patch ─────────────────────────────────────────────
443
442
 
444
- let behaviorPatch = (c: config): patch => {
443
+ let decisionPatch = (c: config): patch => {
445
444
  let n = namesOf(c)
446
445
  {
447
- into: `Aggregate/${c.entity}_Behavior.res`,
446
+ into: `Aggregate/${c.entity}_Decision.res`,
448
447
  at: `the state's fields, the \`evolve\` and \`decide\` switches, and two helpers`,
449
448
  contents: lines([
450
449
  `module Guards = TraitAddressGeocoding.AddressGeocoding_Guards`,
@@ -462,12 +461,15 @@ let behaviorPatch = (c: config): patch => {
462
461
  `// --- evolve arms -------------------------------------------------------------`,
463
462
  ` // A new ${n.subject} invalidates what was known; dropping both puts the row`,
464
463
  ` // back in front of the slice.`,
464
+ ` // The ${n.subject} is personal data: it reads \`Erased\` once the entity is`,
465
+ ` // erased, and the state then holds nothing in its place.`,
465
466
  ` | (Active(s), ${n.updated}({${n.subject}})) =>`,
466
- ` Active({...s, ${n.subject}, location: None, locationResolvedFrom: None})`,
467
+ ` Active({...s, ${n.subject}: ${n.subject}->Reventless.Pii.getOr(""), location: None, locationResolvedFrom: None})`,
467
468
  ` | (Active(s), LocationSet({location, resolvedFrom})) =>`,
468
- ` Active({...s, location: Some(location), locationResolvedFrom: Some(resolvedFrom)})`,
469
+ ` Active({...s, location: Some(location), locationResolvedFrom: resolvedFrom->Reventless.Pii.toOption})`,
469
470
  ` // The caller supplied the pair, so there is nothing left to resolve.`,
470
471
  ` | (Active(s), ${n.located}({${n.subject}, location})) =>`,
472
+ ` let ${n.subject} = ${n.subject}->Reventless.Pii.getOr("")`,
471
473
  ` Active({`,
472
474
  ` ...s,`,
473
475
  ` ${n.subject},`,
@@ -476,7 +478,7 @@ let behaviorPatch = (c: config): patch => {
476
478
  ` })`,
477
479
  ` // Recording the ${n.subject} keeps the slice from handing it back for another round.`,
478
480
  ` | (Active(s), ${n.unresolvable}({${n.subject}})) =>`,
479
- ` Active({...s, location: None, locationResolvedFrom: Some(${n.subject})})`,
481
+ ` Active({...s, location: None, locationResolvedFrom: ${n.subject}->Reventless.Pii.toOption})`,
480
482
  ``,
481
483
  `// --- the trait's view, and what it decides ------------------------------------`,
482
484
  `// Built per call, because the inline record of \`Active\` cannot escape its`,
@@ -498,27 +500,27 @@ let behaviorPatch = (c: config): patch => {
498
500
  ` Guards.onSubjectUpdate(`,
499
501
  ` resolution(s.${n.subject}, s.location, s.locationResolvedFrom),`,
500
502
  ` ~subject=${n.subject},`,
501
- ` )->appended(${n.updated}({${n.subject}: ${n.subject}}))`,
503
+ ` )->appended(${n.updated}({${n.subject}: Value(${n.subject})}))`,
502
504
  ``,
503
505
  ` | (Active(s), ${n.suppliedPairCmd}({${n.subject}, location})) =>`,
504
506
  ` Guards.onSuppliedPair(`,
505
507
  ` resolution(s.${n.subject}, s.location, s.locationResolvedFrom),`,
506
508
  ` ~subject=${n.subject},`,
507
509
  ` ~location,`,
508
- ` )->appended(${n.located}({${n.subject}, location}))`,
510
+ ` )->appended(${n.located}({${n.subject}: Value(${n.subject}), location}))`,
509
511
  ``,
510
512
  ` | (Active(s), SetLocation({location, resolvedFrom})) =>`,
511
513
  ` Guards.onLocationReport(`,
512
514
  ` resolution(s.${n.subject}, s.location, s.locationResolvedFrom),`,
513
515
  ` ~location,`,
514
516
  ` ~resolvedFrom,`,
515
- ` )->appended(LocationSet({location, resolvedFrom}))`,
517
+ ` )->appended(LocationSet({location, resolvedFrom: Value(resolvedFrom)}))`,
516
518
  ``,
517
519
  ` | (Active(s), ${n.markUnresolvableCmd}({${n.subject}, reason})) =>`,
518
520
  ` Guards.onUnresolvableReport(`,
519
521
  ` resolution(s.${n.subject}, s.location, s.locationResolvedFrom),`,
520
522
  ` ~subject=${n.subject},`,
521
- ` )->appended(${n.unresolvable}({${n.subject}, reason}))`,
523
+ ` )->appended(${n.unresolvable}({${n.subject}: Value(${n.subject}), reason}))`,
522
524
  ``,
523
525
  ` // TODO(graft): the two report commands must be legal in every state this`,
524
526
  ` // host has. On a retired entity, swallow rather than refuse — an in-flight`,
@@ -551,6 +553,7 @@ let projectionPatch = (c: config): patch => {
551
553
  ``,
552
554
  `// A new ${n.subject} invalidates the pin: back to Pending for the new one.`,
553
555
  `| ${n.updated}({${n.subject}}) =>`,
556
+ ` let ${n.subject} = ${n.subject}->Reventless.Pii.getOr("")`,
554
557
  ` Update(id, state => {`,
555
558
  ` ...state,`,
556
559
  ` ${n.subject},`,
@@ -560,6 +563,7 @@ let projectionPatch = (c: config): patch => {
560
563
  ` Update(id, state => {...state, geolocation: Located({point: location})})`,
561
564
  `// The client supplied the pair, so no geocode is owed.`,
562
565
  `| ${n.located}({${n.subject}, location}) =>`,
566
+ ` let ${n.subject} = ${n.subject}->Reventless.Pii.getOr("")`,
563
567
  ` Update(id, state => {...state, ${n.subject}, geolocation: Located({point: location})})`,
564
568
  `| ${n.unresolvable}({reason: why}) =>`,
565
569
  ` Update(id, state => {...state, geolocation: Unresolvable({reason: why})})`,
@@ -594,6 +598,6 @@ let emit = (~config: config, ~into: string, ~tests: string): output => {
594
598
  contents: conformanceBinding(config),
595
599
  },
596
600
  ],
597
- patches: [aggregatePatch(config), behaviorPatch(config), projectionPatch(config)],
601
+ patches: [aggregatePatch(config), decisionPatch(config), projectionPatch(config)],
598
602
  }
599
603
  }
@@ -45,7 +45,7 @@ function lines(ls) {
45
45
 
46
46
  function createdPayload(c, n, values) {
47
47
  let extra = values ? Stdlib_Option.getOr(c.createdValues, []) : Stdlib_Option.getOr(c.createdFields, []);
48
- let own = values ? n.subject : n.subject + ": string";
48
+ let own = values ? n.subject + ": Value(" + n.subject + ")" : "@pii " + n.subject + ": string";
49
49
  return extra.concat([own]).join(", ");
50
50
  }
51
51
 
@@ -67,10 +67,10 @@ function sliceSpec(c) {
67
67
  `@schema`,
68
68
  `type consumedEvent =`,
69
69
  ` | ` + c.created + `({` + createdPayload(c, n, false) + `})`,
70
- ` | ` + n.updated + `({` + n.subject + `: string})`,
70
+ ` | ` + n.updated + `({@pii ` + n.subject + `: string})`,
71
71
  ``,
72
72
  `@schema`,
73
- `type outboundItem = {` + c.entityId + `: string, ` + n.subject + `: string}`,
73
+ `type outboundItem = {` + c.entityId + `: string, @pii("` + c.entityId + `") ` + n.subject + `: string}`,
74
74
  ``,
75
75
  `@schema`,
76
76
  `type inboundCommand =`,
@@ -79,7 +79,6 @@ function sliceSpec(c) {
79
79
  ``,
80
80
  `// Retries are for a geocoder that is down, not one that has answered.`,
81
81
  `let maxRetries = 3`,
82
- `let heartbeatInterval = 60`,
83
82
  `let targetName = Some("` + c.entity + `")`,
84
83
  ``,
85
84
  `// The ` + c.entity + ` aggregate by its Spec.name; an outbound slice could once only`,
@@ -106,7 +105,7 @@ function sliceSpec(c) {
106
105
  function sliceTranslation(c) {
107
106
  let n = namesOf(c);
108
107
  let key = "`${sourceId}:${" + n.subject + "}`";
109
- let collectArm = event => " | " + event + "({" + n.subject + "}) => [(" + key + ", {" + c.entityId + ": sourceId, " + n.subject + "})]";
108
+ let collectArm = event => " | " + event + "({" + n.subject + ": Value(" + n.subject + ")}) => [(" + key + ", {" + c.entityId + ": sourceId, " + n.subject + "})]";
110
109
  return [
111
110
  `@@reventless.translation`,
112
111
  ``,
@@ -117,6 +116,8 @@ function sliceTranslation(c) {
117
116
  ` switch event {`,
118
117
  collectArm(c.created),
119
118
  collectArm(n.updated),
119
+ ` // An erased entity is owed nothing.`,
120
+ ` | ` + c.created + `(_) | ` + n.updated + `(_) => []`,
120
121
  ` }`,
121
122
  ``,
122
123
  `// Asking the geocoder and reading its answer are the trait's — including the`,
@@ -169,14 +170,14 @@ function conformanceBinding(c) {
169
170
  ` let posture = TraitAddressGeocoding.AddressGeocoding.WritesBack`,
170
171
  ``,
171
172
  ` module Spec = ` + c.entity,
172
- ` module Behavior = ` + c.entity + `_Behavior`,
173
+ ` module Decision = ` + c.entity + `_Decision`,
173
174
  ``,
174
175
  ` let created = ` + n.subject + ` => [` + c.entity + `.` + createdValue + `]`,
175
- ` let subjectChanged = ` + n.subject + ` => ` + c.entity + `.` + n.updated + `({` + n.subject + `: ` + n.subject + `})`,
176
+ ` let subjectChanged = ` + n.subject + ` => ` + c.entity + `.` + n.updated + `({` + n.subject + `: Value(` + n.subject + `)})`,
176
177
  ` let located = (~point, ~resolvedFrom) =>`,
177
- ` ` + c.entity + `.LocationSet({location: point, resolvedFrom})`,
178
+ ` ` + c.entity + `.LocationSet({location: point, resolvedFrom: Value(resolvedFrom)})`,
178
179
  ` let unresolvable = (~subject, ~reason) =>`,
179
- ` ` + c.entity + `.` + n.unresolvable + `({` + n.subject + `: subject, reason})`,
180
+ ` ` + c.entity + `.` + n.unresolvable + `({` + n.subject + `: Value(subject), reason})`,
180
181
  ` let setLocation = (~point, ~resolvedFrom) =>`,
181
182
  ` ` + c.entity + `.SetLocation({location: point, resolvedFrom})`,
182
183
  ` let markUnresolvable = (~subject, ~reason) =>`,
@@ -195,12 +196,12 @@ function conformanceBinding(c) {
195
196
  ` // not be wider than its triggers, and the suite checks exactly that.`,
196
197
  ` let triggers = ` + n.subject + ` => [`,
197
198
  ` ` + n.slice + `.` + createdValue + `,`,
198
- ` ` + n.slice + `.` + n.updated + `({` + n.subject + `: ` + n.subject + `}),`,
199
+ ` ` + n.slice + `.` + n.updated + `({` + n.subject + `: Value(` + n.subject + `)}),`,
199
200
  ` ]`,
200
201
  ` // The stand-down, as a real constructor rather than a type name: a`,
201
202
  ` // misspelled name would pass the assertion for the wrong reason.`,
202
203
  ` let standsDownOn = [`,
203
- ` ` + c.entity + `.` + n.located + `({` + n.subject + `: subjectA, location: {lat: 0.0, lng: 0.0}}),`,
204
+ ` ` + c.entity + `.` + n.located + `({` + n.subject + `: Value(subjectA), location: {lat: 0.0, lng: 0.0}}),`,
204
205
  ` ]`,
205
206
  ` let isLocation = (cmd: ` + n.slice + `.inboundCommand) =>`,
206
207
  ` switch cmd {`,
@@ -247,12 +248,12 @@ function aggregatePatch(c) {
247
248
  ] : [
248
249
  ` // Spelled out rather than spliced: this host calls the subject`,
249
250
  ` // "` + n.subject + `", and a spread cannot rename what it splices.`,
250
- ` | ` + n.updateCmd + `({` + n.subject + `: string})`,
251
- ` | ` + n.suppliedPairCmd + `({` + n.subject + `: string, location: Reventless.GeoPoint.t})`,
251
+ ` | ` + n.updateCmd + `({@pii ` + n.subject + `: string})`,
252
+ ` | ` + n.suppliedPairCmd + `({@pii ` + n.subject + `: string, location: Reventless.GeoPoint.t})`,
252
253
  ` // Deliberately unguarded — legal in every state, \`Ok([])\` on a retired`,
253
254
  ` // entity, so an in-flight answer never parks a TODO row forever.`,
254
- ` | @noApi SetLocation({location: Reventless.GeoPoint.t, resolvedFrom: string})`,
255
- ` | @noApi ` + n.markUnresolvableCmd + `({` + n.subject + `: string, reason: string})`
255
+ ` | @noApi SetLocation({location: Reventless.GeoPoint.t, @pii resolvedFrom: string})`,
256
+ ` | @noApi ` + n.markUnresolvableCmd + `({@pii ` + n.subject + `: string, reason: string})`
256
257
  ];
257
258
  let eventArms = n.spreadable ? [
258
259
  ` // The graft's four facts, spliced from the trait: \`` + n.updated + `\`,`,
@@ -261,16 +262,16 @@ function aggregatePatch(c) {
261
262
  ` // flat, so the wire format is what hand-written arms produced.`,
262
263
  ` | ...TraitAddressGeocoding.AddressGeocoding.events`
263
264
  ] : [
264
- ` | ` + n.updated + `({` + n.subject + `: string})`,
265
+ ` | ` + n.updated + `({@pii ` + n.subject + `: string})`,
265
266
  ` // \`resolvedFrom\` is provenance, not the ` + n.subject + ` of record; it is what`,
266
267
  ` // makes "is the pin still current?" decidable.`,
267
- ` | LocationSet({location: Reventless.GeoPoint.t, resolvedFrom: string})`,
268
+ ` | LocationSet({location: Reventless.GeoPoint.t, @pii resolvedFrom: string})`,
268
269
  ` // Both halves from a client. Not \`` + n.updated + `\` + \`LocationSet\`: the slice`,
269
270
  ` // collects the former, and this event is not in its consumed set — the`,
270
271
  ` // stand-down.`,
271
- ` | ` + n.located + `({` + n.subject + `: string, location: Reventless.GeoPoint.t})`,
272
+ ` | ` + n.located + `({@pii ` + n.subject + `: string, location: Reventless.GeoPoint.t})`,
272
273
  ` // A fact, not an absence: \`location: None\` already means "not looked up yet".`,
273
- ` | ` + n.unresolvable + `({` + n.subject + `: string, reason: string})`
274
+ ` | ` + n.unresolvable + `({@pii ` + n.subject + `: string, reason: string})`
274
275
  ];
275
276
  return {
276
277
  into: `Aggregate/` + c.entity + `.res`,
@@ -285,10 +286,10 @@ function aggregatePatch(c) {
285
286
  };
286
287
  }
287
288
 
288
- function behaviorPatch(c) {
289
+ function decisionPatch(c) {
289
290
  let n = namesOf(c);
290
291
  return {
291
- into: `Aggregate/` + c.entity + `_Behavior.res`,
292
+ into: `Aggregate/` + c.entity + `_Decision.res`,
292
293
  at: `the state's fields, the \`evolve\` and \`decide\` switches, and two helpers`,
293
294
  contents: [
294
295
  `module Guards = TraitAddressGeocoding.AddressGeocoding_Guards`,
@@ -306,12 +307,15 @@ function behaviorPatch(c) {
306
307
  `// --- evolve arms -------------------------------------------------------------`,
307
308
  ` // A new ` + n.subject + ` invalidates what was known; dropping both puts the row`,
308
309
  ` // back in front of the slice.`,
310
+ ` // The ` + n.subject + ` is personal data: it reads \`Erased\` once the entity is`,
311
+ ` // erased, and the state then holds nothing in its place.`,
309
312
  ` | (Active(s), ` + n.updated + `({` + n.subject + `})) =>`,
310
- ` Active({...s, ` + n.subject + `, location: None, locationResolvedFrom: None})`,
313
+ ` Active({...s, ` + n.subject + `: ` + n.subject + `->Reventless.Pii.getOr(""), location: None, locationResolvedFrom: None})`,
311
314
  ` | (Active(s), LocationSet({location, resolvedFrom})) =>`,
312
- ` Active({...s, location: Some(location), locationResolvedFrom: Some(resolvedFrom)})`,
315
+ ` Active({...s, location: Some(location), locationResolvedFrom: resolvedFrom->Reventless.Pii.toOption})`,
313
316
  ` // The caller supplied the pair, so there is nothing left to resolve.`,
314
317
  ` | (Active(s), ` + n.located + `({` + n.subject + `, location})) =>`,
318
+ ` let ` + n.subject + ` = ` + n.subject + `->Reventless.Pii.getOr("")`,
315
319
  ` Active({`,
316
320
  ` ...s,`,
317
321
  ` ` + n.subject + `,`,
@@ -320,7 +324,7 @@ function behaviorPatch(c) {
320
324
  ` })`,
321
325
  ` // Recording the ` + n.subject + ` keeps the slice from handing it back for another round.`,
322
326
  ` | (Active(s), ` + n.unresolvable + `({` + n.subject + `})) =>`,
323
- ` Active({...s, location: None, locationResolvedFrom: Some(` + n.subject + `)})`,
327
+ ` Active({...s, location: None, locationResolvedFrom: ` + n.subject + `->Reventless.Pii.toOption})`,
324
328
  ``,
325
329
  `// --- the trait's view, and what it decides ------------------------------------`,
326
330
  `// Built per call, because the inline record of \`Active\` cannot escape its`,
@@ -342,27 +346,27 @@ function behaviorPatch(c) {
342
346
  ` Guards.onSubjectUpdate(`,
343
347
  ` resolution(s.` + n.subject + `, s.location, s.locationResolvedFrom),`,
344
348
  ` ~subject=` + n.subject + `,`,
345
- ` )->appended(` + n.updated + `({` + n.subject + `: ` + n.subject + `}))`,
349
+ ` )->appended(` + n.updated + `({` + n.subject + `: Value(` + n.subject + `)}))`,
346
350
  ``,
347
351
  ` | (Active(s), ` + n.suppliedPairCmd + `({` + n.subject + `, location})) =>`,
348
352
  ` Guards.onSuppliedPair(`,
349
353
  ` resolution(s.` + n.subject + `, s.location, s.locationResolvedFrom),`,
350
354
  ` ~subject=` + n.subject + `,`,
351
355
  ` ~location,`,
352
- ` )->appended(` + n.located + `({` + n.subject + `, location}))`,
356
+ ` )->appended(` + n.located + `({` + n.subject + `: Value(` + n.subject + `), location}))`,
353
357
  ``,
354
358
  ` | (Active(s), SetLocation({location, resolvedFrom})) =>`,
355
359
  ` Guards.onLocationReport(`,
356
360
  ` resolution(s.` + n.subject + `, s.location, s.locationResolvedFrom),`,
357
361
  ` ~location,`,
358
362
  ` ~resolvedFrom,`,
359
- ` )->appended(LocationSet({location, resolvedFrom}))`,
363
+ ` )->appended(LocationSet({location, resolvedFrom: Value(resolvedFrom)}))`,
360
364
  ``,
361
365
  ` | (Active(s), ` + n.markUnresolvableCmd + `({` + n.subject + `, reason})) =>`,
362
366
  ` Guards.onUnresolvableReport(`,
363
367
  ` resolution(s.` + n.subject + `, s.location, s.locationResolvedFrom),`,
364
368
  ` ~subject=` + n.subject + `,`,
365
- ` )->appended(` + n.unresolvable + `({` + n.subject + `, reason}))`,
369
+ ` )->appended(` + n.unresolvable + `({` + n.subject + `: Value(` + n.subject + `), reason}))`,
366
370
  ``,
367
371
  ` // TODO(graft): the two report commands must be legal in every state this`,
368
372
  ` // host has. On a retired entity, swallow rather than refuse — an in-flight`,
@@ -393,6 +397,7 @@ function projectionPatch(c) {
393
397
  ``,
394
398
  `// A new ` + n.subject + ` invalidates the pin: back to Pending for the new one.`,
395
399
  `| ` + n.updated + `({` + n.subject + `}) =>`,
400
+ ` let ` + n.subject + ` = ` + n.subject + `->Reventless.Pii.getOr("")`,
396
401
  ` Update(id, state => {`,
397
402
  ` ...state,`,
398
403
  ` ` + n.subject + `,`,
@@ -402,6 +407,7 @@ function projectionPatch(c) {
402
407
  ` Update(id, state => {...state, geolocation: Located({point: location})})`,
403
408
  `// The client supplied the pair, so no geocode is owed.`,
404
409
  `| ` + n.located + `({` + n.subject + `, location}) =>`,
410
+ ` let ` + n.subject + ` = ` + n.subject + `->Reventless.Pii.getOr("")`,
405
411
  ` Update(id, state => {...state, ` + n.subject + `, geolocation: Located({point: location})})`,
406
412
  `| ` + n.unresolvable + `({reason: why}) =>`,
407
413
  ` Update(id, state => {...state, geolocation: Unresolvable({reason: why})})`
@@ -428,7 +434,7 @@ function emit(config, into, tests) {
428
434
  ],
429
435
  patches: [
430
436
  aggregatePatch(config),
431
- behaviorPatch(config),
437
+ decisionPatch(config),
432
438
  projectionPatch(config)
433
439
  ]
434
440
  };
@@ -445,7 +451,7 @@ export {
445
451
  conformanceBinding,
446
452
  transitionArms,
447
453
  aggregatePatch,
448
- behaviorPatch,
454
+ decisionPatch,
449
455
  projectionPatch,
450
456
  emit,
451
457
  }
@@ -7,7 +7,6 @@ An outage is not a verdict — it comes back `Error`, which leaves the TODO pend
7
7
  for another attempt — and once the retries are spent `exhaustedReason` is what the
8
8
  host reports instead, by the same command a confident refusal produces.
9
9
  */
10
-
11
10
  /** The geocoder arrives as a capability, so the deployment decides what answers. */
12
11
  let translate = async (
13
12
  ~text: string,