Skip to content

bug: retention blast-radius guard has no in-product approval path — agent purge and #1581 volume reclaim can never run #1709

Closed

Description

@vybe

Summary

#1644 shipped the retention blast-radius guard with FLOOR_AGENTS = 0 — "every purge destroys Docker volumes. Always ack." — so every agent hard-purge, even a single one, exceeds the threshold and is refused until an admin acknowledgement exists.

The only way to record that acknowledgement is POST /api/settings/retention/acknowledge. That endpoint has no frontend caller and no MCP tool: src/frontend/src/views/Settings.vue wires only the read-only GET /api/settings/retention.

Net effect: no operator can approve, the guard always refuses, the #834 agent purge sweep never completes — and #1581's Docker-volume reclaim, which shipped in the same release, can never run. Volumes still leak forever, now for a different reason.

Context

Found by /release-plan during the v0.8.5 pre-freeze coherence review (2026-07-20).

The guard's design is correct and should not change: destroying agent data volumes is irreversible, so a human gate is right, and FLOOR_AGENTS = 0 is a deliberate "always ask". This issue is only about the missing approval surface — the guard is fail-safe (nothing is wrongly deleted), but it makes a shipped fix inert and the release cannot honestly claim #1581 without it.

Design decision to settle first

GET /api/settings/retention currently reports the effective windows plus guard.max_rows — it does not report that a prune is pending approval, so the UI has nothing to render a prompt from. Two options:

  1. Extend the GET to report pending refusals (setting key, window in force, candidate count, last-refused timestamp).
  2. Read the existing alarm — the guard already raises an operator-queue item on the reserved _retention-guard sentinel with counts and identifiers.

Option 1 keeps the Settings panel self-contained and avoids coupling a settings surface to the operator queue; option 2 adds no endpoint surface. Pick one before building.

Acceptance Criteria

  • An admin can approve a pending retention prune from Settings → Retention without leaving the UI
  • The confirmation names what will be deleted: the setting key, the window in force, and the candidate count — approving blind is not acceptable for an irreversible volume deletion
  • The action is admin-only and human-only — it must reject an agent-scoped principal (reject_agent_principal), since an agent key resolves to its owner carrying the owner's role and the default install is admin-owned
  • The window sent matches the window in force; a mismatch surfaces the existing 409 as a named, readable error rather than a generic failure
  • Acknowledgement remains single-use — after the prune runs the guard re-arms and the UI reflects that (no stale "approved" state)
  • When nothing is pending, the panel shows an honest empty state with a next action — not a dead control or a permanently-enabled button
  • With #1581 in place, an approved purge demonstrably removes the agent's workspace/public/shared volumes
  • The approval is audit-logged (it already is server-side — confirm it surfaces with the acting admin)
  • Guarded by a test that fails if the ack endpoint loses its UI caller again

Technical Notes

  • Guard + floors: src/backend/services/retention_guard.py (FLOOR_AGENTS = 0, MAX_ROWS_PER_SWEEP = 1000, is_acknowledged / record_acknowledgement / consume_acknowledgement)
  • Endpoint: POST /api/settings/retention/acknowledge in src/backend/routers/settings.py — already admin + human-gated, window-bound (409 on mismatch), single-use, audit-logged. No backend auth work needed; this is a surface gap.
  • Consumer: src/backend/services/cleanup_service.py calls the guard before each of the 7 window-driven prunes
  • Panel: src/frontend/src/views/Settings.vue (already renders the read-only retention section)
  • Open-core boundary: the ack capability is OSS-core. The enterprise retention module sells the managed panel (audit trail, updated_by, hot-reload) — do not build that here. Keep this to the plain approval control.
  • Do not raise MAX_ROWS_PER_SWEEP or FLOOR_AGENTS to work around the missing UI. The threshold is deliberately a fixed constant, not a setting, and lowering-is-safe/raising-is-not is pinned by tests/unit/test_1644_retention_guard.py.

Related

  • #1644 — the guard that introduced the gate
  • #1581 — the volume reclaim this blocks
  • #834 — the soft-delete/purge lifecycle the sweep belongs to

Activity

  1. added
    priority-p1
    type-bug
    theme-reliability
    complexity-medium
    status-ready
    on Jul 20, 2026
  2. added
    status-in-progress
    and removed
    status-ready
    on Jul 20, 2026
  3. self-assigned this
    on Jul 20, 2026
  4. added
    status-in-dev
    and removed
    status-in-progress
    on Jul 21, 2026
  5. removed
    status-in-dev
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complexity-mediumpriority-p1theme-reliabilitytype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions