feat(jobs): emit job.enqueue + worktree.pruned audit rows

Deferred audit retrofits from Plan #5 self-review:
- WebhookNotifier now records a job.enqueue audit row after each
  successful repo.Enqueue (best-effort: failures are warn-logged, not
  propagated). Added optional audit.Recorder + *slog.Logger params to
  NewWebhookNotifier.
- WorktreePrune.executionPhase now records a worktree.pruned audit row
  after each successful FinishPruneSuccess. Added optional audit.Recorder
  param to NewWorktreePrune.
- app.go wires the existing auditRec into both constructors.
- integration_test.go: drop the _ = auditRec suppression and pass
  auditRec into the webhook notifier so the closed-loop test exercises
  the audit emit path.
This commit is contained in:
2026-05-06 13:35:45 +08:00
parent f6089ac5fb
commit b1ccce567e
6 changed files with 65 additions and 28 deletions
+4 -4
View File
@@ -25,7 +25,7 @@ func TestWebhookNotifier_EnqueuesForWhitelistedTopic(t *testing.T) {
Enabled: true,
Topics: []string{"workspace.sync_failed"},
Backoff: []time.Duration{30 * time.Second},
}, clock.Real())
}, clock.Real(), nil, nil)
err := n.Send(ctx, notify.Message{
ID: uuid.New(), UserID: uuid.New(), Topic: "workspace.sync_failed",
@@ -51,7 +51,7 @@ func TestWebhookNotifier_DropsNonWhitelistedTopic(t *testing.T) {
Enabled: true,
Topics: []string{"workspace.sync_failed"},
Backoff: []time.Duration{30 * time.Second},
}, clock.Real())
}, clock.Real(), nil, nil)
err := n.Send(ctx, notify.Message{
ID: uuid.New(), UserID: uuid.New(), Topic: "chat.message_failed",
@@ -69,7 +69,7 @@ func TestWebhookNotifier_DisabledShortCircuits(t *testing.T) {
n := jobs.NewWebhookNotifier(repo, jobs.WebhookNotifierConfig{
Enabled: false,
Topics: []string{"workspace.sync_failed"},
}, clock.Real())
}, clock.Real(), nil, nil)
err := n.Send(ctx, notify.Message{
ID: uuid.New(), UserID: uuid.New(), Topic: "workspace.sync_failed", CreatedAt: time.Now(),
})
@@ -79,6 +79,6 @@ func TestWebhookNotifier_DisabledShortCircuits(t *testing.T) {
}
func TestWebhookNotifier_Name(t *testing.T) {
n := jobs.NewWebhookNotifier(nil, jobs.WebhookNotifierConfig{}, clock.Real())
n := jobs.NewWebhookNotifier(nil, jobs.WebhookNotifierConfig{}, clock.Real(), nil, nil)
assert.Equal(t, notify.ChannelWebhook, n.Name())
}