Repository navigation
fix(go): classify JVM class files instead of universal Mach-O for CAFEBABE bytes - #2458
Conversation
The regression fails on main: readGoBinaryImage(javaClassFile()) reports "Universal/fat Mach-O containers require selecting a thin slice" for a JVM class file whose bytes 4..7 are minor/major version, not nfat_arch.
Route the four FAT magics through the shared readFatContainerHeader and classifyFatContainerIdentity facts added for the same disambiguation in the artifact and target lanes (921bb95). Keep the thin-slice failure only when the container identity is confirmed Mach-O; a JVM class file now falls through to the generic only-ELF/PE/thin-Mach-O failure.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Cover the kept behavior with the repository's own fatImage/machoImage builders (narrow and FAT64 tables) so the regression also proves real universal containers keep the slice-selection failure.
|
@greptileai review |
|
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. |
Require positive Mach-O identity before reporting a universal thin-slice remedy; malformed FAT-shaped bytes are not proof. Add the JVM constant-pool CPU lookalike to the existing fixture control. Source inspection and git diff --check; tests/builds/typechecks/CI reruns skipped at explicit user request.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a14c05efa
ℹ️ 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".
Preserve the owning FAT header parser reason for malformed headers while requiring positive Mach-O proof before the universal-slice remedy. Source inspection and git diff --check only. Tests, builds and typechecks skipped by explicit user request. GitHub review writes paused globally.
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. Fixed in 617a4b4. Root cause and structural fix: Malformed FAT headers preserve the owning parser reason, including the truncated-header diagnostic. Parsed malformed tables still do not establish Mach-O identity, so the JVM CPU-lookalike remains free of a false thin-slice remedy. Validation: source inspection and git diff --check only. Tests, builds and typechecks were skipped by the user's explicit request; no runtime or real-provider pass is claimed. No directly related cleanup remains identified. |
Summary
inspect-go-binaryreports JVM class files (CAFEBABE) as "Universal/fat Mach-O containers require selecting a thin slice" — a false format identity. A JVM class file's bytes 4..7 holdminor_version/major_version, notnfat_arch, so the message steers users to a slice-selection dead end that can never succeed. This is the Go-reader sibling of the disambiguation added for the artifact and target lanes in 921bb95 (fixes #2317); #2405 covers the artifact inventory lane. Contradiction on identical bytes:inspect-artifactalready refuses the same class file asunsupported binary format.Problem and expected behavior
Smallest trigger:
rea inspect-go-binary Hello.class(any valid class file; version 65 lands innfat_arch's plausible 1..128 range).Violated invariant: docs/go-binaries.md "Supported boundary" — "Unsupported containers receive a separate unsupported-target failure." A class file is not a container of any kind; the unsupported-target reason must not assert a Mach-O FAT identity the bytes do not support.
Expected: the generic
Only ELF, PE, and thin Mach-O native images are supportedfailure, matching the artifact/target lanes.Change and scope
In
src/go/GoBinaryImage.tsreadContainer, the four FAT magics now route through the sharedreadFatContainerHeader+classifyFatContainerIdentityfacts. The thin-slice failure is kept only when the container identity is confirmed Mach-O (or the header is truncated/malformed enough that FAT cannot be ruled out, preserving the existing 4-byte behavior).not-fat(class files: table extends past file size) andnot-mach-oidentities fall through to the generic failure.Not included:
src/hopper/HopperFileOffset.tsfatLayoutstill classifies CAFEBABE by magic alone; 921bb95's message leaves Hopper readers their own parsing, so I did not change it here.Contribution scope: focused bug fix within existing boundaries; no new capability, target execution, injection, or mutation. Not applicable for a maintainer scope decision.
Contract and boundary impact
readGoBinaryImagecontainer admission); earliest stage is target admission forinspect_go_binary.unsupported_targetreason text for non-Mach-O CAFEBABE inputs changes from the fat-container message to the generic supported-formats message.Expected effects:
Evidence and regression coverage
tests/boundary/go/goBinaryImage.test.ts— JVM class fixture (both the 57-byte table-overflow form and the 4000-byte parsed-garbage-table form) must hit the generic unsupported failure; confirmed universal containers (repositoryfatImage/machoImagebuilders: two real thin Mach-O slices x narrow, FAT64, and both little-endian cigam tables) must keep the thin-slice failure. Commit c39b6a1 lands the failing regression first; e53b21c turns it green; 10328cd and 1b9b658 harden the positive control.node scripts/rea.mjs inspect-go-binary Hello.classreturnsmessage: "... Universal/fat Mach-O containers require selecting a thin slice"; after the fix it returns"... Only ELF, PE, and thin Mach-O native images are supported".HopperFileOffset.tsbehavior is unchanged and noted above.For evidence-bearing changes:
Validation performed
npx vitest run tests/boundary/go/goBinaryImage.test.ts— 81 passed (fails 1/81 on main without the fix)npx vitest run tests/acceptance/artifactInventoryJvmClass.test.ts src/domain/binaryTarget.test.ts tests/boundary/go/— 141 passednpm run typecheck— cleannpm run lint(includes verify:module-boundaries) — 1665 source files checked, cleannpm run verify:test-discovery— 1003 test files discovered exactly oncenpm run build:cachedthen both CLI invocations above — executed, output quotedCompatibility, safety, and release
Before merge
type(scope): outcome.