@altopelago/sansa 0.14.2 → 0.15.0-rc.3

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 (184) hide show
  1. package/CHANGELOG.md +133 -1
  2. package/README.md +98 -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-bounded-expansion-2026-11-24.json +39 -0
  13. package/conformance/results/aeonic-anchor-capacity-bounded-expansion-2026-11-24.json +452 -0
  14. package/conformance/results/aeonic-anchor-capacity-rc3-2026-11-24.json +452 -0
  15. package/conformance/results/aeonic-anchor-capacity.json +452 -0
  16. package/conformance/results/aeonic-anchor-rc3-2026-11-24.json +39 -0
  17. package/conformance/results/aeonic-anchor-snapshot-0.1.json +39 -0
  18. package/conformance/results/aeonic-arithmetic-snapshot-0.1.json +28 -0
  19. package/conformance/results/aeonic-clock-all-bounded-expansion-2026-11-24.json +49 -0
  20. package/conformance/results/aeonic-clock-all-rc3-2026-11-24.json +49 -0
  21. package/conformance/results/aeonic-clock-all-snapshot-0.1.json +49 -0
  22. package/conformance/results/aeonic-clock-arithmetic-bounded-expansion-2026-11-24.json +48 -0
  23. package/conformance/results/aeonic-clock-arithmetic-rc3-2026-11-24.json +48 -0
  24. package/conformance/results/aeonic-clock-arithmetic-snapshot-0.1.json +48 -0
  25. package/conformance/results/aeonic-clock-capacity-bounded-expansion-2026-11-24.json +326 -0
  26. package/conformance/results/aeonic-clock-capacity-rc3-2026-11-24.json +326 -0
  27. package/conformance/results/aeonic-clock-capacity.json +326 -0
  28. package/conformance/results/aeonic-clock-relations-bounded-expansion-2026-11-24.json +48 -0
  29. package/conformance/results/aeonic-clock-relations-rc3-2026-11-24.json +48 -0
  30. package/conformance/results/aeonic-clock-relations-snapshot-0.1.json +48 -0
  31. package/conformance/results/aeonic-comparison-snapshot-0.1.json +19 -0
  32. package/conformance/results/aeonic-datetime-all-bounded-expansion-2026-11-24.json +47 -0
  33. package/conformance/results/aeonic-datetime-all-rc3-2026-11-24.json +47 -0
  34. package/conformance/results/aeonic-datetime-all-snapshot-0.1.json +47 -0
  35. package/conformance/results/aeonic-datetime-arithmetic-bounded-expansion-2026-11-24.json +46 -0
  36. package/conformance/results/aeonic-datetime-arithmetic-rc3-2026-11-24.json +46 -0
  37. package/conformance/results/aeonic-datetime-arithmetic-snapshot-0.1.json +46 -0
  38. package/conformance/results/aeonic-datetime-capacity-bounded-expansion-2026-11-24.json +302 -0
  39. package/conformance/results/aeonic-datetime-capacity-rc3-2026-11-24.json +302 -0
  40. package/conformance/results/aeonic-datetime-capacity.json +302 -0
  41. package/conformance/results/aeonic-datetime-relations-bounded-expansion-2026-11-24.json +46 -0
  42. package/conformance/results/aeonic-datetime-relations-rc3-2026-11-24.json +46 -0
  43. package/conformance/results/aeonic-datetime-relations-snapshot-0.1.json +46 -0
  44. package/conformance/results/aeonic-rational-arithmetic-capacity.json +100 -0
  45. package/conformance/results/aeonic-rational-arithmetic-snapshot-0.2.json +30 -0
  46. package/conformance/results/aeonic-temporal-all-bounded-expansion-2026-11-24.json +39 -0
  47. package/conformance/results/aeonic-temporal-all-property-addressing-2026-11-16.json +39 -0
  48. package/conformance/results/aeonic-temporal-all-rc3-2026-11-24.json +39 -0
  49. package/conformance/results/aeonic-temporal-all-snapshot-0.1.json +39 -0
  50. package/conformance/results/aeonic-temporal-calendar-bounded-expansion-2026-11-24.json +38 -0
  51. package/conformance/results/aeonic-temporal-calendar-property-addressing-2026-11-16.json +38 -0
  52. package/conformance/results/aeonic-temporal-calendar-rc3-2026-11-24.json +38 -0
  53. package/conformance/results/aeonic-temporal-calendar-snapshot-0.1.json +38 -0
  54. package/conformance/results/aeonic-temporal-capacity-bounded-expansion-2026-11-24.json +136 -0
  55. package/conformance/results/aeonic-temporal-capacity-property-addressing-2026-11-16.json +136 -0
  56. package/conformance/results/aeonic-temporal-capacity-rc3-2026-11-24.json +136 -0
  57. package/conformance/results/aeonic-temporal-capacity.json +136 -0
  58. package/conformance/results/aeonic-temporal-relations-bounded-expansion-2026-11-24.json +38 -0
  59. package/conformance/results/aeonic-temporal-relations-property-addressing-2026-11-16.json +38 -0
  60. package/conformance/results/aeonic-temporal-relations-rc3-2026-11-24.json +38 -0
  61. package/conformance/results/aeonic-temporal-relations-snapshot-0.1.json +38 -0
  62. package/docs/aeonic-arithmetic.md +126 -0
  63. package/docs/aeonic-comparison.md +123 -0
  64. package/docs/aeonic-rational-arithmetic.md +167 -0
  65. package/docs/aeonic-temporal-civil-anchor.md +89 -0
  66. package/docs/aeonic-temporal-civil-clock.md +100 -0
  67. package/docs/aeonic-temporal-civil-date.md +124 -0
  68. package/docs/aeonic-temporal-civil-datetime.md +122 -0
  69. package/docs/api-contract.md +130 -3
  70. package/docs/capabilities.json +106 -2
  71. package/docs/child-identity-activation.md +93 -0
  72. package/docs/child-identity-candidate.md +60 -0
  73. package/docs/child-identity-tooling.md +31 -0
  74. package/docs/child-identity-workflows.md +102 -0
  75. package/docs/empty-keys-candidate.md +29 -0
  76. package/docs/migration-0.15.0.md +86 -0
  77. package/docs/property-addressing-implementation.md +118 -0
  78. package/docs/property-resolve-implementation.md +105 -0
  79. package/docs/property-selector-support.md +65 -0
  80. package/docs/property-selectors-api.d.ts +43 -0
  81. package/docs/property-selectors-api.pyi +27 -0
  82. package/docs/property-selectors-api.rs +48 -0
  83. package/docs/property-selectors-contract.md +168 -0
  84. package/docs/query-tool.md +32 -1
  85. package/docs/selector-cursor.md +45 -0
  86. package/docs/unicode-hardening.md +41 -0
  87. package/fixtures/address-v1.json +4 -3
  88. package/fixtures/child-identity-workflows/README.md +9 -0
  89. package/fixtures/child-identity-workflows/moved.aeon +10 -0
  90. package/fixtures/child-identity-workflows/original.aeon +10 -0
  91. package/fixtures/child-identity-workflows/reordered.aeon +10 -0
  92. package/fixtures/child-identity-workflows/replacement.aeon +10 -0
  93. package/fixtures/child-identity-workflows/workflows.json +89 -0
  94. package/fixtures/property-namespace-candidate-v1.json +336 -0
  95. package/fixtures/property-parser-candidate-v1.json +705 -0
  96. package/fixtures/property-query-candidate-v1.json +398 -0
  97. package/fixtures/property-resolve-candidate-v1.json +2702 -0
  98. package/fixtures/unicode-hardening-v1.json +401 -0
  99. package/package.json +30 -3
  100. package/scripts/calibrate-aeonic-anchor-capacity.py +294 -0
  101. package/scripts/calibrate-aeonic-clock-capacity.py +62 -0
  102. package/scripts/calibrate-aeonic-datetime-capacity.py +76 -0
  103. package/scripts/calibrate-aeonic-rational-capacity.py +85 -0
  104. package/scripts/calibrate-aeonic-temporal-capacity.py +95 -0
  105. package/scripts/cts-address.mjs +6 -2
  106. package/scripts/cts-aeonic-anchor.mjs +21 -0
  107. package/scripts/cts-aeonic-arithmetic-adapter.mjs +25 -0
  108. package/scripts/cts-aeonic-arithmetic.mjs +24 -0
  109. package/scripts/cts-aeonic-clock.mjs +24 -0
  110. package/scripts/cts-aeonic-comparison-adapter.mjs +30 -0
  111. package/scripts/cts-aeonic-comparison.mjs +25 -0
  112. package/scripts/cts-aeonic-datetime.mjs +24 -0
  113. package/scripts/cts-aeonic-rational-arithmetic-adapter.mjs +25 -0
  114. package/scripts/cts-aeonic-rational-arithmetic.mjs +24 -0
  115. package/scripts/cts-aeonic-temporal-civil-anchor-adapter.mjs +26 -0
  116. package/scripts/cts-aeonic-temporal-civil-clock-adapter.mjs +28 -0
  117. package/scripts/cts-aeonic-temporal-civil-date-adapter.mjs +28 -0
  118. package/scripts/cts-aeonic-temporal-civil-datetime-adapter.mjs +28 -0
  119. package/scripts/cts-aeonic-temporal.mjs +24 -0
  120. package/scripts/cts-instruction.mjs +4 -2
  121. package/scripts/cts-mutate.mjs +3 -2
  122. package/scripts/cts-resolve.mjs +17 -2
  123. package/scripts/playground.mjs +110 -0
  124. package/src/aeonic-arithmetic-binding.js +61 -0
  125. package/src/aeonic-arithmetic.d.ts +84 -0
  126. package/src/aeonic-arithmetic.js +276 -0
  127. package/src/aeonic-comparison.d.ts +86 -0
  128. package/src/aeonic-comparison.js +274 -0
  129. package/src/aeonic-convenience.d.ts +30 -0
  130. package/src/aeonic-convenience.js +45 -0
  131. package/src/aeonic-exact-number.js +34 -0
  132. package/src/aeonic-json.js +45 -0
  133. package/src/aeonic-rational-arithmetic.d.ts +86 -0
  134. package/src/aeonic-rational-arithmetic.js +417 -0
  135. package/src/aeonic-rational-json.js +51 -0
  136. package/src/aeonic-temporal-civil-anchor.d.ts +54 -0
  137. package/src/aeonic-temporal-civil-anchor.js +316 -0
  138. package/src/aeonic-temporal-civil-clock.d.ts +124 -0
  139. package/src/aeonic-temporal-civil-clock.js +388 -0
  140. package/src/aeonic-temporal-civil-date.d.ts +123 -0
  141. package/src/aeonic-temporal-civil-date.js +310 -0
  142. package/src/aeonic-temporal-civil-datetime.d.ts +138 -0
  143. package/src/aeonic-temporal-civil-datetime.js +501 -0
  144. package/src/index.d.ts +84 -1
  145. package/src/index.js +859 -190
  146. package/src/property-address.js +196 -0
  147. package/src/property-resolve.js +132 -0
  148. package/src/query-metadata.d.ts +16 -0
  149. package/src/query-metadata.js +25 -0
  150. package/src/selector-cursor.d.ts +19 -0
  151. package/src/selector-cursor.js +79 -0
  152. package/stress-tests/address/invalid.sansa-cases +0 -2
  153. package/stress-tests/address/valid.sansa-cases +3 -0
  154. package/tools/mutate-web/examples.mjs +1 -1
  155. package/tools/mutate-web/runtime.mjs +0 -2
  156. package/tools/playground/README.md +165 -0
  157. package/tools/playground/accessibility.js +91 -0
  158. package/tools/playground/aeon-highlight.js +77 -0
  159. package/tools/playground/aeon-source-composer.js +1077 -0
  160. package/tools/playground/anchor-examples.mjs +16 -0
  161. package/tools/playground/arithmetic-evaluator.mjs +28 -0
  162. package/tools/playground/arithmetic-model.mjs +187 -0
  163. package/tools/playground/arithmetic-worker.mjs +14 -0
  164. package/tools/playground/arithmetic.css +1 -0
  165. package/tools/playground/arithmetic.html +29 -0
  166. package/tools/playground/arithmetic.mjs +110 -0
  167. package/tools/playground/clock-examples.mjs +16 -0
  168. package/tools/playground/datetime-examples.mjs +22 -0
  169. package/tools/playground/examples.mjs +46 -0
  170. package/tools/playground/index.html +174 -0
  171. package/tools/playground/local.css +25 -0
  172. package/tools/playground/namespace.mjs +39 -0
  173. package/tools/playground/sansa-playground.js +1565 -0
  174. package/tools/playground/site.css +3914 -0
  175. package/tools/playground/temporal-examples.mjs +20 -0
  176. package/tools/playground/walkthrough.js +90 -0
  177. package/tools/playground/website-origin.json +16 -0
  178. package/tools/query-web/IDENTITY_SELECTORS.md +44 -0
  179. package/tools/query-web/app.js +4 -0
  180. package/tools/query-web/index.html +4 -0
  181. package/tools/query-web/runtime.mjs +70 -19
  182. package/tools/workflows/property-playground-assertions.mjs +33 -0
  183. package/tools/workflows/verify-child-identities.mjs +137 -0
  184. package/tools/workflows/verify-property-playground.mjs +48 -0
@@ -0,0 +1,388 @@
1
+ // Adapted from AltoPelago/aeonic at 8cb31dd3beb44d758ed27c02600b5b4c858fc2a1.
2
+ // Copyright (c) 2026 Patrik. MIT; see LICENSE and docs/aeonic-temporal-civil-clock.md.
3
+ // Bounded UTF-8 counting keeps native/text APIs usable in browser workers.
4
+ function utf8Bytes(text, allowance) {
5
+ let bytes = 0;
6
+ for (const character of text) {
7
+ const point = character.codePointAt(0);
8
+ bytes += point <= 0x7f ? 1 : point <= 0x7ff ? 2 : point <= 0xffff ? 3 : 4;
9
+ if (bytes > allowance) break;
10
+ }
11
+ return bytes;
12
+ }
13
+ import { exceedsJsonDepth, parseStrictJson } from './aeonic-json.js';
14
+ import { RationalJsonNumber } from './aeonic-rational-json.js';
15
+
16
+ export const AEONIC_TEMPORAL_CIVIL_CLOCK_PROFILE = 'aeonic.operations.temporal.civil-clock.v1';
17
+ export const AEONIC_TEMPORAL_CIVIL_CLOCK_DEFAULT_RESOURCE_LIMITS = Object.freeze({ maxRequestBytes: 65536, maxRequestDepth: 32,
18
+ maxTemporalCharacters: 1024, maxInputPieces: 512, maxIntermediatePieces: 4096, maxOutputPieces: 512,
19
+ maxWork: 16384, maxFractionDigits: 256, maxRelativeDayDigits: 256, maxCountCharacters: 32, maxNumericCharacters: 4096,
20
+ maxCoefficientDigits: 1024, maxExponentMagnitude: 1000000, maxWorkspaceDigits: 4096,
21
+ maxOutputCharacters: 1024, maxResultBytes: 131072 });
22
+ const OPERATIONS = { relations: ['equal', 'compare', 'relate'], arithmetic: ['shiftClock', 'step', 'materialize'] };
23
+ const TAGS = new Set(['civilClock', 'civilClockSet', 'civilDateTime', 'civilDateTimeSet', 'civilDate', 'civilDateSet', 'finiteNumber', 'exactNumber', 'exactRational',
24
+ 'string', 'boolean', 'symbol', 'positiveInfinity', 'negativeInfinity', 'nan', 'explicitNull', 'explicitAbsence', 'toggle',
25
+ 'hex', 'radix', 'encoding', 'separator', 'sansaAddress', 'referenceForm', 'temporal', 'container']);
26
+ const CLOCKS = ['hour', 'minute', 'second'];
27
+ const NONE = 'none-declared', APPROX = 'approximation-declared';
28
+ const record = v => v !== null && typeof v === 'object' && !Array.isArray(v);
29
+ const scalar = v => typeof v === 'string' && !/[\uD800-\uDFFF]/u.test(v);
30
+ const identifier = v => scalar(v) && v.length > 0;
31
+ const pointer = (p, k) => scalar(k) ? p + '/' + k.replaceAll('~', '~0').replaceAll('/', '~1') : null;
32
+ function scalarOrder(a, b) {
33
+ const x = a[Symbol.iterator](), y = b[Symbol.iterator]();
34
+ for (;;) { const p = x.next(), q = y.next();
35
+ if (p.done || q.done) return p.done === q.done ? 0 : p.done ? -1 : 1;
36
+ if (p.value !== q.value) return p.value.codePointAt(0) - q.value.codePointAt(0);
37
+ }
38
+ }
39
+ class Failure extends Error {
40
+ constructor(reason, stage, path) { super(reason); this.result = { outcome: 'diagnostic', reason, context: { stage, path } }; }
41
+ }
42
+ function stop(reason, stage, path) { throw new Failure(reason, stage, path); }
43
+ function guarded(action) { try { return action(); } catch (e) { if (e instanceof Failure) return e.result; throw e; } }
44
+ function required(v, fields, path, reason, stage) {
45
+ for (const k of fields) if (!Object.hasOwn(v, k)) stop(reason, stage, pointer(path, k));
46
+ }
47
+ function closed(v, fields, path, reason, stage) {
48
+ for (const k of Object.keys(v).sort(scalarOrder)) if (!fields.includes(k)) stop(reason, stage, pointer(path, k));
49
+ }
50
+ function configured(options) {
51
+ if (!record(options) || Object.keys(options).some(k => !['resourceLimits', 'capabilities'].includes(k))) throw new TypeError('Invalid trusted options');
52
+ const supplied = Object.hasOwn(options, 'resourceLimits') ? options.resourceLimits : {};
53
+ if (!record(supplied)) throw new TypeError('resourceLimits must be an object');
54
+ for (const [k, v] of Object.entries(supplied)) {
55
+ if (!Object.hasOwn(AEONIC_TEMPORAL_CIVIL_CLOCK_DEFAULT_RESOURCE_LIMITS, k) || !Number.isSafeInteger(v) || v < 0) throw new TypeError('Invalid resource limit: ' + k);
56
+ }
57
+ const capabilities = Object.hasOwn(options, 'capabilities') ? options.capabilities : ['relations', 'arithmetic'];
58
+ if (!Array.isArray(capabilities) || !capabilities.length || capabilities.some(k => typeof k !== 'string' || !Object.hasOwn(OPERATIONS, k)) || new Set(capabilities).size !== capabilities.length) throw new TypeError('Invalid trusted capabilities');
59
+ return { limits: { ...AEONIC_TEMPORAL_CIVIL_CLOCK_DEFAULT_RESOURCE_LIMITS, ...supplied }, available: new Set(capabilities.flatMap(k => OPERATIONS[k])) };
60
+ }
61
+
62
+ // Whole relative seconds use BigInt; canonical fractions remain text until
63
+ // an admitted translation aligns them. No calendar or host Date participates.
64
+ const C = (s, f = '') => ({ s, f });
65
+ const cmp = (a, b) => a.s !== b.s ? a.s < b.s ? -1 : 1 : a.f === b.f ? 0 : a.f < b.f ? -1 : 1;
66
+ const same = (a, b) => cmp(a, b) === 0;
67
+ const piece = (lo, hi = lo, il = true, ih = true) => ({ lo, hi, il, ih });
68
+ const empty = p => cmp(p.lo, p.hi) > 0 || same(p.lo, p.hi) && !(p.il && p.ih);
69
+ const floor = (n, d) => n / d - (n < 0n && n % d !== 0n ? 1n : 0n);
70
+ const WIDTH = { hour: 3600n, minute: 60n, second: 1n };
71
+ function fields(text, path, limits, authored = false) {
72
+ if (typeof text !== 'string') stop('invalid_operand', 4, path);
73
+ characters([text], limits.maxTemporalCharacters, path);
74
+ const pattern = authored ? /^([0-9]{2}):(?:([0-9]{2})(?::([0-9]{2})(?:\.([0-9]+))?)?)?$(?![\s\S])/u
75
+ : /^([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.([0-9]+))?$(?![\s\S])/u;
76
+ const m = pattern.exec(text); if (!m) stop('invalid_operand', 4, path);
77
+ const [_, hh, mm, ss, raw = ''] = m;
78
+ if (raw.length > limits.maxFractionDigits) stop('resource_limit', 4, path);
79
+ const f = raw.replace(/0+$/u, '');
80
+ if (!authored && f !== raw) stop('invalid_operand', 4, path);
81
+ if (Number(hh) > 23 || Number(mm ?? 0) > 59 || Number(ss ?? 0) > 59) stop('invalid_operand', 4, path);
82
+ return { seconds: BigInt(Number(hh) * 3600 + Number(mm ?? 0) * 60 + Number(ss ?? 0)), f,
83
+ clock: ss !== undefined ? 'second' : mm !== undefined ? 'minute' : 'hour' };
84
+ }
85
+ function coordinate(v, path, limits) {
86
+ if (!record(v)) stop('invalid_operand', 4, path);
87
+ required(v, ['day', 'time'], path, 'invalid_operand', 4); closed(v, ['day', 'time'], path, 'invalid_operand', 4);
88
+ if (typeof v.day !== 'string') stop('invalid_operand', 4, path + '/day');
89
+ characters([v.day.startsWith('-') ? v.day.slice(1) : v.day], limits.maxRelativeDayDigits, path + '/day');
90
+ if (!/^(?:0|-?[1-9][0-9]*)$(?![\s\S])/u.test(v.day)) stop('invalid_operand', 4, path + '/day');
91
+ const t = fields(v.time, path + '/time', limits);
92
+ return C(BigInt(v.day) * 86400n + t.seconds, t.f);
93
+ }
94
+ function operand(v, limits, path) {
95
+ if (!record(v)) stop('invalid_operand', 4, path);
96
+ required(v, ['temporal'], path, 'invalid_operand', 4);
97
+ const t = v.temporal, at = path + '/temporal';
98
+ if (!record(t)) stop('invalid_operand', 4, at);
99
+ if (typeof t.category !== 'string' || !TAGS.has(t.category)) stop('invalid_operand', 4, at + '/category');
100
+ if (t.category === 'civilClockSet') required(v, ['originClockForm', 'history'], path, 'invalid_operand', 4);
101
+ closed(v, ['temporal', 'originClockForm', 'history'], path, 'invalid_operand', 4);
102
+ const h = Object.hasOwn(v, 'history') ? v.history : NONE;
103
+ if (![NONE, APPROX].includes(h)) stop('invalid_operand', 4, path + '/history');
104
+ if (Object.hasOwn(v, 'originClockForm') && ![...CLOCKS, 'undeclared'].includes(v.originClockForm)) stop('invalid_operand', 4, path + '/originClockForm');
105
+ if (!['civilClock', 'civilClockSet'].includes(t.category)) return { deferred: true };
106
+ let pieces, form;
107
+ if (t.category === 'civilClock') {
108
+ required(t, ['value'], at, 'invalid_operand', 4); closed(t, ['category', 'value'], at, 'invalid_operand', 4);
109
+ form = fields(t.value, at + '/value', limits, true);
110
+ if (limits.maxRelativeDayDigits < 1 || limits.maxInputPieces < 1) stop('resource_limit', 4, at);
111
+ const lo = C(form.seconds, form.f), width = form.clock === 'second' ? 0n : WIDTH[form.clock];
112
+ pieces = [piece(lo, width ? C(lo.s + width) : lo, true, !width)];
113
+ } else {
114
+ required(t, ['pieces'], at, 'invalid_operand', 4); closed(t, ['category', 'pieces'], at, 'invalid_operand', 4);
115
+ if (!Array.isArray(t.pieces) || !t.pieces.length) stop('invalid_operand', 4, at + '/pieces');
116
+ if (t.pieces.length > limits.maxInputPieces) stop('resource_limit', 4, at + '/pieces');
117
+ pieces = [];
118
+ for (let i = 0; i < t.pieces.length; i++) {
119
+ const p = t.pieces[i], where = at + '/pieces/' + i;
120
+ if (!record(p)) stop('invalid_operand', 4, where);
121
+ required(p, ['kind'], where, 'invalid_operand', 4);
122
+ if (!['point', 'interval'].includes(p.kind)) stop('invalid_operand', 4, where + '/kind');
123
+ const keys = p.kind === 'point' ? ['at'] : ['start', 'end', 'includeStart', 'includeEnd'];
124
+ required(p, keys, where, 'invalid_operand', 4); closed(p, ['kind', ...keys], where, 'invalid_operand', 4);
125
+ const lp = where + (p.kind === 'point' ? '/at' : '/start');
126
+ const lo = coordinate(p.kind === 'point' ? p.at : p.start, lp, limits); let q;
127
+ if (p.kind === 'point') q = piece(lo);
128
+ else {
129
+ const hi = coordinate(p.end, where + '/end', limits);
130
+ for (const key of ['includeStart', 'includeEnd']) if (typeof p[key] !== 'boolean') stop('invalid_operand', 4, where + '/' + key);
131
+ if (cmp(lo, hi) >= 0) stop('invalid_operand', 4, where + '/end');
132
+ q = piece(lo, hi, p.includeStart, p.includeEnd);
133
+ }
134
+ const previous = pieces.at(-1);
135
+ if (previous && (cmp(previous.hi, q.lo) > 0 || same(previous.hi, q.lo) && (previous.ih || q.il))) stop('invalid_operand', 4, lp);
136
+ pieces.push(q);
137
+ }
138
+ }
139
+ return { pieces, history: h, origin: v.originClockForm ?? form?.clock ?? 'undeclared' };
140
+ }
141
+ function characters(values, limit, path) {
142
+ let n = 0; for (const value of values) for (const ch of value) if (++n > limit) stop('resource_limit', 4, path);
143
+ }
144
+ function exponent(text, limits, path) {
145
+ const abs = text.replace(/^[+-]/u, '').replace(/^0+/u, '') || '0', cap = String(limits.maxExponentMagnitude);
146
+ if (abs.length > cap.length || abs.length === cap.length && abs > cap) stop('resource_limit', 4, path);
147
+ return (text.startsWith('-') ? -1n : 1n) * BigInt(abs);
148
+ }
149
+ function amount(v, limits, path) {
150
+ if (!record(v)) stop('invalid_operand', 4, path);
151
+ required(v, ['number'], path, 'invalid_operand', 4);
152
+ const t = v.number, at = path + '/number';
153
+ if (!record(t)) stop('invalid_operand', 4, at);
154
+ if (typeof t.category !== 'string' || !TAGS.has(t.category)) stop('invalid_operand', 4, at + '/category');
155
+ if (t.category === 'exactNumber') required(v, ['history'], path, 'invalid_operand', 4);
156
+ closed(v, ['number', 'history'], path, 'invalid_operand', 4);
157
+ const h = v.history ?? NONE; if (![NONE, APPROX].includes(h) || Object.hasOwn(v, 'history') && v.history === null) stop('invalid_operand', 4, path + '/history');
158
+ if (!['finiteNumber', 'exactNumber'].includes(t.category)) return { deferred: true };
159
+ let c, e;
160
+ if (t.category === 'finiteNumber') {
161
+ required(t, ['value'], at, 'invalid_operand', 4); closed(t, ['category', 'value'], at, 'invalid_operand', 4);
162
+ if (typeof t.value !== 'string') stop('invalid_operand', 4, at + '/value');
163
+ characters([t.value], limits.maxNumericCharacters, at + '/value');
164
+ if (!/^[+-]?(?:(?:0|[1-9][0-9]*)(?:\.[0-9]+)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$(?![\s\S])/u.test(t.value)) stop('invalid_operand', 4, at + '/value');
165
+ const [m, x = '0'] = t.value.toLowerCase().split('e'); e = exponent(x, limits, at + '/value');
166
+ const [whole, f = ''] = m.replace(/^[+-]/u, '').split('.'); c = (whole + f).replace(/^0+/u, '') || '0';
167
+ if (c === '0') e = 0n;
168
+ else { const trim = c.replace(/0+$/u, ''); e += BigInt(c.length - trim.length - f.length); c = (m.startsWith('-') ? '-' : '') + trim; }
169
+ if (c.replace(/^-/, '').length > limits.maxCoefficientDigits || (e < 0n ? -e : e) > BigInt(limits.maxExponentMagnitude)) stop('resource_limit', 4, at + '/value');
170
+ } else {
171
+ required(t, ['coefficient', 'exponent'], at, 'invalid_operand', 4); closed(t, ['category', 'coefficient', 'exponent'], at, 'invalid_operand', 4);
172
+ for (const key of ['coefficient', 'exponent']) if (typeof t[key] !== 'string') stop('invalid_operand', 4, at + '/' + key);
173
+ characters([t.coefficient, t.exponent], limits.maxNumericCharacters, at);
174
+ if (!/^(?:0|-?[1-9](?:[0-9]*[1-9])?)$(?![\s\S])/u.test(t.coefficient)) stop('invalid_operand', 4, at + '/coefficient');
175
+ if (!/^(?:0|-?[1-9][0-9]*)$(?![\s\S])/u.test(t.exponent) || t.coefficient === '0' && t.exponent !== '0') stop('invalid_operand', 4, at + '/exponent');
176
+ c = t.coefficient; e = exponent(t.exponent, limits, at + '/exponent');
177
+ if (c.replace(/^-/, '').length > limits.maxCoefficientDigits) stop('resource_limit', 4, at + '/coefficient');
178
+ }
179
+ return { c, e, history: h };
180
+ }
181
+ function selection(input, op, limits) {
182
+ const extras = op === 'step' ? ['clockForm', 'count'] : op === 'materialize' ? ['clockForm'] : [];
183
+ for (const key of ['context', 'policy']) {
184
+ const at = '/input/' + key;
185
+ if (!Object.hasOwn(input, key)) { if (key === 'policy' && extras.length) stop('invalid_policy', 3, at); continue; }
186
+ if (!record(input[key])) stop('invalid_policy', 3, at);
187
+ if (key === 'policy') required(input[key], extras, at, 'invalid_policy', 3);
188
+ closed(input[key], ['profile', ...(key === 'policy' ? extras : [])], at, 'invalid_policy', 3);
189
+ }
190
+ for (const key of ['context', 'policy']) if (Object.hasOwn(input[key] ?? {}, 'profile') && !identifier(input[key].profile)) stop('invalid_policy', 3, '/input/' + key + '/profile');
191
+ const p = input.policy ?? {};
192
+ if (['step', 'materialize'].includes(op)) for (const [k, allowed] of [['clockForm', CLOCKS]]) if (!allowed.includes(p[k])) stop('invalid_policy', 3, '/input/policy/' + k);
193
+ if (op === 'step') {
194
+ if (typeof p.count !== 'string') stop('invalid_policy', 3, '/input/policy/count');
195
+ let n = 0; for (const ch of p.count) if (++n > limits.maxCountCharacters) stop('resource_limit', 3, '/input/policy/count');
196
+ if (!/^(?:0|-?[1-9][0-9]*)$(?![\s\S])/u.test(p.count)) stop('invalid_policy', 3, '/input/policy/count');
197
+ }
198
+ const owner = Object.hasOwn(p, 'profile') ? 'policy' : Object.hasOwn(input.context ?? {}, 'profile') ? 'context' : null;
199
+ if (!owner) stop('invalid_policy', 3, '/input/policy/profile');
200
+ if (input[owner].profile !== AEONIC_TEMPORAL_CIVIL_CLOCK_PROFILE) stop('unsupported_profile', 3, '/input/' + owner + '/profile');
201
+ return { profile: AEONIC_TEMPORAL_CIVIL_CLOCK_PROFILE, ...Object.fromEntries(extras.map(k => [k, p[k]])) };
202
+ }
203
+ function guard(n, cap) { if (n > cap) stop('resource_limit', 6, null); }
204
+ function intersection(a, b) {
205
+ const low = cmp(a.lo, b.lo), high = cmp(a.hi, b.hi);
206
+ return piece(low >= 0 ? a.lo : b.lo, high <= 0 ? a.hi : b.hi, low === 0 ? a.il && b.il : low > 0 ? a.il : b.il, high === 0 ? a.ih && b.ih : high < 0 ? a.ih : b.ih);
207
+ }
208
+ function contains(a, b) {
209
+ let j = 0;
210
+ for (const p of a) {
211
+ while (j < b.length && (cmp(b[j].hi, p.lo) < 0 || same(b[j].hi, p.lo) && (!same(p.lo, p.hi) || !b[j].ih))) j++;
212
+ if (j === b.length) return false;
213
+ const q = b[j];
214
+ if (cmp(q.lo, p.lo) > 0 || cmp(q.hi, p.hi) < 0 || same(q.lo, p.lo) && p.il && !q.il || same(q.hi, p.hi) && p.ih && !q.ih) return false;
215
+ }
216
+ return true;
217
+ }
218
+ const identical = (a, b) => a.length === b.length && a.every((p, i) => same(p.lo, b[i].lo) && same(p.hi, b[i].hi) && p.il === b[i].il && p.ih === b[i].ih);
219
+ function label(a, b, op) {
220
+ const eq = identical(a, b);
221
+ if (op === 'equal') return eq ? 'equal' : 'notEqual';
222
+ const before = (x, y) => cmp(x.at(-1).hi, y[0].lo) < 0 || same(x.at(-1).hi, y[0].lo) && !(x.at(-1).ih && y[0].il);
223
+ if (op === 'compare') return eq ? 'equal' : before(a, b) ? 'before' : before(b, a) ? 'after' : 'indeterminate';
224
+ if (eq) return 'equal'; if (contains(a, b)) return 'containedBy'; if (contains(b, a)) return 'contains';
225
+ let i = 0, j = 0;
226
+ while (i < a.length && j < b.length) {
227
+ if (!empty(intersection(a[i], b[j]))) return 'overlaps';
228
+ const c = cmp(a[i].hi, b[j].hi); if (c <= 0) i++; if (c >= 0) j++;
229
+ }
230
+ return 'disjoint';
231
+ }
232
+ function dimensions(pieces) {
233
+ let D = 1, p = 0;
234
+ for (const part of pieces) for (const c of [part.lo, part.hi]) {
235
+ const day = floor(c.s, 86400n).toString(); D = Math.max(D, day.startsWith('-') ? day.length - 1 : day.length);
236
+ p = Math.max(p, c.f.length);
237
+ }
238
+ return { D, p };
239
+ }
240
+ function shift(pieces, amount, limits) {
241
+ const { D, p } = dimensions(pieces);
242
+ if (amount.c === '0') { guard(pieces.length, limits.maxWork); guard(pieces.length, limits.maxIntermediatePieces); return pieces; }
243
+ const q = BigInt(p) > -amount.e ? BigInt(p) : -amount.e;
244
+ const A = BigInt(amount.c.replace(/^-/, '').length) + amount.e + q;
245
+ const base = BigInt(D) + 5n + q, W = (base > A ? base : A) + 1n;
246
+ if (W > BigInt(limits.maxWorkspaceDigits)) stop('resource_limit', 6, null);
247
+ if (q > BigInt(limits.maxFractionDigits)) stop('resource_limit', 6, null);
248
+ guard(pieces.length, limits.maxWork); guard(pieces.length, limits.maxIntermediatePieces);
249
+ const scale = 10n ** q, delta = BigInt(amount.c) * 10n ** (amount.e + q), digits = Number(q);
250
+ const move = c => {
251
+ const n = c.s * scale + BigInt(c.f || '0') * 10n ** (q - BigInt(c.f.length)) + delta;
252
+ const s = floor(n, scale), f = (n - s * scale).toString().padStart(digits, '0').replace(/0+$/u, '');
253
+ return C(s, f === '0' ? '' : f);
254
+ };
255
+ return pieces.map(p => piece(move(p.lo), move(p.hi), p.il, p.ih));
256
+ }
257
+ function reference(pieces, clock) {
258
+ const x = pieces[0].lo;
259
+ if (clock === 'second') return piece(x);
260
+ const width = WIDTH[clock], lo = C(floor(x.s, width) * width);
261
+ return piece(lo, C(lo.s + width), true, false);
262
+ }
263
+ function step(source, pieces, policy, limits) {
264
+ if (policy.count === '0') return [source];
265
+ const { D, p } = dimensions(pieces), n = policy.count.replace(/^-/, '').length, u = WIDTH[policy.clockForm];
266
+ const W = Math.max(D + 5 + p, n + u.toString().length + p) + 1;
267
+ guard(W, limits.maxWorkspaceDigits);
268
+ const delta = BigInt(policy.count) * u;
269
+ return [piece(C(source.lo.s + delta, source.lo.f), C(source.hi.s + delta, source.hi.f), source.il, source.ih)];
270
+ }
271
+ class PlannedText { constructor(length, render) { this.length = length; this.render = render; } }
272
+ function coordinatePlan(c, limits) {
273
+ const day = floor(c.s, 86400n).toString();
274
+ if ((day.startsWith('-') ? day.length - 1 : day.length) > limits.maxRelativeDayDigits) stop('resource_limit', 7, null);
275
+ const time = Number(c.s - floor(c.s, 86400n) * 86400n);
276
+ return { day, time: new PlannedText(8 + (c.f ? c.f.length + 1 : 0), () =>
277
+ `${String(Math.floor(time / 3600)).padStart(2, '0')}:${String(Math.floor(time / 60) % 60).padStart(2, '0')}:${String(time % 60).padStart(2, '0')}${c.f ? '.' + c.f : ''}`) };
278
+ }
279
+ function descriptor(pieces, limits) {
280
+ return { category: 'civilClockSet', pieces: pieces.map(p => same(p.lo, p.hi)
281
+ ? { kind: 'point', at: coordinatePlan(p.lo, limits) }
282
+ : { kind: 'interval', start: coordinatePlan(p.lo, limits), end: coordinatePlan(p.hi, limits), includeStart: p.il, includeEnd: p.ih }) };
283
+ }
284
+ function materialPlan(source, clock, limits) {
285
+ const coord = coordinatePlan(source.lo, limits), t = coord.time;
286
+ return new PlannedText(clock === 'hour' ? 3 : clock === 'minute' ? 5 : t.length,
287
+ () => clock === 'hour' ? t.render().slice(0, 2) + ':' : clock === 'minute' ? t.render().slice(0, 5) : t.render());
288
+ }
289
+ function finish(planned, limits) {
290
+ let size = 0; const stack = [planned];
291
+ while (stack.length) {
292
+ const v = stack.pop();
293
+ if (v instanceof PlannedText) size += v.length + 2;
294
+ else if (typeof v === 'string') size += v.length + 2;
295
+ else if (typeof v === 'boolean') size += v ? 4 : 5;
296
+ else if (Array.isArray(v)) { size += 2 + Math.max(0, v.length - 1); for (const x of v) stack.push(x); }
297
+ else { const keys = Object.keys(v); size += 2 + Math.max(0, keys.length - 1); for (const k of keys) { size += k.length + 3; stack.push(v[k]); } }
298
+ if (size > limits.maxResultBytes) stop('resource_limit', 7, null);
299
+ }
300
+ const render = v => v instanceof PlannedText ? v.render() : Array.isArray(v) ? v.map(render) : record(v) ? Object.fromEntries(Object.entries(v).map(([k, x]) => [k, render(x)])) : v;
301
+ return render(planned);
302
+ }
303
+ function evaluate(request, limits, available) {
304
+ if (!record(request)) stop('invalid_operand', 2, null);
305
+ required(request, ['operation', 'input'], '', 'invalid_operand', 2);
306
+ if (!identifier(request.operation)) stop('invalid_operand', 2, '/operation');
307
+ if (!record(request.input)) stop('invalid_operand', 2, '/input');
308
+ closed(request, ['operation', 'input'], '', 'invalid_operand', 2);
309
+ const op = request.operation, input = request.input;
310
+ closed(input, ['left', 'right', 'value', 'amount', 'context', 'policy'], '/input', 'invalid_operand', 2);
311
+ if (!available.has(op)) stop('unsupported_operation', 2, '/operation');
312
+ const binary = OPERATIONS.relations.includes(op), keys = binary ? ['left', 'right'] : op === 'shiftClock' ? ['value', 'amount'] : ['value'];
313
+ required(input, keys, '/input', 'invalid_operand', 2); closed(input, [...keys, 'context', 'policy'], '/input', 'invalid_operand', 2);
314
+ const policy = selection(input, op, limits), values = keys.map(k => k === 'amount' ? amount(input[k], limits, '/input/amount') : operand(input[k], limits, '/input/' + k));
315
+ for (let i = 0; i < values.length; i++) if (values[i].deferred) stop('unsupported_domain', 5, '/input/' + keys[i] + (keys[i] === 'amount' ? '/number/category' : '/temporal/category'));
316
+ const [a, b] = values; let td;
317
+ if (binary) { guard(a.pieces.length + b.pieces.length, limits.maxWork); td = { category: 'symbol', value: label(a.pieces, b.pieces, op) }; }
318
+ else {
319
+ let pieces;
320
+ if (op === 'shiftClock') pieces = shift(a.pieces, b, limits);
321
+ else {
322
+ guard(a.pieces.length + 1, limits.maxWork); guard(1, limits.maxIntermediatePieces);
323
+ const source = reference(a.pieces, policy.clockForm), matches = identical(a.pieces, [source]);
324
+ if (!matches || op === 'materialize' && floor(source.lo.s, 86400n) !== 0n) stop(op === 'step' ? 'incompatible_operand' : 'unrepresentable_result', op === 'step' ? 6 : 7, op === 'step' ? '/input/value/temporal' : null);
325
+ if (op === 'step') {
326
+ guard(a.pieces.length + 2, limits.maxWork); guard(2, limits.maxIntermediatePieces);
327
+ pieces = step(source, a.pieces, policy, limits);
328
+ } else pieces = [source];
329
+ }
330
+ // Final coordinate capacity (including excluded ends) precedes piece/text/bytes.
331
+ td = descriptor(pieces, limits);
332
+ if (pieces.length > limits.maxOutputPieces) stop('resource_limit', 7, null);
333
+ if (op === 'materialize') {
334
+ const text = materialPlan(pieces[0], policy.clockForm, limits);
335
+ if (text.length > limits.maxOutputCharacters) stop('resource_limit', 7, null);
336
+ td = { category: 'civilClock', value: text };
337
+ }
338
+ }
339
+ const metadata = { evaluation: 'exact-for-policy', effectivePolicy: policy }; let value;
340
+ if (binary) { value = td; metadata.operandHistory = { left: a.history, right: b.history }; metadata.operandOrigin = { left: a.origin, right: b.origin }; }
341
+ else value = { temporal: td, originClockForm: a.origin, history: op === 'shiftClock' && b.history === APPROX ? APPROX : a.history };
342
+ return finish({ outcome: 'value', value, metadata }, limits);
343
+ }
344
+
345
+ function structuredText(value, limits) {
346
+ const stack = [{ value, depth: 1 }], active = new Set(), pieces = []; let bytes = 0;
347
+ function append(text) { bytes += utf8Bytes(text, limits.maxRequestBytes - bytes); if (bytes > limits.maxRequestBytes) stop('resource_limit', 1, null); pieces.push(text); }
348
+ while (stack.length) {
349
+ const task = stack.pop();
350
+ if (task.frame) {
351
+ const { item, array, keys, index, depth } = task, length = array ? item.length : keys.length;
352
+ if (index === length) { append(array ? ']' : '}'); active.delete(item); continue; }
353
+ if (index) append(','); const key = array ? index : keys[index];
354
+ if (!array) { if (key.length > limits.maxRequestBytes) stop('resource_limit', 1, null); append(JSON.stringify(key)); append(':'); }
355
+ stack.push({ ...task, index: index + 1 }, { value: item[key], depth: depth + 1 }); continue;
356
+ }
357
+ const item = task.value;
358
+ if (item instanceof RationalJsonNumber) { if (item.text.length > limits.maxRequestBytes) stop('resource_limit', 1, null); append(item.text); }
359
+ else if (item !== null && typeof item === 'object') {
360
+ if (task.depth > limits.maxRequestDepth) stop('resource_limit', 1, null);
361
+ if (active.has(item)) stop('invalid_operand', 2, null);
362
+ const array = Array.isArray(item);
363
+ if (!array && ![Object.prototype, null].includes(Object.getPrototypeOf(item))) throw new TypeError('Structured ingress requires JSON values');
364
+ append(array ? '[' : '{'); active.add(item);
365
+ stack.push({ frame: true, item, array, keys: array ? null : Object.keys(item), index: 0, depth: task.depth });
366
+ } else {
367
+ if (typeof item === 'string' && item.length > limits.maxRequestBytes) stop('resource_limit', 1, null);
368
+ if (typeof item === 'number' && !Number.isFinite(item)) throw new TypeError('Structured ingress requires JSON values');
369
+ const text = JSON.stringify(item); if (text === undefined) throw new TypeError('Structured ingress requires JSON values'); append(text);
370
+ }
371
+ }
372
+ return pieces.join('');
373
+ }
374
+ export function evaluateAeonicCivilClockText(text, options = {}) {
375
+ const { limits, available } = configured(options);
376
+ if (typeof text !== 'string') throw new TypeError('requestText must be text');
377
+ return guarded(() => {
378
+ if (!scalar(text)) stop('invalid_operand', 1, null);
379
+ if (text.length > limits.maxRequestBytes || utf8Bytes(text, limits.maxRequestBytes) > limits.maxRequestBytes || exceedsJsonDepth(text, limits.maxRequestDepth)) stop('resource_limit', 1, null);
380
+ let request; try { request = parseStrictJson(text); } catch (e) { if (e instanceof SyntaxError) stop('invalid_operand', 2, null); throw e; }
381
+ return evaluate(request, limits, available);
382
+ });
383
+ }
384
+ export function evaluateAeonicCivilClockStructuredJson(request, options = {}) {
385
+ const { limits } = configured(options);
386
+ return guarded(() => evaluateAeonicCivilClockText(structuredText(request, limits), options));
387
+ }
388
+ export const evaluateAeonicCivilClock = evaluateAeonicCivilClockStructuredJson;
@@ -0,0 +1,123 @@
1
+ export const AEONIC_TEMPORAL_CIVIL_DATE_PROFILE: 'aeonic.operations.temporal.civil-date.v1';
2
+ export interface AeonicTemporalResourceLimits {
3
+ readonly maxRequestBytes: number;
4
+ readonly maxRequestDepth: number;
5
+ readonly maxInputRanges: number;
6
+ readonly maxCountCharacters: number;
7
+ readonly maxOutputRanges: number;
8
+ readonly maxCalendarWork: number;
9
+ readonly maxOutputCharacters: number;
10
+ readonly maxResultBytes: number;
11
+ }
12
+ export const AEONIC_TEMPORAL_CIVIL_DATE_DEFAULT_RESOURCE_LIMITS: Readonly<AeonicTemporalResourceLimits>;
13
+ export type AeonicTemporalCapability = 'relations' | 'calendar';
14
+ export interface AeonicTemporalOptions {
15
+ readonly resourceLimits?: Partial<AeonicTemporalResourceLimits>;
16
+ readonly capabilities?: readonly AeonicTemporalCapability[];
17
+ }
18
+ export type AeonicTemporalGranularity = 'day' | 'month' | 'year';
19
+ export type AeonicTemporalOrigin = AeonicTemporalGranularity | 'undeclared';
20
+ export type AeonicTemporalHistory = 'none-declared' | 'clamping-declared';
21
+ export interface AeonicCivilDate { readonly category: 'civilDate'; readonly value: string }
22
+ export interface AeonicCivilDateRange { readonly start: string; readonly end: string }
23
+ export interface AeonicCivilDateSet {
24
+ readonly category: 'civilDateSet';
25
+ /** Nonempty, sorted inclusive full-date ranges; disjoint and nonadjacent. */
26
+ readonly ranges: readonly AeonicCivilDateRange[];
27
+ }
28
+ export interface AeonicAuthoredDateBundle {
29
+ readonly temporal: AeonicCivilDate;
30
+ readonly originGranularity?: AeonicTemporalOrigin;
31
+ readonly history?: AeonicTemporalHistory;
32
+ }
33
+ export interface AeonicDerivedDateBundle {
34
+ readonly temporal: AeonicCivilDateSet;
35
+ readonly originGranularity: AeonicTemporalOrigin;
36
+ readonly history: AeonicTemporalHistory;
37
+ }
38
+ /** Successful materialization retains metadata; bare date text does not. */
39
+ export interface AeonicMaterializedDateBundle {
40
+ readonly temporal: AeonicCivilDate;
41
+ readonly originGranularity: AeonicTemporalOrigin;
42
+ readonly history: AeonicTemporalHistory;
43
+ }
44
+ export type AeonicTemporalOperand = AeonicAuthoredDateBundle | AeonicDerivedDateBundle;
45
+ export type AeonicTemporalValue = AeonicDerivedDateBundle | AeonicMaterializedDateBundle;
46
+ export interface AeonicTemporalProfile { readonly profile?: string }
47
+ export interface AeonicTemporalRelationRequest {
48
+ readonly operation: 'equal' | 'compare' | 'relate';
49
+ readonly input: {
50
+ readonly left: AeonicTemporalOperand;
51
+ readonly right: AeonicTemporalOperand;
52
+ readonly context?: AeonicTemporalProfile;
53
+ readonly policy?: AeonicTemporalProfile;
54
+ };
55
+ }
56
+ export interface AeonicTemporalShiftRequest {
57
+ readonly operation: 'shift';
58
+ readonly input: {
59
+ readonly value: AeonicTemporalOperand;
60
+ readonly context?: AeonicTemporalProfile;
61
+ readonly policy: AeonicTemporalProfile & {
62
+ readonly unit: AeonicTemporalGranularity | 'eom' | 'eoy';
63
+ /** Canonical signed whole-number text; no implicit fractional calendar units. */
64
+ readonly count: string;
65
+ };
66
+ };
67
+ }
68
+ export interface AeonicTemporalStepRequest {
69
+ readonly operation: 'step';
70
+ readonly input: {
71
+ readonly value: AeonicTemporalOperand;
72
+ readonly context?: AeonicTemporalProfile;
73
+ readonly policy: AeonicTemporalProfile & { readonly granularity: AeonicTemporalGranularity; readonly count: string };
74
+ };
75
+ }
76
+ export interface AeonicTemporalMaterializeRequest {
77
+ readonly operation: 'materialize';
78
+ readonly input: {
79
+ readonly value: AeonicTemporalOperand;
80
+ readonly context?: AeonicTemporalProfile;
81
+ readonly policy: AeonicTemporalProfile & { readonly granularity: AeonicTemporalGranularity };
82
+ };
83
+ }
84
+ export type AeonicTemporalCalendarRequest = AeonicTemporalShiftRequest | AeonicTemporalStepRequest | AeonicTemporalMaterializeRequest;
85
+ export type AeonicTemporalRequest = AeonicTemporalCalendarRequest | AeonicTemporalRelationRequest;
86
+ export interface AeonicTemporalDiagnostic {
87
+ readonly outcome: 'diagnostic';
88
+ readonly reason: 'invalid_operand' | 'invalid_policy' | 'unsupported_profile' | 'unsupported_operation'
89
+ | 'unsupported_domain' | 'incompatible_operand' | 'unrepresentable_result' | 'resource_limit';
90
+ readonly context: { readonly stage: 1 | 2 | 3 | 4 | 5 | 6 | 7; readonly path: string | null };
91
+ readonly message?: string;
92
+ }
93
+ export interface AeonicTemporalMetadata {
94
+ readonly evaluation: 'exact-for-policy';
95
+ readonly clamping: 'applied' | 'not-applied';
96
+ readonly effectivePolicy: {
97
+ readonly profile: typeof AEONIC_TEMPORAL_CIVIL_DATE_PROFILE;
98
+ readonly unit?: AeonicTemporalGranularity | 'eom' | 'eoy';
99
+ readonly count?: string;
100
+ readonly granularity?: AeonicTemporalGranularity;
101
+ };
102
+ }
103
+ export interface AeonicTemporalCalendarValueResult {
104
+ readonly outcome: 'value';
105
+ readonly value: AeonicTemporalValue;
106
+ readonly metadata: AeonicTemporalMetadata;
107
+ }
108
+ export interface AeonicTemporalRelationValueResult {
109
+ readonly outcome: 'value';
110
+ readonly value: { readonly category: 'symbol'; readonly value: 'equal' | 'notEqual' | 'before' | 'after' | 'indeterminate' | 'contains' | 'containedBy' | 'overlaps' | 'disjoint' };
111
+ readonly metadata: AeonicTemporalMetadata & {
112
+ readonly operandHistory: { readonly left: AeonicTemporalHistory; readonly right: AeonicTemporalHistory };
113
+ };
114
+ }
115
+ export type AeonicTemporalCalendarResult = AeonicTemporalCalendarValueResult | AeonicTemporalDiagnostic;
116
+ export type AeonicTemporalRelationResult = AeonicTemporalRelationValueResult | AeonicTemporalDiagnostic;
117
+ export type AeonicTemporalResult = AeonicTemporalCalendarValueResult | AeonicTemporalRelationValueResult | AeonicTemporalDiagnostic;
118
+ /** Explicit profile selection required at runtime. Complete returned bundles can chain directly. */
119
+ export function evaluateAeonicTemporal(request: AeonicTemporalCalendarRequest, options?: AeonicTemporalOptions): AeonicTemporalCalendarResult;
120
+ export function evaluateAeonicTemporal(request: AeonicTemporalRelationRequest, options?: AeonicTemporalOptions): AeonicTemporalRelationResult;
121
+ export function evaluateAeonicTemporal(request: AeonicTemporalRequest, options?: AeonicTemporalOptions): AeonicTemporalResult;
122
+ /** Verbatim scalar JSON ingress, preserving duplicate keys and raw numeric token widths for validation. */
123
+ export function evaluateAeonicTemporalText(requestText: string, options?: AeonicTemporalOptions): AeonicTemporalResult;