console: landing reads survive a cancelled request; census re-pins
Two CI failures on 5893e30a. TestCurrentAccountMintSurvivesCancelledRequest: the gates commit gave memberAccount the request's context, and currentAccount called it with that context before minting, so a landing whose request was already gone failed at its first membership read (LastAccount) and never reached the detached mint. The membership reads that decide whether to mint (both memberAccount calls, before and under the landing lock) now run under context.WithoutCancel(ctx), as the mint already did, so the landing finds or mints the account however the request ended. The mint itself is unchanged (detached, bounded by landingMintTimeout). The landing still carries the request's values, so TestSignedInPagesQueryUnderTheRequestContext's landing case still passes; it no longer stops early when the client goes away, which is the point. TestPlan9B8RecordWriteCensus rejected two console units whose source digests changed. Reviewed: both are the same record writes, with only a context added to the guard calls ahead of them. - Server.attachDomainAs: linkedRefusalFor(ctx, ...). The CreateRecord write is unchanged; kinds unchanged (key:CreateRecord). - Server.placeAppTarget: demoMutationRefusal(ctx, ...) and linkedRefusalFor(ctx, ...). The demo guard used to make its own context.Background(). The record listing and SetRecordRegion writes are unchanged; kinds unchanged. They are re-pinned in a new layer, internal/provision/console_request_ctx_census_test.go (consoleRequestCtxWriteCensusInventory over configReceiptsWriteCensusInventory, refusing any change of class or kinds), and TestPlan9B8RecordWriteCensus reads that layer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+46
−3
internal/console/server.go+5 −2internal/provision/console_request_ctx_census_test.go+40 −0internal/provision/plan9_b8_census_test.go+1 −1
CI cancelled — superseded by a newer push — run details
diff --git a/internal/console/server.go b/internal/console/server.go| index 2e7e5b828..9311c0548 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -3079,8 +3079,11 @@ func (s *Server) redirectToCurrentAccount(w http.ResponseWriter, r *http.Request |
| // minting) give one personal account, not two. It runs detached from the |
| // request's cancellation, bounded by landingMintTimeout: a browser that gives |
| // up mid-mint must not leave a manifest in the bucket with no console row. |
| +// The membership reads that decide whether to mint are detached too: |
| +// a landing whose request is already gone still finds or mints the account, |
| +// so the next sign-in lands on it rather than on a half-made one. |
| func (s *Server) currentAccount(ctx context.Context, addr string) (string, error) { |
| - a, err := s.memberAccount(ctx, addr) |
| + a, err := s.memberAccount(context.WithoutCancel(ctx), addr) |
| if err != nil { |
| return "", err |
| } |
| @@ -3090,7 +3093,7 @@ func (s *Server) currentAccount(ctx context.Context, addr string) (string, error |
| mu := s.landingLock(addr) |
| mu.Lock() |
| defer mu.Unlock() |
| - if a, err := s.memberAccount(ctx, addr); err != nil { |
| + if a, err := s.memberAccount(context.WithoutCancel(ctx), addr); err != nil { |
| return "", err |
| } else if a != nil { |
| return a.Sqid, nil |
diff --git a/internal/provision/console_request_ctx_census_test.go b/internal/provision/console_request_ctx_census_test.go| new file mode 100644 |
| index 000000000..b2a4561d8 |
| --- /dev/null |
| +++ b/internal/provision/console_request_ctx_census_test.go |
| @@ -0,0 +1,40 @@ |
| +package provision |
| + |
| +// Record-write census re-pins for console request contexts (code-health |
| +// batch 3, branch console-request-ctx), layered on |
| +// configReceiptsWriteCensusInventory. No record write is added, moved or |
| +// reclassified, and no unit writes anything new. Two units changed only in |
| +// the guard calls ahead of their writes, which now take the caller's |
| +// context: |
| +// - Server.attachDomainAs (console): linkedRefusalFor(ctx, ...), so the |
| +// linked-app guard's store reads run under the attach's own context. |
| +// The CreateRecord write after it is unchanged. Kinds unchanged: |
| +// record-writer, key:CreateRecord. |
| +// - Server.placeAppTarget (console): demoMutationRefusal(ctx, ...) and |
| +// linkedRefusalFor(ctx, ...), the same two guards under the same |
| +// context; the demo guard used to build context.Background() itself. |
| +// The record listing and SetRecordRegion writes after them are |
| +// unchanged. Kinds unchanged: record-writer, |
| +// key:RecordsPrefix,key:SetRecordRegion. |
| +func consoleRequestCtxWriteCensusInventory() []censusEntry { |
| + entries := append([]censusEntry(nil), configReceiptsWriteCensusInventory()...) |
| + repins := []censusEntry{ |
| + {"internal/console/domainattach.go", "Server.attachDomainAs", "record-writer", "key:CreateRecord", "73e9cac53c477550b622238e1da7b9f3907202fc22f12a07de728199b2db552d"}, |
| + {"internal/console/fleets.go", "Server.placeAppTarget", "record-writer", "key:RecordsPrefix,key:SetRecordRegion", "2315a4338ed343f7fedb9eea9ef8f6de6c56bdc3d2b4c6ddeb109eafde2d0a36"}, |
| + } |
| + for _, r := range repins { |
| + found := false |
| + for i, e := range entries { |
| + if e.File == r.File && e.Unit == r.Unit { |
| + if e.Class != r.Class || e.Kinds != r.Kinds { |
| + panic("console-request-ctx re-pin changes the class or kinds of " + r.File + ":" + r.Unit) |
| + } |
| + entries[i], found = r, true |
| + } |
| + } |
| + if !found { |
| + panic("console-request-ctx re-pin of an unlisted unit " + r.File + ":" + r.Unit) |
| + } |
| + } |
| + return entries |
| +} |
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go| index 1be2b7055..8cf02f418 100644 |
| --- a/internal/provision/plan9_b8_census_test.go |
| +++ b/internal/provision/plan9_b8_census_test.go |
| @@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) { |
| if len(got) < 100 { |
| t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root) |
| } |
| - inventory := configReceiptsWriteCensusInventory() |
| + inventory := consoleRequestCtxWriteCensusInventory() |
| problems := append(censusDiff(inventory, got), censusPolicy(inventory)...) |
| if len(problems) > 0 { |
| t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n ")) |