@altopelago/sansa 0.14.0 → 0.14.1

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 CHANGED
@@ -7,6 +7,36 @@ versions may still include breaking changes when the SANSA specifications move.
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.14.1 - 2026-10-16
11
+
12
+ ### Fixed
13
+
14
+ - Aligned JavaScript and Rust temporal literals and AEON target validation with
15
+ AEON 0.14.0's year/month date ticks composed with clocks. Exact authored
16
+ fractional seconds, second 60, offset anchors and opaque WTC contexts remain
17
+ intact; GP/schema limits are not imposed by the parser.
18
+ - Rejected malformed clock/date fields, noncanonical `Local` case variants,
19
+ and comment-looking suffixes inside WTC contexts, including nested expressions.
20
+ Rust target validation checks the complete payload rather than parsing away
21
+ trailing trivia. Temporal relation helpers fail closed on malformed descriptors
22
+ and unsupported disjoint date/clock completion sets without panicking or
23
+ inventing omitted calendar fields.
24
+ - Updated AEON mutation target validation for the recent reserved `base64`
25
+ decodability rule, while retaining opaque `encoding`, `inline` and `embed`
26
+ payload semantics. Clone/pointer reference addresses are validated as addresses,
27
+ including native Rust descriptors, not decoded as literal Base64URL data.
28
+ - Protected decoded multiline prose/trimtick gutters when the mutation
29
+ workbench writes AEON source. AEON target validation rejects payloads whose
30
+ trailing newlines or whitespace-only content lines cannot survive trimtick
31
+ normalization; ordinary string and Telex payloads are not narrowed.
32
+
33
+ ### Tests
34
+
35
+ - Added one shared JavaScript/Rust value fixture and a 1,109-case valid
36
+ calendar/clock matrix, plus malformed boundaries, Base64URL and symbol probes.
37
+ Tests exercise Query, JavaScript Instruction, native Rust scalar descriptors,
38
+ target validation and round trips through an available AEON Core runtime.
39
+
10
40
  ## 0.14.0 - 2026-10-15
11
41
 
12
42
  ### Added
@@ -2,7 +2,7 @@
2
2
  "claim_format": "aeonite.cts-claims.v1",
3
3
  "repository": "AltoPelago/sansa",
4
4
  "implementation": "@altopelago/sansa",
5
- "implementation_version": "0.14.0",
5
+ "implementation_version": "0.14.1",
6
6
  "cts_repository": "aeonite-org/aeonite-cts",
7
7
  "cts_protocol": "cts.protocol.v1",
8
8
  "claims": [
@@ -1099,6 +1099,34 @@ literals compare through the active temporal profile; the default profile uses
1099
1099
  canonical payload order.
1100
1100
  Explicit null literals are tested through null predicates rather than equality.
1101
1101
 
1102
+ The temporal literal boundary follows Core rather than the general-purpose
1103
+ schema: year/month date ticks can compose with clocks (`2024-T10:Z`,
1104
+ `2024-02T10:&Europe`), second `60` remains structurally valid, and arbitrary
1105
+ authored fractional digits are preserved. WTC `local` is case-sensitive; named
1106
+ contexts remain opaque ASCII payloads. Invalid fields and comment-looking
1107
+ punctuation inside a contiguous WTC token are not reinterpreted as trivia.
1108
+
1109
+ The built-in temporal relation helper handles contiguous date extents and
1110
+ complete-date clock extents. Clock-bearing year/month ticks can denote disjoint
1111
+ daily sets; those comparisons currently return `incomparable` rather than
1112
+ inventing a month/day or flattening the sets into a single interval. This
1113
+ conservative comparison limitation does not reject the literal or its AEON
1114
+ target representation. Default representation equality/order is unchanged.
1115
+
1116
+ AEON target validation also distinguishes reserved `base64` (decodable
1117
+ Base64URL, including valid padding and zero unused tail bits) from opaque
1118
+ `encoding`, `inline` and `embed` payloads. For `prose`/`trimtick`, exact multiline
1119
+ values must survive Core gutter normalization: trailing newlines and nonempty
1120
+ whitespace-only content lines cannot be preserved and produce a target-phase
1121
+ diagnostic before apply. The workbench protects representable leading empty
1122
+ lines and mixed payload indentation when re-emitting trimticks. Ordinary
1123
+ quoted-string values and direct Telex string payloads retain their full domain.
1124
+
1125
+ These datatype-specific literal checks do not decode reference addresses as
1126
+ payload data. Clone/pointer references (including native Rust reference-form
1127
+ descriptors) retain address validation; `base64` describes the referred value,
1128
+ not the bytes or Base64URL tail bits of its address.
1129
+
1102
1130
  Current comparison policy:
1103
1131
 
1104
1132
  | Operands | Equality | Ordering | Result |
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "implementation": "@altopelago/sansa",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "profiles": [
5
5
  "value-semantics-minimum-consumer",
6
6
  "aeon.value.default.v1",
package/docs/releasing.md CHANGED
@@ -77,7 +77,10 @@ are published by the workflow using short-lived OIDC credentials.
77
77
  3. Add the dated `X.Y.Z` release section and human-authored notes to
78
78
  `CHANGELOG.md`.
79
79
  4. Run `npm run version:check`, the test suite, CTS, stress tests, and package
80
- dry-run.
80
+ dry-run. Keep the CTS checkout pinned to the same reviewed commit in CI and
81
+ both publish workflows. CI and npm publication also run the Query and Mutate
82
+ `next` manifests as supplemental AEON value-alignment checks; these do not
83
+ promote development snapshots into stable conformance claims.
81
84
  5. Merge the release-prep PR into `main`.
82
85
  6. Confirm CI passes on `main`.
83
86
  7. Create tag `vX.Y.Z` from the checked `main` commit.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altopelago/sansa",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "Semantic Address NameSpace Abstraction parser, resolver, and query toolkit.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -2049,6 +2049,16 @@ function validateAeonTargetValue(value, hints, path, operationIndex) {
2049
2049
  if (representation === 'node') return validateAeonTargetNodeValue(value, path, operationIndex);
2050
2050
  const scalarValidation = validateAeonTargetScalarValue(value, representation, path, operationIndex);
2051
2051
  if (!scalarValidation.ok) return scalarValidation;
2052
+ // A reference payload is an address, not the referred value's literal data.
2053
+ if (['cloneReference', 'pointerReference', 'referenceForm'].includes(representation)) return { ok: true };
2054
+ if (typeof hints.datatype === 'string' && ['prose', 'trimtick'].includes(datatypeBaseName(hints.datatype))
2055
+ && typeof value === 'string' && !isRepresentableTrimtickPayload(value)) {
2056
+ return invalidAeonTargetValue('Trimtick normalization cannot preserve trailing newlines or whitespace-only content lines', path, operationIndex);
2057
+ }
2058
+ if (typeof hints.datatype === 'string' && datatypeBaseName(hints.datatype) === 'base64'
2059
+ && (typeof value !== 'string' || !isDecodableBase64UrlPayload(value))) {
2060
+ return invalidAeonTargetValue('base64 requires decodable Base64URL with zero unused tail bits', path, operationIndex);
2061
+ }
2052
2062
  if (Array.isArray(value)) {
2053
2063
  for (let index = 0; index < value.length; index += 1) {
2054
2064
  const result = validateAeonTargetValue(value[index], {}, `${path}[${index}]`, operationIndex);
@@ -2121,7 +2131,7 @@ function validateAeonTargetScalarValue(value, representation, path, operationInd
2121
2131
  ? { ok: true }
2122
2132
  : invalidAeonTargetValue('Boolean literals must use boolean payloads', path, operationIndex);
2123
2133
  case 'hex':
2124
- return typeof value === 'string' && /^[0-9A-Fa-f]+$/.test(value)
2134
+ return typeof value === 'string' && value.trim() === value && /^[0-9A-Fa-f]+$/.test(value)
2125
2135
  ? { ok: true }
2126
2136
  : invalidAeonTargetValue('Hex literals must be non-empty hexadecimal text without the # prefix', path, operationIndex);
2127
2137
  case 'radix':
@@ -5388,6 +5398,7 @@ export function compareTemporalClaims(left, right) {
5388
5398
  function parseTemporalCompletionSet(input) {
5389
5399
  const semanticType = String(input?.semanticType ?? 'temporal');
5390
5400
  const payload = String(input?.payload ?? input?.value ?? '');
5401
+ if (!isQueryTemporalLiteral(payload, semanticType)) return null;
5391
5402
  if (semanticType === 'date') {
5392
5403
  const date = parseTemporalDate(payload);
5393
5404
  if (date === null) return null;
@@ -5425,7 +5436,10 @@ function parseTemporalCompletionSet(input) {
5425
5436
  const marker = base.indexOf('T');
5426
5437
  if (marker === -1) return null;
5427
5438
  date = parseTemporalDate(base.slice(0, marker));
5428
- if (date === null) return null;
5439
+ // Clock-bearing year/month ticks have disjoint daily completion sets. This
5440
+ // conservative interval comparator must not invent a month/day or flatten
5441
+ // those sets into one interval. Rust returns incomparable for these too.
5442
+ if (date === null || date.month === null || date.day === null) return null;
5429
5443
  clockText = base.slice(marker + 1);
5430
5444
  }
5431
5445
  const clock = parseTemporalClock(clockText, semanticType === 'time');
@@ -5471,6 +5485,7 @@ function temporalCompletionDomain(semanticType, anchor, context) {
5471
5485
  }
5472
5486
 
5473
5487
  function parseTemporalDate(value) {
5488
+ if (value.trim() !== value) return null;
5474
5489
  const yearOnly = /^(\d{4})-$/.exec(value);
5475
5490
  if (yearOnly !== null) {
5476
5491
  const year = Number(yearOnly[1]);
@@ -5490,9 +5505,10 @@ function parseTemporalDate(value) {
5490
5505
  }
5491
5506
 
5492
5507
  function parseTemporalClock(value, requireColon) {
5508
+ if (value.trim() !== value) return null;
5493
5509
  const pattern = requireColon
5494
- ? /^(\d{2}):(?:(\d{2}))?(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:\d{2})?$/
5495
- : /^(\d{2})(?::(\d{2})?)?(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:\d{2})?$/;
5510
+ ? /^(\d{2}):(?:(\d{2})(?::(\d{2})(?:\.(\d+))?)?)?(Z|[+-]\d{2}:\d{2})?$/
5511
+ : /^(\d{2})(?::(?:(\d{2})(?::(\d{2})(?:\.(\d+))?)?)?)?(Z|[+-]\d{2}:\d{2})?$/;
5496
5512
  const match = pattern.exec(value);
5497
5513
  if (match === null) return null;
5498
5514
  const hour = Number(match[1]);
@@ -8272,7 +8288,7 @@ class QueryExpressionParser {
8272
8288
 
8273
8289
  startsTemporalLiteral() {
8274
8290
  const rest = this.input.slice(this.index);
8275
- return /^\d{4}-(?=$|[\s,)}\]]|\d|T)/.test(rest)
8291
+ return /^\d{4}-/.test(rest)
8276
8292
  || /^\d{2}:/.test(rest);
8277
8293
  }
8278
8294
 
@@ -8495,7 +8511,17 @@ function stripQueryComments(input) {
8495
8511
  output += char;
8496
8512
  continue;
8497
8513
  }
8498
- if (char === '/' && next === '/' && !isTemporalZoneCommentContext(input, index)) {
8514
+ if (char === '/' && (next === '/' || next === '*') && isTemporalZoneCommentContext(input, index)) {
8515
+ // Preserve the rest of this invalid zone token once, avoiding repeated
8516
+ // backwards scans for a long run of comment-looking slashes.
8517
+ while (index < input.length && !isLayout(input[index]) && ![',', ')', '}', ']'].includes(input[index])) {
8518
+ output += input[index];
8519
+ index += 1;
8520
+ }
8521
+ index -= 1;
8522
+ continue;
8523
+ }
8524
+ if (char === '/' && next === '/') {
8499
8525
  output += ' ';
8500
8526
  index += 1;
8501
8527
  while (index + 1 < input.length && input[index + 1] !== '\n' && input[index + 1] !== '\r') {
@@ -8504,7 +8530,7 @@ function stripQueryComments(input) {
8504
8530
  }
8505
8531
  continue;
8506
8532
  }
8507
- if (char === '/' && next === '*' && !isTemporalZoneCommentContext(input, index)) {
8533
+ if (char === '/' && next === '*') {
8508
8534
  const start = index;
8509
8535
  output += ' ';
8510
8536
  index += 1;
@@ -8533,13 +8559,11 @@ function stripQueryComments(input) {
8533
8559
 
8534
8560
  function isTemporalZoneCommentContext(input, index) {
8535
8561
  let cursor = index - 1;
8536
- while (cursor >= 0 && !isLayout(input[cursor]) && ![',', ')', '}', ']'].includes(input[cursor])) {
8562
+ while (cursor >= 0 && !isLayout(input[cursor]) && ![',', '(', ')', '{', '}', '[', ']', '=', '<', '>', '!'].includes(input[cursor])) {
8537
8563
  cursor -= 1;
8538
8564
  }
8539
8565
  const tokenPrefix = input.slice(cursor + 1, index);
8540
- const date = String.raw`\d{4}-\d{2}-\d{2}`;
8541
- const datetimeTime = String.raw`\d{2}(?::(?:\d{2})?)?(?::\d{2})?(?:Z|[+-]\d{2}:\d{2})?`;
8542
- return new RegExp(`^${date}T${datetimeTime}&[A-Za-z0-9_+\\-/]*$`).test(tokenPrefix);
8566
+ return /^\d{4}-/.test(tokenPrefix) && tokenPrefix.includes('T') && tokenPrefix.includes('&');
8543
8567
  }
8544
8568
 
8545
8569
  function renderInstruction(instruction) {
@@ -9051,30 +9075,24 @@ function isQueryCurrentPositionalShorthand(source) {
9051
9075
  }
9052
9076
 
9053
9077
  function isQueryTemporalLiteral(source, kind) {
9054
- const date = String.raw`(\d{4})-(\d{2})-(\d{2})`;
9055
- const time = String.raw`(\d{2}):(?:(\d{2}))?(?::(\d{2})(?:\.(\d+))?)?(?:Z|([+-])(\d{2}):(\d{2}))?`;
9056
- const datetimeTime = String.raw`(\d{2})(?::(\d{2})?)?(?::(\d{2})(?:\.(\d+))?)?(?:Z|([+-])(\d{2}):(\d{2}))?`;
9057
- const zone = String.raw`[A-Za-z0-9_+.\-]+(?:/[A-Za-z0-9_+.\-]+)*`;
9058
- if (kind === 'date') {
9059
- return parseTemporalDate(source) !== null;
9060
- }
9061
- if (kind === 'time') {
9062
- const match = new RegExp(`^${time}$`).exec(source);
9063
- return Boolean(match) && isValidTimeMatch(match);
9064
- }
9065
- if (kind === 'datetime') {
9066
- const match = new RegExp(`^${date}T${datetimeTime}$`).exec(source);
9067
- return Boolean(match)
9068
- && isValidDateParts(match[1], match[2], match[3])
9069
- && isValidTimeMatch(match, 4);
9070
- }
9078
+ if (kind === 'date') return parseTemporalDate(source) !== null;
9079
+ if (kind === 'time') return parseTemporalClock(source, true) !== null;
9080
+ let datetime = source;
9071
9081
  if (kind === 'wtc') {
9072
- const match = new RegExp(`^${date}T${datetimeTime}&(${zone})$`).exec(source);
9073
- return Boolean(match)
9074
- && isValidDateParts(match[1], match[2], match[3])
9075
- && isValidTimeMatch(match, 4);
9082
+ const marker = source.indexOf('&');
9083
+ if (marker === -1) return false;
9084
+ datetime = source.slice(0, marker);
9085
+ const zone = source.slice(marker + 1);
9086
+ if (!zone || zone.trim() !== zone
9087
+ || (zone.toLowerCase() === 'local' && zone !== 'local')
9088
+ || !/^[A-Za-z0-9_+.\-]+(?:\/[A-Za-z0-9_+.\-]+)*$/.test(zone)) return false;
9089
+ } else if (kind !== 'datetime') {
9090
+ return false;
9076
9091
  }
9077
- return false;
9092
+ const marker = datetime.indexOf('T');
9093
+ return marker !== -1
9094
+ && parseTemporalDate(datetime.slice(0, marker)) !== null
9095
+ && parseTemporalClock(datetime.slice(marker + 1), false) !== null;
9078
9096
  }
9079
9097
 
9080
9098
  function isValidDateParts(yearText, monthText, dayText) {
@@ -9090,26 +9108,29 @@ function isLeapYear(year) {
9090
9108
  return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
9091
9109
  }
9092
9110
 
9093
- function isValidTimeMatch(match, offset = 1) {
9094
- const hour = Number(match[offset]);
9095
- const minute = match[offset + 1] === undefined ? null : Number(match[offset + 1]);
9096
- const second = match[offset + 2] === undefined ? null : Number(match[offset + 2]);
9097
- const zoneHour = match[offset + 5] === undefined ? null : Number(match[offset + 5]);
9098
- const zoneMinute = match[offset + 6] === undefined ? null : Number(match[offset + 6]);
9099
- if (hour < 0 || hour > 23) return false;
9100
- if (minute !== null && (minute < 0 || minute > 59)) return false;
9101
- if (second !== null && (second < 0 || second > 60)) return false;
9102
- if (zoneHour !== null && (zoneHour < 0 || zoneHour > 23)) return false;
9103
- if (zoneMinute !== null && (zoneMinute < 0 || zoneMinute > 59)) return false;
9104
- return true;
9105
- }
9106
-
9107
9111
  function isAeonRadixPayload(payload) {
9108
- return /^[+-]?(?:[0-9A-Za-z&!](?:_?[0-9A-Za-z&!])*)(?:\.(?:[0-9A-Za-z&!](?:_?[0-9A-Za-z&!])*))?$|^[+-]?\.(?:[0-9A-Za-z&!](?:_?[0-9A-Za-z&!])*)$/.test(payload);
9112
+ return payload.trim() === payload
9113
+ && /^[+-]?(?:[0-9A-Za-z&!](?:_?[0-9A-Za-z&!])*)(?:\.(?:[0-9A-Za-z&!](?:_?[0-9A-Za-z&!])*))?$|^[+-]?\.(?:[0-9A-Za-z&!](?:_?[0-9A-Za-z&!])*)$/.test(payload);
9109
9114
  }
9110
9115
 
9111
9116
  function isAeonEncodingPayload(payload) {
9112
- return /^[A-Za-z0-9_-]+={0,2}$/.test(payload);
9117
+ return payload.trim() === payload && /^[A-Za-z0-9_-]+={0,2}$/.test(payload);
9118
+ }
9119
+
9120
+ function isRepresentableTrimtickPayload(payload) {
9121
+ return !payload.includes('\n') || (!payload.endsWith('\n')
9122
+ && payload.split('\n').every((line) => line.length === 0 || !/^[ \t]+$/.test(line)));
9123
+ }
9124
+
9125
+ function isDecodableBase64UrlPayload(payload) {
9126
+ if (!isAeonEncodingPayload(payload)) return false;
9127
+ const body = payload.replace(/=+$/, '');
9128
+ const padding = payload.length - body.length;
9129
+ const remainder = body.length % 4;
9130
+ if (remainder === 1 || (padding !== 0 && payload.length % 4 !== 0)
9131
+ || (padding === 1 && remainder !== 3) || (padding === 2 && remainder !== 2)) return false;
9132
+ const last = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'.indexOf(body.at(-1));
9133
+ return remainder === 2 ? (last & 15) === 0 : remainder === 3 ? (last & 3) === 0 : true;
9113
9134
  }
9114
9135
 
9115
9136
  function isAeonSeparatorPayload(payload) {
@@ -1435,7 +1435,19 @@ function renderScalarValue(binding) {
1435
1435
  }
1436
1436
 
1437
1437
  function renderBlockString(value) {
1438
- const text = String(value ?? '').replace(/\\/g, '\\\\').replace(/`/g, '\\`');
1438
+ let text = String(value ?? '');
1439
+ if (text.includes('\n')) {
1440
+ // Core trims after escape decoding. Protect nonblank lines with an opposite
1441
+ // gutter so one common character is removed without touching payload indent.
1442
+ const first = text.split('\n').find((line) => line.length > 0) ?? '';
1443
+ const gutter = first.startsWith(' ') ? '\t' : ' ';
1444
+ const leadingNewline = text.startsWith('\n');
1445
+ text = text.split('\n').map((line) => line.length === 0 ? '' : gutter + line).join('\n');
1446
+ if (leadingNewline) text = '\n' + text;
1447
+ }
1448
+ text = text
1449
+ .replace(/\\/g, '\\\\').replace(/`/g, '\\`')
1450
+ .replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t');
1439
1451
  return `>\`${text}\``;
1440
1452
  }
1441
1453