Repository navigation
test: restore suite collection + fix inherited stale-test failures - #1765
Conversation
…bugs Three pre-existing failures unrelated to any feature work, surfaced once the read-surface PR (#1763) ran the full suite: - tests/infra/app_env.py was imported by test_config_command.py (#1748) but never committed, so pytest aborted collection of the WHOLE suite (one bad import). Restored the helper: an AppEnv with a StringIO-backed console. - test_iter_messages_keyset.py (#1750) seeded messages via raw INSERT without content_hash, getting the schema '' default; the validating mapper rejects empty content_hash on read-back. Fixtures now set a non-empty hash (194 tests). - test_config_command.py (#1748) asserted voyage_api_key redaction, but the flat voyage secret is sourced from the VOYAGE_API_KEY env var (stripped by the autouse env-isolation fixture), not the TOML [embedding] section. Drive the secret through its real source.
…tetime, SQL audit, help snapshots)
📝 WalkthroughWalkthroughThis PR updates test infrastructure and validation assertions across the codebase: it introduces a ChangesTest Infrastructure and Validation Updates
🎯 2 (Simple) | ⏱️ ~12 minutes Possibly Related PRs
Suggested Labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/unit/cli/__snapshots__/test_help_snapshots.ambr (1)
155-183:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFix empty
--helpshort descriptions forblackboard,commands, andrecent(andfacets)
polylogue/cli/click_command_registration.pyregisters root commands via_L(...)withshort_help=_SHORT_HELP.get(name); keys forblackboard,commands, andfacetsare missing from_SHORT_HELP, so Click renders blank short-help even though the command functions have docstrings.
polylogue/cli/click_app.pyregisters query verbs via_LazyCommand(..., short_help=_QUERY_VERB_HELP.get(_verb));_QUERY_VERB_HELPhas no"recent", sorecentalso renders blank.🤖 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/unit/cli/__snapshots__/test_help_snapshots.ambr` around lines 155 - 183, The root cause is missing short-help entries for several commands: add entries for "blackboard", "commands", and "facets" to the _SHORT_HELP mapping used by _L(...) in polylogue/cli/click_command_registration.py, and add "recent" to the _QUERY_VERB_HELP mapping used by _LazyCommand in polylogue/cli/click_app.py; each new key should provide a concise short_help string (or derive one from the command function's docstring) so Click displays non-empty short descriptions for those commands.
🤖 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.
Outside diff comments:
In `@tests/unit/cli/__snapshots__/test_help_snapshots.ambr`:
- Around line 155-183: The root cause is missing short-help entries for several
commands: add entries for "blackboard", "commands", and "facets" to the
_SHORT_HELP mapping used by _L(...) in
polylogue/cli/click_command_registration.py, and add "recent" to the
_QUERY_VERB_HELP mapping used by _LazyCommand in polylogue/cli/click_app.py;
each new key should provide a concise short_help string (or derive one from the
command function's docstring) so Click displays non-empty short descriptions for
those commands.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: da1f1287-bd73-466f-a78a-ec88d7b23f15
📒 Files selected for processing (11)
AGENTS.mddocs/topology-status.mdtests/infra/app_env.pytests/unit/cli/__snapshots__/test_help_snapshots.ambrtests/unit/cli/__snapshots__/test_terminal_snapshots.ambrtests/unit/cli/test_config_command.pytests/unit/lib/test_payload_coercion.pytests/unit/pipeline/test_pipeline_ids.pytests/unit/storage/test_dead_schema_sweep.pytests/unit/storage/test_iter_messages_keyset.pytests/unit/storage/test_no_string_interpolated_sql.py
…ns (#1767) ## Summary Continues clearing the inherited test failures (after #1765). Fixes one real search bug, one real #1737 docs-cleanup gap, and three stale surface pins. ## Problem & Solution Failures that accumulated while CI was off (#1766): 1. **`escape_fts5_query` bug** (`fts_escape_in_insights`): bare-asterisk queries like `* * *` passed through unquoted and SQLite rejected them (`unknown special query: *`). The prefix logic treated any `*`-at-word-boundary as valid `word*` syntax. Now only word-suffixed `*` is preserved; bare asterisks are quoted (safe literal). Updated the `test*` security case to the preserved-prefix form (still MATCH-compiles). 2. **Dangling verification docs** (`render_docs_surface`): #1737 deleted `docs/verification-catalog.md` and `docs/verification-lab.md` but left their entries in `devtools/docs_surface.py`; the renderer skipped the missing files so the README dropped them and the pin failed. Removed the dead entries + test assertion; regenerated the docs README. 3. **Stale surface pins**: `perf_rescue_1314` (v22 moved per-role counts to `conversation_stats`, eliminating the messages scan — dropped the stale assertion); `click_app` (registered 6 new commands); `message_render_envelope` (added `paste_boundary_state`, #1655). ## Verification ``` pytest tests/unit/storage/test_fts_escape_in_insights.py tests/unit/storage/test_query_security.py # 46 passed pytest <perf_rescue, click_app, envelope, render_docs_surface> # all pass devtools verify --quick # push gate green ``` ## Remaining (tracked for follow-up) Still-open inherited failures, triaged in #1765's body — needing per-case judgment: the `ASSURANCE_REGISTRY` real gap (6 new commands need output contracts), `exercise_catalog`/`config source_roots` (ambiguous), and the slower real candidates `test_source_laws` (zip "not seekable" — likely a real regression), `test_resilience` (source_name), `test_acquisition_encoding` (BOM).
## Problem Every JSON conversation export packaged inside a `.zip` (ChatGPT/Claude web exports) silently failed to ingest with `File or stream is not seekable` and was skipped. `process_zip` opens each entry via `zipfile.ZipExtFile` (non-seekable). For individual-JSON entries the path is `emit → _emit_individual → _iter_json_stream → iter_json_stream_with`, which rewinds with `handle.seek(0)` between its ijson multi-strategy attempts. A zip entry can't seek, so the parse raised and the file was dropped at the acquisition boundary. (`_emit_grouped` already materialized to `BytesIO`; the individual path did not.) This is a real ingestion regression for zipped exports — surfaced once the suite could collect again (#1765) and confirmed by tracing the swallowed exception at `source_parsing.py:163`. ## Solution In `iter_json_stream_with`, before the seeking strategies, materialize a non-seekable handle into a `BytesIO` once (the function inherently requires seeking; bounded zip entries are safe to read fully). Added the missing `import io`. ## Verification ``` pytest tests/unit/sources/test_source_laws.py tests/unit/sources/test_acquisition_encoding.py # 123 passed (was 5 failing) ``` Fixes the zip round-trip, raw-capture, multi-conversation-zip, BOM-in-zip, and partial-corruption cases.
## Summary Three more inherited-failure fixes (continuing #1765/#1767/#1768). ## Changes - **`blackboard list --limit`**: used `-n`, violating the repo-wide `-l/--limit` convention enforced by `test_flag_aliases_consistent`. Aligned to `-l` (small CLI fix). - **`exercise_catalog`**: dropped the `insights analytics` nested path from the pin — that command path no longer exists. - **`config source_roots`**: the TOML serializer now renders arrays multi-line (`roots = [\n "/a",\n "/b",\n]`); the test pinned the old single-line spelling. Assert the array shape + members robustly. (Confirmed the cli-override is correctly applied — it was purely a formatting-style drift.) ## Verification ``` pytest <theme_aliases, exercise_catalog, config source_roots, help/terminal snapshots> # all pass ``` ## Deferred (intentionally not touched) The remaining inherited failures cluster on the **in-flux `provider`/`source_name` vocabulary** (#1743 is actively redesigning this) and a product decision — editing them blind risks encoding the wrong interpretation: - `resilience` (4), `ingestion_chaos`, `parsing_service`, `pipeline_probe` (2), `parsers_local_agent` — all turn on parsed `source_name` being the source-config name (`'test'`) vs the detected origin (`'claude-code'`/`'codex'`). Likely a real regression in the origin-vs-source conflation, but it belongs to the #1743 redesign or an explicit operator call. - `ASSURANCE_REGISTRY` — the 6 new commands need declared output contracts (#1272), a per-command product decision.
…1766) ## Summary Restores the `push` / `pull_request` CI triggers that were **accidentally removed** by #718, re-enabling automatic test/lint/nix gating on `master` and PRs. ## Problem #718 (`refactor(cli): remove foreground resource policy`) — a PR whose scope was entirely CLI resource policy, with **no mention of CI** — silently reverted the trigger blocks on four workflows, leaving each with only `workflow_dispatch:` (manual-only): | Workflow | Before #718 | After #718 | |----------|-------------|------------| | `ci.yml` (lint + test ×3 Python) | push + pull_request | **dispatch only** | | `nix.yml` (nix build + flake check) | push + pull_request | **dispatch only** | | `actionlint.yml` | pull_request | **dispatch only** | | `dep-audit.yml` | push + pull_request + weekly schedule | **dispatch only** | Consequence: the CI test gate has not run automatically since **2026-05-02** (the last `ci.yml`/`nix.yml` runs are on `9029a37a`). Across the ~20 commits merged since, **~61 unit-test failures accumulated undetected** — see #1765. This is the root cause of the test debt. (`pr-policy.yml` and `proof-comment.yml` were also gutted by #718, but those stay deleted — that was the intentional ceremonial-verification cleanup in #1737, not collateral. `codeql.yml` retains a working trigger and is unaffected.) ## Solution Restore the exact pre-#718 `on:` blocks (verified against `git show 8b2b0fa~1:.github/workflows/<f>.yml`): - `ci.yml` / `nix.yml`: `push: [master]` + `pull_request: [master]` (opened/reopened/synchronize/ready_for_review) - `actionlint.yml`: `pull_request: [master]` (paths: `.github/workflows/**`, `.github/actions/**`) - `dep-audit.yml`: push/pull_request (paths: `pyproject.toml`, `uv.lock`, the workflow) + weekly `cron: 0 6 * * 1` ## Verification ``` python3 -c "import yaml; ..." # all four on: blocks parse with push/pull_request restored ``` ##⚠️ Expected: re-enabling CI surfaces the pre-existing failures Once merged, `ci.yml` will run on `master` and PRs and will be **red** until the inherited test failures are cleared. That is the intended signal, not a regression introduced here. The known failures are partly fixed in **#1765** (collection error, keyset, config, stale tests) and partly still open (a handful of real-bug candidates triaged in #1765's body). Recommended order: merge #1765, work the remaining real failures, then this fix's CI will go green. Merging this first is also fine — it just makes the existing red state visible. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Enhanced workflow triggers to automatically run validation checks on pull requests and commits targeting the master branch, improving consistency of continuous integration checks. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Fixes the inherited test failures that had accumulated on
master, restores collection of the full unit suite, and surfaces two infrastructure findings: a 4-week CI gap and xdist flakiness that together explain why ~61 failures went unnoticed.Problem
A full
pytest tests/unitrun on master reported 61 failures. Root-cause investigation found:tests/unit/cli/test_config_command.py([bug] Secrets leak viapolylogue config; secret/input write hardening #1748) importedtests.infra.app_env.make_app_env, but that helper module was never committed. pytest aborts on a collection error, so this one bad import masked the true suite state.test_iter_messages_keyset.py([perf] Latent query-scaling hazards: O(M²) pagination, scan-on-completion, wasted sorts #1750) seeded messages via rawINSERTwithoutcontent_hash, getting the schema''default; theMessageRecordvalidator rejects emptycontent_hashon read-back (175 parametrized failures).provider→source_nameerror wording,optional_datetimenow UTC-aware (9735a6f), a new chunked-IN-clause SQL site needing an audit entry, CLI help/list output gaining new commands (commands,recent,--json, …).test_config_command.pyvoyage assertions drove the secret through the TOML[embedding]section, but the flatvoyage_api_keysecret is sourced from theVOYAGE_API_KEYenv var (stripped by the autouse env-isolation fixture).Why these accumulated — two infrastructure findings (need a follow-up)
ci.ymlandnix.ymllast ran on9029a37a(2026-05-02); none of the ~20 commits merged since triggered them. Only Mutation Testing / Pages / Container / CodeQL run on recent commits. The unit-test gate has been effectively off for ~4 weeks — that is how 61 failures landed unnoticed. This is the highest-priority follow-up: fix theci.yml/nix.ymltrigger.-n 16xdist, not real. The entiretests/unit/mcp/test_tool_contracts.pycluster passes in isolation (60 passed) — they fail only under parallel workers (shared-state pollution). Brute-forcing the full suite with-n 16manufactures failures; testmon / per-file runs are the right tool.Solution
tests/infra/app_env.py— anAppEnvwith aStringIO-backed console (unblocks ~10k tests' collection).test_iter_messages_keyset.py— fixtures set a non-emptycontent_hash(194 tests pass).test_config_command.py— drive the voyage secret viaVOYAGE_API_KEY; typed the dynamic console swap formypy --strict.20→22;provider→source_nameerror match;optional_datetimeUTC-aware; audit the chunked-IN-clause SQL site (trusted template +?,?placeholders, values bound); regenerate the help/terminal snapshots for the new commands.AGENTS.md,docs/topology-status.md.Verification
Targeted single-process runs (the brute-force full suite times out and flakes under xdist):
Remaining (deferred — real deterministic failures, triaged)
A smaller set of confirmed-real failures remain (verified failing in isolation), needing per-case judgment — several are stale tests, a few may be real bugs and must not be masked:
test_resilience.py(4) —source_name == 'test'vs'claude-code'(source/provider rename area)test_acquisition_encoding.py(3) — BOM/zip handlingtest_source_laws.py(2) — zip "File or stream is not seekable" (looks like a real bug)test_fts_escape_in_insights.py(2),test_pipeline_probe.py(2), and assorted singlestest_repository_lifecycle_laws.py— a save-idempotency test-semantics question (double-seed thensave_conversationcorrectly reports 0 changed)These are intentionally NOT "fixed" by editing assertions, to avoid masking real regressions — they deserve review with fresh eyes.
Summary by CodeRabbit
New Features
--jsonCLI option as a shortcut for--format jsonwith color and progress disabled.blackboard,commands,completions,config,context,context-pack,correlate,paths,raw,recent.Documentation