Skip to content

Gateway: reconcile tygo codegen with SPA and enforce in CI - #1563

Open
Evanfeenstra wants to merge 1 commit into
mainfrom
claude/hopeful-lehmann-c400af
Open

Gateway: reconcile tygo codegen with SPA and enforce in CI#1563
Evanfeenstra wants to merge 1 commit into
mainfrom
claude/hopeful-lehmann-c400af

Conversation

@Evanfeenstra

Copy link
Copy Markdown
Collaborator

Summary

make tygo-check failed because gateway/internal/adminapi/ui/src/api/types.ts was still the phase-8 hand-maintained stop-gap, and running make tygo produced materially different output (dropped unions, added interfaces). This PR makes types.ts truly generated and wires the drift check into CI as the phase-8 plan intended.

  • types.ts is now tygo-generated (make tygo) and committed; regenerating is byte-stable.
  • New hand-maintained ui/src/api/manual.ts for the types tygo cannot generate:
    • Window / Bucket / Dimension string-literal unions (validated Go-side as plain strings, no struct to translate)
    • ApiError (the phase-7 envelope is built inline by writeError, a map not a struct)
    • TrustOrg / TrustStatus (mirror internal/trust, outside tygo.yaml's adminapi scope)
    • Bifrost pass-through chat/usage shapes (ChatMessage, TokenUsage, CacheDebug, …) that Go carries as json.RawMessage
  • SPA imports updated across queries.ts, client.ts, window.ts and eight pages/components to split between generated and manual types; tsc -b passes.
  • evalRefResponse exported as EvalRefResponse so tygo emits the binding the eval mutations decode.
  • go.sum fix: go.mod requires bifrost core v1.6.2 but go.sum only had v1.5.18 hashes, so go build failed on a clean checkout (Docker masked it via go mod edit -replace). Added the missing hashes — CI's tygo run needs a resolvable module graph.
  • New .github/workflows/gateway-check.yml: on PRs / main pushes touching gateway/**, runs make tygo-check (tygo pinned at v0.2.21, same pin noted in the Makefile) and make ui-build (Node 24; npm cache keyed on package.json since the SPA's package-lock is git-ignored).

Test plan

  • make tygo-check passes (regeneration is a no-op against the committed file)
  • make ui-build passes (tsc type-check + vite bundle)
  • go build ./internal/..., go vet ./internal/adminapi/, go test ./internal/adminapi/ all pass

🤖 Generated with Claude Code

types.ts is now truly tygo-generated (make tygo) instead of the
phase-8 hand-maintained stop-gap. Types with no adminapi Go struct
move to a new hand-maintained ui/src/api/manual.ts: the Window/
Bucket/Dimension unions, the ApiError envelope, the trust-package
mirrors (TrustOrg/TrustStatus), and the Bifrost pass-through chat/
usage shapes. SPA imports updated accordingly.

evalRefResponse is exported as EvalRefResponse so tygo emits the
binding the eval mutations decode. go.sum gains the bifrost core
v1.6.2 hashes that were missed when go.mod was bumped.

New gateway-check.yml workflow runs make tygo-check (tygo pinned at
v0.2.21, same as the Makefile note) and make ui-build on gateway
changes, so Go/TS drift fails CI as the phase-8 plan intended.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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