fix: clarify unverified connections and strengthen regression guards
9 files changed,
+76
−10
go.mod+1 −1internal/equipo/connection_views.go+8 −3internal/equipo/copy.go+2 −0internal/equipo/templates/connections.html+1 −1internal/equipotest/final_connection_test.go+21 −0internal/equipotest/final_topic_test.go+31 −0internal/equipotest/preparation_integration_test.go+2 −2internal/equipotest/task_pages_test.go+10 −1packaging/equipo-runner.service+0 −2
diff --git a/go.mod b/go.mod| index a7002728..71960797 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -34,7 +34,7 @@ require ( |
| modernc.org/memory v1.11.0 // indirect |
| ) |
| -// The CLI this app's own gate runs: make migration-check, and |
| +// The CLI this app's budget and performance gates run, and |
| // rastrillo generate once the app declares manifest resources. It is |
| // declared as a tool so that go mod tidy records the CLI's build |
| // dependencies in go.sum alongside the app's own. Nothing an app |
diff --git a/internal/equipo/connection_views.go b/internal/equipo/connection_views.go| index d99fc4de..9c44b567 100644 |
| --- a/internal/equipo/connection_views.go |
| +++ b/internal/equipo/connection_views.go |
| @@ -11,8 +11,8 @@ import ( |
| type ConnectionView struct { |
| Connection |
| - Report ConnectionReport |
| - Unconfined, Acknowledged, Available bool |
| + Report ConnectionReport |
| + Unconfined, Unverified, Acknowledged, Available bool |
| } |
| type ProjectConnectionView struct { |
| Project Project |
| @@ -44,7 +44,12 @@ func (a *application) connectionsPage(w http.ResponseWriter, r *http.Request, da |
| if err != nil && !errors.Is(err, ErrForbidden) { |
| return err |
| } |
| - data.Connections = append(data.Connections, ConnectionView{Connection: row.Connection, Report: report, Unconfined: !a.store.confined(report), Acknowledged: ack.ID != "", Available: report.Available && freshConnection(row, a.store.runnerClock.Now())}) |
| + available, _, err := a.store.eligible(tx, row, report, a.store.runnerClock.Now()) |
| + if err != nil { |
| + return err |
| + } |
| + unverified := !a.store.confined(report) && !unconfinedException(report) |
| + data.Connections = append(data.Connections, ConnectionView{Connection: row.Connection, Report: report, Unverified: unverified, Unconfined: !a.store.confined(report) && !unverified, Acknowledged: ack.ID != "", Available: available}) |
| } |
| } |
| var projects []Project |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 6a22dd4e..eb24b822 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -250,6 +250,8 @@ var runnerDraftCopy = map[string]string{ |
| "task.group.finished": "Finished this week", |
| // COPY REVIEW REQUIRED: runner.prompt_too_large |
| "runner.prompt_too_large": "The task instructions and reproduction are too large for one turn.", |
| + // COPY REVIEW REQUIRED: isolation.unverified |
| + "isolation.unverified": "Read isolation is not yet verified. This connection cannot run tasks.", |
| // COPY REVIEW REQUIRED: question.send_answer |
| "question.send_answer": "Send answer", |
| // COPY REVIEW REQUIRED: runner.budget |
diff --git a/internal/equipo/templates/connections.html b/internal/equipo/templates/connections.html| index bcf30547..bfa3d1c2 100644 |
| --- a/internal/equipo/templates/connections.html |
| +++ b/internal/equipo/templates/connections.html |
| @@ -1,3 +1,3 @@ |
| {{define "content"}}<h1>{{copy "nav.connections"}}</h1><a rst-btn href="/runners/enrol">{{copy "connections.enrol"}}</a>{{template "region:activity" .}} |
| <h2>{{copy "connections.personal"}}</h2>{{range .Choices}}<form equipo-form method="post" action="/projects/{{.Project.ID}}/connections"><h3>{{.Project.Name}}</h3><input type="hidden" name="revision" value="{{.Revision}}">{{range .Options}}<label><input type="checkbox" name="connection_id" value="{{.ID}}"{{if .Enabled}} checked{{end}}>{{copy "connections.enable"}}: {{.Label}}</label>{{end}}<label>{{copy "connections.pin"}}<select rst-input name="pinned_id"><option value="">{{copy "value.none"}}</option>{{$pinned:=.PinnedID}}{{range .Options}}<option value="{{.ID}}"{{if eq .ID $pinned}} selected{{end}}>{{.Label}}</option>{{end}}</select></label><button rst-btn>{{copy "form.save"}}</button></form>{{end}}{{end}} |
| -{{define "region:activity"}}<div id="activity" {{.Live.Attrs .Topic}}>{{range .Connections}}<section equipo-card><h2>{{.Report.AccountLabel}}</h2><p>{{.Person}}</p>{{if not .Available}}<p>{{copy "runner.preflight.unavailable"}}</p>{{end}}<p>{{copy "connections.versions"}}: {{.Report.Provider}} {{.Report.ProviderVersion}} / {{.Report.PaseoVersion}}</p>{{if .Unconfined}}<p>{{copy "isolation.unconfined"}}</p><p>{{copy "isolation.meaning"}}</p><p>{{if .Acknowledged}}{{copy "isolation.acknowledged"}}{{else}}{{copy "isolation.expired"}}{{end}}</p>{{if $.Owner}}<form method="post" action="/connections/{{.ID}}/acknowledge-unconfined"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="acknowledge" value="unconfined"><button rst-btn>{{copy "isolation.acknowledge"}}</button></form><form method="post" action="/connections/{{.ID}}/revoke-isolation-acknowledgement"><input type="hidden" name="revision" value="{{.Revision}}"><button rst-btn>{{copy "isolation.revoke"}}</button></form>{{end}}{{else}}<p>{{copy "isolation.confined"}}</p>{{end}}</section>{{else}}<p data-empty-state="connections.empty">{{copy "connections.empty"}}</p>{{end}}</div>{{end}} |
| +{{define "region:activity"}}<div id="activity" {{.Live.Attrs .Topic}}>{{range .Connections}}<section equipo-card><h2>{{.Report.AccountLabel}}</h2><p>{{.Person}}</p>{{if not .Available}}<p>{{copy "runner.preflight.unavailable"}}</p>{{end}}<p>{{copy "connections.versions"}}: {{.Report.Provider}} {{.Report.ProviderVersion}} / {{.Report.PaseoVersion}}</p>{{if .Unverified}}<p>{{copy "isolation.unverified"}}</p>{{else if .Unconfined}}<p>{{copy "isolation.unconfined"}}</p><p>{{copy "isolation.meaning"}}</p><p>{{if .Acknowledged}}{{copy "isolation.acknowledged"}}{{else}}{{copy "isolation.expired"}}{{end}}</p>{{if $.Owner}}<form method="post" action="/connections/{{.ID}}/acknowledge-unconfined"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="acknowledge" value="unconfined"><button rst-btn>{{copy "isolation.acknowledge"}}</button></form><form method="post" action="/connections/{{.ID}}/revoke-isolation-acknowledgement"><input type="hidden" name="revision" value="{{.Revision}}"><button rst-btn>{{copy "isolation.revoke"}}</button></form>{{end}}{{else}}<p>{{copy "isolation.confined"}}</p>{{end}}</section>{{else}}<p data-empty-state="connections.empty">{{copy "connections.empty"}}</p>{{end}}</div>{{end}} |
diff --git a/internal/equipotest/final_connection_test.go b/internal/equipotest/final_connection_test.go| new file mode 100644 |
| index 00000000..041b5fcb |
| --- /dev/null |
| +++ b/internal/equipotest/final_connection_test.go |
| @@ -0,0 +1,21 @@ |
| +package equipotest |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +func TestUnverifiedClaudeHasNoAcknowledgementBypass(t *testing.T) { |
| + f := connectionStore(t) |
| + f.reports[0].ProviderVersion = "unverified-version" |
| + executionMust(t, f.s.ReportConnections(connectionContext, f.principal, f.reports)) |
| + server, c := taskPageServer(t, f, false) |
| + body := taskGet(t, c, server.URL, "/connections", 200) |
| + if strings.Contains(body, "/connections/"+f.ids["claude"]+"/acknowledge-unconfined") { |
| + t.Fatal("Claude offered forbidden acknowledgement") |
| + } |
| + if !strings.Contains(body, equipo.RunnerText("isolation.unverified")) { |
| + t.Fatal("missing cannot-run state") |
| + } |
| +} |
diff --git a/internal/equipotest/final_topic_test.go b/internal/equipotest/final_topic_test.go| new file mode 100644 |
| index 00000000..aae459e8 |
| --- /dev/null |
| +++ b/internal/equipotest/final_topic_test.go |
| @@ -0,0 +1,31 @@ |
| +package equipotest |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| + "crypto/sha256" |
| + "encoding/json" |
| + "fmt" |
| + "net/url" |
| + "testing" |
| +) |
| + |
| +func TestLiveRejectsForeignJobAssociations(t *testing.T) { |
| + f := runnerFixtureNew(t, false) |
| + server, c := taskPageServer(t, f.connectionFixture, true) |
| + mustSQL(t, f.d, "CREATE TEMP TABLE foreign_job_copy AS SELECT * FROM jobs WHERE id=?", f.a.Scope.Job) |
| + mustSQL(t, f.d, "UPDATE foreign_job_copy SET id=id+100,account='other-team'") |
| + mustSQL(t, f.d, "INSERT INTO jobs SELECT * FROM foreign_job_copy") |
| + mustSQL(t, f.d, "DROP TABLE foreign_job_copy") |
| + mustSQL(t, f.d, `INSERT INTO tasks(id,team_id,job_id,requester,request_id,project_id) VALUES('foreign-task','other-team',?,'other','other',?)`, f.a.Scope.Job+100, f.project.ID) |
| + topic := func(account string, id team.JobID) string { |
| + raw, _ := json.Marshal(struct { |
| + Kind string |
| + Team string |
| + Job team.JobID |
| + }{"job", account, id}) |
| + return fmt.Sprintf("jobs/%x@0", sha256.Sum256(raw)) |
| + } |
| + taskGet(t, c, server.URL, "/live?t="+url.QueryEscape(topic("other-team", f.a.Scope.Job+100)), 403) |
| + mustSQL(t, f.d, "UPDATE tasks SET team_id='other-team' WHERE id=?", f.a.TaskID) |
| + taskGet(t, c, server.URL, "/live?t="+url.QueryEscape(topic(string(f.a.Scope.Account), f.a.Scope.Job)), 403) |
| +} |
diff --git a/internal/equipotest/preparation_integration_test.go b/internal/equipotest/preparation_integration_test.go| index 41626183..52947e84 100644 |
| --- a/internal/equipotest/preparation_integration_test.go |
| +++ b/internal/equipotest/preparation_integration_test.go |
| @@ -233,8 +233,8 @@ func privateProcTest(t *testing.T) bool { |
| cmd := exec.Command("unshare", "--user", "--map-root-user", "--pid", "--mount", "--fork", "--mount-proc", "/bin/sh", "-c", `"$1" -test.run "^$2$" -test.count=1 -test.v; result=$?; exit "$result"`, "sh", exe, t.Name()) |
| cmd.Env = append(os.Environ(), "EQUIPO_PRIVATE_PROC_TEST=1") |
| out, err := cmd.CombinedOutput() |
| - if err != nil { |
| - t.Fatalf("private /proc test: %v\n%s", err, out) |
| + if err != nil || !strings.Contains(string(out), "--- PASS: "+t.Name()) { |
| + t.Fatalf("private /proc test did not pass %s: %v\n%s", t.Name(), err, out) |
| } |
| t.Log(string(out)) |
| return true |
diff --git a/internal/equipotest/task_pages_test.go b/internal/equipotest/task_pages_test.go| index 106e82fa..c7080a2b 100644 |
| --- a/internal/equipotest/task_pages_test.go |
| +++ b/internal/equipotest/task_pages_test.go |
| @@ -166,6 +166,13 @@ func TestTaskFormsCSRFAndRevision(t *testing.T) { |
| taskGet(t, c, server.URL, res.Header.Get("Location"), 200) |
| } |
| func TestTaskLayoutRules(t *testing.T) { |
| + css, err := os.ReadFile("../equipo/static/equipo.css") |
| + executionMust(t, err) |
| + for _, accent := range []string{"border-left", "border-inline-start"} { |
| + if strings.Contains(strings.ToLower(string(css)), accent) { |
| + t.Fatal("forbidden CSS accent", accent) |
| + } |
| + } |
| f := bugFixture(t) |
| bugTask(t, f) |
| server, c := taskPageServer(t, f, false) |
| @@ -613,7 +620,9 @@ func TestUnconfinedLabelEverySurfaceForgedReport(t *testing.T) { |
| t.Fatal("fixture must claim confinement") |
| } |
| executionMust(t, f.s.RevokeIsolationAcknowledgement(connectionContext, ownerActor, f.ids["codex"], 1)) |
| - if _, err := f.s.CreateBug(connectionContext, ownerActor, f.project.ID, "forged", "forged"); err == nil { |
| + waiting, err := f.s.CreateBug(connectionContext, ownerActor, f.project.ID, "forged", "forged") |
| + executionMust(t, err) |
| + if waiting.WaitCode != "task.wait.setup" || waiting.JobID != 0 { |
| t.Fatal("unlisted tuple bypassed acknowledgement") |
| } |
| executionMust(t, f.s.AcknowledgeUnconfined(connectionContext, ownerActor, f.ids["codex"], 1)) |
diff --git a/packaging/equipo-runner.service b/packaging/equipo-runner.service| index b3ab3280..8c87cdbd 100644 |
| --- a/packaging/equipo-runner.service |
| +++ b/packaging/equipo-runner.service |
| @@ -1,7 +1,5 @@ |
| [Unit] |
| Description=equipo-runner |
| -After=network-online.target |
| -Wants=network-online.target |
| [Service] |
| Type=simple |