Skip to content

fix(generate-types): re-sync TS output + CRLF-safe drift test (supersedes #472)#475

Merged
Dumbris merged 3 commits into
mainfrom
fix/generate-types-sync-crlf-safe
May 17, 2026
Merged

fix(generate-types): re-sync TS output + CRLF-safe drift test (supersedes #472)#475
Dumbris merged 3 commits into
mainfrom
fix/generate-types-sync-crlf-safe

Conversation

@Dumbris
Copy link
Copy Markdown
Member

@Dumbris Dumbris commented May 17, 2026

Summary

Supersedes #472 by @electrolobzik. Carries Roman Chernyak's original two commits unchanged (cherry-picked, authorship preserved), plus one fix for the Windows CI failure that blocked #472.

Roman's work:

  • Re-syncs the hand-maintained TS string literals in cmd/generate-types/main.go with the committed frontend/src/types/contracts.ts (fixes the silent 22-line revert on every make build).
  • Adds TestContractsInSync as a CI guard against future drift.

Why a new PR instead of #472

#472's new TestContractsInSync did a raw byte comparison and failed on windows-amd64 CI: with core.autocrlf=true, git checks out contracts.ts as CRLF while the generator emits LF, so the byte compare failed even though the contract was in sync. #472 is from a fork branch we can't push the fix to, so this PR carries Roman's commits + the fix.

The fix (this PR's extra commit)

  • .gitattributes: pins frontend/src/types/contracts.ts to text eol=lf so it is checked out identically on every platform — the real fix.
  • Test normalization: TestContractsInSync now normalizes CRLF -> LF before comparing — defense in depth, green regardless of local git config.

Verification

Closes #472.

🤖 Generated with Claude Code

electrolobzik and others added 3 commits May 17, 2026 09:13
The TypeScript-as-Go-string literal in cmd/generate-types/main.go drifted
from frontend/src/types/contracts.ts when PR #424 (Server Config tab
parity) and PR #463 (per-tool enable/disable) edited contracts.ts
directly without updating the generator. Running `go run ./cmd/generate-types`
(invoked by Makefile's `frontend-build` target) silently reverts those
fields, producing a dirty working tree on every `make build`:

  - Server.isolation_defaults
  - IsolationConfig.network_mode, IsolationConfig.extra_args
  - IsolationDefaults (entire interface)
  - Tool.disabled, Tool.approval_status

The reverted contracts.ts also feeds back into Vite's bundle hashes,
which is the likely reason web/frontend/dist/* also churns on rebuilds.

This commit catches the generator up to the actual contracts.ts content.
After this, `go run ./cmd/generate-types` is idempotent against HEAD.

Verified: generator output is byte-identical to contracts.ts.
Adds TestContractsInSync, which runs the generator's content function
and asserts byte-equality with the committed frontend/src/types/contracts.ts.
The next time a contributor hand-edits contracts.ts (or hand-edits the
hardcoded TS string in main.go) without updating both sides, CI fails
with a clear message pointing at the fix:

  Either run \`go run ./cmd/generate-types\` from the module root
  (if the generator is the source of truth) or update the string
  literals in main.go (if contracts.ts is the source of truth).

The drift this test guards against is what allowed PRs #424 and #463
to silently leave the generator out of sync.

Refactors main.go to factor out generateFileContent() so the test
can compare without re-implementing the header concat.
The new TestContractsInSync did a raw byte comparison of the committed
contracts.ts against generator output. On Windows CI (core.autocrlf=true)
git checks out contracts.ts with CRLF endings while the generator emits
LF, so the test failed on windows-amd64 even though the contract was in
sync (observed on PR #472).

Two-layer fix:
- .gitattributes pins frontend/src/types/contracts.ts to `text eol=lf`
  so it is checked out identically on every platform (the real fix).
- The test now normalizes CRLF->LF before comparing, keeping it green
  regardless of a contributor's local git config (defense in depth).

Verified: test passes with both LF and CRLF checkouts of contracts.ts;
`go run ./cmd/generate-types` remains idempotent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 08973c4
Status: ✅  Deploy successful!
Preview URL: https://5576b3d7.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-generate-types-sync-crlf.mcpproxy-docs.pages.dev

View logs

@github-actions
Copy link
Copy Markdown

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/generate-types-sync-crlf-safe

Available Artifacts

  • archive-darwin-amd64 (26 MB)
  • archive-darwin-arm64 (23 MB)
  • archive-linux-amd64 (15 MB)
  • archive-linux-arm64 (13 MB)
  • archive-windows-amd64 (26 MB)
  • archive-windows-arm64 (23 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (20 MB)
  • installer-dmg-darwin-arm64 (18 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 25983255261 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@Dumbris Dumbris merged commit 0afa3fb into main May 17, 2026
23 checks passed
@Dumbris Dumbris deleted the fix/generate-types-sync-crlf-safe branch May 17, 2026 06:28
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.

3 participants