Repository navigation
Conversation
…CostTotals in the api contract
…nd providers services in the api contract
This branch has not been deployed
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
The RPC had no contract a compiler could check. A client named a method by string and passed
...any, the backend matched the arguments by position through reflection, and the window's types were hand-written mirrors of the backend's. Two strings swapped in a call compiled, and a JSON tag renamed on one side broke the other at run time.Every method is now declared once, in a new public package,
api:rpc.Handle(d, api.ThemesSelect, fn)only compiles whenfntakes and returns those types. The routes live ininternal/routes, one function per service. Reflection,Registerand thedenyInternallist are gone: a method nothing routes cannot be reached, so the methods kept out for Go callers stay out by construction (the package doc names them).lich,lich mcpand the window callcallMethod(ctx, c, api.X, opts). It is the only way either client posts, so a call by name no longer exists to get wrong.[options]or[]), so alichof another release still talks to this backend, and a route reads an empty list as the zero options.native/backendaliasesapi's types. Only the/eventspayloads are still hand-owned.api/testdata/contract.goldenrecords every method's name, options and result with each JSON field. A change to the contract shows up there in review (go test ./api -update), andTestEveryRequestIsOneObjectkeeps positional arguments out.native/lichclientis renamed tonative/backend.Test plan
api: the golden, one struct per request, the envelopeArgswrites, a duplicate declaration refused.internal/rpc: options decoded by name, an empty list as zero options,Noneanswered asnull, anything but one object refused with 400, the service's error as 500, the request's context handed over, an unknown method as 404.internal/routes: every methodapideclares has a route, per service, and everyxdgprofileprovider has its profile methods declared.internal/cli/wire_test.goposts as a client of another release through the production routes.native/: the window's tests and fakes read the options objects.lich version,sessions,theme list,theme switch,open,worktreesandlich mcp(list_sessions,list_worktrees) answer; the backend log shows no refused call.gofmt,go vet ./...,go test ./...on the backend and innative/; backend coverage 90.5%.