Found while implementing #8671 (redacting emitted credential values on the metadata diff endpoint). Filed rather than fixed — out of that card's scope, which is region-declared to the redaction change inside diffMetaItem. Not assigned; recording, not starting.
What is dead
ObjectStackProtocolImplementation.diffMetaItem (packages/metadata-protocol/src/protocol.ts) opens by awaiting a complete history read:
const events = (await this.historyMetaItem({
type: singularType,
name: request.name,
...(orgId ? { organizationId: orgId } : {}),
})).events;
const versions = events
.map((ev: any) => (ev as any).version as number | undefined)
.filter((v): v is number => typeof v === 'number');
versions is then used exactly once, to be thrown away:
const _used = versions; void _used;
Nothing else in the function reads events or versions. The code immediately below re-fetches the same history through the repository instead, and its own comment says why:
The historyMetaItem MetadataEvent shape doesn't carry the per-(type,name) version directly — re-fetch via the repo to read the underlying history rows with their version.
So the re-fetch is deliberate and correct; what looks unintended is that the original call was left in place rather than removed. historyMetaItem is not free — it resolves the overlay repo and drains an async generator over sys_metadata_history (SysMetadataRepository.history), which issues its own engine.find on the same table the re-fetch then queries again.
Why it is worth a card
GET /api/v1/meta/:type/:name/diff is routed and live, so every request pays for two reads of sys_metadata_history where one is used. That is a modest cost, and the reason to file is less the cost than the shape: void _used is the marker of a value someone kept deliberately, so the next reader has to re-derive that it is genuinely dead rather than load-bearing. It also reads as a suppressed-lint artifact, which is exactly the input that makes an agent reason confidently from dead code.
One thing to decide rather than assume, which is why this is not a blind deletion: historyMetaItem has an early return — it answers { events: [] } for a type that is neither isOverlayAllowed nor isRuntimeCreateAllowed. It does not throw for such a type, so removing the call should not change diffMetaItem's behaviour for anyone; but that gate is the one thing worth confirming before the line goes, since it is the only observable the dead call could still be providing.
Not a duplicate
Searched open issues by keyword (diffMetaItem, historyMetaItem, dead code, discarded result, wasted read) and by file path before filing. The three near matches are all closed and concern saveMetaItem (#5783, #5264, #4754), not this function.
Related: #8671.
Generated by Claude Code
Found while implementing #8671 (redacting emitted credential values on the metadata diff endpoint). Filed rather than fixed — out of that card's scope, which is region-declared to the redaction change inside
diffMetaItem. Not assigned; recording, not starting.What is dead
ObjectStackProtocolImplementation.diffMetaItem(packages/metadata-protocol/src/protocol.ts) opens by awaiting a complete history read:versionsis then used exactly once, to be thrown away:Nothing else in the function reads
eventsorversions. The code immediately below re-fetches the same history through the repository instead, and its own comment says why:So the re-fetch is deliberate and correct; what looks unintended is that the original call was left in place rather than removed.
historyMetaItemis not free — it resolves the overlay repo and drains an async generator oversys_metadata_history(SysMetadataRepository.history), which issues its ownengine.findon the same table the re-fetch then queries again.Why it is worth a card
GET /api/v1/meta/:type/:name/diffis routed and live, so every request pays for two reads ofsys_metadata_historywhere one is used. That is a modest cost, and the reason to file is less the cost than the shape:void _usedis the marker of a value someone kept deliberately, so the next reader has to re-derive that it is genuinely dead rather than load-bearing. It also reads as a suppressed-lint artifact, which is exactly the input that makes an agent reason confidently from dead code.One thing to decide rather than assume, which is why this is not a blind deletion:
historyMetaItemhas an early return — it answers{ events: [] }for a type that is neitherisOverlayAllowednorisRuntimeCreateAllowed. It does not throw for such a type, so removing the call should not changediffMetaItem's behaviour for anyone; but that gate is the one thing worth confirming before the line goes, since it is the only observable the dead call could still be providing.Not a duplicate
Searched open issues by keyword (
diffMetaItem,historyMetaItem, dead code, discarded result, wasted read) and by file path before filing. The three near matches are all closed and concernsaveMetaItem(#5783, #5264, #4754), not this function.Related: #8671.
Generated by Claude Code