Repository navigation
Commit 1324973
fix(service-automation): a package-bound flow's run records the checksum its history row is keyed by (#39431)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DMmPgXVVfb8MdCS5amdMX6N)_
Fixes #39388
repo:objectstack@os-elon-musk · os-elon-musk ·
session_016WV4czHUJLmdQAqm4fdDs9
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
运行打进软件包的流程时,挂起的运行现在记下的版本校验和与该流程版本历史里的那一行一致;改动前它多算了服务端读取时加上的包标记,永远对不上;未打包的流程不变。
-
属于流程运行版本固定(重启或改版后,挂起的运行仍按它开始时的版本跑完),替所有用软件包承载流程的作者解决;另一个正在进行的改动会让每个新流程都绑定到软件包。
-
碰到的是有挂起运行、且流程绑在软件包上的用户:修复前这类运行在重启或再次保存后找不回原版本;此改动只改一个计算,可直接撤回。已按旧值记录的运行不迁移(尚无生产客户)。
- 无
## What changes
`flowContentChecksum` (service-automation `flow-identity.ts`) is the
identity a run records (`flow_checksum`) and a resume looks its body up
by in `sys_metadata_history` (`getByHash`). It hashed the body handed to
`registerFlow`. For a flow bound to a package, that body is a served
body: the read stamps `_packageId` on it. The metadata write door strips
`_packageId`, `_packageVersion` and `_provenance`
(`DERIVED_PROVENANCE_KEYS` / `stripDerivedProvenance`,
`metadata-protocol` `protocol-package-bindings.ts`) before it stores the
body and hashes it into `sys_metadata.checksum` and the history row. So
the run's checksum named no history row.
The checksum now drops exactly those three derived provenance stamps
before `hashSpec(body, 'flow')`:
- **Measured**, not assumed: on the publish path the body `registerFlow`
receives carries `_packageId` and nothing else beyond the stored history
body (a one-off spy on `registerFlow` in this suite's package-bound
case; diagnostic removed).
- **Not the `_lock*` family.** A lock is author-declarable and the write
door persists it, so it is part of the stored body and of its checksum.
Dropping it would break the match in the other direction.
- **Not `METADATA_READ_DECORATIONS`.** The flow schema is closed, so a
body carrying `_diagnostics` and the rest is refused by `registerFlow`
before any checksum is taken.
- **One list, not reused.** The write door's list is module-private in
`@objectstack/metadata-protocol` and the claim's file surface is
`flow-identity.ts`. The three keys are spelled once more there, and the
docblock names the write door's list as the authority (see Acceptance
notes).
Every reader of the identity goes through this one function
(`registerFlow` → `flowChecksums`), or stores the history checksum as
given (`recoverStoredFlow`). The approvals run-body witness compares the
engine against itself. A loose (package-less) flow carries no stamp, so
its checksum is unchanged. Per the maintainer rule, runs recorded with
the old checksum are not migrated.
## Read first
1. `packages/services/service-automation/src/flow-identity.ts`: the
whole change. The risk is the key set. Compare it with
`DERIVED_PROVENANCE_KEYS` in
`packages/metadata-protocol/src/protocol-package-bindings.ts` and the
strip at `protocol-save.ts` (`request.item =
stripDerivedProvenance(request.item)`).
2.
`packages/services/service-automation/src/flow-checksum-served-stamps-39388.integration.test.ts`:
the pin. It compares the run row's `flow_checksum` with the history row
the real save wrote, never with a hash the test computes.
## Two-minute verification
`pnpm --filter @objectstack/service-automation exec vitest run
--maxWorkers=2
src/flow-checksum-served-stamps-39388.integration.test.ts` should show 2
passed. Change `hashSpec(withoutServedStamps(definition), 'flow')` back
to `hashSpec(definition, 'flow')` and the package-bound case goes red,
with two different `sha256:` values.
## Tests
- New pin, its own file (the shared harness
`flow-version-pinning.integration.test.ts` is held by open PR 39386, so
the claim excludes it): one kernel over sqlite, the real metadata
protocol save, the real engine.
- A flow saved into an authored package parks a run, and the run's
`flow_checksum` equals its v1 history row's checksum.
- A loose flow is pinned beside it, unchanged. Its row is laid in the
store first and the save runs in place, so the pin holds whether or not
a package-less create is refused.
- Red first, on `f32b7d6d` (before the fix): package-bound case failed,
`expected 'sha256:19e1044b…' to be 'sha256:061e7f8c…'`; loose case
passed.
- Ablation at `1cf80b34` (`scripts/ablation-replace.mjs`, anchor hit 1 →
0, blob `8d9cc8da` → `d54ffdf1`): package-bound red with the same two
hashes, loose green; restored blob == HEAD, `git diff HEAD` empty.
- `pnpm --filter @objectstack/service-automation exec vitest run
--maxWorkers=2` at `1cf80b34`: 307 files, 4560 tests passed.
- `pnpm --filter @objectstack/service-automation typecheck` at
`1cf80b34`: exit 0 (tsc and `check:test-typecheck` OK).
- Consumer spot check: `pnpm --filter @objectstack/plugin-approvals exec
vitest run --maxWorkers=2 src/flow-route.integration.test.ts` against a
rebuilt service-automation `dist`: 58 passed.
## Acceptance notes
- **Drift risk, noted and not filed.** The three keys are spelled in
`flow-identity.ts` and in metadata-protocol's module-private
`DERIVED_PROVENANCE_KEYS`. If the write door ever strips a fourth served
key, this list must follow it. Exporting the write door's list from
`@objectstack/metadata-protocol` and importing it here would remove the
second spelling. That change is outside this claim's file surface.
- **Prose that now reads one step short:** comments still describe the
identity as "`hashSpec(body, 'flow')`": `run-body-witness.ts`
(plugin-approvals), `run-flow-checksum.ts`, `engine-resume.ts`,
`sys-automation-run.object.ts`. They are still true of the stored body
and out of surface, so they are not edited here.
- The card's other half (the version-pinning suite's
resume-after-restart with a package installed before boot) belongs to
open PR 39386's suite and is not in this PR.
## Verification
Local gates: the families `node scripts/pm/dispatch-gates.mjs
--commands` derived for this diff at `1cf80b34`. Readings are in the
report comment on the card. CI runs every family on the PR.
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4czHUJLmdQAqm4fdDs9)_
<!-- signed: repo:objectstack@os-elon-musk · os-elon-musk ·
session_016WV4czHUJLmdQAqm4fdDs9 -->
Co-authored-by: Claude <noreply@anthropic.com>1 parent c9ea363 commit 1324973
3 files changed
Lines changed: 193 additions & 5 deletions
File tree
- .changeset
- packages/services/service-automation/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 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 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
5 | 34 | | |
6 | 35 | | |
7 | 36 | | |
8 | 37 | | |
9 | 38 | | |
10 | 39 | | |
11 | 40 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
16 | 47 | | |
17 | 48 | | |
18 | 49 | | |
| |||
23 | 54 | | |
24 | 55 | | |
25 | 56 | | |
26 | | - | |
| 57 | + | |
27 | 58 | | |
28 | 59 | | |
29 | 60 | | |
| |||
0 commit comments