Files
Ysopwnableandgensokyo-dev e5004c11ea feat(managed): recover protobuf descriptors from .NET assemblies (#17287)
* feat(managed): describe the protobuf descriptor recovery report and its budget

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

* feat(managed): recover protobuf descriptors from generated Reflection classes

Google.Protobuf's generated <File>Reflection classes build each
FileDescriptorProto in a static constructor that concatenates string
literals and passes them to System.Convert.FromBase64String. Read those
literals from the CIL in order, decode each site and keep the results that
parse as FileDescriptorProtos, byte for byte. A FileDescriptorSet lists
them dependencies first, with the well-known protobuf files they import;
other imports are named as missing. Literal characters count against
max_descriptor_bytes before they are joined. Nothing is loaded or run.

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

* fix(managed): report descriptor recovery refusals as parse failures

A metadata representation budget stops the whole call as a named limit,
including inside one static constructor; other managed reader refusals
become malformed or unsupported input.

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

* feat(managed): recover protobuf descriptors through an identity-checked provider

The provider reads one bounded managed assembly. A refusal at
max_descriptor_bytes, max_metadata_representation_bytes or
max_snapshot_bytes names the control to raise.

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

* feat(analysis): summarize retained protobuf descriptor recovery

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

* feat(managed): add the recover_protobuf_descriptors tool

CLI recover-protobuf-descriptors and MCP recover_protobuf_descriptors
return each embedded .proto file's package, imports, messages, enums and
services, and a FileDescriptorSet for decoding captured payloads. Large
reports return the retained per-file summary within the agent budget.

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

* test(managed): cover protobuf descriptor recovery through the service, MCP and CLI

The protoc-style assembly fixture moves to tests/fixtures so the unit,
MCP and CLI tests share it.

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

* docs(managed): describe protobuf descriptor recovery

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

* docs(skill): route Google.Protobuf assemblies to recover_protobuf_descriptors

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

* ci: scope protobuf descriptor recovery with the managed formats

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

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

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

* fix(managed): attribute, bound and account for every descriptor search

- Static constructors are found among physical MethodDef rows and named by
  the shared ownership lookup, so a MethodPtr table cannot attribute a
  descriptor to the wrong type.
- A FileDescriptorProto's wire form is walked along its schema first, and
  every nested message it would create is charged to the representation
  budget before protobuf-es decodes it.
- A body whose CIL was not fully decoded, and malformed member lists, make
  coverage partial instead of looking searched.

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

* test(managed): build descriptor fixtures in protoc's String.Concat shapes

The fixture's static constructor now joins its literals through
String.Concat, as arguments or a string[], before calling
FromBase64String with its real static byte[](string) signature; the
managed PE fixture can name each MemberRef row. Tests cover both forms
and the descriptor tree bound.

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

* fix(analysis): sample missing imports in the protobuf descriptor summary

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

* docs(managed): save the descriptor set from complete delivery and fail on null

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

* fix(managed): name the descriptor nesting limit instead of rejecting deep files

The nesting cutoff is now the max_descriptor_depth control (100 by
default, up to 1,000). A deeper descriptor stops the call with a named
limit rather than being listed as not a descriptor, and protobuf-es
decodes up to the same depth so it cannot refuse what the walk admitted.

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

* docs(managed): list the descriptor depth budget and record its schema

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 08:42:26 +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.