Go and read the reply to a question Orchestra asked
F64. A plan mismatch that asks for a human decision blocks the task, and nothing came back. Two independent gaps, either one enough to strand it: the reconciler ran only before a lease and at a turn boundary, so a blocked task's reply was never even read, and ResumeAnsweredBlockers listed two block reasons, not this one. PlanMismatchAnswered had no caller anywhere. Blocked tasks awaiting a reply are now reconciled on their own loop, the same reasoning the submitted-work loop above it already uses: a task that cannot be leased cannot be reconciled behind a pre-lease hook. One predicate, BlockReasonAwaitsReply, now names the set for both loops so they cannot drift apart again. The existing test asserted the predicate and never the resume, which is how this survived. It asserts the resume now, and fails without the fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVbaKucEYBjMqVeUgJUsc1
This commit is contained in:
@@ -1831,6 +1831,25 @@ func main() {
|
|||||||
coordinator.ReconcileFailureHandoff = v
|
coordinator.ReconcileFailureHandoff = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// The third reconciliation point, and the same reasoning the submitted
|
||||||
|
// work loop above already uses: a blocked task cannot be leased, so a
|
||||||
|
// pre-lease hook can never see the reply that should unblock it (F64).
|
||||||
|
// Orchestra stopped and asked the human a question; nothing else here
|
||||||
|
// will go and read the answer.
|
||||||
|
go func() {
|
||||||
|
ticker := time.NewTicker(time.Minute)
|
||||||
|
defer ticker.Stop()
|
||||||
|
for range ticker.C {
|
||||||
|
for _, t := range s.Tasks() {
|
||||||
|
if t.State != domain.StateBlocked || !domain.BlockReasonAwaitsReply(t.BlockReason) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := reconciler.Reconcile(context.Background(), t.ID); err != nil {
|
||||||
|
log.Printf("reconcile blocked task %s: %v", t.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
if path := os.Getenv("ORCHESTRA_JSONL"); path != "" {
|
if path := os.Getenv("ORCHESTRA_JSONL"); path != "" {
|
||||||
sup := &provider.Supervisor{Name: "jsonl", Run: func(ctx context.Context) error {
|
sup := &provider.Supervisor{Name: "jsonl", Run: func(ctx context.Context) error {
|
||||||
|
|||||||
@@ -82,6 +82,23 @@ const (
|
|||||||
BlockReasonUnknown BlockReason = "unknown"
|
BlockReasonUnknown BlockReason = "unknown"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// BlockReasonAwaitsReply reports whether this stop is a question waiting on a
|
||||||
|
// human, rather than a fault or a budget. Every reason listed here resumes on
|
||||||
|
// a reply, so both the loop that goes and reads replies and the loop that
|
||||||
|
// returns answered tasks to the queue must agree on the set. They did not:
|
||||||
|
// plan_mismatch blocked for an answer that nothing ever went to fetch, and
|
||||||
|
// nothing would have resumed it if it had (F64).
|
||||||
|
//
|
||||||
|
// operator_required is deliberately absent. A task that has spent its question
|
||||||
|
// budget continues when an operator says so, not when someone replies.
|
||||||
|
func BlockReasonAwaitsReply(r BlockReason) bool {
|
||||||
|
switch r {
|
||||||
|
case BlockReasonHumanDecision, BlockReasonTrajectoryGate, BlockReasonPlanMismatch:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (r BlockReason) Valid() bool {
|
func (r BlockReason) Valid() bool {
|
||||||
switch r {
|
switch r {
|
||||||
case BlockReasonLeaseFailure, BlockReasonWorkerOffline, BlockReasonLeaseExpired,
|
case BlockReasonLeaseFailure, BlockReasonWorkerOffline, BlockReasonLeaseExpired,
|
||||||
|
|||||||
@@ -107,11 +107,9 @@ func ResumeAnsweredBlockers(s *store.Store) ([]domain.Event, error) {
|
|||||||
if t.State != domain.StateBlocked {
|
if t.State != domain.StateBlocked {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch t.BlockReason {
|
|
||||||
case domain.BlockReasonHumanDecision, domain.BlockReasonTrajectoryGate:
|
|
||||||
default:
|
|
||||||
// operator_required is deliberately not resumed by a reply. An
|
// operator_required is deliberately not resumed by a reply. An
|
||||||
// operator decides when a task that spent its budget continues.
|
// operator decides when a task that spent its budget continues.
|
||||||
|
if !domain.BlockReasonAwaitsReply(t.BlockReason) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !blockerAnswered(s, t.ID, t.BlockReason) {
|
if !blockerAnswered(s, t.ID, t.BlockReason) {
|
||||||
|
|||||||
@@ -215,7 +215,16 @@ func TestHumanAnswerResumesTheSamePlanWithoutResealing(t *testing.T) {
|
|||||||
if !PlanMismatchAnswered(s, id) {
|
if !PlanMismatchAnswered(s, id) {
|
||||||
t.Fatal("the human answered and the task is still waiting")
|
t.Fatal("the human answered and the task is still waiting")
|
||||||
}
|
}
|
||||||
|
// F64: asserting the predicate is not asserting the resume. This test
|
||||||
|
// passed for as long as the predicate had no caller, while a task blocked
|
||||||
|
// on a mismatch stayed blocked forever however the human replied.
|
||||||
|
if events, err := ResumeAnsweredBlockers(s); err != nil || len(events) != 1 {
|
||||||
|
t.Fatalf("an answered mismatch did not return to the queue: events=%v err=%v", events, err)
|
||||||
|
}
|
||||||
after, _ := s.Task(id)
|
after, _ := s.Task(id)
|
||||||
|
if after.State != domain.StateQueued {
|
||||||
|
t.Fatalf("state = %s after the human answered, want queued", after.State)
|
||||||
|
}
|
||||||
if after.PlanRef != planRef {
|
if after.PlanRef != planRef {
|
||||||
t.Fatal("answering the question replaced the plan")
|
t.Fatal("answering the question replaced the plan")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user