Skip to content

gateway: fence sessions.list cache on observer-digest writes - #133034

Merged
obviyus merged 6 commits into
openclaw:mainfrom
masatohoshino:session-observer-digest-fence
Sep 3, 2026
Merged

obviyus merged 6 commits into
openclaw:mainfrom
masatohoshino:session-observer-digest-fence

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

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 eee1bed6c7a1dadcae5bfe2153cff8001281a044 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.

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.
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@masatohoshino
masatohoshino marked this pull request as ready for review August 30, 2026 02:46
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Aug 30, 2026
@masatohoshino

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor

@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.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 5:12 AM ET / 09:12 UTC.

ClawSweeper review

What this changes

This PR adds an observer-digest mutation version to the Gateway sessions.list cache fence and regression coverage for live and terminal digest writes.

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 sessions.list invalidation pattern and covers both live and terminal writers. No blocking correctness or security finding was identified.

Priority: P2
Reviewed head: 60348eb160c38f57fd6968fb00fc7e891b6d991a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with credible real-storage/projection proof and no supported blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body records a current-main failing reproduction and an after-fix focused run through the real SQLite session store, listSessionsFromStoreAsync, and the production cache helper: accepted live writes expose the new headline/health, terminal synthesis exposes done, and the no-write control reuses the cached result.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body records a current-main failing reproduction and an after-fix focused run through the real SQLite session store, listSessionsFromStoreAsync, and the production cache helper: accepted live writes expose the new headline/health, terminal synthesis exposes done, and the no-write control reuses the cached result.
Evidence reviewed 6 items Production persistence owner: The introduced counter advances only after defaultPersistDigest accepts the SQLite-backed session-entry patch, preserving the existing rejected/missing-write behavior.
Cache fence contract: The completed-result cache snapshots its fence before projection and stores a result only when the fence remains unchanged afterward; the introduced digest version participates in both comparisons.
Production writer coverage: The observer service uses defaultPersistDigest when no test-specific persister is injected, and both preamble persistence and terminal synthesis use that selected writer.
Findings None None.
Security None None.

How this fits together

The Gateway caches sessions.list results consumed by session views. Observer digest writes change the headline and health in those rows, so successful writes must invalidate the cached projection.

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]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by 18 lines for this bug fix. The existing session-change fence is not advanced by defaultPersistDigest, so the owner-local monotonic version is the narrowest observed way to fence this independent committed write.
Agent review details

Security

None.

PR surface

Source +18, Tests +272. Total +290 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 18 0 +18
Tests 2 299 27 +272
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 317 27 +290

Review metrics

Metric Value Why it matters
Production versus test LOC production +18/-0; tests +299/-27 The production growth is limited to the digest mutation owner and its cache-fence consumer; the larger test delta covers accepted, rejected, live, and terminal paths.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    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.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best 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 sessions.list caches completed row projections, and the supplied focused regression path exercises the real session store and projection boundary.

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.

Labels

Label justifications:

  • P2: A stale observer headline or health value affects a bounded Gateway session-view workflow without data loss or availability loss.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body records a current-main failing reproduction and an after-fix focused run through the real SQLite session store, listSessionsFromStoreAsync, and the production cache helper: accepted live writes expose the new headline/health, terminal synthesis exposes done, and the no-write control reuses the cached result.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records a current-main failing reproduction and an after-fix focused run through the real SQLite session store, listSessionsFromStoreAsync, and the production cache helper: accepted live writes expose the new headline/health, terminal synthesis exposes done, and the no-write control reuses the cached result.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-08-30T20:11:32.721Z sha afd26c0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-30T21:30:28.649Z sha afd26c0 :: needs real behavior proof before merge. :: none
  • reviewed August 30, 2026, 6:49 PM ET / 22:49 UTC sha unknown :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-30T23:18:28.818Z sha afd26c0 :: needs real behavior proof before merge. :: [P3] Fence only committed digest mutations
  • reviewed 2026-08-30T23:47:53.155Z sha afd26c0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-31T00:33:14.860Z sha afd26c0 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-03T08:49:56.947Z sha 8a8471b :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. labels Aug 31, 2026
@obviyus
obviyus merged commit a6f433b into openclaw:main Sep 3, 2026
209 checks passed
@obviyus

obviyus commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Thanks @masatohoshino!

Proof: On current main, an accepted observer-digest write now invalidates the completed sessions.list result and the next row projection shows the new digest. The no-write control still reuses the cached result.

  • Bug: sessions.list could serve a stale observer headline or health after a successful live or terminal write.
  • Fix: defaultPersistDigest advances one monotonic digest fence only after an accepted mutation, and sessions.list captures and compares it.
Before After
Cached row kept the old digest after a successful write. Live and terminal writes rebuild the row with the new digest.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants