* Let httpapi.Config take the issue roles as a database source
bd serve could only be built from a unit-of-work provider: Config.Provider
was the only database field, and Listen refused a nil one. A backend whose
facade is a STORE — which is the shape the storage/backends registry seam
already has — had no way to be served at all, even though its accessors
return exactly the two roles the handlers now use.
Config gains Reader and Claimer beside Provider, and Listen takes exactly
one complete source: a provider, or both roles. Serving a store-backed
workspace is now Config{Reader: rd, Claimer: cl} from that store's own
IssueReader()/IssueClaimer(), with no unit-of-work provider invented in
between.
The provider path is byte-identical. reader() and claimer() still wrap the
provider per request in timedProvider and build the roles over that wrapper,
so uow_ms keeps measuring what it always measured and both timing tests keep
pinning it. On the roles path there is nothing to time — this server opens no
units of work — and 0.000 is the true value, so the startup line gains a
db=provider/db=roles field to make the zero attributable rather than silent.
The pool_* fields and the PoolTuner call stay behind the provider for the
same reason: the pool belongs to whatever the backend is.
A half-set pair is refused rather than tolerated. A reader with no claimer
would bind, answer every read, and fail the one write on this surface with a
nil dereference inside a handler.
No handler, route, spec or generated type changes: the wire is untouched, and
cmd/bd/serve.go still builds the provider it always did. The remaining piece —
serveModeGate narrowing plus a store-backed arm in runServe — waits on the
first registered store-shaped backend, and on resolving that cmd/bd's store
chain fires hooks on a landed claim, which bd serve documents that it does not.
Agent-Signature: claude-opus-5
Co-authored-by: CI Bot <ci@beads.test>
* Make the role seam's guarantees structural again, or loud
Config.Reader/Claimer took three guarantees that the provider seam enforced
by construction and turned them into prose contracts on caller-supplied
code. Two of them can be checked here and now are; the third cannot be
checked here at all, and the docs stop claiming otherwise.
A role that answers with nothing is no longer dereferenced. handleGetIssue
wrote *details and handleClaim wrote *result.Issue on the strength of a
property the provider path could not violate: s.reader() could only return
uow.NewIssueReader(...), whose Get routes through workapi.GetIssueOrWisp,
and that function exists precisely so no caller is ever handed a nil issue
with a nil error. A configured role is ordinary code. checkedReader and
checkedClaimer (roles.go) now wrap every role this server hands a handler,
from EITHER database source — unconditionally, so that "there is no other
way to reach the dereference" is the reason it is safe rather than a
separate belief about how the provider path behaves. A reader with no
detail view is folded into the documented miss and answers the same 404
body an absent issue does, byte for byte. A claimer that reports success
without a row has no documented reading, so it is the generic 500 — with
the fault in the log as an error and a request_error line beside it, which
is what the panic it replaces did not produce.
Listen refuses a role that fires the workspace's hooks. bd serve documents
that hooks do not fire, and a store's accessors hand out its decorators by
design — IssueClaimer recurses so that a CLI claim keeps its on_update — so
store.IssueClaimer() on bd's own chain (HookFiringStore ->
InstrumentedStorage -> raw) returns exactly the claimer that voids that
contract, silently, for as long as the process is up. The Config doc gave
that line verbatim as the intended pattern; it now names the store value to
take roles from instead, and storage.RoleFiresHooks lets checkDatabaseSource
refuse the other one at startup rather than trusting the paragraph.
The embedded-Dolt refusal keeps CLI-side enforcement, and the docs stop
grounding it in a structural fact it no longer has. It was structural while
Listen took a provider or nothing: there is no unit-of-work provider for
that backend, so an embedded-backed server was not constructible. The roles
source makes one constructible, and internal/httpapi cannot close that — a
role is an interface, and every check available at that layer is a
self-declaration by the same caller-supplied code being checked, which is
the trust it would be replacing rather than a replacement for it. So
serveModeGate is now the only enforcement point, and bd-serve-v0.md,
SERVE_RUNBOOK.md and serve.go say so plainly, with the permanence
re-grounded on the backend's commit protocol — a property of the backend
rather than of what has been written so far. The precondition a caller owns
is stated on Config.Reader/Claimer, and
TestServeBuildsOnlyAProviderBackedServer pins against cmd/bd's source that
bd names no database source but the provider that gate vouched for.
No wire change: internal/httpapi/spec and internal/httpapi/apigen are
untouched, and both new answers use codes v0 already publishes.
Agent-Signature: claude-opus-5
Co-authored-by: CI Bot <ci@beads.test>
---------
Co-authored-by: CI Bot <ci@beads.test>