Skip to content

app, docs: add --json output to xtp inspect and xtp census - #24

Merged
simnJS merged 2 commits into
MiamiGame:mainfrom
PrivacyOnion:app/inspect-census-json
Nov 24, 2026
Merged

simnJS merged 2 commits into
MiamiGame:mainfrom
PrivacyOnion:app/inspect-census-json

Conversation

@PrivacyOnion

Copy link
Copy Markdown
Contributor

What and why

Add a stable --json output mode to xtp inspect and xtp census (reusing survey::quote with no new dependencies):

  • xtp inspect <file> --json (format: xtp-inspect 1): emits file, blake3, kind, machine, subsystem, image_base, size_of_image, entry_rva, and sorted imports (including delay-load imports) with each entry's resolution (hle, host, title, or missing).
  • xtp census [paths...] --json (format: xtp-census 1): emits images, unreadable, totals (functions, hle, host, missing), sorted dlls, and missing pairs ordered by descending image count then (dll, symbol).

Size note: 477 changed lines (slightly over 400) because the integration test includes a self-contained strict JSON parser so no new crate dependency is needed.

Fixes: #2
Depends on: none

Area

  • apps/xtp (main.rs, inspect.rs, census.rs, survey.rs, tests/inspect_json.rs)
  • README.md (document --json on xtp inspect and xtp census)

Tests

  • cargo xtask pr-check passes on my machine
  • New or changed behaviour has tests that need no game files, or I explain below why it cannot
  • Ran on the title: no

Integration test apps/xtp/tests/inspect_json.rs builds tests/fixtures/hle-probe and runs:

  • xtp inspect --json <hle_probe.dll>: parses the output as strict JSON, checks file, machine, image_base, verifies xgameruntime.dll resolves as hle, and verifies the missing probe DLL resolves as missing.
  • xtp census --json <hle_probe.dll>: parses the output as strict JSON, checks images == 1, totals, and verifies the missing probe DLL appears in missing.

Provenance

  • I wrote all of this change myself for XTP, or it only moves code already in XTP.
  • Some of it comes from elsewhere. Each source, its licence and the files concerned are listed here, and every licence is compatible with GPL-3.0-or-later:

Written from scratch for XTP, reusing apps/xtp/src/survey.rs's quote helper. I did not read xcl's inspect.rs.

AI assistance: Antigravity assisted with implementation and integration tests; all changes were reviewed and verified locally with cargo xtask pr-check.

Checklist

  • No game data, keys, console SDK code or headers, and nothing that circumvents DRM (asset policy)
  • No code copied from xcl or AnyPS5 (references only: read them to understand, write your own)
  • I agree to license this contribution under GPL-3.0-or-later
  • Title and every commit follow <area>: <summary>; one topic; under 400 changed lines, or the reason is above
  • Docs updated where behaviour, commands or variables changed (README, docs/)

@github-actions github-actions Bot added the overlap another open PR changes the same files label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Other open pull requests change the same files. Check that they do not do the same work, and agree with their authors on which lands first: the other one will then need a rebase.

Pull request Files changed by both
#20 README.md, apps/xtp/src/main.rs
#23 README.md
#26 README.md

This comment is kept up to date automatically and removed when the overlap ends.

@github-actions github-actions Bot added area/app apps/ area/docs docs/, Markdown size/L 400 to 999 changed lines labels Nov 24, 2026

@simnJS simnJS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, the implementation is careful:

  • it adds no dependencies and reuses survey::quote;
  • the text output stays identical;
  • the order is deterministic;
  • logs go to stderr, so stdout is always clean JSON.

The test on hle-probe covers the issue's acceptance criteria, and I found no code from xcl.

One change before approval:

  1. Document the schema in the repo. The issue asks for a stable output, but the field list is only in the PR description. Please add a short paragraph under "Commands" in README.md covering:

    • the fields of xtp-inspect 1 and xtp-census 1 and their types (e.g. "addresses, RVAs and machine are hex strings; sizes and counts are numbers");
    • the resolution values: hle, host, missing, with title reserved, since a static inspect cannot resolve DLLs the title ships, so those show as missing;
    • that --json ignores --imports/--exports and always includes the missing list for census (or reject the combination with conflicts_with);
    • that the format number goes up on a breaking change.

    You could also mark B13 done in docs/analysis/tooling.md.

Optional, here or in a follow-up:

  • In the test, assert "delay": true for xtp-probe-delayed.dll and "kind": "dll". A small unit test of census::to_json with empty maps would also make the [] branches run.
  • The test parser is not quite strict (it accepts raw control characters inside strings), so "minimal" would describe it better. It does catch trailing and missing commas, which is what matters here.
  • build_probe duplicates the loader test's helper and builds the fixture a second time. Moving it to xtp-testkit later would remove both.

Process note for next time: please comment on the issue to claim it before you start (CONTRIBUTING, "Before you start"), so that nobody duplicates the work. It worked out this time, since nobody else had claimed it.

@PrivacyOnion

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback:

  • Documented the xtp-inspect 1 and xtp-census 1 schemas, field types, resolution values (including title reserved), --json flag interactions, and format versioning under Commands in README.md.
  • Added assertions for kind: "dll" and delay: true on xtp-probe-delayed.dll, updated the test parser comment to "minimal", and added a unit test covering empty dlls / missing arrays in census::to_json.

@simnJS simnJS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all addressed: the schema is documented in the README, and the tests now cover delay, kind and the empty arrays. CI is green. Merging.

@simnJS
simnJS merged commit 87d94be into MiamiGame:main Nov 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/app apps/ area/docs docs/, Markdown overlap another open PR changes the same files size/L 400 to 999 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--json output for xtp inspect and xtp census

2 participants