Skip to content

fix(service-automation): a package-bound flow's run records the checksum its history row is keyed by - #39431

Queued
objectstack-fleet[bot] wants to merge 1 commit into
mainfrom
claude/issue-39388-wip
Queued

objectstack-fleet[bot] wants to merge 1 commit into
mainfrom
claude/issue-39388-wip

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

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

…d provenance stamps

A flow bound to a package reaches registerFlow stamped with _packageId by
the read, while the write door strips _packageId, _packageVersion and
_provenance before it stores and hashes the body. flowContentChecksum now
drops those three, so a run's flow_checksum equals the checksum its
sys_metadata_history row is keyed by. The _lock family is stored and stays
hashed.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czHUJLmdQAqm4fdDs9
@github-actions github-actions Bot added size/m 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 Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 71 of 256 client-bound route-ledger rows — the other 185 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 185: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 125 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 — 11 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 5c00c57263d07f060ab09674de1b1cb2ff9933e3 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 081aa7c2313be8e31c383e24bb7129a1ec36a25b — the merge of head 1cf80b3430138d45199ab5dfa70ed1315f3d58b3 into base 5c00c57263d07f060ab09674de1b1cb2ff9933e3, 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 081aa7c2313be8e31c383e24bb7129a1ec36a25b && git checkout 081aa7c2313be8e31c383e24bb7129a1ec36a25b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5c00c57263d07f060ab09674de1b1cb2ff9933e3 1cf80b3430138d45199ab5dfa70ed1315f3d58b3 && git checkout -B drift-repro 5c00c57263d07f060ab09674de1b1cb2ff9933e3 && git merge --no-ff 1cf80b3430138d45199ab5dfa70ed1315f3d58b3

node scripts/docs-audit/affected-docs.mjs --json 5c00c57263d07f060ab09674de1b1cb2ff9933e3

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czHUJLmdQAqm4fdDs9

Final green head · 2026-12-04T00:11Z · 1cf80b3430138d45199ab5dfa70ed1315f3d58b3 · every check-run green or expected skip (PR-body guards re-ran green, run 47229450932, after the claim was re-posted with Branch: claude/issue-39388-wip, 7395817292). L1 requested from the seat's L1-b thread at this head.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czzaKz49WLAvKtdyiY

席位核对

L1 verdict (L1-b): ACCEPT at head 1cf80b3430 (Fixes #39388, p2). Read at 2026-12-04T00:14Z.

Face: l1-face --pr 39431 — 12 ok, 1 flag (all-checks): 40 success · 20 expected skip · 1 failed. Floor checks (Lint & Repo Gates, TypeScript Type Check) success. Dogfood not owed. Draft, base main, first line Fixes #39388, no keyword on another card.

The one red check is stale, not a defect. PR-body guards (job 144688560670) failed check:closing-target-claim at 23:33Z: the card's governing claim then named claude/issue-39388-flow-checksum-served-stamps. The claim was re-posted at 23:38Z (comment 7395817292) naming claude/issue-39388-wip, which is this PR's head branch. Same head since. Landing owes a re-run of the failed job on head 1cf80b3430 (rerun-failed.mjs) and a green read before ready / queue — the queue wants every check green.

Diff (3 files, +193/−5), read in full:

  • flow-identity.ts: SERVED_PROVENANCE_STAMPS = ['_packageId', '_packageVersion', '_provenance'] is the same set, same order, as the write door's DERIVED_PROVENANCE_KEYS (packages/metadata-protocol/src/protocol-package-bindings.ts:467), and withoutServedStamps mirrors stripDerivedProvenance (shallow copy, same reference when none present). _lock* stays hashed, which is right: the write door persists it.
  • The only producer of the run identity is flowContentChecksum ← engine-registration-facet.ts:241; there is no second hash site to keep in step. A loose flow carries no stamp, so its checksum is unchanged (pinned).
  • Pin compares the run row's flow_checksum with the history row the real saveMetaItem wrote, never a test-computed hash. Red-first on f32b7d6d and an ablation at this head are in the body with both hash values. Own file, because feat(metadata-protocol)!: refuse a package-less create; retire POST /automation; notify-channel judge on /meta flow saves #39386 holds flow-version-pinning.integration.test.ts — matches the claim's surface.
  • Changeset read sentence by sentence: patch on @objectstack/service-automation; the three bullets match the diff (three keys only, lock kept, package-less unchanged, no migration — maintainer's no-legacy-migration rule).

Dev's open question (export the write door's list instead of a second spelling): not a REWORK. It is outside the claim's file surface, and the docblock names the authority. It is cheap, though: service-automation already imports from @objectstack/metadata-protocol (flow-precedence.ts:103), so exporting DERIVED_PROVENANCE_KEYS from that package and importing it here removes the drift. Recommended to the seat as an S follow-up card (Acceptance notes → filed #N when filed). The stale hashSpec(body, 'flow') prose in four neighbouring files stays as an Acceptance note — still true of the stored body.

Card half: the PR body says the card's resume-after-restart half rides #39386's suite. Fixes is still right if the card's Ask is the checksum match; the zone confirms against the card before ready, otherwise Part of.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czHUJLmdQAqm4fdDs9

Landing · 2026-12-04T00:16Z · head 1cf80b3430 · L1-b ACCEPT 7396551302

reading result
check-governed-merges.mjs --pr 39431 NOT governed · 198 changed lines ≤ 3000
check-runs at head green or expected skip; PR-body guards re-ran green on this head (run 47229450932, after claim re-post 7395817292), superseding the stale job 144688560670
State: ready + auto-merge. Follow-up filed: #39445 (export DERIVED_PROVENANCE_KEYS, one key list by construction). Fixes #39388 stands: the card itself keeps the version-pinning suite on a loose flow until package-before-boot, which rides #39386.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 4, 2026 00:16
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 4, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
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 size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

service-automation: a package-bound flow's run checksum includes the served _packageId stamp, so it never matches its history row

2 participants