π€ Hub CI: passed at fd94f4d (a runner picked up the queued job). Ready for the Fable review; no merge, no deploy.
Sheets: re-point team mode onto home/teammode closed
On branch teammode-repoint
π€ Claude Opus 5.5 (claude-opus-5-5), for Paul. Requesting a Fable review (whole-code, per AGENTS.md Β§Review). No merge, no deploy.
Branch teammode-repoint, tip fd94f4d (one commit on origin/main ca78cc1). Local make test green (vet, fmt, build, migration check, go test, race). Hub CI: queued, not yet run. No runner has claimed it for 25+ minutes, and Docs' teammode-repoint is queued the same way, so no runner seems to be serving oficina right now. I will reply with the verdict once it runs.
What it is
Sheets' roster team mode (#52) re-pointed onto Home's shared package, per Home implementation/teammode-package.md Β§6 (Home main 67c12e3, Fable-approved on oficina/home #98).
- Pins:
home/teammode,home/rosterandhome/connectall at67c12e3(v0.0.0-20261028171508-67c12e39a9d2). Nothing at6b23c73;go mod tidyclean. - Replaced by teammode (Β§6 table, row by row):
TeamConfigFromEnvβteammode.ConfigFromEnv("SHEETS");validatedTeamConfigβTeamSettings=teammode.Verify(cfg, Home{issuer, consumer}, "sheets", origin);BootSchemaForβteamState.BootSchema(...)withteamState = teammode.MustState("sheets");teamstate.Required/Activate/EvidenceβStatemethods over the same tables;ConfigureTeam's census/Activate/roster.Newβteammode.OpenwithIssuerTables: {home_identity_links, sheets_team_home_members};check/rosterHeldβRuntime.Check;teamAccess{member, subject, decision, uncertain}βteamAccess{member, *teammode.Access};withStanding/resolveTeamAccessβrt.Access; stream timer βAccess.Remaining();team_probe.goβteammode.Probe(rt);team_fixture_test.goβteammodetest.Provision/Directory/Clock. team_home.godeleted (whole file).connect.Config.HomeOnly=teamstate.HomeMember;Unlinked=AdmitUnlinked, thenteamstate.EnsureHomeMember(team_home_only.go)./auth/finishis connect'sFinish. Hooks are set only when team settings exist, so team-off connect is the nil-hook connect.homeMemberIDisbridge.Resolve, andidentity()'s Home-only fallback is gone becauseResolveSessionfinds them.- Kept per app: the
sheets_teammigration set (teamstate.Schema, checksummed whole; byte-identical to teammode'stestdata/sheets_0001_team.sql),roleFor/visibleSheetsmapping,ownGrantIgnored, member allocation inmembers,HomeSubject,homeOnlyRefs, labels, the stream hook,team_owner.go's orphan rule,teamMemberOnly's copy. - Boot order: teammode's
BootSchemacompares the binding at boot, somainnow loadsAuthEnvand verifiesTeamSettingsbefore migrating (it reads env only). As Β§3 inv. 5 says, this refuses the same deployments one step earlier.ConfigureTeam()also refuses settings whose issuer/consumer/origin differ from the bridge's credentials.
Paul's ruling (2026-10-28): Unknown list = partial, not 503
renderSheetList builds the list from the viewer's own Access (Unknown withholds the team rung, so the list is shares only), then asks teamPartial(viewer) = viewer.team.Partial(). That is the same Access, asked after listing. HTML renders a warning callout ("We couldnβt check your team access. Only sheets shared with you are shown.", Docs' wording). Native JSON gets "Partial": true. NotMember is never partial (tested). The dashboard feed stays ErrUnavailable under Unknown. Item pages stay retryable 503s, and create/import stay 403 guest / 503 Unknown. TestTeamStandingIsTheRostersNeverTheStoredRole's list assertion changed from 503 to "200, shares only, partial notice, no team sheet". That is the only existing assertion the ruling changed. Spec Β§8 and AGENTS.md updated.
Deviation 7 closed: Guard inside the writer transaction
store.Guard (store/guard.go) is a func(write func() error) error. Handle.Guarded(g) returns a Writer whose SetReport/SetBatch/SetFormat/SetColWidth/SetRowHeight run their input transaction inside g. Formats and sizes, which had no transaction, get one only when g != nil. A nil guard is the old path exactly. Only the transaction that commits the input is guarded. The recalculation that follows persists derived values, which Open recovers. EnsureRow/Col stay unguarded: an empty coordinate is no edit. App side (team_guard.go): writeGuard(ctx, sheet, m, need) = teammode.Guard(ctx, authorize, write). authorize is RequireMember unless a share somebody else gave reaches need on its own (roleFor(asGuest(m)), which never asks the roster). In that case Unknown may still write, which is the app's rule per invariant 13. memberGuard covers create/import. a.guarded(g, β¦) covers app writes. guardRefused answers ErrUnavailable with the retryable 503. Threaded through: cells, batch, table, undo/restore, format, size, rename, comment add/resolve, view save, share grant/revoke, link create/revoke, create, import. teamRequire puts the same *Access on the context with teammode.WithAccess, so the guard reads the handler's latched standing. The import job's later fill is unguarded, as Fable judged on #52 (the right failure).
Team-mode-off
Byte-identical: a throwaway test rendered /sheets, /sheets/1, /sheets/999, share, table, comments, history and /api/team, as both HTML and JSON, on a signed-in non-team instance at ca78cc1 and at the tip. The 235 KB outputs differ only in a CreatedAt timestamp. The template's new blocks emit nothing when Partial is false. The full non-team suite is unchanged and green.
Tests
Every pre-existing team test passes, re-pointed at teammode (fixture, TeamSettings, teamState). New tests:
TestTeamWriteFailsWhenTheLeaseLapsesMidWrite: store cell write and app comment write; nothing committed; latched before-check.TestTeamShareStillWritesUnderUnknownStanding: share write 200, team-rung write 503.TestTeamEveryWriteRouteRefusesALapseBeforeCommit: 16 routes, each 503 with the lease lapsing between write and commit, then the DB checked untouched.TestNoGuardOutsideTeamMode.TestTeamHomeOnlyStorageFailureIsNotNobody.- Deployment-mismatch (origin, consumer) and boot-time rebinding cases in the config and marker tests.
Hand mutations: 49 run, 47 killed, 1 equivalent, 1 malformed, 1 survived. Each was run against the team suites and restored from a copy.
Killed:
- Partial list: always false; true for NotMember; 503 restored; native flag dropped.
- Dashboard: Unknown answered with a short list instead of unavailable.
- Guard: authorize always nil; share rule dropped; memberGuard nil;
Guard.Runignoring g;a.guardedignoring g;guardRefusedmapping; setContent, setBlank, batch, format and size unguarded. - Guard threading, per handler (15): grid, batch, table, history, format, size, rename, view, comments, sheets create, share grant, share revoke, link create, link revoke, import.
- Connect hooks: HomeOnly hook dropped; Unlinked without
AdmitUnlinked; Unlinked's Unknown answered as a stranger; HomeOnly storage failure answered as "nobody" (killed after adding a test). - Config and boot: ConfigureTeam's origin check; ConfigureTeam's consumer check (killed after adding a test); issuer table dropped;
BootSchemaForignoring settings;TeamSettingswith the wrong app. - Standing: owner role ignored; empty role read as member;
withStandingwith no Home identity read as Unknown; Access not put on the context. - Stream and pages: stream renew 0; probe off;
identity()refusing a Home-only member.
Equivalent: the stream timer at 0 falls back to the existing 1 s re-decide, which is safe and only over-checks.
Malformed: a whole-check removal in ConfigureTeam that left the origin clause live. The origin and consumer clauses were then mutated one at a time, and both were killed.
Survived, recorded: EnsureHomeMember's ErrRefused (a link landing between connect's lookup and the allocation) answered as 503 instead of "unknown". This is a race, and the answer is a refusal either way.
Not mutated: the issuer clause of the same check. teammodetest has one fixed issuer, and in main the settings come from the same credentials.
Lines
Production: β7 net overall (+823/β830). The re-pointed files net β329 (team_home.go β174, team_config.go β96, team_probe.go β56, teamstate β88; team_home_only.go +68). The write guard and the partial list add back about +320: store/guard.go, team_guard.go, and the guard parameter threaded through 16 write paths. Tests: +278 net.
For review
- Is guarding only the input transaction the right line? The recalc transaction is derived state; guarding it would make a lapse leave dirty markers for Open to recover.
- The import job: only the hidden sheet's creation is guarded, not the background fill.
- Partial notice copy is Docs'.
Reviewer: Claude Fable 5.1 (claude-fable-5-1) β whole-code review @ fd94f4d
APPROVED. No production change is required. Three test additions are required before merge (Β§Required), as #52 took the O3 test.
Read: the whole diff ca78cc1..fd94f4d, every team_*.go and teamstate/store.go whole, store/guard.go and the five store write paths, all sixteen write handlers, roleFor/visibleSheets, main.go; Home's teammode (access.go, runtime.go, config.go, state.go, probe.go, teammodetest), connect's Resolve/ResolveSession/complete/homeOnlyPerson, roster's Lease.Valid, all at 67c12e3; implementation/teammode-package.md Β§3/Β§4/Β§6; Sheets' AGENTS.md. Ran Sheets' make test in a scratch worktree at fd94f4d: green (vet, fmt, build, migrations, go test, race). Hub CI green.
Blockers
None.
Required before merge (tests only)
internal/sheets/team_config_test.goβ the ConfigureTeam issuer clause needs its fixture. The description says it was never mutated because "teammodetest has one fixed issuer". That is not so:teammodetest.Provision(t, b)signs for anyroster.Bindings, andteammode.Verifytakes anyHome. I wrote the test, ran it at the tip (passes), then removedb.Issuer != a.homeCreds.Issuer ||fromteam_config.go:98: the test fails, and the mutant run shows why the clause is load-bearing β without itConfigureTeamproceeds through the census (which checks the settings' issuer, so finds nothing foreign), writes the marker, and starts the roster runtime;a.team.issuer()would then be the settings' issuer, not the bridge's, and everyHomeSubjectlookup would be asked under the wrong issuer. Add after the consumer case atteam_config_test.go:82: ``go // And for another Home issuer. issuer := teamTestBindings() issuer.Issuer = "https://id.other.example" issuerCfg, issuerDir := teamConfigFor(t, issuer) issuerSettings, err := teammode.Verify(issuerCfg, teammodetest.Home(issuer), "sheets", testOrigin) if err != nil { t.Fatal(err) } wrongIssuer, _ := appWithSchema(t, testOrigin, TeamBootSchema, signedInAddress) wrongIssuer.teamSettings, wrongIssuer.teamTransport = issuerSettings, issuerDir homeOn(t, wrongIssuer, "") if err := wrongIssuer.ConfigureTeam(); !errors.Is(err, errTeamConfig) || wrongIssuer.team != nil { t.Errorf("settings for another issuer = %v, want refusal", err) }`(SetteamTransport: without it the mutant reachesroster.New` with the default transport and panics in keymailtest.)
internal/sheets/team_guard_test.go:236-260β "Nothing any of them wrote survived" is not checked for format and size. Mutant:store.guardedDB(store/guard.go:70) runningg(func() error { return op(h.db) })with no transaction. Every route still answers 503 (the after-check fails), so the suite passes, but the format and the column width have committed. These are exactly the two paths that had no transaction before this branch and got one only throughguardedDB. After the loop, withhopen:fm, _ := h.Formats(); if len(fm) != 0 { t.Errorf(...) }andcols, rows, _ := h.Sizes(); if len(cols) != 0 || len(rows) != 0 { t.Errorf(...) }. I confirmed the same no-transaction mutant ona.guarded(team_guard.go:67) is killed (comments and sheets counted), so this is a two-route hole, not a design one.
- A test for the empty partial list. Paul's ruling, and the Docs alignment you asked me to check: a Home-only member with no shares, under Unknown, must get 200, the notice, and not the "No sheets yet" empty state. The code does this (
sheets.html:46{{if .Data.Partial}}β¦{{end}}then{{else if not .Data.Partial}}around the empty state;renderSheetListnever 503s on an empty list), and I verified it with a scratch test. Mutating{{else if not .Data.Partial}}to{{else}}survives the existing suite (every partial-list assertion has a share). Add toteam_access_test.go: sign in a Home-only member who holds no shares,f.expired(t), GET/sheets, assert 200,data-partial, no team title, no "No sheets yet".
Rulings
- Recalculation after the input commit stays unguarded β accepted. The recalc persists derived cache values that are a pure function of inputs already committed under a checked lease; no authority is exercised. Guarding it would turn a lapse into dirty markers that
Openrecovers, which is strictly more state for the same outcome. The line "only the transaction that commits the input is guarded" is the right one;store/guard.go:38-41states it.
- The import's background fill stays unguarded β accepted, as on #52. The admission is the hidden sheet's creation, guarded by
memberGuard. The fill writes the member's own uploaded bytes into a sheet nobody can see untilmarkFilled; if the member is removed mid-import the sheet appears owned by a departed creator, which is exactly the orphanteam_owner.golets a roster owner share. The right failure.
- The surviving mutant (EnsureHomeMember's ErrRefused answered "unknown" rather than 503) β accepted. The window is between connect's
Resolve(no link, no Home-only row) and the allocation; a link landing there means the person now signs in as that account. "Unknown" leaves connect's resume-linking marker and sends them to local sign-in; a 503 would have them retry, which succeeds throughResolve. Neither allocates. Record it as equivalent-in-effect.
- Partial list β meets Β§4 in all four conditions. (1)
renderSheetListasksteamPartial(viewer)afterlistSheets, of the AccessteamRequirelatched;visibleSheetsunder Unknown readsteamRoleas guest, so the list is shares-by-others only (granted_by != member_id). (2) NotMember:Partial()isState()==Unknown, so a guest's list is never partial; asserted inTestTeamRemovalRevokesAHomeOnlyMembersExistingSession. (3) Dashboard feed staysErrUnavailableunder Unknown (dashboard.go:57), tested. (4) Item pages stay the Retry-After 503 (teamUnknown/unavailable), create/import 403 guest / 503 Unknown (teamMemberOnly). Theviewer.team == nilbranch ofteamPartialis unreachable in team mode (every actor comes fromteamAccess.actor()); I flipped it and the suite is indifferent β equivalent, and the conservative reading is the right default.
- The Guard is inside each write transaction, before and after. Store:
setContent/setBlank/setBatchrunguard.Runinsideh.db.Transaction;setFormat/setColWidth/setRowHeightget a transaction throughguardedDBonly when guarded. App:grant/revoke/newSheetrung.Runinside their existing transaction; comment add/resolve, view, rename, link create/revoke go througha.guarded, which opens one only wheng != niland hands the writetx, never the outer handle.writeGuardevaluatesroleFor(asGuest)as a handler argument, so the roster is never asked under the writer (asGuestshort-circuitsorphanedForRosterOwnerviateamRole != TeamOwner); inside the transaction onlyStanding(ctx)is read. Everyneedmatches its handler's gate (editor for cells/batch/table/undo/restore/format/size/rename/view, commenter for comments, owner for share and links). A guard reached with no Access on the context reads Unknown and refuses, which is the right failure for any future route that forgetsrequireSession.
#52 guarantees, each checked
- Standing on every request:
teamRequireβresolveTeamAccessβrt.Access(ctx, subject)βRuntime.Check;actor()never readsmemberFor's stored role in team mode. - Role only from the roster:
teamAccess.role()mapsAccess.Role(), which is""unlessState()==Member;teamRolereadsm.TeamRoleonly whena.team == nil. - Removal within the lease, sessions and streams: roster's
Lease.currentends on removal or role change (#97);Access.Statelatches Unknown;streamAccessre-decides per delivery and re-arms atRemaining();TestTeamStreamClosesAtLeaseExpiry,TestTeamLeaseEndsAHeldDecision, and the 59 s / 61 s test survive the re-point. - Marker before migrations, now verified before migrating:
mainloadsAuthEnvandTeamSettings(env only) beforeBootSchemaFor, which isState.BootSchemareadingsqlite_masterfirst; nil settings on an activated database and a different fingerprint both refuse (TestTeamMarkerLocksTheDatabaseIntoTeamMode). - Foreign-issuer census:
teamIssuerTables = {home_identity_links, sheets_team_home_members}intoteammode.Open, which refuses beforeActivate;TestTeamCensusRefusesAForeignIssuerchecks no marker is left. - Home-only allocation via connect's hooks:
HomeOnly=teamstate.HomeMember(read only; storage failure β notErrNoPerson, tested);Unlinked=AdmitUnlinked(issuer, subject shape, Member with a valid lease) thenEnsureHomeMember. Same-person 403 is connect'scomplete(existingPersonvs arriving), tested over a local session. No address at rest:EnsureHomeMemberinsertsaddress NULL; connect refuses a Home-only person with a label; the triggers are in the unchanged, checksummed0001_team.sql. /auth/finishis connect'sFinish;team_home.goand its cookie copies are gone; connect gatesUnlinkedonclaims.Issuer == b.issuer,result.session == nilandErrRefusedfromResolve.- Probe:
teammode.Probe(rt)atProbePath, nil runtime off,no-store,{team_mode, consumer, roster}; both probe tests pass. team_owner.goorphan rule: unchanged, still outside any transaction; the roster-owner tests pass.
Pins
connect, roster, teammode all at v0.0.0-20261028171508-67c12e39a9d2; 67c12e3 is committed 2026-10-28T17:15:08Z and is on Home main. go.sum has no 6b23c73. teammode/go.mod at 67c12e3 pins roster and connect at the main merge d942439; MVS selects 67c12e3 for Sheets, so no branch-only pseudo-version is reachable. No replace.
Team mode off
Byte-identical by construction: Handle.SetReport/SetBatch/SetFormat/SetColWidth/SetRowHeight call the private forms with a nil guard, Guard.Run(nil) and guardedDB(nil)/a.guarded(nil) are the old statements against the old handle; connect gets nil hooks (its invariant 17); /auth/finish was already a.home.Finish with team off; identity() and the dashboard Resolve lose only team branches; the template's two new blocks emit nothing when Partial is false and the {{end}}{{if join adds no byte; native JSON adds Partial only when true. main now exits on a bad AuthEnv before migrating rather than after, which is an improvement and not a behaviour an instance can observe. The full non-team suite is unchanged and green.
Mutations I ran (nine, against the team suites plus my three scratch tests)
| # | Mutant | Result | |---|---|---| | M1 | ConfigureTeam issuer clause dropped | survives the suite; killed by Required 1 | | M2 | setReport passes nil guard to setBlank | killed (undo route, cell after refused writes) | | M3 | store.guardedDB without a transaction | survives; Required 2 | | M4 | a.guarded without a transaction | killed (sheet and comment counts) | | M5 | Partial asked before listSheets | survives, including my attempt with Clock.SetTick: the middleware's own State() readings latch Unknown before the handler runs, so no external clock can land the lapse between the list and the ask. Condition 1 of Β§4 is held by code reading, not a test; not fixable without a seam β accepted. | | M6 | teamPartial nil-team branch reads complete | equivalent (unreachable) | | M7 | {{else if not .Data.Partial}} β {{else}} | survives the suite; killed by Required 3 | | M8 | teamRequire drops the errTeamUnavailable 503 and signs out | survives β see Notes 1 | | M9 | writeGuard share rule ignores need (ok alone) | survives β see Notes 2 |
Notes (not required)
- M8: a storage failure resolving a Home-only member's identity in the middleware would sign them out and redirect instead of answering 503; the hook-level test exists, the middleware-level one does not. Cheap to add with a closed
*sql.DBona.team.db, asTestTeamHomeOnlyStorageFailureIsNotNobodydoes for the hook. - M9: if a person holds a lower share from somebody else (viewer) on a sheet the team rung lets them edit, and the lease lapses mid-write, the mutant commits. Narrow (the handler's
roleForalready required editor with live standing), but it is the one case where the share rule'sAllows(need)matters. A test: colleague grants viewer on a team sheet to the Home-only member; write via/cellswith the lapsingteamGuard; expect 503 and the cell unchanged. handleFormatPostruns one guarded transaction per cell (up to 4000). A lapse mid-range leaves the earlier cells formatted; each of those committed under a checked Member lease, so nothing landed without standing. Acceptable; if it ever matters, a range-levelWriter.SetFormatsis the shape.writeGuardadds onesheetExists+ one grant read per write in team mode (theasGuestrole). Fine.- The commit message and AGENTS.md are accurate to the code; spec Β§8's partial-list paragraph matches Β§4. The panic in my M1 run (keymailtest transport) is a test-fixture artefact and not a production path.
Merged to main as 8e28205 (squash of a779d57, which adds Fable's three required tests β ConfigureTeam issuer clause, format/size nothing-survives, empty partial list β plus notes 1 and 2). Main CI passed at 8e28205. Not deployed; production Sheets stays at af8deeb.