Files
archie/internal/app/archied/task_actions.go
T
sam dbaa7284a3 feat(taskactions): archive reaps the task's worktree; cleanup test models a completed run
A worktree terminal cleanup keeps (uncaptured or unreadable work) now has a
reap path: archiving calls Daemon.RemoveWorktree for the owning identity's
trees, and the keep logs name archive as the way out. The no-change cleanup
test reports completed through one direct transition instead of reaching
merged via a faked pr_open hop.
2026-09-27 13:38:12 +10:00

62 lines
1.6 KiB
Go

package archied
import (
"context"
"fmt"
"github.com/samcharles93/archie-core/internal/domain/taskactions"
"github.com/samcharles93/archie-core/internal/events"
taskactionstore "github.com/samcharles93/archie-core/internal/infrastructure/taskactions"
)
// taskActions assembles the daemon-owned operator action service. The daemon
// retains execution cancellation, retry policy, forge closure and event
// ownership; the dashboard's webui service and the NATS responder both build
// through the same constructor so the surfaces cannot diverge.
func (b *boot) taskActions() taskactions.Service {
return taskactionstore.NewService(
taskactionstore.Store{TaskStore: b.stateStore},
taskactionstore.MaxRetries(b.cfgHolder),
b.cancelTask,
b.closeIssue,
b.removeTaskLogs,
b.removeTaskWorktree,
b.publishEvent,
b.log.Warn,
)
}
func (b *boot) cancelTask(id int64) bool {
if b.d == nil {
return false
}
return b.d.CancelTask(id)
}
func (b *boot) closeIssue(ctx context.Context, owner, repo string, number int, comment string) error {
if b.forgeClient == nil {
return fmt.Errorf("forge is not configured")
}
return b.forgeClient.CloseIssue(ctx, owner, repo, number, comment)
}
func (b *boot) removeTaskLogs(id int64) error {
if b.taskLogs == nil {
return nil
}
return b.taskLogs.Remove(id)
}
func (b *boot) removeTaskWorktree(task *taskactions.Task) error {
if b.d == nil {
return nil
}
return b.d.RemoveWorktree(task.Owner, task.Repo, task.Identity, task.IssueNumber)
}
func (b *boot) publishEvent(e events.Event) {
if b.bus != nil {
b.bus.Publish(e)
}
}