oficina / equipo Public

fix: make the directlive fake driver reliable under load

The fake driver ran 19 serial tuples under one 360-second funded
context. Durable-write latency exhausted it, cascading into journal
uncertainty and empty Coordinator calibration. An isolated baseline
failed at 364.692s; the eight tail tuples passed alone at 207.482s.

Partition the matrix by role with fresh runtime state and funded
contexts after queueing. Limit all fake scenarios to three workers,
retain shared immutable builds and every observation assertion, and
check exact tuple coverage. Add deterministic queue and slot guards.

Two niced package runs passed in 205.194s and 171.207s. The latter used
sixteen nice-19 CPU workers and reached load 34.23. Retain the 360s
record and production deadlines. Vet, gofmt and staticcheck v0.7.0
pass; concurrency, release and coverage mutations fail as expected.
codex agent, operated by paul@keymail.dev pushed by claude agent, operated by paul@keymail.dev 1e2c5d4fcf854104868a10b243dec99ab1239b9a parent 6bf691b
5 files changed, +147 −19
  • .rastrillo/budgets.txt +1 −1
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +28 −0
  • internal/directlive/driver_fixture_test.go +27 −0
  • internal/directlive/driver_schedule_test.go +69 −0
  • internal/directlive/driver_test.go +22 −18

CI failed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index cb19dc99..db729bd2 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -25,7 +25,7 @@ size internal/runner 9500 8800 Task 17 fix round 1 adds authenticated terminal-l
time internal/runner/provider/claude 45s Task 5 measured 32.430s for fake CLI sessions and fsynced account, policy, capture and refresh checks; 45s gives 38 percent headroom on the shared runner.
time internal/runner/provider/codex 35s Plan 3 CI repair measured 24.464s for the full package (controller CI 27.908s). Independent policy subtests now run in parallel; 35s leaves 25 percent above the loaded CI measurement for schema, native approval and fsynced capture fixtures.
-time internal/directlive 360s Plan 3 CI repair measured 308.943s for the full package (controller CI 400.913s). Shared compiled fake drivers, removal of unused runner builds and independent parallel cases retain the 19-case matrix and coordinator failure isolation. Keep 360s with 16 percent headroom for namespaces, both adapters, journal and MCP probes.
+time internal/directlive 360s Directlive reliability repair measured full-package runs of 205.194s and 171.207s, the latter with sixteen nice-19 CPU workers and peak load 34.23. Ten role subtests retain all 19 tuples and their assertions, start fresh funded runs after queueing, and share a three-worker limit with coordinator variants. Keep 360s for durable journal, namespace, recovery and MCP coverage.
time internal/plan3test 300s Initial cap for combined browser and runner acceptance; measure at both usable stops.
size internal/plan3test - 11600 Task 21 adds the mandated 3b onboarding, terminal-login, device-answer, copy/API release and 0018/3a upgrade fixtures. Measured 11146 test lines; all package tests measured 103.643s against the unchanged 300s ceiling. Shared browser/runner fixtures remain in this integration package.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 4eb5ecd5..49db5cf6 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -5379,3 +5379,31 @@ The targeted plan-graph group fell from 146.920s to 30.784s locally; the Codex p
`make budget` passed (35 directories); `make migration-check` passed (0.171s). `CGO_ENABLED=0 go vet -tags browser,perf` and `CGO_ENABLED=0 go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf` passed on the six changed Go packages. `gofmt -l` returned no changed-file paths, and `git diff --check` passed. New app-owned copy keys: none.
The complete CI run remains the controller's responsibility. Containment is close to its default time ceiling (9.762s budget receipt); runner/directlive have 13/16 percent headroom. These are measured shared-machine times, not a guarantee against later load.
+
+
+## Task CI follow-up: directlive fake-driver reliability
+
+The isolated pre-fix `TestDirectDriverFakeCLI` failed in 364.692s (child 363.397s), this time in Codex Engineering, followed by the same journal and Coordinator calibration cascade. All 19 serial tuples shared one 360s funded context. Artifact timing and syscall sampling found substantial durable-write waiting. The four top-level scenarios already had independent contexts and runtime state; shared immutable builds were not the cause. `driver.go` is byte-identical to `6b17fa5^`.
+
+A diagnostic overlay ran only Investigation, Copy, Design and Coordinator with the original assertions. Both providers passed in 207.482s. Coordinator calibration had previously rejected an empty usage slice after deadline expiration, rather than an observed policy violation.
+
+The fix exposes ten named role subtests, each with fresh runtime state and a funded context started after acquiring one of three package-wide worker slots. Every original tuple and observation assertion remains. Exact index comparison and a separate 19-tuple inventory guard replace count-only coverage. The coordinator-only, fake live-mode and expected bad-Coordinator scenarios share the same gate.
+
+Commands below use the absolute package path `/home/paulca/amadan.net/oficina/equipo-plan-3/internal/directlive`, with `nice -n 10 env CGO_ENABLED=0 go test`, `-count=1`, and `-v`:
+
+| Test selection / mutation | Result |
+| --- | --- |
+| `-run '^TestDirectDriverFakeCLI$'`, original source | Exit 1, 364.692s; shared-deadline cascade |
+| `-run '^TestFakeDriverConcurrency$'`, before implementing the gate | Exit 1: started 4 workers, want 3 |
+| Same test, capacity mutated from 3 to 4 | Exit 1 with the same assertion; restored 3 |
+| Same test, release removed through a scratch overlay | Exit 1: synctest deadlock; overlay discarded |
+| `-run '^TestFakeDriverMatrix$'`, Investigation removed | Exit 1: both Investigation tuples missing; role restored |
+| `-run '^TestFakeDriver(Concurrency|Matrix)$'`, restored source | Exit 0, 0.091s |
+| Full package, run 1 | Exit 0, 205.194s; budget receipt 205.095s |
+| Full package, run 2 with sixteen nice-19 CPU workers | Exit 0, 171.207s; budget receipt 171.045s; peak one-minute load 34.23 |
+
+The load run recorded at least 20 in 30 of 35 five-second samples. All load workers were stopped and waited for. The unchanged 360s package record now contains these measurements. No test deadline or funding allowance was raised.
+
+`CGO_ENABLED=0 go vet` and `CGO_ENABLED=0 go run honnef.co/go/tools/cmd/staticcheck@v0.7.0` passed on the absolute package path. `gofmt -l` on that directory and `git diff --check` were clean. No production Go code changed and no app-owned runtime strings were added. Full CI remains the controller's work.
+
+Full report and retained evidence: `.superpowers/sdd/2026-11-04-equipo-plan-3-coordinator/dlfix-report.md` and its adjacent `dlfix-*.log` / `dlfix-load.json` files. No push, live provider run, agents, HANDOFF.md or review server.
diff --git a/internal/directlive/driver_fixture_test.go b/internal/directlive/driver_fixture_test.go
index 8e21a775..af8d35eb 100644
--- a/internal/directlive/driver_fixture_test.go
+++ b/internal/directlive/driver_fixture_test.go
@@ -107,3 +107,30 @@ func buildFakeDriver(badCoordinator bool) (root string, err error) {
}
return root, nil
}
+
+// All fake scenarios share this gate, including the coordinator variants.
+type fakeDriverGate chan struct{}
+
+func newFakeDriverGate() fakeDriverGate { return make(fakeDriverGate, 3) }
+
+func (g fakeDriverGate) acquire() func() {
+ g <- struct{}{}
+ return func() { <-g }
+}
+
+var fakeDriverWorkers = newFakeDriverGate()
+
+var fakeDriverRoles = []string{"Engineering", "Engineering-reproduction", "Review", "Product", "Scope", "Research", "Investigation", "Copy", "Design", "Coordinator"}
+
+func fakeDriverIndex(roles []string) []string {
+ var index []string
+ for _, family := range []string{"claude", "codex"} {
+ for _, role := range roles {
+ if family == "codex" && role == "Product" {
+ continue
+ }
+ index = append(index, family+"-"+role+"/certification.json")
+ }
+ }
+ return index
+}
diff --git a/internal/directlive/driver_schedule_test.go b/internal/directlive/driver_schedule_test.go
new file mode 100644
index 00000000..61f67d97
--- /dev/null
+++ b/internal/directlive/driver_schedule_test.go
@@ -0,0 +1,69 @@
+package directlive
+
+import (
+ "slices"
+ "sync"
+ "sync/atomic"
+ "testing"
+ "testing/synctest"
+)
+
+func TestFakeDriverConcurrency(t *testing.T) {
+ synctest.Test(t, func(t *testing.T) {
+ gate := newFakeDriverGate()
+ release := make(chan struct{})
+ var started atomic.Int32
+ var workers sync.WaitGroup
+ for range 4 {
+ workers.Go(func() {
+ defer gate.acquire()()
+ started.Add(1)
+ <-release
+ })
+ }
+ synctest.Wait()
+ if got := started.Load(); got != 3 {
+ t.Errorf("started %d fake drivers before a slot was released, want 3", got)
+ }
+ close(release)
+ workers.Wait()
+ if got := started.Load(); got != 4 {
+ t.Errorf("queued fake driver never ran: %d", got)
+ }
+ // A completed batch must release every slot for the next scenario.
+ var releases []func()
+ for range 3 {
+ releases = append(releases, gate.acquire())
+ }
+ for _, release := range releases {
+ release()
+ }
+ })
+}
+
+func TestFakeDriverMatrix(t *testing.T) {
+ want := []string{
+ "claude-Engineering/certification.json",
+ "claude-Engineering-reproduction/certification.json",
+ "claude-Review/certification.json",
+ "claude-Product/certification.json",
+ "claude-Scope/certification.json",
+ "claude-Research/certification.json",
+ "claude-Investigation/certification.json",
+ "claude-Copy/certification.json",
+ "claude-Design/certification.json",
+ "claude-Coordinator/certification.json",
+ "codex-Engineering/certification.json",
+ "codex-Engineering-reproduction/certification.json",
+ "codex-Review/certification.json",
+ "codex-Scope/certification.json",
+ "codex-Research/certification.json",
+ "codex-Investigation/certification.json",
+ "codex-Copy/certification.json",
+ "codex-Design/certification.json",
+ "codex-Coordinator/certification.json",
+ }
+ if got := fakeDriverIndex(fakeDriverRoles); !slices.Equal(got, want) {
+ t.Fatalf("fake driver matrix changed: got %v, want %v", got, want)
+ }
+}
diff --git a/internal/directlive/driver_test.go b/internal/directlive/driver_test.go
index c38ed9a8..fa2bfff5 100644
--- a/internal/directlive/driver_test.go
+++ b/internal/directlive/driver_test.go
@@ -12,6 +12,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "slices"
"strings"
"testing"
)
@@ -22,10 +23,18 @@ func TestCoordinatorToolAllowlistFakeCLI(t *testing.T) {
}
func TestDirectDriverFakeCLI(t *testing.T) {
t.Parallel()
- runFakeDriver(t, false)
+ // Start each role's funded run after it obtains a worker slot. A slow role
+ // must not consume the later roles' deadlines.
+ for _, role := range fakeDriverRoles {
+ t.Run(role, func(t *testing.T) {
+ t.Parallel()
+ runFakeDriver(t, false, "EQUIPO_FAKE_ROLE="+role)
+ })
+ }
}
func runFakeDriver(t *testing.T, badCoordinator bool, env ...string) {
t.Helper()
+ defer fakeDriverWorkers.acquire()()
fixture := fakeDriverBuild(t, badCoordinator)
root := t.TempDir()
for _, name := range []string{"claude", "codex", "codex-code-mode-host", "equipo-tool-proxy"} {
@@ -118,22 +127,24 @@ func TestDirectDriverFakeWorker(t *testing.T) {
original[path] = string(raw)
}
}
- runFixture := run
- if os.Getenv("EQUIPO_FAKE_COORDINATOR_ONLY") == "1" {
- runFixture = func(ctx context.Context, c provider.DirectLiveConfig, raw []byte, p Paths, source string, answer answerFunc, paths PolicyPaths) error {
- return runRoles(ctx, c, raw, p, source, answer, paths, []string{"Coordinator"})
+ roles := fakeDriverRoles
+ if role := os.Getenv("EQUIPO_FAKE_ROLE"); role != "" {
+ if !slices.Contains(fakeDriverRoles, role) {
+ t.Fatalf("unknown fake driver role %q", role)
}
+ roles = []string{role}
+ }
+ if os.Getenv("EQUIPO_FAKE_COORDINATOR_ONLY") == "1" {
+ roles = []string{"Coordinator"}
}
if os.Getenv("EQUIPO_FAKE_BAD_COORDINATOR") == "1" {
- runFixture = func(ctx context.Context, c provider.DirectLiveConfig, raw []byte, p Paths, source string, answer answerFunc, paths PolicyPaths) error {
- return runRoles(ctx, c, raw, p, source, answer, paths, []string{"Engineering", "Coordinator"})
- }
+ roles = []string{"Engineering", "Coordinator"}
}
source := "fake-cli"
if os.Getenv("EQUIPO_FAKE_LIVE_MODE") == "1" {
source = "direct-live"
}
- runErr := runFixture(context.Background(), c, marshal(c), p, source, answer, paths)
+ runErr := runRoles(context.Background(), c, marshal(c), p, source, answer, paths, roles)
if os.Getenv("EQUIPO_FAKE_BAD_COORDINATOR") == "1" {
var tuples *TupleFailures
if !errors.As(runErr, &tuples) || !strings.Contains(runErr.Error(), "codex-Coordinator") || strings.Contains(runErr.Error(), "Engineering") {
@@ -165,15 +176,8 @@ func TestDirectDriverFakeWorker(t *testing.T) {
t.Fatal(err)
}
var index []string
- want := 19
- if os.Getenv("EQUIPO_FAKE_COORDINATOR_ONLY") == "1" {
- want = 2
- }
- if os.Getenv("EQUIPO_FAKE_BAD_COORDINATOR") == "1" {
- want = 4
- }
- if json.Unmarshal(raw, &index) != nil || len(index) != want {
- t.Fatal("missing driver coverage")
+ if json.Unmarshal(raw, &index) != nil || !slices.Equal(index, fakeDriverIndex(roles)) {
+ t.Fatalf("driver coverage: got %v, want %v", index, fakeDriverIndex(roles))
}
for _, name := range index {
raw, err = os.ReadFile(filepath.Join(c.EvidenceDir, name))