Repository navigation
Commit 4d5cfa9
fix(automation): status rows of a flow name two packages hold carry their package; the toggle reads back the switched slot (#38652)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9RgRdwG1S43a4gfYWB4Ytyp)_
Fixes #34891
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
-
管理员在自动化页面开关一个由两个已安装包同名持有的流程时,开关回显的状态从"照抄请求"变为"读回该包流程实际存储的状态";状态接口每行多带所属包。
- 属于"一个名字多个包各自持有"的包作用域收口,替管理员解决开关显示与流程实际是否运行不一致的问题。
- 若出错,影响面是这类同名流程的开关回显,流程本身的开关写入不变;可直接撤回本改动。
- 无
## What changes
- `FlowRuntimeState` (`@objectstack/spec/contracts`) gains an optional
`packageId`: the package of the engine slot the row reads (ADR-0150 D4,
one slot per package and name), absent for a flow no package holds. The
spelling is the slot's own (`FlowSlot.packageId`,
`FlowContender.packageId`, the activation ledger row's `packageId`).
- `getFlowRuntimeStates` (service-automation `flow-definitions.ts`)
stamps it on every row of a package-held slot, read from the engine's
`flowSlotPackage(key)`. The engine wrapper's duplicated inline return
type is replaced by one `FlowRuntimeStateRow` type (`FlowRuntimeState`
plus the shadowing receipt), and the wrapper's host passes
`flowSlotPackage`.
- The toggle door (`packages/runtime/src/domains/automation.ts`) records
the package of the slot it serves when the admission hands it a
`flowSlotView`, and reads back the row of `(that package, name)`. The
two-or-more-rows echo is gone for that case. The request is still echoed
in three cases, the same three the route table, the door comment and the
changeset name: a service that does not implement
`getFlowRuntimeStates`; a reading that holds no row of the switched
flow; and two or more rows of the name on a door serving no slot, which
the composed runtime cannot reach because the bare `toggleFlow` refuses
a shared name (see Acceptance notes).
- Landing point is the claim's file surface. One test file outside the
literal surface: the producer pins went into
`packages/services/service-automation/src/flow-slots-per-package.test.ts`
as a new top-level `describe`, because that file is the engine's
per-slot harness and a pin for a component with a shared harness goes
there. Test-only.
Read first, by risk:
1. `packages/runtime/src/domains/automation.ts`, the toggle arm's
read-back filter (the `flowSlotPackage` capture at the admission block
and the `rows` filter).
2. `packages/services/service-automation/src/flow-definitions.ts`,
`getFlowRuntimeStates` (the `packageOf` spread).
3. `packages/spec/src/contracts/automation-service.ts`, the new
`packageId` member.
## Tests
- Door (`automation-addressed-route.test.ts`, the co-held toggle suite):
the double now reads rows the engine's way, each carrying its slot's
`packageId`, and composes a status that keeps a slot off apart from the
switch. New red line: the switched slot is republished `obsolete` while
the switch awaits its durable write; the door answers `200 { enabled:
false }`. The three existing co-held cases now pass by read-back, not by
echo.
- Engine (`flow-slots-per-package.test.ts`, new `describe` "the status
rows carry their slot's package"): a co-held name's two rows each carry
their own package and own state; a one-holder name's row carries its
package and a package-less flow's row has no `packageId` key; and the
race measured on the real engine: with the activation store's write held
open, P2's flow republished `obsolete` mid-switch, `toggleFlowSlot`
resolves, two rows of the name exist, P2's own row reads `enabled:
false, status: 'obsolete'`, and `executeSlot` refuses `FLOW_DISABLED`.
The race the card describes can be reached as written.
- Spec type pin: `FlowRuntimeState['packageId']` is `string |
undefined`.
- `automation-toggle-caller.test.ts` is unchanged: the no-read echo
stays pinned there.
<details><summary>Ablations (each restored: blob equals HEAD, git diff
HEAD empty)</summary>
- Producer: deleted the `...packageOf(this.flowSlotPackage(name)),` line
(`scripts/ablation-replace.mjs`, mutation landed: anchor 1 to 0).
`flow-slots-per-package.test.ts -t 'status rows carry'`: `Tests 3 failed
| 92 skipped (95)`, all three new engine cases red.
- Door: replaced the package filter with `true` (mutation landed: anchor
1 to 0). Runtime toggle files: `Tests 1 failed | 65 passed (66)`. The
red is the obsolete-republish case, answering
`{"name":"convert","enabled":true}`, which is the card's defect. A first
attempt used replacement text that already occurred in the file; the
tool refused it and restored before running anything, so that attempt
measured nothing.
</details>
<details><summary>Suites (head 72f56b4)</summary>
- `pnpm --filter @objectstack/service-automation test`: Test Files 299
passed (299), Tests 4442 passed (4442), exit 0.
- `pnpm --filter @objectstack/runtime test`: Test Files 656 passed
(656), Tests 12522 passed, 25 skipped (12547), exit 0.
- `pnpm --filter @objectstack/spec test`: Test Files 913 passed (913),
Tests 28893 passed, 1 todo (28894), exit 0.
- `turbo run typecheck` for spec, service-automation and runtime: 44
tasks successful. The runtime test layer first failed TS2307 on
`@objectstack/driver-turso` in three files this diff does not touch,
because that devDependency was not built in this worktree. After
building it: `check:test-typecheck: OK` for both packages.
</details>
## Acceptance notes
- The echo that remains: a service whose reading holds NO row of the
switched flow. For the engine on the co-held path that happens only if
the slot is withdrawn while the switch is in flight, which is another
race than this card's. That arm was already the behaviour before this
change and is pinned by other suites in the same file, whose doubles
read no rows. Left as it is.
- A bare toggle (no slot view) still reads the name's one row. Two rows
on a bare door would need an engine with a name resolver but a door with
no registry. Bare `toggleFlow` refuses a shared name otherwise, so that
case is not reachable in the composed runtime.
- `flowRuntimeStateOf` (`packages/types/src/flow-runtime-state.ts`, the
MCP definition reader's switch) still answers `undefined` on two rows of
one name. It could pick by `packageId` once its callers pass the item's
package. Not changed here: it is outside this card's surface, and it
fails closed ("unknown is answered as absent, never as enabled").
- Other row readers are untouched, because the field is optional:
`packages/client` (`getRuntimeStatus` docblock lists the optional
members and does not yet name `packageId`), `packages/cli` `serve.ts`,
and the Console under `ui/`. A Console status badge for a co-held name
could pick its row by `(packageId, name)`. No `ui/` change is in this
PR.
## Verification
Two-minute check: `pnpm --filter @objectstack/runtime exec vitest run
--maxWorkers=2 src/domains/automation-addressed-route.test.ts -t
'republished'`. Expected: 1 passed. The obsolete-republish case answers
`{ enabled: false }`.
<details><summary>Local gates (derived from dispatch-gates --commands at
72f56b4)</summary>
- 100 derived families run. `dispatch-gates --ran` with exit codes
recorded: `100 derived famil(ies) accounted for — 98 run, 2 NOT-MEASURED
(2 DERIVED from a recorded exit 3)`.
- NOT MEASURED: `check:dual-build-cjs-loads`, reason: PREREQUISITE NOT
MET, it reads every package's built output and 38 packages have no
`dist/` in this worktree. `check:published-readme-exports`, reason:
PREREQUISITE NOT MET, 32 packages' built type entries are missing. Both
are left to CI.
- Every other derived family exited 0, among them `check:api-surface`,
`check:authorable-surface`, `check:docs`, `check:export-origins`,
`check:engine-double-contract`, `check:nul-bytes`,
`check:cross-package-test-inputs` and `check:test-source-alias`.
- `overlap-check.mjs` before each push: `VERDICT clean exit 0` against
origin/main and #38618, which shares `engine.ts` and merges cleanly.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmQJUGAAa5rz9Yi2DvW)_
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmQJUGAAa5rz9Yi2DvW -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 74a15cb commit 4d5cfa9
8 files changed
Lines changed: 196 additions & 45 deletions
File tree
- .changeset
- packages
- runtime/src/domains
- services/service-automation/src
- spec/src/contracts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
729 | 729 | | |
730 | 730 | | |
731 | 731 | | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
732 | 738 | | |
733 | 739 | | |
734 | 740 | | |
735 | | - | |
| 741 | + | |
736 | 742 | | |
737 | 743 | | |
738 | 744 | | |
| |||
751 | 757 | | |
752 | 758 | | |
753 | 759 | | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
754 | 763 | | |
755 | 764 | | |
756 | 765 | | |
757 | 766 | | |
758 | 767 | | |
759 | 768 | | |
760 | | - | |
| 769 | + | |
761 | 770 | | |
762 | 771 | | |
763 | 772 | | |
| |||
771 | 780 | | |
772 | 781 | | |
773 | 782 | | |
774 | | - | |
| 783 | + | |
775 | 784 | | |
776 | 785 | | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
777 | 810 | | |
778 | 811 | | |
779 | 812 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3890 | 3890 | | |
3891 | 3891 | | |
3892 | 3892 | | |
3893 | | - | |
3894 | | - | |
3895 | | - | |
3896 | | - | |
| 3893 | + | |
| 3894 | + | |
| 3895 | + | |
| 3896 | + | |
| 3897 | + | |
| 3898 | + | |
| 3899 | + | |
| 3900 | + | |
| 3901 | + | |
| 3902 | + | |
3897 | 3903 | | |
3898 | 3904 | | |
3899 | 3905 | | |
| |||
4178 | 4184 | | |
4179 | 4185 | | |
4180 | 4186 | | |
| 4187 | + | |
| 4188 | + | |
| 4189 | + | |
4181 | 4190 | | |
4182 | 4191 | | |
4183 | 4192 | | |
| |||
4192 | 4201 | | |
4193 | 4202 | | |
4194 | 4203 | | |
| 4204 | + | |
4195 | 4205 | | |
4196 | 4206 | | |
4197 | 4207 | | |
| |||
4547 | 4557 | | |
4548 | 4558 | | |
4549 | 4559 | | |
4550 | | - | |
4551 | | - | |
4552 | | - | |
4553 | | - | |
4554 | | - | |
4555 | | - | |
4556 | | - | |
4557 | | - | |
4558 | | - | |
4559 | | - | |
4560 | | - | |
4561 | | - | |
4562 | | - | |
| 4560 | + | |
| 4561 | + | |
| 4562 | + | |
| 4563 | + | |
| 4564 | + | |
| 4565 | + | |
| 4566 | + | |
| 4567 | + | |
| 4568 | + | |
| 4569 | + | |
| 4570 | + | |
| 4571 | + | |
| 4572 | + | |
| 4573 | + | |
| 4574 | + | |
| 4575 | + | |
| 4576 | + | |
| 4577 | + | |
| 4578 | + | |
| 4579 | + | |
| 4580 | + | |
4563 | 4581 | | |
4564 | 4582 | | |
4565 | | - | |
| 4583 | + | |
| 4584 | + | |
4566 | 4585 | | |
4567 | 4586 | | |
4568 | 4587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| |||
5978 | 5979 | | |
5979 | 5980 | | |
5980 | 5981 | | |
| 5982 | + | |
| 5983 | + | |
| 5984 | + | |
| 5985 | + | |
| 5986 | + | |
5981 | 5987 | | |
5982 | | - | |
5983 | | - | |
5984 | | - | |
5985 | | - | |
5986 | | - | |
5987 | | - | |
5988 | | - | |
5989 | | - | |
5990 | | - | |
5991 | | - | |
5992 | | - | |
5993 | | - | |
| 5988 | + | |
5994 | 5989 | | |
5995 | 5990 | | |
5996 | 5991 | | |
| |||
6000 | 5995 | | |
6001 | 5996 | | |
6002 | 5997 | | |
| 5998 | + | |
6003 | 5999 | | |
6004 | 6000 | | |
6005 | 6001 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
264 | 260 | | |
265 | 261 | | |
266 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
267 | 270 | | |
268 | 271 | | |
269 | 272 | | |
| |||
275 | 278 | | |
276 | 279 | | |
277 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
278 | 286 | | |
279 | 287 | | |
280 | 288 | | |
| |||
0 commit comments