feat(runtime): add bulk purge for archived queue tasks and chat_attachment i18n

Operators can clear all finally-failed tasks in one queue from the runtime
drawer, with audit logging and scoped API access. Also localize the
chat_attachment queue label in the runtime queue details table.
This commit is contained in:
wizardchen
2026-07-23 16:51:09 +08:00
committed by lyingbug
parent de7507cc96
commit 6c794f64cf
18 changed files with 307 additions and 9 deletions
+4
View File
@@ -131,6 +131,10 @@ const (
AuditActionSystemQueueTaskDeleted AuditAction = "system.queue_task_deleted"
AuditActionSystemQueueTaskRunNow AuditAction = "system.queue_task_run_now"
AuditActionSystemQueueTaskCancelled AuditAction = "system.queue_task_cancelled"
// AuditActionSystemQueueArchivedPurged fires when an operator clears every
// archived (finally-failed) task in one queue in a single action. The
// detail payload records the queue and how many records were removed.
AuditActionSystemQueueArchivedPurged AuditAction = "system.queue_archived_purged"
// Knowledge-base activity actions. These rows use scope_type=knowledge_base
// and scope_id=<kb id>; TargetType/TargetID identify the concrete child
+4
View File
@@ -42,6 +42,7 @@ func TestAuditAction_DotNamespaceConvention(t *testing.T) {
AuditActionSystemQueueTaskDeleted,
AuditActionSystemQueueTaskRunNow,
AuditActionSystemQueueTaskCancelled,
AuditActionSystemQueueArchivedPurged,
}
for _, a := range all {
s := string(a)
@@ -128,6 +129,7 @@ func TestAuditAction_NoCollisionsAcrossNamespaces(t *testing.T) {
register("AuditActionSystemQueueTaskDeleted", AuditActionSystemQueueTaskDeleted)
register("AuditActionSystemQueueTaskRunNow", AuditActionSystemQueueTaskRunNow)
register("AuditActionSystemQueueTaskCancelled", AuditActionSystemQueueTaskCancelled)
register("AuditActionSystemQueueArchivedPurged", AuditActionSystemQueueArchivedPurged)
}
// TestAuditAction_SystemNamespacePrefix pins the system.* actions
@@ -146,6 +148,7 @@ func TestAuditAction_SystemNamespacePrefix(t *testing.T) {
AuditActionSystemQueueTaskDeleted,
AuditActionSystemQueueTaskRunNow,
AuditActionSystemQueueTaskCancelled,
AuditActionSystemQueueArchivedPurged,
}
for _, a := range cases {
assert.True(t,
@@ -172,6 +175,7 @@ func TestAuditAction_SystemWireValues(t *testing.T) {
{AuditActionSystemQueueTaskDeleted, "system.queue_task_deleted"},
{AuditActionSystemQueueTaskRunNow, "system.queue_task_run_now"},
{AuditActionSystemQueueTaskCancelled, "system.queue_task_cancelled"},
{AuditActionSystemQueueArchivedPurged, "system.queue_archived_purged"},
}
for _, c := range cases {
assert.Equal(t, c.wire, string(c.constant))
@@ -101,4 +101,12 @@ type RuntimeTaskInspector interface {
// operator-facing AllowedActions. Used when the business row is already
// gone but a retry/pending task survived (orphan cleanup).
ForceDeleteRuntimeTask(ctx context.Context, queue, taskID string) (supported bool, err error)
// PurgeArchivedRuntimeTasks removes every archived (finally-failed) task
// from one queue in a single call and returns how many records were
// deleted. It only ever touches the archived (dead-letter) set, so live
// pending/active/scheduled/retry tasks are never affected. Business state
// is intentionally left untouched: archived tasks have already had their
// document status flipped to "failed" on their last retry, mirroring the
// semantics of deleting archived records one by one.
PurgeArchivedRuntimeTasks(ctx context.Context, queue string) (deleted int, supported bool, err error)
}