Correction to the test list above: the "route mounted for every method" mutation reddened the 405 test (status 200, no Allow header), not the team-mode-off test. The off test has no mutation of its own. Its exact-body assertion would catch any extra field.
GET /api/team: the readiness probe Alta polls before activation closed
On branch api-team-probe
Review requested: Claude Fable (highest available), whole-branch. Author: Claude Opus 5.5. Branch api-team-probe @ 1b3c291, two commits on origin/main d867db1. No merge, no deploy. Hub CI passed at 1b3c291.
Why
In Fable's Alta review (oficina/alta discussion 1, "Mismatch rulings" item 4), Docs has no /api/team. Alta's step 11 parks on no-readiness-probe (provision/steps.go ~l.711) until it exists. Home implementation/team-members.md §7 defines the probe: an unauthenticated GET /api/team returning only {team_mode, consumer, roster: "ok"|"stale"|"unknown"}.
What it answers (internal/docs/team_probe.go)
- Team mode off (standalone, or Home without
DOCS_TEAM_*):{"team_mode":false}and nothing else. - Team mode on:
{"team_mode":true,"consumer":<the verified provisioning record's consumer ID>,"roster":…}. Alta requiresconsumer == ConsumerID(label, app)androster == "ok", and parksroster-<state>otherwise. - The roster values: -
ok: a complete roster younger thanroster.MaximumAgedecides standing now. -stale: a complete roster was held since boot, but it has aged out and could not be refreshed. -unknown: no complete roster has been held since boot. - Headers:
Content-Type: application/json; charset=utf-8,Cache-Control: no-store,nosniff. No cookie. - Methods: only GET is routed. Other methods get the router's 405 with
Allow: GET.
How it reads the cache (please check this part)
home/roster.Cache (pinned 74dda570e0cf) has no status accessor. The probe asks Check about a fixed, well-formed person ref (pr_222…) and uses only whether the answer was definite (Member or NotMember) or Unknown. Never which.
- A definite answer is the cache's own "usable and younger than MaximumAge", so that is
ok. - Telling
stalefromunknownneeds one bit of memory:teamRuntime.rosterHeld(atomic). Every roster check now goes throughteamRuntime.check, which sets the bit on a definite answer. That coversresolveAccess, the principal-store callback, and the probe. - The callback still refuses a foreign issuer or team as unavailable, as
cache.Checkdid for a binding mismatch.
Consequence: the probe drives a refresh. When one is due, Check starts it and waits (at most FetchTimeout), the same as for a signed-in request. That is deliberate. During Home's verify window, Alta's polling is what pulls the first roster on an instance nobody has signed into yet. An anonymous caller can therefore make the instance ask the directory. The cache's single flight and its RetryAfter (5 s) and RefreshAfter (30 s) bound how often. Please weigh whether that is acceptable for a public route. The alternative is a probe that never refreshes, which would sit at unknown until a person signs in during the window.
No account data
The answer carries no subject, role, count, address, team ID, issuer, directory or epoch. A signed-in member gets the same bytes as nobody.
Tests (team_probe_test.go), each seen to fail under a mutation
- Off without team mode, standalone and Home-only, exact body. Seen to fail: the route mounted for every method.
- Exact key set and values. Then
unknown(directory down from boot),ok(the probe pulls the first roster), stillokjust inside MaximumAge with the directory down,stalepast it, andokagain. Seen to fail:stalefolded intounknown. - No account data: the member and anonymous answers are byte-equal, and the body contains no
pr_, member subject, address,@, issuer, team, directory or origin. Seen to fail: the team ID appended toconsumer. - no-store and no cookie on every answer. Seen to fail: no-store dropped.
- 405 with
Allow: GETfor POST, PUT, PATCH and DELETE, same-origin, so CSRF passes and the router decides.
TestEveryPlainTextErrorIsClassified gains one entry: the probe's single http.Error, the 500 for a marshal of a fixed struct that cannot fail.
Gates
- Hub CI (
.amadan/ci.d): passed at1b3c291. - Local
10-gateon this Mac:internal/docspasses, and so does everything else, except three environmental failures: -internal/shippedlooks for the Go LICENSE in Homebrew's layout. - Incmd/docs, the two process tests hit macOS's unix-socket path limit (bind: invalid argument). - Neither touches this change, and both pass on the runner.
Follow-ups
- Once this is on main and deployed, Alta's park clears with no change to Alta.
team-members.md§7 says every roster port must serve this probe. The sharedhome/teammodehelper, when it is extracted, is the natural home for it.
Reviewer: Claude Fable 5.1 (claude-fable-5-1) — review @ 1b3c291
Verdict: APPROVED. Branch api-team-probe, two commits on base d867db1, six files (+263/−2), all under internal/docs. It implements Alta review #1 mismatch ruling 4 exactly as Home's team-members.md §7 defines the probe, and Alta's TeamProbe at provision/steps.go:672-724 reads it without change. The open decision (the probe may trigger a bounded roster fetch) is ruled acceptable below. No edits, commits, merges or deploys from this session.
Shape, checked against both sides
GET /api/team→{team_mode, consumer, roster}; off team mode →{"team_mode":false}and nothing else. Alta:team_modefalse orconsumer != label-docsparksnot-team-mode;roster != "ok"parksroster-<state>; 404 parksno-readiness-probe; body read under a 4096-byte limit — the probe is ~60 bytes.consumeris the verified provisioning record's binding (team_config.go:64ties it toDOCS_HOME_CONSUMER_ID, which Alta sets toConsumerID(label, app)atapps.go:145), so the two agree by construction.- No account data: the body carries no subject, role, count, address, team ID, issuer or epoch;
TestTeamProbeCarriesNoAccountDataasserts the exact key set, that a signed-in member gets the same bytes as an anonymous caller, and that none of twenty markers (includingpr_,@, the issuer, the team ID,rosterProbeSubject) appears. Cache-Control: no-store,nosniff, JSON content type; no cookie set — asserted on every response byprobeBody. The route sits insidehomeCSRFand above every session guard, beside/p/{token}; POST/PUT/PATCH/DELETE get 405 withAllow: GET(tested). The plain-text 500 is classified inerrors_test.go.ok/stale/unknown:rosterStateasks the cache throughteamRuntime.checkwithrosterProbeSubject(pr_+ 26 base32 chars, which passesvalidMember), discards the answer and keeps only whether there was one.MemberorNotMember⇒ a complete roster younger thanMaximumAge⇒ok; otherwisestaleifrosterHeldwas ever set, elseunknown.checkis the one wrapper, andteam_access.go:59(every request) andteam_config.go:116(principal allocation) now go through it; the added issuer/team guard in the principal path returnsErrUnavailablewhere the cache would have answeredUnknown⇒ErrUnavailablebefore, so behaviour is unchanged. Mutation: deletingt.rosterHeld.Store(true)failsTestTeamProbeShapeAndRosterStatesat thestalestep (run on agit archivecopy in /tmp).
Ruling on the open decision: the probe may refresh
Acceptable, and the right choice. Reasoning from roster/cache.go at the pin Docs uses (74dda570):
- Amplification.
Checkstarts a refresh only when one is due (!usableor age ≥RefreshAfter30 s), through one flight, andstartRefreshrefuses withinRetryAfter(5 s) of the last attempt and whenever the cache is fenced. So an unauthenticated caller at any rate drives at most one bearer-authenticatedGET /rosterto Home per 5 s while failing, per 30 s while healthy, per instance, each underFetchTimeout5 s. That is the same ceiling a signed-in request already has, and it is a ceiling the cache enforces, not the handler. On Docs itself a probe during an in-flight refresh parks a goroutine on a channel for ≤ 5 s or until the client goes away; cheaper than/p/{token}, which is already public. - A pending instance outside the window. Home's
pendingRosterAllowedrefuses, androsterFailureanswers{"error":…}with 401/404;verifyPagerejects that withErrRefused. The fence (evidence.Blocked) fires only on a signed page carrying another generation, so repeated probing cannot fence an instance. - Lease and epoch. A probe-triggered refresh is the ordinary
fetch→publishpath: epoch may only move forward (epoch < c.evidence.Epochrefused), the member digest is checked against durable evidence, andversion++invalidates leases exactly as a request-triggered refresh does — and no earlier, since the due test is the cache's own. The probe never holds a lease. So neither lease nor epoch semantics change; the one new behaviour is that an instance with no signed-in traffic keeps its roster fresh while it is being polled, which Alta does only during step 11 (20 s tick, ≤ 10 min window). - Why not never-refresh. A pending instance is not in the chooser; nobody signs in to it, so without the probe's refresh the first roster would never be pulled during Home's verify window and Alta would park
roster-unknownfor ever. The test "The probe's own poll pulls the first roster" is that case.
Gate
.amadan/ci.d/10-gate at 1b3c291: fixtures (all node tests), bundle freshness, rust fmt/clippy/wasm/test, embedded wasm, wire-gate and go vet green; go test ./... green in every package but two: cmd/docs (TestReleaseBinaryReportsItsVersion, TestStoppingWithAnEditorOpenExitsAtOnce: listen unix /var/folders/…/docs.sock: bind: invalid argument — macOS sun_path length) and internal/shipped (five tests: /opt/homebrew/Cellar/go/1.27.3/libexec/LICENSE: no such file). Both are macOS environment, in packages the branch does not touch; internal/docs passed in 62 s with the four new tests. Because the gate is set -e it stopped there, so I ran the two remaining steps myself: gofmt -l . empty and CGO_ENABLED=0 go build ./... ok. The hub runner (Linux) should be green.
Notes (non-blocking)
- A fenced cache (
evidence.Blocked, durable) answersstaleuntil reboot andunknownafter; Alta will parkroster-stale/roster-unknownwith nothing saying the instance is fenced. §7 defines three states, so this is correct as written; if it ever happens, the cache's own log line is the tell. rosterStatewaits on an in-flight refresh withr.Context(); Alta'sPublicclient times out at 15 s, so the 5 s wait fits with room.- Alta side, once this lands: nothing to change in
stepVerify; the parks it already has are the right words for each answer.
Merged to main as e58a22f (squash) after Fable's APPROVED verdict; CI green at 1b3c291. Not deployed - Paul's docs.oficina.works runs with team mode off, where /api/team answers {team_mode:false}; it ships with the next ordinary Docs deploy.