@altopelago/sansa 0.14.2 → 0.15.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/CHANGELOG.md +118 -1
  2. package/README.md +96 -1
  3. package/conformance/README.md +8 -0
  4. package/conformance/aeonic-anchor-claims.json +133 -0
  5. package/conformance/aeonic-arithmetic-claims.json +60 -0
  6. package/conformance/aeonic-clock-claims.json +123 -0
  7. package/conformance/aeonic-comparison-claims.json +37 -0
  8. package/conformance/aeonic-datetime-claims.json +110 -0
  9. package/conformance/aeonic-rational-arithmetic-claims.json +72 -0
  10. package/conformance/aeonic-temporal-claims.json +105 -0
  11. package/conformance/cts-claims.json +17 -3
  12. package/conformance/results/aeonic-anchor-capacity.json +452 -0
  13. package/conformance/results/aeonic-anchor-snapshot-0.1.json +39 -0
  14. package/conformance/results/aeonic-arithmetic-snapshot-0.1.json +28 -0
  15. package/conformance/results/aeonic-clock-all-snapshot-0.1.json +49 -0
  16. package/conformance/results/aeonic-clock-arithmetic-snapshot-0.1.json +48 -0
  17. package/conformance/results/aeonic-clock-capacity.json +326 -0
  18. package/conformance/results/aeonic-clock-relations-snapshot-0.1.json +48 -0
  19. package/conformance/results/aeonic-comparison-snapshot-0.1.json +19 -0
  20. package/conformance/results/aeonic-datetime-all-snapshot-0.1.json +47 -0
  21. package/conformance/results/aeonic-datetime-arithmetic-snapshot-0.1.json +46 -0
  22. package/conformance/results/aeonic-datetime-capacity.json +302 -0
  23. package/conformance/results/aeonic-datetime-relations-snapshot-0.1.json +46 -0
  24. package/conformance/results/aeonic-rational-arithmetic-capacity.json +100 -0
  25. package/conformance/results/aeonic-rational-arithmetic-snapshot-0.2.json +30 -0
  26. package/conformance/results/aeonic-temporal-all-property-addressing-2026-11-16.json +39 -0
  27. package/conformance/results/aeonic-temporal-all-snapshot-0.1.json +39 -0
  28. package/conformance/results/aeonic-temporal-calendar-property-addressing-2026-11-16.json +38 -0
  29. package/conformance/results/aeonic-temporal-calendar-snapshot-0.1.json +38 -0
  30. package/conformance/results/aeonic-temporal-capacity-property-addressing-2026-11-16.json +136 -0
  31. package/conformance/results/aeonic-temporal-capacity.json +136 -0
  32. package/conformance/results/aeonic-temporal-relations-property-addressing-2026-11-16.json +38 -0
  33. package/conformance/results/aeonic-temporal-relations-snapshot-0.1.json +38 -0
  34. package/docs/aeonic-arithmetic.md +126 -0
  35. package/docs/aeonic-comparison.md +123 -0
  36. package/docs/aeonic-rational-arithmetic.md +167 -0
  37. package/docs/aeonic-temporal-civil-anchor.md +89 -0
  38. package/docs/aeonic-temporal-civil-clock.md +100 -0
  39. package/docs/aeonic-temporal-civil-date.md +124 -0
  40. package/docs/aeonic-temporal-civil-datetime.md +122 -0
  41. package/docs/api-contract.md +130 -3
  42. package/docs/capabilities.json +106 -2
  43. package/docs/child-identity-activation.md +93 -0
  44. package/docs/child-identity-candidate.md +60 -0
  45. package/docs/child-identity-tooling.md +31 -0
  46. package/docs/child-identity-workflows.md +102 -0
  47. package/docs/empty-keys-candidate.md +29 -0
  48. package/docs/migration-0.15.0.md +75 -0
  49. package/docs/property-addressing-implementation.md +118 -0
  50. package/docs/property-resolve-implementation.md +105 -0
  51. package/docs/property-selector-support.md +65 -0
  52. package/docs/property-selectors-api.d.ts +43 -0
  53. package/docs/property-selectors-api.pyi +27 -0
  54. package/docs/property-selectors-api.rs +48 -0
  55. package/docs/property-selectors-contract.md +168 -0
  56. package/docs/query-tool.md +32 -1
  57. package/docs/selector-cursor.md +45 -0
  58. package/docs/unicode-hardening.md +41 -0
  59. package/fixtures/address-v1.json +4 -3
  60. package/fixtures/child-identity-workflows/README.md +9 -0
  61. package/fixtures/child-identity-workflows/moved.aeon +10 -0
  62. package/fixtures/child-identity-workflows/original.aeon +10 -0
  63. package/fixtures/child-identity-workflows/reordered.aeon +10 -0
  64. package/fixtures/child-identity-workflows/replacement.aeon +10 -0
  65. package/fixtures/child-identity-workflows/workflows.json +89 -0
  66. package/fixtures/property-namespace-candidate-v1.json +336 -0
  67. package/fixtures/property-parser-candidate-v1.json +705 -0
  68. package/fixtures/property-query-candidate-v1.json +398 -0
  69. package/fixtures/property-resolve-candidate-v1.json +2702 -0
  70. package/fixtures/unicode-hardening-v1.json +401 -0
  71. package/package.json +30 -3
  72. package/scripts/calibrate-aeonic-anchor-capacity.py +294 -0
  73. package/scripts/calibrate-aeonic-clock-capacity.py +62 -0
  74. package/scripts/calibrate-aeonic-datetime-capacity.py +76 -0
  75. package/scripts/calibrate-aeonic-rational-capacity.py +85 -0
  76. package/scripts/calibrate-aeonic-temporal-capacity.py +95 -0
  77. package/scripts/cts-address.mjs +6 -2
  78. package/scripts/cts-aeonic-anchor.mjs +21 -0
  79. package/scripts/cts-aeonic-arithmetic-adapter.mjs +25 -0
  80. package/scripts/cts-aeonic-arithmetic.mjs +24 -0
  81. package/scripts/cts-aeonic-clock.mjs +24 -0
  82. package/scripts/cts-aeonic-comparison-adapter.mjs +30 -0
  83. package/scripts/cts-aeonic-comparison.mjs +25 -0
  84. package/scripts/cts-aeonic-datetime.mjs +24 -0
  85. package/scripts/cts-aeonic-rational-arithmetic-adapter.mjs +25 -0
  86. package/scripts/cts-aeonic-rational-arithmetic.mjs +24 -0
  87. package/scripts/cts-aeonic-temporal-civil-anchor-adapter.mjs +26 -0
  88. package/scripts/cts-aeonic-temporal-civil-clock-adapter.mjs +28 -0
  89. package/scripts/cts-aeonic-temporal-civil-date-adapter.mjs +28 -0
  90. package/scripts/cts-aeonic-temporal-civil-datetime-adapter.mjs +28 -0
  91. package/scripts/cts-aeonic-temporal.mjs +24 -0
  92. package/scripts/cts-instruction.mjs +4 -2
  93. package/scripts/cts-mutate.mjs +3 -2
  94. package/scripts/cts-resolve.mjs +17 -2
  95. package/scripts/playground.mjs +110 -0
  96. package/src/aeonic-arithmetic-binding.js +61 -0
  97. package/src/aeonic-arithmetic.d.ts +84 -0
  98. package/src/aeonic-arithmetic.js +276 -0
  99. package/src/aeonic-comparison.d.ts +86 -0
  100. package/src/aeonic-comparison.js +274 -0
  101. package/src/aeonic-convenience.d.ts +30 -0
  102. package/src/aeonic-convenience.js +45 -0
  103. package/src/aeonic-exact-number.js +34 -0
  104. package/src/aeonic-json.js +45 -0
  105. package/src/aeonic-rational-arithmetic.d.ts +86 -0
  106. package/src/aeonic-rational-arithmetic.js +417 -0
  107. package/src/aeonic-rational-json.js +51 -0
  108. package/src/aeonic-temporal-civil-anchor.d.ts +54 -0
  109. package/src/aeonic-temporal-civil-anchor.js +316 -0
  110. package/src/aeonic-temporal-civil-clock.d.ts +124 -0
  111. package/src/aeonic-temporal-civil-clock.js +388 -0
  112. package/src/aeonic-temporal-civil-date.d.ts +123 -0
  113. package/src/aeonic-temporal-civil-date.js +310 -0
  114. package/src/aeonic-temporal-civil-datetime.d.ts +138 -0
  115. package/src/aeonic-temporal-civil-datetime.js +501 -0
  116. package/src/index.d.ts +84 -1
  117. package/src/index.js +828 -183
  118. package/src/property-address.js +196 -0
  119. package/src/property-resolve.js +132 -0
  120. package/src/query-metadata.d.ts +16 -0
  121. package/src/query-metadata.js +25 -0
  122. package/src/selector-cursor.d.ts +19 -0
  123. package/src/selector-cursor.js +79 -0
  124. package/stress-tests/address/invalid.sansa-cases +0 -2
  125. package/stress-tests/address/valid.sansa-cases +3 -0
  126. package/tools/mutate-web/examples.mjs +1 -1
  127. package/tools/mutate-web/runtime.mjs +0 -2
  128. package/tools/playground/README.md +165 -0
  129. package/tools/playground/accessibility.js +91 -0
  130. package/tools/playground/aeon-highlight.js +77 -0
  131. package/tools/playground/aeon-source-composer.js +1077 -0
  132. package/tools/playground/anchor-examples.mjs +16 -0
  133. package/tools/playground/arithmetic-evaluator.mjs +28 -0
  134. package/tools/playground/arithmetic-model.mjs +187 -0
  135. package/tools/playground/arithmetic-worker.mjs +14 -0
  136. package/tools/playground/arithmetic.css +1 -0
  137. package/tools/playground/arithmetic.html +29 -0
  138. package/tools/playground/arithmetic.mjs +110 -0
  139. package/tools/playground/clock-examples.mjs +16 -0
  140. package/tools/playground/datetime-examples.mjs +22 -0
  141. package/tools/playground/examples.mjs +46 -0
  142. package/tools/playground/index.html +174 -0
  143. package/tools/playground/local.css +25 -0
  144. package/tools/playground/namespace.mjs +39 -0
  145. package/tools/playground/sansa-playground.js +1565 -0
  146. package/tools/playground/site.css +3914 -0
  147. package/tools/playground/temporal-examples.mjs +20 -0
  148. package/tools/playground/walkthrough.js +90 -0
  149. package/tools/playground/website-origin.json +16 -0
  150. package/tools/query-web/IDENTITY_SELECTORS.md +44 -0
  151. package/tools/query-web/app.js +4 -0
  152. package/tools/query-web/index.html +4 -0
  153. package/tools/query-web/runtime.mjs +70 -19
  154. package/tools/workflows/property-playground-assertions.mjs +33 -0
  155. package/tools/workflows/verify-child-identities.mjs +137 -0
  156. package/tools/workflows/verify-property-playground.mjs +48 -0
@@ -0,0 +1,294 @@
1
+ """Isolate eleven native anchoring defaults with explicit companion allowances.
2
+
3
+ These are admitted/denied threshold observations, separate from CTS conformance,
4
+ combined support floors, arbitrary native graphs, framing, heap/disk and chains.
5
+ Only the command supplied explicitly by --sut is executed, without a shell.
6
+ """
7
+ import argparse
8
+ import copy
9
+ from datetime import date, timedelta
10
+ from decimal import Decimal, InvalidOperation
11
+ import hashlib
12
+ import json
13
+ from pathlib import Path
14
+ import shlex
15
+ import subprocess
16
+ import tempfile
17
+
18
+ ROOT = Path(__file__).resolve().parents[1]
19
+ PROFILE = 'aeonic.operations.temporal.civil-anchor.v1'
20
+ DEFAULTS = dict(maxRequestBytes=65536, maxRequestDepth=32, maxTemporalCharacters=1024,
21
+ maxInputRanges=128, maxInputPieces=512, maxRelativeDayDigits=256,
22
+ maxFractionDigits=256, maxWork=16384, maxIntermediatePieces=4096,
23
+ maxOutputPieces=512, maxResultBytes=131072)
24
+ MAX_PROTOCOL_BYTES = 16 * 1024 * 1024
25
+
26
+
27
+ def compact(value, canonical=False):
28
+ return json.dumps(value, ensure_ascii=False, allow_nan=False,
29
+ separators=(',', ':'), sort_keys=canonical)
30
+
31
+
32
+ def fingerprint(value):
33
+ return hashlib.sha256(compact(value, True).encode('utf-8')).hexdigest()
34
+
35
+
36
+ def diagnostic(reason, stage, path=None):
37
+ return dict(outcome='diagnostic', reason=reason, context=dict(stage=stage, path=path))
38
+
39
+
40
+ def clock(text):
41
+ return dict(temporal=dict(category='civilClock', value=text))
42
+
43
+
44
+ def point(i, fraction=''):
45
+ return dict(kind='point', at=dict(day='0', time='%02d:%02d:%02d' %
46
+ (i//3600, i//60 % 60, i % 60) + ('.'+fraction if fraction else '')))
47
+
48
+
49
+ def derived(pieces):
50
+ return dict(temporal=dict(category='civilClockSet', pieces=pieces),
51
+ originClockForm='undeclared', history='none-declared')
52
+
53
+
54
+ def request(value=None, anchor=None):
55
+ return dict(operation='anchor', input=dict(
56
+ anchor=anchor if anchor is not None else dict(temporal=dict(category='civilDate', value='2024-01-01')),
57
+ clock=value if value is not None else clock('00:00:00'), context=dict(profile=PROFILE)))
58
+
59
+
60
+ def success(value):
61
+ """Independent expected fixture image: known reference-day-zero points only.
62
+
63
+ No stage evaluator or general anchoring engine is supplied by this tool.
64
+ """
65
+ temporal = value['temporal']
66
+ if temporal['category'] == 'civilClock':
67
+ text = temporal['value']
68
+ if '.' in text:
69
+ whole, fraction = text.split('.')
70
+ text = whole + ('.'+fraction.rstrip('0') if fraction.rstrip('0') else '')
71
+ points = [dict(kind='point', at='2024-01-01T'+text)]
72
+ origin = 'second'
73
+ else:
74
+ assert all(p['kind'] == 'point' and p['at']['day'] == '0' for p in temporal['pieces'])
75
+ points = [dict(kind='point', at='2024-01-01T'+p['at']['time']) for p in temporal['pieces']]
76
+ origin = 'undeclared'
77
+ return dict(outcome='value', value=dict(temporal=dict(category='civilDateTimeSet', pieces=points),
78
+ originDateGranularity='day', originClockForm=origin,
79
+ history=dict(clamping='none-declared', approximation='none-declared')),
80
+ metadata=dict(evaluation='exact-for-policy', clamping='not-applied', effectivePolicy=dict(profile=PROFILE)))
81
+
82
+
83
+ def build_cases():
84
+ cases = []
85
+
86
+ def add(dimension, role, value, logical, expected, companions=None, text=False, suffix=''):
87
+ companions = companions or {}
88
+ assert dimension in DEFAULTS and dimension not in companions
89
+ assert set(companions) <= set(DEFAULTS)
90
+ cases.append(dict(id=dimension+'-'+role+suffix, dimension=dimension, role=role,
91
+ observed_quantity=value, companion_limits=companions,
92
+ fixture={'requestText' if text else 'request':logical}, expected=expected))
93
+
94
+ small = request(); small_result = success(small['input']['clock']); text = compact(small)
95
+ for size in (65536, 65537):
96
+ add('maxRequestBytes', 'at-default' if size == 65536 else 'over-default', size,
97
+ text+' '*(size-len(text)), small_result if size == 65536 else diagnostic('resource_limit', 1), text=True)
98
+ for size in (65536, 65537):
99
+ q = request(anchor=dict(temporal=dict(category='container', payload='')))
100
+ q['input']['anchor']['temporal']['payload'] = 'x'*(size-len(compact(q)))
101
+ assert len(compact(q).encode('utf-8')) == size
102
+ add('maxRequestBytes', 'at-default' if size == 65536 else 'over-default', size, q,
103
+ diagnostic('unsupported_domain', 5, '/input/anchor/temporal/category') if size == 65536 else diagnostic('resource_limit', 1), suffix='-structured')
104
+ for depth in (32, 33):
105
+ payload = None
106
+ for _ in range(depth-4): payload = [payload]
107
+ q = request(anchor=dict(temporal=dict(category='container', payload=payload)))
108
+ add('maxRequestDepth', 'at-default' if depth == 32 else 'over-default', depth, q,
109
+ diagnostic('unsupported_domain', 5, '/input/anchor/temporal/category') if depth == 32 else diagnostic('resource_limit', 1))
110
+ for size in (1024, 1025):
111
+ c = clock('00:00:00.'+'1'*(size-9))
112
+ add('maxTemporalCharacters', 'at-default' if size == 1024 else 'over-default', size, request(c),
113
+ success(c) if size == 1024 else diagnostic('resource_limit', 4, '/input/clock/temporal/value'), dict(maxFractionDigits=1016))
114
+ for count in (128, 129):
115
+ first = date(2024, 1, 1)
116
+ ranges = [dict(start=(first+timedelta(days=2*i)).isoformat(), end=(first+timedelta(days=2*i)).isoformat()) for i in range(count)]
117
+ a = dict(temporal=dict(category='civilDateSet', ranges=ranges), originGranularity='undeclared', history='none-declared')
118
+ add('maxInputRanges', 'at-default' if count == 128 else 'over-default', count, request(anchor=a),
119
+ diagnostic('incompatible_operand', 6, '/input/anchor/temporal') if count == 128 else diagnostic('resource_limit', 4, '/input/anchor/temporal/ranges'))
120
+ for dimension, count, companions, stage in [
121
+ ('maxInputPieces', 512, {}, 4),
122
+ ('maxIntermediatePieces', 4096, dict(maxInputPieces=4097, maxOutputPieces=4097,
123
+ maxRequestBytes=1048576, maxResultBytes=1048576), 6),
124
+ ('maxOutputPieces', 512, dict(maxInputPieces=513), 7),
125
+ ]:
126
+ for n in (count, count+1):
127
+ c = derived([point(i) for i in range(n)])
128
+ path = '/input/clock/temporal/pieces' if stage == 4 else None
129
+ add(dimension, 'at-default' if n == count else 'over-default', n, request(c),
130
+ success(c) if n == count else diagnostic('resource_limit', stage, path), companions)
131
+ for digits in (256, 257):
132
+ c = derived([dict(kind='point', at=dict(day='9'*digits, time='00:00:00'))])
133
+ add('maxRelativeDayDigits', 'at-default' if digits == 256 else 'over-default', digits, request(c),
134
+ diagnostic('unrepresentable_result', 7) if digits == 256 else diagnostic('resource_limit', 4, '/input/clock/temporal/pieces/0/at/day'))
135
+ for suffix, digit in [('', '1'), ('-raw-trailing-zeroes', '0')]:
136
+ for digits in (256, 257):
137
+ fraction = '1'*digits if digit == '1' else '1'+'0'*(digits-1)
138
+ c = clock('00:00:00.'+fraction)
139
+ add('maxFractionDigits', 'at-default' if digits == 256 else 'over-default', digits, request(c),
140
+ success(c) if digits == 256 else diagnostic('resource_limit', 4, '/input/clock/temporal/value'), suffix=suffix)
141
+ for work in (16384, 16385):
142
+ c = derived([point(i) for i in range(work-1)])
143
+ add('maxWork', 'at-default' if work == 16384 else 'over-default', work, request(c),
144
+ success(c) if work == 16384 else diagnostic('resource_limit', 6),
145
+ dict(maxRequestBytes=2097152, maxInputPieces=16384, maxIntermediatePieces=16384,
146
+ maxOutputPieces=16384, maxResultBytes=2097152))
147
+
148
+ # Reach the *exact* native successful-envelope byte default. Fraction text
149
+ # supplies the remaining bytes without overriding the dimension under test.
150
+ c = derived([point(i) for i in range(512)])
151
+ remaining = 131072-len(compact(success(c)).encode('utf-8'))
152
+ for p in c['temporal']['pieces']:
153
+ take = min(257, remaining)
154
+ if remaining-take == 1: take -= 1
155
+ if take >= 2:
156
+ p['at']['time'] += '.'+'1'*(take-1); remaining -= take
157
+ assert remaining == 0 and len(compact(success(c)).encode('utf-8')) == 131072
158
+ add('maxResultBytes', 'at-default', 131072, request(c), success(c), dict(maxRequestBytes=262144))
159
+ larger = copy.deepcopy(c); raw = larger['temporal']['pieces']
160
+ partial = next((p for p in raw if '.' in p['at']['time'] and len(p['at']['time'].split('.')[1]) < 256), None)
161
+ if partial is not None: partial['at']['time'] += '1'
162
+ else:
163
+ full = next(p for p in raw if '.' in p['at']['time'])
164
+ full['at']['time'] = full['at']['time'][:-1]
165
+ next(p for p in raw if '.' not in p['at']['time'])['at']['time'] += '.1'
166
+ assert len(compact(success(larger)).encode('utf-8')) == 131073
167
+ add('maxResultBytes', 'over-default', 131073, request(larger), diagnostic('resource_limit', 7), dict(maxRequestBytes=262144))
168
+ assert len(cases) == 26 and len({c['id'] for c in cases}) == 26
169
+ for dimension in DEFAULTS:
170
+ assert {'at-default', 'over-default'} <= {c['role'] for c in cases if c['dimension'] == dimension}
171
+ return cases
172
+
173
+
174
+ def strict_pairs(items):
175
+ value = {}
176
+ for key, child in items:
177
+ if key in value: raise ValueError('Duplicate protocol key')
178
+ value[key] = child
179
+ return value
180
+
181
+
182
+ class OpaqueNumber:
183
+ def __init__(self, text): self.text = text
184
+
185
+
186
+ def protocol_number(text):
187
+ # Only small exact stage numbers need numerical interpretation. Preserve
188
+ # other tokens opaquely, including in allowed transport extensions, rather
189
+ # than converting arbitrarily wide decimal integers or extreme exponents.
190
+ if len(text) <= 64:
191
+ try:
192
+ number = Decimal(text)
193
+ if number.is_finite() and number.copy_abs() <= 9007199254740991 and number == number.to_integral_value():
194
+ return int(number)
195
+ except InvalidOperation:
196
+ pass
197
+ return OpaqueNumber(text)
198
+
199
+
200
+ def decode(text):
201
+ def constant(value): raise ValueError('Non-JSON constant: '+value)
202
+ return json.loads(text, object_pairs_hook=strict_pairs, parse_constant=constant,
203
+ parse_int=protocol_number, parse_float=protocol_number)
204
+
205
+
206
+ def equal(a, b):
207
+ if isinstance(a, dict) and isinstance(b, dict): return a.keys() == b.keys() and all(equal(a[k], b[k]) for k in a)
208
+ if isinstance(a, list) and isinstance(b, list): return len(a) == len(b) and all(equal(x, y) for x, y in zip(a, b))
209
+ if type(a) in (int, float) and type(b) in (int, float): return a == b
210
+ return type(a) is type(b) and a == b
211
+
212
+
213
+ def execute(command, envelope, timeout):
214
+ with tempfile.TemporaryFile() as out, tempfile.TemporaryFile() as err:
215
+ child = subprocess.run(shlex.split(command), input=compact(envelope), text=True, encoding='utf-8',
216
+ stdout=out, stderr=err, cwd=ROOT, timeout=timeout)
217
+ err.seek(0); message = err.read(4096).decode('utf-8', errors='replace')
218
+ if child.returncode: raise ValueError('Provider harness failure: '+message)
219
+ if out.tell() > MAX_PROTOCOL_BYTES: raise ValueError('Provider output exceeds controller read cap')
220
+ out.seek(0)
221
+ return decode(out.read(MAX_PROTOCOL_BYTES+1).decode('utf-8'))
222
+
223
+
224
+ def check_output(output, expected):
225
+ if not isinstance(output, dict): raise ValueError('Protocol output must be an object')
226
+ actual = output.get('result')
227
+ ok = expected['outcome'] == 'value'
228
+ if type(output.get('ok')) is not bool or output['ok'] != ok: raise ValueError('Protocol status mismatch')
229
+ if not equal(output.get('warnings'), []): raise ValueError('Unexpected protocol warnings')
230
+ errors = output.get('errors')
231
+ if ok:
232
+ if not equal(errors, []): raise ValueError('Unexpected protocol errors')
233
+ else:
234
+ if not isinstance(errors, list) or len(errors) != 1 or not isinstance(errors[0], dict): raise ValueError('One protocol error required')
235
+ if not all(key in errors[0] and equal(errors[0][key], value) for key, value in dict(code=expected['reason'], path=None, span=None, phase=None).items()): raise ValueError('Protocol error mismatch')
236
+ if isinstance(actual, dict) and 'message' in actual:
237
+ message = actual['message']
238
+ if not isinstance(message, str) or any(0xD800 <= ord(c) <= 0xDFFF for c in message): raise ValueError('Invalid diagnostic message')
239
+ actual = {k:v for k,v in actual.items() if k != 'message'}
240
+ if not equal(actual, expected): raise ValueError('Complete operation result mismatch')
241
+ return actual
242
+
243
+
244
+ def calibrator_digest():
245
+ return hashlib.sha256(Path(__file__).read_bytes()).hexdigest()
246
+
247
+
248
+ def run(command, timeout=30):
249
+ source_digest = calibrator_digest()
250
+ cases = []; failures = []
251
+ for case in build_cases():
252
+ expected = case['expected']
253
+ envelope = dict(lane='aeonic-temporal-civil-anchor', case_id=case['id'], fixture=case['fixture'],
254
+ policy=dict(resourceLimits=case['companion_limits']))
255
+ item = {key:case[key] for key in ['id','dimension','role','observed_quantity','companion_limits']}
256
+ item.update(expected_outcome=expected['outcome'], expected_sha256=fingerprint(expected))
257
+ if expected['outcome'] == 'diagnostic': item.update(expected_reason=expected['reason'], expected_context=expected['context'])
258
+ else: item['expected_result_bytes'] = len(compact(expected).encode('utf-8'))
259
+ try:
260
+ actual = check_output(execute(command, envelope, timeout), expected)
261
+ item.update(status='passed', actual_sha256=fingerprint(actual))
262
+ except Exception as error:
263
+ item.update(status='failed', failure=str(error)[:1500]); failures.append(case['id'])
264
+ cases.append(item)
265
+ covered = []
266
+ for dimension, limit in DEFAULTS.items():
267
+ observed = {(c['role'], c['observed_quantity']) for c in cases
268
+ if c['dimension'] == dimension and c['status'] == 'passed'
269
+ and dimension not in c['companion_limits']}
270
+ if {('at-default', limit), ('over-default', limit+1)} <= observed: covered.append(dimension)
271
+ else: failures.append('incomplete-coverage:'+dimension)
272
+ if calibrator_digest() != source_digest: failures.append('calibrator-integrity')
273
+ return dict(status='failed' if failures else 'passed', checks=len(cases), defaults=DEFAULTS,
274
+ covered_dimensions=sorted(covered), calibrator_sha256=source_digest,
275
+ sut=command, cases=cases, failures=failures, stable_conformance_claim=False,
276
+ scope='Individual native default admission thresholds with explicit companion settings. Range-count and relative-day admitted controls reach later semantic diagnostics; each is recorded as such.',
277
+ limits='No Cartesian-product, arbitrary accessor/proxy/subclass, eager-key, outer-frame, process/heap/disk, browser-preparation or whole-chain capacity guarantee. The controller output read cap is not a provider disk quota.')
278
+
279
+
280
+ def main():
281
+ parser = argparse.ArgumentParser(description=__doc__)
282
+ parser.add_argument('--sut', required=True); parser.add_argument('--report', type=Path)
283
+ parser.add_argument('--timeout', type=float, default=30)
284
+ args = parser.parse_args()
285
+ if not args.sut or not shlex.split(args.sut) or not 0 < args.timeout <= 60: raise ValueError('Explicit provider and positive timeout at most 60s required')
286
+ report = run(args.sut, args.timeout)
287
+ if args.report:
288
+ args.report.parent.mkdir(parents=True, exist_ok=True); args.report.write_text(json.dumps(report, indent=2)+'\n')
289
+ print(json.dumps({key:report[key] for key in ['status','checks','covered_dimensions','failures']}))
290
+ return 1 if report['failures'] else 0
291
+
292
+
293
+ if __name__ == '__main__':
294
+ raise SystemExit(main())
@@ -0,0 +1,62 @@
1
+ """Isolate all16 native default dimensions; no Cartesian/host/whole-chain claim."""
2
+ import argparse
3
+ import json
4
+ from pathlib import Path
5
+ import shlex
6
+ import subprocess
7
+
8
+ parser=argparse.ArgumentParser();parser.add_argument('--sut',required=True);parser.add_argument('--report',type=Path);args=parser.parse_args()
9
+ repository=Path(__file__).resolve().parents[1];PROFILE='aeonic.operations.temporal.civil-clock.v1'
10
+ def compact(v):return json.dumps(v,ensure_ascii=False,separators=(',',':'))
11
+ def civil(v):return dict(temporal=dict(category='civilClock',value=v))
12
+ def derived(pieces):return dict(temporal=dict(category='civilClockSet',pieces=pieces),originClockForm='undeclared',history='none-declared')
13
+ def point(day,time):return dict(kind='point',at=dict(day=day,time=time))
14
+ def points(n):return [point('0','%02d:%02d:%02d'%(i//3600,i//60%60,i%60)) for i in range(n)]
15
+ def request(v,op='shiftClock',policy=None,amount='0'):
16
+ data=dict(value=v,context=dict(profile=PROFILE))
17
+ if policy is not None:data['policy']=policy
18
+ if op=='shiftClock':data['amount']=dict(number=dict(category='finiteNumber',value=amount))
19
+ return dict(operation=op,input=data)
20
+ checks=[]
21
+ def check(name,logical,expected='value',limits=None,text=False):
22
+ envelope=dict(lane='aeonic-temporal-civil-clock',case_id=name,fixture={'requestText' if text else 'request':logical},policy={} if limits is None else dict(resourceLimits=limits))
23
+ child=subprocess.run(shlex.split(args.sut),input=compact(envelope),text=True,capture_output=True,cwd=repository,timeout=30)
24
+ if child.returncode:raise RuntimeError((name,child.stderr))
25
+ result=json.loads(child.stdout)['result']
26
+ valid=result.get('outcome')=='value' if expected=='value' else result.get('reason')==expected[0] and result.get('context',{}).get('stage')==expected[1] and 'value' not in result
27
+ if not valid:raise RuntimeError((name,result))
28
+ checks.append(dict(name=name,status='passed',companion_limits=limits or {},expected=expected));return result
29
+ small=compact(request(civil('00:00:00')))
30
+ for n in (65536,65537):check('request-bytes-'+str(n),small+' '*(n-len(small)),'value' if n==65536 else ('resource_limit',1),text=True)
31
+ for arrays in (28,29):
32
+ payload=None
33
+ for _ in range(arrays):payload=[payload]
34
+ q=dict(operation='equal',input=dict(left=dict(temporal=dict(category='container',payload=payload)),right=civil('09:30'),context=dict(profile=PROFILE)))
35
+ check('request-depth-'+str(arrays+4),q,('unsupported_domain',5) if arrays==28 else ('resource_limit',1))
36
+ for n in (1024,1025):check('temporal-characters-'+str(n),request(civil('00:00:00.'+'1'*(n-9))),'value' if n==1024 else ('resource_limit',4),dict(maxFractionDigits=1025))
37
+ for n in (512,513):check('input-pieces-'+str(n),request(derived(points(n))),'value' if n==512 else ('resource_limit',4))
38
+ for n in (4096,4097):check('intermediate-pieces-'+str(n),request(derived(points(n))),'value' if n==4096 else ('resource_limit',6),dict(maxInputPieces=4097,maxOutputPieces=4097,maxRequestBytes=1048576,maxResultBytes=1048576))
39
+ for n in (512,513):check('output-pieces-'+str(n),request(derived(points(n))),'value' if n==512 else ('resource_limit',7),dict(maxInputPieces=513))
40
+ for n in (16384,16385):
41
+ q=dict(operation='equal',input=dict(context=dict(profile=PROFILE),left=derived(points(8192)),right=derived(points(n-8192))))
42
+ check('work-'+str(n),q,'value' if n==16384 else ('resource_limit',6),dict(maxInputPieces=8193,maxRequestBytes=2097152))
43
+ for n in (256,257):check('fraction-digits-'+str(n),request(civil('00:00:00.'+'1'*n)),'value' if n==256 else ('resource_limit',4))
44
+ for n in (256,257):check('relative-day-digits-'+str(n),request(derived([point('1'*n,'00:00:00')])),'value' if n==256 else ('resource_limit',4))
45
+ for n in (32,33):check('count-characters-'+str(n),request(civil('00:00:00'),'step',dict(clockForm='second',count='9'*n)),'value' if n==32 else ('resource_limit',3))
46
+ for n in (4096,4097):check('numeric-characters-'+str(n),request(civil('00:00:00'),amount='0e'+'0'*(n-2)),'value' if n==4096 else ('resource_limit',4))
47
+ for n in (1024,1025):check('coefficient-digits-'+str(n),request(civil('00:00:00'),amount='1'*n+'e-'+str(n)),'value' if n==1024 else ('resource_limit',4),dict(maxFractionDigits=1025))
48
+ for n in (1000000,1000001):check('authored-exponent-'+str(n),request(civil('00:00:00'),amount='0e'+str(n)),'value' if n==1000000 else ('resource_limit',4))
49
+ for n in (4089,4090):check('workspace-'+str(n+7),request(civil('00:00:00'),amount='1e-'+str(n)),'value' if n==4089 else ('resource_limit',6),dict(maxFractionDigits=4090))
50
+ for n in (1024,1025):check('output-characters-'+str(n),request(civil('00:00:00.'+'1'*(n-9)),'materialize',dict(clockForm='second')),'value' if n==1024 else ('resource_limit',7),dict(maxTemporalCharacters=1025,maxFractionDigits=1016))
51
+ def expected_result(n):return dict(outcome='value',value=derived(points(n)),metadata=dict(evaluation='exact-for-policy',effectivePolicy=dict(profile=PROFILE)))
52
+ base=len(compact(expected_result(1)));increment=len(compact(expected_result(2)))-base;n=1+(131072-base)//increment
53
+ companions=dict(maxInputPieces=n+1,maxOutputPieces=n+1,maxRequestBytes=1048576)
54
+ actual=check('native-result-bytes-last-admitted',request(derived(points(n))),limits=companions)
55
+ if actual!=expected_result(n):raise RuntimeError('Unexpected result value')
56
+ check('native-result-bytes-next-rejected',request(derived(points(n+1))),('resource_limit',7),companions)
57
+ size=len(compact(expected_result(n)))
58
+ check('exact-result-byte-boundary',request(derived(points(n))),limits=dict(companions,maxResultBytes=size))
59
+ check('exact-result-byte-boundary-minus-one',request(derived(points(n))),('resource_limit',7),dict(companions,maxResultBytes=size-1))
60
+ report=dict(status='passed',checks=len(checks),sut=args.sut,cases=checks,result_byte_probe=dict(last_reachable_below_default=size,next_reachable=size+increment),limits='All16 dimensions isolated using recorded companion limits. No Cartesian-product, process/heap, transport, native accessor/proxy or whole-chain guarantee.')
61
+ if args.report:args.report.parent.mkdir(parents=True,exist_ok=True);args.report.write_text(json.dumps(report,indent=2)+'\n')
62
+ print(json.dumps(dict(status='passed',checks=len(checks))))
@@ -0,0 +1,76 @@
1
+ """Native-default capacity probes, independent of shared semantic CTS fixtures.
2
+
3
+ Companion limits isolate each dimension; admission is not a claim about the
4
+ Cartesian product, operating-system heap, arbitrary transports or chain budgets.
5
+ """
6
+ import argparse
7
+ from datetime import date, timedelta
8
+ import json
9
+ from pathlib import Path
10
+ import shlex
11
+ import subprocess
12
+
13
+ parser=argparse.ArgumentParser()
14
+ parser.add_argument('--sut',required=True)
15
+ parser.add_argument('--report',type=Path)
16
+ args=parser.parse_args()
17
+ repository=Path(__file__).resolve().parents[1]
18
+ PROFILE='aeonic.operations.temporal.civil-datetime.v1'
19
+ HISTORY=dict(clamping='none-declared',approximation='none-declared')
20
+ def compact(v):return json.dumps(v,ensure_ascii=False,separators=(',',':'))
21
+ def civil(v):return dict(temporal=dict(category='civilDateTime',value=v))
22
+ def derived(pieces):return dict(temporal=dict(category='civilDateTimeSet',pieces=pieces),originDateGranularity='undeclared',originClockForm='undeclared',history=HISTORY)
23
+ def request(value,op='shift',policy=None,amount=None):
24
+ data=dict(value=value,context=dict(profile=PROFILE))
25
+ if policy is not None:data['policy']=policy
26
+ elif op=='shift':data['policy']=dict(unit='day',count='0')
27
+ if amount is not None:data['amount']=dict(number=dict(category='finiteNumber',value=amount))
28
+ return dict(operation=op,input=data)
29
+ def points(n):return [dict(kind='point',at='2024-03-01T'+f'{i//3600:02}:{i//60%60:02}:{i%60:02}') for i in range(n)]
30
+ def span(days):return derived([dict(kind='interval',start='2000-01-01T00:00:00',end=(date(2000,1,1)+timedelta(days=days)).isoformat()+'T00:00:00',includeStart=True,includeEnd=False)])
31
+ checks=[]
32
+ def check(name,logical,expected='value',limits=None,text=False):
33
+ envelope=dict(lane='aeonic-temporal-civil-datetime',case_id=name,fixture={'requestText' if text else 'request':logical},policy={} if limits is None else dict(resourceLimits=limits))
34
+ child=subprocess.run(shlex.split(args.sut),input=compact(envelope),text=True,capture_output=True,cwd=repository,timeout=30)
35
+ assert child.returncode==0,(name,child.stderr)
36
+ result=json.loads(child.stdout)['result']
37
+ if expected=='value':assert result.get('outcome')=='value',(name,result)
38
+ else:assert result.get('reason')==expected[0] and result.get('context',{}).get('stage')==expected[1] and 'value' not in result,(name,result)
39
+ checks.append(dict(name=name,status='passed',companion_limits=limits or {},expected=expected))
40
+ return result
41
+
42
+ small=compact(request(civil('2024-03-01T09:30')))
43
+ for n in (65536,65537):check('request-bytes-'+str(n),small+' '*(n-len(small)),'value' if n==65536 else ('resource_limit',1),text=True)
44
+ for arrays in (28,29):
45
+ payload=None
46
+ for _ in range(arrays):payload=[payload]
47
+ logical=dict(operation='equal',input=dict(left=dict(temporal=dict(category='container',payload=payload)),right=civil('2024-03-01T09:30'),context=dict(profile=PROFILE)))
48
+ check('request-depth-'+str(arrays+4),logical,('unsupported_domain',5) if arrays==28 else ('resource_limit',1))
49
+ for n in (1024,1025):check('temporal-characters-'+str(n),request(civil('2024-03-01T00:00:00.'+'1'*(n-20))),'value' if n==1024 else ('resource_limit',4),dict(maxFractionDigits=1025))
50
+ for n in (512,513):check('input-pieces-'+str(n),request(derived(points(n))),'value' if n==512 else ('resource_limit',4))
51
+ for n in (4096,4097):check('intermediate-pieces-'+str(n),request(span(n),policy=dict(unit='month',count='1')),'value' if n==4096 else ('resource_limit',6))
52
+ for n in (512,513):check('output-pieces-'+str(n),request(derived(points(n))),'value' if n==512 else ('resource_limit',7),dict(maxInputPieces=513))
53
+ for n in (16384,16385):check('work-'+str(n),request(span(n),policy=dict(unit='month',count='1')),'value' if n==16384 else ('resource_limit',6),dict(maxIntermediatePieces=16385))
54
+ for n in (256,257):check('fraction-digits-'+str(n),request(civil('2024-03-01T00:00:00.'+'1'*n)),'value' if n==256 else ('resource_limit',4))
55
+ for n in (32,33):check('count-characters-'+str(n),request(civil('2024-03-01T09:30'),policy=dict(unit='month',count='9'*n)),('unrepresentable_result',6) if n==32 else ('resource_limit',3))
56
+ for n in (4096,4097):check('numeric-characters-'+str(n),request(civil('2024-03-01T09:30'),'shiftClock',amount='0e'+'0'*(n-2)),'value' if n==4096 else ('resource_limit',4))
57
+ for n in (1024,1025):check('coefficient-digits-'+str(n),request(civil('2024-03-01T09:30:00'),'shiftClock',amount='1'*n+'e-'+str(n)),'value' if n==1024 else ('resource_limit',4),dict(maxFractionDigits=1025))
58
+ for n in (1000000,1000001):check('authored-exponent-'+str(n),request(civil('2024-03-01T09:30'),'shiftClock',amount='0e'+str(n)),'value' if n==1000000 else ('resource_limit',4))
59
+ for n in (4083,4084):check('workspace-'+str(n+13),request(civil('2024-03-01T09:30:00'),'shiftClock',amount='1e-'+str(n)),'value' if n==4083 else ('resource_limit',6),dict(maxFractionDigits=4084))
60
+ for n in (1024,1025):check('output-characters-'+str(n),request(civil('2024-03-01T00:00:00.'+'1'*(n-20)),'materialize',dict(dateGranularity='day',clockForm='second')),'value' if n==1024 else ('resource_limit',7),dict(maxTemporalCharacters=1025,maxFractionDigits=1005))
61
+ def expected_result(n):return dict(outcome='value',value=derived(points(n)),metadata=dict(evaluation='exact-for-policy',clamping='not-applied',effectivePolicy=dict(profile=PROFILE,unit='day',count='0')))
62
+ # Every point has the same spelling length. Derive the last reachable default
63
+ # result from the public envelope, not a value supplied by the SUT.
64
+ base=len(compact(expected_result(1)));increment=len(compact(expected_result(2)))-base
65
+ n=1+(131072-base)//increment
66
+ companions=dict(maxInputPieces=n+1,maxOutputPieces=n+1,maxRequestBytes=524288)
67
+ actual=check('native-result-bytes-last-admitted',request(derived(points(n))),limits=companions)
68
+ assert actual==expected_result(n)
69
+ check('native-result-bytes-next-rejected',request(derived(points(n+1))),('resource_limit',7),companions)
70
+ size=len(compact(expected_result(n)))
71
+ check('exact-result-byte-boundary',request(derived(points(n))),limits=dict(companions,maxResultBytes=size))
72
+ check('exact-result-byte-boundary-minus-one',request(derived(points(n))),('resource_limit',7),dict(companions,maxResultBytes=size-1))
73
+ report=dict(status='passed',checks=len(checks),sut=args.sut,cases=checks,result_byte_probe=dict(last_reachable_below_default=size,next_reachable=size+increment),limits='15 dimensions isolated using recorded companion limits. Counts and extreme zero exponents admit input before later domain/normalization checks. No Cartesian-product, heap, process, transport or whole-chain guarantee.')
74
+ if args.report:
75
+ args.report.parent.mkdir(parents=True,exist_ok=True);args.report.write_text(json.dumps(report,indent=2)+'\n')
76
+ print(json.dumps(dict(status='passed',checks=len(checks))))
@@ -0,0 +1,85 @@
1
+ # Adapted from Aeonic at 64347f19181041f86135e958da5a16ecc4b60b57; MIT, Copyright (c) 2026 Patrik.
2
+ """Bounded default-capacity probes, independent of the shared CTS fixtures."""
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+ import shlex
7
+ import subprocess
8
+
9
+ parser = argparse.ArgumentParser()
10
+ parser.add_argument("--sut", required=True)
11
+ parser.add_argument("--report", type=Path)
12
+ args = parser.parse_args()
13
+ repository = Path(__file__).resolve().parents[1]
14
+ profile = "aeonic.operations.arithmetic.rational.v1"
15
+
16
+
17
+ def finite(text):
18
+ return {"number": {"category": "finiteNumber", "value": text}}
19
+
20
+
21
+ def exact(c, e="0", d=None):
22
+ number = dict(category="exactRational" if d else "exactNumber", coefficient=c, exponent=e)
23
+ if d:
24
+ number["denominator"] = d
25
+ return dict(number=number, history="none-declared")
26
+
27
+
28
+ def request(left, right=None, operation="add", policy=None):
29
+ data = dict(context=dict(profile=profile))
30
+ data.update(dict(value=left, policy=policy) if operation == "materialize" else dict(left=left, right=right or finite("0")))
31
+ return dict(operation=operation, input=data)
32
+
33
+
34
+ checks = []
35
+
36
+
37
+ def check(name, value, expected, limits=None, text=False):
38
+ fixture = {"requestText" if text else "request": value}
39
+ envelope = dict(lane="aeonic-rational-arithmetic", case_id=name, fixture=fixture,
40
+ policy={} if limits is None else dict(resourceLimits=limits))
41
+ child = subprocess.run(shlex.split(args.sut), input=json.dumps(envelope), text=True,
42
+ capture_output=True, cwd=repository, timeout=15)
43
+ if child.returncode:
44
+ raise AssertionError(name + ": harness failure: " + child.stderr)
45
+ result = json.loads(child.stdout)["result"]
46
+ if isinstance(expected, tuple):
47
+ reason, stage = expected
48
+ assert result.get("reason") == reason and result.get("context", {}).get("stage") == stage, (name, result)
49
+ assert "value" not in result, (name, result)
50
+ else:
51
+ assert result.get("outcome") == "value" and result["value"] == expected, (name, result)
52
+ checks.append(dict(name=name, status="passed", companion_limits=limits or {}))
53
+
54
+
55
+ check("coefficient-at-512", request(finite("1"*512)), exact("1"*512))
56
+ check("coefficient-over-512", request(finite("1"*513)), ("resource_limit", 4))
57
+ check("denominator-at-512", request(exact("1", d="9"*512)), exact("1", d="9"*512))
58
+ check("denominator-over-512", request(exact("1", d="9"*513)), ("resource_limit", 4))
59
+ check("numeric-text-at-1024", request(finite("1e"+"0"*1022)), exact("1"))
60
+ check("numeric-text-over-1024", request(finite("1e"+"0"*1023)), ("resource_limit", 4))
61
+ check("exponent-at-million", request(finite("1e1000000")), exact("1", "1000000"))
62
+ check("exponent-over-million", request(finite("1e1000001")), ("resource_limit", 4))
63
+ check("result-exponent-over-million", request(finite("5e1000000"), finite("2"), "multiply"), ("resource_limit", 6))
64
+ companions = dict(maxCoefficientDigits=4096, maxNumericCharacters=2048)
65
+ product = "9"*2047+"8"+"0"*2047+"1" # (10^2048 - 1)^2
66
+ check("workspace-at-4096", request(finite("9"*2048), finite("9"*2048), "multiply"), exact(product), companions)
67
+ check("workspace-below-4096", request(finite("9"*2048), finite("9"*2048), "multiply"),
68
+ ("resource_limit", 6), dict(companions, maxWorkspaceDigits=4095))
69
+ check("output-at-1024", request(exact("1", "1023"), operation="materialize", policy=dict(family="integer")),
70
+ finite("1"+"0"*1023) | dict(history="none-declared"))
71
+ check("output-over-1024", request(exact("1", "1024"), operation="materialize", policy=dict(family="integer")), ("resource_limit", 7))
72
+ logical = json.dumps(request(finite("1")))
73
+ check("bytes-at-16384", logical+" "*(16384-len(logical)), exact("1"), text=True)
74
+ check("bytes-over-16384", logical+" "*(16385-len(logical)), ("resource_limit", 1), text=True)
75
+ for arrays, expected in [(28, ("unsupported_domain", 5)), (29, ("resource_limit", 1))]:
76
+ payload = None
77
+ for _ in range(arrays):
78
+ payload = [payload]
79
+ check("depth-"+str(arrays+4), request(dict(number=dict(category="container", payload=payload))), expected)
80
+ report = dict(status="passed", checks=len(checks), sut=args.sut, cases=checks,
81
+ limits="Independent capacities with explicit workspace companion limits; no Cartesian-product or machine-resource guarantee.")
82
+ if args.report:
83
+ args.report.parent.mkdir(parents=True, exist_ok=True)
84
+ args.report.write_text(json.dumps(report, indent=2)+"\n")
85
+ print(json.dumps(dict(status="passed", checks=len(checks))))
@@ -0,0 +1,95 @@
1
+ """Independent native-default boundary probes; not shared semantic fixtures."""
2
+ import argparse
3
+ from datetime import date, timedelta
4
+ import json
5
+ from pathlib import Path
6
+ import shlex
7
+ import subprocess
8
+
9
+ parser = argparse.ArgumentParser()
10
+ parser.add_argument('--sut', required=True)
11
+ parser.add_argument('--report', type=Path)
12
+ args = parser.parse_args()
13
+ repository = Path(__file__).resolve().parents[1]
14
+ PROFILE = 'aeonic.operations.temporal.civil-date.v1'
15
+
16
+ def civil(value):
17
+ return dict(temporal=dict(category='civilDate', value=value))
18
+
19
+ def derived(ranges):
20
+ return dict(temporal=dict(category='civilDateSet', ranges=ranges), originGranularity='undeclared', history='none-declared')
21
+
22
+ def request(value, operation='shift', policy=None):
23
+ return dict(operation=operation, input=dict(value=value, context=dict(profile=PROFILE), policy=policy or dict(unit='day', count='0')))
24
+
25
+ def points(n):
26
+ return [dict(start=(date(2024, 1, 1)+timedelta(days=2*i)).isoformat(), end=(date(2024, 1, 1)+timedelta(days=2*i)).isoformat()) for i in range(n)]
27
+
28
+ def compact(value):
29
+ return json.dumps(value, ensure_ascii=False, separators=(',', ':'))
30
+
31
+ checks = []
32
+ def check(name, logical, expected='value', limits=None, text=False):
33
+ envelope = dict(lane='aeonic-temporal-civil-date', case_id=name,
34
+ fixture={'requestText' if text else 'request':logical}, policy={} if limits is None else dict(resourceLimits=limits))
35
+ child = subprocess.run(shlex.split(args.sut), input=compact(envelope), text=True, capture_output=True, cwd=repository, timeout=20)
36
+ assert child.returncode == 0, (name, child.stderr)
37
+ result = json.loads(child.stdout)['result']
38
+ if isinstance(expected, tuple):
39
+ reason, stage = expected
40
+ assert result.get('reason') == reason and result.get('context', {}).get('stage') == stage and 'value' not in result, (name, result)
41
+ else:
42
+ assert result.get('outcome') == 'value' and result['metadata']['evaluation'] == 'exact-for-policy', (name, result)
43
+ if result['value']['temporal']['category'] == 'civilDateSet':
44
+ ranges = result['value']['temporal']['ranges']
45
+ assert ranges and all(r['start'] <= r['end'] for r in ranges), name
46
+ assert all(date.fromisoformat(ranges[i]['start']).toordinal() > date.fromisoformat(ranges[i-1]['end']).toordinal()+1 for i in range(1, len(ranges))), name
47
+ checks.append(dict(name=name, status='passed', companion_limits=limits or {}))
48
+ return result
49
+
50
+ small = compact(request(civil('2024-03-15')))
51
+ check('request-bytes-at-16384', small+' '*(16384-len(small)), text=True)
52
+ check('request-bytes-over-16384', small+' '*(16385-len(small)), ('resource_limit', 1), text=True)
53
+ for arrays in [28, 29]:
54
+ payload = None
55
+ for _ in range(arrays):
56
+ payload = [payload]
57
+ logical = dict(operation='equal', input=dict(left=dict(temporal=dict(category='container', payload=payload)), right=civil('2024-01'), context=dict(profile=PROFILE)))
58
+ check('depth-'+str(arrays+4), logical, ('unsupported_domain', 5) if arrays == 28 else ('resource_limit', 1))
59
+ check('input-ranges-at-128', request(derived(points(128))))
60
+ check('input-ranges-over-128', request(derived(points(129))), ('resource_limit', 4))
61
+ check('count-characters-at-32', request(civil('2024-01'), policy=dict(unit='month', count='9'*32)), ('unrepresentable_result', 6))
62
+ check('count-characters-over-32', request(civil('2024-01'), policy=dict(unit='month', count='9'*33)), ('resource_limit', 3))
63
+ # A non-leap source year shifted by one year leaves a gap on target leap days.
64
+ # Through source year524 there are127such gaps→128canonical output ranges.
65
+ for end, expected in [('0524-12-31', 'value'), ('0528-12-31', ('resource_limit', 6))]:
66
+ r = request(derived([dict(start='0001-01-01', end=end)]), policy=dict(unit='year', count='1'))
67
+ result = check('output-ranges-'+end, r, expected, dict(maxCalendarWork=7000))
68
+ if expected == 'value':
69
+ assert len(result['value']['temporal']['ranges']) == 128
70
+ companions = dict(maxOutputRanges=4096, maxResultBytes=524288)
71
+ for end, expected in [('0342-04-30', 'value'), ('0342-05-31', ('resource_limit', 6))]:
72
+ check('calendar-work-'+end, request(derived([dict(start='0001-01-01', end=end)]), policy=dict(unit='month', count='1')), expected, companions)
73
+ check('output-characters-at-10', request(civil('2024-03-15'), 'materialize', dict(granularity='day')))
74
+ check('output-characters-below-10', request(civil('2024-03-15'), 'materialize', dict(granularity='day')), ('resource_limit', 7), dict(maxOutputCharacters=9))
75
+ # Find the last reachable envelope below16KiB. Raise range/input/work companions;
76
+ # exact successful byte preflight is checked at its own size and one byte below.
77
+ def expected_result(n):
78
+ return dict(outcome='value', value=derived(points(n)), metadata=dict(evaluation='exact-for-policy', clamping='not-applied', effectivePolicy=dict(profile=PROFILE, unit='day', count='0')))
79
+ n = 1
80
+ while len(compact(expected_result(n+1))) <= 16384:
81
+ n += 1
82
+ companions = dict(maxInputRanges=n+1, maxOutputRanges=n+1, maxCalendarWork=n+1, maxRequestBytes=65536)
83
+ accepted = check('native-result-bytes-below-16384', request(derived(points(n))), limits=companions)
84
+ size = len(compact(expected_result(n)))
85
+ assert compact(accepted) == compact(expected_result(n)) or accepted == expected_result(n)
86
+ check('native-result-bytes-over-16384', request(derived(points(n+1))), ('resource_limit', 7), companions)
87
+ check('exact-result-byte-boundary', request(derived(points(n))), limits=dict(companions, maxResultBytes=size))
88
+ check('exact-result-byte-boundary-minus-one', request(derived(points(n))), ('resource_limit', 7), dict(companions, maxResultBytes=size-1))
89
+ report = dict(status='passed', checks=len(checks), sut=args.sut, cases=checks,
90
+ result_byte_probe=dict(last_reachable_below_default=size, next_reachable=len(compact(expected_result(n+1)))),
91
+ limits='Companion limits isolate dimensions. Count32 admits syntax then rejects domain at stage6. Date spellings have at most10characters. No Cartesian-product, elapsed-time, heap or process-capacity guarantee.')
92
+ if args.report:
93
+ args.report.parent.mkdir(parents=True, exist_ok=True)
94
+ args.report.write_text(json.dumps(report, indent=2)+'\n')
95
+ print(json.dumps(dict(status='passed', checks=len(checks))))