Repository navigation
Commit 5d8d69d
fix(service-automation)!: automation variable keys cannot use reserved object segments, and one run's writes never change a flow's defaults (#38001)
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — no published skill teaches a flow variable name,
assignment target, screen field name or resume-signal key rule (checked:
`git grep` over `skills/**` for `__proto__`, `constructor`, `prototype`,
and the automation skill's variable, `outputVariable`, assignment,
screen-field and resume text; the only hits are `skills/objectui`
expression-sandbox lists, unrelated)
## 维护者速读
-
用户能看到什么变化:流程作者把变量名(或名字里以点分隔的任一段)写成三个保留词之一时,注册和保存会被拒并指出每一处;恢复暂停中的流程时,提交的数据里带这类键会被拒,流程保持暂停;普通流程无感。
- 为什么做:自动化流程的变量命名与运行之间的隔离加固,安全席位按维护者授权接手的高危项。
- 出错会怎样:已有流程若恰好用了这些名字会注册失败,改名后重新保存即可;整个改动可以直接撤回。
- 要你做什么:审阅后由授权审批人批准,再由席位落地。
## What changes
Three rules, stated once each in the automation service:
1. **A flow variable key may not use `__proto__`, `constructor` or
`prototype` as its name or as any dot-separated part of it — at
registration.** Registration, and the stored pass that previews it,
judges every key a flow names, in every graph it holds: each node's `id`
(it heads every key the node's output is stored under), each declared
variable's `name`, each `assignment` node's targets in every shape, each
node's `outputVariable` / `iteratorVariable` / `indexVariable` /
`errorVariable` / `idVariable`, and each `screen` field's `name`, each
judged with surrounding whitespace trimmed. The judged positions are
held equal to the spec's binding positions by a pin. The refusal names
every such key and where it sits. A name that only contains one of the
words (`constructor_name`) is unaffected.
2. **A caller's resume signal may not carry such a key.** Each key of
`output` and of `inputs` is judged first, before anything reads the
submitted values, a signal handed on to a paused subflow child included;
the answer is `INVALID_SIGNAL` (400), nothing is applied, and the run
stays paused for a valid submission. The engine's own continuations (a
`map` item handing back, a subflow child finishing) are not judged, so a
run paused before this release still completes.
3. **One run's writes never change a flow's defaults, another run's
values, or the record the run was handed.** Each run binds its own copy
of an object or list default and of the trigger record (`record` and
`$record`), seeded once the run's context has resolved so the copy
carries the lookups the start node declares. A dotted write whose head
names a value the run holds is read back by the run's expressions
(conditions and CEL values) and leaves the value as it was, so a text
hole and `$record` read the value. With no durable store, a resumed run
works on its own copy of its variables, as a stored run does. A run
value that contains itself is refused by the copy by name; a paused run
holding one still resumes.
Commits: the door half (rules 1 and 2), then rule 3, then the docs page
and changeset, then one more pin for the chokepoint, then a dogfood pin
updated, then the published prose and the ledger entry, then the review
round: node ids, `idVariable` and trimmed names at registration, the
engine's own continuations exempt at resume, the run's own record copy
(seeded after the context resolves), and the named refusal for a value
that contains itself; then a patch round: the run's record copy taken as
its context resolves, so declared lookups land on the copy; `previous`
copied too; a value that contains itself answered as a failed run; the
third changeset bullet trimmed to its readers; and a second ledger
entry; then a should-fix round (26d6b3a): a declared lookup is grafted
into a new top-level record, so the caller's record, a class instance
included, is never written; new pins cover retry-attempt and dry-run
seeding and a class-instance record. Bound, stated: with no graft, a
record that is not a plain object is used as handed; the engine writes
nothing into it, though a node's in-place change of `record` then
reaches that object, and CEL cannot read a record that is not a plain
object unless a graft landed (service-automation 299 files / 4436 tests,
trigger-record-change 123).
- **A pin in
`packages/triggers/trigger-record-change/src/before-update-flow-payload-reach.test.ts`
stated that a run's `record` variable is the record on its context; it
now states the rule: the run's own copy.**
- **Dogfood pin updated in this PR:**
`packages/qa/dogfood/test/flow-condition-scope-keys.dogfood.test.ts` (a
screen resume's `inputs` and `output` bags) stated the earlier accept
set and goes red under this change; it now states the ruled one —
refused with `INVALID_SIGNAL`, the run stays paused, and the valid
submission then lands.
- **Published prose brought in line with the rule (prose only, no schema
shape change):** the assignment config's comments in
`packages/spec/src/automation/builtin-node-config.zod.ts`, the
`INVALID_SIGNAL` description in
`packages/spec/src/contracts/automation-service.ts`, and the resume
route's status note in `packages/runtime/src/domains/automation.ts`.
- **ADR-0087 ledger:** two semantic entries,
`flow-variable-key-reserved-segment-refused` and
`flow-dotted-write-read-by-run-expressions-only`
(`packages/spec/src/migrations/entries/semantic/`), so `os migrate meta`
and the upgrade guide carry both rules; the changeset is marked
`registered` with both. The changeset is `minor` on
`@objectstack/service-automation` (the kind `narrowed`), `patch` on
`@objectstack/spec` and `@objectstack/runtime`.
## Tests
- `src/variable-key-reserved-segments.test.ts` — rules 1 and 2: each
sample is refused at registration and listed by the stored pass; each
resume sample is refused on a screen (the screen's conditions are never
evaluated, the paused variables are byte-identical, and the valid
submission then lands) and on a pause with no input contract; the
chokepoint refuses them as a whole. Controls: ordinary dotted keys and
names containing the words register, run and resume.
- `src/run-values-isolation.test.ts` — rule 3: object and list defaults
(dotted writes, list index and length, a node that changes the value in
place), the trigger record against `$record`, and a paused run with and
without a store.
- Red before the fix: 38 failed / 5 passed (the controls) on the unfixed
tree, every failure an assertion on the rule.
- Review round: the same two files grow to 88 tests — one case per
judged position, held equal to the spec's binding positions; every
assignment shape (map, the legacy array's three name keys, the bare
config); a key in a nested graph; trimmed names; a `map` node id; a
signal delegated to a subflow child; engine-built signals and an
engine-built continuation that completes; a node changing the trigger
record in place before any pause; a value that contains itself. All 88
pass.
- After: both files 50/50 (first round); the whole package suite 299
files / 4392 tests passed at `5cd060c9d6d` (existing flow suites with
ordinary dotted keys unchanged). The commits after it change no
service-automation source.
<details><summary>Reverse verification — each new pin, one change
reverted at a time (counts only)</summary>
Each leg through `scripts/ablation-replace.mjs` (anchor x1 -> x0,
restored to HEAD, `git diff HEAD` empty after every leg), on the two new
files (50 tests):
| Reverted | Red | Which pins |
| :--- | :--- | :--- |
| the registration check | 18 | every authoring case, registration and
stored pass |
| the resume door's first check | 6 | every screen case; the no-contract
pause stays refused by the chokepoint |
| the chokepoint's check | 6 | every chokepoint case; resume stays
refused by the first check |
| the scope's copy on descent | 1 | the record case |
| the per-run copy of a default | 2 | the in-place cases |
| both copies together | 7 | every default case and the record case |
| the held run's copy | 1 | the paused run with no store |
Review round, on the same two files (88 tests), at `2da449d7736`:
| Reverted | Red | Which pins |
| :--- | :--- | :--- |
| judging node ids | 2 | the node-id position, the `map` node id |
| judging `idVariable` | 4 | the `idVariable` position, the three
trimmed-name cases |
| trimming before judging | 5 | the three trimmed-name cases, the
`outputVariable` and `idVariable` positions |
| `nodeId` in the judged positions | 2 | the two enumeration pins |
| the legacy-array branch | 3 | the three legacy-array cases |
| the engine-built exemption | 7 | the six engine-built cases, the
continuation that completes |
| the resume door's first check | 9 | the six screen cases, the three
delegated `inputs` cases |
| the run's record copy | 1 | the record changed in place before any
pause |
| the cycle guard | 2 | the named refusal, the paused run holding such a
value |
The record copy taken before the context resolved reds 2 tests in the
existing `record-lookup-expand.integration.test.ts` (declared lookups
missing from the run's copy); seeding after the context resolves turns
them green.
</details>
## Acceptance notes
- A flow whose text hole or `$record` read relied on reading a dotted
write now reads the held value; the changeset gives the rewrite (assign
the computed value to a variable of its own).
- A security item is with the owner seat.
## Verification
First read (by risk):
1. `packages/services/service-automation/src/run-resume.ts` — the
resume-door block just before the screen contract.
2.
`packages/services/service-automation/src/flow-registration-checks.ts` —
`validateVariableKeySegments`.
3. `packages/services/service-automation/src/dag-traversal.ts` — the
descent in `celScope`, the default and record seeding, and seeding after
the context resolves.
Two-minute check: `pnpm --filter @objectstack/service-automation exec
vitest run src/variable-key-reserved-segments.test.ts
src/run-values-isolation.test.ts` — expect `Tests 94 passed (94)` (at
26d6b3a).
<details><summary>Local gates at b1d5a7f (later rounds:
service-automation 299 files / 4436 tests and trigger-record-change 123
at 26d6b3a)</summary>
- `@objectstack/service-automation` typecheck (tsc and the test-layer
typecheck): exit 0; the whole package suite: 299 files / 4430 tests
passed (at `82e81476d6c`; the later commits change no source of that
package). `@objectstack/trigger-record-change` tests: 12 files / 123
tests passed. `@objectstack/spec` `check:generated` exit 0 and
`src/migrations` 203/203; `@objectstack/runtime` typecheck exit 0.
- The derivation at `b1d5a7f4597` is the same 142 families as at
`469a6acd57c`; `check:nul-bytes`, `check:test-source-alias`,
`check:tier-file-adoption` and `check:cross-package-test-inputs` re-run
there: exit 0.
- `check:adr-0087-registration`: exit 0, `registered
flow-variable-key-reserved-segment-refused,
flow-dotted-write-read-by-run-expressions-only` (at d2273ab).
`check:cross-package-test-inputs`: exit 0, after declaring the spec
module the enumeration pin reads (the package's declared globs and its
turbo `test` inputs).
- The derived gate list (`dispatch-gates --commands`, 142 families): 139
exit 0; 3 NOT MEASURED, prerequisite not met on this box (exit 3):
`check:skill-examples` (no client SDK build),
`check:dual-build-cjs-loads` (no full build), `check:type-check-debt`
(no full build). CI runs all three. `--ran` reconciliation: 142 derived,
142 run, 0 unrun.
</details>
<details><summary>Dogfood battery at b1d5a7f (re-run at d2273ab:
490 files passed)</summary>
- Closure built at that head, then `pnpm --filter @objectstack/dogfood
test` under the verify lock, no shard: exit 0 · Test Files 490 passed /
3 skipped (493) · Tests 4144 passed / 68 skipped (4212).
- An earlier run at `469a6acd57c` failed to load packages (`Cannot find
package '@objectstack/platform-objects/…'`) because that package's built
output was rewritten while the run was going; the re-run after
rebuilding the closure was green at that head too.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ASNY8XNef4ywkQio6S9ju4)_
<!-- signed: security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3ad3b41 commit 5d8d69d
19 files changed
Lines changed: 1364 additions & 60 deletions
File tree
- .changeset
- content/docs/automation
- packages
- qa/dogfood/test
- runtime/src/domains
- services/service-automation/src
- spec/src
- automation
- contracts
- migrations/entries/semantic
- triggers/trigger-record-change/src
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1476 | 1476 | | |
1477 | 1477 | | |
1478 | 1478 | | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
1479 | 1488 | | |
1480 | 1489 | | |
1481 | 1490 | | |
| |||
2242 | 2251 | | |
2243 | 2252 | | |
2244 | 2253 | | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
2245 | 2271 | | |
2246 | 2272 | | |
2247 | 2273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
217 | | - | |
| 219 | + | |
218 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
219 | 225 | | |
220 | 226 | | |
221 | 227 | | |
222 | 228 | | |
223 | 229 | | |
224 | 230 | | |
225 | | - | |
226 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
227 | 237 | | |
228 | 238 | | |
229 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4798 | 4798 | | |
4799 | 4799 | | |
4800 | 4800 | | |
4801 | | - | |
| 4801 | + | |
| 4802 | + | |
| 4803 | + | |
4802 | 4804 | | |
4803 | 4805 | | |
4804 | 4806 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
1052 | 1052 | | |
1053 | 1053 | | |
1054 | 1054 | | |
1055 | | - | |
1056 | | - | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1057 | 1060 | | |
| 1061 | + | |
1058 | 1062 | | |
1059 | 1063 | | |
1060 | 1064 | | |
1061 | 1065 | | |
1062 | 1066 | | |
1063 | 1067 | | |
1064 | | - | |
1065 | | - | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
1066 | 1077 | | |
1067 | 1078 | | |
1068 | 1079 | | |
| |||
1262 | 1273 | | |
1263 | 1274 | | |
1264 | 1275 | | |
1265 | | - | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
1266 | 1280 | | |
1267 | 1281 | | |
1268 | 1282 | | |
| |||
1278 | 1292 | | |
1279 | 1293 | | |
1280 | 1294 | | |
1281 | | - | |
1282 | | - | |
1283 | | - | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
1284 | 1305 | | |
1285 | 1306 | | |
1286 | 1307 | | |
1287 | | - | |
| 1308 | + | |
| 1309 | + | |
1288 | 1310 | | |
1289 | 1311 | | |
1290 | 1312 | | |
| |||
1378 | 1400 | | |
1379 | 1401 | | |
1380 | 1402 | | |
1381 | | - | |
1382 | 1403 | | |
1383 | 1404 | | |
1384 | 1405 | | |
| |||
1387 | 1408 | | |
1388 | 1409 | | |
1389 | 1410 | | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
1390 | 1415 | | |
1391 | 1416 | | |
1392 | 1417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
796 | 796 | | |
797 | 797 | | |
798 | 798 | | |
799 | | - | |
800 | | - | |
801 | 799 | | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
802 | 805 | | |
803 | 806 | | |
804 | 807 | | |
| |||
0 commit comments