Skip to content

test(schema): enforce Rust and frontend client parity#380

Open
IvGolovach wants to merge 7 commits intojunhoyeo:mainfrom
IvGolovach:feat/client-parity-guard
Open

test(schema): enforce Rust and frontend client parity#380
IvGolovach wants to merge 7 commits intojunhoyeo:mainfrom
IvGolovach:feat/client-parity-guard

Conversation

@IvGolovach
Copy link
Copy Markdown
Contributor

@IvGolovach IvGolovach commented Mar 31, 2026

Summary

  • add a repo-owned parity guard that fails when frontend client definitions drift from Rust ClientId
  • consolidate frontend client metadata into a single registry so validation, types, logos, and display mappings stay in sync
  • close the current frontend gap for explicit crush submissions

Why

Tokscale has already hit real submit-path regressions when Rust client support moved ahead of frontend validation and display surfaces. This PR adds a structural guardrail so new or renamed clients cannot be added in Rust without the frontend surfaces being updated in lockstep.

Diff scope

  • add packages/frontend/src/lib/clientRegistry.ts as the single frontend source of truth for supported client IDs, legacy aliases, display names, logos, and colors
  • switch frontend validation, types, constants, and logo rendering to use that shared registry
  • switch API-side normalization to the same shared helper to remove duplicated alias logic
  • add a Rust parity test that compares frontend canonical client IDs against tokscale-core::ClientId plus the intentional frontend-only synthetic entry
  • verify that frontend display maps and local logo assets fully cover the expected client set
  • extend the Rust CI workflow path filters so the guard also runs when the frontend client registry or logo assets change
  • add crush to frontend submit/display surfaces so explicit CLI submission paths do not drift from core support

Test proof

  • cargo test -p tokscale-core
    • 467 passed, 0 failed, 1 ignored
  • cargo test -p tokscale-cli
    • unit tests: 310 passed, 0 failed, 1 ignored
    • integration tests: 74 passed, 0 failed
  • cargo clippy --workspace --all-features -- -D warnings
    • passed
  • bun x vitest run packages/frontend/__tests__/api/*.test.ts packages/frontend/__tests__/lib/*.test.ts
    • 115 passed
  • cargo fmt --all --check
    • passed
  • git diff --check
    • passed

Verification-pack proof

Not applicable - no infra, governance, or migration verification-pack scope.

Migration notes

Not applicable - no schema or data migration.

CI context confirmation

CI context names unchanged.

Rollback plan

  • if merged with a merge commit: git revert <merge_commit_sha>
  • if merged as a squash commit: git revert <squash_commit_sha>
  • no DB downgrade required

Known residual risks

  • the parity guard protects the client ID contract and frontend coverage maps; it does not by itself solve deployment drift between repo state and live frontend/API deploys
  • synthetic remains an intentional frontend-only entry and is treated as such by the parity test
  • the repo still has an unrelated frontend typecheck issue in BlackholeHero.tsx that was not introduced by this change

Related

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 31, 2026

@IvGolovach is attempting to deploy a commit to the Inevitable Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 11 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/tokscale-core/tests/frontend_client_parity.rs">

<violation number="1" location="crates/tokscale-core/tests/frontend_client_parity.rs:151">
P2: The parity test parses `clientRegistry.ts` with a brittle line-based string parser. It only recognizes a closing brace/bracket when it appears as `"\n}"`/`"\n]"` and expects each line to be a simple `key: value` pair, so harmless formatting changes (indentation before the closing brace, inline comments, quoted keys, multiline values) will panic the test and create false CI failures.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread crates/tokscale-core/tests/frontend_client_parity.rs Outdated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/frontend/src/lib/clientRegistry.ts">

<violation number="1" location="packages/frontend/src/lib/clientRegistry.ts:38">
P2: The registry JSON is cast with `as ClientRegistryData`, so its contents are not validated against the hard-coded ClientType/LegacyClientId unions. If clientRegistry.json adds a new client ID/alias without updating these unions, TypeScript will still accept the JSON and `CLIENT_IDS` will contain values not represented in the union, breaking exhaustiveness checks downstream. Consider validating with `satisfies` or deriving the unions from the JSON so changes cannot bypass type checks.</violation>
</file>

<file name="packages/frontend/src/lib/clientRegistry.json">

<violation number="1" location="packages/frontend/src/lib/clientRegistry.json:62">
P2: Most localSourceLogos paths point to logo files that do not exist in `packages/frontend/public/assets/logos/`, so the UI will render broken images for those clients. Add the missing assets or adjust the paths.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/frontend/src/lib/clientRegistry.ts Outdated
"synthetic": "https://raw.githubusercontent.com/junhoyeo/tokscale/main/.github/assets/client-synthetic.png"
},
"localSourceLogos": {
"opencode": "/assets/logos/opencode.png",
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Most localSourceLogos paths point to logo files that do not exist in packages/frontend/public/assets/logos/, so the UI will render broken images for those clients. Add the missing assets or adjust the paths.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/frontend/src/lib/clientRegistry.json, line 62:

<comment>Most localSourceLogos paths point to logo files that do not exist in `packages/frontend/public/assets/logos/`, so the UI will render broken images for those clients. Add the missing assets or adjust the paths.</comment>

<file context>
@@ -0,0 +1,102 @@
+    "synthetic": "https://raw.githubusercontent.com/junhoyeo/tokscale/main/.github/assets/client-synthetic.png"
+  },
+  "localSourceLogos": {
+    "opencode": "/assets/logos/opencode.png",
+    "claude": "/assets/logos/claude.jpg",
+    "codex": "/assets/logos/openai.jpg",
</file context>
Fix with Cubic

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tokscale Ready Ready Preview, Comment Apr 26, 2026 7:56pm

Request Review

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