[PR #1897] [MERGED] fix(managed): bind row budget charges to metadata identities #4889

Closed
opened 2026-10-31 00:56:27 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1897
Author: @N0zoM1z0
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @N0zoM1z0

Base: main ← Head: fix/1878-managed-row-budget


📝 Commits (1)

  • 2cae10d fix(managed): bind row budget charges to metadata identities

📊 Changes

5 files changed (+142 additions, -25 deletions)

View changed files

📝 src/dotnet/ManagedDecodeBudget.test.ts (+12 -0)
📝 src/dotnet/ManagedDecodeBudget.ts (+13 -0)
📝 src/dotnet/ManagedMetadataHeaps.ts (+3 -2)
📝 src/dotnet/ManagedPe.fixture.ts (+48 -23)
📝 tests/acceptance/managedCliOutput.test.ts (+66 -0)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1897 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/1878-managed-row-budget` --- ### 📝 Commits (1) - [`2cae10d`](https://github.com/morluto/rea/commit/2cae10d66c9e5dfbec6949064b1b7f79d46a17a2) fix(managed): bind row budget charges to metadata identities ### 📊 Changes **5 files changed** (+142 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `src/dotnet/ManagedDecodeBudget.test.ts` (+12 -0) 📝 `src/dotnet/ManagedDecodeBudget.ts` (+13 -0) 📝 `src/dotnet/ManagedMetadataHeaps.ts` (+3 -2) 📝 `src/dotnet/ManagedPe.fixture.ts` (+48 -23) 📝 `tests/acceptance/managedCliOutput.test.ts` (+66 -0) </details> ### 📄 Description ## 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. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] 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 - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed (none changed). - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:56:27 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4889
No description provided.