Skip to content

fix(sessions): preserve unrelated reads after lost category replies - #160656

Merged
vincentkoc merged 1 commit into
mainfrom
fix/session-category-invalidation-scope-20260928
Oct 1, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/session-category-invalidation-scope-20260928

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Fixes #160609

What Problem This Solves

A lost acknowledgement during a session-category edit makes unrelated sessions in the same store reread their rows.

User Impact

Unrelated exact reads can finish while the affected category is reconciled. Affected session authority stays pending until current worker facts arrive. No configuration, schema, protocol, migration, or operator action changes.

Why This Change Was Made

The category worker already captures every key it can change. Carry that category-only scope into resident-row readiness and reconcile through the existing bounded worker path. Keep the full committed-cache discard, no replay, and conservative store-wide fencing for superseded writes or structural uncertainty.

Rebased onto 1b896e6327f74f275d6fad7e0ef2d30de652a109, preserving main’s bounded list preparation and canonical selector. The review diff is 140 changed lines smaller (10.5%), retaining all seven original added cases and adding two archive-readiness controls; this reduces review churn, not production LOC. Production is +376/−153 (net +223) for category-uncertainty ownership, lifecycle-maintained readiness and bounded reconciliation; tests are +629/−33 (net +596). No second scheduler or read path. Release-note context stays here under the release-owned changelog policy.

Evidence

  • The original real-worker regression committed B's category edit, injected a lost reply after settlement, and held B's reconciliation. Unrelated A needed two row reads before the repair and one afterward, with zero host data SQL. This proves work reduction, not latency improvement or native transport failure.
  • Current head 0059b141fd424a19b1a5cb0d8bf9d64cfd211da4 retains current main’s metadata-only worker acceptance, registry fences and list selection. Archive eviction retains unresolved metadata for the canonical preparation path; controls cover public search/full reads and metadata-only acceptance without host SQL or unrelated display work. P0–P2 integration review found this archive-readiness gap; the owner fix and focused follow-up review are complete. The final reader-factory relocation into its materialization owner removes the reported import cycle and was directly reviewed. Formatting and diff checks passed. Exact-head CI completed successfully at 2026-10-01 13:10:39 UTC: 51 successful jobs, 22 intentionally skipped jobs, zero failures. Actual named passes: category 4, worker-read 20, sharing-store 15, prepared-read 15 plus registry-refresh 2, and list-page 4: 60 passed, none skipped in these files. The architecture check passed. The exact-head ClawSweeper review found no correctness/security issue; its sole before-merge and rank-up request for current-path validation is satisfied by these receipts.
  • Controls retain structural dominance, physical-store aliases, ID isolation, unrelated placement work, archive eviction, fixed batches of at most 64 over 8,193 rows, worker failure/explicit retry, current category/identity, and no replay.
Runtime proof and measured test cost

Current affected CI job walls, including setup and other assigned files: category 133s; worker-read 259s; sharing-store 316s; prepared-read/registry-refresh 272s; list-page 258s. These are job costs, not standalone file timings. All named shard-completion receipts reported zero failed invocations.

The complete pre-reduction head 9d8bc6aec973704d978d132c741a18018b9507f9 passed 52/52 cases, zero skipped on 2026-10-01. The ClawSweeper durable review history records the 9d historical review cycle with no correctness/security issue; its cost follow-up was addressed by this single AWS run. These measurements remain bound to that historical head.

Commands ran sequentially as pnpm test <file> --maxWorkers=1 --reporter=verbose on Linux x64, AWS c7a.8xlarge, Node 24.19.0 / V8 13.6.233.17-node.51, pnpm 12.5.1 and Vitest 5.0.1. Every child exited/closed with code 0 and was joined.

File Passed Command wall Vitest duration
src/gateway/session-row-projection.category.test.ts 2 48.582s 44.66s
src/gateway/session-row-projection.worker-read.test.ts 20 55.337s 30.33s
src/gateway/session-row-projection.prepared-read.test.ts 15 62.446s 59.46s
src/config/sessions/session-sharing-store.worker.test.ts 15 61.074s 58.02s

Command wall includes worker preparation, imports, setup and teardown, not just assertions. Driver wall was 233.502s. Source carrier 017d7d4e19eeb3e4d03f1ec1eb31c8bb0c23ed68 had the exact historical tree c4353ec6bea48ea1c0d8b6b98613c51ba3845f58; before/after source guards passed. The sole AWS resource was released with provider cleanup confirmed. No baseline latency comparison is claimed.

Whole-file costs exceed 30s because these tests exercise real worker/projection and SQLite lifecycles with normal preparation and imports. The 8,193-row case took 9.541s, above the 5s target: it crosses the real 8,192-row admission ceiling and checks bounded draining plus archive eviction. A cheaper layered equivalent remains a follow-up, not demonstrated replacement coverage.

Earlier head 662a2843909d0eb3bb256a374baebda33d88bd9c passed 51 cases through scoped runs and its complete CI run. Its historical static validation combined a 26-graph pass with affected gateway-root/lint reruns after mechanical corrections.

Historical 9d CI failed required lint; no waiver was taken. After the source refresh, 6eb CI completed successfully with 51 successful and 21 skipped jobs. That run predates the final integration with main’s bounded list preparation and does not replace final-head CI.

Release-tag reachability and production frequency of the lost-acknowledgement condition remain unestablished.

@vincentkoc vincentkoc self-assigned this Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XL labels Sep 28, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 28, 2026 18:45
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed October 1, 2026, 9:05 AM ET / 13:05 UTC (Revision 6).

ClawSweeper review

What this changes

The PR limits lost category-update acknowledgement fences to affected sessions and reconciles their facts through existing bounded database-worker reads.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR remains useful: current main still invalidates unrelated reads after an uncertain category update. No introduced correctness defect was found, and the earlier merge-conflict blocker is resolved.

Priority: P2
Reviewed head: 0059b141fd424a19b1a5cb0d8bf9d64cfd211da4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent repair with meaningful real-worker evidence and no actionable finding; final integration validation is still outstanding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded historical production-worker fault injection exercises the category writer and projection boundary: unrelated A drops from two reads to one while B reconciles, with no replay and zero host data SQL. Preserve that scoped proof; final-head archive and list integration validation remains pending. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded historical production-worker fault injection exercises the category writer and projection boundary: unrelated A drops from two reads to one while B reconciles, with no replay and zero host data SQL. Preserve that scoped proof; final-head archive and list integration validation remains pending. No stored-data contract changes.
Evidence reviewed 10 items Current main still needs the repair: The fetched main revision still emits a store-wide factsInvalidated publication after an uncertain category.apply outcome, which advances the projection-wide database revision and rejects unrelated held replies.
Introduced uncertainty scope: The pinned introduced diff retains full committed-cache discard and no replay, publishes category-only target keys when known, and preserves store-wide fallback when the captured write was superseded.
Lifecycle-owned readiness: Category reconciliation uses fixed batches of at most 64 keys through the existing exact preparation boundary. Row replacement, removal, archive eviction, metadata-only acceptance, and disposal maintain readiness; unresolved structural facts dominate category uncertainty.
Findings None None.
Security None None.

How this fits together

The Gateway’s session-row projection turns committed SQLite facts into session lists, descriptions, and sharing checks. Category-update uncertainty must hold affected facts pending while allowing unrelated prepared reads to remain usable.

flowchart TD
 A[Category edit] --> B[Database worker commits]
 B --> C{Reply outcome known?}
 C -->|Yes| D[Publish committed facts]
 C -->|No| E[Fence affected session facts]
 E --> F[Bounded worker reconciliation]
 F --> G[Session reads and sharing checks]
 D --> G
Loading

Before merge

  • Complete next step (P2) - Record focused validation of the resolved session-worker and projection paths on the current head, including the new archive-readiness controls.
Agent review details

Security

None.

PR surface

Source +223, Tests +596. Total +819 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 11 376 153 +223
Tests 4 629 33 +596
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 1005 186 +819

Review metrics

Metric Value Why it matters
Production and test growth production +376/−153, net +223; tests +629/−33, net +596 The body justifies production growth through uncertainty ownership, readiness lifecycle, and bounded reconciliation rather than a parallel scheduler.
Recorded focused-test cost 233.502s total wall time on historical head; 8,193-row case 9.541s The body explains the real worker/SQLite lifecycle cost and the admission-ceiling contract; these measurements do not cover the final integration.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #160609
Summary: This PR is a candidate fix for the canonical lost-category-acknowledgement issue; another open proposal addresses the same defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep category uncertainty local to captured keys, retain structural fallback and no replay, and let the existing worker-read owner restore current facts.

Do we have a high-confidence way to reproduce the issue?

Yes: hold A’s real worker reply, commit B’s category edit, inject a lost acknowledgement, and observe current main reject A’s reply through the broad revision fence. This review established the path from source and recorded evidence without executing it.

Is this the best way to solve the issue?

Yes: the patch narrows uncertainty at its producer and reuses the existing preparation owner, while preserving conservative structural fallback and affected-session fencing.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9bf17b16a878.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This removes bounded redundant worker reads; production frequency and end-to-end latency impact remain unestablished.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded historical production-worker fault injection exercises the category writer and projection boundary: unrelated A drops from two reads to one while B reconciles, with no replay and zero host data SQL. Preserve that scoped proof; final-head archive and list integration validation remains pending. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded historical production-worker fault injection exercises the category writer and projection boundary: unrelated A drops from two reads to one while B reconciles, with no replay and zero host data SQL. Preserve that scoped proof; final-head archive and list integration validation remains pending. No stored-data contract changes.

Evidence

What I checked:

  • Current main still needs the repair: The fetched main revision still emits a store-wide factsInvalidated publication after an uncertain category.apply outcome, which advances the projection-wide database revision and rejects unrelated held replies. (src/config/sessions/session-sharing-store.async.ts:140, 9bf17b16a878)
  • Introduced uncertainty scope: The pinned introduced diff retains full committed-cache discard and no replay, publishes category-only target keys when known, and preserves store-wide fallback when the captured write was superseded. (src/config/sessions/session-sharing-store.async.ts:138, 0059b141fd42)
  • Lifecycle-owned readiness: Category reconciliation uses fixed batches of at most 64 keys through the existing exact preparation boundary. Row replacement, removal, archive eviction, metadata-only acceptance, and disposal maintain readiness; unresolved structural facts dominate category uncertainty. (src/gateway/session-row-membership-read.ts:29, 0059b141fd42)
  • Real-worker regression and safety controls: The committed regression invokes the production category writer and real SQLite workers, injects outcome-unknown after commit, holds reconciliation, and checks one unrelated read, affected authority remaining pending, current category recovery, unchanged generation, one mutation application, and zero host data SQL. Structural uncertainty deliberately retains the second unrelated read. (src/gateway/session-row-projection.worker-read.test.ts:366, 0059b141fd42)
  • Proof identity and validation continuity: The captured PR body records the original real-worker before/after observation and 52 passing cases on historical head 9d8bc6a. It explicitly leaves final-head validation pending after integrating bounded list preparation and adding archive-readiness controls; historical results are not final-head execution evidence. This read-only review executed no tests. (9d8bc6aec973)
  • Earlier conflict blocker resolved: The raw test-merge commit records the pinned base followed by the exact reviewed head. Its result changes only the introduced session paths, and the REST read confirms the current head is cleanly mergeable; the previous conflict warning no longer applies. (3c4307fe42d3)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record current-head focused validation covering category recovery, archive readiness, and retained list-page/registry controls.

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 (5 earlier review cycles)
  • reviewed 2026-09-28T18:52:50.233Z sha 662a284 :: blocked before merge. :: none
  • reviewed 2026-09-28T19:07:27.102Z sha 662a284 :: blocked before merge. :: none
  • reviewed 2026-10-01T07:17:00.482Z sha 9d8bc6a :: needs changes before merge. :: none
  • reviewed 2026-10-01T07:43:52.588Z sha 9d8bc6a :: needs maintainer review before merge. :: none
  • reviewed 2026-10-01T12:37:55.745Z sha 6eb0ad530fab403ac98827f87c03a969993a985a :: needs changes before merge. :: none

@vincentkoc
vincentkoc force-pushed the fix/session-category-invalidation-scope-20260928 branch 2 times, most recently from 6eb0ad5 to 87428e5 Compare October 1, 2026 12:49
Carry the category worker's captured key scope into resident row readiness after an uncertain acknowledgement. Keep affected authority pending, reconcile through bounded exact reads, and preserve conservative structural invalidation and no-replay semantics.
@vincentkoc
vincentkoc force-pushed the fix/session-category-invalidation-scope-20260928 branch from 87428e5 to 0059b14 Compare October 1, 2026 12:58
@vincentkoc
vincentkoc merged commit dad8de7 into main Oct 1, 2026
138 of 139 checks passed
@vincentkoc
vincentkoc deleted the fix/session-category-invalidation-scope-20260928 branch October 1, 2026 14:54
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…penclaw#160656)

Carry the category worker's captured key scope into resident row readiness after an uncertain acknowledgement. Keep affected authority pending, reconcile through bounded exact reads, and preserve conservative structural invalidation and no-replay semantics.
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: XL 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.

Lost category update acknowledgements invalidate unrelated session reads

1 participant