@altopelago/sansa 0.9.0 → 0.9.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 +117 -0
- package/README.md +107 -4
- package/conformance/README.md +19 -0
- package/conformance/cts-claims.json +53 -0
- package/docs/api-contract.md +536 -10
- package/docs/capabilities.json +172 -3
- package/docs/instruction-tool.md +345 -0
- package/docs/mutate-policy.md +148 -0
- package/docs/query-tool.md +123 -11
- package/docs/releasing.md +2 -2
- package/fixtures/query-inventory.aeon +65 -3
- package/fixtures/query-inventory.json +194 -3
- package/package.json +9 -2
- package/scripts/cts-instruction.mjs +284 -0
- package/scripts/cts-mutate.mjs +476 -0
- package/scripts/cts-resolve.mjs +9 -0
- package/scripts/instruction.mjs +423 -0
- package/scripts/query-web.mjs +56 -0
- package/scripts/query.mjs +34 -2
- package/scripts/validate-cts-claims.mjs +122 -0
- package/src/index.d.ts +811 -2
- package/src/index.js +5154 -381
- package/tools/mutate-web/app.js +370 -0
- package/tools/mutate-web/examples.mjs +1280 -0
- package/tools/mutate-web/index.html +138 -0
- package/tools/mutate-web/runtime.mjs +1308 -0
- package/tools/mutate-web/styles.css +354 -0
- package/tools/query-web/app.js +8 -1
- package/tools/query-web/examples.mjs +131 -5
- package/tools/query-web/index.html +10 -0
- package/tools/query-web/runtime.mjs +100 -9
- package/tools/query-web/styles.css +1 -1
package/docs/api-contract.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# SANSA Parser API Contract
|
|
2
2
|
|
|
3
|
-
Status: implementation contract for the address parser/model, resolver, query clause parser/model, query expression parser/model, bounded query evaluator, and standalone query tooling slices.
|
|
3
|
+
Status: implementation contract for the address parser/model, resolver, query clause parser/model, query expression parser/model, bounded query evaluator, experimental instruction parse/lower/plan bridge, experimental mutation-plan API, experimental workbench mutation-policy plan filter, and standalone query/instruction tooling slices.
|
|
4
4
|
|
|
5
|
-
The parser validates SANSA address syntax and returns a structural model. The resolver applies the parsed selector model to a host-supplied namespace adapter. The query parser validates the SANSA.Query clause and expression surfaces and returns structural models. The query evaluator applies a bounded query subset over host-exposed binding metadata. The
|
|
5
|
+
The parser validates SANSA address syntax and returns a structural model. The resolver applies the parsed selector model to a host-supplied namespace adapter. The query parser validates the SANSA.Query clause and expression surfaces and returns structural models. The query evaluator applies a bounded query subset over host-exposed binding metadata. The experimental instruction parser validates human-authored change intents and can lower them into structured mutation requests before handing them to the mutation planner. The experimental mutation planner constructs exact-target mutation plans, the target-surface validator checks post-plan representability, and apply runs only through host-supplied mutation hooks. Core SANSA.Mutate does not check authorization, provide transactions, decide schema legality, or assign semantics to qualifiers. The browser workbench includes a separate experimental mutation-policy plan filter for testing host-side authorization.
|
|
6
6
|
|
|
7
|
-
The implementation capability manifest is [capabilities.json](capabilities.json). It advertises `AEON.ValueSemantics`, `SANSA.Addressing`, `SANSA.Resolve`, `SANSA.Query`, Query budget controls, the experimental `validation` Query policy,
|
|
7
|
+
The implementation capability manifest is [capabilities.json](capabilities.json). It advertises `AEON.ValueSemantics`, `SANSA.Addressing`, `SANSA.Resolve`, `SANSA.Query`, Query budget controls, the experimental `validation` Query policy, experimental `SANSA.Transform` extensions, experimental `SANSA.Instruction` parsing/lowering/planning bridge behavior, an experimental `SANSA.Mutate` plan API, and the workbench-only experimental `sansa.mutate.policy.planFilter` slice.
|
|
8
8
|
|
|
9
9
|
CTS lanes:
|
|
10
10
|
|
|
@@ -13,9 +13,20 @@ npm run cts
|
|
|
13
13
|
npm run cts:value-semantics
|
|
14
14
|
npm run cts:query
|
|
15
15
|
npm run cts:query:experimental
|
|
16
|
+
npm run cts:mutate
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
The default Query CTS lane is core conformance and skips experimental extension cases. The experimental lane includes those cases for implementations that advertise matching extensions.
|
|
20
|
+
The Instruction and Mutate CTS lanes are experimental and are not included in
|
|
21
|
+
`npm run cts` while SANSA.Instruction and SANSA.Mutate remain proposal-stage.
|
|
22
|
+
The Mutate lane covers structured planning, apply, target-surface checks, and
|
|
23
|
+
the experimental policy plan-filter boundary.
|
|
24
|
+
Run them explicitly with:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm run cts:instruction
|
|
28
|
+
npm run cts:mutate
|
|
29
|
+
```
|
|
19
30
|
|
|
20
31
|
## Entry Points
|
|
21
32
|
|
|
@@ -26,9 +37,15 @@ parseQuery(input, options?)
|
|
|
26
37
|
parseQueryOrThrow(input, options?)
|
|
27
38
|
parseQueryExpression(input, options?)
|
|
28
39
|
parseQueryExpressionOrThrow(input, options?)
|
|
40
|
+
parseInstruction(input, options?)
|
|
41
|
+
parseInstructionOrThrow(input, options?)
|
|
42
|
+
lowerInstruction(input, namespaceOrOptions?, options?)
|
|
43
|
+
planInstruction(input, namespace, options?)
|
|
29
44
|
evaluateQuery(input, namespace, options?)
|
|
30
45
|
evaluateValueSemanticsOperation(operation, input)
|
|
31
46
|
resolveAddress(input, namespace, options?)
|
|
47
|
+
planMutation(input, namespace, options?)
|
|
48
|
+
applyMutationPlan(plan, namespace, options?)
|
|
32
49
|
renderAddress(address)
|
|
33
50
|
renderQuery(query)
|
|
34
51
|
renderQueryExpression(expression)
|
|
@@ -63,6 +80,111 @@ renderQualifierTerm(term)
|
|
|
63
80
|
|
|
64
81
|
`parseQueryExpressionOrThrow` returns `expression` or throws `SansaParseError`.
|
|
65
82
|
|
|
83
|
+
`parseInstruction` returns a structural `SansaInstruction` model:
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
{ ok: true, instruction }
|
|
87
|
+
{ ok: false, errors: [{ code, message, index }] }
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`parseInstructionOrThrow` returns `instruction` or throws `SansaParseError`.
|
|
91
|
+
Parsed instructions include `provenance.reason` for `because "..."` clauses
|
|
92
|
+
and `provenance.claimedAuthor` for `by "..."` clauses when present. These
|
|
93
|
+
fields are claimed source metadata only; they are not authorization,
|
|
94
|
+
authentication, signatures, or audit proof.
|
|
95
|
+
|
|
96
|
+
`lowerInstruction` accepts either an instruction string or parsed
|
|
97
|
+
`SansaInstruction`. Direct instructions lower without a namespace when their
|
|
98
|
+
targets are already absolute. Query-shaped instructions with `from` or `where`
|
|
99
|
+
require a host namespace so candidates can be resolved and candidate-relative
|
|
100
|
+
targets can become exact structured mutation requests. `require` clauses lower
|
|
101
|
+
to structured Mutate preconditions and are preserved for planning/apply recheck:
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
lowerInstruction(
|
|
105
|
+
"from $.inventory.items.*\nwhere .sku == \"B-200\"\nrequire .qty == 4\nreplace .qty with :int32, 10",
|
|
106
|
+
namespace
|
|
107
|
+
)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Successful lowering returns one requested mutation operation, an operation list,
|
|
111
|
+
or a request envelope when `require` preconditions are present:
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
{ ok: true, request, diagnostics, warnings, provenance }
|
|
115
|
+
{ ok: false, errors }
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For candidate-relative instructions, each surviving candidate receives its own
|
|
119
|
+
precondition target. `where` filters candidates; `require` creates fail-closed
|
|
120
|
+
mutation guards.
|
|
121
|
+
|
|
122
|
+
`lowerInstruction` returns parsed source provenance separately from the lowered
|
|
123
|
+
mutation request. It does not place `because` or `by` on operation provenance,
|
|
124
|
+
because those clauses describe the instruction source rather than individual
|
|
125
|
+
mutation operations.
|
|
126
|
+
|
|
127
|
+
Instruction `append <container> with <value>` and
|
|
128
|
+
`append in <container> with <value>` canonicalize and lower as
|
|
129
|
+
`insert last in <container> with <value>`. They produce an ordinary structured
|
|
130
|
+
`insert` request with `placement: "last"`.
|
|
131
|
+
|
|
132
|
+
Instruction values support scalar literal families, SANSA address literals,
|
|
133
|
+
reference forms, and a conservative container-literal slice:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
:object, { enabled = true }
|
|
137
|
+
:list<string>, ["adapter", "driver"]
|
|
138
|
+
:tuple, ("sku", 7)
|
|
139
|
+
:node, <badge("new", 3)>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Container literal members must recursively be instruction values. This keeps
|
|
143
|
+
Instruction values separate from arbitrary Query expressions.
|
|
144
|
+
Known datatype families in Instruction values are checked against the literal
|
|
145
|
+
representation family before lowering. For example, `:date, 2026-10-10` is
|
|
146
|
+
valid, while `:date, "2026-10-10"` is rejected as string representation with
|
|
147
|
+
date intent. Custom datatype expressions remain semantic intent over the chosen
|
|
148
|
+
literal family, such as `:brandColor, #ff00aa` or `:csv[","], "sku,name"`.
|
|
149
|
+
|
|
150
|
+
`planInstruction` preserves the same boundary, then calls `planMutation(...)`
|
|
151
|
+
with the lowered structured request:
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
planInstruction(
|
|
155
|
+
"from $.inventory.items.*\nwhere .sku == \"B-200\"\nreplace .qty with :int32, 10",
|
|
156
|
+
namespace
|
|
157
|
+
)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Failures keep their phase:
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
{ ok: false, phase: "lower", errors } // instruction lowering failed
|
|
164
|
+
{ ok: false, phase: "plan", loweredRequest, errors } // mutate planning failed
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The phase boundary is part of the contract:
|
|
168
|
+
|
|
169
|
+
| Phase | Boundary |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| `parse` | Instruction syntax and literal payload syntax. |
|
|
172
|
+
| `lower` | Candidate selection and candidate-relative address resolution into exact structured requests. |
|
|
173
|
+
| `plan` | SANSA.Mutate structural legality against the host namespace. |
|
|
174
|
+
| `policy` | Trusted consumer authorization of already-planned operations. |
|
|
175
|
+
| `target` | Target-surface representability of planned datatype/kind/value intent. |
|
|
176
|
+
| `apply` | Host adapter execution of an already-planned operation against current namespace state. |
|
|
177
|
+
|
|
178
|
+
This function is a convenience bridge. Target-surface validation,
|
|
179
|
+
authorization, schema checks, apply, transactions, and host-specific mutation
|
|
180
|
+
policy remain outside Instruction and inside the consumer or mutation adapter
|
|
181
|
+
boundary.
|
|
182
|
+
|
|
183
|
+
Successful `planInstruction` results preserve `because` and `by` on
|
|
184
|
+
`plan.sourceProvenance` alongside `{ type: "SansaInstruction", source }`.
|
|
185
|
+
Consumers may display these fields, but must treat them as claimed source
|
|
186
|
+
metadata rather than trusted actor identity.
|
|
187
|
+
|
|
66
188
|
`evaluateQuery` accepts either a query string or a parsed `SansaQuery` and returns:
|
|
67
189
|
|
|
68
190
|
```js
|
|
@@ -92,6 +214,44 @@ evaluateQuery(query, namespace, { policy: "validation" })
|
|
|
92
214
|
|
|
93
215
|
This policy rejects presentation and transform behavior before evaluation: `order by`, `offset`, `limit`, object projection expressions, and transform-library helpers. Rejections use `SANSA_QUERY_POLICY_VIOLATION` with `phase: "policy"`.
|
|
94
216
|
|
|
217
|
+
Dynamic Address values require an explicit activation policy. Trusted local
|
|
218
|
+
consumers may opt into unrestricted activation deliberately:
|
|
219
|
+
|
|
220
|
+
```js
|
|
221
|
+
evaluateQuery(query, namespace, { addressActivation: "trusted" })
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Consumers crossing a trust boundary should instead provide a constrained
|
|
225
|
+
policy over parsed address structure:
|
|
226
|
+
|
|
227
|
+
```js
|
|
228
|
+
evaluateQuery(query, namespace, {
|
|
229
|
+
addressActivation: {
|
|
230
|
+
allowedRoots: ["$.contacts"],
|
|
231
|
+
allowedSelectors: ["member", "position"],
|
|
232
|
+
allowContextualRoot: true,
|
|
233
|
+
maxAddressDepth: 4,
|
|
234
|
+
maxBindings: 1
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Supported selector capability names are `member`, `position`, `range`,
|
|
240
|
+
`wildcard`, `recursive`, `pattern`, `semanticFilter`,
|
|
241
|
+
`representationFilter`, `attribute`, `local`, and `parent`. Omitted
|
|
242
|
+
`allowedSelectors` defaults to `member` and `position`. `allowedRoots` must
|
|
243
|
+
contain unqualified exact absolute SANSA addresses. Constrained contextual
|
|
244
|
+
activation also requires `allowContextualRoot: true` and an exact canonical
|
|
245
|
+
address on the current binding so the effective target can be checked.
|
|
246
|
+
|
|
247
|
+
No activation policy produces `SANSA_QUERY_PATH_ACTIVATION_POLICY_REQUIRED`.
|
|
248
|
+
Invalid host policy produces `SANSA_QUERY_PATH_ACTIVATION_INVALID_POLICY`.
|
|
249
|
+
Root, selector, contextual-root, parent-containment, and address-depth denial
|
|
250
|
+
produce `SANSA_QUERY_PATH_ACTIVATION_DENIED`. Exceeding `maxBindings` produces
|
|
251
|
+
`SANSA_QUERY_PATH_ACTIVATION_BINDING_LIMIT_EXCEEDED` and no partial query
|
|
252
|
+
result. Reading the binding that stores an Address value never grants authority
|
|
253
|
+
to resolve that address.
|
|
254
|
+
|
|
95
255
|
Query evaluation budgets are optional and fail closed:
|
|
96
256
|
|
|
97
257
|
```js
|
|
@@ -125,9 +285,20 @@ evaluateValueSemanticsOperation("compare", {
|
|
|
125
285
|
evaluateValueSemanticsOperation("isValue", {
|
|
126
286
|
value: { category: "string", value: "active" }
|
|
127
287
|
})
|
|
288
|
+
|
|
289
|
+
evaluateValueSemanticsOperation("compare", {
|
|
290
|
+
left: { category: "string", value: "éclair" },
|
|
291
|
+
right: { category: "string", value: "zebre" }
|
|
292
|
+
}, {
|
|
293
|
+
valueSemantics: createFrenchValueSemanticsProfile()
|
|
294
|
+
})
|
|
128
295
|
```
|
|
129
296
|
|
|
130
|
-
The supported operations are `equal`, `notEqual`, `compare`, and `isValue`. The supported minimum-profile categories are `finiteNumber`, `positiveInfinity`, `negativeInfinity`, `nan`, `string`, `boolean`, `explicitNull`, `explicitAbsence`, `missing`, `container`, and `bindingSet`.
|
|
297
|
+
The supported operations are `equal`, `notEqual`, `compare`, and `isValue`. The supported minimum-profile categories are `finiteNumber`, `positiveInfinity`, `negativeInfinity`, `nan`, `string`, `boolean`, `toggle`, `hex`, `radix`, `encoding`, `separator`, `sansaAddress`, `referenceForm`, `temporal`, `lexicalStructuredScalar`, `explicitNull`, `explicitAbsence`, `missing`, `container`, and `bindingSet`.
|
|
298
|
+
|
|
299
|
+
The default exported profile, `aeonValueSemanticsDefaultProfile`, uses Unicode scalar-value string order and deterministic default Unicode case mapping. It does not perform natural numeric-region ordering: `part-10` sorts before `part-2` under the default profile. `createIntlValueSemanticsProfile(...)` creates an explicit Intl-backed string profile, `createFrenchValueSemanticsProfile(...)` is a convenience profile for French collation and case mapping, and `createNaturalAsciiValueSemanticsProfile(...)` is an exploratory deterministic numeric-region profile where `part-2` sorts before `part-10`. Query evaluation accepts the same profile surface through `evaluateQuery(..., { valueSemantics })`.
|
|
300
|
+
|
|
301
|
+
Custom profile objects must provide a complete string contract: `compareStrings`, `lowerString`, and `upperString` together. They may also provide `compareTemporal` for temporal comparison. Partial hook objects are rejected rather than merged with defaults, because mixed collation, normalization, and case-mapping rules would create an implicit profile that is not portable. The minimum profile does not apply custom string collation to `hex`, `radix`, `encoding`, `separator`, or `sansaAddress` as domain semantics; those families keep their deterministic payload or address-expression behavior unless a future explicit profile defines a richer domain.
|
|
131
302
|
|
|
132
303
|
`resolveAddress` accepts either an address string or a parsed `SansaAddress` and returns:
|
|
133
304
|
|
|
@@ -140,6 +311,20 @@ Parse errors are returned through the same `ok: false` shape. Normal no-match re
|
|
|
140
311
|
|
|
141
312
|
Resolve distinguishes a **resolution miss** from a **resolution failure**. A miss occurs when a valid, supported selector applies to the namespace but finds no exposed structure on one or more branches; that branch contributes no bindings. A failure occurs when resolution cannot safely or validly continue, such as an unsupported selector capability, missing contextual root, forbidden boundary escape, implementation limit failure, or exact-expression multiplicity violation.
|
|
142
313
|
|
|
314
|
+
Callers may bound intermediate and final Binding Set materialization with
|
|
315
|
+
`maxBindings`:
|
|
316
|
+
|
|
317
|
+
```js
|
|
318
|
+
resolveAddress('$.inventory.**', namespace, { maxBindings: 1000 })
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
The resolver stops when the first binding beyond the limit would be retained
|
|
322
|
+
and returns `SANSA_RESOLVE_BINDING_LIMIT_EXCEEDED` with an empty Binding Set,
|
|
323
|
+
`limit`, and `observed`. Invalid limits return
|
|
324
|
+
`SANSA_RESOLVE_INVALID_BINDING_LIMIT`. Query dynamic-address activation maps
|
|
325
|
+
this bounded failure to
|
|
326
|
+
`SANSA_QUERY_PATH_ACTIVATION_BINDING_LIMIT_EXCEEDED`.
|
|
327
|
+
|
|
143
328
|
Resolve invariants:
|
|
144
329
|
|
|
145
330
|
- Selectors are applied left to right.
|
|
@@ -153,6 +338,181 @@ Resolve invariants:
|
|
|
153
338
|
- An exact expression must not produce more than one binding; multiplicity violations fail with `SANSA_RESOLVE_EXACT_MULTIPLICITY_VIOLATION`.
|
|
154
339
|
- Resolve performs no value evaluation, predicate evaluation, projection, sorting, slicing, aggregation, or mutation.
|
|
155
340
|
|
|
341
|
+
## Experimental Mutate API
|
|
342
|
+
|
|
343
|
+
`planMutation` accepts a structured mutation request, a namespace adapter, and optional resolve options. It returns an immutable mutation plan or explicit planning diagnostics:
|
|
344
|
+
|
|
345
|
+
```js
|
|
346
|
+
planMutation({ op: "replace", target: "$.inventory.sku", value: "B-200" }, namespace)
|
|
347
|
+
|
|
348
|
+
planMutation([
|
|
349
|
+
{ op: "create", parent: "$.inventory", name: "status", value: "active" },
|
|
350
|
+
{ op: "remove", target: "$.inventory.oldStatus" }
|
|
351
|
+
], namespace)
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Supported operation requests are `create`, `replace`, `remove`, `insert`, and `move`.
|
|
355
|
+
|
|
356
|
+
Structured requests may include read-only preconditions:
|
|
357
|
+
|
|
358
|
+
```js
|
|
359
|
+
planMutation({
|
|
360
|
+
operations: [
|
|
361
|
+
{ op: "replace", target: "$.inventory.sku", value: "B-200" }
|
|
362
|
+
],
|
|
363
|
+
preconditions: [
|
|
364
|
+
{ expression: "$.inventory.sku == \"A-100\"" },
|
|
365
|
+
{ target: "$.inventory.sku", expression: ". == \"A-100\"" }
|
|
366
|
+
]
|
|
367
|
+
}, namespace)
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Preconditions use the SANSA.Query expression evaluator and must produce a Boolean value. A failed, invalid, or non-Boolean precondition prevents plan construction and produces no executable plan. Preconditions are evaluated during planning against the same host-exposed namespace state as target resolution.
|
|
371
|
+
|
|
372
|
+
Preserved preconditions are rechecked by default before apply invokes any mutation hook. This protects a plan from non-target state drift between planning and apply. Callers that rely on a stronger external transaction or namespace-state contract may pass `{ recheckPreconditions: false }` to `applyMutationPlan`.
|
|
373
|
+
|
|
374
|
+
Request envelopes support only `operations`, `preconditions`, and `provenance`.
|
|
375
|
+
Known operation requests support only their operation fields plus optional inert
|
|
376
|
+
`provenance`. Unsupported request or operation fields fail closed rather than
|
|
377
|
+
being ignored. Successful planning preserves request `provenance` as plan-level
|
|
378
|
+
`sourceProvenance` for audit and diagnostics. Individual requested operations
|
|
379
|
+
may also carry `provenance`, which is preserved on the planned operation.
|
|
380
|
+
Provenance is inert metadata; it is not interpreted as SANSA source,
|
|
381
|
+
authorization policy, validation policy, or mutation rewrite behavior.
|
|
382
|
+
|
|
383
|
+
`create`, `replace`, and `insert` requests may include optional `datatype` and `kind` strings. `datatype` preserves semantic type intent, such as `sansa`, `list<string>`, or a custom type like `brandColor`. `kind` preserves representation or literal-family intent, such as `hex`, `separator`, `object`, `list`, `tuple`, or `node`. The planner validates only that provided hints are non-empty strings and preserves them on the planned operation. It does not decide whether the value is legal for that datatype or kind; schema, host adapters, or higher-level profiles own semantic compatibility checks.
|
|
384
|
+
|
|
385
|
+
Structured Mutate requests intentionally preserve `datatype` and `kind`
|
|
386
|
+
separately until target-surface validation. This differs from SANSA
|
|
387
|
+
Instruction syntax, where known datatype/literal-family mismatches are rejected
|
|
388
|
+
during instruction parsing because the author has supplied a single literal
|
|
389
|
+
form. A structured request may carry `datatype: "brandColor", kind: "hex"` as
|
|
390
|
+
valid custom intent; an AEON target surface may reject `datatype: "number",
|
|
391
|
+
kind: "string"` because both families are known and incompatible for AEON
|
|
392
|
+
materialization.
|
|
393
|
+
|
|
394
|
+
The workbench AEON adapter uses these hints when rendering Source Result output. If `kind` is present, it chooses the representation. Otherwise the adapter infers representation from known `datatype` values, then from the JSON value shape:
|
|
395
|
+
|
|
396
|
+
```js
|
|
397
|
+
planMutation({
|
|
398
|
+
op: "create",
|
|
399
|
+
parent: "$.types",
|
|
400
|
+
name: "brand",
|
|
401
|
+
datatype: "brandColor",
|
|
402
|
+
kind: "hex",
|
|
403
|
+
value: "ff00aa"
|
|
404
|
+
}, namespace)
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
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.
|
|
408
|
+
|
|
409
|
+
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.
|
|
410
|
+
|
|
411
|
+
For scalar values, the workbench adapter treats `kind` as the AEON literal family when one is provided. Known scalar families include `string`, `number`, `boolean`, `toggle`, `hex`, `radix`, `encoding`, `separator`/`sep`, `sansa`, `date`, `time`, `datetime`, `zrut`, `null`, `nan`, `infinity`, `cloneReference`, and `pointerReference`. JSON payloads omit AEON sigils: `kind: "hex"` with `"ff00aa"` renders `#ff00aa`; `kind: "sep"` with `"0.11.0"` renders `^0.11.0`; `kind: "null"` with `"notApplicable"` renders `!notApplicable`; and `kind: "cloneReference"` with `"target"` renders `~target`. The adapter rejects payloads that cannot be rendered as the requested known AEON literal family. Unknown custom `kind` values remain adapter-visible metadata and are not interpreted by the core planner.
|
|
412
|
+
|
|
413
|
+
Experimental Mutate budgets are optional and fail closed:
|
|
414
|
+
|
|
415
|
+
```js
|
|
416
|
+
planMutation(request, namespace, {
|
|
417
|
+
budget: {
|
|
418
|
+
maxOperations: 100,
|
|
419
|
+
maxPreconditions: 20,
|
|
420
|
+
maxValueNodes: 1000,
|
|
421
|
+
maxValueDepth: 32,
|
|
422
|
+
maxStringLength: 65536
|
|
423
|
+
}
|
|
424
|
+
})
|
|
425
|
+
|
|
426
|
+
applyMutationPlan(plan, namespace, {
|
|
427
|
+
budget: {
|
|
428
|
+
maxOperations: 100,
|
|
429
|
+
maxPreconditions: 20,
|
|
430
|
+
maxValueNodes: 1000,
|
|
431
|
+
maxValueDepth: 32,
|
|
432
|
+
maxStringLength: 65536
|
|
433
|
+
}
|
|
434
|
+
})
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
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.
|
|
438
|
+
|
|
439
|
+
`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.
|
|
440
|
+
|
|
441
|
+
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.
|
|
442
|
+
|
|
443
|
+
`applyMutationPlan` applies an already planned mutation only when the namespace exposes matching mutation hooks:
|
|
444
|
+
|
|
445
|
+
```js
|
|
446
|
+
const result = applyMutationPlan(plan, namespace, { requireAtomic: true })
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
Mutation hooks may live under `namespace.mutate`:
|
|
450
|
+
|
|
451
|
+
```js
|
|
452
|
+
{
|
|
453
|
+
root,
|
|
454
|
+
children(binding),
|
|
455
|
+
parent(binding),
|
|
456
|
+
bindingHandle?(binding),
|
|
457
|
+
observedState?(binding),
|
|
458
|
+
mutate: {
|
|
459
|
+
supportsCreate: true,
|
|
460
|
+
supportsReplace: true,
|
|
461
|
+
supportsRemove: true,
|
|
462
|
+
supportsOrderedInsert: true,
|
|
463
|
+
supportsMove: true,
|
|
464
|
+
supportsStableBindingIdentity: true,
|
|
465
|
+
supportsAtomicApply: true,
|
|
466
|
+
sameBinding?(left, right),
|
|
467
|
+
create(parent, name, value, operation),
|
|
468
|
+
replace(target, value, operation),
|
|
469
|
+
remove(target, operation),
|
|
470
|
+
insert(container, placement, value, operation),
|
|
471
|
+
move(source, container, placement, operation)
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
When an operation capability flag is omitted, this implementation infers support from the corresponding mutation hook. When an operation capability flag is explicitly `false`, apply rejects that operation before invoking hooks. `supportsAtomicApply` is only required when callers pass `{ requireAtomic: true }`.
|
|
477
|
+
|
|
478
|
+
Mutation hooks receive the planned operation as their final argument. Adapters that need to materialize host-specific values should read preserved fields such as `datatype`, `kind`, and `provenance` from that operation rather than inferring intent from the raw JSON value alone.
|
|
479
|
+
|
|
480
|
+
The conservative planner rejects structurally incompatible mutation targets before invoking adapter hooks. `create` requires a parent binding whose exposed representation or semantic type is a container. `insert` and `move` require an ordered container (`list`, `tuple`, or `node`). Scalar bindings are not treated as mutation containers merely because a resolver exposes an empty child list for uniform traversal.
|
|
481
|
+
|
|
482
|
+
Attributes are created by targeting the owner's attribute space as the create parent. For example, creating `status` under `$.types.color.@` produces the attribute path `$.types.color.@.status` and renders in AEON as an inline attribute on `color`. Attribute-space parents are valid create containers, but they are not ordered containers for `insert` or `move`.
|
|
483
|
+
|
|
484
|
+
The workbench AEON adapter materializes JSON values according to container `kind` or known container `datatype` hints. JSON objects create object bindings, JSON arrays create list bindings by default, `kind: "tuple"` or `datatype: "tuple"` renders an array as a tuple, and `kind: "node"` or `datatype: "node"` accepts a node payload with a tag and ordered children:
|
|
485
|
+
|
|
486
|
+
```json
|
|
487
|
+
{
|
|
488
|
+
"op": "create",
|
|
489
|
+
"parent": "$.types",
|
|
490
|
+
"name": "badge",
|
|
491
|
+
"datatype": "node",
|
|
492
|
+
"value": {
|
|
493
|
+
"tag": "badge",
|
|
494
|
+
"children": ["new", 3]
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
Because Source Result output is AEON, the workbench adapter rejects JSON payloads that cannot be rendered as legal AEON. For example, object member names and node attribute names must not be empty; malformed node payloads also fail before any mutation is applied.
|
|
500
|
+
|
|
501
|
+
The planner retains the in-process binding object, canonical address, optional `bindingHandle`, and optional `observedState`. `binding`, `bindingHandle`, and `observedState` are local namespace-adapter artifacts; they are not SANSA wire-format fields. Before apply, the implementation resolves each exact address again and rejects stale targets if the resolved binding no longer matches the planned binding identity. This protects positional addresses such as `$.items[2]` from silent index drift. Ordered `insert` and `move` anchors are checked with the same stale-target rule before their hooks run.
|
|
502
|
+
|
|
503
|
+
Successful apply returns one result record per applied operation. Result records expose stable mutation-intent addresses such as `targetAddress`, `parentAddress`, `containerAddress`, `sourceAddress`, and `anchorAddress` when those roles exist. They also expose `previousAddress`, `affectedAddress`, and `resultingAddress` where known. `remove` reports the removed binding as affected, but does not invent a `resultingAddress` unless the adapter explicitly supplies one.
|
|
504
|
+
|
|
505
|
+
If a mutation hook rejects or throws during consumer-selected non-atomic apply, the result is `ok: false` with `SANSA_MUTATE_APPLY_FAILED`. `operationResults` may contain records for hooks that already completed before the failure. This must not be interpreted as full plan success; rollback, transactionality, retries, and compensation remain adapter or consumer responsibilities.
|
|
506
|
+
|
|
507
|
+
The Mutate Workbench JSON response includes a compact `affectedBinding` summary for each applied operation. For AEON-backed bindings this summary preserves `semanticType`, `representationKind`, `scalarKind`, `nullReason`, `nodeTag`, and a JSON-safe `value` where available, so tools can inspect applied literal-family metadata without parsing the rendered Source Result text.
|
|
508
|
+
|
|
509
|
+
This API does not authorize operations, validate proposed values against
|
|
510
|
+
schemas, follow references implicitly, or provide storage transactions.
|
|
511
|
+
Externally selected AEOS schemas or domain validators may check proposed-state
|
|
512
|
+
legality; authorization remains with the consumer, ASP, application, or adapter
|
|
513
|
+
boundary. See [mutate-policy.md](mutate-policy.md) for the separate workbench
|
|
514
|
+
policy prototype that exercises this boundary.
|
|
515
|
+
|
|
156
516
|
Parent traversal defaults to the conservative structural model: traversal from the effective resolution root resolves to an empty Binding Set. The effective resolution root is the root binding established by `$`, `?`, or the root of a dynamic resolution context for the current branch. Callers that need stricter boundary diagnostics can pass:
|
|
157
517
|
|
|
158
518
|
```js
|
|
@@ -232,7 +592,117 @@ The package also includes a browser workbench:
|
|
|
232
592
|
npm run query:web
|
|
233
593
|
```
|
|
234
594
|
|
|
235
|
-
The workbench serves [tools/query-web](../tools/query-web)
|
|
595
|
+
The workbench server serves [tools/query-web](../tools/query-web) and [tools/mutate-web](../tools/mutate-web). The Query Workbench defaults to `.aeon` source input and exposes a local `/api/query` endpoint. For `.aeon` source, the endpoint uses the optional AEON TypeScript core compiler to derive a host-neutral SANSA resolver namespace before running SANSA.Query. A params editor mounts a small AEON source snippet as `$.<"params">`; top-level params bindings become children of that local address space. JSON fixture mode remains available for direct resolver-shape debugging. The browser UI includes a Normal/Validation policy toggle, a Transform extension toggle, and evaluation budget inputs. `/api/query` accepts `policy: "validation"`, `transformExtensions: false`, and `budget` for evaluate requests.
|
|
596
|
+
|
|
597
|
+
The experimental Mutate Workbench exposes `/api/mutate`. It accepts `.aeon`
|
|
598
|
+
source, plan/apply mode, operation/precondition/value mutation budgets, parse
|
|
599
|
+
position-limit input, apply options such as `requireAtomic` and
|
|
600
|
+
`recheckPreconditions`, an optional experimental mutation policy plan filter, and one
|
|
601
|
+
of two request input forms:
|
|
602
|
+
|
|
603
|
+
- `requestKind: "structured"` with a structured JSON mutation request, which
|
|
604
|
+
runs `planMutation(...)` directly.
|
|
605
|
+
- `requestKind: "instruction"` with proposal-stage SANSA Instruction source,
|
|
606
|
+
which runs `planInstruction(...)` and then uses the returned plan for the
|
|
607
|
+
same preview/apply path.
|
|
608
|
+
|
|
609
|
+
The endpoint compiles the AEON source into a fresh host-neutral namespace for
|
|
610
|
+
each request, layers an in-memory mutation adapter over that namespace, and
|
|
611
|
+
returns the structured plan/result plus an AEON-ish rendered source tree after
|
|
612
|
+
apply. It is a technical testing surface for structured mutation requests and
|
|
613
|
+
proposal-stage instructions, not a canonical AEON source rewriter.
|
|
614
|
+
|
|
615
|
+
When the experimental mutation policy plan filter is enabled, policy JSON is trusted
|
|
616
|
+
consumer input and is validated before authorization. Unsupported top-level or
|
|
617
|
+
rule fields fail with `SANSA_MUTATE_POLICY_INVALID` instead of being ignored, so
|
|
618
|
+
claimed provenance such as Instruction `by` metadata cannot accidentally become
|
|
619
|
+
policy authority.
|
|
620
|
+
|
|
621
|
+
Target representability is checked explicitly with
|
|
622
|
+
`validateMutationPlanTarget(plan, targetSurface)`. This API is separate from
|
|
623
|
+
`planMutation(...)` so mutation planning remains target-neutral:
|
|
624
|
+
|
|
625
|
+
```text
|
|
626
|
+
planMutation(...)
|
|
627
|
+
validateMutationPlanTarget(...)
|
|
628
|
+
applyMutationPlan(...)
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
Built-in target surfaces currently include `"aeon"` and `"json"`.
|
|
632
|
+
`"json-compatible"` is accepted as an alias for `"json"`. Callers may also pass
|
|
633
|
+
a custom target surface object with an `id` and `validateOperation(operation,
|
|
634
|
+
context)` hook. Target-surface failures are not SANSA parse or
|
|
635
|
+
mutation-planning failures: they mean the target format cannot represent the
|
|
636
|
+
planned operation. They use `phase: "target"` with codes such as
|
|
637
|
+
`SANSA_MUTATE_TARGET_UNSUPPORTED_DATATYPE`,
|
|
638
|
+
`SANSA_MUTATE_TARGET_UNSUPPORTED_FEATURE`,
|
|
639
|
+
`SANSA_MUTATE_TARGET_UNSUPPORTED_VALUE`, and
|
|
640
|
+
`SANSA_MUTATE_TARGET_UNSUPPORTED_OPERATION`.
|
|
641
|
+
Target-surface diagnostics should preserve `targetFormat` when known. Datatype
|
|
642
|
+
failures include `datatype`; value representability failures may include
|
|
643
|
+
`valuePath` to identify the rejected planned value position.
|
|
644
|
+
|
|
645
|
+
The Mutate Workbench uses this same API. Its `options.targetFormat` defaults to
|
|
646
|
+
`"aeon"` and can be set to `"json"` through the browser target selector or the
|
|
647
|
+
`/api/mutate` request payload.
|
|
648
|
+
|
|
649
|
+
The `/api/mutate` response includes a `targetProfile` object in JSON mode:
|
|
650
|
+
|
|
651
|
+
```json
|
|
652
|
+
{
|
|
653
|
+
"id": "aeon",
|
|
654
|
+
"boundary": "representability",
|
|
655
|
+
"summary": "AEON target surface: accepts AEON-representable datatype, kind, and value intent before apply."
|
|
656
|
+
}
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
`targetProfile.id` is the normalized target surface used for validation, so
|
|
660
|
+
aliases such as `"json-compatible"` report `"json"`. `boundary:
|
|
661
|
+
"representability"` means the selected target surface is checking whether a
|
|
662
|
+
planned operation can be carried by that target format; it is not schema
|
|
663
|
+
approval, authorization, or mutation planning. Target-surface diagnostic text
|
|
664
|
+
therefore begins with a phase summary such as `target-surface: plan produced;
|
|
665
|
+
selected target cannot represent the planned intent for target 'aeon'`. Plan
|
|
666
|
+
failures use a different summary, such as `plan: mutation request could not be
|
|
667
|
+
planned`, so technical tests can distinguish invalid mutation intent from valid
|
|
668
|
+
intent rejected by the selected target surface.
|
|
669
|
+
|
|
670
|
+
For example, SANSA Instruction can parse and lower `:string<null>` as datatype
|
|
671
|
+
intent, but the AEON workbench target rejects it because AEON only allows
|
|
672
|
+
generic parameters on specific datatype families:
|
|
673
|
+
|
|
674
|
+
```text
|
|
675
|
+
create $.types.textProbe with :string<null>, ""
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
Structured requests reach the same target-surface boundary with separate
|
|
679
|
+
fields. Custom semantic intent such as `datatype: "brandColor", kind: "hex",
|
|
680
|
+
value: "ff00aa"` remains representable for an AEON target, while a known-family
|
|
681
|
+
contradiction such as `datatype: "number", kind: "string", value: "42"` is
|
|
682
|
+
reported as target-surface value representability failure rather than as a
|
|
683
|
+
planning failure.
|
|
684
|
+
|
|
685
|
+
JSON target mode accepts ordinary JSON-compatible object/list/string/number/
|
|
686
|
+
boolean/null values, but rejects AEON-only representational features such as
|
|
687
|
+
attribute-space mutations, `sansa` datatype hints, parameterized datatypes,
|
|
688
|
+
tuples, nodes, references, NaN, and Infinity.
|
|
689
|
+
|
|
690
|
+
When the workbench policy toggle is enabled, the endpoint accepts
|
|
691
|
+
`options.policySource` containing a JSON policy document. The endpoint plans
|
|
692
|
+
first, checks the planned operations against the policy, and only applies the
|
|
693
|
+
plan when every operation is authorized. The current workbench policy fields
|
|
694
|
+
are `operation` / `operations`, `target`, `parent`, `container`, `source`,
|
|
695
|
+
`anchor`, `name` / `names`, `datatype` / `datatypes`, `kind` / `kinds`, and
|
|
696
|
+
`value` / `values`. Address-role fields are SANSA address expressions resolved
|
|
697
|
+
against the same namespace view as the plan; `anchor` matches only resolved
|
|
698
|
+
`before` / `after` placement anchors, not `first` or `last` placements.
|
|
699
|
+
Policy diagnostics use
|
|
700
|
+
`phase: "policy"` and workbench-specific codes such as
|
|
701
|
+
`SANSA_MUTATE_POLICY_DENIED`. Policy diagnostics may include
|
|
702
|
+
`operationIndex`, `ruleIndex`, `policyField`, `policyScope`, and
|
|
703
|
+
`policyAddress` so workbench clients can highlight the failed operation, rule,
|
|
704
|
+
field, matcher scope, or unsupported matcher address. This remains outside the
|
|
705
|
+
core planner.
|
|
236
706
|
|
|
237
707
|
Workbench responses include `text` for successful results and diagnostics. Successful parse and evaluate responses also include `inspect`, a scan-friendly diagnostic view for the browser workbench. Text mode is intended for compact inspection, Inspect mode shows candidate/value metadata, and JSON mode exposes the structured result or diagnostic payload.
|
|
238
708
|
|
|
@@ -463,7 +933,7 @@ Currently evaluated:
|
|
|
463
933
|
- `select` expressions
|
|
464
934
|
- scalar literals
|
|
465
935
|
- resolution expressions
|
|
466
|
-
- comparisons between same-type scalar values
|
|
936
|
+
- comparisons between same-type scalar values and same-kind structural containers
|
|
467
937
|
- membership over Binding Sets with `in`
|
|
468
938
|
- Boolean `not`, `and`, `or`
|
|
469
939
|
- existence predicates over resolution expressions: `exists`, `absent`
|
|
@@ -472,6 +942,7 @@ Currently evaluated:
|
|
|
472
942
|
- dynamic address activation in expression positions with `path`
|
|
473
943
|
- missing-aware fallback with `fallback`
|
|
474
944
|
- dynamic direct-child resolution over addressable containers with `resolveChild`
|
|
945
|
+
- explicit read-only reference following with `follow`
|
|
475
946
|
- experimental transform-library object construction with `objectFrom`
|
|
476
947
|
- experimental transform-library field projection with `fieldsFrom`
|
|
477
948
|
- built-in value predicates: `isValue`, `isNull`, `isNullReason`, `isNaN`, `isInfinity`
|
|
@@ -487,6 +958,12 @@ where "admin" in .roles.*
|
|
|
487
958
|
|
|
488
959
|
The left operand is consumed in scalar context. Right-side bindings are evaluated in Binding Set order. Each right-side binding is consumed as a scalar and compared using equality comparison rules. Membership returns true on the first successful match and does not evaluate later bindings. Empty Binding Sets and fully evaluated non-matching sets evaluate to false. Membership does not skip incompatible bindings before a match: explicit null, NaN, missing scalar, cardinality, and mixed-type comparison failures surface as diagnostics. The right operand must evaluate to a Binding Set; string containment remains the `contains(...)` function.
|
|
489
960
|
|
|
961
|
+
Equality and inequality comparison may also consume one resolved container binding on each side. Containers compare structurally only when both sides expose the same normalized container kind (`object`, `list`, `tuple`, or `node`). Lists and tuples compare by child order; objects compare by member names and member values. Nodes compare by exposed tag, exposed attributes, and child order. Containers are not orderable by the minimum profile, and membership remains scalar-only.
|
|
962
|
+
|
|
963
|
+
Container datatype labels remain visible to semantic filters. This includes `#object`, object aliases such as `#obj`, `#o`, and `#envelope`, generic bases such as `#list` for `list<T>`, plus `#tuple` and `#node`. These filters select bindings only; they do not normalize aliases for equality, change structural comparison, or introduce container ordering.
|
|
964
|
+
|
|
965
|
+
Container representation filters such as `%object`, `%list`, `%tuple`, and `%node` select by exposed shape instead of datatype claim. For example, `%object` can select both `obj` and `envelope` bindings when both expose object representation.
|
|
966
|
+
|
|
490
967
|
Existence predicates inspect binding presence rather than scalar value:
|
|
491
968
|
|
|
492
969
|
```text
|
|
@@ -506,32 +983,57 @@ Missing bindings, explicit null values, and special numeric values are distinct:
|
|
|
506
983
|
|
|
507
984
|
```text
|
|
508
985
|
absent(.status) == true when .status resolves zero bindings
|
|
509
|
-
isValue(.status) == true when .status resolves one
|
|
986
|
+
isValue(.status) == true when .status resolves one concrete value binding
|
|
510
987
|
isNull(.status) == true when .status resolves one explicit null binding
|
|
511
988
|
isNullReason(.status, "notSet") == true when the null reason matches
|
|
512
989
|
isNaN(.metric) == true when the scalar is explicit NaN
|
|
513
990
|
isInfinity(.limit) == true when the scalar is positive or negative infinity
|
|
514
991
|
```
|
|
515
992
|
|
|
516
|
-
`isValue(...)` is a missing-aware
|
|
993
|
+
`isValue(...)` is a missing-aware concrete-value guard. It returns true when its operand evaluates to one concrete value, including finite numbers, infinities, strings, Booleans, toggles, lexical structured scalars, SANSA address literals, legal reference forms, and containers. It may inspect scalar expressions directly or consume a Binding Set produced by resolution or `path(...)`. It returns false for zero bindings, explicit null, explicit absence values, and NaN. More than one binding remains a cardinality error.
|
|
517
994
|
|
|
518
995
|
`isNull(...)`, `isNullReason(...)`, `isNaN(...)`, and `isInfinity(...)` consume their first operand in single-binding scalar context. A missing operand therefore fails unless the query guards it with `exists(...)` or another missing-aware operator.
|
|
519
996
|
|
|
520
997
|
`NaN` is not comparable. Scalar comparison and ordering over `NaN` fail with `SANSA_QUERY_EVALUATE_INVALID_COMPARISON`; use `isNaN(...)` for explicit tests. Infinity values remain numeric bounds and may participate in same-type numeric comparisons and ordering.
|
|
521
998
|
|
|
999
|
+
Query source can express selected AEON scalar literal families directly:
|
|
1000
|
+
`#ff00aa`, `%ff00aa`, `&QmFzZTY0IQ==`, `^0.11.0`, `!notSet`, and
|
|
1001
|
+
temporal-looking literals such as `2026-07-25`, `09:30:00Z`,
|
|
1002
|
+
`2026-07-25T09:30:00Z`, and `2026-07-25T09:30:00Z&Australia/Melbourne`. These
|
|
1003
|
+
literals preserve their family metadata for comparison. Same-family temporal
|
|
1004
|
+
literals compare through the active temporal profile; the default profile uses
|
|
1005
|
+
canonical payload order.
|
|
1006
|
+
Explicit null literals are tested through null predicates rather than equality.
|
|
1007
|
+
|
|
522
1008
|
Current comparison policy:
|
|
523
1009
|
|
|
524
1010
|
| Operands | Equality | Ordering | Result |
|
|
525
1011
|
| --- | --- | --- | --- |
|
|
526
1012
|
| number and number | allowed | allowed | numeric comparison |
|
|
1013
|
+
| numeric subtype and numeric subtype | allowed | allowed | `int`, `uint`, and `float` datatype labels remain visible to semantic filters; comparison uses finite numeric values once exposed by the host |
|
|
1014
|
+
| datatype aliases and their literal family | follows family | follows family | aliases remain visible to semantic filters: `n` as number, `bool` as Boolean, `trimtick`/`prose` as string, `radix2`/`radix6`/`radix8`/`radix12` as radix, `base64`/`embed`/`inline` as encoding, `kadot` as separator, and `obj`/`o`/`envelope` as object containers |
|
|
527
1015
|
| string and string | allowed | allowed | Unicode scalar-value ordering |
|
|
528
1016
|
| boolean and boolean | allowed | error | ordering emits `SANSA_QUERY_EVALUATE_INVALID_COMPARISON` |
|
|
1017
|
+
| toggle and toggle | allowed | error | exact token equality; `yes` does not equal `on` |
|
|
1018
|
+
| toggle and boolean | error | error | no implicit Boolean coercion |
|
|
1019
|
+
| hex and hex | allowed | error | canonical payload identity only |
|
|
1020
|
+
| radix and radix | allowed | error | preserved payload and radix-family metadata identity only |
|
|
1021
|
+
| hex and radix | error | error | no implicit numeric or base-16 coercion |
|
|
1022
|
+
| encoding and encoding | allowed | allowed | naïve payload order over preserved encoded payload characters |
|
|
1023
|
+
| separator and separator | allowed | allowed | naïve whole-payload order; no splitting on separator specs |
|
|
1024
|
+
| SANSA address and SANSA address | allowed | allowed | canonical address-expression identity and naïve address-expression order |
|
|
1025
|
+
| temporal and temporal | allowed within same family | allowed within same family | default profile uses canonical temporal payload order; cross-family comparison fails without explicit compatibility |
|
|
1026
|
+
| reference form and reference form | allowed | error | reference-kind and canonical target-path identity; no implicit follow |
|
|
529
1027
|
| explicit null | error | error | use `isNull(...)` / `isNullReason(...)` |
|
|
530
1028
|
| NaN | error | error | use `isNaN(...)` |
|
|
531
1029
|
| infinity and number | allowed | allowed | numeric bound comparison |
|
|
532
1030
|
| mixed types | error | error | no implicit coercion |
|
|
533
1031
|
|
|
534
|
-
|
|
1032
|
+
Semantic filters match the base datatype label of generic claims. For example,
|
|
1033
|
+
`#null`, `#nan`, and `#infinity` match host bindings annotated as `null<T>`,
|
|
1034
|
+
`nan<T>`, and `infinity<T>` before value predicates inspect the scalar.
|
|
1035
|
+
|
|
1036
|
+
By default, this implementation slice compares strings by Unicode scalar value. It must not use natural sorting, host locale, process locale, database collation, or `localeCompare`-style host defaults unless the caller explicitly supplies a value-semantics profile such as `createNaturalAsciiValueSemanticsProfile()` or `createFrenchValueSemanticsProfile()`.
|
|
535
1037
|
|
|
536
1038
|
Ordinary value-producing functions evaluate their arguments before invocation. Resolution-expression arguments are consumed in single-binding scalar context:
|
|
537
1039
|
|
|
@@ -545,10 +1047,34 @@ The current built-in string functions are `contains`, `startsWith`, `endsWith`,
|
|
|
545
1047
|
|
|
546
1048
|
`path(value)` is a function-like structural operator. Its operand is consumed in scalar context and must be a structured SANSA Address Literal value. The initial representation is an object such as `{ type: "SansaAddressLiteral", address: "?.sku" }` or `{ type: "SansaAddressLiteral", address: parsedAddress }`. Plain strings are rejected and are not parsed as address syntax. In expression positions such as `select`, `where`, and `order by`, the activated address resolves in the current candidate context and returns a Binding Set. In `from path(...)`, the activated address supplies the source Binding Set for the query.
|
|
547
1049
|
|
|
1050
|
+
Activation is checked after the operand becomes a structured Address value and
|
|
1051
|
+
before that address is resolved. Structural root checks do not use string
|
|
1052
|
+
prefixes. Parent traversal is normalized for containment and fails closed when
|
|
1053
|
+
its reach cannot be proven. The standalone CLI and browser workbench explicitly
|
|
1054
|
+
use trusted activation because they operate as local technical test tools over
|
|
1055
|
+
fixtures selected by the user; embedding applications must choose their own
|
|
1056
|
+
trusted or constrained policy.
|
|
1057
|
+
|
|
1058
|
+
SANSA Address Literal values remain selectable as values with `#sansa` and
|
|
1059
|
+
`%sansa`. Those filters select the literal binding itself and do not activate
|
|
1060
|
+
the address; activation is always explicit through `path(...)`.
|
|
1061
|
+
|
|
548
1062
|
`fallback(primary, replacement)` is a function-like operator with lazy missing handling. The primary operand is consumed in scalar value context. If it resolves zero bindings, or raises a missing-scalar diagnostic, the replacement operand is evaluated and consumed in the same scalar value context. If the primary operand succeeds, the replacement operand is not evaluated. Explicit null values, cardinality errors, type errors, comparison errors, and unsupported-function errors do not trigger fallback.
|
|
549
1063
|
|
|
550
1064
|
`resolveChild(base, key)` is a function-like structural operator with a distinct argument contract. The base argument must be a resolution expression resolving exactly one addressable container. The key argument is consumed in scalar context; string keys select a direct member of the base, and non-negative integer keys select a direct positional child. A missing target returns an empty Binding Set. Multiple base bindings, multiple key bindings, unsupported key types, and multiple target bindings fail with diagnostics. It does not parse traversal strings, scan collections, or perform join semantics.
|
|
551
1065
|
|
|
1066
|
+
`follow(reference)` is a function-like read-only reference operator. Its operand
|
|
1067
|
+
must evaluate to one AEON reference form. The function resolves the reference's
|
|
1068
|
+
canonical exact target path and returns that target Binding Set. Without
|
|
1069
|
+
`follow(...)`, references compare as reference forms by reference kind and
|
|
1070
|
+
canonical target path; with `follow(...)`, the target binding is consumed by the
|
|
1071
|
+
ordinary scalar, structural, or order context. `follow(...)` does not rewrite,
|
|
1072
|
+
inline, clone, alias, or erase the source reference.
|
|
1073
|
+
|
|
1074
|
+
Concrete reference forms remain visible to representation filters such as
|
|
1075
|
+
`%cloneReference` and `%pointerReference`. These filters select the reference
|
|
1076
|
+
binding itself and do not imply `follow(...)` or materialization.
|
|
1077
|
+
|
|
552
1078
|
`objectFrom(keys, values)` is an experimental transform-library helper with a distinct argument contract. Both arguments must be resolution expressions. The key and value Binding Sets must have equal length. Key bindings must expose unique string scalar values. Value bindings must expose scalar values. The helper pairs keys and values by resolved order and returns one derived object. Mismatched lengths, duplicate keys, non-string keys, and non-scalar values fail with diagnostics. It is not part of the required SANSA.Query v1 core surface.
|
|
553
1079
|
|
|
554
1080
|
`fieldsFrom(keys, values, field, ...)` is an experimental transform-library helper. It uses the same ordered pairing model as `objectFrom`, then returns only the requested string-named fields. It is implemented for workbench and conformance experimentation, but is not part of the required SANSA.Query v1 core surface.
|
|
@@ -582,7 +1108,7 @@ order by path($.<"params">.sortField) asc
|
|
|
582
1108
|
select path($.<"params">.field)
|
|
583
1109
|
```
|
|
584
1110
|
|
|
585
|
-
`isValue(...)`, `exists(...)`, and explicit null predicates can distinguish
|
|
1111
|
+
`isValue(...)`, `exists(...)`, and explicit null predicates can distinguish concrete values, explicit nulls, and missing bindings:
|
|
586
1112
|
|
|
587
1113
|
```text
|
|
588
1114
|
from $.inventory.items.*
|