Skip to content

fix(metadata-protocol): a seed resolves a lookup another package adds through objectExtensions to the target's id - #36272

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-35254-seed-extension-lookup
Nov 22, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-35254-seed-extension-lookup

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #35254

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:应用作者在模块里给别的包的对象加的关联字段,演示数据现在能正确连上目标记录;以前在本地开发和正式部署启动时,这类字段里存的是目标的名称文字,记录页上显示“受限记录”。
  • 为什么做:模块扩展对象是垂直模块的标准做法,两个下游应用的演示数据因此连错,其中一个连带算错了客户评级和订单利润判断。
  • 出错会怎样:只影响种子数据读取对象定义的方式;万一有问题,表现为某个演示数据的关联没连上或启动日志报出无法解析的引用,撤回本次改动即恢复原样。以前已存成文字的记录不会被自动改写,重新跑一次种子数据即可修正。
  • 要你做什么:无

What changes

SeedLoaderService.resolveObjectDefinition (packages/metadata-protocol/src/seed-loader.ts) is the one place the seed loader reads an object definition. Every per-field decision of a load goes through it: the reference graph, natural-key resolution, required-on-insert, the tenant column, the roll-up strip, the replay comparands and the undeclared-column warning.

The in-process boot (@objectstack/verify without an artifact) bridges the metadata service from the folded registry, so the metadata copy and the engine copy already agreed there. This change makes the artifact boot read what that boot already read.

Tests

New pins in packages/metadata-protocol/src/seed-loader-engine-schema-fallback.test.ts, as a top-level describe('[#35254] …') on that file's engine double, which is already pinned. The metadata double serves the authored ext_order without quote_ref. The engine double's getSchema serves the folded object with quote_ref → ext_quote. Every case has a CONTROL: account_ref, a lookup the owner authored on the same object.

  • upsert and ignore (the inserting modes; insert itself is a retired SeedMode): quote_ref stores the quote's id. insertOrder puts ext_quote (and ext_account) before ext_order. The ext_order node's dependsOn is [ext_account, ext_quote], and its references include quote_ref->ext_quote beside account_ref->ext_account.
  • update: the existing order row gets the quote's id and the account's id, and no second order is inserted.
  • A cycle (ext_quote.order_ref back to the order): the cycle is detected, one side waits for pass 2, and both links resolve. The pass-2 writes and the insertOrder are identical to the CONTROL, where quote_ref is authored.
  • An unknown natural key: both the extension lookup and the authored lookup are refused the same way (one errored record, the same error with the field and target names normalised, no raw key stored), and the extension's error names ext_order.quote_ref.
  • falls back to the metadata service definition when the engine has no schema for the object (renamed from prefers the metadata service definition …): the engine is asked first for every seeded object, and the metadata service is read for each.
Premise on the real boot path: os dev on a two-package artifact

A fixture of the card's shape, not committed: app package qx_app owns qx_account and qx_order (with the authored account_ref). Module qx_mod (built with artifactObjects) owns qx_quote, adds quote_ref (→ qx_quote) to qx_order, seeds O-1 in update mode and inserts O-2 in upsert mode, both with quote_ref by the quote's name. The os dev --fresh boot came from this branch's CLI closure build, and the rows were read with GET /api/v1/data/qx_order as the seeded dev admin.

leg O-1.quote_ref (update) O-2.quote_ref (upsert) account_ref (CONTROL)
origin/main resolver put back (blob 2713d6f4cb) "Acme Annual Renewal Quote" "Acme Annual Renewal Quote" the account's id
this branch (blob fdbca4a779) the quote's id the quote's id the account's id

[SeedLoader] Dependency graph built read insertOrder: [qx_account, qx_quote, qx_order] on both legs. That reading does not tell the legs apart on this fixture; the unit pins assert the edge itself.

Ablation of the resolver order

The fix was committed first. node scripts/ablation-replace.mjs --hold replaced the three-line engine-first body with origin/main's metadata-first body: anchor x1 → x0, replacement x0 → x1, blob fdbca4a77946 → 2713d6f4cbe4. Then pnpm --filter @objectstack/metadata-protocol build ran, and ablation-dist-preflight.mjs @objectstack/metadata-protocol 'fromMetadata?.fields' read the marker present in dist/.

The pins were later moved from a new file into seed-loader-engine-schema-fallback.test.ts unchanged (see Acceptance notes). seed-loader.ts did not change after the ablation.

Suite and gate readings
  • pnpm --filter @objectstack/metadata-protocol test at e3d3340: Test Files 363 passed | 9 skipped (372), Tests 23325 passed | 45 skipped (23370). typecheck: VERDICT command-exit 0. At the head (dd69776, a test-file move only), the two edited test files read Tests 22 passed (22) and typecheck exits 0.
  • dispatch-gates.mjs --commands derived 67 families, and the list is identical at the head. All 67 ran locally, with each exit captured before any pipe:
    • 65 exited 0.
    • check:engine-double-contract exited 1 at e3d3340 (RETAINED: the new file's pinned double was not in the pinned ledger). The pins moved onto the file's already-pinned double, and the gate exits 0 at dd69776.
    • check:dual-build-cjs-loads exited 3 (PREREQUISITE NOT MET: no local dist/ for packages outside this diff). NOT MEASURED locally; CI runs it.
  • --ran reconciliation: "67 derived, 67 run, 0 NOT-MEASURED, 0 UNRUN", exit 0.
  • overlap-check at dd69776: VERDICT clean, exit 0.

Acceptance notes

  • The pins live in an existing file. The dispatch asked for a new file named after the card, unless check:engine-double-contract refused a new engine double. The gate asked for its pinned ledger to be regenerated (--write), and that ledger write was refused in this session. So the pins were folded into seed-loader-engine-schema-fallback.test.ts, whose engine double is already pinned and is the same double the new file had copied.
  • The test harness boot does not reproduce the defect. It was measured: a dogfood test booting bootStack from @objectstack/verify with MetadataPlugin({ artifactSource }) over the same two-package artifact read the extension field absent from metadata.getObject('qa_ext_order') and present in getSchema. Yet it stored the quote's id on BOTH legs of the ablation, so it could not pin this defect, and it is not committed. Only the real os dev boot showed the raw key. Why the harness's seed load sees a different definition was not established. This is reported as a finding, not fixed here. Carried by verify: a bootStack-booted seed resolves an extension lookup that os dev stores as the raw natural key, so the harness cannot pin #35254-class seed defects #36274.
  • Rows an earlier load stored with the raw key are not rewritten. Re-running the seed in update or upsert mode replaces the key with the id (the replay compare sees a difference). The changeset says so.
  • The basic-insert fallback seeder in packages/runtime/src/app-plugin.ts (no metadata service, or the loader threw) does not go through this resolver, as fix(metadata-protocol)!: a seed never stores a roll-up (summary) value; the children compute it, and the load says what it dropped #36118's notes already record.

Verification

Two-minute check: pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/seed-loader-engine-schema-fallback.test.ts. Expect Tests 8 passed, including five [#35254] cases.

Read first, by risk:

  1. packages/metadata-protocol/src/seed-loader.ts, the resolveObjectDefinition hunk: the order flip that every per-field read inherits.
  2. The same file, the summaryFields hunk in loadDataset: fix(metadata-protocol)!: a seed never stores a roll-up (summary) value; the children compute it, and the load says what it dropped #36118's union collapsed onto the single source.
  3. packages/metadata-protocol/src/seed-loader-engine-schema-fallback.test.ts: the probe assertion of the renamed fallback pin, and the new [#35254] block.

Generated by Claude Code

…adds like an authored one

The seed loader now reads each object as the engine serves it (object
extensions folded in) and the metadata service's copy only when the
engine has no schema, so an extension lookup joins the dependency graph
and its natural key resolves to the target's id.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh
…act-boot dogfood repro

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh
…unfixed resolver

Measured: bootStack with the artifact MetadataPlugin resolves the extension
lookup on both legs of the ablation, so it cannot pin this defect; the
real os dev boot does reproduce it (recorded in the PR).

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh
…ne-schema-fallback file, on its pinned engine double

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh
@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 Nov 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/metadata-protocol, touching 3 documentable anchor(s).

2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/data-modeling/validation.mdx (via SeedLoaderService (symbol, a top-level class))
  • content/docs/protocol/objectql/state-machine.mdx (via SeedLoaderService (symbol, a top-level class))

⛔ 1 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-1.mdx (via SeedLoaderService (symbol, a top-level class))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • the SDK route bridge reached 67 of 249 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 28ba01fe6939ac40a5e72efe32ea6b7680eed33e → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 2ecd82d59c5645dbc9deadb851794bbe7a16c6ee — the merge of head dd697760d1b01c723810cac1ba33a0d7d476d71b into base 28ba01fe6939ac40a5e72efe32ea6b7680eed33e, 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 2ecd82d59c5645dbc9deadb851794bbe7a16c6ee && git checkout 2ecd82d59c5645dbc9deadb851794bbe7a16c6ee
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 28ba01fe6939ac40a5e72efe32ea6b7680eed33e dd697760d1b01c723810cac1ba33a0d7d476d71b && git checkout -B drift-repro 28ba01fe6939ac40a5e72efe32ea6b7680eed33e && git merge --no-ff dd697760d1b01c723810cac1ba33a0d7d476d71b

node scripts/docs-audit/affected-docs.mjs --json 28ba01fe6939ac40a5e72efe32ea6b7680eed33e

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

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 28ba01fe6939ac40a5e72efe32ea6b7680eed33e → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh

Final green head (area a4-C, claim 7072946170 on #35254): dd697760d1b01c723810cac1ba33a0d7d476d71b · 2026-11-22T04:48Z

  • 4 files, +274/-48, all in packages/metadata-protocol plus one changeset. SeedLoaderService.resolveObjectDefinition reads the engine's registered schema first (the object as served, extensions folded in by the registry) and falls back to the metadata service only when the engine has no schema for the name, so every per-field decision of a load (graph, natural-key resolution, required-on-insert, tenant column, the seed: a seed row that supplies a summary (roll-up) field value is stored as written, and nothing recomputes it until a child write #35655 roll-up strip, replay comparands, undeclared-column warning) sees extension fields. No extension merging in the loader. The os-dev report is 7074066106.
  • Premise measured on the real boot: os dev --fresh on a two-package artifact of the card's shape stored the raw natural key on origin/main (update and upsert rows) and the target's id with the fix; the authored-lookup control resolved on both legs.
  • Pins: a top-level [#35254] describe in seed-loader-engine-schema-fallback.test.ts on its already-pinned engine double (upsert and ignore, update, a cycle resolved in pass 2, an unknown natural key refused like an authored lookup; authored-lookup control in each). They are not in a new card-named file because check:engine-double-contract would need its ledger regenerated for a new double; the fold follows AGENTS.md's shared-harness rule. Ablation (origin/main's resolver restored, dist rebuilt, marker proven): 7/22 red; restore byte-identical, 22/22 green.
  • Clause-②: no, Metadata-protocol: none. Dogfood battery n/a (no !, no narrowing arm).
  • CI at this head (pr-state): 39 success, 18 expected skip, 0 failed, 0 pending; mergeable_state clean. Local: 67 gate families run, 66 exit 0 at the head; check:dual-build-cjs-loads declared to CI.
  • Deviation: overlap-check was not run before the branch's early pushes; it reads clean at this head.
  • Out of scope: @objectstack/verify's bootStack seed path stayed green on both ablation legs, so the harness cannot pin this class; carried by verify: a bootStack-booted seed resolves an extension lookup that os dev stores as the raw natural key, so the harness cannot pin #35254-class seed defects #36274. The basic-insert fallback seeder (packages/runtime/src/app-plugin.ts) still bypasses the loader, as recorded on fix(metadata-protocol)!: a seed never stores a roll-up (summary) value; the children compute it, and the load says what it dropped #36118.
  • Owed next: L1-a. Not a narrowing: the area lands it after ACCEPT.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5

L1 verdict (L1-a): ACCEPT at head dd697760d1b01c723810cac1ba33a0d7d476d71b (Fixes #35254). Full read of origin/main...dd697760d1: 4 files. The changes are in seed-loader.ts, two test files, and one changeset.

席位核对

Shape and gates.

  • l1-face --pr 36272 at dd69776 is CLEAN (13 items).
    • First line: Fixes #35254.
    • Declarations: Clause-②: no · Metadata-protocol: none.
    • Floors are success.
    • Check-runs: 39 success, 18 expected skip, 0 failed, 0 pending.
    • mergeable_state: clean.
  • The changeset names @objectstack/metadata-protocol as a patch, and says that rows an earlier load stored with the raw key are not rewritten, along with how to repair them.

The code.

Clause-②: no holds. The same read now drives the loader's other per-field decisions: required-on-insert, the tenant column, the replay compare, and the undeclared-column warning.

  • Required-on-insert is the mirror of the engine's own insert predicate, as its comment says, and the engine enforces that predicate on the served schema whatever the loader reads. So no seed write the engine would accept is newly refused here.
  • The undeclared-column warning is a log line.
  • The replay compare can now see an extension field. That is the fix's own effect: re-running a seed stores the id in place of a stale key.

Pins and evidence.

  • Five [#35254] cases, each with an authored-lookup CONTROL on the same object:
    • upsert / ignore: the id is stored, insertOrder is right, and the dependsOn and references are right;
    • update: no second row;
    • a cycle resolved in pass 2, identical to the control;
    • an unknown key refused exactly as the control is.
  • The renamed fallback pin is in place.
  • The resolver-order ablation turns 7 pins red, and restores byte-identical with the dist/ preflight.
  • The premise was measured on a real os dev --fresh boot of a two-package artifact: the raw quote name on main's resolver, the quote's id on this branch, and the authored control is the id on both.

Deviations and residuals.

Next. The area lands it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh

Landing · head dd697760d1b01c723810cac1ba33a0d7d476d71b · 2026-11-22T04:50Z

Probe Reading
check-governed-merges --pr 36272 NOT governed; 322 changed lines ≤ 3000
pr-state / check-expected-skips 39 success, 18 expected skip, 0 failed, 0 pending; mergeable_state clean
landing-k --pr 36272 K = 5 < 15, OK
Records at this head L1 ACCEPT 7074404902; Clause-②: no, no contract face (no spec, no narrowing, no governed path)

State: ready + auto-merge now. On merge, #35254 closes by its Fixes line and leaves pm:dispatched.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 22, 2026 04:51
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 8925d5b Nov 22, 2026
58 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35254-seed-extension-lookup branch November 22, 2026 05:25
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

2 participants