Skip to content

perf: separate async audit worker imports - #150107

Merged
steipete merged 1 commit into
mainfrom
codex/audit-worker-import-boundary
Sep 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/audit-worker-import-boundary

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Synchronous audit-store consumers pull in the asynchronous host-worker machinery. The shared SQLite backend reaches that dependency through cron quarantine, even though it only needs connection-bound store operations.

User Impact

Synchronous consumers avoid the host-worker import graph. Configuration audit writes keep the same async registration function, payload capture, maintenance admission, authority checks and transaction behavior.

Why This Change Was Made

Move the existing async registration function unchanged into its own module and update its one production caller and two test imports. Keep the synchronous store and shared kernel unchanged. This separates the existing host and worker responsibilities without a new execution path, delayed import, cache, pool policy, schema or persistent representation.

The function body is byte-identical. Its internal path has no package or SDK export; a compatibility re-export would restore the eager dependency. Production growth is three import-boundary lines after accounting for the move; test imports shrink by four lines. No assertions or test bodies change.

Evidence

All 222 existing config-write cases pass with identical identities, outcomes and order. Another 90 existing audit-store, cron-store and agent-exec cleanup cases pass, including pruning rollback, sibling scopes, payload capture before yielding, quarantine timestamp/idempotence and cleanup before state removal.

During a real writer run, an external observer hash-verified the canonical compiled generation's static emitted imports. The shared backend and transport closure shrinks from 211 files / 2,390,980 bytes to 207 files / 2,334,984 bytes, with the host-owner chunk absent. Bare and dynamic imports were not traversed; this is static closure evidence, not a complete evaluated-module census.

The same-base Node 24.21 diagnostic pair completed all 162 worker lifetimes, with no failed or unmatched replies. Accumulated open-to-reply intervals were 48.58s before and 47.84s after; median 310.0ms and 303.4ms. That is a small single-pair observation. Instrumented wrapper time was 161.22s and 153.84s, but preparation and host variation prevent attributing the entire difference to this change. No aggregate CI saving is claimed.

Independent P0-P2 review and the full changed-file gate passed against the actual branch base. The full pnpm build passed, including declarations and built-plugin validation.

@steipete steipete self-assigned this Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 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 commands Command implementations size: S maintainer Maintainer-authored PR labels Sep 16, 2026
@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 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

Separates asynchronous audit writes into their own module so synchronous SQLite consumers avoid importing host-worker machinery.

Merge readiness

✅ Ready for maintainer review

This remains a useful, narrowly scoped optimization absent from current main. No actionable correctness or security defect was found; the protected maintainer PR should continue through normal merge gates.

Priority: P3
Reviewed head: 6532de76e33d9e9e13e76f0a5328282f00aaa26c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving module split with complete caller migration and relevant reported validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal refactor is exempt from contributor proof requirements and does not materially change authority. Its body supplies relevant writer-run and static-import observations, with timing limitations explicitly stated.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal refactor is exempt from contributor proof requirements and does not materially change authority. Its body supplies relevant writer-run and static-import observations, with timing limitations explicitly stated.
Evidence reviewed 8 items Introduced change preserves execution: The merge-base comparison moves the registration function unchanged, including serialization before yielding, context capture, and assertCurrent forwarding. The synchronous store loses only the worker imports and moved function.
Complete caller migration: Repository-wide search found one production caller and two test callers, all migrated. Remaining consumers use the unchanged synchronous factory; the Docker harness entry also consumes that factory. No package or SDK export of the moved function was found.
Storage and authority contracts remain intact: Configuration audit append still sanitizes records and forwards its current-authority guard. The worker still registers through the same kernel inside the existing write transaction; no schema, retention, permission, or durable representation changes occur.
Findings None None.
Security None None.

How this fits together

OpenClaw stores configuration diagnostics and cron recovery records in shared SQLite storage. Configuration audit writes use the shared worker, while synchronous consumers use connection-bound operations.

flowchart LR
  A[Configuration diagnostics] --> B[Async audit module]
  B --> C[Shared state worker]
  D[Cron recovery records] --> E[Synchronous audit store]
  C --> F[Shared audit kernel]
  E --> F
  F --> G[SQLite diagnostic records]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests -4. Total -1 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 31 28 +3
Tests 2 4 8 -4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 35 36 -1

Review metrics

None.

Technical review

Best possible solution:

Keep synchronous audit storage independent of host-worker imports while preserving the existing async writer and shared transaction kernel.

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

Not applicable as a functional bug report; current-main source confirms the unwanted static dependency, while runtime timing was not independently reproduced.

Is this the best way to solve the issue?

Yes. Moving the unchanged internal function and all callers removes the dependency edge without duplicating persistence logic or retaining a re-export that would restore it.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a low-risk internal import optimization with unchanged user-facing behavior.
  • 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 maintainer-authored internal refactor is exempt from contributor proof requirements and does not materially change authority. Its body supplies relevant writer-run and static-import observations, with timing limitations explicitly stated.

Evidence

What I checked:

  • Introduced change preserves execution: The merge-base comparison moves the registration function unchanged, including serialization before yielding, context capture, and assertCurrent forwarding. The synchronous store loses only the worker imports and moved function. (src/infra/sqlite-audit-record-store.async.ts:10, 6532de76e33d)
  • Complete caller migration: Repository-wide search found one production caller and two test callers, all migrated. Remaining consumers use the unchanged synchronous factory; the Docker harness entry also consumes that factory. No package or SDK export of the moved function was found. (src/config/io.audit.ts:683, 6532de76e33d)
  • Storage and authority contracts remain intact: Configuration audit append still sanitizes records and forwards its current-authority guard. The worker still registers through the same kernel inside the existing write transaction; no schema, retention, permission, or durable representation changes occur. (src/state/openclaw-state.worker.ts:414, 6532de76e33d)
  • Current main still has the dependency: Fetched main retains both worker imports and the async registration function in the synchronous store module, so the proposed separation remains distinct work. (src/infra/sqlite-audit-record-store.ts:8, afb631bf9efd)
  • Latest-release boundary: The v2026.9.4 source exports the synchronous store and sequence type but has no async registration function or worker import. This PR separates newer main-branch machinery rather than removing a released async export. (src/infra/sqlite-audit-record-store.ts:114, 3a9d69db306c)
  • Existing regression coverage retained: Both changed test files were read fully. Their assertions and scenarios remain unchanged, covering atomic pruning rollback, sibling-scope isolation, payload capture before yielding, and database cleanup before state removal. Tests were not executed during this read-only review. (src/infra/sqlite-audit-record-store.test.ts:28, 6532de76e33d)

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.

@steipete
steipete merged commit a58755e into main Sep 16, 2026
197 checks passed
@steipete
steipete deleted the codex/audit-worker-import-boundary branch September 16, 2026 15:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations 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: S 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