Commit Graph
6 Commits
Author SHA1 Message Date
e3713bea60 feat(rust): read cargo-auditable dependencies from WebAssembly modules (#5069)
* feat(rust): read cargo-auditable dependencies from WebAssembly modules

cargo-auditable embeds the same zlib-compressed `.dep-v0` JSON in a
WebAssembly custom section for wasm32 targets, but inspect_rust_binary
rejected every module as an unsupported target because only ELF, PE and
thin Mach-O containers were recognized.

Walk the section framing of version 1 core modules to locate the
`.dep-v0` custom-section payload and the data section, where rustc keeps
its constant /rustc/<hash>/ paths. Rust lookups now read one
format-neutral layout, so native and WebAssembly images share a single
dependency-section owner. WebAssembly declares no container word size, so
`bits` is null for that format only; the Evidence subject format is
`file`, as for inspect_wasm_artifact.

Truncated sections, invalid LEB128 sizes, custom-section names that run
past their section or are not UTF-8, duplicate `.dep-v0` sections and a
second data section are malformed. Components, such as wasm32-wasip2
output, embed core modules and are refused as unsupported, like universal
Mach-O containers, rather than inspected through one selected module.

* fix(rust): bound the WebAssembly section walk

The WebAssembly reader visited every section synchronously, and the format
sets no section count. A 256 MiB input of three-byte custom sections with
empty names walked about 89 million sections and held the event loop for
about 7.4 seconds, delaying cancellation and other MCP requests; empty type
sections took about 1.9 seconds.

Refuse a module with more than 65,536 sections with a typed cpu resource
constraint that reports maximum_wasm_sections, as the Go header search
reports its work budget. Producer output holds a few dozen sections, and the
same inputs are now refused within tens of milliseconds.

* fix(rust): accept WebAssembly Evidence in retained dependency views

Retained Rust views compared the parent subject with a Mach-O-only format
mapping, so WebAssembly Evidence, whose subject format is file, was refused
as a different artifact. The report domain now owns the subject format next
to the architecture mapping, and the service and the view both use it. The
real CLI/MCP view workflow now also covers a WebAssembly module.

* fix(rust): name the WebAssembly section-walk allowance in recovery

Fixed-allowance recovery mapped every Rust resource other than capacity and
transport to the parser allowance, so the section-walk refusal said host
memory does not raise it. Each Rust resource now maps to its own allowance,
and the cpu bound is a fixed work allowance. The MCP error contract test
checks that the refusal is not retryable and names that allowance.

* fix(rust): require WebAssembly container facts in reports

The report schema tied a null word size to WebAssembly, but it accepted a
wasm report that named a native architecture or big-endian byte order, and
a native report that named the wasm architecture. Retained views parse
imported Evidence with this schema, so such a contradictory report was
accepted. The architecture is now wasm exactly when the container is
WebAssembly, and a WebAssembly report must be little-endian.

* docs(rust): record the WebAssembly dependency-metadata feature

Feature work now carries a spec, plan and task list under docs/specs.
This adds that record for reading cargo-auditable metadata from
WebAssembly core modules and indexes it. The record states that it was
written during review and lists the verification that remains open.

* fix(rust): bind section names to containers and share the LEB128 reader

The report schema accepted a dependency section name that does not belong
to the report's container, such as a WebAssembly report naming the Mach-O
section. rustDependencySectionName now owns that name for the reader and
the schema, which refuses a mismatch for every container.

The WebAssembly reader decoded section sizes with its own loop. It now
uses the shared readLeb128, and an integer cut off by the end of the file
is truncated rather than malformed.

* fix(rust): classify a cut-off WebAssembly integer by its boundary

The reader called an unfinished LEB128 integer truncated whenever its
limit equalled the file length. A name length cut off inside the final
section was therefore truncated, and the same bytes followed by another
section were malformed. Each caller now states whether the file or the
enclosing section bounds the integer.

* fix(rust): report a duplicate WebAssembly dependency section first

The section walk kept two .dep-v0 matches but walked on, so a module with
two dependency sections and more than 65,536 sections after them was
refused for the section bound instead of the duplicate it had already
established. The walk now ends at the second match.

* test(rust): assert WebAssembly container facts instead of limitation prose

The CLI acceptance test matched an English limitation sentence. It now
checks format, architecture, bits and byte order on the parsed report.

* fix(rust): state container word size as 32 | 64 | null

Output contract: inspect_rust_binary bits, including the summary view, is
32 | 64 | null. Null is valid only for WebAssembly and is not a number.
ELF, PE and Mach-O reports stay 32 or 64. The schema description, guide,
feature record and skill state that, and CLI renderers keep null instead
of substituting a word size.

---------

Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-18 18:29:31 -05:00
morluto 48e27e19b7 test: prune redundant and implementation-coupled coverage 2026-11-17 18:48:24 -05:00
morluto ec1cf3a9bd refactor(cli): render command help with REA's own help owner (#11683)
* refactor(cli): render command help with REA's own help owner

Add src/cli/help.ts and move the three incur Help.formatCommand callers
(rea mcp add, rea mcp doctor, rea mcp --http) onto it. Option spelling and
the unwrapped field type move to src/cli/optionFields.ts, which completion
now reads instead of its own copies. A counted incur-import guard records
the names still imported from incur so the list can only shrink.

Refs #11654

* refactor(cli): share option spelling across CLI owners and count every incur import

The argv parser, strict positionals, contract command projection and the
command registry now read the flag spelling, declared field type and count
marker from src/cli/optionFields.ts instead of their own copies. The
incur-import guard also counts namespace, default, star, side-effect and
dynamic imports, so `import * as Incur from "incur"` cannot bring a removed
owner back.

* refactor(cli): format and filter CLI output without incur (#11684)

* refactor(cli): format and filter CLI output without incur

formatCliOutput encodes TOON (@toon-format/toon), JSON, YAML and JSON Lines
itself instead of calling incur's Formatter; YAML still loads on first use.
src/cli/outputFilter.ts owns the --filter-output grammar and returns a
Result: an unclosed slice is a parse failure, so output validation reads
the parser instead of a second bracket scanner, and the parsed paths
travel with the output arguments to the result writer and JSON Lines.
@toon-format/toon moves from devDependencies to dependencies because REA
now imports it at runtime.

Refs #11654

* test(cli): pin output encodings and filter grammar with literal cases

Literal expected outputs for empty values, TOON scalars, objects and rows,
JSON-text re-indentation, nested BigInt values, JSON Lines rows and YAML,
and literal parsed paths and unclosed-slice refusals for --filter-output,
so a change to either owner fails without comparing against itself.
2026-11-16 12:01:04 +08:00
morluto 352a846127 test: reduce brittle assertions and test-only runtime paths (#9289)
* test: focus assertions on behavioral evidence

Prune redundant and wording-coupled checks while retaining diagnostic, parser, recovery, and cleanup coverage.

* refactor: remove test-only wrappers and duplicate checks

Exercise production operations through test fixtures, remove unused adapters, and keep managed-member uncertainty guidance under its existing owner.

* test: focus process validation on diagnostic facts

* refactor: remove test-only runtime helpers

Move semantic evidence fixture setup out of runtime and remove unused Windows settle recovery helpers while checking configured defaults independently.

* test: focus artifact diagnostics on format facts

* test: verify retained cleanup guidance delivery
2026-11-08 02:02:31 +08:00
gongfppandgongfpp 08bc52104a fix(cli): preserve Unicode edge whitespace in Markdown tables (#8915)
* fix(cli): preserve Unicode edge whitespace in Markdown tables

* fix(cli): bound Markdown whitespace encoding to linear time

---------

Co-authored-by: gongfpp <22683417+gongfpp@users.noreply.github.com>
2026-11-06 14:53:03 +08:00
aa6f6436c9 feat(cli): add CSV and TSV analysis views (#7254)
* feat(cli): add CSV and TSV analysis views

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

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

* Update src/cli.ts

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

* fix(cli): address delimited export review feedback

* fix(cli): format delimited output block in cliResultOutput

* fix(cli): retain delimited view uncertainty and align completions

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-10-28 11:27:40 +08:00