[GH-ISSUE #2583] fix(managed): preserve metadata beyond the fixture image capacity #900

Closed
opened 2026-10-15 18:29:25 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @coygeek on GitHub (Oct 13, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/2583

Summary

Building a managed verification fixture with 60 assembly references silently cuts off its metadata. The returned PE declares more metadata than the file contains, and the source inspector reports a malformed image. This prevents fixture consumers from inspecting the complete requested reference set.

Steps to reproduce

From the repository root at the environment below, run this command with the installed Node runtime. It builds a control and the failing fixture without compiling or executing either artifact.

node --input-type=module <<'JS'
import { buildManagedPeFixture } from './scripts/fixtures/managed/pe.mjs';
for (const count of [0, 60]) {
  const options = count === 0 ? {} : {
    references: Array.from({ length: count }, (_, i) => `System.Reference.Assembly.${i}`),
  };
  const bytes = buildManagedPeFixture(options);
  console.log(JSON.stringify({ count, imageBytes: bytes.length,
    declaredMetadataBytes: bytes.readUInt32LE(0x20c),
    remainingFileBytes: bytes.length - 0x300 }));
}
JS

Expected behavior

A fixture requested with 60 ordinary assembly references contains the complete metadata for those references. Its metadata directory fits within the file-backed section, and managed artifact inspection can read it as a managed image. The default fixture remains valid.

Actual behavior

The control has 492 declared metadata bytes within 3328 remaining file bytes. With 60 references, the producer returns the same 4096-byte image but declares 3388 metadata bytes within only 3328 remaining file bytes. A focused test using the source inspector also reproduced classification malformed with issue invalid-directory, scope cli.metadata, and detail cli.metadata occupies virtual bytes without file-backed data.

Evidence

  • Expected source: scripts/fixtures/managed/pe.d.mts:25 accepts references without a length bound; scripts/fixtures/managed/pe.mjs:390 defines the PE/CLI fixture entry point; AGENTS.md:75 requires accounting for representation expansion before allocation.
  • Failure source: scripts/fixtures/managed/pe.mjs:334 allocates the fixed image, :371 records the full metadata length, and :385 copies into the remaining capacity. The reproduction and source-inspector test observed the mismatch above.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

The verification context forwards caller options directly to this producer. The TypeScript fixture independently accounts for metadata length when laying out and allocating its image. No production target execution is involved in this reproduction.

Restoration check

Repeat the 60-reference case and require all declared metadata bytes to be file-backed and readable. Inspect the result through the managed artifact inspector and require a managed classification without a metadata-directory issue. Verify that all 60 references remain present and that the default control still passes. Reducing the declared length or dropping references does not restore the contract.

Runtime or environment

Repository revision 8b181716ac; Node v26.10.0; locked dependencies already installed. The source-inspector check used the repository's focused test runner.

Triage assessment

  • Impact level: P2
  • Assessment status: supported
  • Impact basis: A supported verification-fixture input produces truncated metadata and a malformed classification; the observed failure is bounded to generated fixtures, without a demonstrated production-analysis failure.
  • Workaround status: unverified
  • Workaround basis: Smaller reference sets avoid this signal, but they omit requested references; no workaround preserving the complete fixture was verified.
Originally created by @coygeek on GitHub (Oct 13, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/2583 ## Summary Building a managed verification fixture with 60 assembly references silently cuts off its metadata. The returned PE declares more metadata than the file contains, and the source inspector reports a malformed image. This prevents fixture consumers from inspecting the complete requested reference set. ## Steps to reproduce From the repository root at the environment below, run this command with the installed Node runtime. It builds a control and the failing fixture without compiling or executing either artifact. ```bash node --input-type=module <<'JS' import { buildManagedPeFixture } from './scripts/fixtures/managed/pe.mjs'; for (const count of [0, 60]) { const options = count === 0 ? {} : { references: Array.from({ length: count }, (_, i) => `System.Reference.Assembly.${i}`), }; const bytes = buildManagedPeFixture(options); console.log(JSON.stringify({ count, imageBytes: bytes.length, declaredMetadataBytes: bytes.readUInt32LE(0x20c), remainingFileBytes: bytes.length - 0x300 })); } JS ``` ## Expected behavior A fixture requested with 60 ordinary assembly references contains the complete metadata for those references. Its metadata directory fits within the file-backed section, and managed artifact inspection can read it as a managed image. The default fixture remains valid. ## Actual behavior The control has 492 declared metadata bytes within 3328 remaining file bytes. With 60 references, the producer returns the same 4096-byte image but declares 3388 metadata bytes within only 3328 remaining file bytes. A focused test using the source inspector also reproduced classification `malformed` with issue `invalid-directory`, scope `cli.metadata`, and detail `cli.metadata occupies virtual bytes without file-backed data`. ## Evidence - Expected source: `scripts/fixtures/managed/pe.d.mts:25` accepts references without a length bound; `scripts/fixtures/managed/pe.mjs:390` defines the PE/CLI fixture entry point; `AGENTS.md:75` requires accounting for representation expansion before allocation. - Failure source: `scripts/fixtures/managed/pe.mjs:334` allocates the fixed image, `:371` records the full metadata length, and `:385` copies into the remaining capacity. The reproduction and source-inspector test observed the mismatch above. - Evidence provenance: observed - Local verification: reproduced - Reproduction completeness: complete The verification context forwards caller options directly to this producer. The TypeScript fixture independently accounts for metadata length when laying out and allocating its image. No production target execution is involved in this reproduction. ## Restoration check Repeat the 60-reference case and require all declared metadata bytes to be file-backed and readable. Inspect the result through the managed artifact inspector and require a managed classification without a metadata-directory issue. Verify that all 60 references remain present and that the default control still passes. Reducing the declared length or dropping references does not restore the contract. ## Runtime or environment Repository revision 8b181716aca2cb467be499cba226abfb5ae19141; Node v26.10.0; locked dependencies already installed. The source-inspector check used the repository's focused test runner. ## Triage assessment - Impact level: P2 - Assessment status: supported - Impact basis: A supported verification-fixture input produces truncated metadata and a malformed classification; the observed failure is bounded to generated fixtures, without a demonstrated production-analysis failure. - Workaround status: unverified - Workaround basis: Smaller reference sets avoid this signal, but they omit requested references; no workaround preserving the complete fixture was verified.
bsakaguchi 2026-10-15 18:29:25 +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#900
No description provided.