oficina / docs Public

Live push slices 0 + 1a: native probe restored; warm handles behind DOCS_WARM_HANDLE open

On branch feat/live-push-1a

Slices 0 and 1a of the live-push plan (spec docs/superpowers/specs/2026-11-26-live-push-design.md r3, main bde01ef, #172; plan docs/superpowers/plans/2026-11-26-live-push.md, in this branch). Needs Fable's whole-branch review. Don't merge or deploy until then; the coordinator deploys server-first via canary.

Commits

  • 66e15f0: the plan, covering slices 0, 1a, 1b, 2 and 3 with work, tests and done lists from spec §9 and §10.
  • 0255fca (slice 0): RealtimeAuditE2ETests observes projectionGeneration. Since S1a, projection is @ObservationIgnored, so the probe reported n=0. Now run-e2e.py … testEndToEndRemoteUpdates reports n=30 with 40/40 seen; peer POST → visible median is 18 ms at 1 page and 63 ms at 20 pages.
  • 05844cc (slice 1a): warm handles in internal/docs/warm.go, behind $DOCS_WARM_HANDLE. Values are on/off; unset is off; anything else refuses to start. Per spec §8 it stays off by default until proven on production, then a follow-up commit turns it on.
  • c9d54e2: the probe. Shared-document mode, sealed rows (SEAL=1), the warm switch (WARM=1), push-mode clients for 1b, and proto-table.py.
  • 7a4972d: measurements (native/benchmarks/live-push/results-2026-11-26/1a/).

Slice 1a: what the code does (spec §3.5 rules 1–8)

  • Store.ApplyUpdate checks permission, then takes one of two paths: - applyWarm when the switch is on; - applyCold, the old body unchanged, otherwise.

Both end in commitUpdate, the one transaction. It also returns MAX(seq) from before the insert.

  • Rule 1: a per-document mutex is held from Apply through commit.
  • Rule 2: a clean RejectedError keeps the handle (400 as before). A full log, a trap or a recovered instance drops the handle and replays cold inside the same POST.
  • Rule 3: any failure after Apply drops the handle, and its seq advances only after commit. A MAX(seq) mismatch (another process, the agent path) drops it; the row is still written, as a stale replay's was.
  • Rule 4: at the cadence, snapshot at the handle's seq, then Apply, commit, drop. A failed snapshot keeps the handle (team mode fails the POST, as cold does).
  • Rule 5: LRU by count (64) and by core.Handle.ResidentBytes (128 MB of linear memory plus retained updates). One handle over the cap is not kept.
  • Rule 6: dropped in ownerMutation (grant, revoke, visibility), ownerDeletion, deleteDocument, App.Drain and App.Close. Sealing is activated offline with the app stopped, so there is no runtime case.
  • Rule 7: idle 60 s, swept by every POST and every stream heartbeat (stream.go); no timer of its own.
  • Not in the spec: the agent paths call ApplyUpdate on a Store copy whose db is an outer transaction (agent_update.go, agent_store.go). Their "commit" is a savepoint the caller can still roll back after ApplyUpdate returns, which rule 3 can't see. So boundTo(tx) copies never use warm handles. Their committed rows are caught by rule 3's MAX(seq) check on the next warm POST.

Tests (warm_test.go)

Every test below was seen to fail by breaking its rule: no re-seed; keep the handle on a failed commit; no fallback; no access drop; no heartbeat sweep; no caps; stale handle not dropped; drop after every POST (for the timing gate).

  • >4,096 POSTs to one warm document: none refused, at most cadence + 2 updates retained. With re-seed removed, POST 4,097 is refused.
  • Re-seed order: the snapshot is at seq 256 (the state before the 257th POST), the handle is dropped, and the next POST replays from that snapshot.
  • Writer revoked between Apply and commit (inside the transaction): ErrNotWritable, the handle is dropped, and after crossing the cadence the snapshot excludes the refused update and equals a raw replay of the rows it covers.
  • Cold fallback on ErrUpdateLogFull and on a trap; a rejected update keeps the handle.
  • Property test (8 seeds × 60 steps): POSTs, failed commits, cancelled contexts, injected traps, garbage, drops, and commits by a second Store on the same database. The log holds exactly the committed updates, and a warm handle after its own POST equals a raw replay.
  • Caps: count, bytes, LRU order, and one over-cap handle not kept.
  • Drops on grant, revoke, visibility, delete and drain (a drained cache keeps nothing).
  • Heartbeat sweep, with a fake clock and a real stream.
  • Plumbing: boundTo has no cache; the switch parses correctly and defaults off.
  • Relative timing gate (the spec's §9.2 shape, applied to 1a): on ~20 pages, in the same process, a warm POST must be faster than a replay, best of three medians; no absolute threshold. Measured median 818 µs against 6,115 µs.

Gates:

  • go vet ./..., go vet -tags browser;
  • go test ./... -count=1 green. Locally that needs npm ci in fixtures and TMPDIR=/tmp for the unix-socket tests, as the gate sets up.
  • go test -race on the warm, stream, updates and agent tests;
  • hub CI passed at c9d54e2 (7a4972d adds result files only).

Measurements (measured locally; sealed rows; ~6 keys/s; 20 pages ×3 runs on fresh servers, median [range])

| Server CPU, today's pacing | warm off | warm on | |---|---|---| | 1 typist (native 250 ms) | 36 ms/s (10.0 ms/upload, 22 MB/s alloc) | 13 ms/s (3.7, 1 MB/s) | | 1 typist (web 250 ms) | 28 | 12 | | 5 typists, own documents | 157 (9.3) | 47 (2.8) | | 20 typists, own documents (1 run) | 574 (399 MB/s) | 205 (13 MB/s) | | 5 typists + 5 watchers, one document | 529 (31.3/upload) | 370 (21.8) | | 5 + 5, sending at once (headroom for slice 2) | 825 | 513 | | 1 page: 1 / 5 / 5+5 shared | 31 / 108 / 442 | 20 / 60 / 387 |

  • Latency at 50 ms RTT (key → fetched, p50/p95): 1 typist 232/344 → 225/341; 5+5 shared 208/334 → 205/332. That is the replay time, as expected. The ~150 ms of pacing and the fetch round trip go in slices 1b–3.
  • Shared-document cost is still fan-out (about 22 ms per upload with 10 streams). That is 1b's frame-cache question.
  • Warm-handle memory (from the prototype, the same core): 1.8 / 2.7 / 16.5 MB RSS at 1 / 20 / 200 pages.

For the deploy (coordinator)

  • Canary with DOCS_WARM_HANDLE=on on one instance first. Off (or unset) is exactly today's path.
  • Watch for docs: warm handle dropped, replaying (Warn). It means rule 2 fired and should be rare.
  • After the canary: re-run load-p1/load-p20 and the 5+5 shared document on production-like settings (plan, 1a done list), then flip the default to on.

Whole-branch review: Claude Fable (model id claude-fable-5-2), 7a4972d on bde01ef

Verdict: CHANGES NEEDED

One finding breaks the slice's central invariant (the snapshot can persist state that was never committed). The fix is a few lines. Everything else is small. Don't canary with DOCS_WARM_HANDLE=on until finding 1 is fixed; with the switch off the branch is safe to carry.

Read with git diff bde01ef 7a4972d in a review-only worktree (removed). Findings 1–3 were each reproduced with a throwaway test there, not only read.

Findings

1. A rejected update can be half-applied to the kept handle, and the next snapshot persists it. HIGH. warm.go:278-282 (rule 2).

  • The rule "a clean RejectedError leaves the handle as it was" is not true for ERR_APPLY (-3). yrs integrates an update's structs one at a time (native/vendor/yrs-0.23.5/src/update.rs, item.repair(store)? inside the loop); a later struct failing with InvalidParent returns the error after the earlier structs are in the store, and core/src/lib.rs:132 drops the transaction, which commits them.
  • The cold path never noticed because it threw the handle away. The warm path keeps it.
  • Reproduced: a 27-byte update (struct 1 a string under a named root, struct 2 with that string item as its parent) answers 400 with apply rejected the update: code -3. The warm handle then holds struct 1's text. After 256 more ordinary POSTs the doc_snapshots row at seq 256 contains it, and so does every later replay. No doc_updates row holds it.
  • Effect: any writer can put content into the document that no client ever receives over ?since=, and that appears for whoever loads the page after the next snapshot. Server state and open editors disagree permanently.
  • Fix: drop the handle on any error from Apply (a rejection then costs one replay on the next POST), or keep it only for ERR_DECODE. Add the crafted update to TestWarmHandleSurvivesARejectedUpdate and to the property test, whose "garbage" case is decode-only today. The spec's rule 2 wording and core.go's "leaves the instance untouched" comment need the same correction.

2. A panic between Apply and commit keeps an uncommitted handle. MEDIUM. warm.go:245 (defer release), warm.go:289.

  • release runs on a panic too, and nothing marks the handle as applied-but-uncommitted. net/http recovers the panic, the process lives, and the next POST finds MAX(seq) == e.seq and keeps using it.
  • Reproduced with a panic in the commit seam: entry kept at seq 1, warm state word1 word2, log word1.
  • Fix: set a flag on the entry before warmApply and clear it only after a successful commit; release closes a flagged handle. That also covers every future early return.

3. An entry evicted while a POST is between acquire's two locks becomes an orphan that is never closed. MEDIUM/LOW. warm.go:105-120, warm.go:124-142.

  • acquire reads the entry under c.mu, unlocks, then takes e.mu. In that gap drop (grant, revoke, visibility, delete) or a cap eviction can remove the entry and TryLock succeeds, so dead is not set. The POST then replays into the removed entry, and release only handles dead, closed and the byte cap, so it marks it kept without it being in the map.
  • Reproduced by stepping the interleaving by hand: cache reports 0 handles, the entry is not in the map, and the wasm instance is still open. Nothing sweeps, caps or drops it again; the runtime holds the instance until the process ends.
  • This is rule 6's own case (decrypted state outliving a revoke), and it is outside the 128 MB cap. The window is microseconds, so it is rare, not impossible. It never serves a later POST, so it is a leak, not a divergence.
  • Fix: in release, close when c.entries[e.docID] != e.

4. Tests: no concurrency, no team mode, no sealed rows. MEDIUM. warm_test.go.

  • Every warm test is single-goroutine. Rule 1 (the per-document lock), dead, and TryLock eviction are not exercised. I ran 8 goroutines × 400 POSTs with interleaved drops and sweeps under -race: clean, and log, cold replay and warm handle agreed. That test should be in the branch.
  • The fixture is a local actor with sealing off (content sealing not activated in every run), so the team-mode snapshot branch (warm.go:263-269) and sealed rows are covered only by the hand-run probe.
  • The hub gate builds with CGO_ENABLED=0, so nothing in CI runs -race on this code.

5. Rule 6 is narrower than the spec. LOW. warm.go header, team_access.go:219.

  • Spec §3.5 rule 6 lists restore and team state. Restore does not exist yet; team roster changes arrive from outside and drop nothing. Permission is still checked on every POST and in the transaction, so this is retention only (until 60 s idle), not access. The same holds for a grant changed by a second process during a deploy overlap.
  • Say so in the header, and leave a note at the place version restore will be written: it must drop the handle, since a restore that rewrites rows could leave MAX(seq) equal.

6. Entries without a handle count toward the 64 cap. LOW. warm.go:176-193.

  • After a re-seed, a failed replay or a rule 3 drop, the entry stays in the map with no handle until it idles out, and capLocked counts it. Under many active documents it can evict a real handle early. Delete the entry in release when e.h == nil.

7. A client that disconnects mid-Apply logs the rule 2 warning. LOW. warm.go:284.

  • A cancelled request context makes Apply return a RecoveredError, so docs: warm handle dropped, replaying fires and the cold retry then fails on the same context. Correct, but the canary instruction says that line should be rare; skip the log and the retry when ctx.Err() != nil.

Checked and found sound

  • Log writers: only commitUpdate, import (import.go:234, seq 1 of a new document) and the offline content migration write doc_updates. No path deletes rows, and deletion is soft, so ids are not reused. boundTo is the only Store copy left.
  • Staleness check: MAX(seq) is read in the same single-writer transaction as the insert. A second store, the agent paths and a failed or cancelled commit all end in a drop. The seq advances only after commit.
  • Snapshot placement: written at the handle's seq before the new update is applied, as the cold path does. Apart from findings 1 and 2 the handle holds exactly rows ≤ e.seq.
  • Uncommitted state to clients: nothing in 1a sends from the handle; readers and ?since= still replay from the database.
  • Locking: c.mu only ever TryLocks an entry, so there is no lock-order deadlock. Drain and Close set closed; an in-flight POST closes its own handle on release.
  • Off path: applyCold is the old body with the transaction moved into commitUpdate; the added calls are nil-safe no-ops. Unset means off; a bad value refuses to start.
  • Retention: an unauthorised POST is refused before acquire, so it cannot keep a handle fresh. With no stream and no POST a handle lives until hibernation, as rule 7 says.

Gate

  • go vet ./... and go vet -tags browser ./...: clean.
  • go test -count=1 on internal/docs, internal/core, cmd/...: pass. Warm tests under -race: pass.
  • internal/shipped fails on Homebrew's Go 1.27.3 (no LICENSE in its tree) and passes with GOTOOLCHAIN=go1.26.5. Not this branch.
  • Timing gate: relative, about 7× margin, fine.

Fixed in feat/live-push-1a 1fd1f70. Hub CI passed, including the new race step, which ran on the runner: === go: race detector on warm handles and the stream … ok 161.874s. Every new test was seen to fail with its fix undone.

| # | Fix | Test (fails without the fix) | |---|---|---| | 1 HIGH | Any error from Apply drops the handle (warm.go applyWarm). Reproduced first: the hand-built 28-byte halfApplyingUpdate answers code -3, and the kept handle's state contained its first struct. I didn't keep the ERR_DECODE exception. Decode does fail before the transaction (core/src/lib.rs apply_update), but RejectedError doesn't expose the code, and one replay after a garbage POST is cheap. core.go's "untouched" comment is corrected and spec §3.5 rule 2 rewritten. Rolling back inside the core (a scratch transaction) is recorded as a separate core change with its own ABI test. | TestWarmHandleIsDroppedWhenAnUpdateIsRejected (half-applied and undecodable; after crossing the cadence neither the snapshot nor the warm state holds "INJECTED"). The property test gains a half-applying op and checks the warm state for the marker after every step. | | 2 MED | pending flag set before Apply and cleared only after commit. release closes a pending handle, which covers panics and any future early return. | TestWarmHandleIsDroppedAfterAPanicBeforeCommit (panic in the commit seam). | | 3 MED/LOW | release closes the entry when c.entries[e.docID] != e (dropped between acquire's lookup and lock). New afterLookup seam steps the interleaving. | TestWarmHandleOrphanedBetweenLookupAndLockIsClosed | | 4 MED | Stress: 8 goroutines × 150 POSTs to two documents, with drops and sweeps on a clock past warmIdle. I used 150, not your 400: each POST is a new Yjs client, and with the drops forcing replays, 400 per goroutine made the replays themselves hit the core's call deadline on this machine (load 170–650). Team mode with sealed rows: newTeamRouterFixtureWith(t, false, true) activates sealing offline and turns warm on; a linked member's POSTs through the router cross the cadence through the team snapshot branch, warm/cold/log agree, and a removed member gets 404 with nothing logged. Race in CI: new gate step, CGO_ENABLED=1 go test -race -short -count=1 -run 'Warm\|BoundToATransaction\|Stream' ./internal/docs/ (the runner has cc for cargo; without it the step fails rather than skips). Also documented in the plan's 1a section. | TestWarmHandlesUnderConcurrentPOSTs, TestWarmHandleInTeamModeWithSealedRows | | 5 LOW | Written down in warm.go's header and spec §3.5 rule 6: roster changes and a second process's grant change mean retention ≤ 60 s, not access. Dropping on a roster refresh is noted as a 1b candidate. Version restore must drop the handle; a note sits at store.go's updated_at invariant (the place restore is named) and in the plan. | (notes) | | 6 LOW | Entries without a handle leave the map in release. | TestWarmEntriesWithoutAHandleDoNotCount (cap 1, a failed POST on another doc doesn't evict the real handle) | | 7 LOW | ctx.Err() != nil after a failed Apply: drop quietly, no warning, no cold retry. | TestWarmHandleCancelledMidApplyIsQuiet |

Gates: go vet ./..., -tags browser, gofmt, go test ./... -count=1 (locally with TMPDIR=/tmp and fixtures' npm ci, as the gate does), and the race step, both locally (163 s) and on hub CI.

DOCS_WARM_HANDLE stays off by default. Ready for re-review before any canary.

Delta re-review: Claude Fable (model id claude-fable-5-2), git diff 7a4972d 1fd1f70

Verdict: APPROVE AFTER FIXES

All seven findings are fixed, and each of my three reproductions now passes. One of the fixes (finding 6) introduced a performance regression under contention, finding A below. It never produces wrong state, so DOCS_WARM_HANDLE=on is safe to canary now. Fix A before the post-canary measurements and before the default flips, because on a shared document under load it turns most warm POSTs back into replays.

Run in a review-only worktree at 1fd1f70 (removed), GOTOOLCHAIN=go1.26.5, with throwaway tests and counters. Machine load was 500–800 throughout.

Reproductions against 1fd1f70

| Finding | Reproduction | Result | |---|---|---| | 1 HIGH | My own 26-byte variant (1-byte client id, marker PARTIALX). The engine still half-applies it: applied directly to a replayed handle it answers code -3 and the state holds the marker. | Fixed. The POST answers 400 and the entry is gone. After 517 more POSTs, with the bad update re-sent every 50, no snapshot, cold replay or warm handle holds the marker. | | 2 | Panic in the commit seam, and a panic after a real Apply inside the apply seam. | Fixed. No entry survives, the lock is free, and the next POST's warm state is word1 word3, equal to the log. | | 3 | Stepped through afterLookup, removing the entry three ways: drop, a cap eviction, an idle sweep. | Fixed. The orphan's handle is closed in all three; 0 handles, 0 entries. | | 7 / cancel | Context cancelled before a real Apply, and cancelled inside the commit. | Same as the cold path. Both return an error with nothing in the log; the handler answers 5xx (handlers.go:1035-1068), so a client can't believe it saved. A handle is never kept ahead of the log. A rejection still wins over the cancel check, which is right. |

The race step's pattern, my repros and a 4-document, cap-2 stress all pass under -race.

Findings

A. A handle-less entry now leaves the map while other POSTs are queued on its mutex, which starts a replay cascade. MEDIUM, performance only. warm.go:155-161 (new in 1fd1f70, from the finding 6 fix).

  • After a re-seed, a stale drop or any failure, release deletes the entry. POSTs already blocked on e.mu then hold an entry that is no longer the cache's: each replays, commits and throws its handle away (!mine).
  • Meanwhile new POSTs create a fresh entry and run concurrently with those orphans. Their commits see before != e.seq, close, delete that entry too, and orphan its waiters. It sustains itself while there is contention.
  • Measured: 8 goroutines × 100 back-to-back POSTs to one document, no drops or sweeps.

| | Replays | Stale drops | Warm hits | Time | |---|---|---|---|---| | 1fd1f70, no pause | 501 | 431 | 299 | 14.7 s | | 1fd1f70, 20 ms between POSTs | 46 | 24 | 754 | 3.3 s | | Entry kept while referenced (below) | 4 (1 + 3 re-seeds) | 0 | 796 | 0.8–1.6 s |

  • Rule 3 catches every case, so log, cold replay and warm state always agreed. The cost is that a contended document degrades to roughly the cold path, which is the 5+5 shared case this slice exists for. The PR's measurements were taken at 7a4972d and predate this.
  • Fix, tried in my worktree: count references. acquire does e.refs++ under c.mu; release does e.refs-- and deletes a handle-less entry only when refs == 0 || e.dead || c.closed. All Warm tests still pass with it, TestWarmEntriesWithoutAHandleDoNotCount included. Alternatively keep the 7a4972d behaviour and have capLocked count only entries with a handle.
  • Add the no-churn test with an assertion on replay count; it fails today.

B. The race step never takes the warm path. LOW/MEDIUM, test. warm_test.go TestWarmHandlesUnderConcurrentPOSTs, .amadan/ci.d/10-gate:296.

  • Counters in the test as written:

| Run | POSTs | Warm hits | Replays | Re-seeds | Dead-marked | Lock contended | |---|---|---|---|---|---|---| | -race -short (the CI step) | 320 | 0 | 320 | 0 | 288 | 32 | | -short, no race | 320 | 21 | 299 | 0 | 65 | 192 | | full (150), no race | 1,200 | 34 | 1,166 | 17 | 745 | 375 |

  • The 5 ms churn drops every handle before a second POST can use it; under the detector, always. So the step checks the cache's own locking (dead, TryLock, sweep), which is worth having, but not a concurrent Apply on a kept handle and not a concurrent re-seed. At 40 per goroutine a document gets 160 rows and can't reach the cadence at all.
  • On 150 vs 400: the count isn't the weakness. 150 exercises the lock and eviction well (745 dead-marks, 375 contended locks, 17 re-seeds), and the 400 timeouts are test load: 97% of POSTs are full replays of hundreds of clients. The weakness is the churn rate and the missing no-churn phase.
  • Suggest: churn every 50–100 ms; add a phase with no churn on one document (finding A's test); in -short pre-fill past ~230 rows so the re-seed runs under the detector; assert a minimum number of warm hits. Runner numbers may differ from mine, so an assertion is better than trusting either.
  • Cap eviction under concurrency isn't covered (2 documents, cap 64). Setting maxHandles = 1 in the same test would cover it.

C. Rule 1 is not literally true. LOW, comment. warm.go:15-17.

  • Whenever an entry leaves the map while held (dead, orphan, and finding A), two POSTs to one document run at once on separate handles. Rule 3's MAX(seq) check is what keeps that correct, as it always did for the cold path. Say so in the header, so nobody later builds on the lock alone (1b's send-from-handle, for instance).

Checked, no regression

  • Dropping on any Apply error: close runs before the three exits; rejection → 400, cancel → error, anything else → warn and cold. No path keeps a handle after a failed Apply.
  • pending: set after the snapshot write, which only reads the handle, and cleared only after commit; close resets it. A panic in replay or writeSnapshot leaves nothing uncommitted in the handle.
  • release: mine is read under c.mu; a pending handle is closed while e.mu is still held; closed entries leave stats and the byte total.
  • Core comment, spec rule 2 and rule 6 notes, the restore note at store.go:839: accurate.
  • CI step: fails rather than skips without a C compiler, as described.

Canary

Safe to canary with DOCS_WARM_HANDLE=on at 1fd1f70. Nothing I could construct leaves a handle ahead of or different from the log, including under finding A. Land A's fix and its test before re-running load-p1/p20 and the 5+5 shared document, and before turning the default on. B and C can ride with it.

Delta fixes on feat/live-push-1a: three separate commits. Hub CI passed at 1a0d8ef, race step included. 67c6d92 adds only the re-measurements.

| # | Commit | Fix | Test (fails without) | |---|---|---|---| | 1 MED | a2beff6 | warmEntry.refs (under the cache's mu: ++ in acquire, -- in release). A handle-less entry leaves the map only when refs == 0. Dead, orphaned and closed entries still close at once. The count cap counts only entries that keep a handle. warmCounts (replays, hits, stale, reseeds) report what the cache did. | TestWarmHandleContentionDoesNotReplay: 8 × 100 POSTs to one document, no drops. 4 replays, 0 stale, 3 re-seeds, 796 warm hits, ~2 s. Without the reference count: 504 replays, 455 stale, 12 s, so it fails (your 501/431 reproduced). | | 2 LOW/MED | d809d40 | TestWarmHandlesUnderConcurrentPOSTs is pre-filled to just under the cadence, then runs three phases of 8 goroutines: (a) no churn, which must give warm hits ≥ half the POSTs and at least one re-seed; (b) drops and sweeps every 20 ms; (c) maxHandles = 1 with two documents (concurrent cap eviction, ≤ 1 handle kept). | Under the gate's -race -short: 530 warm hits, 2 re-seeds, race-clean. With handles never kept: "0 warm hits in 200 POSTs" and it fails. | | 3 LOW | 1a0d8ef | Rule 1 comment: one POST at a time per handle. An entry leaving the map while held lets two POSTs to one document run on separate handles, and rule 3's in-transaction MAX(seq) check is what keeps that correct. | (comment) |

Gates: go vet, gofmt, go test ./... -count=1, and the race step locally (142 s) and on the hub.

Re-run load measurements on 1a0d8ef (results-2026-11-26/1a-refs/table.md; sealed rows; today's pacing unless noted; 20 pages, 3 runs, median; load average 360–430, so ±20%):

| Server CPU | warm off | warm on | |---|---|---| | 1 typist | 40 ms/s (11.0 ms/upload) | 14 (3.8) | | 5 typists, own documents | 160 | 54 | | 20 typists (1 run) | 567 | 185 | | 5 typists + 5 watchers, one document | 502 | 352 | | 5 + 5, sending at once | 871 | 628 | | 1 page: 1 / 5 / 5+5 shared | 28 / 109 / 398 | 16 / 51 / 193 |

The 1-page shared case is where the reference count shows: 398 → 193, against 442 → 387 before it. In the 20-page shared case, CPU is still mostly the 10 streams' fan-out, which is slice 1b's frame-cache question.

DOCS_WARM_HANDLE stays off by default. Ready to land and canary.

Rebased onto origin/main 6e0c0e0 (S1b); clean, no conflicts. Force-pushed with lease: 67c6d92 → 85a11c7. Hub CI passed at 85a11c7, including the race step (ok … 188s).

Run locally on the rebased tree:

  • Go gate: go vet ./..., go vet -tags browser, gofmt, go test ./... -count=1 (all packages ok), the race step (CGO_ENABLED=1 go test -race -short -run 'Warm|BoundToATransaction|Stream', ok 134 s), and CGO_ENABLED=0 go build ./....
  • Native, compiled: - fresh DocsCRDT.xcframework from native/crdt and native/host; - swift build --build-tests (debug): ok; - swift build -c release --build-tests -Xswiftc -enable-testing -Xswiftc -DDOCS_PROBES -Xswiftc -DDEBUG (the probe build): ok.
  • Native, run: - the probe this branch changes, run-e2e.py … testEndToEndRemoteUpdates against this branch's audit server: n=30, 40/40 seen, peer POST start → visible median 19 ms at 1 page and 63 ms at 20 pages; - LivePushLatencyTests: compiles and runs (2 tests, both skipped without their environment, as designed); - swift test --skip-build --filter 'RealtimeSyncTests|RenderIsolationTests' (debug, on S1b): 16 + 17 tests, 0 failures.

Not merged. DOCS_WARM_HANDLE defaults off.

Landed on main (squash) with DOCSWARMHANDLE defaulting off; hub CI passed at 85a11c7. Next: deploy, canary with the switch on, watch the "warm handle dropped, replaying" log line, re-measure, then flip the default; then slice 1b (push).

Deployed: live push 1a (main 2370192) is on prod. DOCS_WARM_HANDLE=on on docs.oficina.works only; lagged and every canary pinned off.

Versions

  • Hub CI on main 2370192: passed.
  • Built in my own worktree at 2370192 with go1.26.5 (scripts/build-release.sh): v0.1.0-103-g2370192. Shipped with carlos ship --mail submit and promoted to edge.
  • What prod was serving before: v0.1.0-98-gd5a328a on both hosts, not v93. That's the spacing-scale build, promoted 11-22 23:28. It's an ancestor of main, so nothing newer was live. The rollback target is v98.
  • Now: docs.oficina.works and lagged.docs.oficina.works both answer x-carlos-version: v0.1.0-103-g2370192, and /api/version gives the same.

Canary (overnight-docs, switch off)

  • carlos canary deploy --name overnight-release tried to create a new host, overnight-release-docs, and refused because of old data there. It did not reuse overnight-docs, which follows canary/overnight-release. So I shipped, promoted onto canary/overnight-release and restarted the host.
  • Checks on 103: version and healthz OK; /signin is the one-way door (Oficina link, no email form, Other ways link); ?ways=1 chooser OK; /signin/oficina gives 303 → /auth/start; /help/colophon lists Fiesta, minify and parse; junk /native/exchange with a same-origin Origin gives 400; no 5xx.
  • Restored to v0.1.0-87-g8de057d (promote + restart, verified on the host).

Prod (switch off)

  • Promoted, restarted both hosts, and ran the same checks. - docs passes all of them. - lagged shows the email form and /signin/oficina gives 404. That's expected, because it has no DOCS_HOME_*.
  • Logs: no 5xx and no warn/error on docs. Lagged's content sealing not activated ERROR was already there before this deploy (05:49, 08:35, 14:08 today).

Env change and its scope

docs.bds.oncarlos.com is the only route with no environment, so it reads the default bundle alone. Every other route layers a named environment on top of the default bundle. So:

  1. DOCS_WARM_HANDLE=off set in every named environment: lagged, overnight-release, contract-demo, google-import, dashboard, agent-access-nov1. This matches today's behaviour (unset is off) and stops them inheriting the on below.
  2. DOCS_WARM_HANDLE=on set in the default bundle (now cv1:2415a45f…, was cv1:f294e55a…).
  3. carlos env effective: docs = on (default); lagged-docs, overnight-docs, contract-docs and google-import-docs = off (environment).
  4. The host restarted on the config change (16:29:11), and again on carlos restart (16:29:22). It started with no refusing to start and answers normally. The code doesn't log the switch state at startup, so env effective plus the clean start is the evidence it's on.

Note for anyone adding a new environment or team instance: it inherits on from the default bundle unless it sets off itself.

30-minute watch (16:29 to 17:00 UTC)

  • healthz on docs and lagged every 2 min: 16 of 16 returned 200 on 103.
  • 5xx on any docs host: 0. docs: warm handle dropped, replaying: 0. warn/error on docs: none.
  • At 16:31:21 every docs instance (docs, lagged and overnight) shut down cleanly at the same moment. That looks platform-wide, not this build. docs woke at 16:31:39 on 103, cleanly, with the bundle unchanged.
  • Caveat: nobody edited during the window. A carlos db query on the replica shows the last doc_updates row at 14:53 UTC. The warm path has not yet handled a real POST on prod. The next real typing on docs.oficina.works is the actual first test. Look for the drop line with carlos logs --app docs --account oficina --host docs.bds.oncarlos.com --since 1h --grep 'warm handle'.

Rollback

  • Switch only (the first thing to reach for): carlos env set --app docs --account oficina DOCS_WARM_HANDLE=off (or carlos env unset --app docs --account oficina DOCS_WARM_HANDLE), then carlos restart --app docs --account oficina --host docs.bds.oncarlos.com.
  • Build: carlos promote --app docs --account oficina v0.1.0-98-gd5a328a edge, then restart both hosts, then check x-carlos-version. v98 ignores the variable.

Not done, as the plan says: lagged stays off and the default stays off until the 1a re-measure.