Skip to content

test(sessions): hold cold maintenance validation where it actually runs - #161608

Merged
steipete merged 1 commit into
mainfrom
steipete/cold-validation-probes
Sep 30, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/cold-validation-probes

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #160858, #161181

What Problem This Solves

The session maintenance concurrency tests could not detect the writer-blocking regression from #160858: cold agent-database integrity validation ran in the foreground executor while it held the writer permit, so foreground session writes stalled for the whole check, yet the current prepared-admission maintenance cases still passed on that shape.

User Impact

No user-visible change. The behavior was already repaired on main by #161181; this PR makes the maintenance entry points fail loudly if cold validation moves back under the foreground writer.

Why This Change Was Made

observeWorkerAdmission pre-released every native integrity check and only paused the maintenance finalizer before its writer permit, so it passed whether validation ran in the reclamation worker or in the executor under the writer. The probes now:

  • hold the first native integrity check on the fixture database in any worker thread (an atomic first-check claim in the integrity-counter preload), assert that the reclamation worker owns it (the contract documented in worker-access.md), and require a foreground applySessionEntryReplacements commit while it is held. This covers the whole-store, lifecycle and replacement maintenance entry points and the finalizer lifetime recheck.
  • keep the expired-proof path separate: the host handle stays open with its integrity proof expired before finalization. The case proves the retained branch was taken (no cold preparation), that the reclamation worker revalidates before anything commits, and that foreground writes proceed meanwhile.
  • assert exact per-owner check counts. In the cold cases the executor's single check belongs to the foreground write validating its own cold open.

The opt-in hold leaves existing helper callers on their current two-key message shape. The unused before-writer hold mode is removed, and the main-thread probe moves into the existing test-support file to keep the test under its line cap.

Evidence

  • pnpm test src/config/sessions/session-accessor.sqlite-prepared-admission.test.ts --maxWorkers=1: 31/31 pass on this head, 66 s wall (baseline 30 tests, 170 s wall including a cold 50 s worker compile; a later run on a loaded host took 129 s).
  • Negative control: with refactor(cron): move retention cleanup off the Gateway thread #160858's executor-first withSessionEntryWorker(... runExisting ...) preparation temporarily restored in session-accessor.sqlite-reclamation-run.ts, the three cold maintenance cases and the lifetime case fail in about 2 s each with cold validation owner: expected 'executor' to be 'reclamation', and no case times out. The expired-proof case still passes, as expected, because it exercises the separate retained branch. The mutation was reverted byte-for-byte.
  • Other users of the integrity-counter helper still pass: sqlite-reclamation-preparation 3/3, sqlite-reclamation-reuse 24/24, sqlite-lifecycle-admission 9/9 (100 s combined, --maxWorkers=1).
  • oxfmt --check, scoped run-oxlint, and the core-test-agents-sessions tsgo graph pass on the changed files.
  • Test cost: one added case; the file stays within budget (no real timers, sleeps, polling, or new worker pins).

The prepared-admission maintenance probes pre-released every native
integrity check, so they passed even when cold validation ran in the
foreground executor under the writer permit (#160858's shape, repaired by
#161181). Hold the first integrity check on the fixture database in any
worker, assert the reclamation worker owns it, and require a foreground
replacement commit while it is held, for the whole-store, lifecycle and
replacement entry points and the finalizer lifetime recheck.

Keep expired-proof finalization as its own case on the retained branch:
the reclamation worker revalidates before committing while foreground
writes proceed. Existing integrity-counter callers keep their message
shape; the unused before-writer hold mode is removed.

With the executor-first preparation temporarily restored, the four cold
cases fail in about 2 s each on the owner assertion.
@clawsweeper

clawsweeper Bot commented Sep 30, 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 30, 2026 04:37
@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 30, 2026
@clawsweeper

clawsweeper Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 30, 2026, 12:42 AM ET / 04:42 UTC.

ClawSweeper review

What this changes

This PR changes session-maintenance tests to hold a native SQLite integrity check, verify foreground writes can commit during validation, and cover finalization with expired validation proof.

Merge readiness

✅ Ready for maintainer review

Keep this PR open. The merged runtime fix restores foreground responsiveness, but current main does not contain these maintenance-entry-point regression checks. The proposed native-check hold and reported negative control support a distinct, useful test contribution.

Priority: P2
Reviewed head: de27692ff85995874eeb47437b0b00788836ebbf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The native-boundary negative control makes the regression coverage convincing; the patch is substantial but focused on the test owner.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The test-only change exercises production session-maintenance entry points with native SQLite workers and a held integrity check. The PR reports foreground commits on the fixed path, 31 passing focused cases, and four fast failures when the former executor-first route is restored. 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 (terminal): The test-only change exercises production session-maintenance entry points with native SQLite workers and a held integrity check. The PR reports foreground commits on the fixed path, 31 passing focused cases, and four fast failures when the former executor-first route is restored. No stored-data contract changes.
Evidence reviewed 9 items Introduced native hold: The preload atomically claims the first integrity check across workers, reports its owner, and holds that check until released.
Maintenance entry-point assertions: The cold cases require the reclamation worker to own the held check, commit a foreground replacement before release, and verify per-owner check counts.
Retained finalizer case: The added case keeps the host handle open, expires its validation proof, observes worker revalidation, and verifies a foreground replacement commits before maintenance resumes.
Findings None None.
Security None None.

How this fits together

Session maintenance plans archive and remove old session data through a reclamation worker. The tests check that its database validation leaves the foreground session writer available and that finalization still respects the current validation state.

flowchart LR
A[Session maintenance] --> B[Archive plan]
B --> C[Reclamation worker]
C --> D[Native integrity check]
D --> E[Writer admission]
E --> F[Session data and archive]
G[Foreground session update] --> E
H[Test validation hold] --> D
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +219. Total +219 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 411 192 +219
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 411 192 +219

Review metrics

Metric Value Why it matters
Focused native test cost 31 cases; 66 s reported wall time on one worker The PR documents the cost of this slow native boundary suite and a negative control for the added coverage.

Technical review

Best possible solution:

Retain a native-check regression guard through the maintenance callers and expired-proof finalizer, alongside the existing lower-level reclamation test.

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

Yes for the test gap: current main's old probe pre-releases native checks, and the PR reports that restoring the former executor-first route makes four proposed cold cases fail quickly. I did not execute the negative control.

Is this the best way to solve the issue?

Yes. Holding the actual native check and requiring an independent foreground commit tests the documented scheduling contract through the maintenance entry points.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2247f10d9a84.

Labels

Label changes:

  • add P2: This is a focused regression-coverage improvement for foreground session responsiveness, with no production behavior change.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The test-only change exercises production session-maintenance entry points with native SQLite workers and a held integrity check. The PR reports foreground commits on the fixed path, 31 passing focused cases, and four fast failures when the former executor-first route is restored. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The test-only change exercises production session-maintenance entry points with native SQLite workers and a held integrity check. The PR reports foreground commits on the fixed path, 31 passing focused cases, and four fast failures when the former executor-first route is restored. No stored-data contract changes.

Label justifications:

  • P2: This is a focused regression-coverage improvement for foreground session responsiveness, with no production behavior change.
  • 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 (terminal): The test-only change exercises production session-maintenance entry points with native SQLite workers and a held integrity check. The PR reports foreground commits on the fixed path, 31 passing focused cases, and four fast failures when the former executor-first route is restored. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The test-only change exercises production session-maintenance entry points with native SQLite workers and a held integrity check. The PR reports foreground commits on the fixed path, 31 passing focused cases, and four fast failures when the former executor-first route is restored. No stored-data contract changes.

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.

@steipete
steipete merged commit a79c90c into main Sep 30, 2026
189 checks passed
@steipete
steipete deleted the steipete/cold-validation-probes branch September 30, 2026 04:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 1, 2026
…ns (openclaw#161608)

The prepared-admission maintenance probes pre-released every native
integrity check, so they passed even when cold validation ran in the
foreground executor under the writer permit (openclaw#160858's shape, repaired by
openclaw#161181). Hold the first integrity check on the fixture database in any
worker, assert the reclamation worker owns it, and require a foreground
replacement commit while it is held, for the whole-store, lifecycle and
replacement entry points and the finalizer lifetime recheck.

Keep expired-proof finalization as its own case on the retained branch:
the reclamation worker revalidates before committing while foreground
writes proceed. Existing integrity-counter callers keep their message
shape; the unused before-writer hold mode is removed.

With the executor-first preparation temporarily restored, the four cold
cases fail in about 2 s each on the owner assertion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: L 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