control: make advisory review findings non-blocking and bound retryable blocks
Cut the review loop's repeat cost and make a blocked stage actionable, at the
definition level only, with the runner's existing visit counting and caps.
The published maintenance, quick and focused pipelines gain a reviewer
`advisory -> next stage` edge for non-blocking notes, so an advisory-only review
continues the run instead of buying another implementer visit; `rejected ->
implementer` and its unchanged {"max_visits":3,"on":["rejected"]} limit keep a
must-fix finding looping and still terminate. The implementer gains
blocked_retryable -> implementer with {"max_visits":5,"on":["blocked_retryable"]}
for a transient environment/tooling/device problem a fresh attempt could
survive, while blocked -> #failure stays terminal. The cap is at least the
reviewer's rejection budget so the implementer's own pre-execution cap cannot
preempt the reviewer's rejected control.
No production Go code changed. New tests in internal/server/review_contract_test.go
cover advisory-only never revisiting the implementer, must-fix still looping to
the reviewer limit, the implementer cap not preempting the reviewer, retryable
blocks bounded then failing closed, a retry that recovers, and a terminal block
failing immediately; concurrency/control/human tests share the new submitRunner
and startRun seams.
Documentation checked: internal/author/skill/references/control.md and
docs/harnesses-and-control.md carry the new edges and the visit-cap rule;
no packaged template defines these pipelines (they are published immutable
versions), and docs/model-results.md needs no change because the {outcome,output}
result contract is unchanged. README and other shared docs deliberately untouched.
Verified: go build ./... and go test -count=1 ./... pass.
Residual limitation: the must-fix-vs-advisory split is carried by the prompt
contract, not a machine-readable marker, because the recorded findings have none;
a model that still returns rejected for advisory-only notes would still buy a
visit. All 18 recorded implementer blocked runs classify terminal, so the
blocked_retryable edge recovers 0 of them.
This commit is contained in:
@@ -20,6 +20,46 @@ func concurrentStore(t *testing.T) (context.Context, *runner, int64) {
|
||||
return newConcurrentRunner(t, pipeline.Template([]string{"one"}, true))
|
||||
}
|
||||
|
||||
// submitRunner opens a fresh store, submits source through the parser and returns
|
||||
// the runner, its store and the pipeline id. Callers own the returned store's
|
||||
// lifetime and cleanup so tests can inspect persisted runs; newConcurrentRunner and
|
||||
// the review-contract tests share this setup instead of copying it.
|
||||
func submitRunner(t *testing.T, ctx context.Context, source string) (*runner, *pipeline.Store, int64) {
|
||||
t.Helper()
|
||||
store, err := pipeline.Open(filepath.Join(t.TempDir(), "test.db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := store.Submit(ctx, "test", source); err != nil {
|
||||
store.Close()
|
||||
t.Fatal(err)
|
||||
}
|
||||
items, err := store.List(ctx)
|
||||
if err != nil {
|
||||
store.Close()
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, err := newRunner(ctx, store)
|
||||
if err != nil {
|
||||
store.Close()
|
||||
t.Fatal(err)
|
||||
}
|
||||
return r, store, items[0].ID
|
||||
}
|
||||
|
||||
// startRun launches one run of a submitted pipeline and waits for it to stop,
|
||||
// returning the started run detail. It is the single start helper for tests that
|
||||
// only need a completed run.
|
||||
func startRun(t *testing.T, r *runner, pipelineID int64, key string) *protocol.RunDetail {
|
||||
t.Helper()
|
||||
run, err := r.start(protocol.Message{PipelineID: pipelineID, Version: 1, RequestKey: key, Workspace: t.TempDir(), Input: map[string]any{"prompt": "task"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.wg.Wait()
|
||||
return run
|
||||
}
|
||||
|
||||
// newConcurrentRunner builds the shared test store/runner around a submitted
|
||||
// pipeline source. Tests that need an agent stage (useAgent true) must pass a
|
||||
// source with a non-empty tools block: the default template's empty tools block
|
||||
@@ -28,34 +68,13 @@ func concurrentStore(t *testing.T) (context.Context, *runner, int64) {
|
||||
func newConcurrentRunner(t *testing.T, source string) (context.Context, *runner, int64) {
|
||||
t.Helper()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
store, err := pipeline.Open(filepath.Join(t.TempDir(), "concurrent.db"))
|
||||
if err != nil {
|
||||
cancel()
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := store.Submit(ctx, "test", source); err != nil {
|
||||
cancel()
|
||||
store.Close()
|
||||
t.Fatal(err)
|
||||
}
|
||||
items, err := store.List(ctx)
|
||||
if err != nil {
|
||||
cancel()
|
||||
store.Close()
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, err := newRunner(ctx, store)
|
||||
if err != nil {
|
||||
cancel()
|
||||
store.Close()
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, store, id := submitRunner(t, ctx, source)
|
||||
t.Cleanup(func() {
|
||||
cancel()
|
||||
r.wg.Wait()
|
||||
store.Close()
|
||||
})
|
||||
return ctx, r, items[0].ID
|
||||
return ctx, r, id
|
||||
}
|
||||
|
||||
// agentStore returns a runner whose pipeline has an agent stage (a non-empty,
|
||||
|
||||
Reference in New Issue
Block a user