Skip to content

Add agent deletion with explicit retention and active-work guards - #12

Open
srctl wants to merge 2 commits into
mainfrom
feat/delete-agents
Open

Add agent deletion with explicit retention and active-work guards#12
srctl wants to merge 2 commits into
mainfrom
feat/delete-agents

Conversation

@srctl

@srctl srctl commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Adds a visible Delete agent action in agent settings on desktop and mobile. Confirmation names the agent and explains removal and retention. Success reloads Home with a fresh agent list; cancellation preserves the agent and failures stay in the confirmation with an actionable message.

Deletion checks and record removal share one SQLite transaction. Active/steering turns, uncertain coding workers, and outstanding delegated work on another agent block deletion. A stop request alone is insufficient. Queued work is discarded, idle local Codex runtimes are disposed, and persistent tombstones reject stale creation retries and late agent-owned writes.

Retention and assumptions

The policy was recorded before implementing deletion. Its full retention and recovery guidance is preserved below; task-specific documentation is excluded from the final code diff.

  • Permanently removes the agent's app records: conversations/run history, soul-change records, automations/reflections, dashboards/datasets, approvals/notifications, file metadata, coding settings/jobs/inputs/updates, and delegation links. No undo.
  • Retains agents/<id> (soul, history, Codex memory/sessions), workspaces/<id>, and files/<id> indefinitely. Their contents are unavailable through the deleted agent in Roost. This is not secure erasure; backups/provider-side history remain unchanged.
  • Preserves other agents and already-shared conversation content, shared execution profiles/global settings, legacy thread metadata, external repositories/worktrees, terminals, credentials, and infrastructure.
  • Uses Roost's normal single-server deployment model. It does not terminate another Roost installation or manually restarted external sessions. Coding failures/ambiguous launches may require inspection and a confirmed stop/completion before deletion.
  • Schema 10 → 11; older binaries refuse the new schema. Downgrading requires a pre-upgrade backup.

Verification

  • Lint and TypeScript checks pass.
  • 168/168 tests pass, including seven new deletion tests covering record/file isolation, stale retries/writes, queued work, active turns and cancellation, coding-job failures, delegation isolation, rollback, and runtime disposal failure.
  • App and CLI production builds pass.
  • Production-auth smoke passes (enrollment/login, private pages/API, desktop upgrade, revocation/recovery).
  • Site checks pass, including 6/6 tests and both site builds.
  • Actual browser checks at 1440×1000 and 390×844: visible confirmation and buttons; Cancel/Escape preserve the fixture; active-turn failure remains visible; confirmed synthetic deletion navigates Home, removes the agent entry, preserves River, and a stale agent URL shows “Agent not found.”

Verification used isolated temporary fixtures. Initial checks inherited live-worker binary/port overrides and a restrictive umask; tests passed after cleaning only the child-process environment and using umask 022. An inherited NITRO_PORT=3000 initially blocked the production-auth fixture; removing it from that test subprocess allowed the smoke check to pass. No live agents, services, host configuration, or the separate UI-update worktree were changed.

Verification logs: /tmp/delete-agents-check-clean.log (lint/typecheck, 168 tests, builds), /tmp/delete-agents-check-remaining.log (production auth/sites). Browser scripts and logs are disposable local artifacts under /tmp/delete-agents-*.

Full retention and recovery guidance

Deleting an agent

Lifecycle decision (recorded before implementation)

Agent ownership is recorded in roost.sqlite; agent workspaces and Codex homes
are separate directories. Herdr coding jobs can operate on external machines and
repositories. There are no cascading foreign keys or existing agent deletion API.

Deletion permanently removes the agent from Roost, including its conversation
and run history, soul change records, automations, reflection settings,
dashboards/datasets, notifications, approvals, file metadata, coding configuration,
and coding job records. Queued work is discarded in the same transaction.
There is no undo or automatic recovery. A minimal ID/time tombstone is retained
indefinitely to reject stale creation retries and late database writes.

Disk data is retained indefinitely: agents/<id> (soul, soul history, Codex
sessions and memory), workspaces/<id>, and files/<id> attachment/artifact bytes. Ownership
of workspace content and repositories is uncertain; deletion is not a secure
erasure feature. These files are no longer accessible through that agent in
Roost. Backups and provider-side history are unchanged. Administrative recovery
or cleanup is outside this feature; retained files alone do not restore app state.
Thread-indexed database metadata is retained conservatively because legacy
threads can be shared. Shared execution profiles, global settings, subscriptions,
other agents, external repositories, worktrees, terminals and infrastructure are
preserved.

An active/steering conversation blocks deletion; stop it using existing controls
and wait for its terminal outcome, then retry. Coding jobs block deletion unless
never launched, completed, or confirmed cancelled. Failed/ambiguous launches and
blocked/review workers require inspection and a confirmed stop or completion.
Deletion sends no shell commands or interrupts and never equates a stop request
with a stopped worker. Outstanding delegated work involving this agent also
blocks deletion until it settles, preserving other agents' work. Historical
handoff messages already copied into other conversations remain there.

Checks and removal hold the SQLite write lock together. A concurrent claim or
submission either commits first and blocks deletion, or loses to deletion and
cannot recreate agent-owned rows. Successful deletion navigates Home and reloads
the agent list. A failed request keeps the confirmation open for inspection/retry.

Runtime and recovery limits

Roost's normal deployment runs one server/worker process for a data directory.
Deletion closes that process's idle per-agent Codex runtime (including native
memory work) before committing. A busy runtime refuses deletion. Active job
checks use persistent SQLite state; deletion does not attempt distributed
termination of another Roost installation or manually restarted external
terminals. Stopped external sessions remain available for manual inspection.
The feature never deletes worktrees or revokes provider credentials.

The schema advances from 10 to 11. Older Roost binaries refuse the newer schema;
use a pre-upgrade backup for a downgrade. Tombstones must be preserved when
migrating data to keep old creation requests from recreating deleted identities.

Matched rendered screenshots

Actual screenshots were captured before the UI edit and after it, using the same synthetic Scout agent, settings/Soul screen, light theme, scroll position, device scale 1, and viewport. Confirmation images are additional after-only views. No mockups or screenshot artifacts are committed.

All six GitHub attachments were downloaded successfully and their SHA-256 hashes matched the original PNG bytes. The PR remains draft for coordinator review; this handoff does not claim final acceptance.

Desktop before — settings, 1440×1000

Desktop before — settings, 1440×1000

Desktop after — settings, 1440×1000

Desktop after — settings, 1440×1000

Mobile before — settings, 390×844

Mobile before — settings, 390×844

Mobile after — settings, 390×844

Mobile after — settings, 390×844

Desktop confirmation — after only, 1440×1000

Desktop confirmation — after only, 1440×1000

Mobile confirmation — after only, 390×844

Mobile confirmation — after only, 390×844

@srctl
srctl marked this pull request as ready for review September 9, 2026 01:25
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