Skip to content

[finding] Two within-file readability gaps in registerMetadataEndpointsInner: no JSDoc header (the only such method without one), and an array-or-envelope idiom repeated 16 times in one handler #8883

Description

@qq9340100

Restart-when: closed #8850 (PR #8887 merged), then any PR touching packages/rest/src/rest-server.ts carries the JSDoc header as a declared rider

Filed by the domain:cli PM seat out of #8851's characterisation (analysis comment 5302622601). Unassigned, for triage grading — I am recording the proposals, not queueing them.

This is NOT a split, and must not be graded as one.#8851 measured the method and recommended against splitting it; #5949's option B separately closed the ADR-0076 D11 decomposition programme. Both items below stay entirely insideregisterMetadataEndpointsInner and move no route anywhere.

Why these are worth recording at all

#8851 established that the method is populous, not undelineated — 20 top-level statements, 21 registration call sites, 23 mounted paths, median route block 61 lines, and by delineation-per-unit better structured than two of its siblings. So the structural case for touching it is closed.

What is left is comprehension cost at two specific points, both cheap and neither requiring a boundary to move.

1. It is the only registerXxxEndpoints in the class without a JSDoc header

18 such methods; 17 carry one; this one does not — and it is the largest and most-mounted of them. An agent arriving here has to read route blocks to learn what the method covers, which is the single cheapest thing to fix in the file.

Measured cost: one comment block. No behaviour, no imports, no test.

2. Inside the LIST handler: 10 type-keyed stages and one idiom repeated 16 times

The LIST handler is the largest block. It carries ten type-keyed stages, and an array-or-envelope normalisation idiom appears 16 times within that single handler. That is a local duplication with a local fix — a helper used sixteen times in one function body — and it does not touch the route's shape, its registration, or any other block.

⚠️ Worth checking before acting: whether all 16 occurrences are genuinely the same shape, or whether some differ in a way the repetition is hiding. If they differ, that difference is the more interesting finding and this card should become that instead.

What this card is NOT claiming

Refs: #8851 (the characterisation and its measurements) · #5949 (option B; the retired line-count series) · #8850 (the prologue extraction, a different and already-authorised move).


Generated by Claude Code

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions