Recheck runner authority before filing queued access requests
4 files changed,
+46
−7
.rastrillo/budgets.txt+1 −1internal/runner/thin/access.go+11 −5internal/runner/thin/access_test.go+33 −0internal/runner/thin/run.go+1 −1
CI failed — run details
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index 9dbf048b..7edf7198 100644 |
| --- a/.rastrillo/budgets.txt |
| +++ b/.rastrillo/budgets.txt |
| @@ -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 26812 19270 Shared runner state and forge integration; durable access polling, grants and restart guards. Limits match measured lines. |
| +size internal/runner/thin 26817 19303 Shared runner state and forge integration; durable access polling, grants and restart guards. Limits match measured lines. |
| 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/access.go b/internal/runner/thin/access.go| index 7fbd4290..828f0820 100644 |
| --- a/internal/runner/thin/access.go |
| +++ b/internal/runner/thin/access.go |
| @@ -41,11 +41,12 @@ func (s *State) AcceptAccess(ctx context.Context, frame string, c wire.AccessCom |
| } |
| type AccessEngine struct { |
| - State *State |
| - Forge AccessForge |
| - Refresh func() |
| - Notify func() |
| - Logger *slog.Logger |
| + Authorize func(context.Context) error |
| + State *State |
| + Forge AccessForge |
| + Refresh func() |
| + Notify func() |
| + Logger *slog.Logger |
| } |
| // Step files at most once. An interrupted POST has an uncertain outcome and |
| @@ -70,6 +71,11 @@ func (e *AccessEngine) Step(ctx context.Context, id string) error { |
| var err error |
| switch state { |
| case "queued": |
| + if e.Authorize != nil { |
| + if err := e.Authorize(ctx); err != nil { |
| + return err |
| + } |
| + } |
| if _, err = e.State.db.ExecContext(ctx, "UPDATE access_requests SET state='filing' WHERE card_id=?", id); err != nil { |
| return err |
| } |
diff --git a/internal/runner/thin/access_test.go b/internal/runner/thin/access_test.go| index 1234df4f..a7d55233 100644 |
| --- a/internal/runner/thin/access_test.go |
| +++ b/internal/runner/thin/access_test.go |
| @@ -341,3 +341,36 @@ func TestAccessExistingRequestMustMatchConfirmation(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +func TestAccessRunnerChecksCurrentAuthorityBeforeFiling(t *testing.T) { |
| + var calls atomic.Int32 |
| + f := accessForge(t, func(w http.ResponseWriter, r *http.Request) { calls.Add(1); w.WriteHeader(500) }) |
| + ctx := context.Background() |
| + s, err := OpenState(ctx, t.TempDir()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer s.Close() |
| + cmd := accessCommand() |
| + if err := s.AcceptAccess(ctx, "frame", cmd); err != nil { |
| + t.Fatal(err) |
| + } |
| + e := &AccessEngine{State: s, Forge: f, Authorize: func(context.Context) error { return errAccess }} |
| + if err := e.Step(ctx, cmd.CardID); err == nil { |
| + t.Fatal("stale authority permitted filing") |
| + } |
| + if calls.Load() != 0 { |
| + t.Fatal("revoked runner contacted forge") |
| + } |
| + var state string |
| + if err := s.db.QueryRow("SELECT state FROM access_requests").Scan(&state); err != nil || state != "queued" { |
| + t.Fatal(state, err) |
| + } |
| + e.Authorize = func(context.Context) error { return nil } |
| + if err := e.Step(ctx, cmd.CardID); err != nil { |
| + t.Fatal(err) |
| + } |
| + if calls.Load() != 1 { |
| + t.Fatal("current authority did not permit request") |
| + } |
| +} |
diff --git a/internal/runner/thin/run.go b/internal/runner/thin/run.go| index 3c537152..0b80b21e 100644 |
| --- a/internal/runner/thin/run.go |
| +++ b/internal/runner/thin/run.go |
| @@ -309,7 +309,7 @@ func Run(ctx context.Context, c runner.Config, o Options) error { |
| return nil |
| } |
| if af, ok := fg.(AccessForge); ok { |
| - link.Access = &AccessEngine{State: state, Forge: af, Refresh: func() { index.Kick(); link.HelloSoon() }, Notify: link.Notify, Logger: o.Logger} |
| + link.Access = &AccessEngine{State: state, Forge: af, Authorize: link.Confirm, Refresh: func() { index.Kick(); link.HelloSoon() }, Notify: link.Notify, Logger: o.Logger} |
| accessDone := make(chan struct{}) |
| go func() { defer close(accessDone); link.Access.Run(ctx) }() |
| defer func() { cancel(); <-accessDone }() |