Skip to content

feat(daemon): add machine lifecycle endpoints - #1316

Merged
lilyshen0722 merged 9 commits into
mainfrom
kai/daemon-s1
Aug 30, 2026
Merged

lilyshen0722 merged 9 commits into
mainfrom
kai/daemon-s1

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

ADR-026 Phase 1 S1 on the AgentCredential substrate. Adds Machine rows, daemon-only credential issuance/auth, register/list/heartbeat/delete routes, cascade revocation, and agent unbinding by User.machineId.\n\nVerification: git diff --check and Node syntax checks passed. Jest is unavailable in this worktree (no node_modules), so the new service, middleware, and route tests are unrun.\n\nS2 contract: adoption CAS must bind the root User.machineId field.

samxu01 pushed a commit that referenced this pull request Aug 28, 2026
…equiring factory

Vera on #1315: a scope nobody reads doesn't hold the claim. adopt now
requires 'agents:adopt'; heartbeat-only credentials 403. No legacy
daemon credentials exist, so enforcement is strict from birth. This is
THE daemon middleware — #1316 should consume it, not duplicate it.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013pc6nGXRS8mHvrwcXMSRDK
@lilyshen0722
lilyshen0722 changed the base branch from main to feat/daemon-adoption-cas August 28, 2026 22:29
lilyshen0722 added a commit that referenced this pull request Aug 30, 2026
…1315)

* feat(daemon): identity-level machine binding + adoption CAS — ADR-026 D3 (Phase 1 S2)

cm_daemon_* auth against the ledger (lifecycle-scoped: cannot pass
agentRuntimeAuth or act as any agent); botMetadata.machineId declared on
interface AND schema; POST /api/agent-binding/adopt is an atomic
unbound→bound(machineId) conditional update — machineId comes from the
credential server-side, never the body; concurrent adopts yield one
winner and a clean 409; release is an explicit owner action, making
rebind a deliberate two-step.

6 CAS invariant tests on mongodb-memory-server incl. the concurrent race.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013pc6nGXRS8mHvrwcXMSRDK

* fix(daemon): enforce credential scopes — daemonAuth becomes a scope-requiring factory

Vera on #1315: a scope nobody reads doesn't hold the claim. adopt now
requires 'agents:adopt'; heartbeat-only credentials 403. No legacy
daemon credentials exist, so enforcement is strict from birth. This is
THE daemon middleware — #1316 should consume it, not duplicate it.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013pc6nGXRS8mHvrwcXMSRDK

* fix(daemon): routes see req.machine and nothing else (Vera's S1 contract)

Minimal projection {machineId, ownerUserId, scopes} — the credential
document and its internals never reach route handlers.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013pc6nGXRS8mHvrwcXMSRDK

* fix(daemon): sole-installer ownership predicate (Vera's #1315 ruling)

Adoption requires an active installation installedBy the owner AND no
active installation of the identity installedBy anyone else. Test pins
the negative clause: a shared identity is not adoptable by either party.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013pc6nGXRS8mHvrwcXMSRDK

---------

Co-authored-by: Claude Fable 5 <[email protected]>
@lilyshen0722
lilyshen0722 changed the base branch from feat/daemon-adoption-cas to main August 30, 2026 01:14
@lilyshen0722
lilyshen0722 merged commit 6c7ab55 into main Aug 30, 2026
10 of 11 checks passed
@lilyshen0722
lilyshen0722 deleted the kai/daemon-s1 branch August 30, 2026 02:14
@lilyshen0722

Copy link
Copy Markdown
Contributor Author

Held by Sam's ruling (2026-08-30): ADR-026's direction is approved and the doc merges as Proposed, but Phase 0 (token substrate) and everything after it are gated on ADR-023 W2 (hosted runtime) being live — casual signups are the activation goal and hosted is the bigger lever for them. This PR stays open until that gate opens; rebase when it does. Added acceptance criterion for Phase 1: revoke a machine → every agent bound to it stops within one heartbeat, as a tested requirement. The D6 ack race is now its own P1 row (TASK-090) — fix it independently of this stack.

@lilyshen0722

Copy link
Copy Markdown
Contributor Author

RETRACTED — the hold comment above was written from a stale queue listing. Sam ratified ADR-026 as Accepted via his other session on 2026-08-30 and this PR was merged and deployed under that decision before the comment landed. The ratification stands; ignore the hold.

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