feat: per-repo protected suffixes, requeue flag, templ-aware gate config
The first feature run parked exactly as designed but for an avoidable reason: todo is a templ project and the agent edited generated _templ.go files, leaving literal template placeholders in rendered HTML. Systemic fixes, all environmental: - repos gain protect = ["_templ.go"]: suffixes agents can never write (agentloop.ProtectPaths), forcing edits to the sources; the gate's new leading ["templ","generate","./components/"] command regenerates. AgentStage.ProtectPaths now composes with the repo list and takes TaskContext like every other stage hook. - archied -requeue <task-id>: the retry path for parked/waiting tasks (keeps the task's workflow; Requeue with empty workflow preserves it, clears the park reason). Retry of the parked feature task drove the full loop home: PRD-guided plan -> builder edited components.templ (generated file write-blocked), gate regenerated + tested -> PR #8 with 109 lines of tests.
This commit is contained in:
1 parent
239b8eda42
commit
748d9aa9ad
6 files changed
+50
-10
No files matched your search
@@ -36,7 +36,9 @@ gate_max_failures = 5
|
||||
owner = "samcharles93"
|
||||
name = "todo"
|
||||
base = "main"
|
||||
protect = ["_templ.go"]
|
||||
gate = [
|
||||
["templ", "generate", "./components/"],
|
||||
["go", "vet", "./..."],
|
||||
["go", "build", "./..."],
|
||||
["golangci-lint", "run"],
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
@@ -36,6 +37,20 @@ type Repo struct {
|
||||
// [["go","vet","./..."], ["task","check"]]. Workflow stages may
|
||||
// extend or override it (a TDD repro stage inverts the test command).
|
||||
Gate [][]string `toml:"gate"`
|
||||
// Protect lists path suffixes agents must never write directly —
|
||||
// generated files (e.g. "_templ.go") whose sources they should edit
|
||||
// instead. Enforced environmentally via agentloop.ProtectPaths.
|
||||
Protect []string `toml:"protect"`
|
||||
}
|
||||
|
||||
// Protected reports whether path matches a protected suffix.
|
||||
func (r Repo) Protected(path string) bool {
|
||||
for _, suf := range r.Protect {
|
||||
if strings.HasSuffix(path, suf) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (r Repo) FullName() string { return r.Owner + "/" + r.Name }
|
||||
|
||||
@@ -200,17 +200,20 @@ func (s *Store) WaitingTasks(ctx context.Context) ([]Task, error) {
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
// Requeue puts a task back on the queue under a specific workflow —
|
||||
// the waiting_human → approved → implement handoff.
|
||||
// Requeue puts a task back on the queue. A non-empty workflow forces it
|
||||
// (the waiting_human → approved → implement handoff); empty keeps the
|
||||
// task's current workflow (retrying a parked task).
|
||||
func (s *Store) Requeue(ctx context.Context, taskID int64, fromStatus, workflow string) error {
|
||||
if _, err := s.db.ExecContext(ctx, `
|
||||
UPDATE tasks SET status='queued', workflow=?, stage='', updated_at=datetime('now')
|
||||
WHERE id=?`, workflow, taskID); err != nil {
|
||||
UPDATE tasks SET status='queued',
|
||||
workflow=CASE WHEN ?='' THEN workflow ELSE ? END,
|
||||
stage='', park_reason='', updated_at=datetime('now')
|
||||
WHERE id=?`, workflow, workflow, taskID); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := s.db.ExecContext(ctx,
|
||||
`INSERT INTO transitions (task_id, from_status, to_status, detail) VALUES (?, ?, 'queued', ?)`,
|
||||
taskID, fromStatus, "requeued as "+workflow)
|
||||
taskID, fromStatus, "requeued "+workflow)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,10 @@ type AgentStage struct {
|
||||
MaxSteps int
|
||||
// ProtectPaths blocks write/edit on matching paths for this stage —
|
||||
// an environmental constraint, not a prompt rule (TDD's fix stage
|
||||
// protects the committed repro tests).
|
||||
ProtectPaths func(path string) bool
|
||||
// protects the committed repro tests; every builder stage protects
|
||||
// the repo's generated files). The returned matcher is combined
|
||||
// with the repo's configured protected suffixes.
|
||||
ProtectPaths func(*TaskContext) func(path string) bool
|
||||
// Extra adds stage-specific tools to the agent's toolset (e.g.
|
||||
// feasibility's decide tool).
|
||||
Extra func(*TaskContext) core.ToolSet
|
||||
@@ -75,6 +77,22 @@ func (a AgentStage) Stage() Stage {
|
||||
extra = a.Extra(tc)
|
||||
}
|
||||
|
||||
// Repo-configured protected suffixes (generated files) apply to
|
||||
// every writing stage; stage-specific matchers stack on top.
|
||||
var stageProtect func(string) bool
|
||||
if a.ProtectPaths != nil {
|
||||
stageProtect = a.ProtectPaths(tc)
|
||||
}
|
||||
protect := func(path string) bool {
|
||||
if tc.Repo.Protected(path) {
|
||||
return true
|
||||
}
|
||||
return stageProtect != nil && stageProtect(path)
|
||||
}
|
||||
if a.ReadOnly {
|
||||
protect = nil // nothing to protect from read-only tools
|
||||
}
|
||||
|
||||
res, err := agentloop.Run(ctx, agentloop.Config{
|
||||
Runtime: tc.Runtime,
|
||||
ModelRef: modelRef,
|
||||
@@ -88,7 +106,7 @@ func (a AgentStage) Stage() Stage {
|
||||
},
|
||||
Budget: budget,
|
||||
ReadOnly: a.ReadOnly,
|
||||
ProtectPaths: a.ProtectPaths,
|
||||
ProtectPaths: protect,
|
||||
Extra: extra,
|
||||
Logger: tc.Log.With("stage", a.Name, "model", modelRef),
|
||||
})
|
||||
|
||||
@@ -77,6 +77,8 @@ func Implement() Workflow {
|
||||
Gate: func(tc *TaskContext) agentloop.GateConfig {
|
||||
return GateFromRepo(tc.Repo, tc.Cfg.Budgets)
|
||||
},
|
||||
ExtraRules: "Files matching the repository's protected suffixes (e.g. generated code) are " +
|
||||
"write-blocked — edit their sources instead; the gate regenerates them.",
|
||||
Mission: func(tc *TaskContext) string {
|
||||
return fmt.Sprintf(
|
||||
"Implement this GitHub issue on the repository %s, following the plan below.\n\n"+
|
||||
|
||||
@@ -95,8 +95,8 @@ func TDD() Workflow {
|
||||
},
|
||||
// Environmental, not advisory: the fix stage cannot touch
|
||||
// test files at all — the committed repro is the spec.
|
||||
ProtectPaths: func(path string) bool {
|
||||
return strings.HasSuffix(path, "_test.go")
|
||||
ProtectPaths: func(*TaskContext) func(string) bool {
|
||||
return func(path string) bool { return strings.HasSuffix(path, "_test.go") }
|
||||
},
|
||||
ExtraRules: "The repro tests written in the previous stage are the bug's specification. " +
|
||||
"Test files are write-protected in this stage — make them pass by fixing the code they exercise.",
|
||||
|
||||
Reference in new issue
Block a user