Merge branch 'team-page-seeded' into main
Merge team-page-seeded: Equipo/Base keep their own people; who can see the team's data (copy approved by Paul 2026-11-30)
4 files changed,
+75
−3
internal/home/directorydata/members.go+17 −0internal/home/team_page.go+9 −2internal/home/team_page_test.go+41 −0internal/home/templates/team.html+8 −1
CI failed — run details
CI log
amadan: .amadan/timeout: this job's budget is 20m0s (this runner allows up to 30m0s)
=== vet ===
CGO_ENABLED=0 go vet ./...
CGO_ENABLED=0 go vet -tags browser ./internal/home/
cd handoff && CGO_ENABLED=0 go vet ./...
cd roster && CGO_ENABLED=0 go vet ./...
cd dashboard && CGO_ENABLED=0 go vet ./...
cd connect && CGO_ENABLED=0 go vet ./...
cd teammode && CGO_ENABLED=0 go vet ./...
=== fmt ===
=== build ===
CGO_ENABLED=0 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ./cmd/home ./cmd/oficina ./internal/operatorlaunch
cd handoff && CGO_ENABLED=0 go build ./...
cd roster && CGO_ENABLED=0 go build ./...
cd dashboard && CGO_ENABLED=0 go build ./...
cd connect && CGO_ENABLED=0 go build ./...
cd teammode && CGO_ENABLED=0 go build ./...
=== go-test ===
CGO_ENABLED=0 go test -count=1 ./...
? amadan.net/oficina/home/cmd/home [no test files]
ok amadan.net/oficina/home/cmd/home-placeholder 0.905s
? amadan.net/oficina/home/cmd/oficina [no test files]
ok amadan.net/oficina/home/internal/guardstest 0.283s
ok amadan.net/oficina/home/internal/home 57.333s
ok amadan.net/oficina/home/internal/home/directorydata 1.408s
ok amadan.net/oficina/home/internal/home/logtest 0.003s
ok amadan.net/oficina/home/internal/home/seal 0.002s
ok amadan.net/oficina/home/internal/home/sealtest 0.003s
ok amadan.net/oficina/home/internal/home/wisp 0.043s
ok amadan.net/oficina/home/internal/operator 6.418s
ok amadan.net/oficina/home/internal/operatorlaunch 4.113s
ok amadan.net/oficina/home/internal/provisioner 48.727s
cd handoff && CGO_ENABLED=0 go test -count=1 ./...
ok amadan.net/oficina/home/handoff 0.655s
ok amadan.net/oficina/home/handoff/seal 0.003s
cd roster && CGO_ENABLED=0 go test -count=1 ./...
ok amadan.net/oficina/home/roster 5.128s
cd dashboard && CGO_ENABLED=0 go test ./...
ok amadan.net/oficina/home/dashboard (cached)
cd connect && CGO_ENABLED=0 go test -count=1 ./...
ok amadan.net/oficina/home/connect 1.395s
ok amadan.net/oficina/home/connect/linkstore 0.486s
cd teammode && CGO_ENABLED=0 go test -count=1 ./...
ok amadan.net/oficina/home/teammode 0.098s
? amadan.net/oficina/home/teammode/teammodetest [no test files]
=== race ===
go test -race -count=1 ./internal/home/ ./internal/operator/ ./internal/operatorlaunch/ ./internal/home/directorydata/
--- FAIL: TestOperatorCommandActualBinaryDispatch (2.77s)
operator_command_linux_test.go:448: real binary dispatch failed 2 true
FAIL
FAIL amadan.net/oficina/home/internal/home 337.211s
ok amadan.net/oficina/home/internal/operator 82.669s
ok amadan.net/oficina/home/internal/operatorlaunch 22.381s
ok amadan.net/oficina/home/internal/home/directorydata 23.479s
FAIL
make: *** [Makefile:137: test-race] Error 1
amadan: step race failed: exit status 2
amadan: job failed at step race — its output is above, not at the tail of this log
diff --git a/internal/home/directorydata/members.go b/internal/home/directorydata/members.go| index cbca8b5..af9744e 100644 |
| --- a/internal/home/directorydata/members.go |
| +++ b/internal/home/directorydata/members.go |
| @@ -613,3 +613,20 @@ func (s *Store) ConfirmAdd(ctx context.Context, id, actor string, now time.Time, |
| } |
| return in, nil |
| } |
| + |
| +// SeededApps are the apps that keep their own list of people, seeded from |
| +// their environment rather than Home's roster (oficina/alta |
| +// design/team-bundle, spec §5.1 rule 1): a removal on the Team page does |
| +// not reach them. |
| +var SeededApps = []string{"equipo", "base"} |
| + |
| +// HasLiveSeededApp reports whether team has a live instance of a seeded |
| +// app, so the Team page can say that changes there don't reach it. |
| +func (s *Store) HasLiveSeededApp(ctx context.Context, teamID int64) (bool, error) { |
| + var n int |
| + err := s.db.QueryRowContext(ctx, `SELECT count(*) FROM team_instances WHERE team_id=? AND state='live' AND app IN (?,?)`, teamID, SeededApps[0], SeededApps[1]).Scan(&n) |
| + if err != nil { |
| + return false, ErrUnavailable |
| + } |
| + return n > 0, nil |
| +} |
diff --git a/internal/home/team_page.go b/internal/home/team_page.go| index aa403a5..7878c5a 100644 |
| --- a/internal/home/team_page.go |
| +++ b/internal/home/team_page.go |
| @@ -104,8 +104,11 @@ type memberView struct { |
| } |
| type teamView struct { |
| - Name, SQID, Error string |
| - Owner, CanAdd bool |
| + Name, SQID, Error string |
| + Owner, CanAdd bool |
| + // Seeded: the team has a live Equipo or Base, whose own lists of |
| + // people a change here does not reach (team-bundle spec §5.1 rule 1). |
| + Seeded bool |
| Members []memberView |
| AddName, AddRole, FieldError string |
| } |
| @@ -181,6 +184,10 @@ func (a *App) renderTeam(w http.ResponseWriter, r *http.Request, viewer, sqid st |
| return |
| } |
| v := a.teamView(viewer, t, members) |
| + if v.Seeded, err = a.directory.store.HasLiveSeededApp(r.Context(), t.ID); err != nil { |
| + a.errorPage(w, r, http.StatusServiceUnavailable) |
| + return |
| + } |
| v.Error, v.FieldError, v.AddName, v.AddRole = notice.Error, notice.FieldError, notice.AddName, notice.AddRole |
| if v.AddRole == "" { |
| v.AddRole = "member" |
diff --git a/internal/home/team_page_test.go b/internal/home/team_page_test.go| index a33565a..183501a 100644 |
| --- a/internal/home/team_page_test.go |
| +++ b/internal/home/team_page_test.go |
| @@ -520,3 +520,44 @@ func TestTeamWriteBudget(t *testing.T) { |
| t.Fatal(r.Code) |
| } |
| } |
| + |
| +// A team with a live Equipo or Base says, on the Team page, that a change |
| +// there does not reach those two (oficina/alta design/team-bundle, spec |
| +// §5.1 rule 1); every Team page names who can see the team's data. |
| +func TestTeamPageSaysSeededAppsKeepTheirOwnPeople(t *testing.T) { |
| + f := newTeamFixture(t) |
| + member := f.person(t, "member@example.invalid") |
| + f.member(t, f.sqid, member, "member") |
| + ownerCookie := f.session(t, f.owner, time.Now().Add(-time.Hour)) |
| + const ( |
| + removeSeeded = "except Equipo and Base, which keep their own list of people" |
| + noteSeeded = "change who is on those in Equipo and Base themselves" |
| + removePlain = "<p>They lose this team in every app within a minute.</p>" |
| + notePlain = "Changes reach every app in this team within a minute.</p>" |
| + operatorLine = "Paul Campbell runs this Oficina and can see everything this team keeps in it." |
| + ) |
| + body := f.get(f.teamURL(), ownerCookie).Body.String() |
| + if !strings.Contains(body, removePlain) || !strings.Contains(body, notePlain) || strings.Contains(body, removeSeeded) || strings.Contains(body, noteSeeded) || !strings.Contains(body, operatorLine) { |
| + t.Fatal("team without Equipo or Base: wrong lines") |
| + } |
| + // A pending Equipo is not yet one: only a live instance counts. |
| + exec := func(state string) { |
| + t.Helper() |
| + if _, err := f.directory.db.Writer().Exec("INSERT OR REPLACE INTO team_instances VALUES(?,?,?,?,?)", 1, "equipo", "https://canarylabel.equipo.oficina.works", "canarylabel-equipo", state); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + exec("pending") |
| + if body = f.get(f.teamURL(), ownerCookie).Body.String(); strings.Contains(body, removeSeeded) { |
| + t.Fatal("a pending Equipo changed the lines") |
| + } |
| + exec("live") |
| + body = f.get(f.teamURL(), ownerCookie).Body.String() |
| + if !strings.Contains(body, removeSeeded) || !strings.Contains(body, noteSeeded) || strings.Contains(body, removePlain) || strings.Contains(body, notePlain) || !strings.Contains(body, operatorLine) { |
| + t.Fatal("team with a live Equipo: wrong lines") |
| + } |
| + mem := f.get(f.teamURL(), f.session(t, member, time.Now())).Body.String() |
| + if !strings.Contains(mem, noteSeeded) || !strings.Contains(mem, operatorLine) || strings.Contains(mem, "@") && strings.Contains(mem, "member@example.invalid") { |
| + t.Fatal("member view: wrong lines, or an address") |
| + } |
| +} |
diff --git a/internal/home/templates/team.html b/internal/home/templates/team.html| index 93ef508..aa82b9b 100644 |
| --- a/internal/home/templates/team.html |
| +++ b/internal/home/templates/team.html |
| @@ -43,7 +43,11 @@ |
| <summary rst-btn="ghost sm">Remove</summary> |
| <form method="post" action="/team/remove" rst-form> |
| <input type="hidden" name="team" value="{{$.Data.SQID}}"><input type="hidden" name="person" value="{{.Ref}}"> |
| + {{- if $.Data.Seeded}} |
| + <p>They lose this team in every app within a minute, except Equipo and Base, which keep their own list of people. Remove them there too.</p> |
| + {{- else}} |
| <p>They lose this team in every app within a minute.</p> |
| + {{- end}} |
| <div rst-form-foot><button type="submit" rst-btn="danger sm">Remove from team</button></div> |
| </form> |
| </details> |
| @@ -53,7 +57,9 @@ |
| </div> |
| {{- end}} |
| </div> |
| -<p home-dashboard-note>Changes reach every app in this team within a minute.</p> |
| +{{if .Seeded}}<p home-dashboard-note>Changes reach every app in this team within a minute, except Equipo and Base: change who is on those in Equipo and Base themselves.</p> |
| +{{else}}<p home-dashboard-note>Changes reach every app in this team within a minute.</p> |
| +{{end}} |
| {{if .Owner}}{{if .CanAdd}} |
| <section id="add" home-team-add aria-labelledby="add-heading"> |
| <h2 id="add-heading">Add someone</h2> |
| @@ -76,4 +82,5 @@ |
| {{end}}{{else}} |
| <p>Only owners can change who is on this team.</p> |
| {{end}} |
| +<p home-dashboard-note>Paul Campbell runs this Oficina and can see everything this team keeps in it.</p> |
| {{end}}{{end}} |