You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 74e85da
Browse filesBrowse the repository at this point in the historyBrowse files
fix(service-automation): the two-package flow collision line says neither flow is armed (#31802)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9ENWEBFHM19dDwc5CiBumP9)_Fixes#31754
Clause-②: no — log text only; what the engine arms, refuses or runs does
not change. Measured on head ea1c60c on a real cold boot (ObjectKernel
+ ObjectQLPlugin + SqlDriver): in all three refused shapes the engine
refuses the name and arms nothing, the same as on base; only the
collision line and its meta change. `engine.ts` is not in the diff, and
the returned winner and `FlowShadowingRecord` are unchanged.
Metadata-protocol: none
## 维护者速读
-
改了什么:启动日志里「流程名冲突」那一行,现在先问引擎用的同一个包作用域解析器。解析器拒绝这个名字时(另有一个包也发了同名流程),这一行写「两个都不启用」,日志附带的
meta 也不再写 armed。
- 为什么改:E1(#31738)后引擎对这类名字一个都不启用,但日志在三种情形下仍写「启用了
X」:两个包、两个包加覆盖件、两个包加一条存储行。
- 风险与回滚:只改日志文字和 meta,引擎行为不变;解析器放行的名字、以及没接解析器的组合,日志逐字节同 main。回滚即 revert。
-
先看:`packages/services/service-automation/src/flow-precedence.ts`(`refusalOf`
分支),`plugin.ts` 的 `resolveFlowContenders`,再看
`flow-declared-override-first-boot-pull.integration.test.ts` 末尾新增的
describe。
- 两分钟验证:`pnpm --filter @objectstack/service-automation exec vitest run
src/flow-declared-override-first-boot-pull.integration.test.ts -t
31754`,预期 7 条全绿。
- 需要你做的:无,席位落地。
## What changes
The boot pull's collision warning (`resolveFlowPrecedence`) now asks the
resolver the engine asks. Following the seat's ruling (A, card comment
6732521115):
- `resolveFlowPrecedence` takes an optional fifth argument,
`refusalOf(name)` (type `FlowNameRefusalReader`, exported as a type from
the package root). It returns the refusal message the engine's flow-name
resolver gives `name` for a caller with no package, or `undefined` when
it serves the name.
- `AutomationServicePlugin.resolveFlowContenders` (the one precedence
path for the boot pull, the `kernel:ready` sync and the
`metadata:reloaded` re-sync) fills it from `flowNameResolver(ctx)`, the
same reader `init()` attaches to the engine (`setFlowNameResolver`), so
the warning says "refused" exactly when `registerFlow` refuses.
- When the resolver refuses, every arm reads, instead of "arming FIRST
…":
```text
[Automation] Flow name collision: 'NAME' is claimed by N definitions (CONTENDERS); arming neither: the engine refuses this bare name for a caller with no package (ADR-0150 D3), so no definition dispatches; the 'failed to register flow' warning for 'NAME' names every holder. Rename one of them.
```
("arming none of them" when three or more definitions are listed), and
the warning's meta is `{ flow, refused: true, contenders }` (no `armed`,
no `shadowed`).
- When the resolver serves the name, or no resolver is attached, every
arm's line and meta are byte for byte main's.
Measured on base f647430 with a real cold boot (the round-2 report,
6732507604), three shapes in which the engine refuses while main's line
said a flow was armed:
| Shape | main's line | Engine | This PR |
|:--|:--|:--|:--|
| two packages | "arming package 'A' by package id" | refuses, arms
nothing | arming neither |
| the declared override (A's `.custom`) beside a second package |
"arming the declared override in 'A.custom' …" | refuses, arms nothing |
arming neither / arming none of them |
| two packages plus a package-less stored row | "arming package 'A'
because a managed package's flow is sealed" | refuses, arms nothing |
arming neither / arming none of them |
The shadowing record and its three readers (the bootstrap restatement in
`plugin.ts`, the CLI banner via `serve.ts`/`format.ts`, `armedFrom` on
runtime states) are unchanged: measured on the dogfood showcase boot
holding a two-package clash, the engine records no receipt for a refused
name (`getShadowedFlows()` is `[]`, no runtime-state row, no "is ARMED"
line), because the boot pull records it only after `registerFlow`
succeeds.
Pinned strings, found by searching the tree for "by package id",
"arming", "Flow name collision" and "other definition(s)":
- `packages/cli/src/utils/format.boot-warning-classes.test.ts`
(print-once case): **forced test change.** Its collision record paired a
package with a runtime row (the sealed class) but spelled the "by
package id" arm. It now carries the line the sealed class prints. The
assertions (one collision record kept, the restatement withheld) are
unchanged. Because this PR edits the file, `check:test-source-alias`
judged its reach and asked for ten module-top side-effect imports (the
dynamic `import()`s `serve.ts` reaches), the same block
`dev-mcp-connect-hint-origin.test.ts` carries; added, gate green.
- `flow-name-shadowing.test.ts`, `flow-precedence-loader-set.test.ts`:
pin the sealed and override arms with no resolver; unchanged and green.
- `flow-declared-override-first-boot-pull.integration.test.ts`: its boot
helper gains an optional second package (`Second`: none, before or after
the shipping package); every existing case passes `none` by default and
is unchanged.
## Tests
- **Pins, real cold boot** (new top-level describe `[#31754]` in
`flow-declared-override-first-boot-pull.integration.test.ts`): the three
shapes above × the second package registered before and after the
shipping one (6 cases). Each asserts the engine's refusal (every 'failed
to register flow' record for the name says "held by 2 packages" and
names both packages; `getFlow` null before and after `kernel:ready`; no
receipt) and that every collision line for the name agrees ("arming
neither"/"arming none of them", the pointer, no "arming package / the
declared override / a runtime-authored", no "Only the armed definition
dispatches"; meta `refused: true` without `armed`).
- **CONTROL, a name the resolver serves**: one package plus a
package-less row on the same real boot; the line is `toBe` main's sealed
line, the meta is main's, nothing refused, the base armed.
- **CONTROL, no resolver** (E1 harness,
`flow-package-scoped-resolution.test.ts`): the four arms (by package id,
sealed, declared override, arrival order), each `toBe` main's line.
- **Pin, E1 harness**: two packages in both registration orders, with
`refusalOf` built as the plugin builds it; line `toBe` the new text, and
the engine refuses naming both.
Ablations (fix committed first, `scripts/ablation-replace.mjs`, each
restored to the HEAD blob with `git diff HEAD` empty):
<details><summary>refusalOf dropped in
plugin.resolveFlowContenders</summary>
```text
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 68793fa -> 47f53d7e7487
× two packages, the second package registered before the shipping one
× two packages, the second package registered after the shipping one
× the declared override beside a second package, the second package registered before the shipping one
× the declared override beside a second package, the second package registered after the shipping one
× two packages and a package-less stored row, the second package registered before the shipping one
× two packages and a package-less stored row, the second package registered after the shipping one
Tests 6 failed | 7 passed (13)
Received: "[Automation] Flow name collision: 'crm_ticket_created' is claimed by 2 definitions (package 'com.acme.crm', package 'com.acme.other'); arming package 'com.acme.crm' by package id, …"
Received: "… (the declared override in 'com.acme.crm.custom' (sys_metadata), package 'com.acme.crm', package 'com.acme.other'); arming the declared override in 'com.acme.crm.custom' (sys_metadata) because it is the declared override of 'com.acme.crm' (ADR-0146 D9), …"
Received: "… (package 'com.acme.crm', package 'com.acme.other', a runtime-authored row (sys_metadata)); arming package 'com.acme.crm' because a managed package's flow is sealed (ADR-0126 §2), …"
ablation-replace: ok restored: blob == HEAD (68793fa) and `git diff HEAD` is empty
```
</details>
<details><summary>The refused branch in flow-precedence.ts
disabled</summary>
```text
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 56e9626 -> 1bcc1dc269fb
× two packages, registered alpha first: the line arms neither, and the engine refuses
× two packages, registered stranger first: the line arms neither, and the engine refuses
× (the six real-boot cases, as above)
Tests 8 failed | 5 passed | 26 skipped (39)
ablation-replace: ok restored: blob == HEAD (56e9626) and `git diff HEAD` is empty
```
The 5 passing cases are the five CONTROLs.
</details>
## Acceptance notes
- **Correction.** An earlier revision of this body said that two
packages plus an environment row keep a true "arming package …" line,
because the resolver answers a caller with no package with the
environment row. That was **reasoned from the resolver's code, not
measured, and it is wrong**: on a real cold boot the engine refuses that
name too (round-2 report 6732507604, shape 3 above). This revision
covers it.
- The line asks `flowNameResolver(ctx)`, the reader `init()` attaches to
the engine, not the engine itself (no new engine method). A host that
attaches a different resolver to the engine by hand would bypass the
plugin altogether; no such caller exists in this repository.
- `FlowNameRefusalReader` is a new exported type name (the optional
parameter's type), named after the existing `FlowNameResolver`. Open
question for the seat.
## Verification
Every reading below is on head ea1c60c (the final commit), base
f647430.
- `pnpm --filter @objectstack/service-automation test`: Test Files 267
passed (267), Tests 3493 passed (3493). `typecheck`: exit 0. Root
`eslint --no-inline-config packages/services/service-automation`: exit 0
(the package has no `lint` script).
- `pnpm --filter @objectstack/cli exec vitest run --project unit
src/utils/format.boot-warning-classes.test.ts
src/commands/serve-automation-shadowing.test.ts`: 34 passed (34). The
CLI `integration` tier is declared to CI.
- `node scripts/pm/dispatch-gates.mjs --commands`: 73 derived gates,
each run, all exit 0; `--ran` reconciliation: 73 run, 0 NOT-MEASURED, 0
UNRUN.
- Full dogfood: not run (no `!` in the title, no `(narrowing)` arm); the
CI queue runs it.
<!-- signed: domain:server#3 · os-steve ·
session_01ADHkmT3p3cREt88Gsd1rP3 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(service-automation): the boot log's flow name collision line says no flow is armed when the engine refuses the name
6
+
7
+
Clause-②: no — log text only; what the engine arms, refuses or runs does not change.
8
+
Metadata-protocol: none
9
+
10
+
When a second package ships a flow of the same name, the engine's package-scoped resolver refuses the bare name for a caller with no package, and `registerFlow` arms neither flow, naming both packages (ADR-0150 D3). The boot pull's collision warning still read "arming package 'FIRST' by package id", "arming package 'FIRST' because a managed package's flow is sealed" or "arming the declared override …", depending on which other definitions sat beside the two packages, and its log meta named an armed contender.
11
+
12
+
The warning now asks the same resolver the engine asks. When it refuses the name, every such line reads "arming neither: the engine refuses this bare name for a caller with no package (ADR-0150 D3), so no definition dispatches; the 'failed to register flow' warning for 'NAME' names every holder. Rename one of them." ("arming none of them" for three or more definitions), and its meta carries `refused: true` and the contenders instead of `armed`/`shadowed`.
13
+
14
+
A name the resolver serves keeps its line byte for byte, and so does every line when no resolver is attached. `resolveFlowPrecedence` takes the reader as an optional fifth argument (`FlowNameRefusalReader`, exported as a type); the automation plugin passes it.
0 commit comments