Skip to content

Commit 162fe54

Browse files
fix(runtime): the automation write doors keep a flow whose only package is disabled, whatever its package's enable state (#34315)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCpddLFmKzR39wJWZpkRMCi)_ Fixes #34145 Clause-②: yes (widening) Metadata-protocol: none > **Widening:** `AutomationEngine.getHeldFlow(name)` is a new public method on a class `@objectstack/service-automation` exports from its `.` entry (seat rulings 6911640332 on #34145: R1 stands, R2 superseded, M1 = B). Nothing narrows: no `!`, no BREAKING banner, no ADR-0087 marker. ## 维护者速读 - 改了什么:`/automation` 的四个写入口(克隆新名占用检查、写入被拒后的回填副本、PUT 与对已有名字的 POST 沿用的凭据、DELETE 存在性检查)对"仅一个包持有"的名字改读引擎新增的 `getHeldFlow`(按全部持有者判断)。对"两个包共有"的名字,`getHeldFlow` 拒绝后回落到服务视图 `getFlow`,行为与 main 相同(座席裁决 6911640332,M1 = B)。克隆入口把共有名字的拒绝捕获为自己的"名称已占用" 409。 - 为什么改:PR #34048 之后,唯一持有者的包被停用时 `getFlow` 答"无此流程",这四处问的却是持久问题,答案不应随包的启停而变。 - 风险与回滚:无收窄;新增公开方法 `getHeldFlow` 是放宽。唯一可见变化是:两包都启用时克隆到共有名字,原先抛出引擎拒绝,现在返回克隆入口自己的"名称已占用",状态码与 code 不变。两个持有包都被停用的共有名字,克隆入口仍不视为占用(与 main 相同,已在注释与 changeset 写明,后续卡由席位立)。回滚即还原本 PR。 - 先看:`packages/runtime/src/domains/automation.ts` 的 `heldFlowReader`(共有名字的回落)与 `cloneTargetHeld`;`packages/runtime/src/domains/automation-write-doors-durable-34145.test.ts` 末尾的 booted-kernel 用例。 - 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/automation-write-doors-durable-34145.test.ts`,预期全部通过,其中含真实元数据协议保存用例。 - 需要你做的:无,席位落地。 ## What changes - **`AutomationEngine.getHeldFlow(name)`** (service-automation, `engine.ts`): the flow the engine holds under a bare name, judged over every holder through `bareFlowKey`. A disabled sole holder is included. A name two packages hold is refused `409`. Like `getFlow`, it settles the name first (review#1 N1, in the docblock). - **`heldFlowReader`** (runtime, `automation.ts`), used at the four write doors: the clone's taken-name probe, the `registerAndSaveFlow` put-back copy, `keepStoredFlowCredentials`, and the `unregisterAndDeleteFlow` existence probe. - It asks `getHeldFlow`. - If that raises `PackageScopedNameRefusedError` (a name two packages hold), it falls back to `getFlow`, the served holder, as on `main` (M1 = B). - A service without `getHeldFlow` is asked its `getFlow`. - **`cloneTargetHeld`**: the clone's probe catches the refusal of a name two served holders hold and answers it with the door's own name-taken `409`, as `flowWriteRefusal`'s clone arm does (L1 nit, review#1 S2). - **For a flow whose only package is disabled**, the four doors return to the last release's answers: - clone onto the name: `409`; - put-back: the held body; - `PUT`, or `POST /` onto the name: keeps the stored credential; - `DELETE`: `200`. - **For a name two packages hold**, the doors answer as on `main`. The one change is the both-enabled clone, which now gets the name-taken answer. - **Stated, unchanged (review#1 delta 6915149305, S5 option 1):** a name two packages hold with BOTH holders disabled is not taken at the clone door, as on `main`: `getHeldFlow` refuses the shared name, the served fallback `getFlow` answers `null`, and the copy is admitted. The clone door's comment and the `#34145` changeset say so; no code path moves. - **`.changeset/33905-disabled-sole-holder-flow.md`** (pending from PR #34048), corrected (L1 F3, review#1 S3). - Its three write-door bullets are replaced by one paragraph. It says those doors keep the last release's answers for a disabled sole holder, and read a name two packages hold on its served holder. - Every other line is byte-identical. - **DELIBERATE CORRECTION** of the pending note `.changeset/33905-disabled-sole-holder-flow.md` (added by PR #34048, unreleased). Its paragraph "Three HTTP write doors ask `getFlow` whether the name is held, and move with it for such a flow." and its three bullets (clone admits the copy, put-back withdraws the name and drops the credential, `DELETE` answers `404`) would be false after this PR. The corrected sentences: > The HTTP write doors that ask a lasting question of the name do not move with it: the clone door's taken-name check on the new name, the definition a refused `POST /automation` or `PUT /automation/NAME` puts back, the stored credential a `PUT /automation/NAME` body, or a `POST /automation` body onto a name the engine holds, keeps when it leaves it out, and the `DELETE /automation/NAME` existence check read the flow the engine holds whatever its package's enable state. For such a flow the clone's new name is refused `409`, the held definition is put back, the credential is kept and `DELETE` answers a deletion, as before this release. A name two packages hold is read at those doors on its served holder, as the bare entries read it. - `check-empty-changeset` keeps `Check Changeset` red on this file until the dispatching seat's record confirms the correction (its ACCEPT or its same-head contract-review PASS); it is not restored from the base. ## Tests - **Runtime**, `automation-write-doors-durable-34145.test.ts`, through the real `HttpDispatcher`: - Clone: a disabled sole holder's name is taken. A shared name in each of three states (co-holder kept, co-holder withdrawn, both served) gets the door's returned name-taken `409`. - Put-back, credentials and `DELETE` for a disabled sole holder, each with CONTROLs. - Shared-name writes, as on `main`, with no store: `PUT` and `POST /` are admitted `200` into the served holder, and a served-form `PUT` keeps the served holder's secret. CONTROL: both holders enabled gives `409` naming every holder. - The with-store leg runs through the **real metadata protocol save on a booted kernel** (`MetadataPlugin`, `ObjectQLPlugin`, SQLite), with two authored packages each holding a stored flow row and one of them disabled. Package-less `PUT` and `POST` are expected to give `200`, with the edit in the enabled holder's row and the disabled holder's row byte-unchanged. - The no-store narrowing pins from the previous round are removed. - **Engine**, `flow-slots-per-package.test.ts`: - `[#33905]`: `getHeldFlow` is the slot's body. - `[#33893]` withdrawn-slot case: `getHeldFlow` refuses naming both holders, while `getFlow` serves the enabled holder. - Uninstall stretch: `getHeldFlow` settles the name back to the one holder. This backs N1; it is no longer framed as a remedy. ## Acceptance notes - **Review disposition, from both reviews:** - L1 F1 / review#1 S1: re-pinned under B. - L1 F2: moot; there is no narrowing and no remedy. - L1 F3 / review#1 S3: corrected under B. - L1 nit / review#1 S2: done. - review#1 M1: B applied. - review#1 S4: rulings recorded in 6911640332; the claim amendment is the area's. - review#1 N1: done. - review#1 delta 6915149305: S5 option 1 (exception stated in the clone door's comment and the changeset; no behaviour change), N2 (both changesets name `POST /automation` onto a held name beside `PUT` for the kept credential), N3 (this body). These three are prose-only: `e5468471` moves comments and changesets, no code path. - **filed #34394**: both-disabled shared name at the clone door (review#1 6915149305 S5, stated here as the exception, as on main). - The booted-kernel case passes on this head: the real protocol's package-less save addresses the enabled holder's flow row. ## Verification Final head `e5468471` (takeover round, claim 6913100013). `e6f54de659` typed one test read's engine options; `e5468471` moves prose only (comments and changesets). Local runs under the shared verify lock, after rebuilding the `@objectstack/runtime` and `@objectstack/service-automation` closures. **The three red checks on the hand-off head `fa24e9f67c`:** - `Lint · scoped · query-options erasure`, step `pnpm check:query-options-erasure`, first error: "test surface grew 236 → 237 site(s)". This PR's: `automation-write-doors-durable-34145.test.ts` erased the booted-kernel rows read's options to `any`. Fixed in `e6f54de659`: the context rides the read's typed trailing options. Local gate: `test surface: 236 site(s) in 47 file(s) — at the ceiling`, exit 0. CI at `e5468471`: success. - `Lint & Repo Gates`, step `verify-lanes`, first error: "lint lane `lint-scoped-erasure` concluded `failure`". The aggregator of the lane above, nothing of its own. CI at `e5468471`: success. - `Check Changeset`, both runs (`09:02Z`, before the body patch, and `09:06Z`, after it), step `check-empty-changeset --base`, first error: ".changeset/33905-disabled-sole-holder-flow.md exists on the merge base and was not added by this PR". Red by design: the DELIBERATE CORRECTION declared under What changes. Every other step passes in CI and locally: `check-changeset-no-major` with an event carrying the current title and this body, exit 0 ("LEVEL AXIS: this PR declares clause-② `yes (widening)` and metadata-protocol `none` … a non-protocol change at `patch`"); `check-adr-0087-registration`, exit 0 ("this PR adds no declared-breaking changeset (2 non-breaking changeset(s) seen)"). <details><summary>Suites and typechecks (at e6f54de; e546847 adds comments and changesets only)</summary> - `pnpm --filter @objectstack/service-automation test`: Test Files 284 passed (284), Tests 4041 passed (4041). `typecheck`: exit 0, test layer compiles. - `pnpm --filter @objectstack/runtime test`: Test Files 608 passed (608), Tests 11176 passed, 19 skipped (11195). `typecheck`: exit 0, test layer compiles (the edited test file included, 183 pinned debt errors unchanged). - `automation-write-doors-durable-34145.test.ts`: 22/22 passed. </details> <details><summary>Ablation: the shared-name fallback in heldFlowReader</summary> Through `scripts/ablation-replace.mjs` on `automation.ts` (the test imports the source, no `dist/` in the path): the line `if (e instanceof PackageScopedNameRefusedError && served !== undefined) return served(name);` became a rethrow. Anchor 1 → 0, blob `17d55e44ce60` → `ab01b636efef`. Result: Tests 5 failed, 17 passed (22). Red: `PUT /:name` and `POST /` with no metadata store (admitted 200 into the served holder), `PUT /:name` in the served form keeping the served holder's secret, and the booted-kernel `PUT` and `POST` (200 into the enabled holder's row). Restored: blob after restore `17d55e44ce60` == HEAD, `git diff HEAD` empty. </details> <details><summary>Gates and the dogfood battery</summary> - `dispatch-gates --commands` at `e5468471`: 75 families, the same list as at `e6f54de659`. All 75 run on `e5468471`: 74 exit 0, and `check-empty-changeset --base` exit 1 (the correction above). `check:type-check-debt` (first attempt a lock queue-timeout, exit 3) and `check:dual-build-cjs-loads` (first attempt PREREQUISITE NOT MET, exit 3) were re-run under the lock after the builds they need: both exit 0 (re-measure 0 raw tsc errors; 123 require entry points across 72 packages load). `--ran`: "75 derived, 75 run, 0 NOT-MEASURED, 0 UNRUN". - Dogfood battery (`pnpm --filter @objectstack/dogfood test` after the `@objectstack/dogfood^...` build), at `e6f54de659`: Test Files 473 passed, 3 skipped (476); Tests 4003 passed, 42 skipped (4045); exit 0. `e5468471` changes no built code. </details> CI on `e5468471`: 34 success, 16 skipped, 1 failure (`Check Changeset`, the correction above). Of the eleven required contexts, the seven reported on this head are success (`Lint & Repo Gates`, `TypeScript Type Check`, `Test Core`, `Build Core`, `Governed Surface Queue Guard`, `Test UI`, `Dogfood Regression Gate`); `Lint UI`, `Type Check UI` and `Build & E2E UI` skipped (no `ui/` path), and `Live E2E UI` has no run on this head. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3 <!-- signed: repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f84dc19 commit 162fe54

6 files changed

Lines changed: 617 additions & 20 deletions

File tree

‎.changeset/33905-disabled-sole-holder-flow.md‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ What moves, for such a flow, while its package is disabled:
1818
- `getFlow(name)` answered the flow. It now answers `null`, so the bare HTTP doors that ask it first (`GET /automation/NAME`, `POST /automation/NAME/trigger`, `POST /automation/trigger/NAME`, `POST /automation/NAME/toggle`, `POST /automation/NAME/clone`, `GET /automation/NAME/runs`) answer `404`, which is what the namespaced address `/automation/NAMESPACE/NAME…` already answered.
1919
- `toggleFlow(name, …)` switched the flow. It now rejects with `Flow 'NAME' not found`.
2020

21-
Three HTTP write doors ask `getFlow` whether the name is held, and move with it for such a flow. These answers were read from the runtime source; the engine's half of the clone answer was measured. Each holds only where the door's earlier checks, such as the packaged-base and authoring rules, let the request through.
22-
23-
- `POST /automation/SOURCE/clone`, with the flow's name as the new name: the taken-name probe refused the copy with `409`. It now finds no flow and lets the copy through. The engine files the copy's body in the disabled package's slot of the name, and once the package is enabled again its trigger runs the copy's body until the next re-sync. That is the answer the door already gives once the disable's re-sync has withdrawn the flow, so the door accepts nothing the normal path refuses.
24-
- A definition write (`POST /automation`, `PUT /automation/NAME`) or a clone that the engine accepts and that is then refused (an unknown `notify` channel, a refused landing, a refused save) put back the definition the engine held. It now has nothing to put back, so it removes the name's registration. A `PUT` body that leaves out a stored credential no longer keeps the one the engine held.
25-
- `DELETE /automation/NAME` answered a deletion. It still removes the engine's registration, but now answers `404` unless a stored row was removed.
21+
The HTTP write doors that ask a lasting question of the name do not move with it: the clone door's taken-name check on the new name, the definition a refused `POST /automation` or `PUT /automation/NAME` puts back, the stored credential a `PUT /automation/NAME` body, or a `POST /automation` body onto a name the engine holds, keeps when it leaves it out, and the `DELETE /automation/NAME` existence check read the flow the engine holds whatever its package's enable state. For such a flow the clone's new name is refused `409`, the held definition is put back, the credential is kept and `DELETE` answers a deletion, as before this release. A name two packages hold is read at those doors on its served holder, as the bare entries read it.
2622

2723
Remedy: enable the package. Its flow runs on its trigger again with no re-arm, and the bare entries serve it again.
2824

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
'@objectstack/runtime': patch
3+
'@objectstack/service-automation': patch
4+
---
5+
6+
fix(runtime): the automation write doors keep a flow whose only package is disabled, whatever that package's enable state
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
**Added:** `AutomationEngine.getHeldFlow(name)` on `@objectstack/service-automation`: the flow the engine holds under a bare name, judged over every holder (a disabled package's included, `null` for a name it does not hold or a slot-key spelling); a name two packages hold is refused `409` naming every holder. Like `getFlow`, it settles the name first, so a lone qualified slot of a name one package holds again is re-keyed to the bare name.
12+
13+
Four `/automation` write doors ask a lasting question of a flow name: the clone door's taken-name check on the new name, the copy a refused definition write (`POST /`, `PUT /automation/NAME`) puts back, the credential `PUT /automation/NAME`, or `POST /automation` onto a name the engine already holds, keeps when the body leaves it out, and the `DELETE /automation/NAME` existence check. They read the engine's served view (`getFlow`), in which a flow whose one package is disabled is no flow. For a name one package holds they now read the flow the engine holds over every holder, through `getHeldFlow`, so their answers no longer depend on whether that package is enabled. For a flow whose only package is disabled while the engine still holds it:
14+
15+
- Clone with this flow's name as the new name: refused `409`, the door's name-taken answer, and nothing is registered. Before, the copy was admitted and filed in the disabled package's slot.
16+
- A definition write the engine accepts and the store then refuses: the flow the engine held is registered again. Before, the name was withdrawn.
17+
- `PUT`, or `POST /` onto the name, with a body that leaves out a stored credential: the stored credential is kept. Before, nothing was carried forward.
18+
- `DELETE`: the flow is removed and the door answers a deletion. Before, the door removed it and answered `404`.
19+
20+
These are the answers the last release gave: the served view changed after it.
21+
22+
A name two packages hold is read at these doors on its served holder, as before: a refused definition write puts back the served holder's body, and a `PUT`, or a `POST /` onto the name, keeps the served holder's stored credential. With one holder disabled, a package-less `PUT /automation/NAME` or `POST /automation` onto such a name is admitted into the enabled holder, with or without a metadata store (the store's save, naming no package, writes the enabled holder's row), as before. While both holders are enabled, the definition writes and `DELETE` are refused `409` (`RESOURCE_CONFLICT`) naming every holder, as before.
23+
24+
The clone door's new name: a name two packages hold is taken. While one holder is disabled it gets the door's name-taken `409`, as before. While both are enabled, the engine's refusal used to leave the door thrown, naming every holder; the door now answers its own name-taken refusal, returned, with the same status and code (`409`, `RESOURCE_CONFLICT`), whose remedy is a new name. One exception, as before: a name two packages hold with both holders disabled is not taken at the clone door (no holder is served, so the door finds no flow there) and the copy is admitted.
25+
26+
A flow of an enabled package, and a name the engine does not hold, answer as before. The read and run doors (`GET`, trigger, toggle, runs, the clone's source) keep the served view.

0 commit comments

Comments
 (0)