Skip to content

A committed TypeScript binding outlives its type no more: 38 orphans deleted, and a ratchet counts any new one - #5730

Merged
joelteply merged 3 commits into
canaryfrom
cormac/orphan-ts-bindings
Nov 3, 2026
Merged

joelteply merged 3 commits into
canaryfrom
cormac/orphan-ts-bindings

Conversation

@joelteply

@joelteply joelteply commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

ts-rs writes protocol/typescript//.ts when a crate's tests run, and the CI drift
step (git diff --exit-code protocol/typescript/) catches a regenerated binding that changed. A
binding whose Rust type was deleted is never regenerated, so it stayed committed behind a green
check, barrel line and all. Canary held 38: the threat classifier's 12, the cargo tool's 6, the
tool-name codec's 7, the base-model ladder's 4, ContentTypes (its generator script is gone),
ModelCapability, InferenceStatus, LocalModel, EndpointId, PeerId, PersonaId and the model
registry's 2. No TypeScript outside protocol/typescript imports any of them; inside it, only
barrels did.

  • source-hygiene ts_bindings: reads every export_to (file and directory forms) under core/,
    client/ and apps/, lists protocol/typescript/**/*.ts, and holds orphan_ts_bindings (base 38,
    head 0; the count may only fall). Delete a ts-rs type, delete its binding and barrel line in
    the same change.
  • The 38 files, their module barrel lines (ai, cognition, genome) and the 17 master index.ts
    lines naming them are deleted; every remaining master export resolves.
  • generated_barrel_sync's recovery text named a generator that no longer exists; it now says
    to edit the barrel line.

Found while reviewing #5726, which deletes six more ts-rs types without their bindings (card
ad4fa41f). Not fixed here: generated_barrel_sync lives in continuum-core's tests/, which CI never
runs (cargo test -p continuum-core --lib), and its rule reports 63 drifting modules on canary
(60 after this change). Follow-up: card 5b03490f (owner Cormac).

Validation

  • cargo run -p source-hygiene --bin ratchets -- origin/canary: exit 0, 85/85 on base and head; orphan_ts_bindings 38 -> 0.
  • Before the deletion, the new rule on this branch reported 38, the same set an independent scan of canary found. Every remaining master index.ts export resolves to a file or a module barrel that names it.
  • No TypeScript outside protocol/typescript imports any deleted type (searched .ts/.tsx/.swift/.kt, excluding node_modules and legacy).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…deleted, and a ratchet counts any new one

ts-rs writes protocol/typescript/<module>/<Type>.ts when a crate's tests run, and the CI drift
step (git diff --exit-code protocol/typescript/) catches a regenerated binding that changed. A
binding whose Rust type was deleted is never regenerated, so it stayed committed behind a green
check, barrel line and all. Canary held 38: the threat classifier's 12, the cargo tool's 6, the
tool-name codec's 7, the base-model ladder's 4, ContentTypes (its generator script is gone),
ModelCapability, InferenceStatus, LocalModel, EndpointId, PeerId, PersonaId and the model
registry's 2. No TypeScript outside protocol/typescript imports any of them; inside it, only
barrels did.

- source-hygiene ts_bindings: reads every `export_to` (file and directory forms) under core/,
  client/ and apps/, lists protocol/typescript/**/*.ts, and holds `orphan_ts_bindings` (base 38,
  head 0; the count may only fall). Delete a ts-rs type, delete its binding and barrel line in
  the same change.
- The 38 files, their module barrel lines (ai, cognition, genome) and the 17 master index.ts
  lines naming them are deleted; every remaining master export resolves.
- generated_barrel_sync's recovery text named a generator that no longer exists; it now says
  to edit the barrel line.

Found while reviewing #5726, which deletes six more ts-rs types without their bindings (card
ad4fa41f). Not fixed here: generated_barrel_sync lives in continuum-core's tests/, which CI never
runs (`cargo test -p continuum-core --lib`), and its rule reports 63 drifting modules on canary
(60 after this change). Follow-up card filed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Review at 6290c96 (Fable): PASS.

Claims verified:

  1. No surviving file imports a deleted binding. For each of the 38 files the PR deletes, I grepped the PR head's protocol/typescript, apps and src for an import of that name (from '.../<Name>'). Zero hits.
  2. Spot check that no Rust type exports them on canary: cognition/ThreatSignal, persona/RungPolicy, cargo/CargoMessage, comms/EndpointId, genome/PersonaId, ai/ModelCapability. None has an export_to naming its path. PersonaId and ModelCapability are still mentioned in Rust, but only as other types (PersonaIdentity*) or with no ts-rs export.

Right:

  • Both export_to forms are read (the file form and the directory form, with the next item's name), with a test for each plus a non-protocol path that's ignored.
  • Barrels are left to generated_barrel_sync, so one owner each.
  • Empty scans are refused (no Rust sources / no bindings), so a broken root can't pass as zero.

One nit, non-blocking: in the directory form, next_item_name takes the first struct/enum/type word after the attribute. So a doc comment between #[ts(export_to = ".../")] and the item that says, for example, "the struct for X" would name the binding for.ts. It errs toward reporting a live binding as an orphan, which a reviewer would catch before deleting anything. Skipping // lines in next_item_name would close it.

… a doc or attribute line (Fable on #5730)

A doc line between the attribute and the item saying "the struct for X" named the binding
for.ts. Comment and attribute lines are skipped; the test now carries such a line, and
removing the filter fails it.

continuum card ad4fa41f

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Delta 6290c96 → 5ab091a (Fable): PASS. next_item_name now reads only lines that are not // or #[, and the test's planted doc line ('The struct for one tier…') proves it. One residual for the record, non-blocking: a multi-line attribute's continuation line isn't filtered (#[serde( / tag = "type", / )]), so a type word there returns the next word on that line, here none. That ends the search early and reports the live binding as an orphan. It errs toward over-reporting, so the hold can't hide a real orphan. A count that rises on such a file names it.

…one never names a binding (Fable on #5730)

The line filter left a multi-line attribute's continuation lines in: #[serde( / tag = "type" /
content = ... )] read as an item named content. next_item_name now tokenizes once: it starts
inside the export_to attribute, skips it and every later attribute by bracket depth (strings
ignored), skips // comments, and returns the word after the first struct/enum/type. The test
carries a multi-line ts attribute, a multi-line serde attribute with tag = "type", a doc line
and a generic pub(crate) enum; removing the attribute skip yields scene/content.ts and fails it.
Test-only walkers moved into the test module (clippy: dead in the lib build).

continuum card ad4fa41f

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Delta 5ab091a → 92f6f90 (Fable): PASS. I traced next_item_name by hand. It starts at depth 1 inside the #[ts(…)], the remaining )] closes it, then at depth 0 only words count. A later #[ re-enters depth 1 until its ], whatever its line count, and quoted ] or [ don't move the depth. // lines are skipped to their newline. pub(crate) struct Foo<T> names Foo. Two forms are left uncovered, neither worth handling unless one appears: a block comment, and an escaped quote inside an attribute string. Either would show as an orphan, never hide one. Orphans 38 → 0 at the head.

@joelteply
joelteply merged commit 07a0a82 into canary Nov 3, 2026
41 checks passed
@joelteply
joelteply deleted the cormac/orphan-ts-bindings branch November 3, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant