Calls team mode: Fable #31 fixes
- Blocker: POST /signin under a join cookie decides the link's host before the address is read (teamJoinCookieStands, through meetingStands): Unknown is a retryable no-store 503, nothing written, nothing mailed; NotMember settles the meeting and is the dead link it was. The Unknown-host test now asserts 503, no row, no mail. - Test gap: an agent's item GETs under an Unknown operator are 503, an ended meeting's included (which no host check would refuse). - Note: the hub's tick and resume-probe log ErrStandingUnknown at Debug; a failed read stays a Warn (TestStandingUnknownIsNotAWarning). - Spec §16: Paul's 2026-11-01 ruling (a removed host's call ends for everyone), the creator-as-host note, §16.3's sign-in sentence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+145
−16
docs/superpowers/specs/2026-09-07-meet-design.md+28 −11internal/calls/auth.go+3 −0internal/calls/hub/hub.go+8 −1internal/calls/hub/relay.go+8 −1internal/calls/hub/standing_unknown_test.go+50 −0internal/calls/team_call_test.go+20 −3internal/calls/team_links.go+28 −0
CI passed — run details
Intent
diff --git a/docs/superpowers/specs/2026-09-07-meet-design.md b/docs/superpowers/specs/2026-09-07-meet-design.md| index 5ec3751..58b20d4 100644 |
| --- a/docs/superpowers/specs/2026-09-07-meet-design.md |
| +++ b/docs/superpowers/specs/2026-09-07-meet-design.md |
| @@ -3461,6 +3461,9 @@ the peer id. |
| and `implementation/teammode-package.md` §7.4, on `home/teammode` (Home |
| main 67c12e3). Calls is the last of Paul's port order (Sheets, Slides, |
| Memoria, Calendar, Calls). Questions for Paul are marked **Paul**. |
| +Reviewed by Claude Fable 5.1 on oficina/meet #31 (CHANGES REQUIRED at |
| +8baa6f5 for the sign-in form under an Unknown host, fixed below; every |
| +deviation accepted). |
| ### 16.1 What turns it on |
| @@ -3526,22 +3529,31 @@ stands on its host and a Slides presentation on its presenter. |
| write, `ended_by = system:host-removed`, every link revoked) and tells |
| every open stream `lost {reason: "ended"}`, exactly as a member's End. |
| Its links 404 like any ended meeting's, nobody new is let in, no grant |
| - is minted through them, and no pending join is written for them. It is |
| + is minted through them, and no pending join is written for them (the |
| + sign-in form, under a join cookie for one, asks the host before it |
| + reads the address, and settles it too). It is |
| noticed on the first thing that touches the meeting — a link followed, |
| a page, a stream's decision, a signal, an ICE fetch, the list (which |
| settles every listed meeting's host), or the hub's fifteen-second tick |
| for a quiet call — so within the lease plus a tick. Re-adding the host |
| does not revive it. |
| - Host **Unknown**: nothing is ended; every new entry (following a link, |
| - joining by name, a fresh stream, `join`, an ICE fetch, a signal) is a |
| - retryable 503; the call in progress is held (§16.5). |
| - |
| -**Paul — the call in progress when its host is removed.** Built: it ends, |
| -for everyone in it, members included (Slides ends a removed presenter's |
| -talk the same way); the members can start another in one click. The |
| -alternative keeps the meeting for the members still in it and ends only |
| -the guests (whose way in was the host's link), leaving the links dead. |
| -It is a change in one place (`teamStandingFor` and `teamStreamDecide`). |
| + joining by name, signing in through the link — `POST /signin` under its |
| + join cookie, decided before the address is read, so nothing is written |
| + and nothing mailed — a fresh stream, `join`, an ICE fetch, a signal) is |
| + a retryable no-store 503; the call in progress is held (§16.5). |
| + |
| +**The call in progress when its host is removed — RULED 2026-11-01 by |
| +Paul: it ends for everyone in it**, members included, as Slides ends a |
| +removed presenter's talk; the members can start another in one click. |
| +(Fable on #31: after removal the meeting has no host, and keeping it for |
| +the members would need a re-host write that nobody's standing makes |
| +cleanly; if that is ever wanted it is "a present member takes the meeting |
| +over", not "end only the guests".) The host is the creator, not a link's |
| +minter (Fable, accepted): a link is what the meeting hands out. A creator |
| +Calls cannot resolve to a person (anything but `person:` or `agent:`) |
| +stands on nobody and the meeting ends; no such meeting exists in a team |
| +database, which is new. |
| ### 16.4 Writes |
| @@ -3576,6 +3588,10 @@ the member's own standing too; a guest's own standing is not asked (ruling |
| the browser's stall counter never reaches "unreachable" during a Home |
| blip. Terminal events (`lost`, `ended`) are delivered whatever the |
| standing. |
| +- **Logs.** The hub's tick and the resume probe log a standing read that |
| + failed; one that is merely undecidable (`ErrStandingUnknown`, every |
| + peer every fifteen seconds through a blip) is logged at Debug, a failed |
| + read still at Warn. |
| - **`POST /m/{sqid}/signal`** and **`GET /m/{sqid}/ice`** are refused with |
| a retryable 503 under Unknown (the host's or the member's own) — the |
| browser's queue retries 5xx (§4.6) — and with the not-found body for a |
| @@ -3605,7 +3621,8 @@ the member's own standing too; a guest's own standing is not asked (ruling |
| Unknown (a missing meeting too: never "not found"). |
| - **The drive surface's JSON list** (`GET /api/v1/meetings`) is a |
| retryable 503 when partial; an agent stands on its operator's standing, |
| - asked on every request (removed: the one not-found body). |
| + asked on every request (removed: the one not-found body; Unknown: a |
| + retryable 503 at the gate, for the list and every item alike). |
| - **Native**: the Mac and iPhone apps point at Paul's server and are |
| unchanged. Every route they use is standing-checked: `/native/meetings/ |
| start` and `/native/devices` are member routes (503 under Unknown, |
diff --git a/internal/calls/auth.go b/internal/calls/auth.go| index 343cb68..0fd103f 100644 |
| --- a/internal/calls/auth.go |
| +++ b/internal/calls/auth.go |
| @@ -99,6 +99,9 @@ func (a *app) authorize(address string) bool { |
| func (a *app) gateBegin(next http.HandlerFunc) http.HandlerFunc { |
| return func(w http.ResponseWriter, r *http.Request) { |
| _ = r.ParseForm() |
| + if a.team != nil && !a.teamJoinCookieStands(w, r) { |
| + return |
| + } |
| address := r.FormValue("address") |
| // Syntax first. The gate below answers every refusal as "sent", so |
| // a malformed address used to go straight to "Check your email" |
diff --git a/internal/calls/hub/hub.go b/internal/calls/hub/hub.go| index 23883c2..0e1575a 100644 |
| --- a/internal/calls/hub/hub.go |
| +++ b/internal/calls/hub/hub.go |
| @@ -493,7 +493,14 @@ func (h *Hub) Tick(ctx context.Context) { |
| for _, c := range checks { |
| kind, ok, err := h.cfg.StandingFor(ctx, c.room, c.personID) |
| if err != nil { |
| - h.cfg.Logger.Warn("hub: standing lookup failed on tick", |
| + level := slog.LevelWarn |
| + if errors.Is(err, ErrStandingUnknown) { |
| + // A roster blip: every joined participation, every |
| + // fifteen seconds, for as long as it lasts. Expected, so |
| + // not a warning; nothing changes until it is decided. |
| + level = slog.LevelDebug |
| + } |
| + h.cfg.Logger.Log(ctx, level, "hub: standing lookup failed on tick", |
| "room", c.room, "peer", c.peer, "error", err) |
| continue // this participation waits for the next tick |
| } |
diff --git a/internal/calls/hub/relay.go b/internal/calls/hub/relay.go| index ec43559..0e760dd 100644 |
| --- a/internal/calls/hub/relay.go |
| +++ b/internal/calls/hub/relay.go |
| @@ -4,6 +4,7 @@ import ( |
| "context" |
| "errors" |
| "fmt" |
| + "log/slog" |
| "time" |
| ) |
| @@ -196,7 +197,13 @@ func (h *Hub) CanResume(ctx context.Context, sqid, session string, peer PeerID) |
| // A standing read that failed is not evidence of anything. The |
| // participation answers for itself, as it did before §15.12, and |
| // the tick will re-read standing in fifteen seconds. |
| - h.cfg.Logger.Warn("hub: standing lookup failed on a resume probe", "room", sqid, "peer", peer, "error", err) |
| + level := slog.LevelWarn |
| + if errors.Is(err, ErrStandingUnknown) { |
| + // A roster blip, said once per probe for every peer in every |
| + // call: expected while it lasts, so not a warning. |
| + level = slog.LevelDebug |
| + } |
| + h.cfg.Logger.Log(ctx, level, "hub: standing lookup failed on a resume probe", "room", sqid, "peer", peer, "error", err) |
| } |
| h.mu.Lock() |
| defer h.mu.Unlock() |
diff --git a/internal/calls/hub/standing_unknown_test.go b/internal/calls/hub/standing_unknown_test.go| new file mode 100644 |
| index 0000000..9bd8ac4 |
| --- /dev/null |
| +++ b/internal/calls/hub/standing_unknown_test.go |
| @@ -0,0 +1,50 @@ |
| +package hub |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "errors" |
| + "log/slog" |
| + "strings" |
| + "sync/atomic" |
| + "testing" |
| +) |
| + |
| +// Standing that cannot be decided now (team mode's roster outside its |
| +// lease) is expected for as long as a Home blip lasts, for every peer on |
| +// every tick and every resume probe: it is logged below Warn, while a |
| +// failed read stays a warning. |
| +func TestStandingUnknownIsNotAWarning(t *testing.T) { |
| + var answer atomic.Pointer[error] |
| + var logs bytes.Buffer |
| + h := New(Config{ |
| + Logger: slog.New(slog.NewTextHandler(&logs, &slog.HandlerOptions{Level: slog.LevelWarn})), |
| + StandingFor: func(context.Context, string, int64) (Kind, bool, error) { |
| + if err := answer.Load(); err != nil { |
| + return 0, false, *err |
| + } |
| + return KindMember, true, nil |
| + }, |
| + }) |
| + res, err := h.Open("room", "session", 1, "A", KindMember) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := h.Join(context.Background(), "room", "session", res.Peer); err != nil { |
| + t.Fatal(err) |
| + } |
| + unknown := ErrStandingUnknown |
| + answer.Store(&unknown) |
| + h.Tick(context.Background()) |
| + h.CanResume(context.Background(), "room", "session", res.Peer) |
| + if logs.Len() != 0 { |
| + t.Fatalf("Unknown standing logged a warning:\n%s", logs.String()) |
| + } |
| + locked := errors.New("database is locked") |
| + answer.Store(&locked) |
| + h.Tick(context.Background()) |
| + h.CanResume(context.Background(), "room", "session", res.Peer) |
| + if strings.Count(logs.String(), "level=WARN") != 2 { |
| + t.Fatalf("a failed read is no longer a warning:\n%s", logs.String()) |
| + } |
| +} |
diff --git a/internal/calls/team_call_test.go b/internal/calls/team_call_test.go| index da910fc..20cc5cd 100644 |
| --- a/internal/calls/team_call_test.go |
| +++ b/internal/calls/team_call_test.go |
| @@ -363,12 +363,15 @@ func TestTeamHostUnknownRefusesEntriesAndHoldsTheCall(t *testing.T) { |
| visitor := f.jar() |
| f.expired() |
| f.cookies = visitor |
| - if w := f.post("/signin", "address=outsider%40example.test"); w.Code != http.StatusSeeOther { |
| - t.Fatalf("sign-in = %d", w.Code) |
| - } |
| + // The sign-in form under that cookie: a retryable 503 — not "check |
| + // your email" with no mail behind it — and no pending row, no mail. |
| + retryable(t, "signing in through the link", f.post("/signin", "address=outsider%40example.test")) |
| if n := f.count("pending_joins"); n != 0 { |
| t.Fatalf("a link on an undecidable host wrote %d pending joins", n) |
| } |
| + if body := f.mailBody(); body != "" { |
| + t.Fatalf("a link on an undecidable host mailed:\n%s", body) |
| + } |
| f.cookies = map[string]*http.Cookie{} |
| retryable(t, "following the link", f.page("/j/"+token)) |
| retryable(t, "joining by name", f.post("/j/"+token+"/guest", "name=Late")) |
| @@ -602,10 +605,24 @@ func TestTeamAgentStandsOnItsOperator(t *testing.T) { |
| if w := f.api("GET", "/api/v1/meetings", bearer, ""); w.Code != http.StatusOK { |
| t.Fatalf("member's agent = %d", w.Code) |
| } |
| + f.member(teamSubject('q'), "member") |
| + sqid, _ := f.meeting("Somebody's") |
| + // And one already over, which no host check would refuse: only the |
| + // gate's own answer for the operator stands between it and a 200. |
| + over, _ := f.meeting("Over") |
| + if w := f.post("/meetings/"+over+"/end", ""); w.Code != http.StatusSeeOther { |
| + t.Fatalf("end = %d", w.Code) |
| + } |
| f.expired() |
| if w := f.api("GET", "/api/v1/meetings", bearer, ""); w.Code != http.StatusServiceUnavailable || w.Header().Get("Retry-After") == "" || w.Header().Get("Cache-Control") != "no-store" { |
| t.Fatalf("operator Unknown = %d", w.Code) |
| } |
| + // An item, too: a meeting another member made. |
| + for _, item := range []string{sqid, over} { |
| + if w := f.api("GET", "/api/v1/meetings/"+item, bearer, ""); w.Code != http.StatusServiceUnavailable || w.Header().Get("Retry-After") == "" || w.Header().Get("Cache-Control") != "no-store" { |
| + t.Fatalf("an item under an Unknown operator = %d %s", w.Code, w.Body.String()) |
| + } |
| + } |
| f.removed(op) |
| if w := f.api("GET", "/api/v1/meetings", bearer, ""); w.Code != http.StatusNotFound || !strings.Contains(w.Body.String(), "not-found") { |
| t.Fatalf("operator removed = %d %s", w.Code, w.Body.String()) |
diff --git a/internal/calls/team_links.go b/internal/calls/team_links.go| index ada2d30..cad4198 100644 |
| --- a/internal/calls/team_links.go |
| +++ b/internal/calls/team_links.go |
| @@ -32,6 +32,34 @@ func (a *app) teamLinkHost(w http.ResponseWriter, r *http.Request, m Meeting) (* |
| return nil, false |
| } |
| +// teamJoinCookieStands is the sign-in form's host check (POST /signin), |
| +// made before the address is read: a join cookie whose link's host |
| +// cannot be decided now is a retryable 503, as following the link itself |
| +// is (nothing is written, nothing is mailed), rather than "check your |
| +// email" with no mail behind it. A host who has left ends the meeting |
| +// here (meetingStands), so the cookie's link is dead and mayRequestLink |
| +// answers as it always has for a dead link. The work does not depend on |
| +// the address, and the holding page already gives the same person the |
| +// same 503, so it is no membership oracle. It reports whether the form |
| +// may go on. |
| +func (a *app) teamJoinCookieStands(w http.ResponseWriter, r *http.Request) bool { |
| + ck, ok := a.readJoinCookie(r) |
| + if !ok { |
| + return true |
| + } |
| + _, m, live, err := a.store.liveLinkByHash(r.Context(), ck.TokenHash) |
| + if err != nil || !live { |
| + // Read failures and dead links are mayRequestLink's to answer, |
| + // as before. |
| + return true |
| + } |
| + if _, st := a.meetingStands(r.Context(), m); st == roster.Unknown { |
| + a.teamUnavailable(w, r) |
| + return false |
| + } |
| + return true |
| +} |
| + |
| // teamFollowSignedIn is followLink's signed-in half in team mode. A member |
| // goes to the holding screen; somebody the roster has taken off the team |
| // is signed out and told so, exactly as on any other page; anyone else — |