@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.
- package/CHANGELOG.md +118 -1
- package/README.md +96 -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-capacity.json +452 -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-snapshot-0.1.json +49 -0
- package/conformance/results/aeonic-clock-arithmetic-snapshot-0.1.json +48 -0
- package/conformance/results/aeonic-clock-capacity.json +326 -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-snapshot-0.1.json +47 -0
- package/conformance/results/aeonic-datetime-arithmetic-snapshot-0.1.json +46 -0
- package/conformance/results/aeonic-datetime-capacity.json +302 -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-property-addressing-2026-11-16.json +39 -0
- package/conformance/results/aeonic-temporal-all-snapshot-0.1.json +39 -0
- package/conformance/results/aeonic-temporal-calendar-property-addressing-2026-11-16.json +38 -0
- package/conformance/results/aeonic-temporal-calendar-snapshot-0.1.json +38 -0
- package/conformance/results/aeonic-temporal-capacity-property-addressing-2026-11-16.json +136 -0
- package/conformance/results/aeonic-temporal-capacity.json +136 -0
- package/conformance/results/aeonic-temporal-relations-property-addressing-2026-11-16.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 +75 -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 +828 -183
- 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,417 @@
|
|
|
1
|
+
// Adapted from Aeonic rational arithmetic/convenience at 64347f19181041f86135e958da5a16ecc4b60b57.
|
|
2
|
+
// Copyright (c) 2026 Patrik. MIT; see LICENSE and docs/aeonic-rational-arithmetic.md.
|
|
3
|
+
import { FINITE_NUMBER } from './aeonic-exact-number.js';
|
|
4
|
+
import { exceedsJsonDepth, parseStrictJson } from './aeonic-json.js';
|
|
5
|
+
import { RationalJsonNumber } from './aeonic-rational-json.js';
|
|
6
|
+
|
|
7
|
+
function compareScalars(left, right) {
|
|
8
|
+
const a = left[Symbol.iterator]();
|
|
9
|
+
const b = right[Symbol.iterator]();
|
|
10
|
+
while (true) {
|
|
11
|
+
const x = a.next(); const y = b.next();
|
|
12
|
+
if (x.done || y.done) return x.done === y.done ? 0 : x.done ? -1 : 1;
|
|
13
|
+
const difference = x.value.codePointAt(0) - y.value.codePointAt(0);
|
|
14
|
+
if (difference !== 0) return difference < 0 ? -1 : 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Count only through the allowance; avoid a whole-input TextEncoder buffer.
|
|
19
|
+
function utf8ByteLength(text, limit) {
|
|
20
|
+
let bytes = 0;
|
|
21
|
+
for (const character of text) {
|
|
22
|
+
const point = character.codePointAt(0);
|
|
23
|
+
bytes += point <= 0x7f ? 1 : point <= 0x7ff ? 2 : point <= 0xffff ? 3 : 4;
|
|
24
|
+
if (bytes > limit) break;
|
|
25
|
+
}
|
|
26
|
+
return bytes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const AEONIC_RATIONAL_ARITHMETIC_PROFILE = 'aeonic.operations.arithmetic.rational.v1';
|
|
30
|
+
export const AEONIC_RATIONAL_ARITHMETIC_DEFAULT_RESOURCE_LIMITS = Object.freeze({
|
|
31
|
+
maxRequestBytes: 16384, maxRequestDepth: 32, maxNumericCharacters: 1024,
|
|
32
|
+
maxCoefficientDigits: 512, maxDenominatorDigits: 512, maxExponentMagnitude: 1000000,
|
|
33
|
+
maxWorkspaceDigits: 4096, maxOutputCharacters: 1024,
|
|
34
|
+
});
|
|
35
|
+
const FINITE_PROFILE = 'aeonic.operations.arithmetic.exact.v1';
|
|
36
|
+
const MODES = new Set(['half-even', 'half-away-from-zero', 'half-toward-zero',
|
|
37
|
+
'toward-zero', 'away-from-zero', 'floor', 'ceiling']);
|
|
38
|
+
const DEFERRED = new Set(['string', 'boolean', 'symbol', 'positiveInfinity', 'negativeInfinity',
|
|
39
|
+
'nan', 'explicitNull', 'explicitAbsence', 'toggle', 'hex', 'radix', 'encoding',
|
|
40
|
+
'separator', 'sansaAddress', 'referenceForm', 'temporal', 'container']);
|
|
41
|
+
const NONE = 'none-declared', MARKED = 'approximation-declared';
|
|
42
|
+
const record = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
43
|
+
const scalar = (v) => typeof v === 'string' && !/[\uD800-\uDFFF]/u.test(v);
|
|
44
|
+
const identifier = (v) => scalar(v) && v.length > 0;
|
|
45
|
+
const abs = (n) => n < 0n ? -n : n;
|
|
46
|
+
const digits = (n) => abs(n).toString().length;
|
|
47
|
+
const zero = () => ({ c: 0n, e: 0n, d: 1n });
|
|
48
|
+
const pointer = (p, k) => !scalar(k) ? null : p + '/' + k.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
49
|
+
const COEFFICIENT = /^(?:0|-?[1-9](?:[0-9]*[1-9])?)$(?![\s\S])/u;
|
|
50
|
+
const EXPONENT = /^(?:0|-?[1-9][0-9]*)$(?![\s\S])/u;
|
|
51
|
+
const DENOMINATOR = /^[1-9][0-9]*$(?![\s\S])/u;
|
|
52
|
+
class Failure extends Error {
|
|
53
|
+
constructor(reason, stage, path) {
|
|
54
|
+
super(reason); this.result = { outcome: 'diagnostic', reason, context: { stage, path } };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function stop(reason, stage, path) { throw new Failure(reason, stage, path); }
|
|
58
|
+
function required(value, fields, path, reason, stage) {
|
|
59
|
+
for (const field of fields) if (!Object.hasOwn(value, field)) stop(reason, stage, pointer(path, field));
|
|
60
|
+
}
|
|
61
|
+
function closed(value, fields, path, reason, stage) {
|
|
62
|
+
for (const field of Object.keys(value).sort(compareScalars)) {
|
|
63
|
+
if (!fields.includes(field)) stop(reason, stage, pointer(path, field));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function configured(options) {
|
|
67
|
+
if (!record(options) || Object.keys(options).some((k) => k !== 'resourceLimits')) throw new TypeError('Invalid trusted options');
|
|
68
|
+
const supplied = Object.hasOwn(options, 'resourceLimits') ? options.resourceLimits : {};
|
|
69
|
+
if (!record(supplied)) throw new TypeError('resourceLimits must be an object');
|
|
70
|
+
for (const [k, v] of Object.entries(supplied)) {
|
|
71
|
+
if (!Object.hasOwn(AEONIC_RATIONAL_ARITHMETIC_DEFAULT_RESOURCE_LIMITS, k) || !Number.isSafeInteger(v) || v < 0) {
|
|
72
|
+
throw new TypeError('Invalid resource limit: ' + k);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return { ...AEONIC_RATIONAL_ARITHMETIC_DEFAULT_RESOURCE_LIMITS, ...supplied };
|
|
76
|
+
}
|
|
77
|
+
function characters(texts, allowance, stage, path) {
|
|
78
|
+
let count = 0;
|
|
79
|
+
for (const text of texts) for (const character of text) {
|
|
80
|
+
if (++count > allowance) stop('resource_limit', stage, path);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function exponent(text, limits, stage, path) {
|
|
84
|
+
// Grammar is checked by the caller. Compare the magnitude lexically before
|
|
85
|
+
// converting: even an all-zero authored coefficient must pass this guard.
|
|
86
|
+
const magnitude = text.replace(/^[+-]/u, '').replace(/^0+/u, '') || '0';
|
|
87
|
+
const bound = String(limits.maxExponentMagnitude);
|
|
88
|
+
if (magnitude.length > bound.length || (magnitude.length === bound.length && magnitude > bound)) {
|
|
89
|
+
stop('resource_limit', stage, path);
|
|
90
|
+
}
|
|
91
|
+
const value = BigInt(magnitude);
|
|
92
|
+
return text.startsWith('-') ? -value : value;
|
|
93
|
+
}
|
|
94
|
+
function stringBounds(c, e, limits, stage, path) {
|
|
95
|
+
if (c.replace(/^-/, '').length > limits.maxCoefficientDigits) stop('resource_limit', stage, path);
|
|
96
|
+
if (abs(e) > BigInt(limits.maxExponentMagnitude)) stop('resource_limit', stage, path);
|
|
97
|
+
}
|
|
98
|
+
function resultBounds(value, limits) {
|
|
99
|
+
if (digits(value.c) > limits.maxCoefficientDigits) stop('resource_limit', 6, null);
|
|
100
|
+
if (abs(value.e) > BigInt(limits.maxExponentMagnitude)) stop('resource_limit', 6, null);
|
|
101
|
+
if (value.d !== 1n && digits(value.d) > limits.maxDenominatorDigits) stop('resource_limit', 6, null);
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
function gcd(a, b) {
|
|
105
|
+
a = abs(a); b = abs(b);
|
|
106
|
+
while (b) [a, b] = [b, a % b];
|
|
107
|
+
return a;
|
|
108
|
+
}
|
|
109
|
+
function strip(c, e, d = 1n) {
|
|
110
|
+
if (c === 0n) return zero();
|
|
111
|
+
const source = c.toString(), trimmed = source.replace(/0+$/u, '');
|
|
112
|
+
return { c: BigInt(trimmed), e: e + BigInt(source.length - trimmed.length), d };
|
|
113
|
+
}
|
|
114
|
+
function authored(value, limits, path) {
|
|
115
|
+
if (typeof value !== 'string') stop('invalid_operand', 4, path);
|
|
116
|
+
characters([value], limits.maxNumericCharacters, 4, path);
|
|
117
|
+
if (!FINITE_NUMBER.test(value)) stop('invalid_operand', 4, path);
|
|
118
|
+
const [mantissa, original = '0'] = value.toLowerCase().split('e');
|
|
119
|
+
let e = exponent(original, limits, 4, path);
|
|
120
|
+
const negative = mantissa.startsWith('-');
|
|
121
|
+
const [integer, fraction = ''] = mantissa.replace(/^[+-]/u, '').split('.');
|
|
122
|
+
let c = (integer + fraction).replace(/^0+/u, '') || '0';
|
|
123
|
+
if (c === '0') e = 0n;
|
|
124
|
+
else {
|
|
125
|
+
const trimmed = c.replace(/0+$/u, '');
|
|
126
|
+
e += BigInt(c.length - trimmed.length) - BigInt(fraction.length);
|
|
127
|
+
c = (negative ? '-' : '') + trimmed;
|
|
128
|
+
}
|
|
129
|
+
stringBounds(c, e, limits, 4, path);
|
|
130
|
+
return { c: BigInt(c), e, d: 1n };
|
|
131
|
+
}
|
|
132
|
+
function derived(number, limits, path, increment = false) {
|
|
133
|
+
const stage = increment ? 3 : 4, reason = increment ? 'invalid_policy' : 'invalid_operand';
|
|
134
|
+
const rational = !increment && number.category === 'exactRational';
|
|
135
|
+
const fields = rational ? ['coefficient', 'exponent', 'denominator'] : ['coefficient', 'exponent'];
|
|
136
|
+
required(number, fields, path, reason, stage);
|
|
137
|
+
closed(number, ['category', ...fields], path, reason, stage);
|
|
138
|
+
for (const field of fields) if (typeof number[field] !== 'string') stop(reason, stage, path + '/' + field);
|
|
139
|
+
characters(fields.map((k) => number[k]), limits.maxNumericCharacters, stage, path + '/coefficient');
|
|
140
|
+
characters([number.coefficient.replace(/^-/, '')], limits.maxCoefficientDigits, stage, path + '/coefficient');
|
|
141
|
+
const c = number.coefficient;
|
|
142
|
+
if (!COEFFICIENT.test(c) || (rational && c === '0') || (increment && (c === '0' || c.startsWith('-')))) {
|
|
143
|
+
stop(reason, stage, path + '/coefficient');
|
|
144
|
+
}
|
|
145
|
+
if (!EXPONENT.test(number.exponent)) stop(reason, stage, path + '/exponent');
|
|
146
|
+
const e = exponent(number.exponent, limits, stage, path + '/exponent');
|
|
147
|
+
if (c === '0' && e !== 0n) stop(reason, stage, path + '/exponent');
|
|
148
|
+
let d = 1n;
|
|
149
|
+
if (rational) {
|
|
150
|
+
characters([number.denominator], limits.maxDenominatorDigits, stage, path + '/denominator');
|
|
151
|
+
if (!DENOMINATOR.test(number.denominator)) stop(reason, stage, path + '/denominator');
|
|
152
|
+
d = BigInt(number.denominator);
|
|
153
|
+
if (d <= 1n || d % 2n === 0n || d % 5n === 0n) stop(reason, stage, path + '/denominator');
|
|
154
|
+
}
|
|
155
|
+
const coefficient = BigInt(c);
|
|
156
|
+
if (rational && gcd(coefficient, d) !== 1n) stop(reason, stage, path + '/denominator');
|
|
157
|
+
return { c: coefficient, e, d };
|
|
158
|
+
}
|
|
159
|
+
function operand(bundle, limits, path) {
|
|
160
|
+
if (!record(bundle)) stop('invalid_operand', 4, path);
|
|
161
|
+
required(bundle, ['number'], path, 'invalid_operand', 4);
|
|
162
|
+
const number = bundle.number, at = path + '/number';
|
|
163
|
+
if (!record(number)) stop('invalid_operand', 4, at);
|
|
164
|
+
if (!['finiteNumber', 'exactNumber', 'exactRational'].includes(number.category) && !DEFERRED.has(number.category)) {
|
|
165
|
+
stop('invalid_operand', 4, at + '/category');
|
|
166
|
+
}
|
|
167
|
+
if (['exactNumber', 'exactRational'].includes(number.category)) required(bundle, ['history'], path, 'invalid_operand', 4);
|
|
168
|
+
closed(bundle, ['number', 'history'], path, 'invalid_operand', 4);
|
|
169
|
+
const history = Object.hasOwn(bundle, 'history') ? bundle.history : NONE;
|
|
170
|
+
if (![NONE, MARKED].includes(history)) stop('invalid_operand', 4, path + '/history');
|
|
171
|
+
if (DEFERRED.has(number.category)) return { deferred: true, history };
|
|
172
|
+
if (number.category === 'finiteNumber') {
|
|
173
|
+
required(number, ['value'], at, 'invalid_operand', 4);
|
|
174
|
+
closed(number, ['category', 'value'], at, 'invalid_operand', 4);
|
|
175
|
+
return { ...authored(number.value, limits, at + '/value'), history };
|
|
176
|
+
}
|
|
177
|
+
return { ...derived(number, limits, at), history };
|
|
178
|
+
}
|
|
179
|
+
function selection(input, operation, limits) {
|
|
180
|
+
const unary = operation === 'quantize' || operation === 'materialize';
|
|
181
|
+
for (const key of ['context', 'policy']) {
|
|
182
|
+
const path = '/input/' + key;
|
|
183
|
+
if (!Object.hasOwn(input, key)) {
|
|
184
|
+
if (key === 'policy' && unary) stop('invalid_policy', 3, path);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const value = input[key];
|
|
188
|
+
if (!record(value)) stop('invalid_policy', 3, path);
|
|
189
|
+
if (key === 'policy' && unary) required(value, operation === 'quantize' ? ['increment', 'rounding'] : ['family'], path, 'invalid_policy', 3);
|
|
190
|
+
const extra = key !== 'policy' ? [] : operation === 'quantize' ? ['increment', 'rounding']
|
|
191
|
+
: operation === 'materialize' ? ['family', 'zeroSign'] : [];
|
|
192
|
+
closed(value, ['profile', ...extra], path, 'invalid_policy', 3);
|
|
193
|
+
}
|
|
194
|
+
for (const key of ['context', 'policy']) {
|
|
195
|
+
if (Object.hasOwn(input[key] ?? {}, 'profile') && !identifier(input[key].profile)) {
|
|
196
|
+
stop('invalid_policy', 3, '/input/' + key + '/profile');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const policy = input.policy ?? {}, context = input.context ?? {};
|
|
200
|
+
let increment;
|
|
201
|
+
if (operation === 'quantize') {
|
|
202
|
+
const at = '/input/policy/increment', value = policy.increment;
|
|
203
|
+
if (!record(value)) stop('invalid_policy', 3, at);
|
|
204
|
+
required(value, ['category'], at, 'invalid_policy', 3);
|
|
205
|
+
if (value.category !== 'exactNumber') stop('invalid_policy', 3, at + '/category');
|
|
206
|
+
increment = derived(value, limits, at, true);
|
|
207
|
+
if (!MODES.has(policy.rounding)) stop('invalid_policy', 3, '/input/policy/rounding');
|
|
208
|
+
} else if (operation === 'materialize') {
|
|
209
|
+
if (!['integer', 'decimal', 'exponent'].includes(policy.family)) stop('invalid_policy', 3, '/input/policy/family');
|
|
210
|
+
if (Object.hasOwn(policy, 'zeroSign') && !['positive', 'negative'].includes(policy.zeroSign)) {
|
|
211
|
+
stop('invalid_policy', 3, '/input/policy/zeroSign');
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const owner = Object.hasOwn(policy, 'profile') ? 'policy' : Object.hasOwn(context, 'profile') ? 'context' : null;
|
|
215
|
+
const profile = owner ? input[owner].profile : FINITE_PROFILE;
|
|
216
|
+
if (profile !== AEONIC_RATIONAL_ARITHMETIC_PROFILE) stop('unsupported_profile', 3, owner ? '/input/' + owner + '/profile' : null);
|
|
217
|
+
const effective = { profile };
|
|
218
|
+
if (operation === 'quantize') Object.assign(effective, { increment: descriptor(increment), rounding: policy.rounding });
|
|
219
|
+
if (operation === 'materialize') Object.assign(effective, { family: policy.family, zeroSign: policy.zeroSign ?? 'positive' });
|
|
220
|
+
return { effective, increment };
|
|
221
|
+
}
|
|
222
|
+
function workspace(width, limits) {
|
|
223
|
+
if (width > BigInt(limits.maxWorkspaceDigits)) stop('resource_limit', 6, null);
|
|
224
|
+
}
|
|
225
|
+
const width = (n) => BigInt(digits(n));
|
|
226
|
+
const max = (a, b) => a > b ? a : b;
|
|
227
|
+
function multiply(a, b, limits) {
|
|
228
|
+
if (a.c === 0n || b.c === 0n) return zero();
|
|
229
|
+
const sign = (a.c < 0n) !== (b.c < 0n) ? -1n : 1n;
|
|
230
|
+
const g1 = gcd(a.c, b.d), g2 = gcd(b.c, a.d);
|
|
231
|
+
const A = abs(a.c) / g1, B = abs(b.c) / g2, C = a.d / g2, D = b.d / g1;
|
|
232
|
+
workspace(max(width(A) + width(B), width(C) + width(D)), limits);
|
|
233
|
+
return strip(sign * A * B, a.e + b.e, C * D);
|
|
234
|
+
}
|
|
235
|
+
function divide(a, b, limits) {
|
|
236
|
+
if (b.c === 0n) stop('division_by_zero', 6, '/input/right/number');
|
|
237
|
+
if (a.c === 0n) return zero();
|
|
238
|
+
const sign = (a.c < 0n) !== (b.c < 0n) ? -1n : 1n;
|
|
239
|
+
const g1 = gcd(a.c, b.c), g2 = gcd(b.d, a.d);
|
|
240
|
+
const A = abs(a.c) / g1, B = b.d / g2, D = a.d / g2;
|
|
241
|
+
let C = abs(b.c) / g1, twos = 0n, fives = 0n;
|
|
242
|
+
while (C % 2n === 0n) { C /= 2n; twos++; }
|
|
243
|
+
while (C % 5n === 0n) { C /= 5n; fives++; }
|
|
244
|
+
const t = max(twos, fives), p2 = t - twos, p5 = t - fives;
|
|
245
|
+
const extra = (p2 ? 302n * p2 / 1000n + 1n : 0n) + (p5 ? 699n * p5 / 1000n + 1n : 0n);
|
|
246
|
+
workspace(max(width(A) + width(B) + extra, width(C) + width(D)), limits);
|
|
247
|
+
return { c: sign * A * B * (2n ** p2) * (5n ** p5), e: a.e - b.e - t, d: C * D };
|
|
248
|
+
}
|
|
249
|
+
function add(a, b, subtract, limits) {
|
|
250
|
+
const right = subtract ? -b.c : b.c;
|
|
251
|
+
if (a.c === 0n) return { c: right, e: b.e, d: b.d };
|
|
252
|
+
if (right === 0n) return { c: a.c, e: a.e, d: a.d };
|
|
253
|
+
if (a.e === b.e && a.d === b.d && a.c === -right) return zero();
|
|
254
|
+
const g = gcd(a.d, b.d), sl = b.d / g, sr = a.d / g, e = a.e < b.e ? a.e : b.e;
|
|
255
|
+
const xl = width(a.c) + width(sl) + a.e - e, xr = width(right) + width(sr) + b.e - e;
|
|
256
|
+
workspace(max(max(xl, xr) + 1n, width(a.d) + width(sl)), limits);
|
|
257
|
+
let c = a.c * sl * (10n ** (a.e - e)) + right * sr * (10n ** (b.e - e));
|
|
258
|
+
let d = a.d * sl;
|
|
259
|
+
const reduced = gcd(c, d); c /= reduced; d /= reduced;
|
|
260
|
+
return strip(c, e, d);
|
|
261
|
+
}
|
|
262
|
+
function compareScaled(a, ea, b, eb) {
|
|
263
|
+
const left = a.toString(), right = b.toString();
|
|
264
|
+
const wa = BigInt(left.length) + ea, wb = BigInt(right.length) + eb;
|
|
265
|
+
if (wa !== wb) return wa < wb ? -1 : 1;
|
|
266
|
+
for (let i = 0; i < Math.max(left.length, right.length); i++) {
|
|
267
|
+
const x = left[i] ?? '0', y = right[i] ?? '0';
|
|
268
|
+
if (x !== y) return x < y ? -1 : 1;
|
|
269
|
+
}
|
|
270
|
+
return 0;
|
|
271
|
+
}
|
|
272
|
+
function roundingUp(mode, sign, half, whole = 0n) {
|
|
273
|
+
if (mode === 'toward-zero') return false;
|
|
274
|
+
if (mode === 'away-from-zero') return true;
|
|
275
|
+
if (mode === 'floor') return sign < 0n;
|
|
276
|
+
if (mode === 'ceiling') return sign > 0n;
|
|
277
|
+
return half > 0 || (half === 0 && (mode === 'half-away-from-zero' || (mode === 'half-even' && whole % 2n === 1n)));
|
|
278
|
+
}
|
|
279
|
+
function quantize(value, increment, mode, limits) {
|
|
280
|
+
if (value.c === 0n) return zero();
|
|
281
|
+
const sign = value.c < 0n ? -1n : 1n;
|
|
282
|
+
const q = divide({ c: abs(value.c), e: value.e, d: value.d }, increment, limits);
|
|
283
|
+
if (q.d === 1n && q.e >= 0n) return { c: value.c, e: value.e, d: value.d };
|
|
284
|
+
if (compareScaled(q.c, q.e, q.d, 0n) < 0) {
|
|
285
|
+
workspace(max(width(q.c) + 1n, width(q.d)), limits);
|
|
286
|
+
const half = compareScaled(2n * q.c, q.e, q.d, 0n);
|
|
287
|
+
return roundingUp(mode, sign, half) ? { c: sign * increment.c, e: increment.e, d: 1n } : zero();
|
|
288
|
+
}
|
|
289
|
+
workspace(max(width(q.c) + max(q.e, 0n), width(q.d) + max(-q.e, 0n)), limits);
|
|
290
|
+
const n = q.c * (10n ** max(q.e, 0n)), d = q.d * (10n ** max(-q.e, 0n));
|
|
291
|
+
let k = n / d;
|
|
292
|
+
const r = n % d, complement = d - r, half = r < complement ? -1 : r > complement ? 1 : 0;
|
|
293
|
+
if (r && roundingUp(mode, sign, half, k)) k++;
|
|
294
|
+
if (k === 0n) return zero();
|
|
295
|
+
workspace(width(k) + width(increment.c), limits);
|
|
296
|
+
return strip(sign * k * increment.c, increment.e);
|
|
297
|
+
}
|
|
298
|
+
function descriptor(value) {
|
|
299
|
+
return { category: value.d === 1n ? 'exactNumber' : 'exactRational',
|
|
300
|
+
coefficient: value.c.toString(), exponent: value.e.toString(),
|
|
301
|
+
...(value.d === 1n ? {} : { denominator: value.d.toString() }) };
|
|
302
|
+
}
|
|
303
|
+
function render(value, policy, limits) {
|
|
304
|
+
if (value.d !== 1n || (policy.family === 'integer' && value.c !== 0n && value.e < 0n)) {
|
|
305
|
+
stop('unrepresentable_result', 7, null);
|
|
306
|
+
}
|
|
307
|
+
const a = abs(value.c).toString(), e = value.e, w = BigInt(a.length), point = w + e;
|
|
308
|
+
const sign = value.c < 0n || (value.c === 0n && policy.zeroSign === 'negative') ? '-' : '';
|
|
309
|
+
const scientific = e + w - 1n;
|
|
310
|
+
const length = policy.family === 'integer' ? w + e : policy.family === 'exponent'
|
|
311
|
+
? w + (w > 1n ? 1n : 0n) + 1n + BigInt(scientific.toString().length)
|
|
312
|
+
: e >= 0n ? w + e + 2n : point > 0n ? w + 1n : 2n - point + w;
|
|
313
|
+
if (length + BigInt(sign.length) > BigInt(limits.maxOutputCharacters)) stop('resource_limit', 7, null);
|
|
314
|
+
if (policy.family === 'exponent') return sign + a[0] + (a.length > 1 ? '.' + a.slice(1) : '') + 'e' + scientific;
|
|
315
|
+
if (policy.family === 'integer') return sign + a + '0'.repeat(Number(e));
|
|
316
|
+
if (e >= 0n) return sign + a + '0'.repeat(Number(e)) + '.0';
|
|
317
|
+
if (point > 0n) return sign + a.slice(0, Number(point)) + '.' + a.slice(Number(point));
|
|
318
|
+
return sign + '0.' + '0'.repeat(Number(-point)) + a;
|
|
319
|
+
}
|
|
320
|
+
function evaluate(request, limits) {
|
|
321
|
+
if (!record(request)) stop('invalid_operand', 2, null);
|
|
322
|
+
required(request, ['operation', 'input'], '', 'invalid_operand', 2);
|
|
323
|
+
if (!identifier(request.operation)) stop('invalid_operand', 2, '/operation');
|
|
324
|
+
if (!record(request.input)) stop('invalid_operand', 2, '/input');
|
|
325
|
+
closed(request, ['operation', 'input'], '', 'invalid_operand', 2);
|
|
326
|
+
const input = request.input, operation = request.operation;
|
|
327
|
+
closed(input, ['left', 'right', 'value', 'context', 'policy'], '/input', 'invalid_operand', 2);
|
|
328
|
+
if (!['add', 'subtract', 'multiply', 'divide', 'quantize', 'materialize'].includes(operation)) stop('unsupported_operation', 2, '/operation');
|
|
329
|
+
const keys = ['quantize', 'materialize'].includes(operation) ? ['value'] : ['left', 'right'];
|
|
330
|
+
required(input, keys, '/input', 'invalid_operand', 2);
|
|
331
|
+
closed(input, [...keys, 'context', 'policy'], '/input', 'invalid_operand', 2);
|
|
332
|
+
const selected = selection(input, operation, limits);
|
|
333
|
+
const values = keys.map((key) => operand(input[key], limits, '/input/' + key));
|
|
334
|
+
for (const [i, value] of values.entries()) if (value.deferred) stop('unsupported_domain', 5, '/input/' + keys[i] + '/number/category');
|
|
335
|
+
let history = values.some((value) => value.history === MARKED) ? MARKED : NONE;
|
|
336
|
+
let evaluation = 'exact-for-operands', number;
|
|
337
|
+
if (operation === 'materialize') number = { category: 'finiteNumber', value: render(values[0], selected.effective, limits) };
|
|
338
|
+
else {
|
|
339
|
+
const [a, b] = values;
|
|
340
|
+
const result = operation === 'multiply' ? multiply(a, b, limits)
|
|
341
|
+
: operation === 'divide' ? divide(a, b, limits)
|
|
342
|
+
: operation === 'quantize' ? quantize(a, selected.increment, selected.effective.rounding, limits)
|
|
343
|
+
: add(a, b, operation === 'subtract', limits);
|
|
344
|
+
resultBounds(result, limits);
|
|
345
|
+
if (operation === 'quantize' && (a.c !== result.c || a.e !== result.e || a.d !== result.d)) {
|
|
346
|
+
history = MARKED; evaluation = 'rounded-for-operands';
|
|
347
|
+
}
|
|
348
|
+
number = descriptor(result);
|
|
349
|
+
}
|
|
350
|
+
return { outcome: 'value', value: { number, history }, metadata: { evaluation, effectivePolicy: selected.effective } };
|
|
351
|
+
}
|
|
352
|
+
function guarded(action) {
|
|
353
|
+
try { return action(); } catch (error) { if (error instanceof Failure) return error.result; throw error; }
|
|
354
|
+
}
|
|
355
|
+
function structuredText(value, limits) {
|
|
356
|
+
const stack = [{ value, depth: 1 }], active = new Set(), pieces = [];
|
|
357
|
+
let bytes = 0;
|
|
358
|
+
function append(text) {
|
|
359
|
+
bytes += utf8ByteLength(text, limits.maxRequestBytes - bytes);
|
|
360
|
+
if (bytes > limits.maxRequestBytes) stop('resource_limit', 1, null);
|
|
361
|
+
pieces.push(text);
|
|
362
|
+
}
|
|
363
|
+
while (stack.length) {
|
|
364
|
+
const task = stack.pop();
|
|
365
|
+
if (task.frame) {
|
|
366
|
+
const { item, array, keys, index, depth } = task, length = array ? item.length : keys.length;
|
|
367
|
+
if (index === length) { append(array ? ']' : '}'); active.delete(item); continue; }
|
|
368
|
+
if (index) append(',');
|
|
369
|
+
const key = array ? index : keys[index];
|
|
370
|
+
if (!array) {
|
|
371
|
+
if (key.length > limits.maxRequestBytes) stop('resource_limit', 1, null);
|
|
372
|
+
append(JSON.stringify(key)); append(':');
|
|
373
|
+
}
|
|
374
|
+
stack.push({ ...task, index: index + 1 }, { value: item[key], depth: depth + 1 });
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
const item = task.value;
|
|
378
|
+
if (item instanceof RationalJsonNumber) {
|
|
379
|
+
if (item.text.length > limits.maxRequestBytes) stop('resource_limit', 1, null);
|
|
380
|
+
append(item.text);
|
|
381
|
+
} else if (item !== null && typeof item === 'object') {
|
|
382
|
+
if (task.depth > limits.maxRequestDepth) stop('resource_limit', 1, null);
|
|
383
|
+
if (active.has(item)) stop('invalid_operand', 2, null);
|
|
384
|
+
const array = Array.isArray(item);
|
|
385
|
+
if (!array && ![Object.prototype, null].includes(Object.getPrototypeOf(item))) {
|
|
386
|
+
throw new TypeError('Structured ingress requires JSON values');
|
|
387
|
+
}
|
|
388
|
+
append(array ? '[' : '{'); active.add(item);
|
|
389
|
+
stack.push({ frame: true, item, array, keys: array ? null : Object.keys(item), index: 0, depth: task.depth });
|
|
390
|
+
} else {
|
|
391
|
+
if (typeof item === 'string' && item.length > limits.maxRequestBytes) stop('resource_limit', 1, null);
|
|
392
|
+
if (typeof item === 'number' && !Number.isFinite(item)) throw new TypeError('Structured ingress requires JSON values');
|
|
393
|
+
const text = JSON.stringify(item);
|
|
394
|
+
if (text === undefined) throw new TypeError('Structured ingress requires JSON values');
|
|
395
|
+
append(text);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return pieces.join('');
|
|
399
|
+
}
|
|
400
|
+
export function evaluateAeonicRationalArithmeticText(text, options = {}) {
|
|
401
|
+
if (!scalar(text)) throw new TypeError('requestText must be Unicode scalar text');
|
|
402
|
+
const limits = configured(options);
|
|
403
|
+
return guarded(() => {
|
|
404
|
+
if (utf8ByteLength(text, limits.maxRequestBytes) > limits.maxRequestBytes || exceedsJsonDepth(text, limits.maxRequestDepth)) stop('resource_limit', 1, null);
|
|
405
|
+
let request;
|
|
406
|
+
try { request = parseStrictJson(text); } catch (error) {
|
|
407
|
+
if (error instanceof SyntaxError) stop('invalid_operand', 2, null);
|
|
408
|
+
throw error;
|
|
409
|
+
}
|
|
410
|
+
return evaluate(request, limits);
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
export function evaluateAeonicRationalArithmeticStructuredJson(request, options = {}) {
|
|
414
|
+
const limits = configured(options);
|
|
415
|
+
return guarded(() => evaluateAeonicRationalArithmeticText(structuredText(request, limits), options));
|
|
416
|
+
}
|
|
417
|
+
export const evaluateAeonicRationalArithmetic = evaluateAeonicRationalArithmeticStructuredJson;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Adapted from Aeonic rational arithmetic/convenience at 64347f19181041f86135e958da5a16ecc4b60b57.
|
|
2
|
+
// Copyright (c) 2026 Patrik. MIT; see LICENSE and docs/aeonic-rational-arithmetic.md.
|
|
3
|
+
import { parseArithmeticEnvelope } from './aeonic-arithmetic-binding.js';
|
|
4
|
+
|
|
5
|
+
// Internal binding representation; ordinary native nonfinite Numbers still fail.
|
|
6
|
+
export class RationalJsonNumber {
|
|
7
|
+
constructor(text) { this.text = text; }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function parseRationalArithmeticEnvelope(text) {
|
|
11
|
+
const result = parseArithmeticEnvelope(text), frames = [];
|
|
12
|
+
const location = () => {
|
|
13
|
+
const parent = frames.at(-1);
|
|
14
|
+
if (!parent) return { value: result, logical: false, fixture: false, root: true };
|
|
15
|
+
const key = parent.object ? parent.key : parent.index;
|
|
16
|
+
return { value: parent.value[key], parent: parent.value, key,
|
|
17
|
+
logical: parent.logical || (parent.fixture && parent.object && key === 'request'),
|
|
18
|
+
fixture: parent.root && parent.object && key === 'fixture', root: false };
|
|
19
|
+
};
|
|
20
|
+
const done = () => {
|
|
21
|
+
const parent = frames.at(-1);
|
|
22
|
+
if (parent) { parent.state = 'comma'; if (!parent.object) parent.index++; }
|
|
23
|
+
};
|
|
24
|
+
// The existing strict decoder has already checked grammar/duplicate keys and
|
|
25
|
+
// exact trusted limits. Retain numeric token spellings only inside request.
|
|
26
|
+
// Full envelope transport remains outside the logical operation budget.
|
|
27
|
+
for (let i = 0; i < text.length;) {
|
|
28
|
+
const c = text[i];
|
|
29
|
+
if (/\s/u.test(c)) { i++; continue; }
|
|
30
|
+
if (c === '{' || c === '[') {
|
|
31
|
+
const at = location(); done();
|
|
32
|
+
frames.push({ ...at, object: c === '{', state: c === '{' ? 'key' : 'value', key: null, index: 0 }); i++;
|
|
33
|
+
} else if (c === '}' || c === ']') { frames.pop(); i++; }
|
|
34
|
+
else if (c === ':') { frames.at(-1).state = 'value'; i++; }
|
|
35
|
+
else if (c === ',') { const f = frames.at(-1); f.state = f.object ? 'key' : 'value'; i++; }
|
|
36
|
+
else if (c === '"') {
|
|
37
|
+
const start = i++;
|
|
38
|
+
while (i < text.length) { if (text[i] === '\\') i += 2; else if (text[i++] === '"') break; }
|
|
39
|
+
const f = frames.at(-1);
|
|
40
|
+
if (f?.object && f.state === 'key') { f.key = JSON.parse(text.slice(start, i)); f.state = 'colon'; }
|
|
41
|
+
else done();
|
|
42
|
+
} else if (c === '-' || /[0-9]/u.test(c)) {
|
|
43
|
+
const start = i++;
|
|
44
|
+
while (i < text.length && /[0-9eE+.\-]/u.test(text[i])) i++;
|
|
45
|
+
const at = location();
|
|
46
|
+
if (at.logical) at.parent[at.key] = new RationalJsonNumber(text.slice(start, i));
|
|
47
|
+
done();
|
|
48
|
+
} else { i += c === 't' || c === 'n' ? 4 : 5; done(); }
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AeonicTemporalOperand } from './aeonic-temporal-civil-date.js';
|
|
2
|
+
import type { AeonicCivilClockOperand } from './aeonic-temporal-civil-clock.js';
|
|
3
|
+
import type { AeonicDerivedDateTimeBundle } from './aeonic-temporal-civil-datetime.js';
|
|
4
|
+
export const AEONIC_TEMPORAL_CIVIL_ANCHOR_PROFILE: 'aeonic.operations.temporal.civil-anchor.v1';
|
|
5
|
+
export interface AeonicCivilAnchorResourceLimits {
|
|
6
|
+
readonly maxRequestBytes: number;
|
|
7
|
+
readonly maxRequestDepth: number;
|
|
8
|
+
readonly maxTemporalCharacters: number;
|
|
9
|
+
readonly maxInputRanges: number;
|
|
10
|
+
readonly maxInputPieces: number;
|
|
11
|
+
readonly maxRelativeDayDigits: number;
|
|
12
|
+
readonly maxFractionDigits: number;
|
|
13
|
+
readonly maxWork: number;
|
|
14
|
+
readonly maxIntermediatePieces: number;
|
|
15
|
+
readonly maxOutputPieces: number;
|
|
16
|
+
readonly maxResultBytes: number;
|
|
17
|
+
}
|
|
18
|
+
export const AEONIC_TEMPORAL_CIVIL_ANCHOR_DEFAULT_RESOURCE_LIMITS: Readonly<AeonicCivilAnchorResourceLimits>;
|
|
19
|
+
export interface AeonicCivilAnchorOptions {
|
|
20
|
+
readonly resourceLimits?: Partial<AeonicCivilAnchorResourceLimits>;
|
|
21
|
+
readonly capabilities?: readonly ['anchoring'];
|
|
22
|
+
}
|
|
23
|
+
export interface AeonicCivilAnchorProfile { readonly profile?: string }
|
|
24
|
+
export interface AeonicCivilAnchorRequest {
|
|
25
|
+
readonly operation: 'anchor';
|
|
26
|
+
readonly input: {
|
|
27
|
+
/** Coverage must be exactly one day; origin metadata does not determine eligibility. */
|
|
28
|
+
readonly anchor: AeonicTemporalOperand;
|
|
29
|
+
readonly clock: AeonicCivilClockOperand;
|
|
30
|
+
readonly context?: AeonicCivilAnchorProfile;
|
|
31
|
+
readonly policy?: AeonicCivilAnchorProfile;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface AeonicCivilAnchorDiagnostic {
|
|
35
|
+
readonly outcome: 'diagnostic';
|
|
36
|
+
readonly reason: 'invalid_operand' | 'invalid_policy' | 'unsupported_profile' | 'unsupported_operation'
|
|
37
|
+
| 'unsupported_domain' | 'incompatible_operand' | 'unrepresentable_result' | 'resource_limit';
|
|
38
|
+
readonly context: { readonly stage: 1 | 2 | 3 | 4 | 5 | 6 | 7; readonly path: string | null };
|
|
39
|
+
readonly message?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface AeonicCivilAnchorValueResult {
|
|
42
|
+
readonly outcome: 'value';
|
|
43
|
+
readonly value: AeonicDerivedDateTimeBundle;
|
|
44
|
+
readonly metadata: {
|
|
45
|
+
readonly evaluation: 'exact-for-policy';
|
|
46
|
+
readonly clamping: 'not-applied';
|
|
47
|
+
readonly effectivePolicy: { readonly profile: typeof AEONIC_TEMPORAL_CIVIL_ANCHOR_PROFILE };
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export type AeonicCivilAnchorResult = AeonicCivilAnchorValueResult | AeonicCivilAnchorDiagnostic;
|
|
51
|
+
/** Explicit profile required. Retain the complete result.value for date-time continuation. */
|
|
52
|
+
export function evaluateAeonicCivilAnchor(request: AeonicCivilAnchorRequest, options?: AeonicCivilAnchorOptions): AeonicCivilAnchorResult;
|
|
53
|
+
/** Verbatim logical JSON retains duplicate-key and raw numerical evidence. */
|
|
54
|
+
export function evaluateAeonicCivilAnchorText(requestText: string, options?: AeonicCivilAnchorOptions): AeonicCivilAnchorResult;
|