Commit Graph
569 Commits
Author SHA1 Message Date
3a8a717b02 feat(ghidra): set function signatures and define the types they use (#14859)
* feat(ghidra): set function signatures and define the types they use

annotate_native_function accepts an optional C prototype, applied with
USER_DEFINED source in the same transaction as the name and comments,
verified by readback and rolled back with them on refusal.
define_native_data_types stores caller-authored struct, union, enum and
typedef definitions atomically under /rea_caller_defined and refuses
existing names. inspect_native_data_type reports those types with source
caller-defined, and annotation readback reports the applied prototype
and its source.

Refs #14831

* feat(ghidra): bound caller C text with launch controls and refuse unapplied constructs

The lengths of a signature and of type declarations and the nesting depth
of parentheses are launch-only REA_ controls with measured defaults, floors
and maxima, written into the bridge's session descriptor. A refusal names
the control, its effective value, source and range.

The bridge tokenizes caller C before Ghidra's parser sees it and refuses
what that parser accepts without applying: attributes, storage-class
specifiers, variable declarations, directives other than #pragma pack,
literals, function bodies, default arguments, unnamed enums and repeated
member names. A type name that names different types is refused.

When a function has no calling convention and the prototype names none,
the compiler specification's default convention, which Ghidra already uses
to assign the locked storage, is recorded, and annotation readback reports
the convention.

Refs #14831

* fix(ghidra): apply the signature bound to the caller's text

The bridge appended the semicolon its parser needs before checking the
length, so a prototype of exactly the admitted length was refused. The
readback prototype is documented as reusable only when its function and
type names are C identifiers.

Refs #14831

* chore(mcp): refresh advertised schema summaries for Ghidra type edits

Refs #14831

* fix(ghidra): bound caller C text per call and report dropped qualifiers

Ghidra's C parser cannot be cancelled, so REA bounds the text it parses.
The three launch-only environment controls left an agent that hit them
with a restart as its only recovery. The two length bounds are now
per-call parameters, signature_max_utf16 on annotate_native_function and
declarations_max_utf16 on define_native_data_types, with the same defaults
and measured maxima. A refusal reports details.limit with
control_kind "parameter" and required_value, the text's length, so the
generated recovery names the value to pass or asks for shorter text. The
text fields no longer carry a schema maximum, so every over-length
refusal is typed. Parenthesis nesting is a fixed ceiling of 8 levels,
registered as a representation bound, because each level doubles parse
time. The session descriptor no longer carries C parser limits, and the
config module, environment entries and restart-only registry rows are
removed.

const and volatile are still applied without effect, because Ghidra's
types have no representation for them. Both edits now return
dropped_qualifiers with each qualifier's line and column, and for a
signature its parameter index, null for the return type, instead of
dropping them silently.

* fix(ghidra): read caller C through one tokenizer and bound nesting per call

The C admission scan tracked lines only at LF and read directives as raw
lines matched by a regular expression, so a CR-only line break shifted
dropped-qualifier positions and a trailing comment on #pragma pack was
refused. One tokenizer now owns caller C positions, comments and literals:
CR, LF and CRLF each end a line as in Ghidra's parser, and directives are
admitted from its tokens, so comments read as whitespace there too. A block
comment that would carry a directive onto another line is refused.

Parenthesis nesting was a fixed ceiling justified by parse time, a resource
limit. It is now the per-call parenthesis_max_depth (default 8, range
1..12) on both type-edit tools. The bridge measures the deepest nesting
over the whole text and sends it, with a text's length, as the wire
failure's required_value, so details.limit reports the bridge's own
measurement instead of the adapter re-reading the request.

The tokenizer also decides whether a prototype is terminated, so the parser
sees the caller's text unchanged: no leading whitespace is stripped, and a
trailing line comment no longer swallows the appended terminator.

* fix(ghidra): parse caller C inside the edit's rollback and refuse parser diagnostics

Ghidra's C parser writes the type database even with storeDataType false:
a definition whose name matches an existing empty composite fills that
type in place, in the parser's own nested transaction. Both type edits
parsed before opening their transaction, so a refused definition, such as
one conflicting with a DWARF placeholder, left that placeholder filled.
Parsing, validation and storage now share the edit's one transaction, and
parseCallerC refuses to run outside one.

The parser also records diagnostics it cannot apply, such as a repeated
enumerator it drops, and still reports success. Both edits now refuse any
diagnostic with Ghidra's message, before anything is stored.

The real-Ghidra verifier gains a phase with an ELF object whose DWARF
declares an opaque struct, proving a refused definition leaves that empty
composite unchanged, and refuses a repeated enumerator.

* fix(ghidra): admit caller C from one audited table of tokens Ghidra drops

Review kept finding one more construct Ghidra's C parser consumes without
applying, because admission listed spellings piecemeal. The tokenizer now
owns one table, audited against every token and production of Ghidra
12.2's C.jj and checked on Ghidra 12.2, in that grammar's own spellings:

- Refused, because meaning is lost: __ptr32 and __ptr64 (stored as a
  native-width pointer), __near and __far, every attribute, declspec,
  __readableTo, alignas, packed and asm spelling, [[...]] attributes,
  storage and inline specifiers including __forceinline, __pragma and
  _Pragma, _Static_assert, Objective-C @ blocks (Ghidra skips their whole
  text), and backslashes.
- Reported in dropped_qualifiers as pure qualifiers: every const and
  volatile spelling, restrict, __unaligned and __w64.

#pragma pack is admitted only in the operand forms Ghidra applies as
written with a decimal value; (0x1), (010), (show) and (pop, n) were
ignored or read differently, and "# pragma" is a line marker Ghidra
skips. An enum tag that neither the text nor the database defines made
Ghidra invent an empty enum without a diagnostic; declarations now refuse
it as they do an invented struct or union. Identifiers admit $, as C.jj's
do, and the tokenizer reads numbers and [[ as single tokens.

* fix(ghidra): bound caller type depth, admit only constant expressions Ghidra evaluates, refuse unmatched pack pops

Recursion: the tokenizer's [[ lookahead re-entered next() for each "[",
and the dependency walk recursed per pointer, array and member level.
Both are iterative now. Ghidra 12.2's own data-type code recurses too:
1024 pointer or array levels resolve, 2048 exhaust the stack inside
addDataType while its database lock is held, leaving the Program unable
to save. Every parsed type's chain through pointers, arrays, typedefs and
members, including existing database types, is now measured iteratively
and refused beyond a fixed 256-level ceiling before Ghidra walks it. An
unexpected StackOverflowError ends the session with a reason instead of
being caught by the parser call, since Ghidra's lock may then be held.

Constant expressions: Ghidra leaves names, casts, sizeof, floating and
binary literals unevaluated and substitutes a default, so
"MASK = FIRST << 4" was stored as 2, and it truncates values outside int.
Enum values, array sizes and bit-field widths are admitted only as integer
literals with arithmetic, shift, comparison, bitwise and logical
operators, checked iteratively with C's rules to stay in int, including
implicit enumerator values; anything else is refused at its position.

Pragma pack: Ghidra ignores a bare (push), a pop with nothing pushed keeps
the current packing, and a plain pop pops past labelled entries. The
tokenizer tracks admitted pushes and admits a pop only when Ghidra's
result matches C's.

* fix(ghidra): admit constant expressions only as one literal, skip absent pointer targets, state the type-depth recovery truthfully

Constant expressions: emulating C against Ghidra's own evaluator is an
open-ended class of mismatches (comparisons, unsigned arithmetic such as
~0U >> 1 giving -1, names, casts, truncation). The evaluator is removed.
Enum values, array sizes and bit-field widths are admitted only as one
decimal or hex integer literal within int, optionally negated, without
suffixes; anything else is refused at the first token that leaves that
form, and the refusal says to write the computed value. Implicit
enumerator values are still checked against int.

Dependency walk: Ghidra's generic pointer has a null pointed-to type, and
pushing it onto the ArrayDeque threw. Both the dependency and depth walks
now take children from one cTypeChildren and skip an absent child.

Type depth: the depth is measured over the whole chain before comparing it
with the limit, so the refusal reports the depth it used, and it names
the type from the parser's table rather than walking the type for a name.
The recovery no longer suggests splitting into named types, which cannot
help because depth counts through typedefs and existing types; it says
only fewer nested levels do.

* refactor(ghidra): refuse parentheses in definitions and keep parenthesis_max_depth on signatures only

Under the literal-only rule for constant expressions, every parenthesis in
a define_native_data_types text already ended in a refusal (function
declarators, attributes, casts, sizeof, or a Ghidra diagnostic for a
grouped declarator), so parenthesis_max_depth changed only which refusal
a caller saw. A definition now refuses its first parenthesis at its
position, and the parameter is removed from that tool's schema; it stays
on annotate_native_function, whose prototype has a parameter list.

* fix(ghidra): refuse distinct types that share one parser name

Ghidra keeps struct tags, enum tags and typedefs in separate maps.
Combining those maps dropped a typedef such as typedef int item when
struct item was also defined, and the call still succeeded. Overlapping
names are stored only when the definitions are equivalent, which keeps
typedef struct s { ... } s as one struct. Any other overlap is refused
with conflicting_type_definitions before the transaction stores anything.

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

* fix(ghidra): roll back a composite the parser fills in place

Ghidra's parser replaces an empty composite during parsing and returns
that same object. A later same-path check would store the fill as
unchanged. Record those empty composites before parsing and refuse if
parsing fills one, so the open transaction restores them. A different
layout of a non-empty caller type still conflicts and leaves the stored
type in place.

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

* fix(ghidra): close line comments at EOF and refuse overflowing pack values

Ghidra's // skip token requires a line break, so a comment at the end of
declarations or of an already-terminated signature was rejected. A newline
is appended whenever the text ends in a line comment, before any semicolon
added for an unterminated prototype.

Integer.parseInt drops a pack operand outside a Java int and leaves the
previous packing, so #pragma pack(2147483648) stored a natural layout.
Decimal pack operands are admitted only when that parse succeeds.

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

* test(ghidra): assert the empty-composite refusal by code and readback

Defining a struct over the DWARF placeholder fills that empty composite
during parsing, so the refusal is data_type_conflict before the old
name-conflict message. The verifier checks that code and that the
placeholder still has no fields.

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-11-27 06:11:53 -05:00
0f5ab1e042 feat(artifacts): inspect Debian package control metadata and contents (#10689)
* feat(artifacts): inspect Debian package control metadata and contents

* fix(deb): throw ParseFailureError and record the new tool's schema counts

DebPackageFormatFailure now extends ParseFailureError, as the architecture
guard requires of parser failure classes; its kind, partial and message are
unchanged. The advertised-dialect baseline takes the counts the
inspect_deb_package input schema adds ($schema in both profiles, and allOf,
default, examples, the \/ escape, the unanchored path pattern and untyped
nodes in the full profile).

* docs(deb): say dpkg runs maintainer scripts, not dpkg-deb

dpkg-deb only reads the archive; installing with dpkg is what runs the
maintainer scripts. Correct the spec so the safety rationale names the
right tool.

* refactor(deb): project format failures through parseFailureAnalysisError

The provider now maps DebPackageFormatFailure with the shared
parseFailureAnalysisError instead of its own instanceof ladder, passing the
partial ar/control/data observation as diagnostics. The helper takes that
optional diagnostics argument. DebPackageCapacityFailure extends
ParseFailureError<"limit"> with the resource and maximum as its limit, and
the provider keeps its limit recovery.

* test(deb): resolve inspect_deb_package from its contract family

The CLI acceptance and MCP boundary tests now take the contract from
DEB_PACKAGE_TOOL_CONTRACTS instead of the full catalog, as the testing guide
asks of focused contract tests.

* fix(deb): require debian-binary and a control file for complete coverage

Coverage was complete with a missing or empty debian-binary, or a control.tar
that held no control file. It now needs a known format version and the
control file as well as the control and data members, and each gap adds a
limitation.

* fix(deb): count hardlinks in the md5sums path cross-check

dpkg lists every name of a hardlinked file in md5sums, while tar stores the
later names as hardlink entries. The cross-check inventory now takes
hardlink paths as well as regular files, so those names are no longer
counted missing.

* fix(deb): decode xz only when its index declares a size within the limit

The sync @napi-rs/lzma decoder takes no output bound, so a member whose
index could not be read was decoded with no limit and checked only after
allocation. decodeXz now refuses such a member, as truncated when the footer
is missing and malformed otherwise, before calling the decoder.

* fix(deb): leave the md5sums cross-check unknown when an input is unread

md5sums that is not UTF-8 counted as zero listed paths, and a package with
no data.tar counted as an empty inventory. The cross-check is now computed
only when both were read; otherwise it stays null and a limitation says
which input was missing.

* fix(deb): refuse Version and Installed-Size values the output schema rejects

A Version with an empty upstream part or Debian revision (1:, 1:-1, 1.0-)
and an Installed-Size past the safe integer range reached DebControl and
failed the output schema, so the service lost the report. The parser now
records a malformed field issue and leaves the value null.

* build(deb): declare src/deb as a provider module layer

Main now requires every top-level src unit in UNIT_LAYERS. src/deb is a
provider like src/sqlite, and its two type imports of application ports
are recorded in the upward-import baseline the same way. The xz spy
binding now accepts the string or bytes input XzApi.compressSync takes.

* fix(deb): keep tar names and link targets as stored

Read ustar name, prefix and linkname fields, and GNU long names, as
NUL-terminated UTF-8 without trimming or rewriting backslashes, and keep
spaces in md5sums paths. A name that is not UTF-8 is shown with U+FFFD
replacements and counted in a limitation, since it may not match md5sums.

* fix(deb): read control files from the control.tar root only

Look up control, conffiles, md5sums and maintainer scripts by their
normalized root path, so a nested subdir/control or subdir/postinst no
longer stands in for the root file.

* fix(deb): read PAX records by byte length

PAX record lengths count bytes, so walk the extended header bytes and
decode each record on its own. A UTF-8 path no longer swallows part of
the next record. A path or linkpath record that is not UTF-8 is counted
in the same not-UTF-8 limitation as ustar names.

* fix(deb): keep unreadable relationship alternatives as issues

Accept hyphenated architecture qualifiers such as kfreebsd-amd64, and
have parseDebianRelationshipField return the alternatives it cannot
read. parseControl records each as a malformed issue on its field, so
the package reports partial coverage instead of dropping a dependency.

* fix(deb): deliver the whole partial report on a refusal

A Debian package refusal now carries the bounded partial report as
diagnostics.partial, so control facts, relationships, maintainer-script
facts, ar member offsets and file rows read before the failure reach CLI
and MCP callers, not just member names and a count.

* fix(deb): decode only the maintainer script interpreter line

interpreterLine now finds the first newline in the script bytes and
decodes only the #! line, so non-UTF-8 bytes later in the script, or a
cut through a multi-byte character at byte 256, no longer hide a valid
interpreter.

* fix(deb): bound unreadable relationship diagnostics per field

parseDebianRelationshipField now counts unreadable alternatives and keeps
only the first, and parseControl records one issue per field with that
count and the first term cut to 120 characters, so a field of many `|`
separators no longer grows the report with its input.

* test(deb): check parser guidance through its owning formatters

Export undecodableTarNamesLimitation and unreadableRelationshipsDetail
from the parser and assert delivered limitations and issue details
through them, so wording edits change one place.

* fix(deb): bound PAX header work before each tar entry

Keep only the path and linkpath PAX keys the reader uses, set in place
rather than copying an accumulated object per header, and refuse more
than eight GNU long name/link or PAX headers before one entry as
malformed, so a run of short PAX headers cannot stall the server.

* fix(deb): apply PAX owner records to the following entry

PAX uid, gid, uname and gname now override the fixed ustar fields,
which can hold shortened or fallback values. A uid or gid that is not a
safe decimal integer falls back to the fixed field.

* fix(deb): keep GNU ar string tables as counted members

A // string-table member is now kept in the ar inventory and counted
against max_ar_members like any other member. As an unknown role it is
listed in extra_member_names, so coverage reports partial.

* fix(deb): honor PAX size records and escaped md5sums names

- A PAX size record overrides the next entry's ustar size field. Reading
  and skipping by the header field reported an empty file and then parsed
  its data as a header, refusing a valid archive.
- GNU md5sum writes a leading backslash and escapes names that contain a
  backslash, newline or carriage return. Those lines were dropped, so the
  cross-check counted listed files as missing; they are now read, and lines
  that are not digest lines are counted in a limitation.

* fix(deb): bound relationship alternatives and read PAX headers faithfully

- Count relationship alternatives across the control file before building
  any, refusing more than a fixed 65,536; a field of '|' separators within
  the control budget could build millions of report objects.
- Refuse a PAX extended header whose record length is unreadable or runs
  past the member, instead of using the fields read so far.
- Keep global (g) PAX values for every later entry and per-file (x) values
  for the next entry only; global values were cleared after the first file.

* refactor(deb): drop an unused import

* chore(mcp): drop the dialect baseline main retired in #10693

* fix(analysis-view): call completeWithinViewCoverage with main's single count

Main dropped its redundant second argument; both arguments were the same
count here.

* test(mcp): record this PR's advertised-schema summary

Add the advertised-schema summary for inspect_deb_package, generated
with npm run verify:advertised-schemas -- --update-summary.

* fix(deb): bound repeated global PAX text and accept xz stream padding

A global PAX path, linkpath, uname or gname is copied into every later
row, so each reuse is now charged to the member byte budget
(max_data_bytes or max_control_bytes) and refused before the row is
added. An empty global PAX value now deletes the earlier global
override, so later entries read their header owner again.

xzUncompressedSize and the footer check skip trailing zero Stream
Padding in 4-byte groups before locating the footer, so valid padded
xz members are no longer reported as truncated.

* fix(deb): trim trailing tar path slashes with a backward scan

The unanchored /\/+$/u retried from every slash, so a PAX path or
md5sums name made of a long slash run and a final non-slash took
quadratic time. logicalTarPath now trims trailing slashes with a
linear charCodeAt scan from the end.

* fix(deb): parse global PAX owner ids once per global record

Global uid and gid values were run through paxId for every later
entry, and the repeated-text budget skips numeric keys, so a long
global owner value was rescanned once per row. Parse them when the
global record is read and reuse the numbers.

* refactor(deb): report coverage with the shared coverage status schema

* refactor(deb): classify provider failures through classifyProviderFailure

* fix(deb): bound resolved ar member names before copying them

GNU ar /N references can repeat one string-table entry without charging
its text to any budget, and every resolved name is copied into the report
and its Evidence. Refuse a BSD or GNU long name above 4096 bytes before it
is read or sliced, so repeated references cannot expand a small table into
large report text.

* test(deb): register the debPackage capability conformance case

debPackage is declared in CAPABILITY_DECLARATIONS but had no entry in
PROVIDER_CAPABILITY_CONFORMANCE, so the conformance suite failed for it.
Name the existing Debian package CLI acceptance test as its case.

* fix(deb): flag repeated control and data members as extra

Only the first debian-binary, control.tar*, and data.tar* member is
read. A later member with the same role was neither decoded nor listed,
so a package with an empty first data.tar and a populated second one
reported complete coverage. Repeated members now land in
extra_member_names with a limitation, which keeps coverage partial.

* refactor(deb): use the shared excerpt and error message owners

The architecture guards from main count a hand-written ellipsis cut in
the relationship issue detail and two inline error-to-message copies.
Use ellipsisExcerpt and errorMessage instead.

* refactor(deb): move DebPackagePort to src/ports/deb

The provider imported its port from the application layer, which needed
an upward allowance in the module-layer baseline. Put the port beside the
other provider ports and drop the allowance.

* fix(deb): record only caller-selected budgets in Evidence

Omitted inspect_deb_package budgets no longer appear in Evidence
parameters as if the caller set them; only supplied fields are kept.

* fix(deb): report fixed reader allowances as limits

The ar member name, tar extension header, and relationship alternatives
allowances stop inspection without showing the input is invalid. Report
them as `limit` parse failures (DebPackageAllowanceFailure) with the
partial report attached, and project them as resource_constraint with a
fixed-allowance recovery instead of invalid_request.

* fix(deb): refuse GNU ar long name references outside the string table

A `/<offset>` reference past the end of the `//` string table, or one
that lands on an empty entry, resolved to an empty member name. The
report then failed debPackageSchema and callers got AnalysisOutputError
with no file identity or partial facts. Check the offset and the
resolved name, and refuse as a malformed DebPackageFormatFailure that
carries the partial report.

* fix(deb): align ar members by stored size and require padding

Advance past each ar member using the stored header size, so a BSD #1/N
extended name with odd length keeps the next header aligned. Refuse an
odd-sized member whose padding byte is missing at end of file instead of
reporting complete coverage for a truncated container.

* fix(deb): trim NUL-terminated header fields in linear time

Trim fixed-width ar and tar header fields at the first NUL with indexOf
instead of a NUL-to-end regex, which retried from every NUL when a
continuation line followed a NUL run. Control-field decimal parsing no
longer applies header NUL trimming.

* fix(deb): skip the tar path prefix on GNU headers

GNU tar headers use the 345-499 region for atime, ctime and sparse
data, not a POSIX path prefix. Only join the prefix when the header
carries the POSIX "ustar\0" magic.

* docs(readme): drop duplicated target tables in five translations

The fa, ko, th, zh-TW and zh guides carried the target table twice.
Restore each to upstream and add the single Debian packages row.

* fix(deb): report oversized Zstandard windows as a fixed allowance

A valid control or data zstd member can request a decoder window above
the fixed 128 MiB ceiling. Node raises
ZSTD_error_frameParameter_windowTooLarge, which the parser reported as
malformed. Map it to a DebPackageAllowanceFailure naming the new
zstd_window_bytes allowance, matching ZipArtifactReader.

* fix(package): bundle XZ decoder binaries for every plugin host

The plugin archive is produced on Linux x64, where npm ci drops other
platforms' optional packages. The packaging step only restored the PTY
binaries, so Codex plugin installs on macOS and Windows had no
@napi-rs/lzma binding and valid XZ packages failed as unsupported.

Derive the platform packages from the locked runtime tree instead:
every optional dependency of a runtime package that targets
darwin/linux/win32 on x64/arm64 is restored at its locked path with a
verified integrity, and the packed archive is checked for each one.

* fix(deb): keep only applied PAX keys while reading records

parsePax stored every record's key before PAX_KEYS filtered them, so one
extended header of many short records with distinct keys grew an object
property per record before any entry limit ran. Records whose key is not
one this reader applies are now read and dropped, and parsePax is covered
directly in DebPackageParser.test.ts.

* Address review feedback

* Trim deb822 lines with linear scans

The trailing-whitespace alternative of the shared trim expression retried
from every position of a long interior whitespace run, so a package
Description could take quadratic time. Scan from each end instead and
cover a long tab and space run in a test.

* fix(deb): read only the first control paragraph

parseControl used the first paragraph of the control file, but
deb822Paragraphs built a map for every paragraph first. A control file
of many small paragraphs could allocate millions of maps within the
decompressed-size budget. deb822Paragraphs now takes a paragraph limit
and yields string lines lazily, and parseControl stops after the first
paragraph.

* fix(deb): report unreadable tar modes as null

A tar header whose mode field is not octal was reported as mode 0000,
which invents a permission the archive never stated. Report the mode as
null and add a malformed issue for the member, so coverage is partial.

* fix(deb): refuse GNU sparse tar entries

GNU PAX sparse headers (GNU.sparse.*) rename the following entry to a
synthetic GNUSparseFile path and store only mapped segments, so reading
it as a regular file reported the wrong name and size and could miss
md5sums cross-checks. Old GNU sparse (S) entries can also carry
extension blocks their size field does not count. Refuse both as an
unsupported format instead of reporting wrong file facts.

* refactor: use shared artifact inspection for Debian packages

* fix(deb): report per-call budget refusals as parameter limits

* Address review feedback

* Address review feedback

* fix(deb): bound xz decoding, inherit global PAX size, and redact Homepage URLs

* fix(deb): bound xz index preflight memory and preserve typed cancellation with partial facts

* fix(deb): bound nested relationship lists, align tar stored-body rule, and scope async parse

* fix(deb): walk actual XZ block boundaries, scan control lines without arrays, and guard XZ close gate

* refactor(deb): avoid throwaway filter arrays in DebPackageParser

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local>
2026-11-26 18:10:02 -05:00
47daa05a84 feat(pe): report the overlay appended after a PE image's last section (#13245)
* feat(pe): report the overlay appended after a PE image's last section

* chore(schemas): add the inspect_pe_overlay schema summary

* test(pe): expect the shared non-PE refusal message in MZ admission

* test(cli): record completion goldens for inspect-pe-overlay

* fix(pe): preserve overlay diagnostics and validate certificate spans

Keep impossible security directory spans in measured overlay bytes and share bounded format recognition with inventory. Validate structured overlay facts in the domain while preserving provider diagnostics.

* docs(pe): move the PE overlay guide under docs/guides

* fix(pe): keep overlay format recognition within its probe

* Address review feedback

* fix(pe): keep header anomalies in the overlay report

parsePeOverlay dropped pe_header_anomalies from readPeImage, so a
SizeOfHeaders that ends before the section table reached the overlay
report without its warning. Carry header_anomalies through the output
contract and Evidence result, as the certificate, import and load
config reports already do.

* Address review feedback

* fix(pe): report adjustable max_file_bytes budget and preserve omitted caller parameters in inspect_pe_overlay

* fix(pe): preserve required_value on file-size limit and use executeArtifactInspection in PeOverlayService

* chore(schemas): update inspect_pe_overlay advertised schema summary

* fix(pe): include bflt in PE overlay leading formats

* test(pe): import BINARY_DIAGNOSTICS_TOOL_CONTRACTS in PE overlay tests

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local>
2026-11-26 22:07:19 +00:00
2c89136469 feat(artifacts): inspect VS Code extension packages offline (#12469)
* feat(artifacts): inspect VS Code extension packages offline

REA had no owner for a local .vsix ZIP. inspect_vsix_package and inspect-vsix-package now read extension.vsixmanifest and extension/package.json, report identity disagreements, engine range, activation events, a contributes summary, hashed native/wasm/executable members, and a ZIP inventory without installing the extension or contacting a marketplace.

Missing or malformed manifests return the inventory with limitations. Invalid ZIP input fails without partial success. Signature files are reported present or absent and are not verified.

* fix(vsix): bound vsixmanifest XML nodes before building the tree

A compressed extension.vsixmanifest within the 16 MiB byte budget can
still expand into millions of XML nodes. Count nodes as a stream first,
as the Maven POM reader does, and refuse the manifest with an xml_nodes
limit before parseXmlDocument allocates its document.

* fix(vsix): report the vsixmanifest node ceiling as a fixed allowance

The xml_nodes limit is a fixed parser ceiling, not a caller budget, so
the provider fell through to a generic memory refusal that implied more
memory could help. Map it through fixedAllowanceOptions as the Maven
provider does and cover the public error from the provider.

* refactor(vsix): classify provider failures through the shared owner

VsixPackageProvider kept its own chain for cancellation, identity, path,
selected-file and cleanup failures. It now supplies a dialect to
classifyProviderFailure with only the package's own refusals: its parse
ceilings and budget recovery, format failures, fixed reader allowances and
the max_file_bytes refusal. The held snapshot still supplies the completed
identity for a parser failure after the read.

* fix(vsix): report an empty contributes key instead of failing the report

A package.json with an empty contributes key produced a key with an
empty name, which the contract refuses, so the whole inventory was
rejected. The empty key is now left out of contributes.keys and
reported as a limitation.

* fix(vsix): charge member decoding to one package-wide budget

Each hashed member was read with a fresh per-member budget, so a small
compressed package with thousands of members could make the parser
decode several GiB. Member reads now draw on one artifactExpansionBudgetBytes
budget for the package; once it is spent, remaining members stay in the
inventory without a digest and a limitation names the spent budget.

* fix(vsix): resolve dot segments in package.json entry points

packageJsonEntryPath stripped only one leading ./, so a main such as
./out/./extension.js named extension/out/./extension.js and was reported
absent even when extension/out/extension.js existed. Entry points now
resolve . and .. segments under extension/; a path that climbs out of
extension/ keeps its unresolved form and matches no member.

* fix(vsix): resolve entry points with the loader's lookup rules

An extension-less main such as ./out/extension was looked up as a
literal ZIP name and reported absent although Node resolves it to
extension/out/extension.js. main now tries Node's CommonJS file and
directory suffixes, browser tries the .js the web extension host adds,
and the reported path is the member found.

* fix(vsix): resolve a directory main through its own package.json

Node's directory lookup reads the directory's package.json main before
falling back to index files, so an entry like main: ./out with
out/package.json naming ./start.js now resolves as present.

* Address review feedback

* fix(vsix): report interesting member sizes past 4 GiB

A ZIP64 member can declare an uncompressed size above 0xffffffff while
the compressed package stays under max_file_bytes. The parser skips
hashing it and reports the declared size, but interesting_members[].bytes
used the 32-bit uint schema, so the service rejected the whole report.
The field now takes any nonnegative integer, matching
contents[].uncompressed_size.

* fix(vsix): report a malformed directory package.json instead of its index

When main names a directory whose package.json is not a JSON object,
Node's loader throws ERR_INVALID_PACKAGE_CONFIG rather than falling back
to index.js. Keep that outcome distinct from a manifest with no usable
main: mark the entry point absent and add a limitation naming the member.

* fix(vsix): classify Java archives as nested archives

A bundled .jar, .war or .ear is a ZIP, but the path classifier returned unknown for it, so it was never hashed or counted as a nested archive.

* fix(vsix): match entry points by exact member case

Resolve main and browser entry points against exact ZIP member names, as a
case-sensitive file system would, and report a member that matches only when
case is ignored as a limitation instead of marking the entry present. The
directory package.json used to resolve a directory main is matched exactly
too.

* fix(vsix): keep directory-only intent for a trailing-slash main

A main such as "./out/", ".", "..", or one ending in "/." or "/.." can
only name a directory under Node's loader. Normalizing it to a bare path
let a sibling file like extension/out.js match and report the entry as
present. Carry a directory-only flag from the raw value and skip file
candidates in the declared-path lookup and in the check that decides
whether to read <main>/package.json.

* fix(vsix): only blame case when the spelling differs

The case-only entry point warning scanned index candidates even when a
malformed directory package.json had already stopped the main lookup, so
an exact extension/out/index.js could be reported as a case mismatch.
Skip index candidates when the directory manifest is malformed, and skip
any candidate whose member is spelled exactly as declared.

* fix(vsix): stop main lookup at an over-budget directory package.json

When main names a directory whose package.json exceeds
max_manifest_bytes, its main is unknown, so falling back to index.*
could report a file Node would not load. Treat the unread manifest like
a malformed one: report main unresolved, add a limitation that says the
index files were not used, and skip the index files in the case-only
scan.

* fix(vsix): resolve a main that normalizes to the package root

A main of ".", "./" or "./out/.." normalized to "extension/", so the
directory lookups searched "extension//package.json" and
"extension//index.js" and reported a present index file as absent.
Return "extension" for the root so those lookups name real members.

* fix(vsix): stop main lookup at an unread directory package.json

An encrypted or duplicated directory package.json left the directory
main unresolved as "none", so lookup fell through to index files even
though the unread manifest may name another file or be invalid. Mark it
unread and stop the lookup, as the over-budget branch already does.

* test(vsix): tag the decode-budget regression long-running

The package-wide decode budget test passed a fixed 60-second deadline,
which also turned off coverage and CI deadline scaling. Use the
long-running tag the testing guide prescribes instead.

* fix(vsix): leave unread dependency declarations unknown

A missing, encrypted, or malformed manifest reported its extension
dependencies and extension pack as empty lists, so a declaration on the
other side showed up as a disagreement. Report the unread side as null
and only flag a disagreement when both manifests were read.

* fix(vsix): look up entry points by their literal text

package.json main, browser, and a directory package.json main were
trimmed before lookup. A ZIP member name can begin or end with
whitespace and Node does not trim the specifier, so "./out/start.js "
was reported absent or matched the different "out/start.js" member.
Use the declared text as written; only an empty string names nothing.

* fix(vsix): keep activation events literal before eager classification

VS Code matches activation events as exact strings, so "* " and
"onStartupFinished " are not startup activations. The parser read
activationEvents through the whitespace-trimming ID helper, which turned
those values into "*" and "onStartupFinished" and reported them as eager.

Read activation events with a literal helper that drops only empty
strings and exact duplicates, and cover the padded values next to their
exact-name controls.

* fix(vsix): keep mode-executable members inventoried when unread

A member with no recognized suffix but Unix execute bits was only
classified after its magic was read. When the hash budget, the package
decode budget, encryption, or traversal skipped that read, it stayed
unknown and fell out of interesting_members and the executable count.
Unread mode-executable members now keep an inferred executable kind.

* fix(vsix): count a singleton contributes.commands object

VS Code accepts contributes.commands as one command object as well as
an array. Normalize the singleton form before capping and counting so a
package with one command reports commands_total 1 and the commands key
count matches.

* fix(vsix): keep contributed command identifiers literal

VS Code registers and invokes a contributed command by its exact
identifier, and the parser already keeps onCommand activation events
literal. Commands went through the trimming text helper, so a declared
"demo.run " was reported as "demo.run" next to an "onCommand:demo.run "
event, giving two different identities for the same command.

Keep the declared command text as written and report null only for an
empty string. Titles are display text and stay trimmed.

* fix(vsix): do not infer executables from symlink modes

A Unix symlink entry carries 0o120777, so its permission bits made an
unread link look like an executable helper. Only regular files, or
entries with no recorded file type, now count toward mode-inferred
executables.

* style(vsix): apply oxfmt to manifest limit guard

* fix(vsix): keep mode-executable kind when read bytes have no known magic

A suffixless regular Unix member with execute bits but no recognized
magic (for example a shell helper without a shebang) was listed as an
executable only when the hash budget skipped its read. Raising the
budget enough to hash it resolved the kind to unknown and dropped it
from interesting_members and the executable count. Fall back to the
mode-derived executable kind when the read bytes match no magic.

* fix(vsix): charge failed member expansions to the package budget

A member whose ZIP header understates its uncompressed size can decode
its whole allowance before the bounded writer refuses it. That work was
not charged to the package-wide decode budget, so every later failing
member got the same allowance again. Charge the allowance on a
max_member_bytes failure so later members see the spent budget.

* fix(vsix): bound JSON values before parsing manifests

Both package.json readers called JSON.parse after a byte-only check, so a
16 MiB manifest of many tiny values could allocate far more memory than its
text. A one-pass countJsonValues scan now runs first: an extension/package.json
holding more than 1,048,576 values is refused with a fixed json_values parser
allowance, and an over-allowance directory package.json is left unread with a
limitation, so its index files are not used.

* Address review feedback

* fix(vsix): treat absolute directory package.json main as outside the package

Node resolves a directory package main with path.resolve(dir, main), so an
absolute main names a host file, never a package member. Report it as no
main so the lookup falls back to index.* or reports the entry absent.

* fix(vsix): tag escaped entry points instead of matching them as members

A package.json main or browser that climbs out of extension/ was kept as
an ordinary member path string. A traversal ZIP member with the same name
(extension/../outside.js) is in the inventory, so the lookup reported the
entry point present even though that member is never extracted.

packageJsonEntryPath now returns a tagged resolved/escaped value. Escaped
entry points skip the member, directory manifest and case-only lookups and
are reported with present: false.

* fix(vsix): decode directory package.json as UTF-8 like Node

Node reads a nested package.json as UTF-8 only. A UTF-16 manifest
fails with ERR_INVALID_PACKAGE_CONFIG, so report it malformed instead
of transcoding it and marking main present.

* fix(vsix): keep directory package.json main inside the extension root

A directory package.json main such as ../../outside.js could pop the
extension segment and resolve to an archive-root member, which was then
reported as the present main entry point. Treat any main that climbs out
of extension/ as naming no main, so the lookup falls back to index.* or
reports the entry absent.

* fix(vsix): keep a root directory main from matching archive-root files

A nested package.json main such as ".." in extension/out resolves to the
extension root itself. Trying file suffixes on that path matched an
archive-root extension.js, which sits outside the installed payload.
Mark such a main directoryOnly and resolve it through extension/index.*
only, as Node does.

* fix(vsix): skip member reads once the package decode budget is spent

A compressed member declaring zero uncompressed bytes passed the
declared-size check even with no package allowance left, so its decoder
still ran and produced output before the writer rejected it. The failure
then charged zero, letting each later zero-declared member decompress
again past the package ceiling. Skip the read and report the spent
budget once nothing remains.

* fix(vsix): keep declared API proposal names literal

Read enabledApiProposals with the literal list reader used for activation
events. VS Code matches proposal names exactly, so trimming whitespace or
splitting on commas reported identifiers the package never declared and
collapsed declarations that differ only in surrounding whitespace.

* fix(vsix): select manifests by their exact member path

Count ZIP members by exact logical path. A package holding only
extension/Package.json no longer has it parsed as extension/package.json,
and a case-only sibling no longer marks the real lowercase manifest as a
duplicate and drops its facts. Names that differ only in case, and a
manifest present only under another case, are reported as their own
limitations.

* fix(vsix): treat shared libraries as interesting members

Bundled .dll, .so (including versioned .so.N names) and .dylib files
without Unix execute bits were classified unknown, so their magic was
never read and they were missing from interesting_members and the
summary count. Classify these suffixes as executable so they are hashed
and listed like .exe and .node members.

* refactor(vsix): run inspection through the shared artifact runner

VsixPackageService now delegates input parsing, the provider call, output
checks, Evidence creation and late cancellation to executeArtifactInspection,
as NugetNupkgService does, keeping only the VSIX-specific report checks.

* feat(vsix): point first-contact inspection of a .vsix to the VSIX reader

inspect_artifact now suggests inspect_vsix_package when a ZIP holds a
root extension.vsixmanifest file. The non-ZIP refusal test follows main's
unsupported_target classification for malformed target bytes.

* fix(vsix): align artifact failures with main

* fix(vsix): bound inspect_vsix_package output with shared detail/summary contract

* Address review feedback

* fix(vsix): bound summary text fields and report structured parameter limits

* fix(vsix): omit required_value on early-stop parameter limits

* refactor(vsix): count eager activation events without intermediate array

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-26 22:03:28 +00:00
6a6e7b0bbf feat(artifacts): inventory OCI image layouts offline (#12470)
* feat(artifacts): inventory OCI image layouts offline

OCI image-layout directories (oci-layout, index.json, blobs/) arrive as evidence and previously required walking the JSON by hand.

This adds inspect_oci_image_layout / inspect-oci-image-layout for the directory form only. It reports layout version, nested indexes, image config facts, layers, and streamed SHA-256 (and SHA-512 when declared) verification of present referenced blobs. Env values stay omitted unless include_env_values is selected. Missing blobs, digest and size mismatches, unreferenced blobs, unknown media types, unsupported digest algorithms, and symlink blobs are findings. Layer contents are not decompressed.

* fix(oci): preserve whitespace in image config strings

Keep config facts such as WorkingDir exactly as written instead of
returning their trimmed form. Blank values still count as absent.

* fix(oci): read the platform os.version member

The OCI image index stores a platform version under the literal
"os.version" member, so Windows entries that share OS and architecture
keep the build that tells them apart.

* fix(oci): keep config Env values unless the caller omits them

Env values are bytes from the selected image, and AGENTS.md asks to
preserve local evidence without inferring secrecy from names. The
include_env_values control now defaults to true; false still leaves each
value null and keeps the names.

* fix(oci): report descriptors the parser cannot model

An index, layer or config descriptor without a string mediaType or digest
was dropped with no diagnostic, so an index of only malformed descriptors
read as an empty, fully covered index. Each such descriptor now records a
malformed_blob_json finding naming its position, what it lacks and any
digest it carries.

* fix(oci): walk nested indexes breadth-first

The index walk was depth-first with a visited set that ignored depth, so
an index shared between a nested path and the root was first visited too
deep, and what it reached within max_index_depth was never inventoried.
Indexes now queue breadth-first, so each is first reached at the
shallowest depth any path gives it.

* fix(oci): check every declared size of a shared blob

When several descriptors referenced one blob with different sizes,
remember kept only the first declaration, so a wrong later size was
never checked. Each referenced blob now keeps every distinct declared
size, and the file-size and hashed-byte checks run against each one.

* fix(oci): report partial coverage when referenced JSON is not read

A referenced index, manifest or config that was a symlink, or otherwise
could not be read, left its facts unexamined while coverage still read
complete. Any skipped referenced JSON read now makes coverage partial,
whatever finding explains it.

* fix(oci): report unsupported layer digests without calling them missing

A layer whose digest used an unsupported algorithm got no finding and
was recorded as a missing blob, even when its file existed, and coverage
could read complete. Every referenced digest with an unsupported
algorithm now records unsupported_digest_algorithm, its blob record
reflects the file at blobs/<algorithm>/<encoded>, and such a finding
makes coverage partial.

* fix(oci): keep the parse outcome when reader cleanup fails

The provider's finally replaced the parse result with a cleanup failure
that always claimed the parse completed, so a refusal, cancellation or
integrity failure and its layout snapshot were lost when closing the
reader also failed. The parse outcome is now captured first; a failed
parse stays the primary error, with its partial facts, and the cleanup
failure is attached to it.

* Address review feedback

* fix(oci): keep oci-layout snapshot on missing imageLayoutVersion

Build the oci-layout file snapshot before checking imageLayoutVersion and
attach it to the refusal, so a readable oci-layout without a version still
reports its sha256 and byte count.

* fix(oci): keep directory traversal coverage in layout reports

parseOciImageLayout iterated the directory reader without an onCoverage
sink, so names the reader skipped (for example non-UTF-8 names on Linux)
left the report claiming complete coverage with no limitation. Collect
the traversal coverage, carry its limitations into the report, and let
unknown or partial traversal coverage override the findings-based status.
A reader that reports nothing is treated as unknown.

* fix(oci): keep reader failures on referenced blobs

A referenced index, manifest or config read that failed in the reader,
for example a close failure after the JSON was fully read, was recorded
as malformed_blob_json and the call carried on. Only format failures
become findings now; reader failures reach the caller with their own
facts.

* fix(oci): budget decoded descriptors separately from directory entries

max_entries bounds the directory walk, but index, manifest and layer
descriptors also spent it, so many manifests sharing layers were refused
far inside the advertised directory budget. Decoded descriptors now spend
their own max_descriptors allowance (default 65536, maximum 1048576), and
a refusal names that allowance.

* fix(oci): keep the completed inventory when reader cleanup fails

When parsing finished but closing the directory reader failed, the
provider threw a cleanup failure built against a placeholder outcome and
the completed inventory was dropped. The cleanup failure now carries the
completed report as unretained Evidence in its partial observation, the
same way DesktopApplicationReader keeps its report. A provider test
covers that case and checks that a later close retries the failed
reader cleanup.

* fix(oci): keep reader omissions out of complete layout coverage

parseOciImageLayout took the directory reader's coverage but not its
omission callback, so a FIFO, socket or device node under blobs/ was
dropped from the blob inventory while the report still said complete.
Collect omissions other than the intentional skip of directories
outside blobs/, name the first one in a limitation, and report unknown
coverage when any were seen.

* refactor(oci): classify layout failures through classifyProviderFailure

The provider kept its own raw-error ladder in layoutFailure. Its OCI
decisions (unsupported root or symlink, parse limits with budget
recovery, format failures, reader failures) are now the recognise step
of a ProviderFailureDialect, with the io report as its unclassified
fallback, so typed failures pass through, cancelled reads use the shared
cancellation path, and a failed read's cleanup is bound by the shared
owner.

* fix(oci): match referenced blobs by resolved path

parseOciDigest accepts uppercase SHA-256 hex and resolves it to the
lowercase blob path, but the unreferenced-blob sweep keyed membership by
the descriptor's original spelling. A blob named that way was hashed as
referenced and also reported as unreferenced_blob with a second
referenced: false row. Track the resolved paths of referenced blobs and
skip them in the sweep.

* fix(oci): read shared configs once and budget expanded config facts

Each manifest reread and reparsed its config, and every image carried its
own copy of the facts, so many small manifests sharing a large config
could expand to far more memory than the per-file limits suggest before
the service checked the report.

Each config blob is now read and parsed once per layout and its facts are
reused. The config bytes behind each image spend a new max_config_bytes
allowance (default 64 MiB, maximum 512 MiB) before the image is added, so
a shared config counts once per image and an expansion past the budget
refuses the inspect and names that allowance.

* fix(oci): report blob sizes above 4 GiB

Descriptor, layer and blob sizes used the 32-bit count schema, so a
layout with a blob over 4 GiB produced a report the output schema
rejected, hiding its blob_oversize finding. Sizes now accept any
nonnegative safe integer; depth and coverage counts stay 32-bit.

* fix(oci): report a referenced layer that is not a regular file

A referenced layer whose blob path is a directory was recorded as kind
other with present false, but no finding was emitted. Layer blobs never
go through the referenced JSON reader, so coverage stayed complete even
though the layer was never verified. The layer now gets a missing_blob
finding, matching non-file indexes, manifests and configs, and coverage
is reported as partial.

* fix(oci): keep the oci-layout hash when a later budget refuses

A manifest or config past max_json_bytes, or a layout past
max_descriptors or max_config_bytes, threw a bare ParseFailureError
after oci-layout had been read and hashed. The provider only attaches
partial facts to OciImageLayoutRefusal, so that completed observation
was dropped.

The parser now rewraps any later ParseFailureError as an
OciImageLayoutRefusal carrying the oci-layout snapshot, so every
refusal after that point reports it as the partial observation.

* fix(oci): keep blobs unknown when the reference walk is truncated

When max_index_depth, an unreadable index or manifest, or a descriptor
that cannot be modeled stops the reference walk, blobs outside the
walked part were reported as unreferenced_blob. They may still be
reachable from what was not examined, so the parser now only asserts
unreferenced status after a complete walk and otherwise records a
limitation and leaves those blobs out of the inventory.

* fix(oci): report wrong-typed manifests and layers arrays

A non-array manifests member in index.json now refuses the layout and
keeps the oci-layout observation. A non-array manifests member in a
nested index, or a non-array layers member in a manifest, records a
malformed_blob_json finding and marks the reference graph truncated
instead of reading as an empty collection.

* fix(oci): report image configs whose root is not a JSON object

A config blob holding valid JSON such as [] or null fell back to empty
facts with no finding, so the report claimed complete coverage. Record a
malformed_blob_json finding for the config digest while keeping the
manifest and layer observations.

* fix(oci): decode only image config media types as JSON

A manifest whose config is application/octet-stream or another
non-image type no longer has its config run through the JSON decoder.
Valid binary config bytes produced a false malformed_blob_json finding,
and a config larger than max_json_bytes refused the whole inventory even
when it fit max_blob_bytes. Such configs now stay opaque references that
the blob pass hashes; the unknown_media_type finding is kept.

* fix(oci): bound JSON reads by the descriptor budget

The service checked json_bytes_read against one max_json_bytes document
per returned index and image plus two. A layout reads a manifest and a
config per image, and manifests or nested indexes that fail to parse are
read without appearing in the report, so valid layouts whose every
document fit max_json_bytes could be rejected after parsing.

Every nested index or manifest read is charged one descriptor and each
manifest reads at most one config, so bound the total by oci-layout,
index.json and two documents per allowed descriptor.

* fix(oci): count OCI 1.1 subject blobs as referenced

A manifest or index subject that names a blob present in the layout now
joins the referenced set, so the blob is hashed and is not reported as
unreferenced. A subject absent from the layout is allowed by the spec
and adds no finding. A subject that is not a descriptor is reported as
malformed and keeps unreferenced blobs unknown.

* fix(oci): keep caller selections in cleanup-recovered Evidence

When the reader fails to close after a completed inspection, the provider
keeps the inventory as partial Evidence built from the resolved input, so
its parameters named defaults the caller never chose and its Evidence ID
differed from the success path. Build both from one OCI Evidence helper
and have the service rebuild a recovered inventory from the caller's own
selections.

* fix(oci): keep blob rows when the reference graph walk is incomplete

When a nested index or manifest could not be read or exceeded
max_index_depth, every blob outside the walked part was dropped from the
report, losing its path, size and kind. List those blobs with a null
referenced status instead, and report unreferenced_blob only when the
whole graph was examined.

* fix(oci): report unknown media types on present subjects

A subject blob present in the layout now joins the referenced set, which
removed its unreferenced_blob finding. Index entries, layers and configs
also report an unfamiliar media type, but subjects skipped that check, so
an unknown subject format went unreported. A present subject with an
unknown media type now records unknown_media_type.

* perf(oci): index emitted blob findings instead of rescanning them

The blob inventory loop checked each referenced digest against the whole
findings array before recording missing_blob, symlink_blob, or
unsupported_digest_algorithm, which is quadratic for layouts with many
missing blobs. Index finding kind and digest in a set built once before
the loop so each check is constant time. Output is unchanged.

* fix(oci): report invalid descriptor sizes as malformed

An index entry, config, layer or subject descriptor whose required size
was missing, a string, negative or fractional became a null size, which
dropped it from size validation without any finding, so the report could
claim complete coverage. The descriptor still keeps its other facts, but
the defect is now recorded as malformed_blob_json on the owning blob.

* fix(oci): keep damaged config, subject and descriptor facts in the report

Image config parsing kept any string in rootfs.diff_ids, so a readable
config with diff_ids [""] produced output the schema rejects and the
service discarded the whole inventory as an AnalysisOutputError. Config
parsing now owns that boundary: diff_ids members that are not nonempty
strings, and empty ExposedPorts or Volumes keys, are omitted and reported
once per config blob as malformed_blob_json, and the manifest and layer
observations stay in the report.

Related gaps in the same walk:

- A present subject was hashed but never walked, so blobs it names were
  reported as unreferenced. A subject manifest now goes through
  walkManifest and a subject index joins the breadth-first index queue one
  level below its owner, within max_index_depth.
- A manifest with no config member reported complete coverage. A missing
  config is now treated like a malformed one.
- A symlinked referenced blob was not hashed but left coverage complete.
  symlink_blob now makes coverage partial.
- An unusable descriptor size was serialized into the finding message.
  It is now described by type and length, with short strings quoted.
- A reader failure after oci-layout was hashed dropped that observation.
  It is now attached when the reader did not attach its own.
- Annotation and label names allowed by OCI, including the empty key,
  failed the output schema. The name is now any string. The advertised
  compact output schema summary is unchanged.

* perf(oci): index declared sizes for shared blobs

Recording a distinct declared size scanned every earlier declaration for
the same blob, so many references to one blob with distinct sizes cost
quadratic work inside max_descriptors. ReferencedBlob now keeps a Set
beside declaredSizes for membership, and the array keeps declaration order
for verification.

* fix(oci): walk subject manifests from a queue

Finish each manifest before reading the one its local subject names, so a
long subject chain no longer keeps every parsed document alive at once.

* fix(oci): resolve unsupported-digest layer presence at its layout path

A layer stored at blobs/sha1/<hex> was reported present: false because
the layer lookup only resolved verifiable digests, while the blob
inventory reported the same file present. Use the grammar-based path
fallback for layer presence too.

* fix(oci): keep reference coverage uncertain for opaque index entries

An index entry with an unknown media type is not walked, so the blobs
it references are unknown. Mark the reference graph truncated so no
blob is reported unreferenced, and report coverage as partial whenever
the reference graph was not fully examined.

* fix(oci): walk digest aliases that differ only in hex casing once

Descriptors whose digests differ only in accepted hex casing resolve to
one blob, but the index queue, visited set and config cache were keyed
by the source spelling, so each alias reread and rewalked the whole
index. Key traversal by the resolved blob path while descriptors keep
their source spelling in the report.

* fix(oci): keep unparsed digest spellings out of accepted traversal keys

A descriptor spelled blobs/sha256/<hex> did not parse, so its traversal
key fell back to the raw text, which matched the blob path key of the
accepted sha256:<hex> digest. Listed first, it marked the manifest
visited and the valid descriptor was skipped. Prefix accepted and
unparsed keys separately.

* fix(oci): bound index entry text retained across indexes

Index entries keep their digests, media types, platforms and annotations
in the report, but no allowance covered that text across indexes, so many
nested indexes with large annotations could exhaust memory within every
other limit. Charge each retained entry to a new max_descriptor_bytes
budget (64 MiB default, 512 MiB maximum) before adding it.

* fix(oci): hash each blob file once across digest spellings

Digest spellings that differ only in accepted hex casing resolve to one
blob path, but the blob pass hashed the file once per spelling. Cache the
hash result, or its oversize refusal, by blob path so each file is read
once, while every spelling keeps its own row, size checks and digest
check.

* fix(oci): report non-object config and rootfs subobjects

A present config or rootfs value that is not a JSON object now records a
malformed_blob_json defect instead of being replaced by an empty object, so
coverage reports partial. Other image facts are kept. Regenerate the
inspect_oci_image_layout advertised-schema summary.

* fix(oci): check declared sizes for unsupported-digest blobs

A blob referenced by a valid but unsupported digest (for example sha1)
skipped the declared-size checks and left observed_size null, even
though the directory reader already captured the file size. Record
observed_size and emit size_mismatch for it, still without hashing.

* fix(oci): keep reader integrity failures that wrap a JSON parse failure

readJsonDocument unwrapped any ArtifactReaderFailure whose cause was a
ParseFailureError. When a malformed referenced blob changed during
inspection, DirectoryArtifactReader.inspectFile raised an "integrity"
failure carrying that ParseFailureError, and the unwrap turned it back
into a malformed_blob_json finding. Only unwrap the plain "io" transport
wrapper with no cleanup lease, so integrity, cancelled and limit
failures keep their reader facts.

* fix(oci): report malformed config leaf fields

A config with Env: "A=1" or Cmd: ["/bin/sh", false] used to come back
as env: [] or cmd: null with no finding, indistinguishable from an
image that declared neither. parseConfig now checks each present known
field (the top-level strings, User, Env, Entrypoint, Cmd, WorkingDir,
ExposedPorts, Volumes, Labels, StopSignal) and records
malformed_blob_json for a wrong type, keeping the other facts. Env
members that are not a named string and non-string label values are
omitted and counted. null stays an omitted declaration.

* fix(oci): allow json_bytes_read beyond 32 bits

coverage.json_bytes_read sums bytes across every JSON document read.
OciImageLayoutService bounds it by max_json_bytes * (2 + 2 *
max_descriptors), which at a 16 MiB per-document cap passes 0xffffffff
well within budget, so the uint schema made safeParse reject a completed
report as AnalysisOutputError. Give the counter a nonnegative safe-integer
schema; the other uint counters are unchanged.

* fix(oci): report malformed image history

A non-array history or a history member that is not an object was
silently dropped, so damaged build history looked the same as omitted
history. Report both as malformed_blob_json defects on the config blob
and keep the readable history records and other image facts.

* fix(oci): report damaged descriptor metadata and symlinked blob dirs

Descriptor platform and annotations that were present but malformed
(platform: [], a non-string platform field, annotations that are not an
object or hold non-string values) were normalized to null or [] with no
finding. Report each as a malformed_blob_json defect against the owning
document and keep the readable entries.

A symlink at blobs or blobs/<algorithm> is not followed, but nothing
recorded the skipped tree, so an empty index over a linked blob
directory reported an empty inventory with complete coverage. Record a
symlink_blob finding for the linked directory so coverage is partial.

* Address review feedback

* Address review feedback

* Address review feedback

* Bound repeated JSON member names in OCI findings

A long duplicate member name is now described by its length instead of
being copied into the finding message.

* fix(oci): keep the oci-layout hash when its JSON is malformed

The oci-layout file is now read and hashed first, and its observation is
recorded before decoding. An oci-layout with invalid UTF-8, invalid JSON
or a duplicate member is refused with its completed file identity.

* fix(oci): charge accepted descriptor text to max_descriptor_bytes

Accepted subject, config and layer descriptors keep their digest and
media type in image rows, the reference map, findings and blob rows, but
only index entries and rejected descriptors spent max_descriptor_bytes.
A layout with many manifests carrying long distinct layer digests could
retain unbounded text. Charge accepted descriptor text before retaining
it, once per referencing manifest or index.

* fix(oci): report presence defects for unsupported-digest blobs

A referenced blob with an unsupported digest algorithm whose layout path
is missing, a symlink, or not a regular file now gets the same
missing_blob or symlink_blob finding a supported digest gets, alongside
unsupported_digest_algorithm. Present files still only get the size
check and stay non-missing.

* perf(oci): drain index and manifest queues with a cursor

shift() relocates the remaining queue on every step, which makes draining
layouts with many index references quadratic. Walk both breadth-first
queues with an index cursor instead.

* fix(oci): keep blobs under a symlinked blob directory unexamined

When blobs or blobs/<algorithm> is a symlink, the reader lists the link
but never its children, so a referenced blob under it is absent from the
listing without being absent from the layout. One shared lookup now
tells listed, unexamined and confirmed-missing paths apart for the
reference walk, subjects, and both inventory branches. An unexamined
blob gets a symlink_blob finding naming the directory instead of
missing_blob, and an unexamined subject marks the reference graph
truncated.

* fix(oci): charge serialized config facts to max_config_bytes

The config allowance counted the config document's source bytes, but each
image carries the parsed facts, and a sparse history entry such as {}
expands into a record with four null fields. A small shared config with
thousands of empty history entries could pass the budget while the report
grew past the runtime's string limit. Each distinct config now charges the
exact compact JSON size of its facts, once per image that uses it.

* fix(oci): keep the oci-layout snapshot when its read fails to finalize

When the oci-layout read completes but closing its descriptor fails, or
cancellation arrives during the close, the reader rejects before the
parser records the layout hash. The reader keeps the completed bytes on
that failure, so the failure reached translation without the SHA-256 and
byte count it could have carried, unlike the same failure on index.json.
The parser now records the completed layout observation from that outcome
and rethrows the reader's failure unchanged, keeping its cleanup owner.

* fix(oci): keep reference status unknown under an unwalked present subject

A present subject with an unknown media type, or an index or manifest
subject whose digest algorithm is unsupported, is not read, so the blobs
it names were reported as unreferenced with complete coverage. Mark the
reference graph truncated in both cases so unmatched blobs keep an
unknown referenced status.

* fix(oci): keep a malformed index.json primary when its handle close fails

When index.json is malformed and closing its descriptor also fails, the
directory reader raises ArtifactFileCleanupFailure with reason io and keeps
the ParseFailureError as the physical outcome. The OCI dialect translated
the wrapper directly, so the malformed input surfaced as an I/O failure even
after the resource scope retried the close.

The dialect now supplies readCleanup: the shared classifier classifies the
failed outcome as primary, and the unresolved close is attached beside it
and bound to that read's exact cleanup lease. A cleanup-only read keeps its
previous projection.

* fix(oci): count a malformed blob's bytes in json_bytes_read

A referenced index, manifest or config that was read in full but failed
UTF-8, JSON or duplicate-member decoding became a malformed_blob_json
finding, yet its bytes never reached json_bytes_read, because the count
was added only after decoding succeeded.

The blob read now adds the byte count inside the completed read, before
decoding, so coverage reports every byte the parser examined.

* fix(oci): report a missing or non-directory-ancestor path as invalid input

A selected root that resolves to ENOENT or ENOTDIR is a bad path, not an
I/O failure. Classify it as an AnalysisInputError on `path` before the
generic reader translation; other root I/O keeps its execution failure.

* fix(oci): keep the layout hash when index.json close also fails

When malformed index.json also failed to close, readCleanup composed the
error from the classified parse failure, which carries no observation,
so the completed oci-layout hash was dropped. Carry the read's partial
observation onto the primary before composing.

The close-fault test now selects the index.json handle by file identity
(dev and inode) rather than the second close call, and asserts the
fault landed there and the oci-layout hash survived.

* fix(oci): report malformed subject digests and count examined entries

A subject whose digest is not a valid OCI digest has no layout path, so
the walk returned without a finding and kept claiming it could prove
which blobs nothing references. It now records a malformed_blob_json
finding on the owner and marks the reference graph truncated, the same
as any other subject descriptor it cannot model. An absent subject with
a well-formed digest stays finding-free.

coverage.entries_examined counted only the entries the reader yielded.
It now takes the reader's examinedEntries from onCoverage, which
includes names the reader examined but omitted, and falls back to the
yielded count when the reader does not report one. An omission that
rewrites the traversal coverage keeps that count.

* fix(oci): keep the root index out of the blob traversal namespace

The root index was walked and prequeued under the traversal key of its
SHA-256 digest, which is the key of the blob path blobs/sha256/<hex>.
When a damaged nested index named that digest and the blob file there
held different index JSON, the queue skipped the blob as already walked,
so its manifests, configs and layers were never read and were reported
as unreferenced under complete coverage.

index.json now walks under its own traversal identity. A descriptor that
names its digest reads and walks the blob stored at that path like any
other nested index.

* fix(oci): diagnose conflicting media types inside referenced JSON

A referenced manifest or nested index may repeat its media type in its
own optional mediaType member. The walk ignored that declaration, so a
document admitted as a manifest but declaring the index type, or an
unknown type, produced no finding.

Check a present declaration against the descriptor type the walk
admitted it under. An unknown declared type is reported as
unknown_media_type; a known but conflicting type or a non-string value
is reported as malformed_blob_json. The members are still read, so the
other readable facts are kept, and an omitted mediaType stays valid.
The root index.json is admitted under its own declaration and is not
checked against itself.

* fix(oci): charge unknown declared media types to max_descriptor_bytes

A referenced manifest or nested index whose own mediaType is an unknown
string is quoted in an unknown_media_type finding. That text was retained
without spending the descriptor text budget, so many hash-valid documents
with long declarations could grow findings well past max_descriptor_bytes.
Charge the escaped declaration before the finding is recorded.

* fix(oci): mark the reference graph incomplete on document-type conflicts

A referenced manifest or nested index whose own mediaType names another
document kind, or an unknown type, was diagnosed but its blobs were still
judged with a complete reference graph. The walker reads only the members
of the admitted kind, so members of the declared kind, such as an index's
manifests inside a document admitted as a manifest, were never followed
and the blobs they name were reported as unreferenced_blob.

Mark the reference graph truncated for an unknown declared type or one of
a different document kind, so unreached blobs keep an unknown referenced
status. The readable facts are still reported. A declaration of the same
kind, such as the Docker manifest type on an OCI manifest descriptor,
reads the same members and keeps unreferenced status definite.

* docs(oci): state that unsupported digest algorithms skip hashing

The guide said every present referenced blob gets a SHA-256. Blobs whose
digest uses an algorithm other than sha256 or sha512 are not hashed; their
row reports hashed: false with null sha256 and sha512. Document that and pin
the null hash fields in the sha1 layer test.

* fix(oci): check the root index.json mediaType against the index kind

The root index.json skipped declaration checking because no descriptor
names it, so its own mediaType chose the admitted type. A root that
declared the manifest type or an unknown type was still walked as an
index with a complete reference graph, and blobs named by members the
index walk never reads were reported as unreferenced_blob.

Admit the root as an index: an index declaration of either family
stands, and any other declaration is checked against the OCI index type
like a nested index, which diagnoses it and marks the graph incomplete.

Also document that unknown declared media types quoted in findings
spend max_descriptor_bytes.

* Address review feedback

* Address review feedback

* fix(oci): check each referencing media type against a revisited document

A manifest or nested index reached a second time was skipped before its
mediaType declaration was compared with the new descriptor type, so a
conflict was reported or not depending on descriptor order. Each document
now records its declaration on first decode, and every distinct media type
a later reference admits it under is checked against it.

* fix(oci): detach redacted Env names from their bindings

With include_env_values false, each retained Env name was a slice of the
whole NAME=value string, so a long value stayed alive while the config
fact budget charged only the name. Redacted names are now standalone
copies, and a heap regression test covers eight 0.9 MiB values.

* fix(oci): keep only string mediaType declarations for revisit checks

The revisit cache kept each decoded document's raw mediaType, so a layout
of many manifests with large object declarations held all of them for the
whole walk while no byte budget charged them. A non-string declaration is
rejected whatever it holds, so the cache now keeps null in its place and
still reports it as not a string on each new referencing media type.

* Address review feedback

* Address review feedback

* Address review feedback

* fix(oci): preserve layout evidence on malformed targets

* Address review feedback

* fix(oci): diagnose schema versions and charge annotation records

Indexes and manifests whose schemaVersion is omitted, not a number, or a
number other than 2 now get a malformed_blob_json finding and partial
coverage, while their entries, config and layers stay readable.

Index entry annotations now spend max_descriptor_bytes as each
{name, value} record is built, charged at its serialized size, so many
short or empty annotations can no longer retain far more than their text
was charged for.

* docs(oci): describe annotation record accounting for max_descriptor_bytes

* Address review feedback

* fix(oci): wire summary delivery, parameter budget limits, and single-pass annotation parsing

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-26 20:02:44 +00:00
gensokyo-devandgensokyo-dev 68e1ec3e36 fix(package): declare the projected manifest scripts without prepare
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-27 03:43:44 +08:00
gensokyo-devandgensokyo-dev 30c87211f3 fix(package): leave the source-checkout prepare script out of the published manifest
The published manifest kept every development script, including
prepare, which only patches release-please in a source checkout and does
nothing in an installed package. npm 11 treats prepare as an install
script, so "npm install -g rea-agents" warned that rea-agents has install
scripts not covered by allowScripts and suggested allowing them.

The staged package manifest now omits prepare. Installing the staged
tarball with npm 11.19.1 lists only frida's own installer.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-27 03:43:44 +08:00
Beqa 4edb2c08ee fix(artifacts): explain ASAR PE signed-after-packing mismatches (#14702)
* fix(artifacts): explain ASAR PE signed-after-packing mismatches

When an unpacked PE companion fails ASAR integrity only because Authenticode
was applied after packing, record a verifiable signing_explanation on the
SHA-256 contradiction and error details instead of an opaque untrusted
mismatch. Bytes stay observed-untrusted; any other mutation remains an
unexplained contradiction.

Fixes #7212

* fix(artifacts): address signed-after-packing Greptile review

Catch ParseFailureError so unreadable PKCS#7 keeps the digest explanation,
share WIN_CERTIFICATE structural walks, index signer lookups, charge optional
reads to acquisition budgets with reported skips, preserve mismatch details
through cleanup failures, and inherit the shared MCP test deadline.

* fix(pe): walk WIN_CERTIFICATE entries lazily under max_entries

Convert the certificate-table walker into a generator so inspection stops at
the entry budget without materializing every range, and reconstruction can
validate structure with constant memory.
2026-11-26 10:31:54 -05:00
gensokyo-devandgensokyo-dev 42ce0ea231 feat(browser)!: budget observe_web_execution delivery
observe_web_execution returned complete script sources inline. On a local
page loading rxjs, openpgp and isomorphic-git in Chromium 156, the
complete observation was 1,888,024 bytes of structured content, nearly all
source text.

observe_web_execution now takes detail and joins the agent result budget.
Omitted, an observation that fits delivery.agent_result_budget_bytes is
inline and a larger one is retained behind its summary, which pages
through the web-execution view. On that page the default reply was 7,458
bytes. detail summary retains the observation through the shared retained
summary binding. rea observe-web-execution uses the shared CLI Evidence
delivery. The real-browser verifiers request the complete observation
they assert on.

BREAKING CHANGE: an observe_web_execution call that omits detail on an
observation above the agent result budget now returns the retained
summary. Pass detail: "complete" (--detail complete) for the previous
shape.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-26 14:03:36 +08:00
Vincent Koc d9b449d39c refactor(verify): share canonical output schema assertions (#14640) 2026-11-26 03:50:41 +00:00
Vincent Koc a156d20516 refactor(verify): share Ghidra installation prerequisites (#14569) 2026-11-26 01:24:43 +08:00
Vincent Koc 3d9ceeae6b refactor(resources): share the retained close-owner adapter (#14562) 2026-11-26 01:24:30 +08:00
Vincent Koc 0bbdbeaedf refactor(cli): share compiled runtime checks with the session worker (#14557) 2026-11-26 01:24:24 +08:00
Vincent Koc 5bf09b6dff refactor(ghidra): reuse the verifier file digest for fixture checks (#14554) 2026-11-26 01:23:52 +08:00
Vincent Koc 41589492e0 refactor(ghidra): reuse the verifier MCP call binding (#14590)
* refactor(ghidra): reuse the verifier MCP call binding

* test(ghidra): cover shared verifier call decoding
2026-11-25 16:56:05 +00:00
Vincent Koc aad3c9c45a refactor(windows): reuse the verified package argument encoder (#14591) 2026-11-25 16:51:16 +00:00
morluto 123b693f08 feat(delivery)!: bound default results by an agent result budget (#14252)
* feat(delivery)!: bound default results by an agent result budget

Omitted detail now returns complete Evidence only when it fits the new
delivery.agent_result_budget_bytes runtime setting (default 49152 compact
JSON bytes, about 12k tokens at an estimated 4 bytes per token). Larger
results are retained and delivered as the producer's summary with a
limitation naming the budget and the recovery call; nothing is refused or
truncated. inspect_analysis_view gains an evidence-json view that pages the
exact JSON text of retained Evidence. The CLI applies the same budget and
publishes the complete bundle with --evidence_output.

inspect_managed_members type_names now also narrows member_refs and
exported_types, and inspect-byte-entropy gains CLI evidence delivery.

BREAKING CHANGE: An omitted detail no longer always returns complete
Evidence inline on MCP or the CLI for tools with a detail selector
(including inspect_managed_members, inspect_managed_artifact,
inspect_byte_entropy, inspect_artifact, analyze_javascript_application,
list_procedures, list_strings and the other operations listed in
src/domain/agentBudgetOperations.ts). Over the budget they return the
retained summary; pass detail complete (--detail complete) for complete
inline delivery. inspect_managed_members type_names narrows member_refs
and exported_types.

Fixes #14172
Fixes #14180
Part of #14187
Part of #14156

* test(schemas): record advertised summaries for budgeted detail

* fix(delivery): keep budgeted summaries canonical and carry delivery facts beside them

Review fixes for the agent result budget:

- Deliver the producer's own summary record, identical to detail summary,
  so its identity holds in summary consumers such as compare_artifacts.
  The budget, sizes, retention and the exact paging call travel as
  delivery facts: a second MCP text block and _meta, or a delivery field
  in CLI output.
- Capture the caller's detail for application-validated tools too, so
  inspect_binary_layout and similar tools are budgeted.
- Keep recovery facts when a budgeted summary itself exceeds the frame.
- Size an omitted evidence-json limit by escaped UTF-8 bytes and never
  split a surrogate pair, even in a one-unit page.
- Add the REA_AGENT_RESULT_BUDGET_BYTES launch seed; the shared test
  environment raises it for semantic tests, and budget tests clear it.
- Align tool descriptions and verifiers that read complete Evidence.

* fix(delivery): retain the budgeted summary like an explicit summary

* fix(delivery): read the budget seed from the captured environment and count delivery facts in the frame

- The agent result budget seed is read from the environment the server or
  CLI invocation captured: ToolResultDelivery takes it at construction,
  and a CLI invocation binds it in its publication context. The ambient
  process environment is no longer read.
- The frame check reserves the bytes of the delivery block and _meta that
  are added after encoding, so a budgeted response cannot exceed the frame.
- Conformance workflows that resend complete Evidence raise the budget
  through the shared inline-Evidence environment, as do the artifact and
  binary layout verifiers.

* fix(delivery)!: request complete Evidence explicitly and never spill CLI overflow

- Shared test and verifier environments no longer raise the agent result
  budget. Every test and verifier workflow that reads complete Evidence
  from a budgeted tool now requests it with detail complete or --detail
  complete, including the real-provider verifiers outside PR CI (Ghidra,
  Hopper, IDA, Kuna and client verifiers). Default delivery is exercised
  as shipped.
- Budgeting applies only to tools with a detail selector, so every
  budgeted call has a complete opt-out.
- CLI overflow without --evidence_output writes nothing; its delivery
  facts carry exact rerun argv for --detail complete and
  --evidence_output, omitted when the command declares sensitive values.

* test(delivery): prove captured budget seeds with valid in-range values

* test: state complete-detail requests once and fix codemod regressions

- Add tests/support/completeDetail.ts with COMPLETE_DETAIL and
  completeArguments so tests that read complete Evidence request it in one
  place, keeping functions within max-lines-per-function without raising
  the limit.
- Restore provider-client tests (GhidraClient, Hopper health): their
  callTool("name", ...) calls are bridge requests, not MCP tools, and take
  no detail.
- Update the game-scale type inventory test for member_refs narrowing.

* test: request complete Evidence in shared JavaScript analysis helpers and remaining CLI workflows

* test: request complete Evidence by default in the shared test transports

The shared MCP client helpers (createTestMcp, connectLocalToolsMcp and
the CLI fixture's shared MCP session) and the CLI runners (the cli
fixture and the shared CLI session) now apply one named default,
completeEvidenceByDefault. A budgeted tool called with neither detail nor
view gets detail complete; the CLI does the same with --detail complete,
chosen by the command's tool contract. A budgeted operation that resolves
to no contract fails loudly at load. Tests whose subject is delivery opt
out with delivery "budgeted". This is a test-harness choice; production
delivery is unchanged and the budget tests prove the default path.

Per-call complete-detail edits are reverted in the 204 test files whose
transports all apply the default. Explicit requests remain where a test
drives its own SDK client, server, CLI instance or process, and where
the detail choice is the test's subject.

* test: resolve CLI complete-detail defaults from the CLI registry

The Real Apple and browser verifiers read complete Evidence through
artifactCliEvidence, which ran the compiled CLI without a detail choice
and got the budgeted {summary, delivery} output. The helper now requests
complete Evidence for commands that take --detail, read from the compiled
CLI's own registry (scripts/lib/complete-evidence-cli.mjs).

The test harness default had a sibling bug: it treated every cli-flagged
budgeted contract as taking --detail, but only Evidence-delivery commands
do (inspect-binary-layout does not). It now reads the source CLI registry
too, and covers every command the CLI budgets.

* test(verifiers): request complete Evidence at each verifier's SDK client and CLI argv

The real-browser failure was the same missing normalized_result as the
Apple one: browser-capture-metadata-budget-e2e reads analyze-web-bundle
through artifactCliEvidence, fixed in the previous commit.

The shared verifier module, scripts/lib/complete-evidence.mjs, now owns
both transports:
- completeEvidenceClient wraps each verifier's SDK Client once, so every
  callTool to a budgeted tool with neither detail nor view requests
  complete Evidence, whatever local call helper a verifier uses (86
  clients, including the Ghidra, Hopper, IDA and Kuna verifiers'
  argument-less list_procedures and inspect_native_load_image calls).
- completeEvidenceCliArguments covers the remaining verifier CLI argv
  that chose no detail, such as function, decompile, analyze and the
  Android and Apple commands.
Commands and tools that are not budgeted are sent as written.

* test(delivery): await async completeEvidenceCliArguments helper in boundary test

* test(delivery): request complete detail in Electron CLI artifact format test

* docs(delivery): document delivery.rerun as add-only argument arrays

* test(schemas): record advertised summaries for the unified delivery budget

Tool descriptions now name the agent result budget, and the evidence-json default page is derived from the 32 KiB default, which changes the advertised input digests of the 28 affected tools. Recorded from the Build package job's output.

* test(delivery): pin the budget boundary and keep failures unbudgeted

Main's retainedSummaryDelivery tests pinned the size decision at exactly
32,768 and 32,769 UTF-8 JSON bytes. Unifying that decision into
budgetedSummaryBytes deleted them, and their port never landed, so the
byte measurement went unchecked.

Restore them against budgetedSummaryBytes at the configured budget and
one byte over, for the default and a runtime budget, with ASCII, escaped
and multibyte text, plus each condition of the decision. Off-by-one
mutants (< for <=, a cap one byte short) fail six cases; measuring UTF-16
code units instead of UTF-8 bytes fails the multibyte cases.

An MCP case pins that a target failure from a budgeted tool under the
minimum budget is identical with detail omitted and complete, with no
delivery facts.

* test(verifiers): route literal CLI argv for budgeted commands through complete Evidence

real-browser failed with "Scenario CLI did not report external disconnect
ownership": runScenarioCli ran capture-browser-scenario without --detail,
so an over-budget capture came back as its summary, which has no
browser.cleanup. The earlier sweep counted these files as covered
because their MCP clients were wrapped, but their CLI argv was not.

Route the shared runScenarioCli helper (five callers), the local cli
helpers in the module, source-map and script-export verifiers, and
every other literal argv for a budgeted CLI command without --detail or
--view (EVM interface, binary layout, packet capture, devicetree, DOM
destinations, Ghidra relocation symbols, WABT cleanup, Termux browser)
through completeEvidenceCliArguments. A sweep of scripts/ for budgeted
command literals with --json and no detail selection now finds none.

* fix(verifiers): leave clients without callTool unwrapped

The native verifier cleanup test drives native-value-e2e with a connection double whose Client has only connect and close. completeEvidenceClient bound client.callTool unconditionally, so wrapping threw a TypeError before connect ran. That TypeError replaced the primary connection failure the test asserts is preserved, and all four fault cases failed in Test shard 5 and Portable tests. A client without callTool has no tool call to complete, so the helper now returns it unchanged. Locally all five fault modes of the fixture now exit 0.

* fix(delivery): keep the catalog recorder on shipped helpers and expect view-implied summary

The verifier sweep wrapped record-mcp-catalog.mjs in completeEvidenceClient,
which lives in an unshipped helper. deferredRuntime copies only the
package's shipped files plus the recorder, so the recorder failed to load
(ERR_MODULE_NOT_FOUND) and its cleanup recorder never wrote. The recorder
only lists tools and prompts, so the wrapper had no effect; it is removed.

This branch makes a view with no --detail select summary delivery, as MCP
does for a view. Three CLI cases still expected the old view refusal; with
a view alone the missing input is now the summary bundle, so they expect
evidence_output, and a view with --detail complete still refuses the view.

* fix(delivery): request complete Evidence where callers need the whole result

Budgeted delivery made four callers receive a summary they cannot use:

- The GitHub Actions example uploads the analysis as a CI artifact, so it
  now asks for --detail complete; over budget it had saved a summary.
- javascriptIntegrityPolicyCli spawns the CLI itself, outside the test
  harness default, and reads normalized_result; it now applies the same
  completeEvidenceCliArguments default.
- nativeObservationViewsMcp builds its own client to prove complete
  observations overflow into a paging continuation; it now applies the
  harness default so each call asks for complete Evidence.
- The CLI parity goldens are re-recorded for the --detail and
  --evidence_output options the budgeted commands now advertise.

* fix(tests): give processes tests spawn the largest agent result budget

About 90 tests spawn scripts/rea.mjs or a server directly, outside the
harness default that asks for complete Evidence, and read analysis facts
from the result. Over the default budget they received a summary instead;
javascriptChildHandleOwnership failed this way.

The Vitest environment now seeds REA_AGENT_RESULT_BUDGET_BYTES with the
largest accepted value, so a spawned CLI or server delivers complete
Evidence, as the in-process default does. Delivery tests keep their own
budget: agentResultBudgetMcp builds its server without the seed, so its
default-budget cases still exercise the shipped default.

* fix(tests): give budgeted harness tests the shipped agent result budget

The test environment seeds the largest agent result budget so spawned
processes deliver complete Evidence. In-memory servers built by
createApplicationMcpHarness (and connectGhidraMcp, which uses it) inherit
process.env too, so a test that chose testDelivery "budgeted" kept the
seed: the 600-row list_procedures case and the omitted-detail web page
views returned complete Evidence instead of a summary.

testDeliveryEnvironment now owns that choice: a budgeted test's server
environment drops the seed and uses the shipped default. The application
harness applies it to every server it builds.

* fix(tests): expect view-implied summary delivery in the Playwright trace refusal

A view with no --detail now selects summary delivery, so its refusal
names the missing evidence_output bundle; --detail complete still refuses
the view. The trace test still expected a view refusal in both cases.
2026-11-25 11:25:18 -05:00
Vincent Koc 150d6f0e19 refactor(verifiers): share legacy Ghidra snapshot construction (#14566) 2026-11-25 15:59:57 +00:00
Vincent Koc 60af9ef6b3 refactor(verifiers): share whole-file SHA-256 hashing (#14475)
* refactor(verifiers): share whole-file SHA-256 hashing

* fix(verifiers): type the streamed digest input
2026-11-25 10:01:22 +00:00
a61ff39c9a fix(errors)!: refuse malformed SQLite, pwntools and EVM inputs as target failures (#14268)
* feat(errors)!: add the TargetFailure model, its projection table and conformance registry

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

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

BREAKING CHANGE: selected-file malformed and truncated refusals add
details.failure_kind, and a truncated target's remediation now says to
re-acquire the complete file instead of choosing another target. Codes
are unchanged. Affected operations: every operation that refuses a
selected file's malformed or truncated bytes, including the ELF, PE,
Mach-O, DWARF, Go, Rust, BEAM, pyc, devicetree, Apple IPS, kernel
module, binary hardening, managed PE/CLI and IL2CPP readers.

* test(managed): name the target failure error in the merged status test

* docs(reference): name the error CSV instead of linking a non-page file

* fix(tests): expect the path reason for non-regular dyld inputs

#14225 refuses a non-regular dyld input as ArtifactReaderFailure("path");
dylibFileLifetime still expected "format" and fails on main's shard 9.

* fix(tests): expect io, invariant and path where #14225 reclassified

stableArtifact expected "format" for an impossible descriptor byte count
(now io) and an invalid chunk size (now InternalInvariantError);
directoryArtifactReaderOpen expected "format" for a non-file entry (now
path, the same change as #14238). All three fail on main.

* fix(errors)!: raise container reader byte faults as malformed or truncated targets

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

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

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

* test(artifacts): expect target failure codes in compiled CLI and MCP suites

* fix(errors)!: refuse malformed SQLite, pwntools and EVM inputs as target failures

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

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

* fix(errors): give the integrity kind a schema-valid code and list the reference page

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

* fix(artifacts): report a short carrier read as a changed file and keep unsupported desktop probes local

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

* test(errors): expect target failure facts in the pwntools and EVM reply suites

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

* test(errors): register PE DOS-signature and truncated IPS refusals and drop their per-command copies

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

* test(sqlite): drop the malformed-database provider test the conformance registry covers

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

* feat(errors)!: make failure_kind the identifier and derive code and retry from it

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

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

* test(sqlite): expect a malformed target for non-database bytes in the CLI suite

* fix(artifacts): keep changed-file short reads, invalid offsets and EOF declarations apart

PyInstaller reads inside the measured size, and .NET bundle manifest
refills, now raise read-coverage integrity on a zero-byte read instead of
truncated. A .NET bundle field and a Godot PCK directory entry that extend
past the file are truncated (with offset and extents) instead of
malformed. An absent or invalid ASAR packed offset is malformed; only a
valid range past the archive is truncated. The .NET manifest string
offset is reported in file coordinates.

* fix(pwntools): report a short ELF header as a truncated target

The layout and recorded-crash workers raise a distinct truncated reason
when the file ends inside the ELF identification or header, and the
decoder projects it as failure_kind truncated instead of inferring it
from the message.

* fix(artifacts): verify the carrier before blaming a short read on the bytes

The NTFS $MFT decoder, positional members (FIT, uImage, Bun, Deno) and
.NET bundle members now re-verify the source before reporting a short
stream as malformed, so a file that changed during the read reports the
change. The truncation site builds the model's measured extent.

* docs(android): name unsupported_target for truncated boot image structures

* fix(errors)!: report a target that changed during the read as failure_kind changed

Inventory integrity failures whose check means the target moved under the
read (container, member and unpacked-entry identity, read coverage,
traversal coverage) now take the model's changed projection: code
artifact_changed, retry backoff and details.failure_kind changed. A
selected target that no longer matches the one the session admitted gets
its own admitted-identity check and keeps its reopen recovery.

BREAKING CHANGE: inventory_artifact, inspect_artifact, extract_artifact and
the other inventory operations report a target that changed during the
read as artifact_changed (retryable, failure_kind changed) instead of
artifact_operation_failed. Admission-identity refusals report
integrity_check admitted-identity instead of container-identity.

* test(artifacts): expect admitted-identity for selections replaced before admission

A selected source replaced before admission fails the admitted-identity check rather than container-identity since the changed/admitted split.

* test(go): name the fixture and result when an MZ carrier is not refused through MCP

* test(verify): expect target failures for damaged ELF, core and EVM inputs in real-provider verifiers

The binary-layout, recorded-crash and EVM verifiers still expected invalid_input for malformed or truncated selected bytes. The pwntools and EVM adapters now report those as unsupported_target with failure_kind; a missing path remains invalid_input.

* test(web): expect the partial code for a refused source-map admission

The limit-cut code is partial; this Windows-lane test arrived from main with the old truncated spelling.

* test(errors): check the MCP target failure as the text clients receive

The stdio transport removes the private structured carrier from every isError result, so the conformance suite asserted a field that never reaches clients and failed every case. The projected diagnostic is checked from the JSON text instead.

* test(artifacts): expect artifact_changed when selected bytes change after inventory

Bundle resources replaced after open and unselected JavaScript sources rewritten after inventory now fail a change check, so they report artifact_changed with retry backoff rather than artifact_operation_failed.

* fix(errors): report a session digest mismatch as admitted-identity

The digest the session admitted does not change when the same request is
repeated, so targetDigestChangedFailure was inviting a backoff retry that
fails the same way. It now names admitted-identity, which stays
artifact_operation_failed and not retryable, and tells the caller to reopen.

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

* fix(artifacts): classify unused PyInstaller compressed input as layout

zlib stops at the first complete stream, so a declared span that arrives
intact but is not fully consumed is trailing junk or a second stream, not
a file that changed. A source that ends before that span stays read-coverage.
The cached-carrier test replaces the file with a different size so a shared
timestamp cannot hide the rewrite.

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

* test(applications): expect unsupported_target for a damaged trace stream

A trace member whose CRC fails is a malformed zip target. The partial
Evidence assertion now checks that code, failure_kind and format.

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

* test(dylib): expect admitted-identity when the opened target is replaced

The session keeps the digest it admitted, so replacing the executable and
repeating trace_dylib_resolution is not a retryable container change.

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-11-24 21:54:08 -05:00
ShuaixinHuang a9e34a4aae fix(ci): bound browser runtime fixture source readiness (#14364) 2026-11-24 11:48:06 -05:00
morluto a85859e147 feat(pe): inspect x64 exception-directory function ranges (#14254)
* feat(pe): inspect x64 exception-directory function ranges

Add inspect_pe_unwind_ranges, a provider-free reader of the PE32+
exception directory (.pdata). It reports each RUNTIME_FUNCTION's begin,
end and unwind RVAs, whether the entry starts a function or is a chained
fragment (UNW_FLAG_CHAININFO or an indirect unwind RVA), the chain's
parent and primary entry, and empty, unsorted, overlapping, unmapped or
unresolvable entries as explicit issues. Counts cover every entry while
kind, offset and limit select the page.

It reads headers through the shared PE image owner without changing its
admission. Failures use the existing PE failure projection.

Refs #14181

* chore(pe): record the unwind-ranges advertised schema and cursor skill

* fix(pe): index chain parents, map the whole exception directory and keep high RVAs unsigned

An unsorted table looked up every chain parent with a linear scan, and
chain resolution did not yield, so a crafted table could stall the
server. Parents are now found through one begin-RVA order and the pass
yields to cancellation. The file-backed check covers every declared
directory byte, including trailing bytes, and clearing the indirect bit
keeps RVAs at or above 0x80000000 unsigned.

* fix(pe): bound unwind reads and report unreadable codes, mismatched parents and unsorted overlaps

Unwind data is visited in ascending RVA order, so the windowed reader
moves forward and reads each region about once whatever the table order.
A primary entry whose declared code array leaves the file-backed bytes
is unknown (unwind_codes_unmapped), and its header facts are kept. A
chain parent must match the whole RUNTIME_FUNCTION; an entry with the
same begin but another end or unwind RVA is chain_parent_mismatch.
Order and overlap are checked separately. The guide moves under
docs/guides/native, and its route is unchanged.

* fix(pe): index whole RUNTIME_FUNCTION records for chain parents

Entries sharing a begin RVA were scanned for every parent lookup. The
table is now ordered once by (begin, end, unwind), and a parent is a
binary search for the exact record, with a second search for a begin
mismatch.

* test(pe): register the unwind-ranges provider lifecycle coverage

The provider lifecycle registry needs one entry per provider id. Add
rea-pe-unwind-ranges with its public CLI/MCP workflow and a typed
resource and cancellation failure test.

* test(cli): record inspect-pe-unwind-ranges in the completion goldens

* fix(pe): keep a verified unwind report through cleanup failure and check the directory before its allowance

A report completed before final close failed was replaced by the file
hash. The provider now records the verified report and the shared PE
failure projection retains it, as the ELF readers do. The entry
allowance now applies only after the directory is shown file-backed, so
an oversized count that leaves the file is a malformed target.

* chore(pe): register the exception-directory entry allowance as a pending fixed ceiling
2026-11-24 16:11:50 +00:00
67a1e2c937 feat(browser)!: size inspect_web_page delivery and page captures by section (#14368)
* feat(browser)!: size inspect_web_page delivery and page captures by section

inspect_web_page returned the complete capture inline with no detail
choice. A local page with 2,000 list rows, 200 buttons and three bundled
libraries produced a 4.6 MB MCP result, mostly 6,423 DOM nodes and 10,614
accessibility nodes.

inspect_web_page now declares the size-aware detail. Omitted, a capture
up to 32 KiB is inline and a larger one is retained behind a summary of
its small sections and counts. A new web-page view pages dom (node_names),
accessibility (roles), console (types), network (methods), scripts and
resources. The shared Evidence handler applies the same size decision as
the other size-aware tools and keeps detail out of the capture parameters.

BREAKING CHANGE: an MCP inspect_web_page call that omits detail on a
capture above 32 KiB now returns the retained summary. Pass
detail: "complete" for the previous shape, for example before
compare_web_captures.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(cli): deliver inspect-web-page summaries through the Evidence bundle

The contract's size-aware detail also generated a --detail option for
rea inspect-web-page, but the command ignored it and always printed the
complete capture. The command now uses the shared CLI Evidence delivery,
as analyze-web-bundle does: omitted or complete detail prints the
capture, and --detail summary requires --evidence_output and prints the
summary with the bundle receipt.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(browser): bound web-page summaries and keep capture context on pages

Review found three gaps in the new web-page view:
- pages dropped the capture's completeness and the section's context, so
  an empty accessibility page looked like an exhausted one;
- script rows carried their complete captured source, so one large
  bundle could not be paged;
- the summary copied every frame and worker.

Every page now carries the capture's completeness and its section's own
context beside the page coverage. Script rows keep source metadata
without text, and a script-source collection pages one script's text by
UTF-16 offset. The summary counts frames and workers, which page through
their own collections.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* test(browser): request complete captures in the real-browser verifiers

The metadata-budget, URL userinfo, DOM destination and script export
verifiers read the complete inspect_web_page capture through MCP. With
size-aware delivery, an omitted detail above 32 KiB returns the summary,
and the metadata-budget verifier failed reading scripts.items from it.
These calls now request detail complete; their CLI calls already return
the complete capture.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

---------

Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com>
Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-24 10:08:21 -05:00
0b51ca03de feat(ghidra): open M-profile raw images at a separate load base (#7951)
* test(raw): pin raw-binary admission and identity

Record what raw-binary loads produce today, so a later change to how the
load is represented has to keep it:

- every admission result and pairing message over a grid of
  architectures, entry spellings and file sizes;
- the analysis profile digest for each raw family;
- the snapshot target and query identity of a raw ARM load;
- the complete raw-binary load image for the ARM fixture.

The values were computed at d6f88becd without changing production code.

* refactor(raw): carry the raw load selection as one admitted value

The caller's raw load selection (format, architecture and entry_point)
travelled as three loose optional fields through about ten layers:
CLI flags, MCP open, direct analysis (five call sites), the session
port and open options, and target resolution. Every new load input had
to be threaded through each of them. The CLI and MCP boundaries now
build one NativeLoadSelection, and target admission is its only reader.

Admission now returns one RawBinaryLoad, carried on the raw target as
rawLoad. It names the base address of file offset 0 and the entry
separately. Before, the provider client, the load-image attestation,
the analysis profile and the snapshot target each read the entry and
assumed it was also the base. Admission still sets the base to the
entry, so nothing a caller sees changes.

No contract or behaviour change. The tests pinned in the previous
commit pass unchanged: the admission and pairing result grids, the
per-family profile digests, the raw snapshot target and query id, and
the complete raw load image. Tests that build raw targets use the new
rawLoadAtEntry fixture.

* feat(raw): state the M-profile raw load contract

Record provisional decision D1 (#4246) as code before implementing it,
so maintainers can confirm or redirect the contract cheaply.

- src/domain/rawArchitectureVariant.ts owns the variant vocabulary:
  armv6-m, armv7-m, armv7e-m, armv8-m.base and armv8-m.main, each an ARM
  M profile with Thumb-only code and an M-profile vector table. It also
  owns the closed sets that persisted entries use: isa_mode, role (the
  entry's function: entry or reset) and basis (how REA chose it: caller
  or vector-table).
- GHIDRA_RAW_VARIANT_LANGUAGES maps them to ARM:LE:32:Cortex and, for
  v8-M, ARM:LE:32:v8-m, which has the v8-M encodings Cortex lacks. This
  follows the GNU architecture names in Ghidra 12.1.4's ARM.ldefs.
  Provider language ids stay out of the domain.
- CLI and MCP gain architecture_variant, and with it base_address and
  vector_table_address; the open_binary description explains them.
  Narrow first: a separate base is accepted only with a variant, the one
  lane verified with it. The pairing check names the input to correct,
  so MCP error paths come from one owner, and
  rawBinaryVariantSelectionIssue owns the rules for the new inputs.
  Legacy pairing messages and paths are unchanged and pinned.
- Raw target summaries gain optional base_address, architecture_variant
  and vector_table_address. The load-image union gains the versioned
  segments shape (version 1): one file-backed segment, entries with
  address, isa_mode, role and basis, and, when the basis is the vector
  table, the table address with the two words read from it.
- docs/raw-binary.md describes the inputs and Evidence, and two levels
  of identity: coordinates from resolved values only, sessions and
  snapshots also from the provenance that results report. It keeps the
  decision record, which includes not applying Ghidra's
  processor-defined labels to variant loads.
- Tests are generated from the tables: pairing per variant and family,
  the Ghidra binding per variant, and the docs table and the skill
  reference's variant names against the tables. The persisted variant
  names are pinned.

Admission refuses the new inputs until the following commits implement
them. The base_address input follows #4927 by Jean Granié.

* feat(raw): admit M-profile loads at a separate base

Raw admission now implements the D1 inputs:

- architecture_variant must match the family. Its code runs in Thumb
  state, so an even entry is accepted where generic ARM needs 4-byte
  alignment. An odd entry is refused as a Thumb interworking address.
  The error diagnostics give the even code_address and suggest omitting
  entry_point, so the caller's value is never silently changed. An odd
  generic ARM entry keeps its earlier reason and gains a hint to use
  the M-profile inputs.
- With a variant, base_address maps file offset 0. The entry must lie
  inside the mapped image, and the address width is measured from the
  base.
- With a variant and a base but no entry_point, admission asks the
  resolver to read the first two words of the vector table. It reads
  them at vector_table_address, or at the base when that is omitted.
  Word 1 must be odd and point inside the image; the entry is that word
  with bit 0 cleared. Word 0, the initial stack pointer, is recorded as
  observed and not validated.

Admission applies the same rawBinaryVariantSelectionIssue rules as the
pairing check, so CLI and MCP refuse the same selections in the same
words.

RawBinaryLoad records the variant, the entry's instruction set, and
whether the entry was the caller's or read from a vector table. It keeps
canonical values only: caller spellings are not facts about the load,
and a session reused across spellings must report the same load. The
grid pin is recomputed at d6f88becd without the spelling and is
otherwise unchanged. isLegacyRawLoad decides legacy equivalence on
resolved values. Target summaries report base_address,
architecture_variant and vector_table_address only for loads that are
not legacy-equivalent. The load_selection_rejected recovery now lists
the new inputs.

* feat(raw): give M-profile loads a versioned identity

rawLoadIdentity is the one identity function for raw loads. A
legacy-equivalent load has no new identity, so its analysis profile,
coordinate context, snapshot target and query ids stay exactly as
before; the pinned digests prove it.

Any other load gets raw_load (version 1), built from canonical resolved
values: the base, the variant, the vector table that Reset was read
from, and the entry's address, instruction set, role and basis. The
role names the entry's function (entry or reset); the basis records how
REA chose it (caller or vector-table). Every load fact that summaries
and Evidence report is in it, provenance included, so a reused session
never reports what the current request did not choose. Spellings are
excluded, so another base spelling, or an explicit vector table at the
default location, reuses the same session. Absent values are omitted,
as in the summaries and Evidence.

- The snapshot target gains optional raw_load, compared canonically.
  Older snapshots have none and keep matching legacy loads.
- The Ghidra profile commits raw_load, base_address, the variant's
  language, the Thumb entry context, processor_labels not-applied-v1
  and load_image_evidence independent-raw-segments-v1.
- The function coordinate context covers resolved values only. Beside
  the language and entry it already covers, it gains base_address and
  the entry's decode context. Analyses that differ only in role, basis,
  vector table or a variant with the same decoder stay comparable: a
  caller-named entry and Reset at one address share a coordinate
  context while their sessions stay separate.
- The persisted variant names are pinned in raw_load.

* feat(ghidra): open M-profile loads at their base in Thumb state

The Ghidra raw lane now reads the committed load instead of assuming
that the base is the entry:

- The decoder comes from the variant (ARM:LE:32:Cortex or v8-m);
  generic ARM keeps ARM:LE:32:v7.
- BinaryLoader maps the file at the base. A variant load is imported
  with -loader-applyLabels false: ARMCortex.pspec names the vector table
  at ram:0x0-0x40 and marks every handler slot an entry, reserved slots
  included, which at base 0 would cover the image and the code after
  the table. Loads without a variant keep the language default.
- ReaGhidraPrepareRaw receives the base, the entry and the committed
  entry context. It requires the entry inside the file-backed block
  and, for Thumb, TMode=1 at the entry, and fails closed otherwise.
- The bridge descriptor carries entry_context_register. The bridge
  accepts only the registers GHIDRA_RAW_ENTRY_CONTEXT can commit, and a
  launcher test keeps the two equal. It reports that register in
  load-image observations, so it no longer needs to match a language
  string to know about TMode.
- Load-image attestation keeps the raw-binary image unchanged for
  legacy-equivalent loads; the pinned digest proves it. Other loads get
  the segments image (version 1): one file-backed segment at the base,
  the entry with its isa_mode, role and basis, the vector table address
  and both words read from it when Reset was derived, an
  entry_context.TMode check, and a check that the committed entry is
  the only external entry. Spellings of the same load give the same
  image, so a reused session reports what the current request would.
- Raw limitations are derived from the load. Legacy wording is kept,
  except the claim that Cortex-M is unsupported.

The base and entry separation in the prepare script, the TMode check
and the entry-context attestation follow #4927.

Co-authored-by: jgranie <78536786+jgranie@users.noreply.github.com>

* test(raw): check saved raw snapshots and schemas stay compatible

The segments load image is the first persisted shape these inputs add,
so this commit adds the historical-snapshot and schema checks with it:

- A raw-binary snapshot written at d6f88becd, before base_address,
  still parses. It matches the same load admitted today, and its
  load-image Evidence replays and equals what this version produces. An
  M-profile load of the same file does not match it.
- The earlier raw-binary Evidence schema rejects a segments image, so
  readers that predate it refuse the new shape instead of misreading
  it. An unknown segments version is rejected as well.
- The advertised inspect_native_load_image output accepts both the
  saved and the segments images. The advertised open_binary input
  accepts calls from before base_address beside the new inputs, and
  rejects variants outside the table.

* test(ghidra): verify M-profile raw loads against real Ghidra

Add npm run verify:ghidra:cortex-m, adapted from the #4927 verifier and
its Cortex-M0 fixture. It drives the compiled CLI and stdio MCP server
with source-owned images:

- the Cortex-M0 (armv6-m) image at bases 0x0 and 0x08000000, and after
  a 256-byte boot2-style header opened with vector_table_address;
- a Thumb-2 image (movw, movt, ldr.w, it, cbz) opened as armv7-m at 0x0
  and as armv7e-m at 0x08000000;
- an armv8-m.base image with movw, movt, cbz and udiv;
- an armv8-m.main image that sets MSPLIM, which only the v8-M decoder
  names.

LLVM is the independent oracle. The lane assembles each fixture's
annotated source for its triple, requires identical bytes, and requires
Ghidra to decode the same mnemonics in Thumb state. Mnemonics are
compared without width qualifiers (ldr.w) or the dot Ghidra puts before
an IT condition (mov.eq). The Cortex-M0 fill after its last return is
declared as data, so neither decoder counts it as code. The lane also
checks that Reset, read from the vector table, is the only entry Ghidra
reports, the segments load image and its TMode check, decompilation,
odd-entry refusal with code_address while the session is kept, CLI/MCP
parity, unchanged legacy identity, refusal of a base without a variant,
snapshot reuse across base spellings and refusal across variants,
unchanged source bytes, and owned cleanup.

Only named settings reach REA, which fixes the #4927 review finding that
an exported REA_GHIDRA_LANGUAGE_ID broke the verifier.

Verified on Linux x86_64 (Debian 13) with Ghidra 12.1.4, OpenJDK
21.0.12 and LLVM 19.1.7; the oracle also runs with Apple LLVM 21. Not
run on macOS or Windows.

Co-authored-by: jgranie <78536786+jgranie@users.noreply.github.com>

* feat(raw): add the armv8.1-m.main variant

ARMv8.1-M Mainline, as in the Cortex-M55 and Cortex-M85, gets its own
architecture_variant row, decoded with ARM:LE:32:v8-m. Ghidra 12.1.4's
ARM.ldefs lists armv8.1-m.main as a GNU name of that language, and its
slaspec builds it with VERSION_8M. The next commit's real-Ghidra case
checks that it decodes ARMv8.1-M low-overhead loops and MVE.

Folding v8.1-M into armv8-m.main would use the same decoder but drop the
profile from identity, and splitting it out later would change identity
again. The decision record now says so.

The docs table, the skill reference and the pinned persisted names
follow the table. The refused-spelling test now uses armv8.1m.main, the
LLVM triple's spelling, since armv8.1-m.main is accepted.

* fix(ghidra): report Ghidra's ARMv8.1-M loop flow for armv8.1-m.main

On real Ghidra 12.1.4, the ARM:LE:32:v8-m decoder names the ARMv8.1-M
low-overhead-loop branches correctly but gets their flow wrong. In the
Cortex-M55 image the next commit verifies:

- WLS at 0x46 branched to 0x5a, 2 bytes short of its target 0x5c and
  inside the LE instruction;
- LE at 0x58 branched unconditionally to 0x4e, 4 bytes past the loop
  start 0x4a, with no fall-through.

So the code after the loop was never disassembled, and a function with
such a loop is cut short. Results of armv8.1-m.main sessions now carry
that limitation, and the raw-binary docs state it, instead of the claim
that the decoder handles the low-overhead loops. MVE loads, stores and
VCTP decode as LLVM decodes them.

* test(ghidra): verify an ARMv8.1-M image against real Ghidra

The cortex-m lane gains a Cortex-M55 image opened as armv8.1-m.main at
base 0x0: a WLS/LE low-overhead loop around the MVE instructions VLDRW,
VCTP and VSTRW. LLVM assembles it for thumbv8.1m.main with
-mcpu=cortex-m55 -mfloat-abi=hard, because clang 19 refuses MVE under
the default soft-float ABI. The oracle takes the CPU and float ABI from
the fixture.

Ghidra must decode each instruction it reaches with LLVM's mnemonic in
Thumb state, as in the other cases. A data type that gives only the
element size (Ghidra vldrw.32) matches one with signedness (LLVM
vldrw.u32); opposite signedness still fails. The lane now reports every
disagreement in one run instead of stopping at the first.

Ghidra 12.1.4 does not follow the loop's exits (see the previous
commit), so this case requires the pop after the loop to stay
undisassembled, records both loop branches' flow, and checks that the
results report the limitation. Base 0 also checks that the v8-m
decoder's vector table gets no processor labels.

Verified on Linux x86_64 (Debian 13) with Ghidra 12.1.4, OpenJDK
21.0.12 and LLVM 19.1.7: all eight cases pass. The oracle also runs with
Apple LLVM 21. Not run on macOS or Windows.

* refactor: name the variant vocabulary after architecture_variant

The variant table is no longer only for raw loads: the M-profile ELF
lane uses the same vocabulary. Its internal names now follow the public
input, architecture_variant, without an ARM M-profile prefix that would
need renaming again once other architectures get variants:

- src/domain/rawArchitectureVariant.ts becomes architectureVariant.ts,
  together with its test and the docs conformance test;
- RawArchitectureVariant, RAW_ARCHITECTURE_VARIANTS,
  RAW_ARCHITECTURE_VARIANT_NAMES, rawArchitectureVariantSchema and
  rawArchitectureVariantRow drop the raw prefix;
- GHIDRA_RAW_VARIANT_LANGUAGES becomes GHIDRA_VARIANT_LANGUAGES, and
  ghidraRawProcessorLabels becomes ghidraVariantProcessorLabels.

Identifiers only. Saved values, schemas, lane ids and the
processor_labels value are unchanged: the recorded catalog digests and
MCP catalog are byte-identical before and after, the pinned profile and
snapshot digests pass unchanged, and no snapshot fixture changes.

Names that mean the raw load keep theirs: RawBinaryLoad, rawLoad,
raw_load, and the vocabularies of its entries (RAW_ENTRY_ISA_MODES,
RawEntryIsaMode, RAW_ENTRY_ROLES and RAW_ENTRY_BASES).

* refactor(ghidra): keep variant decoder limitations beside the languages

The low-overhead-loop limitation lived in the raw-binary limitations, but
it describes Ghidra's ARM:LE:32:v8-m decoder for armv8.1-m.main whatever
container holds the code. The M-profile ELF lane maps ELF builds to the
same variants and must report the same text.

GHIDRA_VARIANT_LIMITATIONS now sits beside GHIDRA_VARIANT_LANGUAGES and
states the limitations of every variant, so adding a variant also
decides them. Raw results read it; their text and order are unchanged.

* fix(raw): require base_address with every architecture_variant

A variant without base_address mapped the image at its entry, and the
odd-entry suggestion led callers there: retrying with the even
code_address and no base mapped the vector table at Reset, and the
segments image still verified.

architecture_variant now requires base_address, the address of file
offset 0, and the odd-entry suggestion no longer offers a retry without
a base. A code fragment that starts at its entry passes that address as
its base. Loads without a variant are unchanged.

* fix(raw): align vector tables as VTOR does and refuse Reset inside them

VTOR.TBLOFF holds address bits 31:7 wherever VTOR exists (ARMv6-M with
VTOR, ARMv7-M, ARMv8-M), so a vector table is at least 128-byte
aligned. Admission accepted any 4-byte-aligned table, so naming the
Reset slot (0x10000104) instead of the table (0x10000100) read NMI as
Reset and reported it with role reset. A named table and the default at
the base now need 128-byte alignment.

A Reset word that points into the 8 table bytes just read is refused
too. Even, outside and inside Reset words stay load_selection_rejected,
with the observed words as diagnostics: a raw dump has no format they
can violate, and the usual cause is a wrong base, table or variant.

* fix(ghidra): key variant coordinates by base, not entry

A variant load maps file offset 0 at base_address, so with the decoder
and the entry's decode context the base fixes every coordinate. The
coordinate context still held the entry address, so functions found
from two entries of one image did not compare.

Variant coordinate contexts now take the base from the admitted load
and leave the entry out. Variant profiles commit raw_load without flat
entry_point and base_address copies of it; entry_context stays as
Ghidra's seeding commitment, which raw_load does not record. Legacy
profiles keep their parameters and digests.

* refactor(raw): discriminate the segments load image by layout

The segments load image named its shape with variant: "segments", beside
architecture_variant, which names the decoder. It is now
layout: "segments", as layout names data shapes elsewhere in REA. The
shape is unreleased, so no saved Evidence uses the old key.

* docs(raw): record why vector-table words keep their full width

vector_table.initial_stack_pointer and reset_vector are words read from
the table, not addresses: REA reports format words such as GPU
code-object flags and metadata tokens as full-width hex, and the entry
already holds Reset's canonical code address. The schema, admission and
raw-binary guide now say so.

* docs(raw): record why the seeded entry function is named entry

Ghidra names the function REA seeds at a raw entry entry, whatever the
entry's role, as its loaders name a program entry. The load image
reports the role; naming the function after it, as CMSIS Reset_Handler,
would claim a symbol the image does not carry. The prepare script and
the decision record now say so.

* fix(raw): name the refused load input in error details

Raw admission refused a pairing with the rule's message but dropped the
field it named, so callers had to read the input to correct from prose.
Each raw admission refusal now names the input to blame, and
BinaryTargetError projects it as details.field on the CLI and MCP; the
Reset-word refusals and a file too short for a table at its base name
none. Pairing refusals from the target resolver keep their field too.

MCP refuses invalid pairings in the open_binary input schema before
admission; that error reports path [] as it does on main and is left
unchanged here.

* docs(raw): state that results keep no caller spellings yet

The raw_load identity comment claimed Evidence parameters keep the
caller's spellings of the load inputs. They do not: summaries, Evidence
and snapshots report canonical addresses only, as legacy entry_point did
before these inputs. The comment and the raw-binary guide now say so,
and the decision record names the gap and the caller_input_path pattern
that could close it additively.

* docs(raw): explain why reused sessions cannot report stale vector words

raw_load leaves the two vector-table words out, yet results report
them. They cannot go stale: sessions and snapshots also match the file
digest, and with the base and the table address it fixes the bytes the
words are read from. The identity comment and the raw-binary guide now
say so.

* docs(raw): scope architecture_variant to the ARM M profiles

The generic raw-language limitation listed 68020, ColdFire and other
"processor variants" as unsupported, which read as future
architecture_variant values. It now says those languages are not
offered and that architecture_variant names only ARM M profiles.

The variant table and the decision record also state the scope: the
base requirement, Reset derivation and label policy hold for every row
because every row is an M profile, and a variant of another family
would first make them per-row properties.

* docs(raw): state each load pairing rule once in open_binary

open_binary said that architecture_variant requires base_address, and
that entry_point may then be omitted, in its tool description and again
in three field descriptions; the default compact input profile
advertises all of them. Each rule now sits on the field it constrains,
and the tool description points to the M-profile lane in one sentence.
CLI flag help follows the same split.

Measured from tools/list of a server built from this source, the trim
saves 237 bytes of open_binary in each input-schema profile.

* refactor(ghidra): let session limitations own the variant load facts

A segments load image restated that only the file is mapped, that
processor labels are not applied and where Reset came from, beside the
session limitations that every result, the load image included, already
carries. The load image now states only what its verification covers
and requires; the session limitations are the one owner of the load
facts.

* refactor(ghidra): launch with the label policy the profile committed

The Ghidra client recomputed the processor-label policy from the
target's variant instead of reading the processor_labels value the
analysis profile commits, so the launch and the profile each held their
own copy of the rule. The client now reads the committed value, named
once as GHIDRA_PROCESSOR_LABELS_NOT_APPLIED, and a behavior test checks
that a variant profile reaches the launcher without labels.

* refactor(raw): let the vector-table read carry its length

Admission and the target resolver each knew that the vector table read
is 8 bytes: the resolver passed a literal 8 and admission checked one.
RawBinaryVectorTableRead now carries byteLength beside fileOffset, and
admission derives its bounds, inside-table check and message from one
constant.

* test(raw): compare saved raw images by their facts, not their prose

The compatibility test required a snapshot saved before base_address to
equal today's raw load image exactly, limitation text included, so any
rewording of a limitation would fail it although no fact changed. It
now compares every field except limitations.

* test(ghidra): expect not-in-listing where the Cortex-M lane stops

Since #7823, Ghidra reports an address in memory with no listed
instruction or data as not-in-listing instead of undecodable. The
Cortex-M55 case expects the pop after its low-overhead loop to stay
undisassembled, so the lane now expects not-in-listing there.

* test(raw): pin raw identity to main after its instruction-status revision

#7823 commits instruction_status in every Ghidra profile, so the legacy
raw digests pinned at d6f88becd and the variant digest changed, and the
snapshot saved before base_address no longer replays on main either.
The legacy pins now hold main's own digests at 07dfd1261, computed
without these inputs; the merged branch matches them for all six
families. The variant digest is re-pinned.

The compatibility test now checks that the saved snapshot keeps its
target, that its profile differs from today's only by instruction_status,
and that its load-image facts equal today's. The raw-binary guide states
replay relative to REA without these inputs.

* test(ghidra): own the Cortex-M lane's LLVM and CLI commands

The lane's LLVM oracle ran clang and llvm-objdump through execFile with
no deadline, and its CLI parity launch used execFile directly, so a
hung tool could stall the lane and a killed one could leave children
behind. All three now run through createVerifierCommands, the owner
that stops each process tree, with a 120-second deadline for LLVM and
240 seconds for the CLI, as the ESP image verifier does.

The oracle writes under the lane's workspace instead of its own
temporary directory, and the lane closes the owner before removing that
workspace; a failed close keeps it for inspection.

* test(raw): derive the Reset fixtures from one Thumb image

The segments tests verified a Reset load admitted for 16 bytes, with
vector words supplied separately, against the 4-byte ARM fixture, so
the image they called verified held neither the table nor the entry at
0x8000008. fixtureRawBinaryLoadImage now takes the image bytes and the
load and derives the digest, size, mapping, entry and bound language
from them; its defaults keep the legacy fixture unchanged.

The Thumb tests and the compatibility test's segments image use the
Cortex-M0 image the real lane verifies, admit Reset from its own first
eight bytes, and name a caller entry at its add_three function. A
declaration file lets TypeScript tests import that fixture.

* docs(raw-binary): say that recording load spellings would not be additive

The Evidence envelope is strict, so a later field that keeps a load
selection's spellings would make records that REA versions without it
refuse, as caller_input_path did. The guide called that change additive.

* docs(raw-binary): tell callers how to keep their load spellings

Results report canonical addresses, and an omitted vector_table_address
reads as one at the base. A caller that needs its exact spelling keeps
its own request beside the Evidence, with the record's evidence_id: the
raw-binary guide says so for people, and the skill's raw-image paragraph
for agents, loaded only when an agent opens that reference.

* test(ghidra): keep raw digests at main's byte-search and data-type revisions

* test(domain): check raw-binary refusal facts, not sentences

The new variant and raw-binary refusal tests compared whole explanations.
They now check the rejected field, constraint and diagnostics exactly, and
match the parameter names and addresses each reason must state as whole
tokens through tests/support/statingFacts.ts. Rewording a refusal passes;
dropping its mapped range fails. The admission and pairing grids stay
digests of results computed on main before this change.

* docs(adr): move the M-profile raw load decision into an ADR

The raw binary guide held decision D1 inline. Record it under
docs/adr/firmware/ with Nygard sections and Proposed status, index it,
and link it from the guide.

* test(ghidra): repin digests and replay for main's call-coverage revision

main's #8340 bumps call_relationship_coverage from v5 to v7, which changes
every Ghidra profile digest. Repin the raw digests this branch owns, and set
the revision aside in the replay test of the snapshot saved before
base_address, like the other upstream revisions it lists. With the revision
reverted in place, the old pins hold; only main's own two pins, which assert
v7, then fail.

* chore(plugin): regenerate the skill bundle from the authored skill

* test(raw): keep the target route diagnostics within the function length limit

* docs(raw): record the M-profile lane on Ghidra 12.2

* refactor(raw): read vector words and own the Cortex-M workspace through their shared owners

Main's architecture guards require BinaryReader for numeric reads and VerifierFixture for verifier fixture roots.

* fix(raw): name raw-binary as the format of vector-table read failures

* fix(verify): remove the Cortex-M workspace after a verified run

closeEarly stops the command owner but keeps the root, so every successful
run left its fixtures, snapshots and LLVM outputs behind while reporting
cleanup complete. Release the workspace once process lineage is verified; a
failed run still keeps it for diagnosis.

* chore(verify): record open_binary's input schema with the M-profile load fields

CI's package build compares the committed advertised-schema summaries with
the packaged catalog; regenerated with
`node scripts/verify-advertised-schemas.mjs --update-summary`.

* test(cli): expect open_binary's M-profile load flags in the CLI command table

Main's command-table test (#11777) pins the flag of each open_binary field
a direct-analysis command takes; D1 adds --architecture-variant,
--base-address and --vector-table-address.

* test(cli): record the CLI help goldens with the M-profile load flags

Commands that open a target list open_binary's options; D1 adds
--architecture-variant, --base-address and --vector-table-address.
Recorded with REA_RECORD_CLI_PARITY=1 from the built CLI.

* docs(raw-binary): qualify snapshot replay under the producer rule

A load without the M-profile inputs keeps its analysis profile inputs,
snapshot target and load image, but every analysis profile also commits
to the REA release and packaged bridge scripts. A snapshot saved by an
earlier release is therefore refused after an upgrade either way. Say
so, and point to the Ghidra guide's producer rule.

* test(ghidra): report why Cortex-M verifier cleanup could not be checked

The verifier compared the completed lineage's status and descendants
directly, so an unavailable lineage failed as a bare equality without
its reason. Use the shared assertVerifierCleanupComplete, which names
the reason, as docs/development/testing.md requires.

* fix(domain): compare raw-load functions by coordinates, not entry provenance

compare_functions and build_call_path required equal target identity,
which for a non-legacy raw load includes the entry's address, role and
basis and the vector table it was read from. Two loads of the same image
at the same base, one with Reset read from the vector table and one with
a caller-named entry, therefore stopped comparing, although their
function coordinate contexts match and the raw-binary guide says they
compare.

targetIdentity now owns sameTargetCoordinates, which keeps a raw load's
base and variant and leaves out how it chose its entry; a legacy load
still places addresses by its entry. Both comparison workflows use it.
Session, snapshot and Evidence subject matching keep the full identity.

* fix(domain): align coordinateKey canonicalization and target diagnostics with main

---------

Co-authored-by: jgranie <78536786+jgranie@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-24 14:41:19 +00:00
dependabot[bot]andVincent Koc 029ad60f4f chore(deps): update 37 npm pins and preserve capture and release behavior (#14231)
* chore(deps): bump the npm-minor-and-patch group across 2 directories with 38 updates

Bumps the npm-minor-and-patch group with 37 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [@babel/parser](https://github.com/babel/babel/tree/HEAD/packages/babel-parser) | `8.0.4` | `8.1.2` |
| [@babel/types](https://github.com/babel/babel/tree/HEAD/packages/babel-types) | `8.0.4` | `8.1.2` |
| [@bufbuild/protobuf](https://github.com/bufbuild/protobuf-es/tree/HEAD/packages/protobuf) | `2.16.0` | `2.17.0` |
| [@clack/prompts](https://github.com/bombshell-dev/clack/tree/HEAD/packages/prompts) | `1.7.0` | `1.9.0` |
| [@zip.js/zip.js](https://github.com/gildas-lormeau/zip.js) | `2.15.0` | `2.25.0` |
| [evmole](https://github.com/cdump/evmole/tree/HEAD/javascript) | `0.9.3` | `0.9.4` |
| [ignore](https://github.com/kaelzhang/node-ignore) | `7.0.6` | `7.0.14` |
| [isomorphic-git](https://github.com/isomorphic-git/isomorphic-git) | `1.38.7` | `1.44.15` |
| [lossless-json](https://github.com/josdejong/lossless-json) | `4.3.1` | `4.3.3` |
| [parse5](https://github.com/inikulin/parse5) | `8.0.1` | `8.1.1` |
| [playwright-core](https://github.com/microsoft/playwright) | `1.64.1` | `1.65.1` |
| [plist](https://github.com/TooTallNate/plist.js) | `5.0.0` | `5.1.1` |
| [semver](https://github.com/npm/node-semver) | `7.8.5` | `7.8.6` |
| [@types/semver](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/semver) | `7.7.1` | `7.8.0` |
| [smol-toml](https://github.com/squirrelchat/smol-toml) | `1.9.0` | `1.9.1` |
| [stream-chain](https://github.com/uhop/stream-chain) | `4.2.6` | `4.4.2` |
| [stream-json](https://github.com/uhop/stream-json) | `3.7.0` | `3.9.0` |
| [ws](https://github.com/websockets/ws) | `8.21.0` | `8.23.0` |
| [@types/ws](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/ws) | `8.18.1` | `8.18.2` |
| [yaml](https://github.com/eemeli/yaml) | `2.9.0` | `2.9.1` |
| [zod](https://github.com/colinhacks/zod) | `4.6.6` | `4.6.7` |
| [@electron/asar](https://github.com/electron/asar) | `4.2.0` | `4.3.2` |
| [@stryker-mutator/core](https://github.com/stryker-mutator/stryker-js/tree/HEAD/packages/core) | `10.0.0` | `10.1.1` |
| [@stryker-mutator/typescript-checker](https://github.com/stryker-mutator/stryker-js/tree/HEAD/packages/typescript-checker) | `10.0.0` | `10.1.1` |
| [@stryker-mutator/vitest-runner](https://github.com/stryker-mutator/stryker-js/tree/HEAD/packages/vitest-runner) | `10.0.0` | `10.1.1` |
| [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `26.6.4` | `26.6.6` |
| [@types/semver](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/semver) | `7.7.1` | `7.8.0` |
| [@types/ws](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/ws) | `8.18.1` | `8.18.2` |
| [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) | `5.0.3` | `5.1.0` |
| [jscpd](https://github.com/kucherenko/jscpd/tree/HEAD/rust/jscpd) | `5.0.12` | `5.4.3` |
| [knip](https://github.com/webpro-nl/knip/tree/HEAD/packages/knip) | `6.39.0` | `6.45.1` |
| [oxfmt](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxfmt) | `0.72.0` | `0.79.0` |
| [oxlint](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint) | `1.87.0` | `1.94.0` |
| [oxlint-tsgolint](https://github.com/oxc-project/tsgolint) | `7.0.2005` | `7.0.2007` |
| [release-please](https://github.com/googleapis/release-please) | `17.3.0` | `17.11.2` |
| [rolldown](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.12` | `1.3.2` |
| [turbo](https://github.com/vercel/turborepo) | `2.11.7` | `2.11.11` |
| [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) | `5.0.3` | `5.1.0` |
| [frida](https://github.com/frida/frida-node) | `17.23.2` | `17.26.4` |

Bumps the npm-minor-and-patch group with 1 update in the /scripts/verify-tools/skills directory: [skills](https://github.com/vercel-labs/skills).


Updates `@babel/parser` from 8.0.4 to 8.1.2
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v8.1.2/packages/babel-parser)

Updates `@babel/types` from 8.0.4 to 8.1.2
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v8.1.2/packages/babel-types)

Updates `@bufbuild/protobuf` from 2.16.0 to 2.17.0
- [Release notes](https://github.com/bufbuild/protobuf-es/releases)
- [Commits](https://github.com/bufbuild/protobuf-es/commits/v2.17.0/packages/protobuf)

Updates `@clack/prompts` from 1.7.0 to 1.9.0
- [Release notes](https://github.com/bombshell-dev/clack/releases)
- [Changelog](https://github.com/bombshell-dev/clack/blob/main/packages/prompts/CHANGELOG.md)
- [Commits](https://github.com/bombshell-dev/clack/commits/@clack/prompts@1.9.0/packages/prompts)

Updates `@zip.js/zip.js` from 2.15.0 to 2.25.0
- [Release notes](https://github.com/gildas-lormeau/zip.js/releases)
- [Commits](https://github.com/gildas-lormeau/zip.js/compare/v2.15.0...v2.25.0)

Updates `evmole` from 0.9.3 to 0.9.4
- [Release notes](https://github.com/cdump/evmole/releases)
- [Commits](https://github.com/cdump/evmole/commits/0.9.4/javascript)

Updates `ignore` from 7.0.6 to 7.0.14
- [Release notes](https://github.com/kaelzhang/node-ignore/releases)
- [Commits](https://github.com/kaelzhang/node-ignore/compare/7.0.6...7.0.14)

Updates `isomorphic-git` from 1.38.7 to 1.44.15
- [Release notes](https://github.com/isomorphic-git/isomorphic-git/releases)
- [Commits](https://github.com/isomorphic-git/isomorphic-git/compare/v1.38.7...v1.44.15)

Updates `lossless-json` from 4.3.1 to 4.3.3
- [Changelog](https://github.com/josdejong/lossless-json/blob/main/CHANGELOG.md)
- [Commits](https://github.com/josdejong/lossless-json/compare/v4.3.1...v4.3.3)

Updates `parse5` from 8.0.1 to 8.1.1
- [Release notes](https://github.com/inikulin/parse5/releases)
- [Commits](https://github.com/inikulin/parse5/compare/v8.0.1...v8.1.1)

Updates `playwright-core` from 1.64.1 to 1.65.1
- [Release notes](https://github.com/microsoft/playwright/releases)
- [Commits](https://github.com/microsoft/playwright/compare/v1.64.1...v1.65.1)

Updates `plist` from 5.0.0 to 5.1.1
- [Release notes](https://github.com/TooTallNate/plist.js/releases)
- [Changelog](https://github.com/TooTallNate/plist.js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TooTallNate/plist.js/compare/plist@5.0.0...plist@5.1.1)

Updates `semver` from 7.8.5 to 7.8.6
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v7.8.5...v7.8.6)

Updates `@types/semver` from 7.7.1 to 7.8.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/semver)

Updates `smol-toml` from 1.9.0 to 1.9.1
- [Release notes](https://github.com/squirrelchat/smol-toml/releases)
- [Commits](https://github.com/squirrelchat/smol-toml/compare/v1.9.0...v1.9.1)

Updates `stream-chain` from 4.2.6 to 4.4.2
- [Commits](https://github.com/uhop/stream-chain/compare/4.2.6...4.4.2)

Updates `stream-json` from 3.7.0 to 3.9.0
- [Commits](https://github.com/uhop/stream-json/compare/3.7.0...3.9.0)

Updates `ws` from 8.21.0 to 8.23.0
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.21.0...8.23.0)

Updates `@types/ws` from 8.18.1 to 8.18.2
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/ws)

Updates `yaml` from 2.9.0 to 2.9.1
- [Release notes](https://github.com/eemeli/yaml/releases)
- [Commits](https://github.com/eemeli/yaml/compare/v2.9.0...v2.9.1)

Updates `zod` from 4.6.6 to 4.6.7
- [Release notes](https://github.com/colinhacks/zod/releases)
- [Commits](https://github.com/colinhacks/zod/compare/v4.6.6...v4.6.7)

Updates `@electron/asar` from 4.2.0 to 4.3.2
- [Release notes](https://github.com/electron/asar/releases)
- [Changelog](https://github.com/electron/asar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/electron/asar/compare/v4.2.0...v4.3.2)

Updates `@stryker-mutator/core` from 10.0.0 to 10.1.1
- [Release notes](https://github.com/stryker-mutator/stryker-js/releases)
- [Changelog](https://github.com/stryker-mutator/stryker-js/blob/master/packages/core/CHANGELOG.md)
- [Commits](https://github.com/stryker-mutator/stryker-js/commits/v10.1.1/packages/core)

Updates `@stryker-mutator/typescript-checker` from 10.0.0 to 10.1.1
- [Release notes](https://github.com/stryker-mutator/stryker-js/releases)
- [Changelog](https://github.com/stryker-mutator/stryker-js/blob/master/packages/typescript-checker/CHANGELOG.md)
- [Commits](https://github.com/stryker-mutator/stryker-js/commits/v10.1.1/packages/typescript-checker)

Updates `@stryker-mutator/vitest-runner` from 10.0.0 to 10.1.1
- [Release notes](https://github.com/stryker-mutator/stryker-js/releases)
- [Changelog](https://github.com/stryker-mutator/stryker-js/blob/master/packages/vitest-runner/CHANGELOG.md)
- [Commits](https://github.com/stryker-mutator/stryker-js/commits/v10.1.1/packages/vitest-runner)

Updates `@types/node` from 26.6.4 to 26.6.6
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `@types/semver` from 7.7.1 to 7.8.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/semver)

Updates `@types/ws` from 8.18.1 to 8.18.2
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/ws)

Updates `@vitest/coverage-v8` from 5.0.3 to 5.1.0
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v5.1.0/packages/coverage-v8)

Updates `jscpd` from 5.0.12 to 5.4.3
- [Release notes](https://github.com/kucherenko/jscpd/releases)
- [Commits](https://github.com/kucherenko/jscpd/commits/v5.4.3/rust/jscpd)

Updates `knip` from 6.39.0 to 6.45.1
- [Release notes](https://github.com/webpro-nl/knip/releases)
- [Commits](https://github.com/webpro-nl/knip/commits/knip@6.45.1/packages/knip)

Updates `oxfmt` from 0.72.0 to 0.79.0
- [Release notes](https://github.com/oxc-project/oxc/releases)
- [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxfmt/CHANGELOG.md)
- [Commits](https://github.com/oxc-project/oxc/commits/oxfmt_v0.79.0/npm/oxfmt)

Updates `oxlint` from 1.87.0 to 1.94.0
- [Release notes](https://github.com/oxc-project/oxc/releases)
- [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxlint/CHANGELOG.md)
- [Commits](https://github.com/oxc-project/oxc/commits/oxlint_v1.94.0/npm/oxlint)

Updates `oxlint-tsgolint` from 7.0.2005 to 7.0.2007
- [Release notes](https://github.com/oxc-project/tsgolint/releases)
- [Commits](https://github.com/oxc-project/tsgolint/compare/v7.0.2005...v7.0.2007)

Updates `release-please` from 17.3.0 to 17.11.2
- [Release notes](https://github.com/googleapis/release-please/releases)
- [Changelog](https://github.com/googleapis/release-please/blob/main/CHANGELOG.md)
- [Commits](https://github.com/googleapis/release-please/compare/v17.3.0...v17.11.2)

Updates `rolldown` from 1.2.12 to 1.3.2
- [Release notes](https://github.com/rolldown/rolldown/releases)
- [Changelog](https://github.com/rolldown/rolldown/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rolldown/rolldown/commits/v1.3.2/packages/rolldown)

Updates `turbo` from 2.11.7 to 2.11.11
- [Release notes](https://github.com/vercel/turborepo/releases)
- [Changelog](https://github.com/vercel/turborepo/blob/main/RELEASE.md)
- [Commits](https://github.com/vercel/turborepo/compare/v2.11.7...v2.11.11)

Updates `vitest` from 5.0.3 to 5.1.0
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v5.1.0/packages/vitest)

Updates `frida` from 17.23.2 to 17.26.4
- [Commits](https://github.com/frida/frida-node/compare/17.23.2...17.26.4)

Updates `skills` from 1.7.2 to 1.9.0
- [Release notes](https://github.com/vercel-labs/skills/releases)
- [Commits](https://github.com/vercel-labs/skills/compare/v1.7.2...v1.9.0)

---
updated-dependencies:
- dependency-name: "@babel/parser"
  dependency-version: 8.1.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@babel/types"
  dependency-version: 8.1.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@bufbuild/protobuf"
  dependency-version: 2.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@clack/prompts"
  dependency-version: 1.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@electron/asar"
  dependency-version: 4.3.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@stryker-mutator/core"
  dependency-version: 10.1.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@stryker-mutator/typescript-checker"
  dependency-version: 10.1.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@stryker-mutator/vitest-runner"
  dependency-version: 10.1.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@types/node"
  dependency-version: 26.6.6
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: "@types/semver"
  dependency-version: 7.8.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@types/semver"
  dependency-version: 7.8.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@types/ws"
  dependency-version: 8.18.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: "@types/ws"
  dependency-version: 8.18.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: "@vitest/coverage-v8"
  dependency-version: 5.1.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@zip.js/zip.js"
  dependency-version: 2.25.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: evmole
  dependency-version: 0.9.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: frida
  dependency-version: 17.26.4
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: ignore
  dependency-version: 7.0.14
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: isomorphic-git
  dependency-version: 1.44.15
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: jscpd
  dependency-version: 5.4.3
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: knip
  dependency-version: 6.45.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: lossless-json
  dependency-version: 4.3.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: oxfmt
  dependency-version: 0.79.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: oxlint
  dependency-version: 1.94.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: oxlint-tsgolint
  dependency-version: 7.0.2007
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: parse5
  dependency-version: 8.1.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: playwright-core
  dependency-version: 1.65.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: plist
  dependency-version: 5.1.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: release-please
  dependency-version: 17.11.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: rolldown
  dependency-version: 1.3.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: semver
  dependency-version: 7.8.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: skills
  dependency-version: 1.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: smol-toml
  dependency-version: 1.9.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: stream-chain
  dependency-version: 4.4.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: stream-json
  dependency-version: 3.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: turbo
  dependency-version: 2.11.11
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: vitest
  dependency-version: 5.1.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: ws
  dependency-version: 8.23.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: yaml
  dependency-version: 2.9.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: zod
  dependency-version: 4.6.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(deps): adapt release tooling and capture metadata to the new npm pins

* fix(deps): preserve numeric, plist and archive evidence semantics

* test(zip): verify malformed compression with CRC checks enabled

* fix(capture): preserve exact decimal projections and redaction

* test(apple): verify keyed archive controls before altering the trailer

* test(lint): cover safe and suggested regex escape fixes

* fix(reference): preserve directory exclusion provenance with ignore 7

* docs(examples): refresh HAR evidence identities for the current decoder

* fix(reference): preserve metadata failures with strict Git ref reads

* chore(config): remove the unused MCP profile type alias

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-24 21:26:48 +08:00
dependabot[bot]andVincent Koc 417beaf3a5 fix(evidence): preserve saved identities with canonicalize 5 (#8132)
chore(deps): bump canonicalize from 3.0.0 to 5.1.0

Bumps [canonicalize](https://github.com/erdtman/canonicalize) from 3.0.0 to 5.1.0.
- [Release notes](https://github.com/erdtman/canonicalize/releases)
- [Commits](https://github.com/erdtman/canonicalize/compare/v3.0.0...v5.1.0)

---
updated-dependencies:
- dependency-name: canonicalize
  dependency-version: 5.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-24 20:54:13 +08:00
Vincent Koc 73f72c9cd6 refactor(build): share skill file enumeration across generators (#14339) 2026-11-24 10:26:59 +00:00
Vincent Koc 4f0d160254 refactor(tooling): share verifier fixture and lint helpers (#14318)
* refactor(tooling): share verifier fixture and lint helpers

* test(clients): retain tool messages in verifier model substitutes
2026-11-24 09:23:14 +00:00
morluto b565f787cb refactor(cli/server): break remaining module-layer cycles (#14013)
* refactor(cli,server): break remaining module-layer cycles

* fix(ci): follow relocated CLI entry points

* refactor: remove retired internal reader exports
2026-11-23 00:58:01 -05:00
morluto 88dfad5bb7 refactor: remove internal re-export shims and guard against new ones (#14009)
* refactor: remove internal re-export shims and guard against new ones

* fix(ci): catch namespace module re-exports
2026-11-23 00:47:47 -05:00
morluto a5d427a2d1 chore(guards): declare desktop build-computer entries and clear the entry baseline (#14011) 2026-11-23 00:43:38 -05:00
ashritandmorluto 3db9120c5e fix(ghidra): point to the LC_MAIN entry when a stripped Mach-O has no main symbol (#12966)
* fix(ghidra): derive the LC_MAIN entry address from bounded snapshot reads

* fix(ghidra): point to the LC_MAIN entry when a stripped Mach-O has no main symbol

* fix(ghidra): keep snapshot cleanup failures from the LC_MAIN hint read

* fix(ghidra): admit the LC_MAIN segment's file range before hinting

* fix(ghidra): give no LC_MAIN hint for an entry in a file-only segment

admitMachoSegmentCommand admits a segment with no VM size and no protection but marks it unmapped; it owns no analysis address, so the hint must not name one.

* fix(ghidra): confirm Mach-O entry retries against the function inventory

* fix(hopper): offer inventory recovery for unresolved selectors

* fix(ida): offer inventory recovery for missing procedures

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-22 14:14:21 +00:00
morluto 16732c6b72 fix(release): bind checkpoint references to frozen history (#13392) 2026-11-22 11:14:02 +00:00
morluto ac0dd6b371 fix(verification): isolate MCP package canaries from target settings (#13256) 2026-11-22 01:35:33 +00:00
morluto eacbd2522a fix(verification): distinguish MCP probe refusals from local deadlines (#13246) 2026-11-22 00:31:34 +00:00
morluto eba41afd6c fix(browser): retain passive coverage and failure identity (#13231) 2026-11-21 23:03:00 +00:00
morluto 39ccb1d3b8 fix(browser): preserve terminal verifier startup outcomes (#13228) 2026-11-21 22:45:18 +00:00
morluto ce5258043c test(docs): isolate README drift cases and remove duplicate checks 2026-11-21 08:49:29 -05:00
morluto d2a8b8d3d6 fix(docs): align translated READMEs and verify catalog links 2026-11-21 08:46:58 -05:00
6822ebe1f3 feat(ida): support the official Hex-Rays IDA MCP headlessly (#4813)
* feat(ida): support the official Hex-Rays IDA MCP headlessly

Hex-Rays IDA MCP serves database reads only through execute_python, so
REA rejected it as an upstream. A `hexrays` headless stdio registration
now leases a private idalib worker through open_database, answers the
existing database-supervisor reads with a fixed, packaged, read-only
query module, and releases the lease with close_database, verified by
list_databases.

Observations record execute_python, the query and the module digest.
Tool errors are typed so a completed rejection is distinguished from an
unknown outcome; an unconfirmed release is retried and a late lease on
the private input is adopted.

Validated IDA source and bridge tests, static checks, docs, and npm run
verify:ida on Linux x64 against x86-64 and AArch64 ELF fixtures.

* feat(ida): name the Hex-Rays registration for its catalog

A registration without `protocol` that reaches the official Hex-Rays
server failed with only the missing database-supervisor tools. Startup
profile failures now report the advertised catalog, and when it is the
Hex-Rays one the message and recovery name the `hexrays` registration.

Refs #1416

* docs(ida): state Hex-Rays prerequisites and upstream session traces

Upstream needs IDA 9.4 or later with idalib, Python 3.11 or later, uv
and Git. The profile does not analyze databases open in the IDA GUI, and
the server keeps its own session traces outside REA's workspace.

Refs #1416

* fix(ida): skip inline data when scanning Hex-Rays calls

The call scan decoded every head that FuncItems yields. Inline data such
as a jump table can decode as a call and refer to a function or import,
which reported false callees and call-graph edges. Skip non-code heads
before decoding, as disassembly already does.

Refs #1416

* fix(ida): retain Hex-Rays health reads in evidence

The identity and readiness reads around each operation kept only their
parsed result, dropping the bridge digest and any engine output. Keep
them whole as health_observations beside the parsed metadata, in both
successful and partial-failure Evidence.

Refs #1416

* test(ida): list the Hex-Rays bridge in package fixtures

The packed-bridge verifier has required bridge/ida/hexrays_queries.py
since the Hex-Rays profile landed, but three package tests still built
their member lists without it. The verifier stopped at that file, so 21
cases failed or asserted on the wrong omission.

Refs #1416

* feat(ida): open existing IDA databases through the Hex-Rays profile

A headless open re-ran auto-analysis from the input binary, discarding
the names, types and comments of an existing database and taking far
longer on large targets. Target admission now identifies IDA databases
by their IDA1/IDA2 signature, and the hexrays profile opens a private
copy of one; Hopper and the other IDA profiles reject them.

The copy is required, not incidental: idalib repacks a database when
its last lease is released, even without a save. A database reports
the input it was created from, so the session is bound to the opened
copy's idb_path, and health now reports the input SHA-256 it records.

Validated with resolver, provider and session tests, check:fast,
docs:check and test:changed, plus a real Hex-Rays MCP run against a
1.4 GB SC2 .i64 whose original file was left byte-identical.

Refs #1416

* fix(ida): verify the private workspace of a database target by idb_path

* test(ida): fix Hex-Rays health stand-ins and Windows path and runtime teardown

* refactor(ida): resolve the registration once for target support

* docs(ida): record the real Hex-Rays run on an existing .i64

* docs(ida): make the Hex-Rays registration example install-neutral

* chore: keep merge-hook formatting outside the IDA change

* fix(ida): retain live Hex-Rays databases this server does not lease

A list_databases row with instance_id null is a live owner, not a stopped
database. Mapping it to the supervisor's released-worker shape made cleanup
delete files another client still held. Unleased rows stay active, so the
private path must leave inventory before the workspace is removed.

Accept idat inventory rows, hash the query bridge with sha256Hex, and
complete databaseEngine on Hopper fixtures added on main.

* fix(ida): report uncapped Hex-Rays call graphs

* docs(ida): link to the Hex-Rays bridge on GitHub

* fix(ida): verify Hex-Rays worker identity and cleanup

* feat(ida): support Hex-Rays idat headless workers

Refs #12921

* fix(ida): retain workspace after ambiguous Hex-Rays startup

* fix(ida): preserve typed Hex-Rays call edges and deadlines

* test(ida): verify Hex-Rays cleanup with a peer lease

* test(ci): use project deadlines for the Cutter verifier

* test(ida): keep verifier cleanup fixtures scoped to mocked modules

* fix(ida): retain the worker backend in partial evidence

---------

Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-20 17:58:27 -05:00
morluto 4449d13047 test(evaluation): consolidate report verdict and output checks (#12882) 2026-11-20 16:26:39 +00:00
morluto a1dec2d2d5 docs: remove tracked planning and architecture records (#12856) 2026-11-20 09:47:41 -05:00
2474e6ec6c refactor(verify): run Hopper and Kuna verifier commands through the supervised owner (#12718)
* refactor(verify): run Hopper and Kuna verifier commands through the supervised owner

Replace bare execFile in the Hopper and Kuna real-provider verifiers with
createVerifierCommands, and run pre-workspace toolchain probes through
runOwnedCommand. Close the owner before lineage verification and keep the
diagnostic workspace when cleanup, lineage, or the run fails.

Replace isError-only and FAT64 prose refusals with the projected error code
and structured issue or target details.

* fix(verify): release a clean Kuna workspace after a verification failure

A failed check whose provider, command, and lineage cleanup all completed
still removes the root. The workspace stays only when that cleanup is
unconfirmed, which is the contract the Kuna verifier failure-path tests
already require.

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

* fix(verify): keep the Kuna report when workspace release fails

release() closes cleanup registration before it removes the root, so
retain() after a failed release throws and skips the JSON report. Register
retention only when release has not started; a failed release already
keeps the workspace.

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

* fix(verify): keep both Hopper verification and lineage failures

When verification has already failed and lineage observation then fails,
the retained-workspace error carried only the earlier cause. Aggregate
both failures in the Hopper, FAT, and caller verifiers so the cleanup
reason stays with the workspace.

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

* fix(verify): keep Hopper manifests inside the repository

realpath() accepted REA_HOPPER_CONFORMANCE_MANIFEST_PATH as any filesystem
path. Resolve the manifest against the repository and reject a lexical or
symlink escape before it is read.

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

* fix(verify): acquire command owners before verifier workspaces

* fix(verify): create the command owner before the verifier workspace

If command-owner setup fails after a workspace is allocated, the temporary
root is never released. Create the owner first and close it when workspace
allocation fails.

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

* fix(verify): supervise Hopper helper CLI processes

* fix(verify): run Hopper helper CLIs through the command owner

Boundary and Linux owner-exit checks still launched the REA CLI with
execFile, so a timeout could not stop those processes. Both helpers now
require the verifier command owner and run those CLIs through it.

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-11-20 04:35:35 +00:00
f25a0a0599 refactor(verify): run Ghidra verifier commands through the supervised owner (2 of 2) (#12717)
* refactor(verify): run Ghidra verifier commands through the supervised owner (2 of 2)

Route the remaining Ghidra verifier compiler and CLI launches through
createVerifierCommands, close that owner before lineage observation, and
assert the raw arm64 alignment refusal from its structured error.

* fix(verify): stop detached Ghidra verifier commands on interrupt

SIGINT and SIGTERM abort the command owner and the scripts wait for its
cleanup, so a compiler started in its own process group cannot outlive
the verifier.

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

* fix(verify): stop Ghidra verifier analysis when interrupted

Pass the verifier interruption signal into MCP and Ghidra waits, and stop
waiting for calls that cannot observe it, so SIGINT does not continue the
analysis before cleanup.

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

* fix(verify): stop the switch evidence probe when the verifier is interrupted

Pass the verifier interruption signal into the detached Ghidra control
probe and end its wait so supervisor.stop() runs before a later SIGKILL.

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

* fix(verify): observe work already started when a verifier interrupt wins

untilInterrupted now settles the caller's promise after the signal has
already aborted, so a connection started just before the check cannot
reject with nobody listening.

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

* refactor(verify): share verifier interrupt handling and keep it through release

Move the SIGINT/SIGTERM abort wiring into bindVerifierCommandInterruption.
Handlers stay installed until after fixture release, and untilInterrupted
still observes a promise that was already started.

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

* fix(verify): keep diagnostic workspaces and stop fixture builds on interrupt

Check the interruption signal after finalization and before the fixture
root is removed. MIPS and RISC-V fixture compilers and readers now run
through the verifier command owner, so SIGTERM aborts them instead of
waiting out their execFile deadline.

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-11-19 23:29:09 -05:00
ShuaixinHuangandShuaixinHuang 4bebd9a5e1 fix(release): validate the exact MCP registry package at checkpoints (#12550)
Co-authored-by: ShuaixinHuang <ShuaixinHuang@users.noreply.github.com>
2026-11-19 18:00:37 -05:00
bartman081523andmorluto d380dc2409 feat(uefi): add pure-TypeScript UEFI firmware analysis tools (#12342)
* feat(uefi): add pure-TS UEFI firmware volume/FFS parser with inspect/extract tools

Add a dependency-free rea-uefi provider that maps AMI/Aptio flash images:
- inspect_uefi_firmware: aligned _FVH discovery, volume-relative FFS walking,
  guided section/compression classification, conservative PSP-directory probing,
  embedded-volume rescan and leftover-region classification; incremental SHA-256
  and explicit integrity notes.
- extract_uefi_firmware: whole-image/volume/FFS-file/section extraction with
  LZMA-custom/LZMAF86 and AMD-zlib decoding, SafeOutputTree staging, derivations
  and extraction_gaps.
- UefiArtifactReader + 'uefi' format wiring across inventory/domain/contracts
  so parsed volumes and extracted PE32/TE files hand off to deep-provider
  analysis (open_binary -> Ghidra).

* feat(uefi): add inspect_uefi_nvram for AMI NVRAM variable stores

Add a pure-TypeScript tool that maps the vendor AMI NVRAM variable stores
(factory-default "StdDefaults" and peers) inside a flash image:
- scan the raw image for NVAR entry chains ("NVAR" + u16 total size +
  u32 attribute 0x8[23]FFFFFF + state + NUL-terminated name + data),
- recurse into a container entry whose data is itself an NVAR chain, so the
  StdDefaults setup variables surface as depth/parent_offset rows,
- report attributes, state, data range, SHA-256 and trailing padding per entry.

Verified against B550 AORUS Elite V2 FId: one StdDefaults store at 0x37090 with
the 11 expected nested variables (Setup, PlatformLang, AMITSESetup, XhciDID,
GcSensorVarName, PCI_COMMON, SioSetupData, UsbSupport, NetworkStackVar,
SecureBootSetup, Setup). Exposed as MCP tool and inspect-uefi-nvram CLI command.

* fix(uefi): address review on checksums, compression, guided sections, NVRAM bounds

- FFS file checksum: verify the two's-complement invariant (payload sum +
  stored byte == 0 mod 256) instead of comparing sums, and encode the correct
  complement in the fixture builder.
- Compression sections (type 0x01): use the 9-byte header and classify EFI
  standard compression instead of 'none', so extraction reports a gap rather
  than publishing compressed bytes as a raw section.
- GUID-defined sections: derive GUID/data-offset/attributes from the parsed
  common header size (compact or extended) and reject out-of-range payload
  offsets.
- AMI NVRAM: bound recursive chains to the enclosing container's data end and
  report partial coverage when a valid nested chain is cut by max_depth.

* fix(uefi): bound decode memory, serialize operations, enforce deadline, mark truncation

- LZMA worker: enforce max_output_bytes while decoding through a bounded output
  sink, so an oversized stream is rejected during expansion instead of after a
  full decompression plus a second Buffer copy.
- Provider: serialize admitted operations (the promised single decode-worker
  lane must not become one worker per overlapping call) and apply one
  whole-request deadline that covers every decode stage, not a fresh per-stream
  timer. close() drains the queue and the resource scope.
- Scan: track truncated sections of known type and report coverage partial
  instead of complete when a section declares more bytes than are present.

* fix(uefi): cancellable queue, timeout surfacing, availability and reader omissions

- Queue: check the caller signal before enqueue and when a job reaches the head,
  and race the queued promise against abort so a cancelled wait returns
  immediately instead of blocking behind the active request.
- Deadline: track the internal deadline and return AnalysisTimeoutError instead
  of the AnalysisCancelledError that runOwnedCommand reports for any external
  abort, preserving the real failure reason for CLI/MCP callers.
- CapabilityInventory: treat inspect_uefi_nvram like the other bundled rea-uefi
  tools so discovery does not demand Unblob for it.
- UefiArtifactReader: report image truncation through onOmission so inventory
  coverage reflects the unread suffix even when no volume was found.

* fix(uefi): limit early cancellation to unstarted jobs and preserve timeout cleanup

- #raceWithAbort only returns early for jobs that have not started; once a
  request is running, await it so worker cleanup and completed output are
  preserved instead of being discarded by a bare cancellation.
- Reclassify a deadline-induced cancellation as AnalysisTimeoutError while
  keeping its cause and cleanup observations, and never override a different
  primary failure.

* docs(licenses): record UEFI decoder dependency notices

* fix(uefi): preserve stream provenance and bound firmware analysis

* feat(uefi): decode LZMAF86 guided sections

* fix(uefi): validate publication before commit and order decoder cleanup

* fix(uefi): preserve unsupported volumes and extraction gaps

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-19 21:19:35 +00:00
morlutoandCursor Agent c949702e44 fix(release): validate registry pages and release references at their boundaries (#12452)
* fix(release): validate registry pages and release references at their boundaries

* fix(release): compare migration footers as Markdown blocks

* fix(release): preserve literal migration blocks in checkpoint validation

* fix(release): retain raw HTML migration blocks

* style(release): format migration block wording

* fix(release): preserve migration link destinations

* fix(release): match migration links by label position

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-19 19:31:01 +00:00
ShuaixinHuangandShuaixinHuang 80e8bbc871 fix(release): retry commit history gateway timeouts (#12377)
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
2026-11-19 10:33:19 -05:00
ShuaixinHuangandmorluto ff1d06ecb0 fix(release): keep credit examples inside Markdown fences (#12239)
* fix(release): keep credit examples inside Markdown fences

* fix(release): share fenced Markdown boundaries

* fix(release): parse nested Markdown fences and headings

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-19 14:46:31 +00:00
ShuaixinHuangandShuaixinHuang b95a757c33 ci(windows): report package verification phase timings (#12167)
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
2026-11-18 22:07:57 -05:00