beads/internal/httpclient/wire
Julian Knutsen ea0f6e1a46
feat(http): advertise issues.update.claim and route claims by it (S24a/b) (#7555)
* feat(http): advertise issues.update.claim and route claims by it (S24a/b)

updateIssue has served `claim` (upstream #6890), resolved on both planes so
a wisp is claimable, with no capability token: a client could only find it
by eating the skew 400, and gc's wire_compat preflight (which lists
issues.update.claim as an optional token) never saw it, so gc claimed every
wisp through claimIssue, whose Claimer role excludes the wisp plane.

Server: CapIssuesUpdateClaim ("issues.update.claim") joins
behaviorCapabilities. The spec names it on UpdateIssueRequest.claim and in
the context capabilities prose (apigen regenerated, descriptions only). No
request or response member changes; wire_revision stays 2.

Client: Lifecycle.Update reads the token from the cached handshake before
the dial. With it, every claim is one updateIssue call and its answer is
final (no fallback on any error). Without it, a claim alone goes straight to
claimIssue (no doomed 400 first; a wisp still refuses by name,
W-ClaimRequest.Wisp, whose Why now names the token), and a claim beside a
patch, a guard or a force override is refused before the dial with
ErrUnsupported{Capability: issues.update.claim}. serverPredatesUpdateClaim
(the error-sniffing fallback) is gone.

Tests: the four capability lists (routes.go, wire/handshake.go,
server_test, wire vocabulary_test) move together; unit tests for both
routes (pre-dial refusal dials nothing; with the token nothing falls back);
served tests claim a wisp through updateIssue with the token (zero claimIssue
dials, post-claim revision stitched), refuse it by name without it (zero
updateIssue claims, one claimIssue), and refuse a claim beside a patch
without the token while the same request claims and patches the wisp with
it. Live-mutated: ignoring the token fails the unit test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(http): count only ready --claim's requests in the claim-next check

TestE2E_AdvertisedExternalPolicyIsPassedThrough counted every request
since counter.reset(), so its "no by-id claim" check also saw the earlier
`update <other> --claim` step. The MC handshake mask does not advertise
issues.update.claim, so this PR routes that claim to claimIssue
(POST /v0/beads/issues/<id>:claim) by design, and the check failed in
Bazel / embedded Dolt tier (//backend/http:http_served_test shard 6 of
7), turning CI Gate / Required red.

Count from the snapshot length taken just before `ready --claim`, so the
check covers only the requests that command issues. The counter is not
reset: the close-policy check below scans the same history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(http): refuse a token-less template claim on the client's pre-read

Against a server without issues.update.claim, Lifecycle.Update sends a
claim alone to claimIssue (claimWithoutUpdateClaim) and returns before
applyTemplateGuardForServer runs. claimIssue's role has no template check
(bd-jkp9v3), so `bd update <template> --claim` against every server
without the token claimed the template. The base refused it before any
write: on the client's pre-read against a server without
issues.update.allowTemplate, and in updateIssue's own guard against one
with it.

claimWithoutUpdateClaim now pre-reads the row and returns
AuthorizeTemplateUpdate's refusal before the claimIssue dial, whatever the
handshake says about allowTemplate: that token means updateIssue guards
templates, and this route never dials updateIssue. Any other row goes on
to claimIssue as before (a wisp to its refusal by name), and so does an id
the pre-read cannot find, so claimIssue's not-found stays the one reported.

TestUpdateClaimRefusesATemplateWithoutTheToken (stub wire) and
TestServedUpdateClaimRefusesATemplateWithoutTheToken (served tier) pin it
under an allowTemplate-only and a neither-token handshake. Both go red
without the pre-read; the allowTemplate-only legs also go red if the
existing guard is only moved above the claim branch.

TestUpdateClaimFailsClosedWhenThePreReadFails pins the pre-read's third
arm under the same two handshakes: a read that fails other than as
not-found returns that failure and never dials claimIssue, since the
row's template bit is unknown then. A best-effort pre-read (that failure
falling through to the claim) passed go test ./internal/httpclient/ and
its served Claim|Template tier before this test, and goes red on both
legs with it.

A claim beside AllowTemplate is refused before the dial with
ErrUnsupported naming the token, like a claim beside a patch, a guard or
a force override (isClaimOnlyUpdate already excluded it), but no prose
said so: claimWithoutUpdateClaim's doc, CapIssuesUpdateClaim's doc, the
test doc and the CHANGELOG entry now list it, and a
TestUpdateClaimAgainstAServerWithoutTheToken row pins it. Dropping
!req.AllowTemplate from isClaimOnlyUpdate passed the same unit and served
runs without that row and goes red with it.

The prose now follows the handshake rule too: the W-UpdateRequest.Claim
ledger row (and its re-rendered md) no longer calls claimIssue the
fallback for a server that 400s the member, Update's doc names
claimWithoutUpdateClaim instead of the nonexistent claimRouteForServer,
wire.UpdateFlags.Claim drops the "safe to read as skew" rationale no
caller relies on anymore, and the CHANGELOG entry says a template is still
refused on the token-less route.

Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 11:47:45 +00:00
..
BUILD.bazel fix(httpclient): bound response-header waits and retry stalled reads on another connection (#7553) 2026-10-14 05:04:19 +00:00
client.go fix(httpclient): bound response-header waits and retry stalled reads on another connection (#7553) 2026-10-14 05:04:19 +00:00
client_test.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
credential.go fix(httpclient): bound response-header waits and retry stalled reads on another connection (#7553) 2026-10-14 05:04:19 +00:00
credential_source_test.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
credential_test.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
doc.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
handshake.go feat(http): advertise issues.update.claim and route claims by it (S24a/b) (#7555) 2026-10-14 11:47:45 +00:00
handshake_test.go feat(httpclient): OSS HTTP client store and roles + a served http conformance leg (contributed from bd-enterprise under MIT) (#7247) 2026-10-08 12:01:09 +00:00
handshake_wire_revision_test.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
helpers_test.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
paths.go fix(mol): molecule reads, auto-close and close --continue over http through issueops entries (S16) (#7513) 2026-10-12 19:50:34 +00:00
paths_test.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
problem.go fix(issueops): enforce the close guards on every close leg (#7425) 2026-10-09 18:30:42 +00:00
problem_test.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
problem_wire_revision_test.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
project_stamp_test.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
revision_tolerance.go feat(roles): BatchGetter role and POST issues:batchGet (#7248) 2026-10-05 12:09:18 -07:00
revision_tolerance_test.go feat(roles): LeaseReclaimer role, POST issues:reclaim, and bd reclaim on both routes (S9) (#7412) 2026-10-09 14:56:32 +00:00
skew_test.go fix(mol): molecule reads, auto-close and close --continue over http through issueops entries (S16) (#7513) 2026-10-12 19:50:34 +00:00
stall_retry.go fix(httpclient): bound response-header waits and retry stalled reads on another connection (#7553) 2026-10-14 05:04:19 +00:00
stall_retry_test.go fix(httpclient): bound response-header waits and retry stalled reads on another connection (#7553) 2026-10-14 05:04:19 +00:00
stream.go fix(httpclient): bound response-header waits and retry stalled reads on another connection (#7553) 2026-10-14 05:04:19 +00:00
stream_test.go feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210) 2026-10-05 02:58:34 -07:00
vocabulary_test.go feat(http): advertise issues.update.claim and route claims by it (S24a/b) (#7555) 2026-10-14 11:47:45 +00:00
writes.go feat(http): advertise issues.update.claim and route claims by it (S24a/b) (#7555) 2026-10-14 11:47:45 +00:00
writes_batch_cap_test.go feat(httpclient): BatchApplier over HTTP — handshake cap, dep_add lineage on the wire, gc mappings (S5) (#7265) 2026-10-09 01:05:39 +00:00
writes_twospeed_test.go feat(httpclient): OSS HTTP client store and roles + a served http conformance leg (contributed from bd-enterprise under MIT) (#7247) 2026-10-08 12:01:09 +00:00