Skip to content

chore: drop generated artifacts not tracked on master - #215

Merged
jaylfc merged 2 commits into
masterfrom
exec/tsk-4gbzcr
Jul 28, 2026
Merged

chore: drop generated artifacts not tracked on master#215
jaylfc merged 2 commits into
masterfrom
exec/tsk-4gbzcr

Conversation

@jaylfc

@jaylfc jaylfc commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Autonomous build of board card tsk-4gbzcr.

Files:
taosmd/collections.py | 3 ++-
tests/test_collections_db_connect.py | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)

Summary by CodeRabbit

  • Bug Fixes

    • Improved collection database connection handling for better reliability during concurrent access.
    • Enabled WAL mode and a positive busy timeout for collection storage.
  • Tests

    • Added coverage to verify the database connection uses the expected SQLite settings.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

CollectionStore database connection

Layer / File(s) Summary
Shared connection wiring and validation
taosmd/collections.py, tests/test_collections_db_connect.py
CollectionStore uses _db.connect for collections.db; tests verify WAL journal mode and a positive SQLite busy timeout.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 matches a real cleanup aspect of the PR, though it omits the main SQLite connection and test changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 exec/tsk-4gbzcr

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.

@gitar-bot

gitar-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Use shared SQLite connect helper for CollectionStore

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Switch CollectionStore to the shared SQLite connection helper for consistent PRAGMAs.
• Add tests ensuring collections.db uses WAL mode and a non-zero busy timeout.
Diagram

graph TD
  Tests["tests: PRAGMA checks"] --> Store["CollectionStore"] --> Helper["taosmd._db.connect"] --> Conn["SQLite connection"] --> DB[("collections.db")]
  Conn --> Settings["WAL + busy timeout"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Expose a small public diagnostic API instead of using _conn in tests
  • ➕ Avoids coupling tests to a private attribute
  • ➕ Lets refactors change internal connection storage without rewriting tests
  • ➖ Adds surface area to CollectionStore for a narrow need
  • ➖ May encourage production code to rely on diagnostic internals
2. Enforce connection settings centrally via a Store base class / mixin
  • ➕ Makes it harder for future stores to accidentally bypass the shared helper
  • ➕ Encodes the policy once (WAL/timeout) and reuses it everywhere
  • ➖ More structural change than this PR needs
  • ➖ May be overkill if CollectionStore is the last outlier

Recommendation: The PR’s approach (switch to _db.connect + direct PRAGMA assertions) is the right minimal fix for ensuring consistent SQLite configuration. If the team wants stronger encapsulation, consider a follow-up that replaces test access to store._conn with a small diagnostic method or fixture helper.

Files changed (2) +23 / -1

Bug fix (1) +2 / -1
collections.pyOpen collections.db using shared _db.connect helper +2/-1

Open collections.db using shared _db.connect helper

• Imports the shared database helper and replaces direct sqlite3.connect usage with _db.connect. This aligns CollectionStore’s connection settings (e.g., WAL / busy timeout) with other stores using the common helper.

taosmd/collections.py

Tests (1) +21 / -0
test_collections_db_connect.pyAdd tests asserting WAL mode and busy timeout for collections.db +21/-0

Add tests asserting WAL mode and busy timeout for collections.db

• Adds regression tests that instantiate CollectionStore and assert PRAGMA journal_mode is WAL and PRAGMA busy_timeout is non-zero. Ensures connection policy remains consistent across refactors.

tests/test_collections_db_connect.py

@kilo-code-bot

kilo-code-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • taosmd/collections.py
  • tests/test_collections_db_connect.py

Reviewed by step-3.7-flash · Input: 103.9K · Output: 6.9K · Cached: 339.3K

@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: 2

🤖 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 `@tests/test_collections_db_connect.py`:
- Around line 15-19: Update test_collections_db_has_a_busy_timeout to assert
that the PRAGMA busy_timeout result equals taosmd._db.BUSY_TIMEOUT_MS, replacing
the weak timeout > 0 check while preserving the existing CollectionStore
connection setup.
- Around line 6-10: Update test_collections_db_is_in_wal_mode to avoid assuming
tmp_path always supports WAL: run the assertion in a WAL-capable
filesystem/tempdir, or explicitly accept and separately validate the documented
rollback-journal fallback while confirming the CollectionStore connection
remains usable.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b6396e9-55a1-48d9-90e4-bf21d5f69e59

📥 Commits

Reviewing files that changed from the base of the PR and between d0392a7 and b4024ec.

📒 Files selected for processing (2)
  • taosmd/collections.py
  • tests/test_collections_db_connect.py

Comment on lines +6 to +10
def test_collections_db_is_in_wal_mode(tmp_path):
store = CollectionStore(tmp_path)
try:
mode = store._conn.execute("PRAGMA journal_mode").fetchone()[0]
assert mode.lower() == "wal"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files:"
git ls-files | rg '(^|/)(tests/test_collections_db_connect\.py|taosmd/_db\.py)$' || true

echo
echo "Test file:"
if [ -f tests/test_collections_db_connect.py ]; then
  cat -n tests/test_collections_db_connect.py
fi

echo
echo "DB file outline:"
if [ -f taosmd/_db.py ]; then
  wc -l taosmd/_db.py
  ast-grep outline taosmd/_db.py --view compact || true
  echo
  rg -n -C 5 'journal_mode|WAL|busy_timeout|unsupported|fallback|SQLite' taosmd/_db.py
fi

Repository: jaylfc/taosmd

Length of output: 3840


🌐 Web query:

taosmd _db.py journal_mode WAL fallback SQLite unsupported filesystem shared-memory

💡 Result:

SQLite's Write-Ahead Logging (WAL) mode requires shared memory for coordination between processes, which is typically implemented using memory-mapped (mmap) files (-shm files) [1][2][3]. This mechanism is fundamentally incompatible with most network filesystems (e.g., NFS, SMB, CIFS) and certain specialized virtual filesystems (like WSL2's 9P/DrvFS), where shared-memory primitives or necessary POSIX locking semantics are either unsupported or behave incorrectly [2][4][5]. When an application attempts to enable WAL mode on an unsupported filesystem, the PRAGMA journal_mode=WAL; command will fail, often raising an sqlite3.OperationalError (commonly SQLITE_PROTOCOL or SQLITE_IOERR) [6][7][5]. To handle this, robust SQLite implementations (such as the pattern seen in various projects like taosmd or similar database-reliant utilities) often implement a fallback strategy [8][9][6][5]: 1. Detection: The application attempts to set PRAGMA journal_mode=WAL; upon database initialization [6][4]. 2. Error Handling: The application catches the resulting OperationalError when the filesystem does not support the required shared-memory primitives [6][5]. 3. Fallback: Upon failure, the application explicitly sets PRAGMA journal_mode=DELETE; to revert to the traditional rollback journal mode, which is compatible with these restricted filesystems [6][2]. For scenarios where a process is guaranteed to be the sole user of the database, SQLite allows WAL mode without shared memory if the database is opened in EXCLUSIVE locking mode before the first access [10][11][12]. However, this is a restrictive configuration unsuitable for applications requiring concurrent multi-process access [10][11]. In the context of the taosmd project, standard stores utilize a _db.connect helper to consistently apply WAL mode, while other stores (like CollectionStore) have been identified as lacking this configuration, leading to issues with concurrent access and lack of WAL optimizations [8][9]. Projects facing filesystem-specific WAL failures often adopt a "try-WAL-fallback-to-DELETE" wrapper around their connection logic to ensure application stability across diverse deployment environments [6][5].

Citations:


Honor the helper’s documented WAL fallback in this assertion.

taosmd/_db.py documents that PRAGMA journal_mode=WAL can fall back to rollback journal on filesystems without shared-memory support and that the connection remains usable. Running this test against tmp_path without guaranteeing WAL support can therefore fail even though the store is opened as intended. Use a WAL-capable filesystem/tempdir or validate the fallback case separately.

🤖 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 `@tests/test_collections_db_connect.py` around lines 6 - 10, Update
test_collections_db_is_in_wal_mode to avoid assuming tmp_path always supports
WAL: run the assertion in a WAL-capable filesystem/tempdir, or explicitly accept
and separately validate the documented rollback-journal fallback while
confirming the CollectionStore connection remains usable.

Comment on lines +15 to +19
def test_collections_db_has_a_busy_timeout(tmp_path):
store = CollectionStore(tmp_path)
try:
timeout = store._conn.execute("PRAGMA busy_timeout").fetchone()[0]
assert timeout > 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files matching collections_db_connect.py:\n'
fd -a 'test_collections_db_connect.py' . || true

printf '\nRelevant test file excerpt:\n'
f="$(fd 'test_collections_db_connect.py' . | head -n 1)"
if [ -n "${f:-}" ]; then
  cat -n "$f" | sed -n '1,80p'
fi

printf '\nSearch for CollectionStore and BUSY_TIMEOUT_MS:\n'
rg -n "class CollectionStore|CollectionStore|BUSY_TIMEOUT_MS|busy_timeout|BusyTimeout|connect\\(" -S .

Repository: jaylfc/taosmd

Length of output: 12823


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Relevant taosmd/collections.py excerpt:\n'
cat -n taosmd/collections.py | sed -n '135,160p'

printf '\nRelevant taosmd/_db.py excerpt:\n'
cat -n taosmd/_db.py | sed -n '1,70p'

printf '\nImports used by CollectionStore in taosmd/collections.py:\n'
cat -n taosmd/collections.py | sed -n '1,35p'

printf '\nPython semantic probe for SQLite busy_timeout defaults:\n'
python3 - <<'PY'
import sqlite3, tempfile, pathlib
with tempfile.TemporaryDirectory() as d:
    p = pathlib.Path(d) / "collections.db"
    for connect_fn in [sqlite3.connect, sqlite3.connect]:
        path = connect_fn(str(p))
        print(connect_fn.__qualname__, "PRAGMA busy_timeout:", path.execute("PRAGMA busy_timeout").fetchone()[0])
        path.execute("PRAGMA busy_timeout=5000").close()
PY

Repository: jaylfc/taosmd

Length of output: 6737


Assert the configured busy timeout.

timeout > 0 only proves a positive timeout; SQLite’s bare connector default is 5000, which would pass this test even if CollectionStore._db.connect stopped using the configured value. Assert against taosmd._db.BUSY_TIMEOUT_MS instead.

🤖 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 `@tests/test_collections_db_connect.py` around lines 15 - 19, Update
test_collections_db_has_a_busy_timeout to assert that the PRAGMA busy_timeout
result equals taosmd._db.BUSY_TIMEOUT_MS, replacing the weak timeout > 0 check
while preserving the existing CollectionStore connection setup.

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 13 rules

Grey Divider


Remediation recommended

1. Flaky WAL-mode assertion 🐞 Bug ☼ Reliability
Description
test_collections_db_is_in_wal_mode unconditionally asserts journal_mode == 'wal', but _db.connect
explicitly allows WAL to fall back (emitting a warning) on filesystems that don’t support WAL. This
can make CI/dev runs fail in such environments even though the application is designed to keep
working without WAL.
Code

tests/test_collections_db_connect.py[10]

+        assert mode.lower() == "wal"
Relevance

⭐⭐⭐ High

PR#119 accepted WAL fallback (warn, don’t raise); strict journal_mode=='wal' test contradicts this
reliability stance.

PR-#119

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new test requires WAL to always be active, but the repository’s SQLite connection helper
documents and implements a non-fatal fallback when WAL cannot engage (e.g., some network mounts).
That means the asserted condition can be false while the code is still behaving as intended by the
helper.

tests/test_collections_db_connect.py[6-12]
taosmd/_db.py[36-55]
taosmd/_db.py[43-49]
PR-#119

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`test_collections_db_is_in_wal_mode` currently requires `PRAGMA journal_mode` to be exactly `wal`. However, the shared SQLite connector intentionally treats WAL enablement as best-effort: it may fall back to a rollback journal mode on unsupported filesystems and only emits a warning.

### Issue Context
- `_db.connect()` executes `PRAGMA journal_mode=WAL` and reads the result.
- If the result is not `wal` (or `memory`), it **warns** and continues (does not raise).
- The new test contradicts this contract by failing hard when WAL can’t be enabled.

### Fix Focus Areas
- tests/test_collections_db_connect.py[6-13]

### Suggested change
Update the test to accept fallback behavior. One concrete approach:
- Capture warnings during `CollectionStore(tmp_path)` creation.
- Read `PRAGMA journal_mode`.
- If mode is `wal`, pass.
- Otherwise, assert that a `RuntimeWarning` was emitted (or `pytest.skip(...)` with a message indicating WAL unsupported on that filesystem).

This keeps the test verifying “we attempted to enable WAL and made fallback observable” without forcing environments that can’t support WAL to fail.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

store = CollectionStore(tmp_path)
try:
mode = store._conn.execute("PRAGMA journal_mode").fetchone()[0]
assert mode.lower() == "wal"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Flaky wal-mode assertion 🐞 Bug ☼ Reliability

test_collections_db_is_in_wal_mode unconditionally asserts journal_mode == 'wal', but _db.connect
explicitly allows WAL to fall back (emitting a warning) on filesystems that don’t support WAL. This
can make CI/dev runs fail in such environments even though the application is designed to keep
working without WAL.
Agent Prompt
### Issue description
`test_collections_db_is_in_wal_mode` currently requires `PRAGMA journal_mode` to be exactly `wal`. However, the shared SQLite connector intentionally treats WAL enablement as best-effort: it may fall back to a rollback journal mode on unsupported filesystems and only emits a warning.

### Issue Context
- `_db.connect()` executes `PRAGMA journal_mode=WAL` and reads the result.
- If the result is not `wal` (or `memory`), it **warns** and continues (does not raise).
- The new test contradicts this contract by failing hard when WAL can’t be enabled.

### Fix Focus Areas
- tests/test_collections_db_connect.py[6-13]

### Suggested change
Update the test to accept fallback behavior. One concrete approach:
- Capture warnings during `CollectionStore(tmp_path)` creation.
- Read `PRAGMA journal_mode`.
- If mode is `wal`, pass.
- Otherwise, assert that a `RuntimeWarning` was emitted (or `pytest.skip(...)` with a message indicating WAL unsupported on that filesystem).

This keeps the test verifying “we attempted to enable WAL and made fallback observable” without forcing environments that can’t support WAL to fail.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@jaylfc

jaylfc commented Jul 28, 2026

Copy link
Copy Markdown
Owner Author

Lead review, verified rather than accepted.

Implements the card exactly. CollectionStore now opens collections.db through _db.connect — the same helper archive.py, crystallize.py, access_tracker.py, browsing_history.py and pending_decisions.py already use — rather than setting PRAGMAs by hand. That is the right shape: it inherits WAL and the busy timeout from one place, so the next change to connection policy reaches collections automatically instead of drifting.

Card precondition re-verified on the merged code: grep -E "journal|VACUUM|ATTACH|isolation_level|backup" taosmd/collections.py returns nothing, so no behaviour depended on the old journal mode. Tests assert the observable properties (PRAGMA journal_mode == wal, PRAGMA busy_timeout > 0) rather than asserting the helper was called, which is the better assertion — it would still catch a regression if the helper changed.

Suite, same env, both sides — and this run is the first to include the auth surface (per issue #214, my comparison now installs pyjwt + cryptography explicitly, so the three registry-auth files actually execute instead of silently skipping):

passed failed skipped
master 1277 10 2
this branch 1279 10 2

Failing sets byte-identical (the ten known environmental failures: ONNX absent → qmd fallback, torch/CUDA capability). +2 passing, both new.

One thing I fixed rather than bounced: the PR title said "chore: drop generated artifacts not tracked on master", which is a leftover from the lockfile-scrub work and describes nothing in this diff. Retitled. Worth flagging to the lane owner as a pattern — a title that misdescribes the change survives into the squash-merge commit message and makes git log lie about why a line changed.

Merging.

@jaylfc
jaylfc merged commit b1e56b4 into master Jul 28, 2026
3 checks passed
jaylfc added a commit that referenced this pull request Aug 8, 2026
Refreshing the pack at the weekly usage gate. job-005 targeted issue #202,
whose fix has been on master since PR #215 on 2026-07-28 - collections.py
uses the shared _db.connect helper. Before a multi-day pause that job would
have sent a cheaper model to redo landed work. Renamed rather than deleted
so the record survives; issue #202 closed with the same evidence.
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.

1 participant