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
+3
View File
@@ -238,6 +238,9 @@ type Message struct {
// displays. Both are optional so older peers ignore them.
RunEvent *RunEventFrame `json:"run_event,omitempty"`
RunIDs []int64 `json:"run_ids,omitempty"`
// RunsDeleted is the runs_deleted reply to delete_runs (whose request names
// the runs in RunIDs). The runs_removed push carries only RunIDs.
RunsDeleted *RunsDeletedResult `json:"runs_deleted,omitempty"`
// NotificationSettings is the set_notification_settings partial update and
// the notification_settings reply (every key). See notification_settings.go.
NotificationSettings map[string]any `json:"notification_settings,omitempty"`
+4
View File
@@ -57,6 +57,10 @@ type RunEventFrame struct {
// Artifacts is the number of files recorded for the referenced step, so a
// client can surface artifact capture without reading the step.
Artifacts int `json:"artifacts,omitempty"`
// SizeBytes is the run's measured on-disk size (see RunSummary.SizeBytes).
// It is sent on subscribe snapshots and terminal frames; absence means
// unchanged.
SizeBytes int64 `json:"size_bytes,omitempty"`
// Step is present when a single step changed (started, finished or waiting).
Step *RunStepDelta `json:"step,omitempty"`
}
+27
View File
@@ -16,8 +16,30 @@ const (
GetRunEvidence = "get_run_evidence"
RunEvidence = "run_evidence"
RepairSessionExport = "repair_session_export"
// DeleteRuns removes terminal runs and everything the server stores for
// them; the reply is RunsDeleted and other subscribers receive RunsRemoved.
DeleteRuns = "delete_runs"
RunsDeleted = "runs_deleted"
RunsRemoved = "runs_removed"
)
// RunsDeletedResult is the runs_deleted reply to delete_runs. Deleted lists the
// run ids removed, Refused every requested id that was kept with the reason
// (an active run, an unknown id, ...), and FreedBytes the summed size_bytes of
// the deleted runs as measured immediately before deletion. All three are
// always present.
type RunsDeletedResult struct {
Deleted []int64 `json:"deleted"`
Refused []RunDeleteRefusal `json:"refused"`
FreedBytes int64 `json:"freed_bytes"`
}
// RunDeleteRefusal is one requested run id delete_runs did not remove.
type RunDeleteRefusal struct {
RunID int64 `json:"run_id"`
Reason string `json:"reason"`
}
// Waiting statuses. A human stage pauses its run without a live goroutine, so
// the run and its step persist these statuses and the decision path resumes
// them. Store, server, CLI and TUI read the one pair below, never a literal.
@@ -170,6 +192,11 @@ type RunSummary struct {
Model string `json:"model,omitempty"`
StageModels map[string]string `json:"stage_models,omitempty"`
OutputFormat string `json:"output_format,omitempty"`
// SizeBytes is the bytes on disk attributable to the run: its artifact tree
// (turn documents, inputs, outputs, session exports), server-created Pi
// session directories and an estimate of its database rows. It is cached
// server-side; 0 means not measured yet (a background backfill fills it).
SizeBytes int64 `json:"size_bytes"`
}
// RunGraphVisit contains only routing and lifecycle facts, never private step