Skip to content

refactor(state): defer repository database opening until use - #145048

Merged
steipete merged 1 commit into
mainfrom
codex/repository-native-reads-20260911
Sep 11, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/repository-native-reads-20260911

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #144592

What Problem This Solves

Constructing a repository-workspace store opens SQLite even when the caller only needs an artifact path. Transaction helpers also reacquire their store through public read methods instead of using the connection already admitted to the transaction.

Why This Change Was Made

Capture the canonical absolute path without opening the database. Open on actual data access, retaining that captured path through environment changes and reopen. Reuse private native read helpers inside the existing transaction owner.

User Impact

Artifact-path planning no longer creates or reopens SQLite. Existing synchronous operations, revision checks, stored formats and artifact cleanup behavior remain unchanged.

Evidence

  • All 24 store, checkpoint and deletion cases passed; the lazy-opening regression failed on original source for the intended reason.
  • Actual artifact-consumer and SQLite before/after proof preserved create/checkpoint/reopen, stale-revision refusal and sibling artifacts. Construction and artifact-only lookup no longer open the database.
  • Full selected checks and fresh independent Codex review through P2 passed. All created processes joined and the broader recovery candidate remained untouched.
  • No compiled build or worker execution is claimed by this focused prerequisite.

@clawsweeper

clawsweeper Bot commented Sep 11, 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 size: S maintainer Maintainer-authored PR labels Sep 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 12:08 PM ET / 16:08 UTC (Revision 2).

ClawSweeper review

What this changes

The PR delays opening the repository-workspace database until data access and reuses the transaction’s connection for internal reads.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful, focused prerequisite for the accepted storage work, and neither current main nor the latest release includes it. No blocking defect was found. The previous contributor-proof blocker does not apply to the verified repository-admin author under this review’s rules.

Priority: P2
Reviewed head: a8395695221b40cd4b44603c66af9ca1cfaa8288

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused refactor with useful regression coverage and no identified blocking defect; the trusted-author proof exemption applies.
Proof confidence 🌊 off-meta tidepool Not applicable: The verified repository-admin author is exempt from the external proof gate, and this refactor does not materially change authority. The captured body reports artifact-consumer and real-SQLite lifecycle checks matching the changed owner; those claims were not independently executed here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified repository-admin author is exempt from the external proof gate, and this refactor does not materially change authority. The captured body reports artifact-consumer and real-SQLite lifecycle checks matching the changed owner; those claims were not independently executed here.
Evidence reviewed 8 items Verified introduced change: The pinned merge-base-to-head diff changes only store construction, internal connection reuse, and a lifecycle regression. It preserves record formats, synchronous public operations, revision predicates, and current-authority assertions.
Current main and release still open eagerly: Inspected the store on fetched main and v2026.9.4. Both construct databasePath through openOpenClawStateDatabase(), so artifact-only callers still open SQLite. No implemented-on-main conclusion is supported.
Production artifact-only consumer: sessionWorkspaceRoot obtains a store solely to call artifactPath for repository workspaces, establishing an actual caller that benefits from database-free construction.
Findings None None.
Security None None.

How this fits together

Repository-workspace storage tracks cloud sessions’ repository identities and accepted checkpoints in shared SQLite state. Gateway callers use it to retrieve workspace records and locate checkpoint Git artifacts.

flowchart TD
  A[Gateway workspace caller] --> B[Store captures database path]
  B --> C{Requested operation}
  C -->|Artifact location| D[Return Git artifact path]
  C -->|Read or write| E[Shared SQLite owner]
  E --> F[Workspace record or committed update]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +9, Tests +36. Total +45 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 38 29 +9
Tests 1 37 1 +36
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 75 30 +45

Review metrics

None.

Root-cause cluster

Relationship: partial_overlap
Canonical: #144592
Summary: This PR addresses a bounded prerequisite within the broader asynchronous-storage program.

Members:

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

Technical review

Best possible solution:

Keep artifact-path resolution free of database side effects while retaining shared SQLite admission and exact-connection transactional reads.

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

Not applicable as a reported runtime bug: this is a scoped lifecycle refactor; source confirms that current-main artifact-path lookup opens SQLite unnecessarily.

Is this the best way to solve the issue?

Yes: using the existing canonical path resolver and transaction owner is a narrow solution that preserves stored data and caller contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This removes unnecessary database opening in an existing workspace path without a demonstrated urgent user-facing outage.
  • 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 verified repository-admin author is exempt from the external proof gate, and this refactor does not materially change authority. The captured body reports artifact-consumer and real-SQLite lifecycle checks matching the changed owner; those claims were not independently executed here.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 140d9e7 adds src/state/session-repository-workspaces.ts:77 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 140d9e705ea3; files: src/state/session-repository-workspaces.ts)

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 (1 earlier review cycle)
  • reviewed 2026-09-11T15:54:22.684Z sha a839569 :: needs real behavior proof before merge. :: none

@steipete
steipete marked this pull request as ready for review September 11, 2026 16:03
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 11, 2026
@steipete
steipete merged commit c15a953 into main Sep 11, 2026
253 checks passed
@steipete
steipete deleted the codex/repository-native-reads-20260911 branch September 11, 2026 21:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
steipete added a commit that referenced this pull request Sep 29, 2026
* refactor(storage): run repository workspace SQL in workers

Move repository reads and synchronous Kysely mutation kernels to the
existing SQLite workers, and await their actual callers. Publish row changes
from native commit receipts and retain operation custody through cleanup.
Prepared repository facts serve synchronous authorization and event frames.

Revalidate the original physical and logical session source at receipt and
workspace grants, preserving full logical lookup and direct deletion's
historical receipt rules. Remove the obsolete native-handle factory option.
No storage schema, public configuration, permission or retention change.

Current-main proof passes 80 focused SQLite/worker cases and owning types;
qualified receiving adds 198 lifecycle/Gateway cases, all 27 test type graphs,
and 66 repository/checkpoint/publication/file-RPC cases. Source controls
reproduce foreign-write row and receipt loss, and the repaired paths pass.
Independent review is clean through P2. Full build and affected receiving
bundle checks pass with recorded source applicability.

Completes the repository domain cutover after #145048 and #160858.

* fix(gateway): bind prepared events to the current projection

* fix(storage): finish committed repository artifact cleanup

* fix(test): keep Gateway worker paths in canonical order

* test(gateway): align prepared publication fixtures
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
…161124)

* refactor(storage): run repository workspace SQL in workers

Move repository reads and synchronous Kysely mutation kernels to the
existing SQLite workers, and await their actual callers. Publish row changes
from native commit receipts and retain operation custody through cleanup.
Prepared repository facts serve synchronous authorization and event frames.

Revalidate the original physical and logical session source at receipt and
workspace grants, preserving full logical lookup and direct deletion's
historical receipt rules. Remove the obsolete native-handle factory option.
No storage schema, public configuration, permission or retention change.

Current-main proof passes 80 focused SQLite/worker cases and owning types;
qualified receiving adds 198 lifecycle/Gateway cases, all 27 test type graphs,
and 66 repository/checkpoint/publication/file-RPC cases. Source controls
reproduce foreign-write row and receipt loss, and the repaired paths pass.
Independent review is clean through P2. Full build and affected receiving
bundle checks pass with recorded source applicability.

Completes the repository domain cutover after openclaw#145048 and openclaw#160858.

* fix(gateway): bind prepared events to the current projection

* fix(storage): finish committed repository artifact cleanup

* fix(test): keep Gateway worker paths in canonical order

* test(gateway): align prepared publication fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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