oficina / docs Public

Live push slice 1b: the stream carries the update bytes (DOCS_LIVE_PUSH, default off) open

On branch feat/live-push-1b

Slice 1b of the live-push plan: the stream carries the update bytes. Spec docs/superpowers/specs/2026-11-26-live-push-design.md (main), plan slice 1b. Built on main 2370192 (1a landed). Needs Fable's whole-branch review. Don't merge or deploy until then. DOCS_LIVE_PUSH defaults off; off, every client is on today's path.

Commits

  • 0a5ed27: the server slice with its tests and the gate's race step.
  • 2a97f52: probes, measurements (native/benchmarks/live-push/results-2026-11-26/1b/), and spec updates (§3.1 log epoch as built, §4.3 Litestream numbers, question 2).

What the server does (switch on)

  • Push stream (?push=1). - First comes hello <stream id> <current seq> <log epoch>. Then the rows after Last-Event-ID or since arrive as frames. Last-Event-ID wins; garbage in either gets a 400. With neither, today's connect-time update <current> stays. - Each notification produces one write and one flush. Rows are read with updatesGet's query and openContentUpdate. - A row over 32 KiB, or one that can't be opened, goes as update (no id:). A client more than 256 rows or 512 KiB behind gets one update for the current seq. sent moves past both.
  • bye: bye ttl and bye drain before those closes. Team-mode push streams end 2 s before their lease with bye lease.
  • own, checkable. - A POST's Docs-Stream: <id>.<counter> counts only from the session that opened that stream, and only on that document. The session binding is a hash of the session cookie, or failing that the Authorization header. - commitUpdate records (doc, seq) → (stream, counter, SHA-256) inside the transaction. - own <seq> <counter> is written only on a matching id and hash.
  • Frame cache: opened rows are shared per document across its streams. On by default (see measurements).
  • Late answers: over 30 updates/s per session per document, the next answer waits up to 1 s, before ApplyUpdate takes the lock or the writer. Cancel or drain ends the wait. At most 2 answers wait per session; beyond that, 503 + Retry-After: 1 (never a 4xx).
  • Log epoch (logepoch.go, migration 0013), with one deviation from the spec text: - The spec said "a clean-shutdown marker written at the end of a clean drain". CARLOS has CARLOS_SWAP=overlap (zero-downtime spec), where the new generation starts before the old one drains. A marker would be missing at every such deploy, and every client would resync. - As built: a boot counter in the database and in <db>.log-epoch, compared and bumped at each start. It rotates on a missing file (new box) or an older database (restore). A deploy (overlapped or not) and a crash keep it. - Not caught: a restore from a copy taken after the last start, onto the same disk. - GET /updates carries Docs-Log-Epoch. Spec §3.1 is updated.

Tests (each seen to fail with its rule broken)

  • Frames: - one POST → one flushed push per watcher, with the update's bytes, and own for the poster; - own only for the same session, stream and document (another session, another document, malformed and unknown headers all give push), checked against the row's bytes; - own under concurrent writers (fails if the origin is recorded after commit); - frames in seq order under 8 concurrent writers.
  • Stream position and closes: - resume from since, with Last-Event-ID winning; 400 on garbage; - hello and the connect-time update; Docs-Log-Epoch on fetch; - oversized and far-behind rows by fetch, with the cursor moving; - bye ttl, bye drain, and bye lease (team mode).
  • Access: a reader receives frames and can't post; revocation ends the stream.
  • Compatibility: old clients unchanged with the switch on (no hello, update events whose data parses as Int64); switch off.
  • Late answers: limiter unit tests (limit, wait ~1 s, third waiter busy, cancel, drain) and the handler's 503 (no 4xx).
  • Log epoch: overlapping start, restart, missing file, restored older database.
  • Frame cache: transparency (identical frames on and off).
  • Relative timing gate (§9.2): with a 20 ms round trip, POST → bytes in a watcher's hand is 50.1 ms via the fetch path and 29.1 ms via push. Push must be ≥ half a round trip faster, best of three.
  • Race: the gate's race step now also runs Push|LateAnswers (203 s locally, clean).
  • Locally: go test ./..., vet (also -tags browser), gofmt, build: green.

Measurements (measured; 20 pages, sealed rows, warm handles on; 3 runs, median)

| 50 ms RTT, key → bytes in a watcher's hand | today's native client | push + 50 ms floor | |---|---|---| | 1 typist | 238 / 341 ms | 56 / 67 | | 5 typists + 5 watchers, one document | 203 / 330 | 58 / 65 |

  • Server CPU at RTT 0: - 1 typist: 23 → 29 ms/s for 1.7× the uploads (6.3 → 4.8 ms per upload); - 5 + 5 shared: 409 → 634 ms/s (24.3 → 22.2 ms per upload).

In the shared document, cost is still fan-out.

  • Probe artefact: all the probe's clients share one session, so five typists in one document ran into the 30/s late-answer limit (p95 84–146 ms). The shared rows above lift it (LATE=). Real typists each have their own session.
  • Frame cache (TestLivePushFanoutProbe, 5 + 5, 600 uploads): row reads 6,000 → ~1,270 (−79%), with identical frames. Process CPU did not move beyond noise, so something else dominates a flush (the per-flush authorisation check is the next suspect). Kept on for the reads it saves SQLite; a reviewable call.
  • Litestream v0.5.14 (CARLOS' pin; file replica, 1 s sync, one typist, 60 s, 2 runs):

| Pacing | Uploads/min | Replica bytes/min | Files/min | |---|---|---|---| | today's native | ~210 | 490–610 KB | ~65 | | push, 50 ms floor | ~360 | 835–860 KB | ~65 |

So replicated bytes grow about 1.5×. #172 expected no growth. Files (S3 PUTs) are unchanged. Open question 2 is back for Paul with these numbers (spec §4.3, §12).

Found: team-mode streams end spuriously under concurrent editing (pre-existing, not push)

  • Symptom: in team mode with 5 typists and 10 streams on one document, most streams close within seconds: 8 of 10 with today's non-push streams during 300 POSTs, 4 of 10 with push.
  • Where: instrumented, the failing checks are the team guard's two remaining() <= 0 tests (team_stream.go), on leases minutes from expiry.
  • Likely cause: roster.Lease.Remaining() (amadan.net/oficina/home/roster, cache.go) uses TryLock and returns 0 when another goroutine holds the cache's mutex.
  • Effect: web streams close and reopen only on activity today, so a team instance's watchers likely go stale under concurrent editing now. The lagged team instances in production are exposed.
  • This branch doesn't change it. It's for the roster's owners (an RLock or an atomic snapshot), and worth checking before push is switched on for a team.

For the deploy (coordinator)

  • Switch on per instance with DOCS_LIVE_PUSH=on; off is today's path for every client. No client uses push until slices 2 and 3 ship.
  • Per spec §10, 1b is done when: Paul's edge check (edge-timing.js) has run on production; the fan-out has been re-run in team mode (measured here, and it ran into the roster finding above); and the replica bytes have been measured (done locally, above).

Whole-branch review of feat/live-push-1b at 2a97f52 (on main 2370192): Claude Fable, model claude-fable-5-2.

Verdict: APPROVE AFTER FIXES

Findings 1 and 2 should be fixed before merge. Findings 3 and 4 should be closed before DOCS_LIVE_PUSH=on on any instance that matters. The rest are notes.

Read from a review-only worktree (now removed). I ran two throwaway probes there for findings 1 and 2 and nothing else; hub CI is the record for the suite.

What holds

  • Authorisation on the stream. - Every byte leaves through write (stream.go:180), which re-runs the full admission chain plus GetFor (single mode) or guard.check with checkPermission(read) (team mode) after the rows are read and immediately before they are written. - Revoke, visibility change, sign-out and delete (deleted_at IS NULL in GetFor) all end the stream at the next write with no frame sent. - A reader gets frames and its POST is refused in ApplyUpdate, as before.
  • Frame cache. Keyed by document id inside one process, read only by a stream already opened on that document, and its output still passes write's check. I found no path that serves a row across documents or to a session that fails the check. Sealed rows are opened by the same openContentUpdate the fetch uses.
  • Ordering. Seqs are gapless from the single-writer transaction. rowsAfter bounds by a MAX(seq) read first, so a missed or coalesced hub notification only delays rows. The cache path is used only when every seq in the range is present.
  • own. It needs the server-issued 128-bit stream id, the same session binding, the same document, and a hash match on the row's bytes, and it is only ever written to that one stream. A client cannot make a peer skip a row. A rolled-back transaction's stale entry can only match byte-identical content.
  • Switch off. push is false, recordOrigin is nil, and the header and limiter are gated: the stream and POST paths are today's. The one thing that runs regardless is loadLogEpoch at startup (migration 0013 and the sidecar file), so startup now needs the database's directory to be writable.
  • Old clients, switch on. No hello, integer update data, no id:. They do get the late-answer limit and the Docs-Log-Epoch header.
  • Epoch write order (database first, then file) fails towards rotation on a crash between the two, which is the safe direction.

Findings

  1. Medium: the late-answer limiter is keyed on raw request cookies, so one appended cookie bypasses it. push.go:50-69, used at handlers.go:1056. - sessionBinding hashes every cookie named rastrillo_session or __Host-rastrillo_session. Authentication reads only the first. - Probe: 45 POSTs from one real session in 100 ms, each with an extra rastrillo_session=junkN appended, all returned 204 under 45 distinct limiter keys. None waited. - Each junk value also adds a recent entry. That is bounded only by the 4096 sweep, which scans the whole map under the mutex on every admit once it is over. - Fix: key the limiter and the stream binding on the authenticated session's id (or the actor) from the request context, not on header bytes. - own is not weakened by this: the stream id is still required.
  1. Medium: a far-behind stream loads and unseals every row before deciding to send one update, and the cache keeps rows that can never be pushed. push.go:262-284, push.go:279-281, push.go:302. - rowsAfter reads up to 257 full rows (each up to maxUpdateBytes, 1 MiB), opens them, and caches them. Only then does pushFrames measure the total. - Probe: 20 rows of 33 KiB, then ?push=1&since=0. The reply was update 20, after 20 rows (676,800 bytes) were read and opened and all 20 left in the frame cache. None of them is pushable. - Worst case per connect on a paste-heavy document is about 257 MiB transient per stream, and any reader can repeat it. The cache can hold 64 rows of 1 MiB per document, more while a lagging stream is filling it. - Fix: first query COUNT and SUM(LENGTH(update_bin)) (or select seq, LENGTH) and take the far-behind exit before loading bytes. Do not cache.put rows over pushMaxRowBytes.
  1. Medium, before switch-on: the epoch misses the most likely restore. logepoch.go:23-27. - A Litestream replica is continuous, so a point-in-time restore is nearly always from after the last start. Restored in place, or from a volume snapshot that carries the sidecar along, boot matches and the epoch is kept. - A client at cursor 100 that reconnects after a log restored to 98 has grown past 100 gets rows 101 onwards and silently never sees the new 99 and 100. The hello seq check only helps while the log is still behind the cursor. - A code comment saying a runbook can delete the file is not a control. Either the CARLOS restore path removes <db>.log-epoch (tracked on carlos/platform, alongside #1449), or the server rotates on evidence it can check. - Acceptable for merge with the switch off. Not acceptable as the standing answer.
  1. Confirmed, pre-existing: roster.Lease.Remaining() returns 0 on lock contention. home/roster cache.go:117-131. - It uses c.mu.TryLock() and returns 0 when it fails. Cache.Check takes the same mutex with Lock on every request's admission, so concurrent editing contends. - It is worse than transient: teammode.Access.Remaining (access.go:73-76) latches uncertain on a 0. One lost TryLock permanently ends that stream's lease, and teamStreamGuard.check (team_stream.go:36, :58) fails from then on. - There is a fail-open twin at open. stream.go:109: if a.Remaining() loses the TryLock there, guard.deadline stays zero, and the guard treats the stream as resting on no lease. No lease timer and no bye lease; only the per-write checks remain. - This branch does not change it. It needs a fix in roster (an RLock or an atomic snapshot) before push is switched on for a team.
  1. Low: a cursor ahead of the log is accepted silently. stream.go:146-160. With since or Last-Event-ID above current, sent stays high and rows at or below it are never framed. The server relies entirely on the client comparing hello's seq. Consider ending such a stream after hello with a bye, or at least add a test that pins the behaviour.
  1. Low: two near-simultaneous starts can rotate the epoch. logepoch.go:63-99. Process B reads the database after A's Save but before A's rename, sees boot n+1 against a file saying n, and rotates. The result is one spurious resync. Wrapping the read, compare and bump in one write transaction closes it.
  1. Low: the revocation test is weaker than its name. push_test.go:512-520. Any non-push frame satisfies the select, so it does not prove the stream closed. There is no test for delete, sign-out, visibility change or a team roster change mid-stream, and none where the revoked stream would be served from the cache (a second stream warming it). The code is right on these paths; the tests would not catch a regression.
  1. Note: timing gate. TestPushIsFasterThanTheFetchPath is relative and best of three, with about 10 ms of margin on a 20 ms round trip. It also matches the race step's Push pattern. That is fine while it stays green; if it flakes under -race, exclude it there rather than loosen it.
  1. Note: frame cache. Keeping it is reasonable once finding 2 is fixed. With CPU flat, the per-flush admission chain in write is the likely fan-out cost, and it should stay per-write.

Fixes on feat/live-push-1b, one commit each. Hub CI passed at 410582c, race step included (ok … 354 s). Every new test was seen to fail with its fix undone.

| # | Commit | Fix | Test (fails without) | |---|---|---|---| | 1 MED | 946c4ae | The limiter keys on the authenticated actor (person id). The stream binding hashes exactly the cookie auth reads: the first with the configured name, __Host-rastrillo_session on https. Appended cookies change neither. | TestLateAnswersIgnoreAppendedCookies: 45 concurrent POSTs with appended junk cookies are paced (503s, no 4xx), and own survives a junk cookie. Before the fix, all 45 got 204. | | 2 MED | 3feb582 | Far-behind is decided from the count and SELECT seq, LENGTH(update_bin) before any bytes are read. A row too large to push is never loaded, and the cache never keeps a row over 32 KiB. The first unpushable row ends the flush with one update <current>. | TestPushFarBehindReadsNoBytes: 20 rows of 33 KiB give one update 20, with 0 rows read and nothing oversized cached; 300 rows behind reads nothing. Before: 20 rows read and opened. | | 3 MED + 5 LOW | b597ebd | The server checks the cursor itself. push/own frames carry id: <seq>.<tag> (16 hex of SHA-256 over seq and bytes), fetches carry Docs-Seq-Tag, and a resume names its tag (Last-Event-ID: <seq>.<tag> or since=&tag=). A tag mismatch, a missing row, or a cursor ahead of the log gets event: resync <current> and the stream ends. Spec §3.1 amended. | TestPushRestoredLogIsDetected: the database and its sidecar copied at 3; rows 4–5 written and held; the copy restored in place; two different rows written, so the log is back at 5. The resume at 5 gets resync. TestPushFramesCarryTheRowsTag, TestPushCursorAheadOfTheLogResyncs. All accepted in silence before. | | 6 LOW | abe631d | Read, compare and bump run in one write transaction. A sidecar exactly one boot behind with the same epoch (another start's commit-to-rename window) keeps the epoch; an older database still rotates. | TestLogEpochSurvivesAStartBetweenAnotherStartsTwoWrites: rotated before. | | 4 (Docs side) | 1e25812 | Each delivery asks for a fresh Access (teammode: "a stream asks for a new one before each delivery"). A zero lease or Unknown is retried 4× at 2 ms. A leased stream continues only as a Member in the role it opened with, so a role change still ends it (the existing …ClosesAChangedOne test holds), never past its original deadline, with read permission checked under the fresh standing. At open, a Member's zero lease is retried, and still zero means 503, never a stream without a deadline. The seam is teamRuntime.leaseRemaining. | TestTeamStreamSurvivesAContendedLease: one lost read mid-stream, and the next frame still arrives; with one try, the stream ends. TestTeamStreamNeverOpensWithoutALease: a lease stuck at 0 gives 503 (200 without the fix); one lost read at open still opens on a lease (bye lease). | | 7 LOW | 410582c | endsWithoutAFrame fails on any frame and on a stream that stays open. The revocation test adds a second stream that warms the frame cache. New: delete, sign-out, visibility made private under a member, and roster drop (team), each re-checked by a short heartbeat. | Seen red with the per-write check removed (a revoked reader got a push; a deleted document's stream stayed open) and with the team guard always admitting. |

Notes 8 and 9: the timing gate is unchanged and stayed green under -race on the hub; the frame cache stays, now bounded by #2.

Locally, following the machine rules: targeted go test -p 4 -run … for what each commit touched, then the push/team/stream/warm set once (76 s). The full suite was left to hub CI.

Delta re-review of feat/live-push-1b, 2a97f52 → 410582c: Claude Fable, model claude-fable-5-2.

Verdict: APPROVE

Good to merge with DOCS_LIVE_PUSH off. Finding 1 is a one-line fix worth making first, because it runs at every start whatever the switch says. Finding 2 means the roster re-pin after home #158 is still the gate for switching push on for a team; commit 1e25812 does not replace it.

Read-only review (git show / git diff, plus the pinned roster, teammode and rastrillo sources). I ran nothing; hub CI at 410582c is the record for the suite.

My earlier findings

  • 1 (limiter key), 2 (far-behind), 3 and 5 (cursor check), 7 (tests): closed.
  • 6 (epoch race): the large window is closed. A sidecar one boot behind is now kept. The transaction added a new failure mode in the small window (finding 1 below).
  • 4 (lease contention), Docs side: only partly closed (findings 2 and 3 below).

What I checked and found sound

  • Tag scheme. - pushTag is SHA-256 over the 8-byte seq and the opened (plaintext) row bytes, cut to 64 bits. Both call sites hash after openContentUpdate. - It is stable across re-sealing and key rotation, since nonce and key never enter it. Snapshots never delete log rows (nothing deletes doc_updates), so compaction cannot make a cursor row go missing. - 64 bits is ample: the check detects a restore and is not a security boundary. - The tag reaches only someone who also gets the row's bytes: frames go through write's access check, and Docs-Seq-Tag is on an authorised fetch. resync is also written through write, so it is no oracle for a stranger.
  • Old clients and the switch. - With the switch off, nothing new runs on the stream or fetch path. - With it on, a client that does not send push=1 never reaches the resume branch. It gets one extra header, Docs-Seq-Tag, which it ignores. - A push client that sends a cursor without a tag is checked by seq and epoch only, as the spec now says. - No web or native code in the repo sends push=1 or handles resync; that is for slices 2 and 3 (finding 5).
  • Far-behind (3feb582). - Count first, then seq, LENGTH, then only rows at or under 32 KiB + 256 are loaded. - The 256-byte slack covers the seal: AEAD nonce and tag, no compression. - Rows are immutable, so the two statements need no transaction.
  • No wait under a lock or the writer. freshLease's 2 ms retries run only on the stream's own goroutine, at open and in write, which holds neither the document lock nor the SQLite writer.
  • Roster cost per delivery. One Cache.Check: a mutex and a map lookup, no network while the cache is usable.
  • Limiter key. Writers always have a person (permissionScope refuses writes for PersonID <= 0), and an agent resolves to its linked person. A person-less team reader's POST shares the person:0 bucket, but it is refused in ApplyUpdate anyway.
  • Cookie rule. sessionBinding's name choice matches sessions.CookieName() in rastrillo v0.45.0 for an unsigned config.
  • End-of-access tests (410582c). They are meaningful: endsWithoutAFrame fails on any frame and on a stream left open, and the short heartbeat forces the re-check without an update.

Findings

  1. Low, fix before merge: the epoch transaction can fail a start instead of serialising it. logepoch.go:77-95. - rastrillo/db opens SQLite without _txlock=immediate, so the transaction is deferred: it reads first and upgrades to a writer at Save. - Scenario: two processes start together and both read the row. One commits. The other's upgrade then fails with SQLITE_BUSY_SNAPSHOT, which busy_timeout does not retry. loadLogEpoch returns the error and New fails. - At 2a97f52 that interleaving cost one spurious resync. Now it costs a failed boot. The window is microseconds, but this runs with the switch off too. - Fix: make the transaction's first statement a write (for example a no-op UPDATE docs_log_epoch SET boot = boot WHERE id = 1, or the insert-if-missing), so the lock is taken before the read and busy_timeout applies. - This is from reading the code and SQLite's WAL rules; I did not reproduce it.
  1. Medium, before push is on for a team: the retry covers one of the lease reads, not all of them. team_stream.go:115-125. - freshLease retries t.lease(a). After it returns, check calls fresh.state() and fresh.Role() (line 120), and checkPermission calls a.state() in permissionScope. Each is Access.State() → Lease.Valid(), a TryLock that latches Unknown when it loses. - Scenario: under concurrent editing, one of those three loses its TryLock on a delivery. The stream ends, as before the fix. Roughly three unretried reads per delivery remain, where there were five. - TestTeamStreamSurvivesAContendedLease cannot see this: the leaseRemaining seam replaces only t.lease, not State(). - The "4 of 10 streams closed" measurement was not re-run after 1e25812, so there is no evidence the commit fixes the symptom on its own. - Home #158 removes the cause. Keep the roster re-pin as the stated gate for team switch-on, and re-run the team fan-out after it. Optionally, have freshLease return the state and role it saw inside the retry.
  1. Low: a Member's stream can still open without a deadline, after two lost reads. stream.go:114-124. - Scenario: lease(a) loses its TryLock; freshLease succeeds; then fresh.state() == roster.Member at line 116 loses another. The code falls through with the latched Unknown access and lease == 0, so guard.deadline stays zero. guard.check() then passes on a fresh Member standing. - The effect is small: every delivery and heartbeat still asks the roster and re-checks read permission. Only the hard deadline, bye lease and the same-role rule are missing. - The same fix applies: use the state seen inside the retry, not a second read. It goes away with home #158.
  1. Low: on a team instance with Home unreachable, guest pushes can stall for seconds. team_stream.go:57-80, called from :115. - A stream with no lease (a guest's, or one opened under Unknown) used to check permission against its opening access, with no roster call. - Now each delivery calls Cache.Check up to four times. While the cache is unusable, Check waits on the refresh in flight, up to FetchTimeout (5 s), bounded by the 30 s write deadline. - Scenario: Home hangs for over a minute. A guest's frames and pings arrive in bursts seconds apart. - Fix: for a stream with a zero deadline, ask once with a short timeout and do not retry Unknown.
  1. Note for slices 2 and 3: resync and Last-Event-ID. stream.go:167-183, :279-281. - A browser EventSource that does not handle resync reconnects by itself with the same Last-Event-ID and gets resync again, every few seconds. The client must close the stream on resync. Spec §3.1 should say so. - update frames carry no id:, so after a fetch the browser's Last-Event-ID is older than the client's real cursor, and it wins over since. On an automatic reconnect the tag is checked at the older row. A log rewound between the two is missed. - The web client should reopen the stream with since=<cursor>&tag=<Docs-Seq-Tag> after any fetch that moves its cursor.
  1. Note: an unkeyed plaintext digest can land in access logs. push.go:469-478. since=<seq>&tag=<tag> is a query string. On a sealed instance, a log reader without the content key could confirm a guess at a small row. If that matters, key the tag with a subkey of the content key on sealed instances, or prefer the header form.
  1. Note: with the switch on, an empty or snapshot-only fetch reads and opens one more row. handlers.go:956-960. This is the row at highest, up to 1 MiB, for old clients too (each connect-time update costs one). It could be skipped when since == highest.
  1. Note: the limiter is now per person per document. handlers.go:1065. A person's other devices and their agent share the 30/s. An agent writing fast into the document its person is typing in will make the person's answers late. Fine if intended; worth a line in the spec's §5.

Pre-landing fixes on feat/live-push-1b, separate commits. Hub CI passed at 96b188e, race step included (ok … 375 s). The new tests were seen to fail first.

| # | Commit | Change | Test (fails without) | |---|---|---|---| | 1 (required) | dc12ebe | The epoch transaction's first statement is a write: INSERT … ON CONFLICT(id) DO NOTHING of the row. It takes SQLite's write lock before reading, and busy_timeout waits for that lock instead of the read-then-upgrade BUSY failing the boot. An empty epoch marks a row no start has stamped. | TestLogEpochTwoConcurrentStarts: 20 rounds of two concurrent New on one database (×3 runs). Before: round 1 failed with database is locked (5) (SQLITE_BUSY). | | 6 | 985bb45 | The resume tag comes in a Docs-Seq-Tag request header (or Last-Event-ID: <seq>.<tag>), never the query string; ?tag= is not read. Spec §3.1 amended with the access-log reason. | The tag tests send the header (both failed against the query-reading code), and a ?tag= is shown to be ignored. | | 4 | 0518cc0 | A stream on no lease (a guest's grant, or opened under Unknown) keeps its opening standing and asks the roster nothing per delivery. Only a stream opened on a Member lease asks afresh. Its up-to-four asks per delivery, bounded by the delivery's deadline, are recorded in the plan rather than capped further. | TestTeamGuestStreamAsksTheRosterNothing: a removed member's stream on a granted document gets three frames with 0 roster asks. Before: one per delivery. | | 2/3, 5, 7, 8 | 96b188e | Plan only, "As built, and what later slices inherit" under slice 1b: team switch-on gated on Home #158's re-pin and a re-run of the streams-closed measurement; the leased stream's asks; the extra row read per empty or snapshot-only fetch; the per-person limiter (devices and agent share 30/s); and the client rules. Close on resync (EventSource would loop). After any fetch, send the fetched cursor as since (with its Docs-Seq-Tag header) and never rely on Last-Event-ID (update frames carry no id:). EventSource cannot set headers, so the web client streams with fetch, or accepts the seq-and-epoch check without a tag. | — |

Locally: targeted go test -p 4 -run … per commit, then the push/team/stream/warm set once (84 s); the full suite on hub CI. DOCS_LIVE_PUSH still defaults off. Ready to land.

Review by Claude Fable (model id claude-fable-5-2) of the delta 410582c..96b188e — verdict: APPROVE to merge with DOCS_LIVE_PUSH off.

  • 0518cc0 (authz): no stream keeps frames after access ends. A no-lease stream can only hold NotMember or Unknown, both grant-only, so it is never more permissive than 410582c. Guests are re-checked on every delivery against a live grant read with deleted_at IS NULL; TestTeamStreamGuestGrantAndActualSessionRevocation passes at 96b188e. A removed member's Member-lease stream ends at the first non-Member delivery or at the lease deadline.
  • dc12ebe: correct. TestLogEpochTwoConcurrentStarts fails 3/3 on the old logepoch.go and passes now.
  • 985bb45: logs and reflection are clean; malformed Last-Event-ID is safe.

Low, fix before the switch goes on (follow-up branch):

  1. stream.go:172-184: ?since=<seq>.<tag> still carries a tag in the query string. Cut on "." only when the value came from Last-Event-ID; since=5.x → 400. Add a test.
  2. team_stream.go:121: end the stream if g.deadline.IsZero() and the standing reads Member, so the "never Member without a lease" invariant doesn't rest only on Remaining() latching.

Note: rotateLogEpoch, named at logepoch.go:27, doesn't exist yet. Whoever adds it must open with a write too.