oficina / equipo Public

Queue unfinished work in a form every release reads safely

Astra round 4 on the branch (one P1, one P2):

- P1: a report of unfinished work (done, step_timeout) queued in the
  runner's outbox and replayed by a runner rolled back to an older
  release reached an older instance as finished work. The outbox now
  holds it as the step failing step_timeout, which every release reads
  safely; the attempt's row keeps that it was pushed (done,
  step_timeout, committed_unfinished, the candidate), and the sender
  restores the done report only for an instance at protocol 31.
- P2: cutting a long CI log dropped compiler diagnostics: lines in the
  "file.go:12:3: message" form and error words in any case are kept as
  failure lines now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 216458b6f5e8425828901c2295af1b1abef48e81 parent cd2f7a7
6 files changed, +127 −4
  • .rastrillo/budgets.txt +2 −2
  • internal/runner/thin/engineer_time_test.go +64 −0
  • internal/runner/thin/judge_hosted_test.go +12 −0
  • internal/runner/thin/link.go +5 −1
  • internal/runner/thin/step.go +35 −0
  • internal/wire/cilogs.go +9 −1
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index afe99bd3..6f752e60 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -15,7 +15,7 @@ time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial re
time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage.
size internal/equipo 22616 - Stuck tasks, merge_credential copy, no-access merges (2026-11-26); a timed-out step's pushed work on the timeline (2026-11-26); measured 22616 source lines.
-size internal/wire 7289 - Native task evidence, merge reasons (2026-11-26); protocol 31 unfinished work, shell_unavailable, CI unit logs (2026-11-26); measured 7289 source lines.
+size internal/wire 7297 - Native task evidence, merge reasons (2026-11-26); protocol 31 unfinished work, shell_unavailable, CI unit logs (2026-11-26); measured 7297 source lines.
size internal/equipotest - 12017 Task 21 repairs historical migration and conversation fixtures after Plan 3, and the Rastrillo upgrade contract comparing served assets with what Assets serves; measured 0/12017 source/test lines.
time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded);
time internal/runner 330s Plan 3 CI repair measured 292.120s for the full package (controller CI 472.184s).
@@ -38,7 +38,7 @@ time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full
perf GET /releases/* skip Verified runner release file downloads, not browser GET screens.
perf GET /install.sh skip Mac runners: the one-line bootstrap a terminal pipes to sh, not a browser screen.
time internal/runner/containment 15s Plan 3 loaded CI measured 10.817s;
-size internal/runner/thin 28914 23670 Protocol 30 tools, merge credential (2026-11-26); step limit, kept timed-out work, shell use, CI unit shares (2026-11-26); measured 28914/23670.
+size internal/runner/thin 28953 23746 Protocol 30 tools, merge credential (2026-11-26); step limit, kept timed-out work, shell use, CI unit shares (2026-11-26); measured 28953/23746.
time internal/thintest 240s Thin contract and page tests, the Assistant's and the models' included, share one harness. Measured 202s on a shared 16 CPU box (2026-11-13); CI runs two lanes.
time internal/runner/mac 30s Mac runners (Darwin worker): real process groups killed after a grace and proven gone (SIGTERM, SIGKILL, the marker sweep), and the probes run end to end with fake srt and xcodebuild, P6 killing.
time internal/runner/thin 45s Thin v1 slice 4 review: real git repositories for the merge and squash checks, a stalled fetch, and a 16 MiB candidate streamed through the review diff and the checks pack (about 5s).
diff --git a/internal/runner/thin/engineer_time_test.go b/internal/runner/thin/engineer_time_test.go
index b7fe475f..e22bf6e4 100644
--- a/internal/runner/thin/engineer_time_test.go
+++ b/internal/runner/thin/engineer_time_test.go
@@ -181,3 +181,67 @@ func TestUnfinishedPushFailureIsATimeout(t *testing.T) {
t.Fatalf("conflict: %+v", got)
}
}
+
+// Unfinished work is queued as the step failing step_timeout, which an
+// older runner replaying the outbox (rolled back) and an older instance
+// both read safely; the sender says it is done, pushed, to an instance
+// at ProtocolUnfinishedWork only. A plain timeout stays a timeout.
+func TestUnfinishedReportQueuedSafely(t *testing.T) {
+ e, _, r, _ := hubRig(t)
+ ctx := context.Background()
+ s := e.O.State
+ cand := strings.Repeat("2", 40)
+ r.Specialist, r.StepID = wire.SpecialistEngineering, "s9"
+ other := r
+ other.StepID, other.TaskID = "s10", "tk2"
+ r.StepID = "s9"
+ for _, d := range []stepRow{r, other} {
+ if err := s.AcceptDispatch(ctx, "d-"+d.StepID, d.DispatchCommand); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := s.setStepPhase(ctx, r, phaseCommittedUnfinished, "", cand); err != nil {
+ t.Fatal(err)
+ }
+ if err := s.ReportStep(ctx, r, wire.StepReport{TaskID: r.TaskID, StepID: "s9", Attempt: 1, State: wire.StepDone, Reason: "step_timeout", CandidateSHA: cand, Pushed: true, Termination: true, Findings: []wire.Finding{}}); err != nil {
+ t.Fatal(err)
+ }
+ if err := s.ReportStep(ctx, other, wire.StepReport{TaskID: other.TaskID, StepID: "s10", Attempt: 1, State: wire.StepFailed, Reason: "step_timeout", Termination: true, Findings: []wire.Finding{}}); err != nil {
+ t.Fatal(err)
+ }
+ frames, _, err := s.Unacked(ctx, 0)
+ if err != nil || len(frames) != 2 {
+ t.Fatalf("queued %d: %v", len(frames), err)
+ }
+ read := func(f wire.Frame) *wire.StepReport {
+ body, err := f.Decode()
+ if err != nil {
+ t.Fatal(err)
+ }
+ return body.(*wire.StepReport)
+ }
+ for _, f := range frames {
+ if v := read(f); v.State != wire.StepFailed || v.Reason != "step_timeout" || v.Pushed || v.CandidateSHA != "" {
+ t.Fatalf("queued as %+v", v)
+ }
+ }
+ for _, c := range []struct {
+ protocol int
+ step string
+ done bool
+ }{{wire.ProtocolUnfinishedWork, "s9", true}, {wire.ProtocolStuckTasks, "s9", false}, {wire.ProtocolUnfinishedWork, "s10", false}} {
+ for _, f := range frames {
+ if read(f).StepID != c.step {
+ continue
+ }
+ sent, err := s.unfinishedReport(ctx, f, c.protocol)
+ if err != nil {
+ t.Fatal(err)
+ }
+ v := read(sent)
+ if done := v.State == wire.StepDone && v.Pushed && v.CandidateSHA == cand && v.Reason == "step_timeout"; done != c.done || !c.done && v.State != wire.StepFailed {
+ t.Fatalf("%s at %d: %+v", c.step, c.protocol, v)
+ }
+ }
+ }
+}
diff --git a/internal/runner/thin/judge_hosted_test.go b/internal/runner/thin/judge_hosted_test.go
index f6f11fb7..aae5a87d 100644
--- a/internal/runner/thin/judge_hosted_test.go
+++ b/internal/runner/thin/judge_hosted_test.go
@@ -267,3 +267,15 @@ func TestFailedLogsBeyondTheNamedUnits(t *testing.T) {
}
}
}
+
+// A compiler's diagnostic early in a long log is kept when the log is
+// cut, at the runner's share and at the fix round's.
+func TestCIUnitsKeepDiagnostics(t *testing.T) {
+ log := "# amadan.net/oficina/equipo/internal/x\ninternal/x/x.go:12:3: undefined: bar\nbuild error: exit status 1\n" + shardLog(1, 30<<10)
+ for _, limit := range []int{1500, 8 << 10} {
+ out := wire.JoinCIUnits([]wire.CIUnit{{Name: "build", Log: log}}, limit)
+ if !strings.Contains(out, "internal/x/x.go:12:3: undefined: bar\n") || !strings.Contains(out, "build error: exit status 1\n") || len(out) > limit {
+ t.Fatalf("limit %d: %q", limit, out)
+ }
+ }
+}
diff --git a/internal/runner/thin/link.go b/internal/runner/thin/link.go
index 7f059679..b8eca8cc 100644
--- a/internal/runner/thin/link.go
+++ b/internal/runner/thin/link.go
@@ -487,7 +487,11 @@ func (l *Link) send(ctx context.Context, c *websocket.Conn, f wire.Frame) error
}
}
}
- f, err := wire.Encode(f, max(proto, wire.Protocol1))
+ f, err := l.State.unfinishedReport(ctx, f, proto)
+ if err != nil {
+ return err
+ }
+ f, err = wire.Encode(f, max(proto, wire.Protocol1))
if errors.Is(err, wire.ErrProtocol) {
if l.Logger != nil {
l.Logger.Warn("runner frame not sent at protocol 1", "type", f.Type)
diff --git a/internal/runner/thin/step.go b/internal/runner/thin/step.go
index 71a7e6a5..3e4fb165 100644
--- a/internal/runner/thin/step.go
+++ b/internal/runner/thin/step.go
@@ -234,10 +234,45 @@ func (s *State) ReportStep(ctx context.Context, r stepRow, rep wire.StepReport)
return nil
}
}
+ // Unfinished work is queued as the step failing step_timeout,
+ // which any instance, and a runner rolled back to an older
+ // release replaying this outbox, reads safely; the attempt's row
+ // keeps that it was pushed, and the sender says so to an instance
+ // that knows unfinished work (unfinishedReport).
+ wire.WithoutUnfinished(&rep)
return s.enqueue(t, wire.FrameStep, "", rep)
})
}
+// unfinishedReport is a queued step report as the sender sends it at
+// protocol: at ProtocolUnfinishedWork or later, a step that failed
+// step_timeout whose attempt pushed its unfinished work (its row: done,
+// step_timeout, phase committed_unfinished, the candidate) is that work,
+// done with the reason step_timeout. Any other frame is unchanged.
+func (s *State) unfinishedReport(ctx context.Context, f wire.Frame, protocol int) (wire.Frame, error) {
+ if f.Type != wire.FrameStep || protocol < wire.ProtocolUnfinishedWork {
+ return f, nil
+ }
+ body, err := f.Decode()
+ if err != nil {
+ return f, err
+ }
+ rep, ok := body.(*wire.StepReport)
+ if !ok || rep.State != wire.StepFailed || rep.Reason != "step_timeout" || !rep.Termination {
+ return f, nil
+ }
+ var state, reason, phase, candidate string
+ err = s.db.QueryRowContext(ctx, "SELECT coalesce(final_state, ''), coalesce(final_reason, ''), phase, candidate_sha FROM steps WHERE step_id=? AND attempt=?", rep.StepID, rep.Attempt).Scan(&state, &reason, &phase, &candidate)
+ if errors.Is(err, sql.ErrNoRows) || err == nil && (state != wire.StepDone || reason != "step_timeout" || phase != phaseCommittedUnfinished || candidate == "") {
+ return f, nil
+ }
+ if err != nil {
+ return f, err
+ }
+ rep.State, rep.Pushed, rep.CandidateSHA = wire.StepDone, true, candidate
+ return wire.NewFrame(f.ID, f.Type, rep)
+}
+
// advanceStep moves a running step to its next attempt after the
// provider refused this one (quota or credential) and its exit was
// proven (spec §3, Engineering mid-step): durably, before anything runs
diff --git a/internal/wire/cilogs.go b/internal/wire/cilogs.go
index b59b68da..584fbb62 100644
--- a/internal/wire/cilogs.go
+++ b/internal/wire/cilogs.go
@@ -1,6 +1,7 @@
package wire
import (
+ "regexp"
"sort"
"strings"
)
@@ -138,9 +139,16 @@ func clipCILog(log string, n int) string {
// usual error words).
func ciFailure(line string) bool {
t := strings.TrimSpace(line)
- return strings.HasPrefix(t, "--- FAIL") || strings.HasPrefix(t, "FAIL") || strings.HasPrefix(t, "panic:") || strings.Contains(t, "Error")
+ return strings.HasPrefix(t, "--- FAIL") || strings.HasPrefix(t, "FAIL") || strings.HasPrefix(t, "panic:") || ciError.MatchString(t) || ciDiagnostic.MatchString(t)
}
+// ciError is an error word in any case; ciDiagnostic a compiler's or
+// checker's "file.go:12:3: message" (and a test's "x_test.go:12: ...").
+var (
+ ciError = regexp.MustCompile(`(?i)\berror\b`)
+ ciDiagnostic = regexp.MustCompile(`^[^\s:]+\.[A-Za-z0-9]+:\d+(:\d+)?: `)
+)
+
// tailLines is the end of s within limit bytes, starting on a line.
func tailLines(s string, limit int) string {
if limit <= 0 {