Reviewer: Claude Fable 5.1 (claude-fable-5-1) β whole-code review @ 0791dfd
π€ Whole-code review of teammode @ 0791dfdf351f9399ec6d7d6873b9d170764a9de6 (base 0cee9ba, four commits), against my sequencing ruling and roster note on oficina/sheets #52, oficina/home #97, Docs e58a22f (teamstate/, team_config.go, team_access.go, team_probe.go, principalstore), Sheets ca78cc1 (teamstate/), and the four connect consumers on their origin/main (slides, calendar, memoria, calls). Read in a scratch worktree, since removed. make test run locally: vet, fmt, build and go-test green across every module; test-race stops at the pre-existing internal/provisioner linux-only setup failure before it reaches the submodules, so I ran -race on roster, connect and teammode myself with the Makefile's environment: all green. Hub CI green at the tip.
Verdict: APPROVED β the code as reviewed. Two corrections to the design record and a landing order are required before merge (below); they need no re-review.
Required before landing (no re-review)
implementation/teammode-package.mdΒ§6, "A follow-up bump in Home is optional." β wrong, and the sentence that matters most for the next four ports. Replace with: after this lands, one commit on main re-pinsteammode/go.mod(roster, connect) and the rootgo.mod(roster, today onfeat-roster-lease) to the main commit, before any branch is deleted and before Docs or Sheets re-point. Reasoning under ruling 5.implementation/teammode-package.mdΒ§3 invariant 6, "A refusedOpenwrites no marker." β true for the census and a different binding, not for the step after:runtime.go:73-79commitsActivateand then builds the cache, so aroster.Newrefusal (unreadable or malformed evidence) leaves the marker behind. That is Docs' order too and it is harmless β the marker names the binding that was just verified, and the next boot with the same configuration re-activates as a no-op β but an invariant list has to say what the code does. Fix: "a refused census or binding writes no marker; a cache that cannot open leaves the verified marker in place and refuses boot until it can."
Rulings
1. Roster lease (roster/cache.go)
Accepted as written, both additions included.
- The #97 fix.
Leasecarries subject, role, the version it was decided at and a fence count (cache.go:83-90).current(:94-103) accepts a newer version only when the cache is usable, the deadline (c.start+MaximumAgeof the fetch that decided it,:373) has not passed, no fence has happened, the subject still holds that role, andsince[subject] <= lease.version.publish(:519-534) bumps the version first and carriessinceforward only for an unchanged (subject, role) pair; everything else gets the new version. So an unchanged publication keeps the lease on its original deadline (mutation R4, "deadline follows the publication", killed byTestLeaseSurvivesUnchangedPublicationOnItsOwnDeadline), and the 60 s removal contract is exactly what it was: a lease ends at the publication that removes or re-roles the subject, or at its own deadline, whichever first. - No revival after removal β accepted. A lease is an observation that every publication since has confirmed; a removal is a publication that denied it, and a re-add inside the window is a new fact that wants a new decision. The per-member
sinceis the right instrument: it is version-keyed, so a remove-then-re-add at versions 3 and 4 givessince=4 > 2for a lease from version 2, and a role flip-and-back is caught the same way. Mutation R1 (since check dropped) is killed byTestLeaseEndsOnRemovalAndReAddDoesNotReviveIt; R5 (<=to<) by three tests. - Fences end all earlier leases β accepted. This is not new behaviour; it is the pre-#97 behaviour preserved for the one case where #97's relaxation would be wrong. Before this branch
fence()bumped the version and every lease died, and the next publication bumped it again, so nothing revived. Without the counter, a post-fence publication listing the subject unchanged would now revive a pre-fence lease (sincecarries forward across the fence becausefence()does not clearmembers). The counter keeps the old rule. The justification in the comment is right form < c.monoand forUpdateRecord(a new record may carry a new generation or floor); for a pure wall-clock discrepancy the monotonic deadline is in fact still sound, so the rule is conservative there β a retryable 503 on an already-rare event, in the safe direction. Mutations R2 and R8 (check dropped; counter not bumped) killed byTestLeaseEndedByFenceStaysEndedAfterPublication. - Epoch semantics unchanged.
publish's epoch floor and digest checks (:498-504) are untouched and run before any state changes;sinceis keyed on the cache version, not the epoch. The blocked-generation path still fences and never publishes again. - The author's recorded equivalent (role check alone) holds: R6 survives because a role change also resets
since; R7 ("any member accepted") is killed by two tests, so the pair is live.
2. connect hooks (connect/api.go, connect/bridge.go)
Byte-identical with both nil β verified. The one structural change in complete (bridge.go:215-218) replaces links.Resolve(claims.Issuer, β¦) with a pre-check on claims.Issuer == b.issuer then b.Resolve; linkstore.Resolve (store.go:181) returned ErrRefused for a foreign issuer, so the outcome is the same, and the exchange verifies the issuer anyway. Resolve with homeOnly == nil returns linkstore's answer unchanged (api.go:84). All four consumers construct connect.Config with keyed fields and set neither hook (slides home.go:46, calendar home.go:78, memoria home.go:47, calls home.go:53), and use only Resolve, ResolveSession and Linked. The pre-existing connect suite passes unchanged.
HomeOnly everywhere a Home subject resolves β verified. Every person resolution in connect goes through existingPerson (bridge.go:250), which for HomeMethod is b.Resolve (:252) and so the link then the hook; that covers ResolveSession (api.go:116), completion's same-person check (bridge.go:238), and localBinding/link_handlers.go:25,170 (which then refuse a Home session as not fresh-local, correctly: a Home-only person has nothing to link). Same-person 403 holds: bridge.go:239 compares arriving.ID; mutation C1 is killed by TestKnownHomeOnlyArrivalOverAnotherSessionIsRefused and the pre-existing TestHomeBridgeUnknownAndDifferentCurrentAccountNeverMint, and the test asserts the local session survives.
Unlinked only on ordinary completion with nobody signed in β verified. The link flow returns at bridge.go:211 before the hook; the condition at :219 requires result.session == nil, which Finish sets from actualSession (an unreadable or duplicate session cookie is 403 at :171-175 before complete runs, closing the Sheets divergence I noted on #52). The hook runs after Store.Finish has committed the consumption (handoff/http.go:265 then :270), so AdmitUnlinked's Check, which may wait on a refresh that publishes through the writer, never runs under the writer. Mutation C2 (hook asked over a live session) killed.
ErrNoPerson β unknown page + resume marker β verified. homeOnlyPerson maps ErrNoPerson to linkstore.ErrRefused (api.go:97-98), which is the branch that calls rememberUnknown (bridge.go:229-232) β the real one from routes.go:49, not only the test stub. Mutation C7 (marker skipped for a hook refusal) killed; C5 (storage read as refusal) killed, so a roster outage is 503 and leaves no marker.
No address at rest β verified. A Home-only person must have Label == "" (api.go:95; C3 killed), connect's session carries subject, method and auth time only, and the only new table in the suite (unlinked_test.go:30) has no address column. The app-side tables are Sheets' triggers (testdata/sheets_0001_team.sql), which stay per app.
3. teammode API β carries both apps' guarantees
| Guarantee | Where | Checked by | |---|---|---| | All-or-none config | config.go:72-79, :128 | TestConfigFromLookupIsAllOrNone; one variable present is ErrConfig, never allowlist | | Verify pins six bindings from config only | config.go:143-144 | TestVerifyPinsEveryBinding (issuer, consumer, app, origin, team, directory); canonical base64 and strict JSON keys (:156-165, :140) | | Fingerprint is Docs'/Sheets' digest | config.go:106-113 | Same go-json-experiment marshaller as Docs team_config.go:69-74; vector pinned in TestFingerprintIsPinned | | Marker before migrations | state.go:84-107, :116-128 | sqlite_master first; activated + no config or other binding β ErrConfig (T6, T7 killed). Docs' rule, one step earlier than Sheets' | | Namespace byte-identity | state.go:56, :64-69 | State("docs").SQL() equals Docs e58a22f teamstate/migrations/0001_team.sql byte for byte (I diffed the real file); set docs_team, ID docs_team/0001_team, and rastrillo's ledger keys on qualified ID plus Checksum(SQL), which is what TestSchemaIsDocsAndSheetsMarker asserts. Sheets' testdata equals its real file; its marker half is a prefix | | Foreign-issuer census, no marker | runtime.go:57-72 | TestOpenRefusesAForeignIssuerAndWritesNoMarker per table; T5 killed; table names validated (:36, :60) | | Check is the one decision path | runtime.go:92-98 | Access, AdmitUnlinked, RosterState all go through it; T8 (held never set) killed by both probe tests | | Latching Access | access.go:37-46, :69-79 | TryLock through Lease.Valid; T3 and T13 killed by the real one-connection writer test | | Guard in the writer tx | access.go:124-132 | TestGuardUnderTheWriterNeverWaitsOnAPublication queues a real publication behind the tx; T1, T2, T14 killed | | AdmitUnlinked | runtime.go:118-130 | Member and lease valid at re-check; T4 killed by the ticking-clock test; impossible subjects never fetch | | Partial | access.go:88 | T10 killed by four tests, TestFitsDocs among them | | Probe | probe.go | Same struct tags and three headers as Docs team_probe.go:26-28,82-86; TestProbeRosterStates checks no leak and the same body whoever asks |
Author's points 3 and 4 (nil Home β ErrConfig; Schema() via Add over a template): accepted. The ledger keys on ID and checksum, and the test pins both.
4. Fit
TestFitsSheets proves what it claims: Sheets' shape on connect's hooks plus AdmitUnlinked and Access, through a real Start β signed assertion β Finish exchange, with the five cases named. What it does not exercise β Guard, Partial, the stream timer β is covered by the unit tests and TestFitsDocs, and the note's Β§5 says those stay per app. One thinness: the known-arrival case asserts only the 403, not the body or the surviving local session; the connect test does both, so it is covered, just not here.
TestFitsDocs proves what it claims: Guard inside a real sql.Tx with the permission closure reading that tx, matching Docs' ownerMutation (check, mutate, check inside Transaction, team_access.go:181-192); own document 503 under Unknown while a share writes; partialCatalog as Partial; RequireMembership as AdmitUnlinked. It is a store-side fit, not an HTTP one, which is what it says.
Migration mapping (Β§6): right. The Sheets table is faithful to ca78cc1 (keeping its own sheets_team set is the correct call: the ledger checksums the whole file and the file holds the Home-only tables). The Docs table is faithful to e58a22f, and holding homeBridge for a second branch is correct β it moves a link table. One addition for the Docs row on teamstate.Schema: say that Merge qualifies IDs identically whichever way the set was built; that is the fact the ledger identity rests on.
5. Module pins
Facts. teammode/go.mod pins roster and connect at 6b23c73, reachable today only from origin/teammode. The root go.mod (on main, unchanged here) pins roster at 74dda570e0cf, reachable only from origin/feat-roster-lease; its roster/ content is identical to main's (empty diff), so it is not stale, but it is a branch-only pseudo-version all the same. Main's recent history has both merge commits (e2ec1ab, 1449d2d) and squashes.
Ruling. Branch-only pins are acceptable on a branch β in a multi-module repo there is no other way to test the branch β and not acceptable on main. A pseudo-version is fetched by commit; once the branch that reaches it is deleted, every consumer with a cold module cache (hub CI, per the 429 note; every app's CI; Docs and Sheets) fails go mod download, and MVS does not save them: teammode's go.mod names roster@6b23c73 and their go.sum needs its go.mod hash. The root's feat-roster-lease pin is the same hazard already on main, held up only by nobody having deleted that branch.
Order of operations.
- Apply the two record corrections above on this branch.
- Land
teammodeon main with a merge commit, not a squash (asremove-colophonandperf/dashboard-loadingwere): then17db191,15833f7and6b23c73are reachable from main and every pin resolves for as long as main does. If the hub's merge squashes, step 3 becomes mandatory before the branch is deleted. - One follow-up commit on main, immediately: root
go.modroster β the main commit (retiring thefeat-roster-leasepin),teammode/go.modroster and connect β the main commit,go mod tidyin each, CI green. Only then mayfeat-roster-leaseandteammodebe deleted. - Docs and Sheets re-point to that commit for all three modules (
teammode,roster,connect), never to6b23c73.
6. Tests and mutation resistance
Race: roster, connect, teammode all green under -race. I ran 30 hand mutations against the branch (list below); 28 killed, 2 survived, both the author's recorded equivalents, confirmed: T11 (Remaining's own latch; State latches first) and R6 (role check alone; since resets on a role change). No production path I mutated was unguarded.
Killed β roster: since check dropped (R1); fence check dropped (R2); since always reset (R3); deadline following the publication (R4); <= to < (R5); any member accepted (R7); fence() not bumping the counter (R8). Connect: same-person check dropped (C1, killed by a pre-existing test too); Unlinked over a live session (C2); label accepted (C3); Resolve fallback dropped (C4, three tests); storage read as refusal (C5); hook pair unenforced (C6); marker skipped for a hook refusal (C7). Teammode: Guard after-check (T1), before-check (T2); State latch (T3); AdmitUnlinked without the lease re-check (T4); census dropped (T5); boot ignoring the binding (T6) and the marker (T7); held never set (T8); Role ignoring standing (T9); Partial always false (T10); Activate accepting a rebind (T12); latched Unknown ignored (T13); Standing defaulting to Member with nothing carried (T14).
Recommendation on the open product question
Partial list with a notice (Docs'), not Sheets' 503 β confirm. The list page is where every sign-in lands; a 503 there during a Home blip longer than 60 s reads as "the app is down" and gives the person nothing, where a shares-only list with "the team's items can't be shown right now" reads as "Home is slow" and gives them what is theirs by grant. Nothing is over-shown: Unknown never adds an item, it withholds the team rung. Two conditions, both already in the API: ask Partial() after building the list from the same Access (the latch makes a lease that lapses mid-list mark the page), and NotMember is never partial (a guest's shares are their complete list). One carve-out to record: the ruling is for a person's own list page. A feed consumed by another origin (the dashboard pull) stays unavailable under Unknown, not short, as I required of Sheets' dashboard on #52 β a reader who cannot see the notice would take a short list for the truth. Item pages that need standing stay a retryable 503, never a 404.
Notes (non-blocking)
Runtime.Refresh(runtime.go:134) is a second route to the cache. It yields no decision, soheldis unaffected, but "Checkis the only way an app asks the roster" should read "the only way that yields a decision".Bridge.ResolveconsultsHomeOnlyfor any subject linkstore refused, including one refused for shape (store.go:181), so the hook may be asked about a string that is not a person ref. Harmless β it keys on (issuer, subject) andAdmitUnlinkedgates creation onroster.ValidSubjectβ but an app's hook should not assume the shape.TestFitsSheetsknown-arrival: asserts status only (see Β§4).- Local
make teston macOS:test-raceruns the root module first and dies oninternal/provisioner, so the five submodules' race steps never run locally. Pre-existing; CI is Linux. Ordering the submodules before the root in that target would make the local gate say more. - For Calendar (Β§7): "Home-only members have no address, so reminders need an in-app address the instance stores" β that is an address at rest in an app, which is each app's own rule, not Home's; just make sure the Calendar port's review reads it as a new address column, with the privacy gate that implies.
- The
#97test flip inTestLeaseDoesNotWaitForSQLiteWriterPublicationis right: the old lease survives on a strictly earlier deadline than the published one's.