Skip to content

Conversation

@ocean
Copy link
Owner

@ocean ocean commented Dec 30, 2025

Add cleanup for -shm and -wal files in test teardown callbacks to prevent leftover SQLite WAL mode files between test runs.

Summary by CodeRabbit

  • Tests

    • Expanded test cleanup across suites to remove leftover SQLite auxiliary files after test runs.
  • Documentation

    • Removed an internal feature analysis summary and a development guide to streamline docs.
  • Chores

    • Updated the public issue tracker entry to reflect a status change (workflow/state updated).

Note: No user-facing functionality was changed.

✏️ Tip: You can customize this high-level summary in your review settings.

Add cleanup for -shm and -wal files in test teardown callbacks to prevent
leftover SQLite WAL mode files between test runs.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2025

Walkthrough

This PR removes two documentation files, updates one issue's status in .beads/issues.jsonl, and extends test teardown across many test files to also remove SQLite auxiliary -shm and -wal files.

Changes

Cohort / File(s) Summary
Documentation Removals
FEATURE_ANALYSIS_SUMMARY.md, ecto_libsql_development_guide.md
Deleted two documentation artifacts: a feature analysis summary and a development guide for ecto_libsql.
Issue Status Update
.beads/issues.jsonl
Issue el-fpi status changed from open to in_progress.
Test Cleanup Extensions
test/...
test/advanced_features_test.exs, test/batch_features_test.exs, test/connection_features_test.exs, test/ecto_adapter_test.exs, test/ecto_integration_test.exs, test/ecto_libsql_test.exs, test/ecto_migration_test.exs, test/ecto_sql_compatibility_test.exs, test/fuzz_test.exs, test/pragma_test.exs, test/prepared_statement_test.exs, test/savepoint_test.exs, test/security_test.exs, test/statement_features_test.exs, test/statement_ownership_test.exs, test/stmt_caching_benchmark_test.exs
Added removal of SQLite auxiliary files (-shm and -wal) in on_exit/cleanup across many tests; no functional/test logic changes beyond teardown.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 I hopped through files, neat and spry,
Swept -shm and -wal where leftovers lie,
Docs waved goodbye, an issue moved on,
Tests end tidy, then I’m gone. 🌿

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarises the main change: adding cleanup for SQLite WAL files in test teardown across multiple test files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch adjust-tests

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
test/ecto_libsql_test.exs (1)

497-497: Suggest adding WAL file cleanup for encrypted databases.

For consistency with the PR objective and the cleanup patterns added elsewhere in this file, consider also removing -shm and -wal files for the encrypted database files. The same applies to the cleanup at lines 540, 604, and 670.

🔎 Proposed additions for consistent cleanup

For line 497:

 # Clean up
 File.rm("z_ecto_libsql_test-encrypted.db")
+File.rm("z_ecto_libsql_test-encrypted.db-shm")
+File.rm("z_ecto_libsql_test-encrypted.db-wal")

For line 540:

 # Clean up
 File.rm("z_ecto_libsql_test-encrypted2.db")
+File.rm("z_ecto_libsql_test-encrypted2.db-shm")
+File.rm("z_ecto_libsql_test-encrypted2.db-wal")

For line 604:

 # Clean up
 File.rm("z_ecto_libsql_test-encrypted3.db")
+File.rm("z_ecto_libsql_test-encrypted3.db-shm")
+File.rm("z_ecto_libsql_test-encrypted3.db-wal")

For line 670:

 # Clean up
 File.rm("z_ecto_libsql_test-encrypted4.db")
+File.rm("z_ecto_libsql_test-encrypted4.db-shm")
+File.rm("z_ecto_libsql_test-encrypted4.db-wal")
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43bf6e6 and abe4b57.

⛔ Files ignored due to path filters (1)
  • mix.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • .beads/issues.jsonl
  • FEATURE_ANALYSIS_SUMMARY.md
  • ecto_libsql_development_guide.md
  • test/advanced_features_test.exs
  • test/batch_features_test.exs
  • test/connection_features_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/ecto_libsql_test.exs
  • test/ecto_migration_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/fuzz_test.exs
  • test/pragma_test.exs
  • test/prepared_statement_test.exs
  • test/savepoint_test.exs
  • test/security_test.exs
  • test/statement_features_test.exs
  • test/statement_ownership_test.exs
  • test/stmt_caching_benchmark_test.exs
💤 Files with no reviewable changes (2)
  • ecto_libsql_development_guide.md
  • FEATURE_ANALYSIS_SUMMARY.md
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ex,exs,rs,md}

📄 CodeRabbit inference engine (CLAUDE.md)

ALWAYS use British/Australian English spelling and grammar for code, comments, and documentation, except where required for function calls, SQL keywords, error messages, or compatibility with external systems that may use US English

Files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
**/*.{ex,exs}

📄 CodeRabbit inference engine (CLAUDE.md)

ALWAYS run the Elixir formatter (mix format --check-formatted) before committing changes and fix any issues

**/*.{ex,exs}: For Ecto schema definitions in Elixir, use Ecto.Schema and Ecto.Changeset modules to define data models with proper validation and type annotations
Use prepared statements with automatic caching for repeated queries in ecto_libsql to achieve ~10-15x performance improvement; statements are cached internally and bindings are cleared via stmt.reset() between calls
For bulk insert operations in ecto_libsql, use batch_transactional/2 to group multiple inserts into a single atomic transaction, providing better performance than individual inserts
Always use pattern matching for database operation results in ecto_libsql to handle both success and error cases; never use bare unwrap patterns that could crash the VM
For read-heavy workloads with ecto_libsql, use remote replica mode (libsql:// URI with local database file and sync: true) to achieve microsecond read latency from local SQLite while auto-syncing writes to remote Turso
Use vector embeddings with ecto_libsql for semantic search by creating vector columns with EctoLibSql.Native.vector_type/2, storing embeddings via vector() SQL function, and querying with vector_distance_cos/2 for cosine distance calculation
For transaction handling in ecto_libsql, use transaction behaviours (DEFERRED, IMMEDIATE, EXCLUSIVE, READ_ONLY) to control lock acquisition; use IMMEDIATE for write-heavy workloads to prevent writer starvation
Use savepoints (create_savepoint, release_savepoint_by_name, rollback_to_savepoint_by_name) within transactions for partial rollback and error recovery, particularly in batch import scenarios
For large result set processing in ecto_libsql, use DBConnection.stream/3 with cursor-based streaming instead of loading all rows into memory; configure batch size with max_rows option
Use EctoLibSql.Pragma module to configure SQLite parameters: enable_foreign_keys/1, set_journal_mode/2 (p...

Files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
test/**/*.exs

📄 CodeRabbit inference engine (CLAUDE.md)

test/**/*.exs: Add tests for all new features in appropriate Elixir test files (test/ecto_*_test.exs) and Rust test modules (native/ecto_libsql/src/tests/), covering happy path, error cases, edge cases, and type conversions
Add comprehensive tests for unsupported functions asserting that they always return {:error, :unsupported} and that they don't modify database state or corrupt connections

Files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
test/**/*.{ex,exs}

📄 CodeRabbit inference engine (AGENTS.md)

test/**/*.{ex,exs}: For testing, use fixtures or factories (e.g., ExMachina) to create test data in a predictable, maintainable way rather than hardcoding test data
Document and test all database edge cases: NULL handling, type coercions, constraint violations, and concurrent modifications

Files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
test/**/*migration*test.exs

📄 CodeRabbit inference engine (CLAUDE.md)

For SQLite migrations that require column type changes or drops (which SQLite doesn't support via ALTER), use the table recreation pattern: create new table, copy data with transformations, swap tables, and recreate indexes

Files:

  • test/ecto_migration_test.exs
🧠 Learnings (32)
📓 Common learnings
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to lib/ecto/adapters/libsql.ex : When implementing Ecto storage operations (create, drop, status) in lib/ecto/adapters/libsql.ex, ensure they properly handle both local SQLite and remote Turso databases via the connection mode in EctoLibSql.State
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Use EctoLibSql.Pragma module to configure SQLite parameters: enable_foreign_keys/1, set_journal_mode/2 (preferably WAL), set_cache_size/2, set_synchronous/2, and user_version/1 for schema versioning
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Always clean up prepared statement resources by calling EctoLibSql.Native.close_stmt/1 when statements are no longer needed

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/pragma_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_integration_test.exs
  • test/statement_features_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Use prepared statements with automatic caching for repeated queries in ecto_libsql to achieve ~10-15x performance improvement; statements are cached internally and bindings are cleared via stmt.reset() between calls

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/statement_ownership_test.exs
  • test/prepared_statement_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to test/**/*.exs : Add comprehensive tests for unsupported functions asserting that they always return {:error, :unsupported} and that they don't modify database state or corrupt connections

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
  • .beads/issues.jsonl
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to test/**/*.{ex,exs} : Document and test all database edge cases: NULL handling, type coercions, constraint violations, and concurrent modifications

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
  • .beads/issues.jsonl
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to lib/**/*.ex : When working with database locks, use transactions with proper timeout configuration, ensure connections are properly closed in try-after blocks, and use immediate/exclusive transaction behaviours for write-heavy workloads to minimise lock contention

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/pragma_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/statement_features_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Implement supervision tree for database workers to handle connection lifecycle and enable automatic restart on connection failure

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: When debugging failing tests, run with trace (`mix test file.exs --trace`), verify NIF compilation (`File.exists?("priv/native/ecto_libsql.so")`), check Rust output with `cargo test -- --nocapture`, and run Rust tests independently to isolate issues

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Always handle database connection errors gracefully by pattern matching on {:ok, state} and {:error, reason} tuples; use supervision trees to manage connection lifecycle

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/statement_features_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to test/**/*migration*test.exs : For SQLite migrations that require column type changes or drops (which SQLite doesn't support via ALTER), use the table recreation pattern: create new table, copy data with transformations, swap tables, and recreate indexes

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to native/ecto_libsql/src/!(tests)/**/*.rs : In Rust async blocks within NIFs, drop registry locks before entering the `TOKIO_RUNTIME.block_on(async { ... })` call to prevent deadlocks, then re-acquire locks if needed after the async block completes

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/savepoint_test.exs
  • test/statement_ownership_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/ecto_migration_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to lib/ecto_libsql/native.ex : For each new Rust NIF function, add corresponding Elixir NIF stubs and safe wrapper functions in lib/ecto_libsql/native.ex, with proper state management via EctoLibSql.State

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/savepoint_test.exs
  • test/pragma_test.exs
  • test/prepared_statement_test.exs
  • test/statement_features_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Use Repo.transaction/1 with with/1 clauses to handle multiple database operations atomically and rollback on error

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to lib/ecto/adapters/libsql.ex : When implementing Ecto storage operations (create, drop, status) in lib/ecto/adapters/libsql.ex, ensure they properly handle both local SQLite and remote Turso databases via the connection mode in EctoLibSql.State

Applied to files:

  • test/stmt_caching_benchmark_test.exs
  • test/savepoint_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to test/**/*.exs : Add tests for all new features in appropriate Elixir test files (test/ecto_*_test.exs) and Rust test modules (native/ecto_libsql/src/tests/), covering happy path, error cases, edge cases, and type conversions

Applied to files:

  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/advanced_features_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
  • .beads/issues.jsonl
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to config/test.exs : Configure Repo in test environment to use in-memory or separate test database; avoid sharing production database with tests

Applied to files:

  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to test/turso_remote_test.exs : For Turso remote tests, use environment variables TURSO_DB_URI and TURSO_AUTH_TOKEN, loading them from .env.local file before running tests; remote tests should be skipped by default if credentials are missing

Applied to files:

  • test/connection_features_test.exs
  • test/ecto_libsql_test.exs
  • test/ecto_adapter_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to config/**/*.{exs,ex} : For ecto_libsql, use local mode (database: "file.db") for development and testing; use remote replica mode for production

Applied to files:

  • test/connection_features_test.exs
  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to priv/repo/migrations/*.{ex,exs} : When migrating from standard SQLite to libSQL with ALTER COLUMN, understand that changes only affect new/updated rows; use table recreation pattern on standard SQLite if full revalidation is needed

Applied to files:

  • test/savepoint_test.exs
  • test/batch_features_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_migration_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to native/ecto_libsql/src/!(tests)/**/*.rs : In Rust, all non-test code must have no `.unwrap()` calls; this was a critical refactoring in v0.5.0 to eliminate 146 unwrap calls and prevent BEAM VM crashes from panics in native code

Applied to files:

  • test/savepoint_test.exs
  • test/ecto_libsql_test.exs
  • test/statement_ownership_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/ecto_sql_compatibility_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_adapter_test.exs
  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
  • test/ecto_migration_test.exs
  • test/statement_features_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Use savepoints (create_savepoint, release_savepoint_by_name, rollback_to_savepoint_by_name) within transactions for partial rollback and error recovery, particularly in batch import scenarios

Applied to files:

  • test/savepoint_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : For read-heavy workloads with ecto_libsql, use remote replica mode (libsql:// URI with local database file and sync: true) to achieve microsecond read latency from local SQLite while auto-syncing writes to remote Turso

Applied to files:

  • test/batch_features_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Use EctoLibSql.Pragma module to configure SQLite parameters: enable_foreign_keys/1, set_journal_mode/2 (preferably WAL), set_cache_size/2, set_synchronous/2, and user_version/1 for schema versioning

Applied to files:

  • test/ecto_libsql_test.exs
  • test/advanced_features_test.exs
  • test/pragma_test.exs
  • test/security_test.exs
  • test/prepared_statement_test.exs
  • test/ecto_integration_test.exs
  • test/ecto_migration_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to priv/repo/migrations/*.{ex,exs} : In Ecto migrations with ecto_libsql, use ALTER COLUMN to modify column attributes (type, NOT NULL, DEFAULT, CHECK, REFERENCES); note that changes only apply to new/updated rows and existing data is not revalidated

Applied to files:

  • test/ecto_libsql_test.exs
  • test/ecto_migration_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Store encryption keys in environment variables or secret management services, not hardcoded; use at least 32-character encryption keys for database encryption with ecto_libsql

Applied to files:

  • test/security_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Always use pattern matching for database operation results in ecto_libsql to handle both success and error cases; never use bare unwrap patterns that could crash the VM

Applied to files:

  • test/ecto_sql_compatibility_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to native/ecto_libsql/src/tests/**/*.rs : In Rust test modules (marked with `#[cfg(test)]`), `.unwrap()` is permitted for simplicity, but production code must never use it

Applied to files:

  • test/ecto_adapter_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to native/ecto_libsql/src/!(tests)/**/*.rs : In Rust, use the `safe_lock(&REGISTRY, "context_description")` helper function instead of directly calling `.lock().unwrap()` on Mutex types to safely acquire locks with proper error handling

Applied to files:

  • test/ecto_adapter_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to test/**/*.{ex,exs} : For testing, use fixtures or factories (e.g., ExMachina) to create test data in a predictable, maintainable way rather than hardcoding test data

Applied to files:

  • test/ecto_integration_test.exs
  • test/fuzz_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to priv/repo/migrations/*.{ex,exs} : Document RANDOM ROWID usage in migrations as a libSQL extension not available in standard SQLite; note that it is mutually exclusive with WITHOUT ROWID and AUTOINCREMENT

Applied to files:

  • test/ecto_migration_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to priv/repo/migrations/*.{ex,exs} : Use foreign key constraints in migrations with references/2 and on_delete options (delete_all, nilify_all) to maintain referential integrity

Applied to files:

  • test/ecto_migration_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to native/ecto_libsql/src/!(tests)/**/*.rs : When adding a new NIF function in Rust, place it in the appropriate module based on functionality: connection.rs (lifecycle), query.rs (execution), transaction.rs (transactions), batch.rs (batch operations), statement.rs (prepared statements), cursor.rs (streaming), replication.rs (replica sync), metadata.rs (metadata access), or savepoint.rs (nested transactions)

Applied to files:

  • .beads/issues.jsonl
🧬 Code graph analysis (5)
test/stmt_caching_benchmark_test.exs (1)
test/turso_remote_test.exs (1)
  • defp cleanup_local_db(db_path) do (35-41)
test/connection_features_test.exs (1)
test/turso_remote_test.exs (1)
  • defp cleanup_local_db(db_path) do (35-41)
test/savepoint_test.exs (2)
test/turso_remote_test.exs (1)
  • defp cleanup_local_db(db_path) do (35-41)
native/ecto_libsql/src/tests/integration_tests.rs (1)
  • cleanup_test_db (18-20)
test/batch_features_test.exs (1)
test/turso_remote_test.exs (1)
  • defp cleanup_local_db(db_path) do (35-41)
test/statement_ownership_test.exs (1)
test/turso_remote_test.exs (1)
  • defp cleanup_local_db(db_path) do (35-41)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Elixir 1.18.0 / OTP 27.0 / ubuntu-latest
  • GitHub Check: Elixir 1.18.0 / OTP 27.0 / macos-latest
  • GitHub Check: Analyze (rust)
🔇 Additional comments (13)
test/pragma_test.exs (1)

14-15: LGTM! Proper WAL file cleanup added.

The addition of -shm and -wal file cleanup correctly addresses SQLite Write-Ahead Logging artefacts left after tests. Using File.rm/1 without explicit error handling is acceptable in test teardown, as it returns {:error, :enoent} for non-existent files without raising.

test/stmt_caching_benchmark_test.exs (1)

29-30: Consistent WAL cleanup pattern completed across test suite.

This completes the systematic addition of SQLite WAL artefact cleanup across all test files in the PR. The consistent pattern of removing -shm and -wal files after test execution ensures no auxiliary database files are left behind between test runs.

test/prepared_statement_test.exs (1)

33-34: LGTM! Proper cleanup of SQLite auxiliary files.

The addition of WAL (Write-Ahead Log) and SHM (Shared Memory) file cleanup is correct and ensures no leftover ancillary files remain after tests. The use of File.rm/1 (which silently ignores errors if files don't exist) is appropriate for best-effort cleanup operations.

test/batch_features_test.exs (1)

17-18: LGTM! Consistent cleanup pattern applied.

The WAL and SHM file cleanup follows the same pattern used across the test suite, ensuring complete teardown of SQLite database artifacts.

test/savepoint_test.exs (1)

39-40: LGTM! Complete test database cleanup.

Properly extends teardown to remove SQLite WAL and SHM files, preventing leftover artifacts between test runs.

test/security_test.exs (1)

36-37: LGTM! Cleanup properly positioned within error handling.

The WAL and SHM file cleanup is correctly placed within the on_exit callback and benefits from the existing try-rescue block that handles disconnect errors.

test/fuzz_test.exs (1)

39-40: LGTM! Essential cleanup for fuzz testing.

Proper cleanup of WAL and SHM files is particularly important for fuzz tests, which exercise arbitrary inputs and may leave the database in various states. This ensures a clean slate for each test run.

test/statement_ownership_test.exs (1)

24-25: LGTM! Both test databases properly cleaned up.

Correctly extends cleanup to remove auxiliary files for both test databases used in cross-connection ownership tests. The pattern is consistently applied to db_file1 and db_file2.

Also applies to: 27-28

test/ecto_adapter_test.exs (1)

12-16: LGTM! Cleanup refactored and enhanced.

The on_exit callback now provides comprehensive cleanup of the test database and its auxiliary files. The initial cleanup at line 10 is retained, and the on_exit ensures complete teardown regardless of test outcome.

.beads/issues.jsonl (1)

17-17: Status update noted.

Issue el-fpi status updated from open to in_progress, indicating work has commenced on fixing the binary data round-trip test failure for single null byte values.

test/ecto_libsql_test.exs (3)

8-9: LGTM! Proper cleanup of SQLite auxiliary files.

The addition of -shm and -wal file removal ensures clean test state by removing any leftover Write-Ahead Logging mode files from previous test runs.


11-16: LGTM! Proper teardown in on_exit callback.

The on_exit callback ensures bar.db and its WAL auxiliary files are cleaned up after all tests complete, maintaining test isolation and preventing leftover files between test runs.


36-37: LGTM! Consistent per-test cleanup.

The addition of -shm and -wal file cleanup in the per-test on_exit callback maintains consistency with the setup_all cleanup pattern and ensures proper test isolation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
test/ecto_libsql_test.exs (1)

8-16: LGTM! Comprehensive WAL cleanup added.

The additions properly clean up SQLite Write-Ahead Logging auxiliary files (-shm and -wal) for the bar database in both initial setup and teardown. This prevents leftover files between test runs.

Optional: Consider a helper function to reduce duplication

The pattern of cleaning up base + -shm + -wal files is repeated throughout the test suite. Consider extracting to a helper:

+  defp cleanup_db_files(base_name) do
+    File.rm(base_name)
+    File.rm(base_name <> "-shm")
+    File.rm(base_name <> "-wal")
+  end
+
   setup_all do
     # Clean up any existing test database from previous runs
-    File.rm("z_ecto_libsql_test-bar.db")
-    File.rm("z_ecto_libsql_test-bar.db-shm")
-    File.rm("z_ecto_libsql_test-bar.db-wal")
+    cleanup_db_files("z_ecto_libsql_test-bar.db")

     on_exit(fn ->
       # Clean up bar.db at end of all tests too
-      File.rm("z_ecto_libsql_test-bar.db")
-      File.rm("z_ecto_libsql_test-bar.db-shm")
-      File.rm("z_ecto_libsql_test-bar.db-wal")
+      cleanup_db_files("z_ecto_libsql_test-bar.db")
     end)

This same helper could be used in setup callbacks and encryption tests as well.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between abe4b57 and d372ca9.

📒 Files selected for processing (2)
  • .beads/issues.jsonl
  • test/ecto_libsql_test.exs
🚧 Files skipped from review as they are similar to previous changes (1)
  • .beads/issues.jsonl
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ex,exs,rs,md}

📄 CodeRabbit inference engine (CLAUDE.md)

ALWAYS use British/Australian English spelling and grammar for code, comments, and documentation, except where required for function calls, SQL keywords, error messages, or compatibility with external systems that may use US English

Files:

  • test/ecto_libsql_test.exs
**/*.{ex,exs}

📄 CodeRabbit inference engine (CLAUDE.md)

ALWAYS run the Elixir formatter (mix format --check-formatted) before committing changes and fix any issues

**/*.{ex,exs}: For Ecto schema definitions in Elixir, use Ecto.Schema and Ecto.Changeset modules to define data models with proper validation and type annotations
Use prepared statements with automatic caching for repeated queries in ecto_libsql to achieve ~10-15x performance improvement; statements are cached internally and bindings are cleared via stmt.reset() between calls
For bulk insert operations in ecto_libsql, use batch_transactional/2 to group multiple inserts into a single atomic transaction, providing better performance than individual inserts
Always use pattern matching for database operation results in ecto_libsql to handle both success and error cases; never use bare unwrap patterns that could crash the VM
For read-heavy workloads with ecto_libsql, use remote replica mode (libsql:// URI with local database file and sync: true) to achieve microsecond read latency from local SQLite while auto-syncing writes to remote Turso
Use vector embeddings with ecto_libsql for semantic search by creating vector columns with EctoLibSql.Native.vector_type/2, storing embeddings via vector() SQL function, and querying with vector_distance_cos/2 for cosine distance calculation
For transaction handling in ecto_libsql, use transaction behaviours (DEFERRED, IMMEDIATE, EXCLUSIVE, READ_ONLY) to control lock acquisition; use IMMEDIATE for write-heavy workloads to prevent writer starvation
Use savepoints (create_savepoint, release_savepoint_by_name, rollback_to_savepoint_by_name) within transactions for partial rollback and error recovery, particularly in batch import scenarios
For large result set processing in ecto_libsql, use DBConnection.stream/3 with cursor-based streaming instead of loading all rows into memory; configure batch size with max_rows option
Use EctoLibSql.Pragma module to configure SQLite parameters: enable_foreign_keys/1, set_journal_mode/2 (p...

Files:

  • test/ecto_libsql_test.exs
test/**/*.exs

📄 CodeRabbit inference engine (CLAUDE.md)

test/**/*.exs: Add tests for all new features in appropriate Elixir test files (test/ecto_*_test.exs) and Rust test modules (native/ecto_libsql/src/tests/), covering happy path, error cases, edge cases, and type conversions
Add comprehensive tests for unsupported functions asserting that they always return {:error, :unsupported} and that they don't modify database state or corrupt connections

Files:

  • test/ecto_libsql_test.exs
test/**/*.{ex,exs}

📄 CodeRabbit inference engine (AGENTS.md)

test/**/*.{ex,exs}: For testing, use fixtures or factories (e.g., ExMachina) to create test data in a predictable, maintainable way rather than hardcoding test data
Document and test all database edge cases: NULL handling, type coercions, constraint violations, and concurrent modifications

Files:

  • test/ecto_libsql_test.exs
🧠 Learnings (21)
📓 Common learnings
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Use EctoLibSql.Pragma module to configure SQLite parameters: enable_foreign_keys/1, set_journal_mode/2 (preferably WAL), set_cache_size/2, set_synchronous/2, and user_version/1 for schema versioning
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to test/**/*.{ex,exs} : Document and test all database edge cases: NULL handling, type coercions, constraint violations, and concurrent modifications

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to test/**/*.exs : Add comprehensive tests for unsupported functions asserting that they always return {:error, :unsupported} and that they don't modify database state or corrupt connections

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Use EctoLibSql.Pragma module to configure SQLite parameters: enable_foreign_keys/1, set_journal_mode/2 (preferably WAL), set_cache_size/2, set_synchronous/2, and user_version/1 for schema versioning

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to test/**/*migration*test.exs : For SQLite migrations that require column type changes or drops (which SQLite doesn't support via ALTER), use the table recreation pattern: create new table, copy data with transformations, swap tables, and recreate indexes

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to test/**/*.exs : Add tests for all new features in appropriate Elixir test files (test/ecto_*_test.exs) and Rust test modules (native/ecto_libsql/src/tests/), covering happy path, error cases, edge cases, and type conversions

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to priv/repo/migrations/*.{ex,exs} : When migrating from standard SQLite to libSQL with ALTER COLUMN, understand that changes only affect new/updated rows; use table recreation pattern on standard SQLite if full revalidation is needed

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to lib/ecto/adapters/libsql.ex : When implementing Ecto storage operations (create, drop, status) in lib/ecto/adapters/libsql.ex, ensure they properly handle both local SQLite and remote Turso databases via the connection mode in EctoLibSql.State

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to native/ecto_libsql/src/!(tests)/**/*.rs : In Rust, all non-test code must have no `.unwrap()` calls; this was a critical refactoring in v0.5.0 to eliminate 146 unwrap calls and prevent BEAM VM crashes from panics in native code

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to config/**/*.{exs,ex} : For ecto_libsql, use local mode (database: "file.db") for development and testing; use remote replica mode for production

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to priv/repo/migrations/*.{ex,exs} : In Ecto migrations with ecto_libsql, use ALTER COLUMN to modify column attributes (type, NOT NULL, DEFAULT, CHECK, REFERENCES); note that changes only apply to new/updated rows and existing data is not revalidated

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to config/test.exs : Configure Repo in test environment to use in-memory or separate test database; avoid sharing production database with tests

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Always clean up prepared statement resources by calling EctoLibSql.Native.close_stmt/1 when statements are no longer needed

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: When debugging failing tests, run with trace (`mix test file.exs --trace`), verify NIF compilation (`File.exists?("priv/native/ecto_libsql.so")`), check Rust output with `cargo test -- --nocapture`, and run Rust tests independently to isolate issues

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to lib/**/*.ex : When working with database locks, use transactions with proper timeout configuration, ensure connections are properly closed in try-after blocks, and use immediate/exclusive transaction behaviours for write-heavy workloads to minimise lock contention

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Always handle database connection errors gracefully by pattern matching on {:ok, state} and {:error, reason} tuples; use supervision trees to manage connection lifecycle

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Use Repo.transaction/1 with with/1 clauses to handle multiple database operations atomically and rollback on error

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Implement supervision tree for database workers to handle connection lifecycle and enable automatic restart on connection failure

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to test/turso_remote_test.exs : For Turso remote tests, use environment variables TURSO_DB_URI and TURSO_AUTH_TOKEN, loading them from .env.local file before running tests; remote tests should be skipped by default if credentials are missing

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-27T00:00:44.643Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T00:00:44.643Z
Learning: Applies to **/*.{ex,exs} : Store encryption keys in environment variables or secret management services, not hardcoded; use at least 32-character encryption keys for database encryption with ecto_libsql

Applied to files:

  • test/ecto_libsql_test.exs
📚 Learning: 2025-12-17T11:58:26.477Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T11:58:26.477Z
Learning: Applies to native/ecto_libsql/src/!(tests)/**/*.rs : In Rust, use the `safe_lock(&REGISTRY, "context_description")` helper function instead of directly calling `.lock().unwrap()` on Mutex types to safely acquire locks with proper error handling

Applied to files:

  • test/ecto_libsql_test.exs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Elixir 1.18.0 / OTP 27.0 / ubuntu-latest
  • GitHub Check: Elixir 1.18.0 / OTP 27.0 / macos-latest
  • GitHub Check: Analyze (rust)
🔇 Additional comments (2)
test/ecto_libsql_test.exs (2)

36-37: LGTM! Per-test WAL cleanup is correct.

The additions ensure that each test's unique database file has its WAL auxiliary files cleaned up properly, maintaining good test isolation.


498-499: LGTM! Encryption test cleanups are comprehensive.

All four encryption tests now properly clean up WAL auxiliary files alongside the main database files. This ensures no leftover -shm or -wal files persist after encrypted database tests.

Also applies to: 543-544, 609-610, 677-678

@ocean ocean merged commit 19c4c7b into main Dec 30, 2025
14 checks passed
@ocean ocean deleted the adjust-tests branch December 30, 2025 11:31
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