CI contract gate

Fail the build when __pyrpc.ts falls behind the Python procedures, and see the call sites a change breaks.

__pyrpc.ts is committed, so a contract change is a diff someone reviews. The failure mode is a rename in Python that never reached the client: the types go stale, the app keeps calling a procedure that no longer exists, and nothing says so until a page renders blank in production.

pyrpc check closes that gap in CI. It regenerates the types in memory, compares them with each configured client's committed __pyrpc.ts, and when they differ it type-checks the client against the new types and names the call sites that stop compiling.

pyrpc check
✗ web/__pyrpc.ts is out of date
  removed: get_user
  added: fetch_user

  2 call sites break against the new types
    web/page.tsx:3:25
      export const user = api.get_user(1)
      TS2339 Property 'get_user' does not exist on type 'Types'.
    web/sidebar.tsx:4:14
      return api.get_user(id)
      TS2339 Property 'get_user' does not exist on type 'Types'.

  → Run `pyrpc dev` to regenerate the types, then fix the call sites above.

Exit code 1 means the change is not ready to merge. Exit code 0 prints the procedures and clients it compared.

What it reads

pyrpc check uses the same pyrpc.json, the same types module, and the same generator as pyrpc dev, so it cannot disagree with the file your editor sees. It never modifies the working tree: __pyrpc.ts is swapped for the regenerated content only while TypeScript runs, then restored byte for byte.

The type check uses the client's own compiler, resolved from node_modules/typescript in the client root or a parent directory, so an npm workspace with hoisted dependencies works without extra configuration. It runs only when the types are stale, which means a pull request that keeps the types current needs no Node toolchain in that job.

It does not replace your app's type check. It answers a narrower question: did the Python contract change land everywhere it needed to?

In GitHub Actions

The repository ships a reusable action that runs the check and posts the report as a sticky pull request comment, updated in place on every push.

name: Contract

on:
  pull_request:
    branches: ["main"]

permissions:
  contents: read
  pull-requests: write

jobs:
  pyrpc-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: pyrpc/pyrpc/.github/actions/pyrpc-check@v0
        with:
          working-directory: .

The action runs uv sync in working-directory, so the project must be a uv project with pyrpc-core installed. Fork pull requests are checked but never commented, because their token is read-only.

When the types are stale the action type-checks the client, and a complete call-site report needs the client's dependencies installed. If your project does not install them before this step, add one, for example npm ci in the client root. The list of changed procedures is reported either way, because it comes from the diff and not from TypeScript.

This repository runs the same gate on its own examples: every directory with a pyrpc.json is checked in CI, so the committed generated file there can never fall behind the Python it came from. That job installs no Node toolchain, which keeps it fast and still reports the exact procedures that changed.

To wire it up by hand instead, run pyrpc check after installing the project. The output is written for a build log, so a single step is enough.