Skip to content

refactor(sqlite): keep default reporting out of heartbeat startup - #155106

Draft
vincentkoc wants to merge 4 commits into
mainfrom
fix/sqlite-transaction-logger-boundary
Draft

vincentkoc wants to merge 4 commits into
mainfrom
fix/sqlite-transaction-logger-boundary

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Related: #149882

What Problem This Solves

Heartbeat worker startup imports the ordinary SQLite transaction reporter even though the worker supplies a no-op reporter. This unnecessarily loads default subsystem logging and its initialization.

User Impact

The heartbeat worker no longer imports default transaction reporting. Normal SQLite callers retain the default logger, custom warning sinks, and existing transaction behavior. The change does not alter SDK signatures, configuration, schemas, deadlines, readiness, leases, or filesystem security. It does not establish the cause of the historical FreeBSD startup timeout.

Why This Change Was Made

Keep one synchronous transaction engine and admission registry in an internal logger-independent owner. The ordinary module retains its public immediate/deferred functions and asynchronous preparation/admission flow. The heartbeat passes its existing no-op reporter; the coordinator uses the same core registry.

Savepoints, abandoned-handle fencing, commit authority, rollback, cache invalidation, warning thresholds and metadata remain intact. The transaction callback guard, raw-SQL owner allowlist, and review wrapper materialization follow the moved owner. Production: +453/-432 (net +21); tests: +297/-3; tooling: +4/-1. The added production lines express reporter ownership and retain the public wrappers around one engine.

Evidence

Current source: 8dae34392c93066d965ada4a6e99f681eac7e4e7, tree 06859a897518aafb3bc68a1dd7f4d24786a76e17, integrating frozen main a7c27c04a3d6e797b8974ad6ee22724724918e8a. All 14 own postimages match the reviewed preceding head 7fcce84f633432e3ffee6936c13aa7ec56ac3a38; the main-relative patch remains exactly 51,866 bytes / SHA-256 ee4d1f70f26e71a5cadc5a299d517cc3afdc7c9b74e15b175ab730343446fcc0. Independent source and integration reviews plus fresh scoped autoreview found no actionable P0–P2 finding.

The preceding head’s ordinary CI passed 133 jobs and skipped 16; one Gateway shard and its aggregate failed. The obsolete export, native-method lint annotation, and moved diagnostics mock had already passed their repaired gates, including all seven diagnostics cases. The remaining private approval fixture used a one-second readiness poll and left a request unjoined after that assertion failed. Canonical PR #155111 now fixes the publication/cleanup owner; this integration includes that landed repair. The original worker delay remains unmeasured. The refreshed exact-head CI 35651382158, attempt 1 succeeded at 8dae34392c93066d965ada4a6e99f681eac7e4e7: 135 successful jobs and 16 skipped, aggregate 106511459962 passed. The actual seven heartbeat diagnostics, 15 private approval cases and six canonical approval-fixture cases passed, including the original private case and late outer-handler join/DB cleanup. The old failed attempt remains failure evidence.

The integration also inherits main’s fs-safe 0.18 upgrade. Its public seams were reviewed, but its internal copy, Root, hashing, and cancellation changes require fresh package proof. The completed fs-safe 0.17 proof below remains component evidence; it does not qualify this entire new head.

Completed component proof

Paired package proof, attempt 1 / carrier 5889eadd38e98d3d2640969a793b266a56115e39, passed on Linux/Node 24.21.0. It compared composed baseline 17690d0019bb92ee80e8ceaaced8cad822e1159d with candidate 67214ac792717ee72cee7a4ae32b678ff12663fd (tree 288acf94e1a51397afd87462bf7083fe957d82ef), whose difference is the exact same 14-path patch.

  • Actual emitted worker: default transaction logger calls 1→0; file-transport process hooks 2→0; chalk/tslog and default reporter regions removed. Required fs-safe 0.17 import inventory, semver, redaction and storage guards remain.
  • All 18 selected transaction/coordinator/handoff/heartbeat/lifecycle/guard files passed: 236 tests, zero skipped. Kysely, synchronous callback, and SDK surface guards passed.
  • Sealed candidate: 81,970,414 bytes / SHA-256 8dd31bac12fdb2365d64fca537d0224cef39a2287ffd785ee8d245e71a590f96; emitted heartbeat SHA-256 9bd8168f496f56afd825caa7db4164525b2ed89935405209e7d5b4279dd97968.

Measured Vitest costs from that composed proof:

Scope Tests Reported duration
New transaction core file 5 115 ms
New reporting file 3 66 ms
Changed handoff recovery file 10 185 ms
Changed heartbeat diagnostics file 7 288 ms
Changed lifecycle registry file 1 44 ms
Changed transaction callback guard file 6 13 ms
New heartbeat import-boundary case 1 499 ms

These are printed file/case durations, not isolated command wall times or marginal suite costs. The full eager-import file took 26.302 s; the 18-file invocation took 121.52 s. Individual new handoff-case times were not printed.

The raw success receipt and complete leading artifact records were authenticated. The single local ZIP download timed out partially; the full outer ZIP, candidate payload, manifest and source archive are not claimed as locally verified. The artifact’s published digest and seal are retained for strict consumer verification; no duplicate download or package resealing was performed.

Remaining qualification

Exact-head ordinary CI is green. The completed S4 ClawSweeper review artifact binds 8dae34392c93066d965ada4a6e99f681eac7e4e7 and reports no source/security findings. Its public review delivery is still pending in the canonical publication queue. Its remaining proof requests are final fs-safe 0.18 package/emitted-worker plus Linux/FreeBSD operator qualification, and independent per-file test command wall times. Earlier file/case durations above do not satisfy the latter request.

The first B4 producer, attempt 1 at 8a7b543c3a7ce59fe13535261b981f599dee9e16, passed package/build and emitted-worker checks on composed source 10725d8613c64f5efdc8ea58eae70a3b8f4276ac/tree 74bddc0882c455c519931e40040c260df9951ee8. It then failed during report initialization: the canonical multi-invocation collector requires file-based projects, while Gateway loads inline project leaves. Six earlier files passed 77 assertions; remaining tests, guards and sealing did not complete. No candidate payload was uploaded. This is a harness reporting failure, not evidence of a product assertion failure.

The corrected producer 35654738554, attempt 1 succeeded at carrier 1c4bcfef50d09cf73837bfaa1bfccf8fa856d907, on unchanged B4. Its exact 14 common-owner blobs are identical to this standalone S4 head; the producer verified the actual S4 commit/tree/blobs before execution. Actual fs-safe 0.18 and selected Linux native-package content were recorded. Packaged heartbeat: 633,226 bytes/SHA-256 9bd8168f496f56afd825caa7db4164525b2ed89935405209e7d5b4279dd97968, with default logger/chalk/tslog/file hooks absent and required storage/redaction/ten fs-safe import specifiers retained. All 20 files passed: 263 assertions, zero skips/pending/todo, followed by all three guards and canonical sealing. Separate native reports bind 19 files/242 cases in 87.460 s and the gateway file/21 cases in 4.839 s; combined span 92.300 s. These group command spans do not replace independent per-file costs.

Final candidate: 81,917,057 bytes/SHA-256 0071fb86846a29276643133b0ad2958a310f7ee599e204578839655844161cc6; artifact 10665090678, 245,792,513 bytes/API SHA-256 85c73717fceb8c599a8ad032b7adb7e4f7fe4a1c6e1ce879b1ed2b06231c08cd. Complete raw receipt: 371,150 bytes/SHA-256 38c5278a36727264266884b9e608e4f157e1badf61ad62fe8a9eaf47c9480c30. No full ZIP was downloaded locally. Consumer custody checks must authenticate the full archive, manifest, source archive and every member before package execution. This is current fs-safe 0.18 composed-candidate evidence for the matching owner change, not packaged proof of every standalone S4 byte or physical ARM.

Operator run 35657209609, attempt 1 is admitted at signed consumer f2a39ae720878fa77bc27356f7c6c1343ab4025c; it consumes only that sealed B4 artifact. Linux source controls run before seven independent pnpm test <file> --maxWorkers=1 commands after the normal source prerequisite. Actual command wall times/results are recorded before restoring the sealed candidate runtime. Installed Linux/service controls and FreeBSD x64/emulated ARM operator results remain pending. Final consumer review corrected an inherited pre-Doctor bootstrap agents list call; Doctor is now the first candidate OpenClaw CLI against published state, while normal npm postinstall remains unchanged and bootstrap preservation is checked after Doctor/update. Earlier native receipts are not relabeled as Doctor-first proof.

The old fs-safe 0.17 operator workflow was held before publication, so no superseded native run was launched. No repeated baseline ARM, deadline increase or historical timeout-cure claim is part of this change. The exact S4 completed Claw report is authenticated; its canonical public delivery remains queued. Final operator receipts and seven command wall times will disposition its remaining moves before native landing.

@vincentkoc vincentkoc self-assigned this Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 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 scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Sep 21, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 21, 2026 19:13
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head f25f259ae549879a7fba2b274db45c9bfb2d0449. The confirmed unused internal accessor forwarding export is removed and the existing lifecycle test imports its canonical core owner; assertions and SDK exports are unchanged. The identical correction is sealed in the composed candidate. Runtime/package proof remains pending as described in the body; the superseded paired build was cancelled and is not a pass.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 7fcce84f633432e3ffee6936c13aa7ec56ac3a38. The previous exact-head review artifact found no source issue; ordinary CI then identified two fixture corrections. This head adds the scoped native-method capture annotation while preserving exec.call(this, sql), and retargets the existing heartbeat diagnostic pass-through mock to the moved core engine. All assertions, fake timers, renewal failures, real SQL calls, and cleanup remain unchanged. The dependency gate already passed; final-head CI and the reviewed paired package/runtime proof run separately, with their exact source scope and new-test cost still to be reported in the body.

@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 6, 2026, 9:09 PM ET / October 7, 2026, 01:09 UTC (Revision 5).

ClawSweeper review

What this changes

Separates SQLite’s synchronous transaction engine from default logging so the lease heartbeat worker can use an explicit reporter without loading ordinary reporting.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this maintainer-owned PR parked as requested. Current main still loads ordinary transaction reporting in the heartbeat worker, so the extraction is not demonstrably implemented or superseded. No concrete introduced correctness defect was found.

Likely related people: vincentkoc and steipete (medium-confidence routing candidates).

Priority: P3
Reviewed head: 8dae34392c93066d965ada4a6e99f681eac7e4e7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The pinned extraction is coherent and has useful component validation; draft status and deliberate deferral do not lower patch quality.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Recorded emitted-worker comparisons support reporting isolation, while installed operator qualification remains unclaimed; no stored-data format or material authority change is introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Recorded emitted-worker comparisons support reporting isolation, while installed operator qualification remains unclaimed; no stored-data format or material authority change is introduced.
Evidence reviewed 8 items Introduced ownership boundary: The pinned introduced delta moves the existing synchronous engine and admission registry into one internal core module. Ordinary wrappers supply their existing default reporter; heartbeat and coordinator consume the same core. Commit guards, savepoints, and terminal-handle fencing remain in that engine.
Current main still has the reporting import: The current-main heartbeat imports the ordinary transaction module, which eagerly creates its subsystem logger. The proposed core module is absent from that main tree; newer transaction behavior includes schema-fact admission, phase diagnostics, and rollback-observer cleanup.
Latest-release boundary: The v2026.9.8 heartbeat source also imports the ordinary transaction module. This does not establish that the extraction shipped.
Findings None None.
Security None None.

How this fits together

The state-lease heartbeat worker renews database ownership leases used by OpenClaw maintenance operations. Its SQLite transaction helper controls admission, commit, rollback, and warning delivery.

flowchart TD
  A[Maintenance lease owner] --> B[Heartbeat worker]
  B --> C[Explicit silent reporter]
  B --> D[Shared transaction engine]
  E[Ordinary database callers] --> F[Default reporting wrapper]
  F --> D
  D --> G[Lease renewal or rollback]
Loading

Before merge

  • Resolve merge risk (P1) - The conflicting head has no reviewed reconciliation with current-main schema-fact admission, rollback cleanup, transaction diagnostics, and heartbeat lifecycle behavior.
  • Complete next step (P2) - Before any revival proceeds to merge, reconcile the conflicting head with current main and complete the applicable prior test-cost and installed-worker evidence requests.
Agent review details

Security

None.

PR surface

Source +21, Tests +294, Other +3. Total +318 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 4 452 431 +21
Tests 7 297 3 +294
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 4 1 +3
Total 14 753 435 +318

Review metrics

Metric Value Why it matters
Owner extraction growth production net +21; tests net +294; tooling net +3 The small production growth has an explicit reporter-ownership justification; the added tests still need the required command-cost measurements.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Preserve the deferral; any revived logging isolation should use one current transaction owner and retain current admission, cleanup, and diagnostic contracts.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Preserve the deferral; any revived logging isolation should use one current transaction owner and retain current admission, cleanup, and diagnostic contracts.

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

Not applicable to this refactor: source confirms the unwanted reporting import, but no runtime timeout cause or repair was reproduced.

Is this the best way to solve the issue?

Yes for the pinned base: one shared engine with caller-owned reporting is coherent. Its suitability for current main requires reconciliation with the newer owner contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 availability: Current PR review selected no merge-risk labels.

Label justifications:

  • P3: This is a deferred import-boundary refactor with no established user-facing timeout repair.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 member-authored PR is exempt from the external-contributor proof gate. Recorded emitted-worker comparisons support reporting isolation, while installed operator qualification remains unclaimed; no stored-data format or material authority change is introduced.

Evidence

What I checked:

  • Introduced ownership boundary: The pinned introduced delta moves the existing synchronous engine and admission registry into one internal core module. Ordinary wrappers supply their existing default reporter; heartbeat and coordinator consume the same core. Commit guards, savepoints, and terminal-handle fencing remain in that engine. (src/infra/sqlite-transaction-core.ts:367, 8dae34392c93)
  • Current main still has the reporting import: The current-main heartbeat imports the ordinary transaction module, which eagerly creates its subsystem logger. The proposed core module is absent from that main tree; newer transaction behavior includes schema-fact admission, phase diagnostics, and rollback-observer cleanup. (src/state/openclaw-state-lease-heartbeat.worker.ts:10, 7b66485dcd9b)
  • Latest-release boundary: The v2026.9.8 heartbeat source also imports the ordinary transaction module. This does not establish that the extraction shipped. (src/state/openclaw-state-lease-heartbeat.worker.ts:10, fc23bc864e45)
  • Explicit deferral: The September 24 member comment explicitly parks the extraction and excludes it from the FreeBSD campaign: refactor(sqlite): keep default reporting out of heartbeat startup #155106 (comment). It allows separate consideration of warning isolation without declaring this extraction fixed or approved. (8dae34392c93)
  • Live branch state: GitHub confirms the pinned head remains open, draft, assigned to vincentkoc, and conflicting. No pinned test merge is available, so current-main differences are reconciliation requirements rather than proven merge regressions. (8dae34392c93)
  • Proof and review continuity: The captured body records paired emitted-worker comparisons removing default logging and a later fs-safe 0.18 composed package with identical changed-owner blobs. These remain component evidence; installed operator qualification and independent test-command wall times are not completed in the captured body. The previous completed review had no findings, and its reconciliation request remains applicable if revived. The broader FreeBSD campaign is expressly deferred. (8dae34392c93)

Likely related people:

  • vincentkoc: 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)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • If revived, reconcile the extraction with current-main transaction and heartbeat contracts and review that resulting patch.
  • Publish the seven independent test-command wall times and disposition the previously requested installed-worker evidence within the revived scope.

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 (4 earlier review cycles)
  • reviewed 2026-09-21T19:56:35.154Z sha 7fcce84 :: needs changes before merge. :: none
  • reviewed 2026-09-21T21:14:02.750Z sha 8dae343 :: needs changes before merge. :: none
  • reviewed 2026-09-21T21:37:53.911Z sha 8dae343 :: needs changes before merge. :: none
  • reviewed 2026-09-24T07:59:39.896Z sha 8dae343 :: blocked before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 8dae34392c93066d965ada4a6e99f681eac7e4e7. This signed integration of frozen main retains the identical 14-path transaction/logger patch and incorporates the canonical approval-fixture repair from #155111 plus main’s fs-safe 0.18 inputs. The body records the successful paired emitted-worker comparison, 18-file/236-case focused proof, and measured new-test costs on the earlier composed fs-safe 0.17 candidate, explicitly as component evidence. Fresh exact-head CI and a final fs-safe 0.18 composed package with Linux/FreeBSD operator qualification remain pending; the previous package is not being relabeled as this head’s whole-package proof.

@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@vincentkoc

Copy link
Copy Markdown
Member Author

Scope reset: parking this transaction-engine extraction as a draft at 8dae343. The branch is preserved, but the engine split is deferred and will not be landed through the FreeBSD campaign.

A still-needed warning-isolation fix may be considered separately in the existing owner, after checking current main. That does not imply this broader extraction is fixed, merged, or approved.

This branch has not been deployed

No deployments
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. scripts Repository scripts size: XL 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