23 Commits
Author SHA1 Message Date
morlutoandCursor Agent 2bf347dee6 fix(cli): reject invalid inline values and honor requested output on terminals (#14763)
* fix(cli): reject invalid inline values and honor requested output on terminals

- Reject inline boolean and empty number values the schema cannot accept
  instead of coercing --skill=yes to false or --limit= to 0.
- Give captured mcp add output the terminal presentation of every other
  command through one shared result destination.
- Show the unapproved setup plan whose remediation asks a terminal reader to
  review it, and open the setup rail once when a scoped run starts at approval.
- Treat --full-output and --token-count as requesting the result document, so
  setup and argument errors no longer add terminal presentation beside it.
- Answer --schema for an unknown command in the selected format, and set the
  exit code instead of exiting so piped stdout drains.

* fix(cli): keep rejected boolean and number literals across repeated flags

Binding stored one scalar value, so a later valid flag replaced an earlier
literal before the schema could reject it. Boolean and number literals the
field rejects now stay bound, including decimal unions and count options,
while repeated valid flags still use the last value. --dry-run keeps its
own error.

* test(cli): assert the terminal full-output failure envelope

The terminal --full-output regression only checked that usage text was
absent. Decode the default document and the --json envelope and require
VALIDATION_ERROR with the skill field's invalid_type error.

* test(cli): accept a counted setup approval prompt

A scoped terminal plan names every eligible action, so a Linux host that
can install Hopper asks "Apply these N changes?" rather than the singular
question. The consent helper now answers either prompt, and the rail test
finds that question before checking the intro was rendered once.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-26 12:15:17 -05:00
Entrpiandmorluto 721b25e20d feat(rizin)!: record which tool and version answered execute_rizin_command (#7487)
* refactor(process): share executable lookup with provider commands

Process capture owned the only spawn-equivalent PATH lookup, wrapped in
scenario-specific errors. Move the lookup into src/process as a result
type, so a provider command can resolve an executable once, hash it and
then run that same file. Process capture maps the result to its existing
errors unchanged.

* feat(rizin): record which tool and version answered execute_rizin_command

execute_rizin_command recorded version null and labelled any executable
selected by REA_RIZIN_COMMAND as Rizin, although radare2 also accepts
REA's argument list. Before the first command for each executable
digest, resolve the selected executable through PATH, hash it, run it
with -v and read its banner; the command then runs the same file. The
Evidence provider records the tool name and version, and the parameters
record the resolved executable path, its SHA-256 and the banner line.

A tool other than Rizin still runs, with a limitation; a failed, timed
out or unrecognized probe leaves the version unknown. Each digest's
reading, including a failure, is reused for the life of the process, and
concurrent first calls share one probe within the caller's
command_timeout_ms budget. A caller that stops waiting cancels the
probe only when no other caller needs it. A probe whose process cleanup
is incomplete stays retained for retry.

* fix(rizin): probe per call and reuse only completed probes

Sharing an in-flight version probe between callers let a joining call
outlive its own command_timeout_ms and inherit another caller's
cancellation, and the cache was keyed by digest alone, so byte-identical
launchers in different directories shared one reading. Remove the
sharing: each call runs its own probe under its own deadline and
cancellation. Reuse only completed probes (a banner, a non-zero exit or
a timeout), keyed by the resolved launch path and its SHA-256.

The executable lookup now honours the call's deadline and cancellation,
so a stalled PATH entry cannot hang a call or close(). A failed probe
records its exit status and bounded stdout and stderr in
provider_version_probe, and a cancelled probe keeps its captured output
on the error.

* fix(rizin): never let a later probe failure replace a successful reading

Concurrent first calls can each probe the same launch path and digest.
When one probe printed a banner and another later timed out or exited
non-zero, the failure overwrote the cached reading, so every later call
reported an unknown version for the life of the server. Route the cache
write through one rule: a failure never replaces a successful reading,
and a success replaces an earlier failure. Each call still reports its
own probe's outcome.

* docs(rizin): state what the executable digest and version observe

The guide said the command "runs the same file" as the version probe.
REA runs the same resolved path; the recorded SHA-256, tool and version
describe the file there when REA checked it. Say so, with the limit the
guide already states for artifact digests: they cannot prove the exact
bytes executed if the file changes before the launch.

* test(rizin): pin the banner a real Rizin 0.9.1 printed

Homebrew's Rizin 0.9.1 prints `rizin 0.9.1 @ darwin-arm-64, package:
0.9.1_2 (Homebrew)`, with a package suffix after the platform. The
identity test now uses that banner, so a parser that expects the line to
end at the platform fails; the other tests keep the plain form.

The test name and the probe comment now say REA runs the path it hashed
and reuses a completed probe per launch path and digest, as the guide
says since c73a0be9c.

* fix(rizin): replace the service's lookup and execution together

Tests that injected a fake runner still resolved `rizin` through the host
PATH. With Rizin installed, the version probe took the fake runner's
first canned result, and three tests in reverseEngineering.test.ts
failed. CI has no Rizin, so they passed there.

The service now takes one `processes` option: the executable lookup with
either a runner or the owned-process primitive. It replaces `run` and
`runOwned`, so a fake runner cannot be paired with the host lookup.
Omitting it keeps the host lookup and owned execution. The lookup no
longer reads the service's `stat` seam.

The test service pairs a fake runner with a lookup that finds nothing
unless the test passes one; the identity tests pass the real lookup
explicitly. A new test puts an executable `rizin` first on PATH with a
fake runner and checks that each command gets its canned result, and
that the options type rejects a runner without its lookup.

* fix(rizin): end the call when hashing the executable reaches the deadline

When hashing the resolved executable reached command_timeout_ms,
digestFile rejected with ETIMEDOUT and the service recorded an unknown
identity, then launched the caller's command with a fresh deadline. A
caller-selected, possibly side-effecting command ran after its
preflight deadline had passed.

The hash deadline now returns AnalysisTimeoutError with phase
executable_digest, as the lookup's deadline already did, and the timeout
guidance names executable identification among the phases. A test
stalls the executable's stat past a 50 ms deadline and checks that
nothing runs.

* fix(rizin): bound kept version probes and keep only complete readings

The probe cache kept one entry per launch path and digest and never
evicted one, and a kept banner could be as long as the 16 MiB capture.
It now keeps the latest completed probe per launch path with the digest
it read; a new digest replaces it, and a later failure still never
replaces a successful reading of the same digest. The service reads the
banner (the first stdout line, trimmed), keeps at most 2,048 characters
of it and records provider_version_banner_truncated; the provider's
parser now reads that bounded banner, so everything a probe keeps is
bounded.

A -v output that was not valid UTF-8 was parsed anyway, so replacement
characters could become provider.version. It now leaves the version
unknown, with a limitation saying the output is not valid UTF-8.

An owned probe whose output was not fully collected was labelled failed
when it carried a numeric exit status, and cached. A collection failure
is now checked first: the probe is unfinished, is not kept, and its
diagnostics report no exit status.

Tests cover a digest change replacing the kept probe, a capped banner,
undecodable output and a collection failure that is probed again.

* fix(rizin): keep only probe outcomes that describe the executable

A timed-out version probe was kept for its launch path and digest, so a
later call with a longer command_timeout_ms reused it without probing:
its Evidence said the probe reached the command deadline, and the
version stayed unknown until the executable changed. A timeout is a fact
about one call's deadline, not about the file.

Each probe outcome now carries its scope in its type: a reading, a
failed exit and undecodable output describe the executable and are
kept; a timeout and unfinished output describe the call and are not.
The cache accepts only executable-scoped outcomes, so the call site no
longer filters. Both runners report a deadline as ETIMEDOUT, which the
probe checks before any signal, so a stopped probe is always timed-out.

A test times out a probe through the owned runner's deadline failure,
then checks that a call with a longer deadline probes again and reads
the version.

* fix(rizin): flag invalid UTF-8 in version-probe diagnostics

When -v exited nonzero or timed out with output that was not valid
UTF-8, provider_version_probe kept the decoded text, replacement
characters included, with no flag. Undecodable output's stderr had the
same gap.

The failure capture (execFileOutputFailure) now reads the runner's
stdoutInvalidUtf8 and stderrInvalidUtf8, as it already reads
collectionFailure. The probe diagnostics record them for every outcome
that keeps output, as stdout_invalid_utf8 and stderr_invalid_utf8,
following gdb Evidence's stderr_invalid_utf8. The command path takes its
flags from the same capture instead of reading the owned failure
directly. The guide names the two fields.

Tests cover failed and timed-out probes with invalid stdout or stderr,
undecodable output on both streams, and a failed command whose stdout
is not valid UTF-8, which pins the command path's flags to the capture.

* fix(rizin): mark the provider as assumed when no banner identifies it

When the -v banner did not match, identifyRizinTool returned Rizin's
identity with no limitation, so Evidence named Rizin although nothing
identified the tool; the limitation qualified only the version and
formats. Failed, timed-out and undecodable probes, and an executable
that could not be located or read, named Rizin the same way.

The Evidence provider schema requires a name, so the tool cannot be
recorded as unknown. The parser now returns no identification for a
banner it does not recognise. Wherever no banner identified the tool,
the service keeps the configured identity, sets provider_identity to
"assumed" and adds the probe's assumed-identity limitation, which the
Rizin probe owns; an identified tool gets provider_identity "banner".
The guide and the tool description say so.

Tests cover an empty first line and a Usage: banner; two composition
tests now count the added limitation.

* fix(rizin): keep invalid UTF-8 flags in typed errors' captured output

A cancelled or cleanup-incomplete version probe carried captured output
from execFileFailureCapturedOutput, which dropped the runner's
invalid-UTF-8 flags, so its replacement characters looked like provider
output. The command path's own captured output had the same gap when
cancellation ended a run or a failure was captured.

AnalysisCapturedOutput gains stdout_invalid_utf8 and
stderr_invalid_utf8, set to true only when the runner reported invalid
UTF-8, as command observations mark output_invalid_utf8. The shared
projection fills them through capturedInvalidUtf8, and the command
path's two captured outputs use the same helper, so every consumer of
a runner's failure report keeps them. The guide mentions the markers.

Tests cover a cancelled and a cleanup-incomplete probe, and a command
cancelled during and after its run, each with invalid UTF-8 output.

* fix(rizin): probe the executable before every command

A launcher such as a version-manager shim keeps its path and SHA-256
while the tool it delegates to changes, so a reading kept for that path
and digest could name a tool the command no longer runs. A shim's
delegate cannot be observed, so no kept reading can be checked for
freshness.

Every call now probes in its own environment and under its own deadline
before the command, and nothing is reused. The cache, its keep and
replace rules and the outcome scopes that existed only for it are
removed; without a cache, an unfinished probe is reported as failed, and
its diagnostics still give no exit status when output was not fully
collected. The per-call digest stays in Evidence. The guide and the
tool description say each call probes.

On this Mac (Homebrew rizin 0.9.1) a probe costs about 180 ms through
REA's owned-process runner, of which rizin -v itself takes about 15 ms
warm: the price of identifying the answering tool on every call.

A test runs a launcher whose bytes stay the same while the tool it runs
changes, and checks that each call reports the tool that answered.
Tests that only covered the cache are removed; the rest now expect a
probe per call.

* test(rizin): restore the per-caller probe deadline test

dd06ad27c removed the cache-only tests with a script that also removed
"runs each caller's probe under its own deadline and cancellation",
which covers per-call probing: two concurrent calls each probe under
their own deadline and signal, and cancelling one stops only its probe.
Restore it without the reuse check that only the cache needed.

* fix(rizin): read the working directory only when the lookup needs it

The service passed process.cwd() to the executable lookup on every call.
If the server's working directory had been removed, process.cwd() threw
ENOENT before the lookup looked at an absolute REA_RIZIN_COMMAND, and
executeRizinCommand rejected instead of returning its Result.

lookupExecutable now takes a function for the working directory and
reads it only for a relative command or PATH entry, or on Windows, where
an absolute path can still depend on the working directory's drive. A
failed read is a typed no-working-directory status, which the service
records as an executable it could not locate, so the call still
resolves to a Result. Process capture, whose working directory is
already resolved, maps it to its working-directory input error.

Tests make process.cwd() throw ENOENT: an absolute command and target
identify and run without reading it, and a relative command or PATH
entry gets a Result with an assumed identity.

* fix(rizin): cut probe banners and diagnostics between code points

The banner and a failed probe's two diagnostic streams were cut at
2,048 UTF-16 code units, so a cut could leave a lone surrogate. REA
already owns this cut: boundedUtf8Text keeps text within a UTF-8 byte
budget without splitting a code point, as other providers' probes use
it.

The banner and both streams now go through it with a 2,048-byte budget,
and provider_version_banner_truncated and output_truncated come from
its truncated flag. The guide states the limits in UTF-8 bytes.

Tests cut an astral banner and astral diagnostic streams at the
boundary; an ASCII banner keeps its 2,048 bytes.

* fix(rizin): keep diagnostics for a banner that identifies no tool

When -v exited 0 but its banner identified nothing, Evidence recorded
only provider_version_banner: the probe's exit status, stderr and later
stdout lines were dropped, although the guide promises
provider_version_probe for any probe without a usable banner, and that
is when the assumed identity needs explaining.

Such a probe is now its own unrecognized outcome. It keeps the banner
and versionProbeDiagnostics(0, output), like the other unusable
outcomes, and Evidence records both; a recognized banner remains read.

Tests cover an empty first line with an explanatory stderr and a
Usage: banner followed by more lines.

* fix(rizin): identify nothing from a banner cut at its byte limit

identify ran on the banner even when boundedUtf8Text had cut it, so a
version token running past the 2,048-byte cut was published as an exact
provider.version.

A real banner is about 40 characters, so one guard is enough: a cut
banner identifies nothing. It becomes the unrecognized outcome, with the
probe's diagnostics and the assumed identity; no separate token parser
is added. The guide says so.

A test cuts a first line inside its version token; the banner-cap test
now expects no version from a cut banner.

* fix(rizin): accept only the -v banner Rizin and radare2 print

The banner pattern ^(\S+) (\d\S*) read any first line with a digit token
as an identity, so `Warning: 123 …` became tool "Warning:", version 123.

identifyRizinTool now accepts only the first-line form Rizin and
radare2 print: a plain tool token, a version, any build tokens, then
`@ <os>-<arch>-<bits>` and an optional `, <package>` suffix. The real
banners on this Mac fix the form: Rizin 0.9.1 (Homebrew) prints
`rizin 0.9.1 @ darwin-arm-64, package: 0.9.1_2 (Homebrew)`, and radare2
6.1.8 prints `radare2 6.1.8 +0 abi:110 @ darwin-arm_64`. Anything else
is unrecognized, with the assumed identity and the probe's diagnostics;
a well-formed radare2 banner keeps its non-Rizin limitation. The guide
gives the form.

Tests cover `Warning: 123 …`, a status line before the banner, a banner
without the @ suffix, and the real Rizin and radare2 banners. Two
fixtures that printed `@ test` as the platform now print a real form.

* fix(rizin): keep the probe's identification when the command fails to start

After a successful -v probe, a command that failed to start, such as an
oversized command the host refused with E2BIG, returned its typed error
without the tool, version, path, SHA-256 or banner the probe had
observed: only Evidence carried the identification, and these failures
build none.

The identification now records whether a probe ran. When one did, the
launch failure keeps `provider` and the provider_* parameters in its
diagnostics; the Evidence limitations, which describe command output,
stay out. A probe that is cancelled or whose cleanup is incomplete
keeps the executable path and SHA-256 it ran from. An executable that
was not located or could not be read adds nothing, since nothing about
it was observed.

A real-process MCP test probes a fake rizin, then fails the launch with
a real E2BIG (a 2 MiB command) and with ENOENT (the probe removes the
executable after a banner that identifies no tool). The probe
cancellation test checks the path and SHA-256. The guide says where the
facts appear.

* test(rizin): move tool-identity cases to boundary and process-global projects

The tool-identity cases run the real executable lookup and file digest,
which crosses the production filesystem boundary, so they move from the
shared-worker composition project to tests/boundary/filesystem. The two
cases that replace process.cwd move to tests/process-global, whose
isolated forks keep that process-global state from leaking into other
files. The fixture, fake runner and probe count they share move to
tests/support/rizinToolIdentity.ts.

* fix(process): resolve each PATH entry only when the lookup reaches it

Candidate construction resolved every PATH entry up front, so a relative
entry after the match (PATH=/opt/rizin/bin:.) read the working directory
before the absolute entry was checked. With that directory removed, the
lookup reported no-working-directory and skipped hashing and probing,
while the bare command still ran from /opt/rizin/bin with an assumed
identity. Each entry now resolves when the search reaches it.

* fix(rizin): run the found executable when it cannot be read for hashing

When the lookup found an executable that the hash could not read, such
as a native binary with mode 0111, identification fell back to the bare
command name. The command then searched PATH again instead of running
the file the lookup selected, so another executable could answer, and
Evidence lost the path that was observed. The fallback now keeps the
found path for the launch and as provider_executable_path, without a
SHA-256 or probe. The flag that keeps these facts on a launch failure
is renamed from probed to observed, since it now also covers a lookup
whose hash failed.

* fix(rizin): leave the version unknown when probe stderr is not valid UTF-8

An exit-0 probe with a valid stdout banner and malformed stderr was
accepted as a banner, and the read outcome dropped the probe's
diagnostics, so Evidence published the version while losing stderr and
its stderr_invalid_utf8 marker. The documentation says output that is
not valid UTF-8 leaves the version unknown; the probe now checks both
streams before reading a banner.

* fix(process): report no exit status for output that was not fully collected

execFileFailureCapturedOutput published a failed run's numeric exit
code even when its output was not fully collected. The command path and
the version probe's diagnostics already report null for that status, so
a probe that lost output and whose cleanup also failed carried
conflicting completion facts: null in provider_version_probe, a number
in the error's captured_output. The shared projection now owns the
rule, which also applies it to the ADB, Ghidra launcher, Doctor, Apple
asset catalog and Darwin process-token failures that use it.

* fix(rizin): bound the version banner as printed before trimming it

The probe trimmed the first line before applying its 2,048-byte budget,
so a line with more than 2,048 bytes of leading whitespace before a
valid banner lost that prefix unrecorded and was identified, with
provider_version_banner_truncated false, although the documented budget
covers the banner line. The budget and the recorded banner now cover
the line as printed; only identification reads a trimmed copy.

* fix(process): continue the PATH search past an unreadable relative entry

With the working directory removed and PATH starting with "." or an
empty entry, the lookup stopped at that entry with no-working-directory.
A spawned search finds nothing under a removed directory and moves on,
so the command still ran a later match by its bare name, while Evidence
reported an assumed identity without path, digest or version. The
lookup now skips such an entry and reports the unread working directory
only when no later entry matches; an explicit relative command still
reports it at once.

* fix(rizin): keep the found executable path when hashing it ends the call

When the hash of a PATH-selected executable reached the deadline or was
cancelled, the typed error kept only its phase. The call returns no
Evidence then, so the caller lost the provider_executable_path the
lookup had observed and could not tell which PATH location stalled,
although a cancelled probe and a failed hash keep that path. Both
errors now carry it in details.diagnostics beside the phase.

* fix(rizin): keep the PATH candidate a stalled lookup was checking

When the stat or access of a PATH candidate reached command_timeout_ms
or was cancelled, the lookup reported only that it was interrupted, so
the typed error carried phase executable_lookup and nothing else. The
caller could not tell which PATH location stalled, as on a slow network
mount. The interrupted lookup now returns the candidate it was checking,
and both errors carry it as executable_lookup_candidate.

* fix(rizin): state that the executable digest precedes both launches

REA hashes the selected executable before the -v probe and the command
run, so a file replaced in between gives a SHA-256 of the old file
beside the identity and output of the new one. The documentation said
so, but inline Evidence did not. Evidence that records
provider_executable_sha256, identified or assumed, now carries a
limitation saying the digest was read before both launches and does
not prove the bytes that ran.

* fix(process): check an unreadable relative PATH entry as written

12244b7a3 skipped a relative PATH entry whose working directory could
not be read, assuming nothing under a removed directory is reachable.
The kernel still resolves `..` from a removed directory, so with
PATH=../bin:/usr/bin a spawned search runs ../bin/rizin while the
lookup selected /usr/bin/rizin, and the service probed and ran that
other tool. Such an entry is now checked as written, against the
process's working directory: an entry without the executable lets the
search continue, and a match there ends the lookup with
no-working-directory, so the launch by name follows PATH order.

* test(rizin): join the hash-interruption call before teardown

The hash-interruption test waited for its gate with a bounded wait and
only released the gate and aborted the caller in finally, so a failed
wait left the call running past teardown. It now waits through
awaitAcknowledgement, keeps the call in pending, and in finally
releases the gate, aborts, joins the call and closes the service, as
the stalled-lookup test does.

* fix(rizin): keep the selected executable when the command fails to start

When the command failed to start after identification, for example with
E2BIG, the error kept the provider, the resolved path, the digest and
the banner, but not the executable the caller selected. Evidence records
it as provider_executable, and only the ENOENT launch branch carried it
as command; an E2BIG resource constraint carries just argument_bytes, so
a bare alias or configured path was lost. The retained diagnostics now
include provider_executable beside the lookup, hash and probe facts.

* fix(rizin): keep the selected executable on every error before Evidence

7a003942a kept provider_executable only on a launch failure after
identification. The lookup's, the hash's and the probe's errors also
end the call before Evidence exists, as does a launch failure without
identification facts, and none of them kept the executable the caller
selected, so a bare alias or relative spelling was lost. The service
now adds provider_executable to an identification error where it
returns, and to every launch failure, with the observed facts only when
there are some. inspect_with_objdump's launch failures keep it too.

* fix(rizin): mark a version probe whose completion is unknown

When the owned runner reported a collection failure with completed
cleanup and the partial streams fit the 2,048-byte cut, the probe's
diagnostics showed output_truncated false and no completeness field;
only the nulled exit code hinted that bytes were missing. The probe's
diagnostics now carry completion_status with the command's own rule:
unknown when output was not fully collected or the probe was killed,
signalled or left no exit code, and complete otherwise.

* fix(process): end the PATH search at errors a spawned search stops at

The lookup moved past every PATH candidate whose stat failed. A spawned
search moves past only a missing file, a non-directory and a denied
directory; at any other error, such as a symlink loop (ELOOP), it stops
and the launch fails. With PATH=<loop>:/usr/bin, the lookup selected
/usr/bin/rizin and the service hashed, probed and ran it, although a
launch by name fails. The search now ends there, reporting the error in
checked, so the launch by name fails as a spawned search would. A
non-executable file earlier on PATH still lets the search continue.

* fix(process): end the PATH search at execute-check errors a spawn stops at

c1d66e52f classified only stat failures: the execute check still moved
past any error, so an EIO from a failing network-backed PATH entry let
the lookup select a later executable that a launch by name would not
reach. Both checks now use one rule, searchMovesPast: a spawned search
moves past ENOENT, ENOTDIR and EACCES and stops at any other error. The
execute check is injectable beside stat, so the EIO case is tested.

* fix(rizin): state that the version banner, too, precedes the command

a2fc5a11f qualified only the executable's SHA-256 as a pre-launch
observation. The -v banner, and so the recorded tool and version, is
also read before the command runs, so a package update in between
attributes the command's output to the old version. The limitation,
renamed EXECUTABLE_OBSERVATION_TIMING, now says the SHA-256 and any -v
banner were read before the command launched and do not prove the bytes
or the version that ran; the documentation says so too.

* fix(process): skip PATH entries a spawned search cannot hold

c1d66e52f ended the search at any error a spawned search does not move
past, including ENAMETOOLONG. But glibc's execvp on Linux and libuv's
own search on macOS skip a PATH entry of at least PATH_MAX bytes (4,096
and 1,024) before trying it, so with a 5,000-byte entry first, a launch
by name ran /usr/bin/true while the lookup reported it missing, and
capture_process_scenario rejected a command that worked. Such entries
are now skipped before they are checked; a shorter entry with an
over-long component still stops the search with ENAMETOOLONG, as a
launch by name does. On Linux the search also moves past ESTALE, ENODEV
and ETIMEDOUT, as glibc's execvp does.

* test(rizin): check the timing limitation through its constant only

The regex added in 85eb3b6c0 froze the limitation's wording, which
docs/testing.md rules out: guidance delivery is checked against the
owning constant, beside independent assertions for the facts. The test
keeps the EXECUTABLE_OBSERVATION_TIMING delivery check and its
provider, path, digest and banner assertions; a harmless rewording now
passes.

* fix(process): skip long PATH entries only where the host's limit is known

3e32a4422 used a 1,024-byte limit on every host other than Linux, so on
Android (Termux), where execvp has a 4,096-byte buffer, a valid
1,500-byte PATH entry was skipped and a later rizin ran. The length skip
now applies only on Linux (4,096 bytes, glibc and musl) and macOS (1,024
bytes, libuv); elsewhere an over-long entry stops the lookup, and the
launch by name lets the host's own search decide. By the same rule, the
lookup no longer moves past ESTALE, ENODEV and ETIMEDOUT on Linux: glibc
does but musl does not, so the lookup stops there too, leaving the tool
unidentified rather than possibly wrong.

* fix(rizin): keep a probe's timeout when its cleanup is also incomplete

When the -v probe reached command_timeout_ms and stopping it left
cleanup incomplete, the incomplete-cleanup branch ran first and returned
an AnalysisOutputError, so the error said only that cleanup remained and
lost the timeout and its remediation, even after a cleanup retry. The
command path keeps the AnalysisTimeoutError and attaches the cleanup;
the probe now does the same, so the timeout stays the failure, the call
still ends, and the owner is retained until it stops.

* fix(rizin): keep the target's path and digest on errors before Evidence

The lookup, hash and probe errors, and launch failures, end the call
before Evidence exists, after the target was already resolved and
hashed, but kept only the selected executable and provider facts. The
caller could not bind the failed attempt to the artifact it submitted.
Every such error now also keeps artifact_path and artifact_sha256 for a
call with a target, beside provider_executable.

* test(rizin): expect the long PATH entry skip only on Linux and macOS

The long-entry case required a skip on every POSIX host, but the length
skip applies only on Linux and macOS; on Android and other hosts the
lookup stops with ENAMETOOLONG instead, so the test failed there although
the lookup behaved as intended. It now expects the skip on Linux and
macOS and the stop elsewhere.

* fix(rizin): defer an unstartable file to the host and bound stalled I/O

The lookup took an executable regular file as the match, but a spawned
PATH search also moves past a file that fails to start with ENOENT,
such as a script whose interpreter is missing. Pinning the probe and
the command to that file failed calls that the host would run. When
the version probe does not start, the command now runs as selected,
with the version unknown, and a limitation names the file.

A lookup that stops waiting for a stalled stat or access leaves the
call running, and later lookups of the same path now share it instead
of starting another, so retries no longer add calls on an unresponsive
mount. digestFile ends at its deadline or on cancellation even while
the file's open is pending; a destroyed stream reports its error only
after that open returns. A lookup the host refuses to inspect runs the
resolved path and keeps it as provider_executable_path, also when the
launch fails.

Process capture verifies the file it launches, so it still rejects a
scenario where native searches disagree; its docs now say so.

* docs(rizin): say the lookup stops where any native search stops

The lookup stops at every error other than a missing file, a
non-directory or a denied directory, because at least one native
search stops there; musl's stops at each of them. At a symbolic link
loop or an I/O error the searches agree, so "do not agree" was wrong
there. The process-capture docs and resolveExecutable's comment now
state the same rule.

* fix(rizin): bound stalled hash opens and defer EACCES launches

The interruptible hash let each timed-out retry start another open on a
stalled mount, outside the eight-operation cap. A later hash of the same
path now waits, within its own deadline and cancellation, for an earlier
open that has not returned, and hashes share a stalled stat through the
helper lookups use, now src/process/SharedFileCall.ts.

A probe launch that fails with EACCES, as for a script whose interpreter
is not executable, is one a native PATH search moves past, like ENOENT,
so the command now runs as selected. The shared-check test bounds its
gate wait and joins its started checks in teardown.

* test(rizin): return stalled opens and join their streams in finally

The open-gate test returned its stalled open only after its assertions
passed, and the deadline and cancellation test never returned its open,
so a failed assertion, or every run, left a stream waiting on a pending
open. docs/testing.md asks for held work to be released and joined in
finally. A shared helper now holds each stalled open; both tests return
it, destroy the stream and wait a bounded time for its close in finally,
so a failed assertion is still reported as itself.

* refactor(rizin): own the version-probe types in the domain layer

RizinCommand.ts imported ProviderToolIdentification and
ProviderVersionProbe from the application port, so the Rizin provider
depended on the application layer; the architecture has Rizin depend on
the domain only. Move both neutral types into
src/domain/reverseEngineering.ts beside the command inputs. The port,
the service and the Rizin adapter import them from there.

* fix(rizin): hold a hashed path until its stream closes

A hash released its path when the file's open returned. A read that a
stalled mount then held kept its libuv worker after the digest timed
out, while the next hash of the same path opened the file again, so
repeated hashes could start stalled reads without bound. Keep each
stream registered until it closes: a file stream closes only after its
pending open or read returns, so a later hash of the path waits for it,
and stalled opens and reads stay bounded by the paths.

* fix(rizin): make hashes wait only for streams an earlier hash gave up

13515107a kept every hash's stream registered until it closed, so a
hash waited for every earlier hash of the same path, healthy ones
included, and concurrent calls on one target could spend their deadline
waiting and time out before they launched. Register a stream only when
its hash gives up while its open or a read is pending, and keep it until
it closes. Later hashes of that path wait for those streams, so abandoned
I/O stays bounded by the paths, while hashes that have not given up no
longer wait for each other.

* fix(rizin): keep an explicitly selected path the lookup does not accept

An explicitly selected command that resolved to a file without execute
permission ended the lookup as missing, with its absolute path only in
the checked strings. The command then ran by its relative name, and the
launch failure lost provider_executable_path. A missing lookup now
reports the path an explicit selection names, and the service runs that
path and keeps it, as it does for a path the host refuses to inspect.
Process capture ignores the field and still rejects such a file as an
invalid selection.

* fix(rizin): keep an explicit path's facts when its probe does not start

When the version probe of an explicitly selected path failed to start,
as a script with a missing interpreter does, the command ran the
selection as written and kept nothing the lookup and hash observed, so
its launch failure lost the resolved path and SHA-256. An explicit
selection has no later PATH candidate for the host to try. The lookup
now marks a found explicit path with selectedPath, and the service runs
that path and keeps its observations, while a PATH match still runs by
name for the host's search to decide.

* fix(rizin): launch a selection the lookup did not accept as spelled

73554211b launched the absolute path an explicit selection names
whenever the lookup did not accept it. A relative selection that fits
the host's path limit can have an absolute spelling that does not, so a
command that launched before failed with ENAMETOOLONG. Launch the
selection as the caller spelled it again, and keep the resolved path in
Evidence and launch failures as provider_executable_path. A path the
host refused to inspect still launches as resolved.

* test(rizin): release and join the concurrent hashes in their test

The concurrent-hash test left both hashes running when its wait for the
second open failed, so their later rejections could hide that failure.
Wait with awaitAcknowledgement, settle both hashes together, and destroy
the streams and join the hashes in finally.

* fix(rizin): let the host's search decide after ESTALE or ENODEV probes

When the version probe of the file the lookup found failed to start
with ESTALE or ENODEV, the service recorded a failed probe and ran that
file again, although glibc's PATH search moves past such a file and
musl's stops there. Treat both like the errors every search moves past:
the command runs by name and the host's search decides, as the lookup
does where native searches differ. ETIMEDOUT stays the probe's deadline,
which both runners report with that code.

* fix(rizin): keep a call's place until its abandoned file streams close

A call that ended at its deadline while a hash's stream was stalled on
an unresponsive mount freed its place among the eight concurrent
operations, though the stream's read or close still held a libuv worker,
so calls on different files could pile up stalled file work without
bound. A successful hash also completed at its stream's end, before a
close that could stall. A hash now completes when its stream closes, so
a stalled close reaches the deadline as a stalled read does, and each
stream a hash gives up on is reported to the service, which keeps the
call's place until those streams close. The capacity error counts such
calls as operations_awaiting_file_close.

* test(rizin): keep disk reads and prose out of two tests

The admission test for abandoned file streams called the real
digestFile once its files closed, reading the disk in a composition
test; its fake now returns a fixed digest. Two assertions matched the
not-started limitation's whole phrase; they now check that a
limitation names the skipped file and its launch error, so rewording
the limitation does not fail them.

* fix(rizin): give file work that a call gives up on one owner

A lookup or hash that reached its deadline while a stalled mount held a
stat or access check gave the call's place among the eight concurrent
operations back, although that check still held a libuv worker. Streams
were already held, through a separate map, a callback threaded through
three layers and a second set in the service, while stat and access
checks were shared through a third, module-level map.

FileWork now owns all of it. Each call runs its stat, access and stream
steps through a scope of the service's FileWork under one deadline. A
step the deadline or cancellation interrupts is left with the scope that
started it, later work on that path waits for it instead of starting
more, and the service keeps the call's place until what it left has
returned. A call that only waited for another call's work leaves nothing
and keeps no place. The capacity error counts held calls as
operations_awaiting_file_work.

digestFile takes its bounds as one object, like lookupExecutable.
SharedFileCall, the stream map, the onAbandoned callback and the
per-step deadline helpers are removed, and the two edge-case tests that
probed the gap between the old stat and stream listeners now check the
single deadline instead.

* fix(rizin): let a call that stops waiting for left file work detach

A call waiting for file work left behind on its path raced a
Promise.all over that work against its deadline. When the deadline won,
the reactions stayed attached to the stalled work's promises, so retries
on a stalled path kept about 2 KiB each until the mount answered: 207 MiB
over 100,000 interrupted waits. Each waiting call now adds a wake
function to the path's left work and removes it when it stops waiting,
and the last left step on the path wakes the waiters that remain. The
same measurement retains 2.5 MiB, and 4.5 MiB over 400,000 waits.

* fix(rizin): keep where a stopped PATH lookup stopped

When the lookup of a bare command stopped at a candidate whose error at
least one native search stops at, such as ELOOP, EIO or ESTALE, the
command ran by name, but Evidence and launch failures said only that
the executable could not be located. The candidate and its code existed
only as display text in the lookup's checked list. The lookup now
returns them as stoppedAt, and the service names them in the limitation
and keeps them as executable_lookup_candidate and executable_lookup_code.

* fix(rizin): report held file work when the service closes

close() aborted active calls, awaited their results and retried process
cleanup, then resolved, although a call that had returned could still
hold a stat, access or stream step that an unresponsive mount had not
answered. Waiting for that work could hang shutdown on a mount that
never answers, so close now fails instead with a cleanup error that
names file_system_work and counts the calls holding it
(operations_awaiting_file_work), and a later close checks again, as it
does for retained provider processes.

* fix(rizin): keep stalled file work out of close

ad4a22b32 made close() fail while a call still held file work that a
stuck mount had not returned. That error could not clear once the work
returned, it hid behind a process-cleanup failure, and the CLI replaced
the command's own error and Evidence with it. Close cannot release that
work anyway: it cannot be cancelled, joining it would hang shutdown on a
mount that never answers, and the runtime keeps the process alive until
it returns. close() again aborts active calls, awaits them and retries
process cleanup; the call keeps its slot until its file work returns.

* fix(rizin): bound stalled file work by the thread pool

Each stalled stat, access or stream step holds a thread of libuv's pool,
which Node sizes at 4, while the eight-call cap allowed eight on distinct
paths. Four would stall every other file, DNS and compression call in the
process. The pool belongs to the process, so FileWork now has one
process-wide owner, HOST_FILE_WORK, with a budget of 2 held steps. Past
it a new step starts nothing: the service reports a retryable capacity
error with file_steps_held and max_held_file_steps, and the lookup returns
saturated, which capture reports too. A step on a path that already has
stalled work waits and takes no thread. The service takes its owner as an
option, and test services get their own.

* fix(cli): exit after a command while a stalled file step is held

A pending system call keeps Node's event loop alive, so a CLI command
that timed out on a stalled mount wrote its result and then stayed
running until the mount answered, which may be never. The launcher now
asks the CLI runtime whether the process holds stalled file work and, once
the result is delivered and stdout has drained, exits explicitly. Runs
that hold no stalled work end as before.

* fix(rizin): reserve the file-step budget before a step starts

The budget counted only steps already left behind, so calls that stalled
together all started while it read zero, and eight concurrent stats could
exhaust the pool. A step now reserves the budget before it starts and
releases it when the underlying work settles. A step waits within its
deadline while running steps fill the budget, and is refused once
left-behind steps fill it. The budget is half of libuv's pool as
UV_THREADPOOL_SIZE sizes it, with at least one step, instead of a fixed 2.
A refused target preflight also keeps its path as artifact_path.

* fix(rizin): keep unbounded file work out of the shared budget

Process capture's executable lookup has no deadline, so a stalled check
would stay running forever, fill the shared budget and make healthy
captures wait without end. A lookup or hash that is given no owner now
joins no budget, so capture behaves as it does on main, and only the
service, whose calls have deadlines, shares the process-wide owner.
Tests that count steps fix their budget instead of inheriting the host's
UV_THREADPOOL_SIZE, and the concurrent-step tests use bounded waits and
release their work in finally.

* Revert "fix(cli): exit after a command while a stalled file step is held"

This reverts commit 4a4bb74bc. It did not work: process.exit() also
hangs while a pool thread is stuck in a system call, because Node joins
the pool at exit. Its test passed only because the simulated stall held
no thread. The docs now state the limit: a CLI command prints its result
and then stays alive until the mount answers. A real exit path needs a
process-wide design and goes to the maintainer proposal.

* fix(rizin): keep a found file that did not start as a candidate

When the file a bare command's lookup found did not start, the command
ran by name, and a failed launch then lost that file's path, digest and
launch error. Evidence and launch failures now keep them as
executable_lookup_candidate, executable_lookup_candidate_sha256 and
executable_lookup_code, without claiming that the candidate ran.

* fix(rizin): keep why a post-run digest or lookup gave no answer

A post-run hash that the file-step budget refused was reported as an
artifact that could not be read. Evidence now keeps the command output
with artifact_digest_after_refused and a limitation saying the artifact
was not read. A lookup that needed an unreadable working directory also
lost that outcome when the launch by name failed; it now keeps it as
executable_lookup_outcome and executable_lookup_code.

* test(rizin): compare the post-run limitation through its owner

The refused post-run digest test froze one explanatory phrase and banned
another. It now keeps the structured refusal facts and checks that the
unreadable-artifact limitation, an exported constant, is absent.

* fix(rizin): keep preparation failures' output and cleanup

Ownership preparation throws its own failure, or an interruption wraps
it, and runOwnedCommandOutput recognized neither. The compiler output
was lost and a retained helper could not be retried, for the version
probe and for the command. Normalize both shapes at that boundary, so
preparation is a launch failure that carries its output, and its
cleanup reaches retryCleanup through the same stop contract.

* refactor(rizin): drop the shared file-work pool from tool identity

A maintainer asked to separate the shared FileWork pool from this PR
until the lifetime design in #8860 settles. The pool kept a call's place
while file work it gave up on was running, made later work on that path
wait for it, reserved half of libuv's pool as a budget of stalled steps,
and refused new steps with a capacity error once that budget was held.

The lookup and hash now run each stat, access and stream step under one
deadline and cancellation listener (FileDeadline). A step the call stops
waiting for keeps running until its mount answers, untracked, as main's
stat already did. The call returns and gives back its place. The
saturated lookup outcome, FileWorkSaturatedError, the
operations_awaiting_file_work count and artifact_digest_after_refused
are removed, with the tests that covered them. New tests check that a
call gives back its place at its deadline, and that a hash ends at its
deadline on a stalled open, read or close while a later hash of the
path starts its own read.

The pool is kept on the fork branch rizin-filework-pool.

* fix(rizin): keep the PATH candidate a launch by name is denied

When a bare REA_RIZIN_COMMAND finds only a file without execute
permission or a candidate under an unsearchable directory, the lookup
records it only as display text, and the by-name launch then fails with
EACCES. The capability error kept neither selectedPath nor stoppedAt, so
it lost the file whose permissions need repair. The lookup now reports
the first PATH candidate it moved past with EACCES as deniedAt, and the
service keeps it as executable_lookup_denied_candidate in Evidence and
launch failures, with a limitation naming it.

* fix(rizin): keep a non-regular PATH candidate a launch by name is denied

A launch by name also fails with EACCES when the only PATH match is a
directory or another non-regular file, which execve refuses; the lookup
kept that candidate only as checked display text. deniedAt now covers it
and carries its reason, permission or not-regular-file, which the service
keeps as executable_lookup_denied_reason beside the candidate and names
in its limitation.

* fix(process): mark invalid UTF-8 where execFileBytes decodes a failure

execFileOutputFailure projects stdoutInvalidUtf8 and stderrInvalidUtf8,
but execFileBytes decoded a failed command's buffers without setting
them, so direct runner callers such as adb reported replacement
characters without the stdout_invalid_utf8 and stderr_invalid_utf8
markers. The failure now validates each buffer when it decodes it, on
both the execFile and owned-spawn routes, and execFileOutput's result
marks invalid streams the same way, as the owned process runner does.

* test(process): expect the invalid UTF-8 marker on compiler failures

The Darwin token reader's compiler capture now reports stderr_invalid_utf8
for a replaced byte, and the decoding tests get their own block under the
150-line function limit.

* fix(reverse): report a post-run digest deadline with its recovery

A post-run hash that reached command_timeout_ms, for example at a close a
stalled mount holds, fell into the empty catch and was reported as an
unreadable artifact. It now adds a limitation naming the deadline
(ETIMEDOUT) and how to raise command_timeout_ms, and the command's Evidence
is kept. The deadline-raising sentence is shared with the timeout error.

* refactor(rizin): retain version-probe preparation through main's inspection owner

main's #10113 owns ownership-preparation failures for the command: it
maps them to analysis errors and retains their cleanup in the service's
inspection scope. This branch had its own copy in runOwnedCommandOutput
(630610d30), so a retained helper now had two owners, and the copy no
longer typechecked against the inspection-failure union.

The runner returns to main's version. Main's two inline mappings become
one ownershipPreparationError, which the command and the version probe
share: a preparation that fails or stops during the probe ends the call
as it would for the command, and its cleanup joins the same scope, so
retryCleanup closes the helper once. A deadline that interrupts Darwin
preparation keeps the compiler output, as a failed preparation does.

The preparation tests read the primary error under the cleanup wrapper;
main's two new collection-failure tests use this branch's processes
option.
reverseProviderLaunchErrors.test.ts returns to main's version: the
retry assertions this branch added there expected a cleanup failure with
no owner to be retried by polling its state, which main's owner does not
retain; the error still reports the cleanup as incomplete.

* refactor(rizin): parse an ownership preparation failure once before mapping it to an error

* test(rizin): expect PATH entries on search candidates and the launched path in launch failures

* refactor(process): take the host platform of an executable lookup from its caller

* test(rizin): register the renamed Rizin cancellation test for lifecycle coverage

The cancellation test now covers the command and the version probe as
"waits for a Rizin process cancelled during its %s to exit before
returning", so the lifecycle coverage registry names that title.

* test(rizin): assert the facts a post-run digest deadline names, not its wording

The limitation must name the setting that stopped the hash, its value and
the error code; the recovery sentence belongs to nativeDeadlineRecovery,
whose wording may change.

* fix(rizin): keep host capacity during version-probe preparation retryable

When the ownership helper's compiler could not start for EAGAIN, EMFILE,
ENFILE or ENOMEM, the version probe mapped the failure to a non-retryable
ownership-preparation error with setup remediation, while the command
path classifies the same condition as a retryable resource constraint.
Run the shared preparationHostCapacityFailure owner first in the probe,
as the command does, and test each of the four codes.

* test(rizin): create the abandoned-stat fixture with createTestTempDirectory

The fixture root came from mkdtemp before the try block, so a setup failure
skipped its removal. createTestTempDirectory registers the cleanup when it
creates the root.

* test(rizin): align tool identity assertions with normalized_result and clean up lookup

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-24 14:22:27 +00:00
Ysopwnableandgensokyo-dev 62014b566d refactor(cli)!: dispatch commands through REA-owned execution
Run ordinary CLI commands through REA's registry, argv parser and result owner.
Remove Incur, the second admission parse, SDK error middleware, output capture
and redundant command traversal. Preserve explicit redaction, publication
receipts, incremental output, terminal notice eligibility and drain ownership.
Migrate fixtures to real registrations and retain the derived-source notices.

Validation includes unchanged public parity goldens, public and lifecycle
regressions, repaired fixture consumers, real TTY base comparisons, exports
beyond the engine string limit, four schema catalogs and final static/docs
checks. Native provider and optional validator coverage limits are in the PR.

Fixes #11654. Fixes #10583. Refs #11682, #11476 and #10511.

BREAKING CHANGE: Markdown argument diagnostics use REA's literal escaping,
table widths and token counts. Flag-shaped unknown MCP subcommands honor the
selected format. Completion --schema/--version routes use the canonical
REA-owned hook rather than the retired SDK generator. Refresh affected literal
snapshots and regenerate completion hooks with rea completions <shell>.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-16 13:56:34 +00:00
morluto 07c5a54fee refactor(cli): import zod directly instead of through incur (#11655)
* refactor(cli): import zod directly instead of through incur

* fix(verify): count incur z imports from declarations, not comment or string text
2026-11-16 10:37:43 +08:00
morluto ff6467ca97 feat(debuggers): name why an owned debugger stop is incomplete (#11517)
* feat(debuggers): name why an owned debugger stop is incomplete

Owned debugger stop results carry a cleanup code; retained Rizin and GDB
cleanup failures project it as details.diagnostics.debugger_cleanup, close-all
failures carry it, and GDB detach refusals name multiple inferiors, a missing
durable output sink, unknown inferior state or a changed inferior TTY.
GdbSessionManagerCoverage asserts the codes instead of reason prose.

* fix(debuggers): put the cleanup code on every returned failure

incompleteStopFacts builds the cleanup observation and debugger_cleanup
diagnostic together, so GDB startup, cancellation and timeout failures carry
the code; Rizin's composed cleanup failure retains it at its top level; and
one-shot debug commands report debugger_cleanup_codes from the close-all
failure.
2026-11-16 07:33:16 +08:00
morluto 1f24b3fa57 feat(evidence)!: name the Evidence subject by its target identity (format revision 2) (#11416)
* feat(evidence)!: name the Evidence subject by its target identity (format revision 2)

The Evidence subject carries subject.identity (kind, sha256, format,
architecture, selection) and the Evidence ID commits to it, so raw/DOL
entry points and ESP flash offsets of the same bytes are different
subjects. Every record declares evidence_format: 2; revision 1 bundles,
standalone records and snapshots are refused with the recreate guidance.
binaryTargetIdentity is the one projection of an open target, used by
Evidence and snapshot comparison.

BREAKING CHANGE: Evidence format revision 2. Evidence IDs commit to the
subject's target identity (subject.identity, including the raw/DOL entry
point or ESP flash offsets), and every record declares evidence_format: 2.
Evidence bundles, records and analysis snapshots from earlier releases are
refused; recreate the observations with this release.

* refactor(analysis-view): read parent subjects through the Evidence identity accessors (#11423)

Analysis views compare their parent's file identity (evidenceFileTarget)
and take path and digest from evidenceSubjectTarget instead of reading
the subject's digest, format and architecture members, which duplicate
subject.identity until they are removed. A counted guard
(evidence-subject-declaration-read) keeps new direct reads out and
records the 20 remaining files.

* fix(evidence): carry format refusals through Evidence readers and bind target selections

- safeParseEvidence/safeParseImmutableEvidence return the format refusal as
  an expected failure; every consumer maps it to the one integrity refusal
  with the recreate guidance. An unmarked object is an earlier record only
  when it has every member records have always carried.
- ArtifactProvider inventory roots and provider subjects that name the
  target's own bytes carry the target's selection (ESP flash offsets).
- Snapshot rows bind only Evidence whose identity, selection included,
  matches the snapshot target.
- Entry-point selections use the raw-binary entry point form.

* fix(evidence): refuse unauthenticated or earlier-format records instead of reading them as absent

- recognizeEvidence (evidenceValidation) replaces tryParseEvidence: input
  without an evidence_id is not Evidence (ok(undefined)); a record that names
  one but fails authentication or is from another format revision is an
  EvidenceIntegrityError carrying the recreate guidance, never undefined.
- Direct analysis retains that refusal as a secondary failure instead of
  silently skipping source capture; cleanup projection, source-closure
  annotation and the flutter, debugger and release-exposure recoveries use
  the same owner (the last three previously read the unauthenticated schema).
- A desktop capture.json from an earlier format is refused with the recreate
  guidance instead of "not desktop application capture Evidence".

* fix(evidence): advertise revision 2 ledger examples and rank delivery omissions by serialized size

- The obligation ledger and reconstruction coverage examples named
  evidence_format 1, which revision 2 refuses; they now use
  EVIDENCE_FORMAT_REVISION.
- MCP delivery chose which unretained recovery to omit by a parsed-storage
  lower bound clipped at the response budget. Once revision 2 subjects made
  the source record's estimate cross the budget, both candidates tied at the
  clip and the smaller source was omitted ahead of the larger completed
  observation. Candidates are now ranked by serialized size, which is what
  the budget counts.

* refactor(native): compare function snapshots by their Evidence target identity (#11450)

Function snapshots carry the subject's file target identity instead of the
duplicated subject declaration. Call paths and function comparisons compare
targets through sameTargetIdentity, so the same bytes opened at a different
raw entry point or ESP flash offset no longer count as one coordinate space:
build_call_path refuses the mix, and compare_functions no longer matches
entries by address across selections. Structural candidates and native
function matching read the architecture and digest through
evidenceFileTarget.

Refs #11417

* refactor(artifacts): compare artifact and WASM summaries by their Evidence target identity (#11461)

Artifact comparison authenticates a summary against its retained inventory
through sameTargetIdentity and rebinds the alias with the whole target,
selection included, so a flash-selected inventory summary taken under an
alias path is no longer refused. WASM comparison, the analysis view
artifact projection and the inventory root check read the digest, format
and display path through the Evidence identity accessors.

Refs #11417

* refactor(evidence): read record subjects through the identity accessors in JS, managed, ledger and bundle readers (#11470)

JavaScript application graphs, runtime reconciliation, managed inspection
and native verification sources, the record summary filter, the ledger's
residual-unknown target and bundle scope selection read the subject digest,
format and display path through evidenceFileTarget and
evidenceSubjectDisplay. No comparison changes: each reader matches one
record's facts against its own payload or a caller filter.

Refs #11417

* refactor(evidence)!: name the Evidence subject only by its target identity (#11497)

* refactor(evidence)!: name the Evidence subject only by its target identity

The subject keeps `identity` and the display facts `name` and `local_path`.
The duplicated `digest`, `format` and `architecture` members are removed; the
format-owned declaration now validates the identity itself. Readers the type
checker found move to the owner accessors; untyped reads in verify scripts,
the efficiency harness and test matchers move to `subject.identity`. The
`evidence-subject-declaration-read` text guard and its baseline are deleted.

Fixes #11473
Refs #11417

BREAKING CHANGE: the Evidence subject no longer has `digest`, `format` or
`architecture`; read `subject.identity.sha256`, `subject.identity.format` and
`subject.identity.architecture`. A record that still carries them is refused.

* test(evidence): give the Flutter verifier fixture the identity subject and check the DOL declaration without the ID

* test(evidence): drop the removed subject members from the declaration matrix and tamper fixtures

* feat(evidence)!: give every Evidence record an explicit subject identity (#11536)

* feat(evidence)!: give every Evidence record an explicit subject identity

A producer that cannot name a file passes an `unknown` target identity
with a closed reason (derived-from-linked-evidence, not-observed,
unsupported-subject) instead of no subject. The subject is non-null;
unknown subjects have no display facts. The generic missing-subject
limitation and `subjectUnavailableReason` are removed; producer-specific
explanations are ordinary limitations. Comparison identity requires the
derived unknown, and null-subject consumers ask the owner accessors.

Refs #11417

BREAKING CHANGE: every Evidence record has a subject. A record without a
file target names `subject.identity` `{ "kind": "unknown", "reason": … }`
with `name` and `local_path` null, instead of `subject: null` and the
limitation "Artifact identity is unavailable for this observation.".
Their Evidence IDs change.

* fix(evidence): name explicit unknown subjects in JavaScript callers and keep a managed graph's file subject

The verification scripts are not type-checked, so five createEvidence
callers still passed undefined (or a missing first target) after the subject
became required. They now pass unknownTarget("not-observed").

A managed application graph chose the first present input subject. Every
subject is now present, so an unknown artifact subject hid a file subject on
the member or boundary Evidence. The graph now takes the first input subject
that names a file.

* test(evidence): assert the subject kind instead of a presence the type now guarantees

Every Evidence record has a subject after this change, so test guards and
assertions that checked it for null always passed. Each now checks that the
fixture subject names a file, or is removed where a later fileIdentity,
fileSubjectTarget or fileSubjectDisplay call already requires that. Non-null
assertions on Evidence subjects are removed; analysis-view inputs, whose
subject is optional, keep an undefined check.

* test(evidence): expect the Evidence subject format under its identity

Two boundary tests still matched subject.format, which slice 2e moved into
subject.identity. toMatchObject is not type-checked against the Evidence
shape, so they failed only when run (the signature test on macOS).
2026-11-16 06:28:01 +08:00
morluto 960a387731 refactor(contracts): own CLI command names, catalog identity and schema presentation in contracts (#11425)
* refactor(contracts): move the CLI command name owner into src/contracts

* refactor(contracts): own catalog identity in contracts and server identity in process (#11435)

* refactor(contracts): move catalog identity into contracts and server identity into process

* refactor(contracts): own the advertised MCP schema presentation in contracts

* test(mcp): import the advertised presentation from contracts in toolSchemaValidity

* test(release): expect the catalog identity at its contracts path in the canary

* test(mcp): import the catalog identity from contracts in syntheticContractSurfaces

* refactor(contracts): import CLI command names from contracts in the capability conformance test
2026-11-16 05:31:37 +08:00
morluto 49d4991a18 refactor(cli)!: name a failure's per-call control flag at the CLI boundary (#11413)
* refactor(cli)!: name a failure's per-call control flag at the CLI boundary

Services name the contract field a deadline failure reports in
details.limit.parameter; a contract command's output projection adds
details.limit.cli_flag from the command's own field-to-flag binding.

BREAKING CHANGE: MCP failures no longer carry details.limit.cli_flag, and
native deadline remediation text no longer names the CLI flag. CLI output
still reports cli_flag for the command that ran.

* fix(cli): key nested flattened members by their dotted path; restore the test's exit status

* refactor(reverse): bind command_timeout_ms as the per-call control of an objdump or Rizin deadline (#11442)

* refactor(reverse): bind command_timeout_ms as the per-call control of an objdump or Rizin deadline

The deadline failure now comes from nativeDeadlineRecovery: it names command_timeout_ms and carries limit {control_kind: "parameter"}, so the CLI projection adds --command-timeout-ms and MCP output names the field only. The service no longer writes CLI flag text.

* refactor(wasm): bind max_artifact_paths as the per-call control of an auxiliary path admission refusal (#11444)
2026-11-16 04:21:46 +08:00
morluto 897784042a fix(native)!: report a target-selected plist against the target, not the unsent path input (#10798)
* fix(native): report a target-selected plist against the target, not the unsent path input

inspect_plist resolved a plist that the open target itself selects with the same origin as a caller's path input, so an unreadable target plist was reported as an input issue on path even when the caller never sent path. The selection now records a target origin, and unreadablePlist reports it as a BinaryTargetError for the target. The inspect-plist CLI command is projected from its contract, so its --relative-path issues are named by the CLI key.

* refactor(cli)!: route analyze to the contract its target selects (#10808)

* refactor(cli): route analyze to the contract its target selects

analyze hand-declared both lanes: native open options for binary_overview and the JavaScript integrity policy and source selection for analyze_javascript_application, with its own routing and refusals. registerTargetRoutedCommand now projects each route from its contract, takes the union of their options, runs the first route that owns every given option and takes the target, and refuses options the chosen route does not own by their CLI key. Omitted union fields, including a root discriminator, no longer need an argv projection.

* fix(cli): give a routed command's chosen route its CLI-only option defaults

Routing strips option defaults so an omitted option routes no target. Contract fields regain theirs on admission, but CLI-only options have no later parse, so a defaulted one reached the handler as undefined. The chosen route's omitted CLI-only options now receive their defaults before the handler runs.

* refactor(cli): deliver decompile and inspect-macho Evidence by the contract's detail (#10813)

* refactor(cli): deliver decompile and inspect-macho Evidence by the contract's detail

decompile and inspect-macho omitted the contract's detail field and always printed complete Evidence. Both now declare evidenceDelivery, adding --detail and --evidence_output from the contract. Publishing a result never used the provider id it required, so publication takes no provider and runOnSessionTarget no longer needs one to deliver.

* refactor(cli): project managed artifact and native-boundary inspectors from their contracts (#10816)

inspect-managed-artifact and inspect-managed-native-boundaries re-declared the managed budget fields by hand. Both now register from their contracts on a session target, and inspect-managed-artifact gains --detail and --evidence_output from its detail field.

* fix(cli): name every contract command's input issues by their CLI key

Commands applied their CLI field binding only where a session-target or
direct handler returned an undelivered result. With evidenceDelivery,
decompile publishes through the shared delivery, which returned a
provider failure unprojected, so an issue about the procedure would be
reported at ["procedure"] instead of the advertised positional
"address". Handlers that run a service or publish themselves never
applied it: inspect-il2cpp-metadata reported ["generic_instances"],
inspect-go-binary ["max_string_literals"] and inspect-apple-ips
["join_path"] rather than the CLI keys other commands report.

The contract command now projects whatever its handler returns through
the binding it owns, for plain and target-routed commands alike, and
the handler context no longer carries the binding.

* fix(analysis-view): summarize pseudocode that selected an independent fresh decompile

The pseudocode view parsed its parent's parameters with a selection
schema that admitted only procedure and document. A procedure_pseudo_code
observation made with analysis independent_fresh records that field, so
its summary view refused the parent. Through the CLI's new summary
delivery, `decompile --analysis independent_fresh --detail summary
--evidence_output <file>` would fail after a successful decompile and
never save the bundle; an inline inspect_analysis_view of such Evidence
failed the same way.

The selection schema now admits the analysis the contract offers, and
the contract reads that enum from the same owner.

* test(cli): restore the worker's exit status after synthetic contract command runs

logCliCommand sets process.exitCode on a refused or failed command. The
synthetic routed and input-field harnesses ran in the cli-boundary
project's shared workers (isolate: false) and left that status for later
tests. Each invocation now restores the previous status.

* refactor(cli)!: deliver inspect-managed-members Evidence through the shared --evidence_output (#10845)

inspect-managed-members was the last command with its own Evidence
delivery: a hand-written registration passed --detail and
--evidence-bundle to runProviderAnalysis, whose members-only delivery
variant re-checked heap headroom and published through
deliverAnalysisEvidence. Every other producer writes its bundle with
--evidence_output through publishCliAnalysisEvidence, and elsewhere on
the CLI --evidence-bundle names an input bundle to read.

The command now registers from the inspect_managed_members contract on
a session target with evidenceDelivery, like inspect-managed-artifact;
--type is the contract's type_names. runProviderAnalysis loses its
delivery parameter and its two refusals, and deliverAnalysisEvidence,
now unused, is deleted. Its lifecycle tests drive publishEvidenceDelivery
directly or the CLI delivery; the managed-only headroom pre-check tests
are removed, since the shared delivery deliberately does not
re-authenticate immutable Evidence and keeps the writer's check for
mutable sources.

BREAKING CHANGE: `rea inspect-managed-members --evidence-bundle <path>`
is now `--evidence_output <path>`; the old flag is refused as an unknown
flag. With `--detail summary`, stdout is now
`{"summary": <summary Evidence>, "evidence_bundle": {"path", "bytes"}}`
instead of the summary Evidence alone, and a publication failure is the
shared delivery's error projection without the `error` label or
`input_path`. A summary without a destination names `evidence_output`
in its issue path. Migrate by renaming the flag and reading
`.summary`. Compatibility is not kept: one spelling cannot mean "read
this bundle" on view and workflow commands and "write this bundle" on
one producer.

* refactor(cli): project analyze-javascript-application and analyze's JavaScript route from one contract projection

analyze-javascript-application declared its options by hand, mapped
about twelve option names to contract fields itself, parsed its delivery
separately and resolved its own caller path. analyze's JavaScript route,
projected from the same contract, omitted every field but the path,
source selection and integrity policy, so the two commands for one
contract offered different options.

Both now use javaScriptApplicationCliProjection and
runJavaScriptApplicationCommand: the path positional, --artifact-format,
--source-path, and the two options that accept a JSON file
(--source-paths-json, --semantic-precision), with contract delivery.
analyze therefore takes the JavaScript budgets, --artifact-format,
--semantic-precision and --detail/--evidence_output/--view for
JavaScript targets, and refuses them by CLI key for native targets.
javascriptApplicationOptions is deleted.

The command's missing-target refusal now names its CLI key, "path",
as every contract command does.

* refactor(cli): project the apktool commands from their contracts (#10878)

* refactor(cli): project the apktool commands from their contracts

* refactor(cli): project the Flutter commands from their contracts (#10882)

* refactor(cli): project the Flutter commands from their contracts

* refactor(cli): project the JEB commands from their contracts (#10888)

* refactor(cli): project the JEB commands from their contracts

* refactor(cli): project the Android package, class, method and reference commands from their contracts (#10893)

* refactor(cli): compose compare-managed-members from its contract over two inspected targets (#10914)

* refactor(cli): compose compare-managed-members from its contract over two inspected targets

The contract command builder takes Evidence targets: required contract
fields that each take the Evidence a source contract produces for one
positional target, with the source's options admitted for every target.
compare-managed-members now inspects each path through the typed managed
runner, as inspect-managed-members does, and compares the records as MCP
compare_managed_members does. A failing candidate names its argument and
retains the baseline's Evidence; a cancellation as the comparison settles
retains the comparison. The path-only comparison service is removed.

* fix(cli): drain queued interrupts before a composed command settles

Select snapshot faults by file identity, guard real permission denial to
hosts that enforce it, and release retained owners when a test fails.

* refactor(cli): project the ADB commands from their contracts (#10934)

Each ADB command is registered from its ADB_TOOL_CONTRACTS entry through
registerContractCommand, keeping its positionals, flags and kebab-case path
keys. start-adb-activity keeps its repeatable --extra type:key:value option,
which supplies the contract's extras.

* refactor(cli): project Frida discovery from its contracts and share Frida request mapping with MCP (#10951)

list-frida-devices and list-frida-processes are registered from their
contracts, with each remote member as its own option, and admit the request
MCP would send. instrument-with-frida keeps its argv but builds and admits
the instrument_with_frida contract input. One application owner maps Frida
contract inputs to service requests for both adapters.

* refactor(cli): finalize the Evidence-target composition through runOwned

runOnEvidenceTargets turned a completed comparison into a cancellation by reading the abort signal by hand, which main's architecture guard now refuses outside runOwned. The composition now finalizes through runOwned: its close drains queued interrupts (it owns no resource), and a cancellation observed as it settles keeps the completed Evidence as the partial observation, as before.

* fix(errors)!: keep every completed argument's observation beside a composite failure's own partial (#10961)

* fix(errors): keep every completed argument's observation beside a composite failure's own partial

* test(errors): cover argument observations through cleanup composition and the partial-free fallback

* test(errors): settle the cleanup through its owner's release in the argument-observation case

* refactor(cli): project instrument-with-frida through the contract builder (#10962)

* refactor(cli): project instrument-with-frida through the contract builder with CLI-only positionals and handler-filled fields

* fix(cli): keep omitted flattened members omitted so partial capture limits keep their Evidence

* refactor(cli): project the CDP page-target browser commands from their contracts (#10976)

* refactor(cli): project the CDP page-target browser commands from their contracts

* refactor(cli): project inspect-web-page from its contract with a branch-selecting flag

* test(cli): enroll the browser commands in the parity registration check and refuse unenrolled argv fixtures

* refactor(cli): project the V8 Inspector and Electron commands from their contracts (#10977)

* refactor(cli): project the V8 Inspector runtime commands from their contracts

* test(cli): enroll the V8 Inspector runtime commands in the parity registration check

* refactor(cli): project the Electron page observation commands from their contracts (#10987)

* refactor(cli): project the Electron page observation commands from their contracts

* test(cli): enroll the Electron page observation commands in the parity registration check

* refactor(cli): project inspect-electron-fuses from its contract with the shared caller-path rule

The command now registers through registerContractCommand with `path` as a
caller path, so the builder's absoluteCallerPath owns relative-path
anchoring and the command's own absoluteElectronFusePath copy is removed.
inspectWithService records the caller's spelling as caller_input_path.

The named file is unchanged: every `..` is kept for the filesystem, and
Win32 resolves as before. The recorded selected_path drops `.` segments
and repeated separators (`App.app/./` -> `App.app/`), and an empty path is
now refused at argv parsing (VALIDATION_ERROR) like every other
caller-path command.

* test(cli): derive contract-built commands from the builder registries instead of a hand list

Every command named after a public tool contract must register through a contract builder unless it is in a shrinking list of hand registrations, and the renamed contract commands are listed exactly, so an earlier migration that reverts fails instead of dropping out of the parity cases. The JSON-document command hand list is covered by the same check and removed.

* test(cli): drop the empty inspect-electron-fuses path mismatch the CLI now refuses

* refactor(cli): project compare-web-screenshots and analyze-web-bundle from their contracts with builder JSON inputs (#11012)

* refactor(cli): project compare-web-screenshots from its contract with builder JSON inputs read from inline text or a file

The contract command builder gains jsonInputs: structured fields taken as inline JSON or a JSON file path (- reads stdin), read when the command runs and admitted with the contract input before any target is opened. Inline text that is not JSON is refused under its CLI key; a file that cannot be read keeps its own failure. compare-web-screenshots takes both artifacts this way, replacing its hand-written JSON argument parsing.

* refactor(cli): project analyze-web-bundle from its contract

analyze-web-bundle now registers through registerContractCommand with Evidence and view delivery, semantic_precision as a builder JSON input, and source_map_limits flattened onto the existing --source-map-* flags. Page-inspection extras stay omitted, and script sources stay on as the contract default. The superseded javascriptRouteDelivery options, passive browser scope options, observation duration helper and fetched source-map option set are removed.

* refactor(cli): take semantic_precision of JavaScript application analysis as a builder JSON input

analyze-javascript-application and the analyze route read --semantic-precision through the contract builder's jsonInputs instead of a CLI-only option decoded in the handler, so the decoded budgets are admitted with the contract input before analysis.

* refactor(cli): route compare-web-captures to the contract input shape its documents select (#11027)

* refactor(cli): route compare-web-captures to the contract input shape its documents select

* fix(cli): keep routed defaults advertised and reuse the admitted capture parse

* fix(cli): keep explicit routed options distinct from advertised defaults

* refactor(cli): project inspect-ntfs-journal from its contract (#11043)

* refactor(cli): project inspect-ntfs-journal from its contract

* refactor(cli): project the pcap commands from their contracts (#11045)

* refactor(cli): project the pcap commands from their contracts

* refactor(cli): project inspect-playwright-trace, the Cutter commands and execute-rizin-command from their contracts (#11046)

* refactor(cli): project inspect-playwright-trace from its contract

* refactor(cli): project the Cutter commands from their contracts (#11047)

* refactor(cli): project the Cutter commands from their contracts

* refactor(cli): project execute-rizin-command from its contract (#11048)

* fix(cli): refuse a selected page without summary delivery before opening the target

* refactor(cli): project export-web-scripts and trace-web-module-imports from their contracts (#11053)

* refactor(cli): project export-web-scripts and trace-web-module-imports from their contracts

* fix(cli): describe export-web-scripts paths as resolved against the working directory

* refactor(cli): project the web runtime and JavaScript recovery commands from their contracts (#11084)

* refactor(cli): project the web runtime commands from their contracts

* refactor(cli): project recover-javascript-sources from its contract

* refactor(cli): select a contract input branch by its literal field and project guided-workflows (#11085)

* refactor(cli): select a contract input branch by its literal field and project guided-workflows

* fix(cli): refuse delivery options before reading JSON inputs

* fix(cli): keep branch-only defaults to their branch and name admission issues by CLI key

A branch-only field no longer carries its default into the shared options, so another branch never receives it; the selected branch applies the default on parse. Contract admission failures are projected to CLI keys like handler failures. CLI defaults are typed only on top-level fields, the one place that applies them.

* refactor(cli): project compare-process-captures from its contract, checking each capture before reading the next (#11114)

* refactor(cli): project compare-process-captures from its contract, checking each capture before reading the next

The contract builder gains jsonInputChecks: each check runs on a decoded JSON input as soon as it is read, in argv order, so a refused input stops the command before the next is read; the handler receives what each check admitted. compare-process-captures authenticates the left capture before reading the right and the right before the trace specification, then compares the authenticated facts. It now also takes inline JSON, stdin and --max-capture-age-ms like MCP. Empty JSON input text is refused at argv. A JSON input whose final file close fails is reported as cleanup_incomplete naming the file instead of an unclassified failure. compareProcessEvidenceFiles and its trace-spec parser are removed.

* fix(cli): retry a refused JSON input close and keep the read's refusal beside incomplete cleanup

parseCliJsonInput gives the file's owner a resource scope, so a transient close refusal is retried before the command fails. A close that still fails reports cleanup_incomplete composed with the read's own refusal. Routed commands refuse routes that check a shared JSON input differently, since it is checked before the route is chosen.

* refactor(cli): project inspect-web-network-capture from its contract with nested protobuf options

The contract builder flattens a nested optional object member in turn (protobuf.schema), resolves a flattened caller-path member and reports it as spelled under its dotted path in callerInputs, keeps a flattened member's contract default out of argv so an omitted member stays omitted, and takes an array of numbers as repeated decimal tokens within its bounds. inspect-web-network-capture registers from its contract with the same option names; Evidence keeps the capture and descriptor paths as the caller spelled them. CLI input issues name the capturePath argument.

* fix(cli): name a selector field by its own option in admission issues

A selector parameter's positional may share another key (decompile's procedure positional is address), so mapping the field to its positional key renamed selection issues that already name the option, such as a missing or conflicting --procedure. Map a selector field to its option.

* fix(cli): retain a JSON input file whose close fails and keep why its read stopped

parseCliJsonInput dropped its per-read scope after the owner's close retry failed, so the handle lost its owner, and a read or cancellation failure recorded before the close was replaced by the cleanup failure. The read's scope now stays with the CLI process until final CLI cleanup retries it, and the recorded outcome is translated once into the primary failure with the cleanup attached. The module moves into src/cli so it can register with the CLI process owner without a layer cycle.

* refactor(cli): project inspect-with-objdump and inspect-api-contract from their contracts (#11142)

* refactor(cli): project inspect-with-objdump, list-objdump-architectures and inspect-api-contract from their contracts

The contract builder selects input branches by a field that is a literal in
one branch and an enum in another, takes the default of the one branch that
admits omission, and lets a command take a subset of a union's branches by
their discriminating values, fixing the field when one value is selected.

* refactor(cli): project trace-web-source-location from its contract with flattened positional objects (#11167)

* refactor(cli): project trace-web-source-location from its contract with flattened positional objects

The contract builder flattens required objects as well as optional ones; a
flattened field listed in positionals takes its members as positionals in
member order. The hand-written source-map limit options and the separate CLI
delivery schema are removed.

* fix(cli): refuse to flatten a required object without a required member

* fix(cli): refuse a malformed Evidence-input document before reading the selected bundle

runEvidenceInputCommand admits the document with its transport frame before
it reads --evidence-bundle, so every Evidence-input command refuses a
malformed document first, as compare-static-and-observed-endpoints already
did by hand.

* test(cli): expect a selector field to be named by its option in input issues

* fix(cli): report a refused view before the delivery rule it would trip

Refusing delivery options before JSON inputs are read checked --evidence_output before the view's own schema, so a summary view naming an unknown field reported only the missing bundle. Admit the view with the contract's view field first, as full admission does.

* refactor(cli): project inspect-android-jni-bindings from its contract with a grouped --query option (#11196)

* refactor(cli): project inspect-android-jni-bindings from its contract with a grouped --query option

A projection's fieldGroups take several optional top-level contract fields as the members of one JSON object option. The text is decoded when the command runs, refused with the group's message when it is not a JSON object, a member that is not one of the group's fields is refused by its path, and the contract admits each member as its field. inspect-android-jni-bindings keeps its --query selection through a group and now registers through the contract builder, so the hand-registered contract command list is empty; the superseded parseCliAnalysisEvidenceDelivery and androidJniDeliverySchema are removed.

* fix(cli): refuse an object rule that names a grouped field

A grouped field is a JSON member, not an option, so a contract rule such as dependentRequired naming it would be advertised over an option that does not exist. Registration now refuses that combination.

* fix(cli): describe the --view and --maxCaptureAgeMs options of projected commands

A projected view field kept no help because the contract's own description was skipped and none replaced it, and compare-process-captures exposed max_capture_age_ms without help. The canonical CLI catalog test refused both. The view option now takes the same help in both builders.

* refactor(cli): derive the CLI command inventory from the contract registry (#11248)

A contract now declares `cli: true` when the CLI exposes it as the command
named by its kebab-case name. The primary CLI inventory (CLI_COMMAND_NAMES,
now owned by catalogIdentity.ts) is derived from those declarations plus the
commands no contract names, and a contract projection omits `command`: the
builder names the command from the contract and refuses a contract that does
not declare one. CLI_COMMANDS keeps only the 32 commands no contract names;
the 164 contract-named entries and the copied MCP-only list in
cliToolCoverage.test.ts are removed.

* fix(managed): keep decoded members when only their loaded literals exceed capacity

A capacity failure while decoding #US literals discarded the member facts already decoded, because the shared representation budget threw through the whole inspection. Literals carry their own coverage, so the inspection is retried without them and reports user_strings as partial with the capacity issue. compare-managed-members, which now runs full inspections, keeps comparing members it used to read with literals disabled.

* test(cli): expect builder-admitted issues by CLI key and option help with its default

Builder admission of compare-web-captures, compare-web-screenshots and analyze-web-bundle names input issues by the CLI key (beforeJson, afterJson, normalizationJson, endpoint), and --integrity-policy help states its default. Four test files still expected the contract field names and the old help, so they failed on the stack.

* test(cli): read each refused browser input's CLI path directly now that every case names one

Every invalid browser input now carries its CLI key, so the fallback branch narrowed to never and failed the TypeScript compiler's typecheck.

* chore(verify): carry the moved cliJsonInput baseline entry into its per-guard file

Rebased on main after #11316 split the guard baselines and #11181 threaded the launch environment into the web bundle command; the contract-built analyze-web-bundle command now passes that environment to the browser provider.

* refactor(cli): hand whole-input contract handlers the admitted parse instead of parsing again (#11301)

* refactor(cli): hand whole-input contract handlers the admitted parse instead of parsing again

* refactor(cli): parse an argv whole input only when the handler reads it

Admission parsed every argv whole-input command eagerly, so handlers that
hand the raw input to a service (inspectWithService) parsed it twice.
parseWholeInput now parses on the first admittedContractInput call and
reuses the result; run-time JSON and view delivery still parse at
admission. The test counts whole-schema evaluations.

* refactor(cli): hand JSON-document handlers the admitted parse of their document (#11332)

observe-native-calls, capture-electron-scenario and match-native-functions
parsed their resolved document against the contract schema in the handler.
registerContractDocumentCommand now gives each document handler
parseWholeInput, a memoized parse of the resolved document as the whole
contract input whose refusal names the caller's spelling, so
admittedContractInput serves argv and document commands alike. A handler
whose document is not the whole input never calls it, so it adds no parse.

* fix(cli): admit checked JSON inputs through their checks only

compare-process-captures walked and copied both capture records again in
the whole-input parse after their checks had admitted them. Admission now
parses the remaining fields with the contract and hands the handler the
checked documents uncopied. The managed summary example names
--evidence_output.
2026-11-16 03:22:24 +08:00
morluto df1e647266 refactor(desktop): let build-computer and agentenv cleanup errors read their owner's release (#10855)
* refactor(errors): read cleanup completion from dependencies instead of pushing it to dependents

AnalysisError.cleanupIncomplete becomes a getter over the error's own unresolved state and its bound dependencies. The WeakRef dependents graph and resolveCleanup's push propagation are removed, and subclasses mark their initial state through markCleanupIncomplete instead of overriding a public mutable field.

* fix(errors): settle bound dependencies before binding more

A composite whose dependencies had released but whose status was never read
stayed incomplete when a later dependency was bound.

* refactor(errors): let errors read a lease group's release instead of resolving them (#10759)

AnalysisCleanupLeaseGroup no longer calls resolveCleanup() on its error.
The error holds the group as a release claim and reads cleanupReleased when
asked, so completion follows the lease owner without a push.

* chore(verify): count resolveCleanup and bindCleanupDependencies calls so they only shrink (#10763)

* refactor(errors): let errors read a lease group's release instead of resolving them

AnalysisCleanupLeaseGroup no longer calls resolveCleanup() on its error.
The error holds the group as a release claim and reads cleanupReleased when
asked, so completion follows the lease owner without a push.

* chore(verify): count resolveCleanup and bindCleanupDependencies calls so they only shrink

* refactor(process): let worker cleanup errors read their root epoch's release

OwnedWorkerRuntime's root epoch is now an AnalysisCleanupReleaseClaim. Errors bound to it read its release when asked instead of the epoch pushing resolveCleanup() through weak references, and a runtime without a retained root binds an already-released owner. Removes the OwnedWorkerCleanupFailure structural type and four resolveCleanup() pushes; the counted baseline shrinks accordingly.

* refactor(pcap): let pcap cleanup errors read command and snapshot release (#10792)

Retained pcap commands, retained snapshot failures and snapshot completion descriptors now own their release and errors read it: commands and snapshot failures implement AnalysisCleanupReleaseClaim, and a failed completion-descriptor close is retried through an AnalysisCleanupLease bound to its error. Removes four resolveCleanup() pushes; the counted baseline shrinks accordingly.

* refactor(process): let Darwin helper cleanup errors read their owner's release

Darwin helper cache and run-token reader root cleanup now record an AnalysisCleanupRelease that every failure reports; a successful retry confirms it. Replaces the first-failure anchor that later failures depended on and the resolveCleanup() push. Removes two resolveCleanup() and two bindCleanupDependencies() calls; both counted baselines shrink.

* refactor(ghidra): let Ghidra cleanup errors read the client's and checkpoint's release

GhidraClient and GhidraCheckpoint bind each cleanup failure to an AnalysisCleanupRelease and confirm it when a later close or retry releases everything, instead of keeping a set of failures and pushing resolveCleanup() to each. Removes two resolveCleanup() calls; the counted baseline shrinks.

* refactor(process): let debugger session cleanup errors read a confirmed stop

OwnedDebuggerSessionRegistry binds each retained gdb or rizin cleanup failure to the session's AnalysisCleanupRelease and confirms it when a stop is confirmed, keeping the latest failure for retry reporting, instead of pushing resolveCleanup() to a set of failures. Removes one resolveCleanup() call; the counted baseline shrinks.

* refactor(process): drop the debugger registry's unused closeOperation option

Returning the latest retained failure removed the last reader of closeOperation; remove the option and the values gdb and rizin supplied.

* refactor(server): let environment shutdown errors read a successful close

serveEnvironment binds each shutdown failure to an AnalysisCleanupRelease that a later successful close confirms, instead of pushing resolveCleanup() to a set of failures. The state-file retry test now also requires the earlier report to read the release. Removes one resolveCleanup() call; the counted baseline shrinks.

* refactor(desktop): release retained screen-judge cleanup through its lease

Each retained judge or screenshot cleanup owner is wrapped in an AnalysisCleanupLease bound to its failure; close() releases the lease, which records the release the failure reads, instead of closing the owner and pushing resolveCleanup(). Removes one resolveCleanup() call; the counted baseline shrinks.

* refactor(ida): let IDA close failures read the session's later close

IdaSessionClient's close failure binds an owner that is both its resource owner and its release claim, read from the client's closed state, instead of keeping weak references and pushing resolveCleanup() after a successful retry. Removes one resolveCleanup() call; the counted baseline shrinks.

* refactor(javascript): let source-map codec cleanup errors read a later close (#10814)

* refactor(javascript): let source-map codec cleanup errors read a later close

OwnedCodec binds each close failure to an AnalysisCleanupRelease that a later successful close confirms, replacing the first-failure anchor that later failures depended on and the resolveCleanup() push. Removes one resolveCleanup() and one bindCleanupDependencies() call; both counted baselines shrink.

* refactor(cutter): let pending Cutter command errors read the completion receipt (#10815)

* refactor(cutter): let pending Cutter command errors read the completion receipt

Each pending Cutter command keeps an AnalysisCleanupRelease bound to its timeout failure; the producer's terminal completion receipt confirms it instead of pushing resolveCleanup(). Removes one resolveCleanup() call; the counted baseline shrinks.

* refactor(application): let provider candidate cleanup errors read the candidate's close (#10817)

* refactor(application): let provider candidate cleanup errors read the candidate's close

AnalysisProviderRegistry keeps one AnalysisCleanupRelease per candidate whose resource close is unconfirmed; failures bind to it and a later confirmed close confirms it, instead of pushing resolveCleanup() to a set of failures. Removes one resolveCleanup() call; the counted baseline shrinks.

* fix(errors): bind a cleanup release claim to an error at most once

AnalysisError kept release claims in an array, so a provider whose retried close returned the same error bound the same claim again on every retry and each cleanupIncomplete read scanned the duplicates. Keep the claims in a set.

* refactor(application): let reverse-tool cleanup errors read a verified stop (#10819)

* refactor(application): let reverse-tool cleanup errors read a verified stop

Each retained provider process group in ReverseEngineeringService keeps an AnalysisCleanupRelease; its command and retry failures bind to it and a later verified stop confirms it, instead of collecting failures and pushing resolveCleanup(). Removes one resolveCleanup() call; the counted baseline shrinks.

* refactor(sqlite): let SQLite worker and root cleanup errors read their release (#10821)

Each retained SQLite snapshot cleanup records an AnalysisCleanupRelease for its worker and for its runtime root; the resource failures bind to them and a verified stop or root removal confirms them, instead of pushing resolveCleanup(). Composite failures keep reading those resource failures. Removes two resolveCleanup() calls; the counted baseline shrinks.

* refactor(android): let JADX cleanup errors read their retained cleanup's release

Each retained JADX cleanup records an AnalysisCleanupRelease for the admission failure's descriptor owners and one for the whole retained cleanup. The admission failure and every error the cleanup reports bind to them, and a confirmed close confirms them, instead of pushing resolveCleanup() through WeakRefs to reported errors. Removes two resolveCleanup() calls; the counted baseline shrinks.

* refactor(application): let session close failures read the client's later close

A retained session cleanup records an AnalysisCleanupRelease; unowned cleanup failures the client's close reported bind to it and the successful close confirms it, instead of the session collecting them and pushing resolveCleanup(). Failures that already follow their own owner keep reading it. Adds a regression for an unowned close failure. Removes one resolveCleanup() call; the counted baseline shrinks.

* refactor(desktop): let build-computer and agentenv cleanup errors read their owner's release

Build-computer teardown, retained task readers, remote reader folders and agentenv solve sandboxes each record an AnalysisCleanupRelease that their bound failures read; a verified teardown or stop confirms it instead of pushing resolveCleanup() through WeakRef sets. Long-run job failures read whether every job they name has confirmed its stop, so a failure naming two jobs no longer reads complete when only one stops (regression added). WeakRef sets kept only where late facts (completion receipts, reader views) are still retained as diagnostics. Removes six resolveCleanup() calls; the counted baseline shrinks.

* refactor(kuna): let source-map and Kuna cache cleanup errors read their owner's release (#10856)

* refactor(browser): let late source-map fetch errors read their response's release

A pending source-map fetch and a response cancellation each record an AnalysisCleanupRelease that their cancellation or deadline failure reads; releasing the late response or the reader lock confirms it instead of pushing resolveCleanup(). Removes two resolveCleanup() calls; the counted baseline shrinks.

* refactor(kuna): let project-cache cleanup errors read each owner's release

Each retained Kuna resource owner (process, staging, hash descriptor, retired file) records a release that the errors reporting it read; an error completes once every owner it reports confirms, and retirement that moves staging to a retained file forwards the staging owner's release to the file's. Replaces the WeakRef report list, its pruning and the resolveCleanup() push. Removes one resolveCleanup() call; the counted baseline shrinks.

* refactor(process): forbid resolveCleanup() pushes; native markers read their supervisor's release (#10857)

* refactor(providers): let an attributed client failure read its source's completed cleanup

Re-attributing a failure whose source cleanup already completed now binds a claim reading that source's release instead of pushing resolveCleanup() onto the new error; a pending source is still bound as a dependency. Resources stay as history, as before. Removes one resolveCleanup() call; the counted baseline shrinks.

* refactor(process): let native command markers read their supervisor's release

ProviderProcessSupervisor records an AnalysisCleanupRelease that a stop proving the process ended confirms. Native command and LLDB resolver cleanup markers bind to their supervisor's release, so a verified stop by either owner completes them, instead of each owner pushing resolveCleanup() onto the markers it tracks. Removes the last two resolveCleanup() calls outside the error base; the counted baseline is empty.

* chore(verify): forbid resolveCleanup() pushes outside the error base

Every production owner now confirms a release its errors read, so the counted baseline is empty. The guard becomes an outright ban with no baseline entry.

* test(native): complete native command and LLDB markers through a direct supervisor stop

* refactor(errors): complete an error's cleanup from its owner's record and every dependency (#10892)

* refactor(errors): complete an error's cleanup from its owner's record and every dependency

* refactor(errors): complete test errors through an owner release and delete resolveCleanup() (#10898)

* refactor(android): compose JADX and Apktool cleanup failures through one shared owner (#10900)

* refactor(android): compose JADX and Apktool cleanup failures through one shared owner

* refactor(application): compose service cleanup failures through the shared owner (#10902)
2026-11-15 20:06:47 +08:00
morluto cb4e5cfbff feat(analysis): make resource budgets recoverable across CLI and MCP (#9706)
* refactor(analysis): centralize resource budgets and recovery facts

* feat(analysis): expose ASAR and Ghidra runtime admission controls

* feat(artifacts): expose reader admission and preserve limited recognition

* feat(javascript): expose recoverable semantic precision budgets

* feat(web): add recoverable source-map budgets and compact retained views

* feat(web): make historical capture decoding budgets recoverable

* fix(desktop): enforce selected view policies across capture and export

* feat(runtime): make Frida and LLDB retention budgets selectable

* feat(native): expose diagnostic budgets and preserve exhaustion causes

* feat(managed): expose recoverable snapshot and representation budgets

* feat(metadata): make Go and Rust inspection budgets recoverable

* feat(wasm): expose representation and producer admissions

* feat(evm): expose per-call worker resource budgets

* feat(android): make resource and string-pool omissions recoverable

* feat(producers): expose command and recorded-capture budgets

* docs(analysis): record recovery contracts and integrated validation

* fix(docs): link calibration oracle from published verification pages

* fix(docs): restore desktop task anchors and receipt links

* test(analysis): align fixtures with selectable budget contracts

* fix(analysis): remove source-location projector dependency cycle

* test(analysis): refresh budget recovery and verifier regressions

* test(analysis): preserve format and publication recovery expectations

* test(windows): align conformance with owned runtime admission

* fix(desktop): preserve selected alias kinds in exported state

* test(analysis): align provider fixtures with recoverable budgets

* test(desktop): validate emitted alias metadata structurally

* fix(ghidra): classify bounded Windows endpoint refusals

* test(cli): assert selectable artifact admission recovery

* fix(cli): preserve capture provenance in environment builds
2026-11-10 05:11:20 -05:00
morluto d9c9e6ea67 fix(cli): retain completed Evidence through finalization failures (#9469) 2026-11-08 22:05:17 +00:00
morluto c3647ade1e fix(objdump)!: preserve unknown executable identity (#8824)
* fix(objdump)!: preserve unknown executable identity

* fix(objdump): avoid claiming rejected architecture output

* fix(objdump): align launch errors with command identity

* test(objdump): avoid coupling identity checks to wording

* test(objdump): align launch failure expectations
2026-11-04 02:01:44 +08:00
Kaoru0822andClaude Opus 5.5 144843ccc2 fix(debugger): let REA exit when a debugger could not be stopped (#8652)
* fix(debugger): let REA exit when a debugger could not be stopped

`rea debug-with-gdb` and `rea debug-with-rizin` printed cleanup_incomplete
and set exit status 1, but the retained child and its pipes kept the event
loop alive, so the process never exited. A stdio MCP server whose client
disconnected hung the same way.

closeOwnedDebuggerSessions is the owner both managers finish through. It now
unreferences retained sessions, as supervised providers already do after
incomplete cleanup, restores the references on retry, and names the retained
process IDs. The one-shot commands report those IDs, since no later command
can retry. Debugger ownership, signals and detach behavior are unchanged.

GDB cleanup requests also no longer hold the host until their 120 s command
deadline, because cleanup already bounds its own wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(debugger): name retained debuggers when an MCP server shuts down

An MCP server that exits with a retained debugger logged only "REA provider
cleanup failed" and "could not close cleanly", so nothing named the process
left for the caller to check. The PIDs were on OwnedDebuggerCleanupError, but
each shutdown reporter read only the outer aggregate's message, and the debug
failure_cause description dropped the field too.

The failure type now lives in its own dependency-free module with one reader
that walks composed failures. The shutdown report, the server's onclose log,
the debug description and the one-shot CLI all use it, and the shutdown report
writes the same remediation the CLI returns.

The fake debuggers now model each request exactly, with real reply shapes, and
a request they do not model fails the test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(debugger): compare retained-debugger guidance with its formatter

The new checks froze the wording "Check process ... and its target".
docs/testing.md asks guidance checks to compare with the owning formatter,
alongside independent checks of the facts. They now do, and each still proves
the process ID is named, because a formatter comparison alone would pass if the
formatter dropped it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 05:16:34 -08:00
morluto 7bcefead69 test: strengthen and prune audited test coverage (#8573)
* test: strengthen and prune audited test coverage

* test: require delivered DeepSeek skill instructions

* test: keep schema fixture types private

* test: verify Gemini receives skill instructions

* test: bind Qwen skill evidence to its tool result

* test: report NativeAOT verifier checks precisely

* fix: verify Ghidra cleanup paths reliably

* fix: verify Command Code skill activation

* test: tighten cleanup and fixture checks

* test: verify packet capture evidence is recorded

* fix: report HTTP3 capture provenance accurately

* test: preserve resource coverage through MCP

* test: prune repeated assertions and retain cancellation identity

* fix: validate client verifier fixture paths

* test: skip Copilot verifier cases on Windows

* test: keep verifier setup target relative
2026-11-02 02:13:32 +08:00
morluto 60149282fc test: strengthen integration oracles and verification (#8295)
* test: strengthen integration oracles and verification

* test: bound lifecycle gates and strengthen workflow checks

* test: verify complete paged and extracted results

* test: preserve bytecode and cancellation evidence

* test: strengthen retained evidence and fixture cleanup

* test: require cross-projection bridge identities

* test: retain fixture owners through cleanup failures

* test: verify graph examples and project selectors

* test: tighten provider and lifecycle regressions

* test: consolidate hex coverage and bound cutter cleanup

* test: bound subprocess output waits and strengthen graph checks

* test: check mcp recovery and preserve cleanup owners

* test: verify structured mcp argument failures

* test: preserve artifact cleanup and gdb limit evidence

* test: preserve evidence identities and bound provider gates

* test: retain browser and comparison cleanup owners

* test: bound startup and strengthen fixture oracles

* test: bound lifecycle gates and verify recovered evidence

* test: verify public outcomes and lifecycle ownership

* test: assert precise evidence and release lifecycle gates

* test: verify selected facts and bound cleanup waits

* test: check retained evidence and decoded records

* test: verify final reports and retain cleanup ownership

* test: bound reviewed startup gates and retain cleanup

* test: verify PE errors and preserve MCP cleanup

* test: preserve MCP fixture cleanup ownership

* test: release provider gates before late startup
2026-11-01 00:15:28 +08:00
a108a1b817 fix(cli): report incomplete debugger cleanup as typed outcomes (#8021)
* fix(cli): report incomplete debugger cleanup as typed outcomes

debug-with-gdb and debug-with-rizin hand-rolled final cleanup in
try/finally blocks: a failed or interrupted final close only logged
and assigned the process exit status, so callers still received
complete successful Evidence with no typed error or partial
observation.

Both commands now route through the shared close owner used by the
other one-shot CLI commands (deliverCliAnalysisEvidence /
finishAnalysisCommand) via a small closeDebuggerCommandSession
helper. A rejected closeAll projects as ProviderCleanupError, which
the owner turns into cleanup_incomplete retaining the completed
Evidence as partial observation; a signal observed after finalization
projects as cancelled with the same retained observation. The
per-session close failure still only logs, preserving the rule that
the retained owner's closeAll decides completion.

Fixes #7378. Fixes #7429.

* test(cli): reject unmodeled GDB requests in cleanup regressions

* test(cli): match modeled GDB requests exactly

* Update tests/boundary/cli/gdbStartupCleanupCli.test.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-10-29 20:52:03 +08:00
morluto 57aa21af26 fix(rizin): retain cancellation and recover cleanup correlation 2026-10-24 03:11:07 +08:00
087813fb88 fix(cancellation): preserve caller abort reasons through late finalization (#6143)
* fix(cancellation): preserve caller abort reasons through late finalization

Caller aborts that arrived during final provider, cleanup, or protocol
handling were dropped or replaced by I/O, cleanup, or success results.
Each affected path now samples the caller signal after its owner has
settled and returns AnalysisCancelledError carrying the exact
signal.reason, keeping any completed partial Evidence or cleanup state.

- Web script export: keep the exact reason for an interrupted output
  write, and honor a cancellation fact recorded before a retried
  capture close succeeds.
- Native value tracing and Hopper regex search: check the signal after
  the final provider reply or regex worker settles.
- Apple asset catalog: stop assetutil with SIGTERM so cancellation
  settles only after the helper exits.
- CDP observation: end an armed window on a fatal protocol failure.
- ADB bugreport: prefer cancellation over the staging-removal output
  error when the caller aborted.
- JavaScript recovery: check the signal after provider success.
- export-web-scripts CLI: run under command cancellation and forward
  the signal into the export workflow.
- Objdump and Rizin CLI: report cancellation after cleanup completes.
- Binary session: keep cancellation primary when previous-client
  retirement fails after abort.

Fixes morluto/rea#6042
Fixes morluto/rea#6043
Fixes morluto/rea#6048
Fixes morluto/rea#6049
Fixes morluto/rea#6057
Fixes morluto/rea#6060
Fixes morluto/rea#6078
Fixes morluto/rea#6080
Fixes morluto/rea#6108
Fixes morluto/rea#6111
Fixes morluto/rea#6115

* fix(cancellation): keep caller reasons through export rollback and commit

- Rollback failure after a caller abort now returns AnalysisCancelledError
  with the exact signal.reason, attaching the rollback failure as cleanup
  and retaining any published result as partial observation.
- A capture close retry that succeeds after abort returns cancellation
  instead of the stale cleanup diagnostic.
- An abort that lands during the final output commit returns cancellation
  carrying the completed manifest as partial observation.
- Apple assetutil stop test: abort and await the run in finally so a
  timed-out wait does not leave the child running, and skip on Windows
  where the JavaScript SIGTERM handler cannot run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 35b247e9-c793-4b8f-979a-807c27112cf5

* fix(cancellation): bind export cancellations to cleanup and caller reasons

- A rollback-failure cancellation is bound to the retained cleanup lease,
  so a later successful close clears cleanup_incomplete instead of
  reporting a residual directory that no longer exists.
- mapExportFailure wraps the caller's own AnalysisCancelledError reason
  under export_web_scripts rather than returning it as the export's error.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 35b247e9-c793-4b8f-979a-807c27112cf5

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Copilot-Session: 35b247e9-c793-4b8f-979a-807c27112cf5
2026-10-22 04:15:16 +08:00
dbd556043c fix(providers): name JEB, IDA, and one-shot command deadlines (#6014)
* fix(providers): name JEB, IDA, and one-shot command deadlines

Wire JEB catalog discovery to REA_JEB_MCP_TIMEOUT_MS, name the IDA
registration timeoutMs, and add command_timeout_ms for one-shot objdump
and rizin. Debugger, Frida, and Cutter caps stay fixed and say so.

Refs #5910

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(providers): pass remaining deadlines and name the cap that fired

Catalog discovery now sends the JEB budget still remaining to the SDK on
connect and every tools/list page. Objdump and rizin preflight share one
command_timeout_ms across stat and digest; the command still receives that
budget again. Architecture Evidence keeps a selected timeout, and Frida and
Rizin name the capture limit that actually stopped output.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(frida): preserve non-timeout device lookup failures

getDeviceById is a lookup deadline only when Frida rejects with
"Device not found" after the wait. A device-manager or backend failure
stays a capability error. Align the assertions that still expected the
previous capacity and capture sentences.

Co-authored-by: morluto <morluto@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-10-22 04:01:02 +08:00
gensokyo-dev 17f581ff75 perf(reverse): add retained GDB and objdump summaries (#5614)
Add opt-in retained GDB and objdump summaries using the shared analysis-view layer. Preserve default complete Evidence, ordered records, provenance and completion facts.

Validate real Bash disassembly, whole-client context costs, CLI publication and cleanup; retain the original measured cohorts and explicit coverage limitations.

Closes #5584.
2026-10-21 01:20:52 +08:00
gensokyo-devandKaoru0822 3ea0d9489e feat(objdump): select native disassembly by symbol (#5171)
Push optional native symbol selection into GNU objdump before collecting Evidence. Preserve native matching, raw output, artifact identity, scoped limitations and the existing full-disassembly default through the shared CLI/MCP workflow.

Fixes #5159

Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
2026-10-19 20:15:20 +08:00
4aa51bfe19 fix(reverse): reconcile cleanup ownership and mutation diagnostics (#2799)
* feat(process): add owned debugger shutdown lifecycle

* feat(reverse): add local inspection commands

* feat(gdb): add persistent debugger integration

* feat(cutter): add Cutter bridge integration

* test(reverse): enforce complete integration coverage

* fix(process): preserve debugger shutdown ownership

* fix(reverse): retain evidence across interrupted commands

* fix(gdb): honor captured provider environment

* test(process): cover debugger shutdown retries

* fix(reverse): retain evidence for interrupted providers

* test(process): cover debugger shutdown retries

* fix(reverse): retain evidence for interrupted providers

* fix(server): snapshot provider environment at creation

* fix(reverse): close review gaps with complete coverage

* fix(reverse): address inspection review findings

* fix(gdb): bound sessions and retain cleanup ownership

* fix(ci): require reverse-tools quality lane

* fix(process): unref inherited debugger output pipes

* fix(reverse): address remaining PR 1960 findings

* fix(gdb): address remaining PR 1961 findings

* fix(reverse): account for unrestricted provider execution

* fix(process): retain debugger ownership until safe shutdown

* fix(process): preserve replacement debugger sessions

* fix(reverse): preserve admission and output provenance

* fix(process): retain exited debugger until output settles

* fix(mcp): bound provider admission and debugger cleanup

* fix(reverse): preserve failure provenance and classify E2BIG

* fix(gdb): preserve startup cleanup and detach safety

* fix(process): retain debugger ownership after detach failure

* fix(reverse): preserve mutation and failure provenance

* fix(gdb): address debugger review findings

* fix(reverse): rebind sessions after external mutation

* fix(process): cap debugger output after exit

* fix(gdb): protect one-shot detach verification

* feat(debugger): add reverse tool coverage gate

* test(debugger): cover integrated failure paths

* fix(gdb): bound and preserve session observations

* fix(gdb): address review regressions

* style: format merged integration files

* fix(reverse): preserve session and output evidence

* refactor(gdb): share repeated test and partial result setup

* fix(gdb): invalidate TTY proof for Python aliases

* fix(reverse): retain failure output byte counts

* test(process): synchronize late debugger output

* fix(gdb): invalidate TTY proof for wrapped commands

* fix(gdb): recognize wit command abbreviation

* test(reverse): wait for cancelled descendant readiness

* test(reverse): bound descendant cancellation cleanup

* style(reverse): format integration tests and adapters

* style: format reverse engineering integration files

* test(reverse): remove duplicate environment harness

* test(gdb): share session startup assertions

* fix(gdb): invalidate output proof for command abbreviations

* test(reverse): share composition edge case scenarios

* fix(ci): recognize verification and mutation tool entries

* test(rizin): cover successful fake inferior detach

* test(cli): align full output failure envelope

* test(cli): isolate reverse command lifecycle service

* test(process): share debugger output fixture setup

* fix(binary): preserve high-bit Windows signature bytes

* style(binary): format Windows signature parser

* test(mcp): preserve call coverage in unchanged comparison

* fix(ci): include reverse tools Vitest configs in lint cache

* fix(mcp): preserve target content on delivery errors

* ci: align duplication ceiling with expanded suite

* test(reverse): allow signal admission mutants

* fix(reverse): bound retained cleanup failures to process owners

* fix(test): replace drifting mutation ranges with owned selectors

* fix(reverse): admit persistent commands and retain cleanup ownership

* fix(cutter): recover timed-out commands from exact receipts

* fix(cutter): reject unsupported bridge request kinds

* fix(ci): repair client format and shared verification fixtures

* fix(native): preserve debugger cleanup ownership and bridge authentication

* test(native): retain diagnostics without perfect coverage requirements

* chore(licenses): refresh locked dependency inventory and notices

* fix(test): exclude transient command locks from mutation sandboxes

* fix(gdb): admit only platforms with safe detach verification

* fix(cutter): retain bounded completion receipts until acknowledgement

* fix(cutter): acknowledge commands rejected before UI dispatch

* test(reverse): fail cancellation checks before fixture teardown

* test(gdb): clean up the retained broken-stdin fixture owner

* docs(test): clarify focused provider verification scope

* fix(rizin): retain close cleanup failures

* fix(gdb): wait for inferior stop and bound MI buffering

* fix(cutter): retain failed receipt acknowledgements

* fix(rizin): return retained session identity on rebind failure

* fix(gdb): preserve startup cancellation and lossy status

* fix(rizin): retain launch provenance and assemble frames once

* fix(cutter): recover receipts across callers and bound discovery

* docs: describe debugger evidence and bridge recovery

* fix(process): keep cleanup incomplete while writers remain

Stopping a debugger no longer reports success when inherited output
streams stay open, so BinarySession cannot reopen a binary a child is
still changing. Concurrent Cutter cleanup retries share one receipt
acknowledgement instead of treating a consumed receipt as failure.

* fix(debuggers): recover cleanup with captured process identities

* fix(analysis): retire sessions after unrestricted commands

* fix(cli): preserve completed evidence after cleanup recovery

* fix(cutter): bound frame collection and coalesce cleanup

* fix(windows): resolve selected provider paths absolutely

* fix(gdb): report decoding loss in failed startup evidence

* fix(rizin): scope decoding loss to collected command frames

* test(mcp): cover snapshot retirement in reverse tools CI

---------

Co-authored-by: Daniel Gonçalves Araujo <47118053+dandgabr@users.noreply.github.com>
Co-authored-by: REA Maintainers <noreply@github.com>
Co-authored-by: OpenAI Codex <codex@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-10-14 04:47:34 +08:00