oficina / equipo Public

runner: enrolment waits out server errors and says why

Paul's Studio install polled staging for eight minutes unapproved, then
one 5xx on the token poll ended it with only "Runner installation is
unavailable."; the instance did not log the 503 either.

Enrol now waits out no answer, 5xx and 429 with backoff until the code
expires (the protocol question and the start are tried four times),
tells expired from turned down, drops a used code, and reports through
Config.EnrolNotify. Both installers print "Waiting for you to
approve…", each retry with its cause, and why it ended, on stderr and
in the install log. The device routes log server errors. New copy
accepted for now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 0285479bf7070aea02f82c5c3b6534b04b4f8c58 parent 87da2e3
16 files changed, +627 −15
  • .rastrillo/budgets.txt +1 −1
  • cmd/equipo-runner/enrol_report.go +60 −0
  • cmd/equipo-runner/install.go +4 −1
  • cmd/equipo-runner/install_mac.go +4 −1
  • cmd/equipo-runner/install_mac_test.go +41 −0
  • docs/mac-runner.md +14 −2
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +6 −0
  • docs/superpowers/plans/DARWIN-PROGRESS.md +41 −1
  • internal/equipo/copy.go +11 −0
  • internal/equipo/runner_handlers.go +19 −3
  • internal/equipotest/enrolment_link_test.go +67 −0
  • internal/runner/config.go +3 −0
  • internal/runner/diagnostics.go +4 −0
  • internal/runner/enrol.go +163 −6
  • internal/runner/enrol_wait_test.go +168 −0
  • scripts/runner-reference-allowlist.json +21 −0

CI passed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index acff89de..12eca6f3 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -20,7 +20,7 @@ time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded); 60s
time internal/runner 330s Plan 3 CI repair measured 292.120s for the full package (controller CI 472.184s). Parallel plan graphs and removal of repeated progress floods reduced their local targeted run from 146.920s to 30.784s; the original bug graph retains volume coverage. Keep 330s for journal, proxy, recovery and namespace integration, with 13 percent headroom.
perf GET /api/runner/v2/artifacts/{assignment}/{artifact} skip Authenticated runner artifact download, not a browser GET screen. Runner long-poll and blob downloads use POST and are outside the screen inventory.
-size internal/runner 9750 9050 Mac runners (Darwin worker) add the darwin clock, peer credential and walk shims, the worker-only enrolment flag and its role check, and their tests; measured 9689 source and 8960 test lines. Mac runners (slices A and B) add the worker enrolment check (enrol.go) and its test. Thin v1 slice 1 exports helpers for internal/runner/thin beside the old runtime its slice 7 sweep deletes; lower then. Task 17 fix round 1 adds authenticated terminal-login composition and saved-report recovery beside the existing runner journal and state lock. Measured 9421 source and 8719 test lines. Login lifecycle, subprocess handling and environment parsing stay in setup/provider; the 100-line source raise retains only production HTTP/config wiring here. Existing test and 330s time ceilings are unchanged.
+size internal/runner 9900 9200 Mac runners (Darwin worker) make enrolment wait out server errors and say why it ended (expired, turned down, the failure in words) for both installers, and its tests; measured 9874 source and 9128 test lines. Mac runners (Darwin worker) add the darwin clock, peer credential and walk shims, the worker-only enrolment flag and its role check, and their tests; measured 9689 source and 8960 test lines. Mac runners (slices A and B) add the worker enrolment check (enrol.go) and its test. Thin v1 slice 1 exports helpers for internal/runner/thin beside the old runtime its slice 7 sweep deletes; lower then. Task 17 fix round 1 adds authenticated terminal-login composition and saved-report recovery beside the existing runner journal and state lock. Measured 9421 source and 8719 test lines. Login lifecycle, subprocess handling and environment parsing stay in setup/provider; the 100-line source raise retains only production HTTP/config wiring here. Existing test and 330s time ceilings are unchanged.
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.
diff --git a/cmd/equipo-runner/enrol_report.go b/cmd/equipo-runner/enrol_report.go
new file mode 100644
index 00000000..a2f3095e
--- /dev/null
+++ b/cmd/equipo-runner/enrol_report.go
@@ -0,0 +1,60 @@
+package main
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo"
+ "amadan.net/oficina/equipo/internal/runner"
+)
+
+// enrolReport tells the person how enrolment is going and keeps the same
+// lines in the install log (log; "" keeps none): one quiet line while it
+// waits for approval, each failure it waits out, and at the end what went
+// wrong in words. Details carry no secrets (runner.EnrolDetail).
+type enrolReport struct {
+ errout io.Writer
+ log string
+}
+
+func (r enrolReport) say(key string, a ...any) {
+ line := fmt.Sprintf(equipo.RunnerSetupCopy(key), a...)
+ fmt.Fprintln(r.errout, line)
+ if r.log == "" {
+ return
+ }
+ if f, err := os.OpenFile(r.log, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0600); err == nil {
+ fmt.Fprintf(f, "%s %s\n", time.Now().UTC().Format(time.RFC3339), line)
+ f.Close()
+ }
+}
+
+func (r enrolReport) notify(n runner.EnrolNotice) {
+ if n.Waiting {
+ r.say("runner.enrol.waiting")
+ }
+ if n.Retry != nil {
+ r.say("runner.enrol.retrying", runner.EnrolDetail(n.Retry))
+ }
+}
+
+// failed says why enrolment ended; "Runner installation is unavailable."
+// never comes alone.
+func (r enrolReport) failed(err error) {
+ switch {
+ case errors.Is(err, runner.ErrEnrolmentExpired):
+ r.say("runner.enrol.expired")
+ case errors.Is(err, runner.ErrEnrolmentRefused):
+ r.say("runner.enrol.refused")
+ default:
+ detail := runner.EnrolDetail(err)
+ if detail == "" {
+ detail = "unknown"
+ }
+ r.say("runner.enrol.failed", detail)
+ r.say("runner.install.unavailable")
+ }
+}
diff --git a/cmd/equipo-runner/install.go b/cmd/equipo-runner/install.go
index 1eef13c8..fbb8b810 100644
--- a/cmd/equipo-runner/install.go
+++ b/cmd/equipo-runner/install.go
@@ -63,8 +63,11 @@ func installRunner(ctx context.Context, args []string, input io.Reader, out, err
return fail("runner.install.release")
}
cfg.MachineLabel = label
+ report := enrolReport{errout: errout, log: filepath.Join(*root, "install.log")}
+ cfg.EnrolNotify = report.notify
if e = runner.Enrol(ctx, cfg, out); e != nil {
- return fail("runner.install.unavailable")
+ report.failed(e)
+ return 1
}
// Use the already configured environment file. Never copy the invoking
// process's environment (which may contain credentials) into service metadata.
diff --git a/cmd/equipo-runner/install_mac.go b/cmd/equipo-runner/install_mac.go
index f0142029..cdbe46f6 100644
--- a/cmd/equipo-runner/install_mac.go
+++ b/cmd/equipo-runner/install_mac.go
@@ -204,11 +204,14 @@ func installMac(ctx context.Context, args []string, h macInstallHost, out, errou
}
cfg := runner.Config{Origin: *origin, InstanceID: *instance, StateDir: values["EQUIPO_RUNNER_STATE_DIR"], WorkspaceRoot: values["EQUIPO_WORKSPACE_ROOT"], ScratchRoot: values["EQUIPO_SCRATCH_ROOT"], GitPath: values["EQUIPO_GIT_PATH"], MachineLabel: label, Executable: binary, WorkerOnly: true}
say("runner.mac.tap")
+ report := enrolReport{errout: errout, log: filepath.Join(logs, "install.log")}
+ cfg.EnrolNotify = report.notify
if err := h.enrol(ctx, cfg, out); err != nil {
if errors.Is(err, runner.ErrEnrolledAsPrimary) {
return fail("runner.needs_primary")
}
- return fail("runner.install.unavailable")
+ report.failed(err)
+ return 1
}
plist := filepath.Join(agents, mac.AgentLabel+".plist")
if err := os.WriteFile(plist, mac.LaunchAgent(binary, envFile, logs), 0644); err != nil {
diff --git a/cmd/equipo-runner/install_mac_test.go b/cmd/equipo-runner/install_mac_test.go
index a2e4de77..79bf5593 100644
--- a/cmd/equipo-runner/install_mac_test.go
+++ b/cmd/equipo-runner/install_mac_test.go
@@ -458,3 +458,44 @@ func TestInstallMacIgnoresInheritedHome(t *testing.T) {
t.Fatalf("env %v", env)
}
}
+
+// Enrolment says how it is going: a quiet line while it waits, each
+// failure it waits out, and at the end why it stopped, in words, on
+// stderr and in the install log. "Runner installation is unavailable."
+// never comes alone.
+func TestInstallMacEnrolmentInWords(t *testing.T) {
+ unavailable := equipo.RunnerSetupCopy("runner.install.unavailable")
+ for name, c := range map[string]struct {
+ err error
+ want []string
+ bare bool
+ }{
+ "expired": {runner.ErrEnrolmentExpired, []string{"The link expired before it was approved. Run the install command again for a new link."}, false},
+ "turned down": {runner.ErrEnrolmentRefused, []string{"Equipo turned this link down, so this machine was not added. Run the install command again for a new link."}, false},
+ "server": {&runner.EnrolAnswerError{Status: 503, Key: "service.unavailable"}, []string{"Adding this machine to Equipo failed: Equipo answered HTTP 503 (service.unavailable)", unavailable}, true},
+ } {
+ t.Run(name, func(t *testing.T) {
+ x := newMacRig(t)
+ x.h.enrol = func(_ context.Context, cfg runner.Config, out io.Writer) error {
+ _, _ = io.WriteString(out, "[https://equipo.example/runners/enrol?code=ABCDEFGHJK](https://equipo.example/runners/enrol?code=ABCDEFGHJK)\nABCDEFGHJK\n")
+ cfg.EnrolNotify(runner.EnrolNotice{Waiting: true})
+ cfg.EnrolNotify(runner.EnrolNotice{Retry: &runner.EnrolAnswerError{Status: 502}})
+ return c.err
+ }
+ code, _, errout := x.install()
+ want := "Waiting for you to approve…\nEquipo did not answer properly (Equipo answered HTTP 502). Trying again.\n" + strings.Join(c.want, "\n") + "\n"
+ if code != 1 || !strings.HasSuffix(errout, want) {
+ t.Fatalf("%d %q", code, errout)
+ }
+ if !c.bare && strings.Contains(errout, unavailable) {
+ t.Fatal("the bare unavailable line")
+ }
+ log, _ := os.ReadFile(filepath.Join(x.home, "Library/Logs/equipo-runner/install.log"))
+ for _, line := range append([]string{"Waiting for you to approve…", "Equipo answered HTTP 502"}, c.want...) {
+ if !strings.Contains(string(log), line) {
+ t.Fatalf("install log lacks %q:\n%s", line, log)
+ }
+ }
+ })
+ }
+}
diff --git a/docs/mac-runner.md b/docs/mac-runner.md
index e58c97e0..2f2ca07e 100644
--- a/docs/mac-runner.md
+++ b/docs/mac-runner.md
@@ -34,8 +34,13 @@ You do this once per person, on the Mac, as an administrator.
curl -fsSL https://equipo-staging.bds.oncarlos.com/install.sh | sh
```
- It prints a link. Open it on your phone or any signed-in browser and
- tap the button to add the Mac to your team. That's all.
+ It prints a link, then "Waiting for you to approve…". Open the link
+ on your phone or any signed-in browser and tap the button to add the
+ Mac to your team within ten minutes. That's all. If Equipo is slow to
+ answer, the installer says so and keeps trying on its own.
+
+ You can also install from your own account's Terminal with
+ `sudo -iu paulequipo`, as long as `paulequipo` is logged in.
After that the Mac checks itself (it tries to break out of its own
sandbox and makes sure it can't) and then waits for work. You can see
@@ -64,6 +69,13 @@ what it found in Equipo under Connections, Machines.
you logged in as yourself too), leave it logged in, then paste the
command again. Installing from a Terminal with `sudo -iu paulequipo`
works once that session exists.
+- **"The link expired before it was approved"** or **"Equipo turned
+ this link down"**: paste the install command again for a new link,
+ and tap it within ten minutes.
+- **"Adding this machine to Equipo failed"**: the message says what
+ went wrong, and the same lines are kept in
+ `~/Library/Logs/equipo-runner/install.log`. Paste the install command
+ again; if it fails the same way, send that file along.
- **"The checks sandbox could not be downloaded and installed"**: the
Mac still works, but its checks run outside the sandbox and say so.
Paste the install command again when the network is back. The
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 3a599446..43326e42 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -4724,6 +4724,7 @@ records remain unchanged.
| `conversation.age_minutes` | %d min | Chat UI round 2 | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `copyInvalidDatabase` | EQUIPO_DATABASE must be a file name like equipo-v1.db. | Thin v1 slice 1 cutover | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `copyChatSweep` | Could not clear old conversation events. | Thin v1 slice 1 (log line) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `copyRunnerAPIFailed` | A runner request failed on the server. | Mac runners (Darwin worker) (log line) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `chat.offline` | Your runner is offline. Messages wait here until it is back. | Thin v1 slice 1 chat page | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `chat.failed` | The coordinator could not answer this message. | Thin v1 slice 1 chat page | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `chat.cancelled` | Stopped. | Thin v1 slice 1 chat page | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
@@ -5814,6 +5815,11 @@ records remain unchanged.
| `runner.mac.admin` | This Mac user is an administrator. Run the installer as a Standard user with 'equipo' in its account name. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `runner.mac.user` | Equipo runs in its own Mac user so it can't reach your files. Create a Standard user with 'equipo' in its account name, then run this again. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `runner.mac.home` | This user can get into another person's home folder (%[1]s). An administrator can close it with: sudo chmod +a "%[2]s deny list,search,readattr,readextattr,readsecurity" %[1]s (to undo it: sudo chmod -a "%[2]s deny list,search,readattr,readextattr,readsecurity" %[1]s) | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `runner.enrol.waiting` | Waiting for you to approve… | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `runner.enrol.retrying` | Equipo did not answer properly (%s). Trying again. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `runner.enrol.expired` | The link expired before it was approved. Run the install command again for a new link. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `runner.enrol.refused` | Equipo turned this link down, so this machine was not added. Run the install command again for a new link. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `runner.enrol.failed` | Adding this machine to Equipo failed: %s | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `runner.mac.not_logged_in` | Log in as %s on this Mac (fast user switching) and keep it logged in, then run this again. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `runner.mac.homes_unknown` | Equipo could not check the other home folders on this Mac, so it stopped. Ask an administrator to check that /Users can be listed, then paste the command again. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `runner.tainted` | A check has run outside the sandbox on this Mac, so its checks are always labelled that way from now on. To start clean, install the runner again as a new Mac user. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
diff --git a/docs/superpowers/plans/DARWIN-PROGRESS.md b/docs/superpowers/plans/DARWIN-PROGRESS.md
index 193ada08..c91532ce 100644
--- a/docs/superpowers/plans/DARWIN-PROGRESS.md
+++ b/docs/superpowers/plans/DARWIN-PROGRESS.md
@@ -325,11 +325,51 @@ anything from the environment:
list, pass through and open a file in each home and counts only
permission denied as closed.
+## Enrolment that waits and says why (2026-11-10)
+
+Paul's install printed the link (H0SNVFN19S), polled staging from 11:58
+to 12:06 UTC, then ended on "Runner installation is unavailable." The
+enrolment row shows it was never approved (no page load or approve POST
+after 11:58; last good poll 12:06:23). The next poll, at 12:06:28, got a
+5xx; any answer other than 200 or 409 ended `runner.Enrol`, and neither
+the instance (no log line for a 503 to a device) nor the installer (the
+bare unavailable line) said what it was. The approval path itself works
+for a Mac joining a person with a Linux primary
+(`TestMacEnrolmentApprovedAfterAPrimary`).
+
+- `runner.Enrol` waits out no answer, 5xx and 429, backing off from the
+ poll interval up to a minute, until the code expires; the protocol
+ question and the start of the enrolment are tried up to four times. A
+ 5xx on the protocol question is no longer "the instance is older".
+- 403 is "expired" within a minute of the code's expiry, "turned down"
+ otherwise; running out is "expired", unless it was still failing,
+ which is reported as that failure. Expired or turned down, the saved
+ code is dropped so the next run gets a new link.
+- `Config.EnrolNotify` hears "waiting" once and each retry; both
+ installers print "Waiting for you to approve…", each retry with its
+ cause, and at the end the expiry, the refusal or "Adding this machine
+ to Equipo failed: <cause>" before the unavailable line; the same lines
+ go to the install log (`~/Library/Logs/equipo-runner/install.log` on a
+ Mac, `install.log` in the runner root on Linux). Causes are the HTTP
+ status and error key or the network error: never a body.
+- The instance logs a server error on the two device routes, with the
+ route and the error (`TestEnrolmentServerErrorIsLogged`).
+- Tests: `TestEnrolWaitsOutTransientFailures`, `TestEnrolEndsInWords`,
+ `TestInstallMacEnrolmentInWords`. Mutations shown failing: transient
+ never retried, a 5xx protocol answer taken as older, turned down
+ reported as expired, the used code kept, the last failure hidden by
+ expiry.
+- Open: the approve button's confirmation lasts five minutes, the code
+ ten. Tapping a page opened more than five minutes earlier is refused
+ ("You do not have access to this page"); opening the link again
+ works.
+
## Copy for review
All marked COPY ACCEPTED FOR NOW and listed in the plan 3 inventory:
`runner.mac.*` (installer lines, `runner.mac.not_logged_in` and the
-ACL wording of `runner.mac.home` added 2026-11-10), `runner.add_title` ("Add %s to your
+ACL wording of `runner.mac.home` and `runner.enrol.*` added
+2026-11-10), `runner.add_title` ("Add %s to your
team"), the runners view (`runner.platform`, `runner.checks_run`,
`runner.sandbox.*`, `runner.probes`, `runner.probe.P1` to `P7`,
`runner.verdict.*`), `work.checks.outside_sandbox` ("%s, ran outside
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 7c8190f1..75fe6b2d 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -40,6 +40,7 @@ const (
copyNonceSweep = "Could not clear expired form tokens."
copyInvalidDatabase = "EQUIPO_DATABASE must be a file name like equipo-v1.db." // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
copyChatSweep = "Could not clear old conversation events." // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ copyRunnerAPIFailed = "A runner request failed on the server." // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
copyMigrate = "Apply migrations."
copyTidyFailed = "Tidy duplicate tasks."
copyTidied = "Combined duplicate tasks."
@@ -269,6 +270,16 @@ var pageCopy = map[string]string{
"runner.mac.user": "Equipo runs in its own Mac user so it can't reach your files. Create a Standard user with 'equipo' in its account name, then run this again.",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.home
"runner.mac.home": "This user can get into another person's home folder (%[1]s). An administrator can close it with: sudo chmod +a \"%[2]s deny list,search,readattr,readextattr,readsecurity\" %[1]s (to undo it: sudo chmod -a \"%[2]s deny list,search,readattr,readextattr,readsecurity\" %[1]s)",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.enrol.waiting
+ "runner.enrol.waiting": "Waiting for you to approve…",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.enrol.retrying
+ "runner.enrol.retrying": "Equipo did not answer properly (%s). Trying again.",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.enrol.expired
+ "runner.enrol.expired": "The link expired before it was approved. Run the install command again for a new link.",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.enrol.refused
+ "runner.enrol.refused": "Equipo turned this link down, so this machine was not added. Run the install command again for a new link.",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.enrol.failed
+ "runner.enrol.failed": "Adding this machine to Equipo failed: %s",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.not_logged_in
"runner.mac.not_logged_in": "Log in as %s on this Mac (fast user switching) and keep it logged in, then run this again.",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.homes_unknown
diff --git a/internal/equipo/runner_handlers.go b/internal/equipo/runner_handlers.go
index d01d4e4f..9edf7427 100644
--- a/internal/equipo/runner_handlers.go
+++ b/internal/equipo/runner_handlers.go
@@ -30,6 +30,22 @@ func runnerJSON(w http.ResponseWriter, status int, value any) {
_, _ = w.Write(append(data, '\n'))
}
func runnerFailure(w http.ResponseWriter, err error) {
+ status, key := runnerStatus(w, err)
+ runnerJSON(w, status, runnerproto.ErrorResponse{Version: 2, Error: key})
+}
+
+// deviceFailure is runnerFailure for a machine enrolling, which has no
+// other way to say what went wrong: a server error is logged, with the
+// route and the error (never the request body, which holds the secret).
+func (a *application) deviceFailure(w http.ResponseWriter, r *http.Request, err error) {
+ status, key := runnerStatus(w, err)
+ if status >= 500 && a.logger != nil {
+ a.logger.Warn(copyRunnerAPIFailed, "route", r.URL.Path, "status", status, "err", err)
+ }
+ runnerJSON(w, status, runnerproto.ErrorResponse{Version: 2, Error: key})
+}
+
+func runnerStatus(w http.ResponseWriter, err error) (int, string) {
status, key := 503, "service.unavailable"
switch {
case errors.Is(err, ErrRunnerRateLimited):
@@ -56,7 +72,7 @@ func runnerFailure(w http.ResponseWriter, err error) {
case errors.Is(err, ErrConflict), errors.Is(err, team.ErrConflict), errors.Is(err, team.ErrRevision), errors.Is(err, team.ErrState), errors.Is(err, team.ErrDependency), errors.Is(err, team.ErrWorkspace), errors.Is(err, team.ErrReceiptConflict):
status, key = 409, "form.conflict"
}
- runnerJSON(w, status, runnerproto.ErrorResponse{Version: 2, Error: key})
+ return status, key
}
func (a *application) RequireRunner(next http.Handler) http.Handler {
@@ -101,7 +117,7 @@ func (a *application) beginEnrolment(w http.ResponseWriter, r *http.Request) {
}
result, err := a.store.BeginEnrolment(r.Context(), input.MachinePublicKey, input.Label, input.WorkerOnly)
if err != nil {
- runnerFailure(w, err)
+ a.deviceFailure(w, r, err)
return
}
result.VerificationURI = a.origin + "/runners/enrol"
@@ -118,7 +134,7 @@ func (a *application) exchangeEnrolment(w http.ResponseWriter, r *http.Request)
}
result, err := a.store.ExchangeEnrolment(r.Context(), input.DeviceSecret, input.Proof)
if err != nil {
- runnerFailure(w, err)
+ a.deviceFailure(w, r, err)
return
}
runnerJSON(w, http.StatusOK, result)
diff --git a/internal/equipotest/enrolment_link_test.go b/internal/equipotest/enrolment_link_test.go
index 2038a474..a486a161 100644
--- a/internal/equipotest/enrolment_link_test.go
+++ b/internal/equipotest/enrolment_link_test.go
@@ -7,6 +7,7 @@ import (
"testing"
"amadan.net/oficina/equipo/internal/runnerproto"
+ "amadan.net/oficina/equipo/internal/wire"
)
// One tap (Mac runners spec §1.1): the link a runner prints carries its
@@ -88,3 +89,69 @@ func TestMacEnrolmentNeedsAPrimary(t *testing.T) {
t.Fatal("a Mac not offered once there is a primary")
}
}
+
+// Paul's Studio, 2026-11-10: a Mac joins a person who already has a
+// Linux primary. Approved through the page, its exchange gives it a
+// worker's credential; nothing on the way answers with a server error.
+func TestMacEnrolmentApprovedAfterAPrimary(t *testing.T) {
+ f := newEnrolHTTP(t)
+ c := signinClient(t, f.server.URL)
+ signinEmail(t, c, f.server.URL, testOrigin, f.mail, ownerAddress)
+ enrol := func(label string, worker bool) runnerproto.RunnerCredential {
+ t.Helper()
+ pub, key := machine(t)
+ status, body := enrolJSON(t, f.server.Client(), f.server.URL+"/api/enrolments", runnerproto.BeginEnrolmentRequest{Version: 1, MachinePublicKey: pub, Label: label, WorkerOnly: worker}, "")
+ if status != 201 {
+ t.Fatalf("begin HTTP: %d %s", status, body)
+ }
+ var code runnerproto.DeviceCode
+ if err := json.Unmarshal(body, &code); err != nil {
+ t.Fatal(err)
+ }
+ view := taskGet(t, c, f.server.URL, "/runners/enrol?code="+url.QueryEscape(code.UserCode), 200)
+ pagePost(t, c, f.server.URL, "/runners/enrol", testOrigin, formFields(t, view, "/runners/enrol"), 303)
+ status, body = enrolJSON(t, f.server.Client(), f.server.URL+"/api/enrolments/token", runnerproto.ExchangeEnrolmentRequest{Version: 1, DeviceSecret: code.DeviceSecret, Proof: deviceProof(code, key)}, "")
+ if status != 200 {
+ t.Fatalf("%s exchange: %d %s", label, status, body)
+ }
+ var cred runnerproto.RunnerCredential
+ if err := json.Unmarshal(body, &cred); err != nil {
+ t.Fatal(err)
+ }
+ return cred
+ }
+ if cred := enrol("docs-t1", false); cred.Role == wire.RoleWorker {
+ t.Fatal("the first runner is not the primary")
+ }
+ if cred := enrol("Tito Studio", true); cred.Role != wire.RoleWorker {
+ t.Fatalf("the Mac enrolled as %q", cred.Role)
+ }
+}
+
+// A machine enrolling cannot say what went wrong on the server, so the
+// server logs it: the route and the error, never the device secret.
+func TestEnrolmentServerErrorIsLogged(t *testing.T) {
+ f := newEnrolHTTP(t)
+ pub, key := machine(t)
+ status, body := enrolJSON(t, f.server.Client(), f.server.URL+"/api/enrolments", runnerproto.BeginEnrolmentRequest{Version: 1, MachinePublicKey: pub, Label: "Tito Studio", WorkerOnly: true}, "")
+ if status != 201 {
+ t.Fatalf("begin HTTP: %d %s", status, body)
+ }
+ var code runnerproto.DeviceCode
+ if err := json.Unmarshal(body, &code); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := f.db.Writer().Exec("ALTER TABLE runner_enrolments RENAME TO unavailable_enrolments"); err != nil {
+ t.Fatal(err)
+ }
+ if status, body := enrolJSON(t, f.server.Client(), f.server.URL+"/api/enrolments/token", runnerproto.ExchangeEnrolmentRequest{Version: 1, DeviceSecret: code.DeviceSecret, Proof: deviceProof(code, key)}, ""); status != 503 || !strings.Contains(string(body), "service.unavailable") {
+ t.Fatalf("exchange: %d %s", status, body)
+ }
+ logs := f.logs.String()
+ if !strings.Contains(logs, "A runner request failed on the server.") || !strings.Contains(logs, "route=/api/enrolments/token") || !strings.Contains(logs, "status=503") || !strings.Contains(logs, "runner_enrolments") {
+ t.Fatalf("not logged: %s", logs)
+ }
+ if strings.Contains(logs, code.DeviceSecret) {
+ t.Fatal("the device secret was logged")
+ }
+}
diff --git a/internal/runner/config.go b/internal/runner/config.go
index afdad523..ba72a8c1 100644
--- a/internal/runner/config.go
+++ b/internal/runner/config.go
@@ -25,6 +25,9 @@ type Config struct {
// WorkerOnly: a runner that can only be a worker (a Mac, or the test
// build's fake Mac). It refuses an instance without workers.
WorkerOnly bool
+ // EnrolNotify hears how enrolment is going (EnrolNotice); nil is
+ // silent.
+ EnrolNotify func(EnrolNotice)
}
func LoadConfig(getenv func(string) string) (Config, error) {
diff --git a/internal/runner/diagnostics.go b/internal/runner/diagnostics.go
index 539a5ff0..9fcd3b81 100644
--- a/internal/runner/diagnostics.go
+++ b/internal/runner/diagnostics.go
@@ -69,6 +69,10 @@ func Diagnostic(err error) (string, string) {
code = "runner.instance_older_than_worker"
case errors.Is(err, ErrEnrolledAsPrimary):
code = "runner.enrolled_as_primary"
+ case errors.Is(err, ErrEnrolmentExpired):
+ code = "runner.enrolment_expired"
+ case errors.Is(err, ErrEnrolmentRefused):
+ code = "runner.enrolment_refused"
}
return code, "-"
}
diff --git a/internal/runner/enrol.go b/internal/runner/enrol.go
index 8e16b6f4..3712b858 100644
--- a/internal/runner/enrol.go
+++ b/internal/runner/enrol.go
@@ -6,12 +6,14 @@ import (
"crypto/ed25519"
"crypto/rand"
"encoding/base64"
+ "encoding/json"
"errors"
"io"
"net/http"
"net/url"
"os"
"path/filepath"
+ "strconv"
"strings"
"time"
@@ -33,7 +35,7 @@ func Enrol(ctx context.Context, c Config, output io.Writer) (resultErr error) {
// A worker enrolled with an older instance would be its newest
// runner, which that instance takes for the primary. Ask first.
variable = "EQUIPO_ORIGIN"
- if err := workerProtocol(ctx, c.Origin); err != nil {
+ if err := retryTransient(ctx, c, func() error { return workerProtocol(ctx, c.Origin) }); err != nil {
return err
}
variable = "EQUIPO_RUNNER_STATE_DIR"
@@ -113,11 +115,11 @@ func Enrol(ctx context.Context, c Config, output io.Writer) (resultErr error) {
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
- return 0, provider.ErrUncertain
+ return 0, &enrolNetworkError{err}
}
defer resp.Body.Close()
if resp.StatusCode != 200 && resp.StatusCode != 201 {
- return resp.StatusCode, provider.ErrIdentity
+ return resp.StatusCode, answerError(resp)
}
return resp.StatusCode, runnerproto.DecodeLimit(resp.Body, out, 64<<10)
}
@@ -142,7 +144,10 @@ func Enrol(ctx context.Context, c Config, output io.Writer) (resultErr error) {
}
if err != nil || !pending.usable(c.Origin, c.InstanceID) {
var code runnerproto.DeviceCode
- _, err = post("/api/enrolments", runnerproto.BeginEnrolmentRequest{Version: 1, MachinePublicKey: base64.RawURLEncoding.EncodeToString(ed25519.PrivateKey(key).Public().(ed25519.PublicKey)), Label: label, WorkerOnly: c.WorkerOnly}, &code)
+ err = retryTransient(ctx, c, func() error {
+ _, err := post("/api/enrolments", runnerproto.BeginEnrolmentRequest{Version: 1, MachinePublicKey: base64.RawURLEncoding.EncodeToString(ed25519.PrivateKey(key).Public().(ed25519.PublicKey)), Label: label, WorkerOnly: c.WorkerOnly}, &code)
+ return err
+ })
if err != nil {
return err
}
@@ -163,8 +168,16 @@ func Enrol(ctx context.Context, c Config, output io.Writer) (resultErr error) {
if _, err = io.WriteString(output, "["+link+"]("+link+")\n"+code.UserCode+"\n"); err != nil {
return err
}
+ c.notify(EnrolNotice{Waiting: true})
+ // Polled until approved: "not yet" (409) and anything transient (no
+ // answer, a server error, too soon) are waited out, backing off, until
+ // the code expires. Turned down or expired, the saved code is dropped
+ // so the next run starts with a new one.
+ interval := time.Duration(code.PollIntervalSeconds) * enrolPollUnit
+ wait, failures := interval, 0
+ var last error
for time.Now().Before(code.ExpiresAt) {
- timer := time.NewTimer(time.Duration(code.PollIntervalSeconds) * time.Second)
+ timer := time.NewTimer(min(wait, max(time.Until(code.ExpiresAt), 0)+enrolPollUnit))
select {
case <-ctx.Done():
timer.Stop()
@@ -174,8 +187,25 @@ func Enrol(ctx context.Context, c Config, output io.Writer) (resultErr error) {
var cred runnerproto.RunnerCredential
status, err := post("/api/enrolments/token", runnerproto.ExchangeEnrolmentRequest{Version: 1, DeviceSecret: code.DeviceSecret, Proof: proof}, &cred)
if status == 409 {
+ wait, failures, last = interval, 0, nil
+ continue
+ }
+ if transient(err) {
+ last = err
+ failures++
+ wait = backoff(interval, failures)
+ c.notify(EnrolNotice{Retry: err})
continue
}
+ if status == http.StatusForbidden {
+ // The instance answers 403 for a code turned down (revoked)
+ // and for one that has expired by its clock.
+ _ = os.Remove(pendingPath)
+ if time.Until(code.ExpiresAt) < time.Minute {
+ return ErrEnrolmentExpired
+ }
+ return ErrEnrolmentRefused
+ }
if err != nil {
return err
}
@@ -200,9 +230,133 @@ func Enrol(ctx context.Context, c Config, output io.Writer) (resultErr error) {
}
return WriteRole(c.StateDir, role)
}
+ if last != nil {
+ // Still failing when the code ran out: that, not the expiry, is
+ // what to fix.
+ return last
+ }
+ _ = os.Remove(pendingPath)
+ return ErrEnrolmentExpired
+}
+
+// ErrEnrolmentExpired: nobody approved the link before its code expired.
+var ErrEnrolmentExpired = errors.New("the enrolment link expired before it was approved")
+
+// ErrEnrolmentRefused: the instance turned the enrolment down (removed
+// or no longer valid) before it expired.
+var ErrEnrolmentRefused = errors.New("the instance turned the enrolment down")
+
+// EnrolNotice is what Enrol reports while it works: Waiting once the
+// link is printed, Retry for each transient failure it waits out.
+type EnrolNotice struct {
+ Waiting bool
+ Retry error
+}
+
+func (c Config) notify(n EnrolNotice) {
+ if c.EnrolNotify != nil {
+ c.EnrolNotify(n)
+ }
+}
+
+// enrolPollUnit is a second: the poll interval's unit (tests shorten it).
+var enrolPollUnit = time.Second
+
+// enrolAttempts bounds the tries of a request made once (the protocol
+// question, starting the enrolment) when it fails transiently.
+const enrolAttempts = 4
+
+// enrolNetworkError: the instance could not be reached or did not answer.
+type enrolNetworkError struct{ err error }
+
+func (e *enrolNetworkError) Error() string { return "no answer from Equipo: " + e.err.Error() }
+func (e *enrolNetworkError) Unwrap() error { return provider.ErrUncertain }
+
+// EnrolAnswerError is an answer from the instance that is not success:
+// its HTTP status and the error key it gave, nothing more.
+type EnrolAnswerError struct {
+ Status int
+ Key string
+}
+
+func (e *EnrolAnswerError) Error() string {
+ if e.Key == "" {
+ return "Equipo answered HTTP " + strconv.Itoa(e.Status)
+ }
+ return "Equipo answered HTTP " + strconv.Itoa(e.Status) + " (" + e.Key + ")"
+}
+func (e *EnrolAnswerError) Unwrap() error {
+ if e.Status >= 500 {
+ return provider.ErrUncertain
+ }
return provider.ErrIdentity
}
+func answerError(resp *http.Response) error {
+ var body runnerproto.ErrorResponse
+ key := ""
+ if json.Unmarshal(mustRead(resp.Body), &body) == nil && len(body.Error) <= 64 && strings.Trim(body.Error, "abcdefghijklmnopqrstuvwxyz0123456789._-") == "" {
+ key = body.Error
+ }
+ return &EnrolAnswerError{Status: resp.StatusCode, Key: key}
+}
+
+// transient: worth asking again (no answer, a server error, too soon).
+func transient(err error) bool {
+ var answer *EnrolAnswerError
+ var network *enrolNetworkError
+ return errors.As(err, &network) || errors.As(err, &answer) && (answer.Status >= 500 || answer.Status == http.StatusTooManyRequests)
+}
+
+// backoff doubles the wait after each failure in a row, up to a minute.
+func backoff(interval time.Duration, failures int) time.Duration {
+ return min(interval<<min(failures, 4), 60*enrolPollUnit)
+}
+
+// retryTransient runs once-only requests up to enrolAttempts times while
+// they fail transiently.
+func retryTransient(ctx context.Context, c Config, f func() error) error {
+ interval := runnerproto.PollIntervalSeconds * enrolPollUnit
+ for n := 1; ; n++ {
+ err := f()
+ if !transient(err) || n == enrolAttempts {
+ return err
+ }
+ c.notify(EnrolNotice{Retry: err})
+ t := time.NewTimer(backoff(interval, n-1))
+ select {
+ case <-ctx.Done():
+ t.Stop()
+ return ctx.Err()
+ case <-t.C:
+ }
+ }
+}
+
+// EnrolDetail is what went wrong, in words, for the person and the
+// install log: the cause under the diagnostic code, which carries no
+// secrets (the device secret and tokens are only ever in request and
+// response bodies, never in errors).
+func EnrolDetail(err error) string {
+ var known *diagnosticError
+ if errors.As(err, &known) && known.cause != nil {
+ err = known.cause
+ }
+ if err == nil {
+ return ""
+ }
+ detail := strings.Map(func(r rune) rune {
+ if r < 0x20 || r == 0x7f {
+ return ' '
+ }
+ return r
+ }, err.Error())
+ if len(detail) > 300 {
+ detail = detail[:300]
+ }
+ return detail
+}
+
// RoleFile keeps the role a runner was enrolled with, in its state
// directory.
const RoleFile = "role"
@@ -239,9 +393,12 @@ func workerProtocol(ctx context.Context, origin string) error {
}
resp, err := outboundClient().Do(req)
if err != nil {
- return provider.ErrUncertain
+ return &enrolNetworkError{err}
}
defer resp.Body.Close()
+ if resp.StatusCode >= 500 || resp.StatusCode == http.StatusTooManyRequests {
+ return &EnrolAnswerError{Status: resp.StatusCode}
+ }
var v wire.RunnerProtocol
if resp.StatusCode != http.StatusOK || wire.Strict(mustRead(resp.Body), &v) != nil || v.Protocol < wire.Protocol2 {
return ErrInstanceOlder
diff --git a/internal/runner/enrol_wait_test.go b/internal/runner/enrol_wait_test.go
new file mode 100644
index 00000000..cc06fc1f
--- /dev/null
+++ b/internal/runner/enrol_wait_test.go
@@ -0,0 +1,168 @@
+package runner
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "io"
+ "net"
+ "net/http"
+ "os"
+ "path/filepath"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// enrolScript is a fake instance whose answers to each route are given in
+// order (the last repeats): a status, or 0 to drop the connection
+// unanswered. The code it hands out expires after expires.
+type enrolScript struct {
+ mu sync.Mutex
+ protocol, begin, token []int
+ expires time.Duration
+ asked []string
+}
+
+func (s *enrolScript) next(path string, answers *[]int) int {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ s.asked = append(s.asked, path)
+ a := (*answers)[0]
+ if len(*answers) > 1 {
+ *answers = (*answers)[1:]
+ }
+ return a
+}
+
+func (s *enrolScript) run(t *testing.T, worker bool) ([]EnrolNotice, string, error) {
+ t.Helper()
+ old := enrolPollUnit
+ enrolPollUnit = 5 * time.Millisecond
+ t.Cleanup(func() { enrolPollUnit = old })
+ l, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ srv := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ var status int
+ switch r.URL.Path {
+ case wire.RunnerProtocolPath:
+ status = s.next(r.URL.Path, &s.protocol)
+ case "/api/enrolments":
+ status = s.next(r.URL.Path, &s.begin)
+ case "/api/enrolments/token":
+ status = s.next(r.URL.Path, &s.token)
+ default:
+ status = 404
+ }
+ switch status {
+ case 0:
+ conn, _, _ := w.(http.Hijacker).Hijack()
+ conn.Close()
+ case 200, 201:
+ switch r.URL.Path {
+ case wire.RunnerProtocolPath:
+ _, _ = w.Write([]byte(`{"protocol":2}`))
+ case "/api/enrolments":
+ _, _ = fmt.Fprintf(w, `{"version":1,"enrolment_id":"e1","instance_id":"inst","device_secret":"s3cret-device","user_code":"ABCDEFGHJK","challenge":"c","verification_uri":"http://%s/runners/enrol","expires_at":%q,"poll_interval_seconds":5}`, r.Host, time.Now().Add(s.expires).UTC().Format(time.RFC3339Nano))
+ default:
+ _, _ = fmt.Fprintf(w, `{"version":1,"token":"t0ken","token_type":"Bearer","runner_id":"R2","credential_id":"C2","person":"p@x","expires_at":%q,"role":"worker"}`, time.Now().Add(time.Hour).UTC().Format(time.RFC3339))
+ }
+ default:
+ key := map[int]string{409: "runner.pending", 403: "form.forbidden", 503: "service.unavailable", 429: "runner.rate-limited"}[status]
+ w.WriteHeader(status)
+ _, _ = fmt.Fprintf(w, `{"version":2,"error":%q}`, key)
+ }
+ })}
+ go srv.Serve(l)
+ t.Cleanup(func() { srv.Close() })
+ var mu sync.Mutex
+ var notices []EnrolNotice
+ state := filepath.Join(t.TempDir(), "state")
+ c := Config{Origin: "http://" + l.Addr().String(), InstanceID: "inst", StateDir: state, MachineLabel: "Tito Studio", WorkerOnly: worker, EnrolNotify: func(n EnrolNotice) {
+ mu.Lock()
+ defer mu.Unlock()
+ notices = append(notices, n)
+ }}
+ err = Enrol(context.Background(), c, io.Discard)
+ mu.Lock()
+ defer mu.Unlock()
+ return notices, state, err
+}
+
+func retries(notices []EnrolNotice) []string {
+ var out []string
+ for _, n := range notices {
+ if n.Retry != nil {
+ out = append(out, EnrolDetail(n.Retry))
+ }
+ }
+ return out
+}
+
+// Paul's Studio, 2026-11-10: one server error while waiting ended the
+// install. Server errors, dropped connections and "too soon" are waited
+// out, backing off, and each is reported in words; the wait itself is
+// announced once.
+func TestEnrolWaitsOutTransientFailures(t *testing.T) {
+ s := &enrolScript{protocol: []int{503, 200}, begin: []int{0, 201}, token: []int{409, 503, 0, 429, 409, 200}, expires: time.Minute}
+ notices, state, err := s.run(t, true)
+ if err != nil {
+ t.Fatalf("enrol: %v (%s)", err, EnrolDetail(err))
+ }
+ if ReadRole(state) != wire.RoleWorker {
+ t.Fatal("not enrolled")
+ }
+ got := retries(notices)
+ if len(got) != 5 || got[0] != "Equipo answered HTTP 503" || !strings.HasPrefix(got[1], "no answer from Equipo: ") || got[2] != "Equipo answered HTTP 503 (service.unavailable)" || !strings.HasPrefix(got[3], "no answer from Equipo: ") || got[4] != "Equipo answered HTTP 429 (runner.rate-limited)" {
+ t.Fatalf("retries %q", got)
+ }
+ waiting := 0
+ for _, n := range notices {
+ if n.Waiting {
+ waiting++
+ }
+ }
+ if waiting != 1 || !notices[2].Waiting {
+ t.Fatalf("waiting announced %d times: %+v", waiting, notices)
+ }
+ for _, d := range got {
+ if strings.Contains(d, "s3cret") || strings.Contains(d, "t0ken") {
+ t.Fatalf("a secret in %q", d)
+ }
+ }
+}
+
+// Expired and turned down each end the wait with their own error, and the
+// saved code is dropped so the next run asks for a new one. A failure
+// still happening when the code runs out is reported as that failure.
+func TestEnrolEndsInWords(t *testing.T) {
+ for name, c := range map[string]struct {
+ s *enrolScript
+ want error
+ code string
+ }{
+ "turned down": {&enrolScript{begin: []int{201}, token: []int{409, 403}, expires: 10 * time.Minute}, ErrEnrolmentRefused, "runner.enrolment_refused"},
+ "expired by its clock": {&enrolScript{begin: []int{201}, token: []int{409, 403}, expires: 30 * time.Second}, ErrEnrolmentExpired, "runner.enrolment_expired"},
+ "ran out": {&enrolScript{begin: []int{201}, token: []int{409}, expires: 300 * time.Millisecond}, ErrEnrolmentExpired, "runner.enrolment_expired"},
+ } {
+ t.Run(name, func(t *testing.T) {
+ _, state, err := c.s.run(t, false)
+ if code, _ := Diagnostic(err); !errors.Is(err, c.want) || code != c.code {
+ t.Fatalf("%v %q", err, code)
+ }
+ if _, err := os.Stat(filepath.Join(state, "enrolment.json")); !os.IsNotExist(err) {
+ t.Fatal("the used code was kept")
+ }
+ })
+ }
+ s := &enrolScript{begin: []int{201}, token: []int{503}, expires: 300 * time.Millisecond}
+ _, _, err := s.run(t, false)
+ if errors.Is(err, ErrEnrolmentExpired) || EnrolDetail(err) != "Equipo answered HTTP 503 (service.unavailable)" {
+ t.Fatalf("a failing instance reported as %v (%s)", err, EnrolDetail(err))
+ }
+}
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index 77aaece8..7ae8b43a 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -11591,6 +11591,13 @@
"count": 1,
"reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
},
+ {
+ "path": "cmd/equipo-runner/install_mac_test.go",
+ "line_sha256": "ad3bfb7b536fef55b5cc3d2cfd73232b0025845cd24440da0cae05cdd0a53ccd",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
{
"path": "internal/release/install_assets.go",
"line_sha256": "7f7ed824e9d8388f23c6fc72a27d85e4ee2d981fc78b4cdc63456e673d5ef847",
@@ -12151,6 +12158,13 @@
"count": 1,
"reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
},
+ {
+ "path": "docs/superpowers/plans/DARWIN-PROGRESS.md",
+ "line_sha256": "d66c703cfc2cc5fc83c7e245a2aa40d0a21d7c004385098aeea45d39f19c3e34",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
{
"path": "internal/runner/thin/mac_test.go",
"line_sha256": "1fbe1464099bf4c31f891c4822863f95659d773e5d285ad08b0b5b8a632d4399",
@@ -12165,6 +12179,13 @@
"count": 2,
"reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
},
+ {
+ "path": "docs/mac-runner.md",
+ "line_sha256": "9b587081c90141c8f5e9ff7f5f3920c165d4f809048675116a18f0451700766e",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
{
"path": "docs/mac-runner.md",
"line_sha256": "b11c129f20121943c44b15e935aeb7137878f63a12740e4f1e78dfba589983b1",