[PR #3508] [MERGED] fix(managed): report metadata range failures at artifact file offsets #5790

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3508
Author: @kaoru0822-kitauji
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/managed-table-stream-file-offsets


📝 Commits (2)

  • 5bf8c59 fix(managed): report metadata range failures at artifact file offsets
  • df70e87 Merge remote-tracking branch 'origin/main' into fix/managed-table-stream-file-offsets

📊 Changes

2 files changed (+58 additions, -10 deletions)

View changed files

📝 src/dotnet/ManagedMetadataExtraData.test.ts (+22 -1)
📝 src/dotnet/ManagedMetadataLayout.ts (+36 -9)

📄 Description

Summary

Managed metadata range diagnostics now report artifact file offsets. A truncated #~ table stream used to be reported at offset 24, which falls inside the DOS header, instead of the failed read's file offset 888. Fixes #3364.

Problem and expected behavior

ManagedMetadataLayout's requireRange reported the offset relative to the buffer it checked. The callers pass two different subarrays:

  • the metadata root: metadata.version, metadata.stream-count, metadata.stream-header, metadata.<stream>
  • the table stream: metadata.tables-header, metadata.table-row-count, metadata.table-data

Every other diagnostic in the reader already uses file offsets (for example rootOffset + cursor and tablesOffset + tableCursor). These seven therefore pointed at unrelated bytes in inspect-managed-artifact, inspect-managed-members and inspect-managed-native-boundaries.

Change and scope

requireRange now takes the checked buffer's artifact file offset (base) and reports base + offset. Every caller passes rootOffset or the table stream's file offset. The check itself, the issue codes and the scopes are unchanged.

Contribution scope: an ordinary fix within existing boundaries, so no maintainer scope decision is needed.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/dotnet/ManagedMetadataLayout.ts requireRange, the shared range check for metadata parsing.

  • Contribution scope fit and linked maintainer decision: not applicable (ordinary fix).

  • CLI and MCP/tool-catalog contract: no schema change. Only the offset values of these issues change.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: issue offsets now point into the selected artifact, as the other managed diagnostics already do.

  • Target selection, authority, upstream behavior, and cleanup details: unchanged.

  • Generated metadata: none.

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated (src/dotnet/ManagedMetadataExtraData.test.ts):
    • The existing truncated row-count test now asserts offset: tablesOffset + extraDataOffset - 4.
    • A new test sets the #~ extent past the metadata root and expects scope: "metadata.#~" at the stream's file offset.
    • With the source change reverted, both fail (2 failed, 9 passed).
  • Base reproduction (the generator from #3364, then all three CLI commands):
    • main: {"scope":"metadata.table-row-count","offset":24}
    • this PR: {"scope":"metadata.table-row-count","offset":888}, matching the generator's failed_read_file_offset: 888
  • Real data: I shortened #~ to 24 bytes in a real AWSSDK.Core.dll (net8.0, 2.0 MB; generator: root 300084, tables 300192, failed_read 300216). Both commands moved from offset: 24 to offset: 300216.
  • No regression on valid files: inspect-managed-artifact and inspect-managed-members JSON for the unmodified AWSSDK.Core.dll and itextsharp.dll (2.6 MB) is byte-identical to main's (Evidence ID excluded). Wall time and peak RSS are unchanged:
command / file main this PR
members, AWSSDK.Core 1.04 s, 387 MB 1.04 s, 387 MB
members, itextsharp 0.69 s, 363 MB 0.68 s, 369 MB
artifact, AWSSDK.Core 0.44 s, 312 MB 0.44 s, 312 MB
  • Remaining proof gaps: none known. These are pure parser offsets.

  • 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:local -- src/dotnet/*.test.ts (14 files): 322 passed before the new tests were added, and ManagedMetadataExtraData.test.ts (11 tests) passes with them
  • npm run test:focused -- tests/boundary/providers/managed/*.test.ts tests/boundary/mcp/managed*.test.ts: 101 passed
  • npm run check:fast: passed
  • Built CLI on the #3364 generator output and on real DLLs: as listed above

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Issue offsets are corrected; field shapes are unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no change.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • 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.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🤖 Generated with Claude Code


🔄 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/3508 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/managed-table-stream-file-offsets` --- ### 📝 Commits (2) - [`5bf8c59`](https://github.com/morluto/rea/commit/5bf8c5998af5201c333687bdec6f4bc48b0f55ce) fix(managed): report metadata range failures at artifact file offsets - [`df70e87`](https://github.com/morluto/rea/commit/df70e8702fc20d65304a68cae5e53de4d2339dc5) Merge remote-tracking branch 'origin/main' into fix/managed-table-stream-file-offsets ### 📊 Changes **2 files changed** (+58 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/dotnet/ManagedMetadataExtraData.test.ts` (+22 -1) 📝 `src/dotnet/ManagedMetadataLayout.ts` (+36 -9) </details> ### 📄 Description ## Summary Managed metadata range diagnostics now report artifact file offsets. A truncated `#~` table stream used to be reported at offset `24`, which falls inside the DOS header, instead of the failed read's file offset `888`. Fixes #3364. ## Problem and expected behavior `ManagedMetadataLayout`'s `requireRange` reported the offset relative to the buffer it checked. The callers pass two different subarrays: - the metadata root: `metadata.version`, `metadata.stream-count`, `metadata.stream-header`, `metadata.<stream>` - the table stream: `metadata.tables-header`, `metadata.table-row-count`, `metadata.table-data` Every other diagnostic in the reader already uses file offsets (for example `rootOffset + cursor` and `tablesOffset + tableCursor`). These seven therefore pointed at unrelated bytes in `inspect-managed-artifact`, `inspect-managed-members` and `inspect-managed-native-boundaries`. ## Change and scope `requireRange` now takes the checked buffer's artifact file offset (`base`) and reports `base + offset`. Every caller passes `rootOffset` or the table stream's file offset. The check itself, the issue codes and the scopes are unchanged. Contribution scope: an ordinary fix within existing boundaries, so no maintainer scope decision is needed. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/dotnet/ManagedMetadataLayout.ts` `requireRange`, the shared range check for metadata parsing. - Contribution scope fit and linked maintainer decision: not applicable (ordinary fix). - CLI and MCP/tool-catalog contract: no schema change. Only the `offset` values of these issues change. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: issue offsets now point into the selected artifact, as the other managed diagnostics already do. - Target selection, authority, upstream behavior, and cleanup details: unchanged. - Generated metadata: none. - [x] Read existing files or captured data. ## Evidence and regression coverage - Tests added or updated (`src/dotnet/ManagedMetadataExtraData.test.ts`): - The existing truncated row-count test now asserts `offset: tablesOffset + extraDataOffset - 4`. - A new test sets the `#~` extent past the metadata root and expects `scope: "metadata.#~"` at the stream's file offset. - With the source change reverted, both fail (2 failed, 9 passed). - Base reproduction (the generator from #3364, then all three CLI commands): - main: `{"scope":"metadata.table-row-count","offset":24}` - this PR: `{"scope":"metadata.table-row-count","offset":888}`, matching the generator's `failed_read_file_offset: 888` - Real data: I shortened `#~` to 24 bytes in a real `AWSSDK.Core.dll` (net8.0, 2.0 MB; generator: `root 300084, tables 300192, failed_read 300216`). Both commands moved from `offset: 24` to `offset: 300216`. - No regression on valid files: `inspect-managed-artifact` and `inspect-managed-members` JSON for the unmodified `AWSSDK.Core.dll` and `itextsharp.dll` (2.6 MB) is byte-identical to main's (Evidence ID excluded). Wall time and peak RSS are unchanged: | command / file | main | this PR | |---|---|---| | members, AWSSDK.Core | 1.04 s, 387 MB | 1.04 s, 387 MB | | members, itextsharp | 0.69 s, 363 MB | 0.68 s, 369 MB | | artifact, AWSSDK.Core | 0.44 s, 312 MB | 0.44 s, 312 MB | - Remaining proof gaps: none known. These are pure parser offsets. - [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:local -- src/dotnet/*.test.ts` (14 files): 322 passed before the new tests were added, and `ManagedMetadataExtraData.test.ts` (11 tests) passes with them - `npm run test:focused -- tests/boundary/providers/managed/*.test.ts tests/boundary/mcp/managed*.test.ts`: 101 passed - `npm run check:fast`: passed - Built CLI on the #3364 generator output and on real DLLs: as listed above ## Compatibility, safety, and release - Breaking changes or migration steps: none. Issue offsets are corrected; field shapes are unchanged. - Real Hopper/Ghidra, browser, or OS coverage: not applicable. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no change. ## Author readiness Human owner: <!-- @GitHub-handle --> - [ ] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [ ] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [ ] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] 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. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:09: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#5790
No description provided.