@altopelago/sansa 0.12.0 → 0.14.0

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,8 +7,62 @@ versions may still include breaking changes when the SANSA specifications move.
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.14.0 - 2026-10-15
11
+
12
+ ### Added
13
+
14
+ - Added a proposal-stage Rust SANSA.Mutate type shell and a side-effect-free
15
+ planner covering all 28 cases assigned to the pinned experimental plan
16
+ surface. The planner retains opaque exact bindings, evaluates Query
17
+ preconditions, enforces conservative container/conflict/budget rules, and
18
+ preserves provenance and portability warnings.
19
+ - Added post-plan Rust SANSA.Mutate target-surface validation covering all 36
20
+ pinned experimental AEON and JSON cases. Built-in validation remains
21
+ representability-only, and a host-neutral trait permits separate custom
22
+ validators without granting authority or exposing mutation hooks. Apply and
23
+ policy remain independent unimplemented surfaces.
24
+
25
+ ### Fixed
26
+
27
+ - JSON mutation target validation in Rust and JavaScript now distinguishes
28
+ actual attribute-space selectors from quoted property names containing
29
+ `.@`, including contextual aliases and attribute descendants.
30
+ - Corrected Rust target-validator dispatch so JSON's container and attribute
31
+ restrictions run in the JSON validator, while AEON accepts those targets.
32
+ Public API regression coverage now exercises every mutation operation across
33
+ AEON, JSON, and their default/alias spellings.
34
+ - Hardened the Rust mutation planner so every resolved alias of the namespace
35
+ root is protected from removal, pre-parsed targets are revalidated under the
36
+ planner's Address ceiling, and non-portable Address warnings inside Query
37
+ preconditions are retained on the plan. Precondition resolution now has a
38
+ finite default binding ceiling and reports exhaustion through the normalized
39
+ mutation budget diagnostic.
40
+
41
+ ## 0.13.0 - 2026-10-06
42
+
43
+ ### Added
44
+
45
+ - Added bounded Rust SANSA Query clause and expression parsing, covering all 57
46
+ stable parser cases from the pinned Query CTS. The syntax surface includes
47
+ canonical AST rendering, AEON scalar literal families, projections, dynamic
48
+ `path(...)` sources, and explicit input, token, AST-node, nesting, and literal
49
+ ceilings.
50
+ - Added host-neutral Rust SANSA Query evaluation over opaque namespace handles,
51
+ covering all 169 stable evaluator cases from the pinned Query CTS. The
52
+ evaluator implements From, Where, Order, Offset, Limit, Select, stable
53
+ functions and value families, short-circuiting, deterministic ordering,
54
+ phase-specific budgets, and constrained dynamic-address activation. Together
55
+ with parsing, the Rust runtime now claims the complete 226-case stable core
56
+ `SANSA.Query` lane; experimental Transform cases remain excluded.
57
+
10
58
  ## 0.12.0 - 2026-10-01
11
59
 
60
+ ### Added
61
+
62
+ - Added the publishable `altopelago-sansa-runtime` Rust crate. The initial
63
+ Rust surface implements the pinned stable Address, Resolve, and shared AEON
64
+ minimum value-semantics CTS lanes while reporting Query as unimplemented.
65
+
12
66
  ### Changed
13
67
 
14
68
  - Added AEON symbolic literals to Query, Instruction, mutation target
package/CONTRIBUTING.md CHANGED
@@ -32,6 +32,7 @@ version is:
32
32
  ## Development expectations
33
33
 
34
34
  - run `npm test` for normal package changes
35
+ - run `npm run test:rust` for Rust runtime or conformance-harness changes
35
36
  - run `npm run cts` for conformance-affecting changes
36
37
  - run `npm run cts:query:experimental` when touching experimental Query or
37
38
  Transform behavior
@@ -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.12.0",
5
+ "implementation_version": "0.14.0",
6
6
  "cts_repository": "aeonite-org/aeonite-cts",
7
7
  "cts_protocol": "cts.protocol.v1",
8
8
  "claims": [
@@ -453,7 +453,7 @@ planMutation({
453
453
  }, namespace)
454
454
  ```
455
455
 
456
- If mutation targets parse successfully but produce SANSA portability warnings, successful planning preserves those diagnostics on `plan.portabilityWarnings`. For example, a caller may raise the local position-index limit above the SANSA portable ceiling; if the target resolves exactly, the plan remains inspectable but carries the non-portability warning.
456
+ If mutation targets or addresses embedded in precondition expressions parse successfully but produce SANSA portability warnings, successful planning preserves those diagnostics on `plan.portabilityWarnings`. For example, a caller may raise the local position-index limit above the SANSA portable ceiling; if the address resolves successfully, the plan remains inspectable but carries the non-portability warning. Pre-parsed target addresses are rendered and revalidated under the planner's configured Address ceiling, so they cannot bypass its limit or warning behavior.
457
457
 
458
458
  Mutation plans are current-process execution artifacts, not portable serialized plan documents. A plan retains live binding objects supplied by the resolver, along with local adapter artifacts such as `bindingHandle` and `observedState`. These fields are for same-process continuity checks and diagnostics. Do not `JSON.stringify` a plan and replay it later or in another implementation; cloned or serialized plans cannot prove live binding continuity and should fail apply-time stale-target checks. A portable mutation-plan serialization format may be defined by a later profile.
459
459
 
@@ -490,10 +490,24 @@ applyMutationPlan(plan, namespace, {
490
490
 
491
491
  Budget exhaustion returns `SANSA_MUTATE_BUDGET_EXCEEDED` with `phase`, `budget`, `limit`, and `observed`. It does not produce a partial plan and does not apply partial mutations.
492
492
 
493
+ Query preconditions also inherit the planner's Resolve `maxBindings` ceiling.
494
+ The Rust planner applies a fail-closed default of `100000` bindings when the
495
+ caller does not provide a stricter ceiling. Exhausting this resolution budget
496
+ is normalized as `SANSA_MUTATE_BUDGET_EXCEEDED` with `budget: "maxBindings"`
497
+ and the failing precondition index.
498
+
493
499
  `maxValueNodes`, `maxValueDepth`, and `maxStringLength` are budgets over supplied values for `create`, `replace`, and `insert`. They are honored during planning and again during apply when callers provide a prebuilt plan. `maxValueNodes` counts all supplied value nodes across the request or plan; arrays and objects count as one node plus their entries. `maxValueDepth` is the deepest supplied value tree, with scalar values at depth `1`. `maxStringLength` is the longest supplied string payload observed by this implementation.
494
500
 
495
501
  Planning is side-effect free. Every executable target is resolved exactly at planning time. Expanded selectors such as `$.items.*`, ranges such as `$.items[0..2]`, filters, name patterns, and parent traversal are not accepted as mutation targets in this initial slice. `create` targets an existing exact parent and carries the new child name separately.
496
502
 
503
+ The Rust runtime exposes post-plan target validation separately through
504
+ `mutate_target::validate_mutation_plan_target`. Its built-in proposal-stage
505
+ surfaces cover AEON and JSON representability and are exercised directly by all
506
+ 36 target-validation cases in the pinned experimental CTS snapshot.
507
+ `MutationTargetValidator` permits a host-defined immutable plan validator, but
508
+ successful representability does not imply schema validity, authorization, or
509
+ permission to apply the plan.
510
+
497
511
  `applyMutationPlan` applies an already planned mutation only when the namespace exposes matching mutation hooks:
498
512
 
499
513
  ```js
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "implementation": "@altopelago/sansa",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "profiles": [
5
5
  "value-semantics-minimum-consumer",
6
6
  "aeon.value.default.v1",
package/docs/releasing.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Releasing
2
2
 
3
- SANSA publishes to npm from GitHub Actions using npm trusted publishing.
3
+ SANSA publishes its JavaScript package to npm and its host-neutral Rust runtime
4
+ to crates.io from GitHub Actions using trusted publishing.
4
5
 
5
6
  ## npm setup
6
7
 
@@ -19,16 +20,57 @@ packages published from public repositories.
19
20
 
20
21
  ## GitHub setup
21
22
 
22
- Create a GitHub environment named `npm`. Add required reviewers to that
23
- environment if release approval should be explicit before publishing.
23
+ Create GitHub environments named `npm` and `crates-io`. Add required reviewers
24
+ to either environment if release approval should be explicit before publishing.
24
25
 
25
26
  The publish workflow runs when a GitHub Release is published. It verifies that
26
27
  the release tag matches the package version, so `package.json` version `X.Y.Z`
27
28
  must be released from tag `vX.Y.Z`.
28
29
 
30
+ ## crates.io setup
31
+
32
+ crates.io does not allow a trusted publisher to create a crate. Bootstrap the
33
+ initial release with a conventional crates.io API token, then configure a
34
+ trusted publisher for `altopelago-sansa-runtime`:
35
+
36
+ - GitHub organization or user: `AltoPelago`
37
+ - Repository: `sansa`
38
+ - Workflow filename: `rust-publish.yml`
39
+ - Environment name: `crates-io`
40
+
41
+ The Rust workflow uses a separate signed annotated `rust/vX.Y.Z` tag. It checks
42
+ that the tag resolves to `main`, matches the shared project version, passes all
43
+ implemented stable Rust CTS lanes, and produces a package that builds before
44
+ requesting a short-lived crates.io token through GitHub OIDC. A clean consumer
45
+ then installs and exercises the exact published version.
46
+
47
+ ### Initial crates.io bootstrap
48
+
49
+ For the initial `0.12.0` publication only:
50
+
51
+ 1. Merge the reviewed Rust-publication PR and confirm CI passes on `main`.
52
+ 2. Create the narrowest short-lived crates.io API token that permits publishing
53
+ a new crate.
54
+ 3. From a clean checkout of that `main` commit, run `cargo login`, enter the
55
+ token when prompted, and then run:
56
+
57
+ ```sh
58
+ cargo publish --locked --manifest-path implementations/rust/crates/sansa-runtime/Cargo.toml
59
+ ```
60
+
61
+ 4. Run `cargo logout` and revoke the bootstrap token on crates.io.
62
+ 5. Configure the trusted publisher above now that the crate exists.
63
+ 6. Create and push the signed annotated `rust/v0.12.0` tag from the same
64
+ reviewed commit. The workflow verifies the existing exact release, skips a
65
+ duplicate upload, and runs the clean-registry smoke test.
66
+
67
+ Do not retain the bootstrap token as a GitHub secret. Subsequent Rust releases
68
+ are published by the workflow using short-lived OIDC credentials.
69
+
29
70
  ## Release steps
30
71
 
31
- 1. Run `npm run version:set -- X.Y.Z` to update machine-owned release metadata.
72
+ 1. Run `npm run version:set -- X.Y.Z` to update machine-owned npm,
73
+ capability, and Rust release metadata atomically.
32
74
  2. Update `conformance/cts-claims.json` so `implementation_version` matches the
33
75
  package release, and confirm every claimed immutable CTS snapshot id remains
34
76
  authoritative for the release.
@@ -39,11 +81,18 @@ must be released from tag `vX.Y.Z`.
39
81
  5. Merge the release-prep PR into `main`.
40
82
  6. Confirm CI passes on `main`.
41
83
  7. Create tag `vX.Y.Z` from the checked `main` commit.
42
- 8. Publish a GitHub Release for `vX.Y.Z`.
43
- 9. Let `Publish npm` run from GitHub Actions.
44
- 10. Confirm the npm package page shows the expected version and provenance.
84
+ 8. Publish a GitHub Release for `vX.Y.Z` and let `Publish npm` complete.
85
+ 9. Create a signed annotated `rust/vX.Y.Z` tag from the same checked `main`
86
+ commit and push it.
87
+ 10. Let `Rust Publish` complete, including its clean-registry smoke test.
88
+ 11. Confirm both registry pages show the expected version and provenance.
89
+
90
+ For the initial Rust-only 0.12.0 publication, follow the bootstrap procedure
91
+ above; the existing npm `v0.12.0` tag and artifact remain unchanged. From the
92
+ next coordinated version onward, create both tags from the same checked commit.
45
93
 
46
- `version:set` updates `package.json` and `docs/capabilities.json` together.
94
+ `version:set` updates `package.json`, `docs/capabilities.json`, and
95
+ `implementations/rust/Cargo.toml` together.
47
96
  `version:check` is enforced by CI and the publish workflow; it also requires a
48
97
  matching dated changelog heading. The setter accepts valid SemVer without a
49
98
  leading `v`, permits an exact idempotent rerun, and otherwise requires the new
@@ -51,6 +100,6 @@ version to have higher SemVer precedence. Neither command commits, tags, or
51
100
  publishes.
52
101
  Updates use staged files, backups, and atomic renames. If a process is
53
102
  interrupted, both `version:set` and `version:check` fail closed until
54
- `npm run version:recover` either restores the original pair or finishes cleanup
55
- for a committed pair. Run recovery only after confirming no other version
56
- command is active.
103
+ `npm run version:recover` either restores the original release set or finishes
104
+ cleanup for a committed set. Run recovery only after confirming no other
105
+ version command is active.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altopelago/sansa",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "Semantic Address NameSpace Abstraction parser, resolver, and query toolkit.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -65,7 +65,8 @@
65
65
  "version:check": "node scripts/version.mjs check",
66
66
  "version:recover": "node scripts/version.mjs recover",
67
67
  "validate:cts-claims": "node scripts/validate-cts-claims.mjs",
68
- "test": "node --test test/*.test.js"
68
+ "test": "node --test test/*.test.js",
69
+ "test:rust": "cargo fmt --all --check --manifest-path implementations/rust/Cargo.toml && cargo clippy --locked --workspace --all-features --all-targets --manifest-path implementations/rust/Cargo.toml -- -D warnings && cargo test --locked --workspace --all-features --all-targets --manifest-path implementations/rust/Cargo.toml"
69
70
  },
70
71
  "keywords": [
71
72
  "sansa",
@@ -23,6 +23,7 @@ const repositoryRoot = path.resolve(
23
23
  const expectedPackageName = '@altopelago/sansa';
24
24
  const packagePath = path.join(repositoryRoot, 'package.json');
25
25
  const capabilitiesPath = path.join(repositoryRoot, 'docs', 'capabilities.json');
26
+ const cargoManifestPath = path.join(repositoryRoot, 'implementations', 'rust', 'Cargo.toml');
26
27
  const changelogPath = path.join(repositoryRoot, 'CHANGELOG.md');
27
28
  const transactionPath = path.join(repositoryRoot, '.sansa-version-transaction');
28
29
  const journalPath = path.join(transactionPath, 'journal.json');
@@ -45,6 +46,13 @@ const transactionTargets = [
45
46
  backup: path.join(transactionPath, 'capabilities.backup'),
46
47
  restore: path.join(transactionPath, 'capabilities.restore'),
47
48
  },
49
+ {
50
+ label: 'implementations/rust/Cargo.toml',
51
+ path: cargoManifestPath,
52
+ next: path.join(transactionPath, 'cargo.next'),
53
+ backup: path.join(transactionPath, 'cargo.backup'),
54
+ restore: path.join(transactionPath, 'cargo.restore'),
55
+ },
48
56
  ];
49
57
 
50
58
  function fail(message) {
@@ -294,6 +302,30 @@ async function jsonWithReplacedVersion(file, label, currentVersion, nextVersion)
294
302
  );
295
303
  }
296
304
 
305
+ function cargoVersionFromSource(source) {
306
+ const matches = [...source.matchAll(/^version\s*=\s*"([^"]+)"\s*$/gm)];
307
+ if (matches.length !== 1) {
308
+ throw new Error(
309
+ 'implementations/rust/Cargo.toml must contain exactly one workspace package version',
310
+ );
311
+ }
312
+ return matches[0][1];
313
+ }
314
+
315
+ async function cargoWithReplacedVersion(currentVersion, nextVersion) {
316
+ const source = await readFile(cargoManifestPath, 'utf8');
317
+ const actualVersion = cargoVersionFromSource(source);
318
+ if (actualVersion !== currentVersion) {
319
+ throw new Error(
320
+ `implementations/rust/Cargo.toml version ${JSON.stringify(actualVersion)} does not match package version ${JSON.stringify(currentVersion)}`,
321
+ );
322
+ }
323
+ return source.replace(
324
+ new RegExp(`^(version\\s*=\\s*)"${escapeRegExp(currentVersion)}"[ \\t]*$`, 'm'),
325
+ `$1${JSON.stringify(nextVersion)}`,
326
+ );
327
+ }
328
+
297
329
  function releaseHeadingProblem(changelog, version) {
298
330
  const releaseHeading = new RegExp(
299
331
  `^## ${escapeRegExp(version)} - \\d{4}-\\d{2}-\\d{2}$`,
@@ -305,7 +337,7 @@ function releaseHeadingProblem(changelog, version) {
305
337
  : `CHANGELOG.md must have exactly one dated release heading for ${version}`;
306
338
  }
307
339
 
308
- function metadataProblems(packageManifest, capabilities, changelog = null) {
340
+ function metadataProblems(packageManifest, capabilities, cargoVersion, changelog = null) {
309
341
  const problems = [];
310
342
  const version = packageManifest.version;
311
343
  if (packageManifest.name !== expectedPackageName) {
@@ -324,6 +356,11 @@ function metadataProblems(packageManifest, capabilities, changelog = null) {
324
356
  `docs/capabilities.json version ${JSON.stringify(capabilities.version)} does not match package version ${JSON.stringify(version)}`,
325
357
  );
326
358
  }
359
+ if (cargoVersion !== version) {
360
+ problems.push(
361
+ `implementations/rust/Cargo.toml version ${JSON.stringify(cargoVersion)} does not match package version ${JSON.stringify(version)}`,
362
+ );
363
+ }
327
364
  if (changelog !== null && typeof version === 'string') {
328
365
  const problem = releaseHeadingProblem(changelog, version);
329
366
  if (problem !== null) problems.push(problem);
@@ -332,14 +369,21 @@ function metadataProblems(packageManifest, capabilities, changelog = null) {
332
369
  }
333
370
 
334
371
  async function loadMetadata({ includeChangelog }) {
335
- const [packageManifest, capabilities, changelog] = await Promise.all([
372
+ const [packageManifest, capabilities, cargoManifest, changelog] = await Promise.all([
336
373
  readJson(packagePath, 'package.json'),
337
374
  readJson(capabilitiesPath, 'docs/capabilities.json'),
375
+ assertRegularFile(cargoManifestPath, 'implementations/rust/Cargo.toml')
376
+ .then(() => readFile(cargoManifestPath, 'utf8')),
338
377
  includeChangelog
339
378
  ? assertRegularFile(changelogPath, 'CHANGELOG.md').then(() => readFile(changelogPath, 'utf8'))
340
379
  : Promise.resolve(null),
341
380
  ]);
342
- return { packageManifest, capabilities, changelog };
381
+ return {
382
+ packageManifest,
383
+ capabilities,
384
+ cargoVersion: cargoVersionFromSource(cargoManifest),
385
+ changelog,
386
+ };
343
387
  }
344
388
 
345
389
  async function checkVersion() {
@@ -348,6 +392,7 @@ async function checkVersion() {
348
392
  const problems = metadataProblems(
349
393
  metadata.packageManifest,
350
394
  metadata.capabilities,
395
+ metadata.cargoVersion,
351
396
  metadata.changelog,
352
397
  );
353
398
  await Promise.all([
@@ -363,6 +408,10 @@ async function checkVersion() {
363
408
  metadata.capabilities.version,
364
409
  metadata.capabilities.version,
365
410
  ),
411
+ cargoWithReplacedVersion(
412
+ metadata.packageManifest.version,
413
+ metadata.packageManifest.version,
414
+ ),
366
415
  ]).catch((error) => problems.push(errorMessage(error)));
367
416
  if (problems.length > 0) throw new Error(problems.join('; '));
368
417
  console.log(
@@ -421,6 +470,7 @@ async function setVersion(version) {
421
470
  const problems = metadataProblems(
422
471
  metadata.packageManifest,
423
472
  metadata.capabilities,
473
+ metadata.cargoVersion,
424
474
  metadata.changelog,
425
475
  );
426
476
  if (problems.length > 0) {
@@ -449,6 +499,7 @@ async function setVersion(version) {
449
499
  metadata.capabilities.version,
450
500
  version,
451
501
  ),
502
+ cargoWithReplacedVersion(metadata.packageManifest.version, version),
452
503
  ]);
453
504
  await writeVersionTransaction(updates);
454
505
  console.log(`Set ${expectedPackageName} release metadata to ${version}.`);
package/src/index.js CHANGED
@@ -2420,7 +2420,13 @@ function validateJsonTargetAddresses(operation, operationIndex) {
2420
2420
  for (const role of ['target', 'parent', 'source', 'container']) {
2421
2421
  const target = operation[role];
2422
2422
  if (!target) continue;
2423
- if (target.binding?.representationKind === 'attributeSpace' || String(target.canonicalAddress ?? '').includes('.@')) {
2423
+ // A quoted member can contain literal .@ text. Classify selectors in both
2424
+ // paths so contextual aliases still reveal canonical attribute ancestors.
2425
+ // Do not reimpose the portable index ceiling on an already planned path.
2426
+ const canonical = parseAddress(String(target.canonicalAddress ?? ''), { maxPositionIndex: Number.MAX_SAFE_INTEGER });
2427
+ const hasAttributeSelector = target.address?.selectors?.some((selector) => selector.type === 'attributeSpace')
2428
+ || (canonical.ok && canonical.address.selectors.some((selector) => selector.type === 'attributeSpace'));
2429
+ if (target.binding?.representationKind === 'attributeSpace' || hasAttributeSelector) {
2424
2430
  return {
2425
2431
  ok: false,
2426
2432
  error: mutationTargetSurfaceError(
@@ -4355,6 +4361,9 @@ function consumeFallbackOperand(value, namespace) {
4355
4361
  };
4356
4362
  }
4357
4363
  const scalar = getBindingScalarValue(namespace, value.bindings[0]);
4364
+ if (!scalar.ok && scalar.error.code === 'SANSA_QUERY_EVALUATE_MISSING_SCALAR') {
4365
+ return { ok: false, missing: true };
4366
+ }
4358
4367
  if (!scalar.ok) return scalar;
4359
4368
  return scalarQueryValue(scalar.value, scalar.metadata);
4360
4369
  }
@@ -6428,10 +6437,17 @@ function getBindingScalarInfo(namespace, binding) {
6428
6437
  const radixBase = getBindingRadixBase(namespace, binding);
6429
6438
  const radixScale = getBindingRadixScale(namespace, binding);
6430
6439
  if (typeof namespace.value === 'function') {
6431
- return { ok: true, value: namespace.value(binding), kind, semanticType, nullReason, numericLexeme, radixBase, radixScale };
6440
+ const value = namespace.value(binding);
6441
+ if (value !== undefined) {
6442
+ return { ok: true, value, kind, semanticType, nullReason, numericLexeme, radixBase, radixScale };
6443
+ }
6444
+ }
6445
+ if (Object.hasOwn(binding, 'value') && binding.value !== undefined) {
6446
+ return { ok: true, value: binding.value, kind, semanticType, nullReason, numericLexeme, radixBase, radixScale };
6447
+ }
6448
+ if (Object.hasOwn(binding, 'scalar') && binding.scalar !== undefined) {
6449
+ return { ok: true, value: binding.scalar, kind, semanticType, nullReason, numericLexeme, radixBase, radixScale };
6432
6450
  }
6433
- if (Object.hasOwn(binding, 'value')) return { ok: true, value: binding.value, kind, semanticType, nullReason, numericLexeme, radixBase, radixScale };
6434
- if (Object.hasOwn(binding, 'scalar')) return { ok: true, value: binding.scalar, kind, semanticType, nullReason, numericLexeme, radixBase, radixScale };
6435
6451
  return {
6436
6452
  ok: false,
6437
6453
  error: queryEvaluateError('SANSA_QUERY_EVALUATE_MISSING_SCALAR', 'Binding does not expose a scalar value'),