Add run size_bytes and delete_runs to free disk space

Every run summary carries size_bytes (artifact tree, server-created Pi
session directories and an estimate of the run's database rows), cached in
pipeline_runs.size_bytes, invalidated by triggers, measured when a run
finishes and backfilled in the background. delete_runs removes terminal
runs with every scoped row and server-owned file, refuses active ones with
a reason, and pushes runs_removed to subscribers. pipelines runs rm is the
CLI form; retention apply now shares the complete row deletion.
This commit is contained in:
2026-10-31 22:11:14 +00:00
parent 62b56e66d0
commit 31e89e872b
20 changed files with 1421 additions and 12 deletions
+23 -1
View File
@@ -319,7 +319,29 @@ and matched field. `list_runs` also returns all-history `usage`
aggregates. `attention_acks` reads and `ack_attention` adds to the operator's
shared in-app acknowledgements (dismissed Needs-you entries and chat read
watermarks; see [ntfy.md](ntfy.md#clearing-notifications-across-devices)); other
connections receive an `attention_acks_changed` push. See
connections receive an `attention_acks_changed` push.
Every run summary (`list_runs` rows, `get_run`, subscribe snapshots and terminal
`run_event` frames) carries `size_bytes`: bytes on disk for the run (artifact tree
with turn documents and session exports, server-created Pi session directories,
plus an estimate of its database rows). It is cached in `pipeline_runs.size_bytes`,
invalidated by triggers when the run changes, measured on completion, and
backfilled in the background; 0 means not measured yet. `delete_runs` removes
finished runs to free space:
```json
{"type":"delete_runs","id":"1","run_ids":[12,13,99]}
{"type":"runs_deleted","id":"1","runs_deleted":{"deleted":[12],"refused":[{"run_id":13,"reason":"run is running; cancel it or wait for it to finish"},{"run_id":99,"reason":"run not found"}],"freed_bytes":48213}}
{"type":"runs_removed","run_ids":[12]}
```
Only terminal runs (succeeded, failed, canceled, interrupted) are deleted; active
runs, unconfirmed cleanup, a running session export, a run an unfinished retry
depends on, and unknown ids are refused individually. Deletion removes every
row scoped to the run in one transaction plus `<artifacts>/<run>` and owned Pi
session directories; user workspaces are never touched. Subscribed connections
whose scope covers the runs receive the `runs_removed` push. `pipelines runs rm
<id...>` is the CLI form. See
`internal/protocol/message.go` for JSON envelopes. Mutating RPCs
have real effects; they are not previews. TUI-only animation, scrolling, and
transient client logs are presentation, not separate server capabilities.