Files
rea/docs/python-pyc.md
T
gensokyo-dev e2463372ea feat(python): query selected pyc code-object facts (#6928)
* feat(python): query retained pyc code-object facts

* test(python): bind complete pyc selection benchmark tasks

* test(python): include server instructions in token accounting

* docs(perf): record pyc selected-facts task measurements

* test(python): keep oracle dependencies separate from selected targets

* docs(perf): record guarded oracle requalification

* test(python): narrow complete Evidence through its owning contract
2026-10-24 10:23:06 +08:00

10 KiB
Raw Blame History

CPython pyc inspection

inspect_python_pyc / inspect-python-pyc reports the supported CPython format and version declared by one selected local .pyc file's magic, how its 16-byte header records source identity, and which nested code objects its decoded marshal graph contains. It reads the file without running bytecode and requires no Python installation, active binary target, Hopper, Ghidra, or IDA.

rea inspect-python-pyc /absolute/path/to/module.pyc --json

The CLI resolves relative paths against the caller's working directory. MCP requires an absolute filesystem path and preserves that exact selection:

{
  "name": "inspect_python_pyc",
  "arguments": { "path": "/artifacts/module.pyc" }
}

Selected code objects

Complete output remains the default. To read selected code objects from a large report, request MCP detail: "summary". The summary contains artifact/header identity, source coverage and a limitation count; its normalized_result.parent_evidence_id identifies the complete retained report. Use that parent ID with inspect_analysis_view and:

{
  "kind": "python-pyc",
  "collection": "code_objects",
  "names": ["parse_args", "parse_known_args"],
  "fields": [
    "name",
    "qualname",
    "filename",
    "firstlineno",
    "bytecode",
    "nested_code"
  ],
  "offset": 0,
  "limit": 64
}

This is the request's view field. To receive these selected facts in the first call, include the same view directly in inspect_python_pyc alongside detail: "summary". Later pages use the returned parent ID with inspect_analysis_view. view requires summary delivery; complete delivery rejects a view instead of ignoring it. names matches retained display strings and returns every same-name object. indices selects original code_objects inde