Repository navigation
test(rpc): add a compile-time params catalog parity gate - #20281
Conversation
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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe 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 Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to 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)
✅ Passed checks (4 passed)
Full details: Description checkExplanation 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.
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
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]) andRpcParams<name>from the generated catalog, with anIsAnyguard 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 includessrc/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.
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
There was a problem hiding this comment.
✅ 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()inconfig/scripts/generate-rpc-params-catalog.mjsskipsOUTPUT_PATHwhen adding resolved relative imports, closing the path that let the parity file pull a stale catalog into regeneration.
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

What
Asserts that
RpcParams<M>from the generated catalog matches the parsed-params type of methodM's owndefineMethoddeclaration, 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
typeof ALL_RPC_METHODS, so a newly registered method is covered with nothing to remember.IsAnyguard soanyon either side fails rather than silently satisfyingextendsboth ways. That is the usual way a gate like this rots.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
anyfails the node typecheck and names the method: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
safeParsepath remain the runtime contract.Gates
pnpm tc·typecheck:tsc·vitest run src/main/runtime/rpc·verify:rpc-params-catalog·check:code-quality:changed.