* perf(analysis-view): reuse the owner's sealed JavaScript result without a graph walk
Since #13315 the JavaScript parent goes through createAnalysisViewResultReader.
On a record's first read, its fast path returns a new wrapper around the same
owned graphs, so the reader walks both whole trees in
canBorrowParsedJsonSnapshot to prove it can keep the source. Since #14252 every
over-budget delivery reads its summary that way, so each big JavaScript result
blocks the server for that walk: 331 to 429 ms per 1,200-function call in
--cpu-prof runs on 0ad967258 (#1065).
The parser now remembers the fast-path results it returns. Once
createOwnedJavaScriptApplicationEvidenceCooperatively has sealed one in place
and bound it to its Evidence, it admits that exact object to the parser's
validated set, so a later parse returns it and the reader's borrow check ends
at its identity test. A sealed copy, an imported result, or one not yet
sealed is never admitted and keeps today's checks.
🤖 Generated with Claude Code (Opus 5.5) 🦊
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* perf(analysis-view): re-check the sealed owned result before admitting it
Admission trusted the result as the parser returned it, so a change between
that return and sealing would have gone unseen. Before admitting, the sealed
result now passes the fast path's checks again: the metadata schema with the
owned graphs by identity, an exact match between the sealed and re-parsed
wrapper outside the graphs, and the cross-graph bindings. The bindings run in
bounded steps through completeJavaScriptAnalysisSteps, without the request
signal, so a cancel still gets its Evidence as before.
🤖 Generated with Claude Code (Opus 5.5) 🦊
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(artifacts): inspect PlayStation PS-X EXE headers
A file starting with the PS-X EXE magic is inventoried as psx-exe. Root
metadata reports the initial PC and GP, the text, data and BSS ranges,
the stack base and offset with the initial SP, the region marker and
its licensed region, and whether the file length agrees with 0x800 plus
the declared text size. header.bin and text.bin are stored ranges;
text.bin carries its load address and holds only the bytes present.
A file shorter or longer than the declared text, or a text size that is
not a whole number of 2048-byte sectors, leaves coverage unknown with
the offset involved. A file that ends inside the header is refused as
truncated with the offset where it ends. Nothing is executed.
* fix(artifacts): read PS-X EXE fields through BinaryReader and match regions exactly
A region marker such as constructor matched an inherited property of the
region table, so the metadata held a function and inventory failed when
it was cloned. Regions now come from a Map. Header words are read
through BinaryReader instead of a local decoder. The fixture writes
literal offsets with distinct non-zero values, including data and a
stack offset, and the guide says inventory reads the members to hash
them.
* fix(artifacts): validate PS-X file sizes and name the omitted text member
* test(artifacts): extract PS-X EXE members in the reader test
* style(artifacts): format the PS-X reader test
---------
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
* feat(native): identify Nim, Zig, GHC, OCaml and D toolchains
Add identify_native_toolchain, a static, read-only reader that reports
whether a local ELF, PE or thin or universal Mach-O image was built by
Nim, Zig, Haskell (GHC), OCaml or D, including stripped images without
a DWARF producer.
The reader searches a bounded part of the selected image for a fixed
table of runtime symbol names, runtime messages, mangled names, source
paths and producer strings, and returns each observed marker with its
file offset, section or segment, matched text and occurrence count.
Data sections are searched before bytes outside sections and before
instruction sections, so a bounded scan reaches strings first;
coverage reports the bytes examined.
The verdict is derived from the listed markers only: a language needs
two distinct markers, one strong. Conflicting, too few or no markers
give unknown, and a version is reported only when a marker states it.
* perf(native): order toolchain scan ranges in linear time
Intersect instruction sections with the bytes outside data sections in one pass, so an image with tens of thousands of sections does not take quadratic time before the scan starts.
* fix(native): bound stated toolchain versions and describe scan order
Track distinct versions per marker in a Set and list at most eight,
counting the rest in versions_omitted, so an image with many version
strings costs constant time per match and a bounded result. A candidate
reports a version only when exactly one was stated.
Describe max_scan_bytes and examined_bytes as a total in scan order
rather than a prefix from the image start, and place the chunk-boundary
test's marker across an actual read boundary.
* fix(native): keep every stated toolchain version in the report
* fix(native): bound stated toolchain version bytes before keeping them
* feat(native): make the stated version budget a per-call control
* fix(native): give no larger-limit retry once a toolchain control is at its maximum
* fix(native): do not match toolchain markers on truncated runs
* fix(native): keep exact markers on a final run at the image end
* style(native): format the toolchain changes
---------
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
* feat(artifacts): inspect Game Boy and GBA ROM headers
Game Boy and Game Boy Color images (game-boy-rom) are claimed when at
least the first 24 bytes of the boot logo at 0x104 match, the half every
boot ROM compares. Root metadata reports the entry code and its JP
target, full or top-half logo match, title and manufacturer code, CGB
and SGB flags, mapper and features, declared ROM and RAM sizes,
destination, licensee codes, version, and declared and computed header
and global checksums. The global checksum is summed over the file in
bounded reads.
Game Boy Advance images (gba-rom) are claimed from an ARM branch at 0,
the fixed 0x96 at 0xB2, and the boot logo or a matching complement
check. Root metadata reports the entry branch target, logo match, title,
game and maker codes, fixed value, unit and device type, version, the
complement check, and the multiboot fields when that layout could apply.
Both serve header.bin and program.bin as stored ranges. Logos are
compared by SHA-256 digest, so no logo bytes are carried. Checksum,
logo and size disagreements leave coverage unknown; a header cut short
is refused as truncated with the offset where the file ends.
* fix(artifacts): keep missing GBA multiboot fields unknown and pin checksum vectors
A GBA file that ends inside the multiboot fields reported boot_mode and
slave_id as zero. They are now null, with a limitation naming where the
file ends. The Game Boy reader charges artifact_limits.expanded_bytes
from the file size before it sums the file for the global checksum.
Checksum tests now use hand-derived vectors instead of copying the
parser's own result.
* refactor(artifacts): read Game Boy and GBA header fields through BinaryReader
The GBA parser decoded words with a local reader that read missing bytes
as zero. Both parsers now read header fields through BinaryReader, as the
tool-design guide requires, after their length checks. The fixtures write
literal offsets instead of the parsers' field constants, and the guides
say inventory reads the stored members to hash them.
* fix(artifacts): read documented GB size codes and MBC4, refuse truncated GBA headers
* style(artifacts): format the handheld ROM test
---------
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
* feat(artifacts): inspect MetaTrader 5 EX5 program headers and resources
Recognize compiled MQL5 programs by their EX5 magic and inventory them
through inspect_artifact and extract_artifact. Report the program type,
compiler build, copyright/link/version property slots, nonzero header
fields of unknown meaning, and the resource table. List the opaque body
and resource payloads as stored byte ranges; nothing is decrypted,
decompressed or decompiled.
Refs #16495
* feat(artifacts): read MetaTrader 4 EX4 programs with the EX5 layout
EX4 (magic EX-) shares the EX5 header, property slots and resource
table, so both containers become one mql-program format with a
container field. The version slot is 64 bytes and the opaque body
starts at 0x2E8 in both containers; the earlier 0x3A8 header length
counted 192 opaque bytes as part of the version slot. EX4 type code 3
is a library; build is reported under a neutral name because its EX4
meaning is not established.
* fix(artifacts): bound repeated MQL resource ranges and let tar outrank printable magics
Resource records may share one payload range, and each occurrence is
hashed and extractable, so the reader now charges every record against
artifact_limits.expanded_bytes, as the DTBO reader does.
A checksum-valid tar header now runs before the recognizers that match a
printable magic at offset 0. A tar whose first member was named EX-...,
GDPC... or UnityFS was claimed as an MQL program, Godot PCK or UnityFS.
Slot text keeps a leading U+FEFF, which is declared content rather than
an encoding mark.
* fix(artifacts): refuse an invalid tar header only after leading-magic formats
Only a checksum-valid tar header outranks the printable leading magics. A
Godot pack can hold ustar at 257 inside its own content without a valid
tar checksum; refusing that header first rejected the valid pack.
* fix(artifacts): compare MetaTrader resource declarations
A resource's name, kind, record index and unpacked size live in the
resource table, outside the stored payload that content comparison
hashes, so a renamed resource compared as unchanged. Compare them as
the resource's declaration, as tar, ar and UnityFS members do.
* fix(artifacts): keep unreadable MetaTrader resource names unknown in comparison
* fix(artifacts): report an unrecognized file's leading bytes and working fallbacks
A file no format route recognizes was refused with only the raw-binary
load as recovery, which suits headerless machine code but not data
containers. The refusal now reports the file size and first 16 bytes,
names inspect_byte_entropy and inspect_yara_matches, which accept any
file, and keeps raw-binary for machine code. The REA skill gains a
workflow for continuing analysis when no route recognizes a file.
* docs(development): require recovery fallbacks to fit and accept the refused input
* docs(skill): describe entropy ranges as places to inspect, not content labels
The count-mismatch test added a removed field, so the strict report schema
rejected it before the count check ran. It now changes counts.loads on a
schema-valid report, with the unchanged report as a control.
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
inspect_firmware_literal_pools and inspect_firmware_mmio_synthesis answered
the same question and differed only in the instruction idiom they decode.
One tool, inspect_firmware_mmio, now takes a single architecture vocabulary
across all nine ISAs and dispatches to the literal-pool or split-immediate
decoder.
Both decoders write the same report:
- accesses rows: instruction, address register, access kind and width,
address and MIPS physical address, region kind, architectural block, and
CMSIS-SVD peripheral and register facts;
- a source object with the decoder's own facts: pool slot and disassembly,
or pattern and high instruction;
- decoder facts on the report.
firmwareMmioGroups.ts owns grouping MMIO accesses by SVD peripheral,
architectural block or 4 KiB page. mmioAttributionBasis owns the group
basis. The retained view kind is firmware-mmio, with collections accesses,
peripheral_groups and anomalies, and its summary lists the top 16 groups as
compact rows.
max_references and max_syntheses are removed, since max_representation_bytes
already bounds the rows they counted. The literal-pool pre-allocation
measurement now includes an upper bound for each group, so its refusal
reports the exact required bytes. max_scan_bytes defaults to its 16 MiB
maximum, so one call covers a whole application image. mmio_only, default
true, now also drops literal-pool constants that are not MMIO;
counts.candidate_accesses still counts every decoded access.
BREAKING CHANGE: inspect_firmware_literal_pools and
inspect_firmware_mmio_synthesis (CLI inspect-firmware-literal-pools and
inspect-firmware-mmio-synthesis) and the retained view kinds
firmware-literal-pools and firmware-mmio-synthesis are replaced by
inspect_firmware_mmio (inspect-firmware-mmio) and view kind firmware-mmio.
isa becomes architecture, max_svd_nodes becomes max_svd_xml_nodes, and
max_references and max_syntheses are removed. Neither old tool has been
released.
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>