Repository navigation
fix(seed): a deferred-key seed row a person deleted stays deleted - #35361
Conversation
A seed row that lands while a reference in its externalId is still empty keyed '' and was recorded in the landed-key ledger under nothing, so the next load re-inserted the row a person deleted. Record it under the id it lands with (seedDeferredKeyRowId over the authored key) and let the honour check find that key both while the reference stays empty and after it resolves. A withdrawn row's own pass-2 deferrals are dropped with it. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CaysxGzF62ACvZ1x9x
The engine double there is already pinned in the engine-double ledger, so the new pins reuse it instead of adding a second copy (and a ledger entry). Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CaysxGzF62ACvZ1x9x
📓 Docs Drift Check1 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
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 5733c1bc6a4a24337de94a5e291f3e89e99833ea && git checkout 5733c1bc6a4a24337de94a5e291f3e89e99833ea
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3819afeca1307a2c1095ff4abe2eeaa6871d1b2a ca2df4fd69358c2046b56bf2e0ed163fc2c6e9e0 && git checkout -B drift-repro 3819afeca1307a2c1095ff4abe2eeaa6871d1b2a && git merge --no-ff ca2df4fd69358c2046b56bf2e0ed163fc2c6e9e0
node scripts/docs-audit/affected-docs.mjs --json 3819afeca1307a2c1095ff4abe2eeaa6871d1b2a |
|
repo:objectstack#5 · os-bill · session_01Utp6CaysxGzF62ACvZ1x9x Final head for review · area pkg-1 · 2026-11-19T06:42Z |
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head
|
|
repo:objectstack#5 · os-bill · session_01Utp6CaysxGzF62ACvZ1x9x Landing · head
Status: |
Fixes #34856
Clause-②: no
Metadata-protocol: none
维护者速读
landedKeys开启的 upsert/ignore 数据集里、键含延迟引用的行;键完整的行、从未落地的行、重新播种行为不变。回滚即 revert 本 PR。packages/metadata-protocol/src/seed-loader.ts(deferredLandedKey、isWithdrawnRow、撤回分支里丢弃本行 pass-2 延迟),packages/metadata-protocol/src/seed-loader-deferred-key-reference.test.ts末尾的 seed: a row whose key reference was deferred at landing is recorded under no ledger key, so deleting it does not stick (re-inserted on the next load) #34856 describe。pnpm --filter @objectstack/metadata-protocol exec vitest run src/seed-loader-deferred-key-reference.test.ts,预期 17 个用例全绿(其中 8 个是 seed: a row whose key reference was deferred at landing is recorded under no ledger key, so deleting it does not stick (re-inserted on the next load) #34856 新增)。What changes
A seed row whose
externalIdincludes a reference that is still empty on the load that lands it (the #34800 shape: a person not signed up yet) keyed''in the landed-key ledger, and the ledger records only non-empty keys, so a person's delete of that row was undone by the next load.seed-loader.ts: such a row is now recorded underdeferredLandedKey, anidkey overseedDeferredKeyRowIdof the AUTHORED key (the id the row lands with, seed: a composite externalId that includes a reference only fillable after the first load never matches on later loads, so each load inserts another row #34800 / PR fix(metadata-protocol): a seed key reference empty on the first load holds one row across loads #34854). It is read off the record before any reference resolves, so the next load computes the same key whether the reference is still empty or has resolved since.isWithdrawnRow) consults that key after the existing natural-key and found-by-id checks, both when the record keys''and when it keys complete but that complete key was never recorded.successassertion before this line existed).Why the derived id and not "the key it will carry": the resolved key is unknown while the reference stays empty, which is exactly the state the first delete happens in. The derived id is the one identity computable in both states. Its
idspelling cannot collide with a reference-keyed dataset's natural-key entries, because field names travel with the values in a ledger key.Tests
A new top-level
describeinpackages/metadata-protocol/src/seed-loader-deferred-key-reference.test.ts, the #34800 harness (realSeedLoaderService, that file's already-pinned engine double, a fresh loader per load). It goes in that file rather than a new one so the pinned double is reused instead of copied into the engine-double ledger:ignoreandupsert: deleted while the person is still missing, not inserted again (success, skipped 1, inserted 0).ignoreandupsert: deleted, then the person signs up, still not inserted again.[["id", ROW_ID]]for the row's landed id.with the landed-key record kept, the row is found too…in the same file, still green.Acceptance notes
@objectstack/metadata-protocolhas no objectql/driver dependency, and the real-driver sibling lives inpackages/runtime, outside this card's file fence. Loader-level pins with the copied engine double cover the behaviour.organization_idas a natural-key reference rather than taking the stamped tenant organization,seedDeferredKeyRowIdis computed over the pre-resolution value at the honour check and the post-resolution value at landing (pre-existing in seed: a composite externalId that includes a reference only fillable after the first load never matches on later loads, so each load inserts another row #34800'srowLandedWithEmptyKeyReference).deferredLandedKeyis computed once, before resolution, so the ledger stays self-consistent across loads either way.Verification
All readings on head
ca2df4fd.Red on main, then green
Tests 7 failed | 2 passed (9). The four delete cases failed withexpected [ { name: 'Onboard', … } ] to have a length of +0 but got 1, which reproduces the card.pnpm --filter @objectstack/metadata-protocol typecheckexit 0; full packagevitest run:Test Files 359 passed | 9 skipped (368),Tests 23227 passed | 45 skipped (23272)(run on 3bd8c56; ca2df4f only moves the pins into the harness file).seed-loader-deferred-key-reference.test.ts+seed-loader-landed-ids.test.ts:Tests 44 passed (44); typecheck exit 0.Ablations (each restored, `git diff HEAD` empty and HEAD blob hash matched after)
else if (deferredKeyFields.size > 0 …) landedKeyByRecordIndex.set(i, deferredLandedKey)): 6 failed.return false: 5 failed (on ca2df4f, against the folded pins:Tests 5 failed | 12 passed (17)).deferredUpdates.length = deferredUpdatesBeforeRow: 2 failed (thesuccessassertion on the still-missing cases).scripts/ablation-replace.mjs(anchor 1 to 0, blob moved); no build involved, as the pins import./seed-loader.jsfrom source.Gates
dispatch-gates.mjs --commandsderived 67 families for this diff; all 67 run on ca2df4f, all exit 0.--ranreconciliation: 67 derived, 67 run, 0 NOT-MEASURED, 0 UNRUN.check-plugin-teardown-shape.mjs --self-testfirst exited 3 on a shallow clone (its pinned fixture commit was missing); after fetching that one commit it passed, 48 cases.check:engine-double-contract:OK — 1359 pinned.overlap-check.mjs --branch=HEAD:VERDICT clean exit 0, 0 PR heads share a file.check-nul-bytes.mjs: OK.Generated by Claude Code