Skip to content

feat(tools): preview generated stubs as JSON - #13300

Closed
StoneDC wants to merge 1 commit into
boykopovar:mainfrom
StoneDC:b42/stub-preview
Closed

StoneDC wants to merge 1 commit into
boykopovar:mainfrom
StoneDC:b42/stub-preview

Conversation

@StoneDC

@StoneDC StoneDC commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

What

Adds preview_stubs.py, a read-only JSON view of the existing stub generator: deduplicated NIDs, emitted code and technical-debt text. It has no output-file or network operation.

Implementation basis: Calls the existing parse_nids, parse_db and generate functions. A real CLI fixture checks explicit unknown bindings, preserved throwing placeholders, duplicate NIDs, UTF-8, invalid inputs and exact compatibility with the original generator's code/debt streams.

Known limits: The existing generator's unknown signatures remain unknown. The JSON is a review/planning artifact: emitted placeholders are not implemented exports, not verified ABI declarations and not compiled or installed by this command. Input decoding/name validation follow stubgen's existing policy.

Source/schema: tools/preview_stubs.py tools/stubgen.py

Exact topic head 2b2c61c36de8268a9752c122969af258acd257e8 is one independent commit on main 51c31ea17e9f66cb36fe9655ec31c81610bfcfc9. The current-main repository overlap checker against 51c31ea17e9f66cb36fe9655ec31c81610bfcfc9 reported no confirmed overlap. It could not finish comparisons for these older PRs already conflicting with main: #674, #1835, #3786, #5021, #7642, #9539, #10897, #12862. Their shared-file diffs were reviewed separately. 7 scoped file changes projected onto main and then combined with this topic without a new conflict; 1 peer file changes already conflict with main and are not claimed automatically mergeable. They do not provide this command or test matrix. Registration uses a separate target/name and there is no landing-order dependency. Changes to shared registration before landing need a refreshed merge/test check. Depends on: none. The twenty current topic heads are also merged into tested integration cedab5157a32822332671c90812c6780d05157e8.

Tested

Topic head: 2b2c61c36de8268a9752c122969af258acd257e8. Combined integration: cedab5157a32822332671c90812c6780d05157e8, based on main 51c31ea17e9f66cb36fe9655ec31c81610bfcfc9. Ubuntu/WSL GCC 15.2, CMake 4.2.3, Python 3.14.4; Windows MinGW GCC 15.2, CMake 4.3.1, Python 3.14.3.

python tools/tests/test_preview_stubs.py: 2 tests passed on each platform, no skips. A mutation in the actual new tool was rejected by the fixture.

Registered CTest tools_stub_preview passed on Linux and Windows as part of the filtered twenty-topic run: ctest --test-dir <build> -R <20-topic-pattern> -j 8 -V --output-on-failure, 20/20 passed on each platform, zero skips. cmake --build <linux-full-build> --parallel 8: complete default Linux product build passed. Windows used the full configuration and built the sixteen affected libc test targets plus relinker with --parallel 8; a complete default Windows build is not claimed. Conventions, whitespace, script registration and the public-header declaration/umbrella audit passed. No PS5, title or GPU validation run is claimed. macOS, WASM execution and hosted full-build CI are not reported as passed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed — looks good

The JSON preview uses the existing stub-generation functions without writing files, and its exact-head tests verify parity with the original generator.

What I ran

  • Reviewed head 2b2c61c36de8268a9752c122969af258acd257e8 against current main 58d5af7daa8087d2ffbdb50ae6e0db3cb6a88e48.
  • Merge preview was clean: tree d7b6385e5a91258735409de04470e5bd3ffdec62.
  • Environment: Debian Linux, Python 3.11.2. The focused unit test ran in an isolated detached worktree at the PR head. I did not build or configure AnyPS5.
  • Commands:
git merge-tree --write-tree 58d5af7daa8087d2ffbdb50ae6e0db3cb6a88e48 2b2c61c36de8268a9752c122969af258acd257e8
git diff --check 58d5af7daa8087d2ffbdb50ae6e0db3cb6a88e48...2b2c61c36de8268a9752c122969af258acd257e8
python3 tools/check_conventions.py --base 58d5af7daa8087d2ffbdb50ae6e0db3cb6a88e48 --head refs/remotes/upstream/pr-13300 --title 'feat(tools): preview generated stubs as JSON' --body /tmp/pr-13300-body.md
python3 -m unittest tools.tests.test_preview_stubs
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13300

Results

Check Result
Current-main diff Three files: the CLI, its unit test, and CTest registration.
Current-main merge preview Pass; clean tree d7b6385e5a91258735409de04470e5bd3ffdec62.
Diff whitespace check Pass; no output.
Conventions and PR template Pass; All conventions checks passed.
Focused Python tests Pass; 2 tests.
Precheck Syntax, unit tests, Python test registration, conventions, diff check, and live mergeability passed. The test-quality heuristic could not run because tools/pr_test_quality.py is absent from the isolated PR snapshot. Its base snapshot was 42d009f; current main is 58d5af7, so I repeated the merge, diff, and conventions checks against current main.
Hosted checks Conventions, eligibility, and intake pass. Labels and relinker/Windows jobs were pending; Linux product was skipped by workflow policy.
Unedited focused-test output
..
----------------------------------------------------------------------
Ran 2 tests in 0.347s

OK

Findings

Blocking

None found in the reviewed head.

Non-blocking

The author reports an additional mutation control; I did not independently reproduce it. The output is a preview artifact and does not implement or compile any generated exports, as the PR description states.

Sources

Not verified

I did not configure/build CMake or run CTest; I ran the Python test directly. The hosted platform jobs still pending were not treated as passed.

@github-actions

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 674 CMakeLists.txt
PR 1835 CMakeLists.txt
PR 3786 CMakeLists.txt
PR 5021 CMakeLists.txt
PR 7642 CMakeLists.txt
PR 9539 CMakeLists.txt
PR 10897 CMakeLists.txt
PR 12862 CMakeLists.txt

@adriadam10 adriadam10 self-assigned this Oct 30, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

Closing this one, with the reasons below; you're welcome to reopen if they are addressed.

  • tools/stubgen.py already is the read-only preview: without --out/--td-out it writes nothing to disk (code to stdout, debt lines to stderr). preview_stubs.py only calls its parse_nids/parse_db/generate and re-serialises the same two strings as JSON; the test asserts report["code"] == original.stdout and report["technical_debt"] == original.stderr, i.e. it adds no capability.
  • The PR names no consumer or issue that needs the JSON form (Unblocks: none, Fixes: none). A second entry point plus a ctest target and a CMake registration for it is maintenance with no stated use.

If there is a concrete workflow that needs structured output, an option on stubgen.py itself (e.g. --json) with that use case described would be the place to discuss it.

@adriadam10 adriadam10 closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants