Skip to content

feat(database): update SQLite pool to create missing parent directories#230

Merged
sergiofilhowz merged 2 commits into
mainfrom
fix/database-worker
Jun 5, 2026
Merged

feat(database): update SQLite pool to create missing parent directories#230
sergiofilhowz merged 2 commits into
mainfrom
fix/database-worker

Conversation

@sergiofilhowz

@sergiofilhowz sergiofilhowz commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

This commit enhances the SQLite connection pool to ensure that any missing parent directories for the database file are created during initialization. This change addresses a critical issue where the worker would crash on startup if the default database path did not exist. Additionally, it includes tests to verify the new behavior and updates the version to 0.2.7 in both Cargo.toml and Cargo.lock files.

Summary by CodeRabbit

  • Bug Fixes

    • SQLite now creates missing parent directories for on-disk databases to avoid startup failures.
  • Tests

    • Added CI interface-smoke job to validate worker interfaces across the Rust worker matrix.
    • New integration test verifies SQLite parent directory creation and end-to-end DB usability.
  • Documentation

    • Quickstart updated to include the coder worker.
  • Chores

    • Bumped database crate version (patch).

This commit enhances the SQLite connection pool to ensure that any missing parent directories for the database file are created during initialization. This change addresses a critical issue where the worker would crash on startup if the default database path did not exist. Additionally, it includes tests to verify the new behavior and updates the version to 0.2.7 in both `Cargo.toml` and `Cargo.lock` files.
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview, Comment Jun 5, 2026 7:46pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Complex PR? Review this PR in Change Stack to move by importance, not file order.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fed91ac1-cff0-4e35-80f5-c43e29dd5851

📥 Commits

Reviewing files that changed from the base of the PR and between a8fdc16 and 47d7c4c.

📒 Files selected for processing (1)
  • database/tests/integration.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • database/tests/integration.rs

📝 Walkthrough

Walkthrough

This PR creates missing parent directories for file-backed SQLite pools (with tests and a version bump), adds a GitHub Actions interface-smoke job to build/run Rust workers and collect their interfaces, and updates the harness quickstart to include the coder worker.

Changes

SQLite Parent Directory Creation Fix

Layer / File(s) Summary
Parent directory creation helper and pool integration
database/src/pool/sqlite.rs
SqlitePool::new computes and creates missing parent directories for file-backed SQLite paths using a new parent_dir_to_create helper that parses SQLite URLs, skips in-memory forms, and strips query parameters.
Unit and integration tests for directory creation
database/src/pool/sqlite.rs, database/tests/integration.rs
Unit tests verify the parent_dir_to_create helper handles in-memory, bare filename, nested path, and URI formats; integration test reproduces the startup scenario and confirms pool initialization succeeds and the database is usable.
Database crate version bump
database/Cargo.toml
database crate version incremented from 0.2.6 to 0.2.7.

Interface Smoke Test CI Job

Layer / File(s) Summary
Job definition and environment setup
.github/workflows/ci.yml
Defines the interface-smoke job wired to the Rust-worker matrix with timeout and includes steps for checkout, Python tooling, Rust toolchain + cache, and conditional Node/pnpm setup for bundled SPA pre-builds.
Worker binary compilation and iii CLI installation
.github/workflows/ci.yml
Builds the worker binary via cargo build from the worker directory and installs a pinned iii CLI (v0.17.0) by running the remote installer script and verifying the version.
III engine startup and baseline capture
.github/workflows/ci.yml
Starts a local III engine from an ad-hoc config.yaml, polls engine::workers::list for readiness, and snapshots baseline trigger types and worker lists as JSON.
Worker startup, interface collection, and assertion
.github/workflows/ci.yml
Starts the compiled worker binary from the worker directory (resolving the binary name from iii.worker.yaml), runs collect_worker_interface.py to generate worker-interface.json, and asserts the collected interface is non-empty.
Failure logging and process cleanup
.github/workflows/ci.yml
On failure prints tail logs for engine and worker; always step kills backgrounded engine/worker processes using recorded PID files.

Harness Quickstart Documentation Update

Layer / File(s) Summary
Quickstart worker list update
harness/README.md
Quickstart step 3 now includes coder when adding workers to the harness environment.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • iii-hq/workers#220: Related to baseline-aware interface collection and worker/function collection logic used by the CI interface-smoke job.
  • iii-hq/workers#76: Also changes CI to run interface collection for workers; differs in using prebuilt release binaries.
  • iii-hq/workers#67: Adds/refines .github/scripts/collect_worker_interface.py used by the new CI job.

Suggested reviewers

  • ytallo

Poem

🐰 I dug a path where SQLite feared to tread,
I made the dirs so data has a bed.
CI wakes workers, gathers what they say,
And coder hops in to join the play. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: updating SQLite pool to create missing parent directories, which aligns with the main code modifications across database files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/database-worker

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

skill-check — worker

0 verified, 14 skipped (no docs/).

Layer Result
structure
vale
ai
render

Four for four. Nicely done.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 323-331: The workflow step "Dump logs on failure" uses the direct
expansion worker-${{ matrix.worker }} in the shell which risks template/shell
injection; change it to export or set an env var (e.g., WORKER_NAME = ${{
matrix.worker }}) at the job or step level and then reference the log file via
the env var in the tail command (tail -n 200 "worker-${WORKER_NAME}.log" or tail
-n 200 "worker-${WORKER_NAME}.log" with proper quoting) so the matrix.worker
value is not directly interpolated by the shell; update the step that contains
the tail invocation to use the new WORKER_NAME env var instead of `${{
matrix.worker }}`.
- Around line 235-247: The workflow sets VERSION but never uses it and only runs
iii --version without verifying it; update the step so the VERSION env is
actually passed to the installer (e.g., export or invoke install-iii.sh with the
version argument if the installer supports it) and replace the bare iii
--version call with an explicit verification that the output equals the expected
VERSION (failing the job if it does not). Target the run block that downloads
and executes install-iii.sh and the final iii --version check so you both pass
VERSION to the installer and assert the installed iii version matches VERSION.

In `@database/tests/integration.rs`:
- Around line 216-221: AppState construction in the test is missing the required
config field; update the struct literal to include config (e.g., config:
build_state().config or otherwise obtain the same config used by build_state())
so the test AppState matches the one produced by build_state() and handlers that
read AppState.config will compile and run correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 80844dcf-7160-42f1-83dd-5757091486f8

📥 Commits

Reviewing files that changed from the base of the PR and between 1065941 and a8fdc16.

⛔ Files ignored due to path filters (1)
  • database/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • .github/workflows/ci.yml
  • database/Cargo.toml
  • database/src/pool/sqlite.rs
  • database/tests/integration.rs
  • harness/README.md

Comment thread .github/workflows/ci.yml
Comment on lines +235 to +247
- name: Install iii CLI + engine
env:
VERSION: '0.17.0'
run: |
set -euo pipefail
curl -fsSL https://install.iii.dev/iii/main/install.sh -o /tmp/install-iii.sh
sh /tmp/install-iii.sh
{
echo "$HOME/.local/bin"
echo "$HOME/.iii/bin"
} >> "$GITHUB_PATH"
export PATH="$HOME/.local/bin:$HOME/.iii/bin:$PATH"
iii --version

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

VERSION env var is unused; installed version isn't verified.

The VERSION: '0.17.0' environment variable is defined but never passed to the install script. Additionally, iii --version is called without asserting the output matches the expected version, so the job could silently run with a different CLI version if the remote installer behavior changes.

Consider passing the version to the installer (if supported) or verifying the installed version:

🔧 Suggested fix to verify installed version
       - name: Install iii CLI + engine
         env:
           VERSION: '0.17.0'
         run: |
           set -euo pipefail
           curl -fsSL https://install.iii.dev/iii/main/install.sh -o /tmp/install-iii.sh
           sh /tmp/install-iii.sh
           {
             echo "$HOME/.local/bin"
             echo "$HOME/.iii/bin"
           } >> "$GITHUB_PATH"
           export PATH="$HOME/.local/bin:$HOME/.iii/bin:$PATH"
-          iii --version
+          installed_version=$(iii --version | head -1)
+          echo "Installed: $installed_version (expected: $VERSION)"
+          if ! echo "$installed_version" | grep -qF "$VERSION"; then
+            echo "::warning::iii version mismatch: expected $VERSION, got $installed_version"
+          fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 235 - 247, The workflow sets VERSION
but never uses it and only runs iii --version without verifying it; update the
step so the VERSION env is actually passed to the installer (e.g., export or
invoke install-iii.sh with the version argument if the installer supports it)
and replace the bare iii --version call with an explicit verification that the
output equals the expected VERSION (failing the job if it does not). Target the
run block that downloads and executes install-iii.sh and the final iii --version
check so you both pass VERSION to the installer and assert the installed iii
version matches VERSION.

Comment thread .github/workflows/ci.yml
Comment on lines +323 to +331
- name: Dump logs on failure
if: failure()
run: |
echo "::group::iii engine log"
tail -n 200 iii-engine.log || true
echo "::endgroup::"
echo "::group::worker log"
tail -n 200 "worker-${{ matrix.worker }}.log" || true
echo "::endgroup::"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Potential template injection: use env var instead of direct expansion.

Line 330 uses ${{ matrix.worker }} directly in a shell string. While matrix.worker is derived from directory names (which limits exploitation), the safer pattern used elsewhere in this job (e.g., line 288) is to assign it to an env var first. This avoids shell metacharacter interpretation if a worker directory name ever contains special characters.

🔒 Suggested fix
       - name: Dump logs on failure
         if: failure()
+        env:
+          WORKER: ${{ matrix.worker }}
         run: |
           echo "::group::iii engine log"
           tail -n 200 iii-engine.log || true
           echo "::endgroup::"
           echo "::group::worker log"
-          tail -n 200 "worker-${{ matrix.worker }}.log" || true
+          tail -n 200 "worker-$WORKER.log" || true
           echo "::endgroup::"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Dump logs on failure
if: failure()
run: |
echo "::group::iii engine log"
tail -n 200 iii-engine.log || true
echo "::endgroup::"
echo "::group::worker log"
tail -n 200 "worker-${{ matrix.worker }}.log" || true
echo "::endgroup::"
- name: Dump logs on failure
if: failure()
env:
WORKER: ${{ matrix.worker }}
run: |
echo "::group::iii engine log"
tail -n 200 iii-engine.log || true
echo "::endgroup::"
echo "::group::worker log"
tail -n 200 "worker-$WORKER.log" || true
echo "::endgroup::"
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 330-330: code injection via template expansion (template-injection): may expand into attacker-controllable code

(template-injection)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 323 - 331, The workflow step "Dump
logs on failure" uses the direct expansion worker-${{ matrix.worker }} in the
shell which risks template/shell injection; change it to export or set an env
var (e.g., WORKER_NAME = ${{ matrix.worker }}) at the job or step level and then
reference the log file via the env var in the tail command (tail -n 200
"worker-${WORKER_NAME}.log" or tail -n 200 "worker-${WORKER_NAME}.log" with
proper quoting) so the matrix.worker value is not directly interpolated by the
shell; update the step that contains the tail invocation to use the new
WORKER_NAME env var instead of `${{ matrix.worker }}`.

Comment thread database/tests/integration.rs
The new SQLite parent-dir regression test omitted the required config
field, causing clippy and E2E harness jobs to fail at compile time.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sergiofilhowz sergiofilhowz merged commit f5f507c into main Jun 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants