From c155bb24ba39a477cab7782d3be0f78a4ed67813 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 11 Nov 2026 02:59:02 +1100 Subject: [PATCH] fix(taskactions): record the retention rule for archived task children (#1859) Archiving deletes the task row but deliberately keeps its child rows: execution history, usage and the dispatch ledger are records about the work, not attachments to the row. Nothing recorded that rule, so the kept rows had no parent row to explain them and no query could say what happened to an archived task. Record the rule in the archive event's data. The kind is protected from audit retention and already projects into the audit feed, so that event is the archived-task record: it names the kept child sets and leaves event rows to the instance's per-kind retention. --- CHANGELOG.md | 1 + internal/domain/taskactions/service.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12e73c3d9..097e806b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ release's per-component sections are labelled beneath its heading. - A model provider that refuses a task's credential or has run out of credit now blocks the task with a fix to follow, instead of leaving a raw API error, and the task is flagged for retry once the provider settings change. - New Google providers added from the catalogue work without setting a base URL. +- Archiving a task now records that its execution history is kept deliberately and which child tables hold it, so its audit event explains what happened to the task after its row was removed. ### archie-ui diff --git a/internal/domain/taskactions/service.go b/internal/domain/taskactions/service.go index 4d7fb932e..e44d8b6f5 100644 --- a/internal/domain/taskactions/service.go +++ b/internal/domain/taskactions/service.go @@ -598,6 +598,20 @@ func (s Service) applyMerge(ctx context.Context, task *Task, actor Actor, o outc func (s Service) applyArchive(ctx context.Context, task *Task, actor Actor, o outcome) (outcome, error) { o.event.Kind, o.event.Detail = events.KindTaskArchiveRequested, actor.describe("archive requested") + // Archiving removes the task row but deliberately keeps its child rows: + // execution history, usage and the dispatch ledger are records about the + // work, not attachments to the row. This event is their provenance and says + // what was kept; audit retention never prunes it. Events are named apart + // because the instance's per-kind retention, not this decision, owns their + // lifetime, and run credentials are not listed because they expire and the + // sweep removes them. + o.event.Data = map[string]any{ + "retention": "kept", + "children": []string{ + "transitions", "step_executions", "model_usage", "tool_calls", "binding_dispatches", + }, + "events": "audit_retention", + } id, err := s.Store.ArchiveTask(ctx, task.ID, task.Status, o.event) if err != nil { return o, err