Filed unassigned and unlabelled by the domain:cli execution seat while working #15068 — grading and domain:* are triage's to produce. ⛔ Not fixed there: a different defect class (provenance keys surviving an unwrap, not org read scope), so it was left alone rather than folded in as a rider.
The site
packages/runtime/src/domains/packages.ts, applyPublishedSeeds — the route-level seed apply behind POST /packages/:id/publish-drafts. Locate by content, not by line: the surrounding function moved 119 lines while #15068 was open.
It reads each just-published seed body back through protocol.getMetaItem, unwraps the envelope, and hands the result to SeedLoaderRequestSchema.safeParse:
const seed = item?.object && Array.isArray(item?.records)
? item
: (item?.item ?? item?.metadata ?? item?.body);
...
const parsedRequest = SeedLoaderRequestSchema.safeParse({ seeds: datasets, config: { ... } });
if (!parsedRequest.success) throw seedRequestValidationError(parsedRequest.error.issues);
What was measured
Driven for real on a #15068 branch: a state:'draft' seed row promoted by the shipping publishPackageDrafts on a real ObjectStackProtocolImplementation, then read back through that same protocol. The wrapper getMetaItem answers is
{"type":"seed","name":"project_seed","lock":"none","packageId":"com.workspace","editable":true,
"item":{"object":"project","externalId":"name","mode":"upsert","records":[...],
"_packageId":"com.workspace","_diagnostics":{"valid":true}}}
.item is the branch the unwrap takes, and the two underscore keys are inside it — added by decorateMetadataItem (packages/metadata-protocol/src/metadata-diagnostics.ts), which runs on every read exit and appends _diagnostics whenever a schema is registered for the type. SeedLoaderRequestSchema is closed, so the parse fails and the route answers, on a 200, as data:
[handlePackages] seed apply failed: [invalid_metadata] the published seed bodies failed spec validation: 1 issue — seeds.0 [unrecognized_keys]
⇒ zero rows load, and the author is told their seed body is malformed when nothing about it is.
Why it has stayed invisible
Two independent reasons, and they compose:
- The shipping protocol self-applies.
publishPackageDrafts reports seedApplied itself, and the route runs its fallback only when that field is absent ("never run both, or an externalId-less seed would double-insert"). So the shipping composition never reaches this parse.
- The existing coverage doubles the read.
packages/runtime/src/domains/packages-seed-apply-disclosure.test.ts builds its protocol with getMetaItem: vi.fn(...) returning a hand-written wrapper with no decoration — a body the schema accepts. Its section 0 positive control is green precisely because the decoration is not there.
⇒ The fallback is exercised only against undecorated doubles, and would be reached in production only by a custom protocol that does not self-apply. Whether such a protocol decorates is the open question below.
What is not settled here
- Is the fallback still live at all? If no supported composition can reach it, the honest fix may be to delete it rather than to strip keys — and that is a decision, not an implementation detail.
- If it is live, where does the strip belong?
applyPublishedSeeds already owns a provenance-stripping helper for its export path (PROVENANCE_KEYS, same file), so the shape exists; but stripping at the consumer is the tolerant-reader move this repo's contract-first rule pushes back on, and the alternative is that the seed apply should read a body that was never decorated.
- ⚠️ Underscore keys are not one population:
_packageId is provenance the export path already knows to drop, while _diagnostics is a computed badge. A blanket startsWith('_') strip would be a guess about both.
Refs
Filed unassigned and unlabelled by the
domain:cliexecution seat while working #15068 — grading anddomain:*are triage's to produce. ⛔ Not fixed there: a different defect class (provenance keys surviving an unwrap, not org read scope), so it was left alone rather than folded in as a rider.The site
packages/runtime/src/domains/packages.ts,applyPublishedSeeds— the route-level seed apply behindPOST /packages/:id/publish-drafts. Locate by content, not by line: the surrounding function moved 119 lines while #15068 was open.It reads each just-published seed body back through
protocol.getMetaItem, unwraps the envelope, and hands the result toSeedLoaderRequestSchema.safeParse:What was measured
Driven for real on a #15068 branch: a
state:'draft'seed row promoted by the shippingpublishPackageDraftson a realObjectStackProtocolImplementation, then read back through that same protocol. The wrappergetMetaItemanswers is{"type":"seed","name":"project_seed","lock":"none","packageId":"com.workspace","editable":true, "item":{"object":"project","externalId":"name","mode":"upsert","records":[...], "_packageId":"com.workspace","_diagnostics":{"valid":true}}}.itemis the branch the unwrap takes, and the two underscore keys are inside it — added bydecorateMetadataItem(packages/metadata-protocol/src/metadata-diagnostics.ts), which runs on every read exit and appends_diagnosticswhenever a schema is registered for the type.SeedLoaderRequestSchemais closed, so the parse fails and the route answers, on a 200, as data:⇒ zero rows load, and the author is told their seed body is malformed when nothing about it is.
Why it has stayed invisible
Two independent reasons, and they compose:
publishPackageDraftsreportsseedApplieditself, and the route runs its fallback only when that field is absent ("never run both, or an externalId-less seed would double-insert"). So the shipping composition never reaches this parse.packages/runtime/src/domains/packages-seed-apply-disclosure.test.tsbuilds its protocol withgetMetaItem: vi.fn(...)returning a hand-written wrapper with no decoration — a body the schema accepts. Its section 0 positive control is green precisely because the decoration is not there.⇒ The fallback is exercised only against undecorated doubles, and would be reached in production only by a custom protocol that does not self-apply. Whether such a protocol decorates is the open question below.
What is not settled here
applyPublishedSeedsalready owns a provenance-stripping helper for its export path (PROVENANCE_KEYS, same file), so the shape exists; but stripping at the consumer is the tolerant-reader move this repo's contract-first rule pushes back on, and the alternative is that the seed apply should read a body that was never decorated._packageIdis provenance the export path already knows to drop, while_diagnosticsis a computed badge. A blanketstartsWith('_')strip would be a guess about both.Refs
seedisallowOrgOverride: falseandgetMetaItemgates it #15068 — the card this was found under (the org-then-env ladder at the same call site); the measurement above is from its branch.packages/runtime's package-publish door has its own copy of the P9 seed-apply disclosure, outsidemetadata-protocol#8443 — the disclosure work that established the doubled-protocol harness this defect hides behind.GET /meta/:type/:nameanswers two different body shapes on the same request — the cached branch (the DEFAULT) returns the bare document, the non-cached branch returns the spec-declared{ type, name, item }envelope #5563 — the envelope change that madegetMetaItemanswer the wrapper this unwrap tolerates.