feat(client): colibri prune-agents + doctor --fix stale-agent prune #303

Closed
clawdie wants to merge 1 commit from feat-agents-prune into main
Owner

Implements the stale-agent prune from #295 — the second doctor --fix dispatch target, alongside binary_vs_git_version → upgrade.

What a stale agent is

registration_linkage (doctor.rs) flags store agents whose name has no live handle in state.agents — DB rows left behind when an agent process exits/crashes/restarts. They accumulate (osa 17, debby 4) and were previously unfixable without hand-editing SQLite.

Changes

  • ledgerdelete_agent(id): idempotent DELETE FROM agents (returns false for absent ids).
  • daemonPruneAgents RPC: recomputes stale exactly like the doctor check (store agents not in the live handle map), deletes them, returns { pruned, agents: [{id, name}] }. Live agents are never touched.
  • clientcolibri prune-agents command + DaemonClient::prune_agents.
  • doctorregistration_linkage WARN is now .with_fixable() with a colibri prune-agents hint.
  • fix_fixable — dispatches registration_linkage → prune_agents (auto-prune in --fix, per the chosen design).

Safety

Auto-prune only ever removes rows with no live handle, so it can never drop a running agent. (The narrow register-before-handle race was the reason the grace-window option existed; we chose plain auto-prune — a just-registered agent without a handle yet is the same race the check itself already reports.)

Gates

  • cargo fmt --all --check clean; cargo clippy --workspace --all-targets -- -D warnings clean
  • full test suite green; new test_delete_agent_is_idempotent

Closes the prune item in #295.

🤖 Generated with Claude Code

Implements the stale-agent prune from #295 — the **second `doctor --fix` dispatch target**, alongside `binary_vs_git_version → upgrade`. ### What a stale agent is `registration_linkage` (`doctor.rs`) flags store agents whose name has **no live handle** in `state.agents` — DB rows left behind when an agent process exits/crashes/restarts. They accumulate (osa 17, debby 4) and were previously unfixable without hand-editing SQLite. ### Changes - **ledger** — `delete_agent(id)`: idempotent `DELETE FROM agents` (returns false for absent ids). - **daemon** — `PruneAgents` RPC: recomputes stale **exactly like the doctor check** (store agents not in the live handle map), deletes them, returns `{ pruned, agents: [{id, name}] }`. **Live agents are never touched.** - **client** — `colibri prune-agents` command + `DaemonClient::prune_agents`. - **doctor** — `registration_linkage` WARN is now `.with_fixable()` with a `colibri prune-agents` hint. - **fix_fixable** — dispatches `registration_linkage → prune_agents` (auto-prune in `--fix`, per the chosen design). ### Safety Auto-prune only ever removes rows with no live handle, so it can never drop a running agent. (The narrow register-before-handle race was the reason the grace-window option existed; we chose plain auto-prune — a just-registered agent without a handle yet is the same race the check itself already reports.) ### Gates - `cargo fmt --all --check` clean; `cargo clippy --workspace --all-targets -- -D warnings` clean - full test suite green; new `test_delete_agent_is_idempotent` Closes the prune item in #295. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(client): colibri prune-agents + doctor --fix stale-agent prune
Some checks failed
CI / rust (pull_request) Has been cancelled
CI / markdown (pull_request) Has been cancelled
CI / port (pull_request) Has been cancelled
CI / agent-jail-pkgs (pull_request) Has been cancelled
f5c6097e44
Gives doctor --fix its second dispatch target (after binary_vs_git_version →
upgrade): registration_linkage WARN now self-heals by pruning stale agent
registrations — store rows whose name has no live handle (osa 17, debby 4).

- ledger: delete_agent(id) — idempotent DELETE FROM agents
- daemon: PruneAgents RPC — recomputes stale exactly like the doctor check
  (store agents not in the live handle map), deletes them, returns {pruned,
  agents}; live agents are never touched
- client: colibri prune-agents command + DaemonClient::prune_agents
- doctor: registration_linkage WARN now .with_fixable() + hint
- fix_fixable: dispatches registration_linkage → prune_agents, alongside the
  existing binary_vs_git_version → upgrade

Closes the prune item in #295.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
clawdie closed this pull request 2026-06-29 08:45:52 +02:00
Author
Owner

Closing as superseded by #304, which shipped the same stale-agent prune (parallel implementation, already merged to main). No unique content here — main already has colibri agents prune + the doctor --fix dispatch.

Closing as superseded by #304, which shipped the same stale-agent prune (parallel implementation, already merged to main). No unique content here — main already has `colibri agents prune` + the doctor --fix dispatch.
Some checks are pending
CI / rust (pull_request) Has been cancelled
CI / markdown (pull_request) Has been cancelled
CI / port (pull_request) Has been cancelled
CI / agent-jail-pkgs (pull_request) Has been cancelled
format-check / prettier*
Required
leak-guard / guard*
Required

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
clawdie/colibri!303
No description provided.