Commit a53890a
committed
fix(metadata-protocol): unscoped metadata list dedupes package-aware, not by bare name (ADR-0048 #1828)
`getMetaItems` merged registry items, `sys_metadata` overlay rows,
draft-preview rows, and MetadataService items into `Map`s keyed by bare
`name`. When two installed packages ship the same `type/name` (e.g.
`page/home`) and either has an overlay, the DB-overlay merge collapsed
them to one row (last-write-wins), so an unscoped `GET /meta/:type`
returned only one — and the frontend prefer-local resolution, which reads
the unscoped list, could no longer tell the two packages' rows apart.
Key the three merge sites (plus the env/org `mergedMap`) by
`(package, name)` via a shared `mergePackageAwareOverlay` helper whose
per-package resolution mirrors `getMetaItem(name, packageId=P)`
(scoped row, else package-less/global fallback), so:
- two packages' same-name rows stay distinct, each with its own `_packageId`;
- a package-less (env-wide) overlay still wins over the single artifact it
customizes — ADR-0005 precedence and single-package behaviour unchanged;
- a legacy row whose active/draft layers disagree on package attribution
still collapses (draft wins), matching the single-item path.
Also scope the registry-hydration artifact graft to each row's own
`package_id` so a colliding overlay no longer grafts the first-registered
package's provenance/lock onto another package's row (the secondary
provenance-pollution gap in #1828).
Tests: two-package overlay collision keeps both rows with correct
`_packageId`; single-package env-wide overlay unchanged; MetadataService
collision keeps both.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DKFjwN2EVXPB2CJwNzPs8c1 parent 06cb319 commit a53890a
2 files changed
Lines changed: 234 additions & 65 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |