Repository navigation
fix(artifacts): route native images to static readers and name their architecture - #14189
Conversation
…architecture inspect_artifact sent every PE, ELF and Mach-O root straight to open_binary (PE first to inspect_managed_artifact, whatever its CLI header) and left architecture null on every inventory node and on the inspection subject, although the header parsers already know the CPU. Inventory classification now returns the header's CPU family with the format, from the same ELF, Mach-O and PE record parsers target admission uses, so each thin image node (including universal slices and archive members) names its architecture; an undecoded machine stays null, and a universal container node names none. When the inventory root is the open target's own bytes, its Evidence subject carries the architecture target admission parsed, as it already carried the selection. Native next probes now list the provider-free readers for the format before open_binary: PE imports, exports, load config, resources, hardening and release exposure; ELF dependencies, exports, hardening and release exposure; Mach-O inspect_macho, inspect_signature, hardening and release exposure. inspect_managed_artifact leads only when the PE declares a CLI header, is omitted when it declares none, and stays a conditional probe for directory members whose declaration is unknown. The PE hypothesis that inventory cannot tell managed from native is kept only for that unknown case. Fixes #14157
Codex Review Summary: ❌ FailedThis 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryThe PR keeps native architecture facts in artifact inventory and recommends static readers before deep native analysis.
Review used source inspection; no tests were run. Whether another PR supersedes this one could not be checked because GitHub access was unavailable. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Target admission] --> B[Native format and managed declaration]
C[Inventory bytes] --> D[Artifact format and architecture]
D --> E[Inventory evidence]
B --> F{Root digest matches?}
E --> F
F -->|Yes| G[Package readers plus native readers]
F -->|No| H[Inventory-based readers]
G --> I[Remove repeated operations]
H --> I
I --> J[Deep native provider last]
Reviews (5) · Last reviewed commit: "Merge main into fix/inspect-artifact-nat..." · Reviewed by Greptile |
An executable whose contents inventory as an embedded package (Godot PCK, PyInstaller, Node SEA, Deno, Bun or a .NET single-file bundle) is also a native image. Previously inspection proposed only the package reader and hid the native side. The inspection now takes the native image facts that target admission parsed for the root's own bytes, not only the PE CLI-header flag. When inventory reads those bytes as a package, the package reader comes first, then the carrier's static readers, then open_binary. A probe names exactly one operation, so the static readers cannot be grouped into one entry without changing the advertised schema. They stay separate rows and share one short rationale, because each tool's description already says what it reads. Each format's reader list is now a table.
202d83e to
38ffd78
Compare
… boundary A PE declaring a CLI header recommended open_binary with generic function-level advice, so pure managed assemblies were steered to a deep native provider. Its rationale again requires managed inspection to report a native or mixed boundary, and a PE whose header is unknown states the same condition.
…probe snapshots The universal Mach-O test assumed slice inventory on every host, but the slice reader runs native lipo and is skipped off macOS, so it failed on the Linux test shards and portable tests. The test now selects the host platform through a HostPlatform mock: the slice inventory case runs only on a macOS host, and the other-host case asserts unknown container coverage with only the file occurrence on every host. Both keep the selected-slice subject architecture and static reader order. Pruning in the probe tests: - Merge the ARM64 PE, ELF and Mach-O single-image probe tests into one parameterised case that asserts subject and root-node architecture, the complete static reader list, and that open_binary is the only probe beyond artifact bytes. - Remove the Deno carrier ordering case from the native image probe test; the Deno CLI acceptance test covers the same three carriers through the public workflow and now asserts the same ordering and authority facts. - Replace full next-probe arrays in the Bun, Deno, dotnet-bundle and PyInstaller CLI/MCP tests with a shared carrier assertion: package readers lead, the carrier's format reader is present, and open_binary is last and the only non-artifact-bytes probe. The per-format reader list stays owned by the native image probe test. Malformed-header (undecoded machine), unknown architecture and package subject identity coverage are unchanged.
…main Merging main brought two contract changes these tests still asserted the old shape for: morluto#14225 moved an invalid chunk size to an internal invariant violation and an impossible descriptor byte count to io, and morluto#14189 added contentArchitecture to the classification role. The auditd role test added here predates the new field, so Source tests failed on contentArchitecture: null and shard 9 failed on the two stable-artifact reasons. Assert the reasons and fields the producers now return so both lanes match the intended contract.
Fixes #14157
Root cause
Two owners dropped facts they already had:
classifyArtifactBytes) decidedpe,elfandmach-ofrom the same header parsers target admission uses, but returned only the format.createArtifactNodethen hard-codedarchitecture: nullfor every node, andsubjectForinArtifactProvidercopied the target's selection, but not the architecture target admission had parsed.probesForFormatinsrc/domain/artifactInspection.tsmapped PE toinspect_managed_artifactthenopen_binary, and ELF or Mach-O toopen_binaryonly. Inspection never saw the native image facts that target admission had parsed: the format, and for PE whether it declares a CLI header (BinaryTarget.managed). So an executable that inventories as an embedded package also lost its native side.Structural fix
Architecture
readNativeHeaderFormatreturns{ format, architecture }. The newclassifyArtifactHeaderreturns format and architecture together. For PE it runs the same record parser as target admission (parsePeRecordFacts).classifyArtifactBytesis now a projection of it.null. A universal container node also staysnull, because each slice node names its own architecture.target.architecture, alongside the selection it already carried. For universal Mach-O this is the selected slice.Next probes
ArtifactProviderpasses inspection the native image facts target admission parsed for the root's bytes (ArtifactInspectionRootImage).nativeImageProbes, lists the provider-free readers per format (STATIC_READERS), thenopen_binary:inspect_pe_imports,inspect_native_exports,inspect_pe_load_config,inspect_pe_resources,inspect_binary_hardening,audit_release_exposureinspect_elf_dependencies,inspect_native_exports,inspect_binary_hardening,audit_release_exposureinspect_macho,inspect_signature,inspect_binary_hardening,audit_release_exposureinspect_managed_artifactdepends on the CLI header:open_binary. Combined lists are deduplicated by operation, and deep-provider probes always come last.operationper entry. Grouping the static readers into one entry would change the advertised schema, so they stay separate rows. They share one short rationale ("Execution-free header read of the native image; no deep provider."), because each tool's own description already says what it reads.nodes[].architectureandsubject.identity.architecturealready existed and were nullable.Validation
npx vitest run tests/boundary/mcp/pyinstallerArtifactMcp.test.ts tests/boundary/providers/native src/domain/artifactInventoryEvidence.test.ts src/artifacts/inventory tests/boundary/filesystem/elfDeclaredRanges.test.ts: 877 of 879 passed. The two failures are innativeSignatureTargetBinding.test.ts(codesign unavailable through xcrun on this host). They fail the same way on unmodifiedmain.npx oxfmt --checkandnpx oxlinton the changed files: clean apart from warnings that are already present.node scripts/verify/architecture-guards.mjs: passed.artifactProvider.nativeImageProbes.test.tsgoes through the publicinspect_artifactworkflow with fixtures built in the test. It covers:arm64, static readers, no managed probenullextract_artifact, then that carrier's readers, thenopen_binarypyinstallerArtifactMcp.test.tspasses.dist/. I took the expected carrier formats from running the same fixtures in-process; the Bun fixture I took from its builder name (elfAppendedBunPayload), because my in-process probe of it failed.Not run locally: the full typecheck, and tests that need
dist/(compiled MCP, CLI-process and JavaScript-worker tests). CI covers both. I did not run this against real release binaries.Remaining cleanup