fix(eda): clear completed tasks; document the tool allowlist's reach and unchecked profile names
ClearTerminalTasks now deletes completed tasks, with a test that holds its SQL list to taskstate.Terminal. The AllowTools comment says agentloop's built-in file tools are outside the allowlist and why. The PRD model diagram lists only what a profile holds (image, tools), and the profile field and AgentProfile say a workflow's profile name is resolved at dispatch, not when the workflow is saved.
This commit is contained in:
1 parent
d320a1a01a
commit
d8bec1ae06
8 files changed
+51
-10
No files matched your search
@@ -43,7 +43,10 @@ type LoopRunner struct {
|
||||
// AllowTools is the agent profile's allowlist over the tools archie adds
|
||||
// (central/MCP, repository scripts and skill plugins). Empty allows them
|
||||
// all. A stage's capture tools are how it returns structured results, so
|
||||
// they are never filtered.
|
||||
// they are never filtered. The agent loop's built-in file tools are not
|
||||
// covered either: ai-sdk agentloop registers them itself with no filter
|
||||
// hook, so they are always present (read-only when the stage asks), and
|
||||
// restricting them needs an ai-sdk change.
|
||||
AllowTools []string
|
||||
}
|
||||
|
||||
@@ -393,8 +396,6 @@ func scriptToolSet(workspace string) core.ToolSet {
|
||||
}
|
||||
}
|
||||
|
||||
// mergeToolSets combines tool sets into one; later sets win on name
|
||||
// collisions.
|
||||
// allowedTools keeps the tools allow names; an empty allow keeps them all.
|
||||
func allowedTools(set core.ToolSet, allow []string) core.ToolSet {
|
||||
if len(allow) == 0 {
|
||||
@@ -409,6 +410,8 @@ func allowedTools(set core.ToolSet, allow []string) core.ToolSet {
|
||||
return kept
|
||||
}
|
||||
|
||||
// mergeToolSets combines tool sets into one; later sets win on name
|
||||
// collisions.
|
||||
func mergeToolSets(sets ...core.ToolSet) core.ToolSet {
|
||||
merged := core.ToolSet{}
|
||||
for _, set := range sets {
|
||||
|
||||
@@ -914,7 +914,9 @@ type ContainerConfig struct {
|
||||
|
||||
// AgentProfile is a named execution environment for an agent. Secrets and
|
||||
// forge or network access are granted to identities, not profiles
|
||||
// (docs/prds/orgs-and-access.md).
|
||||
// (docs/prds/orgs-and-access.md). A workflow's profile name is not checked
|
||||
// when the workflow is saved: a name with no profile here parks the task for
|
||||
// an operator when it is dispatched (daemon pinTaskProfile).
|
||||
type AgentProfile struct {
|
||||
// Image is the container image; empty means [containers].image.
|
||||
Image string `toml:"image" yaml:"image" json:"image,omitempty"`
|
||||
|
||||
@@ -39,7 +39,9 @@ type InputSpec struct {
|
||||
type WorkflowInterface struct {
|
||||
Inputs map[string]InputSpec `yaml:"inputs,omitempty" json:"inputs,omitempty"`
|
||||
Repository RepositoryMode `yaml:"repository,omitempty" json:"repository,omitempty"`
|
||||
Profile string `yaml:"profile,omitempty" json:"profile,omitempty"`
|
||||
// Profile names a [containers.profiles] entry. It is resolved when a task
|
||||
// is dispatched, not when the workflow is saved.
|
||||
Profile string `yaml:"profile,omitempty" json:"profile,omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/taskstate"
|
||||
)
|
||||
|
||||
// ClearTerminalTasks deletes exactly the statuses taskstate.Terminal names, so
|
||||
// the SQL list cannot fall behind a new terminal status.
|
||||
func TestClearTerminalTasksMatchesTaskstate(t *testing.T) {
|
||||
s := storeFor(t)
|
||||
statuses := taskstate.Statuses()
|
||||
for i, meta := range statuses {
|
||||
if _, err := s.EnqueueIssue(t.Context(), "acme", "widgets", i+1, "t", "b", "", ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := s.pool.Exec(t.Context(), "UPDATE tasks SET status = $1 WHERE issue_number = $2", meta.ID, i+1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if _, err := s.ClearTerminalTasks(t.Context()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for i, meta := range statuses {
|
||||
task, err := s.TaskByIssue(t.Context(), "acme", "widgets", i+1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if kept := task != nil; kept == taskstate.Terminal(meta.ID) {
|
||||
t.Errorf("status %q: kept = %v, want kept only when not terminal", meta.ID, kept)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ func (q *Queries) ClaimNextTask(ctx context.Context) (Task, error) {
|
||||
|
||||
const clearTerminalTasks = `-- name: ClearTerminalTasks :execrows
|
||||
DELETE FROM tasks
|
||||
WHERE status IN ('merged', 'rejected', 'dead', 'closed_wont_do')
|
||||
WHERE status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed')
|
||||
`
|
||||
|
||||
func (q *Queries) ClearTerminalTasks(ctx context.Context) (int64, error) {
|
||||
|
||||
@@ -88,7 +88,7 @@ WHERE id = $1 AND status = $4;
|
||||
|
||||
-- name: ClearTerminalTasks :execrows
|
||||
DELETE FROM tasks
|
||||
WHERE status IN ('merged', 'rejected', 'dead', 'closed_wont_do');
|
||||
WHERE status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed');
|
||||
|
||||
-- name: RecoverStaleTasks :execrows
|
||||
UPDATE tasks SET status = 'queued', updated_at = now() WHERE status = 'running';
|
||||
|
||||
Reference in new issue
Block a user