Skip to content

test(rpc): add a compile-time params catalog parity gate - #20281

Merged
Jinwoo-H merged 2 commits into
mainfrom
rpc-params-type-parity
Sep 13, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
rpc-params-type-parity

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 0 0 0 0
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​50 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49

What

Asserts that RpcParams<M> from the generated catalog matches the parsed-params type of method M's own defineMethod declaration, for every registered method.

The catalog maps method → schema by object identity, and a byte-comparison drift gate already catches regeneration changes. Neither checks that the resulting types agree with the host's. This closes that.

Cheap now because #20016 stopped erasing the parsed-params type from defineMethod.

Not a rebuild of the gate we deleted

The previous runtime parity gate was removed for cause: 22,772 probes of which ~88% were vacuous (each set one field and omitted every required sibling, so both sides rejected them for the same unrelated reason), and it was red in CI because it resolved mobile/node_modules/zod, which the unit-test workflow never installs. This is type-level, runs inside the existing node typecheck, and adds no probes.

Design

  • Driven off typeof ALL_RPC_METHODS, so a newly registered method is covered with nothing to remember.
  • Mutual assignability, not one direction — a one-way check misses a widening.
  • An IsAny guard so any on either side fails rather than silently satisfying extends both ways. That is the usual way a gate like this rots.
  • A second assertion keeps the uncatalogued allow-list from going stale: if one of those methods ever gains a catalog entry, the exclusion itself fails.

Three methods are excluded as uncatalogued (emulator.install, orchestration.send, orchestration.taskUpdate). Verified: they are the three already listed as omitted-by-design in the generated catalog, not silent drops.

Evidence

Widening one catalog entry to any fails the node typecheck and names the method:

rpc-params-type-parity.ts(39,47): error TS2344: Type '"worktree.ps"' does not satisfy the constraint 'never'.

What it does not catch

It is a type gate. It cannot prove runtime parse behaviour — identical types can still parse differently. The byte-comparison drift gate and the host's own safeParse path remain the runtime contract.

Gates

pnpm tc · typecheck:tsc · vitest run src/main/runtime/rpc · verify:rpc-params-catalog · check:code-quality:changed.

Check each registered handler against its catalog params type in both directions, with explicit exceptions for the three uncatalogued schemas.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d595c910-50e3-4b0b-8e4d-b014ba241924

📥 Commits

Reviewing files that changed from the base of the PR and between b522e35 and 1bb3330.

📒 Files selected for processing (1)
  • config/scripts/generate-rpc-params-catalog.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change prevents the RPC catalog generator from indexing its own output file. It also adds compile-time checks that compare each registered handler's first parameter with its catalog RpcParams type and treat any as a mismatch. The checks detect registered methods that are neither catalogued nor explicitly allowed. Exported aliases assert that both mismatch sets resolve to never.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 1bb33

The changes provide the intended compile-time parity gate and reliably exclude the generated catalog from regeneration. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, motivation, design, limitations, and validation commands. However, it omits the required Linked Issue, Visual Proof or an explicit N/A statement, Testing checklist… Add the missing template sections. Include a linked issue after “Fixes #”, state “N/A” with a reason for Visual Proof, complete the Testing and Agent skill upstream boundary checkboxes, and address AI Disclosure, Review, Notes, and Checklis…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a compile-time RPC parameter catalog parity gate.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the change, motivation, design, limitations, and validation commands. However, it omits the required Linked Issue, Visual Proof or an explicit N/A statement, Testing checklist details, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections.

Resolution

Add the missing template sections. Include a linked issue after “Fixes #”, state “N/A” with a reason for Visual Proof, complete the Testing and Agent skill upstream boundary checkboxes, and address AI Disclosure, Review, Notes, and Checklist requirements.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot 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.

Important

The new file sits under src/main/runtime/rpc/, which the catalog generator scans, so its type-only import pulls the generator's own output back into its inputs and can crash pnpm run generate:rpc-params-catalog when the committed catalog has a dangling import — the exact state that requires regenerating. Everything else checks out; the type gate itself is sound and I verified it fails loudly on a real mismatch.

Reviewed changes

  • Compile-time params parity gate — adds src/main/runtime/rpc/rpc-params-type-parity.ts, asserting mutual assignability between each registered method's parsed handler params (Parameters<Method['handler']>[0]) and RpcParams<name> from the generated catalog, with an IsAny guard and a second alias that keeps the three-method uncatalogued allowlist from going stale.
  • No behavioral runtime surface — the file is type-only, has no importers, and is exercised by config/tsconfig.node.json (which includes src/main/**/*) rather than by an explicit reference.

typecheck:tsc:node, verify:rpc-params-catalog, and check:code-quality:changed all pass locally, and mutating one catalog entry does produce a named TS2344 failure.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

The parity gate imports the generated catalog for types, and it lives under
RPC_DIR, which indexableModules() scans for shared imports. That re-added
OUTPUT_PATH after line 46 removed it, so the generator bundled and require()d
the committed catalog. A catalog referencing a renamed or deleted shared export
then crashed regeneration — in exactly the state that requires regenerating.

Reproduced before and after: with a dangling reference injected into the
catalog, `generate:rpc-params-catalog` threw; it now rewrites the file.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

@pullfrog pullfrog Bot 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.

✅ No new issues found.

The follow-up commit resolves the generator self-inclusion regression cleanly. indexableModules() now guards with resolved !== OUTPUT_PATH, so the parity file's type-only import of rpc-params-catalog.generated no longer re-adds the generator's own output to its input set. I reproduced the failure mode — injected a dangling import into the committed catalog and ran pnpm run generate:rpc-params-catalog — and it regenerates successfully, with the rewritten catalog byte-identical to the valid committed version. Prior thread resolved.

Reviewed changes

  • Generator guard — indexableModules() in config/scripts/generate-rpc-params-catalog.mjs skips OUTPUT_PATH when adding resolved relative imports, closing the path that let the parity file pull a stale catalog into regeneration.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit bc5e676 into main Sep 13, 2026
28 checks passed
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.

1 participant