Skip to content

feat(agent): add the v1 Connect foundation with AgentService and ProjectService - #57

Merged
cooper (czxtm) merged 2 commits into
mainfrom
feat/agent-api-v1-foundation
Sep 23, 2026
Merged

cooper (czxtm) merged 2 commits into
mainfrom
feat/agent-api-v1-foundation

Conversation

@czxtm

@czxtm cooper (czxtm) commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

First slice of ADR 0004. It adds the versioned proto/stackpanel/agent/v1 package:

  • AgentService.GetAgentInfo returns the agent version and the procedure paths it serves, read from the registered descriptors. It is public, so the Studio can check compatibility before pairing.
  • ProjectService lists, adds and removes projects in the user project registry, and sets the default one. Per ADR 0005, selecting a project stays a client-side choice.

It also adds:

  • the generated Go and TS code
  • a shared Connect interceptor chain for Bearer auth and panic recovery
  • withAllowedOrigin, which moves the origin allowlist out of requireAuth so both API surfaces share it
  • cfg.Version, plumbed from the CLI build info

Verification by the implementer, in the devshell:

  • go build ./..., go vet and gofmt are clean.
  • The new tests pass: 3 in internal/agent/project and 2 in internal/agent/server, one of which covers 5 auth cases. All of them run through the generated Connect clients against httptest.
  • The server package's full run fails only TestSetupAcknowledgementRequiresAuthAndProjectEvidence, one of the 5 tests that already fail on main.

Codegen:

  • buf 1.59 regenerated everything. Existing generated files are unchanged after nix fmt, and the order-only churn in connect_entities_gen.go was reverted.
  • The only new outputs are gen/gopb/stackpanel/** and gen/ts/stackpanel/**.
  • buf.gen.yaml excludes stackpanel.agent.v1 from the legacy jsonschema and protobuf-ts plugins.

Review follow-up (second commit): v1 request messages are now capped at 2 MiB with connect.WithReadMaxBytes, the same cap REST applies. connect-go reads and decompresses a request before interceptors run, so without a limit a caller without a token could make the agent buffer an unbounded or gzip-inflated payload before auth rejected it. TestV1RejectsOversizedRequestsBeforeAuth sends an oversized request and a small gzip body that inflates past the limit. Both fail with ResourceExhausted without reaching auth or the handler, and the test fails without the fix.

Refs stackpanel-thq.8.3, stackpanel-thq.8

…ectService

First slice of ADR 0004. proto/stackpanel/agent/v1 adds AgentService,
whose GetAgentInfo reports the agent version and the procedure paths it
serves so the Studio can gate features across agent versions, and
ProjectService (list, add, remove and set-default over the user-level
project registry; per ADR 0005, selecting a project is a client-side
choice).

The v1 services share one interceptor chain: Bearer-token auth, with
GetAgentInfo public so the Studio can check compatibility before
pairing, and panic recovery. The origin allowlist moves out of
requireAuth into withAllowedOrigin so both API surfaces share it. The
legacy JSON-schema and protobuf-ts generators skip the v1 package.

Refs: stackpanel-thq.8.3, stackpanel-thq.8
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Preview pr-57 has been destroyed.

connect-go reads and gzip-decompresses a unary request message before
any interceptor runs, and it applies no size limit by default. The v1
handlers set none, so a caller without a token could make the agent
buffer an arbitrarily large, or highly compressed, payload before the
auth interceptor rejected it. GetAgentInfo and ListProjects are
NO_SIDE_EFFECTS and accept GET, so a web page could send such a payload
in the query string without an Origin header.

Limit v1 request messages to 2 MiB, the cap REST applies to request
bodies. The limit covers the bytes read, the decompressed message and
GET query messages, and connect answers ResourceExhausted before auth
or the handler runs.

Refs: stackpanel-thq.8.3
@czxtm
cooper (czxtm) merged commit 21b53fc into main Sep 23, 2026
13 of 14 checks passed
@czxtm
cooper (czxtm) deleted the feat/agent-api-v1-foundation branch September 23, 2026 13:34
@linear-code

linear-code Bot commented Sep 23, 2026

Copy link
Copy Markdown

ENG-841

@github-actions

Copy link
Copy Markdown
Contributor

Docs preview pr-57 has been destroyed.

This branch had an error being deployed

1 failed and 1 active deployments
pr-57 — 62801a80 Deployed Sep 23, 2026 by czxtm via deploy #210
docs-preview — 62801a80 Deployed Sep 23, 2026 by czxtm via deploy #195
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