@reventlessdev/trait-address-geocoding 1.0.0-alpha.70 → 1.0.0-alpha.72

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/trait-address-geocoding",
3
- "version": "1.0.0-alpha.70",
3
+ "version": "1.0.0-alpha.72",
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": [
@@ -13,10 +13,10 @@
13
13
  "dependencies": {
14
14
  "sury": "11.0.0",
15
15
  "sury-ppx": "11.0.0",
16
- "@reventlessdev/reventless-infra": "3.0.0-alpha.217",
16
+ "@reventlessdev/reventless-gwt": "1.0.0-alpha.270",
17
17
  "@reventlessdev/reventless-ppx": "1.0.0-alpha.109",
18
- "@reventlessdev/reventless-spec": "3.0.0-alpha.188",
19
- "@reventlessdev/reventless-gwt": "1.0.0-alpha.268"
18
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.190",
19
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.219"
20
20
  },
21
21
  "devDependencies": {
22
22
  "rescript": "12.3.1"
@@ -37,6 +37,11 @@ no error. A host that spells this reaches a deploy-time refusal instead.
37
37
  */
38
38
  let capabilityNeeds: array<Reventless.CapabilityNeed.t> = [Geocoding]
39
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
+
40
45
  /**
41
46
  The four facts the graft appends, as real constructors a host splices into its own
42
47
  event type:
@@ -67,18 +72,35 @@ record inside it would turn every reshaping release into a migration.
67
72
  type events =
68
73
  /** A new address invalidates what was resolved, which is what puts the row back
69
74
  in front of the slice. */
70
- | AddressUpdated({address: string})
75
+ | AddressUpdated({
76
+ address: @s.matches(Reventless.Pii.marked(~subject=Reventless.Pii.streamSubject, S.string))
77
+ Reventless.Pii.t<string>,
78
+ })
71
79
  /** `resolvedFrom` is provenance, not the address of record; it is what makes "is
72
80
  the pin still current?" decidable rather than assumed. */
73
- | 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
+ })
74
88
  /** Both halves from a client. Deliberately not `AddressUpdated` + `LocationSet`:
75
89
  the slice collects the former, so emitting it here would spend a request
76
90
  re-geocoding an address a human just pinned, then race the machine's answer
77
91
  against theirs. This event is not in the slice's consumed set — the stand-down. */
78
- | 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
+ })
79
97
  /** A fact, not an absence: `location: None` already means "not looked up yet",
80
98
  and one state meaning two things is one nobody can act on. */
81
- | 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
+ })
82
104
 
83
105
  /**
84
106
  The two commands the outbound slice reports its answer through, as constructors a
@@ -93,8 +115,18 @@ on this union — so a host that splices these does not publish them.
93
115
  */
94
116
  @schema
95
117
  type reportCommands =
96
- | @noApi SetLocation({location: Reventless.GeoPoint.t, resolvedFrom: string})
97
- | @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
+ })
98
130
 
99
131
  /**
100
132
  The two commands a caller changes the address through, as constructors a host
@@ -120,11 +152,18 @@ correction too, as the same address with a new point.
120
152
  @schema
121
153
  type addressCommands =
122
154
  /** Change the address and let the geocoder find the point. */
123
- | UpdateAddress({address: string})
155
+ | UpdateAddress({
156
+ address: @s.matches(Reventless.Pii.mark(~subject=Reventless.Pii.streamSubject, S.string))
157
+ string,
158
+ })
124
159
  /** Change the address *and* say where it is — a client that already has a
125
160
  point, because it geocoded or a human dragged the pin. Suppresses the
126
161
  geocoder for this address, there being nothing left to look up. */
127
- | 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
+ })
128
167
 
129
168
  /** One host, bound. Written over an abstract `subject` (the address) so retyping it
130
169
  is a re-instantiation of this module, not a break in the trait. */
@@ -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
  ]);
@@ -145,7 +145,9 @@ let lines = (ls: array<string>) => ls->Array.join("\n")
145
145
  One helper for both so the two can never fall out of step. */
146
146
  let createdPayload = (c: config, ~n: names, ~values: bool) => {
147
147
  let extra = values ? c.createdValues->Option.getOr([]) : c.createdFields->Option.getOr([])
148
- let own = values ? n.subject : n.subject ++ ": string"
148
+ let own = values
149
+ ? n.subject ++ ": Value(" ++ n.subject ++ ")"
150
+ : "@pii " ++ n.subject ++ ": string"
149
151
  Array.concat(extra, [own])->Array.join(", ")
150
152
  }
151
153
 
@@ -169,10 +171,10 @@ let sliceSpec = (c: config): string => {
169
171
  `@schema`,
170
172
  `type consumedEvent =`,
171
173
  ` | ${c.created}({${createdPayload(c, ~n, ~values=false)}})`,
172
- ` | ${n.updated}({${n.subject}: string})`,
174
+ ` | ${n.updated}({@pii ${n.subject}: string})`,
173
175
  ``,
174
176
  `@schema`,
175
- `type outboundItem = {${c.entityId}: string, ${n.subject}: string}`,
177
+ `type outboundItem = {${c.entityId}: string, @pii("${c.entityId}") ${n.subject}: string}`,
176
178
  ``,
177
179
  `@schema`,
178
180
  `type inboundCommand =`,
@@ -216,7 +218,9 @@ let sliceTranslation = (c: config): string => {
216
218
  event ++
217
219
  "({" ++
218
220
  n.subject ++
219
- "}) => [(" ++
221
+ ": Value(" ++
222
+ n.subject ++
223
+ ")}) => [(" ++
220
224
  key ++
221
225
  ", {" ++
222
226
  c.entityId ++
@@ -232,6 +236,8 @@ let sliceTranslation = (c: config): string => {
232
236
  ` switch event {`,
233
237
  collectArm(c.created),
234
238
  collectArm(n.updated),
239
+ ` // An erased entity is owed nothing.`,
240
+ ` | ${c.created}(_) | ${n.updated}(_) => []`,
235
241
  ` }`,
236
242
  ``,
237
243
  `// Asking the geocoder and reading its answer are the trait's — including the`,
@@ -293,11 +299,11 @@ let conformanceBinding = (c: config): string => {
293
299
  ` module Decision = ${c.entity}_Decision`,
294
300
  ``,
295
301
  ` let created = ${n.subject} => [${c.entity}.${createdValue}]`,
296
- ` 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})})`,
297
303
  ` let located = (~point, ~resolvedFrom) =>`,
298
- ` ${c.entity}.LocationSet({location: point, resolvedFrom})`,
304
+ ` ${c.entity}.LocationSet({location: point, resolvedFrom: Value(resolvedFrom)})`,
299
305
  ` let unresolvable = (~subject, ~reason) =>`,
300
- ` ${c.entity}.${n.unresolvable}({${n.subject}: subject, reason})`,
306
+ ` ${c.entity}.${n.unresolvable}({${n.subject}: Value(subject), reason})`,
301
307
  ` let setLocation = (~point, ~resolvedFrom) =>`,
302
308
  ` ${c.entity}.SetLocation({location: point, resolvedFrom})`,
303
309
  ` let markUnresolvable = (~subject, ~reason) =>`,
@@ -316,12 +322,12 @@ let conformanceBinding = (c: config): string => {
316
322
  ` // not be wider than its triggers, and the suite checks exactly that.`,
317
323
  ` let triggers = ${n.subject} => [`,
318
324
  ` ${n.slice}.${createdValue},`,
319
- ` ${n.slice}.${n.updated}({${n.subject}: ${n.subject}}),`,
325
+ ` ${n.slice}.${n.updated}({${n.subject}: Value(${n.subject})}),`,
320
326
  ` ]`,
321
327
  ` // The stand-down, as a real constructor rather than a type name: a`,
322
328
  ` // misspelled name would pass the assertion for the wrong reason.`,
323
329
  ` let standsDownOn = [`,
324
- ` ${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}}),`,
325
331
  ` ]`,
326
332
  ` let isLocation = (cmd: ${n.slice}.inboundCommand) =>`,
327
333
  ` switch cmd {`,
@@ -385,12 +391,12 @@ let aggregatePatch = (c: config): patch => {
385
391
  : [
386
392
  ` // Spelled out rather than spliced: this host calls the subject`,
387
393
  ` // "${n.subject}", and a spread cannot rename what it splices.`,
388
- ` | ${n.updateCmd}({${n.subject}: string})`,
389
- ` | ${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})`,
390
396
  ` // Deliberately unguarded — legal in every state, \`Ok([])\` on a retired`,
391
397
  ` // entity, so an in-flight answer never parks a TODO row forever.`,
392
- ` | @noApi SetLocation({location: Reventless.GeoPoint.t, resolvedFrom: string})`,
393
- ` | @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})`,
394
400
  ]
395
401
  let eventArms = n.spreadable
396
402
  ? [
@@ -401,16 +407,16 @@ let aggregatePatch = (c: config): patch => {
401
407
  ` | ...TraitAddressGeocoding.AddressGeocoding.events`,
402
408
  ]
403
409
  : [
404
- ` | ${n.updated}({${n.subject}: string})`,
410
+ ` | ${n.updated}({@pii ${n.subject}: string})`,
405
411
  ` // \`resolvedFrom\` is provenance, not the ${n.subject} of record; it is what`,
406
412
  ` // makes "is the pin still current?" decidable.`,
407
- ` | LocationSet({location: Reventless.GeoPoint.t, resolvedFrom: string})`,
413
+ ` | LocationSet({location: Reventless.GeoPoint.t, @pii resolvedFrom: string})`,
408
414
  ` // Both halves from a client. Not \`${n.updated}\` + \`LocationSet\`: the slice`,
409
415
  ` // collects the former, and this event is not in its consumed set — the`,
410
416
  ` // stand-down.`,
411
- ` | ${n.located}({${n.subject}: string, location: Reventless.GeoPoint.t})`,
417
+ ` | ${n.located}({@pii ${n.subject}: string, location: Reventless.GeoPoint.t})`,
412
418
  ` // A fact, not an absence: \`location: None\` already means "not looked up yet".`,
413
- ` | ${n.unresolvable}({${n.subject}: string, reason: string})`,
419
+ ` | ${n.unresolvable}({@pii ${n.subject}: string, reason: string})`,
414
420
  ]
415
421
  {
416
422
  into: `Aggregate/${c.entity}.res`,
@@ -455,12 +461,15 @@ let decisionPatch = (c: config): patch => {
455
461
  `// --- evolve arms -------------------------------------------------------------`,
456
462
  ` // A new ${n.subject} invalidates what was known; dropping both puts the row`,
457
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.`,
458
466
  ` | (Active(s), ${n.updated}({${n.subject}})) =>`,
459
- ` Active({...s, ${n.subject}, location: None, locationResolvedFrom: None})`,
467
+ ` Active({...s, ${n.subject}: ${n.subject}->Reventless.Pii.getOr(""), location: None, locationResolvedFrom: None})`,
460
468
  ` | (Active(s), LocationSet({location, resolvedFrom})) =>`,
461
- ` Active({...s, location: Some(location), locationResolvedFrom: Some(resolvedFrom)})`,
469
+ ` Active({...s, location: Some(location), locationResolvedFrom: resolvedFrom->Reventless.Pii.toOption})`,
462
470
  ` // The caller supplied the pair, so there is nothing left to resolve.`,
463
471
  ` | (Active(s), ${n.located}({${n.subject}, location})) =>`,
472
+ ` let ${n.subject} = ${n.subject}->Reventless.Pii.getOr("")`,
464
473
  ` Active({`,
465
474
  ` ...s,`,
466
475
  ` ${n.subject},`,
@@ -469,7 +478,7 @@ let decisionPatch = (c: config): patch => {
469
478
  ` })`,
470
479
  ` // Recording the ${n.subject} keeps the slice from handing it back for another round.`,
471
480
  ` | (Active(s), ${n.unresolvable}({${n.subject}})) =>`,
472
- ` Active({...s, location: None, locationResolvedFrom: Some(${n.subject})})`,
481
+ ` Active({...s, location: None, locationResolvedFrom: ${n.subject}->Reventless.Pii.toOption})`,
473
482
  ``,
474
483
  `// --- the trait's view, and what it decides ------------------------------------`,
475
484
  `// Built per call, because the inline record of \`Active\` cannot escape its`,
@@ -491,27 +500,27 @@ let decisionPatch = (c: config): patch => {
491
500
  ` Guards.onSubjectUpdate(`,
492
501
  ` resolution(s.${n.subject}, s.location, s.locationResolvedFrom),`,
493
502
  ` ~subject=${n.subject},`,
494
- ` )->appended(${n.updated}({${n.subject}: ${n.subject}}))`,
503
+ ` )->appended(${n.updated}({${n.subject}: Value(${n.subject})}))`,
495
504
  ``,
496
505
  ` | (Active(s), ${n.suppliedPairCmd}({${n.subject}, location})) =>`,
497
506
  ` Guards.onSuppliedPair(`,
498
507
  ` resolution(s.${n.subject}, s.location, s.locationResolvedFrom),`,
499
508
  ` ~subject=${n.subject},`,
500
509
  ` ~location,`,
501
- ` )->appended(${n.located}({${n.subject}, location}))`,
510
+ ` )->appended(${n.located}({${n.subject}: Value(${n.subject}), location}))`,
502
511
  ``,
503
512
  ` | (Active(s), SetLocation({location, resolvedFrom})) =>`,
504
513
  ` Guards.onLocationReport(`,
505
514
  ` resolution(s.${n.subject}, s.location, s.locationResolvedFrom),`,
506
515
  ` ~location,`,
507
516
  ` ~resolvedFrom,`,
508
- ` )->appended(LocationSet({location, resolvedFrom}))`,
517
+ ` )->appended(LocationSet({location, resolvedFrom: Value(resolvedFrom)}))`,
509
518
  ``,
510
519
  ` | (Active(s), ${n.markUnresolvableCmd}({${n.subject}, reason})) =>`,
511
520
  ` Guards.onUnresolvableReport(`,
512
521
  ` resolution(s.${n.subject}, s.location, s.locationResolvedFrom),`,
513
522
  ` ~subject=${n.subject},`,
514
- ` )->appended(${n.unresolvable}({${n.subject}, reason}))`,
523
+ ` )->appended(${n.unresolvable}({${n.subject}: Value(${n.subject}), reason}))`,
515
524
  ``,
516
525
  ` // TODO(graft): the two report commands must be legal in every state this`,
517
526
  ` // host has. On a retired entity, swallow rather than refuse — an in-flight`,
@@ -544,6 +553,7 @@ let projectionPatch = (c: config): patch => {
544
553
  ``,
545
554
  `// A new ${n.subject} invalidates the pin: back to Pending for the new one.`,
546
555
  `| ${n.updated}({${n.subject}}) =>`,
556
+ ` let ${n.subject} = ${n.subject}->Reventless.Pii.getOr("")`,
547
557
  ` Update(id, state => {`,
548
558
  ` ...state,`,
549
559
  ` ${n.subject},`,
@@ -553,6 +563,7 @@ let projectionPatch = (c: config): patch => {
553
563
  ` Update(id, state => {...state, geolocation: Located({point: location})})`,
554
564
  `// The client supplied the pair, so no geocode is owed.`,
555
565
  `| ${n.located}({${n.subject}, location}) =>`,
566
+ ` let ${n.subject} = ${n.subject}->Reventless.Pii.getOr("")`,
556
567
  ` Update(id, state => {...state, ${n.subject}, geolocation: Located({point: location})})`,
557
568
  `| ${n.unresolvable}({reason: why}) =>`,
558
569
  ` Update(id, state => {...state, geolocation: Unresolvable({reason: why})})`,
@@ -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 =`,
@@ -105,7 +105,7 @@ function sliceSpec(c) {
105
105
  function sliceTranslation(c) {
106
106
  let n = namesOf(c);
107
107
  let key = "`${sourceId}:${" + n.subject + "}`";
108
- 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 + "})]";
109
109
  return [
110
110
  `@@reventless.translation`,
111
111
  ``,
@@ -116,6 +116,8 @@ function sliceTranslation(c) {
116
116
  ` switch event {`,
117
117
  collectArm(c.created),
118
118
  collectArm(n.updated),
119
+ ` // An erased entity is owed nothing.`,
120
+ ` | ` + c.created + `(_) | ` + n.updated + `(_) => []`,
119
121
  ` }`,
120
122
  ``,
121
123
  `// Asking the geocoder and reading its answer are the trait's — including the`,
@@ -171,11 +173,11 @@ function conformanceBinding(c) {
171
173
  ` module Decision = ` + c.entity + `_Decision`,
172
174
  ``,
173
175
  ` let created = ` + n.subject + ` => [` + c.entity + `.` + createdValue + `]`,
174
- ` 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 + `)})`,
175
177
  ` let located = (~point, ~resolvedFrom) =>`,
176
- ` ` + c.entity + `.LocationSet({location: point, resolvedFrom})`,
178
+ ` ` + c.entity + `.LocationSet({location: point, resolvedFrom: Value(resolvedFrom)})`,
177
179
  ` let unresolvable = (~subject, ~reason) =>`,
178
- ` ` + c.entity + `.` + n.unresolvable + `({` + n.subject + `: subject, reason})`,
180
+ ` ` + c.entity + `.` + n.unresolvable + `({` + n.subject + `: Value(subject), reason})`,
179
181
  ` let setLocation = (~point, ~resolvedFrom) =>`,
180
182
  ` ` + c.entity + `.SetLocation({location: point, resolvedFrom})`,
181
183
  ` let markUnresolvable = (~subject, ~reason) =>`,
@@ -194,12 +196,12 @@ function conformanceBinding(c) {
194
196
  ` // not be wider than its triggers, and the suite checks exactly that.`,
195
197
  ` let triggers = ` + n.subject + ` => [`,
196
198
  ` ` + n.slice + `.` + createdValue + `,`,
197
- ` ` + n.slice + `.` + n.updated + `({` + n.subject + `: ` + n.subject + `}),`,
199
+ ` ` + n.slice + `.` + n.updated + `({` + n.subject + `: Value(` + n.subject + `)}),`,
198
200
  ` ]`,
199
201
  ` // The stand-down, as a real constructor rather than a type name: a`,
200
202
  ` // misspelled name would pass the assertion for the wrong reason.`,
201
203
  ` let standsDownOn = [`,
202
- ` ` + 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}}),`,
203
205
  ` ]`,
204
206
  ` let isLocation = (cmd: ` + n.slice + `.inboundCommand) =>`,
205
207
  ` switch cmd {`,
@@ -246,12 +248,12 @@ function aggregatePatch(c) {
246
248
  ] : [
247
249
  ` // Spelled out rather than spliced: this host calls the subject`,
248
250
  ` // "` + n.subject + `", and a spread cannot rename what it splices.`,
249
- ` | ` + n.updateCmd + `({` + n.subject + `: string})`,
250
- ` | ` + 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})`,
251
253
  ` // Deliberately unguarded — legal in every state, \`Ok([])\` on a retired`,
252
254
  ` // entity, so an in-flight answer never parks a TODO row forever.`,
253
- ` | @noApi SetLocation({location: Reventless.GeoPoint.t, resolvedFrom: string})`,
254
- ` | @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})`
255
257
  ];
256
258
  let eventArms = n.spreadable ? [
257
259
  ` // The graft's four facts, spliced from the trait: \`` + n.updated + `\`,`,
@@ -260,16 +262,16 @@ function aggregatePatch(c) {
260
262
  ` // flat, so the wire format is what hand-written arms produced.`,
261
263
  ` | ...TraitAddressGeocoding.AddressGeocoding.events`
262
264
  ] : [
263
- ` | ` + n.updated + `({` + n.subject + `: string})`,
265
+ ` | ` + n.updated + `({@pii ` + n.subject + `: string})`,
264
266
  ` // \`resolvedFrom\` is provenance, not the ` + n.subject + ` of record; it is what`,
265
267
  ` // makes "is the pin still current?" decidable.`,
266
- ` | LocationSet({location: Reventless.GeoPoint.t, resolvedFrom: string})`,
268
+ ` | LocationSet({location: Reventless.GeoPoint.t, @pii resolvedFrom: string})`,
267
269
  ` // Both halves from a client. Not \`` + n.updated + `\` + \`LocationSet\`: the slice`,
268
270
  ` // collects the former, and this event is not in its consumed set — the`,
269
271
  ` // stand-down.`,
270
- ` | ` + n.located + `({` + n.subject + `: string, location: Reventless.GeoPoint.t})`,
272
+ ` | ` + n.located + `({@pii ` + n.subject + `: string, location: Reventless.GeoPoint.t})`,
271
273
  ` // A fact, not an absence: \`location: None\` already means "not looked up yet".`,
272
- ` | ` + n.unresolvable + `({` + n.subject + `: string, reason: string})`
274
+ ` | ` + n.unresolvable + `({@pii ` + n.subject + `: string, reason: string})`
273
275
  ];
274
276
  return {
275
277
  into: `Aggregate/` + c.entity + `.res`,
@@ -305,12 +307,15 @@ function decisionPatch(c) {
305
307
  `// --- evolve arms -------------------------------------------------------------`,
306
308
  ` // A new ` + n.subject + ` invalidates what was known; dropping both puts the row`,
307
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.`,
308
312
  ` | (Active(s), ` + n.updated + `({` + n.subject + `})) =>`,
309
- ` Active({...s, ` + n.subject + `, location: None, locationResolvedFrom: None})`,
313
+ ` Active({...s, ` + n.subject + `: ` + n.subject + `->Reventless.Pii.getOr(""), location: None, locationResolvedFrom: None})`,
310
314
  ` | (Active(s), LocationSet({location, resolvedFrom})) =>`,
311
- ` Active({...s, location: Some(location), locationResolvedFrom: Some(resolvedFrom)})`,
315
+ ` Active({...s, location: Some(location), locationResolvedFrom: resolvedFrom->Reventless.Pii.toOption})`,
312
316
  ` // The caller supplied the pair, so there is nothing left to resolve.`,
313
317
  ` | (Active(s), ` + n.located + `({` + n.subject + `, location})) =>`,
318
+ ` let ` + n.subject + ` = ` + n.subject + `->Reventless.Pii.getOr("")`,
314
319
  ` Active({`,
315
320
  ` ...s,`,
316
321
  ` ` + n.subject + `,`,
@@ -319,7 +324,7 @@ function decisionPatch(c) {
319
324
  ` })`,
320
325
  ` // Recording the ` + n.subject + ` keeps the slice from handing it back for another round.`,
321
326
  ` | (Active(s), ` + n.unresolvable + `({` + n.subject + `})) =>`,
322
- ` Active({...s, location: None, locationResolvedFrom: Some(` + n.subject + `)})`,
327
+ ` Active({...s, location: None, locationResolvedFrom: ` + n.subject + `->Reventless.Pii.toOption})`,
323
328
  ``,
324
329
  `// --- the trait's view, and what it decides ------------------------------------`,
325
330
  `// Built per call, because the inline record of \`Active\` cannot escape its`,
@@ -341,27 +346,27 @@ function decisionPatch(c) {
341
346
  ` Guards.onSubjectUpdate(`,
342
347
  ` resolution(s.` + n.subject + `, s.location, s.locationResolvedFrom),`,
343
348
  ` ~subject=` + n.subject + `,`,
344
- ` )->appended(` + n.updated + `({` + n.subject + `: ` + n.subject + `}))`,
349
+ ` )->appended(` + n.updated + `({` + n.subject + `: Value(` + n.subject + `)}))`,
345
350
  ``,
346
351
  ` | (Active(s), ` + n.suppliedPairCmd + `({` + n.subject + `, location})) =>`,
347
352
  ` Guards.onSuppliedPair(`,
348
353
  ` resolution(s.` + n.subject + `, s.location, s.locationResolvedFrom),`,
349
354
  ` ~subject=` + n.subject + `,`,
350
355
  ` ~location,`,
351
- ` )->appended(` + n.located + `({` + n.subject + `, location}))`,
356
+ ` )->appended(` + n.located + `({` + n.subject + `: Value(` + n.subject + `), location}))`,
352
357
  ``,
353
358
  ` | (Active(s), SetLocation({location, resolvedFrom})) =>`,
354
359
  ` Guards.onLocationReport(`,
355
360
  ` resolution(s.` + n.subject + `, s.location, s.locationResolvedFrom),`,
356
361
  ` ~location,`,
357
362
  ` ~resolvedFrom,`,
358
- ` )->appended(LocationSet({location, resolvedFrom}))`,
363
+ ` )->appended(LocationSet({location, resolvedFrom: Value(resolvedFrom)}))`,
359
364
  ``,
360
365
  ` | (Active(s), ` + n.markUnresolvableCmd + `({` + n.subject + `, reason})) =>`,
361
366
  ` Guards.onUnresolvableReport(`,
362
367
  ` resolution(s.` + n.subject + `, s.location, s.locationResolvedFrom),`,
363
368
  ` ~subject=` + n.subject + `,`,
364
- ` )->appended(` + n.unresolvable + `({` + n.subject + `, reason}))`,
369
+ ` )->appended(` + n.unresolvable + `({` + n.subject + `: Value(` + n.subject + `), reason}))`,
365
370
  ``,
366
371
  ` // TODO(graft): the two report commands must be legal in every state this`,
367
372
  ` // host has. On a retired entity, swallow rather than refuse — an in-flight`,
@@ -392,6 +397,7 @@ function projectionPatch(c) {
392
397
  ``,
393
398
  `// A new ` + n.subject + ` invalidates the pin: back to Pending for the new one.`,
394
399
  `| ` + n.updated + `({` + n.subject + `}) =>`,
400
+ ` let ` + n.subject + ` = ` + n.subject + `->Reventless.Pii.getOr("")`,
395
401
  ` Update(id, state => {`,
396
402
  ` ...state,`,
397
403
  ` ` + n.subject + `,`,
@@ -401,6 +407,7 @@ function projectionPatch(c) {
401
407
  ` Update(id, state => {...state, geolocation: Located({point: location})})`,
402
408
  `// The client supplied the pair, so no geocode is owed.`,
403
409
  `| ` + n.located + `({` + n.subject + `, location}) =>`,
410
+ ` let ` + n.subject + ` = ` + n.subject + `->Reventless.Pii.getOr("")`,
404
411
  ` Update(id, state => {...state, ` + n.subject + `, geolocation: Located({point: location})})`,
405
412
  `| ` + n.unresolvable + `({reason: why}) =>`,
406
413
  ` Update(id, state => {...state, geolocation: Unresolvable({reason: why})})`