Repository navigation
fix(metadata-protocol): a seed resolves a lookup another package adds through objectExtensions to the target's id - #36272
Conversation
…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
…tObjects 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
…in's header 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
📓 Docs Drift CheckThis PR changes 1 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
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 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
|
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh Final green head (area a4-C, claim 7072946170 on #35254):
|
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5 L1 verdict (L1-a): ACCEPT at head 席位核对Shape and gates.
The code.
Pins and evidence.
Deviations and residuals.
Next. The area lands it. |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh Landing · head
State: ready + auto-merge now. On merge, #35254 closes by its |
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.fields, and fell back to the engine's schema only when the metadata service had none. A boot that loads a compiled artifact (os dev,os serve, the cloud runtime) gives the metadata service each object as its own package wrote it. The fields another package adds throughobjectExtensions(ADR-0130 D5) live only in the ObjectQL registry's fold. So a lookup that an extension adds was never a reference. It had no graph edge, and its natural key was written verbatim into the foreign-key column.IDataEnginedoes not require one). The loader merges no extension itself: the registry's fold is the one source. The marketplace case the old fallback existed for (an object only the engine registry knows) is still served: it is now found on the first read.engineSchemaOf. The resolved definition now IS the engine's schema whenever the engine has one, so the union collapses tosummaryFieldNames(objectDefinition). Its pins are unchanged and green.resolveObjectDefinition,seedReferenceGraphFields,declaresNameColumn, and 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 extension pin's header inseed-loader-summary-stale.test.ts..changeset/35254-seed-extension-lookup.md:@objectstack/metadata-protocolpatch.The in-process boot (
@objectstack/verifywithout 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-leveldescribe('[#35254] …')on that file's engine double, which is already pinned. The metadata double serves the authoredext_orderwithoutquote_ref. The engine double'sgetSchemaserves the folded object withquote_ref → ext_quote. Every case has a CONTROL:account_ref, a lookup the owner authored on the same object.upsertandignore(the inserting modes;insertitself is a retiredSeedMode):quote_refstores the quote's id.insertOrderputsext_quote(andext_account) beforeext_order. Theext_ordernode'sdependsOnis[ext_account, ext_quote], and its references includequote_ref->ext_quotebesideaccount_ref->ext_account.update: the existing order row gets the quote's id and the account's id, and no second order is inserted.ext_quote.order_refback to the order): the cycle is detected, one side waits for pass 2, and both links resolve. The pass-2 writes and theinsertOrderare identical to the CONTROL, wherequote_refis authored.ext_order.quote_ref.falls back to the metadata service definition when the engine has no schema for the object(renamed fromprefers 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_appownsqx_accountandqx_order(with the authoredaccount_ref). Moduleqx_mod(built withartifactObjects) ownsqx_quote, addsquote_ref(→qx_quote) toqx_order, seedsO-1inupdatemode and insertsO-2inupsertmode, both withquote_refby the quote's name. Theos dev --freshboot came from this branch's CLI closure build, and the rows were read withGET /api/v1/data/qx_orderas the seeded dev admin.O-1.quote_ref(update)O-2.quote_ref(upsert)account_ref(CONTROL)"Acme Annual Renewal Quote""Acme Annual Renewal Quote"[SeedLoader] Dependency graph builtreadinsertOrder: [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 --holdreplaced the three-line engine-first body withorigin/main's metadata-first body: anchor x1 → x0, replacement x0 → x1, blob fdbca4a77946 → 2713d6f4cbe4. Thenpnpm --filter @objectstack/metadata-protocol buildran, andablation-dist-preflight.mjs @objectstack/metadata-protocol 'fromMetadata?.fields'read the marker present indist/.Tests 7 failed | 15 passed (22). All five seed loader: a seed that sets a lookup another package adds through objectExtensions writes the raw natural key into the FK column (resolveObjectDefinition reads the object without its extensions) #35254 pins were red (for exampleexpected 'Q-ACME' to be 'gen-1'). So were the renamed fallback pin (expected [] to deeply equal [ 'crm_account', … ], metadata read first) and 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 extension roll-up pin (expected [ 'name', 'total', 'ext_refunds' ] to not include 'ext_refunds', because the union is gone). The throwing-schema CONTROL stayed green.os devon that build: the raw names in the table above.git checkout HEAD -- ABS_PATHin a trap. Blob after restore fdbca4a77946 equals the HEAD blob,git diff HEADis empty, andgit status --porcelain -- packages/is empty. After a rebuild, the--absentdist reading passed. The tree reading reported only the uncommittedos devfixture (since deleted). Green again:Tests 22 passed (22), andos devstored the ids.The pins were later moved from a new file into
seed-loader-engine-schema-fallback.test.tsunchanged (see Acceptance notes).seed-loader.tsdid not change after the ablation.Suite and gate readings
pnpm --filter @objectstack/metadata-protocol testat 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 readTests 22 passed (22)andtypecheckexits 0.dispatch-gates.mjs --commandsderived 67 families, and the list is identical at the head. All 67 ran locally, with each exit captured before any pipe:check:engine-double-contractexited 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-loadsexited 3 (PREREQUISITE NOT MET: no localdist/for packages outside this diff). NOT MEASURED locally; CI runs it.--ranreconciliation: "67 derived, 67 run, 0 NOT-MEASURED, 0 UNRUN", exit 0.overlap-checkat dd69776: VERDICT clean, exit 0.Acceptance notes
check:engine-double-contractrefused 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 intoseed-loader-engine-schema-fallback.test.ts, whose engine double is already pinned and is the same double the new file had copied.bootStackfrom@objectstack/verifywithMetadataPlugin({ artifactSource })over the same two-package artifact read the extension field absent frommetadata.getObject('qa_ext_order')and present ingetSchema. 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 realos devboot 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.updateorupsertmode replaces the key with the id (the replay compare sees a difference). The changeset says so.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. ExpectTests 8 passed, including five[#35254]cases.Read first, by risk:
packages/metadata-protocol/src/seed-loader.ts, theresolveObjectDefinitionhunk: the order flip that every per-field read inherits.summaryFieldshunk inloadDataset: 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.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