Skip to content

fix(test): drain session fixtures before removing state - #144087

Merged
steipete merged 1 commit into
mainfrom
codex/session-fixture-reconcile-drain-20260910
Sep 10, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/session-fixture-reconcile-drain-20260910

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #144034
Related: #137381

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.

What Problem This Solves

Resolves a problem where session regression tests leave native transcript-reconcile workers running after their fixture directories are deleted. In shared unit-fast workers, that work can overlap later TaskFlow teardown and contend on the shared-state lifecycle lock.

The investigation started with the TaskFlow teardown failures in CI. The unchanged CI base reproduced the failures, so the model-defaults change in #144034 is not required to trigger them.

Why This Change Was Made

The fixture now drains each owned root through the existing cleanupSessionStateForTest helper before removing its directories. Teardown attempts every root sequentially, preserves the directories and tracker if any drain fails, and reports one original error or aggregates multiple failures.

The change is confined to one test file: +23 / -2 lines, with every test body unchanged. It retains the session rewrite regression coverage contributed by @jalehman in #137381.

User Impact

Developers get complete fixture cleanup in shared-worker test runs. Production behavior, database coordination, and runtime APIs are unchanged.

Evidence

  • Final pnpm check:changed: passed (exit 0) on the frozen final source. The earlier lint failure remains in the local evidence; this is a completed whole-gate rerun after its correction.
  • P2 autoreview: scoped-clean on the exact final source.
  • Linux x64, Node v24.19.0, SQLite 3.53.3: explicit original-order pair of the session fixture and TaskFlow tests passed 14/14.
  • The retained three-worker Linux CI cohort passed 8,984 tests, with 8 skipped, across 695 files (694 passed, one skipped). The main-based repair includes 695 of the original 696 cohort paths; the extra inline-defaults test belongs to fix(models): select authored rows before applying defaults #144034 and was absent at the repair base.
  • Native tracing covered all seven fixture removals and four reconcile workers: no fixture-owned database/coordinator activity occurred after cleanup, no native database/coordinator state remained active at removal, and no coordinator errors occurred. Worker-exit callback timing was not used as the success condition.
  • The host and Linux candidate source hashes matched, and the candidate remained unchanged throughout proof. No build was needed for this test-only change.

Attribution limit: the earlier baseline run reproduced TaskFlow failures, while later instrumented runs identified escaped native owners and same-path contention separately. Those instrumented runs did not capture a failing TaskFlow stack with the native holder fully correlated. The repair is supported by the fixture ownership defect and direct cleanup-boundary proof.

Wait for each session fixture's native transcript reconciliation and state
cleanup before deleting its temporary directory. Attempt all owned roots,
retain failed cleanup state, and preserve the existing test assertions.

Related: #144034
Preserves the session regression coverage from #137381 by @jalehman.
@clawsweeper

clawsweeper Bot commented Sep 10, 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 10, 2026 13:57
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 10:05 AM ET / 14:05 UTC.

ClawSweeper review

What this changes

The session regression tests now drain their background work before deleting temporary state, retaining directories and reporting errors when cleanup fails.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fixture-lifecycle repair: current main still removes these directories without draining reconciliation. No introduced correctness or security defect was found.

Priority: P2
Reviewed head: 600084d574df7aa0dd253b2c7de9e6238ea791d5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair using the existing cleanup owner, with unchanged assertions and relevant recorded validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a member-authored test-only repair, so the external-contributor runtime gate does not apply; the body reports original-order Linux tests and native cleanup observations matching the changed teardown.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a member-authored test-only repair, so the external-contributor runtime gate does not apply; the body reports original-order Linux tests and native cleanup observations matching the changed teardown.
Evidence reviewed 7 items Introduced change and merge scope: The pinned introduction changes only teardown in the session mutation-boundary tests; all test bodies remain unchanged. The verified test-merge comparison has the same single-file scope, and the introduced diff passes whitespace checking.
Existing cleanup owner: The helper drains writer queues, awaits root-scoped reconciliation, drains subsequent writes, and closes matching agent handles before shared-state handles. The patch consumes this existing lifecycle rather than adding another cleanup implementation.
Current-main necessity: Fetched main still registers the synchronous automatic directory cleanup in this fixture, without calling the session-state drain. No release inclusion for this proposed repair was established; the supplied latest release is v2026.9.3.
Findings None None.
Security None None.

How this fits together

Session regression tests exercise OpenClaw’s SQLite transcript storage, which can schedule background reconciliation. Their teardown must finish that work before removing fixture files so later tests do not inherit active database work.

flowchart TD
  A[Session regression tests] --> B[Tracked fixture directories]
  B --> C[Drain writers and reconciliation]
  C --> D[Close fixture databases]
  D --> E{Cleanup succeeded?}
  E -->|Yes| F[Remove temporary directories]
  E -->|No| G[Retain directories and report errors]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +21. Total +21 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 23 2 +21
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 23 2 +21

Review metrics

None.

Technical review

Best possible solution:

Keep fixture disposal behind the existing session-state drain while preserving the regression assertions and failed-cleanup evidence.

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

Yes for the fixture-lifetime defect: current main deletes directories without awaiting their reconciliation owner. Tests were not run here, and the precise causal link to the observed TaskFlow failure remains unproven.

Is this the best way to solve the issue?

Yes. Calling the established cleanup helper before directory removal repairs ownership at the fixture boundary without changing production coordination, assertions, or timeouts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 03628385d332.

Labels

Label changes:

  • add P2: This repairs a concrete test-fixture lifetime defect with limited scope and no production behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This repairs a concrete test-fixture lifetime defect with limited scope and no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

  • jalehman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • 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 eb9f4ff into main Sep 10, 2026
164 checks passed
@steipete
steipete deleted the codex/session-fixture-reconcile-drain-20260910 branch September 10, 2026 14:09
@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 11, 2026
)

Wait for each session fixture's native transcript reconciliation and state
cleanup before deleting its temporary directory. Attempt all owned roots,
retain failed cleanup state, and preserve the existing test assertions.

Related: openclaw#144034
Preserves the session regression coverage from openclaw#137381 by @jalehman.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant