Skip to content

fix(ci): drain heartbeat fixture state before deleting its files - #153591

Merged
steipete merged 1 commit into
mainfrom
codex/heartbeat-fixture-drain-20260920
Sep 20, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/heartbeat-fixture-drain-20260920

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes false heartbeat worker-identity failures in Linux CI after earlier test cases delete their temporary state directories.

User Impact

No production behavior changes. The heartbeat tests retain their current assertions, deadlines, and native worker authority checks.

Why This Change Was Made

The outcome-store fixture drains agent workers, but only synchronously closes shared-state handles before deleting its directories. Shared-state async lifecycle records therefore survive deletion. When a later file has the same physical identity, the captured record can still name the previous canonical path and the native lease guard correctly refuses it.

Await shared-state shutdown before the synchronous test reset and directory removal, matching the existing heartbeat sandbox cleanup. This drains resources and retires their identity records through the existing owner. No schema, lifecycle implementation, or admission-guard changes.

Evidence

  • Original Linux CI: run 35499425346, failing job 106048547403. Seven failures occur in core-runtime-infra-heartbeat-core at Agent worker lease differs from its captured native owner.
  • That run tested merge revision 15affb5bc00ea79c4717d07e24f066430e05d5b9, incorporating refactor(heartbeat): run outcome queries in the agent database worker #147463 from main into unrelated updater PR fix(update): verify paired trusted-proxy gateways with service credentials #153540. The updater source head predates the heartbeat worker cutover. This repair is based on main 6584af0ae9aee96cda722b2254d06b716a6edec4.
  • Exact failing merge on macOS Node 24: 11 heartbeat tests pass. Candidate on the same host: 11 pass. This alone does not establish Linux recovery.
  • Deterministic real-file owner probe: rename a synthetic file while preserving its physical identity. Synchronous invalidation leaves the old captured canonical path; awaiting lifecycle close first produces the current path. No mocks or changed production guards.
  • Independent review: no actionable P0–P2 findings.
  • Hosted Linux CI 35501696816, job 106054596006: all 11 outcome-store cases pass in their original order, including all 7 previously failing cases. Candidate merge revision ae3a4391cdba21697ee3268e38ee9575eab6609a. Test-only routing ran the exact file through the unchanged isolated infra configuration; the entire outer heartbeat-core group was not rerun.
  • A fresh Testbox attempt failed during source transfer before executing tests; the lease was stopped. No Testbox test success is claimed.
  • Local changed gate passed formatting, line caps, plugin boundaries, wrapper shadowing, and package guards, then refused typecheck because the read-only dependency donor is outside this worktree. Hosted CI owns the physical-install typecheck; the boundary was not bypassed.

@clawsweeper

clawsweeper Bot commented Sep 20, 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 size: XS maintainer Maintainer-authored PR labels Sep 20, 2026
@steipete
steipete marked this pull request as ready for review September 20, 2026 09:13
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 5:34 AM ET / 09:34 UTC (Revision 2).

ClawSweeper review

What this changes

The heartbeat tests now await shared-state database shutdown before resetting fixture state and deleting temporary files.

Merge readiness

✅ Ready for maintainer review

The repair remains necessary on current main, and no actionable patch defects were found. The updated Linux evidence and verified file isolation resolve the previous review’s replay concern.

Priority: P3
Reviewed head: 0244990bcbcf46f48a9daf858c33d9cb729f655d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair using the established cleanup contract, supported by relevant Linux validation and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The contributor runtime-proof gate is exempt for this maintainer PR. For the changed fixture, the supplied Linux ordered replay and independently confirmed successful job support recovery; source-verified file isolation resolves the earlier outer-group concern. Raw case logs were inaccessible to this reviewer.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The contributor runtime-proof gate is exempt for this maintainer PR. For the changed fixture, the supplied Linux ordered replay and independently confirmed successful job support recovery; source-verified file isolation resolves the earlier outer-group concern. Raw case logs were inaccessible to this reviewer.
Evidence reviewed 7 items Introduced change: The verified merge-base comparison adds only the existing asynchronous shared-state close to fixture teardown and its import; assertions, deadlines, production code, and authority checks are unchanged.
Canonical shutdown contract: The asynchronous close drains registered resources before native retirement. Its lifecycle owner then forgets physical-identity records; synchronous invalidation only changes their generation. The existing heartbeat sandbox already follows async close, test reset, then file deletion.
Current main still needs the repair: Fetched main still performs the synchronous shared-state reset immediately before temporary-directory cleanup, without awaiting shared-state shutdown.
Findings None None.
Security None None.

How this fits together

Heartbeat outcome tests exercise SQLite persistence and worker-backed claims using temporary databases. Their cleanup must retire workers, handles, and cached file identities before subsequent tests create new databases.

flowchart TD
 A[Heartbeat test cases] --> B[Temporary SQLite databases]
 B --> C[Drain agent workers]
 C --> D[Await shared-state shutdown]
 D --> E[Reset test state]
 E --> F[Delete temporary files]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +4. Total +4 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 5 1 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 5 1 +4

Review metrics

None.

Technical review

Best possible solution:

Keep fixture deletion behind the existing lifecycle owner’s completed shutdown, preserving all production guards and test assertions.

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

Yes, the source establishes that synchronous cleanup retains identity records across file deletion, providing a concrete failure mechanism when physical identities are reused. This read-only review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes. Calling the existing asynchronous close before reset and deletion matches the established sibling fixture and fixes cleanup without weakening checks or adding another lifecycle owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 03e1d2043091.

Labels

Label justifications:

  • P3: This is a bounded test-fixture reliability repair with no production behavior change.
  • 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. Not applicable: The contributor runtime-proof gate is exempt for this maintainer PR. For the changed fixture, the supplied Linux ordered replay and independently confirmed successful job support recovery; source-verified file isolation resolves the earlier outer-group concern. Raw case logs were inaccessible to this reviewer.

Evidence

What I checked:

  • Introduced change: The verified merge-base comparison adds only the existing asynchronous shared-state close to fixture teardown and its import; assertions, deadlines, production code, and authority checks are unchanged. (src/infra/heartbeat-outcome-store.test.ts:52, 0244990bcbcf)
  • Canonical shutdown contract: The asynchronous close drains registered resources before native retirement. Its lifecycle owner then forgets physical-identity records; synchronous invalidation only changes their generation. The existing heartbeat sandbox already follows async close, test reset, then file deletion. (src/state/openclaw-state-db-async-lifecycle.ts:509, 0244990bcbcf)
  • Current main still needs the repair: Fetched main still performs the synchronous shared-state reset immediately before temporary-directory cleanup, without awaiting shared-state shutdown. (src/infra/heartbeat-outcome-store.test.ts:49, 03e1d2043091)
  • Release comparison: The v2026.9.5 fixture also lacks asynchronous shared-state shutdown, but predates the current worker-backed fixture. It does not establish that the reported CI failure affects released users. (src/infra/heartbeat-outcome-store.test.ts:31, ec9c1a13db89)
  • Relevant replay boundary: The infra configuration explicitly enables file isolation, disables file parallelism, and uses forks; the scoped configuration preserves isolation. The supplied September 20 comment reports all 11 cases passing in their original order, including the seven earlier failures. This covers the relevant within-file sequence without requiring the entire outer group. (test/vitest/vitest.infra.config.ts:11, 0244990bcbcf)
  • Linux job independently confirmed: GitHub confirms checks-node-changed succeeded on Ubuntu for the reviewed head at 09:15:47 UTC. The captured discussion identifies test-merge ae3a4391cdba21697ee3268e38ee9575eab6609a and the ordered 11-case result. Raw-log retrieval was blocked by the artifact-host allowlist, so case-level results remain attributed to that supplied discussion rather than independently inspected logs. (0244990bcbcf)

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-20T09:19:11.098Z sha 0244990 :: blocked before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

The Linux evidence is now available in the exact-head changed-test job. I retrieved its completed logs: checkout was ae3a4391cdba21697ee3268e38ee9575eab6609a, merging reviewed head 0244990bcbcf46f48a9daf858c33d9cb729f655d into main 963aa2395617486a4d772f566e5799f372a52fbf.

The job ran src/infra/heartbeat-outcome-store.test.ts through the unchanged infra configuration. All 11 cases passed in their original order, including each of the seven cases that failed in the earlier heartbeat-core job. The ordered run began at 09:15:13 UTC and completed with 11 passed at 09:15:41 UTC.

Test-only CI selects this exact file rather than the whole outer heartbeat-core group. That does preserve the relevant state sequence: the infra configuration uses isolate: true and forks, so the leaked records accumulate between cases within this file. I am not claiming a rerun of the entire outer group. The original seven-case Linux failure, this matched ordered success, and the deterministic real-file identity-retirement probe cover this test-fixture repair. The PR body now records the same evidence and limits. Production identity checks and all existing assertions remain unchanged.

@steipete
steipete merged commit b240686 into main Sep 20, 2026
178 checks passed
@steipete
steipete deleted the codex/heartbeat-fixture-drain-20260920 branch September 20, 2026 09:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 20, 2026
Include the merged heartbeat fixture drain repair from #153591.
The workspace cleanup production diff remains unchanged.

Verified 98 workspace tests with one existing platform skip and all
31 selected checks. Reuse the unchanged independent P2 review inputs.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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