Commit Graph
1853 Commits
Author SHA1 Message Date
RRFZandVincent Koc 3eb030ccb4 fix(source-maps): report details.limit for source_map_limits refusals (#14797)
Share source_map_limits bounds through a domain-owned SOURCE_MAP_BUDGETS table and attach details.limit across local source-map read, decoder admission, codec reply, and memory/output limit refusals (Refs #14234).

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-27 10:01:44 +08:00
Vincent Koc cd744b1bfb fix(ci): require complete path references for test coverage (#14819) 2026-11-27 01:54:43 +00:00
RRFZandVincent Koc c366df0bf0 fix(wasm): report details.limit for max_interface_bytes refusals (#14795)
Define WASM_INTERFACE_BYTE_BUDGET in src/domain/wasm/wasmInterface.ts so wasmInterfaceByteBudgetSchema and WasmInterfaceBudget share one owner, and attach details.limit to max_interface_bytes refusals (Refs #14234).

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-27 09:46:01 +08:00
ShuaixinHuangandShuaixinHuang 48adc9df0b fix(ci): fall back when a changed test fixture has no traced consumer (#14709)
* fix: deepen verified coverage for PR #14354

* test(ci): assert the selected fixture consumers

---------

Co-authored-by: ShuaixinHuang <ShuaixinHuang@users.noreply.github.com>
2026-11-27 09:31:15 +08:00
RRFZandVincent Koc 58a33642f2 fix(api-contract): report details.limit for max_file_bytes and mark heap headroom exhaustion (#14798)
Share max_file_bytes bounds through API_CONTRACT_FILE_BYTES_BUDGET in src/domain/apiContract/apiContractQuery.ts, attach details.limit with required_value in ApiContractRead, mark V8 parser heap headroom refusals as measuredExhaustion, and drop all three entries from the untyped refusal baseline (Refs #14234).

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-27 08:42:41 +08:00
Adolanium 7e01f1df85 fix(browser): bound armed timeline rows by the retained-event allowance (#14799)
* fix(browser): bound armed timeline rows by the retained-event allowance

Armed timeline rows were appended with no byte budget. Pre-arm
messages and document request identities already stop at the
retained-event allowance.

Count each armed row before keeping it. A row that does not fit fails
the observation with payload_limit and does not return a shorter
timeline. Event count has no separate ceiling.

* chore(browser): format the timeline allowance check

oxfmt --check rejects the wrapped comparison in TimelineCapture.#add.

* fix(browser): give timeline retention a caller control

Armed timeline rows use browser.timeline_retained_bytes. A call can pass
timeline_retained_bytes. Request identities keep a separate counter.
A row that does not fit returns payload_limit with details.limit, including
a row admitted during terminal progress.

* fix(browser): refresh advertised schemas for the timeline allowance

The new setting and per-call field change the compact input hashes for
observe_web_session, inspect_analysis_settings, and update_analysis_settings.

* fix(browser): report measured timeline bytes without required_value

Admission stops at the first row that does not fit, so later rows are
unknown. measured_timeline_bytes records the rows already measured.
The budget test waits until all four lifecycle events are delivered.
2026-11-27 08:28:44 +08:00
AdolaniumandVincent Koc 1c8b3b64e8 fix(cli): isolate a synchronous resource-closer throw (#14796)
* fix(cli): isolate a synchronous resource-closer throw

closeCliResources invoked each closer while building the
Promise.allSettled input. A closer that threw before returning a
promise left that call, so later owners did not run.

Start each closer on its own turn. A synchronous throw stays with
that owner, and every other owner still settles. Closers stay
registered, so a later close retries them.

A failed registration can request process exit twice. The first
request now owns shutdown. A second registration fail or host exit
returns without starting another resource close or exit timer.

* test(cli): exercise duplicate exit after rendering failure

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-27 07:55:54 +08:00
Adolanium 777832eff5 fix(browser): reject a file URL with a hostname (#14792)
* fix(browser): reject a file URL with a hostname

A file URL names another host when its hostname is not empty. The navigation hook blocks that URL. An empty host stays allowed, including file://localhost, because the URL standard ignores that host.

* test(browser): cover a blocked file-host redirect

The file-host regression emits will-redirect for a remote file URL and a local file URL. Dropping the redirect check leaves preventDefault unset and fails the test.
2026-11-27 07:40:06 +08:00
Vincent Koc 0de6029fb6 perf(ci): read each source file once in architecture guards (#14808) 2026-11-26 23:39:03 +00:00
2a4c8ccfba fix(ci): clear stale static diagnostic context before recording (#14713)
* fix(ci): clear stale static diagnostic context before recording

* test(ci): align inherited Mach-O assertion with main

---------

Co-authored-by: ShuaixinHuang <ShuaixinHuang@users.noreply.github.com>
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
2026-11-27 07:30:44 +08: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
14b4d1f7ad feat(firmware): inventory and extract UBI image volumes offline (#13333)
* feat(firmware): inventory and extract UBI image volumes offline

* docs: name ubi-volume among compared format metadata kinds

The artifact comparison contract lists every format metadata kind that
compare_artifacts compares. ubi-volume now carries a declaration, so the
contract names it beside the other members.

* fix(firmware): keep UBI LEB ranges private to the reader

entries() yielded copyArtifactEntry(entry), which spreads the private
volume field by reference, so a caller could rewrite volume.ranges and
change the bytes the next open() read. Yield only the public entry
fields, and test that a returned entry carries no volume mapping.

* fix(firmware): keep LEB source ranges in ubi-volume metadata

Saved Evidence now records the lnum, PEB, image offset and length of each
chosen LEB, so a reassembled volume can be traced to its image bytes. The
image summary keeps counts.

* fix(firmware): reject smaller UBI eraseblock sizes whose LEB padding is invalid

A dynamic LEB with data_size 0 and data_pad equal to a smaller candidate LEB passed the size check, so a valid aligned image was refused as ambiguous. Require data_pad below the candidate LEB, as classifyUbiPeb and the volume table alignment rule already do.

* fix(ubi): refuse a UBI# file shorter than its erase-counter header

recognizeUbiImage recognized any 4 to 63 byte file starting with UBI#
without a CRC or version to check, so open_binary accepted it as an
archive and inventory labelled it a container. It now takes the file size
and refuses a file that cannot hold the 64-byte header. A short prefix
read from a longer file still defers to the reader.

* fix(ubi): refuse a volume whose only surviving LEB copy failed its CRC

When both competing PEBs for a LEB are wear-leveling copies and both fail
their data CRC, the older failed copy still won and open() served bytes
that had already failed verification. Mark that LEB unverified and refuse
the volume with extract refusal unverified_copy, keeping its inventory.

* fix(ubi): refuse an image whose EC headers disagree instead of skipping them

Eraseblock discovery and both spacing checks skipped a valid erase-counter
header whose image_seq or layout differed from PEB 0, treating it as
absent. Alternating sequences or a conflicting second header then measured
a multiple of the real eraseblock size and read the image, so a volume
became an extractable empty or header-polluted volume. Any valid header now
begins an eraseblock, and classifyUbiPeb and checkUbiPebs refuse the
disagreement.

* fix(ubi): rule out a smaller eraseblock size whose volume table is invalid

The ambiguity check declared a smaller eraseblock size equally valid from
erased header positions and LEB fit alone. With 128 KiB eraseblocks,
data_offset 4096 and a volume of alignment 6144, data_pad is 4096, but a
64 KiB LEB would need data_pad 0, so that size cannot describe the image
and a valid image was refused. The check now also requires a volume table
copy to stay valid under the smaller geometry, and runs after the table
copies are read.

* fix(ubi): compare the volume ID in a UBI volume declaration

The compared ubi-volume declaration left out the volume ID. A volume
renumbered from ID 0 to ID 1 keeps its path and reconstructed bytes, so
artifact comparison reported it unchanged even though consumers that
address volumes by number now see a different volume. The declaration now
includes the ID, and PEB placement stays out of it.

* fix(ubi): refuse a volume with no mapped LEB when PEBs are corrupt

When a volume's only data PEB had a bad EC or VID header CRC,
classification dropped its mapping and reassembly read the absence of
surviving headers as an empty volume: a static volume got used_ebs 0, a
dynamic one zero LEBs, and both were served as extractable empty files.
A corrupt PEB may have held that data, so a volume with no mapped LEB in
an image with corrupt PEBs is now inventoried but refused as lost_lebs,
with used_ebs null and a named limitation. An image without corrupt PEBs
still reads an unmapped volume as empty.

* fix(ubi): accept EC headers in static LEB data no smaller eraseblock holds

A static volume holding a nested UBI image with the same EC layout puts
valid EC headers on a smaller grid inside its payload. With 128 KiB
eraseblocks, data_offset 4096 and full 126976-byte static LEBs, the
spacing check and the smaller-grid scan refused such a header as a
geometry conflict, though ubiSmallerPebSizeHoldsLebs already rules out
every smaller size those LEBs would have to fit.

Both scans now run their verdict after the PEBs and volume table copies
are read, and set aside a header at a position only ruled-out sizes would
begin at. A spacing conflict still takes precedence over later failures,
and a header where a smaller size stays possible, as under dynamic LEBs,
is still refused.

* Address review feedback

* Address review feedback

* Address review feedback

* Address review feedback

* fix(ubi-image): carry parser limit facts through reader refusals

parseFailure now passes the named parser limit and a typed parser
fixedAllowance when it wraps a UBI limit refusal, so the 16 MiB
eraseblock size ceiling and the 262,144-eraseblock count ceiling reach
CLI and MCP with reported_limits and the fixed-ceiling recovery.

* fix(ubi-image): ignore nested EC headers no eraseblock could begin at

The second-header scan now skips headers inside the data the first PEB's
own VID header declares, so a static LEB holding a nested UBI image no
longer measures the eraseblock at the nested header.

The spacing check now counts only headers at positions an eligible
smaller eraseblock (dividing the measured size, larger than data_offset)
would begin at, and after the LEBs are read only the sizes they still
admit. A dynamic LEB holding a nested image of small eraseblocks parses
the same in PEB 2 as in PEB 5.

* fix(ubi-image): read only the first VID header within the eraseblock ceiling

The eraseblock search read every byte from offset 0 through the first PEB's
declared vid_hdr_offset to find its VID header. A CRC-valid EC header could
declare an offset of 1 GiB and make the reader allocate a buffer that size
before the eraseblock ceiling refused the image.

ubiFirstVidHeaderOffset now admits the VID header only when it lies inside
the file and the fixed eraseblock ceiling, and the reader reads just those
64 bytes. A header past the ceiling is never read, so the search reaches
its bounded eraseblock-size refusal as before.

* fix(ubi-image): skip EC headers whose offset cannot be the eraseblock size

A dynamic VID header declares data_size 0, so a first PEB holding a nested
UBI image only rules out the nested header at data_offset. The next nested
header, 6144 bytes into a 128 KiB eraseblock, was taken as the eraseblock
size and the valid 524288-byte image was refused as not a multiple of it.

The second-header search now skips headers at offsets that do not divide
the file size, since no eraseblock size could put them there. The first
header at any offset is still kept for the refusal when no size fits.

* fix(ubi-image): reject truncated dumps with misleading PEB headers

* Address review feedback

* Address review feedback

* Address review feedback

* Keep undersized UBI candidates provisional on valid VID extents

A CRC-valid VID header whose data_pad and data_size do not fit a
candidate LEB now records the eraseblock size it needs. A dividing
candidate smaller than that stays retryable, with its image kept as the
fallback, so a later candidate that holds every LEB in full is accepted.

* Address review feedback

* Address review feedback

* Exercise the UBI PEB count ceiling in memory

* fix: reject unrelated UBI header conflicts

* fix: verify static UBI payloads before retrying geometry

* fix: bound UBI static payload CRC work across PEB size candidates

* fix: repair UBI integration after merging main

* Address review feedback

* fix: let cancellation retire paused UBI volume streams

* test: synchronize paused UBI volume cancellation

* fix: preserve UBI read failures during cancellation

* perf(ubi): count PEB states and extractable volumes in one pass

Replace the per-state .filter(...).length scans in assembleUbiImage and
summarizeUbiImage with single loops, per docs/development/tool-design.md.

* Address review feedback

* fix(firmware): close UBI geometry ambiguity and corrupt-PEB tail gaps

* fix(firmware): verify erased UBI PEB bodies and validate layout VID headers

* fix(firmware): defer and cache UBI erased-body scans and deduplicate stream check helper

* fix(firmware): eliminate quadratic UBI erased-range scans and cache dynamic copy CRCs

* test(firmware): assert UBI erased-range coalescing, walk steps, and elapsed time

* perf(ubi): cache EC header scan across block-size retries

* fix(ubi): bound EC header scan cache and stream past cap

---------

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:37:31 +00: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
gensokyo-devandgensokyo-dev 981dd11ec4 feat(artifacts)!: budget extract_artifact delivery
extract_artifact returned every written file inline. Extracting VLC's APK
through MCP returned 1,214,138 bytes of content, beside the same
structured result, for a call whose files are already on disk.

extract_artifact now takes detail and joins the agent result budget.
Omitted, an extraction that fits delivery.agent_result_budget_bytes is
inline and a larger one is retained behind its artifact-extraction
summary; detail never reaches the provider. The CLI uses the shared
Evidence delivery. The same APK now returns a 14,592-byte summary, and a
lib/** page of its native libraries 12,472 bytes.

BREAKING CHANGE: an extract_artifact call that omits detail on an
extraction 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-27 05:21:32 +08:00
3e8f6a43a9 feat(artifacts): decode Android Verified Boot vbmeta images offline (#13239)
* feat(artifacts): decode Android Verified Boot vbmeta images offline

* fix(artifacts): locate vbmeta tail-length failures at their length fields

* fix(artifacts): make vbmeta admission budgets adjustable per call

* fix(firmware): refuse vbmeta fields too long to hex-encode

With raised descriptor_bytes and auxiliary_block_bytes limits, a valid
KERNEL_CMDLINE longer than half the host string bound passed the byte
limits, and toString("hex") then threw ERR_STRING_TOO_LONG, which
surfaced as an I/O error. Check the field against the host bound before
hex encoding and report a typed capacity failure with its own limit.

* fix(firmware): check vbmeta extents before admission budgets

A header whose declared blocks do not fit the file, or whose descriptor
range does not fit its auxiliary block, now reports truncation or a
malformed range instead of a limit a larger budget cannot repair. The
over-budget fixtures are now fully present so they still prove the limit.

* perf(firmware): count vbmeta descriptor tags in one pass and reuse readers

The summary counts every descriptor tag in a single loop instead of six
filtered arrays, and androidVbmeta reuses one BinaryReader per buffer.
The malformed-header refusal fixtures follow main's unsupported_target
classification for malformed target bytes.

* chore: regenerate advertised schema hash after merging main

* docs(android-vbmeta): name unsupported_target for structural refusals

Malformed vbmeta headers classify as unsupported_target, not
invalid_request, matching analysisErrorClassification and the refusal
fixtures.

* chore: regenerate advertised schema hashes after merging main

* chore: regenerate advertised schema hashes after merging main

* fix: restore Android vbmeta artifact reader after merging main

* test(artifacts): expect partial for the CLI vbmeta descriptor refusal

* feat(artifacts): preserve vbmeta descriptor bytes and partial refusals

Co-authored-by: iamcipherdev <268238676+iamcipherdev@users.noreply.github.com>

* fix(artifacts): use Buffer.equals in vbmeta tests and update advertised schema summaries

---------

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: Vincent Koc <vincentkoc@ieee.org>
Co-authored-by: iamcipherdev <268238676+iamcipherdev@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-26 20:05:59 +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
51b3671b08 feat(artifacts): inventory Nintendo DS ROM binaries, overlays and file tables offline (#14664)
* feat(artifacts): inventory Nintendo DS ROM binaries, overlays and file tables offline

Recognition now claims a Nintendo DS ROM from the cartridge header:
stored logo CRC 0xCF56, unit code 0, 2, or 3, an ARM9 offset after the
header, and a matching logo-area or header CRC. Inspection records those
header facts on the root and lists arm9.bin, arm7.bin,
overlays/<cpu>/overlay_<id>.bin, FNT-named data/<path> files, and
unnamed fat/<id>.bin files as stored byte ranges. A checksum mismatch, a
partial table, or a range past the end of the file leaves coverage
unknown. Secure-area encryption, compressed overlays, and NitroARC
archives stay undecoded, and the format is registered for inventory,
extraction, and the docs.

* docs: move the Nintendo DS ROM guide under guides/firmware

* Address review feedback

* Address review feedback

* Address review feedback

* fix: Compare NDS entry addresses and overlay facts

* fix(artifacts): bound NDS path expansion and enforce expanded_bytes

* fix(artifacts): omit NDS format declaration for ordinary filesystem files

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-26 19:15:18 +00:00
RRFZ d97b796076 fix(dwarf)!: bound PE COFF section-name decoding with max_structure_bytes (#14787)
BREAKING CHANGE: Oversized individual PE COFF long section names in inspect_dwarf_units now project an adjustable_budget refusal (boundary max_structure_bytes with details.limit) instead of fixed_ceiling (pe-section-name-bytes).
2026-11-26 13:13:09 -05:00
RRFZ 47875ba073 fix(native)!: bound Android packed relocations with max_structure_bytes (#14788)
BREAKING CHANGE: Oversized Android APS2 packed relocation tables in inspect_native_initializers now project a memory/adjustable_budget refusal (boundary max_structure_bytes with details.limit) instead of capacity/fixed_ceiling (native-index-capacity).
2026-11-26 12:48:22 -05:00
2SinceJulyandVincent Koc 2bb086c87a feat(providers): retain native selection provenance in Evidence (#9668)
* feat(providers): retain provider selection provenance with session evidence

The registry records how a deep provider became selected and why every other candidate was rejected, and binary_session exposes those facts for the active route. Evidence already carried provider identity, but nothing recorded which candidates the session evaluated, so a retained record could not explain why this engine produced the observation or what the alternatives were.

Attach provider_selection to Evidence admitted by the session: the selection source and, for each evaluated candidate, its identity and version, selection state, availability and target-support outcome, and the stable rejection codes. The field is optional and excluded from semantic identity, following caller_input_path, so each admitted record stays attributable to the exact provider instance without changing observation identity, evidence IDs or replay.

Copy only stable selection facts. Candidate diagnostics, remediation prose and target content stay in the session status projection instead of being repeated in every record.

* style(domain): reformat the provider-selection assertion

oxfmt --check rejected the three-line expect() call; the formatter's
single-line layout is the canonical one, so Static checks failed only
on formatting.

* fix(evidence): keep a rejected record inside the Result boundary

`recordEvidence` ran `withEvidenceProviderSelection` before handing the record
to the ledger. That helper parses to seal the rebound envelope, so a tampered or
otherwise invalid record threw a `ZodError` from the attribution step and never
reached `EvidenceLedger.record`, which is where the declared `Result` is
produced. `tests/boundary/mcp/processEvidenceIdentityMcp.test.ts:454` asserts
`session.recordEvidence(tampered).ok === false` and fails on the throw.

Authenticate the input first and return the ledger's own rejection for a value
it would refuse anyway; attribution then only ever sees a record its reader
accepts.

* fix(binary): attribute imported records to the recording session

Import replaces a same-ID record's presentation metadata, and
provider_selection is part of that metadata. When runDirectAnalysis imports
the provider's own bundle, the copy it rebuilds carries no selection, so the
import erased the attribution the session had stamped and the caller kept an
unattributed record instead. Attribute at both merge sites, where the session
already authenticates everything it admits.

A refreshed route after a failed switch can bind a different selection than
the one the earlier binding held, so re-derive it there as the initial open
does; spreading the previous binding kept the stale value.

* fix(binary): admit record input before sealing it for attribution

recordEvidence and the two bundle import paths seal Evidence through
withEvidenceProviderSelection before handing it to the ledger. A sealed
value skips the ledger's ordinary-JSON and heap-headroom admission, so a
session with no authentication allowance accepted a mutable record and a
large record was copied and traversed before the guard ran.

Hold the caller's own value to that admission first, then attribute. The
import paths also refuse with a Result instead of falling through to an
unattributed import when admission fails.

* fix(binary): re-attribute a sealed record without traversing it again

recordEvidence now admits the caller's value before attributing it, but a
record returned by evidenceForAnalysis has already been through that
admission and is sealed. Running the ordinary-JSON walk and the
heap-headroom check over it again repeats the work the ledger itself
skips for a sealed value.

Ask the ledger first: a value it holds is the admission it made, so the
check costs one lookup. Only a value the ledger has not seen pays for the
full walk.

* fix(providers): return the recorded Evidence after import

Import re-stamps session provenance onto the Evidence it records, but callers kept the pre-import copy, so retained selection attribution and cache metadata were dropped from what analysis reported. Read the recorded record back after a successful import, and leave an already-retained record as the ledger attributed it instead of re-deriving attribution from the caller's copy.

* fix(providers): keep the caller's copy when re-attributing an imported record

The merge with main brought in the unchanged-record path, where an import whose only change is display metadata now replaces the ledger's record. Re-attributing that incoming value put the session's provider selection on the caller's copy, so the import reported a record that differed from what the caller sent. Attribution now applies only to records the ledger does not already hold.

The snapshot cache test now asserts the session's attribution explicitly instead of byte equality with the un-attributed source.

* fix(providers): keep the caller's record when importing over a retained one

The previous change skipped attribution for a record the ledger already held, which left the imported copy's own selection — missing or from another session — in place. Import replaces a same-ID record's presentation metadata, and provider_selection is part of it, so the session's attribution wins over the caller's copy while the caller's other display metadata is kept untouched.

* fix(providers): attribute staged snapshot and unknown-mutation Evidence

Address the open review findings on session provider provenance:

- importAnalysisSnapshot merged the re-attributed bundle into the ledger but
  staged the snapshot's own bundle, so AnalysisSnapshotCache rebuilt replay
  bindings from records the merge had replaced. Hand the merged bundle back
  to the stage so replays bind to the attributed evidence.
- recordResult recorded an attributed record and then serialized the
  caller's copy, so successful MCP responses omitted provider_selection
  while the ledger and exports carried it. Read the recorded Evidence back
  before delivery, as the direct analysis path already does.
- recordUnknown and updateUnknown synthesized unknown-mutation Evidence
  without the active session's provider selection, so those exported
  records were unattributed. Thread the binding's selection through to
  unknownMutationEvidence, which is where the record is produced.

* fix(providers): attribute the atomic Evidence-and-Unknown mutation record

recordEvidenceWithUnknown synthesizes its own rea.residual-unknown-mutation record, so the selection the session threads into recordUnknown and updateUnknown never reached it. The atomic comparison workflows therefore exported one record without provider_selection, contradicting the guarantee that every admitted record carries the recording session's selection. Thread the active binding through the atomic method as well; analyst-authored mutation records still keep analyst-inference authority and gain only the session selection.

* fix(evidence): require one selected candidate in provider provenance

provider_selection carries no separate selected-provider id, so a reader can only name the recording session's provider when exactly one candidate claims the selection. The schema accepted any candidates array, so an imported bundle could re-export zero or several selected candidates under a stable Evidence id and consumers would have no way to resolve the provider.

The recording paths always derive the selection from a single bound provider (AnalysisProviderRegistry selects one usable candidate, and SessionProviderRouter marks only the bound id selected), so the refine rejects only foreign input.

* fix(evidence): adopt the recording session's selection on a duplicate record

Recording an observation the ledger already holds under the same semantic ID
returned duplicate and discarded the attributed object, so lookup and export
kept the imported record's missing or foreign provider_selection. Replace the
retained display metadata with the active selection on that path; semantic
identity and the stored payload stay the same record.

The provenance schema also accepted a selected candidate that is unavailable
or unsupported, which no registry path can bind. Require the selected
candidate to be available and supported so an imported bundle cannot
re-export a selection that never occurred.

* fix(evidence): keep retained display metadata and notify observers on duplicate

Attribution replaced the whole stored record with the incoming copy, so a
provider-produced duplicate without the caller-selected path, alias set or
subject display erased the metadata the recording session retained merely to
add provider_selection. Adopt only the display facts the incoming copy actually
carries; omission is not deletion. Import keeps its documented replace
semantics.

The duplicate branch also returned before refreshEvidenceMetadata and
#emitSnapshotChanged, so replay caches and snapshot subscribers kept the old
metadata after a successful replacement. Treat a non-no-op replacement exactly
as the import path does.

* fix(artifacts): compare Evidence by identity across a replay session

The composed-workflow test opened a second fixture, which writes its own
temp artifact, so a replay record's subject path and the session-attributed
provider selection no longer matched the snapshot copy. Both are display
metadata outside the Evidence id; the provider call is what establishes
the binding here, so compare the content the id commits to and assert the
ids separately, which the test already does.

Also apply the formatter to BinarySessionInvestigation.test.ts, which
fails format:check on its own.

* fix(server): deliver the retained copy that carries the session selection

Recording stamps the active session's provider selection onto the ledger copy
of a semantic ID. The tools that build or project their own Evidence value
then delivered that unattributed copy, so the MCP response and the snapshot
export disagreed for the same evidence_id: Ghidra reference and evidence
flows, composed workflow overviews, analysis functions and the process
capture tools all failed deep-equality against the retained record.

Hand the delivered copy the session's selection when the ID is retained.
Other retained display metadata, such as a caller path carried by an
imported record, stays as the caller built it.

* test(investigation): keep the session test within its lint and format limits

Two checks on this branch failed for reasons the branch itself introduced:

format:check wants the withEvidenceProviderSelection call in
UnknownEvidence.ts wrapped at its argument list, which the branch's
edit moved off.

lint reports max-lines-per-function (152 lines, limit 150) for the
"reobserves resource-scoped ..." case after the branch expanded two
assertions in it. The provider-selection expectation is a fixed value,
so it moves to a module-level constant and the case drops back under
the limit without weakening either assertion.

* fix(server): carry the session selection on the workflow copy delivered

Commit 76d14ff9f stamped the delivered copy with the retained session
selection by patching registerEnhancedTools and registerEvidenceTools.
Upstream #11617 replaced both with the shared contract bindings, so the
merge dropped the stamp and the composed-workflow tools delivered an
unattributed copy again: workflowSnapshotReplayMcp compares the live
binary_overview response against the replayed Evidence and saw 19 fields
against 18.

Stamp at createAnalysisToolHandler, where every analysis workflow's
Evidence leaves for delivery, using the retention lookup already passed
in. A call whose ID is not retained, or whose record carries no
selection, is delivered unchanged.

* chore(schemas): record the provider_selection evidence schema digest

Adding provider_selection to the shared Evidence schema changes the output
compact schema of every tool that returns Evidence, so Build package
rejects 211 stale advertised catalog summaries. The summaries were
refreshed by running npm run verify:advertised-schemas -- --update-summary;
each file changes only its output compact digest.

* test(mcp): assert retained provider attribution instead of producer identity

Recording now stamps the session's provider selection onto retained Evidence,
so a producer-built copy and the retained record share every semantic member
but differ in provider_selection. Replace raw object identity/equality
assertions with display-metadata agreement plus a selection-neutral deep
comparison, and deliver the retained selection from contract tools so callers
do not receive an unattributed copy of the same evidence_id.

Verified: tests/boundary/mcp (345 files, 2289 passed / 12 skipped after
generating .cache/mcp-tool-catalog.json); npx tsc --noEmit exit 0.

* test(mcp): share the selection-neutral comparison across provenance assertions

Seven sites repeated the same spread-and-mask expression, which pushed the
test past the 150-line function limit and failed Static checks. Move it into a
withoutSelection helper that drops the session's provider_selection stamp and
compare both sides through it.

Verified: npm run check:fast (typecheck, lint, architecture guards);
the six boundary files CI reported, 37 passed.

* test(mcp): fold repeated retention checks into one helper

Static checks failed on format:check for three files and then on
max-lines-per-function after oxfmt re-wrapped the assertions. Run oxfmt on
the three files and replace the repeated selection-neutral comparisons with
an expectRetained helper so the test stays under the 150-line limit.

Verified: npm run check:fast (typecheck, lint, architecture guards);
npm run format:check; the six boundary files CI reported, 37 passed.

* test(snapshot): compare retained records without the session selection stamp

The same attribution change makes a fixture-built record differ from the
retained one by provider_selection alone, so the equality assertion failed in
both the portable and sharded lanes. Mask the stamp and keep every semantic
member under strict comparison.

Verified: npx vitest run tests/boundary/filesystem/analysisSnapshotProvenance.test.ts,
2 passed; npm run lint (0 errors); oxfmt --check.

* chore(schemas): record the provider_selection output digest on five tools

The session_provider_facts binding gained a .describe() explaining that the
selection source and candidate outcomes are retained with each admitted
Evidence record. That text is part of the advertised output schema, so every
tool whose output embeds the binding has a new compact digest.

Regenerate the committed catalog summaries with
npm run verify:advertised-schemas -- --update-summary. Only the five output
compact hashes change; no tool's shape or pattern changes.

* fix(evidence): keep a retained record's caller-selected path when adopting metadata

adoptEvidenceDisplayMetadata let a later copy's caller_input_path overwrite the value already held under the same semantic id, so a second selection through a different alias rewrote the display path the first selection recorded. Prefer the retained value and take the incoming one only as a fact the retained record lacks.

* fix(evidence): stamp the session provider selection on summarized delivery

Recording stamps the active session's provider_selection onto the retained
record under the same Evidence id. The summary delivery path re-admitted
the summarized copy without that stamp, so a caller reading a summarized
result saw no provider_selection while the retained record carried one, and
the response and the retained view disagreed for a single id. Pass the
retention lookup to deliverEvidenceResult on both the analyze_function and
external-mutation summary paths so the delivered copy carries the same stamp.

* chore(schemas): refresh UEFI tool summaries for the Evidence schema change

main added the UEFI inspection and extraction tools after this branch
regenerated the advertised catalog summaries, so their output compact
digest still recorded the pre-provider_selection value. Regenerate them
so the shared Evidence schema digest matches the branch.

* test(investigation): compare borrowed records without the selection stamp

Importing a sealed bundle stamps the session's provider_selection onto every retained record, so a borrowed record no longer shares object identity with the caller's unstamped bundle record. Replace the identity and equality assertions with a selection-neutral deep comparison, matching the attribution handling already applied to the snapshot and MCP provenance tests.

* fix(investigation): admit unknown mutations against their expanded Evidence

record_unknown and update_unknown check authentication headroom against the
caller's input before building the mutation Evidence. The Evidence repeats
parts of the input (for example the question in both parameters and the
normalized result), so with live headroom that admits the input but not the
larger record, the operation authenticated and sealed a representation past
the stated bound. #readEvidence skips the admission for immutable records, so
nothing downstream re-checked it.

Charge the derived Evidence's authentication cost in addition to the input
before sealing it, across the record, atomic record-with-unknown and update
paths. The regression test finds an allowance between the two sizes and
asserts the operation is refused with no Evidence recorded.

* chore(schemas): refresh advertised summaries after the provider-selection change

The advertised-schema catalog digests still described the pre-change input
schemas, so the Build package lane failed with 28 missing or stale summary
files and skipped every lane downstream of it. Regenerate the summaries with
npm run verify:advertised-schemas -- --update-summary.

* test(deno): damage Deno PE resource framing at the directory entry

The fixed-allowance case shrank the language directory Size to make the
65,535-row table malformed, but #14253 now walks resource trees at their
RVA whatever Size declares, so the table stayed well-formed and the run
reported the entry allowance (truncated/limit) instead of malformed
framing (unsupported_target/malformed). Point the type directory's entry
at a language directory outside the file-backed resource bytes, whose
header cannot be read. This mirrors the fix already on main (271bad782).

* fix(evidence): preserve source provenance and admit before copying

* fix(providers): scope selection provenance to native executions

* fix(providers): carry native provenance through workflow projections

* fix(providers): retain selection on shared session limitations

* fix(providers): preserve provenance during source recovery

* test(contracts): refresh combined Android reference schema

* fix(evidence): admit provider metadata before copying observations

* fix(evidence): recover completed calls after context refusal

* test(contracts): format merged call path schema summary

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-27 01:25:26 +08:00
188e2bd684 fix(website): honor validators and restore the implicit design system (#14768)
* fix(website): honor validators and restore the implicit design system

- Route every worker answer that skips Markdown negotiation through the HTML
  fallback, so validators and ranges removed for the probe still apply.
- Replace undefined classes with existing components and remove 27 CSS
  classes no page uses.
- Express article text color as a token so component colors win in both
  themes, and use logical properties for text-flow layout in RTL pages.
- Give an untranslated English fallback notice English direction.
- Start the page navigation closed without JavaScript, dismiss it with Escape
  or an outside click, and keep later copy clicks, failed key imports and
  first animation frames from corrupting demo state.
- Sync the theme bootstrap into the Notes fixture through a declared region.

* fix(website): skip Markdown negotiation for requests with a body

Markdown probing takes ownership of the caller request body. Methods other
than GET and HEAD have no Markdown representation, so they reach the asset
service once with the original body and validators.

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

* fix(website): describe the homepage menu's closed start

The disclosure has no open attribute, so without JavaScript it starts
closed and the summary reveals the fragment links. The guide now matches
that, including overlay dismissal.

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

* style(website): wrap the worker precondition assertion

oxfmt's 80-column width is what Static checks enforce. The If-Match
comparison in the non-retrieval test exceeded 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-26 17:04:00 +00:00
Dery Ferdikaandmorluto e99d0b2d86 fix(call-path): bound inline shortest-path enumeration (#4984)
* fix(call-path): bound inline shortest-path enumeration

build_call_path could allocate every shortest path before response-budget enforcement. Count the exact total with a capped BigInt pass over the distance graph instead, and bound enumeration itself: max_paths (default 64) is a caller-selected count preference while a 2 MiB serialized paths-field budget is the resource bound, checked before each cited path is formed.

The representation accounting measures each string with the rules JSON.stringify applies instead of charging six bytes per code unit, so an ASCII address or Evidence id is no longer billed six times what it writes, and the paths-array brackets the per-path accounting excludes are reserved. A path that serializes to 469,497 bytes is no longer refused as over the budget.

Results report total_shortest_paths, total_shortest_paths_capped, paths_truncated and paths_limited_by_bytes so exact counts, representation limits and completeness stay distinguishable, and a found result whose single path cannot fit still reports the known path with byte-budget truncation.

* fix(call-path): always return the first shortest path and measure cited paths

The byte budget dropped a sole shortest path whose citations exceeded
2 MiB, although that path is linear in the supplied Evidence; only path
count grows exponentially, and max_paths bounds it. Always return the
first path and let the budget bound the paths after it.

Measure each cited path with JSON.stringify instead of a hand-written
estimator that duplicated citePath's shape and JSON escaping (it also
charged U+007F-U+009F as escaped). The found result again requires at
least one path.

* refactor(call-path): measure cited paths from cached parts before assembling

A candidate path was cited and serialized in full before the byte check,
so a rejected path still built its representation. Move citation into
CitedPathParts, which builds each node and edge record once per graph
position with its exact JSON size. Enumeration sums a candidate from
those parts and assembles only an accepted path, which shares the cached
records. The path skeleton is measured from the same record constructor,
so size and output cannot drift.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-26 11:25:00 -05:00
Afloatandmorluto 331808dcd2 fix(website): resolve tagged and latest release download links (#9238)
* fix(website): resolve tagged and latest release download links

* fix(website): reuse parsed release asset identity

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-26 10:59:33 -05:00
Vincent Koc 752f5769e2 fix(android): allow filtering references by the unnamed package (#14752) 2026-11-26 15:35:31 +00: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
RRFZ d5b4c4bb61 fix(verify): bound concurrent file reads in architecture and limit guards (#14720)
* fix(verify): bound concurrent file reads in architecture and limit guards

`scripts/verify/architecture-guards.mjs` reads every `.ts`, `.mts`, `.mjs`,
and `.py` file under `src/`, `tests/`, `scripts/`, and `bridge/` (8,203 files
on current `main`) via unbounded `Promise.all(paths.map(readFile))`. On
Windows, queuing all `open()` calls at once exceeds the UCRT 8,192 file
descriptor ceiling and deterministically fails `npm run verify:architecture-guards`,
`npm run check:fast`, and the pre-push hook with `EMFILE: too many open files`.

Add a zero-dependency JSDoc-typed `mapWithConcurrency` helper in
`scripts/verify/bounded-file-reads.mjs` (default cap 64, registered in
`tsconfig.scripts.json` so it runs before `npm ci`), apply it across all four
bulk `readFile` loops in `scripts/verify/architecture-guards.mjs` and the
sibling `src/` scan in `scripts/verify/rea-numeric-limits.mjs`, and add unit
coverage in `tests/evaluation/boundedFileReads.test.ts`.

* test(verify): copy bounded-file-reads helper in numericLimitGuardPermission fixture

`scripts/verify/rea-numeric-limits.mjs` now imports
`./bounded-file-reads.mjs`. Copy both scripts into the temporary checkout
in `tests/boundary/process/numericLimitGuardPermission.test.ts` so the
copied verifier starts cleanly on non-root Linux/macOS runs instead of
failing with `ERR_MODULE_NOT_FOUND`.
2026-11-26 23:25:32 +08:00
192177f0c9 feat(artifacts): inventory and expand Android sparse images offline (#13244)
* feat(artifacts): inventory and expand Android sparse images offline

* chore(schemas): update artifact tool schema summaries for the sparse image limit

* fix(artifacts): retire undrained sparse image streams on cancellation

* fix(artifacts): keep large RAW reads in the sparse stream's owner

A large RAW run was streamed through a nested readFileHandleChunks
Readable, which could prefetch a descriptor read while the outer
iterator was idle, so close or cancellation could retire the stream
with that read still running. Read the run directly in the expansion
iterator so every read is pending in the owner that cancellation waits
on, and add held-read close and cancellation regressions.

* fix(firmware): drop unused ANDROID_SPARSE_MAGIC_BYTES export

* test(artifacts): release held sparse reads before restoring mocks

Release the held RAW read and join the retiring close or cancellation in
finally before restoring the read spy, so a failed assertion cannot leave
reader.close() waiting on a read nobody will finish. Use
awaitAcknowledgement for the held-read start barrier and drop the
per-test five-second timeouts in favor of the shared test deadlines.

* fix(lint): register sparse-image forwarded fixed ceiling

Upstream main added the fixed-ceiling registry check. The sparse-image
reader projects the parser's own named ceiling, so register it as
forwarding like the boot-image reader.

* Address review feedback

* test(android-sparse): expect partial code for chunk budget refusal

* test(android-sparse): expect partial code in MCP chunk budget refusal

* fix(artifacts): keep the chunk_sz offset when a RAW chunk outgrows its header

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local>
2026-11-26 21:16:57 +08:00
gensokyo-devandgensokyo-dev 5257f40ffb feat(android)!: count class members in summaries and page them
The inspect_android_class summary was the complete normalized class: on
VLC's org.videolan.vlc.PlaybackService, with 302 methods, it was 70,266
bytes, twice the agent result budget it was delivered for. Claude Code
saved it to a file, and REA-only agents read the class back through about
five evidence-json pages.

The class summary now carries the class name, engine, counts of methods,
constructors, overloaded method names, fields, encoded static values and
inner classes, the overloaded method names with their overload counts,
and the mapping's identity and record counts. The android-class view pages
methods (exact names, name prefixes, constructors), fields (exact names,
name prefixes, static values), inner classes and mapping symbols, and
inspect_android_class accepts it with detail summary in the same call.
Method summaries are unchanged and keep their own projector.

With real JADX on VLC the class summary was 4,601 bytes.

BREAKING CHANGE: the inspect_android_class summary, delivered for detail
summary or above the agent result budget, no longer lists methods, fields,
inner classes or mapping symbols. Page them with the android-class view,
or pass detail: "complete".

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-26 19:56:07 +08:00
gensokyo-devandgensokyo-dev 32280113a7 feat(android)!: budget trace_android_references delivery
trace_android_references returned every using node inline. On VLC's
org.videolan.vlc.PlaybackService the MCP result was 214,955 bytes, so
Claude Code saved it to a file a REA-only agent could not read, and
inspect_analysis_view did not support the operation. In two trials asking
which outer classes reference the class, Claude Code answered nothing
after 17 to 20 calls and about 870,000 tokens.

trace_android_references now takes detail and view and joins the agent
result budget. Omitted, a trace that fits delivery.agent_result_budget_bytes
is inline and a larger one is retained behind its summary. With detail
summary, view returns one android-references page in the same call. The
CLI uses the shared Evidence delivery with --view.

With real JADX on VLC the default reply was 5,987 bytes, and the
top-classes page of all 97 top classes 16,724 bytes. In two trials each,
Claude Code then answered correctly with 92,000 to 125,000 tokens, and
Codex with 208,000 to 217,000 tokens instead of 364,000 to 408,000.

BREAKING CHANGE: a trace_android_references call that omits detail on a
trace 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 19:56:07 +08:00
gensokyo-devandgensokyo-dev a16facbd9f feat(apktool)!: budget decode_android_resources delivery
decode_android_resources returned the complete decode inline. Claude Code
saves an MCP result above about 25,000 tokens to a file, so on VLC 3.7.2
(180,996 bytes) a Claude Code agent limited to REA tools never saw the
strings: in two trials it failed every answer after 20 or more calls and
about 900,000 tokens. Even string_limit 1 returned 77 KB, because the
manifest text is always inline.

decode_android_resources now takes detail and joins the agent result
budget. Omitted, a decode that fits delivery.agent_result_budget_bytes is
inline and a larger one is retained behind its summary. With detail
summary, view returns one android-resources page in the same call, so the
German and Japanese values of one string take one call. The CLI uses the
shared Evidence delivery with --view.

On VLC with real Apktool 3.0.3 the default reply was 3,368 bytes, and the
two-locale strings page 2,695 bytes.

BREAKING CHANGE: a decode_android_resources call that omits detail on a
decode 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 19:56:07 +08:00
0053ad589c fix(ghidra): pass inspected JDK to the Windows verifier (#10752)
* fix(ghidra): resolve bare java command against PATH on Windows

The Windows owned-process launcher requires absolute executable paths and
rejects bare names (ERR_REA_WINDOWS_NATIVE, Win32 87). When JAVA_HOME is
unset, ghidraJavaLaunch handed the bare "java.exe" to that launcher, so the
documented remediation ("a 64-bit full JDK 21 or newer on PATH") could never
work on Windows even with Java on PATH.

Resolve the bare command against PATH (Path/PATH, join + existsSync) before
spawning; if no candidate is found, keep the bare name so the existing
probe-failure diagnostics stay unchanged. POSIX behavior is unchanged.

Reproduction: Node 24 / Windows 11 x64, Ghidra 12.1.2, JDK 21 on PATH
(via javapath shim), no JAVA_HOME -> provider unavailable,
java_probe_failure ERR_REA_WINDOWS_NATIVE. Setting JAVA_HOME to an absolute
JDK root makes the provider available, confirming the launch path.

* fix(ghidra): resolve PATH java for inspection and harden the resolver

- resolve java.exe for installation inspection on win32: the provider-
  availability decision comes from the inspection probe, which still sent
  the bare name to the Windows owned-process launcher after the launch-path
  fix (Greptile P1)
- unwrap quoted PATH entries so installer-written directories resolve
  (XiaoBinGan Gap 1)
- throw GhidraAdmissionError java_command_unresolved with the searched
  PATH instead of silently falling back to the bare name on the launch path
  (XiaoBinGan Gap 2); an already-aborted caller keeps its cancellation
- extract the shared resolver into GhidraJavaPathResolution.ts
- add subprocess-free regression tests: inspection through a quoted Path
  entry, bare-fallback parity when java.exe is absent, resolver unit cases,
  and the launch rejection code

* test(ghidra): translate win32 fixture paths for POSIX hosts

The win32 platform option makes appendCallerPath join with backslashes
(win32.join), so the inspection tests' host readText/executable received
backslash-separated paths that only resolve on Windows. Translate the
separator back to the host's before touching the real filesystem; fixture
directories contain no literal backslashes and Windows accepts forward
slashes, so the translation is safe on both (greptile review finding).

* fix(ghidra): parse Windows PATH through the executable search owner

GhidraJavaPathResolution split PATH on every semicolon, so a quoted entry
such as "C:\Tools;Local\jdk\bin" became two candidates and the installation
inspection missed java.exe. The environment variable lookup was also
case-sensitive.

Reuse windowsPathCandidates, which preserves quoted entries, matches
environment names without case, and keeps relative entries out of the
absolute-only selection. The launch diagnostic now reads the same normalized
snapshot. Add a regression test for a quoted entry containing a semicolon.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>

---------

Co-authored-by: Z <Z@example.com>
Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-26 19:01:13 +08:00
a00511e88e fix(mcp): paginate tools/list under the FastMCP SSE limit (#9142)
* fix(mcp): paginate tools/list under the FastMCP SSE limit

Unsloth's FastMCP client rejects the single tools/list event because the full 241-tool catalog serializes to about 4.2 MB, over its 1 MiB SSE cap, so every refresh fails. The MCP SDK returns the whole catalog with no nextCursor, and the server never handled the cursor at all.

Page oversized listings at the transport seam, per the MCP cursor contract: pages stay under 896 KiB, cursors are bound to the catalog snapshot, and catalogs that fit are returned in one response as before.

* fix(mcp): track pending tools/list requests in one map

pendingToolListCursors already held every tools/list id, including
requests without a cursor. Membership, cancellation, and cleanup now
use that map.

Cursor rejection tests assert JSON-RPC -32602, then a cursorless
listing returns the complete current catalog.

* fix(mcp): count one schema discovery per tools/list pagination

The paged tools/list turns one logical discovery into several wire
requests, which broke the artifact verifier probe's per-request
counting and its duplicate injection assumed the target tool on the
first page. Count one discovery per listTools call and inject the
duplicate only on the page carrying the tool.

* fix(mcp): bind tools/list cursors to full tool definitions

A cursor digest now covers each advertised tool, so a schema change
invalidates it. One tool larger than REA_MCP_TOOLS_LIST_PAGE_BYTES
fails with a resource_constraint error instead of a successful page.

* test(doctor): keep the configuration table within its line limit

The page-budget refusal stays covered by the setting parser tests.

* fix(mcp): honor the tools/list page budget on the stdio path and register the setting

Register REA_MCP_TOOLS_LIST_PAGE_BYTES in the numeric limit registry and
the limit inventory so the numeric limit check passes.

Carry the parsed page budget from AppConfig into DeferredEvidenceMcpServer
so the default stdio startup path honors the setting instead of always
using the 917504-byte default.

Harden the page budget parser tests to surface the parse error instead of
returning early on failure.

* fix(mcp): return a fitting final tools/list page and use the parsed page budget

verifiedPage returns the remaining tools as one final page without a
cursor when they fit, instead of failing a resumed listing whose first
tool plus a cursor exceeds the budget.

parseConfig builds the page budget from parseEnvironment's admitted
number instead of re-parsing the raw environment, and the now-unused
resolveMcpToolsListPageBudget helper is removed.

* fix(mcp): use shared isRecord in tools/list pagination

Static checks flagged the local record predicate in toolListPagination.ts:
import the shared isRecord from src/domain/isRecord.ts instead.

The numeric-limit registry test still expected 15 entries after the
REA_MCP_TOOLS_LIST_PAGE_BYTES entry was added; bump it to 16.

* test(mcp): page tools/list fixtures under explicit small budgets

The compact-only presentation strips field descriptions before advertising, so the 80-tool catalog fits one page and the oversized tool fits too. Set explicit small page budgets against the advertised size. The parseConfig success test now throws the typed error before reading the value, per the test guide.

* test(config): throw typed parse errors in tools/list budget test

Greptile P2 on #9142: the budget test checked the selected parse via
an inline toMatchObject on the Result, hiding the typed error on
failure. Bind both parse results and throw their errors before
asserting values, per the repo test guide.

* fix(mcp): format tools/list pagination test to repo style

oxfmt --check flagged src/server/toolListPagination.test.ts
(the cursor-identity expectation was written expanded; oxfmt
collapses the two-element array onto one line). No behavior change.

* style(mcp): oxfmt the page-budget assertion

The Greptile P2 fix re-wrapped the expect call past oxfmt's width; run
the pinned formatter so Static checks stays green.

* fix(mcp): use the shared sha256Hex helper for the tools/list catalog digest

The architecture guards forbid a second one-shot SHA-256 hex digest;
use the shared helper from src/kernel/sha256Hex instead.

* fix(mcp): build the tools/list page-budget refusal through the shared owner helper

The architecture guard counts hand-built AnalysisResourceConstraintError
constructions; toolsListPageBudgetError() held the only new copy. The
refusal cause is a page budget, not a parse limit, so parseLimitConstraint
does not fit. Add toolsListPageBudgetConstraint() beside it in
parseFailureAnalysisError.ts and build the refusal from the page-budget
facts there; the produced error is unchanged.

Also give the pagination test SDK client the shared schema validator
from createMcpSchemaValidation, released with the client.

* fix(server): adapt instructions call to the predicate API

Main changed serverInstructions to take an advertisesTool predicate
instead of a tool-family set, and RecordedMcpCatalog gained required
toolFamilies and promptRequirements fields. The merge head no longer
typechecked, failing Build package, Documentation and Static checks.
Adapt the call site to main's own adapter shape and add the two empty
fixture fields.

* fix(mcp): restore main's tool-family scope in deferred startup

The merge dropped the family scoping main added to the deferred
startup path. A scoped stdio start advertised every recorded tool and
saved the full catalog identity, so attachRuntime rejected the selected
identity on first use. Restore the toolFamilies option, scoped
capabilities/instructions/identity, and the shared helper through
runDeferred and the deferred constructor.

* fix(mcp): share page limit facts and stream catalog sizing

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-26 18:54:35 +08:00
gensokyo-devandgensokyo-dev 523d44f6d8 feat(browser): accept retained capture references in compare_web_captures
compare_web_captures now advertises the request schema and admits it in
the application, which reads the session's retained Evidence. Each
capture field is the opaque complete observation or an exact
retained-evidence reference. The tool description says either ID works,
and inspect_web_page no longer says comparison needs the complete
capture.

Because the fields are declared reference alternatives, an inline
comparison refused for exceeding REA_MCP_MAX_INPUT_ELEMENTS names the
retained reference as its recovery. On a local Chromium 156 page with
2,000 list rows and three libraries, two complete captures were 6,701,922
bytes of arguments and were refused at the shipped allowance; the
reference request was 274 bytes and returned the same result and
parameters.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-26 15:45:19 +08:00
Vincent Koc 9ca9654500 refactor(ci): share repository identifier validation (#14678) 2026-11-26 07:27:09 +00:00
155715942e fix(limits)!: budget Rust dependency parser ceilings per call (#14666)
* fix(limits)!: budget Rust dependency parser ceilings per call

inspect_rust_binary refused a compressed .dep-v0 stream or its inflated
JSON with one fixed parser allowance. Those ceilings are now the per-call
parameters max_compressed_dependency_bytes (1 MiB),
max_inflated_dependency_bytes (8 MiB) and max_dependency_inflate_ratio
(64). A refusal is adjustable_budget and names the parameter that stopped
the parse. Allocation before the consumed length is known uses the stored
extent, including PE alignment padding. Omitted fields keep the previous
defaults.

BREAKING CHANGE: Rust dependency-parser refusals report details.limit for
the binding parameter instead of a fixed_ceiling allowance.

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

* test(rust): admit dependency sections above the former ceilings

A stored section larger than 1 MiB and 8 MiB is refused at those defaults
and parsed once both budgets are raised. A stream that inflates more than
64 times is refused at the default ratio and parsed once the ratio is raised.

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-26 06:50:51 +00:00
morluto 0eb19a395e fix(limits)!: let apktool and assetutil take producer_limits.output_bytes and type Android and process capture refusals (#14624)
* fix(limits)!: let apktool and assetutil take producer_limits.output_bytes and type Android and process capture refusals

decode_android_resources and inspect_asset_catalog refused larger apktool or
assetutil output with a fixed capture ceiling. Both now accept
producer_limits.output_bytes (defaults 4 MiB and 64 MiB) and report
details.limit for it. assetutil's budget covers each stream and the JSON
retained across catalogs, capped at 128 MiB for the in-process decode.

capture_process's retained-frame refusal reports details.limit for
limits.output_bytes, and a JADX JVM heap failure is marked as measured
exhaustion. The lipo field-retention allowance is reclassified as derived from
the native command output capture, and the JADX external DEX representation
allowance as protocol (a fraction of the bridge's local MCP frame).

BREAKING CHANGE: apktool and assetutil output refusals report details.limit for
producer_limits.output_bytes instead of a fixed_ceiling refusal.

* test(apktool): decode raised output after the default refuses it, and check deadlines leave the output budget unchanged

* fix(resources): keep a file-size refusal's observed size through failure rebuilds
2026-11-26 06:26:51 +00:00
4c9dca63a0 feat(native)!: give the Go and Rust readers max_structure_bytes and Rust max_wasm_sections (#14661)
* feat(native)!: give the Go and Rust readers max_structure_bytes and Rust max_wasm_sections

inspect_go_binary and inspect_rust_binary read the ELF directory and
Mach-O load commands through the shared container reader with the fixed
16 MiB structural allowance. Both now accept max_structure_bytes, threaded
through readBinaryContainerFromReader. inspect_rust_binary's fixed
65,536-section WebAssembly walk becomes max_wasm_sections (default 65,536,
at most 16,777,216).

Refusals report details.limit and the generated recovery. The Go budget
refusals drop their authored prose and always report their limit, so a
value at its maximum gets the generated narrowing advice.

Part of #14235.

BREAKING CHANGE: Go and Rust structural refusals and the WebAssembly
section refusal report details.limit instead of a fixed_ceiling refusal.

* chore: refresh the Go and Rust advertised schema summaries

* test: keep the Rust section-walk admission check type-correct

* refactor(native): own the max_structure_bytes refusal in the native domain

The Go and Rust providers may not import src/native, so nativeStructureConstraint moves to src/domain/native/nativeStructureBudget.ts next to the limit it builds, and every provider imports it from there.

* fix(native): report the effective Go structure budget and document max_wasm_sections

The Go limitation text named a fixed 16 MiB structural bound after a caller could raise it; it now names the effective max_structure_bytes. The Rust guide and MCP boundary test describe max_wasm_sections as a per-call control, and the admission test requires a raised value to succeed.

* fix(native): report the effective Go structure budget and Rust section control

Go inspection limitations named a fixed 16 MiB structural bound after
max_structure_bytes selected another value. The report now uses that
effective budget, including the shared default when the field is omitted.

Rust WebAssembly section refusals are an adjustable max_wasm_sections
budget. The MCP expectation, the Rust guide, and the CLI and MCP checks
follow that control, and a raised budget must admit the same module.

* style(rust): format the section-walk CLI assertion

oxfmt rejects the wrapped cast in the CLI recovery check. Static checks
run format:check, which check:fast does not.

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-26 06:25:47 +00:00
morluto 6ae722a660 feat(limits)!: register producer.output_bytes as the session default for bounded producer output (#14648)
* feat(limits): register producer.output_bytes as the session default for bounded producer output

inspect_packet_capture, decode_signal_recording and inspect_signal_decoders
share BOUNDED_PRODUCER_LIMITS, and an agent decoding several large captures or
recordings raised producer_limits.output_bytes on every call. The registered
setting producer.output_bytes (seed REA_PRODUCER_OUTPUT_BYTES, default 4 MiB)
now supplies the omitted field. A per-call value wins, then the runtime
override, then the seed, then the default. An output refusal reports the
setting's limit with its parameter and source, so the generated recovery
names both routes.

* fix(limits): refuse an invalid producer output seed after retained cleanup, forward it through setup, and cover the seed
2026-11-26 06:06:37 +00: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
morluto 0aca049128 feat(native)!: give the PE readers per-call text, entry and metadata budgets (#14659)
* feat(native)!: give the PE readers per-call text, entry and metadata budgets

inspect_pe_imports refused at a fixed 16 MiB of retained names,
inspect_pe_unwind_ranges at a fixed 2,097,152 exception-directory entries
and inspect_pe_resources at a fixed 8 MiB result. They now accept
max_text_bytes (default 16 MiB, at most 256 MiB), max_entries (default
2,097,152, at most 16,777,216) and max_metadata_bytes (default 8 MiB, at
most 256 MiB). The DLL, function and TLS callback refusals report
details.limit for max_dlls, max_functions and max_callbacks instead of
authored recovery, and an unwind refusal reports the declared entry count
as required_value.

The shared PE failure projection no longer maps an unnamed
BinaryResourceFailure to "The PE structural decoding allowance": no PE
reader produces one, since PE header and section tables are bounded by the
format.

Part of #14234 and #14235.

BREAKING CHANGE: the PE retained-text, exception-directory entry and
resource metadata refusals report details.limit instead of a fixed_ceiling
refusal.

* fix(native): update PE advertised schema summaries, test types, and assert retry success

* test: compare PE resource refusals across adapters with each adapter's control spelling

* test: avoid shadowing the CLI fixture in the PE resources parity check
2026-11-26 05:39:56 +00:00
morluto 4d3fa5a080 feat(native)!: give inspect_native_exports per-call inventory, text and structure budgets (#14658)
* feat(native)!: give inspect_native_exports per-call inventory, text and structure budgets

The native export reader refused at a fixed 262,144-row inventory, a fixed
16 MiB retained-text allowance and the fixed 16 MiB structural allowance.
It now accepts max_entries (rows and declared symbol counts; default 262,144,
at most 4,194,304), max_text_bytes (default 16 MiB, at most 256 MiB) and
max_structure_bytes, which now also bounds the ELF dynamic, symbol and
version tables located through PT_DYNAMIC.

The parser threads one NativeExportBudgets object through the ELF and PE
paths and elfDynamicExportTables; the Android JNI reader keeps the defaults.
Refusals report details.limit and the generated recovery. A declared table
count is reported as required_value; the text budget stops at the first
excess and reports none.

Part of #14235.

BREAKING CHANGE: export inventory and retained-text refusals report
details.limit for max_entries or max_text_bytes instead of a fixed_ceiling
refusal, and MAX_NATIVE_EXPORT_ROWS is renamed DEFAULT_NATIVE_EXPORT_ROWS.

* chore: refresh the inspect_native_exports advertised schema summary

* fix(native): omit lower-bound GNU hash required_value, decouple version work from max_entries, and update export recovery tests

* test: expect the lower-bound marker on a stopped GNU hash chain walk

* fix(native): cap ELF version traversal work and aggregate malformed version definition diagnostics
2026-11-26 05:39:28 +00:00
morluto 1cc655bbc0 feat(native)!: give inspect_dwarf_units a per-call max_decompressed_bytes (#14660)
* feat(native)!: give inspect_dwarf_units a per-call max_decompressed_bytes

inspect_dwarf_units refused at a fixed 256 MiB of decompressed DWARF
sections for one image. It now accepts max_decompressed_bytes (default
256 MiB, at most 1 GiB) and reports details.limit; the sections decompress
in turn, so the refusal reports no required_value.

The ELF note text, hash and scan allowance is reclassified as derived: it
equals the admitted image length plus its decoded section names.

Part of #14235.

BREAKING CHANGE: a DWARF decompression refusal reports details.limit for
max_decompressed_bytes instead of a fixed_ceiling refusal.

* fix(native): document DWARF decompression budget charges, update schema summary, and test raise-and-retry
2026-11-26 05:19:54 +00:00
morluto 31297470ef feat(artifacts): back archive member counts with the artifact.member_count setting (#14650)
* feat(artifacts): back archive member counts with the artifact.member_count setting

Archive member, entry, module and asset counts are the reader limit an
agent is most likely to raise repeatedly in one session. A new runtime
setting, artifact.member_count (launch seed REA_ARTIFACT_MEMBER_COUNT,
default 100,000), now supplies the default for artifact_limits
bun.module_count, dotnet_bundle.entry_count, node_sea.asset_count and
deno.vfs_entries. An explicit artifact_limits field still wins for that
call. A refusal at one of those fields reports the setting's limit with
the field as parameter and the value's source, so its recovery names
the per-call field and update_analysis_settings (or the launch seed on
the CLI). When a non-default session value applies, Evidence reports
the resolved effective_limits.

* test(artifacts): cover the artifact.member_count session route over stdio MCP

update_analysis_settings at 1 refuses a two-entry .NET bundle with the
setting, source runtime and both recovery routes; an explicit
artifact_limits field wins over the session value; raising the setting
to 2 admits the same bundle.

* fix(artifacts): resolve caller member counts before the session seed

When a call selects every field artifact.member_count backs, the
session value and its launch seed are no longer read, so an invalid
REA_ARTIFACT_MEMBER_COUNT cannot block an explicit per-call recovery;
a request-sourced refusal still names the setting. The setting now
lists inventory_artifact, which it also applies to.

* fix(config): own the artifact.member_count seed outside the runtime settings module

Resolving the seed through launchAnalysisSetting made
runtimeAnalysisSettings import the launch schema map, which imports
modules that import runtimeAnalysisSettings; the cycle left the bridge
reply schema uninitialized in some load orders. The seed now has its
own owner, src/config/artifactMemberCount.ts, like the pwntools input
seed, and the definition names its environment variable literally as
the numeric-limits guard requires.
2026-11-25 23:40:41 -05:00
morluto 1badb6a8ae fix(native)!: report details.limit for remaining native reader budgets and make BEAM table rows adjustable (#14631)
* fix(native)!: report details.limit for native reader per-call budgets

Devicetree, Windows shortcut, kernel build config, firmware staging and
byte-entropy refusals of caller-selected budgets named their control only
in remediation prose. Each now sets details.limit from a domain-owned
budget object that also builds the schema (src/domain/parameterBudget.ts),
so the reported range is the one the next call accepts.

inspect_devicetree's fixed 32 MiB decoded representation allowance becomes
the per-call max_decoded_bytes (default 32 MiB, 1 KiB to 256 MiB); its
refusal reports boundary max_decoded_bytes instead of decoded_bytes.

The pwntools allocation failure declares measuredExhaustion, the firmware
inherited RLIMIT_FSIZE refusal declares measuredExhaustion, and the LLDB
combined-result ceiling is a registered representation bound.

Part of #14234 and #14235.

BREAKING CHANGE: inspect_devicetree's decoded-representation refusal reports
reported_limits.boundary "max_decoded_bytes" with details.limit, instead of
"decoded_bytes".

* fix(native): keep FIT decoded-budget boundary, LLDB narrowing and entropy length range exact

The FIT reader compared the renamed devicetree limit against decoded_bytes, so a decoded-budget refusal became capacity; it now checks max_decoded_bytes, with a test. The LLDB representation ceiling keeps a short name and carries its recovery as narrowing. The byte-entropy length maximum is the window the selected block_size admits.

* fix(cli): describe inspect-devicetree --max-decoded-bytes

* refactor(native): let the generated adjustable-budget recovery name the native reader controls

With #14625 the refusal owns per-call recovery, so the devicetree, Windows shortcut, kernel build config, firmware staging and byte-entropy refusals drop their authored sentences. inspect_byte_entropy reports the smallest admitting block_size as required_value.

* fix(native)!: report details.limit for remaining native reader budgets and make BEAM table rows adjustable

inspect_elf_dependencies, inspect_elf_unwind_ranges, inspect_apple_ips,
inspect_dwarf_units, inspect_native_initializers and inspect_pe_resources
named their per-call budgets only in remediation prose. Each now reports
details.limit from a domain-owned budget object that also builds the
schema. The unwind per-page symbol-name text refusal names the page size
`limit`, the control that admits it.

The fixed 65,536-row BEAM table ceiling becomes the per-call
max_table_rows (default 65,536, at most 1,048,576).

The plist nesting allowance is reclassified as a representation bound
(MAX_JSON_DEPTH less the report envelope). GPU and APK input refusals that
named their fixed allowances only in prose now declare them, registered
as pending #14235.

Part of #14234 and #14235.

BREAKING CHANGE: a BEAM table-row refusal reports details.limit for
max_table_rows instead of a fixed_ceiling refusal.

* fix(native): keep naming the dependency and BEAM row controls in recovery

* refactor(native): let the generated adjustable-budget recovery name the remaining native controls

With #14625 the refusal owns per-call recovery, so the ELF dependency, ELF unwind, Apple IPS, DWARF, initializer, PE resource and BEAM refusals drop their authored sentences. BEAM reports the complete row and atom counts as required_value. The unwind per-page text allowance is a registered fixed allowance whose narrowing names a smaller limit, because a larger page would not admit it.

* style: format the PE resources provider test

* refactor(native): keep one owner of the IPS budget bounds and document the unwind text allowance
2026-11-26 04:31:33 +00:00
Vincent Koc 43117a8ae0 perf(ci): omit unused PR associations from timing queries (#14636) 2026-11-26 04:30:46 +00:00
Vincent Koc fb1b4c0fbb perf(ci): resolve small pinned test batches directly (#14638) 2026-11-26 04:30:33 +00:00
Vincent Koc 25c27df316 chore(deps): update lossless-json to 4.3.4 (#14634)
* chore(deps): update lossless-json to 4.3.4

* fix(capture): report locked JSON parser versions in evidence

* fix(contracts): refresh capture examples from decoded evidence
2026-11-26 12:29:29 +08:00