@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/capabilities.json
CHANGED
|
@@ -1,26 +1,160 @@
|
|
|
1
1
|
{
|
|
2
2
|
"implementation": "@altopelago/sansa",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"profiles": [
|
|
5
5
|
"value-semantics-minimum-consumer",
|
|
6
|
+
"aeon.value.default.v1",
|
|
7
|
+
"aeon.value.string.codepoint.v1",
|
|
8
|
+
"aeon.value.string.natural.ascii.v1",
|
|
9
|
+
"aeon.value.string.locale.fr.v1",
|
|
6
10
|
"addressing",
|
|
7
11
|
"resolve",
|
|
8
|
-
"query"
|
|
12
|
+
"query",
|
|
13
|
+
"instruction"
|
|
9
14
|
],
|
|
10
15
|
"capabilities": [
|
|
11
16
|
"AEON.ValueSemantics",
|
|
12
17
|
"SANSA.Addressing",
|
|
13
18
|
"SANSA.Resolve",
|
|
14
19
|
"SANSA.Query",
|
|
20
|
+
"SANSA.Instruction",
|
|
21
|
+
"SANSA.Mutate",
|
|
15
22
|
"SANSA.Transform"
|
|
16
23
|
],
|
|
17
24
|
"core": {
|
|
18
25
|
"valueSemanticsMinimumConsumer": true,
|
|
19
26
|
"addressing": true,
|
|
20
27
|
"resolve": true,
|
|
21
|
-
"query": true
|
|
28
|
+
"query": true,
|
|
29
|
+
"instruction": false,
|
|
30
|
+
"mutate": false
|
|
22
31
|
},
|
|
32
|
+
"experimentalCapabilities": [
|
|
33
|
+
{
|
|
34
|
+
"id": "sansa.instruction.prototype.v1",
|
|
35
|
+
"capability": "SANSA.Instruction",
|
|
36
|
+
"category": "instruction-parse-lower-plan",
|
|
37
|
+
"maturity": "experimental",
|
|
38
|
+
"verbs": [
|
|
39
|
+
"create",
|
|
40
|
+
"replace",
|
|
41
|
+
"remove",
|
|
42
|
+
"insert",
|
|
43
|
+
"append",
|
|
44
|
+
"move"
|
|
45
|
+
],
|
|
46
|
+
"aliases": [
|
|
47
|
+
{
|
|
48
|
+
"sourceVerb": "append",
|
|
49
|
+
"canonicalVerb": "insert",
|
|
50
|
+
"placement": "last"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"entryPoints": [
|
|
54
|
+
"parseInstruction",
|
|
55
|
+
"lowerInstruction",
|
|
56
|
+
"planInstruction"
|
|
57
|
+
],
|
|
58
|
+
"boundaries": [
|
|
59
|
+
"lowering emits SANSA.Mutate request operations",
|
|
60
|
+
"append is source-level Instruction sugar and lowers to insert-last mutation intent",
|
|
61
|
+
"require clauses lower into SANSA.Mutate preconditions",
|
|
62
|
+
"because and by clauses are inert claimed provenance, not authorization or authentication",
|
|
63
|
+
"planning delegates to SANSA.Mutate plan API",
|
|
64
|
+
"target-surface validation remains a downstream Mutate/adapter boundary",
|
|
65
|
+
"apply remains SANSA.Mutate adapter responsibility"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "sansa.mutate.plan.v1",
|
|
70
|
+
"capability": "SANSA.Mutate",
|
|
71
|
+
"category": "mutation-plan",
|
|
72
|
+
"maturity": "experimental",
|
|
73
|
+
"operations": [
|
|
74
|
+
"create",
|
|
75
|
+
"replace",
|
|
76
|
+
"remove",
|
|
77
|
+
"insert",
|
|
78
|
+
"move"
|
|
79
|
+
],
|
|
80
|
+
"valueIntentHints": [
|
|
81
|
+
"datatype",
|
|
82
|
+
"kind"
|
|
83
|
+
],
|
|
84
|
+
"targetSurfaceValidation": [
|
|
85
|
+
"aeon",
|
|
86
|
+
"json",
|
|
87
|
+
"custom"
|
|
88
|
+
],
|
|
89
|
+
"entryPoints": [
|
|
90
|
+
"planMutation",
|
|
91
|
+
"validateMutationPlanTarget",
|
|
92
|
+
"applyMutationPlan"
|
|
93
|
+
],
|
|
94
|
+
"adapterCapabilityFlags": [
|
|
95
|
+
"supportsCreate",
|
|
96
|
+
"supportsReplace",
|
|
97
|
+
"supportsRemove",
|
|
98
|
+
"supportsOrderedInsert",
|
|
99
|
+
"supportsMove",
|
|
100
|
+
"supportsStableBindingIdentity",
|
|
101
|
+
"supportsAtomicApply"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "sansa.mutate.policy.planFilter",
|
|
106
|
+
"capability": "SANSA.Mutate",
|
|
107
|
+
"category": "policy",
|
|
108
|
+
"maturity": "experimental",
|
|
109
|
+
"surface": "workbench",
|
|
110
|
+
"entryPoints": [
|
|
111
|
+
"tools/mutate-web",
|
|
112
|
+
"/api/mutate options.policySource"
|
|
113
|
+
],
|
|
114
|
+
"policyRuleFields": [
|
|
115
|
+
"operation",
|
|
116
|
+
"operations",
|
|
117
|
+
"target",
|
|
118
|
+
"parent",
|
|
119
|
+
"container",
|
|
120
|
+
"source",
|
|
121
|
+
"anchor",
|
|
122
|
+
"name",
|
|
123
|
+
"names",
|
|
124
|
+
"datatype",
|
|
125
|
+
"datatypes",
|
|
126
|
+
"kind",
|
|
127
|
+
"kinds",
|
|
128
|
+
"value",
|
|
129
|
+
"values"
|
|
130
|
+
],
|
|
131
|
+
"diagnostics": [
|
|
132
|
+
"SANSA_MUTATE_POLICY_INVALID_JSON",
|
|
133
|
+
"SANSA_MUTATE_POLICY_INVALID",
|
|
134
|
+
"SANSA_MUTATE_POLICY_INVALID_ADDRESS",
|
|
135
|
+
"SANSA_MUTATE_POLICY_DENIED"
|
|
136
|
+
],
|
|
137
|
+
"boundaries": [
|
|
138
|
+
"policy is trusted consumer input, not document input",
|
|
139
|
+
"policy authorizes or denies already planned mutation intent",
|
|
140
|
+
"policy must not rewrite mutation plans or make schema-invalid values valid",
|
|
141
|
+
"unsupported policy fields fail closed instead of being ignored",
|
|
142
|
+
"policy remains outside SANSA.Mutate core conformance"
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
],
|
|
23
146
|
"policies": [
|
|
147
|
+
{
|
|
148
|
+
"id": "dynamic-address-activation",
|
|
149
|
+
"capability": "SANSA.Query",
|
|
150
|
+
"category": "authority",
|
|
151
|
+
"maturity": "proposal",
|
|
152
|
+
"requiredFor": "path",
|
|
153
|
+
"modes": [
|
|
154
|
+
"trusted",
|
|
155
|
+
"constrained"
|
|
156
|
+
]
|
|
157
|
+
},
|
|
24
158
|
{
|
|
25
159
|
"id": "validation",
|
|
26
160
|
"capability": "SANSA.Query",
|
|
@@ -52,6 +186,41 @@
|
|
|
52
186
|
"capability": "SANSA.Query",
|
|
53
187
|
"category": "evaluation-budget",
|
|
54
188
|
"phase": "select"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"id": "maxOperations",
|
|
192
|
+
"capability": "SANSA.Mutate",
|
|
193
|
+
"category": "mutation-budget",
|
|
194
|
+
"phase": "plan-apply",
|
|
195
|
+
"maturity": "experimental"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"id": "maxPreconditions",
|
|
199
|
+
"capability": "SANSA.Mutate",
|
|
200
|
+
"category": "mutation-budget",
|
|
201
|
+
"phase": "plan-apply",
|
|
202
|
+
"maturity": "experimental"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"id": "maxValueNodes",
|
|
206
|
+
"capability": "SANSA.Mutate",
|
|
207
|
+
"category": "mutation-budget",
|
|
208
|
+
"phase": "plan-apply",
|
|
209
|
+
"maturity": "experimental"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"id": "maxValueDepth",
|
|
213
|
+
"capability": "SANSA.Mutate",
|
|
214
|
+
"category": "mutation-budget",
|
|
215
|
+
"phase": "plan-apply",
|
|
216
|
+
"maturity": "experimental"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"id": "maxStringLength",
|
|
220
|
+
"capability": "SANSA.Mutate",
|
|
221
|
+
"category": "mutation-budget",
|
|
222
|
+
"phase": "plan-apply",
|
|
223
|
+
"maturity": "experimental"
|
|
55
224
|
}
|
|
56
225
|
],
|
|
57
226
|
"extensions": [
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
# SANSA Instruction Tool
|
|
2
|
+
|
|
3
|
+
The package includes an experimental instruction tool for exercising
|
|
4
|
+
SANSA.Instruction parse, lower, and plan behavior from the command line.
|
|
5
|
+
The browser Mutate Workbench also accepts Instruction source through its input
|
|
6
|
+
mode toggle.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm run instruction -- --mode parse --instruction 'replace $.inventory.items[1].qty with :int32 10'
|
|
10
|
+
npm run instruction -- --mode lower --instruction $'from $.inventory.items.*\nwhere .sku == "B-200"\nreplace .qty with :int32, 10'
|
|
11
|
+
npm run instruction -- --mode plan --instruction $'from $.inventory.items.*\nwhere .sku == "B-200"\nreplace .qty with :int32, 10'
|
|
12
|
+
npm run instruction -- --mode plan --target json --instruction 'create $.types.selectorCliProbe with :sansa, $.inventory.items.*'
|
|
13
|
+
npm run instruction -- --format json --mode plan --instruction-file instruction.sansai
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The default fixture is [../fixtures/query-inventory.json](../fixtures/query-inventory.json),
|
|
17
|
+
the same host-neutral namespace fixture used by the Query CLI. Use
|
|
18
|
+
`--fixture <path>` to test against another JSON or AEON fixture, and
|
|
19
|
+
`--fixture-kind json|aeon` when the extension is ambiguous.
|
|
20
|
+
|
|
21
|
+
`.aeon` fixture support is optional and uses the same AEON TypeScript Core
|
|
22
|
+
runtime discovery path as the Query tool. JSON fixtures expose bindings with
|
|
23
|
+
`address`, `children`, optional `attributeSpace` or `attributes`, optional
|
|
24
|
+
`localSpaces`, and scalar values through `value` or `scalar`.
|
|
25
|
+
|
|
26
|
+
## Modes
|
|
27
|
+
|
|
28
|
+
`parse` validates instruction source and prints its canonical form.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run instruction -- --mode parse --instruction 'replace $.inventory.items[1].qty with :int32 10'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Text output:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
replace $.inventory.items[1].qty with :int32, 10
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`lower` resolves query-shaped candidate clauses and emits structured
|
|
41
|
+
SANSA.Mutate request operations. It does not call the mutate planner.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm run instruction -- --mode lower --instruction $'from $.inventory.items.*\nwhere .sku == "B-200"\nreplace .qty with :int32, 10'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Text output:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
replace $.inventory.items[1].qty = 10 (datatype:int32, kind:number)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`plan` lowers the instruction and then calls `planMutation(...)`. This is the
|
|
54
|
+
best CLI mode for checking whether an instruction can become a conservative
|
|
55
|
+
mutation plan.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run instruction -- --mode plan --instruction $'from $.inventory.items.*\nwhere .sku == "B-200"\nreplace .qty with :int32, 10'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Text output includes the lowered operation and the planned operation summary.
|
|
62
|
+
JSON output includes a sanitized plan summary instead of live binding objects.
|
|
63
|
+
|
|
64
|
+
`plan` mode may also validate the resulting plan against a target surface:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm run instruction -- --mode plan --target aeon --instruction $'from $.inventory.items.*\nwhere .sku == "B-200"\nreplace .qty with :int32, 10'
|
|
68
|
+
npm run instruction -- --mode plan --target json --instruction 'create $.types.selectorCliProbe with :sansa, $.inventory.items.*'
|
|
69
|
+
npm run instruction -- --mode plan --target json-compatible --instruction 'create $.types.label with "ok"'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The target check runs after planning by calling
|
|
73
|
+
`validateMutationPlanTarget(plan, target)`. It does not change instruction
|
|
74
|
+
parsing, lowering, or mutation planning.
|
|
75
|
+
`json-compatible` is accepted as an alias for the JSON target surface; target
|
|
76
|
+
diagnostics still report normalized `targetFormat: "json"`.
|
|
77
|
+
|
|
78
|
+
## Phase Model
|
|
79
|
+
|
|
80
|
+
Instruction tooling keeps the conservative mutation phases visible:
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
Instruction Source
|
|
84
|
+
-> Parsed Instruction
|
|
85
|
+
-> Lowered Structured Operations
|
|
86
|
+
-> Mutation Plan
|
|
87
|
+
-> Consumer Policy / Authorization
|
|
88
|
+
-> Target Surface Check
|
|
89
|
+
-> Preview / Apply
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The command-line tool stops at parse, lower, or plan unless `--target` is
|
|
93
|
+
provided. The browser Mutate Workbench can additionally run its experimental
|
|
94
|
+
policy plan filter after planning and before target-surface validation. Policy
|
|
95
|
+
and target-surface checks are post-plan consumer checks; neither one is encoded
|
|
96
|
+
by the Instruction source.
|
|
97
|
+
|
|
98
|
+
Each phase has a different authority boundary:
|
|
99
|
+
|
|
100
|
+
| Phase | Question Answered | Example Failure |
|
|
101
|
+
| --- | --- | --- |
|
|
102
|
+
| `parse` | Is this valid Instruction syntax and literal payload syntax? | `replace $.x with lower("A")` is rejected because values must be literals. |
|
|
103
|
+
| `lower` | Can candidate-relative Instruction intent become exact structured mutation requests? | `from $.items.* replace .missing with "x"` fails when `.missing` resolves nowhere. |
|
|
104
|
+
| `plan` | Are the exact mutation requests structurally legal against this namespace? | `append .sku with "x"` can lower, then fail because `.sku` is not an ordered container. |
|
|
105
|
+
| `policy` | Does a trusted consumer authorize the already-planned operations? | A default-deny workbench policy rejects a create operation with no matching allow rule. |
|
|
106
|
+
| `target` | Can the selected target format represent the planned value and datatype/kind intent? | JSON target mode rejects `:sansa, $.inventory.items.*`. |
|
|
107
|
+
| `apply` | Can the host mutation adapter apply the already-planned operation now? | Apply fails if a target or ordered anchor has drifted since planning. |
|
|
108
|
+
|
|
109
|
+
Target and policy phases are deliberately outside Instruction. An Instruction
|
|
110
|
+
can be syntactically valid, lower successfully, and produce a valid mutation
|
|
111
|
+
plan while still being denied by a consumer policy or rejected by a selected
|
|
112
|
+
target renderer.
|
|
113
|
+
|
|
114
|
+
## Instruction Surface
|
|
115
|
+
|
|
116
|
+
This prototype accepts the conservative mutation verbs currently supported by
|
|
117
|
+
the SANSA.Mutate planner, plus source-level aliases that lower to those verbs:
|
|
118
|
+
|
|
119
|
+
```text
|
|
120
|
+
create $.inventory.status with "active"
|
|
121
|
+
create "display name" with "Adapter"
|
|
122
|
+
replace $.inventory.qty with :int32, 10
|
|
123
|
+
remove $.inventory.oldStatus
|
|
124
|
+
insert first in $.inventory.tags with "new"
|
|
125
|
+
insert last in $.inventory.tags with "sale"
|
|
126
|
+
append $.inventory.tags with "sale"
|
|
127
|
+
insert before $.inventory.tags[1] in $.inventory.tags with :string, "featured"
|
|
128
|
+
insert after $.inventory.tags[1] in $.inventory.tags with :string, "clearance"
|
|
129
|
+
move $.inventory.tags[0] first in $.inventory.tags
|
|
130
|
+
move $.inventory.tags[0] last in $.inventory.tags
|
|
131
|
+
move $.inventory.tags[0] before $.inventory.tags[2] in $.inventory.tags
|
|
132
|
+
move $.inventory.tags[0] after $.inventory.tags[2] in $.inventory.tags
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`append <container> with <value>` and `append in <container> with <value>` are
|
|
136
|
+
source-level aliases for `insert last in <container> with <value>`. They lower
|
|
137
|
+
to an ordinary SANSA.Mutate `insert` operation with `placement: "last"` and
|
|
138
|
+
canonicalize as `insert last ...`.
|
|
139
|
+
|
|
140
|
+
For `insert` and `move`, `first` and `last` describe a destination within the
|
|
141
|
+
named container. `before <anchor>` and `after <anchor>` additionally name an
|
|
142
|
+
anchor that must resolve to a child of that same container during planning.
|
|
143
|
+
|
|
144
|
+
Instructions may also use `from` and `where` clauses to lower
|
|
145
|
+
candidate-relative targets into exact mutation requests:
|
|
146
|
+
|
|
147
|
+
```text
|
|
148
|
+
because "manual correction"
|
|
149
|
+
by "Bob"
|
|
150
|
+
from $.inventory.items.*
|
|
151
|
+
where .sku == "C-300"
|
|
152
|
+
create status with "pending"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`where` selects candidate bindings. `require` preserves a Mutate precondition
|
|
156
|
+
that must hold during planning and, by default, again before apply:
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
from $.inventory.items.*
|
|
160
|
+
where .sku == "A-100"
|
|
161
|
+
require .qty == 1
|
|
162
|
+
require .status == "open"
|
|
163
|
+
replace .qty with :int32, 10
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
For candidate-relative instructions, each surviving candidate receives a
|
|
167
|
+
candidate-scoped precondition target. This keeps filtering and fail-closed
|
|
168
|
+
mutation guards separate.
|
|
169
|
+
|
|
170
|
+
One Instruction contains one declared mutation intent. That intent may lower to
|
|
171
|
+
multiple exact operations when a candidate selector matches multiple bindings,
|
|
172
|
+
but repeated source-level mutation clauses are rejected rather than treated as a
|
|
173
|
+
batch syntax. Use structured mutation-request JSON for heterogeneous or
|
|
174
|
+
unrelated multi-operation batches.
|
|
175
|
+
|
|
176
|
+
`because` and `by` are optional source-provenance clauses. They are preserved as
|
|
177
|
+
inert metadata on the lowered instruction and plan source:
|
|
178
|
+
|
|
179
|
+
```text
|
|
180
|
+
because "manual correction"
|
|
181
|
+
by "Bob"
|
|
182
|
+
from $.inventory.items.*
|
|
183
|
+
where .sku == "A-100"
|
|
184
|
+
replace .qty with :int32, 10
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
`because` is a human-readable reason. `by` is claimed attribution. Neither
|
|
188
|
+
clause provides authorization, authentication, approval, signature material, or
|
|
189
|
+
audit proof. Real actor identity, delegation, policy checks, and audit evidence
|
|
190
|
+
belong to the host envelope or mutation adapter.
|
|
191
|
+
|
|
192
|
+
Values use type-first intent in the same broad style as AEON-facing examples:
|
|
193
|
+
|
|
194
|
+
```text
|
|
195
|
+
create $.types.brand with :brandColor, #ff00aa
|
|
196
|
+
create $.types.format with :csv[","], "sku,name"
|
|
197
|
+
create $.types.color.@.selector with :sansa, $.inventory.items.*
|
|
198
|
+
create $.types.@.selector with :sansa, $.inventory.items.*
|
|
199
|
+
create $.types.absentCopy with :null<string>, !notApplicable
|
|
200
|
+
create $.cloneCopy with :number, ~target
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The optional comma after a datatype annotation is accepted for readability:
|
|
204
|
+
`:int32 10` and `:int32, 10` are equivalent.
|
|
205
|
+
|
|
206
|
+
The datatype annotation is operation intent. The literal still supplies the
|
|
207
|
+
representation family: `:csv[","], "sku,name"` is string-shaped payload with
|
|
208
|
+
`csv[","]` datatype intent, while `:tuple, ("sku", 7)` is tuple-shaped payload
|
|
209
|
+
with `tuple` datatype intent. Top-level datatype and representation kind are
|
|
210
|
+
preserved on the structured mutation operation.
|
|
211
|
+
|
|
212
|
+
Instruction values also include a conservative container-literal slice for
|
|
213
|
+
testing structured mutation payloads:
|
|
214
|
+
|
|
215
|
+
```text
|
|
216
|
+
create $.types.settings with :object, { enabled = true }
|
|
217
|
+
create $.types.settingsGeneric with :object<node>, { enabled = true }
|
|
218
|
+
create $.types.aliases with :list<string>, ["adapter", "driver"]
|
|
219
|
+
create $.types.pairing with :tuple<string>, ("sku", "A-100")
|
|
220
|
+
create $.types.badge with :node<node>, <badge(<label("new")>)>
|
|
221
|
+
insert before $.inventory.items[1] in $.inventory.items with :object, { sku = "B-150" name = "Brace" qty = 4 category = "hardware" }
|
|
222
|
+
append in $.inventory.items[1].roles with :string, "admin,editor"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Some datatype annotations are valid Instruction intent but may still be
|
|
226
|
+
rejected by a selected target surface. For example, `csv[","]` can be planned as
|
|
227
|
+
SANSA.Mutate intent, while the current AEON target surface rejects square
|
|
228
|
+
bracket arguments on `csv`.
|
|
229
|
+
|
|
230
|
+
List, tuple, and node-child values use commas between items in this prototype.
|
|
231
|
+
Object fields use AEON-like `name = value` fields and may be separated by
|
|
232
|
+
layout or commas. Duplicate object field names are rejected so instruction
|
|
233
|
+
authoring never silently applies last-value-wins behavior:
|
|
234
|
+
|
|
235
|
+
```text
|
|
236
|
+
create $.types.settings with :object, { enabled = true, status = false }
|
|
237
|
+
create $.types.labels with :object, { "display name" = "Adapter", "quote\"key" = "ok" }
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Quoted object field names use AEON-style quoted keys, not address-style member
|
|
241
|
+
selectors. For example, `"display name" = "Adapter"` is valid inside an
|
|
242
|
+
Instruction object value, while `["display name"] = "Adapter"` is reserved for
|
|
243
|
+
SANSA address/member selector syntax and is rejected in object values.
|
|
244
|
+
|
|
245
|
+
Nested value annotations inside container literals are retained in the parsed
|
|
246
|
+
Instruction AST and canonical source, but the conservative structured Mutate
|
|
247
|
+
operation currently carries the plain container payload plus top-level value
|
|
248
|
+
intent. Child-specific datatype intent needs separate exact operations or a
|
|
249
|
+
future structured value-intent model.
|
|
250
|
+
|
|
251
|
+
Instruction values are literal payloads. Query expressions such as
|
|
252
|
+
`lower("A")`, membership expressions, and candidate-relative value expressions
|
|
253
|
+
are not accepted as replacement or create payloads in this conservative slice.
|
|
254
|
+
|
|
255
|
+
Instruction parsing and lowering are target-neutral. A target format can reject
|
|
256
|
+
value intent that SANSA can express. For example, `:string<null>` is valid
|
|
257
|
+
Instruction datatype intent, but the current AEON workbench target rejects it
|
|
258
|
+
because AEON only allows generic parameters on specific datatype families:
|
|
259
|
+
|
|
260
|
+
```text
|
|
261
|
+
create $.types.textProbe with :string<null>, ""
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
The browser Mutate Workbench exposes this as a separate target-surface phase.
|
|
265
|
+
The default target is AEON. JSON target mode is stricter and accepts only
|
|
266
|
+
JSON-compatible object/list/string/number/boolean/null values while rejecting
|
|
267
|
+
AEON-only features such as attributes, typed SANSA values, parameterized
|
|
268
|
+
datatypes, tuples, nodes, references, NaN, and Infinity.
|
|
269
|
+
|
|
270
|
+
| Instruction intent | AEON target | JSON target |
|
|
271
|
+
| --- | --- | --- |
|
|
272
|
+
| `:object, { enabled = true }` | accepted | accepted |
|
|
273
|
+
| `:list, ["adapter"]` | accepted | accepted |
|
|
274
|
+
| `:list<string>, ["adapter"]` | accepted | rejected: parameterized datatype |
|
|
275
|
+
| `:object<node>, { enabled = true }` | accepted | rejected: parameterized datatype |
|
|
276
|
+
| `:tuple<string>, ("sku", "A-100")` | accepted | rejected: parameterized datatype |
|
|
277
|
+
| `:node<node>, <badge(<label("new")>)>` | accepted | rejected: parameterized datatype |
|
|
278
|
+
| `:sansa, $.inventory.items.*` | accepted | rejected: SANSA datatype |
|
|
279
|
+
| `:tuple, ("sku", 7)` | accepted | rejected: tuple datatype |
|
|
280
|
+
| `:node, <badge("new")>` | accepted | rejected: node datatype |
|
|
281
|
+
| `:number, ~target` | accepted | rejected: reference-family payload |
|
|
282
|
+
| `$.item.@.selector with :sansa, $.path` | accepted when AEON attribute-space exists | rejected: attribute-space mutation |
|
|
283
|
+
|
|
284
|
+
Examples that lower successfully but fail JSON target-surface validation:
|
|
285
|
+
|
|
286
|
+
```text
|
|
287
|
+
create $.inventory.aliases with :list<string>, ["adapter"]
|
|
288
|
+
create $.inventory.pair with :tuple, ("sku", 7)
|
|
289
|
+
create $.inventory.badge with :node, <badge("new", 3)>
|
|
290
|
+
create $.inventory.copy with :number, ~target
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Quoted create member names are accepted for member names that cannot be written
|
|
294
|
+
as bare identifiers. Attribute creation uses ordinary SANSA attribute-space
|
|
295
|
+
addressing (`.@.`) and lowers to a create operation whose parent is the
|
|
296
|
+
attribute space.
|
|
297
|
+
|
|
298
|
+
This is not yet a full replacement for structured mutation-request JSON.
|
|
299
|
+
Instruction preserves source-level claimed provenance, but it does not express
|
|
300
|
+
heterogeneous multi-operation requests as a single instruction. Use structured
|
|
301
|
+
JSON for those cases until a later instruction/vocabulary slice defines them.
|
|
302
|
+
|
|
303
|
+
The Mutate Workbench labels examples that only exist on one input surface as
|
|
304
|
+
`structured-only` or `instruction-only` so this boundary is visible while
|
|
305
|
+
testing. The workbench also includes instruction-only diagnostic examples for
|
|
306
|
+
duplicate object fields, literal-only value failures, invalid create member
|
|
307
|
+
names, target-surface rejection, and policy-boundary behavior. Policy examples
|
|
308
|
+
load their policy JSON into the Policy tab when selected, so the planned or
|
|
309
|
+
applied operation and the trusted authorization surface can be inspected
|
|
310
|
+
together. Workbench examples are defined in
|
|
311
|
+
[tools/mutate-web/examples.mjs](../tools/mutate-web/examples.mjs) so the UI and
|
|
312
|
+
runtime tests consume the same catalog. Catalog variants also declare expected
|
|
313
|
+
plan behavior, operation counts, selected text snippets, and focused apply
|
|
314
|
+
checks so example drift is caught by the package test suite.
|
|
315
|
+
|
|
316
|
+
## Diagnostics
|
|
317
|
+
|
|
318
|
+
Failures preserve the phase boundary:
|
|
319
|
+
|
|
320
|
+
- parse failures come from `parseInstruction(...)`;
|
|
321
|
+
- lower failures come from instruction lowering, candidate resolution, or
|
|
322
|
+
candidate-relative target resolution;
|
|
323
|
+
- plan failures come from `planMutation(...)`;
|
|
324
|
+
- policy failures come from a trusted consumer or workbench policy layer;
|
|
325
|
+
- target-surface failures come from a target renderer/adapter deciding that the
|
|
326
|
+
planned value cannot be represented by that target.
|
|
327
|
+
|
|
328
|
+
Candidate-relative misses are lowering failures. Structural mutation legality,
|
|
329
|
+
such as inserting into a non-ordered container or moving across containers,
|
|
330
|
+
remains a Mutate planning failure after lowering has produced exact addresses.
|
|
331
|
+
|
|
332
|
+
For example, a missing candidate-relative target fails during lowering:
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
npm run instruction -- --mode lower --instruction $'from $.inventory.items.*\nreplace .missing with "x"'
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Workbench text diagnostics include nested parse causes when available, so an
|
|
339
|
+
instruction parse wrapper can still expose the concrete source error such as
|
|
340
|
+
`SANSA_INSTRUCTION_DUPLICATE_OBJECT_FIELD`.
|
|
341
|
+
Target-surface text diagnostics include available context such as target format,
|
|
342
|
+
datatype, and value path, while JSON diagnostics expose those fields
|
|
343
|
+
structurally as `targetFormat`, `datatype`, and `valuePath`.
|
|
344
|
+
|
|
345
|
+
JSON diagnostics are available with `--format json`.
|