Skip to main content

snapshot_tasks

Function snapshot_tasks 

Source
pub fn snapshot_tasks(
    corpus: &str,
    service: &str,
    actor: Actor,
    database_url: &State<DatabaseUrl>,
) -> Result<(Status, Json<SnapshotAckDto>), Status>
Expand description

Freezes the current per-task statuses of a (corpus, service) into historical_tasks — the agent twin of the report screen’s “save snapshot” action (POST /savetasks/...), so an agent can capture a baseline before a rerun campaign and later diff against it (GET /api/runs/.../tasks). Token-gated via the Actor guard; the snapshot is append-only (history stays immutable over the API — there is deliberately no snapshot delete/modify endpoint; pruning is a human-admin operation, see crate::frontend::retention). 401 without a valid token, 404 on an unknown corpus/service, 202 with the appended-row count on success. Uses a fresh connection (not the request pool) since the snapshot is a single bulk INSERT … SELECT over every task and shouldn’t pin a pooled slot.