Skip to content

fix(managed): bind row budget charges to metadata identities - #1897

Merged
N0zoM1z0 merged 1 commit into
mainfrom
fix/1878-managed-row-budget
Oct 11, 2026
Merged

N0zoM1z0 merged 1 commit into
mainfrom
fix/1878-managed-row-budget

Conversation

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

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

  • Semantic owner and earliest changed stage: managed layout-owned representation admission, before constructing a row cursor.
  • CLI and MCP/tool-catalog contract: unchanged.
  • Provider, bridge, target-format, or platform compatibility: shared static PE/CLI reader; no provider protocol changes.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged; existing coverage and failure reasons remain visible.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata, package, or installation impact: none.

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.
  • Final focused rerun of src/dotnet/ManagedArtifactInspector.test.ts — 19 tests passed after the fixture helper's argument cleanup.
  • Actual CLI and pinned-SDK stdio MCP on the source-owned regression assembly — complete normalized-result parity, identity, liveness and unchanged-byte checks passed.
  • Actual CLI on two unchanged release DLLs — complete metadata inventories; full-member requests preserve their remaining typed resource-limit outcomes.
  • 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-discovery and git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux x86_64 static managed CLI/MCP; those engines and other operating systems were not exercised for this change.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the 64 MiB ceiling, malformed-row checks, transient and expanded-output guards remain enforced. Target code is never loaded or executed. Heavy verification ran serially under one CPU and 3 GiB; no binaries, private paths or generated outputs are committed.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed (none changed).
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T16:27:14.333941Z 2cae10d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Temporary managed row cursors exhaust the retained metadata budget

2 participants