oficina / docs Public

Docs: re-point roster team mode onto home/teammode (store side). Config parsing, Verify pinning and the fingerprint, the activation marker and evidence (State("docs"), byte-identical to the applied docs_team/0001_team migration, ledger proved unchanged against an old database), the access tri-state, Guard in ownerMutation's transaction, AdmitUnlinked behind principalstore's allocation gate, Partial and the /api/team probe now come from home/teammode, with teammode and roster pinned at Home main 67c12e3; homeBridge stays for a second branch. Following Paul's 2026-10-28 ruling, the list page under Unknown is a partial list with the notice, asked after listing and shown even when the list is empty; NotMember stays complete, item pages a retryable 503, and the dashboard feed and the native list answer 503 under Unknown because neither can show the notice. Reviewed by Claude Fable 5.1 on oficina/docs #100: CHANGES REQUIRED for the native list, APPROVED after the fix at 25419d9.

Squashed from teammode-repoint into main.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 7c9122ff0ec4766d57b67afddd13ca80a8265dee parent e58a22f
27 files changed, +532 −410
  • cmd/docs/main.go +5 −3
  • go.mod +2 −1
  • go.sum +6 −2
  • internal/docs/app.go +10 −8
  • internal/docs/dashboard.go +8 −1
  • internal/docs/dashboard_test.go +33 −0
  • internal/docs/errors_test.go +0 −1
  • internal/docs/grants.go +1 −1
  • internal/docs/handlers.go +5 −1
  • internal/docs/native.go +8 −0
  • internal/docs/stream.go +3 −4
  • internal/docs/team_access.go +40 −33
  • internal/docs/team_access_test.go +28 −11
  • internal/docs/team_config.go +35 −54
  • internal/docs/team_emission.go +2 −2
  • internal/docs/team_home_test.go +1 −1
  • internal/docs/team_identity_test.go +47 −2
  • internal/docs/team_probe.go +10 −78
  • internal/docs/team_probe_test.go +1 −1
  • internal/docs/team_router_test.go +131 −0
  • internal/docs/team_state_test.go +121 −0
  • internal/docs/team_stream.go +14 −15
  • internal/docs/team_stream_test.go +20 −4
  • internal/docs/teamstate/store.go +0 −98
  • internal/docs/teamstate/store_test.go +0 −89
  • internal/docs/{teamstate => testdata/teamstate-e58a22f}/migrations/0001_team.sql +0 −0
  • internal/shipped/shipped.go +1 −0

CI passed — run details

diff --git a/cmd/docs/main.go b/cmd/docs/main.go
index a1db24c..f984078 100644
--- a/cmd/docs/main.go
+++ b/cmd/docs/main.go
@@ -10,6 +10,7 @@ import (
"strings"
"syscall"
+ "amadan.net/oficina/home/teammode"
"amadan.net/rastrillo/rastrillo"
"amadan.net/rastrillo/rastrillo/mail"
@@ -290,9 +291,10 @@ func main() {
cfg.Home = &home
}
- team := docs.TeamConfig{TeamID: os.Getenv("DOCS_TEAM_ID"), DirectoryOrigin: os.Getenv("DOCS_TEAM_DIRECTORY_ORIGIN"), ProvisioningBase64: os.Getenv("DOCS_TEAM_PROVISIONING_BASE64"), OperatorKeysBase64: os.Getenv("DOCS_TEAM_OPERATOR_KEYS_BASE64"), RosterToken: os.Getenv("DOCS_TEAM_ROSTER_TOKEN")}
- if team.TeamID != "" || team.DirectoryOrigin != "" || team.ProvisioningBase64 != "" || team.OperatorKeysBase64 != "" || team.RosterToken != "" {
- cfg.Team = &team
+ // The five DOCS_TEAM_* variables, all or none: one set alone is a
+ // configuration docs.New refuses, never allowlist mode.
+ if team := teammode.ConfigFromEnv("DOCS"); team != nil {
+ cfg.Team = &docs.TeamConfig{TeamID: team.TeamID, DirectoryOrigin: team.DirectoryOrigin, ProvisioningBase64: team.ProvisioningBase64, OperatorKeysBase64: team.OperatorKeysBase64, RosterToken: team.RosterToken}
if seedFlag {
logger.Error("docs: seed unavailable in TeamMode")
os.Exit(1)
diff --git a/go.mod b/go.mod
index 940cf99..c50c4d4 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,8 @@ require (
amadan.net/oficina/estilo.git v0.0.0-20261026205409-aa90aaceb796
amadan.net/oficina/home/dashboard v0.0.0-20261024235511-baa2503c7064
amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489
- amadan.net/oficina/home/roster v0.0.0-20260908123429-74dda570e0cf
+ amadan.net/oficina/home/roster v0.0.0-20261028171508-67c12e39a9d2
+ amadan.net/oficina/home/teammode v0.0.0-20261028171508-67c12e39a9d2
amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3
amadan.net/rastrillo/rastrillo v0.29.1-0.20261027164201-054787952dd2
github.com/carlosframework/rastrillo v0.23.0
diff --git a/go.sum b/go.sum
index ffce12c..248ac38 100644
--- a/go.sum
+++ b/go.sum
@@ -1,11 +1,15 @@
amadan.net/oficina/estilo.git v0.0.0-20261026205409-aa90aaceb796 h1:yj3d1pKgMbZ3e+7zTf+SWdGYux4E0hhnCOr4YJxH9VE=
amadan.net/oficina/estilo.git v0.0.0-20261026205409-aa90aaceb796/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw=
+amadan.net/oficina/home/connect v0.0.0-20261028165624-d942439ac4e4 h1:WQ4irMKZerybbbccJblyukiloZZ9zfIxcay4vVyVowU=
+amadan.net/oficina/home/connect v0.0.0-20261028165624-d942439ac4e4/go.mod h1:ix81eFV87yE9f2SXiRuxYCVM4lAgTRC5YoQMiH3+TDk=
amadan.net/oficina/home/dashboard v0.0.0-20261024235511-baa2503c7064 h1:2YbDksZDxpY9khlhXmTeiM89yze7w2XfYSumtrzH4tc=
amadan.net/oficina/home/dashboard v0.0.0-20261024235511-baa2503c7064/go.mod h1:+7xsX+QyVFrKy5gDAGh+FZ5+75z4CibWTL0wl9DWAw0=
amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 h1:RPKtyry/71i06o8L+gjAaUyexbmG56kO1YPs601URAM=
amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k=
-amadan.net/oficina/home/roster v0.0.0-20260908123429-74dda570e0cf h1:SRKjCUgtk42WwR7VSn+V0eLNk20mfiY8dQmzdw13Sbo=
-amadan.net/oficina/home/roster v0.0.0-20260908123429-74dda570e0cf/go.mod h1:gqshuXyDtFZUCYbhuZyV3Epc51pUcsLbpqAqiA5UiXg=
+amadan.net/oficina/home/roster v0.0.0-20261028171508-67c12e39a9d2 h1:yKUTS0nOiVw7ktHpTin0bCcUDLFjmMjpW6CsHIZzZKk=
+amadan.net/oficina/home/roster v0.0.0-20261028171508-67c12e39a9d2/go.mod h1:gqshuXyDtFZUCYbhuZyV3Epc51pUcsLbpqAqiA5UiXg=
+amadan.net/oficina/home/teammode v0.0.0-20261028171508-67c12e39a9d2 h1:0PQiRUkC+9cbTHE67Y4/SmW1sPH1NNWNwTceNFyMjTY=
+amadan.net/oficina/home/teammode v0.0.0-20261028171508-67c12e39a9d2/go.mod h1:dXBZeB2ic33SIZiGUCzafmviUT8TYWgzSYZvo2rM6zA=
amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3 h1:5EFx7BLJj/+G/rt8bTmeyMWVfF5s5Sns7ajTvX4w/I8=
amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3/go.mod h1:ZaaxeE278dJltdrLwmwpxUjQ5wuKzqDAVSNRet+WupY=
amadan.net/rastrillo/rastrillo v0.29.1-0.20261027164201-054787952dd2 h1:ybFov1+wRduFtkxTn44QnzCKTDhyjfFWxWsW+cKaAyk=
diff --git a/internal/docs/app.go b/internal/docs/app.go
index 1518d7c..23f20c9 100644
--- a/internal/docs/app.go
+++ b/internal/docs/app.go
@@ -26,6 +26,7 @@ import (
"amadan.net/oficina/estilo.git/theme"
"amadan.net/oficina/home/dashboard"
"amadan.net/oficina/home/handoff"
+ "amadan.net/oficina/home/teammode"
nativeauth "amadan.net/rastrillo/native/server"
"amadan.net/rastrillo/rastrillo"
rauth "amadan.net/rastrillo/rastrillo/auth"
@@ -37,7 +38,6 @@ import (
"github.com/go-chi/chi/v5"
"github.com/carlosframework/docs/internal/core"
- "github.com/carlosframework/docs/internal/docs/teamstate"
)
// Config configures New.
@@ -395,15 +395,17 @@ func New(cfg Config) (*App, error) {
return nil, fmt.Errorf("docs: open database: %w", err)
}
- required, activated, err := teamstate.Required(context.Background(), d.Writer())
- if err != nil || activated && (teamSettings == nil || required != teamSettings.fingerprint) {
+ // The marker is read before any migration: an activated database
+ // refuses to boot without team configuration, or with another binding.
+ var settings *teammode.Settings
+ if teamSettings != nil {
+ settings = teamSettings.Settings
+ }
+ schema, err := teamState.BootSchema(context.Background(), d.Writer(), settings, BootSchema, TeamBootSchema)
+ if err != nil {
d.Close()
return nil, errTeamConfig
}
- schema := BootSchema
- if teamSettings != nil {
- schema = TeamBootSchema
- }
if _, err := migrate.Apply(context.Background(), d, schema); err != nil {
d.Close()
return nil, fmt.Errorf("docs: apply migrations: %w", err)
@@ -638,7 +640,7 @@ func New(cfg Config) (*App, error) {
r.Get("/p/{token}", h.publicShow)
// Alta's readiness probe (team_probe.go): unauthenticated, no account
// data, and {"team_mode":false} on an instance not in team mode.
- r.Get(teamProbePath, h.teamProbe)
+ r.Method(http.MethodGet, teamProbePath, teamProbe(store.team))
// Help → Fonts and Help → Colophon (colophon.go): public, like every
// Oficina app's open-source page; the door links the Colophon.
r.Get(fontsPath, h.helpFonts)
diff --git a/internal/docs/dashboard.go b/internal/docs/dashboard.go
index ad66574..21f5c31 100644
--- a/internal/docs/dashboard.go
+++ b/internal/docs/dashboard.go
@@ -46,8 +46,9 @@ func (h *handlers) dashboardProvider(home *homeRoutes, c *homeSettings, list all
if e != nil || id.Actor.PersonID != person {
return dashboard.Response{}, dashboard.ErrRefused
}
+ var access *requestAccess
if h.store.team != nil {
- access := h.store.team.resolveAccess(ctx, id)
+ access = h.store.team.resolveAccess(ctx, id)
ctx = context.WithValue(ctx, accessContextKey{}, access)
ctx.Value(dashboardAccessKey{}).(*dashboardAccess).access = access
}
@@ -55,6 +56,12 @@ func (h *handlers) dashboardProvider(home *homeRoutes, c *homeSettings, list all
if e != nil {
return dashboard.Response{}, e
}
+ // Home renders this feed, where no partial notice can be shown, so
+ // under Unknown it is unavailable rather than short (Paul's ruling
+ // on list pages, 2026-10-28, condition 3). Asked after listing.
+ if access != nil && access.Partial() {
+ return dashboard.Response{}, dashboard.ErrUnavailable
+ }
out := dashboard.Response{Truncated: len(rows) > dashboard.MaxItems}
if out.Truncated {
rows = rows[:dashboard.MaxItems]
diff --git a/internal/docs/dashboard_test.go b/internal/docs/dashboard_test.go
index 5c486b0..b462f37 100644
--- a/internal/docs/dashboard_test.go
+++ b/internal/docs/dashboard_test.go
@@ -129,3 +129,36 @@ func TestDashboardTeamResponseUsesEmissionGuard(t *testing.T) {
t.Fatal("expired lease emitted data", late.Code, late.Body.String())
}
}
+
+// Under Unknown the feed is unavailable, not short: Home renders it where
+// no partial notice can be shown, and a reader would take the shares alone
+// for the whole list (Paul's ruling on list pages, 2026-10-28, condition 3).
+func TestDashboardTeamFeedIsUnavailableUnderUnknown(t *testing.T) {
+ f := newTeamRouterFixtureWithDashboard(t, true)
+ b := f.browser()
+ b.localSignin(t, "alice@example.com")
+ b.linkProof(t, teamSubject('a'), "alice@example.com")
+ routerRedirect(t, b.do("POST", "/account/home/confirm", ""), connectedURL("/"))
+ call := func() *httptest.ResponseRecorder {
+ jti, _ := dashboard.ID()
+ nonce, _ := dashboard.ID()
+ now := time.Now().Unix()
+ token, e := dashboard.Sign(f.key, dashboard.Claims{Version: 1, Issuer: bridgeIssuer, Audience: bridgeOrigin, Directory: f.cfg.Directory, Subject: teamSubject('a'), Team: "TeamA", Purpose: "dashboard-read", KeyID: f.keyID, ID: jti, Nonce: nonce, Issued: now, Expires: now + 120})
+ if e != nil {
+ t.Fatal(e)
+ }
+ r := httptest.NewRequest("GET", bridgeOrigin+dashboard.Path, nil)
+ r.Header.Set("Authorization", "Bearer "+token)
+ w := &teamDeadlineRecorder{ResponseRecorder: httptest.NewRecorder()}
+ f.app.Handler().ServeHTTP(w, r)
+ return w.ResponseRecorder
+ }
+ if w := call(); w.Code != 200 || !strings.Contains(w.Body.String(), "Alice original") || !strings.Contains(w.Body.String(), "Bob shared") {
+ t.Fatal("member feed", w.Code, w.Body.String())
+ }
+ f.directory.change(nil, true)
+ f.clock.step(61 * time.Second)
+ if w := call(); w.Code != 503 || strings.Contains(w.Body.String(), "Bob shared") {
+ t.Fatal("feed under Unknown was not unavailable", w.Code, w.Body.String())
+ }
+}
diff --git a/internal/docs/errors_test.go b/internal/docs/errors_test.go
index 37249d5..06bced7 100644
--- a/internal/docs/errors_test.go
+++ b/internal/docs/errors_test.go
@@ -260,7 +260,6 @@ func TestEveryPlainTextErrorIsClassified(t *testing.T) {
"stream.go:handlers.stream": {7, "live update stream"},
"team_access.go:teamRuntime.admission": {1, "shared guard, identity missing: a wiring failure, not a page state"},
"team_emission.go:writeGuardedBody": {1, "response already guarded"},
- "team_probe.go:handlers.teamProbe": {1, "Alta's readiness probe JSON, fetched by a provisioner, never a page"},
}
got := httpErrorSites(t)
var problems []string
diff --git a/internal/docs/grants.go b/internal/docs/grants.go
index fd7e3e8..8e431eb 100644
--- a/internal/docs/grants.go
+++ b/internal/docs/grants.go
@@ -350,7 +350,7 @@ func (s *Store) listForLimited(ctx context.Context, a Actor, limit int) ([]*Docu
}
if s.team != nil && len(docs) == 0 {
a, ok := s.access(ctx, a)
- if !ok || a.state() == roster.Unknown {
+ if !ok || a.state() == roster.Unknown && !a.partialNotice {
return nil, errTeamUnavailable
}
}
diff --git a/internal/docs/handlers.go b/internal/docs/handlers.go
index a1441d7..57c7b11 100644
--- a/internal/docs/handlers.go
+++ b/internal/docs/handlers.go
@@ -283,9 +283,11 @@ func (h *handlers) list(w http.ResponseWriter, r *http.Request) {
// JavaScript (spec §6.2) — the form is a GET and the page it lands
// on is an ordinary page.
query := strings.TrimSpace(r.URL.Query().Get("q"))
+ // This page shows the partial notice, so under Unknown its list may be
+ // empty: the empty state and the notice, not a 503.
+ h.acceptPartial(r)
data := listPage{
- PartialCatalog: h.partialCatalog(r),
HomeLinkLabel: h.homeLinkLabel(r),
CanCreate: h.member(r),
Title: rastrillo.T(r, "docs.list.title"),
@@ -320,6 +322,7 @@ func (h *handlers) list(w http.ResponseWriter, r *http.Request) {
}
now := time.Now().UTC()
data.Searching = true
+ data.PartialCatalog = h.partialCatalog(r)
thumb := h.thumbnailer(r.Context())
for _, d := range hits {
data.Results = append(data.Results, docRow{
@@ -343,6 +346,7 @@ func (h *handlers) list(w http.ResponseWriter, r *http.Request) {
h.fail(w, r, h.internalFailureStatus(), failStatus)
return
}
+ data.PartialCatalog = h.partialCatalog(r)
data.Groups = groupByRecency(r, time.Now().UTC(), docs, h.thumbnailer(r.Context()), who.PersonID)
if err := h.render.page(w, r, "list", data); err != nil {
h.logger.Error("docs: render list", "err", err)
diff --git a/internal/docs/native.go b/internal/docs/native.go
index 93197de..dbbfe42 100644
--- a/internal/docs/native.go
+++ b/internal/docs/native.go
@@ -55,6 +55,14 @@ func (h *handlers) nativeList(w http.ResponseWriter, r *http.Request) {
} else {
documents, err = h.store.ListFor(r.Context(), actor)
}
+ // The Mac and iPhone apps render no partial notice, so under Unknown
+ // this list is unavailable rather than short, as the dashboard feed is
+ // (Fable on oficina/docs #100). Asked after listing, from the same
+ // Access. A "partial" field is the better contract once the clients
+ // render it.
+ if a, ok := r.Context().Value(accessContextKey{}).(*requestAccess); err == nil && ok && a != nil && a.Partial() {
+ err = errTeamUnavailable
+ }
if err != nil {
http.Error(w, rastrillo.T(r, "docs.error.generic"), h.internalFailureStatus())
return
diff --git a/internal/docs/stream.go b/internal/docs/stream.go
index 8ea7935..f953822 100644
--- a/internal/docs/stream.go
+++ b/internal/docs/stream.go
@@ -7,7 +7,6 @@ import (
"strconv"
"time"
- "amadan.net/oficina/home/roster"
"amadan.net/rastrillo/rastrillo"
)
@@ -98,14 +97,14 @@ func (h *handlers) stream(w http.ResponseWriter, r *http.Request) {
return
}
guard = &teamStreamGuard{store: h.store, access: a, request: r, docID: doc.ID}
- if a.decision.State == roster.Member {
- guard.deadline = time.Now().Add(a.decision.Lease.Remaining())
+ if lease := a.Remaining(); lease > 0 {
+ guard.deadline = time.Now().Add(lease)
}
if _, ok := guard.check(); !ok {
http.Error(w, rastrillo.T(r, "docs.error.generic"), http.StatusServiceUnavailable)
return
}
- if a.decision.State == roster.Member {
+ if !guard.deadline.IsZero() {
remaining := guard.remaining()
if remaining <= 0 {
http.Error(w, rastrillo.T(r, "docs.error.generic"), http.StatusServiceUnavailable)
diff --git a/internal/docs/team_access.go b/internal/docs/team_access.go
index 7e6ce07..9713204 100644
--- a/internal/docs/team_access.go
+++ b/internal/docs/team_access.go
@@ -6,19 +6,25 @@ import (
"net/http"
"amadan.net/oficina/home/roster"
+ "amadan.net/oficina/home/teammode"
"amadan.net/rastrillo/rastrillo"
"gorm.io/gorm"
)
type accessContextKey struct{}
+
+// requestAccess is one request's standing (teammode.Access: Member,
+// NotMember or Unknown, the lease re-checked whenever it is asked and
+// Unknown latched) and the actor it was decided for.
type requestAccess struct {
- uncertain bool
+ *teammode.Access
responseStore *Store
responseDocs map[int64]permission
runtime *teamRuntime
actor Actor
- subject string
- decision roster.Decision
+ // partialNotice: this response renders the partial notice, so a list
+ // built under Unknown may be empty (acceptPartial).
+ partialNotice bool
}
type permission uint8
@@ -28,7 +34,7 @@ const (
permissionOwner
)
-var errTeamNotMember = errors.New("docs: team membership required")
+var errTeamNotMember = teammode.ErrNotMember
func sameActor(a, b Actor) bool {
if a.PersonID != b.PersonID || (a.VerifiedAddress == nil) != (b.VerifiedAddress == nil) {
@@ -40,25 +46,14 @@ func (a *requestAccess) state() roster.State {
if a == nil {
return roster.Unknown
}
- if a.uncertain {
- return roster.Unknown
- }
- if a.decision.State == roster.Member && !a.decision.Lease.Valid() {
- a.uncertain = true
- return roster.Unknown
- }
- return a.decision.State
+ return a.Access.State()
}
func (s *Store) access(ctx context.Context, actor Actor) (*requestAccess, bool) {
a, ok := ctx.Value(accessContextKey{}).(*requestAccess)
return a, ok && a != nil && a.runtime == s.team && sameActor(a.actor, actor)
}
func (t *teamRuntime) resolveAccess(ctx context.Context, id requestIdentity) *requestAccess {
- a := &requestAccess{runtime: t, actor: id.Actor, subject: id.HomeSubject, decision: roster.Decision{State: roster.NotMember}}
- if id.HomeSubject != "" {
- a.decision = t.check(ctx, id.HomeSubject)
- }
- return a
+ return &requestAccess{Access: t.cache.Access(ctx, id.HomeSubject), runtime: t, actor: id.Actor}
}
func (t *teamRuntime) admission(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -137,14 +132,7 @@ func (s *Store) requireMember(ctx context.Context, actor Actor) error {
if !ok {
return errTeamUnavailable
}
- switch a.state() {
- case roster.Member:
- return nil
- case roster.NotMember:
- return errTeamNotMember
- default:
- return errTeamUnavailable
- }
+ return teammode.RequireMember(a.state())
}
func (s *Store) ownerActor(ctx context.Context, owner int64) Actor {
@@ -178,16 +166,21 @@ func (s *Store) snapshotPermission(ctx context.Context, db *gorm.DB, docID int64
return s.checkPermission(ctx, db, a.actor, docID, permissionWrite)
}
+// ownerMutation authorizes, mutates and authorizes again inside one writer
+// transaction, so it commits only if the standing that admitted it still
+// holds. The rule reads the standing in permissionScope, from the request's
+// own latched Access matched to the actor, rather than from Guard's
+// argument; with team mode off it is ownership alone.
func (s *Store) ownerMutation(ctx context.Context, owner, docID int64, mutate func(*gorm.DB) error) error {
actor := s.ownerActor(ctx, owner)
return s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
- if err := s.checkPermission(ctx, tx, actor, docID, permissionOwner); err != nil {
- return err
- }
- if err := mutate(tx); err != nil {
- return s.permissionError(ctx, actor, err)
- }
- return s.checkPermission(ctx, tx, actor, docID, permissionOwner)
+ authorize := func(roster.State) error { return s.checkPermission(ctx, tx, actor, docID, permissionOwner) }
+ return teammode.Guard(ctx, authorize, func() error {
+ if err := mutate(tx); err != nil {
+ return s.permissionError(ctx, actor, err)
+ }
+ return nil
+ })
})
}
@@ -223,12 +216,26 @@ func (h *handlers) requireMemberRequest(w http.ResponseWriter, r *http.Request,
return false
}
+// acceptPartial lets a list built under Unknown be empty, for a response
+// that renders the partial notice: an empty partial list, not a 503 (Paul's
+// ruling, 2026-10-28). A list nobody marks (the dashboard feed, the native
+// list) keeps refusing an empty Unknown list as unavailable.
+func (h *handlers) acceptPartial(r *http.Request) {
+ if a, ok := r.Context().Value(accessContextKey{}).(*requestAccess); ok && a != nil && a.runtime == h.store.team {
+ a.partialNotice = true
+ }
+}
+
+// partialCatalog is the notice for a list built under Unknown: the person's
+// shares, without the team rung (Paul's ruling, 2026-10-28). Ask it after
+// the list is built, from the same Access, so a lease that lapsed while
+// listing marks the page partial. NotMember is never partial.
func (h *handlers) partialCatalog(r *http.Request) string {
if h.store.team == nil {
return ""
}
a, ok := r.Context().Value(accessContextKey{}).(*requestAccess)
- if !ok || a == nil || a.runtime != h.store.team || a.state() == roster.Unknown {
+ if !ok || a == nil || a.runtime != h.store.team || a.Partial() {
return rastrillo.T(r, "docs.team.partial")
}
return ""
diff --git a/internal/docs/team_access_test.go b/internal/docs/team_access_test.go
index 3504e61..5c9fb77 100644
--- a/internal/docs/team_access_test.go
+++ b/internal/docs/team_access_test.go
@@ -3,6 +3,7 @@ package docs
import (
"amadan.net/oficina/home/handoff/seal"
"amadan.net/oficina/home/roster"
+ "amadan.net/oficina/home/teammode"
family "amadan.net/rastrillo/rastrillo/crypto"
"amadan.net/rastrillo/rastrillo/migrate"
"amadan.net/rastrillo/rastrillo/sessions"
@@ -11,7 +12,7 @@ import (
"encoding/base64"
"errors"
"github.com/carlosframework/docs/internal/docs/principalstore"
- "github.com/carlosframework/docs/internal/docs/teamstate"
+ "github.com/go-json-experiment/json"
"gorm.io/gorm"
"io"
"net/http"
@@ -51,7 +52,7 @@ func TestTeamPermissionFormerOwnerOnlyReachesExactGrant(t *testing.T) {
s.team = &teamRuntime{}
actor := localActor(owner, "former@example.com")
for _, state := range []roster.State{roster.NotMember, roster.Unknown} {
- a := &requestAccess{runtime: s.team, actor: actor, decision: roster.Decision{State: state}}
+ a := &requestAccess{runtime: s.team, actor: actor, Access: standing(state)}
c := context.WithValue(ctx, accessContextKey{}, a)
for _, mode := range []permission{permissionRead, permissionWrite, permissionOwner} {
for _, doc := range []*Document{private, shared, stranger} {
@@ -107,13 +108,23 @@ func TestTeamPermissionFormerOwnerOnlyReachesExactGrant(t *testing.T) {
t.Fatal("missing or foreign access context was accepted")
}
}
- c := context.WithValue(ctx, accessContextKey{}, &requestAccess{runtime: s.team, actor: actor, decision: roster.Decision{State: roster.NotMember}})
+ c := context.WithValue(ctx, accessContextKey{}, &requestAccess{runtime: s.team, actor: actor, Access: standing(roster.NotMember)})
var n int64
if e = s.permissionScope(c, s.db.Model(&Document{}), localActor(other, "former@example.com"), permissionRead).Count(&n).Error; e != nil || n != 0 {
t.Fatal("actor mismatch accepted")
}
}
+// standing is an Access that no lease backs: NotMember, as for a person
+// with no Home subject, or Unknown (a nil Access).
+func standing(s roster.State) *teammode.Access {
+ if s != roster.NotMember {
+ return nil
+ }
+ var none *teammode.Runtime
+ return none.Access(context.Background(), "")
+}
+
type teamTestClock struct {
next func()
mu sync.Mutex
@@ -153,10 +164,6 @@ func testTeamRoster(t *testing.T, s *Store, app *App) (*teamRuntime, *teamTestCl
if e != nil {
t.Fatal(e)
}
- record, e := roster.VerifyProvisioning(raw, []roster.Key{{ID: "operator1", Public: base64.RawURLEncoding.EncodeToString(op.SignPub())}}, b)
- if e != nil {
- t.Fatal(e)
- }
sealer, e := seal.New(bytes.Repeat([]byte{9}, 32), "team-test")
if e != nil {
t.Fatal(e)
@@ -180,7 +187,15 @@ func testTeamRoster(t *testing.T, s *Store, app *App) (*teamRuntime, *teamTestCl
}
return &http.Response{StatusCode: 200, Header: http.Header{"Content-Type": {"application/json"}}, Body: io.NopCloser(bytes.NewReader(raw))}, nil
})
- cache, e := roster.New(t.Context(), roster.Config{Record: record, Token: fixed(7), Clock: clock, Sealer: sealer, Durable: teamstate.Evidence{DB: app.db.Writer()}, Transport: transport})
+ keys, e := json.Marshal([]roster.Key{{ID: "operator1", Public: base64.RawURLEncoding.EncodeToString(op.SignPub())}})
+ if e != nil {
+ t.Fatal(e)
+ }
+ settings, e := teammode.Verify(&teammode.Config{TeamID: b.Team, DirectoryOrigin: b.Directory, ProvisioningBase64: base64.StdEncoding.EncodeToString(raw), OperatorKeysBase64: base64.StdEncoding.EncodeToString(keys), RosterToken: fixed(7)}, &teammode.Home{Issuer: b.Issuer, ConsumerID: b.Consumer}, "docs", b.Audience)
+ if e != nil {
+ t.Fatal(e)
+ }
+ cache, e := teammode.Open(t.Context(), teammode.RuntimeConfig{Settings: settings, State: teamState, DB: app.db.Writer(), Sealer: sealer, IssuerTables: []string{"docs_identity_links", "docs_home_identities"}, Clock: clock, Transport: transport})
if e != nil {
t.Fatal(e)
}
@@ -254,7 +269,7 @@ func TestTeamWriterGrantRevokedWhileWaitingForSQLiteWriter(t *testing.T) {
}
s.team = &teamRuntime{}
actor := localActor(guest, "guest@example.com")
- ctx = context.WithValue(ctx, accessContextKey{}, &requestAccess{runtime: s.team, actor: actor, decision: roster.Decision{State: roster.NotMember}})
+ ctx = context.WithValue(ctx, accessContextKey{}, &requestAccess{runtime: s.team, actor: actor, Access: standing(roster.NotMember)})
writer := app.db.Writer()
tx, e := writer.BeginTx(ctx, nil)
if e != nil {
@@ -422,7 +437,7 @@ func TestTeamPermissionContentionCannotRecoverIntoPermanentDenial(t *testing.T)
f.clock.next = func() { close(entered); <-release }
f.clock.mu.Unlock()
go func() {
- f.app.store.team.cache.Check(t.Context(), bridgeIssuer, "TeamA", teamSubject('a'))
+ f.app.store.team.cache.Check(t.Context(), teamSubject('a'))
close(finished)
}()
<-entered
@@ -430,7 +445,9 @@ func TestTeamPermissionContentionCannotRecoverIntoPermanentDenial(t *testing.T)
scope := f.app.store.permissionScope(ctx, f.app.store.db.Model(&Document{}), id.Actor, permissionWrite)
close(release)
<-finished
- if !a.decision.Lease.Valid() {
+ // The request's lease is from this same publication: valid again once
+ // the contention ends, so only the latch keeps the request Unknown.
+ if d := f.app.store.team.cache.Check(t.Context(), teamSubject('a')); d.State != roster.Member || !d.Lease.Valid() {
t.Fatal("fixture did not recover the same valid lease")
}
var found Document
diff --git a/internal/docs/team_config.go b/internal/docs/team_config.go
index b99f120..cf7edb0 100644
--- a/internal/docs/team_config.go
+++ b/internal/docs/team_config.go
@@ -3,22 +3,19 @@ package docs
import (
"amadan.net/rastrillo/rastrillo/sessions"
"context"
- "crypto/sha256"
"database/sql"
- "encoding/base64"
"errors"
"net/http"
- "sync/atomic"
"amadan.net/oficina/home/handoff/seal"
"amadan.net/oficina/home/roster"
+ "amadan.net/oficina/home/teammode"
"amadan.net/rastrillo/rastrillo/migrate"
"github.com/carlosframework/docs/internal/docs/principalstore"
- "github.com/carlosframework/docs/internal/docs/teamstate"
- "github.com/go-json-experiment/json"
)
// TeamConfig is explicit deployment configuration, never browser request input.
+// cmd/docs fills it from teammode.ConfigFromEnv("DOCS").
type TeamConfig struct {
transport http.RoundTripper
clock roster.Clock
@@ -29,95 +26,79 @@ type TeamConfig struct {
RosterToken string
}
-var errTeamConfig = errors.New("docs: invalid team configuration")
-var errTeamUnavailable = errors.New("docs: team authority unavailable")
+// Docs' two team errors are teammode's, so a refusal from Verify, Open or
+// Guard is the same value the handlers already map to a refused boot and a
+// retryable 503.
+var errTeamConfig = teammode.ErrConfig
+var errTeamUnavailable = teammode.ErrUnavailable
+
+// teamState is the activation marker and roster evidence. Its schema is
+// byte-for-byte the docs_team/0001_team migration Docs applied before it
+// used teammode, so an activated database's ledger is unchanged
+// (TestTeamStateKeepsTheAppliedLedger).
+var teamState = teammode.MustState("docs")
type teamSettings struct {
- transport http.RoundTripper
- clock roster.Clock
- record roster.VerifiedRecord
- token string
- fingerprint string
+ *teammode.Settings
+ transport http.RoundTripper
+ clock roster.Clock
}
-var TeamBootSchema = migrate.Merge(BootSchema, principalstore.Schema, teamstate.Schema)
+var TeamBootSchema = migrate.Merge(BootSchema, principalstore.Schema, teamState.Schema())
func validatedTeamConfig(cfg *TeamConfig, home *homeSettings, origin string) (*teamSettings, error) {
if cfg == nil {
return nil, nil
}
- if home == nil || !roster.ValidChallenge(cfg.RosterToken) {
- return nil, errTeamConfig
- }
- raw, ok := homeConfigBase64(cfg.ProvisioningBase64, roster.BodyLimit)
- if !ok {
- return nil, errTeamConfig
- }
- encoded, ok := homeConfigBase64(cfg.OperatorKeysBase64, 4096)
- if !ok {
- return nil, errTeamConfig
- }
- var keys []roster.Key
- if json.Unmarshal(encoded, &keys, json.RejectUnknownMembers(true)) != nil {
- return nil, errTeamConfig
- }
- expected := roster.Bindings{Issuer: home.issuer, Directory: cfg.DirectoryOrigin, Consumer: home.consumerID, App: "docs", Team: cfg.TeamID, Audience: origin}
- record, e := roster.VerifyProvisioning(raw, keys, expected)
- if e != nil {
+ if home == nil {
return nil, errTeamConfig
}
- b, e := json.Marshal(record.Bindings())
+ settings, e := teammode.Verify(&teammode.Config{TeamID: cfg.TeamID, DirectoryOrigin: cfg.DirectoryOrigin, ProvisioningBase64: cfg.ProvisioningBase64, OperatorKeysBase64: cfg.OperatorKeysBase64, RosterToken: cfg.RosterToken}, &teammode.Home{Issuer: home.issuer, ConsumerID: home.consumerID}, "docs", origin)
if e != nil {
return nil, errTeamConfig
}
- digest := sha256.Sum256(b)
- return &teamSettings{transport: cfg.transport, clock: cfg.clock, record: record, token: cfg.RosterToken, fingerprint: base64.RawURLEncoding.EncodeToString(digest[:])}, nil
+ return &teamSettings{Settings: settings, transport: cfg.transport, clock: cfg.clock}, nil
}
type teamRuntime struct {
+ // cache is the roster cache, behind teammode's runtime: its Check is
+ // the only way Docs asks it, and Access the only way a request does.
+ cache *teammode.Runtime
bridge *homeBridge
readSession func(context.Context, *http.Request) (sessions.Session, bool)
- cache *roster.Cache
principals *principalstore.Store
bindings roster.Bindings
db *sql.DB
- // rosterHeld: some check since boot had a complete roster (team_probe.go).
- rosterHeld atomic.Bool
}
func newTeamRuntime(ctx context.Context, settings *teamSettings, db *sql.DB, home *homeSettings) (*teamRuntime, error) {
if settings == nil || db == nil || home == nil {
return nil, errTeamConfig
}
- b := settings.record.Bindings()
- var foreign int
- if e := db.QueryRowContext(ctx, "SELECT (SELECT COUNT(*) FROM docs_identity_links WHERE issuer!=?)+(SELECT COUNT(*) FROM docs_home_identities WHERE issuer!=?)", b.Issuer, b.Issuer).Scan(&foreign); e != nil {
- return nil, errTeamUnavailable
- }
- if foreign != 0 {
- return nil, errTeamConfig
- }
- if e := teamstate.Activate(ctx, db, settings.fingerprint); e != nil {
- return nil, errTeamConfig
- }
sealer, e := seal.New(home.dek, "oficina/docs")
if e != nil {
return nil, errTeamConfig
}
- cache, e := roster.New(ctx, roster.Config{Record: settings.record, Token: settings.token, Transport: settings.transport, Clock: settings.clock, Durable: teamstate.Evidence{DB: db}, Sealer: sealer})
+ cache, e := teammode.Open(ctx, teammode.RuntimeConfig{Settings: settings.Settings, State: teamState, DB: db, Sealer: sealer, IssuerTables: []string{"docs_identity_links", "docs_home_identities"}, Transport: settings.transport, Clock: settings.clock})
if e != nil {
+ if errors.Is(e, teammode.ErrConfig) {
+ return nil, errTeamConfig
+ }
return nil, errTeamUnavailable
}
+ b := cache.Bindings()
runtime := &teamRuntime{cache: cache, bindings: b, db: db}
+ // The allocation gate until Docs moves onto home/connect, whose
+ // Unlinked hook takes AdmitUnlinked directly: a Home-only principal
+ // is created only while the roster says Member under a valid lease.
principals, e := principalstore.New(db, principalstore.Config{Issuer: b.Issuer, Team: b.Team, RequireMembership: func(ctx context.Context, request principalstore.MembershipRequest) error {
- if request.Issuer != b.Issuer || request.Team != b.Team {
+ if request.Team != b.Team {
return principalstore.ErrUnavailable
}
- d := runtime.check(ctx, request.Subject)
- if d.State == roster.Member && d.Lease.Valid() {
+ switch e := cache.AdmitUnlinked(ctx, request.Issuer, request.Subject); {
+ case e == nil:
return nil
- }
- if d.State == roster.NotMember {
+ case errors.Is(e, teammode.ErrNotMember):
return principalstore.ErrRefused
}
return principalstore.ErrUnavailable
diff --git a/internal/docs/team_emission.go b/internal/docs/team_emission.go
index 2605287..bd4f87b 100644
--- a/internal/docs/team_emission.go
+++ b/internal/docs/team_emission.go
@@ -34,7 +34,7 @@ func (a *requestAccess) checkResponse(ctx context.Context) error {
if a.responseStore == nil {
return errTeamUnavailable
}
- if len(a.responseDocs) == 0 && a.state() == roster.Unknown {
+ if len(a.responseDocs) == 0 && a.state() == roster.Unknown && !a.partialNotice {
return errTeamUnavailable
}
for id, p := range a.responseDocs {
@@ -77,7 +77,7 @@ func writeGuardedBody(w http.ResponseWriter, r *http.Request, status int, parts
prepare := func() error {
remaining := defaultStreamWriteDeadline
if a.state() == roster.Member {
- lease := a.decision.Lease.Remaining()
+ lease := a.Remaining()
if lease <= 0 {
return errTeamUnavailable
}
diff --git a/internal/docs/team_home_test.go b/internal/docs/team_home_test.go
index ddfe8e8..d55595d 100644
--- a/internal/docs/team_home_test.go
+++ b/internal/docs/team_home_test.go
@@ -29,7 +29,7 @@ func TestTeamCompletionCannotAllocateAroundCurrentAccount(t *testing.T) {
calls := 0
rt.principals, e = principalstore.New(app.db.Writer(), principalstore.Config{Issuer: rt.bindings.Issuer, Team: rt.bindings.Team, RequireMembership: func(ctx context.Context, q principalstore.MembershipRequest) error {
calls++
- d := rt.cache.Check(ctx, q.Issuer, q.Team, q.Subject)
+ d := rt.cache.Check(ctx, q.Subject)
if d.State == roster.Member && d.Lease.Valid() {
return nil
}
diff --git a/internal/docs/team_identity_test.go b/internal/docs/team_identity_test.go
index 3929a70..3408563 100644
--- a/internal/docs/team_identity_test.go
+++ b/internal/docs/team_identity_test.go
@@ -12,7 +12,6 @@ import (
family "amadan.net/rastrillo/rastrillo/crypto"
"amadan.net/rastrillo/rastrillo/migrate"
"github.com/carlosframework/docs/internal/docs/principalstore"
- "github.com/carlosframework/docs/internal/docs/teamstate"
"github.com/go-json-experiment/json"
"gorm.io/gorm"
)
@@ -63,7 +62,7 @@ func TestTeamConfigPinsAndColdMarker(t *testing.T) {
if rt.cache == nil || rt.principals == nil {
t.Fatal("runtime missing")
}
- if got, yes, e := teamstate.Required(t.Context(), app.db.Writer()); e != nil || !yes || got != settings.fingerprint {
+ if got, yes, e := teamState.Required(t.Context(), app.db.Writer()); e != nil || !yes || got != settings.Fingerprint() {
t.Fatal("runtime did not commit marker")
}
var count int
@@ -133,3 +132,49 @@ func TestTeamIdentityAddressAbsenceNeverRedeemsEmptyGrant(t *testing.T) {
t.Fatal("unsupported local method accepted")
}
}
+
+// Activation refuses a database holding a Home identity from another issuer,
+// in either of Docs' tables, and writes no marker: the marker pins one issuer,
+// and a row from another would be read under it.
+func TestTeamActivationCensusCoversBothIdentityTables(t *testing.T) {
+ for _, table := range []string{"docs_identity_links", "docs_home_identities"} {
+ t.Run(table, func(t *testing.T) {
+ cfg, home := teamConfigFixture(t)
+ settings, e := validatedTeamConfig(cfg, home, "https://docs.example")
+ if e != nil {
+ t.Fatal(e)
+ }
+ app := newSampleDocumentsInternalTestApp(t, "0")
+ ctx := t.Context()
+ if _, e = migrate.Apply(ctx, app.db, TeamBootSchema); e != nil {
+ t.Fatal(e)
+ }
+ const other = "https://other.example"
+ subject := "pr_" + strings.Repeat("a", 26)
+ switch table {
+ case "docs_identity_links":
+ person, e := app.Store().EnsurePerson(ctx, "linked@example.com")
+ if e != nil {
+ t.Fatal(e)
+ }
+ if _, e = app.db.Writer().Exec("INSERT INTO docs_identity_links(issuer,subject,person_id) VALUES(?,?,?)", other, subject, person); e != nil {
+ t.Fatal(e)
+ }
+ default:
+ ps, e := principalstore.New(app.db.Writer(), principalstore.Config{Issuer: other, Team: "TeamA", RequireMembership: func(context.Context, principalstore.MembershipRequest) error { return nil }})
+ if e != nil {
+ t.Fatal(e)
+ }
+ if _, e = ps.EnsureHome(ctx, principalstore.HomeIdentity{Issuer: other, Subject: subject}); e != nil {
+ t.Fatal(e)
+ }
+ }
+ if _, e = newTeamRuntime(ctx, settings, app.db.Writer(), home); e != errTeamConfig {
+ t.Fatal("activated over another issuer's identity", e)
+ }
+ if _, activated, e := teamState.Required(ctx, app.db.Writer()); e != nil || activated {
+ t.Fatal("a refused census wrote the marker", e)
+ }
+ })
+ }
+}
diff --git a/internal/docs/team_probe.go b/internal/docs/team_probe.go
index 77a0167..390bd7c 100644
--- a/internal/docs/team_probe.go
+++ b/internal/docs/team_probe.go
@@ -1,90 +1,22 @@
package docs
import (
- "context"
- "encoding/json"
"net/http"
- "strings"
- "amadan.net/oficina/home/roster"
- "amadan.net/rastrillo/rastrillo"
+ "amadan.net/oficina/home/teammode"
)
// teamProbePath is the readiness probe Alta polls at provisioning step 11,
// before it activates this instance in Home's directory (Home
// implementation/team-members.md §7; Alta provision/steps.go TeamProbe).
-//
-// It is unauthenticated and answers only {team_mode, consumer, roster}:
-// whether this instance runs in team mode, the consumer ID its verified
-// provisioning record names, and how its roster cache stands. No account
-// data — no subject, role, member count, address, team ID or issuer — and
-// nothing that differs with who is asking. With team mode off it answers
-// {"team_mode":false} and nothing else.
-const teamProbePath = "/api/team"
-
-type teamProbe struct {
- TeamMode bool `json:"team_mode"`
- Consumer string `json:"consumer,omitempty"`
- Roster string `json:"roster,omitempty"`
-}
-
-// rosterProbeSubject is a well-formed person ref the probe asks the cache
-// about. Its answer is never used, only whether there was one: Member or
-// NotMember both mean the cache holds a complete roster younger than
-// roster.MaximumAge, which is what "ok" claims.
-var rosterProbeSubject = "pr_" + strings.Repeat("2", 26)
-
-// check is the only way this runtime asks the roster cache, so that every
-// definite answer — a request's, a principal allocation's or the probe's —
-// records that a complete roster has been held since boot.
-func (t *teamRuntime) check(ctx context.Context, subject string) roster.Decision {
- d := t.cache.Check(ctx, t.bindings.Issuer, t.bindings.Team, subject)
- if d.State != roster.Unknown {
- t.rosterHeld.Store(true)
- }
- return d
-}
-
-// rosterState is the probe's roster field:
-//
-// - "ok": a complete roster, fetched within roster.MaximumAge, decides
-// standing now.
-// - "stale": one was held since this process started, but it has aged out
-// and could not be refreshed, so standing is Unknown.
-// - "unknown": no complete roster has been held since boot.
-//
-// Asking the cache starts a refresh when one is due and waits for it (at
-// most roster.FetchTimeout), exactly as a signed-in request does — which is
-// what lets Alta's polling pull the first roster while Home's verify window
-// is open. The cache's own single flight and RetryAfter backoff bound how
-// often an unauthenticated caller can make this instance ask the directory.
-func (t *teamRuntime) rosterState(ctx context.Context) string {
- if t.check(ctx, rosterProbeSubject).State != roster.Unknown {
- return "ok"
- }
- if t.rosterHeld.Load() {
- return "stale"
- }
- return "unknown"
-}
-
-func (h *handlers) teamProbe(w http.ResponseWriter, r *http.Request) {
- probe := teamProbe{}
- if team := h.store.team; team != nil {
- probe = teamProbe{TeamMode: true, Consumer: team.bindings.Consumer, Roster: team.rosterState(r.Context())}
- }
- body, err := json.Marshal(probe)
- if err != nil {
- h.logger.Error("docs: encode team probe", "err", err)
- http.Error(w, rastrillo.T(r, "docs.error.generic"), http.StatusInternalServerError)
- return
- }
- w.Header().Set("Content-Type", "application/json; charset=utf-8")
- // Readiness changes from one second to the next; a cached "ok" would
- // let Alta activate an instance whose roster has since gone stale.
- w.Header().Set("Cache-Control", "no-store")
- w.Header().Set("X-Content-Type-Options", "nosniff")
- if _, err = w.Write(body); err != nil {
- h.logger.Error("docs: write team probe", "err", err)
+// teammode.Probe answers it: unauthenticated, {team_mode, consumer, roster}
+// only, the same body whoever asks, and {"team_mode":false} with team mode
+// off.
+const teamProbePath = teammode.ProbePath
+
+func teamProbe(t *teamRuntime) http.Handler {
+ if t == nil {
+ return teammode.Probe(nil)
}
+ return teammode.Probe(t.cache)
}
diff --git a/internal/docs/team_probe_test.go b/internal/docs/team_probe_test.go
index d4605c4..6bc940f 100644
--- a/internal/docs/team_probe_test.go
+++ b/internal/docs/team_probe_test.go
@@ -129,7 +129,7 @@ func TestTeamProbeCarriesNoAccountData(t *testing.T) {
body := anonymous.Body.String()
for _, secret := range []string{
- "pr_", teamSubject('a'), teamSubject('b'), teamSubject('c'), rosterProbeSubject,
+ "pr_", teamSubject('a'), teamSubject('b'), teamSubject('c'), "pr_" + strings.Repeat("2", 26),
"alice@example.com", "bob@example.com", "@",
bridgeIssuer, "TeamA", "https://home.example", bridgeOrigin,
"member", "owner", "epoch", "generation", "count",
diff --git a/internal/docs/team_router_test.go b/internal/docs/team_router_test.go
index d28f683..d87278f 100644
--- a/internal/docs/team_router_test.go
+++ b/internal/docs/team_router_test.go
@@ -11,6 +11,7 @@ import (
"io"
"log/slog"
"net/http"
+ "net/http/httptest"
"net/url"
"path/filepath"
"strings"
@@ -22,6 +23,7 @@ import (
family "amadan.net/rastrillo/rastrillo/crypto"
"amadan.net/rastrillo/rastrillo/sessions"
"github.com/carlosframework/docs/internal/docs/principalstore"
+ "gorm.io/gorm"
)
type teamRouterDirectory struct {
@@ -337,3 +339,132 @@ func TestTeamRouterActivatedDatabaseRefusesMissingAndMismatchedConfiguration(t *
t.Fatal("activated database accepted missing Home identity configuration")
}
}
+
+// The partial notice is asked after the list is built, from the same
+// Access (Paul's ruling on list pages, 2026-10-28, condition 1): a lease
+// that lapses after the page's first look at it, and before the list is
+// scoped, must still mark the shares-only list partial.
+func TestTeamListAsksPartialAfterListing(t *testing.T) {
+ f := newTeamRouterFixture(t)
+ b := f.browser()
+ b.localSignin(t, "alice@example.com")
+ b.linkProof(t, teamSubject('a'), "alice@example.com")
+ routerRedirect(t, b.do("POST", "/account/home/confirm", ""), connectedURL("/"))
+ if r := b.do("GET", "/", ""); r.Code != 200 || strings.Contains(r.Body.String(), `<p>docs.team.partial</p>`) || !strings.Contains(r.Body.String(), "Alice original") {
+ t.Fatal("member list", r.Code)
+ }
+ f.directory.change(nil, true)
+ // Armed when the request resolves its person, before admission: the
+ // roster clock's first reading is admission's decision (Member), the
+ // second the handler's first look at it (Member), and the lease has
+ // lapsed by the third.
+ reads := 0
+ var count func()
+ count = func() {
+ if reads++; reads == 3 {
+ f.clock.elapsed += 60 * time.Second
+ return
+ }
+ f.clock.next = count
+ }
+ if e := f.app.store.db.Callback().Query().Before("gorm:query").Register("test:arm-lapse", func(tx *gorm.DB) {
+ if tx.Statement.Table == "people" && reads == 0 {
+ f.clock.mu.Lock()
+ f.clock.next = count
+ f.clock.mu.Unlock()
+ }
+ }); e != nil {
+ t.Fatal(e)
+ }
+ defer f.app.store.db.Callback().Query().Remove("test:arm-lapse")
+ r := b.do("GET", "/", "")
+ if reads < 3 || r.Code != 200 || strings.Contains(r.Body.String(), "Alice original") || !strings.Contains(r.Body.String(), "Bob shared") {
+ t.Fatal("the lease did not lapse between the first look and the list", reads, r.Code)
+ }
+ if !strings.Contains(r.Body.String(), `<p>docs.team.partial</p>`) {
+ t.Fatal("a shares-only list built under a lapsed lease was not marked partial")
+ }
+}
+
+// A first Home entry the roster cannot decide is a retryable 503 that
+// allocates nothing: the allocation gate is Runtime.AdmitUnlinked, and only
+// its definite "not a member" is the 403 "unknown".
+func TestTeamRouterHomeOnlyFirstEntryUnderUnknownIsRetryable(t *testing.T) {
+ f := newTeamRouterFixture(t)
+ f.directory.change(nil, true)
+ f.clock.step(61 * time.Second)
+ b := f.browser()
+ nonce := b.start(t, "/auth/start?return_to=%2F", "")
+ if r := b.exchange(t, nonce, teamSubject('c'), time.Now()); r.Code != 503 {
+ t.Fatal("undecided first entry was not retryable", r.Code)
+ }
+ if _, e := f.app.store.team.principals.Resolve(t.Context(), bridgeIssuer, teamSubject('c')); !errors.Is(e, principalstore.ErrRefused) {
+ t.Fatal("undecided first entry allocated a principal", e)
+ }
+}
+
+// The native list renders no partial notice, so under Unknown it is
+// unavailable rather than a short list of shares (Fable on #100).
+func TestTeamNativeListUnderUnknownIsUnavailableNotShort(t *testing.T) {
+ f := newTeamRouterFixture(t)
+ b := f.browser()
+ b.localSignin(t, "alice@example.com")
+ b.linkProof(t, teamSubject('a'), "alice@example.com")
+ routerRedirect(t, b.do("POST", "/account/home/confirm", ""), connectedURL("/"))
+ native := func(path string) *httptest.ResponseRecorder {
+ r := b.request("GET", path, "")
+ r.Header.Set("Accept", "application/json")
+ return b.serve(r)
+ }
+ if r := native("/"); r.Code != 200 || !strings.Contains(r.Body.String(), "Alice original") || !strings.Contains(r.Body.String(), "Bob shared") {
+ t.Fatal("member native list", r.Code)
+ }
+ f.directory.change(nil, true)
+ f.clock.step(61 * time.Second)
+ for _, path := range []string{"/", "/?q=Bob"} {
+ if r := native(path); r.Code != 503 || strings.Contains(r.Body.String(), "Bob shared") {
+ t.Fatal("native list under Unknown was short, not unavailable", path, r.Code, r.Body.String())
+ }
+ }
+}
+
+// Under Unknown the list page is the partial list with the notice even when
+// it is empty: the empty state and the notice, not a 503 (Paul's ruling on
+// list pages, 2026-10-28). NotMember's empty list is complete, so it carries
+// no notice; item pages and the dashboard feed are unchanged.
+func TestTeamEmptyListUnderUnknownIsPartialNotUnavailable(t *testing.T) {
+ f := newTeamRouterFixture(t)
+ b := f.browser()
+ b.localSignin(t, "bob@example.com")
+ // Bob signed in locally with no Home link is a guest, and nothing is
+ // shared with him: an empty list, complete, with no notice.
+ if r := b.do("GET", "/", ""); r.Code != 200 || strings.Contains(r.Body.String(), `<p>docs.team.partial</p>`) || !strings.Contains(r.Body.String(), "docs.list.empty.title") {
+ t.Fatal("guest's empty list", r.Code)
+ }
+ b.linkProof(t, teamSubject('b'), "bob@example.com")
+ routerRedirect(t, b.do("POST", "/account/home/confirm", ""), connectedURL("/"))
+ if r := b.do("GET", "/", ""); r.Code != 200 || !strings.Contains(r.Body.String(), "Bob private") {
+ t.Fatal("member list", r.Code)
+ }
+ f.directory.change(nil, true)
+ f.clock.step(61 * time.Second)
+ for _, path := range []string{"/", "/?q=Bob"} {
+ r := b.do("GET", path, "")
+ body := r.Body.String()
+ if r.Code != 200 || !strings.Contains(body, `<p>docs.team.partial</p>`) || strings.Contains(body, "Bob private") || strings.Contains(body, "Bob shared") {
+ t.Fatal("empty list under Unknown was not partial", path, r.Code)
+ }
+ }
+ if r := b.do("GET", "/", ""); !strings.Contains(r.Body.String(), "docs.list.empty.title") {
+ t.Fatal("empty partial list lost its empty state")
+ }
+ if r := b.do("GET", "/d/"+f.hidden.Sqid, ""); r.Code != 503 {
+ t.Fatal("own item under Unknown was not a retryable 503", r.Code)
+ }
+ // The native list renders no notice, so it is still unavailable.
+ native := b.request("GET", "/", "")
+ native.Header.Set("Accept", "application/json")
+ if r := b.serve(native); r.Code != 503 {
+ t.Fatal("native list under Unknown was not unavailable", r.Code)
+ }
+}
diff --git a/internal/docs/team_state_test.go b/internal/docs/team_state_test.go
new file mode 100644
index 0000000..99e6f08
--- /dev/null
+++ b/internal/docs/team_state_test.go
@@ -0,0 +1,121 @@
+package docs
+
+import (
+ "crypto/sha256"
+ "database/sql"
+ "embed"
+ "encoding/base64"
+ "io/fs"
+ "path/filepath"
+ "reflect"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/home/roster"
+ "amadan.net/oficina/home/teammode"
+ "amadan.net/rastrillo/rastrillo/db"
+ "amadan.net/rastrillo/rastrillo/migrate"
+ "github.com/carlosframework/docs/internal/docs/principalstore"
+ "github.com/go-json-experiment/json"
+)
+
+// The team migration exactly as Docs applied it before teammode
+// (internal/docs/teamstate/migrations/0001_team.sql at e58a22f).
+//
+//go:embed testdata/teamstate-e58a22f/migrations/0001_team.sql
+var teamstateE58a22f embed.FS
+
+// legacyTeamDatabase is a database as the old code left it: the old
+// docs_team set applied beside the app's schema, and the marker the old
+// teamstate.Activate wrote, with the old fingerprint (base64url SHA-256 of
+// the bindings' JSON).
+func legacyTeamDatabase(t *testing.T, path, migration string, b roster.Bindings) []ledgerRow {
+ t.Helper()
+ sub, err := fs.Sub(teamstateE58a22f, "testdata/teamstate-e58a22f")
+ if err != nil {
+ t.Fatal(err)
+ }
+ old := migrate.MustFromFS(sub, "docs_team")
+ if migration != "" {
+ old = migrate.MustFromFS(embed.FS{}, "docs_team").Add(migrate.Migration{ID: "0001_team", SQL: migration})
+ }
+ d, err := db.Open(path, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer d.Close()
+ if _, err = migrate.Apply(t.Context(), d, migrate.Merge(BootSchema, principalstore.Schema, old)); err != nil {
+ t.Fatal(err)
+ }
+ raw, err := json.Marshal(b)
+ if err != nil {
+ t.Fatal(err)
+ }
+ digest := sha256.Sum256(raw)
+ if _, err = d.Writer().Exec("INSERT INTO docs_team_required(id,bindings) VALUES(1,?)", base64.RawURLEncoding.EncodeToString(digest[:])); err != nil {
+ t.Fatal(err)
+ }
+ return readLedger(t, d.Writer())
+}
+
+type ledgerRow struct{ ID, AppliedAt, Checksum string }
+
+func readLedger(t *testing.T, q *sql.DB) []ledgerRow {
+ t.Helper()
+ rows, err := q.QueryContext(t.Context(), "SELECT id, applied_at, checksum FROM rastrillo_migrations ORDER BY id")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer rows.Close()
+ var out []ledgerRow
+ for rows.Next() {
+ var r ledgerRow
+ if err := rows.Scan(&r.ID, &r.AppliedAt, &r.Checksum); err != nil {
+ t.Fatal(err)
+ }
+ out = append(out, r)
+ }
+ return out
+}
+
+// A database activated by the old code boots under teammode with its
+// migration ledger untouched: State("docs").Schema() is the applied
+// docs_team/0001_team byte for byte, so nothing re-runs and no checksum
+// moves, and the old marker is the fingerprint teammode computes.
+func TestTeamStateKeepsTheAppliedLedger(t *testing.T) {
+ cfg := newTeamRouterFixture(t).cfg
+ b := roster.Bindings{Issuer: bridgeIssuer, Directory: "https://home.example", Consumer: "router-docs", App: "docs", Team: "TeamA", Audience: bridgeOrigin}
+
+ cfg.DBPath = filepath.Join(t.TempDir(), "legacy.db")
+ before := legacyTeamDatabase(t, cfg.DBPath, "", b)
+ app, err := New(cfg)
+ if err != nil {
+ t.Fatal("a database activated by the old code did not boot:", err)
+ }
+ after := readLedger(t, app.db.Writer())
+ marker, activated, err := teamState.Required(t.Context(), app.db.Writer())
+ if closeErr := app.Close(); closeErr != nil {
+ t.Fatal(closeErr)
+ }
+ if !reflect.DeepEqual(before, after) {
+ t.Fatalf("ledger moved:\nbefore %v\nafter %v", before, after)
+ }
+ if err != nil || !activated || marker != teammode.Fingerprint(b) {
+ t.Fatal("the old marker is not teammode's fingerprint", err)
+ }
+
+ // Byte for byte, not only up to the ledger's whitespace-blind checksum.
+ applied, err := teamstateE58a22f.ReadFile("testdata/teamstate-e58a22f/migrations/0001_team.sql")
+ if err != nil || string(applied) != teamState.SQL() {
+ t.Fatal("State(\"docs\").SQL() is not the migration Docs applied", err)
+ }
+
+ // The ledger check is live: had the applied SQL differed (here, in a
+ // trigger's message), the same boot would have refused.
+ cfg.DBPath = filepath.Join(t.TempDir(), "moved.db")
+ legacyTeamDatabase(t, cfg.DBPath, strings.Replace(teamState.SQL(), "docs team: refused", "docs team: refusal", 1), b)
+ if app, err := New(cfg); err == nil {
+ app.Close()
+ t.Fatal("a moved team migration booted")
+ }
+}
diff --git a/internal/docs/team_stream.go b/internal/docs/team_stream.go
index 93e27fb..83dde9a 100644
--- a/internal/docs/team_stream.go
+++ b/internal/docs/team_stream.go
@@ -5,29 +5,28 @@ import (
"net/http"
"time"
- "amadan.net/oficina/home/roster"
"amadan.net/rastrillo/rastrillo/sessions"
)
type teamStreamGuard struct {
- store *Store
- access *requestAccess
- request *http.Request
- docID int64
+ store *Store
+ access *requestAccess
+ request *http.Request
+ docID int64
+ // deadline is the Member lease's, fixed when the stream opened; zero
+ // for a stream that rests on no lease (a guest's, or Unknown's, grant).
deadline time.Time
}
+// remaining is how long the stream may run before it must re-decide. A
+// leased stream ends with its lease (Access.Remaining is 0 once the lease
+// has lapsed or the standing has gone Unknown), and never past the deadline
+// it opened with.
func (g *teamStreamGuard) remaining() time.Duration {
- if g.access.uncertain {
- return 0
+ if g.deadline.IsZero() {
+ return defaultStreamWriteDeadline
}
- if g.access.decision.State == roster.Member {
- if g.deadline.IsZero() {
- return 0
- }
- return min(g.access.decision.Lease.Remaining(), time.Until(g.deadline))
- }
- return defaultStreamWriteDeadline
+ return min(g.access.Remaining(), time.Until(g.deadline))
}
// A stream never renews its lease. Reconnection obtains fresh admission, so a
@@ -50,7 +49,7 @@ func (g *teamStreamGuard) check() (time.Duration, bool) {
}
request := sessions.WithSession(g.request.WithContext(ctx), session)
id, e := t.bridge.resolver.resolve(request)
- if e != nil || !sameActor(id.Actor, g.access.actor) || id.HomeSubject != g.access.subject {
+ if e != nil || !sameActor(id.Actor, g.access.actor) || id.HomeSubject != g.access.Subject() {
return 0, false
}
if e = g.store.checkPermission(ctx, g.store.db.WithContext(ctx), id.Actor, g.docID, permissionRead); e != nil {
diff --git a/internal/docs/team_stream_test.go b/internal/docs/team_stream_test.go
index aeeb6a8..02db04a 100644
--- a/internal/docs/team_stream_test.go
+++ b/internal/docs/team_stream_test.go
@@ -93,7 +93,13 @@ func TestTeamStreamActualSessionWriterWaitCannotExtendOriginalLease(t *testing.T
t.Fatal("stream cancellation revoked legacy session")
}
}
-func TestTeamStreamHealthyPublicationClosesOriginalLeaseAndReconnects(t *testing.T) {
+
+// A publication that still lists the member with the same role keeps the
+// stream's lease (Home #97: before it, every refresh ended every lease, and
+// this test asserted that). One that changes their role ends it at once, and
+// the reconnect is decided afresh. The lease's deadline never moves, so the
+// 60 s contract is untouched (TestTeamStreamActualSessionWriterWait...).
+func TestTeamStreamPublicationKeepsAListedLeaseAndClosesAChangedOne(t *testing.T) {
f := newTeamRouterFixture(t)
b := f.browser()
b.localSignin(t, "alice@example.com")
@@ -104,16 +110,26 @@ func TestTeamStreamHealthyPublicationClosesOriginalLeaseAndReconnects(t *testing
defer srv.Close()
res := teamOpenActualStream(t, f, b, srv)
defer res.Body.Close()
+ done := make(chan struct{})
+ go func() { io.Copy(io.Discard, res.Body); close(done) }()
+ f.clock.step(roster.RetryAfter)
+ if e := f.app.store.team.cache.Refresh(context.Background()); e != nil {
+ t.Fatal(e)
+ }
+ select {
+ case <-done:
+ t.Fatal("a publication that still lists the member closed the stream")
+ case <-time.After(300 * time.Millisecond):
+ }
+ f.directory.change([]roster.MemberEntry{{Subject: teamSubject('a'), Role: "owner"}, {Subject: teamSubject('b'), Role: "member"}, {Subject: teamSubject('c'), Role: "member"}}, false)
f.clock.step(roster.RetryAfter)
if e := f.app.store.team.cache.Refresh(context.Background()); e != nil {
t.Fatal(e)
}
- done := make(chan struct{})
- go func() { io.Copy(io.Discard, res.Body); close(done) }()
select {
case <-done:
case <-time.After(time.Second):
- t.Fatal("old stream renewed instead of closing after publication")
+ t.Fatal("old stream renewed instead of closing after a role change")
}
fresh := teamOpenActualStream(t, f, b, srv)
fresh.Body.Close()
diff --git a/internal/docs/teamstate/store.go b/internal/docs/teamstate/store.go
deleted file mode 100644
index 63ebb7b..0000000
--- a/internal/docs/teamstate/store.go
+++ /dev/null
@@ -1,98 +0,0 @@
-// Package teamstate keeps the mandatory-mode marker and opaque roster evidence.
-package teamstate
-
-import (
- "context"
- "database/sql"
- "embed"
- "encoding/base64"
- "errors"
-
- "amadan.net/oficina/home/roster"
- "amadan.net/rastrillo/rastrillo/migrate"
-)
-
-//go:embed migrations/*.sql
-var migrations embed.FS
-var Schema = migrate.MustFromFS(migrations, "docs_team")
-var ErrRefused = errors.New("docs team: refused")
-var ErrUnavailable = errors.New("docs team: unavailable")
-
-func validBinding(s string) bool {
- b, e := base64.RawURLEncoding.DecodeString(s)
- return e == nil && len(b) == 32 && base64.RawURLEncoding.EncodeToString(b) == s
-}
-
-// Required distinguishes a never-activated database from an unreadable marker.
-func Required(ctx context.Context, db *sql.DB) (string, bool, error) {
- var count int
- if e := db.QueryRowContext(ctx, "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='docs_team_required'").Scan(&count); e != nil {
- return "", false, ErrUnavailable
- }
- if count == 0 {
- return "", false, nil
- }
- var value string
- e := db.QueryRowContext(ctx, "SELECT bindings FROM docs_team_required WHERE id=1").Scan(&value)
- if errors.Is(e, sql.ErrNoRows) {
- return "", false, nil
- }
- if e != nil {
- return "", false, ErrUnavailable
- }
- if !validBinding(value) {
- return "", false, ErrRefused
- }
- return value, true, nil
-}
-
-// Activate commits before the caller may serve requests or allocate identities.
-// It records an already-verified deployment binding, never an owner or roster.
-func Activate(ctx context.Context, db *sql.DB, binding string) error {
- if !validBinding(binding) {
- return ErrRefused
- }
- tx, e := db.BeginTx(ctx, nil)
- if e != nil {
- return ErrUnavailable
- }
- defer tx.Rollback()
- if _, e = tx.ExecContext(ctx, "INSERT INTO docs_team_required(id,bindings) VALUES(1,?) ON CONFLICT(id) DO NOTHING", binding); e != nil {
- return ErrUnavailable
- }
- var got string
- if e = tx.QueryRowContext(ctx, "SELECT bindings FROM docs_team_required WHERE id=1").Scan(&got); e != nil {
- return ErrUnavailable
- }
- if got != binding {
- return ErrRefused
- }
- if tx.Commit() != nil {
- return ErrUnavailable
- }
- return nil
-}
-
-type Evidence struct{ DB *sql.DB }
-
-func (s Evidence) Load(ctx context.Context) ([]byte, error) {
- var b []byte
- e := s.DB.QueryRowContext(ctx, "SELECT payload FROM docs_team_roster_evidence WHERE id=1").Scan(&b)
- if errors.Is(e, sql.ErrNoRows) {
- return nil, roster.ErrNoEvidence
- }
- if e != nil || len(b) > roster.EvidenceLimit+128 {
- return nil, ErrUnavailable
- }
- return b, nil
-}
-func (s Evidence) Save(ctx context.Context, b []byte) error {
- if len(b) == 0 || len(b) > roster.EvidenceLimit+128 {
- return ErrRefused
- }
- _, e := s.DB.ExecContext(ctx, "INSERT INTO docs_team_roster_evidence(id,payload) VALUES(1,?) ON CONFLICT(id) DO UPDATE SET payload=excluded.payload", b)
- if e != nil {
- return ErrUnavailable
- }
- return nil
-}
diff --git a/internal/docs/teamstate/store_test.go b/internal/docs/teamstate/store_test.go
deleted file mode 100644
index 934ca1e..0000000
--- a/internal/docs/teamstate/store_test.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package teamstate
-
-import (
- "bytes"
- "context"
- "encoding/base64"
- "path/filepath"
- "strings"
- "testing"
-
- "amadan.net/oficina/home/roster"
- "amadan.net/rastrillo/rastrillo/db"
- "amadan.net/rastrillo/rastrillo/migrate"
-)
-
-func fixture(t *testing.T) *db.DB {
- t.Helper()
- d, e := db.Open(filepath.Join(t.TempDir(), "team.db"), nil)
- if e != nil {
- t.Fatal(e)
- }
- t.Cleanup(func() { d.Close() })
- return d
-}
-func TestMarkerActivationAndImmutability(t *testing.T) {
- d := fixture(t)
- ctx := context.Background()
- if _, yes, e := Required(ctx, d.Writer()); e != nil || yes {
- t.Fatal("fresh DB requires team")
- }
- if _, e := migrate.Apply(ctx, d, Schema); e != nil {
- t.Fatal(e)
- }
- if _, yes, e := Required(ctx, d.Writer()); e != nil || yes {
- t.Fatal("schema alone activated mode")
- }
- b := base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{1}, 32))
- if e := Activate(ctx, d.Writer(), b); e != nil {
- t.Fatal(e)
- }
- if got, yes, e := Required(ctx, d.Writer()); e != nil || !yes || got != b {
- t.Fatal("marker missing")
- }
- if e := Activate(ctx, d.Writer(), b); e != nil {
- t.Fatal("idempotent activation", e)
- }
- other := base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{2}, 32))
- if Activate(ctx, d.Writer(), other) != ErrRefused {
- t.Fatal("binding changed")
- }
- for _, q := range []string{"DELETE FROM docs_team_required", "UPDATE docs_team_required SET bindings=bindings"} {
- if _, e := d.Writer().Exec(q); e == nil {
- t.Fatal("marker mutable")
- }
- }
-}
-func TestMalformedMarkerAndEvidenceFailure(t *testing.T) {
- d := fixture(t)
- ctx := context.Background()
- if _, e := migrate.Apply(ctx, d, Schema); e != nil {
- t.Fatal(e)
- }
- if _, e := d.Writer().Exec("INSERT INTO docs_team_required VALUES(1,?)", strings.Repeat("?", 43)); e != nil {
- t.Fatal(e)
- }
- if _, _, e := Required(ctx, d.Writer()); e != ErrRefused {
- t.Fatal("malformed marker accepted")
- }
- evidence := Evidence{DB: d.Writer()}
- if _, e := evidence.Load(ctx); e != roster.ErrNoEvidence {
- t.Fatal(e)
- }
- first := []byte("opaque sealed test envelope")
- if e := evidence.Save(ctx, first); e != nil {
- t.Fatal(e)
- }
- cancelled, cancel := context.WithCancel(ctx)
- cancel()
- if evidence.Save(cancelled, []byte("replacement")) == nil {
- t.Fatal("cancelled replacement succeeded")
- }
- if evidence.Save(ctx, make([]byte, roster.EvidenceLimit+129)) != ErrRefused {
- t.Fatal("oversize accepted")
- }
- got, e := evidence.Load(ctx)
- if e != nil || !bytes.Equal(got, first) {
- t.Fatal("failed write replaced evidence")
- }
-}
diff --git a/internal/docs/teamstate/migrations/0001_team.sql b/internal/docs/testdata/teamstate-e58a22f/migrations/0001_team.sql
similarity index 100%
rename from internal/docs/teamstate/migrations/0001_team.sql
rename to internal/docs/testdata/teamstate-e58a22f/migrations/0001_team.sql
diff --git a/internal/shipped/shipped.go b/internal/shipped/shipped.go
index b5509e8..c0ec21a 100644
--- a/internal/shipped/shipped.go
+++ b/internal/shipped/shipped.go
@@ -60,6 +60,7 @@ var FirstParty = map[string]bool{
"amadan.net/oficina/home/dashboard": true,
"amadan.net/oficina/home/handoff": true,
"amadan.net/oficina/home/roster": true,
+ "amadan.net/oficina/home/teammode": true,
}
// toolchain is a toolchain the build or the checks run, found by its