Skip to content

test(archive): add CLI output contract tests, FTS failure mode test (#807) - #934

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/807-resolve
May 7, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/807-resolve

Conversation

@Sinity

@Sinity Sinity commented May 7, 2026

Copy link
Copy Markdown
Owner

CLI contract tests + FTS failure mode test.

Copilot AI review requested due to automatic review settings May 7, 2026 17:47
@Sinity
Sinity merged commit 413bcd2 into master May 7, 2026
@Sinity
Sinity deleted the feature/fix/807-resolve branch May 7, 2026 17:47
@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 39 minutes and 56 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c578cdf3-e194-4465-9df2-425d3bcded41

📥 Commits

Reviewing files that changed from the base of the PR and between 3b91a42 and 7170946.

📒 Files selected for processing (2)
  • tests/unit/cli/test_output_contracts.py
  • tests/unit/storage/test_fts5.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/807-resolve

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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread tests/unit/cli/test_output_contracts.py Resolved

Copilot AI 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.

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.

Comment on lines +1554 to +1557
from polylogue.storage.sqlite.schema_ddl_archive import ARCHIVE_STORAGE_DDL

conn = sqlite3.connect(":memory:")
conn.executescript(ARCHIVE_STORAGE_DDL)
Comment on lines +1559 to +1560
"INSERT INTO conversations(conversation_id, provider_name, provider_conversation_id) VALUES(?,?,?)",
("c1", "test", "pc1"),
Comment on lines +1564 to +1568
# 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"),
)
Comment on lines +1557 to +1592
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()
Comment on lines +26 to +39
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
Sinity added a commit that referenced this pull request May 7, 2026
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
Sinity added a commit that referenced this pull request May 7, 2026
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
@Sinity

Sinity commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 78.F028 / P1: fixed-already at the checked revision: tests/unit/cli/test_output_contracts.py:28 invokes config directly with --format json, and line 38 invokes config without a subcommand. Neither test supplies the unsupported show argument.

Only the rows listed above are dispositioned. Held findings remain open.

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