Skip to content

chore(cli-rs): run check:drift on pull requests that change its TypeScript inputs - #68686

Open
simonklee wants to merge 2 commits into
devfrom
drift-on-prs
Open

simonklee wants to merge 2 commits into
devfrom
drift-on-prs

Conversation

@simonklee

@simonklee simonklee commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

N/A (CI proposal for the Rust client; no issue exists)

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

A proposal for Simon to accept or close. check-cli-rs.yml runs on pull requests only when they change packages/cli-rs, so a PR that changes the server API or config schema passes its own checks and turns dev's Rust check red until someone regenerates. That happened four times in three days: #68150 (fixed by #68286), #68521 (#68576), #68600 (#68627), and #68625, machine relays (#68683, open).

The new check-cli-rs-drift.yml runs only bun run check:drift (setup-bun, rustup toolchain install for rustfmt, then the check) on PRs that change these paths, which are what the generators in packages/cli-rs/script/gen import directly:

  • packages/protocol/**, packages/schema/**, packages/client/** (API types, flags, plugin types; all four incidents)
  • packages/httpapi-codegen/** (script/gen/api.ts builds the Rust API from its compile output)
  • packages/tui/src/config/**, packages/tui/src/theme/**, packages/theme/** (keybinds, themes)
  • packages/cli/src/commands/** (CLI commands and output)

Left out from the dev push list: the rest of packages/tui, packages/cli/src, packages/util and packages/plugin, which the generators reach only through imports or which only the parity oracles read, and bun.lock. Including them would run this on almost every TUI and CLI PR. The dev push run still catches them.

The dev push list in check-cli-rs.yml gains packages/httpapi-codegen/** too: it was missing, so drift from that package got past both runs. It is the only workspace package the generators import directly that either list lacked.

If the check fails, the author runs bun run check:drift in packages/cli-rs (it needs rustfmt) and commits the files it rewrites; the job's error says so. That is the right command, not bun run generate, which doesn't rerun the parity oracles that check:drift checks and does run two generators that check:drift skips (network grammars, ICU time). Committing the result touches packages/cli-rs, so the full check-cli-rs then runs on the PR and shows any hand-written Rust it needs, as #68576 did.

Cost per affected PR: about 70 s, measured on this PR's own run (checkout 5 s, cached Bun setup 7 s, toolchain install 6 s, check:drift 50 s). Fork PRs are safe: pull_request with contents: read and no secrets.

No feature flag: CI-only.

How did you verify your code works?

  • Ran bun run check:drift in a fresh worktree of origin/dev with only bun install and a system rustfmt, no cargo build or OpenTUI download: 55 s. It needed nothing beyond node_modules.
  • Traced which files each generator opens to pick the paths.
  • actionlint 1.7.12 is clean apart from the Blacksmith runner label it doesn't know, which check-cli-rs.yml gets too.
  • This PR's own run of the new job will be red until fix(cli-rs): regenerate the API for machine relays #68683 (machine relays regeneration) merges: check:drift fails on dev today for that reason.

Screenshots / recordings

N/A: CI-only change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@simonklee
simonklee requested a review from thdxr as a code owner December 6, 2026 07:31

@opencodejr opencodejr 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.

The approach looks right: run just check:drift on PRs that change the generators' TypeScript inputs, with the same setup as check-cli-rs.yml. I checked the path list against the imports in packages/cli-rs/script/gen and script/rust, and against script/drift.ts. I couldn't run the job, because this environment has no rustfmt. This PR's own CI run will be the real test.

Public API: unchanged (CI only).

One gap: packages/httpapi-codegen is a direct generator input, but it's missing here and from the dev push list (inline comment).

paths:
- packages/protocol/**
- packages/schema/**
- packages/client/**

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.

script/gen/api.ts and script/rust/methods.ts import compile / Endpoint from @opencode/httpapi-codegen, so a change in packages/httpapi-codegen can change the generated Rust API. That package isn't listed here or in the dev push paths of check-cli-rs.yml, so drift from it would get past both runs. Worth adding packages/httpapi-codegen/** to both lists.

@opencodejr opencodejr 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.

The earlier point is fixed: packages/httpapi-codegen/** is now in both the new workflow's PR paths and the dev push list of check-cli-rs.yml. Nothing new to raise. I checked this by reading the diff; I couldn't run the job here because this environment has no rustfmt.

Public API: unchanged (CI only).

This branch has not been deployed

No deployments
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