Repository navigation
ci(typescript): ts-rs binding drift guard (task #62) - #1626
Merged
Merged
Conversation
The substrate has Rust types with `#[derive(TS)]` + `#[ts(export_to =
"../../../protocol/typescript/...")]` attributes. `cargo test`
regenerates those .ts files as a side effect of running per-type
`export_bindings_*` tests.
When an author adds a new field or variant to a Rust type but forgets
to commit the regenerated .ts file, the wire shape drifts silently:
- Mac/Linux dev: cargo test regenerates locally, looks fine, ships
PR without the .ts in the diff.
- Reviewer: sees only the Rust change, approves.
- Downstream TS consumer at runtime: hits the new variant / missing
field; no compile-time guard fires (the .ts file is stale).
Today's session had a near-miss on continuum #1624 (Mac Intel
classify_silicon fix): TargetSilicon gained the MacIntelMetal variant
but the regenerated `protocol/typescript/governor/TargetSilicon.ts`
was not in the initial push. Had to amend.
Adds `.github/workflows/ts-rs-binding-drift-guard.yml`:
- triggers on PRs touching Cargo, rust-toolchain, core/**, or
protocol/typescript/** (a TS edit needs the gate too — it must
match the Rust source);
- picks up Rust 1.95 from rust-toolchain.toml (#1614);
- runs ONLY the `export_bindings_*` tests (cheap — same skip
patterns as #1616's CI gate so GPU/env-var tests don't sink it);
- then `git diff --exit-code protocol/typescript/`. Non-empty diff
means the test run regenerated bindings that the PR did NOT
commit. Fail with a verbatim fix-recipe in the error log.
Composes with:
- #1614 toolchain pin (Rust version)
- #1616 unit-test CI gate (same skip patterns)
- #1624 (the near-miss this workflow would have caught at CI)
Co-Authored-By: Claude Opus 4.7 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements task #62: substrate-doctrine CI guard against ts-rs binding drift. The substrate has Rust types annotated with
#[derive(TS)]and#[ts(export_to = "../../../protocol/typescript/...")].cargo testregenerates those .ts files as a side effect. When an author adds a field or variant to a Rust type but forgets to commit the regenerated .ts, the wire shape drifts silently:cargo testregenerates locally, looks fine, ships PR without the .ts in the diff.Today's session had a near-miss on continuum #1624 (Mac Intel
classify_siliconfix) —TargetSilicongainedMacIntelMetalbut the regeneratedprotocol/typescript/governor/TargetSilicon.tswas not in the initial push. I had to amend. This guard makes that mistake impossible to land.Changes
.github/workflows/ts-rs-binding-drift-guard.yml:Cargo.toml/Cargo.lock,rust-toolchain.toml,core/**, orprotocol/typescript/**.rust-toolchain.toml(build(toolchain): pin rust 1.95 — unblock continuum-core unit tests on stable #1614).export_bindings_*tests (cheap — same skip patterns as ci(rust): cargo test -p continuum-core --lib on every PR #1616's CI gate so GPU/env-var tests don't fail this run).git diff --exit-code protocol/typescript/. Non-empty diff means the test run regenerated bindings that the PR did NOT commit. Fail with a verbatim fix-recipe in the error log:Composes
Test plan
#[derive(TS)]Rust type without committing the regenerated .ts gets a red gate with the fix recipe.🤖 Generated with Claude Code