Skip to content

fix(errors)!: reject retired target-failure vocabularies in the architecture guards - #14417

Merged
morluto merged 12 commits into
fix/macho-target-failure-kindsfrom
fix/target-failure-vocabulary-guard
Nov 25, 2026
Merged

morluto merged 12 commits into
fix/macho-target-failure-kindsfrom
fix/target-failure-vocabulary-guard

Conversation

@morluto

@morluto morluto commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Depends on #14416. The base branch is #14416's, so the diff shows only this PR.

Final PR of the #14239 stack: a guard that rejects the retired vocabularies, the zero-use search, and the public-corpus before/after.

Root cause

Each earlier PR deleted its area's parallel vocabulary, but nothing stopped a new reader from bringing one back: a second error class for unsupported targets, a Mach-O issue struct, details.format_failure, or a "format" failure reason on a worker wire.

Structural fix

  • scripts/verify/architecture-guards.mjs (run by npm run check:fast and CI) fails on any of these in src, tests, scripts or the Python bridges:
    • AnalysisUnsupportedTargetError, AnalysisMalformedTargetError, MachoReadIssue, FatSliceRangeIssue;
    • format_failure;
    • a reason of "format" (:, ===, !==), a "reason":"format" wire value, or a Python …Failure("format", …).
    • a failure-kind union pairing "format" with a TargetFailure kind (the retired ESP spelling); unrelated "format" kinds such as the desktop draft change stay allowed.
      The patterns live in scripts/verify/retired-target-failure-vocabulary.mjs, tested by tests/evaluation/retiredTargetFailureVocabulary.test.ts; those two files are exempt. Compile-time checks already cover the rest: ArtifactOperationError has no target reasons, and ArtifactReaderFailure requires the owner's facts for every target reason.
  • The ESP image decoder's own failure kind "format" becomes "malformed", the last internal use of that spelling as a failure kind.
  • The three tests that asserted details.format_failure is absent are removed; the guard now enforces it everywhere.

Design notes

  1. A guard on names, not on prose. It matches identifiers and reason literals, so documentation and release history can still describe the migration.
  2. Shrink-only is unnecessary. The search is at zero, so the guard rejects any use rather than counting a baseline.

Zero-use search

grep -rnE 'AnalysisUnsupportedTargetError|AnalysisMalformedTargetError|MachoReadIssue|FatSliceRangeIssue|format_failure|reason\s*(:|===|!==)\s*["'"'"']format["'"'"']|"reason"\s*:\s*"format"|Failure\(\s*["'"'"']format["'"'"']\s*,' over the whole repository (excluding node_modules, dist, .git, docs/releases) returns two lines, both in docs/reference/target-failures.md's Migration section, which names the retired field for callers. No code, test, script or bridge uses any of them.

Mutation check

Appending { reason: "format" } to src/domain/firmware/espImage.ts and a LayoutFailure("format", …) line to bridge/pwntools/layout_impl.py makes the guard fail and name both files; reverting passes.

Public corpus before/after

Inputs, downloaded into a scratch directory and only read, never executed: every file in corkami/pocs PE/bin (243 files) and WerWolv/ImHex-Patterns tests/patterns/test_data (190 files). Each ran inspect-artifact <file> --json in-process through createCli from source, once on main (26cb5b53ce, which already includes #14247) and once on this branch.

Corpus Files Result on main Result on this branch Changed code Changed failure_kind
corkami PE/bin 243 223 ok, 20 target_unavailable 223 ok, 20 target_unavailable 0 0
ImHex test_data 190 22 ok, 168 target_unavailable 22 ok, 168 target_unavailable 0 0

No file changed code or failure_kind. The refusals I sampled (a PE bin.sha and an ImHex 3ds file) are target-admission refusals (BinaryTargetError, details.constraint: "file_format_rejected", "unsupported binary format"), which happens before any reader and carries no failure_kind. That admission path is outside this stack; it is where #14151's unrecognized verdict would land. The readers this stack migrated are exercised by the conformance registry instead.

Validation

  • node scripts/verify/architecture-guards.mjs: passes.
  • npx vitest run src/domain/firmware src/artifacts/EspImageArtifactReader.test.ts src/domain/targetFailure.test.ts: 296 passed.
  • oxfmt on every changed file.

Remaining cleanup

Listed in the stack PRs and kept out of the guard because they are not retired spellings: Hopper and binaryTarget universal-container strings (#14416), the source-map and capture decoders' invalid_request for malformed bytes and the asarFailure/keyed-archive fallbacks (#14292), and owners that call a magic mismatch malformed rather than unrecognized (#14281).

…tecture guards

The stack replaced every parallel vocabulary for why a target could not be
read with the TargetFailure model. The architecture guards now fail when
any retired carrier or spelling returns in src, tests, scripts or the
Python bridges: AnalysisUnsupportedTargetError, AnalysisMalformedTargetError,
MachoReadIssue, FatSliceRangeIssue, details.format_failure, and a "format"
failure reason in TypeScript or on a worker wire.

The ESP image decoder's own failure kind "format" becomes "malformed", and
the tests that asserted format_failure is absent are removed: the guard
covers that.

BREAKING CHANGE: no public field changes here; this completes the #14239
migration's removal of the retired reason vocabularies.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-25T02:12:17.604236Z
We couldn’t complete this review. Comment @codex review to try again.
6067079 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no actionable issues found.

Summary

This PR adds an architecture guard against retired target-failure names and reason values.

  • The architecture check blocks retired target-failure wording across the codebase.
  • ESP image decoding reports malformed input with the malformed kind.

Reviews (11) · Last reviewed commit: "Merge remote-tracking branch 'origin/fix..." · Reviewed by Greptile

Comment thread scripts/verify/architecture-guards.mjs Resolved
@morluto
morluto merged commit bf64456 into fix/macho-target-failure-kinds Nov 25, 2026
38 checks passed
@morluto
morluto deleted the fix/target-failure-vocabulary-guard branch November 25, 2026 13:38
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant