@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.
- package/CHANGELOG.md +133 -1
- package/README.md +98 -1
- package/conformance/README.md +8 -0
- package/conformance/aeonic-anchor-claims.json +133 -0
- package/conformance/aeonic-arithmetic-claims.json +60 -0
- package/conformance/aeonic-clock-claims.json +123 -0
- package/conformance/aeonic-comparison-claims.json +37 -0
- package/conformance/aeonic-datetime-claims.json +110 -0
- package/conformance/aeonic-rational-arithmetic-claims.json +72 -0
- package/conformance/aeonic-temporal-claims.json +105 -0
- package/conformance/cts-claims.json +17 -3
- package/conformance/results/aeonic-anchor-bounded-expansion-2026-11-24.json +39 -0
- package/conformance/results/aeonic-anchor-capacity-bounded-expansion-2026-11-24.json +452 -0
- package/conformance/results/aeonic-anchor-capacity-rc3-2026-11-24.json +452 -0
- package/conformance/results/aeonic-anchor-capacity.json +452 -0
- package/conformance/results/aeonic-anchor-rc3-2026-11-24.json +39 -0
- package/conformance/results/aeonic-anchor-snapshot-0.1.json +39 -0
- package/conformance/results/aeonic-arithmetic-snapshot-0.1.json +28 -0
- package/conformance/results/aeonic-clock-all-bounded-expansion-2026-11-24.json +49 -0
- package/conformance/results/aeonic-clock-all-rc3-2026-11-24.json +49 -0
- package/conformance/results/aeonic-clock-all-snapshot-0.1.json +49 -0
- package/conformance/results/aeonic-clock-arithmetic-bounded-expansion-2026-11-24.json +48 -0
- package/conformance/results/aeonic-clock-arithmetic-rc3-2026-11-24.json +48 -0
- package/conformance/results/aeonic-clock-arithmetic-snapshot-0.1.json +48 -0
- package/conformance/results/aeonic-clock-capacity-bounded-expansion-2026-11-24.json +326 -0
- package/conformance/results/aeonic-clock-capacity-rc3-2026-11-24.json +326 -0
- package/conformance/results/aeonic-clock-capacity.json +326 -0
- package/conformance/results/aeonic-clock-relations-bounded-expansion-2026-11-24.json +48 -0
- package/conformance/results/aeonic-clock-relations-rc3-2026-11-24.json +48 -0
- package/conformance/results/aeonic-clock-relations-snapshot-0.1.json +48 -0
- package/conformance/results/aeonic-comparison-snapshot-0.1.json +19 -0
- package/conformance/results/aeonic-datetime-all-bounded-expansion-2026-11-24.json +47 -0
- package/conformance/results/aeonic-datetime-all-rc3-2026-11-24.json +47 -0
- package/conformance/results/aeonic-datetime-all-snapshot-0.1.json +47 -0
- package/conformance/results/aeonic-datetime-arithmetic-bounded-expansion-2026-11-24.json +46 -0
- package/conformance/results/aeonic-datetime-arithmetic-rc3-2026-11-24.json +46 -0
- package/conformance/results/aeonic-datetime-arithmetic-snapshot-0.1.json +46 -0
- package/conformance/results/aeonic-datetime-capacity-bounded-expansion-2026-11-24.json +302 -0
- package/conformance/results/aeonic-datetime-capacity-rc3-2026-11-24.json +302 -0
- package/conformance/results/aeonic-datetime-capacity.json +302 -0
- package/conformance/results/aeonic-datetime-relations-bounded-expansion-2026-11-24.json +46 -0
- package/conformance/results/aeonic-datetime-relations-rc3-2026-11-24.json +46 -0
- package/conformance/results/aeonic-datetime-relations-snapshot-0.1.json +46 -0
- package/conformance/results/aeonic-rational-arithmetic-capacity.json +100 -0
- package/conformance/results/aeonic-rational-arithmetic-snapshot-0.2.json +30 -0
- package/conformance/results/aeonic-temporal-all-bounded-expansion-2026-11-24.json +39 -0
- package/conformance/results/aeonic-temporal-all-property-addressing-2026-11-16.json +39 -0
- package/conformance/results/aeonic-temporal-all-rc3-2026-11-24.json +39 -0
- package/conformance/results/aeonic-temporal-all-snapshot-0.1.json +39 -0
- package/conformance/results/aeonic-temporal-calendar-bounded-expansion-2026-11-24.json +38 -0
- package/conformance/results/aeonic-temporal-calendar-property-addressing-2026-11-16.json +38 -0
- package/conformance/results/aeonic-temporal-calendar-rc3-2026-11-24.json +38 -0
- package/conformance/results/aeonic-temporal-calendar-snapshot-0.1.json +38 -0
- package/conformance/results/aeonic-temporal-capacity-bounded-expansion-2026-11-24.json +136 -0
- package/conformance/results/aeonic-temporal-capacity-property-addressing-2026-11-16.json +136 -0
- package/conformance/results/aeonic-temporal-capacity-rc3-2026-11-24.json +136 -0
- package/conformance/results/aeonic-temporal-capacity.json +136 -0
- package/conformance/results/aeonic-temporal-relations-bounded-expansion-2026-11-24.json +38 -0
- package/conformance/results/aeonic-temporal-relations-property-addressing-2026-11-16.json +38 -0
- package/conformance/results/aeonic-temporal-relations-rc3-2026-11-24.json +38 -0
- package/conformance/results/aeonic-temporal-relations-snapshot-0.1.json +38 -0
- package/docs/aeonic-arithmetic.md +126 -0
- package/docs/aeonic-comparison.md +123 -0
- package/docs/aeonic-rational-arithmetic.md +167 -0
- package/docs/aeonic-temporal-civil-anchor.md +89 -0
- package/docs/aeonic-temporal-civil-clock.md +100 -0
- package/docs/aeonic-temporal-civil-date.md +124 -0
- package/docs/aeonic-temporal-civil-datetime.md +122 -0
- package/docs/api-contract.md +130 -3
- package/docs/capabilities.json +106 -2
- package/docs/child-identity-activation.md +93 -0
- package/docs/child-identity-candidate.md +60 -0
- package/docs/child-identity-tooling.md +31 -0
- package/docs/child-identity-workflows.md +102 -0
- package/docs/empty-keys-candidate.md +29 -0
- package/docs/migration-0.15.0.md +86 -0
- package/docs/property-addressing-implementation.md +118 -0
- package/docs/property-resolve-implementation.md +105 -0
- package/docs/property-selector-support.md +65 -0
- package/docs/property-selectors-api.d.ts +43 -0
- package/docs/property-selectors-api.pyi +27 -0
- package/docs/property-selectors-api.rs +48 -0
- package/docs/property-selectors-contract.md +168 -0
- package/docs/query-tool.md +32 -1
- package/docs/selector-cursor.md +45 -0
- package/docs/unicode-hardening.md +41 -0
- package/fixtures/address-v1.json +4 -3
- package/fixtures/child-identity-workflows/README.md +9 -0
- package/fixtures/child-identity-workflows/moved.aeon +10 -0
- package/fixtures/child-identity-workflows/original.aeon +10 -0
- package/fixtures/child-identity-workflows/reordered.aeon +10 -0
- package/fixtures/child-identity-workflows/replacement.aeon +10 -0
- package/fixtures/child-identity-workflows/workflows.json +89 -0
- package/fixtures/property-namespace-candidate-v1.json +336 -0
- package/fixtures/property-parser-candidate-v1.json +705 -0
- package/fixtures/property-query-candidate-v1.json +398 -0
- package/fixtures/property-resolve-candidate-v1.json +2702 -0
- package/fixtures/unicode-hardening-v1.json +401 -0
- package/package.json +30 -3
- package/scripts/calibrate-aeonic-anchor-capacity.py +294 -0
- package/scripts/calibrate-aeonic-clock-capacity.py +62 -0
- package/scripts/calibrate-aeonic-datetime-capacity.py +76 -0
- package/scripts/calibrate-aeonic-rational-capacity.py +85 -0
- package/scripts/calibrate-aeonic-temporal-capacity.py +95 -0
- package/scripts/cts-address.mjs +6 -2
- package/scripts/cts-aeonic-anchor.mjs +21 -0
- package/scripts/cts-aeonic-arithmetic-adapter.mjs +25 -0
- package/scripts/cts-aeonic-arithmetic.mjs +24 -0
- package/scripts/cts-aeonic-clock.mjs +24 -0
- package/scripts/cts-aeonic-comparison-adapter.mjs +30 -0
- package/scripts/cts-aeonic-comparison.mjs +25 -0
- package/scripts/cts-aeonic-datetime.mjs +24 -0
- package/scripts/cts-aeonic-rational-arithmetic-adapter.mjs +25 -0
- package/scripts/cts-aeonic-rational-arithmetic.mjs +24 -0
- package/scripts/cts-aeonic-temporal-civil-anchor-adapter.mjs +26 -0
- package/scripts/cts-aeonic-temporal-civil-clock-adapter.mjs +28 -0
- package/scripts/cts-aeonic-temporal-civil-date-adapter.mjs +28 -0
- package/scripts/cts-aeonic-temporal-civil-datetime-adapter.mjs +28 -0
- package/scripts/cts-aeonic-temporal.mjs +24 -0
- package/scripts/cts-instruction.mjs +4 -2
- package/scripts/cts-mutate.mjs +3 -2
- package/scripts/cts-resolve.mjs +17 -2
- package/scripts/playground.mjs +110 -0
- package/src/aeonic-arithmetic-binding.js +61 -0
- package/src/aeonic-arithmetic.d.ts +84 -0
- package/src/aeonic-arithmetic.js +276 -0
- package/src/aeonic-comparison.d.ts +86 -0
- package/src/aeonic-comparison.js +274 -0
- package/src/aeonic-convenience.d.ts +30 -0
- package/src/aeonic-convenience.js +45 -0
- package/src/aeonic-exact-number.js +34 -0
- package/src/aeonic-json.js +45 -0
- package/src/aeonic-rational-arithmetic.d.ts +86 -0
- package/src/aeonic-rational-arithmetic.js +417 -0
- package/src/aeonic-rational-json.js +51 -0
- package/src/aeonic-temporal-civil-anchor.d.ts +54 -0
- package/src/aeonic-temporal-civil-anchor.js +316 -0
- package/src/aeonic-temporal-civil-clock.d.ts +124 -0
- package/src/aeonic-temporal-civil-clock.js +388 -0
- package/src/aeonic-temporal-civil-date.d.ts +123 -0
- package/src/aeonic-temporal-civil-date.js +310 -0
- package/src/aeonic-temporal-civil-datetime.d.ts +138 -0
- package/src/aeonic-temporal-civil-datetime.js +501 -0
- package/src/index.d.ts +84 -1
- package/src/index.js +859 -190
- package/src/property-address.js +196 -0
- package/src/property-resolve.js +132 -0
- package/src/query-metadata.d.ts +16 -0
- package/src/query-metadata.js +25 -0
- package/src/selector-cursor.d.ts +19 -0
- package/src/selector-cursor.js +79 -0
- package/stress-tests/address/invalid.sansa-cases +0 -2
- package/stress-tests/address/valid.sansa-cases +3 -0
- package/tools/mutate-web/examples.mjs +1 -1
- package/tools/mutate-web/runtime.mjs +0 -2
- package/tools/playground/README.md +165 -0
- package/tools/playground/accessibility.js +91 -0
- package/tools/playground/aeon-highlight.js +77 -0
- package/tools/playground/aeon-source-composer.js +1077 -0
- package/tools/playground/anchor-examples.mjs +16 -0
- package/tools/playground/arithmetic-evaluator.mjs +28 -0
- package/tools/playground/arithmetic-model.mjs +187 -0
- package/tools/playground/arithmetic-worker.mjs +14 -0
- package/tools/playground/arithmetic.css +1 -0
- package/tools/playground/arithmetic.html +29 -0
- package/tools/playground/arithmetic.mjs +110 -0
- package/tools/playground/clock-examples.mjs +16 -0
- package/tools/playground/datetime-examples.mjs +22 -0
- package/tools/playground/examples.mjs +46 -0
- package/tools/playground/index.html +174 -0
- package/tools/playground/local.css +25 -0
- package/tools/playground/namespace.mjs +39 -0
- package/tools/playground/sansa-playground.js +1565 -0
- package/tools/playground/site.css +3914 -0
- package/tools/playground/temporal-examples.mjs +20 -0
- package/tools/playground/walkthrough.js +90 -0
- package/tools/playground/website-origin.json +16 -0
- package/tools/query-web/IDENTITY_SELECTORS.md +44 -0
- package/tools/query-web/app.js +4 -0
- package/tools/query-web/index.html +4 -0
- package/tools/query-web/runtime.mjs +70 -19
- package/tools/workflows/property-playground-assertions.mjs +33 -0
- package/tools/workflows/verify-child-identities.mjs +137 -0
- package/tools/workflows/verify-property-playground.mjs +48 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
// Adapted from AltoPelago/aeonic at 627219ac90fdd09d17bfd0a3c25db717305d1d0f.
|
|
2
|
+
// Copyright (c) 2026 Patrik. MIT; see LICENSE and docs/aeonic-temporal-civil-date.md.
|
|
3
|
+
// Bounded UTF-8 count keeps the adapted engine 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_DATE_PROFILE = 'aeonic.operations.temporal.civil-date.v1';
|
|
17
|
+
export const AEONIC_TEMPORAL_CIVIL_DATE_DEFAULT_RESOURCE_LIMITS = Object.freeze({ maxRequestBytes: 16384, maxRequestDepth: 32,
|
|
18
|
+
maxInputRanges: 128, maxCountCharacters: 32, maxOutputRanges: 128, maxCalendarWork: 4096,
|
|
19
|
+
maxOutputCharacters: 10, maxResultBytes: 16384 });
|
|
20
|
+
const OPERATIONS = { relations: ['equal', 'compare', 'relate'], calendar: ['shift', 'step', 'materialize'] };
|
|
21
|
+
const DEFERRED = new Set(['finiteNumber', 'exactNumber', 'exactRational', 'string', 'boolean', 'symbol',
|
|
22
|
+
'positiveInfinity', 'negativeInfinity', 'nan', 'explicitNull', 'explicitAbsence', 'toggle', 'hex', 'radix',
|
|
23
|
+
'encoding', 'separator', 'sansaAddress', 'referenceForm', 'temporal', 'container']);
|
|
24
|
+
const GRAINS = ['day', 'month', 'year'], NONE = 'none-declared', MARKED = 'clamping-declared';
|
|
25
|
+
const record = v => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
26
|
+
const scalar = v => typeof v === 'string' && !/[\uD800-\uDFFF]/u.test(v);
|
|
27
|
+
const identifier = v => scalar(v) && v.length > 0;
|
|
28
|
+
const pointer = (p, k) => scalar(k) ? p + '/' + k.replaceAll('~', '~0').replaceAll('/', '~1') : null;
|
|
29
|
+
function scalarOrder(a, b) {
|
|
30
|
+
const x = a[Symbol.iterator](), y = b[Symbol.iterator]();
|
|
31
|
+
for (;;) { const p = x.next(), q = y.next();
|
|
32
|
+
if (p.done || q.done) return p.done === q.done ? 0 : p.done ? -1 : 1;
|
|
33
|
+
if (p.value !== q.value) return p.value.codePointAt(0) - q.value.codePointAt(0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class Failure extends Error {
|
|
37
|
+
constructor(reason, stage, path) { super(reason); this.result = { outcome: 'diagnostic', reason, context: { stage, path } }; }
|
|
38
|
+
}
|
|
39
|
+
function stop(reason, stage, path) { throw new Failure(reason, stage, path); }
|
|
40
|
+
function guarded(action) { try { return action(); } catch (e) { if (e instanceof Failure) return e.result; throw e; } }
|
|
41
|
+
function required(v, fields, path, reason, stage) {
|
|
42
|
+
for (const k of fields) if (!Object.hasOwn(v, k)) stop(reason, stage, pointer(path, k));
|
|
43
|
+
}
|
|
44
|
+
function closed(v, fields, path, reason, stage) {
|
|
45
|
+
for (const k of Object.keys(v).sort(scalarOrder)) if (!fields.includes(k)) stop(reason, stage, pointer(path, k));
|
|
46
|
+
}
|
|
47
|
+
function configured(options) {
|
|
48
|
+
if (!record(options) || Object.keys(options).some(k => !['resourceLimits', 'capabilities'].includes(k))) throw new TypeError('Invalid trusted options');
|
|
49
|
+
const supplied = Object.hasOwn(options, 'resourceLimits') ? options.resourceLimits : {};
|
|
50
|
+
if (!record(supplied)) throw new TypeError('resourceLimits must be an object');
|
|
51
|
+
for (const [k, v] of Object.entries(supplied)) {
|
|
52
|
+
if (!Object.hasOwn(AEONIC_TEMPORAL_CIVIL_DATE_DEFAULT_RESOURCE_LIMITS, k) || !Number.isSafeInteger(v) || v < 0) throw new TypeError('Invalid resource limit: ' + k);
|
|
53
|
+
}
|
|
54
|
+
const capabilities = Object.hasOwn(options, 'capabilities') ? options.capabilities : ['relations', 'calendar'];
|
|
55
|
+
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');
|
|
56
|
+
return { limits: { ...AEONIC_TEMPORAL_CIVIL_DATE_DEFAULT_RESOURCE_LIMITS, ...supplied }, available: new Set(capabilities.flatMap(k => OPERATIONS[k])) };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Pure civil calendar: no host Date, timezone or floating-point epoch conversion.
|
|
60
|
+
const leap = y => y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0);
|
|
61
|
+
const monthLength = (y, m) => m === 2 ? leap(y) ? 29 : 28 : [4, 6, 9, 11].includes(m) ? 30 : 31;
|
|
62
|
+
const yearStart = y => 365 * (y - 1) + Math.floor((y - 1) / 4) - Math.floor((y - 1) / 100) + Math.floor((y - 1) / 400) + 1;
|
|
63
|
+
function ordinal(y, m, d) { let n = yearStart(y) + d - 1; for (let k = 1; k < m; k++) n += monthLength(y, k); return n; }
|
|
64
|
+
const LAST = yearStart(10000) - 1;
|
|
65
|
+
function date(n) {
|
|
66
|
+
let lo = 1, hi = 9999;
|
|
67
|
+
while (lo < hi) { const mid = Math.ceil((lo + hi) / 2); if (yearStart(mid) <= n) lo = mid; else hi = mid - 1; }
|
|
68
|
+
let m = 1, d = n - yearStart(lo) + 1;
|
|
69
|
+
while (d > monthLength(lo, m)) { d -= monthLength(lo, m); m++; }
|
|
70
|
+
return { y: lo, m, d };
|
|
71
|
+
}
|
|
72
|
+
const monthIndex = d => 12 * (d.y - 1) + d.m - 1;
|
|
73
|
+
const monthAt = n => ({ y: Math.floor(n / 12) + 1, m: n % 12 + 1 });
|
|
74
|
+
const fullText = n => { const d = date(n); return `${String(d.y).padStart(4, '0')}-${String(d.m).padStart(2, '0')}-${String(d.d).padStart(2, '0')}`; };
|
|
75
|
+
function literal(text, path, full = false) {
|
|
76
|
+
const pattern = full ? /^[0-9]{4}-[0-9]{2}-[0-9]{2}$(?![\s\S])/u : /^(?:[0-9]{4}-|[0-9]{4}-[0-9]{2}|[0-9]{4}-[0-9]{2}-[0-9]{2})$(?![\s\S])/u;
|
|
77
|
+
if (typeof text !== 'string' || !pattern.test(text)) stop('invalid_operand', 4, path);
|
|
78
|
+
const y = Number(text.slice(0, 4)), m = text.length > 5 ? Number(text.slice(5, 7)) : 1, d = text.length > 7 ? Number(text.slice(8)) : 1;
|
|
79
|
+
if (y < 1 || m < 1 || m > 12 || d < 1 || d > monthLength(y, m)) stop('invalid_operand', 4, path);
|
|
80
|
+
const granularity = text.length === 5 ? 'year' : text.length === 7 ? 'month' : 'day';
|
|
81
|
+
const start = ordinal(y, m, d), end = granularity === 'year' ? yearStart(y + 1) - 1 : granularity === 'month' ? ordinal(y, m, monthLength(y, m)) : start;
|
|
82
|
+
return { ranges: [[start, end]], granularity };
|
|
83
|
+
}
|
|
84
|
+
function operand(v, limits, path) {
|
|
85
|
+
if (!record(v)) stop('invalid_operand', 4, path);
|
|
86
|
+
required(v, ['temporal'], path, 'invalid_operand', 4);
|
|
87
|
+
const t = v.temporal, at = path + '/temporal';
|
|
88
|
+
if (!record(t)) stop('invalid_operand', 4, at);
|
|
89
|
+
if (typeof t.category !== 'string' || (!['civilDate', 'civilDateSet'].includes(t.category) && !DEFERRED.has(t.category))) stop('invalid_operand', 4, at + '/category');
|
|
90
|
+
if (t.category === 'civilDateSet') required(v, ['originGranularity', 'history'], path, 'invalid_operand', 4);
|
|
91
|
+
closed(v, ['temporal', 'originGranularity', 'history'], path, 'invalid_operand', 4);
|
|
92
|
+
const history = Object.hasOwn(v, 'history') ? v.history : NONE;
|
|
93
|
+
if (![NONE, MARKED].includes(history)) stop('invalid_operand', 4, path + '/history');
|
|
94
|
+
if (Object.hasOwn(v, 'originGranularity') && ![...GRAINS, 'undeclared'].includes(v.originGranularity)) stop('invalid_operand', 4, path + '/originGranularity');
|
|
95
|
+
if (DEFERRED.has(t.category)) return { deferred: true };
|
|
96
|
+
if (t.category === 'civilDate') {
|
|
97
|
+
required(t, ['value'], at, 'invalid_operand', 4); closed(t, ['category', 'value'], at, 'invalid_operand', 4);
|
|
98
|
+
if (limits.maxInputRanges < 1) stop('resource_limit', 4, at);
|
|
99
|
+
const parsed = literal(t.value, at + '/value');
|
|
100
|
+
return { ranges: parsed.ranges, origin: v.originGranularity ?? parsed.granularity, history };
|
|
101
|
+
}
|
|
102
|
+
required(t, ['ranges'], at, 'invalid_operand', 4); closed(t, ['category', 'ranges'], at, 'invalid_operand', 4);
|
|
103
|
+
if (!Array.isArray(t.ranges) || !t.ranges.length) stop('invalid_operand', 4, at + '/ranges');
|
|
104
|
+
if (t.ranges.length > limits.maxInputRanges) stop('resource_limit', 4, at + '/ranges');
|
|
105
|
+
const ranges = [];
|
|
106
|
+
for (let i = 0; i < t.ranges.length; i++) {
|
|
107
|
+
const r = t.ranges[i], p = at + '/ranges/' + i;
|
|
108
|
+
if (!record(r)) stop('invalid_operand', 4, p);
|
|
109
|
+
required(r, ['start', 'end'], p, 'invalid_operand', 4); closed(r, ['start', 'end'], p, 'invalid_operand', 4);
|
|
110
|
+
const start = literal(r.start, p + '/start', true).ranges[0][0], end = literal(r.end, p + '/end', true).ranges[0][0];
|
|
111
|
+
if (start > end) stop('invalid_operand', 4, p + '/end');
|
|
112
|
+
if (ranges.length && start <= ranges.at(-1)[1] + 1) stop('invalid_operand', 4, p + '/start');
|
|
113
|
+
ranges.push([start, end]);
|
|
114
|
+
}
|
|
115
|
+
return { ranges, origin: v.originGranularity, history };
|
|
116
|
+
}
|
|
117
|
+
function selection(input, op, limits) {
|
|
118
|
+
const extras = op === 'shift' ? ['unit', 'count'] : op === 'step' ? ['granularity', 'count'] : op === 'materialize' ? ['granularity'] : [];
|
|
119
|
+
for (const key of ['context', 'policy']) {
|
|
120
|
+
const path = '/input/' + key;
|
|
121
|
+
if (!Object.hasOwn(input, key)) { if (key === 'policy' && extras.length) stop('invalid_policy', 3, path); continue; }
|
|
122
|
+
if (!record(input[key])) stop('invalid_policy', 3, path);
|
|
123
|
+
if (key === 'policy') required(input[key], extras, path, 'invalid_policy', 3);
|
|
124
|
+
closed(input[key], ['profile', ...(key === 'policy' ? extras : [])], path, 'invalid_policy', 3);
|
|
125
|
+
}
|
|
126
|
+
for (const key of ['context', 'policy']) if (Object.hasOwn(input[key] ?? {}, 'profile') && !identifier(input[key].profile)) stop('invalid_policy', 3, '/input/' + key + '/profile');
|
|
127
|
+
const p = input.policy ?? {};
|
|
128
|
+
if (op === 'shift' && !['day', 'month', 'year', 'eom', 'eoy'].includes(p.unit)) stop('invalid_policy', 3, '/input/policy/unit');
|
|
129
|
+
if (['step', 'materialize'].includes(op) && !GRAINS.includes(p.granularity)) stop('invalid_policy', 3, '/input/policy/granularity');
|
|
130
|
+
if (['shift', 'step'].includes(op)) {
|
|
131
|
+
if (typeof p.count !== 'string') stop('invalid_policy', 3, '/input/policy/count');
|
|
132
|
+
let characters = 0;
|
|
133
|
+
for (const ch of p.count) if (++characters > limits.maxCountCharacters) stop('resource_limit', 3, '/input/policy/count');
|
|
134
|
+
if (!/^(?:0|-?[1-9][0-9]*)$(?![\s\S])/u.test(p.count)) stop('invalid_policy', 3, '/input/policy/count');
|
|
135
|
+
}
|
|
136
|
+
const owner = Object.hasOwn(p, 'profile') ? 'policy' : Object.hasOwn(input.context ?? {}, 'profile') ? 'context' : null;
|
|
137
|
+
if (!owner || input[owner].profile !== AEONIC_TEMPORAL_CIVIL_DATE_PROFILE) stop('unsupported_profile', 3, owner ? '/input/' + owner + '/profile' : null);
|
|
138
|
+
return { profile: AEONIC_TEMPORAL_CIVIL_DATE_PROFILE, ...Object.fromEntries(extras.map(k => [k, p[k]])) };
|
|
139
|
+
}
|
|
140
|
+
function countValue(text, unit) {
|
|
141
|
+
const magnitude = text.replace(/^-/, ''), bound = String(unit === 'day' ? LAST : ['month', 'eom'].includes(unit) ? 119988 : 9999);
|
|
142
|
+
if (magnitude.length > bound.length || (magnitude.length === bound.length && magnitude > bound)) stop('unrepresentable_result', 6, null);
|
|
143
|
+
return Number(text); // At most seven digits, after lexical domain guard.
|
|
144
|
+
}
|
|
145
|
+
function period(ranges, grain) {
|
|
146
|
+
if (ranges.length !== 1) return false;
|
|
147
|
+
const [a, b] = ranges[0], d = date(a);
|
|
148
|
+
return grain === 'day' ? a === b : grain === 'month' ? d.d === 1 && b === ordinal(d.y, d.m, monthLength(d.y, d.m)) : a === yearStart(d.y) && b === yearStart(d.y + 1) - 1;
|
|
149
|
+
}
|
|
150
|
+
function domain(ranges, unit, count) {
|
|
151
|
+
const first = ranges[0][0], last = ranges.at(-1)[1];
|
|
152
|
+
const within = (a, b, lo, hi) => { if (a < lo || b > hi) stop('unrepresentable_result', 6, null); };
|
|
153
|
+
if (unit === 'day') within(first + count, last + count, 1, LAST);
|
|
154
|
+
else if (unit === 'eoy') within(date(first).y + count, date(last).y + count, 1, 9999);
|
|
155
|
+
else { const n = unit === 'year' ? count * 12 : count; within(monthIndex(date(first)) + n, monthIndex(date(last)) + n, 0, 119987); }
|
|
156
|
+
}
|
|
157
|
+
function work(ranges, op, unit, count, limits, right) {
|
|
158
|
+
let total = op === 'step' || op === 'materialize' ? 1 : right ? ranges.length + right.length : 0;
|
|
159
|
+
if (!right && op === 'shift') for (const [a, b] of ranges) {
|
|
160
|
+
total += count === 0 || unit === 'day' ? 1 : unit === 'eoy' ? date(b).y - date(a).y + 1 : monthIndex(date(b)) - monthIndex(date(a)) + 1;
|
|
161
|
+
if (total > limits.maxCalendarWork) stop('resource_limit', 6, null);
|
|
162
|
+
}
|
|
163
|
+
if (total > limits.maxCalendarWork) stop('resource_limit', 6, null);
|
|
164
|
+
}
|
|
165
|
+
function append(ranges, a, b, limits) {
|
|
166
|
+
if (ranges.length && a <= ranges.at(-1)[1] + 1) ranges.at(-1)[1] = Math.max(b, ranges.at(-1)[1]);
|
|
167
|
+
else { if (ranges.length >= limits.maxOutputRanges) stop('resource_limit', 6, null); ranges.push([a, b]); }
|
|
168
|
+
}
|
|
169
|
+
function image(ranges, unit, count, limits) {
|
|
170
|
+
const output = []; let clamped = false;
|
|
171
|
+
for (const [start, end] of ranges) {
|
|
172
|
+
if (unit === 'day' || count === 0) { append(output, start + (unit === 'day' ? count : 0), end + (unit === 'day' ? count : 0), limits); continue; }
|
|
173
|
+
let a = start;
|
|
174
|
+
while (a <= end) {
|
|
175
|
+
const source = date(a);
|
|
176
|
+
if (unit === 'eoy') {
|
|
177
|
+
const b = Math.min(end, yearStart(source.y + 1) - 1), target = source.y + count;
|
|
178
|
+
const offset = (leap(target) ? 366 : 365) - (leap(source.y) ? 366 : 365);
|
|
179
|
+
const first = a - yearStart(source.y) + 1 + offset, last = b - yearStart(source.y) + 1 + offset;
|
|
180
|
+
clamped ||= first < 1;
|
|
181
|
+
append(output, yearStart(target) + Math.max(1, first) - 1, yearStart(target) + Math.max(1, last) - 1, limits); a = b + 1;
|
|
182
|
+
} else {
|
|
183
|
+
const sourceLength = monthLength(source.y, source.m), b = Math.min(end, ordinal(source.y, source.m, sourceLength));
|
|
184
|
+
const target = monthAt(monthIndex(source) + (unit === 'year' ? 12 * count : count)), length = monthLength(target.y, target.m);
|
|
185
|
+
const first = source.d, last = date(b).d, offset = length - sourceLength;
|
|
186
|
+
const map = d => unit === 'eom' ? Math.max(1, d + offset) : Math.min(d, length);
|
|
187
|
+
clamped ||= unit === 'eom' ? first + offset < 1 : last > length;
|
|
188
|
+
append(output, ordinal(target.y, target.m, map(first)), ordinal(target.y, target.m, map(last)), limits); a = b + 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return { ranges: output, clamped };
|
|
193
|
+
}
|
|
194
|
+
function subset(a, b) {
|
|
195
|
+
let j = 0;
|
|
196
|
+
for (const [start, end] of a) {
|
|
197
|
+
while (j < b.length && b[j][1] < start) j++;
|
|
198
|
+
if (j === b.length || b[j][0] > start || b[j][1] < end) return false;
|
|
199
|
+
}
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
function labels(a, b, op) {
|
|
203
|
+
const ab = subset(a, b), ba = subset(b, a), same = ab && ba;
|
|
204
|
+
if (op === 'equal') return same ? 'equal' : 'notEqual';
|
|
205
|
+
if (op === 'compare') return same ? 'equal' : a.at(-1)[1] < b[0][0] ? 'before' : b.at(-1)[1] < a[0][0] ? 'after' : 'indeterminate';
|
|
206
|
+
if (same || ab || ba) return same ? 'equal' : ab ? 'containedBy' : 'contains';
|
|
207
|
+
let i = 0, j = 0;
|
|
208
|
+
while (i < a.length && j < b.length) { if (a[i][1] < b[j][0]) i++; else if (b[j][1] < a[i][0]) j++; else return 'overlaps'; }
|
|
209
|
+
return 'disjoint';
|
|
210
|
+
}
|
|
211
|
+
function resultSize(value, allowance) {
|
|
212
|
+
let total = 0; const stack = [value];
|
|
213
|
+
while (stack.length) {
|
|
214
|
+
const v = stack.pop();
|
|
215
|
+
if (typeof v === 'string') total += v.length + 2; // Successful strings are bounded ASCII without escapes.
|
|
216
|
+
else if (Array.isArray(v)) { total += 2 + Math.max(0, v.length - 1); for (const x of v) stack.push(x); }
|
|
217
|
+
else { const keys = Object.keys(v); total += 2 + Math.max(0, keys.length - 1); for (const k of keys) { total += k.length + 3; stack.push(v[k]); } }
|
|
218
|
+
if (total > allowance) stop('resource_limit', 7, null);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function evaluate(request, limits, available) {
|
|
222
|
+
if (!record(request)) stop('invalid_operand', 2, null);
|
|
223
|
+
required(request, ['operation', 'input'], '', 'invalid_operand', 2);
|
|
224
|
+
if (!identifier(request.operation)) stop('invalid_operand', 2, '/operation');
|
|
225
|
+
if (!record(request.input)) stop('invalid_operand', 2, '/input');
|
|
226
|
+
closed(request, ['operation', 'input'], '', 'invalid_operand', 2);
|
|
227
|
+
const op = request.operation, input = request.input;
|
|
228
|
+
closed(input, ['left', 'right', 'value', 'context', 'policy'], '/input', 'invalid_operand', 2);
|
|
229
|
+
if (!available.has(op)) stop('unsupported_operation', 2, '/operation');
|
|
230
|
+
const binary = OPERATIONS.relations.includes(op), keys = binary ? ['left', 'right'] : ['value'];
|
|
231
|
+
required(input, keys, '/input', 'invalid_operand', 2); closed(input, [...keys, 'context', 'policy'], '/input', 'invalid_operand', 2);
|
|
232
|
+
const policy = selection(input, op, limits), values = keys.map(k => operand(input[k], limits, '/input/' + k));
|
|
233
|
+
for (let i = 0; i < values.length; i++) if (values[i].deferred) stop('unsupported_domain', 5, '/input/' + keys[i] + '/temporal/category');
|
|
234
|
+
const [a, b] = values; let value, clamped = false;
|
|
235
|
+
if (binary) {
|
|
236
|
+
work(a.ranges, op, null, 0, limits, b.ranges);
|
|
237
|
+
value = { category: 'symbol', value: labels(a.ranges, b.ranges, op) };
|
|
238
|
+
} else {
|
|
239
|
+
if (op === 'step' && !period(a.ranges, policy.granularity)) stop('incompatible_operand', 6, '/input/value/temporal');
|
|
240
|
+
const unit = op === 'shift' ? policy.unit : policy.granularity;
|
|
241
|
+
const count = op === 'materialize' ? 0 : countValue(policy.count, unit);
|
|
242
|
+
if (op !== 'materialize') domain(a.ranges, unit, count);
|
|
243
|
+
work(a.ranges, op, unit, count, limits);
|
|
244
|
+
let ranges;
|
|
245
|
+
if (op === 'materialize') {
|
|
246
|
+
if (!period(a.ranges, policy.granularity)) stop('unrepresentable_result', 7, null);
|
|
247
|
+
const text = fullText(a.ranges[0][0]), rendered = policy.granularity === 'day' ? text : policy.granularity === 'month' ? text.slice(0, 7) : text.slice(0, 5);
|
|
248
|
+
if (rendered.length > limits.maxOutputCharacters) stop('resource_limit', 7, null);
|
|
249
|
+
value = { temporal: { category: 'civilDate', value: rendered }, originGranularity: a.origin, history: a.history };
|
|
250
|
+
} else {
|
|
251
|
+
if (op === 'step') {
|
|
252
|
+
const start = a.ranges[0][0], d = date(start); ranges = [];
|
|
253
|
+
if (unit === 'day') append(ranges, start + count, start + count, limits);
|
|
254
|
+
else if (unit === 'year') append(ranges, yearStart(d.y + count), yearStart(d.y + count + 1) - 1, limits);
|
|
255
|
+
else { const t = monthAt(monthIndex(d) + count); append(ranges, ordinal(t.y, t.m, 1), ordinal(t.y, t.m, monthLength(t.y, t.m)), limits); }
|
|
256
|
+
} else { const result = image(a.ranges, unit, count, limits); ranges = result.ranges; clamped = result.clamped; }
|
|
257
|
+
value = { temporal: { category: 'civilDateSet', ranges: ranges.map(([start, end]) => ({ start: fullText(start), end: fullText(end) })) }, originGranularity: a.origin, history: clamped ? MARKED : a.history };
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const metadata = { evaluation: 'exact-for-policy', clamping: clamped ? 'applied' : 'not-applied', effectivePolicy: policy };
|
|
261
|
+
if (binary) metadata.operandHistory = { left: a.history, right: b.history };
|
|
262
|
+
const result = { outcome: 'value', value, metadata }; resultSize(result, limits.maxResultBytes); return result;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Structured ingress is a lazy, byte-bounded JSON rendering. Shared nodes are
|
|
266
|
+
// expanded only while their actual serialized bytes remain within allowance.
|
|
267
|
+
function structuredText(value, limits) {
|
|
268
|
+
const stack = [{ value, depth: 1 }], active = new Set(), pieces = []; let bytes = 0;
|
|
269
|
+
function append(text) { bytes += utf8Bytes(text, limits.maxRequestBytes - bytes); if (bytes > limits.maxRequestBytes) stop('resource_limit', 1, null); pieces.push(text); }
|
|
270
|
+
while (stack.length) {
|
|
271
|
+
const task = stack.pop();
|
|
272
|
+
if (task.frame) {
|
|
273
|
+
const { item, array, keys, index, depth } = task, length = array ? item.length : keys.length;
|
|
274
|
+
if (index === length) { append(array ? ']' : '}'); active.delete(item); continue; }
|
|
275
|
+
if (index) append(','); const key = array ? index : keys[index];
|
|
276
|
+
if (!array) { if (key.length > limits.maxRequestBytes) stop('resource_limit', 1, null); append(JSON.stringify(key)); append(':'); }
|
|
277
|
+
stack.push({ ...task, index: index + 1 }, { value: item[key], depth: depth + 1 }); continue;
|
|
278
|
+
}
|
|
279
|
+
const item = task.value;
|
|
280
|
+
if (item instanceof RationalJsonNumber) { if (item.text.length > limits.maxRequestBytes) stop('resource_limit', 1, null); append(item.text); }
|
|
281
|
+
else if (item !== null && typeof item === 'object') {
|
|
282
|
+
if (task.depth > limits.maxRequestDepth) stop('resource_limit', 1, null);
|
|
283
|
+
if (active.has(item)) stop('invalid_operand', 2, null);
|
|
284
|
+
const array = Array.isArray(item);
|
|
285
|
+
if (!array && ![Object.prototype, null].includes(Object.getPrototypeOf(item))) throw new TypeError('Structured ingress requires JSON values');
|
|
286
|
+
append(array ? '[' : '{'); active.add(item);
|
|
287
|
+
stack.push({ frame: true, item, array, keys: array ? null : Object.keys(item), index: 0, depth: task.depth });
|
|
288
|
+
} else {
|
|
289
|
+
if (typeof item === 'string' && item.length > limits.maxRequestBytes) stop('resource_limit', 1, null);
|
|
290
|
+
if (typeof item === 'number' && !Number.isFinite(item)) throw new TypeError('Structured ingress requires JSON values');
|
|
291
|
+
const text = JSON.stringify(item); if (text === undefined) throw new TypeError('Structured ingress requires JSON values'); append(text);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return pieces.join('');
|
|
295
|
+
}
|
|
296
|
+
export function evaluateAeonicTemporalText(text, options = {}) {
|
|
297
|
+
const { limits, available } = configured(options);
|
|
298
|
+
if (typeof text !== 'string') throw new TypeError('requestText must be text');
|
|
299
|
+
return guarded(() => {
|
|
300
|
+
if (!scalar(text)) stop('invalid_operand', 1, null);
|
|
301
|
+
if (text.length > limits.maxRequestBytes || utf8Bytes(text, limits.maxRequestBytes) > limits.maxRequestBytes || exceedsJsonDepth(text, limits.maxRequestDepth)) stop('resource_limit', 1, null);
|
|
302
|
+
let request; try { request = parseStrictJson(text); } catch (e) { if (e instanceof SyntaxError) stop('invalid_operand', 2, null); throw e; }
|
|
303
|
+
return evaluate(request, limits, available);
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
export function evaluateAeonicTemporalStructuredJson(request, options = {}) {
|
|
307
|
+
const { limits } = configured(options);
|
|
308
|
+
return guarded(() => evaluateAeonicTemporalText(structuredText(request, limits), options));
|
|
309
|
+
}
|
|
310
|
+
export const evaluateAeonicTemporal = evaluateAeonicTemporalStructuredJson;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { AeonicArithmeticOperand } from './aeonic-arithmetic.js';
|
|
2
|
+
|
|
3
|
+
export const AEONIC_TEMPORAL_CIVIL_DATETIME_PROFILE: 'aeonic.operations.temporal.civil-datetime.v1';
|
|
4
|
+
export interface AeonicCivilDateTimeResourceLimits {
|
|
5
|
+
readonly maxRequestBytes: number;
|
|
6
|
+
readonly maxRequestDepth: number;
|
|
7
|
+
readonly maxTemporalCharacters: number;
|
|
8
|
+
readonly maxInputPieces: number;
|
|
9
|
+
readonly maxIntermediatePieces: number;
|
|
10
|
+
readonly maxOutputPieces: number;
|
|
11
|
+
readonly maxWork: number;
|
|
12
|
+
readonly maxFractionDigits: number;
|
|
13
|
+
readonly maxCountCharacters: number;
|
|
14
|
+
readonly maxNumericCharacters: number;
|
|
15
|
+
readonly maxCoefficientDigits: number;
|
|
16
|
+
readonly maxExponentMagnitude: number;
|
|
17
|
+
readonly maxWorkspaceDigits: number;
|
|
18
|
+
readonly maxOutputCharacters: number;
|
|
19
|
+
readonly maxResultBytes: number;
|
|
20
|
+
}
|
|
21
|
+
export const AEONIC_TEMPORAL_CIVIL_DATETIME_DEFAULT_RESOURCE_LIMITS: Readonly<AeonicCivilDateTimeResourceLimits>;
|
|
22
|
+
export interface AeonicCivilDateTimeOptions {
|
|
23
|
+
readonly resourceLimits?: Partial<AeonicCivilDateTimeResourceLimits>;
|
|
24
|
+
readonly capabilities?: readonly ('relations' | 'arithmetic')[];
|
|
25
|
+
}
|
|
26
|
+
export type AeonicCivilDateTimeDateGranularity = 'year' | 'month' | 'day';
|
|
27
|
+
export type AeonicCivilDateTimeClockForm = 'hour' | 'minute' | 'second';
|
|
28
|
+
export interface AeonicCivilDateTimeHistory {
|
|
29
|
+
readonly clamping: 'none-declared' | 'clamping-declared';
|
|
30
|
+
readonly approximation: 'none-declared' | 'approximation-declared';
|
|
31
|
+
}
|
|
32
|
+
export interface AeonicCivilDateTimeOrigin {
|
|
33
|
+
readonly dateGranularity: AeonicCivilDateTimeDateGranularity | 'undeclared';
|
|
34
|
+
readonly clockForm: AeonicCivilDateTimeClockForm | 'undeclared';
|
|
35
|
+
}
|
|
36
|
+
export interface AeonicCivilDateTimePoint { readonly kind: 'point'; readonly at: string }
|
|
37
|
+
export interface AeonicCivilDateTimeInterval {
|
|
38
|
+
readonly kind: 'interval';
|
|
39
|
+
readonly start: string;
|
|
40
|
+
/** The boundary marker is legal only with includeEnd: false. */
|
|
41
|
+
readonly end: string | { readonly boundary: 'endOfDomain' };
|
|
42
|
+
readonly includeStart: boolean;
|
|
43
|
+
readonly includeEnd: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface AeonicCivilDateTimeSet {
|
|
46
|
+
readonly category: 'civilDateTimeSet';
|
|
47
|
+
/** Nonempty canonical sorted pieces. No redundant points or mergeable intervals. */
|
|
48
|
+
readonly pieces: readonly (AeonicCivilDateTimePoint | AeonicCivilDateTimeInterval)[];
|
|
49
|
+
}
|
|
50
|
+
export interface AeonicAuthoredDateTimeBundle {
|
|
51
|
+
readonly temporal: { readonly category: 'civilDateTime'; readonly value: string };
|
|
52
|
+
readonly originDateGranularity?: AeonicCivilDateTimeOrigin['dateGranularity'];
|
|
53
|
+
readonly originClockForm?: AeonicCivilDateTimeOrigin['clockForm'];
|
|
54
|
+
readonly history?: AeonicCivilDateTimeHistory;
|
|
55
|
+
}
|
|
56
|
+
export interface AeonicDerivedDateTimeBundle {
|
|
57
|
+
readonly temporal: AeonicCivilDateTimeSet;
|
|
58
|
+
readonly originDateGranularity: AeonicCivilDateTimeOrigin['dateGranularity'];
|
|
59
|
+
readonly originClockForm: AeonicCivilDateTimeOrigin['clockForm'];
|
|
60
|
+
readonly history: AeonicCivilDateTimeHistory;
|
|
61
|
+
}
|
|
62
|
+
export interface AeonicMaterializedDateTimeBundle extends AeonicAuthoredDateTimeBundle {
|
|
63
|
+
readonly originDateGranularity: AeonicCivilDateTimeOrigin['dateGranularity'];
|
|
64
|
+
readonly originClockForm: AeonicCivilDateTimeOrigin['clockForm'];
|
|
65
|
+
readonly history: AeonicCivilDateTimeHistory;
|
|
66
|
+
}
|
|
67
|
+
export type AeonicCivilDateTimeOperand = AeonicAuthoredDateTimeBundle | AeonicDerivedDateTimeBundle;
|
|
68
|
+
export interface AeonicCivilDateTimeProfile { readonly profile?: string }
|
|
69
|
+
export interface AeonicCivilDateTimeRelationRequest {
|
|
70
|
+
readonly operation: 'equal' | 'compare' | 'relate';
|
|
71
|
+
readonly input: { readonly left: AeonicCivilDateTimeOperand; readonly right: AeonicCivilDateTimeOperand;
|
|
72
|
+
readonly context?: AeonicCivilDateTimeProfile; readonly policy?: AeonicCivilDateTimeProfile };
|
|
73
|
+
}
|
|
74
|
+
export interface AeonicCivilDateTimeShiftRequest {
|
|
75
|
+
readonly operation: 'shift';
|
|
76
|
+
readonly input: { readonly value: AeonicCivilDateTimeOperand; readonly context?: AeonicCivilDateTimeProfile;
|
|
77
|
+
readonly policy: AeonicCivilDateTimeProfile & { readonly unit: 'day' | 'month' | 'year' | 'eom' | 'eoy'; readonly count: string } };
|
|
78
|
+
}
|
|
79
|
+
export interface AeonicCivilDateTimeClockShiftRequest {
|
|
80
|
+
readonly operation: 'shiftClock';
|
|
81
|
+
readonly input: { readonly value: AeonicCivilDateTimeOperand;
|
|
82
|
+
/** Finite authored or exact-decimal bundle; nonterminating rationals require explicit quantization first. */
|
|
83
|
+
readonly amount: AeonicArithmeticOperand; readonly context?: AeonicCivilDateTimeProfile; readonly policy?: AeonicCivilDateTimeProfile };
|
|
84
|
+
}
|
|
85
|
+
export interface AeonicCivilDateTimeOutputPolicy extends AeonicCivilDateTimeProfile {
|
|
86
|
+
readonly dateGranularity: AeonicCivilDateTimeDateGranularity;
|
|
87
|
+
readonly clockForm: AeonicCivilDateTimeClockForm;
|
|
88
|
+
}
|
|
89
|
+
export interface AeonicCivilDateTimeStepRequest {
|
|
90
|
+
readonly operation: 'step';
|
|
91
|
+
readonly input: { readonly value: AeonicCivilDateTimeOperand; readonly context?: AeonicCivilDateTimeProfile;
|
|
92
|
+
readonly policy: AeonicCivilDateTimeOutputPolicy & { readonly count: string } };
|
|
93
|
+
}
|
|
94
|
+
export interface AeonicCivilDateTimeMaterializeRequest {
|
|
95
|
+
readonly operation: 'materialize';
|
|
96
|
+
readonly input: { readonly value: AeonicCivilDateTimeOperand; readonly context?: AeonicCivilDateTimeProfile;
|
|
97
|
+
readonly policy: AeonicCivilDateTimeOutputPolicy };
|
|
98
|
+
}
|
|
99
|
+
export type AeonicCivilDateTimeArithmeticRequest = AeonicCivilDateTimeShiftRequest | AeonicCivilDateTimeClockShiftRequest
|
|
100
|
+
| AeonicCivilDateTimeStepRequest | AeonicCivilDateTimeMaterializeRequest;
|
|
101
|
+
export type AeonicCivilDateTimeRequest = AeonicCivilDateTimeArithmeticRequest | AeonicCivilDateTimeRelationRequest;
|
|
102
|
+
export interface AeonicCivilDateTimeDiagnostic {
|
|
103
|
+
readonly outcome: 'diagnostic';
|
|
104
|
+
readonly reason: 'invalid_operand' | 'invalid_policy' | 'unsupported_profile' | 'unsupported_operation'
|
|
105
|
+
| 'unsupported_domain' | 'incompatible_operand' | 'unrepresentable_result' | 'resource_limit';
|
|
106
|
+
readonly context: { readonly stage: 1 | 2 | 3 | 4 | 5 | 6 | 7; readonly path: string | null };
|
|
107
|
+
readonly message?: string;
|
|
108
|
+
}
|
|
109
|
+
export interface AeonicCivilDateTimeMetadata {
|
|
110
|
+
readonly evaluation: 'exact-for-policy';
|
|
111
|
+
readonly clamping: 'applied' | 'not-applied';
|
|
112
|
+
readonly effectivePolicy: { readonly profile: typeof AEONIC_TEMPORAL_CIVIL_DATETIME_PROFILE;
|
|
113
|
+
readonly unit?: 'day' | 'month' | 'year' | 'eom' | 'eoy'; readonly count?: string;
|
|
114
|
+
readonly dateGranularity?: AeonicCivilDateTimeDateGranularity; readonly clockForm?: AeonicCivilDateTimeClockForm };
|
|
115
|
+
}
|
|
116
|
+
export interface AeonicCivilDateTimeArithmeticValueResult {
|
|
117
|
+
readonly outcome: 'value';
|
|
118
|
+
readonly value: AeonicDerivedDateTimeBundle | AeonicMaterializedDateTimeBundle;
|
|
119
|
+
readonly metadata: AeonicCivilDateTimeMetadata;
|
|
120
|
+
}
|
|
121
|
+
export interface AeonicCivilDateTimeRelationValueResult {
|
|
122
|
+
readonly outcome: 'value';
|
|
123
|
+
readonly value: { readonly category: 'symbol'; readonly value: 'equal' | 'notEqual' | 'before' | 'after' | 'indeterminate'
|
|
124
|
+
| 'contains' | 'containedBy' | 'overlaps' | 'disjoint' };
|
|
125
|
+
readonly metadata: AeonicCivilDateTimeMetadata & {
|
|
126
|
+
readonly operandHistory: { readonly left: AeonicCivilDateTimeHistory; readonly right: AeonicCivilDateTimeHistory };
|
|
127
|
+
readonly operandOrigin: { readonly left: AeonicCivilDateTimeOrigin; readonly right: AeonicCivilDateTimeOrigin };
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export type AeonicCivilDateTimeArithmeticResult = AeonicCivilDateTimeArithmeticValueResult | AeonicCivilDateTimeDiagnostic;
|
|
131
|
+
export type AeonicCivilDateTimeRelationResult = AeonicCivilDateTimeRelationValueResult | AeonicCivilDateTimeDiagnostic;
|
|
132
|
+
export type AeonicCivilDateTimeResult = AeonicCivilDateTimeArithmeticValueResult | AeonicCivilDateTimeRelationValueResult | AeonicCivilDateTimeDiagnostic;
|
|
133
|
+
/** Explicit versioned profile selection required; full returned bundles chain directly. */
|
|
134
|
+
export function evaluateAeonicCivilDateTime(request: AeonicCivilDateTimeArithmeticRequest, options?: AeonicCivilDateTimeOptions): AeonicCivilDateTimeArithmeticResult;
|
|
135
|
+
export function evaluateAeonicCivilDateTime(request: AeonicCivilDateTimeRelationRequest, options?: AeonicCivilDateTimeOptions): AeonicCivilDateTimeRelationResult;
|
|
136
|
+
export function evaluateAeonicCivilDateTime(request: AeonicCivilDateTimeRequest, options?: AeonicCivilDateTimeOptions): AeonicCivilDateTimeResult;
|
|
137
|
+
/** Verbatim logical JSON ingress preserves duplicate-key and raw numeric evidence for validation. */
|
|
138
|
+
export function evaluateAeonicCivilDateTimeText(requestText: string, options?: AeonicCivilDateTimeOptions): AeonicCivilDateTimeResult;
|