Skip to content

publishPackageDrafts' ADR-0010 audit row records the raw stored type spelling — the #8769 fold closed this for publishMetaItem only #8858

Description

@hotlong

Observation recorded while measuring #8820 (which is about a different consumer of the same unfolded value). Not fixed there: the audit site is outside that card's declared region.

What was measured

At origin/main fd6bdf89f, packages/metadata-protocol/src/protocol.ts:13845:

for (const p of promoted) {
    await this.recordMetadataAudit({
        type: p.d.type,
        name: p.d.name,

p.d is the draft row as SysMetadataRepository.listDrafts returned it. That method applies no type fold — it selects on state/organization_id and maps type: row.type straight through (sys-metadata-repository.ts:914-918) — so p.d.type is the raw stored sys_metadata.type.

promoteDraftForPublish folds internally (:12944, PLURAL_TO_SINGULAR[request.type] ?? request.type) and that folded value is kept separately as p.singularType; the raw spelling stays on p.d.type (:13640).

Why it is a defect

publishMetaItem's audit row at :12862 reads request.type after the boundary fold at :12832, so it records the canonical singular. The batch route records whatever spelling the stored row carries. The in-file comment at :12814 describes precisely this failure mode as something the fold fixed:

the ADR-0010 audit row and the receipt sentence, which both read request.type and so recorded the CALLER's spelling for a row written under the canonical one — a compliance query on type = 'view' missed a publish addressed /meta/views/….

That is still true one route over: a compliance query on type = 'object' misses a batch publish of a legacy plural-typed draft row. Legacy plural rows at rest are real — canonicalMetaType's own header (:158) states that rows written under a plural type before that fix are real and nothing rewrites them on upgrade, which is the reason promoteDraftForPublish carries its own fold at all.

Scope note: new rows are written folded (saveMetaItem persists singularTypeForRepo, :12173/:12226), so this is a data-at-rest concern, not a newly-minted one.

Suggested disposition

Record the canonical spelling — p.singularType is already in hand at that site and is what the neighbouring applyRegistryWriteThrough call uses. Worth confirming against the ADR-0010 intent first: if the audit trail is meant to record the caller's literal spelling, then publishMetaItem is the site that is wrong and the two should be reconciled the other way. Either way the two routes should not disagree.

Backlink: #8820 (the measurement that surfaced this; a different consumer of the same unfolded p.d.type).

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions