feat: delete task history of a template #4409
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 409 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.360
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4409"
general
weight: 0.35
mansur-akhmadi
Closes #1101
Adds
DELETE /api/project/{project_id}/templates/{template_id}/tasks, which deletes the task history of a template, and a "Delete Task History" button with a confirmation on the template page.Behaviour
RemoveTask): admin only, with the same deny audit record. 204 on success (also when nothing was deleted), 401 for a non-admin, 404 for an unknown template or one from another project.task.history/delete_alltargeting the template, with the number of deleted tasks. I added a kind rather than reusingtask.history/deletebecause the catalog keeps one metadata type per kind, as withstop/stop_all.project__template.taskscounter afterwards.Deleting in batches
Tasks are deleted in batches of 500, each in its own transaction, so a large history doesn't hold the SQLite write lock for the whole run. If a later batch fails, the earlier ones stay deleted and the audit event is marked
partial.Stages, stage results and Ansible hosts/errors go by
ON DELETE CASCADE. MySQL has no foreign key onaccess_key.task_idortask.build_task_id, so the task-bound access keys are deleted andbuild_task_idreferences cleared explicitly; task output is deleted explicitly too.Testing
go test ./db/sql/ -count=20passes.DELETE (204) /api/project/1/templates/7/tasks.Not included: a CLI /
pkg/apiclientcommand and translations for the new strings (other locales fall back to English).<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Administrators can delete a template’s finished task history from the template page. Queued and running tasks, tasks needed by unfinished work, and the newest task for build templates are retained.
The action requires confirmation and reports success or errors. The task list refreshes after the request, including when an error occurs.
Deletions are recorded in the audit history.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Supersedes #4407 (reopened from my main account; the review there is addressed).