@inhuman.tools/plexus-expectations 0.0.0-stage → 0.1.0

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.
Files changed (160) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +144 -2
  3. package/dist/driver/ExpectationActor.d.ts +56 -0
  4. package/dist/driver/ExpectationActor.d.ts.map +1 -0
  5. package/dist/driver/ExpectationActor.js +210 -0
  6. package/dist/driver/ExpectationActor.js.map +1 -0
  7. package/dist/driver/PEWDriver.d.ts +144 -0
  8. package/dist/driver/PEWDriver.d.ts.map +1 -0
  9. package/dist/driver/PEWDriver.js +303 -0
  10. package/dist/driver/PEWDriver.js.map +1 -0
  11. package/dist/driver/PEWDriverConnection.d.ts +139 -0
  12. package/dist/driver/PEWDriverConnection.d.ts.map +1 -0
  13. package/dist/driver/PEWDriverConnection.js +298 -0
  14. package/dist/driver/PEWDriverConnection.js.map +1 -0
  15. package/dist/driver/actor-machine.d.ts +28 -0
  16. package/dist/driver/actor-machine.d.ts.map +1 -0
  17. package/dist/driver/actor-machine.js +50 -0
  18. package/dist/driver/actor-machine.js.map +1 -0
  19. package/dist/driver/connection-miss.d.ts +9 -0
  20. package/dist/driver/connection-miss.d.ts.map +1 -0
  21. package/dist/driver/connection-miss.js +13 -0
  22. package/dist/driver/connection-miss.js.map +1 -0
  23. package/dist/driver/index.d.ts +6 -0
  24. package/dist/driver/index.d.ts.map +1 -0
  25. package/dist/driver/index.js +5 -0
  26. package/dist/driver/index.js.map +1 -0
  27. package/dist/error-with-invariant.d.ts +9 -0
  28. package/dist/error-with-invariant.d.ts.map +1 -0
  29. package/dist/error-with-invariant.js +12 -0
  30. package/dist/error-with-invariant.js.map +1 -0
  31. package/dist/executor/index.d.ts +4 -0
  32. package/dist/executor/index.d.ts.map +1 -0
  33. package/dist/executor/index.js +4 -0
  34. package/dist/executor/index.js.map +1 -0
  35. package/dist/executor/kernel-intern.d.ts +16 -0
  36. package/dist/executor/kernel-intern.d.ts.map +1 -0
  37. package/dist/executor/kernel-intern.js +98 -0
  38. package/dist/executor/kernel-intern.js.map +1 -0
  39. package/dist/executor/orchestrator.d.ts +97 -0
  40. package/dist/executor/orchestrator.d.ts.map +1 -0
  41. package/dist/executor/orchestrator.js +465 -0
  42. package/dist/executor/orchestrator.js.map +1 -0
  43. package/dist/executor/types.d.ts +8 -0
  44. package/dist/executor/types.d.ts.map +1 -0
  45. package/dist/executor/types.js +2 -0
  46. package/dist/executor/types.js.map +1 -0
  47. package/dist/index.d.ts +2 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +2 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/schemas/connection.d.ts +4 -0
  52. package/dist/schemas/connection.d.ts.map +1 -0
  53. package/dist/schemas/connection.js +4 -0
  54. package/dist/schemas/connection.js.map +1 -0
  55. package/dist/schemas/index.d.ts +2 -0
  56. package/dist/schemas/index.d.ts.map +1 -0
  57. package/dist/schemas/index.js +2 -0
  58. package/dist/schemas/index.js.map +1 -0
  59. package/dist/shared/attention.d.ts +27 -0
  60. package/dist/shared/attention.d.ts.map +1 -0
  61. package/dist/shared/attention.js +116 -0
  62. package/dist/shared/attention.js.map +1 -0
  63. package/dist/shared/control.d.ts +4 -0
  64. package/dist/shared/control.d.ts.map +1 -0
  65. package/dist/shared/control.js +2 -0
  66. package/dist/shared/control.js.map +1 -0
  67. package/dist/shared/index.d.ts +7 -0
  68. package/dist/shared/index.d.ts.map +1 -0
  69. package/dist/shared/index.js +7 -0
  70. package/dist/shared/index.js.map +1 -0
  71. package/dist/shared/map-field-awareness.d.ts +19 -0
  72. package/dist/shared/map-field-awareness.d.ts.map +1 -0
  73. package/dist/shared/map-field-awareness.js +58 -0
  74. package/dist/shared/map-field-awareness.js.map +1 -0
  75. package/dist/shared/models/ApprovableExpectation.d.ts +15 -0
  76. package/dist/shared/models/ApprovableExpectation.d.ts.map +1 -0
  77. package/dist/shared/models/ApprovableExpectation.js +138 -0
  78. package/dist/shared/models/ApprovableExpectation.js.map +1 -0
  79. package/dist/shared/models/ConnectionSpec.d.ts +44 -0
  80. package/dist/shared/models/ConnectionSpec.d.ts.map +1 -0
  81. package/dist/shared/models/ConnectionSpec.js +180 -0
  82. package/dist/shared/models/ConnectionSpec.js.map +1 -0
  83. package/dist/shared/models/DriverSpec.d.ts +45 -0
  84. package/dist/shared/models/DriverSpec.d.ts.map +1 -0
  85. package/dist/shared/models/DriverSpec.js +221 -0
  86. package/dist/shared/models/DriverSpec.js.map +1 -0
  87. package/dist/shared/models/IntrospectingPlexusModel.d.ts +8 -0
  88. package/dist/shared/models/IntrospectingPlexusModel.d.ts.map +1 -0
  89. package/dist/shared/models/IntrospectingPlexusModel.js +48 -0
  90. package/dist/shared/models/IntrospectingPlexusModel.js.map +1 -0
  91. package/dist/shared/models/Job.d.ts +85 -0
  92. package/dist/shared/models/Job.d.ts.map +1 -0
  93. package/dist/shared/models/Job.js +261 -0
  94. package/dist/shared/models/Job.js.map +1 -0
  95. package/dist/shared/models/ProgrammaticJob.d.ts +6 -0
  96. package/dist/shared/models/ProgrammaticJob.d.ts.map +1 -0
  97. package/dist/shared/models/ProgrammaticJob.js +80 -0
  98. package/dist/shared/models/ProgrammaticJob.js.map +1 -0
  99. package/dist/shared/models/WorkContainer.d.ts +36 -0
  100. package/dist/shared/models/WorkContainer.d.ts.map +1 -0
  101. package/dist/shared/models/WorkContainer.js +140 -0
  102. package/dist/shared/models/WorkContainer.js.map +1 -0
  103. package/dist/shared/models/WorkExpectation.d.ts +63 -0
  104. package/dist/shared/models/WorkExpectation.d.ts.map +1 -0
  105. package/dist/shared/models/WorkExpectation.js +290 -0
  106. package/dist/shared/models/WorkExpectation.js.map +1 -0
  107. package/dist/shared/models/WorkExpectationWithIntrospection.d.ts +4 -0
  108. package/dist/shared/models/WorkExpectationWithIntrospection.d.ts.map +1 -0
  109. package/dist/shared/models/WorkExpectationWithIntrospection.js +28 -0
  110. package/dist/shared/models/WorkExpectationWithIntrospection.js.map +1 -0
  111. package/dist/shared/models/index.d.ts +7 -0
  112. package/dist/shared/models/index.d.ts.map +1 -0
  113. package/dist/shared/models/index.js +6 -0
  114. package/dist/shared/models/index.js.map +1 -0
  115. package/dist/shared/models/jsonRecord.d.ts +14 -0
  116. package/dist/shared/models/jsonRecord.d.ts.map +1 -0
  117. package/dist/shared/models/jsonRecord.js +46 -0
  118. package/dist/shared/models/jsonRecord.js.map +1 -0
  119. package/dist/shared/resolution.d.ts +39 -0
  120. package/dist/shared/resolution.d.ts.map +1 -0
  121. package/dist/shared/resolution.js +124 -0
  122. package/dist/shared/resolution.js.map +1 -0
  123. package/dist/shared/revalidation-demand.d.ts +27 -0
  124. package/dist/shared/revalidation-demand.d.ts.map +1 -0
  125. package/dist/shared/revalidation-demand.js +116 -0
  126. package/dist/shared/revalidation-demand.js.map +1 -0
  127. package/dist/shared/role.d.ts +12 -0
  128. package/dist/shared/role.d.ts.map +1 -0
  129. package/dist/shared/role.js +21 -0
  130. package/dist/shared/role.js.map +1 -0
  131. package/dist/shared/types.d.ts +43 -0
  132. package/dist/shared/types.d.ts.map +1 -0
  133. package/dist/shared/types.js +12 -0
  134. package/dist/shared/types.js.map +1 -0
  135. package/package.json +79 -3
  136. package/src/driver/ExpectationActor.ts +244 -0
  137. package/src/driver/PEWDriver.ts +302 -0
  138. package/src/driver/actor-machine.ts +54 -0
  139. package/src/driver/connection-miss.ts +13 -0
  140. package/src/driver/index.ts +5 -0
  141. package/src/executor/index.ts +3 -0
  142. package/src/executor/kernel-intern.ts +121 -0
  143. package/src/executor/orchestrator.ts +463 -0
  144. package/src/executor/types.ts +3 -0
  145. package/src/index.ts +1 -0
  146. package/src/schemas/connection.ts +4 -0
  147. package/src/schemas/index.ts +1 -0
  148. package/src/shared/control.ts +4 -0
  149. package/src/shared/index.ts +6 -0
  150. package/src/shared/map-field-awareness.ts +65 -0
  151. package/src/shared/models/ConnectionSpec.ts +84 -0
  152. package/src/shared/models/DriverSpec.ts +102 -0
  153. package/src/shared/models/Job.ts +192 -0
  154. package/src/shared/models/WorkContainer.ts +90 -0
  155. package/src/shared/models/WorkExpectation.ts +229 -0
  156. package/src/shared/models/index.ts +6 -0
  157. package/src/shared/models/jsonRecord.ts +49 -0
  158. package/src/shared/revalidation-demand.ts +121 -0
  159. package/src/shared/role.ts +32 -0
  160. package/src/shared/types.ts +57 -0
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Attention occupancy. Clients publish on kernel awareness; PEW reduces to
3
+ * none | ambient | focused. Interned connections outlive a session wrap, so
4
+ * occupancy is not session-plane. Drivers read the reduced token — never clientIds.
5
+ */
6
+ import { FieldAwareness } from "@here.build/plexus";
7
+ import { ConnectionSpec } from "./models/ConnectionSpec.js";
8
+ import { DriverSpec } from "./models/DriverSpec.js";
9
+ export const ATTENTION_LANE = "attention";
10
+ export const ATTENTION_FOCUS_LANE = "attentionFocus";
11
+ export function attentionRefFromSpec(spec) {
12
+ if (isConnectionSubject(spec))
13
+ return { kind: "connection", id: spec.id };
14
+ return { kind: "driver", name: spec.name };
15
+ }
16
+ export function collectAttentionRefs(source) {
17
+ if (source == null)
18
+ return [];
19
+ if (isAttentionSubject(source))
20
+ return [attentionRefFromSpec(source)];
21
+ const out = [];
22
+ const seen = new Set();
23
+ for (const item of source) {
24
+ if (item == null || !isAttentionSubject(item))
25
+ continue;
26
+ const ref = attentionRefFromSpec(item);
27
+ const key = refKey(ref);
28
+ if (seen.has(key))
29
+ continue;
30
+ seen.add(key);
31
+ out.push(ref);
32
+ }
33
+ return out;
34
+ }
35
+ export function publishAttention(hub, refs) {
36
+ const lane = new FieldAwareness(hub, ATTENTION_LANE);
37
+ if (refs.length === 0) {
38
+ lane.clear();
39
+ return;
40
+ }
41
+ lane.set(refs);
42
+ }
43
+ export function publishAttentionFocus(hub, ref) {
44
+ const lane = new FieldAwareness(hub, ATTENTION_FOCUS_LANE);
45
+ if (ref == null) {
46
+ lane.clear();
47
+ return;
48
+ }
49
+ lane.set(ref);
50
+ }
51
+ /** Union of every client's occupancy. Focused wins over ambient. */
52
+ export function attentionOf(hub, target) {
53
+ const focus = new FieldAwareness(hub, ATTENTION_FOCUS_LANE);
54
+ for (const clientId of focus.clientIds) {
55
+ const value = asAttentionRef(focus.getOther(clientId));
56
+ if (value != null && sameRef(value, target))
57
+ return "focused";
58
+ }
59
+ const ambient = new FieldAwareness(hub, ATTENTION_LANE);
60
+ for (const clientId of ambient.clientIds) {
61
+ const list = asAttentionRefList(ambient.getOther(clientId));
62
+ if (list.some((item) => sameRef(item, target)))
63
+ return "ambient";
64
+ }
65
+ return "none";
66
+ }
67
+ function isConnectionSubject(spec) {
68
+ if (spec instanceof ConnectionSpec)
69
+ return true;
70
+ if (spec instanceof DriverSpec)
71
+ return false;
72
+ return "driver" in spec && "configuration" in spec;
73
+ }
74
+ function isAttentionSubject(value) {
75
+ if (value instanceof ConnectionSpec || value instanceof DriverSpec)
76
+ return true;
77
+ if (typeof value !== "object" || value === null)
78
+ return false;
79
+ if ("driver" in value && "configuration" in value)
80
+ return true;
81
+ return "importPath" in value && "can" in value;
82
+ }
83
+ function asAttentionRef(value) {
84
+ if (typeof value !== "object" || value === null)
85
+ return null;
86
+ const rec = value;
87
+ if (rec.kind === "driver" && typeof rec.name === "string" && rec.name !== "") {
88
+ return { kind: "driver", name: rec.name };
89
+ }
90
+ if (rec.kind === "connection" && typeof rec.id === "string" && rec.id !== "") {
91
+ return { kind: "connection", id: rec.id };
92
+ }
93
+ return null;
94
+ }
95
+ function asAttentionRefList(value) {
96
+ if (!Array.isArray(value))
97
+ return [];
98
+ const out = [];
99
+ for (const item of value) {
100
+ const ref = asAttentionRef(item);
101
+ if (ref != null)
102
+ out.push(ref);
103
+ }
104
+ return out;
105
+ }
106
+ function sameRef(a, b) {
107
+ if (a.kind === "driver" && b.kind === "driver")
108
+ return a.name === b.name;
109
+ if (a.kind === "connection" && b.kind === "connection")
110
+ return a.id === b.id;
111
+ return false;
112
+ }
113
+ function refKey(ref) {
114
+ return ref.kind === "driver" ? `driver:${ref.name}` : `connection:${ref.id}`;
115
+ }
116
+ //# sourceMappingURL=attention.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attention.js","sourceRoot":"","sources":["../../src/shared/attention.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAwB,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIpD,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAC1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAUrD,MAAM,UAAU,oBAAoB,CAAC,IAAsB;IACzD,IAAI,mBAAmB,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IAC1E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IAC1D,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC;IAC9B,IAAI,kBAAkB,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;YAAE,SAAS;QACxD,MAAM,GAAG,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI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AAC/E,CAAC","sourcesContent":["/**\n * Attention occupancy. Clients publish on kernel awareness; PEW reduces to\n * none | ambient | focused. Interned connections outlive a session wrap, so\n * occupancy is not session-plane. Drivers read the reduced token — never clientIds.\n */\nimport { FieldAwareness, type PlexusAwareness } from \"@here.build/plexus\";\n\nimport { ConnectionSpec } from \"./models/ConnectionSpec.js\";\nimport { DriverSpec } from \"./models/DriverSpec.js\";\n\nexport type Attention = \"none\" | \"ambient\" | \"focused\";\n\nexport const ATTENTION_LANE = \"attention\";\nexport const ATTENTION_FOCUS_LANE = \"attentionFocus\";\n\nexport type AttentionRef =\n | { readonly kind: \"driver\"; readonly name: string }\n | { readonly kind: \"connection\"; readonly id: string };\n\nexport type AttentionSubject = DriverSpec | ConnectionSpec;\n\nexport type AttentionSource = AttentionSubject | Iterable<AttentionSubject | null | undefined> | null | undefined;\n\nexport function attentionRefFromSpec(spec: AttentionSubject): AttentionRef {\n if (isConnectionSubject(spec)) return { kind: \"connection\", id: spec.id };\n return { kind: \"driver\", name: spec.name };\n}\n\nexport function collectAttentionRefs(source: AttentionSource): AttentionRef[] {\n if (source == null) return [];\n if (isAttentionSubject(source)) return [attentionRefFromSpec(source)];\n const out: AttentionRef[] = [];\n const seen = new Set<string>();\n for (const item of source) {\n if (item == null || !isAttentionSubject(item)) continue;\n const ref = attentionRefFromSpec(item);\n const key = refKey(ref);\n if (seen.has(key)) continue;\n seen.add(key);\n out.push(ref);\n }\n return out;\n}\n\nexport function publishAttention(hub: PlexusAwareness, refs: readonly AttentionRef[]): void {\n const lane = new FieldAwareness(hub, ATTENTION_LANE);\n if (refs.length === 0) {\n lane.clear();\n return;\n }\n lane.set(refs as never);\n}\n\nexport function publishAttentionFocus(hub: PlexusAwareness, ref: AttentionRef | null): void {\n const lane = new FieldAwareness(hub, ATTENTION_FOCUS_LANE);\n if (ref == null) {\n lane.clear();\n return;\n }\n lane.set(ref as never);\n}\n\n/** Union of every client's occupancy. Focused wins over ambient. */\nexport function attentionOf(hub: PlexusAwareness, target: AttentionRef): Attention {\n const focus = new FieldAwareness(hub, ATTENTION_FOCUS_LANE);\n for (const clientId of focus.clientIds) {\n const value = asAttentionRef(focus.getOther(clientId));\n if (value != null && sameRef(value, target)) return \"focused\";\n }\n const ambient = new FieldAwareness(hub, ATTENTION_LANE);\n for (const clientId of ambient.clientIds) {\n const list = asAttentionRefList(ambient.getOther(clientId));\n if (list.some((item) => sameRef(item, target))) return \"ambient\";\n }\n return \"none\";\n}\n\nfunction isConnectionSubject(spec: AttentionSubject): spec is ConnectionSpec {\n if (spec instanceof ConnectionSpec) return true;\n if (spec instanceof DriverSpec) return false;\n return \"driver\" in spec && \"configuration\" in spec;\n}\n\nfunction isAttentionSubject(value: unknown): value is AttentionSubject {\n if (value instanceof ConnectionSpec || value instanceof DriverSpec) return true;\n if (typeof value !== \"object\" || value === null) return false;\n if (\"driver\" in value && \"configuration\" in value) return true;\n return \"importPath\" in value && \"can\" in value;\n}\n\nfunction asAttentionRef(value: unknown): AttentionRef | null {\n if (typeof value !== \"object\" || value === null) return null;\n const rec = value as { kind?: unknown; name?: unknown; id?: unknown };\n if (rec.kind === \"driver\" && typeof rec.name === \"string\" && rec.name !== \"\") {\n return { kind: \"driver\", name: rec.name };\n }\n if (rec.kind === \"connection\" && typeof rec.id === \"string\" && rec.id !== \"\") {\n return { kind: \"connection\", id: rec.id };\n }\n return null;\n}\n\nfunction asAttentionRefList(value: unknown): AttentionRef[] {\n if (!Array.isArray(value)) return [];\n const out: AttentionRef[] = [];\n for (const item of value) {\n const ref = asAttentionRef(item);\n if (ref != null) out.push(ref);\n }\n return out;\n}\n\nfunction sameRef(a: AttentionRef, b: AttentionRef): boolean {\n if (a.kind === \"driver\" && b.kind === \"driver\") return a.name === b.name;\n if (a.kind === \"connection\" && b.kind === \"connection\") return a.id === b.id;\n return false;\n}\n\nfunction refKey(ref: AttentionRef): string {\n return ref.kind === \"driver\" ? `driver:${ref.name}` : `connection:${ref.id}`;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ /** `null` on the entity means not done. Cancel is `failed`, not a fourth state. */
2
+ export type ExpectationOutcome = "successful" | "failed";
3
+ export type EndCause = "settled" | "cancel" | "crash";
4
+ //# sourceMappingURL=control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/shared/control.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEzD,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.js","sourceRoot":"","sources":["../../src/shared/control.ts"],"names":[],"mappings":"","sourcesContent":["/** `null` on the entity means not done. Cancel is `failed`, not a fourth state. */\nexport type ExpectationOutcome = \"successful\" | \"failed\";\n\nexport type EndCause = \"settled\" | \"cancel\" | \"crash\";\n"]}
@@ -0,0 +1,7 @@
1
+ export * from "./models/index.js";
2
+ export * from "./revalidation-demand.js";
3
+ export * from "./control.js";
4
+ export * from "./map-field-awareness.js";
5
+ export * from "./role.js";
6
+ export * from "./types.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./models/index.js";
2
+ export * from "./revalidation-demand.js";
3
+ export * from "./control.js";
4
+ export * from "./map-field-awareness.js";
5
+ export * from "./role.js";
6
+ export * from "./types.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./models/index.js\";\nexport * from \"./revalidation-demand.js\";\nexport * from \"./control.js\";\nexport * from \"./map-field-awareness.js\";\nexport * from \"./role.js\";\nexport * from \"./types.js\";\n"]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * One awareness field as a string-keyed map.
3
+ *
4
+ * Each client owns its map. A write patches the local map. A read is the
5
+ * first present entry across bases, local then others, so a peer's key is
6
+ * visible here. `undefined` means the key is absent; `""` and `null` are
7
+ * stored values.
8
+ *
9
+ * Callers read and write through this lens. A process-local map misses
10
+ * every peer entry.
11
+ */
12
+ import { FieldAwareness, type AwarenessShape, type PlexusAwareness, type ShapeOfAwareness } from "@here.build/plexus";
13
+ export declare class MapFieldAwareness<A extends PlexusAwareness<AwarenessShape> = PlexusAwareness, K extends string & keyof ShapeOfAwareness<A> = string & keyof ShapeOfAwareness<A>> extends FieldAwareness<A, K> {
14
+ #private;
15
+ mapGet(key: string): unknown;
16
+ mapSet(key: string, value: unknown): void;
17
+ mapDelete(key: string): void;
18
+ }
19
+ //# sourceMappingURL=map-field-awareness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-field-awareness.d.ts","sourceRoot":"","sources":["../../src/shared/map-field-awareness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,iBAAiB,CAC5B,CAAC,SAAS,eAAe,CAAC,cAAc,CAAC,GAAG,eAAe,EAC3D,CAAC,SAAS,MAAM,GAAG,MAAM,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,gBAAgB,CAAC,CAAC,CAAC,CACjF,SAAQ,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;IAC5B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAU5B,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAIzC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAmB7B"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * One awareness field as a string-keyed map.
3
+ *
4
+ * Each client owns its map. A write patches the local map. A read is the
5
+ * first present entry across bases, local then others, so a peer's key is
6
+ * visible here. `undefined` means the key is absent; `""` and `null` are
7
+ * stored values.
8
+ *
9
+ * Callers read and write through this lens. A process-local map misses
10
+ * every peer entry.
11
+ */
12
+ import { FieldAwareness, } from "@here.build/plexus";
13
+ export class MapFieldAwareness extends FieldAwareness {
14
+ mapGet(key) {
15
+ const own = readAt(this.get(), key);
16
+ if (own !== undefined)
17
+ return own;
18
+ for (const id of this.clientIds) {
19
+ const value = readAt(this.getOther(id), key);
20
+ if (value !== undefined)
21
+ return value;
22
+ }
23
+ return undefined;
24
+ }
25
+ mapSet(key, value) {
26
+ this.#write({ ...this.#record(), [key]: value });
27
+ }
28
+ mapDelete(key) {
29
+ const current = this.#record();
30
+ if (!(key in current))
31
+ return;
32
+ delete current[key];
33
+ // An empty object is still a published value. The last delete leaves the lane null.
34
+ if (Object.keys(current).length === 0)
35
+ this.clear();
36
+ else
37
+ this.#write(current);
38
+ }
39
+ #record() {
40
+ const value = this.get();
41
+ if (!isRecord(value))
42
+ return {};
43
+ return { ...value };
44
+ }
45
+ /** `set` wants the lane's serializable value. The bag is a plain object. */
46
+ #write(bag) {
47
+ this.set(bag);
48
+ }
49
+ }
50
+ function isRecord(value) {
51
+ return value !== null && typeof value === "object" && !Array.isArray(value);
52
+ }
53
+ function readAt(value, key) {
54
+ if (!isRecord(value) || !(key in value))
55
+ return undefined;
56
+ return value[key];
57
+ }
58
+ //# sourceMappingURL=map-field-awareness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-field-awareness.js","sourceRoot":"","sources":["../../src/shared/map-field-awareness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,cAAc,GAIf,MAAM,oBAAoB,CAAC;AAE5B,MAAM,OAAO,iBAGX,SAAQ,cAAoB;IAC5B,MAAM,CAAC,GAAW;QAChB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QACpC,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,GAAG,CAAC;QAClC,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;YAC7C,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,KAAK,CAAC;QACxC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,GAAW,EAAE,KAAc;QAChC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,SAAS,CAAC,GAAW;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC;YAAE,OAAO;QAC9B,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;QACpB,oFAAoF;QACpF,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC;YAAE,IAAI,CAAC,KAAK,EAAE,CAAC;;YAC/C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO;QACL,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAChC,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,4EAA4E;IAC5E,MAAM,CAAC,GAA4B;QACjC,IAAI,CAAC,GAAG,CAAC,GAA6B,CAAC,CAAC;IAC1C,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,MAAM,CAAC,KAAc,EAAE,GAAW;IACzC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1D,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC","sourcesContent":["/**\n * One awareness field as a string-keyed map.\n *\n * Each client owns its map. A write patches the local map. A read is the\n * first present entry across bases, local then others, so a peer's key is\n * visible here. `undefined` means the key is absent; `\"\"` and `null` are\n * stored values.\n *\n * Callers read and write through this lens. A process-local map misses\n * every peer entry.\n */\nimport {\n FieldAwareness,\n type AwarenessShape,\n type PlexusAwareness,\n type ShapeOfAwareness,\n} from \"@here.build/plexus\";\n\nexport class MapFieldAwareness<\n A extends PlexusAwareness<AwarenessShape> = PlexusAwareness,\n K extends string & keyof ShapeOfAwareness<A> = string & keyof ShapeOfAwareness<A>,\n> extends FieldAwareness<A, K> {\n mapGet(key: string): unknown {\n const own = readAt(this.get(), key);\n if (own !== undefined) return own;\n for (const id of this.clientIds) {\n const value = readAt(this.getOther(id), key);\n if (value !== undefined) return value;\n }\n return undefined;\n }\n\n mapSet(key: string, value: unknown): void {\n this.#write({ ...this.#record(), [key]: value });\n }\n\n mapDelete(key: string): void {\n const current = this.#record();\n if (!(key in current)) return;\n delete current[key];\n // An empty object is still a published value. The last delete leaves the lane null.\n if (Object.keys(current).length === 0) this.clear();\n else this.#write(current);\n }\n\n #record(): Record<string, unknown> {\n const value = this.get();\n if (!isRecord(value)) return {};\n return { ...value };\n }\n\n /** `set` wants the lane's serializable value. The bag is a plain object. */\n #write(bag: Record<string, unknown>): void {\n this.set(bag as ShapeOfAwareness<A>[K]);\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction readAt(value: unknown, key: string): unknown {\n if (!isRecord(value) || !(key in value)) return undefined;\n return value[key];\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { WorkExpectation } from "./WorkExpectation.js";
2
+ export declare abstract class ApprovableExpectation<TResult = unknown, TReport = unknown, TProposal = never> extends WorkExpectation<TResult, TReport, TProposal> {
3
+ accessor policyResult: Record<string, string>;
4
+ accessor policyAsk: Record<string, string>;
5
+ accessor explicitApprovalResult: true | false | null;
6
+ accessor judges: Record<string, WorkExpectation>;
7
+ policyResultOf(id: string): boolean | null;
8
+ writePolicyResult(id: string, value: boolean): void;
9
+ policyAskOf(id: string): boolean;
10
+ writePolicyAsk(id: string): void;
11
+ effectiveApproval(id: string): boolean | null;
12
+ get approvalWork(): readonly WorkExpectation[];
13
+ get work(): readonly WorkExpectation[];
14
+ }
15
+ //# sourceMappingURL=ApprovableExpectation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApprovableExpectation.d.ts","sourceRoot":"","sources":["../../../src/shared/models/ApprovableExpectation.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,8BACsB,qBAAqB,CACzC,OAAO,GAAG,OAAO,EACjB,OAAO,GAAG,OAAO,EACjB,SAAS,GAAG,KAAK,CACjB,SAAQ,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC;IAEpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAGnD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAGhD,QAAQ,CAAC,sBAAsB,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,CAAQ;IAG5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAM;IAEtD,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAKzC;IAED,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAElD;IAED,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE/B;IAED,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE/B;IAED,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAG5C;IAED,IAAI,YAAY,IAAI,SAAS,eAAe,EAAE,CAE7C;IAED,IACa,IAAI,IAAI,SAAS,eAAe,EAAE,CAE9C;CACF"}
@@ -0,0 +1,138 @@
1
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
2
+ var useValue = arguments.length > 2;
3
+ for (var i = 0; i < initializers.length; i++) {
4
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
5
+ }
6
+ return useValue ? value : void 0;
7
+ };
8
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
9
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
10
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
11
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
12
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13
+ var _, done = false;
14
+ for (var i = decorators.length - 1; i >= 0; i--) {
15
+ var context = {};
16
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
17
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
18
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
19
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
20
+ if (kind === "accessor") {
21
+ if (result === void 0) continue;
22
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
23
+ if (_ = accept(result.get)) descriptor.get = _;
24
+ if (_ = accept(result.set)) descriptor.set = _;
25
+ if (_ = accept(result.init)) initializers.unshift(_);
26
+ }
27
+ else if (_ = accept(result)) {
28
+ if (kind === "field") initializers.unshift(_);
29
+ else descriptor[key] = _;
30
+ }
31
+ }
32
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
33
+ done = true;
34
+ };
35
+ /**
36
+ * Work that always runs the approval flow.
37
+ *
38
+ * `id` is an argument — this model does not read SessionRoot. Explicit wins
39
+ * when not null. `judges` is a child record of WorkExpectation so PEW does
40
+ * not import harness (runtime: harness CompletionExpectation).
41
+ *
42
+ * Per-policy facts are string records (`"true"` | `"false"`; absent = unset)
43
+ * because live `@syncing.record` bags are `Record<string, string>`.
44
+ *
45
+ * docs/design/approval.md
46
+ */
47
+ import { syncing } from "@here.build/plexus";
48
+ import { computed } from "mobx";
49
+ import { WorkExpectation } from "./WorkExpectation.js";
50
+ let ApprovableExpectation = (() => {
51
+ var _a, _b, _c;
52
+ let _classDecorators = [syncing("@inhuman.tools/plexus-expectations:ApprovableExpectation")];
53
+ let _classDescriptor;
54
+ let _classExtraInitializers = [];
55
+ let _classThis;
56
+ let _classSuper = WorkExpectation;
57
+ let _instanceExtraInitializers = [];
58
+ let _policyResult_decorators;
59
+ let _policyResult_initializers = [];
60
+ let _policyResult_extraInitializers = [];
61
+ let _policyAsk_decorators;
62
+ let _policyAsk_initializers = [];
63
+ let _policyAsk_extraInitializers = [];
64
+ let _explicitApprovalResult_decorators;
65
+ let _explicitApprovalResult_initializers = [];
66
+ let _explicitApprovalResult_extraInitializers = [];
67
+ let _judges_decorators;
68
+ let _judges_initializers = [];
69
+ let _judges_extraInitializers = [];
70
+ let _get_work_decorators;
71
+ var ApprovableExpectation = class extends _classSuper {
72
+ static { _classThis = this; }
73
+ static {
74
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
75
+ _policyResult_decorators = [(_a = syncing).record.bind(_a)];
76
+ _policyAsk_decorators = [(_b = syncing).record.bind(_b)];
77
+ _explicitApprovalResult_decorators = [syncing];
78
+ _judges_decorators = [(_c = syncing.child).record.bind(_c)];
79
+ _get_work_decorators = [computed];
80
+ __esDecorate(this, null, _policyResult_decorators, { kind: "accessor", name: "policyResult", static: false, private: false, access: { has: obj => "policyResult" in obj, get: obj => obj.policyResult, set: (obj, value) => { obj.policyResult = value; } }, metadata: _metadata }, _policyResult_initializers, _policyResult_extraInitializers);
81
+ __esDecorate(this, null, _policyAsk_decorators, { kind: "accessor", name: "policyAsk", static: false, private: false, access: { has: obj => "policyAsk" in obj, get: obj => obj.policyAsk, set: (obj, value) => { obj.policyAsk = value; } }, metadata: _metadata }, _policyAsk_initializers, _policyAsk_extraInitializers);
82
+ __esDecorate(this, null, _explicitApprovalResult_decorators, { kind: "accessor", name: "explicitApprovalResult", static: false, private: false, access: { has: obj => "explicitApprovalResult" in obj, get: obj => obj.explicitApprovalResult, set: (obj, value) => { obj.explicitApprovalResult = value; } }, metadata: _metadata }, _explicitApprovalResult_initializers, _explicitApprovalResult_extraInitializers);
83
+ __esDecorate(this, null, _judges_decorators, { kind: "accessor", name: "judges", static: false, private: false, access: { has: obj => "judges" in obj, get: obj => obj.judges, set: (obj, value) => { obj.judges = value; } }, metadata: _metadata }, _judges_initializers, _judges_extraInitializers);
84
+ __esDecorate(this, null, _get_work_decorators, { kind: "getter", name: "work", static: false, private: false, access: { has: obj => "work" in obj, get: obj => obj.work }, metadata: _metadata }, null, _instanceExtraInitializers);
85
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
86
+ ApprovableExpectation = _classThis = _classDescriptor.value;
87
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
88
+ __runInitializers(_classThis, _classExtraInitializers);
89
+ }
90
+ #policyResult_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _policyResult_initializers, {}));
91
+ get policyResult() { return this.#policyResult_accessor_storage; }
92
+ set policyResult(value) { this.#policyResult_accessor_storage = value; }
93
+ #policyAsk_accessor_storage = (__runInitializers(this, _policyResult_extraInitializers), __runInitializers(this, _policyAsk_initializers, {}));
94
+ get policyAsk() { return this.#policyAsk_accessor_storage; }
95
+ set policyAsk(value) { this.#policyAsk_accessor_storage = value; }
96
+ #explicitApprovalResult_accessor_storage = (__runInitializers(this, _policyAsk_extraInitializers), __runInitializers(this, _explicitApprovalResult_initializers, null));
97
+ get explicitApprovalResult() { return this.#explicitApprovalResult_accessor_storage; }
98
+ set explicitApprovalResult(value) { this.#explicitApprovalResult_accessor_storage = value; }
99
+ #judges_accessor_storage = (__runInitializers(this, _explicitApprovalResult_extraInitializers), __runInitializers(this, _judges_initializers, {}));
100
+ get judges() { return this.#judges_accessor_storage; }
101
+ set judges(value) { this.#judges_accessor_storage = value; }
102
+ policyResultOf(id) {
103
+ const raw = this.policyResult[id];
104
+ if (raw === "true")
105
+ return true;
106
+ if (raw === "false")
107
+ return false;
108
+ return null;
109
+ }
110
+ writePolicyResult(id, value) {
111
+ this.policyResult[id] = value ? "true" : "false";
112
+ }
113
+ policyAskOf(id) {
114
+ return this.policyAsk[id] === "true";
115
+ }
116
+ writePolicyAsk(id) {
117
+ this.policyAsk[id] = "true";
118
+ }
119
+ effectiveApproval(id) {
120
+ if (this.explicitApprovalResult !== null)
121
+ return this.explicitApprovalResult;
122
+ return this.policyResultOf(id);
123
+ }
124
+ get approvalWork() {
125
+ return Object.values(this.judges);
126
+ }
127
+ get work() {
128
+ return [this, ...this.approvalWork];
129
+ }
130
+ constructor() {
131
+ super(...arguments);
132
+ __runInitializers(this, _judges_extraInitializers);
133
+ }
134
+ };
135
+ return ApprovableExpectation = _classThis;
136
+ })();
137
+ export { ApprovableExpectation };
138
+ //# sourceMappingURL=ApprovableExpectation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApprovableExpectation.js","sourceRoot":"","sources":["../../../src/shared/models/ApprovableExpectation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;IAGjC,qBAAqB;;4BAD1C,OAAO,CAAC,0DAA0D,CAAC;;;;sBAK1D,eAAe;;;;;;;;;;;;;;;qCAAvB,SAAQ,WAA4C;;;;wCACnD,CAAA,KAAA,OAAO,EAAC,MAAM;qCAGd,CAAA,KAAA,OAAO,EAAC,MAAM;kDAGd,OAAO;kCAGP,CAAA,KAAA,OAAO,CAAC,KAAK,EAAC,MAAM;oCA+BpB,QAAQ;YAvCT,yLAAS,YAAY,6BAAZ,YAAY,mGAA8B;YAGnD,gLAAS,SAAS,6BAAT,SAAS,6FAA8B;YAGhD,uNAAS,sBAAsB,6BAAtB,sBAAsB,uHAA6B;YAG5D,uKAAS,MAAM,6BAAN,MAAM,uFAAuC;YA+BtD,mKAAa,IAAI,6DAEhB;YAhDH,6KAiDC;;;YAjDqB,uDAAqB;;QAMzC,kCANoB,mDAA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IAAI,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;QACtC,CAAC;;;;;;;;SAhDmB,qBAAqB","sourcesContent":["/**\n * Work that always runs the approval flow.\n *\n * `id` is an argument — this model does not read SessionRoot. Explicit wins\n * when not null. `judges` is a child record of WorkExpectation so PEW does\n * not import harness (runtime: harness CompletionExpectation).\n *\n * Per-policy facts are string records (`\"true\"` | `\"false\"`; absent = unset)\n * because live `@syncing.record` bags are `Record<string, string>`.\n *\n * docs/design/approval.md\n */\nimport { syncing } from \"@here.build/plexus\";\nimport { computed } from \"mobx\";\n\nimport { WorkExpectation } from \"./WorkExpectation.js\";\n\n@syncing(\"@inhuman.tools/plexus-expectations:ApprovableExpectation\")\nexport abstract class ApprovableExpectation<\n TResult = unknown,\n TReport = unknown,\n TProposal = never,\n> extends WorkExpectation<TResult, TReport, TProposal> {\n @syncing.record\n accessor policyResult: Record<string, string> = {};\n\n @syncing.record\n accessor policyAsk: Record<string, string> = {};\n\n @syncing\n accessor explicitApprovalResult: true | false | null = null;\n\n @syncing.child.record\n accessor judges: Record<string, WorkExpectation> = {};\n\n policyResultOf(id: string): boolean | null {\n const raw = this.policyResult[id];\n if (raw === \"true\") return true;\n if (raw === \"false\") return false;\n return null;\n }\n\n writePolicyResult(id: string, value: boolean): void {\n this.policyResult[id] = value ? \"true\" : \"false\";\n }\n\n policyAskOf(id: string): boolean {\n return this.policyAsk[id] === \"true\";\n }\n\n writePolicyAsk(id: string): void {\n this.policyAsk[id] = \"true\";\n }\n\n effectiveApproval(id: string): boolean | null {\n if (this.explicitApprovalResult !== null) return this.explicitApprovalResult;\n return this.policyResultOf(id);\n }\n\n get approvalWork(): readonly WorkExpectation[] {\n return Object.values(this.judges);\n }\n\n @computed\n override get work(): readonly WorkExpectation[] {\n return [this, ...this.approvalWork];\n }\n}\n"]}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * YAML connection inventory. Settings ride a private synced bag; the public
3
+ * face is {@link configuration} (deep-readonly get, whole-bag set).
4
+ * Secrets never live here. PEW process facts are `readyState` / `error`
5
+ * plus {@link live}. YAML file fill does not touch process facts.
6
+ */
7
+ import { PlexusModel } from "@here.build/plexus";
8
+ import type { ReadyState, SpecCatalog } from "../types.js";
9
+ import { DriverSpec } from "./DriverSpec.js";
10
+ import { type LiveFacts } from "./jsonRecord.js";
11
+ export type ConfigurationAtom = string | number | boolean | null;
12
+ export type ConfigurationValue = ConfigurationAtom | readonly ConfigurationValue[] | {
13
+ readonly [key: string]: ConfigurationValue;
14
+ };
15
+ export type ConnectionConfiguration = {
16
+ readonly [key: string]: ConfigurationValue;
17
+ };
18
+ export declare class ConnectionSpec extends PlexusModel<SpecCatalog | null> {
19
+ #private;
20
+ get id(): string;
21
+ /** Only `failed` is a problem. */
22
+ get issue(): "failed" | false;
23
+ /** YAML `driver:` resolves to this entity. */
24
+ accessor driver: DriverSpec;
25
+ accessor name: string;
26
+ accessor annotation: string;
27
+ private accessor configurationMap;
28
+ /** PEW instance self-report. `null` = never ensured. YAML fill does not touch this. */
29
+ accessor readyState: ReadyState;
30
+ accessor error: string;
31
+ private accessor liveMap;
32
+ /** Frozen through; assign the whole bag to write. */
33
+ get configuration(): ConnectionConfiguration;
34
+ set configuration(settings: Readonly<Record<string, unknown>> | undefined);
35
+ get live(): LiveFacts;
36
+ set live(next: Readonly<Record<string, unknown>> | undefined);
37
+ /** Process self-report. YAML fill does not call this. */
38
+ stampProcess(next: {
39
+ readonly readyState: ReadyState;
40
+ readonly error: string;
41
+ readonly live: Readonly<Record<string, unknown>> | undefined;
42
+ }): void;
43
+ }
44
+ //# sourceMappingURL=ConnectionSpec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionSpec.d.ts","sourceRoot":"","sources":["../../../src/shared/models/ConnectionSpec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,WAAW,EAAW,MAAM,oBAAoB,CAAC;AAG1D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,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