Skip to content

refactor(state): reduce SQLite duplication and test-only seams - #167533

Merged
steipete merged 3 commits into
mainfrom
dbasync/dslstate-1
Oct 9, 2026
Merged

steipete merged 3 commits into
mainfrom
dbasync/dslstate-1

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

SQLite schema tracking duplicated mutation bookkeeping, while incognito tests kept an otherwise unused production diagnostic command and execution facade alive.

User Impact

No user-visible behavior change. Authority, foreign-commit freshness, FIFO ordering, accepted-work settlement, schemas, durability, permissions, and released SDK contracts remain unchanged.

Why This Change Was Made

Ordinary statements and iterators now share the schema owner's mutation entry and settlement logic, and catalog rows are projected in one pass. Incognito tests exercise real session reads through the existing owner, allowing removal of the private memory diagnostic, its operation alias, and the test-only .run facade. Repeated actor setup, host-SQL observation, and reply interception use shared test support.

Every existing test case remains. Allocation arithmetic assertions are replaced with retained-session-data checks; foreign-writer, iterator-close, live-authority, FIFO, native-loss, and exact completion-source regressions are preserved. The removed facade is absent from the released SDK actor contract.

Deslop

Area Added Removed Net
Production 57 124 −67
Tests and test support 327 399 −72
Total 384 523 −139

907 changed lines. No schema or dependency changes, compatibility aliases, new options, or new test cases.

Evidence

SQL gate passed under the campaign’s deferred-startup rule. Exact-head CI, focused behavior proof, and fresh P2 review are complete.

  • Schema-facts and schema-contract focused proof: 156 tests passed. The changed schema-facts file retains all 42 cases (5.979 seconds test time; 69.04 seconds wrapper wall for the three-file run).
  • Incognito actor owner: all 16 tests passed. This loaded-host run measured 166.337 seconds of summed test time, 360.42 seconds in Vitest, and 691.84 seconds wrapper wall including 289.659 seconds of compiled-worker preparation. The suite exercises real worker opening, cancellation, native loss, and accepted-work settlement. Session-manager caller proof also passed all 21 tests (121.70 s Vitest, 191.30 s total wall). The broader owner/caller suites passed in CI on the final head.
  • check:changed: the combined run found missed test-only facade callers; those were migrated and production plus all 27 core test typecheck graphs now pass. All remaining guards and targeted lint pass after correcting helper lint. The export scan still reports the inherited unused ClientVoiceToolEffect in the untouched Talk store (identical Git blob in base and candidate).
  • pnpm check:madge-import-cycles: 0 cycles. pnpm deadcode:knip: clean file/dependency scan. git diff --check: clean.
  • CI run 37862661354 passed on 8e01625010e8268710820187f7c03af22789ae82, including 284 relevant owner/caller test cases and both changed Gateway shutdown files.
  • Fresh Codex review through P2: scoped-clean on the final candidate, with complete actor and caller context.

Paired SQL proof

Final Testbox run 37870378770 compared baseline 4f33fe7402bf6f2d807dfec0864344a3824a4ae2 with candidate 8e01625010e8268710820187f7c03af22789ae82 in three alternating pairs on the same isolated Linux host (Node 24.19.0; 99.50–99.87% CPU idle before runs). Candidate tree: 342b6014c575269b101262496e4c6badb2e25ada.

The workload and native SQL counting contract are unchanged. A task-local copy adds the existing transport census so SQL can be joined to request IDs, parents, timestamps, and callers; it records no bindings or result bodies. All six full workloads passed: 13 turns, native child, cron, compaction, 37 successful RPCs, clean shutdown, and no surviving fixture children. Calibration remains seven executed statements per thread. Raw traces conserve exactly against every phase/thread/SQL CSV.

Phase / flow Main median Candidate median Delta
Boot 2333 2332 −1
Connect 340 342 +2
First turn, raw 2895 2905 +10
First turn excluding only proven boot-origin catalog work 2895 2895 0
Boot + connect + first turn 5587 5587 0
Warmed turn mean 1330.8 1330.3 −0.5
Second session 4491 4501 +10
Control 42 37 −5
Cron 1354 1353 −1
Compaction 756 755 −1
Shutdown 830 841 +11

The first-turn shift is directly linked to startup: candidate pair 2 sends catalog request 7899:10:task-worker:1 during boot, then its explicitly parented pluginCatalog.read helper process:7994:1 executes 27 statements during the first turn. The catalog owner and callers are unchanged. Excluding only those boot-origin helper statements yields first-turn samples main [2895,2899,2848], candidate [2895,2878,2902], both median 2895. Full boot+connect+first samples are main [5568,5587,5598], candidate [5594,5587,5576], both median 5587. Combined medians are computed from full-window samples, not by adding phase medians. No noise-floor exception is needed.

Other positive deltas are within the attributed non-turn allowance: connect +2 is existing startup media/snapshot timing; second-session +10 is unchanged maintenance/projection/cache work; shutdown +11 is one existing projection refresh (nine row-fact statements plus two shared-fact statements), also observed on main. No scheduling owner changed. First/warmed duration ratios are 1.033/1.028; every reported phase ratio is below 1.071.

Shutdown before/after proof passed the same two selected real-close cases on both heads: appends 4.133→3.747 seconds, outbox 3.775→3.817 seconds; combined case time 7.908→7.564 seconds and invocation duration 62.57→59.69 seconds. Four unrelated cases were excluded by the same exact name filter. All task leases were stopped after local artifact verification.

Earlier measurement and tooling limitations

The loaded-Mac schema-only series did not clear its first-turn gate (3029→3142; warmed 1353.2→1349.9). A standard-observer isolated series improved first turn (2889→2879) but had a small warmed rise (1328.2→1329.6); missing request origins made attribution incomplete. The final census series was added to resolve that evidence gap, and neither earlier series is relabeled as a raw zero-increase pass.

The first isolated attempt completed its workloads but hit the inline artifact collector’s 10 MiB limit. Recovery used direct download, validated the archive and source binding locally, then stopped the lease. The final census series logged one recovered baseline plugin-lease lock-contention diagnostic; every workload completed. Raw test logs are not published.

Changed test-file CI cost

Times below sum the reported case durations; shared worker startup and shard overhead are excluded. Every listed case passed.

Test file Cases CI test seconds
src/agents/sessions/session-manager-incognito.test.ts 21 1.695
src/gateway/server-close.agent-databases.test.ts 5 12.374
src/gateway/server-close.incognito-manager.test.ts 1 6.004
src/infra/sqlite-schema-facts.test.ts 42 0.388
src/state/openclaw-agent-execution-incognito.compute.test.ts 32 14.316
src/state/openclaw-agent-execution-incognito.creation.test.ts 5 0.804
src/state/openclaw-agent-execution-incognito.entry-patch.test.ts 12 1.228
src/state/openclaw-agent-execution-incognito.history.test.ts 48 5.901
src/state/openclaw-agent-execution-incognito.lifecycle.test.ts 19 5.080
src/state/openclaw-agent-execution-incognito.memory.test.ts 9 0.880
src/state/openclaw-agent-execution-incognito.outbox.test.ts 8 1.380
src/state/openclaw-agent-execution-incognito.pending-history.test.ts 5 6.378
src/state/openclaw-agent-execution-incognito.sessions.test.ts 24 7.115
src/state/openclaw-agent-execution-incognito.test.ts 16 9.249

Released SDK check at landing

Compared v2026.10.1-beta.1 (6830fe76b3db05ad59e8ff7f0f872d4e2639a1fe) with the approved head using pnpm plugin-sdk:api:diff; the command completed successfully (report digest cd5a19f0080fc26482ccc9ef34d7ae4d73088ea70ab48c521cddac995e9f43fa). The release-wide report contains 1,187 affected exports from intervening development and no added or removed SDK entrypoints; it is not a PR-only zero-diff claim.

The removed IncognitoAgentDatabaseExecution.run facade and AgentDatabaseIncognitoOperations diagnostic alias are internal: no released SDK export, documented SDK subpath, or api.runtime contract exposes them. Their report mentions occur only in conservative whole-module (*) declaration sections, not named exported signatures. The declaration renderer intentionally retains an entire subtree when it cannot index a declaration. Direct source checks against the release tag and current SDK/runtime barrels confirm the boundary; the existing transcript SDK adapter returns its declared context-reader contract and consumes the narrower incognito actor internally. No compatibility facade or deprecation record is needed for these private removals. The stable v2026.9.9 tag predates the internal incognito execution module.

Exercise the existing FIFO, authority, completion-source and shutdown regressions through real session reads. Remove the private allocation diagnostic and execution facade, and share actor fixtures and worker reply observation. No public SDK, schema, durability or permission changes.
@clawsweeper

clawsweeper Bot commented Oct 9, 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 gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 9, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The branch consolidates SQLite mutation bookkeeping, removes private incognito diagnostics used only by tests, and shares actor test support.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful owner-level simplification with completed production runtime comparisons, passing exact-head CI, and no actionable finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The complete body records paired isolated Gateway workloads exercising SQLite admission and mutation tracking through turns, cron, compaction, RPCs, and shutdown, plus passing accepted-append and outbox close scenarios. Source inspection confirms unchanged stored schemas and formats, so no migration is required.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
Reason: The established area contributor is reducing duplicated bookkeeping and removing production interfaces maintained solely for tests. The change preserves existing outputs and lifecycle contracts.

Merge readiness

✅ Ready for maintainer review

This PR remains useful on current main and is ready for ordinary maintainer review. No actionable introduced defect or unresolved product choice was found.

Priority: P3
Reviewed head: 8e01625010e8268710820187f7c03af22789ae82

Before merge

None.

Findings

None.

Agent review details

How this fits together

SQLite admission tracks which database facts remain valid across writes, transactions, and foreign commits. Incognito session workers serve memory-only session operations with ordered execution and accepted-work settlement.

flowchart TD
 A[Session requests] --> B[Incognito session owner]
 B --> C[Ordered worker execution]
 C --> D[Memory-only SQLite]
 E[Statements and iterators] --> F[Shared mutation tracking]
 D --> F
 F --> G[Current database facts]
Loading

Technical review

Best possible solution:

Keep freshness and settlement under their existing owners, with lifecycle coverage exercised through real session operations.

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

Not applicable: this PR proposes a behavior-preserving refactor rather than a reported product defect.

Is this the best way to solve the issue?

Yes: consolidating bookkeeping inside its existing owner and retiring diagnostic-only production interfaces removes duplication without creating another runtime path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 70abbe7 adds src/state/openclaw-agent-execution-incognito.ts:76 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 70abbe72eff7; files: src/state/openclaw-agent-execution-incognito.ts)

PR surface

Source -67, Tests -72. Total -139 across 23 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 57 124 -67
Tests 17 327 399 -72
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 384 523 -139

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is internal maintenance with no intended user-visible change or demonstrated urgent failure.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-09T00:06:28.244Z sha 8e01625 :: needs changes before merge. :: none
  • reviewed 2026-10-09T00:32:44.202Z sha 8e01625 :: needs changes before merge. :: none
  • reviewed 2026-10-09T02:04:39.565Z sha 8e01625 :: needs maintainer review before merge. :: none

Reviewed October 8, 2026, 11:12 PM ET / October 9, 2026, 03:12 UTC (Revision 4).

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
@steipete
steipete merged commit f76f434 into main Oct 9, 2026
177 of 178 checks passed
@steipete
steipete deleted the dbasync/dslstate-1 branch October 9, 2026 03:45
@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…law#167533)

* refactor(sqlite): share schema mutation bookkeeping

* refactor(state): retire incognito test-only execution seam

Exercise the existing FIFO, authority, completion-source and shutdown regressions through real session reads. Remove the private allocation diagnostic and execution facade, and share actor fixtures and worker reply observation. No public SDK, schema, durability or permission changes.

* test(state): clarify the incognito reply observer snapshot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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