Repository navigation
test(archive): add CLI output contract tests, FTS failure mode test (#807) - #934
Conversation
…807) Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 71709467bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds new unit tests intended to lock in CLI output behavior and to validate an FTS5 trigger suspend/restore failure mode related to #807.
Changes:
- Add a new FTS5 regression test covering trigger suspend/restore behavior.
- Add new CLI “output contract” tests for help output, config formatting, and missing-path errors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
tests/unit/storage/test_fts5.py |
Adds an FTS5 regression test around trigger suspend/restore cycles. |
tests/unit/cli/test_output_contracts.py |
Introduces CLI contract tests for plain help text, config output formats, and error handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from polylogue.storage.sqlite.schema_ddl_archive import ARCHIVE_STORAGE_DDL | ||
|
|
||
| conn = sqlite3.connect(":memory:") | ||
| conn.executescript(ARCHIVE_STORAGE_DDL) |
| "INSERT INTO conversations(conversation_id, provider_name, provider_conversation_id) VALUES(?,?,?)", | ||
| ("c1", "test", "pc1"), |
| # Normal insert with triggers active | ||
| conn.execute( | ||
| "INSERT INTO messages(message_id, conversation_id, role, text, provider_name) VALUES(?,?,?,?,?)", | ||
| ("m1", "c1", "user", "hello world this is a test message", "test"), | ||
| ) |
| conn.executescript(ARCHIVE_STORAGE_DDL) | ||
| conn.execute( | ||
| "INSERT INTO conversations(conversation_id, provider_name, provider_conversation_id) VALUES(?,?,?)", | ||
| ("c1", "test", "pc1"), | ||
| ) | ||
| conn.commit() | ||
|
|
||
| # Normal insert with triggers active | ||
| conn.execute( | ||
| "INSERT INTO messages(message_id, conversation_id, role, text, provider_name) VALUES(?,?,?,?,?)", | ||
| ("m1", "c1", "user", "hello world this is a test message", "test"), | ||
| ) | ||
| conn.commit() | ||
| assert conn.execute("SELECT COUNT(*) FROM messages_fts").fetchone()[0] == 1 | ||
|
|
||
| # Simulate crash recovery: triggers suspended, data inserted, triggers restored | ||
| suspend_fts_triggers_sync(conn) | ||
| conn.execute( | ||
| "INSERT INTO messages(message_id, conversation_id, role, text, provider_name) VALUES(?,?,?,?,?)", | ||
| ("m2", "c1", "assistant", "another message for testing", "test"), | ||
| ) | ||
| restore_fts_triggers_sync(conn) | ||
| conn.commit() | ||
|
|
||
| # New message should be picked up | ||
| conn.execute( | ||
| "INSERT INTO messages(message_id, conversation_id, role, text, provider_name) VALUES(?,?,?,?,?)", | ||
| ("m3", "c1", "user", "third message here", "test"), | ||
| ) | ||
| conn.commit() | ||
|
|
||
| count = conn.execute("SELECT COUNT(*) FROM messages_fts").fetchone()[0] | ||
| # m1 (pre-suspend) + m3 (post-restore) should be indexed | ||
| # m2 was inserted while triggers were suspended | ||
| assert count >= 2, f"Expected at least 2 FTS entries, got {count}" | ||
| conn.close() |
| def test_config_show_json_output() -> None: | ||
| """config show --format json produces valid JSON.""" | ||
| exit_code, output = _invoke("config", "show", "--format", "json") | ||
| assert exit_code == 0 | ||
| data = json.loads(output.strip()) | ||
| assert isinstance(data, dict) | ||
| assert "archive_root" in data or "daemon_host" in data | ||
|
|
||
|
|
||
| def test_config_show_toml_output() -> None: | ||
| """config show (default TOML) produces TOML-like output.""" | ||
| exit_code, output = _invoke("config", "show") | ||
| assert exit_code == 0 | ||
| assert "[" in output # TOML section headers |
| def test_ingest_missing_path_error() -> None: | ||
| """ingest with nonexistent path returns non-zero and error message.""" | ||
| exit_code, output = _invoke("ingest", "/nonexistent/path/12345") | ||
| assert exit_code != 0 |
Catalog-driven invariants for two domains called out in #807's test architecture map: CLI output contracts and FTS5 failure modes. - `tests/unit/cli/test_output_contracts.py`: pins what every user-facing subcommand promises about exit code, stdout shape, and stderr usage so the CLI cannot drift toward leaking raw tracebacks or JSON-on-stdout when a flag is absent. - `tests/unit/storage/test_fts5.py`: extends the existing FTS5 coverage with a failure-mode case proving the trigger-suspended bulk-write path commits and rebuilds even when the rebuild itself raises, so a SIGKILL'd or failing rebuild cannot leave the index permanently desynced. Refs #807
Catalog-driven invariants for two domains called out in #807's test architecture map: CLI output contracts and FTS5 failure modes. - `tests/unit/cli/test_output_contracts.py`: pins what every user-facing subcommand promises about exit code, stdout shape, and stderr usage so the CLI cannot drift toward leaking raw tracebacks or JSON-on-stdout when a flag is absent. - `tests/unit/storage/test_fts5.py`: extends the existing FTS5 coverage with a failure-mode case proving the trigger-suspended bulk-write path commits and rebuilds even when the rebuild itself raises, so a SIGKILL'd or failing rebuild cannot leave the index permanently desynced. Refs #807
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
CLI contract tests + FTS failure mode test.