Repository navigation
feat(daemon): Phase 2 work surface — placement requests, work list, runtime mint, agent-state heartbeats - #1562
Merged
Merged
Conversation
…untime mint, agent-state heartbeats ADR-026 Phase 2, slice 1 (server side). Four additions, all driver-layer: - POST /api/agent-binding/request (owner JWT): the UI's "run it on <machine>" choice, stored as a DIRECTIVE (botMetadata.requestedMachineId) — never a binding. The adopt CAS remains the only binding writer; a successful adopt consumes the request, and release withdraws it. - GET /api/agent-binding/assigned (daemon token): the daemon's work list — identities bound to or requested onto THIS machine (credential-derived machineId), scoped by the owner's active installation set, each row carrying its runtime config so the daemon can provision without another read. - POST /api/agent-binding/runtime-token (daemon token): mints the cm_agent_* credential for an agent BOUND here, as a child of the machine's daemon credential (D4.5 lineage — machine removal cascade-revokes it). An existing token 409s unless rotate:true, and rotation is total: ledger row revoked plus both legacy stores cleared, or the old bearer survives via the auth fallback. - Heartbeat now carries per-agent supervisor state (D5): running|stopped| crashed + restarts, replaced wholesale per report; an absent array preserves the last report so Phase-1 daemons keep working. Tests: 13 new (route + service tiers), all four daemon suites green. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EtwYLMJAYuZ3grLQoXWMWT
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.
ADR-026 Phase 2, slice 1 — the server-side surface a resident daemon needs before
commonly daemon run(slice 2, next PR) can exist. All driver-layer; no kernel change.What changed
Placement request —
POST /api/agent-binding/request(owner JWT). The UI's "run it on <machine>" choice, stored as a directive (botMetadata.requestedMachineId), never a binding. D3 holds: the adopt CAS remains the only binding writer, a successful adopt consumes the request, release withdraws it. Ownership is the same sole-installer predicate as adopt; the target machine must be owned by the caller; a bound-elsewhere identity 409s withboundTo.Daemon work list —
GET /api/agent-binding/assigned(daemon token,agents:adoptscope). Identities bound to or requested onto THIS machine (credential-derived machineId, never caller input), intersected with the owner's active installation set — an identity outside it never appears. Each row carriesstate: bound|requested, podIds, and the installation'sconfig.runtimeso the daemon can provision (model pin included) without another read.Runtime credential mint —
POST /api/agent-binding/runtime-token(daemon token). Requires the D3 binding to this machine; mints thecm_agent_*token as a child of the machine's daemon credential (D4.5 lineage — machine removal already cascade-revokes descendants). An existing token 409stoken_existsunlessrotate:true; rotation is total — ledger row revoked AND both legacy stores cleared (User.agentRuntimeTokens + installation runtimeTokens copies), otherwise the old bearer would keep working through the legacy auth fallback.req.machinestays the minimal S1 projection; the parent credential is re-derived server-side.Agent-state heartbeats (D5) —
POST /api/machines/:id/heartbeatnow acceptsagents: [{agentName, instanceId, state: running|stopped|crashed, restarts}], validated and capped in the service, replaced wholesale per report. An absent array preserves the last report (a Phase-1 daemon keeps working); an explicit empty array is itself a report. States serialize on every machine view, so the UI can render "nothing is running gavin-codex" truthfully.Verification
31 tests green across the four daemon suites: 13 new (placement directive semantics, work-list machine+owner scoping, mint lineage/rotation totality/wrong-machine refusal, heartbeat state normalization + preserve-vs-clear), plus the existing adoption CAS suite untouched.
🤖 Generated with Claude Code
https://claude.ai/code/session_01EtwYLMJAYuZ3grLQoXWMWT