Files
reverse-engineering-anything/tests/conformance
Ysopwnableandgensokyo-dev e1b66df5bc feat(native): recover UniFFI library interfaces from exports (#17215)
* feat(native): describe the UniFFI library report and its read budgets

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(native): recover UniFFI interfaces from a library's exports

Group a library's UniFFI scaffolding exports by namespace: objects named
by their free and clone functions with their constructors and methods,
functions, callback interfaces and runtime helpers. The contract version
and each item's checksum are read from function bodies that return only
that constant (x86, x86-64 with or without endbr, arm64), and NAMESPACE
and UDL_FILE metadata buffers are decoded. Nothing is called; a method
that two object names could own is listed under the longer and counted.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(native): read UniFFI libraries through an identity-checked provider

The provider reads one bounded PE or ELF file, maps its export addresses
through the image's own declarations and decodes the UniFFI interface. A
refusal at max_entries, max_text_bytes or max_file_bytes names the budget
to raise.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(analysis): summarize retained UniFFI library reports

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* refactor(analysis): bound the UniFFI summary's namespaces with boundedList

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(native): add the inspect_uniffi_library tool

CLI inspect-uniffi-library and MCP inspect_uniffi_library recover a
UniFFI library's namespaces, objects, methods, functions, callback
interfaces, contract version and checksums from its exports without
loading it. Large reports return the retained per-namespace summary
within the agent budget.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* docs(native): describe UniFFI interface recovery

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* docs(skill): route UniFFI libraries to inspect_uniffi_library

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* ci: scope the UniFFI reader with the native formats

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* chore(schemas): record the advertised inspect_uniffi_library catalog summary

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): keep UniFFI grouping linear and its omissions visible

- Namespaces, metadata owners and object owners are found by looking up
  each underscore-delimited prefix of a name, instead of scanning every
  namespace or object for every export.
- A body or metadata buffer reads the longest mapped prefix, so a constant
  that ends at its mapping's end is still decoded.
- A metadata buffer that cannot be read or decoded is counted apart from
  kinds this reader does not decode, and makes coverage partial.
- A partial export table carries its reasons into the report.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(native): expose max_structure_bytes for UniFFI library inspection

The export reader's table-size limit is now a caller control, and its
refusal names it, as inspect_native_exports does.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(cli): honour delivery options for inspect-uniffi-library

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* docs(native): list the UniFFI structure budget and record its schema

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): match UniFFI namespaces and owners with a prefix trie

Namespaces, metadata owners and object owners are now found by walking
the name once through a trie of the known words, from the positions where
UniFFI spells them. The cost per name grows with its length, not with its
underscore count squared or with the number of known words.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): index UniFFI prefixes by hash instead of a character trie

A character trie allocated a node and a map for every distinct prefix, so
long crafted export names could exhaust the heap before the report's text
checks. The prefix index now keeps one entry per known word, keyed by two
polynomial hashes, and walks each name once computing the hashes of its
underscore-ended prefixes; only the longest matches are compared.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): map UniFFI reads through one index and check namespace shapes

- Constant and metadata reads use one file-mapping index built with the
  image's zero-filled ranges, so each read is a lookup and an ambiguous
  address reads as unknown instead of as definite bytes.
- The ELF container read honours max_structure_bytes, as the export read
  already did.
- 32-bit x86 images, which the shared readers name 386, decode their
  constants.
- A scaffolding symbol belongs to the longest namespace whose remainder
  has a scaffolding shape, so a namespace ending in _fn cannot take
  another namespace's functions.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): carry the export reader's issues into a partial UniFFI report

A partial export table now reports its first issues by code and message,
counting the rest, before falling back to its limitations.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): consider every shaped namespace match for UniFFI symbols

The scaffolding shape after a namespace is now checked while the name is
walked, so every span followed by _fn_ or _checksum_ is a candidate, not
only the longest four matches; only the chosen word is compared.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

---------

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-12-06 06:30:31 +08:00
..

Source-built conformance fixtures

These sources are deliberately small semantic oracles for REA providers. Run npm run verify:fixtures on macOS or Linux to compile them into the ignored build/conformance/ directory, emit a hash-and-toolchain manifest, and verify their platform-native symbols and strings with local command-line tools. The portable C, version, and large-inventory fixtures build as Mach-O on macOS and ELF on Linux; Objective-C, Swift, and N-API-like fixtures remain macOS-only.

Only source files are versioned. Generated binaries, generated large-fixture source, debug information, and manifests must remain under build/.

ghidra/inventory.c is also compiled into temporary Linux ELF debug and stripped variants by npm run verify:ghidra. It fixes local functions, external puts linkage, defined strings, and writable/executable memory needed to prove the read-only Ghidra inventory contracts without committing a binary.

scripts/create-ghidra-windows-fixture.mjs separately emits a deterministic, ignored native x86-64 PE application for the controlled Windows Ghidra P0 lane. The generator and fixed SHA-256 are versioned; the .exe is never committed or executed. npm run verify:ghidra:windows uses it to verify the admitted read-only operation inventory, digest linkage, transport, and cleanup on the self-hosted real-Ghidra runner.

The C fixture fixes a known call chain and strings. The version pair fixes an added symbol, changed string, and changed call relationship. The generated large fixture contains 1,205 uniquely named functions and strings to verify that providers return complete inventories. Objective-C, Swift, and N-API-like fixtures provide metadata-oriented inputs without package or network dependencies.

readiness/ adds source-only generated JavaScript CLI and Electron fixtures for the repository's reconstruction-readiness verifier. npm run verify:readiness inspects the compiled native fixture through CLI and checks JavaScript/Electron static-analysis Evidence identity through CLI and MCP. It does not execute the fixture applications. The development-owned evaluator under readiness/report/ separately checks synthetic report conformance; its nine stages do not describe observed runtime journeys. The report keeps these scopes separate as documented in docs/development/reconstruction-readiness.md.