Repository navigation
fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state - #34810
Conversation
…isarms; the toggle door answers the engine state toggleFlow refuses enabled=true on a packaged flow whose definition's status disables it (RESOURCE_CONFLICT / 409), after the provenance refusal and before the ledger write, so nothing half-flips. The verdict is flowStatusDisabled, now passed in the toggleFlowKey host literal; the toggleFlow docblock's @throws names the refusal. Switching such a flow off still writes the ledger row. POST /automation/:name/toggle answers enabled read back from getFlowRuntimeStates instead of echoing the request; a service without that read keeps the legacy echo. Claude-Session: https://claude.ai/code/session_01ADHkmQAXHSQEgnYyx9tstb Co-authored-by: Claude <noreply@anthropic.com>
…med toggle as refused Claude-Session: https://claude.ai/code/session_01ADHkmQAXHSQEgnYyx9tstb Co-authored-by: Claude <noreply@anthropic.com>
…ggle-status-disarmed
Claude-Session: https://claude.ai/code/session_01ADHkmQAXHSQEgnYyx9tstb Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 41 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 12 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 36 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b1cdf9cbb74db8b70133c5d4e77cd9407702ff9e && git checkout b1cdf9cbb74db8b70133c5d4e77cd9407702ff9e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin fc5913e117405814e5c40e4e9bbe6b2da7420048 6d6e25955b97efa12e20fcd43072a68f41521eb1 && git checkout -B drift-repro fc5913e117405814e5c40e4e9bbe6b2da7420048 && git merge --no-ff 6d6e25955b97efa12e20fcd43072a68f41521eb1
node scripts/docs-audit/affected-docs.mjs --json fc5913e117405814e5c40e4e9bbe6b2da7420048
|
…ggle-status-disarmed
…rowing, with both moved paths and their one-line fix Claude-Session: https://claude.ai/code/session_01ADHkmQAXHSQEgnYyx9tstb Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-steve · session_01ADHkmQAXHSQEgnYyx9tstb Judged a flake, re-running once: |
|
repo:objectstack#3 · os-support-ai · session_01WGufzi8zDwpH6wX7ZPUcHR 席位核对L1 first review (full) · REWORK · Head-sha: No earlier L1 record exists. L1-b2 read Must-fixM1. On a name two packages hold, the toggle door's new read-back can report the other package's flow. This is in
Failure scenario, on the fixture of Fix either way:
Either fix needs a door pin with two holders: toggle the holder registered second, and the answer must equal that slot's state, with a CONTROL on the first holder. Fix the comment at Should-fixS1. The PR body carries a withdrawn routing line. The body's Checklist (the rest holds)
Owed
|
On a name two packages hold, the door reaches the flow through flowSlotView, whose toggleFlow switches one slot, while the engine's getFlowRuntimeStates reads one row per slot under the bare name. A row picked by name was then the first-registered holder's, so toggling the second holder answered the other package's state. Two or more rows of the name now read back nothing and the request is echoed, which every engine toggle entry makes true (it refuses switching on a flow its status keeps off). Pinned at the door with two holders, switching the second-registered one, with CONTROLs on the first holder and one row. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX
… the one-row read-back Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX
|
repo:objectstack#3 · os-support-ai · session_01WGufzi8zDwpH6wX7ZPUcHR 席位核对L1 delta review · ACCEPT · Head-sha: This reviews the delta from L1 6948915409 (REWORK at
No new findings. Owed, for the seat: a contract-review delta at CONTRACT_REVIEW_TIER for |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract reviewServed-tier: First contract review of this PR, so the whole PR, not a delta. No earlier ① Derived judgments
② Semver levelClause-②: no (narrowing) — present on the PR body and the changeset, and it matches the diff: one request that answered 200 now answers 409, and one row is no longer overwritten. The changeset carries ③ Boundary flags
④ Design judgmentNo must-fix, no should-fix. The narrowing itself. Read against the published spec on
The echo route, judged explicitly: echoing is correct. I could not make the door answer a state that differs from what is stored. Attempts, each read in the tree at this head:
Nits (none affects correctness or the contract; each is left as a follow-up or accepted deviation, since a fix outside the prose faces moves the head):
Implemented-by: VERDICT: PASS |
…5 before landing #34810) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX
|
repo:objectstack#3 · os-support-ai · session_01WGufzfr1xZSFZzCR8HnqXX Landing · PR #34810 (card #34655 half B,
|
…efusal; the changeset names refreshPackagedFlowDefaults N1 of the contract review on #34810 (half B), carried here as half A edits packages/spec: the toggle door's contract prose listed only the customer-authored 409. It now also names the 409 for switching ON a packaged flow whose own status disables it, and that switching it off is accepted. JSDoc only; no schema moves. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX
Brings #34810 (half B: the status-disarmed switch-on refusal) into half A. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX
…orable surface The automation API reference renders the module JSDoc edited for #34810's N1. The api surface regains GetMetaItemRequest:userTextLocales, which the merge of main deferred to the regeneration (merge=os-regen). Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX
Requested by Yibo Wang · project thread
Refs #34655 (half B; half A follows in its own PR)
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — skills/objectstack-automation/SKILL.md teaches the toggle only as the off switch for an installed package's flow; nothing it says changes
维护者速读
active:true却让 flow 继续关着,接口仍回{enabled:true},管理员以为已开、实际从不运行(卡 34655 的 B 半,分诊要求先落)。service-automation/src/flow-definitions.ts第 554 行起的新拒绝;engine.ts第 7571 行 host 字面量与第 7528 行起的@throws;runtime/src/domains/automation.ts第 4453 行起的应答读回(只在该名字恰有一行时读回)。pnpm --filter @objectstack/service-automation exec vitest run --maxWorkers=2 src/toggle-door-packaged-only.test.ts,预期全绿且含 "switching ON a packaged flow its own status disarms is refused" 一组;本轮的双持有者应答:pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/automation-addressed-route.test.ts,预期 "the toggle door answers the switched slot" 一组 5 条全绿。What changes
toggleFlowwithenabled: trueon a packaged flow whose definition'sstatusdisables it (obsolete/invalid, the verdictregisterFlowrecords inflowStatusDisabled) is refused withRESOURCE_CONFLICT/ 409. It sits right after the provenance refusal (refuseCustomerAuthoredToggle), before the ledger write and before any in-process change, so nothing half-flips. No new error code or public name. The verdict is read fromflowStatusDisabled, now passed inAutomationEngine.toggleFlowKey's host literal, so the status rule keeps one source. ThetoggleFlowdocblock@throwsnames the new refusal.Flow 'NAME' cannot be enabled through this switch: its definition's status is 'STATUS', which keeps it off. This switch never changes a definition's status; publish the flow with status 'active' (for a package that is read-only here, that takes a package version that ships it active). Nothing was changed.active: false. Turning off a flow that is already off is not an error, and the row records the installation's choice: when a later definition ships the flowactive, it stays off until an administrator turns it on. A pin holds this.active: trueover an administrator's earlieractive: falserow, so a later republish asactivemade it run at once. The row now stays, so after that republish the flow is still off until it is switched on again. One-line fix: publish the flow with statusactivefirst, then switch it on.POST /automation/:name/toggleanswers200 { name, enabled }withenabledread back fromgetFlowRuntimeStates(the readingGET /automation/_statusserves). It no longer echoes the request. That reading names the switched flow only while the name has one row there: a flow name two packages hold has one row per holder under the same name (ADR-0150 D4), and the door reaches such a name throughflowSlotView(its address/automation/:ns/:name/toggle, or the bare name while one holder's package is enabled), which switches one slot. Two or more rows therefore read back nothing. In that case, and for a service that does not implement the read or holds no row of the name, the door keeps the legacy echo. For the engine's own service (the only one with slots) that echo is true by construction, because the refusal above stops the one request whose echo was false, on every toggle entry. The handler comment, the route docblock and the changeset say so.Tests
New pins:
service-automation/src/toggle-door-packaged-only.test.ts, new top-level describe[ADR-0126 §7.2] switching ON a packaged flow its own status disarms is refused, and nothing half-flips:obsoleteand statusinvalid: codeRESOURCE_CONFLICTand status 409, the status named.setActiveis never called, the ledger stays empty, the/_statusrow is unchanged, the trigger stays unbound andexecuteanswersFLOW_DISABLED.active.active, the switch arms it.activeand statusdraft: off and on work as before.runtime/src/domains/automation-toggle-caller.test.ts, new top-level describe[ADR-0126 §7.2] the toggle door answers the engine state, not the request:{enabled:false}, which equals/_status.{enabled:true}.getFlowRuntimeStates: the legacy echo.runtime/src/domains/automation-addressed-route.test.ts, new top-level describe[ADR-0126 §7.2] the toggle door answers the switched slot, on a name two packages hold(real dispatcher, realSchemaRegistry, an engine double that keeps each slot's state and reads one row per slot under the bare name, in registration order). Each case switches the holder registered SECOND, with the first holder's row reading the opposite state:200 {enabled: true}, equal to that slot's state.200 {enabled: false}.200 {enabled: true}, throughtoggleFlowSlot, the baretoggleFlownever called.Existing tests whose behaviour changed, each named:
service-automation/src/flow-activation-ledger.test.ts, case "a STATUS-disabled subflow gets a remedy through its definition — this switch never moves a status". It asserted thattoggleFlow('shared_step', true)resolves and the child still answersFLOW_DISABLED. It now asserts the toggle rejects withRESOURCE_CONFLICT/ 409, and the child still answersFLOW_DISABLED.service-automation/src/flow-activation-late-trigger.test.ts, case "re-enabling the LEDGER bit of a flow whose STATUS is obsolete does not arm it". It is renamed "switching ON a flow whose STATUS is obsolete is refused before the ledger write, and it stays unarmed". The toggle now rejects withRESOURCE_CONFLICT/ 409, and the unbound,enabled:false,FLOW_DISABLEDassertions are unchanged.The runtime toggle test file gains a module-top
import '@objectstack/metadata', whichcheck:test-source-aliasasks for (the same line its sibling tests carry).Acceptance notes
Landing tier: narrowing (
Clause-②: no (narrowing), BREAKING), handed to the seat as Tier H. The changeset carries the ADR-0087 dispositionnot-required (no-migration-prescription): no schema key, value, metadata type or stored row moves, only one REST door's answer.fix(lint,service-automation)!: a flow value envelope is typed for the date-text verdicts, so timestamp() over a date field is refused at os validate and registerFlow #34654 has landed; this branch has taken it. That PR also edited
engine.ts. This PR touches only two spots there, thetoggleFlowKeyhost literal and thetoggleFlowdocblock (now near lines 7528 and 7571).origin/maine9f65a3, which carries fix(lint,service-automation)!: a flow value envelope is typed for the date-text verdicts, so timestamp() over a date field is refused at os validate and registerFlow #34654, merged into this branch cleanly in fix round 1 (merge 8eee7dd).Half A (a packaged flow that declares it ships switched off) is not in this PR. It is a new authorable key and gets its own PR and contract review.
The engine's arming gate in
activateFlowTriggerstill declines any flow that may not run. The toggle no longer reaches it with a status-disarmed flow switched on.Fix round 1 (L1 REWORK 6948915409), by seat 3:
flowSlotViewwas not taken: the engine's rows carry no slot key, so a view cannot tell its own row apart without a new engine member, outside this PR's claimed surface.rows[0]): 3 of 65 red, exactly the three second-holder cases; both CONTROLs green.packages/qa/dogfood/test/flow-name-per-namespace.dogfood.test.ts(alpha'sqa_ns_q4off, theta's installed second). With the fix,POST /automation/theta/qa_ns_q4/toggle {enabled:true}answered{enabled:true}andgetFlowRuntimeStatesread twoqa_ns_q4rows[false, true]. With the fix reverted and@objectstack/runtimerebuilt (marker proven indist/), the same call answered{"name":"qa_ns_q4","enabled":false}, alpha's row, the scenario L1 described. Restored, rebuilt, marker proven absent.origin/mainmerged (it carries fix(lint,service-automation)!: a flow value envelope is typed for the date-text verdicts, so timestamp() over a date field is refused at os validate and registerFlow #34654), clean; overlap-check VERDICT clean.VERDICT command-exit 0, Test Files 479 passed / 3 skipped (482), Tests 4067 passed / 68 skipped (4135). Readings in Verification.Verification
Fix round 1 (head 8eee7dd): tests, ablation, real-stack probe, battery, gates
Every run went through
scripts/pm/os-verify-lock.sh; each verdict line is quoted from that run.automation-addressed-route.test.ts+automation-toggle-caller.test.ts: Test Files 2 passed (2), Tests 65 passed (65),VERDICT command-exit 0.scripts/ablation-replace.mjs): anchorconst state = rows.length === 1 ? rows[0] : undefined;replaced byconst state = rows[0];, anchor 1 to 0, blob a1367e7548b8 to b7aa5bd21d9a. Same two files: Tests 3 failed / 62 passed,VERDICT command-exit 1. Red: ON at the second holder's address, OFF at the second holder's address, the bare name with the second holder served. Green: both CONTROLs. Restored: blob == HEAD a1367e7548b8,git diff HEADempty. The suites import the door by relative path, so nodist/sits between mutation and run.flow-name-per-namespace.dogfood.test.tson 8eee7dd: with the fix, Tests 10 passed (10). Fix reverted (blob 65e6a60baddd to 08a723a102aa),@objectstack/runtimerebuilt,ablation-dist-preflightfound the marker indist/: Tests 1 failed / 9 passed,{"success":true,"data":{"name":"qa_ns_q4","enabled":false}}against expectedenabled: true. Restored to HEAD blob, rebuilt, preflight--absentexit 0; probe removed,git statusclean.pnpm --filter @objectstack/runtime test: Test Files 613 passed (613), Tests 11417 passed / 23 skipped.pnpm --filter @objectstack/runtime typecheck: exit 0.pnpm --filter @objectstack/service-automation test: Test Files 287 passed (287), Tests 4139 passed (4139).pnpm --filter @objectstack/service-automation typecheck: exit 0.pnpm --filter @objectstack/dogfood test, no shard, no path) on 8eee7dd:VERDICT command-exit 0, Test Files 479 passed / 3 skipped (482), Tests 4067 passed / 68 skipped (4135).node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackon 8eee7dd: 75 families, each run with stdin from /dev/null. 73 exit 0 on the first sweep.check:type-check-debtanswered queue-timeout (exit 99 inside, PREREQUISITE NOT MET 3) while the battery held the lock; rerun under the lock: exit 0.check:dual-build-cjs-loadsanswered PREREQUISITE NOT MET (3, no dist for some packages); after the full package build, exit 0.--ranwith exit codes: 75 derived, 75 run, 0 NOT-MEASURED, 0 UNRUN.node scripts/pm/overlap-check.mjs: origin/main e9f65a3 and feat(spec, service-automation): a packaged flow can ship switched off for an administrator to turn on (defaultActive) #34793 merge cleanly,VERDICT clean exit 0.successand 16skipped, none failed (includingLint & Repo Gates,TypeScript Type Check,Test Core,Build Core,Dogfood Regression Gate,Live E2E UI,Test UI,Check Changeset,Governed Surface Queue Guard).Premise re-measured on
origin/mainf6f5b50 before the change, with throwaway tests, since deleted:toggleFlow(f, true): forobsoleteandinvalidthe call resolved, a rowactive:truewas written, the flow read enabled false, the trigger stayed unbound andexecuteansweredFLOW_DISABLED. Foractiveanddraft(CONTROL) the flow read enabled true and the trigger was bound.{"success":true,"data":{"name":"f","enabled":true}}, whileGET /automation/_statusreadenabled:false.git merge-tree --write-treeof head a65f6b4 against #34654's head8598c1dcb77d7865c91fac5e967d1df84ed44d7d: exit 0, clean, tree 85297242129540c331add7b00258ba97dda41841.Ablation readings (one per changed behaviour, through scripts/ablation-replace.mjs; mutation landed and restored to the HEAD blob, git diff HEAD empty)
if (enabled && this.flowStatusDisabled.get(name) === true) {changed toif (false && …), anchor 1 to 0, blob d82d74740f6a to 2e5b155587b8. Result:toggle-door-packaged-only+flow-activation-ledger5 failed / 63 passed. Red: both status pins, the both-ways pin, the step-completes pin and the existing ledger subflow case. The toggle-off pin and both CONTROLs stayed green, as expected. Restored to d82d74740f6a.deps.success({ name, enabled })), anchor 1 to 0, blob 66105af9556e to 3fe21d164cbd. Result:automation-toggle-caller2 failed / 4 passed. Red: both disagreeing-state pins. The CONTROL and the no-read-method echo pin stayed green. Restored to 66105af9556e.Both suites import the source under test by relative path, so no
dist/sits between the mutation and the run.Local tests (heads 0c7fc78 and a65f6b4)
All runs went through
scripts/pm/os-verify-lock.sh, which ended withVERDICT command-exit 0.pnpm --filter @objectstack/service-automation teston 8c918c4, before the merge oforigin/mainf02f4f6: the first run showed 1 failed, the existingflow-activation-late-triggercase named above, which was updated in 8c918c4. That file was rerun: 11/11. The package total is 287 files and 4113 tests, all green except that one case before its update.pnpm --filter @objectstack/service-automation typecheck(tsc plus check:test-typecheck): exit 0.pnpm --filter @objectstack/runtime test && pnpm --filter @objectstack/runtime typecheck, then the three touched service-automation files, on merge head 03f7f18: runtime Test Files 611 passed (611), Tests 11342 passed, 19 skipped; service-automation Test Files 3 passed (3), Tests 79 passed (79).automation-toggle-caller.test.ts. That file was rerun: 6/6.@objectstack/speccheck:generated after the merge: all 14 generated artifacts are up to date.origin/mainat a65f6b4: runtime test + typecheck 611/611 files, 11346 passed / 19 skipped; the three touched service-automation files 79/79; typecheck exit 0; the three changeset gates exit 0.Derived gates (dispatch-gates --commands, reconciled with --ran)
Derived on head a65f6b4 (and first on 0c7fc78):
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstacklisted 75 families. Each one was run with stdin from /dev/null, and its exit code was taken before any pipe.dispatch-gates --ran: 75 derived, 75 run, 0 NOT-MEASURED, 0 UNRUN.check:dual-build-cjs-loadsanswered exit 3 (PREREQUISITE NOT MET, no dist). It went green after a fullpnpm build.check:test-source-aliasanswered exit 1: the new runtime pins reach@objectstack/metadatathrough a dynamic import. 0c7fc78 adds the module-top import the gate asks for.Generated by Claude Code