Skip to content

fix(seed): a deferred-key seed row a person deleted stays deleted - #35361

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34856-deferred-key-ledger
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34856-deferred-key-ledger

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #34856

Clause-②: no
Metadata-protocol: none

维护者速读

What changes

A seed row whose externalId includes 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.

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 id spelling 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 describe in packages/metadata-protocol/src/seed-loader-deferred-key-reference.test.ts, the #34800 harness (real SeedLoaderService, 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:

  • ignore and upsert: deleted while the person is still missing, not inserted again (success, skipped 1, inserted 0).
  • ignore and upsert: deleted, then the person signs up, still not inserted again.
  • The ledger entry equals [["id", ROW_ID]] for the row's landed id.
  • CONTROL: a complete-key row deleted stays deleted, as before.
  • CONTROL: a deferred-key row the seed never landed here still lands, beside the deleted one.
  • A kept deferred-key row found again and filled once the person signs up is the existing pin with the landed-key record kept, the row is found too… in the same file, still green.
  • CONTROL: a deliberate re-seed brings the deleted row back.

Acceptance notes

  • Real-engine pin (ObjectQL + SqlDriver) not added: @objectstack/metadata-protocol has no objectql/driver dependency, and the real-driver sibling lives in packages/runtime, outside this card's file fence. Loader-level pins with the copied engine double cover the behaviour.
  • Edge, not changed: when a dataset authors organization_id as a natural-key reference rather than taking the stamped tenant organization, seedDeferredKeyRowId is 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's rowLandedWithEmptyKeyReference). deferredLandedKey is 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
  • Before the fix (pins run against the unchanged loader at 81c0947): Tests 7 failed | 2 passed (9). The four delete cases failed with expected [ { name: 'Onboard', … } ] to have a length of +0 but got 1, which reproduces the card.
  • pnpm --filter @objectstack/metadata-protocol typecheck exit 0; full package vitest 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).
  • On ca2df4f: 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)
  • Delete the ledger-record line (else if (deferredKeyFields.size > 0 …) landedKeyByRecordIndex.set(i, deferredLandedKey)): 6 failed.
  • Replace the honour branch with return false: 5 failed (on ca2df4f, against the folded pins: Tests 5 failed | 12 passed (17)).
  • Delete deferredUpdates.length = deferredUpdatesBeforeRow: 2 failed (the success assertion on the still-missing cases).
  • Mutations landed through scripts/ablation-replace.mjs (anchor 1 to 0, blob moved); no build involved, as the pins import ./seed-loader.js from source.
Gates
  • dispatch-gates.mjs --commands derived 67 families for this diff; all 67 run on ca2df4f, all exit 0. --ran reconciliation: 67 derived, 67 run, 0 NOT-MEASURED, 0 UNRUN.
  • check-plugin-teardown-shape.mjs --self-test first 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

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
@github-actions github-actions Bot added 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 Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

1 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 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 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 — 10 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 3819afeca1307a2c1095ff4abe2eeaa6871d1b2a → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 5733c1bc6a4a24337de94a5e291f3e89e99833ea — the merge of head ca2df4fd69358c2046b56bf2e0ed163fc2c6e9e0 into base 3819afeca1307a2c1095ff4abe2eeaa6871d1b2a, 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 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

⚠️ 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#5 · os-bill · session_01Utp6CaysxGzF62ACvZ1x9x

Final head for review · area pkg-1 · 2026-11-19T06:42Z
Head: ca2df4fd69358c2046b56bf2e0ed163fc2c6e9e0 — every third-party check suite on it completed with no failure.
Fixes #34856 · Clause-②: no · Metadata-protocol: none · +160/−2 over 3 files. The pins sit as a top-level describe in the #34800 harness file seed-loader-deferred-key-reference.test.ts (AGENTS.md shared-harness rule and the pinned engine double), not in a new card-named file as the claim's surface said; overlap-check clean on it.
Review route: L1-a thread. Landing after its ACCEPT, by the area.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 用户能看到什么变化:示例数据里有一类记录,它关联的人当时还没注册。这类记录被人手动删掉后,下次加载示例数据不会再自己冒出来;那个人后来注册了,也不会。
  • 为什么做:以前这类记录删了还会被重新插回去,用户的删除不算数。
  • 出错会怎样:最坏情况是被删的这类记录照旧又出现一次,和修之前一样;其他示例数据照常加载,主动重新灌示例数据时仍会恢复全部记录。
  • 要你做什么:不需要你做任何事,区域审完自己落地。

席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head ca2df4fd69358c2046b56bf2e0ed163fc2c6e9e0 · 2026-11-19T06:44Z

  • 形态 — 3 files, +160/−2 (162 lines): metadata-protocol/src/seed-loader.ts, the 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 harness test file, and one changeset. Base 81c09477, main moved K=13 first-parent commits (< 15, no merge needed). check-governed-merges.mjs --pr 35361: not governed, under the 3000-line limit. Clause-②: no, Metadata-protocol: none.
  • Fixes vs card 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 — the card offers two remedies; this PR takes the second, the derived id. deferredLandedKey is seedLandedKey({ id: seedDeferredKeyRowId(objectName, org, authoredKey) }, 'id'), using the same three arguments as the id the row actually lands with (seed-loader.ts ~:2810). It is read before any reference resolves, so it is the same on the landing load, on a load where the reference is still empty, and on a load where it has resolved. Recording: when landedKeyOf is '' and the row deferred a key field, the row goes into landedKeyByRecordIndex under that key. isWithdrawnRow traced case by case:
    • key '' → no longer returns false early;
    • row still present by key or by id → not withdrawn;
    • complete key recorded → withdrawn, as before;
    • otherwise withdrawn iff the deferred key is recorded.
      A row that landed with its key complete is never recorded under a deferred id, so the new branch cannot match it.
  • Changeset — @objectstack/metadata-protocol patch, read sentence by sentence against the diff and pins. The landedKeys: 'honour' condition, the old "recorded under no key" cause, recording under the id derived from the authored key, the still-empty and resolved-since cases, and the two controls (never landed here still lands; a deliberate re-seed brings it back) all match.
  • Pins — new describe in seed-loader-deferred-key-reference.test.ts:
    • ignore and upsert × (deleted while the reference is still empty / deleted, then the person signs up), each asserting 0 inserted and 1 skipped over two further loads;
    • the ledger row stored under the derived seed_ id;
    • CONTROL: a complete-key row stays deleted as before;
    • CONTROL: a never-landed deferred row still lands beside a withdrawn one;
    • CONTROL: a deliberate re-seed restores it.
  • 门禁 — 53 check-runs on this head: 37 success, 16 skipped (path-filtered), 0 failure.
  • 接受的偏差 — (1) The pins are folded into the existing 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 file as a top-level describe rather than a new card-named file. That is what AGENTS.md asks when a component has a shared harness file, so it is correct, not a deviation. (2) The pins run the real SeedLoaderService over the harness engine double, not ObjectQL with SqlDriver, because those are not dependencies of metadata-protocol. Accepted: the behaviour sits in the loader's ledger logic, not in the driver. (3) A withdrawn deferred row also rolls back its referencesDeferred and deferredUpdates, the same way the row already rolled back referencesResolved. Without that, pass 2 would try to write onto a row that is not there and report a dropped reference. Accepted, and covered by second.success === true in the still-missing pin.
  • 范围外去向 — none found.
  • 落地条款 — not governed: pkg-1 lands this head after this ACCEPT. A new push needs a fresh L1 only if it changes more than a main merge.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CaysxGzF62ACvZ1x9x

Landing · head ca2df4fd69 · after L1-a ACCEPT 7001918313 · 2026-11-19T06:45Z

Probe Reading
Checks at head ca2df4fd69 37 success, 16 skipped, 0 failed
check-governed-merges.mjs --pr 35361 NOT governed, 0 of 3 paths, 162 lines
K 13 (< 15), no locale pack

Status: pr_ready + automerge_enable. On MERGED the area closes out #34856.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 19, 2026 06:45
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 35c6331 Nov 19, 2026
54 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34856-deferred-key-ledger branch November 19, 2026 07:19
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.

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)

2 participants