Skip to content

feat(spec, service-automation): a packaged flow can ship switched off for an administrator to turn on (defaultActive) - #34793

Merged
os-zhuang merged 14 commits into
mainfrom
claude/project-thread-sjzr94
Nov 17, 2026
Merged

os-zhuang merged 14 commits into
mainfrom
claude/project-thread-sjzr94

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

Fixes #34655

Clause-②: yes (widening) — FlowSchema gains the optional defaultActive boolean. Before, any flow declaring it was refused as an unknown key (strictObject); now a packaged flow that declares it registers. A flow authored in the environment that declares it is still refused, now by the engine with a sentence naming its status as its switch. Nothing that registered before is refused.
Metadata-protocol: added
Skills-docs: updated here — skills/objectstack-automation/SKILL.md (one paragraph under "A flow an installed package ships"), evals/flows-triggers-approvals.json (eval id 24)

维护者速读

  • 改了什么:flow 新增作者可写的 defaultActive(紧挨 status,可选,缺省为开)。打包 flow 写 defaultActive: false 后,新装时不挂触发器、不运行,/automation/_status 报 enabled:false;管理员用现有开关(toggle / Studio 的 Enabled)打开即写一行账本,这行优先于包默认,重启、升级、重装都保持。环境自写 flow 写这个键在注册时被拒(它的开关是 status);克隆去掉这个键;unmanaged 安装把 false 抄成 status:'obsolete'。ADR-0126 §4 加修订注;automation skill 加一段说明和 eval 24。
  • 为什么改:hotcrm#2558「接受报价起草合同」要作为默认关闭、管理员可开的打包 flow 发出,今天做不到:没有账本行就是开,status:'obsolete' 又会永久关死。
  • 风险与回滚:加法,没写这个键的 flow 行为不变(空账本仍然什么都不改)。默认是读时取的,安装时不写行,所以「有行=管理员选过」不变;包升级改默认只影响没人动过开关的安装;本轮(L2 S4)补上 override 被元数据保存激活后、基础包热升级翻转默认时的漏读,每次 metadata:reloaded 重新读一次包默认。回滚即 revert 本 PR(已写 defaultActive 的包会回到「未知键被拒」)。
  • 先看:packages/services/service-automation/src/engine.ts(shipsOff 接线、refuseUnpackagedDefaultActive、refreshPackagedFlowDefaults)、packages/services/service-automation/src/flow-activation-projection.ts(无行时读包默认)、packages/services/service-automation/src/plugin.ts(resyncFlowsFromProtocol 每次重同步调用刷新)。
  • 两分钟验证:pnpm --filter @objectstack/service-automation exec vitest run src/flow-default-active-34655.test.ts,预期 34 条全过。
  • 需要你做的:批准本 PR(碰 packages/spec/src、docs/adr 与 skills/,契约复审记录由席位路由)。

What changes

A packaged flow can ship switched off, for an administrator to turn on.

  • packages/spec/src/automation/flow.zod.ts: FlowSchema.defaultActive, z.boolean().optional(), next to status, with no materialized default, so a flow that does not declare it parses exactly as before. The JSDoc and describe say what it is (the default of the packaged-flow switch), that a ledger row wins over it, that status stays the author's, and that only a packaged flow may carry it.
  • packages/services/service-automation/src/flow-activation-projection.ts: has(key) is now the row that decides for the flow (rowVerdict, the old body, answering undefined where it used to answer false for "no row decides") or else the new shipsOff reader. offByDefault(key) names the "no row, shipped off" case for the refusal log. hasShared became sharedRowVerdict the same way.
  • packages/services/service-automation/src/engine.ts: the projection's shipsOff reader is packagedFlowDefault(key) === false, the declaration of the PACKAGE's own body for the version installed now: the armed body when the loader's body is armed, else the loader's body for the slot's package (new setPackagedFlowDefaultSource; seat ruling on L2 S2, option (a)), asked once per armed body and cached against it, so isFlowEnabled never reads the loader's set; the cache is replaced at every metadata:reloaded re-sync by refreshPackagedFlowDefaults() (new public method, L2 S4), which re-arms or disarms each held flow whose armed body is not the loader's own when its answer moved, because the re-sync does not re-register every body. So an upgrade that changes the declaration moves only an installation nobody switched, and a declared .custom override does not move the default in either direction. refuseUnpackagedDefaultActive is a member of the one registration check list (v18 stored preview: os migrate meta --stored still leaves out two families the v18 doors refuse — page components binding the retired API data source, and registerFlow's other refusals #23317), judged by name: does ANY package's loader set hold it (isShippedFlowName, the loader's own per-package answer, so a name two packages ship keeps the key): registerFlow throws it (the automation write doors answer VALIDATION_FAILED / 400, registerAndSaveFlow), dryRun refuses the draft, and the stored pass (canonicalizeStoredFlow().todos) lists a stored row at flows[0].defaultActive. The metadata door (PUT /api/v1/meta/flow/:name) parses without registering, so it stores such a row; the engine refuses to arm it. describeDisabledFlow's log line names the shipped default when no row decides; the isFlowEnabled and hydrateFlowActivations docblocks say what the default and an active row now do.
  • packages/services/service-automation/src/plugin.ts, flow-registration-checks.ts, index.ts: packagedFlowDefaultReader, over the protocol's shippedArtifactsOf at question time (the read packagedFlowReader already makes for a package's own question), attached at init beside setPackagedFlowSource; resyncFlowsFromProtocol calls refreshPackagedFlowDefaults() after its loop (L2 S4); the check list gains the member; PackagedFlowDefaultSource is exported beside PackagedFlowSource.
  • packages/services/service-automation/src/flow-definitions.ts (hydrateFlowActivations only): a row switching a flow ON is now applied through activateFlowTrigger (idempotent, the same gate) and its callers re-judged. Without it, a host whose trigger was registered before the pull would keep a shipped-off flow unarmed after a restart even though an administrator switched it on. The stock boot order (trigger plugins at kernel:ready) armed it anyway.
  • packages/runtime/src/flow-clone.ts: FLOW_CLONE_DROPPED_KEYS names defaultActive. The copy is a writable package's flow, switched by its status, which the clone already writes obsolete.
  • packages/metadata-protocol/src/package-unmanaged-install.ts: copyUnmanagedFlowSwitch: an unmanaged install copies defaultActive: false as status: 'obsolete' (a status that already disarms is kept) and drops the key; true is dropped. A non-boolean is handed on for the save door to refuse.
  • packages/spec/src/contracts/automation-service.ts (toggleFlow JSDoc) and packages/spec/src/api/automation-api.zod.ts (module JSDoc; regenerated content/docs/references/api/automation-api.mdx): N1 of the contract review on fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810 (record 6952048597), carried here at the seat's request because half A edits packages/spec. The toggle contract prose now names the 409 for switching ON a packaged flow whose own status disables it (landed with fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810, merged into this branch), and that switching such a flow off is accepted. Prose only: no schema, describe, export or error code moves.
  • docs/adr/0126-packaged-metadata-customization-model.md: an amendment note under §4 and a Status-line entry. The amended sentence is not rewritten.
  • skills/objectstack-automation/SKILL.md (the card's "Document it in the automation skill"): one paragraph under "A flow an installed package ships": defaultActive: false ships the flow unarmed (_status enabled: false) until an administrator turns the switch on, that choice outlives restart / upgrade / reinstall, status: 'obsolete' disarms past the switch, and a flow authored in the deployment is refused the key. evals/flows-triggers-approvals.json gains eval 24. scripts/check-skills-token-ratchet.mjs: the file's ceiling 6903 → 6992, the measured addition (+357 priced bytes, nothing removed), under the standing ruling 「A:先削重复,余额按实测提高」 (record 6513306068); no restatement of the switch, its default or status as a switch was found to pay down, as the ceiling's note says.
  • packages/spec/liveness/flow.json (defaultActive: live), regenerated authorable-surface, content/docs/references/**, liveness/state-counts/flow.md; .changeset/34655-flow-default-active.md (minor spec and service-automation, patch runtime and metadata-protocol).

Tests

  • packages/services/service-automation/src/flow-default-active-34655.test.ts (34): fresh install neither arms nor runs it (FLOW_DISABLED, the switched-off sentence, _status enabled:false); the log line names the shipped default; toggle on writes { active: true }, arms and runs; survives a restart in the stock boot order and on a host whose trigger was registered first; survives an uninstall (a boot without the package leaves the row) and a reinstall; survives an upgrade that changes the body; a flow switched back off stays off when the next version ships it on; with no row, an upgrade that changes the declaration moves the installation both ways; CONTROL true and absent ship on; an obsolete flow a row switches on still does not arm; a packaged caller of a shipped-off subflow is held unarmed until the subflow is switched on; defaultActive: false and true on an environment flow are refused with the exact sentence and nothing is filed (the code and status are the write door's, as for every registerFlow refusal); CONTROL: the same environment flow without the key runs; the key is judged by name, so a package arm for a name the loader's set does not hold is refused and a name it holds keeps the key under any arm; a dry run of an environment draft with the key throws what registration throws; the stored pass lists such a row at flows[0].defaultActive and none without it; a package that ships the flow off is not armed by an override that omits the key, and one that ships it on is not switched off by an override writing false (the administrator's switch works in both); packagedFlowDefaultReader answers the named package's own body and none for a missing body, a non-boolean, or no protocol. L2 S4 / N13 (six cases): on the engine, refreshPackagedFlowDefaults() moves a held override with no row both ways after the loader's answer flips, a CONTROL where a ledger row and a loader-armed body are not moved, and a body rollbackFlow puts back reads the set installed now; on the automation plugin (LiteKernel, a protocol stand-in serving the declared override in the base's slot, no ledger), an override armed by the metadata-mutation sync (no reload) is not re-registered by the next metadata:reloaded, and a hot upgrade flipping the base's defaultActive still moves it: on to off stops it (unbound, FLOW_DISABLED), off to on starts it (bound, runs), with a CONTROL reload that leaves the declaration as it was and moves nothing.
  • packages/spec/src/automation/flow-default-active-34655.test.ts (3): accepts both booleans, absent stays absent, a non-boolean is refused at the key.
  • packages/runtime/src/flow-clone-default-active-34655.test.ts (2) and packages/metadata-protocol/src/package-unmanaged-flow-switch-34655.test.ts (5).
  • Two existing tests account for the new key: packages/spec/src/system/metadata-form-zod-reconciliation.test.ts gains a root ledger row for flow.defaultActive (the flow form saves only environment-authored flows, where the engine refuses the key, and its meaning lives in its absence, like skill.mcpPrompt), and packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts moves flow's served top-level count 23 → 24. No other existing test changed.

Acceptance notes

  • Read-time default, not an install-time row (seat ruling on the area thread). A row written at install could not be told from an administrator's choice, so an upgrade that turns the default on would either override an administrator's off or never reach an installation nobody touched.
  • Only packaged flows (area agreed, for the L2 and the seat to read): the predicate is by name, with no arm exception since the L2 round: does any package's loader set hold the name (isShippedFlowName). It asks the one owner first (the toggle door's isPackagedFlow), then each package that may hold the name, per package (packagedFlowSlotOwner): the packages whose slots hold it now and the package the body names itself as. The stamp only picks which package to ask; a stamp naming a package that ships no such flow is still refused (pinned). A .custom override is served at the base's name, which the loader's set holds (ADR-0146 D9.3), so it is not refused; the default it carries is not read (seat ruling, S2 option (a)).
  • Reinstall: the activation store has no delete (packages/core/src/utils/metadata-activation-store.ts, "deliberately has no delete"), and nothing on the uninstall path writes the ledger (read). The engine half is now pinned: a boot without the package leaves the row and the reinstall arms the flow.
  • "On" rows that do not count: a row naming no package that switches a flow ON is not recorded by the projection, and an ON row of a package that no longer holds the name is skipped, so neither overrides a ship-off default (the matching OFF rows still switch the flow off). Both fail closed; the JSDoc and the ADR note now say so. Not changed here.
  • Release floor: a package declaring the key needs a platform at or above this release; an older runtime refuses the flow as an unknown key. Said in the changeset.
  • Unmanaged import answer (L2 N7): the answer does not list a flow whose defaultActive: false was copied as status: 'obsolete'. Accepted as is: the copy's status says it, and listing it is new answer surface outside the card.
  • No reader attached (L2 N8): a host that composes the engine without setPackagedFlowDefaultSource reads the default only off an armed package body, so while a .custom override is armed a flow its package ships off runs (fail-open). Such an engine cannot see the package's body, and an unknown default treated as on is how every packaged flow behaved before this key. The automation plugin always attaches the reader; the changeset says so.
  • The reader's protocol read (L2 N8): packagedFlowDefaultReader reaches the protocol's shippedArtifactsOf by duck type, as packagedFlowReader already does. It is now pinned through the real protocol: the first-boot-pull integration harness (ObjectKernel + ObjectQLPlugin + SqlDriver + AutomationServicePlugin) boots a base shipping defaultActive: false with a stored override that omits the key; the reader answers false for the base and nothing for the pair, the override is armed and reported enabled: false, and a record change fires nothing.
  • Half B (the toggle door for a status-disarmed flow) landed as fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810 and is merged into this branch from main, as is 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; this PR does not touch toggleFlow or packages/runtime/src/domains/automation.ts.
  • L2 S4 fix direction (delta record 6949383615 offered two): the cache is dropped at every re-sync and the held non-loader flows go back through the arming gate, rather than skipping the mutation-mark skip for a non-loader winner. The review notes N13 rides with the cache drop, and the drop also covers the second stock path the review names (a re-registration that throws keeps the old body), which the skip change would not. Cost per reload: one reader call per held flow whose armed body is not the loader's own. N14 (an unstamped first or third holder registered through the engine API) is left as the review allowed: registry-fed bodies are stamped.
  • Changed lines after this round's merges: the PR's net diff against main stays inside the claimed surface plus claim amendment 6953980143 (the two spec JSDoc paths for fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810's N1).
  • CI at 1074c040, seat 3 fix round (no code change): Test Core (2/10) failed one case, packages/spec/scripts/build-schemas-check-mode.anchor.test.ts "still fails offline on a deletion the anchor records and this build cannot account for", with Hook timed out in 10000ms in its beforeEach (line 69: fixture file writes plus git add/commit/rev-parse/update-ref in the sandbox). Judged a flake: the same hook passed for the file's other 14 cases in that run; the file's inputs (packages/spec/authorable-surface/**, authorable-surface.base.json, packages/spec/scripts/**, root scripts/**) are byte-identical to 5fe7b810, whose Test Core shards were all green, and 1074c040 touched only a JSDoc comment in packages/spec. The failed jobs of run 44082971653 are re-run once; a second failure is real.

Verification

Head 34181ed124: this round (below) on top of 208c272ef1 (a merge of origin/main c4c0794, then the regenerated automation API reference), the automation-skill commit and the two existing-test updates (bef53a4790, CI all green), then the contract-review rework (5fe7b810c4) and its delta (1074c040a7).

L2 delta 6949383615 fix round (S4, N12, N13) and #34810's N1, on 34181ed
  • Commits: 96a99d06d8 merge of origin/main (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); 05656d74f1 the S4 fix and its pins; 536d5a1c12 the spec prose (fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810 N1) and the changeset sentence; 198cdf7bf6 merge of origin/main (fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810 landed); 34181ed124 the regenerated automation API reference, and authorable-surface/api.json regenerated after the merge (the driver had deferred it; it differs from main's only by this PR's own api/CreateFlowRequest:defaultActive row).
  • S4: AutomationEngine.refreshPackagedFlowDefaults(); the plugin's resyncFlowsFromProtocol calls it after its loop on every metadata:reloaded. The packagedFlowDefaults and packagedFlowDefault docblocks say when the default is read again. The changeset names the method as public API, since a host composing the engine itself must call it after the installed packages change.
  • N13: covered by the same drop (the map a rolled-back body was cached in is replaced), pinned. N12: this body counts 34 for the card's test file (28 before this round plus six).
  • Ablation (scripts/ablation-replace.mjs, anchor this.engine.refreshPackagedFlowDefaults(); in plugin.ts deleted, x1 to x0, blob 02ab3709 to 1e49c39b): 2 failed / 32 passed. The two flip pins fail (expected true to be false on to off, expected false to be true off to on); the CONTROL reload stays green. Restored: blob equals HEAD (02ab3709), git diff HEAD empty. The test imports ./plugin.js from source, so no build is involved.
  • service-automation: tsc --noEmit and check:test-typecheck exit 0; full suite Test Files 288 passed (288), Tests 4174 passed (4174) at 198cdf7bf6 (4167 at 536d5a1c12, before fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810 merged). flow-default-active-34655.test.ts 34/34.
  • runtime targeted (flow-clone-default-active-34655, automation-flow-clone, automation-toggle-caller, automation-addressed-route, automation-toggle-deny-message, automation-toggle-unknown-flow): 6 files, 111/111. Spec typecheck exit 0; spec check:generated 14/14 and check:docs exit 0 at 34181ed124 (the spec dist was built after the merge; gen:docs regenerated automation-api.mdx).
  • dispatch-gates --commands at 198cdf7bf6: 149 families, each run with its exit code captured before any pipe; --ran: 149 accounted for, 146 run, 3 NOT-MEASURED. NOT MEASURED (declared narrowing, CI runs them): check:skill-examples and check:dual-build-cjs-loads (exit 3, they need built packages outside the closure: client, client-react and 30 more), check:type-check-debt (exit 3, its closure build never got the shared verify lock behind a long dogfood run). This round changed no skill file and no package's typecheck wiring. check:docs and check:generated first exited 1 (the reference page above), and both exit 0 after the regeneration. check-nul-bytes exit 0. overlap-check at 34181ed124: clean against origin/main 46991d0 and the two open PRs that share files.
  • CI on 34181ed124: in progress when this was written.
Contract review delta (record 6947617913 on 5fe7b81)
  • S3 (a name two packages ship refused the key): the check asks whether any package's loader set holds the name (isShippedFlowName), not whether it has one owner. Pinned: both holders, a re-sync / hot upgrade re-registration and a third holder register with the key, true and false; a dry run and the stored pass agree; CONTROL: a name no package ships is still refused, whatever package the body names itself as.
  • N8: the changeset names AutomationEngine.setPackagedFlowDefaultSource and PackagedFlowDefaultSource as public additions and states the fail-open behaviour without a reader, with the reason; the duck-typed protocol read is pinned through the real protocol (Acceptance notes).
  • N9: the reader is asked once per armed body (packagedFlowDefaults, a WeakMap keyed by the body registerFlow armed); a re-registration (the metadata:reloaded re-sync after an upgrade re-registers the winner) asks again. Pinned: one call across repeated state reads and runs, one more after a re-registration.
  • N10: the 维护者速读 count is 28. N11: the FlowSchema JSDoc sentence reads as sentences.
  • Ablations (each restored, git diff HEAD empty): the check asks the one owner only → 2 failed / 26 passed (the co-held registrations, the dry run and stored pass); the cache read removed → 1 failed / 27 passed (the once-per-body pin); the reader reading a key the body does not carry → the real-protocol pin fails.
  • service-automation full suite: Test Files 288 passed (288), Tests 4135 passed (4135). tsc --noEmit exit 0. Spec check:generated 14/14 after a spec build. 20 affected gates (ADR anchors and links, docblock and scripts symbol anchors, liveness, test-source alias, issue citations, the changeset gates, docs transcript and corpus claim drift, engine double contract, optional error sink, undeclared dep imports, type-check coverage, startup registry, doc authoring, skill examples): all exit 0.
Contract review rework (record 6946901031 on bef53a4)
  • S1 (the refusal outside the one check list): fixed as the area ruled. refuseUnpackagedDefaultActive is a member of registrationChecks, judged by name; dryRun refuses an environment draft with the key and the stored pass lists a stored row, both pinned. The changeset names which doors answer 400 and what the metadata door does.
  • S2 (an override moves the default): seat ruling (a), the default is the package's own body's. packagedFlowDefault + packagedFlowDefaultReader; the JSDoc and the ADR note say so; both directions pinned.
  • N1 hydrate docblock updated. N2 the two "on" rows that do not count are in the JSDoc and the ADR note. N3 reinstall pinned at the engine. N4 gone: the check no longer trusts an arm. N5 release floor in the changeset. N6 the owed-skill note removed. N7 accepted as is (Acceptance notes).
  • Ablations (each restored, git diff HEAD empty): the list member removed → 5 failed / 19 passed (both environment refusals, the by-name refusal, the dry run, the stored pass); the default read off the armed body whatever its arm → 3 failed / 21 passed (both override directions and the by-name CONTROL).
  • service-automation full suite: 276 files passed; 12 failed to collect because the spec dist was rebuilt mid-run, and re-run alone: 12 files, 110 tests passed. tsc --noEmit exit 0. Spec check:generated 14/14 after a spec build. 23 affected gates (ADR anchors and links, docblock and scripts symbol anchors, liveness, error-code provenance, test-source alias, issue citations, the changeset gates, docs transcript drift, engine double contract, undeclared dep imports, …): all exit 0.
Since 208c272 (the skill paragraph, the form ledger row, the served-property count)
  • CI on 208c272 was red in Test Core (2/8) (spec metadata-form-zod-reconciliation.test.ts: flow.(root): accepted by the Zod but unauthorable in the form … expected [ 'defaultActive' ] to deeply equal []) and Test Core (6/8) (metadata-protocol protocol.meta-types-degenerate-derivation.test.ts: flow served 24, pinned 23). Both are the new key, accounted for in the next commit: the reconciliation file 76/76, the derivation file 18/18; the full metadata-protocol suite had that one failure and 23060 passed before the fix.
  • PR-body guards was red on check:closing-target-claim (the card's claim named half B's branch); the seat posted a claim naming this branch.
  • Gates the new files add, and the skill gates re-run: 39 commands (check-skills-token-ratchet with --self-test, check:skill-docs, check:skill-examples, check:skill-refs, check:skill-identifier-liveness, check:skill-links, check:skill-compatibility, check:skill-frame-sync, check:issue-citations, the changeset gates, …): all exit 0. check:skill-examples first exited 3 on a stale spec dist, then 0 after building spec (347 prose examples type-check). Record appended to the gates file below.
Premise on origin/main f6f5b50

FlowSchema declares only status (flow.zod.ts, status: z.enum(['draft', 'active', 'obsolete', 'invalid'])); no default-active key anywhere in packages/spec/src. isFlowEnabled composes flowStatusDisabled and flowLedgerDisabled.has(name), and the projection answered false (on) with no row. toggleFlow writes active: enabled and the projection keeps the holder's row in either state. Read in code; the card's fresh-install reading is hotcrm's, on 18.5.0.

Packages
  • pnpm --filter @objectstack/service-automation exec vitest run --maxWorkers=3 (at eb5a27d plus the engine edits): Test Files 288 passed (288), Tests 4121 passed (4121); typecheck exit 0.
  • src/flow-default-active-34655.test.ts 34/34 at the final head; src/flow-declared-override-first-boot-pull.integration.test.ts 28/28 (one new real-protocol pin).
  • spec src/automation/flow-default-active-34655.test.ts 3/3; runtime src/flow-clone-default-active-34655.test.ts + src/domains/automation-flow-clone.test.ts 24/24; metadata-protocol src/package-unmanaged-flow-switch-34655.test.ts + src/package-unmanaged-install.test.ts 103/103.
  • spec check:generated exit 0 at the final head (14/14); check:test-typecheck OK (needs NODE_OPTIONS=--max-old-space-size=8192 in this container, else tsc runs out of heap).
Ablations (scripts/ablation-replace.mjs, each restored, git diff HEAD empty)
  • shipsOff reader answers false → 5 failed / 10 passed (fresh install, the log line, the upgrade both ways, the subflow caller, the package-arm CONTROL).
  • the refuseUnpackagedDefaultActive call removed → 2 failed / 13 passed (both environment refusals).
  • the hydrate's activateFlowTrigger removed → 1 failed / 14 passed (restart on a host whose trigger registered first).
  • defaultActive kept on a clone → 1 failed / 1 passed.
  • copyUnmanagedFlowSwitch not applied → 2 failed / 3 passed.

Log: /mnt/project-files/objectstack-seat2/34655A-ablation.log.

Gates

node scripts/pm/dispatch-gates.mjs --commands: 122 families, each run with its exit captured before any pipe; --ran: 122 derived famil(ies) accounted for — 122 run, 0 NOT-MEASURED. First pass: check-plugin-teardown-shape --self-test, check:skill-examples and check:dual-build-cjs-loads exit 3 (shallow clone; unbuilt packages), re-run after git fetch --unshallow and a build: exit 0. check:error-code-provenance exit 1 on the first draft's VALIDATION_FAILED stamp in service-automation and check:test-source-alias exit 1 on the new unmanaged test: fixed (the refusal is a plain registration Error; the test preloads lint), both exit 0. Record: /mnt/project-files/objectstack-seat2/34655A-gates-ran.txt.

git merge-tree against the in-flight neighbours

git merge-tree --write-tree --name-only of 208c272 with:

🤖 Generated with Claude Code

https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX

Claim note (seat 3, o3-J): #34793's branch is named on its own Claim: line on #34655 (half-A claim after takeover 6948719649), which the closing-target guard reads.

… (defaultActive: false)

FlowSchema gains the optional `defaultActive`. With no activation-ledger
row, a packaged flow declaring `false` is not armed and does not run; an
administrator's toggle writes a row, which wins over the default across
restarts and upgrades. The default is read at the consult point (the
projection's `shipsOff` reader), never written as a row at install.

A flow authored in the environment that declares the key is refused at
registration; a clone drops it; an unmanaged install copies `false` as
`status: 'obsolete'`. The ledger hydrate arms a flow a row switches on.
ADR-0126 §4 carries an amendment note.

Claude-Session: https://claude.ai/code/session_01ADHkmPTavMbXsRBw7f7fCb
Co-authored-by: Claude <noreply@anthropic.com>
…or defaultActive

Claude-Session: https://claude.ai/code/session_01ADHkmPTavMbXsRBw7f7fCb
Co-authored-by: Claude <noreply@anthropic.com>
…ation refusal; preload lint in the unmanaged test

Claude-Session: https://claude.ai/code/session_01ADHkmPTavMbXsRBw7f7fCb
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 4 package(s): @objectstack/metadata-protocol, @objectstack/runtime, @objectstack/service-automation, @objectstack/spec, touching 46 documentable anchor(s). ⚠️ 6 changed file(s) yielded no anchor (packages/services/service-automation/src/index.ts, packages/spec/authorable-surface/api.json, packages/spec/authorable-surface/automation.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

16 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 62fbbeb76760373c31d280a8900fd831ade7ec02.

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

What this run could not see
  • 6 changed file(s) yielded no anchor (packages/services/service-automation/src/index.ts, packages/spec/authorable-surface/api.json, packages/spec/authorable-surface/automation.json, …) — pages documenting those are invisible to this run
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • 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 — 178 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 62fbbeb76760373c31d280a8900fd831ade7ec02 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 424fc9194a6c5a24b176d51c1ddfe79d59af447f — the merge of head 34181ed12496f3fd49db092367fc5015f31ae284 into base 62fbbeb76760373c31d280a8900fd831ade7ec02, 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 424fc9194a6c5a24b176d51c1ddfe79d59af447f && git checkout 424fc9194a6c5a24b176d51c1ddfe79d59af447f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 62fbbeb76760373c31d280a8900fd831ade7ec02 34181ed12496f3fd49db092367fc5015f31ae284 && git checkout -B drift-repro 62fbbeb76760373c31d280a8900fd831ade7ec02 && git merge --no-ff 34181ed12496f3fd49db092367fc5015f31ae284

node scripts/docs-audit/affected-docs.mjs --json 62fbbeb76760373c31d280a8900fd831ade7ec02

⚠️ 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 62fbbeb76760373c31d280a8900fd831ade7ec02 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 17, 2026
…utomation skill

The card's Done-when asks for it in the automation skill, so it lands in the
same PR: one paragraph under "A flow an installed package ships" and eval 24.
The token ceiling of the skill moves by the measured addition (+89), with
nothing to pay down; the changeset's Skills-docs line reads "updated here".

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmPTavMbXsRBw7f7fCb
…e` in the form ledger and the served-property count

The flow form does not offer `defaultActive`: every flow the form saves is
authored in the environment, where the engine refuses the key, and its
meaning lives in its absence. A root ledger row says so. `/meta/types`
serves flow 24 top-level properties, one more for the key.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmPTavMbXsRBw7f7fCb
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head bef53a4 · 2026-11-17T11:25Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: bef53a4790a305647b5313f79a80200cddb945ca
Local-runs: none
Scope: packages/spec/src/automation/flow.zod.ts, docs/adr/0126-packaged-metadata-customization-model.md, skills/objectstack-automation/SKILL.md, skills/objectstack-automation/evals/flows-triggers-approvals.json + packages/services/service-automation/src/engine.ts, packages/services/service-automation/src/flow-activation-projection.ts, packages/services/service-automation/src/flow-definitions.ts, packages/runtime/src/flow-clone.ts, packages/metadata-protocol/src/package-unmanaged-install.ts, packages/spec/liveness/flow.json, scripts/check-skills-token-ratchet.mjs
Security-touching: yes

The skill paragraph, the schema jsdoc and the ADR note teach who arms a packaged flow and through which gated door (an administrator, the activation switch, the ledger row that outranks the package's declaration), so the low-risk arm does not apply. The change itself moves toward less automatic arming: a packaged flow already ran on install with no admin step (ADR-0126 §4, absence of a row = active, unchanged on main); this PR adds only the ability to ship one off. The skill states the pre-existing default in the paragraph above the new one (the toggle with enabled: false = off for this deployment).

Read: card #34655 body and its ten comments, PR #34793 body, file list and net diff against merge-base c4c0794dc0, the check-runs on the head, the cited code at the head and on main. main has not moved on any path in Scope since the merge-base. Not read: any L1 result.

Check-runs on the head: no failure. Concluded success: PR-body guards (both runs), Governed Surface Queue Guard, Spec property liveness, Check Changeset (first run), Check Documentation Links, Flag docs affected by code changes, Lint · ESLint, Lint · docs and code guards, Lint · repo and tooling gates, Lint · CI, release and engine gates, Lint · PM dispatch-gates, Lint · scoped · tooling self-tests, Lint · scoped · slot lookup and corpus, Type Check · source gates, Type Check · debt ledger, Dogfood Regression Gate, Build UI Deps, both shard plans, filter, Check PR Size, Auto Label. PENDING, so not verdicts: Test Core 1/10 through 10/10, Test UI 1/16 through 16/16, Build Core, Build Docs, Build and E2E UI, Live E2E UI, Type Check · workspace, Type Check · consumer gates, Type Check UI, Lint · scoped · query-options erasure, and the second Check Changeset run. The two tests that were red on the earlier head (spec form reconciliation, metadata-protocol served-count) sit in the pending Test Core shards: this record does not vouch for them.

① Derived judgments

  • FlowSchema.defaultActive (z.boolean().optional(), no materialised default): accept-set widened by one optional top-level key; absent stays absent. Right. The shipped name matches the seat's record on the card (claim amendment 6944001902: defaultActive, top level beside status, optional, absent = on).
  • Before: any flow carrying the key was refused by the strict parse. After: parse accepts it everywhere; the engine refuses it at registerFlow on a runtime arm whose name the loader's set does not hold. A package or override arm, and a runtime body under a name a package ships, keep it. Right as a widening; nothing that registered before is refused.
  • The split by door, as read in the tree:
    • spec parse: accepts for every flow (provenance is not the parse's to know). Right, and the describe and jsdoc both say the key is for packaged flows only and that an environment flow may not declare it.
    • automation write doors (POST /, PUT /:name, clone) via registerAndSaveFlow: engine first, store second, so an environment flow with the key answers 400 and nothing is stored. Right.
    • clone: FLOW_CLONE_DROPPED_KEYS drops the key before the copy is registered; the copy is written obsolete by the clone as before. Right.
    • unmanaged install: copyUnmanagedFlowSwitch runs in planUnmanagedImport before the save; the key never reaches the save door as a boolean. Right.
    • managed install, boot pull, protocol syncs: arm comes from precedence, which reads the loader's set, never the body's stamps. Right.
    • the metadata save door (PUT /meta/flow/:name): protocol-save.ts canonicalises and schema-gates a flow body and does not call registerFlow, so an environment flow with the key is STORED with a success answer; the mutation sync then refuses to register it (the engine keeps the registration it had, if any) and the boot pull refuses it with a warning. The key never takes effect on an environment flow (the shipsOff reader only reads registered bodies), so the split holds in effect and fails closed, but the door is not the 400 the changeset states. Wrong as stated; see S1.
    • duplicatePackage: not taught the key. A copied row that carries it lands as an environment flow and is refused at registration (fail closed). Not in the diff; noted for the seat.
  • FlowActivationProjection.has: was "a row says off", now "the deciding row, else the package's default". Every consumer that reads it (isFlowEnabled, the arming gate, hydrate, the subflow guards, bindPackagelessActivation) wants exactly the composed answer. Right. offByDefault is additive.
  • GET /automation/_status reports a shipped-off, unswitched flow enabled: false (through isFlowEnabled). Right.
  • hydrateFlowActivations now offers every flow an active row names to the arming gate. Additive, idempotent (boundFlowTriggers short-circuit), still declined by a disarming status. Right.
  • packages/spec/liveness/flow.json row defaultActive: live: the three cited consumers exist at the head and read the key as described; the Spec property liveness check-run concluded success, which is the verdict on the row and the 42/44 state count. The regenerated authorable-surface files are generated output, not reviewed.
  • A package that declares the key is refused as an unknown key by a runtime older than this release (fail closed: the flow does not register). Nothing in the diff says so; N5.

② Semver level

Clause-②: yes (widening) — true to the diff: the strict parse refused the key before, a packaged flow carrying it registers now, and nothing that registered before is refused. No narrowing found in any hunk.

  • @objectstack/spec minor: a new authorable key. Right.
  • @objectstack/service-automation minor: new engine behaviour (a read-time default, a new registration refusal, hydrate arming). Right. FlowActivationProjection is not exported from the package index, so its new reader is not public surface.
  • @objectstack/runtime patch: one more entry in FLOW_CLONE_DROPPED_KEYS; no new export. Right.
  • @objectstack/metadata-protocol patch: copyUnmanagedFlowSwitch is not re-exported from the package index (only unmanagedInstallPostureRefusal is), so no public API is added; the install plan's behaviour moves. Right.
  • Metadata-protocol: added: the served flow type gains one top-level property (the pinned count moves 23 to 24). Right.
  • Skills-docs: updated here: true to the diff. The changeset gate's first run concluded success; its second run is pending.
  • The changeset sentence "the write doors answer VALIDATION_FAILED, 400" is true of the automation doors only; see S1.

③ Boundary flags

  • Dev deviation 1 (hydrate edit in flow-definitions.ts): answered by the seat's claim amendment 6944184550, hydrateFlowActivations only. The diff stays inside it; toggleFlow is untouched.
  • Dev deviation 2 (ADR-0126 amendment note in this PR): answered by the seat ruling in 6944001902.
  • "Only packaged flows, for the L2 and the seat to read" (PR body): the predicate is the toggle door's own (isPackagedFlow) or a package arm. Right. One edge it leaves, N4.
  • "Reinstall: read in code, not run" (PR body): confirmed by reading (metadata-activation-store.ts has no delete, and no uninstall path outside the automation service writes the ledger). The claim is taught as fact in the schema, ADR note, skill and eval with no test behind it; N3.
  • "A row naming no package that switches a flow ON is not recorded" (PR body): confirmed in FlowActivationProjection.delete. Accepted as stated; N2.
  • The os-dev-report on the card (6945950295) names head 208c272ef1, not this head: its file list lacks the skill, the eval, the ratchet script and the two updated tests, and its line_budget reads "n/a (no skills touched)" while this head moves the automation skill's ceiling. The ratchet arithmetic is verified here (④), but the report of record does not cover the head. Escalated to the seat.
  • The PR body contradicts itself: the header line says Skills-docs: updated here and the Acceptance notes still say the skill is "owed as a follow-up card by the seat". N6.
  • Open question escalated to the seat for a ruling: what a declared .custom override does to the package's default (S2).
  • Overlap, checked textually with no checkout:
  • SQL push-down: no new query, id materialisation or in-app join. Hydrate iterates the rows it already listed; the projection is an in-memory read. No finding.
  • Governed surface: docs/adr/** is in the diff, so the PR stays draft until the governed approvers approve; Tier H is the seat's step, and the ADR amendment's acceptance is the maintainer's merge. packages/spec/src/** and skills/** ride the same approval.

④ Design judgment

packages/spec/src/automation/flow.zod.ts against the seat ruling, the ADR note and its first consumer (the engine).
The key, its optionality and its place match the ruling. Each jsdoc sentence was checked against the code: default applied only with no deciding row (true), a row wins in either state (true for the holder's own row; N2), an upgrade that changes the declaration moves only unswitched installations (true: the reader reads the body armed now), status disarms past the switch (true: isFlowEnabled composes the two), registration of an environment flow that declares it is refused (true at registerFlow), clone drops it (true), unmanaged install copies false as obsolete (true). The describe carries the packaged-only split. Holds, subject to S1 and S2.

docs/adr/0126 against §4 as written on main, its first consumer and the code.
Append-only: the Status line gains one entry at its end and §4 gains one quoted note after its last paragraph; no decided sentence is rewritten. The note does change the reach of two decided sentences ("absence of a row means the packaged default — active", "an empty ledger changes nothing anywhere") and says so openly, restating the second as holding for every item that declares no default. That is an amendment, correctly labelled as one, and it is the governed approvers' to accept. It does not touch the ledger's schema, so §4's "zero packages/spec surface" and §9's line on the ledger stand as the note reads them. The first consumer is flow alone and the note limits itself to flow. Every code anchor it cites exists at the head under the cited name.

Precedence, tried against the code:

  • holder's row active: true: rowVerdict answers false, the default is not consulted, the flow is on. Holds across restart (hydrate records the row, then arms it).
  • holder's row active: false: off, whatever the package declares, including a later version that ships it on.
  • no row: follows the armed body. An upgrade flipping the declaration either way re-registers, and the arming gate re-reads the new body.
  • uninstall then reinstall: the row survives (no delete) and decides again.
  • two packages holding one name: each slot is judged by its own package's row, else by its own slot's body (shipsOff is keyed by slot key). A package-less off row still fails closed for both. Holds.
  • clone: key dropped, copy obsolete. Right: the copy is the environment's flow and its switch is status.
  • unmanaged install: false becomes status: 'obsolete' unless the status already disarms; true is dropped and the declared status stands, so a flow shipped on arrives as it always did. Right mapping: obsolete is what Studio's own switch writes, and the admin arms the copy by publishing it active. A non-boolean passes through for the parse to refuse. The copied === item.body identity test keeps the unchanged-item fast path correct when only the lock strip changed the body.
  • status-disarmed and switched on by a row: stays unarmed (the gate). Holds.

skills/objectstack-automation/SKILL.md and its eval against the card's scenario and the spec it teaches.
The paragraph is true to the code sentence by sentence: defaultActive: false beside status: 'active', unarmed with _status enabled: false, the administrator's switch, survival across restart and upgrade (tested) and reinstall (read, N3), obsolete disarming past the switch, the refusal on a deployment-authored flow. "That switch" resolves to the activation switch the preceding paragraph introduces. Eval 24 is the card's own scenario (a crm record-change flow that must arrive off and be switched on per deployment) and its expected output matches the paragraph and the code; the assertions are narrow but true. Ratchet: main's file is 27631 bytes, the head's 27988, a 357-byte addition with nothing removed; less the 20-byte stamp that is 27968 priced bytes, and ceil(27968 / 4) = 6992. The ceiling moves by the measured addition only, and the tooling self-tests check-run concluded success.

Implementing files, sentence by sentence.
flow-activation-projection.ts: rowVerdict is the old has body with its two "no row decides" exits answering undefined instead of false; sharedRowVerdict likewise. Agrees with its docblocks and with the ADR note. flow-definitions.ts: the new loop agrees with its comment. flow-clone.ts and package-unmanaged-install.ts: agree with their docblocks. engine.ts: shipsOff, the refusal and the log line agree with their comments, with the findings below.

S1 (should-fix) — the new refusal sits outside the one registration-check list, so two published contract sentences and one changeset sentence are false for it. refuseUnpackagedDefaultActive is a second call in registerFlow, placed directly above the #23317 comment that says a check "belongs in that list, never as a second call here, or the stored pass would read a flow this method refuses as on protocol". Consequences as read: (a) IAutomationService.dryRun (packages/spec/src/contracts/automation-service.ts: "A definition registerFlow would refuse under the definition's own name: throws what registerFlow throws for it") dry-runs an environment draft that declares the key, and publish then refuses it; (b) canonicalizeStoredFlow().todos ("the stored pass previews registration's whole verdict") does not list a stored environment flow carrying the key, which the boot refuses; (c) such a row can now exist, because PUT /meta/flow/:name stores what the parse accepts without registering, so the changeset's "the write doors answer VALIDATION_FAILED, 400" holds for the automation doors only. All three fail closed. Fix either way: make the refusal a member of the list keyed on the name (isPackagedFlow(name) answers the same question for the dry run and the stored pass), or keep it where it is and say so in the three places (the two engine docblocks, the changeset sentence naming which doors answer 400 and what the metadata door does).

S2 (should-fix) — a declared .custom override decides the package's default, and nothing states or pins it. shipsOff reads this.flows.get(key), the body armed under the key, which for an override arm is the override's body, not the base's. So for a flow the package ships defaultActive: false and nobody has switched: publishing an override that omits the key arms the flow with no administrator turning the switch on, which the describe ("not armed on an installation until an administrator turns it on with the packaged-flow switch") and the skill paragraph both deny; the skill teaches the override path in the paragraph directly above and says the override "keeps ... its one activation switch". The reverse also holds (an override adding false switches an unswitched flow off). Studio's customize path builds the override from the served body and so likely carries the key; a hand-written override per the skill does not. The ADR note's "follows the body armed today" covers it only by implication. Needs the seat's ruling, then either the reader takes the default from the package's own body for an override arm, or the schema jsdoc, the ADR note and the skill say that an override carries its own default, with a test either way.

N1 (nit) — AutomationEngine.hydrateFlowActivations's docblock, which flow-definitions.ts names as the body's contract, still describes only disarming ("Returns the names it disarmed", "an empty ledger ... rebinds nothing"); it does not say an active row now arms its flow.
N2 (nit) — "a row wins in either state" has two unstated exceptions for ON rows, both failing closed: an active row naming no package is not recorded, and an active row of a package that no longer holds the name is skipped, while the matching OFF rows do decide. The PR body names the first; the ADR note and jsdoc name neither.
N3 (nit) — survival across a reinstall is taught in five places and pinned by no test.
N4 (nit) — a body registered under an explicit package arm on an engine with no loader source attached keeps the key, ships off, and cannot be switched on (the toggle door refuses it as not packaged); refuseCustomerAuthoredToggle would then also describe a ledger row that does not exist, since it reads has. Reachable only through the engine API, not through a stock composition.
N5 (nit) — neither the skill nor the changeset says a package using the key needs a platform at or above this release; an older runtime refuses the flow as an unknown key.
N6 (nit) — the PR body's Acceptance note on the skill being owed as a follow-up contradicts its own Skills-docs line; PR-body prose, fixable without moving the head.
N7 (nit) — the unmanaged import's answer lists each stripped lock but does not list a flow whose defaultActive: false was copied as status: 'obsolete', so the admin is not told why a copied flow arrived switched off.

Verdict basis: no finding fails the round. S1 and S2 are open on this head and each earns a delta review of its fix; the nits ride with those fixes or stay as accepted deviations. The pending check-runs named above are not covered.

Implemented-by: claude/project-thread-sjzr94
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

VERDICT: PASS

…eck list, and read the default off the package's own body

Contract review on #34793 (S1, S2 and nits):

- The refusal of `defaultActive` on a flow no package ships is now a member
  of the one registration check list (#23317), judged by name against the
  loader's set, so a dry run refuses such a draft and the stored pass lists
  such a row, as registration refuses it. A package arm for a name the
  loader's set does not hold is refused too.
- The default is the package's: read off the loader's body for the slot's
  package (`setPackagedFlowDefaultSource`, the plugin's
  `packagedFlowDefaultReader` over the protocol's `shippedArtifactsOf`), so a
  declared `.custom` override does not change it in either direction.
- The schema JSDoc, the ADR-0126 note and the changeset say which doors answer
  400, what the metadata door does, the override rule, the two "on" rows that
  do not count, and the release floor; the hydrate docblock says an active row
  arms. Tests pin the dry run, the stored pass, the override both ways, the
  reader and a reinstall.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmPTavMbXsRBw7f7fCb
@github-actions github-actions Bot added size/xl and removed size/l labels Nov 17, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 5fe7b81 · 2026-11-17T12:00Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 5fe7b810c4f1985dbd1a6001b8c9533debe75194
Local-runs: probe — merge-tree of the head against #34654's head to check for overlap
Scope: packages/spec/src/automation/flow.zod.ts, docs/adr/0126-packaged-metadata-customization-model.md, skills/objectstack-automation/SKILL.md, skills/objectstack-automation/evals/flows-triggers-approvals.json + packages/services/service-automation/src/engine.ts, packages/services/service-automation/src/flow-activation-projection.ts, packages/services/service-automation/src/flow-definitions.ts, packages/services/service-automation/src/flow-registration-checks.ts, packages/services/service-automation/src/index.ts, packages/services/service-automation/src/plugin.ts, packages/runtime/src/flow-clone.ts, packages/metadata-protocol/src/package-unmanaged-install.ts, packages/spec/liveness/flow.json, scripts/check-skills-token-ratchet.mjs
Security-touching: yes

The delta's jsdoc, ADR note and changeset teach who arms a packaged flow and what can and cannot move that default (an administrator's ledger row; never a .custom override), so the low-risk arm does not apply. The direction is unchanged from the prior record: a packaged flow already ran on install with no admin step on main; this PR only adds the ability to ship one off, and this delta removes one way (an override omitting the key) a shipped-off flow could arm without the administrator.

DELTA record. Prior at-tier record: comment 6946901031 on head bef53a4790a305647b5313f79a80200cddb945ca (PASS, S1 and S2 open, N1 to N7). Judged here: the one commit between that head and this one (its parent is the reviewed head; nothing from main), 8 files. Read: that record, the dev report 6947406231 on card #34655, the card's rulings, the PR body at this head, the delta diff, the cited code at the head (engine.ts, flow-registration-checks.ts, flow-definitions.ts, flow-slots.ts, flow-precedence.ts, plugin.ts, dry-run.ts, and outside the diff protocol-save.ts, protocol-artifact-lookup.ts, protocol-write-gates.ts, registry-package-addressing.ts), and the check-runs. origin/main as fetched has not moved on any path in Scope since the merge-base c4c0794dc0. Not read: any L1 result. Nothing was built or run; every behavioural statement below is read from the tree.

Check-runs on the head: no failure. Concluded success: PR-body guards (both runs), Check Changeset (both runs), Governed Surface Queue Guard, Spec property liveness, Check Documentation Links, Flag docs affected by code changes, Dogfood Regression Gate, Plan Test Core shards, Plan Test UI shards, filter, Check PR Size, Auto Label. PENDING, so not verdicts: Test Core 1/10 through 10/10, Build Core, Build Docs, Build UI Deps, Live E2E UI, Type Check · workspace, Type Check · consumer gates, Type Check · source gates, Type Check · debt ledger, Lint · ESLint, Lint · docs and code guards, Lint · repo and tooling gates, Lint · CI, release and engine gates, Lint · PM dispatch-gates, Lint · scoped · tooling self-tests, Lint · scoped · slot lookup and corpus, Lint · scoped · query-options erasure. The Test UI shards had not been created yet. The 24 tests of flow-default-active-34655.test.ts, the generated-artefact check for the reworded jsdoc and the type check all sit in pending runs: this record does not vouch for them.

① Derived judgments

  • refuseUnpackagedDefaultActive: was a second call in registerFlow keyed on the arm (runtime arm and name not in the loader's set); is now a member of registrationChecks, keyed on the name alone (isPackagedFlow(flowName)), returning a refusal with one site at flows[0].defaultActive. judgeFlowRegistration (shared by registerFlow and dryRun) throws it; registrationCheckRefusals lists it for canonicalizeStoredFlow().todos. Right for a name one package holds or none holds. Wrong for a name two packages hold; see S3.
  • Accept-set movement of that change: a body under a package or override arm whose name the loader's set does not hold was accepted at the prior head and is refused now (pinned; closes N4). A runtime body under a name a package ships still keeps the key, as before. Neither moves anything relative to main, where every body with the key is refused.
  • The doors, each changeset statement against the code:
    • POST /api/v1/automation, PUT /api/v1/automation/:name answer 400 and store nothing: true, unchanged from the prior record (registerAndSaveFlow, engine first).
    • a dry run refuses the draft: true. dry-run.ts calls judgeFlowRegistration under the definition's own name; pinned against the message registration throws.
    • PUT /api/v1/meta/flow/:name parses without registering and stores the row: true. protocol-save.ts takes only storable from the canonicalizer and never reads todos at the save; registrationCheckRefusals never throws. The engine then refuses to arm it (the sync's registerFlow throws) and records the refusal, which the metadata read serves beside the stored flow.
    • os migrate meta --stored lists it at the key: true through canonicalizeStoredFlow().todos and flowRegistrationTodo; the site path is pinned. A stored .custom override row under a held name is not listed (by-name pass), which is right.
    • No door is left that accepts the key on a non-packaged flow and has it take effect: the default is read only for a name the loader's set holds. The metadata door still answers success for a row the engine will not arm; that is now stated in the changeset, the engine docblock and the PR body, and it is the same shape every other registration check has at that door. duplicatePackage is as the prior record left it (not in the diff, fails closed at registration).
  • shipsOff: was this.flows.get(key)?.defaultActive === false (the armed body, whatever its arm); is now packagedFlowDefault(key) === false. For a package arm the answer is the same body as before. For an override or runtime arm under a held name it is the loader's body for the slot's package, through packagedFlowDefaultSource. For a name no package holds it is none. Right against the seat's ruling (a).
  • What the reader reads: packagedFlowDefaultReader asks the protocol's shippedArtifactsOf('flow', name) and keeps the artifact whose _packageId equals the package asked for. That set is built from SchemaRegistry.getArtifactItem, which answers code-artifact entries only and skips tenant-authored and sys_metadata rows, so a stored override row is never in it. A non-boolean answers none. Right.
  • Reader absent, protocol unreachable, method missing, or no body of that package: the answer is none, so the flow is ON. With the loader's own body armed this path is not taken (the armed body answers). It is taken only while an override or a runtime body is armed under a held name, and there it fails open: such a flow is armed even when the package ships it off and even when the override itself writes false. In the stock composition the reader is attached at init beside setPackagedFlowSource and the owner and the body come from the same registry lookup, so the two cannot disagree. Stated in the packagedFlowDefault and reader docblocks; not in the changeset. See N8.
  • The admin switch path: toggleFlow, rowVerdict, sharedRowVerdict, FlowActivationProjection and flow-definitions.ts are untouched by the delta. A row is consulted before shipsOff, so the switch decides in both states under either arm; both override tests end by turning the switch and reading the binding.
  • hydrateFlowActivations docblock: now says an active row is offered to the arming gate and that the return value names only what was disarmed. Right, matches the body the prior record read.
  • Liveness, the skill, its eval and the ratchet script are not in the delta. The liveness row's cited consumers still exist under the cited names (flow-activation-projection.ts, engine.ts), and the Spec property liveness run on this head concluded success. The skill paragraph stays true and is now true for an override as well ("unarmed until an administrator turns that switch on").

② Semver level

Clause-②: yes (widening), still true: the delta narrows nothing relative to main. The one acceptance it withdraws (a package arm for an unheld name) existed only inside this PR.

  • @objectstack/spec minor: unchanged; the delta touches jsdoc only, the describe and the schema are as reviewed.
  • @objectstack/service-automation minor: still right, and it now also covers new public surface. The package has one export (., the index). PackagedFlowDefaultSource is exported from the index as a type, and setPackagedFlowDefaultSource is a public method of the exported AutomationEngine. packagedFlowDefaultReader is exported from plugin.ts but not from the index (the index takes only AutomationServicePlugin and createPackageFileLoader from it), and packagedFlowDefault is a private method: neither is published. The changeset names neither published addition; N8.
  • Names: packagedFlowDefault (the default the package declares for a flow) and packagedFlowDefaultReader (the reader the plugin hands the engine for it) say what they do, and sit beside packagedFlowOwner / packagedFlowReader in the same pattern. Quality is the seat's call.
  • @objectstack/runtime patch and @objectstack/metadata-protocol patch: no file of either in the delta. Unchanged.
  • Metadata-protocol: added and Skills-docs: updated here: unchanged and still true. Both Check Changeset runs concluded success on this head.
  • Every changeset sentence the delta adds was checked in ① and is true at this head, with the one unstated exception in S3.

③ Boundary flags

  • Dev deviation, new in report 6947406231: plugin.ts packagedFlowDefaultReader and the engine's setPackagedFlowDefaultSource. Answered by the seat's ruling (a) on S2; the diff stays inside it. Two files join the surface (flow-registration-checks.ts, index.ts) for the list member and the type export; both follow from the two rulings.
  • Dev deviation, skill in this PR: answered by the area ruling the report cites (the card's Done-when). The report of record now names this head and its file list matches the PR's 26 files, which answers the prior record's escalation about the stale report.
  • "No arm exception since the L2 round" (PR body, Acceptance notes): true in the code. It is also the cause of S3.
  • ADR-0126 is governed. The delta's edit is inside the amendment note this PR itself appends: it rewrites two sentences of that not-yet-merged note and adds four. Against main the file's whole change is still add-only: 22 lines added, and one line replaced, the Status line, whose new text is the old line byte for byte with one entry appended at its end. No settled sentence of the ADR is reworded. The amendment's acceptance stays the governed approvers'.
  • Governed surface: docs/adr/**, packages/spec/src/** and skills/** are in the PR, so it stays draft until the governed approvers approve. Tier H is the seat's step.
  • Overlap, textual, no checkout:
  • SQL push-down: no query, no id materialisation, no in-app join over stored rows. The new reader is an in-memory registry read; its cost is N9.
  • PR body: the maintainer summary still says the two-minute check expects 15 tests while the Tests section says 24; N10.

④ Design judgment

packages/spec/src/automation/flow.zod.ts against the rulings and the engine.
The delta adds three statements to the jsdoc. "An on row counts only when it names the package that holds the flow now" is true (FlowActivationProjection, unchanged). "The default is the PACKAGE's: the key is read off the package's own body; a declared .custom override does not change it in either direction; it is switched by the same switch" is true in the stock composition (① above). "A dry run of one, and the stored pass lists a stored one" is true; its wording is N11. The describe still carries the packaged-only split. Holds.

docs/adr/0126 against §4 on main and the code.
Add-only as judged in ③. Each new sentence against the code: the two "on" rows that do not count (true), the default following "the declaration of the package's own body for the version installed now" (true: the armed loader body, else the loader's set), the override not moving it and being switched by the same row (true), and the anchor engine.ts#packagedFlowDefault exists at the head under that name. The note still limits itself to flow.

skills/objectstack-automation/SKILL.md and its eval: not in the delta; re-read against the new behaviour and still true sentence by sentence. The ratchet ceiling is unmoved by the delta.

Implementing files.
flow-registration-checks.ts: the member is last in the list, after the parse-shaped checks, so an earlier refusal is still the one thrown; its comment agrees with the engine docblock. index.ts: one type export, comment true. plugin.ts: the reader agrees with its docblock; it is attached once, at init, beside the owner reader. engine.ts: packagedFlowDefault agrees with its docblock branch by branch, including "with no reader attached, only an armed loader's body answers".

Precedence, re-tried on the changed reader:

  • row present, either state, either arm: the row decides; the default is not consulted.
  • no row, loader's body armed: the armed body's declaration; an upgrade flipping it moves the installation both ways (pinned).
  • no row, override armed, package ships off: off whether the override omits the key or writes true; on once the row says so (pinned for the omitting case).
  • no row, override armed, package ships on: on even when the override writes false (pinned).
  • two packages holding one name, slot armed from its own loader body: the slot's own body answers; an override in a slot asks the reader for the slot's package. Holds for the default. Registration of such a body does not hold; S3.
  • uninstall then reinstall: now pinned at the engine (a boot without the package leaves the row; the reinstall arms from it).

S1: closed
S2: closed
N1: closed
N2: closed
N3: closed
N4: closed
N5: closed
N6: closed
N7: closed

S3 (should-fix) — the by-name judgment refuses a packaged flow that declares defaultActive when two packages hold its name. registerFlow judges under the bare name before the slot is placed, and the check asks isPackagedFlow(bareName). packagedFlowOwner answers none for a bare name once two slots hold it ("a bare name two slots hold has no one owner, and answers none"), because both slots are then filed under qualified keys. So after both holders are registered, any further registration of either one's body that carries the key (a hot upgrade or re-sync with a changed body; a third holder at boot) is refused, with the sentence "was authored in this deployment, not shipped by a package", which is false, and the engine keeps the body it had. true is refused as well as false. The first two registrations at boot pass only because the second is judged while the first slot still sits under the bare key. The same answer reaches dryRun and the stored pass for such a name. At the prior head the package and override arms passed, so this arrives with the delta. It contradicts the jsdoc ("only a flow a package ships"), the changeset and the ADR note, which promise the key to every packaged flow, and nothing pins a two-holder name with the key. Read in the tree (engine.ts packagedFlowOwner, placeFlowSlot; flow-slots.ts add, isShared; flow-slots-per-package.test.ts registers by bare name with a holder arm), not run. Fix direction: the check's question is "does any package's loader set hold a flow of this name", not "does the name have one owner"; ask it that way (the per-package read packagedFlowSlotOwner already exists), and pin a co-held name declaring the key through a second registration.

N8 (nit) — the changeset does not name the two published additions (AutomationEngine.setPackagedFlowDefaultSource, the PackagedFlowDefaultSource type), and does not say what a host that composes its own engine gets without the setter: while an override or a runtime body is armed under a held name, no reader means the flow is on, even when the package ships it off. The engine docblock says it; the release note does not. The reader also reaches the TypeScript-private shippedArtifactsOf by duck type and is pinned only against a mock, so a protocol rename would turn that same case on with no red test.
N9 (nit) — shipsOff is consulted on every isFlowEnabled read with no deciding row. For an override-armed flow each read now calls shippedArtifactsOf, which lists every registered flow in both spellings and every package (shippingPackagesOf). The owner reader already pays the same cost for co-held names, so there is precedent; the loader-armed path is unaffected.
N10 (nit) — the PR body's maintainer summary says the two-minute check expects 15 tests; the file holds 24 at this head and the Tests section says so. PR-body prose, fixable without moving the head.
N11 (nit) — the jsdoc parenthesis "(and a dry run of one, and the stored pass lists a stored one)" does not parse as a sentence; the changeset says the same thing clearly.

Verdict basis: S1 and S2 are fixed as ruled and every changeset sentence the delta adds is true at this head. S3 is open on this head and earns a delta review of its fix; it fails closed, is confined to a name two packages hold, and withdraws nothing main accepts. The nits ride with that fix or stay as accepted deviations. The pending check-runs named above are not covered.

Implemented-by: claude/project-thread-sjzr94
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

VERDICT: PASS

…e`; ask the loader's default once per armed body

L2 delta on 5fe7b81 (S3, N8-N11):

- S3: the registration check asks whether ANY package's loader set holds
  the name (`isShippedFlowName`: the one owner, else each package that may
  hold it, asked per package), so a co-held name's bodies register with the
  key on every re-sync, upgrade and third holder; dry run and the stored
  pass agree. The refusal stands only when no package ships the name.
- N9: the package default reader is asked once per armed body (a WeakMap
  keyed by the body registerFlow armed), not on every isFlowEnabled.
- N8: the changeset names setPackagedFlowDefaultSource and
  PackagedFlowDefaultSource and states the fail-open behaviour without a
  reader; the reader's duck-typed protocol read is pinned through the real
  protocol in the first-boot-pull integration harness.
- N11: FlowSchema JSDoc sentence reworded.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmPTavMbXsRBw7f7fCb
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 1074c04 · 2026-11-17T12:28Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

席位核对

L1 first review (full) · REWORK, paper only · Head-sha: 1074c040a7c1686fadeebe2e9874979747f1de05 · card #34655 half A (Fixes #34655) · read 2026-11-17T13:16Z

There is no earlier L1 record. The contract review passed twice: 6946901031 at bef53a47, then 6947617913 at 5fe7b810 with S3 open. Inputs:

  • half-A claim 6946117692 and amendments 6943849177, 6944001902 and 6944184550;
  • hand-off 6948282082 and takeover 6948719649;
  • the PR body;
  • the net diff from merge-base c4c0794d (27 files, +1120 / -28), with the delta 5fe7b810..1074c040 read line by line;
  • check-runs on this head.

One finding, and it is paper. The code reads correct.

Must-fix

M1. Six paths fall outside half A's claimed surface, and the card has no amendment for them. Amendments 6944001902 and 6944184550 name:

  • flow.zod.ts, flow-activation-projection.ts, engine.ts, flow-clone.ts and package-unmanaged-install.ts;
  • the ADR-0126 note, the automation skill and the generated spec artefacts;
  • tests beside those files, and .changeset/;
  • in flow-definitions.ts, hydrateFlowActivations only.

The diff also moves these:

  • packages/services/service-automation/src/flow-registration-checks.ts (the refusal joins the one check list, which is the L2 S1 fix);
  • packages/services/service-automation/src/plugin.ts and src/index.ts (packagedFlowDefaultReader and the PackagedFlowDefaultSource type export, the L2 S2 fix);
  • scripts/check-skills-token-ratchet.mjs (the automation skill's ceiling 6903 → 6992, with its arithmetic);
  • packages/spec/src/system/metadata-form-zod-reconciliation.test.ts and packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts (existing tests forced by the new key, the same pair feat(spec, runtime, lint): an action body refuses in the caller's language through a declared refusal catalogue #34719's amendment named).

Each one is forced by an L2 fix, by the new key or by a gate. Please post one amendment on #34655 that names them with these reasons. The card thread is gone, so area o3-J posts it. A delta ACCEPT on this same head follows.

Delta 5fe7b810..1074c040 (the L2 6947617913 items)

  • S3 is closed. refuseUnpackagedDefaultActive now asks isShippedFlowName: any package's loader set holding the name, not "one owner". It asks packagedFlowSlotOwner of each candidate package: the slots holding the bare name now, plus the body's own _packageId, which is used only to pick which package to ask. A stamp naming a package that ships no such flow therefore answers no. It is pinned by the new describe "(L2 S3) — a name two packages hold keeps the key" in flow-default-active-34655.test.ts: two holders, a re-sync, a third holder.
  • N8 is closed. The changeset now names AutomationEngine.setPackagedFlowDefaultSource and PackagedFlowDefaultSource as public API. It states the fail-open of an engine composed without a reader, and why. The integration test now reads the package's body through the real protocol (packagedFlowDefaultReader with no mock), with the pair CONTROL answering undefined.
  • N9 is closed. packagedFlowDefault caches the reader's answer per armed body (WeakMap, reset whenever either reader is attached), so isFlowEnabled no longer calls the loader set on every read. The loader-armed path still reads armed.defaultActive directly. The cache relies on each re-sync re-registering a freshly parsed body, as its docblock states. Recorded here for the seat's L2 delta, not as a finding.
  • N10 and N11 are body and jsdoc text, and they now read correctly.

Checklist (the rest holds)

  • Shape: Draft against main. The only closing keyword is Fixes #34655: half A closes the card, and half B (fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810) only Refs it. The body's signed trailer is seat 3's now, and the withdrawn Contract-review-handoff line is gone.
  • Declarations: Clause-②: yes (widening) matches the diff. FlowSchema.defaultActive is a new optional key on a strictObject, so a flow declaring it was refused before. An environment-authored flow is still refused, now with a sentence. Nothing that registered before is refused. Metadata-protocol: added is right. The changeset levels are spec and service-automation minor, runtime and metadata-protocol patch, and they name every published package whose src moved. The skills/** text ships in @objectstack/skills, which is in the same fixed group.
  • Seat rulings (6944001902) are kept:
    • the key is defaultActive, absent means on;
    • the default is read at the consult point and never seeded as a row;
    • the administrator's row wins;
    • an override never changes the package's default (packagedFlowDefault reads the package's own body);
    • the ADR-0126 §4 amendment note is in this PR.
  • The ADR note against the code:
    • an "on" row counts only for the package that holds the flow now;
    • hydrateFlowActivations arms a switched-on flow through activateFlowTrigger, whose gate still declines a flow its status disarms;
    • a clone drops the key (FLOW_CLONE_DROPPED_KEYS);
    • an unmanaged install copies false as status: 'obsolete' (copyUnmanagedFlowSwitch), keeping an obsolete/invalid status that is already there.
      Each claim matches its named symbol.
  • Docs made false: none found. The FlowSchema.defaultActive describe, the regenerated references/automation/flow.mdx and references/api/automation-api.mdx, and the changeset agree with the engine. The half B interplay holds: switching on a status: 'active', defaultActive: false flow is not refused by fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810's status check, and obsolete still is.
  • Skills (skills/**, whole-pack read): one 5-line paragraph in objectstack-automation/SKILL.md. It points at the switch the paragraph before it introduces instead of restating it, so it adds no duplicate teaching to the pack. Eval 24 asks the real authoring question, and its must_contain tokens (defaultActive: false, toggle) are words a correct reply carries. The ratchet moves +89, which is the measured addition only.
  • Tests: flow-default-active-34655.test.ts (new) covers ships-off, the switch on and off, restart and upgrade, override, two holders, the refusal and the dry run. There are also new spec, runtime-clone and unmanaged-install pins, and the integration test reads through the real protocol.
  • Gates at this head: latest attempt per check, 86 runs: success or skipped, none failed. Test Core (2/10), red on its first attempt (anchor.test.ts hook timeout under load, unrelated), is success on its rerun, and so is the Test Core roll-up. PR-body guards, red at the claim-line parse, is success after the body edit.

Owed after this (nothing here readies, queues or arms the PR)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

席位核对

L1 delta review (same head) · ACCEPT · Head-sha: 1074c040a7c1686fadeebe2e9874979747f1de05 · card #34655 half A (Fixes #34655) · read 2026-11-17T13:19Z

Delta from L1 6949131778 (REWORK, paper only) on this same head. The code did not move. The one input that changed is the claim amendment 6949150059 on #34655.

  • M1 is closed. The amendment names all six paths L1 listed: flow-registration-checks.ts, plugin.ts, src/index.ts, scripts/check-skills-token-ratchet.mjs, metadata-form-zod-reconciliation.test.ts and protocol.meta-types-degenerate-derivation.test.ts. Each carries the forcing reason L1 gave (the L2 S1 and S2 fixes, the token-ratchet ruling record 6513306068, and the two gate-forced tests). It adds no other path. The net diff from merge-base c4c0794d now sits inside the claimed surface.
  • Gates at this head: latest attempt per check is success or skipped. PR-body guards has one red attempt followed by a later attempt that is success.
  • No new findings. The rest of the L1 checklist from 6949131778 still holds.

Owed, for the seat: the L2 delta at CONTRACT_REVIEW_TIER for the 5fe7b810..1074c040 delta (L2 S3 open at 6947617913; L1 read it closed). Please also check the packagedFlowDefaults WeakMap cache assumption there. This is Tier H (governed skills/** and the ADR-0126 note), so a Tier H record for os-zhuang is owed before anything readies it. 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: 1074c040a7c1686fadeebe2e9874979747f1de05
Local-runs: none
Scope: packages/spec/src/automation/flow.zod.ts, docs/adr/0126-packaged-metadata-customization-model.md, skills/objectstack-automation/SKILL.md, skills/objectstack-automation/evals/flows-triggers-approvals.json + packages/services/service-automation/src/engine.ts, packages/services/service-automation/src/flow-activation-projection.ts, packages/services/service-automation/src/flow-definitions.ts, packages/services/service-automation/src/flow-registration-checks.ts, packages/services/service-automation/src/index.ts, packages/services/service-automation/src/plugin.ts, packages/runtime/src/flow-clone.ts, packages/metadata-protocol/src/package-unmanaged-install.ts, packages/spec/liveness/flow.json, scripts/check-skills-token-ratchet.mjs
Security-touching: yes

The delta's changeset and engine docblocks teach who arms a packaged flow and when a flow its package ships off runs anyway (the fail-open of an engine composed without a reader), and the skill paragraph, schema jsdoc and ADR note teach the administrator's switch. The low-risk arm does not apply.

DELTA record. Prior at-tier records: 6946901031 on bef53a4790 (PASS; S1, S2, N1 to N7) and 6947617913 on 5fe7b810c4 (PASS; S3 open, N8 to N11). Judged here: the one commit 5fe7b810..1074c040 (its parent is the reviewed head; no merge of main in it), 5 files: the changeset, engine.ts, the flow.zod.ts jsdoc and two test files. Read: card #34655 and all 18 comments, the PR body and file list (27 files), both prior records, the L1 record 6949131778 (paper only, M1 answered by claim amendment 6949150059), the delta diff, the check-runs, and the cited code at the head: engine.ts, flow-definitions.ts, plugin.ts, flow-precedence.ts, and outside the diff metadata-protocol/src/served-override.ts, objectql/src/plugin.ts, runtime/src/domains/packages.ts. Nothing was built or run; every behavioural statement below is read from the tree.

Check-runs on the head, latest attempt per check: all success or skipped. Test Core 1/10 to 10/10 and its roll-up, Test UI 1/16 to 16/16 and its roll-up, Build Core, Build Docs, Build UI Deps, Build and E2E UI, Live E2E UI, the four Type Check jobs, TypeScript Type Check, Type Check UI, every Lint job, Lint and Repo Gates, Spec property liveness, Governed Surface Queue Guard, Check Changeset, Check Documentation Links, Dogfood Regression Gate: success. Two earlier attempts were red and are superseded: Test Core (2/10) (the build-schemas-check-mode.anchor.test.ts hook timeout, green on its rerun) and one PR-body guards run (the claim-line parse, green after claim 6948896353). So the tests the prior record could not vouch for are now verdicts: the 28 cases of flow-default-active-34655.test.ts and the real-protocol pin passed.

① Derived judgments

  • refuseUnpackagedDefaultActive: was "the name has ONE owner" (isPackagedFlow); is now "any package's loader set holds the name" (isShippedFlowName). It answers yes when the name has one owner, else asks packagedFlowSlotOwner of each candidate package: every package whose slot holds the bare name now, plus the package the body stamps itself as. Every yes is the loader's own answer; the stamp only picks whom to ask. Right. Accept-set relative to 5fe7b810: a holder's body under a co-held name is accepted again; relative to main nothing narrows (every body with the key is refused there).
  • The same answer reaches dryRun (through judgeFlowRegistration) and the stored pass (registrationCheckRefusals), which hand the parsed body. Right, pinned for a co-held name and for the forged-stamp control.
  • With no packagedFlowSource attached every candidate answers none, so the key is refused on every flow: unchanged from the prior head (N4's closure), fail closed. Right.
  • packagedFlowDefault: the loader-armed path is unchanged (armed.defaultActive). For any other arm the reader's answer is now cached in a WeakMap keyed by the armed body object; a missing reader answers none before the cache is consulted; both setters replace the map. Right for cost. Wrong as a statement of when the default is re-read; see S4.
  • When the cache is filled: registerFlow calls the arming gate (activateFlowTrigger, and isFlowEnabled once the vocabulary is sealed) right after it files the body, so the reader is asked at registration, against the loader's set as it stands at that instant. The value, including a cached "none", then holds for the life of that body object.
  • Is the body object fresh on every registration: yes. canonicalizeFlow ends in FlowSchema.parse(converted), a new object on every call, and registerFlow is the only arming write to this.flows (a door handing back the parsed body it held is re-parsed too). The boot pull, the kernel:ready bind and the kernel:bootstrapped pass register every contender with no skip. So "re-registered" always means "asked again". The open question is whether every re-sync re-registers; it does not (S4).
  • Changeset: two paragraphs added. The co-held sentence is true. The public-API sentence names AutomationEngine.setPackagedFlowDefaultSource and PackagedFlowDefaultSource, both published through the package index, and states the fail-open without a reader with its reason: true to packagedFlowDefault. "Asked once per registration, not on every enablement read": true.
  • flow.zod.ts: jsdoc only; the schema and the describe are byte-identical to the reviewed head. The ADR, the skill, its eval, the ratchet script, the liveness row, flow-clone.ts, package-unmanaged-install.ts, flow-activation-projection.ts, flow-definitions.ts, flow-registration-checks.ts, index.ts and plugin.ts are not in the delta.

② Semver level

Clause-②: yes (widening), still true: the delta narrows nothing relative to main, and widens the prior head's accept-set back to every holder of a co-held name.

  • @objectstack/spec minor, @objectstack/service-automation minor, @objectstack/runtime patch, @objectstack/metadata-protocol patch: unchanged and right. The delta adds no export; the changeset now names the two published additions the prior record asked for.
  • Metadata-protocol: added and Skills-docs: updated here: unchanged and true. Check Changeset concluded success on this head.
  • One changeset sentence has an unstated exception: "an upgrade that changes it moves only installations nobody switched" does not hold for an override-armed flow in the case S4 describes.

③ Boundary flags

  • Dev report of record 6948029570 names this head; its four deviations (the hydrate edit, the ADR note, the skill in this PR, the reader and setter) are the ones the prior records answered by the seat's and the area's rulings. The delta stays inside them. The fix-round report 6948847225 carries open_questions: [] and no code change.
  • L1 6949131778 M1 (six paths outside the claimed surface): answered on the card by claim amendment 6949150059. Paper; the L1 delta ACCEPT is L1's to give.
  • Out-of-scope finding in 6948847225 (the anchor test's beforeEach runs on the default hook timeout): noted there, not filed. Escalated to the seat to file or drop; not this PR's.
  • main has moved on files in Scope since the merge-base c4c0794dc0: 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 landed (15385963a4) and touches engine.ts, flow-registration-checks.ts and plugin.ts, in the value-envelope refusal and its docblocks, none of them a hunk this PR touches. The landing order requires this branch to merge main; that moves the head, and this record does not cover the merged head.
  • ADR-0126: not in the delta; add-only against main as the prior record judged it. Governed: packages/spec/src, docs/adr and skills/** keep the PR at Tier H.
  • SQL push-down: the delta adds an in-memory WeakMap and a loop over the name's slots. No query, no id materialisation, no in-app join. No finding.
  • PR body: the 维护者速读 count and the Packages section say 28, which is the file's count at this head (27 it sites, one inside a two-value loop); the Tests section still heads the file "(24)". N12.

④ Design judgment

packages/spec/src/automation/flow.zod.ts against the rulings and the engine. The reworded paragraph reads as sentences and each is true: registration of an environment flow declaring the key is refused, a dry run of one is refused, the stored pass lists a stored one, a clone drops the key, an unmanaged install copies false as status: 'obsolete'. The sentence "a later version of the package that changes it moves an installation nobody switched" is true for a loader-armed flow and has the S4 exception for an override-armed one.

docs/adr/0126, skills/objectstack-automation/SKILL.md and its eval: not in the delta; re-read against the delta's behaviour. The skill paragraph and eval 24 stay true sentence by sentence (they claim survival of the administrator's choice, which a row decides before any default is read). The ADR note's "With no row the flow follows the declaration of the package's own body for the version installed now, so an upgrade that changes it moves only installations nobody switched" carries the same S4 exception.

Implementing file in the delta, engine.ts, sentence by sentence. isShippedFlowName agrees with its docblock. refuseUnpackagedDefaultActive's docblock agrees with the body. packagedFlowDefault agrees with its docblock. The packagedFlowDefaults docblock does not: see S4.

Tried on isShippedFlowName:

  • two holders registered, a third arrives, or one re-registers with a changed body: the slots or the stamp name a package whose loader set holds the name. Accepted. Pinned.
  • an environment body under a name no package ships, stamped with a real package's id: that package's set does not hold the name. Refused. Pinned.
  • an environment draft under a co-held name: accepted by this check (by-name, as for a single-held name), then refused by placeFlowSlot for naming no holder. No hole.
  • the first holder of a co-held name whose body carries no _packageId: no slot yet and no stamp, so no candidate, and it would be refused. Registry bodies are always stamped, so the stock composition does not reach it. N14.

S3: closed
N8: closed
N9: closed
N10: closed
N11: closed

S4 (should-fix) — the N9 cache serves a stale default when a re-sync re-uses the armed body object, and one stock path does. The cache is keyed by the armed body and its docblock rests on "every re-registration (the metadata:reloaded re-sync after an upgrade re-registers the winner) asks again". resyncFlowsFromProtocol (plugin.ts) does not always re-register: it skips a winner whose slot carries a mutationArmedFlows mark equal to the stored body, and keeps the held object. That mark is set whenever the metadata-mutation sync armed the flow, and is cleared only by the next re-sync. A publish raises both signals back to back, so there the skip is spent at once. A mark lingers when the mutation came with no reload: a direct active save through PUT /api/v1/meta/flow/:name (the per-item announce in objectql/src/plugin.ts fires on publish only), or a peer replica's write replayed here (the mutation signal crosses replicas, metadata:reloaded is kernel-local). The next metadata:reloaded is then whatever comes next, including a hot upgrade of the base package (announcePackageReload, changed: ['app/ID']). The override's stored body does not change with the base (basedOn never gates, and the served envelope is _packageId alone), so the mark matches, the override is not re-registered, and the default cached from the previous version's loader body stays until the next registration of that flow or a restart. With no ledger row:

  • the base moves from on to off: the override-armed flow keeps running, and _status reports enabled: true, though the installed version ships it off. At 5fe7b810 the reader was asked on every read, so execute answered FLOW_DISABLED here; the cache turns that into fail-open.
  • the base moves from off to on: the flow stays off.
    Both contradict the jsdoc, the ADR note and the changeset ("follows the package's own declaration for the version installed today", "an upgrade that changes it moves only installations nobody switched"). The same reuse happens when the re-sync's registerFlow throws and "the engine keeps the registration it had". Read in the tree, not run. Confined to a slot whose armed body is not the loader's own (an override arm, or a runtime body under a held name), with no row; a loader-armed flow reads its own body and is unaffected. Fix direction: the cached answer depends on the loader's set, so it must not outlive a change to that set. Either drop the cache at each metadata:reloaded re-sync and send every held non-loader slot back through the arming gate, or do not take the mutation-mark skip for a winner that is not the loader's own body. Correct the packagedFlowDefaults docblock either way, and pin it: an override armed by the mutation sync, then a reload with the base's declaration flipped, in both directions.

N12 (nit) — the PR body's Tests section heads flow-default-active-34655.test.ts "(24)"; the file holds 28 cases at this head, as the 维护者速读 and Packages sections say. PR-body prose, fixable without moving the head.
N13 (nit) — rollbackFlow puts a body object from the version history back into this.flows without registering it, so an override-armed body rolled back to one armed before an upgrade answers the default cached then. Engine API only: no wire door calls it, and it re-arms nothing. Rides with the S4 fix (the same cache drop covers it) or stays as an accepted deviation.
N14 (nit) — isShippedFlowName learns a not-yet-slotted holder only from the body's _packageId, never from the arm's holder. A first or third holder of a co-held name registered through the engine API with an unstamped body is refused with the "authored in this deployment" sentence. Registry-fed bodies are stamped, and every S3 pin stamps its bodies. Follow-up card or accepted deviation.

Verdict basis: S3 is fixed as the prior record asked (the question is "does any package's loader set hold the name", asked per package, pinned through a re-registration and a third holder, with the forged-stamp control), and N8, N10 and N11 are fixed as written. N9's cost is fixed, and its fix opens S4: one stock path re-uses the armed body across a re-sync, and the cached default is then the previous version's. S4 is not a must-fix: it needs an override armed by a mutation that raised no reload, then a hot upgrade that flips the base's declaration, on an installation with no row, and a restart repairs it. It is open on this head, earns a delta review of its fix, and under the merge standard (only nits may stay open at landing) blocks landing. The nits ride with that fix or stay as accepted deviations.

Implemented-by: claude/project-thread-sjzr94
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: PASS

Brings #34654 (value-envelope refusal) and later main into half A before
the L2 S4 fix round.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX
… every re-sync

L2 S4 on #34793: the package default cached per armed body outlived a
change to the loader's set. The metadata:reloaded re-sync keeps a body the
metadata-mutation sync armed from the same stored row (and one whose
re-registration threw), and a declared override's stored body does not
change with its base, so a hot upgrade that flipped the base's
defaultActive left the previous version's default in force with no ledger
row: on to off kept running, off to on stayed off.

AutomationEngine.refreshPackagedFlowDefaults() replaces the cache and sends
each held flow whose armed body is not the loader's own back through the
arming gate when its enablement moved; the plugin calls it at every
re-sync. The cache docblock says when the default is re-read. The same
drop covers a body rollbackFlow puts back (L2 N13).

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX
…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
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

席位核对

L1 delta review · ACCEPT; landing waits on gates and Tier H · Head-sha: 34181ed12496f3fd49db092367fc5015f31ae284 · card #34655 half A · read 2026-11-17T17:24Z

This reviews the delta from L1 6949212729 (same-head ACCEPT at 1074c040). Inputs:

  • dev report 6955521121 and amendment 6953980143;

  • the two fix commits 05656d74 (S4) and 536d5a1c (prose), read line by line;

  • the two main merges 96a99d06 and 198cdf7b, and the regeneration 34181ed1;

  • check-runs on this head.

  • L2 S4 is closed, by the cache-drop direction L2 named first. The new public AutomationEngine.refreshPackagedFlowDefaults() works in three steps:

    • it snapshots isFlowEnabled for every armed body whose arm is not package;
    • it replaces the packagedFlowDefaults WeakMap;
    • for each key whose enablement moved, it runs deactivateFlowTrigger or activateFlowTrigger, then rejudgeSubflowCallers.

    activateFlowTrigger re-asks isFlowEnabled at its own gate, so re-arming goes through the one enablement gate. resyncFlowsFromProtocol calls the method after its loop, before it clears mutationArmedFlows. That covers both reuse paths L2 named: the mutation-mark skip, and a re-registration that threw. A loader-armed flow is never cached, so it is correctly left to its re-registration. A ledger row decides before any default is read, so a switched flow does not move. The pins:

    • a held override with no row, base moves on → off and off → on;
    • the CONTROL, where a ledger row or the loader's own body decides;
    • through the plugin, both directions plus a CONTROL reload that leaves the declaration as it was.

    The body reports that ablating the plugin call turns exactly the two flip pins red. I did not re-run it.

  • L2 N13 is closed by the same drop. A body rollbackFlow restores is asked again, because the map it was cached in is gone. There is a pin.

  • L2 N12 is closed. The body counts 34 tests (28 + 6).

  • fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810 contract review N1 is closed. The toggleFlow JSDoc in packages/spec/src/contracts/automation-service.ts and the module JSDoc in packages/spec/src/api/automation-api.zod.ts now name the status-disarmed switch-on 409 and the accepted switch-off. Both match fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810's code, which is on this branch through the second merge. automation-api.mdx is regenerated from them.

  • Prose: the packagedFlowDefaults docblock no longer claims "every re-registration … asks again". The changeset names refreshPackagedFlowDefaults() as new public API and says when a self-composing host calls it.

  • Merges: for 96a99d06 the PR's net diff is line-identical to main's side. For 198cdf7b the one difference is that the merge dropped main's api/GetMetaItemRequest:userTextLocales row from authorable-surface/api.json. The regeneration 34181ed1 restored it. Against main, the generated files now differ only by this PR's own rows: CreateFlowRequest:defaultActive, Flow:defaultActive, and the two references pages.

  • Surface: engine.ts, plugin.ts, the card's test and the changeset are in the claim as amended. The two spec JSDoc paths come in through amendment 6953980143. The regenerated references and authorable-surface files are the generated spec artefacts already claimed.

No new findings. L2 N14 stays the accepted deviation the seat recorded.

Gates at this head: CI was still running when this was read (31 of 67 checks in progress, none failed). This ACCEPT does not stand in for green.

Owed, for the seat:

  • the contract-review delta at CONTRACT_REVIEW_TIER. It covers a new public engine method, and two spec contract JSDoc edits that are prose only, with no export or key moving;
  • because the PR is governed, the Tier H record with os-zhuang's approval before anything readies it.

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: 34181ed12496f3fd49db092367fc5015f31ae284
Local-runs: none
Scope: packages/spec/src/api/automation-api.zod.ts, packages/spec/src/automation/flow.zod.ts, packages/spec/src/contracts/automation-service.ts, docs/adr/0126-packaged-metadata-customization-model.md, skills/objectstack-automation/SKILL.md, skills/objectstack-automation/evals/flows-triggers-approvals.json + packages/services/service-automation/src/engine.ts, packages/services/service-automation/src/plugin.ts, packages/services/service-automation/src/flow-activation-projection.ts, packages/services/service-automation/src/flow-definitions.ts, packages/services/service-automation/src/flow-registration-checks.ts, packages/services/service-automation/src/index.ts, packages/runtime/src/flow-clone.ts, packages/metadata-protocol/src/package-unmanaged-install.ts, packages/spec/liveness/flow.json, scripts/check-skills-token-ratchet.mjs
Security-touching: yes

The changeset and engine docblocks teach who arms a packaged flow and when a flow its package ships off runs anyway (the fail-open of an engine composed without a reader), the two spec prose edits teach which toggle requests the door refuses, and the skill paragraph, schema jsdoc and ADR note teach the administrator's switch. The low-risk arm does not apply.

DELTA record over 6949383615 on 1074c040a7 (PASS; S4 open, N12 to N14). Earlier at-tier records: 6946901031 on bef53a4790 and 6947617913 on 5fe7b810c4. Judged here: 1074c040..34181ed1, which is three commits of this branch (05656d74f1 the S4 fix and its pins, 536d5a1c12 the spec prose and the changeset sentence, 34181ed124 the regenerated reference page and authorable-surface/api.json) and two merges of main (96a99d06d8, 198cdf7bf6). Read: card #34655 and all 21 comments (dev report 6955521121 and claim amendment 6953980143 among them), the PR body and file list (29 files), the three prior records, the L1 delta ACCEPT 6955617545, the net diff against main at the merge-base 13e0305c33, the check-runs, and the cited code at the head: engine.ts, plugin.ts, flow-definitions.ts, flow-activation-projection.ts, and outside the diff toggleFlow as #34810 landed it. Nothing was built or run; every behavioural statement below is read from the tree.

Check-runs on the head, all concluded, one attempt: 74 runs, 60 success, 12 skipped, 2 failure. NOT all green. The two red are Test Core (5/10) (job 134222341627) and its roll-up Test Core. The shard failed on one task of 56, @objectstack/lint#test, one case of 9181: packages/lint/src/validate-expressions.flow-null-guards.test.ts, "LIT — on each ownership tier os build judges exactly the injected columns the tier carries, as the door does", Error: Test timed out in 5000ms (5616 ms measured), a timeout and not an assertion. This PR's diff touches nothing under packages/lint. That reads as a loaded-shard timeout, but one occurrence does not establish a flake, and this record does not call it one: a rerun of the failed job is the seat's to order, and a second failure is real. Every other gate is a verdict: Test Core 1 to 4 and 6 to 10 (the shards holding service-automation, spec, runtime and metadata-protocol; shard 5 held none of them), Test UI 1/16 to 16/16, the Type Check jobs, Lint and Repo Gates, Spec property liveness, Check Changeset, Governed Surface Queue Guard, Dogfood Regression Gate, the builds and both E2E jobs: success. So the 34 cases of flow-default-active-34655.test.ts, the six new ones among them, passed in CI.

① Derived judgments

  • AutomationEngine.refreshPackagedFlowDefaults() is new and public. It snapshots isFlowEnabled for every held key whose armed body's arm is not package, replaces the packagedFlowDefaults map, re-reads each key, and for a key whose answer moved calls deactivateFlowTrigger or activateFlowTrigger, then rejudgeSubflowCallers for each moved key. Right: it registers nothing, so no body, slot, version-history entry or refusal record is written a second time; activateFlowTrigger returns at once for a bound key and re-asks isFlowEnabled at its own gate, so nothing is armed twice and nothing is armed past a status, a ledger row or a declined subflow. The old map is unreferenced after the swap, so nothing leaks.
  • resyncFlowsFromProtocol calls it once, after the registration loop and the teardown loop, before mutationArmedFlows.clear(). Right: a body the loop re-registered was asked at that registration against the set as it stands now, so it reads the same before and after and is not moved; a body the loop kept (the mutation-mark skip, or a registerFlow that threw) still holds its old cached answer in the first snapshot and the new one in the second, so it moves. Both reuse paths the prior record named go through this one call.
  • Accept-set: unchanged from 1074c040. No registration check, schema line or describe moves in the delta. flow.zod.ts is not in the delta at all.
  • packages/spec/src/api/automation-api.zod.ts and packages/spec/src/contracts/automation-service.ts: comment lines only, one hunk each, inside an existing docblock. No schema, describe, export, type or error code moves, so the published accept-set and the IAutomationService shape are byte-identical to main. The regenerated content/docs/references/api/automation-api.mdx carries the same five sentences. Right: prose, not a contract change in shape.
  • packages/spec/authorable-surface/api.json: the second merge dropped main's api/GetMetaItemRequest:userTextLocales row (the regeneration merge driver deferred it) and 34181ed124 restores it. Net against the merge-base the file differs by this PR's one row, api/CreateFlowRequest:defaultActive. Right.
  • The merges: git show --cc of both is empty, so neither resolved a conflict by hand. main at 2fcc9cf708 has not moved any file in Scope since the merge-base.

② Semver level

Clause-②: yes (widening), still true. The delta narrows nothing: it adds a method and comment lines.

  • @objectstack/service-automation minor covers the new public method; @objectstack/spec minor, @objectstack/runtime patch, @objectstack/metadata-protocol patch are unchanged and right. Check Changeset concluded success on this head.
  • The Clause-②: line states the accept-set change (the defaultActive key) and does not name the method, which is correct: the method changes no accept-set. The changeset BODY names AutomationEngine.refreshPackagedFlowDefaults() as new public API, says what it does, that the automation plugin calls it at every metadata:reloaded re-sync, and that a host composing the engine itself calls it after the set of installed packages changes. Each of those sentences is true to the code.
  • Metadata-protocol: added: unchanged and right; the delta adds nothing an author can write.
  • PR body against the changeset: the same Clause-②, Metadata-protocol and Skills-docs lines; the body names the method in 维护者速读, in What changes (engine and plugin bullets) and in the fix-round fold. They agree with the tree.
  • The changeset sentence the prior record marked with an exception ("an upgrade that changes it moves only installations nobody switched") now holds for an override-armed flow on the stock composition.

③ Boundary flags

  • Dev report 6955521121 names this head and carries open_questions: []. Its one out-of-scope entry (N14 left as an accepted deviation) is what the prior record allowed. Its deviations (model-free trailers on an amended local merge, a scratch log) touch no contract.
  • Claim amendment 6953980143 adds the two spec paths for the prose of fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810's N1; the delta's spec edits stay inside it (two docblocks, nothing else under packages/spec/src).
  • The three NOT-MEASURED local gates the dev report declares (check:skill-examples, check:dual-build-cjs-loads, check:type-check-debt) ran in CI: Lint and Repo Gates and the Type Check jobs concluded success on this head.
  • Test Core is red on this head (above). Escalated to the seat: rerun the failed job; this record does not stand in for green.
  • Interaction with fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810 (toggleFlow refuses a switch ON of a packaged flow whose status disarms it, and the door answers the engine's state), read at the head. A flow shipped defaultActive: false with status: 'active' passes the new refusal, the write names the loader's owner, and the projection then holds that owner's row as on, which rowVerdict reads before any default, so the door's read-back answers enabled: true truthfully. With two rows of one name the door echoes the request, and that stays true here: past the status refusal a switch ON always leaves the ledger dimension on. A flow shipped off AND status-disarmed is refused on switch ON with nothing written, which agrees with the schema jsdoc ("no switch overrides that"). No semantic conflict.
  • ADR-0126, the skill, its eval, flow.zod.ts: not in the delta; add-only against main as judged before. Governed paths keep the PR at Tier H.
  • SQL push-down: the delta adds an in-memory map swap and a loop over the engine's held flows, each asking a reader the registration path already asks. No query, no id materialisation, no in-app join. No finding.

④ Design judgment

packages/spec/src/contracts/automation-service.ts and packages/spec/src/api/automation-api.zod.ts against the code they describe (toggleFlow in flow-definitions.ts, landed by #34810 and on this branch). Sentence by sentence: the refusal is for a switch ON only (enabled && flowStatusDisabled.get(name) === true); flowStatusDisabled is exactly obsolete / invalid; the error carries RESOURCE_CONFLICT / 409; it is thrown before the ledger write and before any in-process change, so nothing is written; its sentence names publishing the flow with status 'active'; a switch OFF is not refused by it and writes the row. True. One clause is loose under this PR's own key: see N17.

packages/spec/src/automation/flow.zod.ts, docs/adr/0126, skills/objectstack-automation/SKILL.md and its eval: not in the delta; re-read against the delta's behaviour. The sentences the prior record marked with the S4 exception ("a later version of the package that changes it moves an installation nobody switched"; the ADR note's "an upgrade that changes it moves only installations nobody switched") now hold for an override-armed flow as well. The skill paragraph and eval 24 claim only that the administrator's choice survives, which a row decides before any default is read; "status: 'obsolete' disarms past the switch" agrees with #34810's refusal.

Implementing files in the delta, sentence by sentence.

  • engine.ts, the packagedFlowDefaults docblock: "keyed by the body registerFlow armed, which is a new object on every registration" true; "a re-sync does not always re-register" true, and both cases it names are the ones in resyncFlowsFromProtocol; "replaced whenever either reader is attached and at every re-sync" true (both setters, and the refresh). It no longer rests on "every re-registration asks again".
  • engine.ts, the refreshPackagedFlowDefaults docblock: agrees with the body, including "returns the keys it moved", "a loader-armed flow ... is never cached, so it is not re-judged here" (packagedFlowDefault returns armed.defaultActive before the cache for a package arm), and "a flow an administrator switched does not move" (has reads rowVerdict first).
  • plugin.ts, the comment at the call: agrees with the loop above it.

Tried on the fix:

  • an override armed by the mutation sync, no row, base flips on to off at a reload: mark matches, body kept, first snapshot reads the cached undefined (on), second reads false; unbound, execute answers FLOW_DISABLED, callers re-judged. Pinned through the plugin, ablated.
  • the same, off to on: bound through the gate. Pinned through the plugin, ablated.
  • a re-registration that throws at the reload: judgeFlowRegistration and placeFlowSlot throw before this.flows is written, the old body and its cached answer stay, and the refresh moves it. Read, not pinned on its own (the same call covers it).
  • a body the loop re-registered: read fresh at registration, same in both snapshots, not touched again. No double arming.
  • a flow with a ledger row, and a loader-armed flow: not moved. Pinned as the CONTROL.
  • a flow whose status disarms it and whose default flips to on: isFlowEnabled composes the status, so it reads off in both snapshots.
  • a name two packages hold: the snapshot runs over slot keys, the keys activateFlowTrigger and deactivateFlowTrigger take everywhere else.
  • the refresh throws: nothing in its body throws on the stock composition (deactivateFlowTrigger and activateFlowTrigger catch their trigger's failures; the reader catches a missing protocol). See N16 for the uncaught case.

S4: closed
N12: closed
N13: closed

N14 stays the accepted deviation the seat recorded. #34810's N1 (record 6952048597, the toggle contract prose) is answered by the two spec edits judged above.

No must-fix, no should-fix.

N15 (nit) — refreshPackagedFlowDefaults compares enablement before and after the cache drop, and takes the first reading as what the trigger binding reflects. That holds for every body the engine armed, because arming asks. It does not hold for a body with no cached answer at the call: rollbackFlow puts a history body back without arming it, and if nothing reads that flow's enablement before the next reload, both snapshots read the new set, nothing "moves", and the binding left by the body before the rollback stays (execute and _status.enabled are right; bound is not). Needs the engine-API rollback, no read in between, a kept body at the reload and a flipped default. Follow-up card or accepted deviation; judging the binding itself (boundFlowTriggers) instead of the first snapshot would close it.
N16 (nit) — the refresh call in resyncFlowsFromProtocol sits outside any try, in a method whose docblock says a failure "is logged without disturbing the rest of the runtime". packagedFlowDefaultReader catches getService but not shippedArtifactsOf; if that read threw, the reload hook would reject after the flow loop, mutationArmedFlows would not be cleared and the hook's connector reconcile would not run. No stock path throws there (the same read runs uncaught under packagedFlowReader on every registration), and a failed protocol read returns before the call, as it does for every other flow at that reload. Follow-up card or accepted deviation.
N17 (nit) — automation-service.ts, the new clause "publishing its definition 'active' arms it": for a flow its package ships defaultActive: false with no row, publishing it active leaves it off until an administrator switches it on. The automation-api.zod.ts wording ("names publishing the definition 'active'") does not over-claim. Prose; fixing it moves the head, so follow-up card or accepted deviation.
N18 (nit) — PR body prose: the Packages fold still reads "src/flow-default-active-34655.test.ts 28/28 at the final head" (34 at this head, as 维护者速读 and Tests say), and the fix-round fold says authorable-surface/api.json "now equals main's" where it differs from main by this PR's own row. Fixable without moving the head.

Verdict basis: S4 is closed by the cache-drop direction the prior record offered first. A stale packaged default can no longer survive a metadata:reloaded re-sync in either direction on the stock composition: the map is replaced at every re-sync, every held body that is not the loader's own is read again, and the ones whose answer moved go through the one arming gate, with their subflow callers re-judged. Nothing is registered twice and nothing leaks. N13 rides with it, N12 is fixed, the spec edits are prose that matches #34810's code, the new public method is declared at the right level and named in the changeset and the PR body, and the merge of main does not conflict in meaning with #34810. Four nits stay open, which the merge standard allows. What this record does NOT give is green: Test Core is red on this head, on a 5000 ms test timeout in packages/lint, a package this diff does not touch. The PASS is the contract verdict on this head; landing still waits on that gate going green on this same head (a rerun changes no sha, so this record keeps covering it) and on the Tier H approval.

Implemented-by: claude/project-thread-sjzr94
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Red read · PR #34793 · head 34181ed1 · CI run 44134653552 · 2026-11-17T17:53Z

Test Core (5/10) fails on a 5 s test timeout in packages/lint/src/validate-expressions.flow-null-guards.test.ts. That file and packages/lint/** are outside this PR's diff (service-automation, runtime, spec contract prose and generated references). The Test Core aggregate is red only because of that shard. Judged a timing flake (the seat reads it the same way). The failed jobs are re-run once. A second failure goes to the seat as a reading, not a re-run.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

席位记录 · 2026-11-17T18:24Z

Head-sha: 34181ed12496f3fd49db092367fc5015f31ae284

维护者速读(终稿)

  • 改了什么:flow 新增作者可写的可选键 defaultActive(紧挨 status,缺省为开)。打包 flow 写 defaultActive: false 后,新装时不挂触发器、不运行,/automation/_status 报 enabled:false;管理员用现有开关打开后写一行账本,这行优先于包默认,重启、升级、重装都保持。环境里自写的 flow 带这个键会在注册时被拒(它的开关是 status);克隆会去掉这个键;unmanaged 安装把 false 抄成 status:'obsolete'。ADR-0126 §4 加修订注,automation skill 加一段和 eval 24。
  • 为什么改:automation: a packaged flow cannot ship switched off for an administrator to turn on — status: 'obsolete' disarms it for good, yet POST /automation/:name/toggle answers 200 {enabled:true} #34655。hotcrm#2558「接受报价起草合同」要作为默认关闭、管理员可开的打包 flow 发出,今天做不到:没有账本行就是开,status:'obsolete' 又会永久关死。
  • 风险与回滚:Clause-②: yes (widening),Metadata-protocol: added,spec 和 service-automation 为 minor。没写这个键的 flow 行为不变。默认在读时取,安装时不写行,所以「有行 = 管理员选过」这个含义不变;包升级改默认只影响没人动过开关的安装。新增公开方法 refreshPackagedFlowDefaults(),每次 metadata:reloaded 重读一次包默认,changeset 已写明。回滚即 revert(已写 defaultActive 的包会回到「未知键被拒」)。
  • 先看:packages/services/service-automation/src/engine.ts(refuseUnpackagedDefaultActive、refreshPackagedFlowDefaults),再看 flow-activation-projection.ts(没有账本行时读包默认)和 ADR-0126 §4 的修订注。
  • 两分钟验证:pnpm --filter @objectstack/service-automation exec vitest run src/flow-default-active-34655.test.ts,预期 34 条全过。
  • 需要你做的:这是 Tier H,因为改到受管路径(packages/spec/src、docs/adr/**、skills/**,3/29 个路径命中),行数 1401,在 3000 行线以下。请 os-zhuang 审批。本 head 上已有 L1-e delta ACCEPT 6955617545 和席位 L2 delta PASS 6956238029。批准后由 o3-J 按落地条款合入。

席位意见:建议批准。L2 一共四轮:

  • l2-review#4 首轮 PASS 6946901031(bef53a47);
  • 5fe7b81 上 PASS 6947617913,留 S3,已修;
  • 1074c04 上席位 delta PASS 6949383615,留 S4(热升级翻转包默认时,已被元数据保存激活的覆盖体漏读新默认);
  • 本 head 上席位 delta PASS 6956238029,S4、N12、N13 已关。

现在只剩 nit N14–N18,都不影响正确性。

席位核对

  • 形态:Fixes #34655;草稿 PR,base main,+1370/−31,29 个文件。受管命中 packages/spec/src/**、docs/adr/**(ADR-0126 修订注,删 1 行,所以不算只加注)、skills/**。security 标签是机器人按路径打的,不是安全卡。
  • 前提实测:读时默认而非安装时写行(area 裁定);只有打包 flow 可带此键,按名字判断(isShippedFlowName),两个包同名时保留键(S3 修复,有钉子)。fix(automation)!: switching on a packaged flow that its own status disarms is refused, and the toggle door answers the engine state #34810(半 B,切换门)已合入 main 并并进本分支;L2 读过两者交互,无语义冲突。
  • 门禁:
    • 本 head 的 check-runs:58 success,0 failed。Test Core 5/10 首次在 packages/lint 的一个 5000ms 超时上红(本 PR 不碰 lint),重跑一次后通过。
    • 派生门禁 149 条:146 条跑过,3 条 NOT-MEASURED(check:skill-examples、check:dual-build-cjs-loads、check:type-check-debt,需闭包外构建,CI 已跑且绿)。
    • 这是放宽,不是收窄,所以不需要收窄臂 dogfood battery。
  • 接受的偏差:
    • N15:rollbackFlow 放回历史体后若重载前无人读启用状态,触发器绑定可能停在旧状态(execute 和 _status.enabled 正确)。仅限引擎 API 回滚加特定时序,接受。
    • N16:resyncFlowsFromProtocol 里的刷新调用没有包在 try 里;没有常规路径会抛错,接受。
    • N17:automation-service.ts 新句「发布为 active 就会挂上」对包默认关的 flow 略有过度表述,散文,接受。
    • N18:PR 正文 Packages 折叠段的「28/28」应为 34,以及一处 api.json 描述,可不动 head 修正。
    • N14:经引擎 API 注册的无戳记第一或第三持有者,L2 允许保留。
  • 范围外去向:无新增。
  • 落地条款:Tier H,批准前 ⛔ 不 ready、不入队、不开自动合并。批准后若 main 已前移,o3-J 先合 main;纯合并按 Regen-provenance 补一条,手解冲突则补 L1 delta 和席位 L2 delta,然后入队。

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 17, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 17, 2026 21:56
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 99bd220 Nov 17, 2026
127 of 129 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-sjzr94 branch November 17, 2026 22:25
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 pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue protocol:system security size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

3 participants