Skip to content

refactor(state): remove redundant database forwarding layers - #180928

Merged
steipete merged 5 commits into
mainfrom
dbasync/simpldb-worker
Oct 22, 2026
Merged

steipete merged 5 commits into
mainfrom
dbasync/simpldb-worker

Conversation

@steipete

@steipete steipete commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Database infrastructure retains small forwarding layers that no longer own behavior: an engine observation-scope helper, an audit registration helper, and a module exporting only the retired message_tool_run_outcomes table name.

User Impact

Database behavior is unchanged. This batch removes 23 net production lines (+22/-45), one net test line, and one stale tooling-inventory line. Direct engine commands allocate one fewer adapter object and forwarding closure. Audit registration loses a forwarding call and temporary record object. No wall-clock, CPU, or memory-size improvement is claimed.

Why This Change Was Made

Keep observation at direct engine dispatch; retain the scoped adapter only where scoped operations need it. Keep synchronous warm dispatch, serialize cold inputs before awaiting recovery, preserve receiver binding and close/reopen checks, and never replay uncertain commands.

Call the existing audit writer directly, preserving a fresh writer per invocation and awaited registration. The writer still owns capture, preparation, admission, retention and settlement. The caller now captures context immediately before UUID/time argument evaluation; those synchronous expressions neither await nor change store selection.

Inline the identical retired table literal in the compatibility list and delete its one-line module. Remove its wrapper inventory entry as part of the complete cutover. SQL text and shape, transactions, schema, retention, request counts, effect-authority checks and public SDK surfaces are unchanged. Source provenance: #170138, #165561 and #177694 (Peter Steinberger).

This consolidates #180912 and #180930 into this PR. The wider inventory covered 731 production files / 129,107 lines. The larger candidates retain real migration-freshness, recovery, decoding, import-boundary or released SDK contracts; none justified a larger safe removal. The session-sharing facade removal was withdrawn because it added a modify/delete conflict with #121450. No compatibility implementation is added to meet a deletion quota.

Evidence

  • Work counts: direct observation adapters 1→0; forwarding closures 1→0; observation calls and worker requests 1→1. Audit forwarding calls 1→0 and temporary record objects 1→0. Executed SQL is unchanged, so no frozen SQL pair or timing comparison applies.
  • Schema compatibility: 3 focused suites / 10 tests passed. Audit persistence, rollback, capture and retained-state cleanup: 3 focused files / 21 tests passed. Their source and test blobs are unchanged in this batch.
  • Wrapper inventory correction: all 19 tests in test/scripts/eager-import-closure.test.ts passed on the combined tree. This fixes the six failures in prior refactor(state): inline retired table name in compatibility owner #180912 run 39839214136 / job 120036306698, caused by the stale deleted-file entry.
  • Combined-tree Workboard recovery/lifecycle and database-observation proof: 3 files / 14 tests passed.
  • Changed-file format/type-aware lint passed for the component changes and final combined tree; git diff --check passed. Earlier exact-base scans: Knip production 42→42, all exports 58→58, scripts 0→0, identical findings; Madge 0; T1 170 / compatibility 15; dialect 0/0/6 unchanged. The final batch passed fresh CI static gates, types, and all three PostgreSQL conformance shards. Local types reject the mandated external virtual-store layout before compilation, so CI supplies type proof.
  • Independent Codex component reviews were clean: schema 2 rounds, engine 1, audit 1. The batch combines the published component versions. The engine review was followed by a disclosed lint-only correction using a local captured-command variable; the only new batch hunk deletes the coordinator-requested inventory line. No third schema review was run.
  • Open-PR conflict proof: all 58 overlapping open-main PRs were checked at their live heads against base 2d4e8deab84b80662ab765b84ed30ee9fcd2037d and candidate 160263edb76cfa7bd4a7f346e79d9150d65213c9: no new conflict paths or blocks; all existing conflict blocks are byte-identical. The 12 PRs opened since the shared 2,938-PR census have no overlaps (largest file list: 22, no truncated lists). Results are below.
  • Exact-head coordinator and PostgreSQL reviews approved 160263edb76cfa7bd4a7f346e79d9150d65213c9. Final CI run: 39840444421.
  • CI tests the merge with newer main dfe0396d257 from feat(plugins): keep requester command schedules across Gateway restarts #180844. Its test-selection assertion in test/scripts/ci-changed-node-test-plan.source-owners.test.ts expects commands-plugin.scheduled-turns.test.ts after feat(plugins): keep requester command schedules across Gateway restarts #180844 removed that file's operator-authority import. The exact same assertion fails on main dfe0396d257 (8 selected versus 9 expected), while the six focused owner-selection cases pass on this PR branch. This is an independently reproduced inherited failure; it has been reported for repair on main. All three PostgreSQL shards, type/lint lanes, source/architecture guards, build, and other test jobs passed. CI completed with only this inherited test failure and its aggregate CI-gate failure. Landing uses the campaign's authorized inherited-failure exception; CI is not being described as fully green.
All 58 open-PR conflict comparisons

Each cell shows conflict-file counts before → after. Existing conflict blocks are unchanged throughout.

PR Checked head Conflict files
#180466 aa4b22416d9a 1 → 1
#180286 0794052e2497 0 → 0
#179693 901971131244 0 → 0
#179173 c5ed52da84e5 0 → 0
#178512 f80d0b2916ef 1 → 1
#177812 5cb29d92860b 2 → 2
#177242 c7f91fb698c4 5 → 5
#177141 c9f464482229 11 → 11
#176192 a36e7e15605b 3 → 3
#175328 4191f0a41f93 0 → 0
#174461 996ef1da381d 0 → 0
#173135 6f2c9aa53c7f 3 → 3
#172128 5b0c63ef5ee4 1 → 1
#170852 a257ad3f203b 1 → 1
#170657 c9805a2c3e8f 18 → 18
#170176 37a244b8e046 5 → 5
#170160 ee6003da2db0 71 → 71
#169763 d9c110158fae 1114 → 1114
#169241 6426296c6aef 7 → 7
#169159 05eed6c8d61f 0 → 0
#168211 59322816725f 3 → 3
#167048 780fe85315e3 1 → 1
#166893 4ba4b4a26068 5 → 5
#166488 b4840cdc61d8 6 → 6
#164722 ad401930260e 1 → 1
#164449 f5f5b80877d3 2 → 2
#163964 d5a65a503ac6 559 → 559
#163835 0c500450cbac 16 → 16
#162160 588af7c58287 557 → 557
#162144 5ccbb4ccb1cd 557 → 557
#162132 c978efa59f1c 557 → 557
#162126 e48a73e79cb2 557 → 557
#161840 5dc7ae267968 1 → 1
#161344 c243b9d29741 561 → 561
#157679 5120627c92e0 18 → 18
#157197 1a17560c4036 12 → 12
#156924 fc5d1d5c8370 9 → 9
#156420 a830cba1008f 9 → 9
#155106 8dae34392c93 7 → 7
#154268 19efa787800f 2 → 2
#152205 24ff19f9bda8 582 → 582
#151441 e6ac94f213a2 562 → 562
#150381 0be3595ed005 0 → 0
#150348 25d08f67e969 3 → 3
#150246 4a94ab9dd156 559 → 559
#149882 aca8f05544e2 85 → 85
#148581 bb721c82a7d0 560 → 560
#147932 8d72643069ba 3 → 3
#146076 2baa28783b9e 0 → 0
#144043 29a80bdda6f9 21 → 21
#137014 9d9481f94763 279 → 279
#129388 f4675cff003d 232 → 232
#126932 bc14687f6bb4 6 → 6
#126255 d6a05a0b86b0 7 → 7
#123837 d3c9ca87eb7c 6 → 6
#120138 6b42e60d4e27 20 → 20
#101866 2b72aeba123d 0 → 0
#82950 c3bb06c1a1ef 1 → 1

@clawsweeper

clawsweeper Bot commented Oct 22, 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.

@steipete
steipete marked this pull request as ready for review October 22, 2026 19:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T19:31:38.167993Z 160263e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete steipete changed the title refactor(state): observe direct worker dispatch without a scope wrapper refactor(state): remove redundant database forwarding layers Oct 22, 2026
@steipete
steipete merged commit 0730e41 into main Oct 22, 2026
148 of 154 checks passed
@steipete
steipete deleted the dbasync/simpldb-worker branch October 22, 2026 19:51
@clawsweeper

clawsweeper Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR removes redundant database observation and audit forwarding layers and inlines a retired table name in its compatibility owner.

Example: Persist a system-agent audit entry for config.setDefaultModel.

  • Before: The caller constructs a temporary record and forwards it through registerSqliteAuditRecordAsync.
  • After: The caller directly awaits a fresh audit writer’s register method, preserving the stored record and retention behavior.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-verifiable, with useful existing in-process validation but no supplied demonstration through a shipped entry point.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored refactor is outside the ordinary contributor proof gate; its body reports existing production-path worker suites passing, while the inspected prepared images concern unrelated continuation features and establish no database behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: No user-visible defect is claimed; redundant internal forwarding adds maintenance and allocation overhead.
Reason: The maintainer-authored direction follows the repository’s single-owner guidance and removes indirection without changing supported behavior.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: the cleanup preserves existing database contracts, and no actionable patch defect was found; exact-head CI remains unresolved.

Priority: P3
Reviewed head: 160263edb76cfa7bd4a7f346e79d9150d65213c9

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped-entry-point demonstration of the combined refactor is supplied; reported validation exercises existing worker, persistence, lifecycle, and schema suites.
Agent review details

How this fits together

Database callers submit commands and audit records through engine and shared-state worker owners, which retain admission, recovery, transaction settlement, and persistence responsibilities.

flowchart LR
  A[Database callers] --> B[Engine worker store]
  B --> C[Request observation]
  C --> D[Worker broker]
  E[System agent audit] --> F[Existing audit writer]
  F --> D
  D --> G[Selected database]
Loading

Technical review

Best possible solution:

Retain this focused cleanup with recovery, admission, persistence, and compatibility decisions in their existing owners.

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

There is no reported runtime bug to reproduce; source comparison verifies redundant forwarding and unchanged values without executing target code.

Is this the best way to solve the issue?

This is the smallest complete cleanup: use the existing writer directly, observe direct dispatch without an adapter, retain the necessary scoped adapter, and remove the obsolete module and inventory entry.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9d97e10 adds src/system-agent/audit.ts:40 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9d97e10efe08; files: src/system-agent/audit.ts)

PR surface

Source -23, Tests -1, Other -1. Total -25 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 22 45 -23
Tests 2 6 7 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 8 28 53 -25

Review metrics

Metric Value Why it matters
Production versus test changes Production +22/-45; tests +6/-7 The reduction removes forwarding machinery without introducing state, new owners, or additional test scaffolding.

Root-cause cluster

Relationship: canonical
Canonical: #180928
Summary: This PR consolidates the two closed component PRs, whose bodies explicitly identify it as their successor.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P3: This is focused internal cleanup with unchanged user-visible behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is focused internal cleanup with unchanged user-visible behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 22, 2026, 3:51 PM ET / 19:51 UTC.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
…w#180928)

Remove redundant observation and audit forwarding paths and the obsolete message-tool-outcome schema module. Preserve synchronous warm dispatch, cold input capture before recovery, receiver binding, no-replay behavior, and the existing audit writer ownership. SQL, transactions, schemas, request counts, public SDK surfaces and effect-authority checks are unchanged.

Production +22/-45 (net -23); total net -25. Direct commands allocate one fewer adapter and forwarding closure; no timing claim.

Validation: focused schema, audit, Workboard/observation and wrapper-inventory tests; type-aware lint, types, source/architecture guards, Knip/Madge and database ratchets. All three exact-head PostgreSQL conformance shards passed. The CI owner-selection assertion introduced on newer main by openclaw#180844 reproduces identically on main d41e3f8; recorded for main repair. Independent component reviews and exact-head coordinator/PostgreSQL review approved the change.

Source provenance: openclaw#170138, openclaw#165561 and openclaw#177694 (Peter Steinberger).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant