Skip to content

feat(server): add GetCompatibilityInfo, the feature registry, and --deployment-id - #823

Merged
samuv merged 1 commit into
mainfrom
sdk/01-server-info
Aug 31, 2026
Merged

samuv merged 1 commit into
mainfrom
sdk/01-server-info

Conversation

@samuv

@samuv samuv commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #822 (ADRs 0248–0250 + the acceptance plan). Review that one first — it holds the decisions this implements.

What

PR 1 of 9 in the #821 server-enabler stack. Implements Scenario 1 of docs/acceptance/sdk-server-enablers.md — AC1.1 through AC1.7 — per ADR 0248.

Adds GetCompatibilityInfo (gRPC + GET /v1/compatibility), the build's feature registry, and mecated --deployment-id.

⚠️ Renamed since first review: GetServerInfo → GetCompatibilityInfo

This PR was originally GetServerInfo + GET /v1/server-info, and was approved under that name. While the stack was open, main shipped its own GetServerInfo — ADR 0245 "Safe build diagnostics" (Accepted), carrying build_id / server_implementation / an optional sanitized provider display endpoint on GET /v1/info, already consumed by mecatui's diagnostics pane.

That is a hard collision (identical RPC and message names) and a semantic one. ADR 0245 draws an explicit privacy boundary around its response: it "must never carry … capabilities, authentication or TLS details, arbitrary configuration". capabilities and features are precisely what that excludes.

So the two are now separate resources:

RPC Route Answers Owner
GetServerInfo GET /v1/info which build is this? ADR 0245 (shipped)
GetCompatibilityInfo GET /v1/compatibility what may I do with this server? ADR 0248 (this PR)

Why not fold them. Merging would have meant superseding a shipped privacy contract to save one round trip. Overloading the name the other way is worse — one message answering both questions has two audiences and two change cadences. A client wanting both makes both calls; that is the honest cost of the boundary.

build_version is gone. An earlier revision derived it from debug.ReadBuildInfo(). ADR 0245's ldflags-stamped internal/buildinfo.BuildID (wired in Taskfile.yml and .ko.yaml) is the single build-identity mechanism, and a second field derived a second way is exactly the drift the single-source discipline exists to prevent. Dropped, field number included, since the message never shipped. This reverts the buildversion.go work added in response to @jhrozek's review comment — that comment was right, and main has since answered it better; details on that thread.

The ADRs also renumbered 0244–0246 → 0248–0250, because main took 0244/0245/0246.

Why

A client could not ask "what may I do with this server?" without side effects. ServerCapabilities rides CreateSessionResponse only, so discovery cost a probe session that then had to be cleaned up. GetCompatibilityInfo answers it directly on both transports.

The load-bearing decision

The response carries two vocabularies side by side, not one merged set:

Field Question Changes when
capabilities what has this operator enabled? operator config changes
features what does this build implement? mecatl is upgraded

Conflating them is a bug in both directions: a client reading a disabled capability as version skew rejects a correctly-configured --no-bash deployment; one inferring protocol support from an operator toggle calls an RPC the server has never heard of. TestADR_0248_CapabilitiesAreNotFeatures pins the independence by toggling a capability and asserting the feature set does not move.

capabilities reuses Service.capabilities() verbatim rather than building a parallel projection — a second projection would drift from the CreateSession echo and let the server contradict itself about its own configuration. AC1.1 asserts proto.Equal between the two.

Notable choices

features are open strings, not a proto enum — the EvNoProgress/StopBudget string-passthrough discipline AGENTS.md already records. Each PR in this stack appends its identifier as it lands, so a partially-deployed stack (which will exist — these land in main incrementally) describes itself honestly. serverFeatures() returns a clone; the test mutates a returned slice to prove the registry can't be corrupted through a response the gRPC layer may retain.

api_major starts at 1 and stays there for this entire stack. Being able to add capability without bumping the major is the whole point of features.

--deployment-id is empty by default and never inferred from hostname, pod name, or environment. Infrastructure topology isn't something an authenticated caller is owed, and a label the operator didn't choose is a leak with no consenting author. It's validated at startup — printable, single-line, valid UTF-8, ≤128 bytes — because the value is echoed verbatim to every caller and rendered by clients we don't control:

  • invalid UTF-8 would kill the response at protobuf marshal time (the class AGENTS.md documents);
  • a newline forges a log line, an ESC injects into the alt-screen TUI that renders it.

Rejecting while the operator is present beats sanitising at every render site.

Auth failure must not look like version skew. GetCompatibilityInfo is authenticated like every other RPC, and the test pins that a missing or wrong token yields UNAUTHENTICATED, never UNIMPLEMENTED — the SDK reads UNIMPLEMENTED as "below the compatibility floor" and stops probing, so a credentials problem presenting as a version problem would send an operator hunting the wrong thing.

Acceptance criteria

AC Test
1.1 capabilities match the session echo, no probe session TestSDKServerEnablers_Scenario1_CompatibilityInfoMatchesCapabilities
1.2 gRPC/HTTP parity TestSDKServerEnablers_Scenario1_CompatibilityInfoTransportParity
1.3 authenticated; distinguishable from UNIMPLEMENTED TestSDKServerEnablers_Scenario1_CompatibilityInfoRequiresAuth
1.4 one registry, sorted, dedup, copy-on-return TestADR_0248_FeatureRegistryIsSingleSource
1.5 capabilities ≠ features TestADR_0248_CapabilitiesAreNotFeatures
1.6 deployment label operator-set only TestADR_0248_DeploymentIdentityIsOperatorSetOnly + TestValidateDeploymentID
1.7 capability truth is one intersection TestInvariant_capability_truth_single_intersection

Verification

  • task lint — 0 issues across all modules.
  • task api:check — green.
  • task test — green across root, engine, authn/oidc, all four provider/* modules, test:engine-standalone, and test:provider-standalone.
  • go run ./cmd/mecademo — full offline session still prints.
  • task generate reproduces contracts/gen/ byte-for-byte; no hand-edits.
  • docs/lint + matlatl check --strict green.

⚠️ Pre-existing failures on main, not from this PR

  1. test:authn-standalone: authn/oidc/fixture_test.go:12 imports internal/adapter/server, breaking the GOWORK=off standalone hygiene proof. Verified present on origin/main.
  2. On macOS, jsonlstore's durability check (fix(jsonlstore): finish durability guarantees #786) rejects the default TMPDIR because it sits under /var, a symlink to /private/var. Local runs need TMPDIR overridden; CI on Linux is unaffected.

Both left alone — each deserves its own fix, and folding them in would hide them.

Refs #821.

🤖 Generated with Claude Code

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed with four parallel specialist passes (proto shape, security, architecture, library-reuse) plus verified the generated-code claim myself (task generate reproduces contracts/gen/ byte-for-byte). Everything checks out — auth is enforced structurally with no exemption path, deployment-id validation bounds are correct, capabilities/features are genuinely single-source, no hand-rolled logic that stdlib already covers. One question below, nothing blocking either way — approving.

Comment thread internal/adapter/server/service.go Resolved
samuv added a commit that referenced this pull request Aug 31, 2026
Addresses the #823 review: Config.BuildVersion had no writer anywhere outside
server_info_test.go — no flag, no app.Config field, no linker var — so every
real deployment reported build_version: "" while ADR 0244 presented it as a real
affordance. Wired rather than deferred, because an affordance that is always
empty is worse than an absent one: a client cannot tell "this server has no
version" from "this field is broken".

Derived, not operator-set. That is the opposite call from --deployment-id two
commits earlier, and deliberately so: a deployment label names infrastructure
topology an authenticated caller is not owed, whereas a build version names the
software that caller is already talking to. There is nothing to leak.

The source is the build info the Go toolchain already embeds, so an ordinary
`task build` reports something useful with no build-system changes — which
matters here because the repo has no ldflags infrastructure and no goreleaser to
hook into. A released module reports its version; a source checkout reports the
abbreviated VCS revision, suffixed -dirty when the toolchain recorded
uncommitted changes. The dirty marker is the point of that arm: an operator
reading a bug report most needs to know the binary corresponded to no commit
precisely when the revision alone would mislead them into thinking it did.
Verified against a real binary — bin/mecated reports
v0.0.22-0.20260831075615-e7ceef15a515+dirty.

app.Config.BuildVersion remains as an override, which is the -ldflags seam for a
release build that knows better than the toolchain.

THE POLICY IS SPLIT FROM THE READ, and the split is what makes the test real
rather than decorative. debug.ReadBuildInfo() is not injectable and reports
something DIFFERENT under `go test` than in a shipped binary: a test binary
carries no vcs.* settings at all. A test calling the reader directly skipped —
I wrote that version first and it passed while proving nothing about the case
that actually broke. buildVersionFrom takes the *debug.BuildInfo as a parameter,
so all four arms (released, checkout, dirty, genuinely-unknown) are exercised.

The value is bounded and rejected outright if non-printable. It lands in a proto
string on every GetServerInfo, and the override arm is arbitrary bytes chosen at
link time — a newline there would inject a second line into anything that logs
it. Rejecting beats sanitising for a diagnostic field: a mangled version string
is worse than none, because it still looks like data.

Gates: task lint 0 issues all modules; go test green on internal/app and
internal/adapter/server.

Refs #821.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>
@samuv
samuv force-pushed the sdk/01-server-info branch from 7a05966 to 4eb977a Compare August 31, 2026 08:11
@samuv
samuv force-pushed the sdk/01-server-info branch from 4eb977a to 5d7c7e0 Compare August 31, 2026 08:50
@samuv
samuv force-pushed the sdk/01-server-info branch from 5d7c7e0 to 2b60e4e Compare August 31, 2026 08:52
@samuv samuv changed the title feat(server): add GetServerInfo, the feature registry, and --deployment-id feat(server): add GetCompatibilityInfo, the feature registry, and --deployment-id Aug 31, 2026
Base automatically changed from sdk/00-decision-record to main August 31, 2026 09:02
@samuv
samuv force-pushed the sdk/01-server-info branch 2 times, most recently from fa83226 to 3ab5581 Compare August 31, 2026 09:16
…eployment-id

PR 1 of the #821 server-enabler stack. Implements Scenario 1 of
docs/acceptance/sdk-server-enablers.md (AC1.1-AC1.7) per ADR 0248.

An SDK's first question is "what may I do with this server?" and today the only
way to ask is to create a probe session and read the ServerCapabilities echo off
CreateSessionResponse. GetCompatibilityInfo answers it directly: api_major, the
operator-enabled capabilities, the build's feature identifiers, and an optional
deployment label. Authenticated like every other RPC, with a GET /v1/compatibility
peer reading the SAME projection so the two transports cannot disagree.

SEPARATE FROM GetServerInfo, WHICH IS NOT A NAMING PREFERENCE. This scenario was
written proposing the name GetServerInfo. While the stack was open, ADR 0245
(safe build diagnostics) shipped an RPC by that name for build identity —
build_id, server_implementation, an optional sanitized provider display endpoint
— behind an explicit privacy boundary: that response "must never carry ...
capabilities, authentication or TLS details, arbitrary configuration".

capabilities and features are exactly what the boundary excludes, so folding this
descriptor into that message would have meant superseding a shipped privacy
contract to save one round trip. Overloading the name the other way is worse:
one message answering both "which build is this?" and "what may I do here?" has
two audiences and two change cadences. So identity stays on GetServerInfo //
/v1/info and negotiation lives on GetCompatibilityInfo // /v1/compatibility. A
client wanting both makes both calls — the honest cost of the boundary.

NO BUILD IDENTITY HERE. An earlier revision carried build_version derived from
debug.ReadBuildInfo(). ADR 0245's ldflags-stamped internal/buildinfo.BuildID
(wired in Taskfile.yml and .ko.yaml) is the single build-identity mechanism, and
a second field derived a second way is the drift the single-source discipline
exists to prevent. Dropped, including the field number, since the message has
never shipped.

CAPABILITIES AND FEATURES ARE TWO VOCABULARIES, NOT ONE. capabilities answers
"what has this operator enabled?" and moves with config; features answers "what
does this build implement?" and moves on upgrade. Collapsing them makes a
--no-bash deployment indistinguishable from version skew — a client would reject
a correctly-configured server as too old, or call an RPC this build has never
heard of. AC1.5 pins the independence.

features are OPEN STRINGS, not an enum: the EvNoProgress/StopBudget
string-passthrough discipline. An unrecognised identifier is ignored by an older
client, so publishing one is a minor release rather than a wire-compat event.
The registry is the single source for both transports (AC1.4).

capabilities reuses the EXISTING composition-computed intersection verbatim
rather than recomputing — the AGENTS.md invariant that capability truth is ONE
intersection. Media stays session-authoritative: the image/audio hint here is
UI chrome, and the per-session CreateSessionResponse echo remains the authority
(AC1.7).

--deployment-id is opaque, bounded (128 bytes), printable single-line, and empty
by default. It is NEVER inferred from hostname, pod name, or environment:
infrastructure topology is not something an authenticated caller is owed, and a
label the operator did not choose is a leak with no consenting author.

Gates: task lint 0 issues all modules; task generate reproduces contracts/gen
byte-for-byte; go test green; docs/lint + matlatl --strict green.

Refs #821.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

Signed-off-by: Samuele Verzi <[email protected]>
@samuv
samuv force-pushed the sdk/01-server-info branch from 3ab5581 to d4d9bf0 Compare August 31, 2026 10:18
@samuv
samuv merged commit a148bf9 into main Aug 31, 2026
23 checks passed
@samuv
samuv deleted the sdk/01-server-info branch August 31, 2026 10:31
kantord added a commit that referenced this pull request Aug 31, 2026
Per samuv's review: fix the promoted-run wedge (drain via the same
approve-handler REHYDRATE precedent instead of handing back a bare
run_id), carry multimodal parts in the request contract (ADR 0251),
add a feature-registry row instead of discover-by-404ing (PR #823),
and rename steer-cancel to cancel-steer to match the cancel-child
verb-first convention.

Fully or partially written by an AI agent.

Co-Authored-By: Claude <[email protected]>
kantord added a commit that referenced this pull request Aug 31, 2026
* docs: ADR 0252 — HTTP steer endpoint

Extends ADR 0232's named deferral: POST /v1/sessions/{id}/steer +
steer-cancel, mirroring approve/cancel, reusing the RFC 9457 registry
for stale-control rejection. No engine change — pure transport
addition over the existing Service.Steer/Service.CancelSteer calls.

Docs only; implementation tracked separately.

Refs #873, #821.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* docs: address review feedback on ADR 0252

Per samuv's review: fix the promoted-run wedge (drain via the same
approve-handler REHYDRATE precedent instead of handing back a bare
run_id), carry multimodal parts in the request contract (ADR 0251),
add a feature-registry row instead of discover-by-404ing (PR #823),
and rename steer-cancel to cancel-steer to match the cancel-child
verb-first convention.

Fully or partially written by an AI agent.

Co-Authored-By: Claude <[email protected]>

* docs: regenerate llms.txt after rebase

* docs: spell out the two distinct stale-run-control refusals

Per samuv's review thread on the 409 bullet: name both refusal
paths funneling through stale_run_control explicitly (an
expected_run_id naming a non-current run, and strict steer's
deliberate non-promotion on a terminal named run) rather than
leaving the second implicit.

Fully or partially written by an AI agent.

Co-Authored-By: Claude <[email protected]>

* docs: name the shared media validation/capability path for steer parts

Per samuv's review thread: state explicitly that steer parts reuse
toContentParts/session.NewContent/ValidateMediaParts and the same
ProviderCapabilities() gate as the ACP prompt path, not a second
validation path.

Fully or partially written by an AI agent.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
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.

2 participants