Skip to content

fix(sessions): stop re-reading the Goal session node after certification - #149765

Merged
steipete merged 1 commit into
mainfrom
upd/redmain45-goals-reads
Sep 16, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/redmain45-goals-reads

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Refs #149537 #149722 #149740

What Problem This Solves

Goal management still rereads and decodes the session after the canonical writer has certified its stored metadata, although these operations cannot change session identity.

User Impact

Editing, pausing, blocking, completing, and clearing a Goal avoid two full session reads and repeated decoding of saved prompt data. Goal results, receipts, session identity, lifecycle, and Gateway change notifications retain their behavior. No schema, migration, configuration, dependency, or update behavior changes.

Why This Change Was Made

The Goal operation owner already reads the authoritative entry after write admission and the current-authority check. Pass that entry to the canonical writer and remove both identity snapshots and their inert publication: these management operations preserve the exact session key and generation. The shared writer continues to certify stored metadata and publish cache invalidation; Goal state and its receipt still commit atomically.

Historical attribution identifies #149388 (bc28af41e10) as the change that added the certification SELECT. That read validates the bytes SQLite actually stored and must remain. #149722 correctly removes the post-write identity reread but leaves the pre-write snapshot; #149740 independently removes both. This maintainer-directed repair completes that same simplification, with credit to Vincent Koc for the approach in #149722.

Current main incorporates #149697 (08584b3d34c), which restored the three-read budget by reusing the admitted entry in the previous-identity snapshot. This PR retains that reuse directly at the writer and removes the remaining post-write reread and inert identity machinery. The final two changed files are byte-identical to the reviewed pre-rebase candidate.

Evidence

  • improve(sessions): reduce repeated reads during session updates #149537's parent c698cf3dee3 and merge 3af348c27a0 each passed all 12 Goal operation tests. Current main at db1d5d2dccbc9acaffc6232401dcd4f77855d51a reproduced exactly one failure: expected 4 to be less than or equal to 3.
  • An execution trace from the existing SQLite statement-counter harness identified the four reads below. Temporary tracing was removed from the patch. The fix retains the first and third reads; the existing three-read ceiling and byte budget are unchanged.
  • The candidate passed all 12 Goal operation tests, including literal objective preservation, receipt replay, rollback, stale generation rejection, and current-authority fencing. Added assertions cover unchanged edit/clear session identity, no identity-mutation event, and completed canonical validation.
  • The required neighboring run, node scripts/run-vitest.mjs src/config/sessions/, finished with 170 passing files and 2 failing files: 2,280 tests passed and 3 failed. The unrelated failures are recorded below and are outside this repair.
  • At rebased head c30b768d4ed858016b75a05dbf4fa767141a3c8e, all 22 tests across Goal operations, SQLite identity, and canonical validation passed. Fresh independent Codex branch review was scoped-clean through P1. node scripts/check-changed.mjs, formatting, and git diff --check passed.
  • Required exact-head CI run 35061524769 passed. The canonical watcher reported GREEN in its supported CI-run mode; the separate cancelled label job is not a required main check.
  • ClawSweeper's current-head review found no actionable correctness or security issues and lists no before-merge actions or rank-up moves.
  • Against the updated base, production: +3 / -24 lines (net -21); tests: +10 / -2 lines (net +8). Against the original base, production was net -17.
Trace order Query / caller Disposition
1 SELECT * FROM session_nodes WHERE session_key = ?; mutateSessionGoal → readSessionEntryRow → readSessionEntryRowScan Retained: fresh entry and generation fence
2 Same full-row SELECT; mutateSessionGoal → readSessionIdentitySnapshot → readExactSessionEntryRow before write Removed: duplicates the captured entry
3 Canonical metadata SELECT with retained-window join; writeSessionEntry → certifyCanonicalSessionValidationRows Retained: certification after SQLite binding
4 Same full-row SELECT; mutateSessionGoal → readSessionIdentitySnapshot → readExactSessionEntryRow after write Removed: Goal management cannot change session identity

Unrelated neighboring-suite failures (preserved, not retried or weakened):

  • session-accessor.sqlite-reclamation-memory.test.ts: “settles borrowed cache cleanup and guarded deletion without blocking the authorizer” — memory plugin unavailable.
  • session-transcript-reconcile.lifecycle.test.ts: “retains the active reconcile handle under cache pressure (explicit close: true)” — 30-second test timeout.
  • The same lifecycle file: “keeps the operation pending until lease release after done” — database is not open.

@clawsweeper

clawsweeper Bot commented Sep 16, 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.

@steipete
steipete marked this pull request as ready for review September 16, 2026 05:49
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 16, 2026
Reuse the authoritative entry inside write admission and remove inert identity snapshots. Preserve canonical stored-row certification, receipt atomicity, and session identity.

Co-authored-by: Vincent Koc <[email protected]>
@steipete
steipete force-pushed the upd/redmain45-goals-reads branch from f277580 to c30b768 Compare September 16, 2026 05:56
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review current head c30b768d4ed858016b75a05dbf4fa767141a3c8e. The conflict with #149697 is resolved; the complete Goal-owner simplification is unchanged, and all 22 Goal, identity, and canonical-validation tests passed on this head. The PR body includes the historical query trace and current proof.

@clawsweeper

clawsweeper Bot commented Sep 16, 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: 🐚 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 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 2:15 AM ET / 06:15 UTC (Revision 2).

ClawSweeper review

What this changes

Goal management reuses the session entry already read inside its transaction, removes redundant identity snapshots and publication, and extends tests for preserved identity and completed validation.

Merge readiness

✅ Ready for maintainer review

Keep open: the simplification remains useful on fetched main, and the pinned patch has no actionable correctness findings. The earlier read-budget repair does not remove the remaining identity snapshots, and no merged replacement supersedes this work.

Priority: P2
Reviewed head: c30b768d4ed858016b75a05dbf4fa767141a3c8e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused simplification with relevant supplied validation and no actionable correctness or security findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal simplification is exempt from external-contributor proof requirements and does not materially change authority. Its supplied query trace and pinned-head test results support the Goal transaction path; they are not claimed as live Gateway proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal simplification is exempt from external-contributor proof requirements and does not materially change authority. Its supplied query trace and pinned-head test results support the Goal transaction path; they are not claimed as live Gateway proof.
Evidence reviewed 7 items Verified introduced scope: The local merge-base-to-head diff matches the host's complete introduced patch. Only the Goal operation owner and its existing tests change; unrelated endpoint drift belongs to base-branch work. Diff whitespace checks passed.
Current-main necessity: Fetched main still collects identity lookup keys, reads the remaining snapshots, and prepares identity publication. The merged repair #149697 already reuses the selected entry but leaves this additional simplification outstanding.
Exact identity and current authority remain intact: The complete Goal owner retains its synchronous current-authority check, fresh session read, generation fence, receipt replay checks, and atomic transaction. The row reader selects only the exact trimmed session key, and merging a Goal patch preserves the existing session ID.
Findings None None.
Security None None.

How this fits together

Goals are durable objectives attached to OpenClaw sessions. Gateway management requests update Goal state and retry receipts through the session store, then notify clients of the committed change.

flowchart TD
  A[Goal management request] --> B[Current authorization and writer admission]
  B --> C[Read exact session and check generation]
  C --> D[Replay existing receipt or update Goal]
  D --> E[Shared writer certifies stored metadata]
  E --> F[Commit Goal and receipt together]
  F --> G[Invalidate cache and notify clients]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -21, Tests +8. Total -13 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 24 -21
Tests 1 10 2 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 13 26 -13

Review metrics

None.

Technical review

Best possible solution:

Keep Goal-only mutations in the existing transaction owner, using its fresh entry while retaining stored-row certification, atomic receipts, and independent cache and Gateway notifications.

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

Not applicable as a remaining functional failure: the earlier merged repair restored the read budget. Current source still demonstrates redundant identity reads; no runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes. Removing an inert identity comparison from the existing Goal owner is narrower than manufacturing replacement snapshots, and the actual certification and notification owners remain intact.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3257cbbf4a2f.

Labels

Label justifications:

  • P2: This is a bounded session-store efficiency improvement that avoids redundant saved-prompt decoding without changing user-facing contracts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored internal simplification is exempt from external-contributor proof requirements and does not materially change authority. Its supplied query trace and pinned-head test results support the Goal transaction path; they are not claimed as live Gateway proof.

Evidence

What I checked:

Likely related people:

  • steipete: 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 (1 earlier review cycle)
  • reviewed 2026-09-16T06:09:24.171Z sha c30b768 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit b80fe68 into main Sep 16, 2026
202 of 204 checks passed
@steipete
steipete deleted the upd/redmain45-goals-reads branch September 16, 2026 06:32
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…ion (openclaw#149765)

Reuse the authoritative entry inside write admission and remove inert identity snapshots. Preserve canonical stored-row certification, receipt atomicity, and session identity.

Co-authored-by: Vincent Koc <[email protected]>
ruel225 added a commit to ruel225/openclaw that referenced this pull request Sep 17, 2026
The only failing shard runs goals-operations, which main has since
repaired via openclaw#149765; re-trigger to pick up the fixed base.

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

1 participant