Repository navigation
Conversation
Record the retirement reason before terminating a store worker and log an unrequested departure once with its cause, so worker lifecycle counters and gateway logs say why a SQLite worker left instead of blaming a plain exit. Closes openclaw#163150
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR attributes requested SQLite worker retirements and logs unexpected departures once with a redacted cause. Example: A SQLite storage worker throws Error("sqlite carrier lost").
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR: current main retains the reported diagnostics gap, and the focused patch introduces no concrete correctness defect; GitHub reports a merge conflict. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe SQLite broker lifecycle owns storage-worker creation and retirement, forwarding native events to failure settlement and publishing diagnostics through the existing worker registry and logger. flowchart LR
A[SQLite broker] --> B[Worker lifecycle]
B --> C[Native storage worker]
C --> D[Error and exit events]
D --> B
B --> E[Lifecycle counters]
B --> F[Redacted warning log]
B --> G[Failure settlement]
Technical reviewBest possible solution: Retain the focused diagnostic change in the existing lifecycle owner while preserving current-main admission, custody, and failure-settlement behavior. Do we have a high-confidence way to reproduce the issue? Current-main lifecycle, registry, and failure-settlement source show why requested exits remain unattributed and unexpected departures lack a dedicated warning; no target code was executed. Is this the best way to solve the issue? The patch uses the existing retirement registry and redacting logger at the lifecycle owner, with meaningful native-worker regression coverage and no competing policy owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 41932f3e5cb4. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +25, Tests +116, Other -1. Total +140 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (7 earlier review cycles)
Reviewed November 5, 2026, 4:59 PM ET / 21:59 UTC (Revision 8). |
The broker-lifecycle suite mocks ./worker-cpu.js through importOriginal, so its closed-factory baseline entry is orphaned and the ratchet only shrinks.
|
Independent exact-head qualification for Module-only pre-fix control: six intended diagnostic assertion failures. Candidate: 42 passing tests across six suites, including four real Linux Node24 Worker cases (normal retirement, caller-requested failure, unexpected exit0 and uncaught error). Every case released its native thread and slot, with registry occupancy back to baseline. Unrequested departures produced one redacted warning; a synthetic bearer canary was absent from the retained logs. Thirty surrounding owner/policy file hashes stayed unchanged. Supported secretless Crabbox Independent AutoReview completed scoped-clean for all three selected files at P0–P2. The +25 production lines implement the missing diagnostic owner witness with the existing registry/logger; termination, custody, admission, failure settlement, slots, storage and redaction policies stay unchanged. Unexpected exit0 retains the existing Fresh GitHub now reports a test-file merge conflict at the same head. This is not a ready-to-merge claim: native preparation and resulting exact-head gates still need to complete. No merge or deployment performed. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Main added an opener-authority table to this test file and a request diagnostics field to the broker job type, so the base sync keeps both sides: - imports are the union of the upstream admission helpers and the retirement registry symbols this PR reads - the ./worker-cpu.js factory stays the spread-preserving one, which is why the baseline entry for it is removed and ./bun-sqlite-library.js remains - sqlite-worker-broker-lifecycle.ts is unchanged on main, so this PRs departure reporting applies as authored
…: 163377 reds were main-side)
Closes #163150
What Problem This Solves
Fixes: when a SQLite store worker thread disappears, the worker lifecycle counters call it an
unattributed
exitand the Gateway log says nothing, so an operator cannot tell a crash from aretirement the broker asked for.
User Impact
User impact: a retirement the broker requested now shows its own reason (
closed, orfailurewhen the slot had already failed) in the stability bundle's
workerLifecycle, and a worker thatleaves without any request writes exactly one warning line naming its cause to the log file, so a
lost storage worker is diagnosable from the bundle and the log instead of only from a repro.
Why This Change Was Made
The lifecycle registry takes the retirement reason from whatever the worker's owner recorded
before native exit; without that record it falls back to
exit, whichdocs/gateway/prometheus.mdalready defines as "an owner did not specify a reason". The task-poolowners do record it, the SQLite store worker owner never did, so every one of its retirements
landed in the fallback. Reasons are now recorded where this owner asks the worker to leave, and on
the
error/messageerrorevents that precede native exit. A departure that no one requested hasno other witness, so it is logged once at warn; requested retirements stay silent because their
caller already reports the outcome. Nothing in the broker's failure path changed, and the log line
carries only the redacted error text.
Evidence
Failing test first, then the fix, on
src/infra/sqlite-worker-broker-lifecycle.test.ts:After the change the same two tests pass, and they check both halves of the symptom against the
real registry and the real log-file transport: a retirement the owner asked for adds a
closedcount and leaves
exitunchanged, and a worker that throws on its own adds afailurecount whilethe log file holds one
left without a retirement requestline containing the cause text.Adjacent lanes, run locally with the same config:
Local gates:
oxfmt --checkclean on both files (28ms),run-oxlint.mjson the core tsconfigreported "Found 0 warnings and 0 errors" (68.1s),
git diff --checkclean, andcheck-line-cap-ratchet.mtsreported "Line-cap ratchet OK: 2 changed source files; no newviolations or over-cap growth".
check-changed.mjs --dry-runlisted the CI gates this diffselects. Pre-commit hooks ran normally; no hook was skipped.
Cost of the new tests, per the repo validation rules: they add 87ms and 178ms inside a file whose
targeted run takes 26s with a warm transform cache and 212s cold on this machine. Neither test
sleeps, polls, or uses a wall-clock timer; they await the worker
onlineevent, the slot's ownexit promise, and
flushLogger().Gaps worth naming: the run was Windows, where the six pre-existing cases in this test file already
fail at
fileURLToPath("file:///openclaw/...")withERR_INVALID_FILE_URL_PATHbefore thischange and in code this diff does not touch, so those cases are covered here by CI's Linux infra
lane; the two new tests derive their carrier URL from
import.meta.urlso they run on bothplatforms.
pnpm tsgo:corerefuses a worktree that shares its install with the main checkout("Declaration input escapes checkout"), so the typecheck gate was not run locally and is left to
CI. No live Gateway was started on this machine; the log-line half is proven by reading the file
the file transport actually wrote.
CI on head
e129273e8(server-recorded basedbb580aed, which is 171 commits behind currentmain): 129 check runs = 67 success / 59 skipped / 1 neutral (CodeQL) / 2 failure. The two failures arechecks-windows-node-test-5(completed 2026-10-02T08:19:37Z) and the 2 s aggregateopenclaw/ci-gatethat follows it in the same run. The failing case istest/scripts/write-unified-entry-dts.test.ts > write-unified-entry-dts > reuses unaffected canonical groups while rebuilding runtime after input edits, and it throwsERR_PACKAGE_PATH_NOT_EXPORTED: Package subpath './record-coerce' is not defined by "exports"from apackage.jsoninside that test's own temporary fixture project (%TEMP%\oc-vt-8AAiWh\openclaw-sdk-declarations-5DFbNf\Project\node_modules\@openclaw\normalization-core), imported fromsrc/process/exec-result.tsin the same temp tree. This diff is two files, bothsrc/infra/sqlite-worker-broker-lifecycle.*: it touches none oftest/scripts/,packages/normalization-core/, orsrc/process/, andpackages/normalization-core/package.jsonon this head does export./record-coerce.What is deliberately not claimed here: inheritance is not proven. That node-id was re-run in a clean detached worktree checked out at this PR's base commit
dbb580aed, and it fails there too - but with a different, Windows-only error while the fixture links its compiler (EPERM: operation not permitted, symlink '..\typescript\bin\tsc' -> '...\Project\node_modules\.bin\tsgo'), so this machine's harness cannot exercise that fixture path and no local verdict about the CI error is available. For reference, the samechecks-windows-node-test-5check completed withsuccessat 2026-10-02T15:23:03Z on unrelated head5ce2d2d6(#163594). No rerun, re-push, or rebase was dispatched to chase a green signal, per the repository's validation rules; naming this failure is offered so a maintainer can weigh it against the two lanes this change actually touches.