refactor(go): shared endpointsvc resolution layer - #240
Open
rado0x54 wants to merge 1 commit into
Open
Conversation
… resolution (was hand-rolled 3x: rest/sessions, rest/endpoints, agent/session) and the userVerification/description constraints REST+MCP validate; REST session cap moves to Manager.CountOpenForAccount with the MCP live-owned divergence documented at both sites
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.
What
Review item 2: the demo-aware endpoint resolution logic existed three times (
rest/sessions.go,rest/endpoints.go,agent/session.go) and the endpoint field constraints twice (rest,mcp) — and the copies had already drifted once (the MCP validation gap fixed in #238). This PR gives them one home.New package:
internal/endpointsvcService.ListForAccount— own endpoints first, then demo entries when the account's visibility toggle shows them (order pinned by the endpoints-list golden); returns provenance (IsDemo) so REST can render the flag and MCP can ignore it.Service.GetForAccount— account-scoped get; demo ids resolve regardless of toggle (a caller that knows the id can inspect it); foreign/unknown ids are an indistinguishable nil (no cross-account probing).Service.RefForAccount— resolves to theterminal.EndpointRefsession creation consumes (previously the identical mapping lived in bothrest.toRefandagent.resolveRef).UserVerificationValues/IsUserVerification/DescriptionMaxLen, now referenced by both REST validation and the MCP patch decoder; the "duplicated until a shared endpoint service exists" copies are deleted.Mutations stay on
store.Endpoints(exposed asService.Endpoints): demo entries are synthesized per request, never stored, and the wire layers reject demo ids before mutating.Consumers
rest.Endpoints/rest.Sessionsdrop theirStore+Demofields forSvc;resolveEndpoint/toRefdeleted.agent.Depsbecomes{Manager, Svc};GetEndpoint/ListEndpoints/resolveRefnow delegate.terminal.Manager.CountOpenForAccount, whose doc comment states the account-wide semantics and points at the deliberately-different MCP live-owned count inagent.Session— the two semantics are a documented split, not an accident, so they are named rather than unified.Tests
internal/endpointsvc/endpointsvc_test.go: toggle-off list vs. get-by-id, toggle-on merge order, ref resolution for stored + demo endpoints, foreign/unknown-id nil semantics.go vet,gofmt,pnpm spdx:checkclean.Also adds an
endpointsvcbullet todocs/go-backend-architecture.md§5.5.