oficina / equipo Public

runner: say "Open this link" only when a link follows

On a Mac whose enrolment is still valid, equipo-runner install printed
"Open this link and add this Mac to your team:" with no link after it,
then "This Mac is ready." The line was said unconditionally before enrol,
and runner.Enrol keeps a valid enrolment without printing a link.

runner.EnrolNotice gains Kept (a valid enrolment is kept, no link) and
Link (sent just before the link is written). enrolReport takes optional
copy keys for both; macEnrolReport sets runner.mac.tap and the new
runner.mac.already ("Already added to your team."). The Mac installer
no longer says the tap line itself.

Linux (install.go) has no such line: its prompt asks to enrol and the
link follows from runner.Enrol. Its report sets neither key, so its
output is unchanged; the onboarding test pins that.

Tests: TestInstallMacLinkLine (kept: no tap line, the already line then
"This Mac is ready."; new: the tap line directly before the link) and
TestOnboardingEnrolLinkLines (the real runner.Enrol on a loopback fake
instance, Mac and Linux reports, new and kept). Both failed before the
fix; removing the Link notice fails the onboarding test and
TestEnrolWaitsOutTransientFailures, whose notice order now has Link
right before Waiting.

Copy: runner.mac.already in copy.go and the Plan 3 inventory. Delegated
Astra pass (gpt-6-astra, effort high): KEEP. COPY ACCEPTED BY DELEGATION
(Astra, 2026-11-11).

Budget: internal/runner 9900 to 9905 source lines, the measured size
with the two notices.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev f24ba01f955c8f55a68ee64dad9cfc8df90fe7cf parent d096dfc
9 files changed, +142 −9
  • .rastrillo/budgets.txt +1 −1
  • cmd/equipo-runner/enrol_report.go +20 −3
  • cmd/equipo-runner/install_mac.go +3 −2
  • cmd/equipo-runner/install_mac_test.go +30 −0
  • cmd/equipo-runner/onboarding_test.go +75 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +1 −0
  • internal/equipo/copy.go +2 −0
  • internal/runner/enrol.go +8 −2
  • internal/runner/enrol_wait_test.go +2 −1

CI passed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 269a9bf4..d2726136 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 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.
+size internal/runner 9905 9200 The installer line with no link: enrolment tells the installer when it keeps a valid enrolment and just before it prints the link (EnrolNotice Kept and Link, about 5 lines); measured 9905. 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
index a2f3095e..bfbcac9b 100644
--- a/cmd/equipo-runner/enrol_report.go
+++ b/cmd/equipo-runner/enrol_report.go
@@ -14,10 +14,21 @@ import (
// 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).
+// wrong in words. Details carry no secrets (runner.EnrolDetail). An
+// installer that introduces the link names its line in link, said just
+// before the link and only when one follows, and the line for a kept
+// enrolment in kept ("" says nothing).
type enrolReport struct {
- errout io.Writer
- log string
+ errout io.Writer
+ log string
+ link, kept string
+}
+
+// macEnrolReport is the Mac installer's: "Open this link and add this
+// Mac to your team:" right before the link, "Already added to your
+// team." when the enrolment it has is kept.
+func macEnrolReport(errout io.Writer, log string) enrolReport {
+ return enrolReport{errout: errout, log: log, link: "runner.mac.tap", kept: "runner.mac.already"}
}
func (r enrolReport) say(key string, a ...any) {
@@ -33,6 +44,12 @@ func (r enrolReport) say(key string, a ...any) {
}
func (r enrolReport) notify(n runner.EnrolNotice) {
+ if n.Kept && r.kept != "" {
+ r.say(r.kept)
+ }
+ if n.Link && r.link != "" {
+ r.say(r.link)
+ }
if n.Waiting {
r.say("runner.enrol.waiting")
}
diff --git a/cmd/equipo-runner/install_mac.go b/cmd/equipo-runner/install_mac.go
index cdbe46f6..c022aaa0 100644
--- a/cmd/equipo-runner/install_mac.go
+++ b/cmd/equipo-runner/install_mac.go
@@ -203,8 +203,9 @@ func installMac(ctx context.Context, args []string, h macInstallHost, out, errou
return fail("runner.install.config")
}
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")}
+ // The line to open the link comes right before the link, and only
+ // when there is one: a valid enrolment is kept and said so instead.
+ report := macEnrolReport(errout, filepath.Join(logs, "install.log"))
cfg.EnrolNotify = report.notify
if err := h.enrol(ctx, cfg, out); err != nil {
if errors.Is(err, runner.ErrEnrolledAsPrimary) {
diff --git a/cmd/equipo-runner/install_mac_test.go b/cmd/equipo-runner/install_mac_test.go
index 79bf5593..b977feb5 100644
--- a/cmd/equipo-runner/install_mac_test.go
+++ b/cmd/equipo-runner/install_mac_test.go
@@ -95,9 +95,12 @@ func newMacRig(t *testing.T) *macRig {
}
return nil
},
+ // As runner.Enrol tells it: the link notice, the link, waiting.
enrol: func(_ context.Context, cfg runner.Config, out io.Writer) error {
x.enrolled = &cfg
+ cfg.EnrolNotify(runner.EnrolNotice{Link: true})
_, _ = io.WriteString(out, "[https://equipo.example/runners/enrol?code=ABCDEFGHIJ](https://equipo.example/runners/enrol?code=ABCDEFGHIJ)\nABCDEFGHIJ\n")
+ cfg.EnrolNotify(runner.EnrolNotice{Waiting: true})
return nil
},
launchctl: func(_ context.Context, args ...string) error {
@@ -296,6 +299,33 @@ func TestEnvFileAndExits(t *testing.T) {
}
}
+// The line asking Paul to open the link comes only with a link, right
+// before it. A Mac whose enrolment is still valid keeps it and says it
+// is already on the team (Paul's Studio, 2026-11-11: the line came with
+// no link after it).
+func TestInstallMacLinkLine(t *testing.T) {
+ tap, already, ready := equipo.RunnerSetupCopy("runner.mac.tap"), equipo.RunnerSetupCopy("runner.mac.already"), equipo.RunnerSetupCopy("runner.mac.installed")
+ link := "[https://equipo.example/runners/enrol?code=ABCDEFGHIJ](https://equipo.example/runners/enrol?code=ABCDEFGHIJ)\nABCDEFGHIJ\n"
+ install := func(x *macRig) string {
+ var both bytes.Buffer
+ if code := installMac(context.Background(), []string{"--release", "abc1234", "--origin", "https://equipo.example", "--instance", "team1"}, x.h, &both, &both); code != 0 {
+ t.Fatalf("code %d: %s", code, both.String())
+ }
+ return both.String()
+ }
+ kept := newMacRig(t)
+ kept.h.enrol = func(_ context.Context, cfg runner.Config, _ io.Writer) error {
+ cfg.EnrolNotify(runner.EnrolNotice{Kept: true})
+ return nil
+ }
+ if got := install(kept); strings.Contains(got, tap) || !strings.HasSuffix(got, already+"\n"+ready+"\n") {
+ t.Fatalf("kept enrolment: %q", got)
+ }
+ if got := install(newMacRig(t)); strings.Count(got, tap) != 1 || !strings.Contains(got, tap+"\n"+link) || strings.Contains(got, already) {
+ t.Fatalf("new enrolment: %q", got)
+ }
+}
+
// Installing again over a running runner stops it first: nothing is
// replaced while it runs, and the enrolment check gets the state lock
// the running runner held (here the test holds it until bootout).
diff --git a/cmd/equipo-runner/onboarding_test.go b/cmd/equipo-runner/onboarding_test.go
index eb8b3b96..70c18349 100644
--- a/cmd/equipo-runner/onboarding_test.go
+++ b/cmd/equipo-runner/onboarding_test.go
@@ -5,11 +5,19 @@ import (
"bytes"
"context"
"encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "net/http/httptest"
"os"
"path/filepath"
"strings"
"testing"
"time"
+
+ "amadan.net/oficina/equipo/internal/equipo"
+ "amadan.net/oficina/equipo/internal/runner"
+ "amadan.net/oficina/equipo/internal/wire"
)
func TestOnboardingInstallVersioned(t *testing.T) {
@@ -21,6 +29,73 @@ func TestOnboardingInstallVersioned(t *testing.T) {
}
}
+// The real enrolment through each installer's report, on one terminal:
+// a new enrolment prints the Mac's "Open this link" line directly before
+// the link, and a kept one prints "Already added to your team." with no
+// link and no tap line. The Linux installer introduces neither.
+func TestOnboardingEnrolLinkLines(t *testing.T) {
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ switch r.URL.Path {
+ case wire.RunnerProtocolPath:
+ _, _ = w.Write([]byte(`{"protocol":2}`))
+ case "/api/enrolments":
+ w.WriteHeader(201)
+ _, _ = fmt.Fprintf(w, `{"version":1,"enrolment_id":"e1","instance_id":"inst","device_secret":"s","user_code":"ABCDEFGHJK","challenge":"c","verification_uri":"http://%s/runners/enrol","expires_at":%q,"poll_interval_seconds":5}`, r.Host, time.Now().Add(time.Hour).UTC().Format(time.RFC3339))
+ default:
+ w.WriteHeader(409)
+ _, _ = w.Write([]byte(`{"version":2,"error":"runner.pending"}`))
+ }
+ }))
+ defer srv.Close()
+ tap, already, waiting := equipo.RunnerSetupCopy("runner.mac.tap"), equipo.RunnerSetupCopy("runner.mac.already"), equipo.RunnerSetupCopy("runner.enrol.waiting")
+ link := "[" + srv.URL + "/runners/enrol?code=ABCDEFGHJK](" + srv.URL + "/runners/enrol?code=ABCDEFGHJK)\nABCDEFGHJK\n"
+ enrol := func(state string, report func(io.Writer) enrolReport) string {
+ var both bytes.Buffer
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ r := report(&both)
+ // Stop once it waits for approval: what was printed is the point.
+ cfg := runner.Config{Origin: srv.URL, InstanceID: "inst", StateDir: state, MachineLabel: "Tito Studio", WorkerOnly: true, EnrolNotify: func(n runner.EnrolNotice) {
+ r.notify(n)
+ if n.Waiting {
+ cancel()
+ }
+ }}
+ _ = runner.Enrol(ctx, cfg, &both)
+ return both.String()
+ }
+ kept := func(t *testing.T) string {
+ state := filepath.Join(t.TempDir(), "state")
+ if err := os.Mkdir(state, 0700); err != nil {
+ t.Fatal(err)
+ }
+ files := map[string]string{
+ "credentials.json": fmt.Sprintf(`{"bearer":{"version":1,"token":"t","runner_id":"R1","expires_at":%q,"role":"worker"}}`, time.Now().Add(time.Hour).UTC().Format(time.RFC3339)),
+ "enrolment.json": fmt.Sprintf(`{"origin":%q,"label":"Tito Studio","code":{"version":1,"instance_id":"inst"}}`, srv.URL),
+ }
+ for name, body := range files {
+ if err := os.WriteFile(filepath.Join(state, name), []byte(body), 0600); err != nil {
+ t.Fatal(err)
+ }
+ }
+ return state
+ }
+ mac := func(w io.Writer) enrolReport { return macEnrolReport(w, "") }
+ linux := func(w io.Writer) enrolReport { return enrolReport{errout: w} }
+ if got := enrol(filepath.Join(t.TempDir(), "state"), mac); got != tap+"\n"+link+waiting+"\n" {
+ t.Fatalf("new enrolment on a Mac: %q", got)
+ }
+ if got := enrol(kept(t), mac); got != already+"\n" {
+ t.Fatalf("kept enrolment on a Mac: %q", got)
+ }
+ if got := enrol(filepath.Join(t.TempDir(), "state"), linux); got != link+waiting+"\n" {
+ t.Fatalf("new enrolment on Linux: %q", got)
+ }
+ if got := enrol(kept(t), linux); got != "" {
+ t.Fatalf("kept enrolment on Linux: %q", got)
+ }
+}
+
func TestOnboardingInstallLabelPrompt(t *testing.T) {
root := t.TempDir()
if e := os.Mkdir(filepath.Join(root, "state"), 0700); e != nil {
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index a87690c6..31c18dad 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -5871,6 +5871,7 @@ records remain unchanged.
| `runner.needs_primary` | This Mac can only run checks for your main runner. Add your main runner first, then open this Mac's link again. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `runner.mac.no_srt` | The checks sandbox could not be downloaded and installed. Checks will run outside the sandbox and say so. Run the install command again to retry. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `runner.mac.tap` | Open this link and add this Mac to your team: | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `runner.mac.already` | Already added to your team. | Mac runners: installer on a Mac whose enrolment is kept (2026-11-11) | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| `runner.mac.installed` | This Mac is ready. It checks itself, then waits for work whenever this user is logged in. | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `work.checks.outside_sandbox` | %s, ran outside the sandbox | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `runner.add_title` | Add %s to your team | Mac runners (Darwin worker) | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index e901af82..01a0f379 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -346,6 +346,8 @@ var pageCopy = map[string]string{
"runner.mac.no_srt": "The checks sandbox could not be downloaded and installed. Checks will run outside the sandbox and say so. Run the install command again to retry.",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.tap
"runner.mac.tap": "Open this link and add this Mac to your team:",
+ // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): runner.mac.already
+ "runner.mac.already": "Already added to your team.",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.installed
"runner.mac.installed": "This Mac is ready. It checks itself, then waits for work whenever this user is logged in.",
diff --git a/internal/runner/enrol.go b/internal/runner/enrol.go
index 44947c0e..f24a7da4 100644
--- a/internal/runner/enrol.go
+++ b/internal/runner/enrol.go
@@ -56,6 +56,7 @@ func Enrol(ctx context.Context, c Config, output io.Writer) (resultErr error) {
if privateJSON(filepath.Join(c.StateDir, "enrolment.json"), &saved) != nil || saved.Origin != c.Origin || saved.Code.InstanceID != c.InstanceID {
return provider.ErrIdentity
}
+ c.notify(EnrolNotice{Kept: true})
return nil
}
journalPath := filepath.Join(c.StateDir, "journal.db")
@@ -165,6 +166,7 @@ func Enrol(ctx context.Context, c Config, output io.Writer) (resultErr error) {
// The link carries the code, so opening it shows this machine with one
// button to add it; the code stays on its own line for typing.
link := code.VerificationURI + "?code=" + url.QueryEscape(code.UserCode)
+ c.notify(EnrolNotice{Link: true})
if _, err = io.WriteString(output, "["+link+"]("+link+")\n"+code.UserCode+"\n"); err != nil {
return err
}
@@ -246,9 +248,13 @@ var ErrEnrolmentExpired = errors.New("the enrolment link expired before it was a
// 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.
+// EnrolNotice is what Enrol reports while it works: Kept when a valid
+// enrolment is kept and no link is printed, Link just before the link is
+// printed, Waiting once it is, Retry for each transient failure it waits
+// out.
type EnrolNotice struct {
+ Kept bool
+ Link bool
Waiting bool
Retry error
}
diff --git a/internal/runner/enrol_wait_test.go b/internal/runner/enrol_wait_test.go
index cc06fc1f..565a10f6 100644
--- a/internal/runner/enrol_wait_test.go
+++ b/internal/runner/enrol_wait_test.go
@@ -127,7 +127,8 @@ func TestEnrolWaitsOutTransientFailures(t *testing.T) {
waiting++
}
}
- if waiting != 1 || !notices[2].Waiting {
+ // The link notice comes once, directly before the link and the wait.
+ if waiting != 1 || !notices[2].Link || !notices[3].Waiting {
t.Fatalf("waiting announced %d times: %+v", waiting, notices)
}
for _, d := range got {