Route the daemon's task-lifecycle / work-intake / workflow consumers (the TaskStore composite) through b.stateStore instead of reaching into b.st directly, the same additive composition pattern .4.4 used for the capture/mapping/binding contracts (docs/prds/state-store-contract.md §10/§12 step 6). b.stateStore is the in-process *store.Store by default and a remote *staterpc.Client dialed to the standalone archie-state-store gRPC service when [services.state].target is set, so this is behaviour-neutral until an operator flips the seam. Consumers migrated: daemon.Daemon.Store, webui.Server.Store, the message gateway routers, the chat task lister/log-reader adapters, the operator task action service, event persistence (persistAndBroadcastEvents), the manual requeue path, and the chat task creator/controller. openStores now seeds b.stateStore = b.st so it is never nil in either the daemon (Run) or the gateway (RunGateway) composition; the gateway never calls openStateStoreAdapter, so it stays on the local adapter and never dials a remote store (preserving the .4.4 fail-closed intent). The in-process State Store gRPC server keeps fronting b.st (the agent's gRPC and NATS storerpc handoff paths both stay on the daemon's local store) and the in-process serving path is untouched (deletion is .4.6). Adds focused composition-regression tests asserting the daemon, webui and task-actions consumers resolve their store from b.stateStore, plus the existing bufconn conformance suite (grpc adapter) already proves contract fidelity for the TaskStore surface.
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package archied
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
"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(config.NewHolder(b.cfg)),
|
|
b.cancelTask,
|
|
b.closeIssue,
|
|
b.removeTaskLogs,
|
|
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) publishEvent(e events.Event) {
|
|
if b.bus != nil {
|
|
b.bus.Publish(e)
|
|
}
|
|
}
|