carlos / platform Public

console: the serial bump runs after the session's admission step, outside any unit (rootfs plan 6 task 10 fix round 2)

Astra re-review 1, P2 2 residual: bumpSerial's detached 2 s ran inside the
admission's unit. It now runs once the admission step has returned (the
unit ended, the id active), best effort and outside any lifetimes unit, as
the console's other post-write bumps; failure handling unchanged. The
admission holds its reservation and unit for at most OpenWait plus the
store's fixed per-mutation change-index tail (2 s, shared by every console
write), stated beside the step's deadline.

TestTheSerialBumpHoldsNoAdmission: with the serial PUT hanging, the unit is
released and the id active within OpenWait + 2 s, and the bump lands after.
Record-write census: admitSession re-pinned. Root-read census unchanged
(seal f02fd204).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 6f1d08778fa432d18cd9b88d9cbe09ad59098b48 parent 37691fc
3 files changed, +89 −5
  • internal/console/apiinteractive.go +14 −4
  • internal/console/apiinteractive_test.go +71 −0
  • internal/provision/rootfs_apps_6_census_test.go +4 −1

Intent

Human

<task-notification> <task-id>a7099b6064086f5c2</task-id> <tool-use-id>toolu_0145keP3BVfYUCWtkZxvvc5h</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/a7099b6064086f5c2.output</output-file> <status>completed</status> <summary>Agent "Plan 6 Task 10: console session door" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>I've fixed all three of Astra's P2s in one commit. Status: **DONE_WITH_CONCERNS**. **Commit:** 37691fcf (fix round 1, on 70254b07). Not pushed. **Fixes:** - **Failed grant delete:** the end now stays pending until the marker clear and the grant delete have both landed, and the end audit row is written once, after them. - **Admission cleanup:** the grant cleanup now runs on the admission's own OpenWait deadline. A grant it can't delete in time is left for the sweep to delete. That entry gets no audit row, and the reservation and unit are released when the admission step returns. - **Ended ids:** an ended id is kept only until its PickupBy, then pruned on each end and each sweep pass. A new `activeSession` lookup gives the Task 11 door the same 404 for ended, pruned and unknown ids. **Tests:** three new tests failed before the fix and pass after it: the delete fails once through the real store; the grant PUT and DELETE hang under a 500 ms OpenWait; three sessions end and are pruned. All eight new mutations are killed. The session-door and lifetimes tests pass under `-race -count=3`, and the console claim, route, run, perf and budget suites pass (budget still 18/21 +2). The two provision census tests, the copy gates and the darwin/arm64, windows/amd64 and linux/arm64 builds pass. **Census:** `admitSession` and `endWrites` are re-pinned with the same class. The record-write total is four new entries and four re-pins, and the report's "five" is corrected. The root-read card is unchanged (seal f02fd204), so the overlay was not re-proposed. **Concerns:** - **Serial bump can outlast OpenWait by about 2 s.** `bumpSerial` after activation detaches from cancellation with its own 2 s limit, so in the worst case the admission's unit is held that long past OpenWait. Astra didn't flag it, and changing the shared helper was out of scope. - **Door rule 3 isn't tested here.** The 409 on a second attach depends on Task 11's attached flag, which doesn't exist yet. Pruning only ever removes ended ids, never active ones, so it can't affect that rule. The fix report is appended to `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-apps-6/.superpowers/sdd/2026-10-24-rootfs-apps-6-interactive/task-10-report.md`.</result> <usage><subagent_tokens>418691</subagent_tokens><tool_uses>11</tool_uses><duration_ms>957855</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>bzt08cji0</task-id> <tool-use-id>toolu_01Nz6fdmRaN4P5KxjdJTwvHY</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/bzt08cji0.output</output-file> <status>completed</status> <summary>Background command "Run Astra re-review of Task 10 fix" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 14.5 g CO₂e (1,847,386 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on rootfs-apps-6-interactive, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/console/apiinteractive.go b/internal/console/apiinteractive.go
index 6693325b3..527d37554 100644
--- a/internal/console/apiinteractive.go
+++ b/internal/console/apiinteractive.go
@@ -227,7 +227,12 @@ func (s *Server) serveInteractive(rctx context.Context, ws *websocket.Conn, d in
err = s.lifetimesStep(ctx, true, func(sctx context.Context) error {
// The admission's whole bound: its writes and any cleanup of them
// (fix round 1, P2 2). The reservation and the unit are released
- // when this returns.
+ // when this returns. The bound is OpenWait plus the deployment
+ // store's fixed per-mutation change-index tail (bumpAfterMutation's
+ // detached 2 s, shared by every console write): a mutation that
+ // lands near the deadline may still spend it before returning.
+ // Nothing else in the step outlives OpenWait; the serial bump runs
+ // after it (fix round 2).
sctx, cancel := context.WithTimeout(sctx, h.openWait())
defer cancel()
refusal = s.admitSession(sctx, sess, token)
@@ -245,6 +250,12 @@ func (s *Server) serveInteractive(rctx context.Context, ws *websocket.Conn, d in
refuseSession(ws, *refusal)
return
}
+ // The box's prompt pickup, best effort, as the console's other
+ // post-write bumps: after the admission step has returned, so it holds
+ // neither the unit nor a reservation, and outside any lifetimes unit
+ // (the serial is no record). A failure is logged; boxes fall back to
+ // the hourly pass.
+ s.bumpSerial(ctx)
if err := sendSessionJSON(ws, interactive.KindStatus, interactive.Status{State: interactive.StateWaiting}); err != nil {
s.endSession(ws, sess, interactive.End{Reason: interactive.EndCancelled})
return
@@ -302,8 +313,8 @@ func (s *Server) resolveConsole(ctx context.Context, d interactiveDoor) ([]strin
}
// admitSession is the admission's write step (steps 4 to 6): the signed
-// grant, the record CAS, activate, the serial bump and the
-// interactive-start row. A refusal is the End to send, with the grant
+// grant, the record CAS, activate and the interactive-start row. The serial
+// bump comes after the step (serveInteractive). A refusal is the End to send, with the grant
// deleted and nothing else left behind.
func (s *Server) admitSession(ctx context.Context, sess *hubSession, token string) *interactive.End {
h := s.interactive
@@ -346,7 +357,6 @@ func (s *Server) admitSession(ctx context.Context, sess *hubSession, token strin
// Unreachable: only this goroutine releases or ends its id.
log.Printf("console: api interactive %s/%s/%s: %s was not reserved at activation", sess.acct, sess.app, sess.host, sess.id)
}
- s.bumpSerial(ctx)
s.auditActivity(sess.account, sess.app, sess.by, Activity{Action: "interactive-start", TargetType: "instance", Target: sess.host,
Detail: interactiveStartDetail(sess)})
return nil
diff --git a/internal/console/apiinteractive_test.go b/internal/console/apiinteractive_test.go
index 8ee120019..025e62c76 100644
--- a/internal/console/apiinteractive_test.go
+++ b/internal/console/apiinteractive_test.go
@@ -1189,3 +1189,74 @@ func TestEndedSessionsArePruned(t *testing.T) {
}
}
}
+
+// hungSerialStore holds the serial's PUT, whatever its context says, until
+// the test lets it go: a bucket that stops answering the serial bump.
+type hungSerialStore struct {
+ release.Store
+ entered chan struct{}
+ release chan struct{}
+ once sync.Once
+}
+
+func (h *hungSerialStore) Put(ctx context.Context, key string, body []byte, ifMatch string) (string, error) {
+ if key == release.SerialKey {
+ h.once.Do(func() { close(h.entered) })
+ <-h.release
+ }
+ return h.Store.Put(ctx, key, body, ifMatch)
+}
+
+// TestTheSerialBumpHoldsNoAdmission (fix round 2, P2 2): the serial bump runs
+// after the admission step has returned, outside any lifetimes unit. With
+// the bump hanging, the admission's unit is released and its id is active
+// (no longer a reservation) within OpenWait plus the store's 2 s
+// change-index tail, and the bump still lands afterwards.
+func TestTheSerialBumpHoldsNoAdmission(t *testing.T) {
+ var hung *hungSerialStore
+ fx := newInteractiveFxWith(t, 7, "code-ix-serial", consoleFixtureOptions{WithKey: true, WrapReleases: func(s release.Store) release.Store {
+ hung = &hungSerialStore{Store: s, entered: make(chan struct{}), release: make(chan struct{})}
+ return hung
+ }})
+ ixWorld(t, fx)
+ t.Cleanup(func() {
+ select {
+ case <-hung.release:
+ default:
+ close(hung.release)
+ }
+ })
+ h := fx.srv.interactive
+ const wait = 500 * time.Millisecond
+ h.openWaitFor = wait
+ before := serial(t, fx.consoleFixture)
+ ws, err := ixDial(t, fx.ts.URL, fx.ixURL(ixHost), fx.alice)
+ if err != nil {
+ t.Fatal(err)
+ }
+ start := time.Now()
+ ixSendOpen(t, ws, ixOpenArgv())
+ waitForSignal(t, hung.entered, "the serial bump")
+ rec, _ := ixRecord(t, fx, ixHost)
+ if rec.Interactive == nil {
+ t.Fatal("no marker while the bump hangs")
+ }
+ id := rec.Interactive.ID
+ bound := wait + 2*time.Second
+ for (fx.srv.cutover.status().Pending != 0 || hubState(h, id) != "active") && time.Since(start) < bound {
+ time.Sleep(5 * time.Millisecond)
+ }
+ if p, st := fx.srv.cutover.status().Pending, hubState(h, id); p != 0 || st != "active" {
+ t.Fatalf("with the bump hanging %v after the Open: the gate counts %d units, the id is %q; want 0 and active within %v", time.Since(start), p, st, bound)
+ }
+ if got := serial(t, fx.consoleFixture); got != before {
+ t.Fatalf("serial %d before the bump landed", got)
+ }
+ close(hung.release)
+ ixWantWaiting(t, ws)
+ if got := serial(t, fx.consoleFixture); got != before+1 {
+ t.Fatalf("serial %d, want %d: the bump still happens", got, before+1)
+ }
+ ws.Close()
+ ixWaitEvents(t, fx, "interactive-end", 1)
+}
diff --git a/internal/provision/rootfs_apps_6_census_test.go b/internal/provision/rootfs_apps_6_census_test.go
index 8cb7a327d..82f05b7ae 100644
--- a/internal/provision/rootfs_apps_6_census_test.go
+++ b/internal/provision/rootfs_apps_6_census_test.go
@@ -41,6 +41,9 @@ package provision
// grant delete now return a failure (so an end stays pending and the
// row is written once, after every write). The same one
// SetRecordInteractive in each; re-pinned.
+// - Task 10 fix round 2: admitSession no longer bumps the serial (the
+// bump runs after the admission step, outside any unit). The same one
+// SetRecordInteractive; re-pinned.
func rootfsApps6WriteCensusInventory() []censusEntry {
entries := append([]censusEntry(nil), fleetPublicRoutesWriteCensusInventory()...)
replacements := []censusEntry{
@@ -67,7 +70,7 @@ func rootfsApps6WriteCensusInventory() []censusEntry {
added := []censusEntry{
{"internal/provision/interactive.go", "SetRecordInteractive", "record-writer", "key:SetRecordInteractive,key:updateRecord", "f2f8c0ad8647cc048a0be0fa3edc051ddd8e3157eba038123f9e5bab79f4530e"},
{"internal/appconfig/interactive.go", "claimRawSetInteractive", "nonrecord", "sel:Put", "d4c768601d1b9bdb44c0fd0c2c6f058c18c1434856e357f00628d2f600ce039b"},
- {"internal/console/apiinteractive.go", "Server.admitSession", "record-writer", "key:SetRecordInteractive", "c81a6696dfbeb6c4f4746cec9487e099b27506c5c5555b30cbff0c0b2f6ce5f1"},
+ {"internal/console/apiinteractive.go", "Server.admitSession", "record-writer", "key:SetRecordInteractive", "480a81596e1a07fab59673711a889f20e1ea30d96b870767f20488cdd20acd98"},
{"internal/console/apiinteractive.go", "Server.endWrites", "record-writer", "key:SetRecordInteractive", "6a183621b60073e45f698e046a177adca2f536b47a365bdb66de5548257b9fea"},
{"internal/console/apiinteractive.go", "Server.putGrant", "nonrecord", "sel:Put", "22a18ef45051da8cfb8a6a62ad8891afd28e3bf71cc26a541639cd2a1dc0a1ff"},
{"internal/console/server.go", "consolePerfSkip", "key-site", "lit:instances", "d4b65473d3702b49d79a799d46f078e4491b6e86a59a101dd4c1ce4d50f698e7"},