fix(generate-types): re-sync TS output + CRLF-safe drift test (supersedes #472)#475
Merged
Conversation
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>
4 tasks
Deploying mcpproxy-docs with
|
| 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 |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 25983255261 --repo smart-mcp-proxy/mcpproxy-go
|
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
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:
cmd/generate-types/main.gowith the committedfrontend/src/types/contracts.ts(fixes the silent 22-line revert on everymake build).TestContractsInSyncas a CI guard against future drift.Why a new PR instead of #472
#472's new
TestContractsInSyncdid a raw byte comparison and failed onwindows-amd64CI: withcore.autocrlf=true, git checks outcontracts.tsas 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: pinsfrontend/src/types/contracts.tstotext eol=lfso it is checked out identically on every platform — the real fix.TestContractsInSyncnow normalizesCRLF -> LFbefore comparing — defense in depth, green regardless of local git config.Verification
go test ./cmd/generate-types/passes with both LF and CRLF checkouts ofcontracts.ts(the CRLF case is exactly what failed in fix(generate-types): re-sync hardcoded TS output with contracts.ts + drift test #472 CI).go run ./cmd/generate-typesremains idempotent (zero diff).Closes #472.
🤖 Generated with Claude Code