Commit Graph
1925 Commits
Author SHA1 Message Date
morluto bdba620af3 fix(mcp): serve input rules agents need within every client's schema budget (#15393)
* test(mcp): check schema parity against the served tools/list

Schema parity tests registered contracts on a bare SDK server, so they
checked a schema REA never serves and missed the compact presentation's
losses (#15310, #15311).

- Add servedToolCatalog, which lists every tools/list page from a session
  server, and use it for parity checks in toolSchemaValidity and
  advertisedDialect.
- Add a catalog-wide test that derives one violating value per
  constrained canonical field from each contract example and requires
  the served schema to reject it or the served description to name the
  rule. Today's gaps are listed by root cause; an entry that stops
  matching fails the test.
- Remove absoluteLocalPathTools.test.ts; the catalog test covers every
  absolute-path field it checked.

Refs #15328

* test(mcp): add a seeded property and visited fields to served parity

- Generate string values for every constrained string field with a fixed
  fast-check seed; the refinement gaps it found (rules in .refine() with
  no served keyword or guidance) are listed with a violating value each.
- Assert the sweep derives violations for root, nested and array
  absolute-path fields.
- Check canonical schema validity against the contract schemas directly
  instead of a bare SDK server, and drop the served-listing test that
  validated canonicalInputSchema.
- Move the reserved environment key check into the compact handler test,
  which now requires the served description to name the rule.
- testing.md: assert parity against the served tools/list.

Refs #15328

* fix(mcp): advertise the absolute-path pattern and dialect-dropped rules

absoluteLocalPathStringSchema serialized as two allOf patterns, and the
dialect projection kept only the first (NUL-free), so every absolute-path
field advertised a schema that accepts relative paths.

- absoluteLocalPathStringSchema emits one pattern: the absolute envelope
  over a NUL-free path. NUL is still refused first with its own message.
- mergeAllOf conjoins exactly what it can: bounds keep the tighter value
  and negated-class patterns become one class. A pattern it cannot
  conjoin is named in tool guidance instead of dropped silently.
- multipleOf, length bounds of 1999 or more and exclusive bounds on
  non-integers become tool guidance, including on nullable values.
- Move the allOf merge into advertisedAllOf.ts.

Fixes #15310
Refs #15328

* fix(mcp): keep defaults, scalar rules, examples and field semantics in compact schemas

Compact input schemas dropped facts an agent needs for a correct first
call: every default, the enums and bounds of reduced root properties, any
example for reduced or pruned schemas, and the Frida cross-field rules.
Name-keyed fallback descriptions also labelled fields of another type.

- Tool guidance names root property defaults in one "Defaults:" sentence.
- A reduced schema keeps the enum, const, pattern and bounds of each
  scalar root property.
- A reduced or depth-pruned schema states its smallest canonical example
  (up to 1,024 bytes), and a pruned schema says nested fields are omitted.
- Frida contracts state each cross-field rule once, as the refusal and
  the root description.
- Fallback descriptions apply only to a property of the JSON type they
  describe; they move to propertyFallbackDescriptions.ts.

Refs #15311
Refs #15328

* test(mcp): validate the served schema in three advertisement tests

compare_artifacts sources, compare_web_captures inputs and the
analyze_javascript_application source selection called a canonical or
bare-server schema advertised. They now validate the served listing;
canonical rejections stay on the contract parser, and the gaps the
reduced form leaves are asserted with a pointer to the parity list.

Refs #15328

* test(mcp): check recovery promises on an agent's first wrong calls

Calls every served tool with generated wrong arguments on a session with
nothing open: an unknown path key, an omitted required field, valid
arguments for an active-target tool, a missing file and an unknown id.
Every refusal must name only advertised tools, name open_binary for an
active-target tool, give no schema remediation to arguments the served
schema accepts, and claim retryable only when an identical replay can
succeed. A seeded property varies the guessed key and missing path.

Known failures are listed by root cause (#15309, #15312, #15323 and the
active-target declarations #15350 removes); a new failure or a stale
entry fails the sweep.

* test(mcp): assert the served schema where tests claimed the advertisement

Five tests validated the canonical schema and called it advertised, so they
asserted rules the served tools/list does not carry: batch_decompile
maxItems, inspect_api_contract format and view, the inspect_dart_aot length
and line-terminator rules, extract_artifact uniqueItems, and examples on
compare_javascript_export_shapes. Each now validates the served schema and
keeps the handler enforcement. A missing rule is pinned as a known gap (in
the parity sweep where it can see the field, or beside the test where the
contract example leaves it unreachable), so the expectation fails once the
rule is served.

The parity sweep now also derives maxItems and uniqueItems violations from
example arrays; it finds inspect_managed_members type_names uniqueItems.
Two value-correct tests are relabelled and check the served schema too.

* fix(mcp): fit every advertised input schema under Codex's 5,000-byte compaction threshold

Codex compacts any MCP input schema above 5,000 serialized bytes and drops
descriptions and nested structure first, so update_analysis_settings
reached the model as a list of empty objects with no setting IDs. Lower the
advertised input budget from 13 KiB to 5,000 bytes, bound $ref expansion
separately so projection and depth pruning are judged on their result,
and advertise update_analysis_settings changes as one object whose setting
enum lists every ID; the canonical parser still enforces each setting's
bounds.

Refs #15339

* fix(mcp): address review findings across the served-schema stack

Keep the recorded description, or its absence, when the deferred runtime
materializes, so discovery and the loaded listing agree. Measure example
guidance in UTF-8 bytes once, resolve defaults through each property's own
reference scope, keep root names and types when scalar rules alone would
overflow the reduced form, and decline joining negated classes that a
literal hyphen could turn into a range.

Served parity now counts guidance only when one sentence labels the field
and states its rule, and counts uniqueItems guidance. That stricter match
exposed seven gaps the loose match hid; they join their root causes, and
the fixed arrayRules gap is removed. The first-contact sweep keys findings
by check, checks a structured next step against the served catalog, and
uses the catalog's own MCP settings.

* chore(mcp): refresh advertised catalog summaries

* fix(paths): keep the NUL path refusal's format reason

Moving the NUL check out of the advertised pattern turned its issue into a
custom refinement, so tool refusals reported reason invalid_value instead
of invalid_format with expected regex. The check now raises the same
format issue, and still stops before the absolute-path rule.

* fix(mcp): state the optional Frida device choice and match bounds by rule

The Frida device rule now says both fields may be omitted for the local
device. Served parity matches a numeric bound by its direction, unit and
complete value, so another bound on the same field cannot cover it.

* test(mcp): stop pinning served-schema omissions in workflow tests

Workflow tests asserted that the served schema accepts values runtime
refuses, so serving a rule would fail them. They keep the valid-input and
runtime-refusal checks; the catalog-wide parity sweep tracks what is
served.

* test(mcp): count a required field only when guidance requires it

A sentence that only mentions a field, or a same-named key under another
parent, no longer covers a missing required rule. Guidance must state the
requirement about the field's full path, or state a shape listing every
required key of the field's parent.

* test(mcp): credit a served rejection only to the rule that failed

The parity sweep counted any served rejection as coverage, so a probe that
also broke another rule (a too-long locale that breaks its pattern) hid a
missing bound. Served validation now reports every failing keyword, and a
rejection covers a rule only when that rule's served keyword fails.
2026-12-01 00:23:37 -05:00
morluto 0e07a3c876 fix(delivery)!: deliver over-budget results and errors inside the agent result budget (#15396)
* fix(mcp)!: deliver over-budget delivery facts inside the structured result

Codex and VS Code forward only structuredContent to the model, and Gemini
CLI and LangChain forward only the text blocks; _meta reaches no model. An
over-budget result put its delivery facts in a second text block and in
_meta, so Codex and VS Code agents received a summary with no sign that it
was one.

An over-budget result is now {summary, delivery} in structuredContent,
the shape the CLI already prints, and its one text block is that value's
serialization. The delivery layer owns the alternative: every budgeted
operation's registered output schema admits it, so canonical and compact
advertisements validate the result.

An overflowing completed result no longer picks its recovery by tool
name. The producer declares an overflow recovery (stateless, retained or
committed, with its next call and identities): list_unknowns,
get_evidence_bundle, inspect_address_context and committed unknowns
declare theirs in their bindings, and retained Evidence declares its own.
Undeclared results fall back to the contract's effects. Only a CLI
contract that reads no session is told to use its `rea` command, so
session reads and committed mutations are never told to use CLI JSON.

BREAKING CHANGE: When a budgeted tool's omitted detail returns a retained
summary, structuredContent is {"summary": <summary Evidence>, "delivery":
<delivery facts>} instead of the summary Evidence, the second
{"delivery": ...} text block is gone, and _meta["rea/agent-budget-delivery"]
is no longer set. Read the summary from structuredContent.summary and the
delivery facts from structuredContent.delivery (or the same members of the
text block). Pass detail "summary" or "complete" to receive Evidence at the
root as before.

Refs #15338
Refs #15326

* fix(delivery)!: deliver every error result under the agent result budget

A failure whose text exceeds delivery.agent_result_budget_bytes is now
retained whole as Evidence (mcp_tool_error in the MCP session,
cli_command_error in the CLI's private cache) and replaced by a bounded
summary. The summary keeps the code, category, retry, recovery and
remediation and every detail field that fits, names the fields it left
out, and carries details.failure_delivery with the inspect_analysis_view
call that pages the complete failure. Non-Evidence facts such as a
mid-extraction artifact inventory were previously inlined whole.

The transport's unretained string-ceiling fallback no longer points at
complete CLI JSON output.

BREAKING CHANGE: An MCP error, or a one-shot CLI failure without
--evidence_output, larger than the agent result budget is delivered as a
bounded summary: oversized details fields are listed in
details.omitted_details instead of being inlined, and
details.failure_delivery names the retained failure Evidence and the
inspect_analysis_view call that pages it. Pass detail complete (CLI
--detail complete) for the complete failure inline, or raise
delivery.agent_result_budget_bytes.

Refs #15326

* fix(delivery): keep overflow recovery from repeating effects or losing the session target

A retained overflow no longer offers the CLI command: the retained record is the complete result, and a call with effects is told not to repeat it. The CLI fallback for an unretained result excludes session tools. The MCP result guarantee is limited to successful results. The schema validity test selects the complete-result alternative of a budgeted output schema.

* fix(delivery): keep failure summaries schema-valid and CLI failure retention self-contained

boundedFailureSummary restores the details a code's schema requires. The CLI retains the failure as it was before its partial observation was summarized, so the record does not depend on a partial file the cache could evict, and a cache write that commits before failing or leaves cleanup incomplete keeps its receipt and cleanup owner.

* fix(delivery): retain the delivered CLI failure with its complete partial restored

* fix(delivery): budget CLI-enveloped failures through the envelope's owner

Provider-backed CLI commands wrap the canonical failure in their error envelope (a label and input diagnostics). The strict projection schema rejected the wrapped failure, so an over-budget failure printed whole without being retained. The envelope's owner now splits it; delivery budgets the canonical failure and keeps the envelope fields on the bounded result. CLI logging uses the same splitter instead of its own destructuring.

* fix(cli): print a bounded failure's retrieval facts on a terminal

A failure bounded to the agent budget carries its retained record and paging call in details.failure_delivery. The terminal presentation printed only the concise error for it, because its preserved-Evidence check did not know that field. It now does, so the structured failure is printed whole.
2026-12-01 04:10:00 +00:00
Saim Shafique 1c00958431 fix(android): advertise portable DEX descriptor patterns (#15392) 2026-11-30 21:37:47 -05:00
morluto 4d84c6919f fix(frida): recover detached sessions and report why Frida detached them (#15357)
* fix(frida): give detached and unknown sessions lifecycle recovery

A session whose target detached was refused with the unknown-session error,
"No open Frida session; start one with start_frida_session", although the
session is still held, frida_session_status still returns its remaining
messages and close_frida_session must still release it. Following the advice
abandoned the session and its messages.

load_frida_script and resume_frida_session now refuse a detached session with
a capability refusal naming frida_session_status, then close_frida_session.
Unknown session and script IDs conform to the input contract, so their
recovery names the lifecycle tools instead of schema guidance, matching the
gdb and rizin session errors.

Refs #15329

* fix(frida): track session phase and report why a session detached

ManagedSession kept attachment as a `detached` boolean beside
`cleanupStarted` and `resumeAfterDetachPending`, and the `detached`
signal handler ignored Frida's (reason, crash) arguments, so an agent
could see that a session detached but not whether the target exited,
crashed, or the connection dropped.

The session now has one phase: attached, detached with its detachment,
or closing with the detachment seen so far and whether a paused spawn
still owes a resume. The signal arguments are parsed at the native
boundary; a detach seen only through isDetached() is recorded as
`unobserved`. frida_session_status, start_frida_session and
instrument_with_frida report an optional `detachment` with Frida's
reason and crash summary, and the detached-session refusal names the
reason. close_frida_session cleanup is unchanged.

Refs #15329

* fix(frida): report whether a retained crash summary was truncated

A crash summary is bounded to 4096 bytes; detachment output now carries
crash_summary_truncated so a clipped summary is not presented as
complete. The detached-session test also proves messages captured before
the detach stay readable. Commits the advertised schema summary for
start_frida_session.

* docs(frida): state why the crash summary bound is fixed

* fix(frida): keep Frida's one-line crash summary complete instead of capping it

The 4096-byte cap had no format, protocol or resource reason, and cutting
the summary left no way to read the rest. The summary is now kept whole
apart from credential redaction, so the truncation flag and constant are
removed.
2026-12-01 02:36:09 +00:00
morluto 2d1748117e fix(browser): redact literal credentials in browser scenarios unless retained (#15347)
* fix(browser): redact literal credentials in browser scenarios unless retained

capture_browser_scenario records the scenario in Evidence parameters as
written. A literal Authorization header value or cookie seed therefore stayed
verbatim in Evidence, while the same record's network events redacted it.

Literal values of transport-credential headers (isTransportCredentialHeader)
and cookie seeds are now redacted like declared secrets. One domain owner,
scenarioLiteralCredentials, lists them with their redaction identities; the
capture session adds them to its redaction set, and Evidence parameters and
scenario_sha256 record the redacted scenario. A caller that wants the literal
kept sets retain_literal_credentials: true. Other literals stay ordinary
evidence; secrecy is not inferred from names.

Refs #15340

* test(browser): assert whole-value redaction instead of any change

not.toBe(value) also passed for partial redaction, such as a marker appended
with the secret left in place. Assert that each redacted value is exactly one
marker and that no fragment of the secret or its JSON-escaped form remains in
text, bytes, URLs or protected response bodies.

Refs #15340

* fix(browser): redact the trimmed spelling of padded literal credentials and commit the schema summary

* fix(browser): treat a credential header's prefix as part of its literal credential and retain fingerprint fixtures

* fix(browser): keep the bare literal token redacted beside the prefixed header
2026-12-01 02:27:15 +00:00
morluto d09fa76eca fix(debuggers)!: report the inferior disposition that debugger cleanup established (#15353)
* fix(debuggers)!: report the inferior disposition that debugger cleanup established

The shared owned-debugger stop returned `stopped` or `already_exited`
without saying what happened to the inferior, so close_gdb_session
re-derived a local target_state (reporting a verified -target-detach as
"unknown") and close_rizin_debug_session always returned the literal
"unknown".

The stop result now carries one InferiorDisposition (none_observed,
detached, exited, or unknown with the provider's reason), mapped once
from the recorded detach outcome. `stopped_inferior_unknown` is folded
into it. Providers report a verified state through `verifiedInferior`
(replacing `inferiorStateUnknown`), and a detach whose identified
inferior then ended reports `inferior-ended` instead of `no-inferior`.
GDB tracks its verified inferior state as a union instead of a boolean,
so the detach that close performed is still reported after the debugger
stops. Both close tools return `target_state` from the stop result.

Refs #15324

BREAKING CHANGE: close_gdb_session and close_rizin_debug_session
output `target_state` is now one of none_observed, detached, exited or
unknown. close_gdb_session previously returned only none_observed or
unknown; close_rizin_debug_session always returned unknown. Clients that
validate output against the previous schemas must accept the new values;
`unknown` keeps its meaning (the debugger was terminated without a
verified detach, so the inferior may still be running).

* test(debuggers): type the lifecycle close fake with the full inferior disposition

* test(debuggers): commit close schema summaries and prove what a failed close keeps

Commits the advertised schema summaries for close_gdb_session and
close_rizin_debug_session. The GDB manager test now asserts the close
itself stopped the owned process, and the external-mutation lifecycle
test asserts a command refused behind a failed close is that retained
cleanup blocker and never reaches the debugger.
2026-12-01 02:19:09 +00:00
morluto fbfcad3152 fix(evidence): route web script export and WASM comparison through shared Evidence inputs (#15385)
* fix(evidence): resolve web script and WASM comparison sources through the shared Evidence input owner

export_web_scripts accepts its capture as declared Evidence input: a
complete record, a retained reference, or a retained inspect_analysis_view
summary, which reads its retained parent. compare_wasm_interfaces admits
both sides through resolveEvidenceRequest, so a malformed side is a
bounded evidence_integrity_mismatch and a summary reads its parent. The
summary-to-parent rule lives in the shared resolver as completeProducers.
A catalog test checks that every declared Evidence input resolves a
retained reference through the shared resolver.

Refs #15341

* fix(evidence): retain an inline web script capture before publishing and commit the schema summary
2026-11-30 20:42:45 -05:00
Ysopwnableandgensokyo-dev 3e3c2ba1cc feat(artifacts): inspect SWF and extract embedded payloads (#15264)
Inventory FWS and CWS files through the shared artifact reader. Preserve the
carrier and normalized identities, top-level tag counts, and individual
DefineBinaryData occurrences. Use the existing selected-extraction pipeline and
per-call artifact admission controls.

Refs #3614

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-12-01 00:41:11 +08:00
ShuaixinHuangandVincent Koc 3f6260249c fix(api-contract): report structured retained-facts allowance (#15256)
* fix(api-contract): report structured retained-facts allowance

* fix(limits): track contract retention as a pending resource policy

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-12-01 00:23:06 +08:00
BeqaandVincent Koc 130243a7c1 fix(setup): recognize path-qualified cmd.exe and npm rea.cmd shims (#15045)
* fix(setup): recognize path-qualified cmd.exe and npm rea.cmd shims

Unwrap C:\Windows\System32\cmd.exe /d /c package runners, and read the
script an npm rea.cmd shim launches so those registrations stay owned.

* fix(setup): parse npm rea.cmd launch statements with a bounded read

Own only the script argument of the npm cmd-shim launch line, skip rem
comments, refuse oversized files before allocating, and join with host
path rules so UNC roots stay intact.

* fix(setup): ignore echoed npm launch text in rea.cmd shims

Skip echo lines and refuse ownership when a later "%_prog%" launch names
a non-package script, so printed paths cannot prove an unrelated row.

* fix(setup): require executed npm rea.cmd launch statements

Anchor "%_prog%" matching to a real launch command, skip @rem comments,
and ignore conditional echo lines so ownership cannot follow text that
is never executed.

* fix(setup): require strict npm cmd-shim structure for rea.cmd ownership

* fix(setup): match exact npm cmd-shim template for rea.cmd ownership

* fix(client-identity): reject batch variables and support local node_modules/.bin rea.cmd shims

* fix(setup): recognize current npm command shims

* fix(ci): route CMD shim tests to the Windows package lane

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 23:53:39 +08:00
ShuaixinHuangandVincent Koc bd6ff678c4 feat(artifacts): inventory standalone Unix ar archives offline (#15224)
* feat(artifacts): inventory standalone Unix ar archives offline

* test(artifacts): align standalone ar assertions and comparison docs

* fix(artifacts): preserve ar names, admission and permission uncertainty

* chore(contracts): refresh ar admission schema summaries

* fix(artifacts): handle GNU thin references and exact name budgets

* perf(artifacts): cache ar name-table observations

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 22:46:35 +08:00
ShuaixinHuangandShuaixinHuang 4886a406f9 fix(release): recover verified versions after npm advances (#15234)
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
2026-11-30 22:39:39 +08:00
fbb113b0d0 fix(release): confirm npm absence with an exact-version lookup (#15233)
* fix(release): confirm npm absence with an exact-version lookup

* test: cover the reviewed CI boundary cases

* fix(release): share the npm registry lookup deadline

---------

Co-authored-by: ShuaixinHuang <ShuaixinHuang@users.noreply.github.com>
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 22:34:39 +08:00
Adolanium 9d5c5f687d fix(process): accept legal characters in Windows batch paths (#15128)
* fix(process): quote Windows batch operators cmd.exe keeps literal

cmd.exe with delayed expansion off keeps & | < > ( ) ^ ! literal inside quotes. Empty tokens and %name% spans are still refused, including when that name is unset, because the child environment can define it.

* fix(process): report a refused batch path as invalid configuration

A percent expansion or an unusable COMSPEC is configuration_invalid. Packet capture does not append the Wireshark install remediation, and an apktool decode does not report a capability gap.

* fix(process): refuse percent spans joined across batch tokens

cmd.exe expands a percent span on the joined command line. Tokens that
are legal alone are refused when joining them forms a span. The spawn
regression kills its child if that child is still running after 10 seconds.

* test(process): include the Windows batch regression in CI

The curated Windows lane now runs WindowsBatchCommand.test.ts.

* fix(domain): preserve a configuration error's caller message

ConfigurationError accepted userMessage and dropped it, so the public
projection replaced the caller text with the generic doctor sentence.
The constructor now stores that message.

* fix(pcap): keep a batch refusal in the public configuration message

A Windows batch refusal stays in the configuration error the caller
sees, including the refused path and the percent-expansion reason.

* fix(apktool): report a decode batch refusal as invalid configuration

Inspection still reports not_configured. Decoding reports
configuration_invalid and names the launcher that cmd.exe cannot receive.
A percent span that appears only after the quoted tokens are joined is
refused the same way.

* test(process): own the Windows batch regression in the package lane

The curated Windows job already runs WindowsBatchCommand.test.ts. The package scope did not name that file, so the lane ownership check reported it as unowned.
2026-11-30 22:28:54 +08:00
Lucien b0a910b8f4 fix(update): report Frida native module readiness (#7216)
fix(update): report Frida readiness after verified updates
2026-11-30 22:26:52 +08:00
ShuaixinHuangandShuaixinHuang 8c3491439e fix(release): bind every publication preflight to its target branch (#15232)
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
2026-11-30 22:17:19 +08:00
54a700e18c fix(ghidra): use host transport defaults for direct clients (#6410)
* fix(tests): make three Windows-failing tests pass and give the Ghidra transport one owner

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* test(ghidra): cover the per-platform default bridge transport

defaultGhidraTransport had no direct test. Pins authenticated loopback TCP on win32 and a Unix socket on linux and darwin.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* test(ghidra): retain Windows transport boundary coverage

* test(ghidra): align Java fixtures with their host platform

* ci(ghidra): verify transport and byte search on Windows

* test(ghidra): keep Windows probes in the existing test process

* fix(ghidra): await complete Windows endpoint publication

* test(ghidra): use owned child identities for Windows fixtures

* ci(ghidra): own the Windows transport regression inputs

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 21:51:57 +08:00
AfloatandVincent Koc 66f0882ece fix(config): validate target and loader options before printing MCP registrations (#9279)
* fix(config): validate target and loader options before printing MCP registrations

* Preserve executable mode of MCP configuration helper

* Format MCP config CLI and its validation tests

* Run MCP configuration printer regressions in the process boundary suite

Move the config printer's valid, invalid and help cases into the registered MCP launcher Vitest suite. Run the real script with the test-scoped process fixture so CI owns each child and checks its output and exit code.

* test: align verification fixtures with current public contracts

Keep the production changes from upstream and update the verification consumers that still asserted their retired contracts:

- assert unknown workflow identity structurally and retain the bounded provider caveats;
- observe the process capture's partial-error delivery while preserving live cleanup ownership assertions;
- use the package's declared imports in the isolated release controller;
- refresh the replay card digest after the Evidence subject identity migration;
- use the supported compact Kimi profile while testing case-insensitive environment keys;
- assert each public interface's own capture issue path.

These are shared test and verifier compatibility repairs. The evidence summary pagination and config-printer feature changes remain separate.

* test(mcp): observe Kuna close failures at the session owner

Read the original session.close promise result when checking cleanup retry guidance. This keeps the real typed error and all retry assertions while avoiding the retired delivery path after upstream #11647.

* test(mcp): assert DOL snapshots through target identity

Follow the upstream target identity migration in ff017625 (#11551). Preserve the exact DOL format, architecture and entry-point assertions together with the snapshot replay and provider-call checks.

* test: align CLI and progress fixtures with shared owners

Reuse the core registrar for decompile-all instead of registering it twice
after upstream #11680. Assert the outer MCP start/completion notifications
separately from provider cleanup progress introduced by #11637, retaining
cleanup, rate, timeout, cancellation, and evidence assertions.

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 20:35:43 +08:00
2SinceJuly aea385cda1 feat(evtx): inventory Windows event log records offline
Inventory EVTX file, chunk and record headers with source-scoped identities, full timestamp precision and explicit partial coverage. Discover the reader from first-contact inspection.

Refs #9174.
2026-11-30 20:25:14 +08:00
SandivandVincent Koc f5055cd2ed fix(process): report denied inspection as typed cleanup failures (#9261)
* fix(process): report denied inspection as typed cleanup failures

Preserve the native ps diagnostic through owned-worker cleanup and finalize one-shot JavaScript analysis before Evidence delivery. Retain mandatory inspection and existing cleanup authority.

Preserve the inspector diagnostic when the initial process-table read succeeds but pre-signal revalidation fails, and remove the unreachable typed-error branch so retained artifact retry failures project through the existing cleanup contract.

* fix(resources): preserve independent close failure ownership

* fix(cli): retain cleanup recovery and nested close evidence

* refactor(providers): classify rejected closes at the shared boundary

* test(cli): preserve bundle metadata and physical inspection failures

* fix(cli): preserve the JavaScript failure envelope after finalization

* test(cli): validate the JavaScript error envelope at its boundary

* fix(providers): preserve unnamed close failure resources

* fix(cli): retain invocation owners through outer cleanup

* test(cli): distinguish reported cleanup failures from uncaught errors

* fix(cli): compose each runtime’s declared cleanup owners

* test(cli): preserve the original cleanup rejection

* test(cli): allow cleanup retry recovery after a reported failure

* fix(cli): report final cleanup after returned results

* fix(cli): preserve launcher executable mode

* test(cli): retain invocation cleanup in file sessions

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 19:38:45 +08:00
608378c311 fix(windows): reject native addons with unusable delay-import tables (#15216)
* fix: deepen verified coverage for PR #14258

* fix(windows): recognize GNU delay-import terminator placement

* fix(windows): validate complete delay-import address tables

* fix(windows): validate delay-load descriptor targets

* fix(windows): validate delay-import function names

* fix(windows): bound delay imports to the dedicated IAT section

* test(windows): cover delay-import verifier refusals

* test(windows): cover nonzero delay-import padding

* fix(windows): require readable delay-import descriptors

* test(windows): accept read-only delay import names

* fix(windows): validate initial delay loader state

---------

Co-authored-by: ShuaixinHuang <ShuaixinHuang@users.noreply.github.com>
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 19:18:16 +08:00
a5aee4f9e9 feat(artifacts): inventory Android super image metadata (#14928)
* feat(artifacts): inventory Android super image metadata

Refs #14391

* fix(artifacts): preserve partial Android super metadata evidence

* fix(artifacts): recognize Android super PE overlays

Refs #14928

* fix(artifacts): reject an Android super device with no usable sector

A first usable sector at the device size was accepted, so extent checks
reported a different field. Keep stored copy failures to malformed,
truncated, and unsupported now that format failures include unrecognized.

* fix(artifacts): preserve Android super partial evidence on budget exhaustion

* fix(mcp): preserve existing provider partial observation contracts

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-30 06:15:43 -05:00
ShuaixinHuang 81657ccede fix(analysis-view): return continuation for GPU pages at the byte limit (#15206)
* fix(analysis-view): return continuation for GPU pages at the byte limit

* test(analysis-view): admit GPU pagination requests through the schema

* fix(analysis-view): reuse shared byte-bounded GPU pagination
2026-11-30 19:09:46 +08:00
HolyDEEW 6ec105be6d fix(screenshots): report the PNG comparison memory allowance (#15217)
* fix(screenshots): report the PNG comparison memory allowance

* style(screenshots): format memory allowance assertion
2026-11-30 19:08:39 +08:00
Saim ShafiqueandVincent Koc 60de294646 fix(process): compare Windows server paths by native realpath (#15044)
* fix(process): compare Windows server paths by native realpath

compareServerPaths returned mismatch for every non-equal Windows path,
so case, separator, 8.3, and junction spellings of the running server
were reported as registration_path_mismatch. Compare native realpaths
on Windows, matching registration identity: a different existing file
still mismatches and an unresolvable path stays unknown.

* test(process): run the server path identity regression on Windows

The injected win32 platform only selects the comparison branch; on
the Linux source-test host realpathSync.native still uses POSIX
rules, so Windows letter case, separators, and junction behavior
were unverified. Add Windows-only spelling cases beside the portable
regression and include the file in the curated Windows lane, with
the lane guard asserting it stays there.

* ci(windows): own the server identity regression in the package lane

The Windows lane now runs serverIdentity.test.ts, so the package scope
must own that path for the native-host lane ownership check.

* docs(process): clarify server path comparison authority

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 19:05:38 +08:00
Vincent Koc c12177ce0d perf(ci): confirm test-only macOS selection on Linux (#15203)
* perf(ci): confirm test-only macOS selection on Linux

* fix(ci): keep explicit Apple scope in job admission

* perf(ci): publish the build cache only for confirmed consumers
2026-11-30 18:51:07 +08:00
Dery FerdikaandVincent Koc 81384ecfdc fix(conformance): validate paired fixture count expectations (#14125)
* fix(conformance): refuse a fixture that declares half of a count pair

A counted expectation is a pair: the prefix selects the records and the count is
what the verifier binds to the source. Admission accepted either half, and
verifyCount returned silently when one was missing, so a fixture could declare
the invariant and never have it checked while verify:fixtures still reported
the fixture as verified.

Require both members in parseConformanceFixtureManifest and treat a half pair
at verification time as a producer defect instead of skipping the count.

* fix(fixtures): validate counted expectation types

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 18:01:46 +08:00
Saim ShafiqueandVincent Koc 31cec30f51 fix(android): declare Android mapping and JNI fixed allowances (#15183)
* fix(android): declare Android mapping and JNI fixed allowances

* fix(android): avoid ineffective JNI allowance recovery advice

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 17:38:39 +08:00
91380cff6a fix(ci): run npm lifecycle hooks in selected host lanes (#15169)
* fix(ci): run npm lifecycle hooks in selected host lanes

* fix(ci): avoid nested lifecycle hooks in host lanes

---------

Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 16:19:02 +08:00
CyberSproutandVincent Koc 6c7dffc59b fix(json): classify JSON input heap headroom and string-ceiling refusals (#14949)
* fix(json): classify JSON input heap headroom and string-ceiling refusals

Mark live V8 heap-headroom refusals in JsonInputFile as measuredExhaustion, bind single-string runtime and serialization ceilings in JsonInputFile and JsonAuthenticationHeadroom to registered representation allowances, and remove all 4 entries from untyped-budget-refusal-baseline.json (Refs #14234).

* test(json): inject runtime probes instead of mocking node:v8

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-30 15:55:37 +08:00
CyberSprout 0985a6b053 fix(windows): report the ACE count a private DACL check observed (#14450) 2026-11-30 13:33:02 +08:00
morluto cb7627efea fix(release): advance the GitHub Actions example pin with the package (#15144) 2026-11-29 22:26:53 -05:00
6f36de3012 feat(ghidra): admit raw 8051 images (#15057)
* feat(ghidra): admit raw 8051 images

Add 8051 as a raw-only architecture: byte-aligned entry, mapping within
0x0000..0xffff, analyzed by Ghidra with 8051:BE:16:default in the CODE
space. Hopper, IDA, Kuna and Windows Ghidra P0 keep refusing it.

Document the lane, including that bank-switch thunks and Keil ?C?CCASE
switch arms are not followed by auto-analysis and need
REA_GHIDRA_SEED_FILE entries.

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

* test(mcp): update the advertised open_binary schema summary for raw 8051

The architecture enum gained 8051, so the committed input schema digest
for open_binary changed. Regenerated with
`npm run verify:advertised-schemas -- --update-summary`.

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

* test(ghidra): pin the 8051 CODE binding and correct the 8051 docs

- Assert the 8051 language binding (8051:BE:16:default, CODE) and that
  load-image attestation requires the CODE default space; replacing CODE
  with ram now fails three tests.
- Assert that Windows Ghidra P0 refuses raw 8051.
- Derive the raw-binary architecture refusal from BINARY_ARCHITECTURES
  with Intl.ListFormat; the wording, and so the admission grid digest,
  is unchanged.
- Docs: list the memory blocks Ghidra really creates for 8051 (no
  external RAM block), explain bank addressing for paged banks and the
  entry-decode requirement, state when the seed file is read, and add
  8051 to the n64 guide's family list. Fix a duplicated "and" in the
  generic-language limitation.

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

---------

Co-authored-by: Alex Petrochenko <5717309+petrochen@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 18:20:10 +00:00
Adolanium 996ab6e2ae fix(zip): bound the member count of a ZIP inventory (#14997)
* fix(limits): admit a ZIP member count on reader limits

artifact.member_count now resolves artifact_limits.zip.member_count. Recorded Evidence from before this group may omit zip.

* fix(zip): refuse a central directory past the member count

Count every central-directory record before retaining it. The refusal omits required_value because later records stay unread.

* test(zip): cover a central directory past the member count

Three empty members at a count of two refuse through the reader and through the zip format reader.

* docs(limits): name zip.member_count on the member-count setting

The existing REA_ARTIFACT_MEMBER_COUNT seed already supplies that default.

* test(artifacts): select the ZIP member count with the explicit fields

The acceptance case ignores an invalid artifact.member_count seed only when every backed field is selected. zip.member_count is one of those fields.

* fix(schemas): record the ZIP member-count input summaries

extract_artifact and inspect_artifact changed their input compact schema when zip.member_count was advertised.

* fix(zip): keep member count on Flutter, Playwright, and SAZ

Those readers omitted the session count and described the refusal as a byte budget. They now admit artifact.member_count and report the count.

* test(zip): cover member-count refusals outside artifact inventory

A two-member archive at a session count of one stays a count for Flutter, Playwright traces, and SAZ. One member still passes that cap.

* docs(limits): name the ZIP consumers of artifact.member_count

Flutter APK inventory, Playwright trace import, and SAZ decoding use the session count and report it as a count.

* fix(capture): read the fixed-limit boundary from the ceiling

CaptureFormatError keeps that boundary on ceiling. The SAZ reply read cause.boundary, so a fixed-limit reply omitted the field the parent requires.

* fix(limits): recover ZIP member count through the session setting

Flutter, Playwright, and SAZ have no artifact_limits argument. The refusal names artifact.member_count, leaves parameter unset, and tells the caller to raise that setting. sessionSettingConstraint owns the error next to the other resource refusals.

* fix(android): keep a partial JNI report at the ZIP member count

readAndroidJniLibraries already returns a partial inventory when its entry allowance stops the scan. The session member count is that same stop. The reader takes artifact.member_count, and the report names the unexamined remainder instead of aborting the inspection.

* fix(zip): resolve the member count from the selected environment

ZIP admission and its refusal use the launch environment selected for the runtime. Only SAZ sends that count to the capture decoder.

* fix(zip): drop the unused ZipReaderLimits export

Knip reports the type because no caller imports it. ZIP limits stay on the schema.

* fix(playwright): return an invalid member-count seed as a result

The trace catch uses the count captured before the failure. A configuration error stays a Result and keeps the archive hash.

* fix(jni): name the member count on a partial library scan

The partial report keeps the count that stopped the scan and the recovery for artifact.member_count.

* fix(settings): register artifact.member_count for its ZIP consumers

Scoped inspection of the Flutter, Playwright, capture, and JNI operations includes the setting.

* test(artifacts): parse Evidence that omits the audit-log policy

The merged reader-limit schema still accepts a record that omits the Kubernetes audit-log policy.
2026-11-29 13:08:56 -05:00
Adolanium 06761f2993 fix(xml): bound element depth at the XML syntax boundary (#14998)
* fix(xml): refuse element depth at the syntax check

saxes keeps one handler per event and walks the open-element stack on
every start tag. checkXmlSyntax now owns opentagstart and closetag, runs
every caller handler after the depth check, and refuses depth above 1024
as xml-element-depth. 1024 stays above the desktop XML view cap and the
plist nesting cap. This release adds no runtime override.

* fix(xml): keep the depth limit when package parsers read XML

XAR TOC, installer XML, Maven POM, and VSIX manifest parsing wrapped
every syntax failure as malformed or a node budget. A depth limit is
returned as the limit failure those callers already accept.

* test(xml): cover element depth past the syntax ceiling

A document one element past 1024 fails the syntax check, including a
XAR TOC that used to parse because a later opentagstart handler replaced
the depth guard. A sibling range after a branch at the ceiling still
matches.

* test(plist): keep nesting refusals inside the XML depth ceiling

Plist fixtures deeper than 1024 now fail at syntax, so the nesting-limit
cases sit on the deepest document the syntax check admits. One plist and
one keyed archive assert the syntax limit past that ceiling.

* fix(xml): type the depth guard as a saxes start tag

opentagstart emits a start tag, not the finished SaxesTagNS. The handler call failed typecheck on that assignment.

* fix(xml): report element depth from the package providers

A VSIX manifest or Maven POM past the syntax ceiling is an XML limit. Those providers only translated their own format, so the refusal became an I/O error.

* fix(xml): report element depth as a fixed allowance

* fix(firmware): report SVD element depth as the XML ceiling

* fix(nuget): preserve XML element depth on package XML

* fix(capture): preserve XML element depth in SAZ metadata

* style(nuget): format the package fixture

* fix(plist): report XML element depth from native inspection

* fix(pkg): carry the XML depth allowance through a deep TOC

* test(plist): narrow the XML depth refusal before projection

The native depth failure is an analysis error. Project it after that check.
2026-11-29 13:08:39 -05:00
CyberSprout df093225ac fix(limits): classify protocol and analysis-view fixed ceilings (#14948)
* fix(limits): classify protocol and analysis-view fixed ceilings

Bind the 1 MiB analysis-view page ceiling, Evidence JSON nesting depth limit, Ghidra .ldefs read bound, and MCP startup stdio buffer capacity to registered fixedAllowanceOptions ceilings and shrink untyped-budget-refusal-baseline.json by 6 sites (Refs #14234).

* fix(limits): preserve retained-parent guidance in analysis-view refusals
2026-11-29 13:06:45 -05:00
morluto 8e18bdecef test(clients): check configured MCP catalogs in native harnesses (#15121)
* test(clients): check configured MCP catalogs in native harnesses

* test(opencode): resolve the native CLI in the isolated home

* ci(clients): identify native catalog discovery in the job log

* test(ci): isolate native clients and preserve registration failures
2026-11-29 18:03:55 +00:00
2SinceJulyandCursor Agent 295bdfaf73 feat(artifacts): inventory Kubernetes audit logs offline (#14952)
* feat(artifacts): inventory Kubernetes audit logs offline

A Kubernetes audit log exported from kube-apiserver is JSON-lines that the
inventory treated as an unknown file: no format claim, no reader, and no way
to see what an acquired log declares without a live cluster. Recognize the
format from its first event and report, offline, the line, stage and verb
totals and a bounded window of the events joined on their auditID.

Each line stays an event in its own right, so a request whose stages were
written out of order, repeated at one stage, or missing a stage is reported
rather than reordered into a tidy request. Unknown API versions keep their
auditID and stage but are not interpreted under field names the version may
not use. Malformed lines are counted and bounded, never dropped silently.

Refs #11352 (first slice: request, user, object reference and response code;
request/response bodies, annotations and impersonation metadata are not read).

* fix(artifacts): bound Kubernetes audit inventory and preserve stage evidence

* fix(artifacts): preserve audit fields and extend first-record recognition

* fix(artifacts): stream audit identity without decoding skipped bodies

* fix(artifacts): handle every audit probe tokenizer event

* fix(artifacts): read padded Kubernetes audit logs and modelled stages

Recognition stopped at the first newline and rejected a leading UTF-8 BOM, while the reader skipped blank lines and trimmed that BOM away. Both now treat empty lines, JSON whitespace, and one leading U+FEFF as padding.

Request fields come from the first stage whose API version is modelled, so an earlier unmodelled stage no longer hides a later v1 record.

* fix(artifacts): skip unowned Kubernetes audit JSON bodies

JSON.parse built a value tree for ignored request and response objects, so a deeply nested body could abort the process. Each line is tokenized and only the summary fields are kept. The tokenizer stops at 64 containers; identity already read is kept, and a deeper body before that identity is one line diagnostic.

* fix(artifacts): report audit depth limits and wrong field shapes

A container where a scalar or string list was required now leaves that field null, and a source address or group list past the retained text budget is not stored. Lines that exceed the tokenizer depth are counted separately from malformed JSON, and a sampled request says when the scan stopped early. Recognition uses the same depth cap and does not flush a tokenizer that already stopped.

* fix(artifacts): keep audit field omission and last-key facts

A source address or group list past the retained text budget sets request_fields_omitted instead of looking absent. Owned strings stop growing once they pass that budget. A later scalar that replaces user, objectRef, or responseStatus clears the earlier object.

* fix(artifacts): chunk audit tokenization and depth-cutoff versions

Ordinary lines are tokenized in 4 KiB slices. A depth overflow rereads that line one code unit at a time. When the cutoff hides apiVersion, request fields stay uninterpreted. A later array that replaces user, objectRef, or responseStatus clears the earlier object.

* fix(artifacts): reread overflowed audit records from the start

A depth overflow discarded every token in that slice, so identity later in the same record could be missed. Recognition keeps the first record's decoded slices and rereads them after an overflow. A scalar that replaces user.groups clears the earlier list.

* fix(artifacts): stop replaying audit records once identity is known

A depth overflow after auditID and stage no longer rereads the first record, and decoded slices are dropped once that identity is known. A replacement sourceIPs or groups list clears the previous list when it starts, including when the depth cap ends the replacement.

* fix(artifacts): replay only the overflowed audit slice

A depth overflow now rereads the failed slice one code unit at a time and the earlier slices in chunks, so a later stage key in that slice still wins. A cutoff before apiVersion suppresses request fields without labeling the version unsupported.

* fix(artifacts): let a readable stage fill fields cut by depth

A first stage whose request body hits the JSON depth cap observes no
apiVersion, so its request fields are withheld. The sample still marked
fieldsRecorded true because only a declared unsupported version counted,
so a later readable stage for the same auditID never supplied the URI,
verb, user, or object details. Gate both the flag and the later fill on
suppressFields so depth-suppressed stages stay fillable.

* fix(artifacts): clear audit budget omission when the final value fits

A later duplicate that supplies a small user agent, URI, or list no longer leaves request_fields_omitted set for the value that was replaced.

* fix(artifacts): drop audit budget omission when null replaces the value

A later null or container for an owned field clears the budget-omission mark left by the value it replaces.

* fix(artifacts): keep audit omission keys distinct and release replay slices

Nested field omission no longer shares a key with a top-level property of the same spelling. Replacing a list with an object clears that list's budget mark. Recognition drops the first-record replay buffer when the line ends and when the probe finishes.

* fix(artifacts): clear list budget marks and keep replay text until the line is read

A later null for sourceIPs or groups clears that list's budget mark. Recognition keeps the first record's slices until that line has been tokenized, then drops them.

* fix(artifacts): clear nested audit omissions and release failed replay text

A later null or object for user.groups clears that list's budget mark, and a new user or objectRef object clears its child marks. Syntax failures drop the recognition replay buffer before the probe returns.

* fix(artifacts): limit audit budget omission to request fields

An over-budget apiVersion no longer sets request_fields_omitted. Replacing an objectRef field, or starting a new sourceIPs or groups list, clears that field's budget mark.

* fix(artifacts): accept long zero-fraction audit response codes

A status lexeme such as 200.00000000000000000 is still the safe integer 200. The number text bound is 64 characters, which covers that form and still rejects an unbounded digit string.

* test(artifacts): cover audit response code number bounds

The response code is now admitted by its numeric value instead of a 20-character text bound. Pin the two edges that keep the wider bound honest: the widest safe integer on both sides, an exponent form that evaluates to a safe integer, and a value past the safe range that is still dropped.

* fix(artifacts): keep padded audit status codes and pending recognition

Trailing zeros after a decimal do not drop an integral status code. A verb dropped by the text budget counts as unlisted. A recognition finish before the first line ends stays pending and keeps its replay text.

* fix(artifacts): keep integral audit status exponents and probe padding

A status code is the safe integer its lexeme evaluates to, including a fraction that an exponent cancels. Leading padding has its own recognition allowance, and a verb dropped before an unread API version stays out of the histogram.

* fix(artifacts): keep audit status codes with a cancelling exponent

A large exponent is rejected only when it cannot cancel to a safe integer inside the maximum line. The final shift still decides the code.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-28 16:14:52 -05:00
Oke Iyanuoluwa EnochandYsopwnable 21cfc809bc ci(windows): run the caller path separator regression in the Windows lane (#4988)
test(ci): keep the separator regression in the Windows-only lane guard

Fold windowsTargetSeparators.test.ts into the existing guard for
Windows-only cases instead of a separate test with the same reason.

Co-authored-by: Ysopwnable <161784452+N0zoM1z0@users.noreply.github.com>
2026-11-28 23:49:35 +08:00
gensokyo-devandgensokyo-dev 2dcdacce92 fix(ci): accept a skipped selection the macOS lane runs
A selection whose every module is gated to macOS, such as a change to only
tests/acceptance/applications/nativePlistNesting.test.ts, can only report
skipped modules on Linux, and the portable report then failed with 'Every
portable test module was skipped' although the macOS lane ran the tests.

The report now accepts an entirely skipped selection when the plan selected
the macOS lane and every reported module is gated to macOS by the same
isDarwinGatedTestSource rule that the macOS lane uses to discover its
tests. The summary says so. Any other entirely skipped selection, and an
entirely skipped complete suite, still fail.

Fixes #14596

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 23:31:40 +08:00
gensokyo-devandgensokyo-dev 48cef4662f fix(ci): select the macOS lane when every selected test may be gated to it
The plan selected the macOS lane only for a changed test that may be gated
to macOS. A source change whose affected tests are all such modules left
Linux to skip every one of them while no lane ran them.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 23:31:40 +08:00
gensokyo-devandgensokyo-dev 8acf5e33a1 test(ghidra): forward the caller locale to native value verifier children
The verifier starts REA with a minimal environment. Without a locale a
Linux JVM encodes file names as ASCII, so the socket boundary control's
non-ASCII runtime directory became ??? and Ghidra could not start.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 16:46:31 +08:00
gensokyo-devandgensokyo-dev afd860ec1b test(ghidra): read complete Evidence in boundary CLI comparisons
Over-budget CLI results now deliver a summary, so comparing the CLI
function dossier with MCP read an absent normalized_result.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 16:46:31 +08:00
gensokyo-devandgensokyo-dev 72d6d275d4 test(ghidra): compare native value graphs by cited procedure across adapters
The real-Ghidra verifier required identical CLI and MCP dependency
graphs, including upstream Evidence IDs. An MCP session states session
limitations once and the CLI records the caller input path, so the same
analysis has different record IDs in each adapter. Each adapter now checks
that every cited ID is a linked procedure record of its trace, and the
graphs are compared with those IDs replaced by the procedures they record.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 16:46:31 +08:00
gensokyo-devandgensokyo-dev 66b8e7b2e4 test(ghidra): verify the bare unmapped selector rejection against real Ghidra
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 15:46:03 +08:00
c24ec44c94 fix(ghidra): refuse over-deep caller types before Ghidra parses them (#14930)
* fix(ghidra): refuse over-deep caller types before Ghidra parses them

The 256-level type-depth bound ran only after Ghidra's C parser
returned, but the parser recurses over a declarator's pointer and
array chain. On a JVM whose stack it exhausts (Ghidra 12.2 under
WSL2), define_native_data_types surfaced the generic unclassified
provider failure instead of the resource_constraint refusal naming
the exceeded limit.

Measure the same chain from the admitted tokens before parsing:
each pointer, array, typedef, bit-field, function and composite
level adds one, base names resolve through types defined earlier
in the text and then the database, and a reference back into a
composite still being measured adds no depth. The post-parse walk
remains the authority for chains through database types a
definition fills in place.

* fix(ghidra): measure grouped declarators and separate tag depths

The pre-parse depth pass read the caller text a second time instead
of measuring the tokens admission already produced. It also counted
a typedef level for an anonymous composite, which Ghidra stores as
the composite itself, so an allowed 256-level type was refused;
kept tag and typedef depths in one map, so a typedef sharing a tag
name reset the chain later composites build on; and left grouped
declarators unmeasured, so an over-deep grouped signature still
reached the parser.

Measure the admitted tokens, track tag and ordinary names apart,
count an anonymous composite typedef as the composite, and measure
grouped and trailing function declarators. The real-Ghidra verifier
now covers the 256/257 anonymous boundary, a grouped signature
flood, and the shared tag and typedef name chain.

* fix(ghidra): measure stars behind calling conventions in grouped declarators

A convention inside a function-pointer parenthesis, before or after the
stars, made the pre-parse depth measure give up and send the chain to
Ghidra unmeasured. Conventions are now skipped around the star count in
declarators and signatures, so over-deep chains refuse before parsing.

The shared tag and typedef verifier case now asserts the conflicting
definitions refusal it actually produces, and a convention-prefixed
flood case covers the measured chain.

* fix(ghidra): fail closed on partial over-deep declarators

The pre-parse depth measure discarded an already-counted over-deep
parameter when a missing closing parenthesis made the declarator
unmeasured, sending the chain to Ghidra's parser. Partial declarator,
array, parameter, composite, and signature measurements now retain
their deepest count, so an over-deep chain refuses before parsing.

A redundant forward declaration also overwrote a completed tag depth
with 1, hiding later definitions chained through that tag. Tag depths
now never fall. The real-provider verifier covers both cases.

* fix(ghidra): separate in-progress tags and count grouped arrays

The pre-parse depth measure treated a same-named typedef as recursive
while its tag body was being measured, so the typedef depth did not
chain through the member. In-progress tags are now tracked apart from
ordinary names.

Grouped signature names also left their array suffixes unmeasured, so
an over-deep pointer and array chain could reach Ghidra's parser.
Signature measurement now counts those suffixes before expecting the
parameter list. The real-provider verifier covers both cases.

* fix(ghidra): measure arrays after each grouped declarator close

* fix(ghidra): measure trailing and nested signature declarators

* fix(ghidra): descend nested grouped declarators in depth preflight

A pointer group that itself groups the declarator, as in (*(*f)),
stopped measurement at the outer star and then threw on the inner
parenthesis, leaving the inner pointer chain uncounted. Accumulate
stars across nested groups so the whole chain is measured before
Ghidra parses it, and cover the nested case in the real-provider
verifier.

* fix(ghidra): parse caller C on a fixed stack before the depth walk

Ghidra's C parser recurses once per pointer and can exhaust a 1 MiB
thread stack before the iterative depth walk runs, so the 256-level
ceiling surfaced as an unclassified bridge exception. Parsing on a
16 MiB thread lets that walk remain the authority and report
type_depth_limit. A parser overflow on that thread is the same
refusal. The hand-rolled declarator preflight is removed.

* test(ghidra): refuse an unnamed grouped abstract declarator

The depth ceiling is measured from the parsed type, so an abstract
parameter (__stdcall *[])(void) is the same refusal as the named form.

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

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-11-27 23:23:53 -05:00
CyberSproutandmorluto a91d9fa2b5 feat(firmware): decode ARM M-profile and RISC-V mtvec interrupt vector tables (#14421)
* feat(firmware): decode ARM M-profile and RISC-V mtvec interrupt vector tables

* fix(firmware): name vector-table exceptions per ARM variant and report unbound SVD interrupts

The architecture field now takes the ARM M-profile variant names REA uses
for raw images (armv6-m through armv8.1-m.main) plus riscv. ARMv8-M
Baseline gets ARMv6-M's exceptions; only Mainline names MemManage,
BusFault, UsageFault, SecureFault and DebugMonitor. The old armv8-m value
named Mainline faults on Cortex-M23 tables.

vtor_aligned checks the 128-byte ARMv7-M/ARMv8-M minimum and is null on
ARMv6-M, whose VTOR is optional and implementation-defined. Slots past the
end of the 32-bit address space are no longer decoded with wrapped
addresses, and an initial stack pointer that is not word-aligned is
flagged.

CMSIS-SVD interrupts without a name or with a non-integer value are
reported as anomalies instead of skipped silently, and the expanded-name
budget is charged once while parsing instead of twice with two formulas.
likely_default_stub is removed: every shared-handler group set it to true.
RISC-V limitations now cover vectored exceptions on slot 0, CLIC address
tables and the mcause numbering assumed for SVD bindings.

* fix(firmware): bound SVD anomaly diagnostics, RISC-V pair addresses, and shared budget recovery

* fix(firmware): index SVD duplicates per peripheral and admit one-slot RISC-V tables

Duplicate interrupt declarations were found by rebuilding a key that
repeats the full peripheral name for every <interrupt>, so a long name
repeated across many declarations cost name length times declaration
count. Bound names are now indexed per peripheral name, looked up once
per <peripheral>.

The 8-byte minimum held for every architecture, but only an ARM table
must start with InitialSP and Reset; a RISC-V Direct-mode table can be
one instruction. max_entries and max_file_bytes now admit one slot.

* refactor(firmware): hoist the SVD IRQ value patterns to module scope

* fix(firmware): record RISC-V pair byte extent and attribute caller input errors

* style(firmware): format the vector-table provider

* fix(firmware): add summary delivery and analysis views for vector tables

* test(firmware): check vector-table recoveries and budgets through their owners

Recovery assertions compare the delivered action with the shared refusal
formatter applied to the reported limit, instead of pinning sentences.
The summary-delivery test set REA_AGENT_RESULT_MAX_BYTES, which nothing
reads, and used a result large enough to exceed the default budget too;
it now sets REA_AGENT_RESULT_BUDGET_BYTES, asserts the reported budget,
and uses a result between the minimum and default budgets, checking that
the default delivers it complete.

The view counts active ARM entries and recognized RISC-V slots with a loop
instead of filtered copies.

* perf(firmware): count active vector slots once in the report producer

The analysis view recounted active ARM entries and recognized RISC-V slots
on every summary and page request. The producer already collects exactly
those slots as handler targets, so the report now stores
active_arm_entry_count and recognized_riscv_slot_count from them, and the
view reads the stored fields. The service checks the stored counts against
the slots once when it validates the provider's report.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 20:07:08 -05:00
88373e3fba feat(apple): inspect Image4 (IMG4, IM4P, IM4M) firmware containers offline (#14907)
* feat(apple): inspect Image4 (IMG4, IM4P, IM4M) firmware containers offline

Image4 files are recognized from a DER SEQUENCE whose first element is
the IA5String IMG4, IM4P, or IM4M, independent of the filename, and are
inventoried as apple-img4. The stored payload octet string is exposed as
payload, the embedded IM4M sequence as manifest.der, and the IM4R
sequence as restore-info.der. Keybags contribute a count and key types,
with initialization vectors and keys left out of metadata; an encrypted
payload is refused on open; signatures and certificates are reported by
size; LZFSE and complzss payloads stay compressed; IM4R property names
are listed and their values stay redacted. Four fixed allowances refuse
excessive DER depth, element count, property count, and string length,
and inventory coverage is unknown whenever a limitation is recorded.

* fix(apple): read Image4 fields by universal tag and position

Compare universal tag numbers instead of identifier octets, so constructed
OCTET STRING and string values are recognized and reported. Read IM4P fields
by position so an unsupported payload keeps its slot and a constructed keybag
still marks the payload encrypted. Walk every constructed value once, caching
the children of header-walked values so each element is charged once, and
check large values a consumer does not decode. Report unknown restore members,
extra property and object fields and a mistyped certificate chain. Decode
UTF8String as UTF-8, accept DER sign padding on unsigned 32-bit integers, and
recognize the magic with the shared BER header decoder.

* fix(apple): read IM4P and IMG4 slots by position and keep unknown counts null

Follow img4tool and img4lib: after the payload, an optional keybag OCTET
STRING, then an optional compression SEQUENCE, then PAYP in [0]; IMG4 holds
IM4P, [0] IM4M and [1] IM4R in that order. A value outside its slot is
reported as unknown and never takes another field's role, and an EXPLICIT
wrapper holds exactly one value. An absent or undecodable description is
null rather than empty, and an undecoded keybag reports a null count and
types instead of zero; a decoded keybag counts every entry.

* fix(apple): keep Image4 compression unknown when it cannot be read

An encrypted payload without a compression field, or a declared algorithm
other than LZFSE with no recognizable magic, now reports compression
"unknown" instead of "none". Make ia5Text the single owner of the
retained-text allowance so a string too large to tree-parse is refused
rather than reported absent, keep the canonical BOOLEAN check in the
structural pass only, check the keybag's inner SEQUENCE through the shared
decoder instead of its first octet, note a manifest version other than 0,
and name the spec constants after their sources. Add a hand-encoded IM4P
golden that does not use the fixture builders.

* fix(apple): keep stopped Image4 slots and bound retained bytes

A value whose end cannot be found keeps its identifier, so a stopped keybag
still marks the payload encrypted and a stopped payload keeps its slot; the
values after it become a limitation. The IMG4 payload slot is consumed
whatever it holds, so an unsupported value does not hide the manifest and
restore slots. A property body that is not a SET or SEQUENCE is reported
instead of read as empty, and an entry whose name cannot be read is one
unknown entry whose value is never walked for more names, so restore values
stay redacted. Load a value only when it may be decoded and fits an 8 MiB
retained budget; larger primitives and values past the budget are walked by
header.

* fix(apple): keep restore properties opaque and small fields readable

A PRIVATE-tagged restore value is one property: only its name is reported,
and its value is never searched for names, even when the name is unreadable
or is IM4R. Only the IM4R property SET is walked as a container. Small
primitives are always loaded, so names and scalars stay readable after the
retained budget is used. A declared uncompressed size that is negative or
not an exact integer is reported as a limitation.

* fix(apple): reserve tree budget only for parsed values and keep PRIVATE manifest entries opaque

Reserve retained bytes only for a value that will be tree-parsed, so a
ranged wrapper around a large payload no longer uses budget a later small
indefinite value needs. A PRIVATE manifest entry must name itself; when its
name cannot be read it is reported and its value is never interpreted as
manifest facts.

* fix(apple): report MANB, MANP and IM4R entries with no body

A MANB, MANP or IM4R entry that holds only its name is a missing body, not a
confirmed-empty one, so it is reported as a limitation while sibling facts
are kept.

* fix(apple): require a SEQUENCE for named manifest entries

A context-, application- or other-tagged manifest value that begins with a
name is unsupported structure, reported as an unknown tag rather than read
as a manifest entry.

* fix(apple): assign IMG4 values to slots by position and context tag

One slot assigner owns the IMG4 layout: a context-tagged value fills the
slot with its tag number, skipping earlier optional slots, and any other
value occupies the next slot even when it cannot fill it. An unsupported
manifest value therefore no longer hides a following [1] IM4R.

---------

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: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-11-28 01:01:22 +00:00
zhuweiyeandmorluto f25312a8bc feat(labview): inspect RSRC containers and embedded VI trees (#13337)
* feat(labview): inspect RSRC containers and embedded VI trees

Add inspect_labview_artifact, a static reader for LabVIEW RSRC containers in
.vi/.ctl/.llb files and in LabVIEW-built PE resources. It reports the container
header, the recorded LabVIEW version, the complete block inventory with each
section's coding, and whether the block-diagram and front-panel heaps are
present, without starting LabVIEW or any process.

Only zlib-coded sections are decoded, for their byte count; no payload is
returned. An absent block-diagram heap is reported as a limitation rather than
reconstructed.

* docs(labview): document RSRC inspection

Describe the inspect_labview_artifact contract, section codings, and the
block-diagram limitation, and list the target in the supported-targets table
and the documentation index.

* test(labview): cover provider admission for the RSRC reader

Add the provider-admission coverage the repository requires for a new
provider, without changing the reader:

- Move the synthetic RSRC container builder into a shared test fixture so
  the unit and boundary tests build the same bytes once.
- Add a CLI and stdio MCP boundary test for inspect_labview_artifact.
- Register `rea-labview-rsrc` lifecycle coverage for operation and cancel.
- Declare the `labviewArtifact` conformance case.
- Regenerate the advertised catalog summary for inspect_labview_artifact.

* fix(labview): require an absolute path in the inspection contract

`inspect_labview_artifact` admitted a relative `path`, while every other
caller-path contract requires an absolute one. The CLI/contract parity
check caught it: the CLI resolves a relative argument before admission,
so the contract must hold the absolute rule alone.

Use `absoluteLocalPathStringSchema`, the schema the other caller-path
contracts already use.

* fix(labview): bound inspection work and preserve parse facts

Address the review findings on the RSRC reader:

- Bound the PE resource walk with a visited set, a total visit budget,
  directory-entry and container allowances, and a typed limit failure
  instead of a silently partial scan.
- Check the resource directory and its data against the declared resource
  range rather than the whole file.
- Cap zlib inflation at its declared length, add a total decoded-work
  budget, and recognise any valid zlib header instead of three byte pairs.
- Check nested RSRC records against their declared data/info sections and
  cap the total section count across blocks.
- Read the artifact through readStableArtifact so identity, bounds and
  cancellation bind to the bytes actually inspected.
- Carry parse failures as ParseFailureError facts: malformed input keeps
  its kind/offset/field, and a limit becomes a typed fixed-allowance
  refusal instead of invalid_format.
- Report heap presence as `unknown` when an embedded program tree or an
  unexamined container could still hold it, not as `absent`.
- Cover cancellation that arrives after the read starts.
- Move the analyst guide under docs/guides/native/.

* fix(labview): retry retained cleanup and keep read failures distinct

- Own the artifact resource scope and run each read through it, so a
  retained failed close is retried before later work and reported at
  shutdown.
- Translate the read failure as recorded instead of replacing it with the
  signal's current state; the stable read owns its cancellation facts.
- State the 256 MiB input ceiling as a fixed allowance so an oversized
  artifact keeps its structured maximum and recovery.
- Match the guide to the decoded-byte behavior: a section over the budget
  is reported `unknown` and the inventory continues.

* fix(labview): bound the version scan and keep cleanup on refusal

- Replace the unbounded `\d+\.\d+` scan with a bounded single-pass search
  over the first 64 KiB of each vers section; a digit-only section no
  longer drives quadratic matching work in the shared server.
- Classify read failures through the shared provider classifier with a
  LabVIEW dialect, so the size ceiling is restated as a fixed allowance
  and the read's cleanup, partial observation and cancellation facts
  survive the refusal.
- Cover both with regressions.

* fix(labview): reuse the shared PE layout and bound the decode work

- Walk PE resources through readPeResourceLayout, so RVA lookup is indexed,
  a payload may map through any admitted section, and the home-grown
  section scan is gone. Add a total entry budget.
- Charge every attempted inflation against the container's decode budget,
  including failed and length-mismatched attempts.
- Bound block records by the list's declared extent, clamped to the
  container because real LabVIEW-built PEs declare more than the resource
  payload holds.
- Reject a named section whose name leaves the list instead of reporting
  it as unnamed.
- Pass the selected container to the parser without copying it.
- Cover the PE path and the over-declared list extent with regressions.

* fix(labview): bound repeated decodes and report unexamined coverage

- Charge compressed input bytes as well as declared output, and memoize
  the decoding of one stored section, so records that share a stream do
  not repeat its work.
- Keep a zlib-coded `vers` section's decoded bytes for the version scan.
- Cap list records by both the declared extent and the info section.
- Report PE walk coverage, and keep heap presence `unknown` for a `.llb`
  archive or an unreadable PE resource branch.

* fix(labview): key cached decoding by block and section

A section's coding depends on both its stored bytes and the block that
declares it: LVzp is XOR regardless of the bytes, while another block may
read the same bytes as raw or zlib. Include the block identifier in the
memo key so a shared section keeps each block's interpretation.

Cover the shared-section case with a regression.

* fix(labview): derive block facts once and stop inferring format from names

- Compute the block-diagram, front-panel and program-tree facts in one
  pass over the inventory and reuse them.
- Check the visited set before charging the PE directory-visit budget, so
  aliases of one directory do not exhaust it.
- Deduplicate aliased resource payload ranges before counting containers.
- Report a direct RSRC container's heap facts as unknown: its content does
  not establish whether it is a VI, a control, or an archive of member VIs,
  and the caller's spelling is not evidence of format.

* fix(labview): decode the packed version record and keep resource type

- Read the LabVIEW version from the packed four-byte word at the start of
  a `vers` record instead of scanning the whole record as Latin-1, and
  report `version_coverage` so an undecodable record is unknown rather
  than absent.
- Accept only RT_RCDATA (type 10) PE resource payloads, so the
  `pe-rcdata-rsrc` kind is accurate and a larger custom resource cannot
  win selection.

* fix(labview): walk only the RCDATA subtree and validate packed digits

- Walk only the RCDATA (type 10) resource subtree, so a shared directory
  reached under another type cannot hide the container and unrelated
  branches are not charged to the entry budget.
- Reject a packed version word whose digit nibbles are not decimal; a
  damaged record is skipped and a damaged-only container reports
  `version_coverage: unknown`.
- Derive the heap and program-tree facts in the parser and consume them in
  the provider, so one owner defines their meaning.

* fix(labview): filter root resource entries before dispatch

- Apply the RCDATA root-type filter before either target branch, so a root
  entry that points straight at a payload cannot enter the result.
- Validate only the decimal major, minor and bugfix fields; the build
  field is not part of the reported version.

* fix(labview): filter PE root types before dispatch and validate only reported version digits

The RT_RCDATA filter ran only for directory targets, so a noncanonical root
entry of another type pointing straight at a data entry could be counted
and labelled pe-rcdata-rsrc. Filter the depth-0 type identity before
either target branch, and share the RT_RCDATA constant with the PE
resource facts owner.

The vers check rejected a record whose build bits held a nibble above 9.
Only major.minor is reported, and pylabview (decimal build digits) and the
classic NumVersion layout (binary non-release revision) disagree on the
build, so only the reported major and minor nibbles are validated.

* fix(labview): resolve names against the shared list and keep read identity

- Locate the one section-name list after every block's start table and use
  it for all blocks, so named sections before the last block keep their
  identity instead of reading a neighbouring table.
- Retain the completed read's byte identity on later refusals and failed
  closes, so a parse failure still names the bytes that were read.

* fix(labview): report why recognized zlib sections stay undecoded

A valid RFC 1950 header with FDICT set was classified as uncompressed, so
a vers section's four-byte length prefix was read as version 0.0. FDICT
now marks the section as recognized-but-undecodable zlib.

Each undecoded zlib section records its reason (preset dictionary,
compressed-input or decoded-output allowance, or failed inflation), and the
report names the fixed allowance that stopped it, so a capacity omission is
distinguishable from damaged bytes.

A PE whose RCDATA branch could not be read is no longer described as
carrying no embedded RSRC resource. The RSRC magic and zlib header fields
are named once and shared.

* fix(labview): keep PE admission separate from an unreadable tree

A file that does not declare `MZ` is not a PE, so it must not be reported
as a malformed PE resource tree. The scan reports whether the file was
admitted as a PE separately from whether the walk was complete.

* fix(labview): take PE identity from the MZ owner and bound section tables

A two-byte MZ check treated plain DOS MZ and NE/LE/LX images as declared
PEs, so an ordinary non-LabVIEW file was reported as an unreadable PE
resource tree. PE identity now comes from observeMzWindowsHeader: only a
PE signature at e_lfanew declares a PE. The unused admitted field is
removed.

A section-start offset inside the count word or block-header rows was
accepted and could fabricate an inventory from block metadata. Tables must
start at or after the end of every block header; blocks may still share a
later table.

The refusal tests now assert the error type unconditionally.

* fix(labview): report embedded parse failures in file coordinates

A malformed RSRC embedded in a PE failed with container-relative offsets,
but the refusal names the selected executable and carries no
container.file_offset, so callers could not locate the failure. The
parser now takes the container origin and moves a failure offset into the
selected file's coordinates; successful results keep container-relative
ranges with container.file_offset.

* fix(labview): frame RSRC tables before applying their count allowances

A damaged container declaring an impossible block or section count was
refused as a capacity limit before its table extent was checked, so a
truncated target surfaced as resource_constraint. Each table is now framed
first; a fully framed table over its allowance is still a capacity
refusal.

* fix(labview): keep unread PE resource roots and rows out of observed absence

A nonzero resource RVA whose file-backed run cannot hold one directory
header returned complete coverage without reading anything, so the file
was reported as carrying no embedded RSRC. Only a zero RVA is observed
absence now; a short declared root is an unread tree.

Directory rows were checked against the entry allowances before their
extent, so a damaged directory declaring impossible counts surfaced as
resource_constraint. Rows are framed first; a fully framed directory over
its allowance is still a capacity refusal.

* fix(labview): reject RSRC data sections that overlap the fixed header

A data offset inside the 32-byte RSRC header let a section's stored-length
word be read from header fields, returning a fabricated empty section as a
successful inventory. A data offset below the header is now malformed.

* fix(labview): check decode-omission guidance structurally and own the RSRC magic once

The allowance test froze the delivered sentence. It now checks the parser's
decodeOmissions fact and the effective allowance, and compares the public
limitation with the provider's own formatter output.

The RSRC magic was declared again in artifact recognition; it now has one
owner in the LabVIEW domain contract, used by recognition, the parser, the
PE scan and the provider.

* feat(labview): summarize and page the RSRC inventory from retained Evidence

inspect_labview_artifact returned every block and section inline, so an
admitted container with 4096 named sections could exceed a megabyte and
bypass the agent result budget. The tool now takes detail: complete keeps
the inline inventory; summary, or omitted detail over the budget, returns
container, version and heap facts with block and section counts, and the
complete inventory is paged with inspect_analysis_view kind
labview-artifact (blocks, sections, optional block filter) or read with
evidence-json. The CLI delivers the same way.

RSRC data and info ranges that intersect are refused as malformed rather
than reading list metadata as section data.

* test(labview): read the CLI report as the complete inventory

The advertised output now admits complete or summary detail, so the test
parses the complete report schema explicitly.

* perf(labview): build view rows only for the requested page

Each view call copied every section before reading the request, so a
summary or one-row page did work proportional to the whole inventory. A
section index (block and section position, and positions per block) is
built once per immutable retained report and reused; summaries read
counts from it, and section pages build objects only for selected rows.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 22:26:04 +00:00
ba1ddffd7e feat(artifacts): inspect Sega Mega Drive and Genesis ROM headers offline (#14895)
* feat(artifacts): inspect Sega Mega Drive and Genesis ROM headers offline

These ROMs are inventoried as containers. A plain image matches when the
four bytes at offset 0x100 are SEGA; an SMD dump matches the copier mark
0xAA 0xBB and a block count whose de-interleaved bytes carry SEGA, then
the odd and even halves are merged into the linear image. The root
record stores the 68000 vectors, header strings, declared and computed
word checksum, ROM and RAM ranges, devices, external RAM, and region,
with members vectors.bin, header.bin, and program.bin (SMD members carry
an image offset and a null file range). A checksum or range disagreement
leaves coverage unknown, 32X and Sega CD remain labels only, and a file
past 8 MiB or 512 SMD blocks is refused under the named fixed ceilings
before its body is buffered; the shared region reader maps that refusal
onto the typed allowance, and the guide, CLI, supported-targets table,
CI scopes, and ceiling registry include the format.

* Address review feedback

* Address review feedback

* Address review feedback

* fix(artifacts): read Mega Drive work RAM on the 24-bit bus and keep ambiguous regions

A header that declares work RAM as 0xE0FF0000-0xE0FFFFFF, the SGDK
default, was reported outside the work-RAM window because the check
compared full 32-bit values. The 68000 drives 24 address lines, so the
window check now compares bus addresses; metadata keeps the declared
values.

A region field of a lone A, B or E is both a classic region letter and
a one-digit mask, and references disagree on which it is. It was
reported as letters with no limitation. It is now region_style
ambiguous, keeps both readings in region_characters and region_mask,
and records a limitation.

* refactor(artifacts): name Mega Drive header fields once and share the SMD half layout

Header field offsets and lengths were literals repeated at each read, and
device support was sliced twice from separate literals. One TEXT_FIELDS
table, the named numeric offsets and the EXTERNAL_RAM block now hold the
layout, citing SGDK's rom_head.c and Genesis Plus GX's getrominfo and
sram_init.

SMD recognition and de-interleaving each encoded which block half holds
the odd bytes. Both now use SMD_ODD_HALF and SMD_EVEN_HALF, and the
decoder takes the block count from the de-interleaved image instead of
recomputing it from the file size.

The SMD round-trip test only checked the fixture against its own inverse.
It now also pins the fixture's file bytes to the Genesis Plus GX
deinterleave_block layout.

* fix(artifacts): model the Mega Drive 68000 bus once and decide SMD dumps before ESP images

Header addresses were compared in three places with two rules: the RAM
check masked to 24 bits while the reset-PC check compared raw 32-bit
values, and neither knew the work-RAM mirror. One owner now holds the
MC68000 24-bit bus (the top byte is not driven) and the Mega Drive work
RAM, 64 KiB mirrored through 0xE00000-0xFFFFFF (Genesis Plus GX gen_init
maps pages 0xE0-0xFF to it). The reset PC is checked against the ROM
range on that bus, so 0xFF000200 fetches from 0x200, and a RAM range is
work RAM when it covers at most 64 KiB inside the mirror, such as
0xE00000-0xE0FFFF. Metadata keeps the declared values.

An SMD dump of 233 or 489 blocks has 0xE9, the ESP image magic, in its
copier header's block-count byte, so the ESP image recognizer claimed
it. The shared recognizer table now decides the SMD layout, whose
signature also needs the AA BB mark, interleaved SEGA bytes and an exact
size, before the ESP recognizers, and the plain layout keeps its place
after the leading-magic formats.

* fix(docs): restore separate Mega Drive and N64 entries after the main merge

* fix(mega-drive): read ROM range and checksum window on the 24-bit bus

The reset PC check already masked the top address byte, but ROM ordering,
extent, the nonzero-start note and the checksum window still used the raw
declared endpoints. A 0x400-byte image declaring 0xFF000000-0xFF0002FF
summed through 0x3FF instead of 0x2FF, and a full 0xFF000000-0xFF0003FF
alias was marked incomplete. Derive bus addresses once in the parser and
keep the declared values in metadata.

* fix(artifacts): order every Mega Drive header range on the 24-bit bus

The ROM range was ordered on the 68000 bus, but the RAM range and the
external RAM range still compared raw 32-bit endpoints. A header whose
endpoints alias through different top bytes, such as RAM
0xE0FF0000-0x00FFFFFF, was reported as reversed even though the bus
range is the 0xFF0000-0xFFFFFF work RAM.

The bus owner now has one ordering rule, busOrdered, and the ROM, RAM
and external RAM checks all use it. Declared values stay in metadata. A
range whose end wraps past the 24-bit bus, such as 0xFF0000-0x1000000,
is now reported as reversed, which is what the bus sees.

* fix(artifacts): keep truncated region failures typed and publish Mega Drive bus addresses

A region decoder could only report malformed, limit or unsupported, and
the shared DecodedRegionArtifactReader mapped every kind but malformed to
a fixed-limit refusal. A recognized Mega Drive header cut short was
therefore reported as malformed, and an unsupported region failure would
have surfaced as a limit. RegionDecodeFailure now has truncated, with
the measured extent, and the reader maps each kind to its own typed
failure: malformed, truncated, unsupported or limit.

The header checks already interpret ROM, RAM and reset addresses on the
68000's 24-bit bus, but metadata exposed only the stored longwords, so
the raw m68k hand-off told callers to load at the stored ROM start. A
header that stores 0xFF000000 then loads at the wrong address. ROM and
RAM ranges now carry bus_start and bus_end, the reset vector carries
reset_pc_bus, and the guide and skill hand off with rom.bus_start.

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 22:25:43 +00:00