Files
roboco/alembic/versions/027_system_settings.py
T
fbbb7b3251 Feat: transcript retention (#123)
* feat(retention): prune old agent transcripts + panel-tunable setting

Agents write a {session-id}.jsonl per spawn under ~/.claude/projects; nothing
ever deleted them, so the operator's bind-mounted ~/.claude grew without bound.

Add a throttled orchestrator sweep that prunes agent-owned transcripts (the
shared -app dir + per-workspace dirs) older than a retention window — and ONLY
agent-owned dirs, never the operator's own Claude sessions (proven by the
temp-dir selection tests). The window is panel-tunable: a new system_settings
key-value table (migration 027) holds transcript_retention_days, read via
SettingsService with the roboco.config default (14d) as the fallback, exposed
through GET/PUT /api/settings. Panel wiring follows.

* feat(panel): add a panel-tunable transcript retention control

Wire the settings page to the /api/settings backend: a settings API client and
a self-contained Transcript Retention card (React Query) that loads
transcript_retention_days and saves it back, with client-side validation. The
existing settings controls are unchanged.

---------

Co-authored-by: Renn F <rennf93@users.noreply.github.com>
2026-06-12 23:11:01 +02:00

46 lines
1.3 KiB
Python

"""Add system_settings — runtime-editable, panel-tunable settings.
A key-value store for operator settings that must persist across restarts and be
editable from the panel. First user: ``transcript_retention_days``, the window
for the agent-transcript prune sweep. Seeded to 14 so the prune has a value
before anyone touches the panel; code defaults in ``roboco.config`` are the
fallback when a key is absent.
Revision ID: 027_system_settings
Revises: 026_token_usage_tables
Create Date: 2026-06-12
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
revision = "027_system_settings"
down_revision = "026_token_usage_tables"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
"system_settings",
sa.Column("key", sa.String(length=100), primary_key=True, nullable=False),
sa.Column("value", sa.Text(), nullable=False),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
nullable=False,
server_default=sa.text("now()"),
),
)
# Seed the retention window so the prune sweep has a value pre-panel.
op.execute(
"INSERT INTO system_settings (key, value, updated_at) "
"VALUES ('transcript_retention_days', '14', now())"
)
def downgrade() -> None:
op.drop_table("system_settings")