Skip to content

refactor: remove SQLite CLI dependency from gitcrawl reads - #1126

Merged
steipete merged 6 commits into
mainfrom
steipete/node-sqlite-migration
Aug 11, 2026
Merged

steipete merged 6 commits into
mainfrom
steipete/node-sqlite-migration

Conversation

@steipete

@steipete steipete commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

ClawSweeper's local gitcrawl readers still required a host-installed sqlite3 executable. Related-context discovery and both repair importers could fail because the binary was absent, not executable through PATH, timed out, or exceeded a subprocess output buffer even when the database itself was healthy.

Why This Change Was Made

The five scalar/JSON subprocess call sites now share a small Node 24 node:sqlite reader that opens each store with DatabaseSync(dbPath, { readOnly: true }), reads integers as BigInts, and explicitly normalizes JSON-row integers to the existing JavaScript-number contract. Related-context keeps its best-effort fallbacks; importer errors remain terminal. The cluster-intake workflow no longer installs the obsolete CLI.

User Impact

Operators can run related-context discovery and gitcrawl repair imports anywhere the supported Node 24 runtime is present, including the normal Linux container, without separately provisioning sqlite3. There is no change to generated job content or repair policy.

OpenClaw Bay Impact

OpenClaw Bay is unaffected. This changes local read-only gitcrawl store access and workflow bootstrap only; it does not change lifecycle publication, queues, status telemetry, dashboard data, or Bay's observer-only boundary.

Documentation Lifecycle

docs/proof/node-sqlite-migration/ is historical, commit-bound validation evidence rather than an active runbook. No active documentation lifecycle changes.

Evidence

Real Behavior Proof

  • Claim: all five gitcrawl SQLite subprocess call sites can use read-only node:sqlite without changing scalar text, parsed JSON rows, empty-result behavior, or caller-level error outcomes.
  • Exercised surface: related-context portable and legacy cluster lookup; cluster importer source detection and member query; low-signal importer candidate query; missing/corrupt databases; committed WAL rows; integer values above Number.MAX_SAFE_INTEGER; cluster-intake bootstrap.
  • Scenario/fixture: disposable real SQLite files created with node:sqlite, including both gitcrawl cluster schemas and a portable database whose committed fixture rows remain in a live -wal sidecar. Importer subprocess tests run with an empty PATH.
  • Command/environment: Node 24.19.0, pnpm 11.10.0, host sqlite3 3.51.0 for the old side only; node docs/proof/node-sqlite-migration/run-proof.mjs; node --test test/repair/gitcrawl-sqlite.test.ts; the seven gates recorded below; pnpm run check.
  • Observable result: three old/new scalar results and three old/new parsed JSON results are byte-identical. The focused suite passes 6/6. Missing/corrupt stores retain []/false or []/null in related-context and nonzero failure in both importers. 9007199254740993 remains exact scalar text and normalizes to JSON number 9007199254740992, matching the old CLI path.
  • Artifact/trace: docs/proof/node-sqlite-migration/equivalence.json binds host proof to implementation commit c5b65dfa2daf24b7158939b5f7f10fb5803fbbb9; the harness extracts the three old source files from origin/main and verifies all five old invocations before comparison.
  • Limits: fixtures are local and contact no GitHub API, Gitcrawl service, Worker storage, or production system. The host uses sqlite3 only for old-path equivalence. The fresh-PR container runs only the new path because that image intentionally has no sqlite3 binary.

proof: sufficient. Host equivalence and the fresh-PR container receipt both apply to the pushed implementation; the final head adds only the committed receipt.

Local gates

  1. Host old/new equivalence proof: passed (3 scalar + 3 JSON cases).
  2. Focused real-database fixtures: 6 passed, 0 failed.
  3. pnpm run build:all: passed.
  4. pnpm run test:no-build: 3,333 tests; 3,324 passed, 9 skipped, 0 failed.
  5. pnpm run lint: passed.
  6. pnpm run format:check: 663 files passed.
  7. pnpm run check:static: passed.

The composed pnpm run check gate also passed on committed head 72d2947f7c, including 81.58% line, 74.05% branch, and 87.39% function coverage. Pre-commit and committed-branch structured Codex reviews reported no accepted/actionable findings.

Fresh-PR container

Crabbox resolved provider=aws and ran pushed head 31386dccd6ee9f77fe480ab6c705253647f4aaf2 from fresh PR checkout openclaw/clawsweeper#1126 in node:24-bookworm:

  • run run_61e78be4ed53; lease cbx_3ddd8eadc1bb (amber-barnacle-28b5), c7a.8xlarge;
  • checksum-verified jq 1.8.2 (jq-linux-amd64, SHA-256 b1c22172dd303f3be49e935aa56aa48a8b7a46e0bc838b4997d3bb451495870f);
  • sqlite3 absent before and after the rsync-only dependency setup;
  • 6/6 focused real-database fixtures passed;
  • full pnpm run check passed: 3,333 tests, 3,325 passed, 8 skipped, 0 failed; 81.60% lines, 74.06% branches, 87.40% functions;
  • command exit 0 in 187,543 ms; full stdout SHA-256 28669d632e2d5387d901c76504611ab37a19bd23de0c29453767e2bf5efe5c76;
  • TruffleHog 3.96.0 found zero verified or unverified secrets in the full stdout and the committed proof-bearing excerpt;
  • Crabbox 0.41.1 explicitly released the lease after the older project-local wrapper's release calls timed out; the provider-specific lease list is empty.

Commit bd8d595a36 adds container-provenance.json, container-secret-scan.json, and the secret-scanned stdout receipt in the same push. The provenance also records three discarded harness attempts: temporary jq PATH loss, login-shell PATH reset, and the base image's missing rsync. None was treated as proof.

Review disposition

No accepted or actionable source findings remain. The branch intentionally preserves the old lossy JSON-number contract because downstream issue/cluster fields are consumed as numbers; scalar callers continue to receive exact decimal text before their existing Number() conversion.

@steipete
steipete requested a review from a team as a code owner August 11, 2026 19:23
@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 11, 2026, 4:46 PM ET / 20:46 UTC.

ClawSweeper review

What this changes

This PR replaces five local gitcrawl SQLite CLI reads with Node’s read-only SQLite API, removes the cluster-intake CLI install, and adds compatibility proof and fixtures.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Needs maintainer review before merge - 4 items remain

Keep this PR open: the Node 24 migration and real-store proof are strong, but the earlier documentation blocker remains and maintainers need to decide whether related-context reads may now block indefinitely.

Priority: P2
Reviewed head: bd8d595a369c15169a0e39f11728c166bba5b521
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The proof is unusually strong, but the unresolved documentation blocker and availability decision prevent a higher readiness rating.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body and committed receipt provide after-fix real SQLite fixtures and a fresh Node 24 container run without sqlite3, with focused and full checks passing.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body and committed receipt provide after-fix real SQLite fixtures and a fresh Node 24 container run without sqlite3, with focused and full checks passing.
Evidence reviewed 6 items Current related-context behavior: Current main runs the sqlite3 CLI with a 10-second timeout and bounded buffers for best-effort related-context queries.
Documentation contract is stale after the proposed migration: Current operator documentation says missing sqlite3 skips gitcrawl context; the PR’s supplied changed-file list does not update this page although its new reader removes that dependency.
Proposed reader and proof: The supplied PR diff adds a shared read-only DatabaseSync helper and focused real-database coverage; the PR body records a fresh Node 24 container run with sqlite3 absent and 6/6 focused tests passing.
Findings 1 actionable finding [P2] Update the related-context SQLite availability documentation
Security None None.

How this fits together

Related-context discovery and repair importers query local gitcrawl SQLite stores for review relationships and repair-job inputs. Their results feed review prompts and cluster/low-signal job preparation.

flowchart LR
  Store[Local gitcrawl store] --> Reader[Read-only SQLite reader]
  Reader --> Context[Related-context discovery]
  Reader --> Imports[Repair importers]
  Context --> Reviews[Review prompts]
  Imports --> Jobs[Repair job preparation]
Loading

Decision needed

Question Recommendation
Should optional related-context discovery retain a bounded failure path, or may a local SQLite read block the review process without a deadline? Retain bounded fallback: Use an isolated or otherwise bounded Node SQLite execution path and prove that a delayed or locked store returns the existing empty/null fallback.

Why: The migration intentionally removes an existing timeout while changing a best-effort review dependency; choosing the acceptable availability tradeoff requires maintainer ownership.

Before merge

  • Update the related-context SQLite availability documentation (P2) - The migration makes Node 24’s SQLite API the reader, but docs/related-issue-discovery.md still says that missing sqlite3 skips this source. That leaves operators with the old prerequisite and troubleshooting path. Preserve the database-unavailable fallback, but document the Node 24 reader instead. This is the still-unresolved documentation concern from an earlier review cycle.
  • Resolve merge risk (P1) - The two related-context calls previously fell back after 10 seconds; the proposed synchronous SQLite path has no equivalent deadline, so a locked or unusually slow local store can stall a review process instead of omitting optional context.
  • Complete next step (P2) - A maintainer must decide the acceptable availability behavior for optional related-context SQLite reads; the remaining documentation correction is concrete.

Findings

  • [P2] Update the related-context SQLite availability documentation — src/clawsweeper-related-context.ts:5
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Change composition production +9, tests +453, proof/docs +718 The runtime helper is small, while most of the branch is dedicated regression coverage and reproducible proof.
SQLite call sites 5 CLI reads replaced across 3 consumers All affected local-store read paths share one new helper, so its availability behavior is shared.

Merge-risk options

Maintainer options:

  1. Restore a bounded related-context fallback (recommended)
    Preserve the dependency removal while ensuring a slow or locked optional store cannot hold the review process indefinitely, then add focused proof of the fallback.
  2. Accept the blocking-read tradeoff
    Merge the direct synchronous reader only if maintainers intentionally accept stalled reviews as preferable to skipping optional gitcrawl context.

Technical review

Best possible solution:

Keep the Node 24 read-only reader, update the operator documentation, and preserve a bounded best-effort failure path for related-context reads before merging.

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

Not applicable as a report; the PR supplies current-head real SQLite fixture and container evidence for its claimed behavior.

Is this the best way to solve the issue?

Unclear: removing the CLI dependency fits the Node 24 runtime contract, but the direct synchronous replacement is not the safest solution until the timeout tradeoff is resolved.

Full review comments:

  • [P2] Update the related-context SQLite availability documentation — src/clawsweeper-related-context.ts:5
    The migration makes Node 24’s SQLite API the reader, but docs/related-issue-discovery.md still says that missing sqlite3 skips this source. That leaves operators with the old prerequisite and troubleshooting path. Preserve the database-unavailable fallback, but document the Node 24 reader instead. This is the still-unresolved documentation concern from an earlier review cycle.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 27d0dca68158.

Labels

Label changes:

  • add merge-risk: 🚨 availability: The PR removes the existing 10-second best-effort timeout from related-context reads, allowing a local store to block review execution.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (linked_artifact): The PR body and committed receipt provide after-fix real SQLite fixtures and a fresh Node 24 container run without sqlite3, with focused and full checks passing.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.
  • remove merge-risk: 🚨 compatibility: Current PR review merge-risk labels are merge-risk: 🚨 availability.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded reliability and documentation correction affecting optional review and repair inputs, without evidence of an active user outage.
  • merge-risk: 🚨 availability: The PR removes the existing 10-second best-effort timeout from related-context reads, allowing a local store to block review execution.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (linked_artifact): The PR body and committed receipt provide after-fix real SQLite fixtures and a fresh Node 24 container run without sqlite3, with focused and full checks passing.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and committed receipt provide after-fix real SQLite fixtures and a fresh Node 24 container run without sqlite3, with focused and full checks passing.

Evidence

What I checked:

  • Current related-context behavior: Current main runs the sqlite3 CLI with a 10-second timeout and bounded buffers for best-effort related-context queries. (src/clawsweeper-related-context.ts:468, 27d0dca68158)
  • Documentation contract is stale after the proposed migration: Current operator documentation says missing sqlite3 skips gitcrawl context; the PR’s supplied changed-file list does not update this page although its new reader removes that dependency. (docs/related-issue-discovery.md:73, 27d0dca68158)
  • Proposed reader and proof: The supplied PR diff adds a shared read-only DatabaseSync helper and focused real-database coverage; the PR body records a fresh Node 24 container run with sqlite3 absent and 6/6 focused tests passing. (src/sqlite-readonly.ts:1, bd8d595a369c)
  • Prior review continuity: The latest completed review at this same head lists no findings, but its earlier cycle explicitly raised the still-applicable related-context sqlite3 documentation blocker; the current source document remains unchanged. (docs/related-issue-discovery.md:73, bd8d595a369c)
  • Feature provenance: Blame attributes the existing timeout-and-buffer process boundary to the scheduled-delivery structural-cache work, establishing that this PR deliberately changes that operational behavior. (src/clawsweeper-related-context.ts:472, 62acb03356bb)
  • Portable-store history: Portable gitcrawl cluster support predates this PR and is a shared repair concern, rather than a new store contract introduced here. (src/repair/import-gitcrawl-clusters.ts:216, 6a0a32c8754d)

Likely related people:

  • steipete: Current related-context sqlite3 timeout handling blames to Peter Steinberger’s merged structural-cache work; the same area was recently refactored in the repair lane. (role: introduced the current related-context process boundary and recent repair-area contributor; confidence: high; commits: 62acb03356bb, 1ee584328f2f; files: src/clawsweeper-related-context.ts, src/repair/import-gitcrawl-clusters.ts)
  • Vincent Koc: The portable cluster schema path used by the importer dates to the portable-gitcrawl-clusters change. (role: portable gitcrawl cluster support contributor; confidence: medium; commits: 6a0a32c8754d; files: src/repair/import-gitcrawl-clusters.ts)

Rank-up moves

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

  • Correct the public related-context SQLite prerequisite text.
  • Resolve the bounded-read decision and, if retaining it, add a delayed or locked-store fallback proof.

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-08-11T19:26:35.869Z sha 72d2947 :: needs real behavior proof before merge. :: [P1] Remove the unpinned jq executable download | [P2] Update the related-context sqlite3 requirement
  • reviewed 2026-08-11T19:56:03.248Z sha 5c600c5 :: needs real behavior proof before merge. :: [P1] Remove the dynamic jq bootstrap from the proof runner
  • reviewed 2026-08-11T20:10:40.670Z sha 31386dc :: needs real behavior proof before merge. :: [P3] Correct the documented jq version
  • reviewed 2026-08-11T20:42:16.360Z sha bd8d595 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 11, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. and removed merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 11, 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 repository_dispatch).
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 proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. 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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 11, 2026
@steipete
steipete merged commit 4b79888 into main Aug 11, 2026
30 checks passed
@steipete
steipete deleted the steipete/node-sqlite-migration branch August 11, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant