Skip to content

test: type cli command contracts - #289

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/cli-test-contracts
Apr 21, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/cli-test-contracts

Conversation

@Sinity

@Sinity Sinity commented Apr 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Replace dynamic test annotations across 11 CLI command-contract files with concrete fixture, path, runner, JSON, and generated-case types.
  • Type CLI property-test case inputs from the existing strategy dataclasses instead of treating them as unstructured values.
  • Add explicit JSON result narrowing helpers where CLI envelopes intentionally return object-shaped decoded payloads.

Problem

The mypy cleanup campaign still had broad Any use in CLI tests. These files cover command routing, JSON envelopes, reset behavior, runtime health, query execution laws, and embed command contracts, but dynamic annotations hid fixture and payload contract drift.

Solution

Typed the CLI test surfaces around existing shared fixtures (dict[str, Path], CliRunner, pytest.MonkeyPatch, pytest.CaptureFixture[str], ConversationRepository) and existing strategy case dataclasses. Where decoded JSON carries mixed payloads, tests now narrow result objects explicitly before indexing.

Ref #281

Verification

  • ruff check tests/unit/cli/test_embed.py tests/unit/cli/test_analytics.py tests/unit/cli/test_check_runtime.py tests/unit/cli/test_auth.py tests/unit/cli/test_run_int.py tests/unit/cli/test_deterministic_output.py tests/unit/cli/test_reset.py tests/unit/cli/test_json_envelope_contract.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_qa.py tests/unit/cli/test_terminal_snapshots.py
  • mypy tests/unit/cli/test_embed.py tests/unit/cli/test_analytics.py tests/unit/cli/test_check_runtime.py tests/unit/cli/test_auth.py tests/unit/cli/test_run_int.py tests/unit/cli/test_deterministic_output.py tests/unit/cli/test_reset.py tests/unit/cli/test_json_envelope_contract.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_qa.py tests/unit/cli/test_terminal_snapshots.py
  • pytest -q tests/unit/cli/test_embed.py tests/unit/cli/test_analytics.py tests/unit/cli/test_check_runtime.py tests/unit/cli/test_auth.py tests/unit/cli/test_run_int.py tests/unit/cli/test_deterministic_output.py tests/unit/cli/test_reset.py tests/unit/cli/test_json_envelope_contract.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_qa.py tests/unit/cli/test_terminal_snapshots.py
  • PATH=/tmp/polylogue-281/.cache/codex-bin:$PATH devtools verify --quick

@coderabbitai

coderabbitai Bot commented Apr 21, 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 13 minutes and 0 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 13 minutes and 0 seconds.

⌛ 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: 6d70ff4a-dcc7-4f33-ac3d-c997c61d403d

📥 Commits

Reviewing files that changed from the base of the PR and between c552101 and b362244.

📒 Files selected for processing (11)
  • tests/unit/cli/test_analytics.py
  • tests/unit/cli/test_auth.py
  • tests/unit/cli/test_check_runtime.py
  • tests/unit/cli/test_deterministic_output.py
  • tests/unit/cli/test_embed.py
  • tests/unit/cli/test_json_envelope_contract.py
  • tests/unit/cli/test_qa.py
  • tests/unit/cli/test_query_exec_laws.py
  • tests/unit/cli/test_reset.py
  • tests/unit/cli/test_run_int.py
  • tests/unit/cli/test_terminal_snapshots.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/cli-test-contracts

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.

@Sinity
Sinity merged commit 659e3ee into master Apr 21, 2026
13 checks passed
@Sinity
Sinity deleted the feature/refactor/cli-test-contracts branch April 21, 2026 10:04
Sinity added a commit that referenced this pull request Apr 22, 2026
## Summary
- Replace dynamic test annotations across 11 CLI command-contract files with concrete fixture, path, runner, JSON, and generated-case types.
- Type CLI property-test case inputs from the existing strategy dataclasses instead of treating them as unstructured values.
- Add explicit JSON result narrowing helpers where CLI envelopes intentionally return object-shaped decoded payloads.

## Problem
The mypy cleanup campaign still had broad `Any` use in CLI tests. These files cover command routing, JSON envelopes, reset behavior, runtime health, query execution laws, and embed command contracts, but dynamic annotations hid fixture and payload contract drift.

## Solution
Typed the CLI test surfaces around existing shared fixtures (`dict[str, Path]`, `CliRunner`, `pytest.MonkeyPatch`, `pytest.CaptureFixture[str]`, `ConversationRepository`) and existing strategy case dataclasses. Where decoded JSON carries mixed payloads, tests now narrow result objects explicitly before indexing.

Ref #281

## Verification
- `ruff check tests/unit/cli/test_embed.py tests/unit/cli/test_analytics.py tests/unit/cli/test_check_runtime.py tests/unit/cli/test_auth.py tests/unit/cli/test_run_int.py tests/unit/cli/test_deterministic_output.py tests/unit/cli/test_reset.py tests/unit/cli/test_json_envelope_contract.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_qa.py tests/unit/cli/test_terminal_snapshots.py`
- `mypy tests/unit/cli/test_embed.py tests/unit/cli/test_analytics.py tests/unit/cli/test_check_runtime.py tests/unit/cli/test_auth.py tests/unit/cli/test_run_int.py tests/unit/cli/test_deterministic_output.py tests/unit/cli/test_reset.py tests/unit/cli/test_json_envelope_contract.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_qa.py tests/unit/cli/test_terminal_snapshots.py`
- `pytest -q tests/unit/cli/test_embed.py tests/unit/cli/test_analytics.py tests/unit/cli/test_check_runtime.py tests/unit/cli/test_auth.py tests/unit/cli/test_run_int.py tests/unit/cli/test_deterministic_output.py tests/unit/cli/test_reset.py tests/unit/cli/test_json_envelope_contract.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_qa.py tests/unit/cli/test_terminal_snapshots.py`
- `PATH=/tmp/polylogue-281/.cache/codex-bin:$PATH devtools verify --quick`
Sinity added a commit that referenced this pull request Apr 22, 2026
CLI tests covering command routing, JSON envelopes, reset behavior,
runtime health, query execution laws, and embed command contracts
still had broad `Any` use. Dynamic annotations hid fixture and
payload contract drift.

Replaces dynamic test annotations across 11 CLI command-contract
files with concrete fixture, path, runner, JSON, and generated-case
types. Types the test surfaces around existing shared fixtures
(`dict[str, Path]`, `CliRunner`, `pytest.MonkeyPatch`,
`pytest.CaptureFixture[str]`, `ConversationRepository`) and
existing strategy case dataclasses. Where decoded JSON carries
mixed payloads, tests now narrow result objects explicitly before
indexing. Types CLI property-test case inputs from the existing
strategy dataclasses instead of treating them as unstructured
values; adds explicit JSON result narrowing helpers where CLI
envelopes intentionally return object-shaped decoded payloads.

Verification: ruff + mypy + pytest over the 11 touched CLI test
files; devtools verify --quick green.

Ref #281
Sinity added a commit that referenced this pull request Apr 22, 2026
CLI tests covering command routing, JSON envelopes, reset behavior,
runtime health, query execution laws, and embed command contracts
still had broad `Any` use. Dynamic annotations hid fixture and
payload contract drift.

Replaces dynamic test annotations across 11 CLI command-contract
files with concrete fixture, path, runner, JSON, and generated-case
types. Types the test surfaces around existing shared fixtures
(`dict[str, Path]`, `CliRunner`, `pytest.MonkeyPatch`,
`pytest.CaptureFixture[str]`, `ConversationRepository`) and
existing strategy case dataclasses. Where decoded JSON carries
mixed payloads, tests now narrow result objects explicitly before
indexing. Types CLI property-test case inputs from the existing
strategy dataclasses instead of treating them as unstructured
values; adds explicit JSON result narrowing helpers where CLI
envelopes intentionally return object-shaped decoded payloads.

Verification: ruff + mypy + pytest over the 11 touched CLI test
files; devtools verify --quick green.

Ref #281
Sinity added a commit that referenced this pull request Apr 22, 2026
CLI tests covering command routing, JSON envelopes, reset behavior,
runtime health, query execution laws, and embed command contracts
still had broad `Any` use. Dynamic annotations hid fixture and
payload contract drift.

Replaces dynamic test annotations across 11 CLI command-contract
files with concrete fixture, path, runner, JSON, and generated-case
types. Types the test surfaces around existing shared fixtures
(`dict[str, Path]`, `CliRunner`, `pytest.MonkeyPatch`,
`pytest.CaptureFixture[str]`, `ConversationRepository`) and
existing strategy case dataclasses. Where decoded JSON carries
mixed payloads, tests now narrow result objects explicitly before
indexing. Types CLI property-test case inputs from the existing
strategy dataclasses instead of treating them as unstructured
values; adds explicit JSON result narrowing helpers where CLI
envelopes intentionally return object-shaped decoded payloads.

Verification: ruff + mypy + pytest over the 11 touched CLI test
files; devtools verify --quick green.

Ref #281
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ 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".

@Sinity
Sinity requested review from Copilot and removed request for Copilot May 1, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant