@altopelago/sansa 0.14.2 → 0.15.0-rc.2

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 (156) hide show
  1. package/CHANGELOG.md +118 -1
  2. package/README.md +96 -1
  3. package/conformance/README.md +8 -0
  4. package/conformance/aeonic-anchor-claims.json +133 -0
  5. package/conformance/aeonic-arithmetic-claims.json +60 -0
  6. package/conformance/aeonic-clock-claims.json +123 -0
  7. package/conformance/aeonic-comparison-claims.json +37 -0
  8. package/conformance/aeonic-datetime-claims.json +110 -0
  9. package/conformance/aeonic-rational-arithmetic-claims.json +72 -0
  10. package/conformance/aeonic-temporal-claims.json +105 -0
  11. package/conformance/cts-claims.json +17 -3
  12. package/conformance/results/aeonic-anchor-capacity.json +452 -0
  13. package/conformance/results/aeonic-anchor-snapshot-0.1.json +39 -0
  14. package/conformance/results/aeonic-arithmetic-snapshot-0.1.json +28 -0
  15. package/conformance/results/aeonic-clock-all-snapshot-0.1.json +49 -0
  16. package/conformance/results/aeonic-clock-arithmetic-snapshot-0.1.json +48 -0
  17. package/conformance/results/aeonic-clock-capacity.json +326 -0
  18. package/conformance/results/aeonic-clock-relations-snapshot-0.1.json +48 -0
  19. package/conformance/results/aeonic-comparison-snapshot-0.1.json +19 -0
  20. package/conformance/results/aeonic-datetime-all-snapshot-0.1.json +47 -0
  21. package/conformance/results/aeonic-datetime-arithmetic-snapshot-0.1.json +46 -0
  22. package/conformance/results/aeonic-datetime-capacity.json +302 -0
  23. package/conformance/results/aeonic-datetime-relations-snapshot-0.1.json +46 -0
  24. package/conformance/results/aeonic-rational-arithmetic-capacity.json +100 -0
  25. package/conformance/results/aeonic-rational-arithmetic-snapshot-0.2.json +30 -0
  26. package/conformance/results/aeonic-temporal-all-property-addressing-2026-11-16.json +39 -0
  27. package/conformance/results/aeonic-temporal-all-snapshot-0.1.json +39 -0
  28. package/conformance/results/aeonic-temporal-calendar-property-addressing-2026-11-16.json +38 -0
  29. package/conformance/results/aeonic-temporal-calendar-snapshot-0.1.json +38 -0
  30. package/conformance/results/aeonic-temporal-capacity-property-addressing-2026-11-16.json +136 -0
  31. package/conformance/results/aeonic-temporal-capacity.json +136 -0
  32. package/conformance/results/aeonic-temporal-relations-property-addressing-2026-11-16.json +38 -0
  33. package/conformance/results/aeonic-temporal-relations-snapshot-0.1.json +38 -0
  34. package/docs/aeonic-arithmetic.md +126 -0
  35. package/docs/aeonic-comparison.md +123 -0
  36. package/docs/aeonic-rational-arithmetic.md +167 -0
  37. package/docs/aeonic-temporal-civil-anchor.md +89 -0
  38. package/docs/aeonic-temporal-civil-clock.md +100 -0
  39. package/docs/aeonic-temporal-civil-date.md +124 -0
  40. package/docs/aeonic-temporal-civil-datetime.md +122 -0
  41. package/docs/api-contract.md +130 -3
  42. package/docs/capabilities.json +106 -2
  43. package/docs/child-identity-activation.md +93 -0
  44. package/docs/child-identity-candidate.md +60 -0
  45. package/docs/child-identity-tooling.md +31 -0
  46. package/docs/child-identity-workflows.md +102 -0
  47. package/docs/empty-keys-candidate.md +29 -0
  48. package/docs/migration-0.15.0.md +75 -0
  49. package/docs/property-addressing-implementation.md +118 -0
  50. package/docs/property-resolve-implementation.md +105 -0
  51. package/docs/property-selector-support.md +65 -0
  52. package/docs/property-selectors-api.d.ts +43 -0
  53. package/docs/property-selectors-api.pyi +27 -0
  54. package/docs/property-selectors-api.rs +48 -0
  55. package/docs/property-selectors-contract.md +168 -0
  56. package/docs/query-tool.md +32 -1
  57. package/docs/selector-cursor.md +45 -0
  58. package/docs/unicode-hardening.md +41 -0
  59. package/fixtures/address-v1.json +4 -3
  60. package/fixtures/child-identity-workflows/README.md +9 -0
  61. package/fixtures/child-identity-workflows/moved.aeon +10 -0
  62. package/fixtures/child-identity-workflows/original.aeon +10 -0
  63. package/fixtures/child-identity-workflows/reordered.aeon +10 -0
  64. package/fixtures/child-identity-workflows/replacement.aeon +10 -0
  65. package/fixtures/child-identity-workflows/workflows.json +89 -0
  66. package/fixtures/property-namespace-candidate-v1.json +336 -0
  67. package/fixtures/property-parser-candidate-v1.json +705 -0
  68. package/fixtures/property-query-candidate-v1.json +398 -0
  69. package/fixtures/property-resolve-candidate-v1.json +2702 -0
  70. package/fixtures/unicode-hardening-v1.json +401 -0
  71. package/package.json +30 -3
  72. package/scripts/calibrate-aeonic-anchor-capacity.py +294 -0
  73. package/scripts/calibrate-aeonic-clock-capacity.py +62 -0
  74. package/scripts/calibrate-aeonic-datetime-capacity.py +76 -0
  75. package/scripts/calibrate-aeonic-rational-capacity.py +85 -0
  76. package/scripts/calibrate-aeonic-temporal-capacity.py +95 -0
  77. package/scripts/cts-address.mjs +6 -2
  78. package/scripts/cts-aeonic-anchor.mjs +21 -0
  79. package/scripts/cts-aeonic-arithmetic-adapter.mjs +25 -0
  80. package/scripts/cts-aeonic-arithmetic.mjs +24 -0
  81. package/scripts/cts-aeonic-clock.mjs +24 -0
  82. package/scripts/cts-aeonic-comparison-adapter.mjs +30 -0
  83. package/scripts/cts-aeonic-comparison.mjs +25 -0
  84. package/scripts/cts-aeonic-datetime.mjs +24 -0
  85. package/scripts/cts-aeonic-rational-arithmetic-adapter.mjs +25 -0
  86. package/scripts/cts-aeonic-rational-arithmetic.mjs +24 -0
  87. package/scripts/cts-aeonic-temporal-civil-anchor-adapter.mjs +26 -0
  88. package/scripts/cts-aeonic-temporal-civil-clock-adapter.mjs +28 -0
  89. package/scripts/cts-aeonic-temporal-civil-date-adapter.mjs +28 -0
  90. package/scripts/cts-aeonic-temporal-civil-datetime-adapter.mjs +28 -0
  91. package/scripts/cts-aeonic-temporal.mjs +24 -0
  92. package/scripts/cts-instruction.mjs +4 -2
  93. package/scripts/cts-mutate.mjs +3 -2
  94. package/scripts/cts-resolve.mjs +17 -2
  95. package/scripts/playground.mjs +110 -0
  96. package/src/aeonic-arithmetic-binding.js +61 -0
  97. package/src/aeonic-arithmetic.d.ts +84 -0
  98. package/src/aeonic-arithmetic.js +276 -0
  99. package/src/aeonic-comparison.d.ts +86 -0
  100. package/src/aeonic-comparison.js +274 -0
  101. package/src/aeonic-convenience.d.ts +30 -0
  102. package/src/aeonic-convenience.js +45 -0
  103. package/src/aeonic-exact-number.js +34 -0
  104. package/src/aeonic-json.js +45 -0
  105. package/src/aeonic-rational-arithmetic.d.ts +86 -0
  106. package/src/aeonic-rational-arithmetic.js +417 -0
  107. package/src/aeonic-rational-json.js +51 -0
  108. package/src/aeonic-temporal-civil-anchor.d.ts +54 -0
  109. package/src/aeonic-temporal-civil-anchor.js +316 -0
  110. package/src/aeonic-temporal-civil-clock.d.ts +124 -0
  111. package/src/aeonic-temporal-civil-clock.js +388 -0
  112. package/src/aeonic-temporal-civil-date.d.ts +123 -0
  113. package/src/aeonic-temporal-civil-date.js +310 -0
  114. package/src/aeonic-temporal-civil-datetime.d.ts +138 -0
  115. package/src/aeonic-temporal-civil-datetime.js +501 -0
  116. package/src/index.d.ts +84 -1
  117. package/src/index.js +828 -183
  118. package/src/property-address.js +196 -0
  119. package/src/property-resolve.js +132 -0
  120. package/src/query-metadata.d.ts +16 -0
  121. package/src/query-metadata.js +25 -0
  122. package/src/selector-cursor.d.ts +19 -0
  123. package/src/selector-cursor.js +79 -0
  124. package/stress-tests/address/invalid.sansa-cases +0 -2
  125. package/stress-tests/address/valid.sansa-cases +3 -0
  126. package/tools/mutate-web/examples.mjs +1 -1
  127. package/tools/mutate-web/runtime.mjs +0 -2
  128. package/tools/playground/README.md +165 -0
  129. package/tools/playground/accessibility.js +91 -0
  130. package/tools/playground/aeon-highlight.js +77 -0
  131. package/tools/playground/aeon-source-composer.js +1077 -0
  132. package/tools/playground/anchor-examples.mjs +16 -0
  133. package/tools/playground/arithmetic-evaluator.mjs +28 -0
  134. package/tools/playground/arithmetic-model.mjs +187 -0
  135. package/tools/playground/arithmetic-worker.mjs +14 -0
  136. package/tools/playground/arithmetic.css +1 -0
  137. package/tools/playground/arithmetic.html +29 -0
  138. package/tools/playground/arithmetic.mjs +110 -0
  139. package/tools/playground/clock-examples.mjs +16 -0
  140. package/tools/playground/datetime-examples.mjs +22 -0
  141. package/tools/playground/examples.mjs +46 -0
  142. package/tools/playground/index.html +174 -0
  143. package/tools/playground/local.css +25 -0
  144. package/tools/playground/namespace.mjs +39 -0
  145. package/tools/playground/sansa-playground.js +1565 -0
  146. package/tools/playground/site.css +3914 -0
  147. package/tools/playground/temporal-examples.mjs +20 -0
  148. package/tools/playground/walkthrough.js +90 -0
  149. package/tools/playground/website-origin.json +16 -0
  150. package/tools/query-web/IDENTITY_SELECTORS.md +44 -0
  151. package/tools/query-web/app.js +4 -0
  152. package/tools/query-web/index.html +4 -0
  153. package/tools/query-web/runtime.mjs +70 -19
  154. package/tools/workflows/property-playground-assertions.mjs +33 -0
  155. package/tools/workflows/verify-child-identities.mjs +137 -0
  156. package/tools/workflows/verify-property-playground.mjs +48 -0
@@ -0,0 +1,20 @@
1
+ const civil = value => ({ temporal: { category: 'civilDate', value } });
2
+ const dates = ranges => ({ temporal: { category: 'civilDateSet', ranges: ranges.map(([start, end]) => ({ start, end })) }, originGranularity: 'month', history: 'none-declared' });
3
+ const temporalRequest = (operation, left, right, policy) => ({ operation, input: {
4
+ ...(['shift', 'step', 'materialize'].includes(operation) ? { value: left } : { left, right }),
5
+ context: { profile: 'aeonic.operations.temporal.civil-date.v1' }, ...(policy ? { policy } : {}),
6
+ } });
7
+ export const TEMPORAL_EXAMPLES = [
8
+ { id: 'date-month-shift', lane: 'temporal', title: 'Shift February’s dates', detail: 'February 2024 shifted by one calendar month covers March 1–29. Reuse this precise bundle to shift again or compare it.', request: temporalRequest('shift', civil('2024-02'), undefined, { unit: 'month', count: '1' }) },
9
+ { id: 'date-month-step', lane: 'temporal', title: 'Step the month period', detail: 'Stepping the complete February period gives all of March. This intentionally differs from a date-wise shift.', request: temporalRequest('step', civil('2024-02'), undefined, { granularity: 'month', count: '1' }) },
10
+ { id: 'date-month-day', lane: 'temporal', title: 'Same day next month', detail: 'February 28 plus one calendar month is March 28.', request: temporalRequest('shift', civil('2024-02-28'), undefined, { unit: 'month', count: '1' }) },
11
+ { id: 'date-eom', lane: 'temporal', title: 'Distance from month-end', detail: 'February 27, 2023 is one day before month-end. One EOM shift gives March 30.', request: temporalRequest('shift', civil('2023-02-27'), undefined, { unit: 'eom', count: '1' }) },
12
+ { id: 'date-eoy', lane: 'temporal', title: 'Distance from year-end', detail: 'One EOY shift maps February 28, 2023 to February 29, 2024. An ordinary year shift would give February 28.', request: temporalRequest('shift', civil('2023-02-28'), undefined, { unit: 'eoy', count: '1' }) },
13
+ { id: 'date-clamping', lane: 'temporal', title: 'Clamp and retain history', detail: 'January 31 shifts to February 28. Shift the result again: current clamping changes, while the earlier marker remains.', request: temporalRequest('shift', civil('2023-01-31'), undefined, { unit: 'month', count: '1' }) },
14
+ { id: 'date-direct', lane: 'temporal', title: 'Two months, one clamp', detail: 'A direct two-month shift gives March 31. Two separate one-month shifts give March 28.', request: temporalRequest('shift', civil('2023-01-31'), undefined, { unit: 'month', count: '2' }) },
15
+ { id: 'date-materialize', lane: 'temporal', title: 'Materialize an exact month', detail: 'A complete March range can materialize as 2024-03. Its declared origin and clamping history remain separate.', request: temporalRequest('materialize', dates([['2024-03-01', '2024-03-31']]), undefined, { granularity: 'month' }) },
16
+ { id: 'date-partial-output', lane: 'temporal', title: 'A containing label loses dates', detail: 'March 1–29 cannot materialize as the whole month. The diagnostic produces no value; the exact input bundle remains available.', request: temporalRequest('materialize', dates([['2024-03-01', '2024-03-29']]), undefined, { granularity: 'month' }) },
17
+ { id: 'date-containment', lane: 'temporal', title: 'A year contains a day', detail: '2024- contains January 1, 2024. They are different exact sets and do not compare equal.', request: temporalRequest('relate', civil('2024-'), civil('2024-01-01')) },
18
+ { id: 'date-indeterminate', lane: 'temporal', title: 'Chronology can be indeterminate', detail: 'March and March 15 overlap. Whole-set chronology returns |indeterminate|; relate returns |contains|.', request: temporalRequest('compare', civil('2024-03'), civil('2024-03-15')) },
19
+ { id: 'date-disjoint-gaps', lane: 'temporal', title: 'Disjoint, yet interleaved', detail: 'March 1 and 3 are disjoint from March 2. Chronological comparison is still indeterminate.', request: temporalRequest('relate', dates([['2024-03-01', '2024-03-01'], ['2024-03-03', '2024-03-03']]), civil('2024-03-02')) },
20
+ ];
@@ -0,0 +1,90 @@
1
+ document.addEventListener("DOMContentLoaded", () => {
2
+ if (!window.AeonWebHighlight) {
3
+ return;
4
+ }
5
+
6
+ window.AeonWebHighlight.renderStaticBlocks();
7
+
8
+ let runtimeReady = null;
9
+
10
+ function loadRuntime() {
11
+ if (!runtimeReady) {
12
+ runtimeReady = import("@aeon/runtime").catch((error) => ({ error }));
13
+ }
14
+ return runtimeReady;
15
+ }
16
+
17
+ function diagnosticLine(diagnostic) {
18
+ const label = diagnostic?.level === "warning" ? "Warning" : "Issue";
19
+ const code = diagnostic?.code ? `${diagnostic.code}: ` : "";
20
+ return `${label}: ${code}${diagnostic?.message ?? "Unable to validate source."}`;
21
+ }
22
+
23
+ function setStatus(status, message, state = "neutral") {
24
+ status.textContent = message;
25
+ status.dataset.state = state;
26
+ }
27
+
28
+ async function verifyEditor(textarea, status, requestIdRef) {
29
+ const requestId = ++requestIdRef.current;
30
+ setStatus(status, "Checking...");
31
+
32
+ try {
33
+ const runtime = await loadRuntime();
34
+ if (requestId !== requestIdRef.current) {
35
+ return;
36
+ }
37
+ if (runtime.error) {
38
+ throw runtime.error;
39
+ }
40
+
41
+ const result = runtime.runRuntime(textarea.value, {
42
+ mode: "loose",
43
+ datatypePolicy: "reserved_only",
44
+ includeAnnotations: true,
45
+ output: "json"
46
+ });
47
+ const issue = result.meta?.errors?.[0] ?? result.meta?.warnings?.[0] ?? null;
48
+ setStatus(
49
+ status,
50
+ issue ? diagnosticLine(issue) : "No issues detected.",
51
+ issue ? "issue" : "ok"
52
+ );
53
+ } catch (error) {
54
+ if (requestId !== requestIdRef.current) {
55
+ return;
56
+ }
57
+ setStatus(status, error instanceof Error ? `Issue: ${error.message}` : `Issue: ${String(error)}`, "issue");
58
+ }
59
+ }
60
+
61
+ document.querySelectorAll("[data-aeon-editor]").forEach((editor) => {
62
+ const textarea = editor.querySelector("textarea");
63
+ const backdrop = editor.querySelector(".highlight-backdrop");
64
+ if (!textarea || !backdrop) {
65
+ return;
66
+ }
67
+
68
+ window.AeonWebHighlight.attachHighlightEditor(textarea, backdrop);
69
+
70
+ if (!editor.hasAttribute("data-aeon-verify")) {
71
+ return;
72
+ }
73
+
74
+ const status = editor.closest(".walkthrough-editor-card")?.querySelector("[data-aeon-editor-status]");
75
+ if (!status) {
76
+ return;
77
+ }
78
+
79
+ const requestIdRef = { current: 0 };
80
+ const scheduleVerify = () => {
81
+ window.clearTimeout(editor._aeonVerifyTimer);
82
+ editor._aeonVerifyTimer = window.setTimeout(() => {
83
+ verifyEditor(textarea, status, requestIdRef);
84
+ }, 160);
85
+ };
86
+
87
+ textarea.addEventListener("input", scheduleVerify);
88
+ verifyEditor(textarea, status, requestIdRef);
89
+ });
90
+ });
@@ -0,0 +1,16 @@
1
+ {
2
+ "sourceRepository": "AltoPelago/aeon-website",
3
+ "revision": "632d2fb2785bb16a03182d1281a165e1e4b55e78",
4
+ "sourceFiles": {
5
+ "html/assets/css/site.css": "6777f2970518e18580ae58168519f4ecd7c00b6efdcd05654ebb15f8021a5a60",
6
+ "html/assets/js/aeon-highlight.js": "20406247bcdff481d6e680daacdcc35733d4870e4cbae3661da0d9a8c25da299",
7
+ "html/assets/js/walkthrough.js": "70f55344ca77f29b44172ee5baa3917f2b75782090fa843be3e4f437ae2c7448",
8
+ "html/assets/js/aeon-source-composer.js": "c0875592af952f6ae13a707dafacc55a68dcc9964f4df25f7ffb519b35c71509",
9
+ "html/assets/js/sansa-playground.js": "465421d851826f79f7f52242d05f9fd0ff4c0ce4836e0bee1c4c32138edd17b2",
10
+ "html/sansa-playground.php": "179c9c65e89ae01a40fcc39bb7bad47c141c064367183ca9de1bc82f458ce693",
11
+ "content/sansa-playground.aeon": "242de737de0afb7cda46d3e18f321294adcbda20ee8d053fdc20fac430ffc707",
12
+ "html/assets/js/site.js": "5853e68ab5983b10e822c91156e3d65608df5b20cb86234054824e072a29c49f"
13
+ },
14
+ "adaptation": "Static HTML shell, direct SANSA source import, shared SDK namespace/Resolve, local examples and scope/budget controls. Website source remains unchanged.",
15
+ "accessibilityExtraction": "Modal focus state/functions and keyboard trap only; website search/navigation code excluded."
16
+ }
@@ -0,0 +1,44 @@
1
+ # Child identities in the Query workbench (candidate)
2
+
3
+ Read-only Query sources and address expressions accept authored child identities:
4
+
5
+ ```aeon
6
+ group\g\:object = { child\c\:string = "hello" }
7
+ ```
8
+
9
+ ```sansa
10
+ from $.\g\ select .\c\
11
+ ```
12
+
13
+ The result retains `$.group.child`. This is child traversal, not a global ID
14
+ lookup. AEON identity queries project complete portable occurrence topology,
15
+ including distinct NodeLiteral/NodeHead IDs and explicit attribute spaces.
16
+ Ordinary queries and the default `namespaceFromAeonSource` helper retain their
17
+ existing native adapter behavior. The helper's opt-in `{identityAware: true}`
18
+ uses the same projection as identity-containing queries. An incompatible runtime
19
+ fails explicitly; identity-looking text inside a quoted string is not an opt-in.
20
+
21
+ Telex and the existing Film reader expose declared portable record identities.
22
+ The browser offers AEON, Telex and JSON inputs; no Film editor or writer is added.
23
+ JSON fixture `identity` fields remain opaque and do not grant structural identity
24
+ capability. Params authored as AEON expose declared IDs in the params local space
25
+ when used by an identity query. Existing local-space navigation remains in place.
26
+
27
+ The Identity inspections control maps to `budget.maxIdentityInspections` in the
28
+ existing workbench request, then to Query's `resolve.maxIdentityInspections`.
29
+ Default 10,000; nonnegative safe integers only. One query shares its counter
30
+ across clauses, candidates, repeated reads and params. Misses and absent IDs cost
31
+ inspections; failure discards all results. JSON output retains diagnostic limit,
32
+ observed and authored-identity context. Existing other budget fields keep their
33
+ previous behavior. A new request starts fresh.
34
+
35
+ Trusted `path(...)` activation, Instruction and mutation do not gain identity
36
+ admission. AEON reference targets and canonical storage/event paths stay
37
+ structural. There is no new recursive/root selector or global index.
38
+
39
+ Use a compatible installed AEON Core/AES package in the calling project, or the
40
+ existing `SANSA_AEON_CORE_MODULE` / `SANSA_AEON_AES_MODULE` overrides. The development
41
+ sibling layout also works. Run `npm run query:web` and open the printed localhost
42
+ URL. These are local candidate capabilities; official release, final dependency
43
+ pins, independent review and remaining platform checks are separate work. No new
44
+ performance qualification is claimed; retained JS heap remains deferred.
@@ -278,6 +278,10 @@ function queryPolicy() {
278
278
  function queryBudget() {
279
279
  const budget = {};
280
280
  for (const input of budgetInputs) {
281
+ if (input.id === 'maxIdentityInspections' && input.value.trim()) {
282
+ budget[input.id] = Number(input.value);
283
+ continue;
284
+ }
281
285
  const value = parseBudgetInput(input.value);
282
286
  if (value !== undefined) budget[input.id] = value;
283
287
  }
@@ -101,6 +101,10 @@
101
101
  </div>
102
102
 
103
103
  <div class="budget-row" role="group" aria-label="Evaluation budgets">
104
+ <label>
105
+ Identity inspections
106
+ <input type="number" id="maxIdentityInspections" min="0" step="1" inputmode="numeric" placeholder="10000">
107
+ </label>
104
108
  <label>
105
109
  From
106
110
  <input type="number" id="maxFromBindings" min="0" step="1" inputmode="numeric">
@@ -41,6 +41,9 @@ export async function evaluateQueryForWorkbench({
41
41
  valueSemantics = '',
42
42
  budget = {},
43
43
  }) {
44
+ // Keep the legacy native adapter for ordinary queries. Identity expressions
45
+ // opt into complete portable occurrence topology, including NodeHead levels.
46
+ const identityAware = queryUsesChildIdentity(query);
44
47
  let namespaceResult;
45
48
  if (sourceKind === 'json') {
46
49
  namespaceResult = namespaceFromJsonSource(source);
@@ -49,14 +52,14 @@ export async function evaluateQueryForWorkbench({
49
52
  } else if (sourceKind === 'film') {
50
53
  namespaceResult = await namespaceFromFilmSource(source);
51
54
  } else {
52
- namespaceResult = await namespaceFromAeonSource(source);
55
+ namespaceResult = await namespaceFromAeonSource(source, { identityAware });
53
56
  }
54
57
 
55
58
  if (!namespaceResult.ok) {
56
59
  return namespaceResult;
57
60
  }
58
61
 
59
- const mounted = await mountParamsLocalSpace(namespaceResult.namespace, paramsSource);
62
+ const mounted = await mountParamsLocalSpace(namespaceResult.namespace, paramsSource, { identityAware });
60
63
  if (!mounted.ok) {
61
64
  return {
62
65
  ...mounted,
@@ -139,7 +142,7 @@ export function namespaceFromJsonSource(source) {
139
142
  }
140
143
  }
141
144
 
142
- export async function namespaceFromAeonSource(source) {
145
+ export async function namespaceFromAeonSource(source, { identityAware = false } = {}) {
143
146
  const loaded = await loadAeonCore();
144
147
  if (!loaded.ok) {
145
148
  const errors = [{
@@ -173,6 +176,15 @@ export async function namespaceFromAeonSource(source) {
173
176
  };
174
177
  }
175
178
 
179
+ if (identityAware) {
180
+ try {
181
+ if (typeof aeonCore.projectPortableEvents !== 'function') throw new Error('The selected AEON runtime does not expose complete portable projection.');
182
+ return { ok: true, namespace: buildNamespaceFromPortableRecords(aeonCore.projectPortableEvents(compiled.events)), diagnostics: [] };
183
+ } catch (error) {
184
+ const errors = [{ code: 'SANSA_QUERY_WORKBENCH_IDENTITY_ADAPTER_UNAVAILABLE', message: error.message }];
185
+ return { ok: false, mode: 'evaluate', sourceKind: 'aeon', errors, text: renderDiagnosticText(errors) };
186
+ }
187
+ }
176
188
  return {
177
189
  ok: true,
178
190
  namespace: buildNamespaceFromEvents(compiled.events, aeonCore.formatPath),
@@ -381,7 +393,7 @@ export async function namespaceFromFilmSource(source) {
381
393
  }
382
394
  }
383
395
 
384
- async function mountParamsLocalSpace(namespace, paramsSource) {
396
+ async function mountParamsLocalSpace(namespace, paramsSource, { identityAware = false } = {}) {
385
397
  if (String(paramsSource).trim().length === 0) {
386
398
  return { ok: true, namespace, diagnostics: [] };
387
399
  }
@@ -420,8 +432,18 @@ async function mountParamsLocalSpace(namespace, paramsSource) {
420
432
  };
421
433
  }
422
434
 
423
- const paramsNamespace = buildNamespaceFromEvents(compiled.events, aeonCore.formatPath);
424
- const paramsBinding = remapLocalSpaceBinding(paramsNamespace.root, '$.<"params">');
435
+ let paramsNamespace;
436
+ try {
437
+ paramsNamespace = identityAware
438
+ ? buildNamespaceFromPortableRecords(aeonCore.projectPortableEvents(compiled.events))
439
+ : buildNamespaceFromEvents(compiled.events, aeonCore.formatPath);
440
+ } catch (error) {
441
+ const errors = [{ code: 'SANSA_QUERY_WORKBENCH_IDENTITY_ADAPTER_UNAVAILABLE', message: error.message }];
442
+ return { ok: false, mode: 'evaluate', errors, text: renderDiagnosticText(errors) };
443
+ }
444
+ const paramsIdentity = paramsNamespace.identity;
445
+ const paramsOrigins = typeof paramsIdentity === 'function' ? new WeakMap() : undefined;
446
+ const paramsBinding = remapLocalSpaceBinding(paramsNamespace.root, '$.<"params">', paramsOrigins);
425
447
  const root = typeof namespace.root === 'function' ? namespace.root() : namespace.root;
426
448
  if (!root) {
427
449
  const errors = [{
@@ -441,11 +463,19 @@ async function mountParamsLocalSpace(namespace, paramsSource) {
441
463
  params: paramsBinding,
442
464
  };
443
465
  const localSpace = namespace.localSpace;
466
+ const sourceIdentity = namespace.identity;
444
467
 
445
468
  return {
446
469
  ok: true,
447
470
  namespace: {
448
471
  ...namespace,
472
+ ...(paramsOrigins ? {
473
+ identity: (binding) => {
474
+ const original = paramsOrigins.get(binding);
475
+ if (original !== undefined) return paramsIdentity.call(paramsNamespace, original);
476
+ return typeof sourceIdentity === 'function' ? sourceIdentity.call(namespace, binding) : undefined;
477
+ },
478
+ } : {}),
449
479
  localSpace: (binding, name) => {
450
480
  if (binding === root && name === 'params') return root.localSpaces?.params;
451
481
  return localSpace?.(binding, name) ?? binding.localSpaces?.[name];
@@ -648,27 +678,27 @@ function caughtErrorMessage(error) {
648
678
  }
649
679
  }
650
680
 
651
- function remapLocalSpaceBinding(binding, targetAddress) {
652
- return remapBindingTree({
653
- ...binding,
654
- address: '$',
655
- representationKind: binding.representationKind ?? 'object',
656
- }, '$', targetAddress);
681
+ function remapLocalSpaceBinding(binding, targetAddress, origins) {
682
+ const output = remapBindingTree(binding, '$', targetAddress, origins);
683
+ output.address = targetAddress;
684
+ output.representationKind ??= 'object';
685
+ return output;
657
686
  }
658
687
 
659
- function remapBindingTree(binding, sourceBase, targetBase) {
688
+ function remapBindingTree(binding, sourceBase, targetBase, origins) {
660
689
  const address = remapAddress(binding.address, sourceBase, targetBase);
661
690
  const output = {
662
691
  ...binding,
663
692
  address,
664
- children: (binding.children ?? []).map((child) => remapBindingTree(child, sourceBase, targetBase)),
693
+ children: (binding.children ?? []).map((child) => remapBindingTree(child, sourceBase, targetBase, origins)),
665
694
  };
695
+ origins?.set(output, binding);
666
696
  if (binding.attributeSpace) {
667
- output.attributeSpace = remapBindingTree(binding.attributeSpace, sourceBase, targetBase);
697
+ output.attributeSpace = remapBindingTree(binding.attributeSpace, sourceBase, targetBase, origins);
668
698
  }
669
699
  if (binding.localSpaces) {
670
700
  output.localSpaces = Object.fromEntries(Object.entries(binding.localSpaces).map(([name, localSpace]) => (
671
- [name, remapBindingTree(localSpace, sourceBase, targetBase)]
701
+ [name, remapBindingTree(localSpace, sourceBase, targetBase, origins)]
672
702
  )));
673
703
  }
674
704
  return output;
@@ -857,6 +887,9 @@ function buildNamespaceFromPortableRecords(records) {
857
887
 
858
888
  return {
859
889
  root,
890
+ // Portable record.identity is declared structural metadata. JSON fixture
891
+ // identity fields remain opaque and do not acquire this capability.
892
+ identity: (binding) => binding.identity,
860
893
  children: (binding) => binding.children ?? [],
861
894
  attributeSpace: (binding) => binding.attributeSpace,
862
895
  localSpace: (binding, name) => binding.localSpaces?.[name],
@@ -1198,9 +1231,9 @@ function radixBaseFromPortableRecord(record) {
1198
1231
 
1199
1232
  function radixBaseFromSemanticType(semanticType) {
1200
1233
  if (typeof semanticType !== 'string') return undefined;
1201
- const normalized = semanticType.trim().toLowerCase();
1234
+ const normalized = semanticType.trim();
1202
1235
  if (normalized === 'decimal') return 10;
1203
- const alias = /^radix(2|6|8|12)$/u.exec(normalized);
1236
+ const alias = /^radix(2|6|8|12|16)$/u.exec(normalized);
1204
1237
  if (alias !== null) return Number(alias[1]);
1205
1238
  const clarified = /^radix\[(\d+)\]$/u.exec(normalized);
1206
1239
  if (clarified === null) return undefined;
@@ -1518,6 +1551,7 @@ function normalizeDiagnostics(errors) {
1518
1551
  ...(Number.isSafeInteger(error.observed) ? { observed: error.observed } : {}),
1519
1552
  ...(Number.isInteger(error.index) ? { index: error.index } : {}),
1520
1553
  ...(Number.isInteger(error.selectorIndex) ? { selectorIndex: error.selectorIndex } : {}),
1554
+ ...(typeof error.identity === 'string' ? { identity: error.identity } : {}),
1521
1555
  }));
1522
1556
  }
1523
1557
 
@@ -1528,7 +1562,24 @@ function queryBudgetOption(value) {
1528
1562
  const limit = value[key];
1529
1563
  if (Number.isSafeInteger(limit) && limit >= 0) budget[key] = limit;
1530
1564
  }
1531
- return Object.keys(budget).length === 0 ? {} : { budget };
1565
+ return {
1566
+ ...(Object.keys(budget).length === 0 ? {} : { budget }),
1567
+ ...(Object.hasOwn(value, 'maxIdentityInspections')
1568
+ ? { resolve: { maxIdentityInspections: value.maxIdentityInspections } } : {}),
1569
+ };
1570
+ }
1571
+
1572
+ function queryUsesChildIdentity(source) {
1573
+ const parsed = parseQuery(source);
1574
+ if (!parsed.ok) return false;
1575
+ const pending = [parsed.query];
1576
+ while (pending.length) {
1577
+ const value = pending.pop();
1578
+ if (!value || typeof value !== 'object') continue;
1579
+ if (value.type === 'SansaAddress' && value.selectors?.some(selector => selector.type === 'childIdentity')) return true;
1580
+ pending.push(...Object.values(value));
1581
+ }
1582
+ return false;
1532
1583
  }
1533
1584
 
1534
1585
  function normalizeAeonError(error) {
@@ -0,0 +1,33 @@
1
+ import assert from 'node:assert/strict';
2
+ import {resolveAddress} from '../../src/index.js';
3
+ import {selectionRows} from '../playground/namespace.mjs';
4
+
5
+ export function verifyPropertySelection(selected, example, owner, rows, id) {
6
+ assert.equal(selected.ok, true, id);
7
+ const original = binding => {
8
+ const exact = resolveAddress(binding.address, owner);
9
+ assert.equal(exact.ok, true, id);
10
+ assert.equal(exact.bindings.length, 1, id);
11
+ assert.equal(binding, exact.bindings[0], id);
12
+ };
13
+ const project = bindings => {
14
+ const projected = selectionRows({bindings}, rows);
15
+ for (let i = 0; i < bindings.length; i++) {
16
+ assert.equal(projected[i].binding, bindings[i], id);
17
+ original(bindings[i]);
18
+ }
19
+ };
20
+ if (example.view === 'query') {
21
+ assert.deepEqual(selected.results.map(entry => entry.candidateAddress), example.expectedCandidatePaths, id);
22
+ for (const entry of selected.results) {
23
+ assert.equal(entry.binding.address, entry.candidateAddress, id);
24
+ original(entry.binding);
25
+ assert.equal(entry.value.type, 'bindingSet', id);
26
+ project(entry.value.bindings);
27
+ }
28
+ assert.deepEqual(selected.results.flatMap(entry => entry.value.bindings.map(binding => binding.address)), example.expectedQueryPaths, id);
29
+ } else {
30
+ assert.deepEqual(selected.bindings.map(binding => binding.address), example.expectedPaths, id);
31
+ project(selected.bindings);
32
+ }
33
+ }
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env node
2
+ import assert from 'node:assert/strict';
3
+ import {readFileSync} from 'node:fs';
4
+ import {evaluateQuery,parseAddress,planMutation,planInstruction,resolveAddress} from '../../src/index.js';
5
+ import {rowsFromNamespace,scopedNamespace,selectionRows} from '../playground/namespace.mjs';
6
+ import {evaluateQueryForWorkbench} from '../query-web/runtime.mjs';
7
+
8
+ // This tool deliberately needs an explicitly selected coordinated candidate.
9
+ // It performs no install, mutation, ordering operation or reference rewriting.
10
+ const manifest = process.argv[2];
11
+ if (!manifest) throw new Error('Usage: node tools/workflows/verify-child-identities.mjs <candidate-modules.json>');
12
+ const paths = JSON.parse(readFileSync(manifest,'utf8'));
13
+ for (const name of ['core','canonical','aes','sdk','aeos','titonic']) {
14
+ assert.equal(typeof paths[name],'string',`Missing candidate module: ${name}`);
15
+ assert.ok(paths[name].startsWith('file:'),`Use an explicit file URL for ${name}`);
16
+ }
17
+ const [core,canonical,aes,sdk,aeos,titonic] = await Promise.all(['core','canonical','aes','sdk','aeos','titonic'].map(name=>import(paths[name])));
18
+ const suite = JSON.parse(readFileSync(new URL('../../fixtures/child-identity-workflows/workflows.json',import.meta.url)));
19
+ const snapshots = new Map();
20
+ const report={snapshots:[],checks:{resolve:0,query:0,activation:0,aeos:0,titonic:0,workbench:0,canonicalization:0,references:0,boundaries:0}};
21
+ const samePaths=(bindings,expected)=>assert.deepEqual(bindings.map(b=>b.address),expected);
22
+ for (const item of suite.snapshots) {
23
+ const source=readFileSync(new URL(`../../fixtures/child-identity-workflows/${item.source}`,import.meta.url),'utf8');
24
+ const compiled=core.compile(source);assert.deepEqual(compiled.errors,[],item.id);
25
+ const namespace=sdk.createAeonNamespace(compiled.events,{scope:'payload',sourceBytes:new TextEncoder().encode(source)});
26
+ const selected=resolveAddress(item.selector,namespace);assert.equal(selected.ok,true,JSON.stringify(selected.errors));
27
+ samePaths(selected.bindings,[item.namePath]);assert.equal(selected.bindings[0].value,item.nameValue);
28
+ assert.equal(selected.bindings[0],resolveAddress(item.namePath,namespace).bindings[0]);
29
+ assert.equal(parseAddress(item.selector).address.isExact,false);
30
+ const scoped=scopedNamespace(namespace,item.subtree);
31
+ assert.equal(resolveAddress('$',scoped).bindings[0].representationKind,'ObjectNode');
32
+ samePaths(resolveAddress(suite.scopedSelf,scoped).bindings,[]);
33
+ samePaths(resolveAddress('$.\\stock1\\',namespace).bindings,[]);
34
+ samePaths(resolveAddress(suite.scopedSelector,scoped).bindings,[item.namePath]);
35
+ samePaths(resolveAddress(suite.contextualSelector,scoped).bindings,[item.namePath]);
36
+ assert.equal(selectionRows(selected,rowsFromNamespace(namespace))[0].binding,selected.bindings[0]);report.checks.resolve++;
37
+
38
+ const query=`from ${item.subtree}.items.*\nselect .\\name1\\`;
39
+ const result=evaluateQuery(query,namespace);assert.equal(result.ok,true,JSON.stringify(result.errors));
40
+ assert.deepEqual(result.results.map(r=>r.value.bindings.map(b=>b.address)),item.projected);
41
+ const filtered=evaluateQuery(`from ${item.subtree}.items.*\nwhere exists(.\\name1\\)\nselect .\\name1\\`,namespace);
42
+ assert.equal(filtered.ok,true);assert.deepEqual(filtered.results.map(r=>r.valueAddress),[item.namePath]);
43
+ for(let repeat=0;repeat<2;repeat++) {
44
+ const limited=evaluateQuery(`from ${item.selector}\nselect .`,namespace,{resolve:{maxIdentityInspections:3}});
45
+ assert.equal(limited.ok,false);assert.deepEqual(limited.results,[]);assert.equal(limited.errors[0].code,'SANSA_RESOLVE_IDENTITY_LIMIT_EXCEEDED');
46
+ assert.equal(evaluateQuery(`from ${item.selector}\nselect .`,namespace,{resolve:{maxIdentityInspections:4}}).ok,true);
47
+ }report.checks.query++;
48
+
49
+ const activation={allowedRoots:[item.parent],allowedSelectors:['member','position','childIdentity'],allowContextualRoot:false};
50
+ const activated=evaluateQuery('from $\nselect path($.selection)',namespace,{addressActivation:activation});
51
+ assert.equal(activated.ok,true,JSON.stringify(activated.errors));samePaths(activated.results[0].value.bindings,[item.namePath]);
52
+ for(const addressActivation of [undefined,'trusted']) {
53
+ const denied=evaluateQuery('from $\nselect path($.selection)',namespace,addressActivation===undefined?{}:{addressActivation});
54
+ assert.equal(denied.ok,false);assert.deepEqual(denied.results,[]);
55
+ }report.checks.activation++;
56
+
57
+ const schema={rules:[{selector:item.selector,constraints:{required:true,type:'StringLiteral'}}]};
58
+ const records=aes.projectPortableEvents(compiled.events);
59
+ assert.equal(records.every(record=>!record.path.includes('\\')),true);
60
+ const wire=aes.encodeTelex(records);
61
+ assert.deepEqual(aes.parseTelex(wire).records,records);
62
+ const bad={rules:[{selector:item.selector,constraints:{required:true,type:'NumberLiteral'}}]};
63
+ for(const [events,goodSchema,badSchema] of [[compiled.events,schema,bad],[records,schema,bad]]) {
64
+ assert.equal(aeos.validate(events,goodSchema).ok,true);
65
+ const failed=aeos.validate(events,badSchema);assert.equal(failed.ok,false);
66
+ assert.ok(failed.errors.some(e=>e.code==='type_mismatch'&&e.path===item.namePath),JSON.stringify(failed.errors));
67
+ }
68
+ assert.equal(aeos.validateTelex(wire,schema).ok,true);
69
+ const deniedPath=aeos.validate(compiled.events,{rules:[{path:item.selector,constraints:{}}]});
70
+ assert.equal(deniedPath.ok,false);report.checks.aeos++;
71
+
72
+ const document=titonic.createTitonicFromAeon(source,{requireStrictMode:false});
73
+ const got=titonic.resolveTitonicAddress(document,item.selector);assert.deepEqual(got.diagnostics,[]);
74
+ assert.deepEqual(got.bindings.map(b=>b.pathText),[item.namePath]);assert.equal(got.bindings[0].value,item.nameValue);
75
+ const contextPath=item.subtree.slice(2).split('.');
76
+ assert.deepEqual(titonic.resolveTitonicAddress(document,'?.\\stock1\\',{contextPath}).bindings,[]);
77
+ const contextual=titonic.resolveTitonicAddress(document,suite.contextualSelector,{contextPath});
78
+ assert.deepEqual(contextual.diagnostics,[]);assert.equal(contextual.bindings[0].pathText,item.namePath);
79
+ const exported=titonic.exportTitonicAeon(document);
80
+ const replay=core.compile(exported);assert.deepEqual(replay.errors,[]);
81
+ samePaths(resolveAddress(item.selector,sdk.createAeonNamespace(replay.events)).bindings,[item.namePath]);report.checks.titonic++;
82
+
83
+ for(const [sourceKind,input] of [['aeon',source],['telex',wire]]) {
84
+ const wb=await evaluateQueryForWorkbench({sourceKind,source:input,query:`from ${item.selector}\nselect .`});
85
+ assert.equal(wb.ok,true,JSON.stringify(wb.errors));
86
+ assert.equal(wb.text,`${item.namePath} = ${JSON.stringify(item.nameValue)}`);
87
+ const empty=await evaluateQueryForWorkbench({sourceKind,source:input,query});
88
+ assert.equal(empty.ok,true);assert.deepEqual(empty.results.map(r=>r.value.bindings.map(b=>b.address)),item.projected);
89
+ const limited=await evaluateQueryForWorkbench({sourceKind,source:input,query:`from ${item.selector}\nselect .`,budget:{maxIdentityInspections:3}});
90
+ assert.equal(limited.ok,false);assert.equal(limited.errors[0].code,'SANSA_RESOLVE_IDENTITY_LIMIT_EXCEEDED');
91
+ assert.equal(limited.results,undefined);
92
+ report.checks.workbench++;
93
+ }
94
+ const canonicalized=canonical.canonicalize(source);assert.deepEqual(canonicalized.errors,[]);
95
+ assert.deepEqual(canonical.canonicalize(canonicalized.text),canonicalized);
96
+ const replayed=core.compile(canonicalized.text);assert.deepEqual(replayed.errors,[]);
97
+ const canonicalBinding=resolveAddress(item.selector,sdk.createAeonNamespace(replayed.events)).bindings[0];
98
+ assert.equal(canonicalBinding.address,item.namePath);assert.equal(canonicalBinding.value,item.nameValue);report.checks.canonicalization++;
99
+
100
+ // A structural reference remains an authored position, not an identity alias.
101
+ const target=item.subtree+'.items[0].name';
102
+ for(const marker of ['~','~>']) {
103
+ const sourceWithReference=source+`copy = ${marker}${target}\n`;
104
+ const before=core.compile(sourceWithReference);assert.deepEqual(before.errors,[]);
105
+ const reference=before.events.find(e=>e.key==='copy').value.path;
106
+ const canonicalRef=canonical.canonicalize(sourceWithReference);assert.deepEqual(canonicalRef.errors,[]);
107
+ const after=core.compile(canonicalRef.text);assert.deepEqual(after.errors,[]);
108
+ assert.deepEqual(after.events.find(e=>e.key==='copy').value.path,reference);
109
+ assert.deepEqual(aes.projectPortableEvents(after.events).find(e=>e.path==='$.copy').value,
110
+ aes.projectPortableEvents(before.events).find(e=>e.path==='$.copy').value);
111
+ const indexValue=resolveAddress(target,namespace).bindings[0].value;
112
+ assert.equal(indexValue,item.itemOrder[0]==='item1'?item.nameValue:'Bracket');
113
+ const exportedReference=titonic.exportTitonicAeon(titonic.createTitonicFromAeon(sourceWithReference,{requireStrictMode:false}));
114
+ assert.deepEqual(core.compile(exportedReference).events.find(e=>e.key==='copy').value.path,reference);
115
+ report.checks.references++;
116
+ }
117
+ for(const marker of ['~','~>']) {const denied=core.compile(`bad = ${marker}${item.selector}`);assert.ok(denied.errors.length);assert.equal(denied.events.length,0);}
118
+ assert.equal(planMutation({op:'remove',target:item.selector},namespace).ok,false);
119
+ assert.equal(planInstruction(`from ${item.selector}\nremove .`,namespace).ok,false);
120
+ report.checks.boundaries++;
121
+ snapshots.set(item.id,{item,source,compiled,namespace,selected:selected.bindings[0],schema});
122
+ report.snapshots.push({id:item.id,path:selected.bindings[0].address,value:selected.bindings[0].value});
123
+ }
124
+ const original=snapshots.get('original'),reordered=snapshots.get('reordered'),moved=snapshots.get('moved'),replacement=snapshots.get('replacement');
125
+ assert.notEqual(original.selected,reordered.selected);
126
+ assert.equal(original.selected.value,'Widget');assert.equal(original.selected.address,original.item.namePath);
127
+ assert.equal(aeos.validate(reordered.compiled.events,original.schema).ok,true,'same selector/schema gets fresh snapshot paths');
128
+ assert.equal(aeos.validate(moved.compiled.events,original.schema).ok,false,'move does not turn the old selector into global lookup');
129
+ assert.deepEqual(resolveAddress(original.item.selector,moved.namespace).bindings,[]);
130
+ assert.ok(core.compile(moved.source+`stale = ~${original.item.namePath}\n`).errors.length,'old structural reference is not silently relocated');
131
+ assert.equal(moved.item.selector,replacement.item.selector);assert.equal(moved.selected.address,replacement.selected.address);
132
+ assert.notEqual(moved.selected,replacement.selected);assert.notEqual(moved.selected.value,replacement.selected.value);
133
+ let calls=0;const identity=moved.namespace.identity;moved.namespace.identity=b=>{calls++;return identity(b);};
134
+ const stale=evaluateQuery('from $\nselect path($.selection)',moved.namespace,{addressActivation:{allowedRoots:[original.item.subtree],allowedSelectors:['member','position','childIdentity']}});
135
+ assert.equal(stale.ok,false);assert.equal(stale.errors[0].code,'SANSA_QUERY_PATH_ACTIVATION_DENIED');assert.equal(calls,0);
136
+ report.crossSnapshot={schemaCacheFresh:true,oldRouteMisses:true,staleStructuralReferenceRejected:true,staleActivationScopeDeniedBeforeInspection:true,idReuseIsReplacement:true};
137
+ console.log(JSON.stringify(report,null,2));
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ import assert from 'node:assert/strict';
3
+ import {readFileSync} from 'node:fs';
4
+ import {resolve} from 'node:path';
5
+ import {pathToFileURL} from 'node:url';
6
+ import vm from 'node:vm';
7
+ import {parseAddress, parseQuery, evaluateQuery, resolveAddress} from '../../src/index.js';
8
+ import {rowsFromNamespace, scopedNamespace} from '../playground/namespace.mjs';
9
+ import {verifyPropertySelection} from './property-playground-assertions.mjs';
10
+
11
+ // Explicit owner build: no SDK substitute, installation, cache or field fallback.
12
+ const root = process.argv[2];
13
+ if (!root || (process.argv[3] !== undefined && process.argv[3] !== '--installed')) throw Error('Usage: node tools/workflows/verify-property-playground.mjs /absolute/path/to/built/aeon-or-consumer [--installed]');
14
+ const prefix = process.argv[3] === '--installed' ? 'node_modules/@altopelago/aeon-' : 'implementations/typescript/packages/';
15
+ const url = path => pathToFileURL(resolve(root, prefix + path)).href;
16
+ const [{runRuntime}, {createAeonNamespace}] = await Promise.all([import(url('runtime/dist/index.js')), import(url('sdk/dist/sansa.js'))]);
17
+ const context = vm.createContext({window:{}, document:{querySelector:()=>({innerHTML:''})}});
18
+ vm.runInContext(readFileSync(new URL('../playground/examples.mjs', import.meta.url), 'utf8'), context);
19
+ const examples = JSON.parse(JSON.stringify(context.window.SansaPlaygroundExamples));
20
+ const report = {examples:[], queryPropertiesAdmitted:true, release:false, deployment:false};
21
+ for (const [id, example] of Object.entries(examples).filter(([id]) => id.startsWith('property'))) {
22
+ const compiled = runRuntime(example.source, {mode:'transport', datatypePolicy:'reserved_only', includeAnnotations:true, output:'map'});
23
+ assert.deepEqual(compiled.meta.errors, [], id);
24
+ const owner = createAeonNamespace(compiled.aes);
25
+ const namespace = scopedNamespace(owner, example.scope);
26
+ const rows = rowsFromNamespace(owner);
27
+ const options = {maxIdentityInspections:example.inspections,maxPropertyInspections:example.propertyInspections,maxBindings:1000};
28
+ const isQuery = example.view === 'query';
29
+ const parsed = isQuery ? parseQuery(example.query) : parseAddress(example.address);
30
+ assert.equal(parsed.ok, true, id);
31
+ for (const address of isQuery ? [example.query, parsed.query] : [example.address, parsed.address]) {
32
+ const selected = example.view === 'query' ? evaluateQuery(address, namespace, {addressActivation:'trusted',resolve:options}) : resolveAddress(address, namespace, options);
33
+ if (example.expectedCode) {
34
+ assert.equal(selected.ok, false, id);
35
+ assert.equal(selected.errors[0].code, example.expectedCode, id);
36
+ assert.deepEqual(example.view === 'query' ? selected.results : selected.bindings, []);
37
+ if (id === 'propertyBudget') {
38
+ assert.equal(selected.errors[0].budget, 'maxPropertyInspections');
39
+ assert.equal(selected.errors[0].limit, 1); assert.equal(selected.errors[0].observed, 2);
40
+ }
41
+ } else {
42
+ verifyPropertySelection(selected, example, owner, rows, id);
43
+ }
44
+ }
45
+ report.examples.push(id);
46
+ }
47
+ assert.equal(report.examples.length, 15);
48
+ console.log(JSON.stringify(report, null, 2));