Repository navigation
gateway: fence sessions.list cache on observer-digest writes - #133034
Conversation
createSessionObserverDigestPersister and synthesizeSessionObserverTerminalDigest both persist SessionObserverDigest through defaultPersistDigest, but neither bumped a monotonic version the sessions.list cache fence could key on. A list computed between an accepted digest write and the next unrelated mutation served the stale headline/health in the session sidebar row indefinitely. Add sessionObserverDigestVersion, bumped on every accepted write in the shared defaultPersistDigest seam, and wire it into the sessions.list fence alongside the 8 existing version fields.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper review Please run a fresh exact-item review on current ClawSweeper main to verify the hosted history-hydration fix landed in openclaw/clawsweeper#1308. The prior controlled run completed review generation for this unchanged PR head; its separate bulk publication job failed during Worker state hydration. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: blocked before merge. Reviewed September 3, 2026, 5:12 AM ET / 09:12 UTC. ClawSweeper reviewWhat this changesThis PR adds an observer-digest mutation version to the Gateway Merge readiness⛔ Blocked before merge - 1 item remains Keep open: current main still lacks an observer-digest cache fence, while this PR wires accepted digest persistence into the established Priority: P2 Review scores
Verification
How this fits togetherThe Gateway caches flowchart LR
A[Observer digest writer] --> B[Session storage update]
B --> C[Digest mutation version]
D[sessions.list request] --> E[Cache fence comparison]
C --> E
E --> F[Fresh session row projection]
F --> G[Control UI session sidebar]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +18, Tests +272. Total +290 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the owner-local digest version: it matches the existing per-projection fence design and avoids incorrectly treating every session-entry patch as a Gateway session-change event. Do we have a high-confidence way to reproduce the issue? Yes: current main lacks any observer-digest fence while Is this the best way to solve the issue? Yes: placing the version at accepted digest persistence covers both production writers without changing the protocol, SQLite schema, or Control UI contract; the generic session-change fence is not invoked by this write path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 74ade6f54c87. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
# Conflicts: # src/gateway/session-observer-model.test.ts # src/gateway/session-observer-model.ts
|
Thanks @masatohoshino! Proof: On current
|
…w#133034) ## Summary Add one monotonic `sessions.list` cache fence for accepted observer-digest writes. The fence covers both production writers: live or preamble persistence and terminal synthesis. ## What Problem This Solves The completed `sessions.list` cache did not observe observer-digest writes. After a successful write, it could reuse a row built before the write. The Control UI then showed a stale observer headline or health value until another cache fence changed. ## Why This Change Was Made Both production writers use the shared `defaultPersistDigest` mutation owner in the Gateway. The owner now advances `sessionObserverDigestVersion` only after the SQLite mutation is accepted. The `sessions.list` cache captures and compares that version with its other row-projection fences. Rejected writes and missing rows do not advance the fence. The existing completed-result cache still reuses results when no digest changes. ## User Impact After a live or terminal observer-digest write, the next `sessions.list` request rebuilds the row and exposes the new headline or health. Requests with no digest change keep using the completed result. ## Evidence ### Baseline red Fresh current `main` at `e766077c08ab474f90889c2f2eff3f6d71f6f919` failed the real Gateway row projection reproduction. Command: `node scripts/run-vitest.mjs src/gateway/server-methods/sessions-list-cache.observer-digest.repro.test.ts` The accepted SQLite write completed, but the cached row still returned no observer digest. ### Candidate green The repaired head uses the same real row projection through `listSessionsFromStoreAsync` and `buildGatewaySessionRow`. The live writer case rebuilds the row with headline `Reviewing changes` and health `on-track`. The terminal synthesis case rebuilds the row with health `done`. The no-write control returns the same completed result without another row build. Focused command: `node scripts/run-vitest.mjs src/gateway/server-methods/sessions-list-cache.observer-digest.test.ts src/gateway/session-observer-model.test.ts src/gateway/session-observer-persistence.test.ts src/gateway/session-observer.terminal.test.ts` Result: 51 tests passed. Targeted Oxlint, formatting, `git diff --check`, conflict-marker, max-line, assertion-safety, changelog-attribution, coercion-helper, and deprecated-API checks passed. Exact-head CI run `33737139131` completed successfully for the repaired head. An earlier exact-head run found and was repaired for one test-type error in the terminal fixture. The remaining earlier failures were current-main failures in unrelated auto-reply, gateway-tool, and session-cache tests. ### Review follow-up The production delta is intentionally positive for one reason: observer-digest writes are a distinct accepted mutation, and no existing `sessions.list` fence observes them. Reusing another fence would either miss the write or invalidate unrelated row consumers, so the dedicated monotonic version is the owner-level fix. ### Current-main unrelated red Current `main` also reproduces an existing workspace probe failure in `src/gateway/session-utils.test.ts`. The failure reports `plain.workspaceGit: true` where the test expects `false`. That test and probe are outside this four-file Gateway digest-cache change. ## Non-Scope This change does not alter the Gateway protocol, SQLite schema, observer digest format, or Control UI rendering. Co-authored-by: Ayaan Zaidi <[email protected]>
Summary
Add one monotonic
sessions.listcache fence for accepted observer-digest writes.The fence covers both production writers: live or preamble persistence and terminal synthesis.
What Problem This Solves
The completed
sessions.listcache did not observe observer-digest writes.After a successful write, it could reuse a row built before the write.
The Control UI then showed a stale observer headline or health value until another cache fence changed.
Why This Change Was Made
Both production writers use the shared
defaultPersistDigestmutation owner in the Gateway.The owner now advances
sessionObserverDigestVersiononly after the SQLite mutation is accepted.The
sessions.listcache captures and compares that version with its other row-projection fences.Rejected writes and missing rows do not advance the fence.
The existing completed-result cache still reuses results when no digest changes.
User Impact
After a live or terminal observer-digest write, the next
sessions.listrequest rebuilds the row and exposes the new headline or health.Requests with no digest change keep using the completed result.
Evidence
Baseline red
Fresh current
mainateee1bed6c7a1dadcae5bfe2153cff8001281a044failed the real Gateway row projection reproduction.Command:
node scripts/run-vitest.mjs src/gateway/server-methods/sessions-list-cache.observer-digest.repro.test.tsThe accepted SQLite write completed, but the cached row still returned no observer digest.
Candidate green
The repaired head uses the same real row projection through
listSessionsFromStoreAsyncandbuildGatewaySessionRow.The live writer case rebuilds the row with headline
Reviewing changesand healthon-track.The terminal synthesis case rebuilds the row with health
done.The no-write control returns the same completed result without another row build.
Focused command:
node scripts/run-vitest.mjs src/gateway/server-methods/sessions-list-cache.observer-digest.test.ts src/gateway/session-observer-model.test.ts src/gateway/session-observer-persistence.test.ts src/gateway/session-observer.terminal.test.tsResult: 51 tests passed.
Targeted Oxlint, formatting,
git diff --check, conflict-marker, max-line, assertion-safety, changelog-attribution, coercion-helper, and deprecated-API checks passed.Exact-head CI run
33737139131completed successfully for the repaired head.An earlier exact-head run found and was repaired for one test-type error in the terminal fixture.
The remaining earlier failures were current-main failures in unrelated auto-reply, gateway-tool, and session-cache tests.
Review follow-up
The production delta is intentionally positive for one reason: observer-digest writes are a distinct accepted mutation, and no existing
sessions.listfence observes them.Reusing another fence would either miss the write or invalidate unrelated row consumers, so the dedicated monotonic version is the owner-level fix.
Current-main unrelated red
Current
mainalso reproduces an existing workspace probe failure insrc/gateway/session-utils.test.ts.The failure reports
plain.workspaceGit: truewhere the test expectsfalse.That test and probe are outside this four-file Gateway digest-cache change.
Non-Scope
This change does not alter the Gateway protocol, SQLite schema, observer digest format, or Control UI rendering.