Skip to content

fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state - #34810

Merged
objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/issue-34655-toggle-status-disarmed
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/issue-34655-toggle-status-disarmed

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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

维护者速读

  • 改了什么:管理员对一个"作者已把 status 设为 obsolete/invalid"的打包 flow 点"开启"时,开关不再写入激活账本并谎报"已开启",而是直接拒绝(409)并说明原因;开关接口的成功应答改为回报引擎读回的真实状态(同名 flow 被两个包持有时,回报被切换那个包自己的状态)。
  • 为什么改:此前开关写了 active:true 却让 flow 继续关着,接口仍回 {enabled:true},管理员以为已开、实际从不运行(卡 34655 的 B 半,分诊要求先落)。
  • 风险与回滚:这是一次收窄(BREAKING):对 status 为 obsolete/invalid 的打包 flow 点"开启"由 200 改为 409,并且不再覆盖已有的 active:false 行——此前"先开、再以 active 重发"会直接运行,现在重发后还要再开一次;关闭方向与正常 flow 不变。回滚即还原本 PR。
  • 先看: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 条全绿。
  • 需要你做的:作为收窄 PR(Tier H),在审核记录到位后批准落地;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 已合入,本分支已合并 main。

What changes

  • Refusal (engine). toggleFlow with enabled: true on a packaged flow whose definition's status disables it (obsolete / invalid, the verdict registerFlow records in flowStatusDisabled) is refused with RESOURCE_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 from flowStatusDisabled, now passed in AutomationEngine.toggleFlowKey's host literal, so the status rule keeps one source. The toggleFlow docblock @throws names the new refusal.
  • The sentence (the flow's name and status filled in): 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.
  • Toggle off is unchanged, on purpose. Switching a status-disarmed flow OFF still writes 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 flow active, it stays off until an administrator turns it on. A pin holds this.
  • A second moved path. Switching on a status-disarmed flow used to write active: true over an administrator's earlier active: false row, so a later republish as active made 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 status active first, then switch it on.
  • The door's answer (runtime). POST /automation/:name/toggle answers 200 { name, enabled } with enabled read back from getFlowRuntimeStates (the reading GET /automation/_status serves). 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 through flowSlotView (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:
    • status obsolete and status invalid: code RESOURCE_CONFLICT and status 409, the status named. setActive is never called, the ledger stays empty, the /_status row is unchanged, the trigger stays unbound and execute answers FLOW_DISABLED.
    • Off both ways (ledger row and status): refused, and the row is unchanged.
    • Toggle off: accepted, the row is written, and the flow stays off after a republish as active.
    • The named step completes: republished active, the switch arms it.
    • CONTROL, status active and status draft: 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:
    • Enable request over a service whose state reads off: {enabled:false}, which equals /_status.
    • Disable request over a service whose state reads on: {enabled:true}.
    • CONTROL: state and request agree.
    • A service without 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, real SchemaRegistry, 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:
    • ON at the second holder's address, the first holder off: 200 {enabled: true}, equal to that slot's state.
    • OFF at the second holder's address, the first holder on: 200 {enabled: false}.
    • The bare name whose one served holder is the second registered (the first package disabled, its slot off): 200 {enabled: true}, through toggleFlowSlot, the bare toggleFlow never called.
    • CONTROL: the first holder's address, the second reading the opposite: the answer is the first holder's own state.
    • CONTROL: a name one package holds still answers its one row read back, not the request.

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 that toggleFlow('shared_step', true) resolves and the child still answers FLOW_DISABLED. It now asserts the toggle rejects with RESOURCE_CONFLICT / 409, and the child still answers FLOW_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 with RESOURCE_CONFLICT / 409, and the unbound, enabled:false, FLOW_DISABLED assertions are unchanged.

The runtime toggle test file gains a module-top import '@objectstack/metadata', which check:test-source-alias asks 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 disposition not-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, the toggleFlowKey host literal and the toggleFlow docblock (now near lines 7528 and 7571). origin/main e9f65a3, 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 activateFlowTrigger still 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:

    • M1 fixed. The read-back picked the first row of the name, which on a name two packages hold is the first-registered holder's, so switching the other holder (at its address, or bare with one served holder left) answered the wrong package's state. The door now reads back only a name's one row; with two or more rows it echoes, which every engine toggle entry makes true. A fix inside flowSlotView was 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.
    • Pins: the five cases above. Ablation (fix reverted to rows[0]): 3 of 65 red, exactly the three second-holder cases; both CONTROLs green.
    • Real stack, measured once and not committed: a throwaway step appended to the Q4 case of packages/qa/dogfood/test/flow-name-per-namespace.dogfood.test.ts (alpha's qa_ns_q4 off, theta's installed second). With the fix, POST /automation/theta/qa_ns_q4/toggle {enabled:true} answered {enabled:true} and getFlowRuntimeStates read two qa_ns_q4 rows [false, true]. With the fix reverted and @objectstack/runtime rebuilt (marker proven in dist/), the same call answered {"name":"qa_ns_q4","enabled":false}, alpha's row, the scenario L1 described. Restored, rebuilt, marker proven absent.
    • S1: the withdrawn contract-review routing line (review#1, stamped 12:31Z) is removed.
    • origin/main merged (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.
    • Full dogfood battery on head 8eee7dd: 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.

  • Door pins on 5b5f2e6: automation-addressed-route.test.ts + automation-toggle-caller.test.ts: Test Files 2 passed (2), Tests 65 passed (65), VERDICT command-exit 0.
  • Ablation (scripts/ablation-replace.mjs): anchor const state = rows.length === 1 ? rows[0] : undefined; replaced by const 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 HEAD empty. The suites import the door by relative path, so no dist/ sits between mutation and run.
  • Real-stack probe (throwaway, not committed), Q4 case of flow-name-per-namespace.dogfood.test.ts on 8eee7dd: with the fix, Tests 10 passed (10). Fix reverted (blob 65e6a60baddd to 08a723a102aa), @objectstack/runtime rebuilt, ablation-dist-preflight found the marker in dist/: Tests 1 failed / 9 passed, {"success":true,"data":{"name":"qa_ns_q4","enabled":false}} against expected enabled: true. Restored to HEAD blob, rebuilt, preflight --absent exit 0; probe removed, git status clean.
  • On 8eee7dd: 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.
  • Full dogfood (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/objectstack on 8eee7dd: 75 families, each run with stdin from /dev/null. 73 exit 0 on the first sweep. check:type-check-debt answered 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-loads answered PREREQUISITE NOT MET (3, no dist for some packages); after the full package build, exit 0. --ran with 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.
  • CI on 8eee7dd: 53 check-runs, all completed, 37 success and 16 skipped, none failed (including Lint & 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/main f6f5b50 before the change, with throwaway tests, since deleted:

  • Engine, packaged flow with a record-change trigger and a ledger, toggleFlow(f, true): for obsolete and invalid the call resolved, a row active:true was written, the flow read enabled false, the trigger stayed unbound and execute answered FLOW_DISABLED. For active and draft (CONTROL) the flow read enabled true and the trigger was bound.
  • Door: 200 {"success":true,"data":{"name":"f","enabled":true}}, while GET /automation/_status read enabled:false.

git merge-tree --write-tree of head a65f6b4 against #34654's head 8598c1dcb77d7865c91fac5e967d1df84ed44d7d: 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)
  • Refusal removed (if (enabled && this.flowStatusDisabled.get(name) === true) { changed to if (false && …), anchor 1 to 0, blob d82d74740f6a to 2e5b155587b8. Result: toggle-door-packaged-only + flow-activation-ledger 5 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.
  • Door read-back removed (the answer back to deps.success({ name, enabled })), anchor 1 to 0, blob 66105af9556e to 3fe21d164cbd. Result: automation-toggle-caller 2 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 with VERDICT command-exit 0.

  • pnpm --filter @objectstack/service-automation test on 8c918c4, before the merge of origin/main f02f4f6: the first run showed 1 failed, the existing flow-activation-late-trigger case 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).
  • The last commit, 0c7fc78, adds only the module-top import to automation-toggle-caller.test.ts. That file was rerun: 6/6.
  • @objectstack/spec check:generated after the merge: all 14 generated artifacts are up to date.
  • Full dogfood on a65f6b4 under os-verify-lock: VERDICT command-exit 0; Test Files 479 passed | 3 skipped (482); Tests 4059 passed | 68 skipped (4127). After the merge of origin/main at 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/objectstack listed 75 families. Each one was run with stdin from /dev/null, and its exit code was taken before any pipe.

  • Result: 75 of 75 exit 0. dispatch-gates --ran: 75 derived, 75 run, 0 NOT-MEASURED, 0 UNRUN.
  • On the first sweep (head 03f7f18), two families were not green:
    • check:dual-build-cjs-loads answered exit 3 (PREREQUISITE NOT MET, no dist). It went green after a full pnpm build.
    • check:test-source-alias answered exit 1: the new runtime pins reach @objectstack/metadata through a dynamic import. 0c7fc78 adds the module-top import the gate asks for.
  • Both families are exit 0 on the final sweep. The repo-wide families are left to CI.

Generated by Claude Code

…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>
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/runtime, @objectstack/service-automation, touching 23 documentable anchor(s).

41 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json fc5913e117405814e5c40e4e9bbe6b2da7420048.

⛔ 12 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 36 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json fc5913e117405814e5c40e4e9bbe6b2da7420048 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from b1cdf9cbb74db8b70133c5d4e77cd9407702ff9e — the merge of head 6d6e25955b97efa12e20fcd43072a68f41521eb1 into base fc5913e117405814e5c40e4e9bbe6b2da7420048, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs fc5913e117405814e5c40e4e9bbe6b2da7420048 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…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>
@objectstack-fleet objectstack-fleet Bot changed the title fix(automation): switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state Nov 17, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmQAXHSQEgnYyx9tstb

Judged a flake, re-running once: Live E2E UI (run 44071427284, job 133998830967) failed at e2e/live/studio-editor.spec.ts:74, "Add block opens a block-type picker…", an element of the Studio page editor not found. This PR changes only the automation toggle (service-automation toggleFlow, the engine.ts host literal and docblock, the runtime toggle door) and a changeset; no page-editor, Studio or UI file is in the diff. A second failure at this head is treated as real.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzi8zDwpH6wX7ZPUcHR

席位核对

L1 first review (full) · REWORK · Head-sha: a65f6b41fb05abe4e28066790ebb4e98b63fb574 · card #34655 half B (Refs #34655) · read 2026-11-17T13:07Z

No earlier L1 record exists. L1-b2 read 0c7fc785 informally in a thread message. Inputs: card body; claim 6943786242 and half-B amendment 6944022372; dev reports 6946220643 and 6948138832; hand-off 6948282082; takeover 6948719649. Also the net diff from merge-base 07f2861f (8 files, +256 / -14) and the check-runs on this head. I read everything on GitHub and in git at this head.

Must-fix

M1. On a name two packages hold, the toggle door's new read-back can report the other package's flow. This is in packages/runtime/src/domains/automation.ts:4443-4447. The 200 now answers getFlowRuntimeStates().find((s) => s.name === name). The comment above it says "A name two packages hold never reaches here (toggleFlow refuses it), so the name's row is the flow switched". That holds for the bare engine entry. It does not hold for the slotted path, read in code at this head:

  • The slotted path reaches this handler. A qualified address /automation/:ns/:name/toggle, and a bare name whose one served holder remains (ADR-0150: the flow doors held at main under R4-G judge the served holders (what a disabled holder's flow slot answers) #33386), are admitted as status: 'slot'. The door then swaps automationService for flowSlotView(automationService, packageId, name) (automation.ts:4083-4088).
  • The view's toggleFlow switches the right slot. It goes through slots.toggleFlowSlot (flow-slot-view.ts:167-168).
  • The view does not bind getFlowRuntimeStates. It is not among the members in bound (flow-slot-view.ts:160-176), so the proxy hands back the engine's own method.
  • The engine returns one row per slot, under the bare name. getFlowRuntimeStates maps each slot key through flowSlotName (flow-definitions.ts:266-276, "two packages' flows of one name are two rows of that name").
  • So .find returns the first row of that name in flows order, which belongs to whichever holder registered first, not necessarily the slot just switched.

Failure scenario, on the fixture of packages/qa/dogfood/test/flow-name-per-namespace.dogfood.test.ts Q4: alpha's qa_ns_q4 is switched off, and theta's qa_ns_q4 is installed and on. POST /automation/theta/qa_ns_q4/toggle {enabled: true} switches theta's flow on (no change), then answers 200 {enabled: false}, which is alpha's row. Theta's flow is on. That is the false toggle answer this card exists to remove, moved onto a path that answered correctly before: the echo was true there, and with this PR's refusal it is true by construction. I read this in code and did not run it. Pins on the slotted address would settle it.

Fix either way:

  • read the switched slot's own row: bind a getFlowRuntimeStates (or a one-row read) in flowSlotView that answers the slot key's row;
  • or keep the echo when the service is a slot view, which this PR's refusal makes true.

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 :4440-4442 to match.

Should-fix

S1. The PR body carries a withdrawn routing line. The body's Contract-review-handoff: review#1 — CONTRACT_REVIEW_TIER routed by maintainer order (…) · head a65f6b41… line (its routing stamped 2026-11-17T12:31Z) names a review seat whose routing was withdrawn at 12:34Z (hand-off 6948282082 says the same of half A's body). The contract review now comes from seat 3. Remove or replace the line when the body is next edited. The card thread is gone, so the area edits the body.

Checklist (the rest holds)

  • Shape: Draft against main, mergeable_state: clean. The only card reference is Refs #34655, with no closing keyword. Half A's feat(spec, service-automation): a packaged flow can ship switched off for an administrator to turn on (defaultActive) #34793 carries the Fixes. Title is fix(automation)!.
  • Scope vs claim:
    • flow-definitions.ts, runtime/src/domains/automation.ts, the tests beside them and .changeset/ are in claim 6943786242.
    • engine.ts is in amendment 6944022372, which allows "two hunks only". The diff has exactly those two: the toggleFlowKey host literal gains flowStatusDisabled, and the toggleFlow docblock gains its @throws line.
    • The two existing tests edited (flow-activation-ledger.test.ts and flow-activation-late-trigger.test.ts) sit beside flow-definitions.ts, and the body names each with its reason.
  • The refusal (flow-definitions.ts:554-565):
    • It sits after refuseCustomerAuthoredToggle and before packagedFlowOwner and the ledger write, so nothing is written or flipped.
    • It reads flowStatusDisabled, the verdict registerFlow records, so there is one source for the status rule.
    • It refuses only enabled: true, and its sentence names the step that arms the flow.
    • Its error shape { code: 'RESOURCE_CONFLICT', status: 409 } is the same as the provenance refusal's on the same door (:563).
    • The §7.3 subflow remedy still never prescribes the toggle (flow-activation-ledger.test.ts, not.toContain("Enable 'shared_step'")).
    • The other toggleFlow caller, flow-slot-view.ts:168, reaches the same body through toggleFlowKey, so the refusal also holds on the slotted path.
  • Declarations: Clause-②: no (narrowing) matches the diff: one door answer moves from 200 to 409, and an active: false row is no longer overwritten. The card's Asked item B allows the refusal. Metadata-protocol: none with patch for @objectstack/service-automation and @objectstack/runtime follows the level rule. Check Changeset is success. The ADR-0087 disposition not-required (no-migration-prescription) holds: no key, value, type or stored row shape moves.
  • Changeset text, read sentence by sentence: both moved paths and the one-line fix are stated. The "Unchanged" list matches the code, since toggle off still writes, active/draft behave as before and the provenance refusal comes first. One statement depends on M1: "The door's 200 answer reads enabled back from getFlowRuntimeStates, the same reading GET /automation/_status serves." Once M1 is fixed, re-read that sentence and the body's matching bullet against the fix.
  • Docs and skills:
    • Skills-docs: none is true: skills/objectstack-automation/SKILL.md:51 teaches only { enabled: false }.
    • No page in content/docs/** states the toggle-on answer for a status-disarmed flow.
    • ToggleFlowResponseSchema.enabled ("New enabled state", packages/spec/src/api/automation-api.zod.ts) stays true once M1 is fixed.
  • Tests: there are new pins in toggle-door-packaged-only.test.ts (obsolete and invalid refused; both ways; off accepted and held after an active republish; the arming step completes; CONTROLs active and draft) and in automation-toggle-caller.test.ts (read-back disagrees both ways; CONTROL; no-read echo). The ablation in the body turned 5 of 63 red (refusal) and 2 of 6 red (read-back), and the expected CONTROLs stayed green. No pin covers the slotted address, which is the M1 gap.
  • Narrowing evidence: the body reports a full dogfood run on a65f6b41fb (479 files, 4059 tests, VERDICT command-exit 0), which is the current head.
  • Gates at this head: 57 check-runs, all completed: success or skipped, none failed. The earlier Live E2E UI red (studio-editor.spec.ts:74) is success on its rerun. Lint & Repo Gates and TypeScript Type Check are success.

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
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzi8zDwpH6wX7ZPUcHR

席位核对

L1 delta review · ACCEPT · Head-sha: 8eee7ddbe2a23e44308b063f322536818168e144 · card #34655 half B (Fixes #34655) · read 2026-11-17T15:04Z

This reviews the delta from L1 6948915409 (REWORK at a65f6b41: M1 and S1). Inputs:

  • dev report 6951786536;

  • the delta a65f6b41..494da208 (3 files, +123 / -13), read line by line;

  • the main merge 8eee7ddb, which takes 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;

  • the PR body;

  • check-runs on this head.

  • M1 is closed, by the echo route, and I accept that route. The door now keeps getFlowRuntimeStates() rows under the name and reads one back only when exactly one row exists. With two or more rows, it echoes the request. That is the slotted case, where rows carry no slot key, so a view cannot find its own row. I checked that the echo is true for the engine's service. toggleFlowSlot and toggleFlow both reach toggleFlowKey and then toggleFlow with the slot key. flowStatusDisabled is keyed by that same key (engine.ts:5697), so the status refusal judges the switched slot.

    • A switch-on that is not refused clears flowLedgerDisabled for that slot. A switch-off adds it.
    • isFlowEnabled composes exactly those two (engine.ts:6864).
    • So a 200 means the slot reads what the request asked.

    Binding getFlowRuntimeStates in flowSlotView would need a new engine member outside the claimed surface. Not doing it was the right call for this card. The one-row read-back, which is the point of the change, is kept for every name one package holds.

  • The pins are real. There are five door pins on a name two packages hold:

    • switched on at the second holder's address while the first is off;
    • switched off at the second holder's address while the first is on;
    • the bare name whose only served holder is the second one registered;
    • CONTROL: the first holder's own state;
    • CONTROL: a one-package name still answers its row, not the request.

    The first three would each have answered the first holder's row before the fix. The body reports the ablation 3 red / 62 green, and the real-stack Q4 probe went red without the fix (enabled: false against true). I did not re-run them.

  • Prose: the route docblock, the handler comment and the changeset sentence now state when the answer is an echo and why it is true. The handler comment's old claim, "A name two packages hold never reaches here", is gone.

  • S1 is closed. The withdrawn routing line is removed from the body.

  • Merge: the net diff over the PR's 9 files from the merge-base to 494da208 is line-identical to main..8eee7ddb.

  • Surface: the delta moves automation.ts, automation-addressed-route.test.ts and the changeset, all inside the claim.

  • Gates at this head: latest attempt per check, 53 checks: success or skipped, none failed. The narrowing battery is pinned to this head: 479 files / 4067 tests, VERDICT command-exit 0.

No new findings.

Owed, for the seat: a contract-review delta at CONTRACT_REVIEW_TIER for a65f6b41..494da208, which is a narrowing. Please include the echo-route judgment. Re-run the battery if the head moves again. This comment readies, queues and arms nothing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8eee7ddbe2a23e44308b063f322536818168e144
Local-runs: none
Scope: packages/services/service-automation/src/flow-definitions.ts, packages/services/service-automation/src/engine.ts, packages/runtime/src/domains/automation.ts, packages/services/service-automation/src/toggle-door-packaged-only.test.ts, packages/services/service-automation/src/flow-activation-ledger.test.ts, packages/services/service-automation/src/flow-activation-late-trigger.test.ts, packages/runtime/src/domains/automation-toggle-caller.test.ts, packages/runtime/src/domains/automation-addressed-route.test.ts + packages/services/service-automation/src/flow-activation-projection.ts, packages/services/service-automation/src/flow-slots.ts, packages/runtime/src/flow-slot-view.ts, packages/spec/src/api/automation-api.zod.ts, packages/spec/src/contracts/automation-service.ts (the last five outside the diff: read, not reviewed)

First contract review of this PR, so the whole PR, not a delta. No earlier ## Contract review record exists on PR #34810 (its four comments are the docs-drift bot, a flake note, L1 REWORK 6948915409 and L1 delta ACCEPT 6951880023) or on card #34655 for half B. The L2 records the card names (6946901031, 6947617913) are half A's, on #34793. Inputs: the card body and its 19 comments, the PR body and file list, the net diff origin/main...8eee7ddb (9 files, +366 / -14; merge-base e9f65a3), and the 57 check-runs on this head.

① Derived judgments

  • Accept-set, toggleFlow(name, true) on a packaged flow whose status is obsolete or invalid: narrowed from resolve to RESOURCE_CONFLICT / 409. Right. flow-definitions.ts:554 reads flowStatusDisabled.get(name), the verdict registerFlow writes at engine.ts:5697. It sits after refuseCustomerAuthoredToggle and before the subflow guard, the store write and the projection write, so nothing half-flips. The error shape is the one the provenance refusal already uses on this door, so no new code or name is published.
  • Accept-set, switch-off of such a flow: unchanged. Right. The row records the installation's choice and holds after a later active republish; pinned.
  • Accept-set, active and draft flows: unchanged. Right. Both CONTROLs pinned.
  • Stored state, the second moved path: an earlier active: false row is no longer overwritten by a refused switch-on. Right, and declared. It follows from refusing before the write. The changeset states it with its one-line remedy.
  • Public surface, the door's 200 body: enabled is read back from getFlowRuntimeStates when the name has exactly one row, else the request is echoed. Right. See ④ for the echo route. The body's shape (ToggleFlowResponseSchema) does not move.
  • Public surface, AutomationEngine: no member added. toggleFlowKey's host literal gains one field; the toggleFlow docblock gains its @throws. Right, and inside claim amendment 6944022372 (two hunks only).
  • No change to packages/spec. Right for this card half: no schema key, value or type moves.

② Semver level

Clause-②: 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 patch for @objectstack/service-automation and @objectstack/runtime, the ! title and a BREAKING paragraph with who moves and the one-line fix. Check Changeset is success on this head (both attempts), and that conclusion is the level gate's verdict. The ADR-0087 disposition not-required (no-migration-prescription) holds: nothing exists for objectstack migrate meta to rewrite.

③ Boundary flags

  • Dev flags: the fix-round report 6951786536 has open_questions: [] and security_findings: none. Earlier reports (6946220643, 6948138832) list only process deviations (three small vitest runs outside the verify lock, throwaway and deleted), none of which touches the contract.
  • Out-of-scope finding in 6951786536 ("GET /automation/_status rows for a name two packages hold carry no package or slot key; not a card"): answered in ④ as N3. I disagree with "not a card".
  • SQL push-down: no finding. The diff adds no query, no id materialisation and no in-app join. The read-back filters an in-memory projection the engine already holds; the refusal removes a ledger write.
  • Gates on this head: 57 check-runs, every one success or skipped, none failed. Note for the approver: the CI matrix job Dogfood Regression Gate (shard/3) is skipped by the path filter, so the aggregate Dogfood Regression Gate: success did not run the battery. The narrowing battery on this head is the dev's locked run recorded in 6951786536 (479 files / 4067 tests, VERDICT command-exit 0), which I did not re-run.

④ Design judgment

No must-fix, no should-fix.

The narrowing itself. Read against the published spec on main:

  • automation-api.zod.ts:673-678 declares the 200 body's enabled as "New enabled state". On main the door echoed the request, so for a status-disarmed flow that declaration was false. The read-back and the refusal together make it true.
  • automation-api.zod.ts:30-36 and contracts/automation-service.ts:1971-1977 declare the switch as the activation-ledger bit of a packaged flow, and the status as the author's switch. isFlowEnabled (engine.ts:6864) composes the two and neither overrides the other. A switch-on over a disarming status therefore never delivered "enabled"; no declared capability to make such a flow run is taken away.
  • What the refusal does withdraw is narrow: clearing an earlier active: false row while the status still disarms the flow (pre-arming it for a later active release). The spec declares no such pre-arming, the card's Asked item B offers the refusal by name, the result fails closed (the flow stays off until switched on again), and the changeset states it as BREAKING with the fix. I accept it as a declared narrowing and name it here so the Tier H approver sees it. The other route the card allowed (accept the write, answer enabled: false) would have kept pre-arming; that choice is the maintainer's to confirm, not a defect.

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:

  • Two or more rows implies a shared name. getFlowRuntimeStates (flow-definitions.ts:267-277) emits one row per key of flows, named flowSlotName(key). Two rows of one name are two slots of that name, so FlowSlotTable.isShared (flow-slots.ts:113) is true and the enabled reading goes through FlowActivationProjection.hasShared.
  • Switch-on that returns 200. The status refusal ran on the slot key: toggleFlowSlot and the bare toggleFlow both end in toggleFlowKey(key), and flowStatusDisabled is keyed by that key (engine.ts:5697; moveFlowRecords at engine.ts:5289-5299 moves it when a key moves). Then flowLedgerDisabled.delete(flowName, packageOwner) sets the holder's own row to on, and hasShared lets the holder's own row decide. packagedFlowOwner(key) for a shared slot is the slot's own package (engine.ts:6157-6160), so the row written is the row read. isFlowEnabled(key) is true.
  • A package-less active: false row over a shared name. This was my best candidate: under two holders the row is not deleted (if (!shared) at flow-definitions.ts:630) and it keeps every holder off that has no row of its own. But the switch-on writes the holder's own row, and hasShared checks that row first. Enabled is true. flow-slots-per-package.test.ts:429-433 pins this on the real engine.
  • Switch-off that returns 200. The holder's own row is set off; hasShared answers true; enabled is false.
  • The one-row read-back. toggleFlow throws "not found" unless the switched key is in flows, so a name's single row is the switched flow's row. This holds through flowSlotView too (a lone served holder beside a disabled co-holder).
  • A stale or unowned row on an unshared name (FlowActivationProjection.has, the holder === undefined and stale branches) can leave a flow off after an accepted switch-on. That is the one-row case, where the door reads back and answers enabled: false, which is the truth and which the card allows.
  • A service that is not the engine has no slots; with no read method or no row it keeps the legacy echo, as the changeset says.
  • Not binding getFlowRuntimeStates in flowSlotView was the right call for this card. The rows carry no slot key, so the view would need a new engine member, outside claim 6943786242 and its amendment. See N3 for the follow-up.

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):

  • N1 (nit) — the published contract's prose lists one refusal. contracts/automation-service.ts:1971-1977 and automation-api.zod.ts:30-36 name only the customer-authored 409; the status 409 is named in the engine docblock and the route docblock only. Follow-up: add the sentence in half A (feat(spec, service-automation): a packaged flow can ship switched off for an administrator to turn on (defaultActive) #34793), which already edits packages/spec.
  • N2 (nit) — the invariant the echo rests on has no pin on the real engine. The five door pins use an engine double whose toggleFlowSlot always sets the state, and the new refusal pins use names one package holds. Nothing committed asserts that toggleFlowSlot(pkg, name, true) on a status-disarmed co-held slot is refused. It holds today by the reading above (and the body's real-stack probe was throwaway). Follow-up card: one case in toggle-door-packaged-only.test.ts or flow-slots-per-package.test.ts.
  • N3 (nit) — GET /automation/_status rows of a co-held name carry no package, which is why the door cannot read back there and why an administrator cannot tell the two rows apart. The dev noted it and filed nothing. It deserves a card: with a package on the row, the door reads back on every path and the echo goes away.
  • N4 (nit) — in the echo case only, a definition republished obsolete between the refusal check and the return (the body awaits the run stores and the ledger write) would answer enabled: true over a flow now off. The one-row path reads back and is not exposed. Accepted deviation; N3's fix closes it.

Implemented-by: claude/issue-34655-toggle-status-disarmed
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzfr1xZSFZzCR8HnqXX

Landing · PR #34810 (card #34655 half B, Refs #34655) · head 6d6e25955b · 2026-11-17T15:39Z

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 15:40
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 583bbf3 Nov 17, 2026
54 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34655-toggle-status-disarmed branch November 17, 2026 16:09
os-support-ai pushed a commit that referenced this pull request Nov 17, 2026
…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
os-support-ai pushed a commit that referenced this pull request Nov 17, 2026
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
os-support-ai pushed a commit that referenced this pull request Nov 17, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants