Skip to content

fix(errors)!: report unsupported and unrecognized targets on the TargetFailure model - #14281

Merged
morluto merged 125 commits into
mainfrom
fix/unsupported-target-failure
Nov 25, 2026
Merged

morluto merged 125 commits into
mainfrom
fix/unsupported-target-failure

Conversation

@morluto

@morluto morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

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

Sixth PR of the #14239 stack: AnalysisUnsupportedTargetError and the foreign-bytes loop move onto the model.

Root cause

AnalysisUnsupportedTargetError was a second carrier for "this target is outside coverage". It had a free-text reason, an optional producer-written remediationAction and an undecodedContent flag, but no format, failure_kind or retry. Its 54 producers each wrote recovery prose, often naming MCP tools in text that the CLI then printed unchanged, and its consumers (release exposure, provider evaluation, provider selection, screenshot replay) tested its class instead of the fact.

Structural fix

  • Deleted: the AnalysisUnsupportedTargetError class, its classification row, presentation branches, projection branch, error tag and catalogue row.
  • Producers raise the model. unsupportedTarget(operation, path, format, detail, { undecodedContent, offset, field, ...options }) and unrecognizedTarget(...) build AnalysisTargetFailureError. Each of the 54 sites names its owner's format (for example zip, bplist, macho, dart-aot, playwright-trace, openapi, android-package, evidence). parseFailureAnalysisError, machoSliceSelection and Apple dispatch metadata now pass the owner's ParseFailure straight through, so unsupported keeps its facts.
  • Consumers read the fact. targetFailureOfKind(error, "unsupported", "unrecognized") replaces the instanceof checks, and release exposure reads undecodedContent from the failure.
  • Recovery is the table's. renderTargetFailureRecovery is the one place a target failure's recovery is written. It takes the owner's alternatives (related.operations, related.providers) and an adapter spelling (TargetFailureSpelling, MCP by default). Producer remediation that named another workflow becomes related.operations (inspect_plist, decode_interface_builder, inspect_electron_page, get_evidence_bundle, the JavaScript absent-input operations). Guidance specific to one refusal moves into detail.
  • Kinds. A file that is a different kind of artifact (a keyed-archive selection that is an ordinary plist, an archive without Playwright members, a non-ZIP APK, an inventory with no JavaScript inputs) is unrecognized. A form outside coverage stays unsupported. A file where inspect_desktop_application needs a directory is selection.

Design notes

  1. One carrier. "Outside coverage" is a TargetFailure kind, not a class. Every refusal now projects through TARGET_FAILURE_PROJECTIONS.
  2. Alternatives are facts, not prose. The owner names operations and providers. The table renders them, so each adapter can spell them (the next PR adds the CLI spelling, [Bug] MCP error remediation does not name the alternative tool or provider, and embeds CLI commands #14162).
  3. No new limits or retries. All 54 sites keep unsupported_target and retryable: false. The visible changes are failure_kind, format, retry: "none" and the recovery text.

Removed tests and the registry case that covers each

Removed Registry case (tests/support/targetFailure/readers/foreignBytes.ts)
stableArtifactParserFailureCli (whole file): "retains the completed file identity after format refusal", 18 commands <operation>/foreign-bytes for the same 18 operations, same bytes (FOR1 for BEAM, 64 × 0x7f otherwise)

The registry cases also check MCP, failure_kind, format, retry and that the file is unchanged, not only partial_observation.

Mutation checks, run in-process through createCli and the MCP server: reporting readBinaryContainer's refusal as malformed fails inspect_rust_binary/foreign-bytes and inspect_go_binary/foreign-bytes; reporting the devicetree magic mismatch as malformed fails inspect_devicetree/foreign-bytes. All pass after revert.

Tests

  • 49 test files that asserted the deleted class, its reason, remediationAction or undecodedContent now assert AnalysisTargetFailureError and failure.detail, or the projected failure_kind, related_operations and recovery.
  • keyedArchiveSelection: an ordinary plist is unrecognized keyed-archive, the recovery names inspect_plist, and the non-macOS host requirement is in reason.

Validation

  • npx vitest run over every changed source directory (src/{adb,apkSignature,apktool,application,artifacts,browser,domain,dotnet,electron,evm,flutter,ghidra,native,pcap}): all pass after the updates (23,565 tests; two timing-sensitive tests passed on rerun).
  • The changed boundary tests pass from source, except suites that run the compiled CLI, stdio MCP or SQLite worker from dist/ (artifactZipIntegrity, serverLifecycleMcp SQLite cases, adbCommandFinalization), which CI covers.
  • All 63 registry cases ran in-process from source. Every CLI and non-session MCP path passed except the four SQLite and managed cases that need dist/ or a deep-provider session.
  • Scoped tsc over the 600 files that name these types is clean apart from the pre-existing frida errors. Also clean: oxfmt, oxlint (no new warnings), architecture-guards.
  • docs/user-visible-errors.csv regenerated from source with tsx.

Behaviour changes

  • Unsupported and unrecognized refusals report failure_kind, format, top-level retry: "none", and a recovery from the table. message reads Unsupported <format> target for <operation> at <path>: <reason>.
  • Where the owner names an alternative, details.related_operations lists it and the recovery names it.
  • inspect_desktop_application on a file reports selection (invalid_request), not unsupported_target.
  • docs/reference/target-failures.md records the change under Migration.

Real-provider verification scope

None run. The adb, apktool, Ghidra profile, pwntools and EVM refusal paths are covered by their simulated-provider tests only.

Remaining cleanup

  • Several owners report a magic mismatch on foreign bytes as malformed (not an ELF image, invalid or truncated DOS MZ header, Expected an MZ PE image, pyc and IPS prefixes). The registry records what they report today. Reporting them as unrecognized touches the shared ELF and DOS header readers and their consumers; I left it for a follow-up rather than widen this PR.
  • CLI spelling and provider alternatives ([Bug] MCP error remediation does not name the alternative tool or provider, and embeds CLI commands #14162), wire reasons, Mach-O and the guard follow in the next PRs.

…conformance registry

Introduce one domain-owned TargetFailure value whose kind alone derives
the public code, category, retryability, recovery and details, for CLI
and MCP alike. Selected-file malformed and truncated refusals are the
first area on it: AnalysisMalformedTargetError is replaced by
AnalysisTargetFailureError, and ParseFailure's byte-structure variants
are TargetFailure variants rather than a parallel type.

The shared stableArtifactParserFailureCli loop is replaced by a
declarative registry (tests/support/targetFailure/readers/*.ts) and one
generated suite that runs every registered case through the CLI and MCP.

BREAKING CHANGE: selected-file malformed and truncated refusals add
details.failure_kind, and a truncated target's remediation now says to
re-acquire the complete file instead of choosing another target. Codes
are unchanged. Affected operations: every operation that refuses a
selected file's malformed or truncated bytes, including the ELF, PE,
Mach-O, DWARF, Go, Rust, BEAM, pyc, devicetree, Apple IPS, kernel
module, binary hardening, managed PE/CLI and IL2CPP readers.
#14225 refuses a non-regular dyld input as ArtifactReaderFailure("path");
dylibFileLifetime still expected "format" and fails on main's shard 9.
stableArtifact expected "format" for an impossible descriptor byte count
(now io) and an invalid chunk size (now InternalInvariantError);
directoryArtifactReaderOpen expected "format" for a non-file entry (now
path, the same change as #14238). All three fail on main.
…cated targets

Delete the ambiguous `format` reason from ArtifactReaderFailure and
ArtifactOperationError. Each container reader now raises its owner's
fact once, through malformedArtifact / truncatedArtifact, with format,
offset, field and measured extents. Short reads inside a measured extent
are read-coverage integrity failures, path-kind refusals are `path`,
foreign or recovery-requiring inputs are `unsupported`, host tool output
is `io`, and REA defects are InternalInvariantError.

The trace, NTFS journal, release exposure, web capture, native macOS and
web artifact adapters project the reader's parsed facts as
AnalysisTargetFailureError instead of invalid_request. Inventory
malformed, truncated, unsupported and cancelled reasons take their code
from the TargetFailure projection table, so a truncated container is
unsupported_target with failure_kind "truncated" on both paths.

BREAKING CHANGE: inventory_artifact, inspect_artifact, extract_artifact,
analyze_javascript_application, inspect_desktop_application,
inspect_keyed_archive, inspect_asset_catalog, inspect_nuget_nupkg,
trace_dylib_resolution, trace_web_module_imports and
trace_web_source_location report damaged container bytes as
unsupported_target (details.reason "malformed" or "truncated", with
failure_kind and format) instead of artifact_operation_failed with
reason "format", and a truncated container as unsupported_target instead
of truncated. inspect_playwright_trace, inspect_ntfs_journal,
audit_release_exposure, the web capture inspection operations and the
caller-selected import and source maps report damaged selected bytes as
unsupported_target instead of invalid_request. The `format` reason no
longer appears in details.reason.
…get failures

The SQLite engine's `format` reason is renamed to `malformed` at its
owner (SQLITE_INSPECTION_REASONS), and its refusal becomes an
AnalysisTargetFailureError at the selected path with format "sqlite".
The pwntools and EVM worker replies keep their wire reason "format",
which their workers define, and the adapters translate it once into a
malformed target failure with the profile's format (elf, elf-core,
evm-bytecode) instead of an invalid_format argument issue. SQLite joins
the target-failure conformance registry.

BREAKING CHANGE: inspect_sqlite_database, inspect_binary_layout,
inspect_recorded_crash and inspect_evm_interface report a selected
file's malformed bytes as unsupported_target with details.failure_kind
"malformed", format_failure, format and path, instead of invalid_request
with an invalid_format issue on path.
… reference page

artifact_integrity_mismatch's projection schema requires declared and
calculated digests, which a TargetFailure of kind integrity does not
carry, so the kind now projects artifact_operation_failed with category
integrity_mismatch. The model test validates every kind's projection
against analysisErrorProjectionSchema. The reference page joins the
documentation sidebar.
…odel

# Conflicts:
#	tests/boundary/filesystem/stableArtifact.test.ts
…p unsupported desktop probes local

A Bun or Node SEA short read inside a range already checked against the
measured size meant the file changed, not that it was truncated. The
carrier range reader and Bun's readExact now raise read-coverage
integrity for it, and keep 'outside the file' as the truncated case.
DesktopFileInspection records an unsupported managed-metadata probe as a
row issue again, so later file checks still run.
…ly suites

The literal-replacement scenario now reads the failure's detail instead
of an issues[] message, and a malformed reply wrapped by cleanup failure
reports category unsupported_target.
…d drop their per-command copies

The non-MZ PE imports and load-config cases (PE32/PE32+, ZZ and high-bit
signatures) and the truncated Apple IPS body move into the conformance
registry, which runs them through the CLI and MCP and now also checks
that a refusal leaves the selected file unchanged. The per-command tests
keep only their valid-image controls.
…ce registry covers

inspect_sqlite_database/not-a-database in the target-failure registry runs
the same non-SQLite bytes through the CLI and MCP, asserts the malformed
target facts and checks the selected file is unchanged.
…etry from it

Apply the owner review on #14239 to the TargetFailure model:
- remove details.format_failure; failure_kind is the only identifier;
- give integrity, conflict and io their own codes
  (target_integrity_mismatch, input_conflict, host_io_failed) and derive
  inventory malformed, truncated and unsupported codes from the same table;
- add a retry hint (none, backoff, after_change) derived from the kind,
  with io refined by its transient errno fact; retryable stays the
  unchanged-retry flag and is true exactly for backoff;
- rename the limit-cut result code and category truncated to partial;
- drop cancelled and resource from the target kinds and spell
  identifiers in American English (unrecognized);
- return a target failure a tool handler throws as a projected isError
  result instead of letting the SDK flatten it to text.

BREAKING CHANGE: details.format_failure is removed (read
details.failure_kind). The truncated result code and category are now
partial. Target integrity failures report target_integrity_mismatch,
host read failures host_io_failed and disagreeing inputs input_conflict.
Inventory operations (inventory_artifact, inspect_artifact,
extract_artifact and the other inventory callers) report truncated
container bytes as unsupported_target. Every target failure carries a
top-level retry hint.
…rget-failures

# Conflicts:
#	docs/reference/target-failures.md
#	src/domain/analysisErrorClassification.ts
#	src/resources/ArtifactOperationFailure.test.ts
#	tests/boundary/cli/artifactZstandardWindow.test.ts
…F declarations apart

PyInstaller reads inside the measured size, and .NET bundle manifest
refills, now raise read-coverage integrity on a zero-byte read instead of
truncated. A .NET bundle field and a Godot PCK directory entry that extend
past the file are truncated (with offset and extents) instead of
malformed. An absent or invalid ASAR packed offset is malformed; only a
valid range past the archive is truncated. The .NET manifest string
offset is reported in file coordinates.
The layout and recorded-crash workers raise a distinct truncated reason
when the file ends inside the ELF identification or header, and the
decoder projects it as failure_kind truncated instead of inferring it
from the message.
…as target failures

Managed readers interpret an issue code once, in managedIssueTargetFailure:
a coverage gap is an unsupported target, every other rule violation is a
malformed target, and the inventory metadata status is derived from that
same fact. managedInspectionTargetFailure now returns only
AnalysisTargetFailureError.

An IL2CPP binary that parses but does not link to its metadata is a
conflict target failure that lists both inputs and blames neither, in
place of an invalid_request with two issue entries. Metadata version 108
is an unsupported target. The CLI spells each conflict input's field by
the command's option name.

BREAKING CHANGE: inspect_managed_artifact, inspect_managed_members,
inspect_managed_native_boundaries and the managed comparison operations
report unsupported metadata or signature forms as an
AnalysisTargetFailureError (failure_kind unsupported, format pe-cli,
field, offset) instead of a bare unsupported target. inspect_il2cpp_metadata
reports a binary/metadata pair that does not link as code input_conflict
with failure_kind conflict and details.inputs, instead of invalid_request
with details.issues, and metadata version 108 with failure_kind
unsupported.
…odel

# Conflicts:
#	src/domain/analysisErrorProjection.ts
#	src/domain/parseFailure.ts
#	tests/acceptance/stableArtifactParserFailureCli.test.ts
#	tests/boundary/cli/managedMemberComparisonCli.test.ts
morluto and others added 11 commits November 24, 2026 21:45
details.reason is the owner's description. The compiled CLI refusal is
identified by failure_kind and format.

Co-authored-by: morluto <[email protected]>
A desktop root that is not a directory is a selection failure, so the
CLI reports invalid_request. An analysis view the parent cannot supply
is unsupported evidence; the tests read failure_kind, format, field and
related_operations.

Co-authored-by: morluto <[email protected]>
Base automatically changed from fix/inventory-target-failure-path to main November 25, 2026 03:51
cursoragent and others added 3 commits November 25, 2026 04:08
Pass the reader's UnsupportedBinaryPlistUidError failure through instead of
rebuilding a bplist refusal that drops field and undecodedContent.

Co-authored-by: morluto <[email protected]>
Assert the reader projects format, field, and undecoded content from the
parser failure instead of a rebuilt bplist refusal.

Co-authored-by: morluto <[email protected]>
@morluto
morluto merged commit 38bf511 into main Nov 25, 2026
56 checks passed
@morluto
morluto deleted the fix/unsupported-target-failure branch November 25, 2026 04:25
morluto added a commit that referenced this pull request Nov 25, 2026
Brings in the failure-model stack (#14247, #14265, #14268, #14272,
#14277, #14281, #14289). Target failures reach MCP through
toErrorToolResult and the CLI through projectCliAnalysisResult; neither
path calls the budget decision, so their projection is unchanged.

Conflicts: the Android verifiers keep main's sha256File helper and this
branch's complete-evidence wrappers; the ELF and Rust MCP tests and the
EVM description take main's version, since the harness default already
requests complete Evidence. A leftover delivery reassignment in the
EvidenceMcpServerCore constructor, already set by its parameter
property, is removed.
morluto added a commit that referenced this pull request Nov 25, 2026
#14281 moved dyld_info's file-type refusal onto the TargetFailure model.
The supported forms now appear in the refusal reason, and recovery comes
from the shared target-failure table, so remediation no longer says
"linked Mach-O". The test still pinned that wording and failed on main;
CI did not select it for #14281 or #14416.

It now asserts the facts the model owns: failure_kind unsupported, format
macho, field filetype, retry none, and the reason naming the linked
executables and relocatable objects dyld_info reads.
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Nov 26, 2026
2SinceJuly added a commit to 2SinceJuly/rea that referenced this pull request Nov 26, 2026
Upstream morluto#14281 deleted the ambiguous `format` reason from ArtifactReaderFailure and replaced it with the TargetFailure kinds, so the merge of main left this reader passing "format" to a constructor that no longer accepts it. Map the parser's own kinds instead: malformed for bytes that break the header rules, truncated for captures that end inside the MAM or Prefetch header, and keep undecoded container variants on unavailable so a supported-looking MAM file is still not called corrupt.

Tests follow the rename: the three truncation cases now assert truncated, and the MAM cases keep asserting unavailable.
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.

3 participants