Skip to content

fix(lock): tolerate legacy manager state during exit cleanup - #254

Merged
steipete merged 2 commits into
openclaw:mainfrom
metahacker:fix/legacy-manager-exit-cleanup
Sep 11, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
metahacker:fix/legacy-manager-exit-cleanup

Conversation

@metahacker

@metahacker metahacker commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Mixed package versions share the process-wide sidecar-lock manager registry. Exit cleanup could encounter an older manager without reclaimGuards, throw a TypeError, and leave later managers unprocessed. Treat that missing collection as empty while retaining the existing ownership checks and retainOnExit behavior.

The contributor regression holds real legacy-shaped and modern locks in a child process. Maintainer qualification adds a built-package probe and documents the first-registration-wins limitation: restart with the fixed copy registering the exit handler first. Loading it later does not replace an older handler.

Validation at the maintained head:

  • The built-package probe reproduced the TypeError and surviving modern lock with the original unguarded iteration.
  • node scripts/legacy-lock-exit-proof.mjs passes on macOS and Linux: both eligible locks removed, retained lock preserved, no stderr.
  • All 47 focused process-exit, sidecar-regression, and acquisition-failure tests pass on macOS.
  • Full pnpm check passes on Linux: 8,457 tests, plus build, documentation, boundary, and package checks.
  • Local and branch Codex reviews found no actionable P0–P2 findings.
  • Hosted CI and merged coverage pass at the exact maintained head.

Thanks @metahacker for the original fix and regression. The contributor commit is preserved. Release notes are consolidated in the final notes/dependency PR #257; this PR changes code, tests, documentation, and its repeatable probe only.

Related to openclaw/openclaw#132616. This fixes the library cleanup defect; it does not claim to resolve every consumer shutdown symptom.

@clawsweeper

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

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 6:13 PM ET / 22:13 UTC (Revision 3).

ClawSweeper review

What this changes

The PR prevents legacy shared lock-manager state from interrupting process-exit cleanup, adding regression coverage, a built-package probe, and documentation.

Merge readiness

✅ Ready for maintainer review

The PR remains necessary: current main and v0.8.6 still contain the unguarded iteration. The focused repair has sufficient real filesystem proof and no actionable findings; the earlier proof gap is resolved.

Priority: P2
Reviewed head: 288bb639130286162931c8af9b716fce9335b477

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant real filesystem proof, regression coverage, and no remaining actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Recorded macOS/Linux built-package runs exercise the production file-lock API and exit handler with real sidecars and injected legacy state, showing both eligible locks removed, the retained lock preserved, and no stderr after the fix.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Recorded macOS/Linux built-package runs exercise the production file-lock API and exit handler with real sidecars and injected legacy state, showing both eligible locks removed, the retained lock preserved, and no stderr after the fix.
Evidence reviewed 8 items Current-main defect: Main still iterates state.reclaimGuards without a fallback. State backfill runs only through resolveManagerState, whereas the exit handler traverses all registered managers directly.
Main and release verification: The GitHub main endpoint still returned the pinned base SHA. Inspection of v0.8.6 also found the unguarded iteration, so the requested repair is neither on reviewed main nor in that release.
Introduced change and safety boundary: The complete local diff matches the supplied introduction evidence: a nullish fallback changes only reclaim-guard iteration. Ownership snapshots, retained-lock checks, Root cleanup, exports, dependencies, and workflows remain unchanged.
Findings None None.
Security None None.

How this fits together

fs-safe uses sidecar files to coordinate access to shared files. Its process-exit handler visits shared lock managers and removes eligible owned locks while preserving retained or changed sidecars.

flowchart TD
 A[File lock acquisitions] --> B[Shared manager registry]
 C[Process exit] --> D[Visit every manager]
 B --> D
 D --> E[Check ownership and retention]
 E --> F[Remove eligible raw locks]
 E --> G[Preserve retained or changed locks]
 D --> H[Clean available reclaim guards]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

None.

Technical review

Best possible solution:

Keep the narrow missing-state fallback, existing ownership and retention checks, documented registration order, and coordinated release note.

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

Yes. Current source exposes the failure when exit cleanup encounters a manager without reclaimGuards before another manager; supplied before/after built-package runs corroborate it. This review did not execute the scenario.

Is this the best way to solve the issue?

Yes. Treating the absent collection as empty repairs the direct exit path without duplicating acquisition backfill or replacing globally registered handlers.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This fixes a bounded mixed-version cleanup failure that can leave later managers' lock files behind.
  • 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. Sufficient (terminal): Recorded macOS/Linux built-package runs exercise the production file-lock API and exit handler with real sidecars and injected legacy state, showing both eligible locks removed, the retained lock preserved, and no stderr after the fix.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded macOS/Linux built-package runs exercise the production file-lock API and exit handler with real sidecars and injected legacy state, showing both eligible locks removed, the retained lock preserved, and no stderr after the fix.

Evidence

What I checked:

  • Current-main defect: Main still iterates state.reclaimGuards without a fallback. State backfill runs only through resolveManagerState, whereas the exit handler traverses all registered managers directly. (src/sidecar-lock.ts:115, e8a087715a65)
  • Main and release verification: The GitHub main endpoint still returned the pinned base SHA. Inspection of v0.8.6 also found the unguarded iteration, so the requested repair is neither on reviewed main nor in that release. (src/sidecar-lock.ts:115, 733bc50c81b9)
  • Introduced change and safety boundary: The complete local diff matches the supplied introduction evidence: a nullish fallback changes only reclaim-guard iteration. Ownership snapshots, retained-lock checks, Root cleanup, exports, dependencies, and workflows remain unchanged. (src/sidecar-lock.ts:117, 288bb6391302)
  • Real filesystem proof: The captured proof comment at fix(lock): tolerate legacy manager state during exit cleanup #254 (comment) identifies the exact reviewed head and reports built-library runs on macOS and Linux: the original iteration throws and leaves the later lock; the fix removes both eligible locks, preserves the retained lock, and emits no stderr. The inspected probe invokes createFileLockManager, acquires real temporary sidecars, injects legacy-shaped registry state, and exits the child process. These runs were supplied evidence, not executed during this review. (scripts/legacy-lock-exit-proof.mjs:10, 288bb6391302)
  • Registration limitation is documented: The added documentation explicitly preserves first-registration-wins behavior and explains that the updated copy must register first after restart. Existing tests also cover retaining the older registered handler. (docs/sidecar-lock.md:28, 288bb6391302)
  • Release-note handoff: The supplied discussion assigns release notes to chore: refresh dependencies and consolidate release notes #257. A read-only API check confirms that open PR contains the specific Unreleased cleanup note and contributor credit, and is intended to land afterward; it does not replace this implementation. (CHANGELOG.md, db324f8481d0)

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 (2 earlier review cycles)
  • reviewed 2026-09-11T18:15:33.770Z sha f6c976c :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-11T22:03:09.447Z sha 288bb63 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 11, 2026 21:59
@steipete
steipete requested a review from a team as a code owner September 11, 2026 21:59
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. 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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 11, 2026
@steipete

Copy link
Copy Markdown
Contributor

Maintainer proof for 288bb639130286162931c8af9b716fce9335b477:

  • CI: success.
  • Merged coverage: success on Linux, macOS, and Windows.
  • node scripts/legacy-lock-exit-proof.mjs uses the built library and real temporary sidecars. The original unguarded iteration reproduces the TypeError and leaves the modern lock behind. The fix removes both eligible locks, preserves the retained lock, and produces no stderr on macOS and Linux.
  • macOS focused suites: 47 passed. Full Linux pnpm check: 8,457 passed, with build/docs/package checks successful.
  • Local and branch Codex reviews: clean at P0–P2.

Ready for squash merge. Preserve the original contributor credit; the release note thanking @metahacker is consolidated in #257. Handler ownership remains first-registration-wins, as documented.

@steipete
steipete merged commit 612d50e into openclaw:main Sep 11, 2026
29 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants