Repository navigation
fix(managed): bind row budget charges to metadata identities - #1897
Conversation
Charge fixed row bookkeeping once per table and row within an admitted metadata layout. Repeated owner lookups no longer permanently consume capacity for temporary cursors; distinct rows and failed admissions retain the existing representation limit and typed failure behavior. Verify repeated local attribute-constructor lookups through public CLI metadata/member inspection and preserve the remaining capacity guards. Closes #1878 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2cae10d66c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /** Retain one bookkeeping reservation per physical row, independently of lookup replay. */ | ||
| reserveRow(table: number, row: number, offset: number): void { | ||
| let rows = this.#rows.get(table); | ||
| if (rows?.has(row) === true) return; |
There was a problem hiding this comment.
Keep a bound on repeated row lookup work
When an assembly has many CustomAttribute rows referencing a local MethodDef owned by a late TypeDef, each attribute calls declaringTypeForMethod, which synchronously scans the TypeDef table and creates roughly two cursors per row. This early return removes the only finite charge on those repeated scans, so a small assembly with tens of thousands of attributes and types can perform hundreds of millions of cursor reads while its unique-row and output accounting remains below 64 MiB, blocking CLI/MCP processing. Cache/precompute MethodDef ownership or retain a separate work admission limit rather than making replay entirely unbounded.
AGENTS.md reference: AGENTS.md:L42-L42
Useful? React with 👍 / 👎.
Summary
Repeated custom-attribute owner lookups can exhaust managed inspection capacity before any method decoding. Charge fixed row bookkeeping once per physical metadata row, so temporary lookup replay no longer consumes retained capacity. Fixes #1878.
Problem and expected behavior
A 17,408-byte source-owned assembly with 513 types and 512 attributes whose constructors are local MethodDefs exhausts the 64 MiB representation budget on the base revision. Both metadata and member inspection should retain its facts and executable CIL without treating every temporary cursor as permanent output.
Change and scope
The layout-owned decode budget records admitted
(table, row)identities. Each new identity reserves the existing 256-byte allowance before it is recorded; replay has no additional fixed charge. Distinct tables remain separate, and a rejected admission cannot become a successful cached replay. Row validation still precedes admission.The fixture builder now produces repeated local attributes and preceding empty types. This complements #1706's ordered owner-lookup optimization; it bounds identity accounting independently of the lookup strategy. It does not increase capacity or introduce type selection.
Contract and boundary impact
Evidence and regression coverage
Tests added or updated: public CLI metadata/member regression plus a distinct capacity-boundary test covering row replay, table identity and repeated rejected admission.
Base reproduction: the new CLI regression failed with
metadata.representation, empty attributes and partial coverage before the fix.User-visible CLI/MCP output: the regression now returns complete coverage, 512 attributes, 513 types and one decoded CIL instruction through both public interfaces. Normalized results, provider and artifact digest agree; a following MCP ping succeeds and artifact bytes remain unchanged.
Remaining proof gaps: two larger release assemblies now return complete metadata inventories (11,381 and 9,302 attributes), but their unselected full-member requests still hit a later representation limit. This PR resolves cursor accounting, not every large-result capacity failure. Optional external reconstruction oracle and operator-selected managed manifest were not configured.
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:focused -- tests/acceptance/managedCliOutput.test.ts src/dotnet/ManagedDecodeBudget.test.ts src/dotnet/ManagedMetadataHeaps.test.ts src/dotnet/ManagedArtifactInspector.test.ts src/dotnet/ManagedMemberInspector.test.ts src/dotnet/ManagedArtifactFailures.test.ts tests/boundary/mcp/managedMcp.test.ts— 103 tests passed across seven files.src/dotnet/ManagedArtifactInspector.test.ts— 19 tests passed after the fixture helper's argument cleanup.npm run verify:managed— 11 portable managed scenarios passed; optional external oracle and operator manifest reported unavailable.npm run check— typecheck, lint, module boundaries, formatting, metadata, unused-code and architecture checks passed.npm run verify:test-discoveryandgit diff --check— passed.Compatibility, safety, and release
Review checklist
type(scope): outcome.