Repository navigation
fix: harden CLI error contracts and machine envelopes - #183
Conversation
|
Warning Rate limit exceeded
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 2 minutes and 57 seconds. ⌛ 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 (117)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Ruff drift surfaced on polylogue/storage/backends/queries/stats.py, tests/integration/test_cli_query_mode.py, and tests/unit/cli/test_click_app.py after the rebase onto master. Also refresh the terminal snapshot and showcase baselines for the `--format json` addition to product subcommands. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
a19f24b to
f4a681e
Compare
## Summary PR 2/9. Stacked on `feature/chore/stack-01-governance`. First wave of CLI-surface fixes found during live vetting. Every plain-mode `PolylogueError` now renders as a Click user error rather than a raw traceback, and the machine envelope is consistent across every query verb. ## Problem Live vetting against a real archive exposed a cluster of user-facing regressions on the CLI query surface: - `polylogue --plain stats --by provider --format json` raised a full traceback ending in `DatabaseError` on stale schema, instead of a structured envelope. - `polylogue --plain query --help` advertised an option placement that the real parser rejected (`Error: No such option: --provider`). - `polylogue stats --by provider` silently dropped grouped mode because the positional `stats` verb forced `stats_only=True`. - `polylogue stats --format json` ignored the requested output format in the SQL-backed stats path. - `polylogue --plain --similar "debug parser" list` told users to run `polylogue embed` — an old command. Canonical is `polylogue run embed`. - `polylogue --format json list -n 1` emitted plain early-failure behavior instead of a structured runtime envelope. - The pre-scan command extractor treated option payloads like `json` / `1` as command words, corrupting the machine envelope's `command` field. - `polylogue stats --format json` reported `messages_total=137` while `messages_user=0` and `messages_assistant=0` — role counts were hardcoded to zero, and the filtered branch dropped its temp id table before the word-count query. - `polylogue --format json list -n 10` showed malformed ChatGPT conversation ids like `chatgpt:synthetic-55392 synthetic-55392 syn` because synthetic tree generation left the top-level ChatGPT `id` field as schema-generated text. - `open --print-path <conversation-id>` failed with `Got unexpected extra argument` when given a direct `provider:id`. - `polylogue stats --by provider --limit 10` required `--limit` before the verb because the `stats` verb relied on root for `--limit`. - `polylogue --plain tags --format json` failed with `No such option: --format`. - Terminal snapshot baselines and showcase CLI boundaries still referenced `python -m polylogue` rather than the public `polylogue` executable. ## Solution - Harden the root CLI error boundary so plain and JSON machine-main render `PolylogueError` as Click user errors instead of tracebacks. - Correct the root help example so provider/date filters appear before the query verb where the parser actually accepts them. - Make `stats_only` false when `--by` is present; pass `output_format` through SQL-backed stats; emit structured JSON/YAML/CSV for archive-wide stats. - Update the similarity-error branches to point at `polylogue run embed`. - Harden machine-mode detection for root `--format json` across `list`, `open`, `tags`, `products`, `schema`, and query mode; harden the pre-scan command extractor. - Fix `aggregate_message_stats` to report real role counts and word counts. - Assign clean UUIDs and stable timestamps to synthetic ChatGPT conversations. - Route a single trailing `provider:id` token in `open` through the exact `conv_id` filter. - Give `stats` a local `--limit/-n` option and forward it into the shared query params. - Accept `--format json` on `tags` in addition to `--json`. - Add archive-backed zsh completions for conversation IDs (with provider/title descriptions), `open <target>`, `--tag`/`--exclude-tag`, `--tool`/`--exclude-tool`, comma-aware provider completion. - Switch showcase CLI verification to the public `polylogue` executable and refresh the full help baseline. - Refresh terminal snapshot baselines and `invalid option` snapshot. ## Verification - `pytest -q --ignore=tests/integration` - `pytest -q tests/unit/cli/test_click_app.py tests/unit/cli/test_machine_main.py tests/unit/cli/test_machine_contract.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_exec.py tests/unit/cli/test_products.py tests/unit/cli/test_check.py tests/integration/test_cli_query_mode.py tests/integration/test_cli_tags_surface.py` - `ruff check polylogue tests devtools` - Manual live probes: `polylogue --format json list -n 1`, `polylogue --plain stats --by provider --format json`, `polylogue --plain open --print-path claude-code:<id>`, `polylogue --plain tags --format json`. Commits on this branch: 30 (delta against `feature/chore/stack-01-governance`). ## Stack Base: `feature/chore/stack-01-governance`. Next: `feature/fix/stack-03-runtime-repair`.
… unification (#186) ## Summary Combined arc covering the remainder of the `feature/chore/repo-cleanup-governance` branch work. Arcs 1–3 landed in PRs #174, #183, #184. This PR covers arcs 4–9: - **Perf** (arc 4): materialize rebuild bounds, single-record inline ingest, worker throttling, session refresh by message volume, default doctor probe slimming, JSONL lone-surrogate tolerance, malformed-line reporting, reparse preview/scope safety, acquisition heartbeats, site progress. - **Artifact graph + storage bootstrap** (arc 5): shared action-event and raw-ingest artifact semantics, explicit artifact graph, unified schema bootstrap. - **Scenario substrate wave 1** (arc 6): ScenarioMetadata, OperationSpec, typed QA requests, catalog extractions, runtime coverage maps. - **Scenario execution + corpus roots** (arc 7): CorpusSpec as single input, ExecutionSpec unification, showcase exercise collapse, runtime path modeling, memory-budget lane compilation. - **Final unification** (arc 8): AssertionSpec, ValidationLaneFamily, CorpusProfile, MaintenanceTargetSpec, CliSurfaceFamily, SQLite runtime collapse. - **Runtime fixes** (arc 9): parse-vs-validation failure split, action-event orphan readiness, verifier decode-error preservation. ## Problem The 244-commit branch introduced tightly-coupled architectural unifications across scenario, verification, storage, and runtime surfaces. Splitting these into 6 independently-functional PRs proved impractical — cherry-picking individual arcs onto an intermediate master created semantic drift that broke test consistency. ## Solution Cherry-pick the remaining 161 commits (positions 84–244 of the original branch) onto the current master (which already has arcs 1–3 merged). Three conflicts resolved during cherry-pick: CLAUDE.md transclusion paths (`.claude/` → `.agent/`), `async_sqlite_schema.py` (format drift), `schema_upgrade.py` (deletion accepted). Followed by a ruff format pass, snapshot refresh, showcase baseline update, and xfail removal. ## Verification - `pytest -q --ignore=tests/integration` → 4881 passed (7 test-isolation artifacts pass individually) - `ruff check polylogue/ tests/ devtools/` → all checks passed - `ruff format --check polylogue/ tests/ devtools/` → all formatted - `devtools verify-showcase --update` → 43 exercises, baselines current - `pytest tests/unit/cli/test_terminal_snapshots.py --snapshot-update` → 10 passed
Live vetting against a real archive exposed a cluster of user-facing CLI regressions: raw tracebacks leaking through plain mode, help text advertising flag positions the parser rejected, `stats` silently dropping grouped mode, role counts hardcoded to zero, synthetic ChatGPT conversation ids malformed, and the machine envelope's `command` field corrupted by option payloads. Root fixes rather than per-symptom patches. The root CLI error boundary now renders `PolylogueError` as Click user errors across plain and JSON machine-main — no more raw stack traces. Machine-mode detection hardens across `list`, `open`, `tags`, `products`, `schema`, and query verbs; the pre-scan command extractor no longer treats option values as command words. `stats` grows a local `--limit` option so it stops relying on the root verb, and `aggregate_message_stats` reports real role and word counts instead of zeros. Help text and similarity-error hints point at the actual commands (`polylogue run embed`, not the old `polylogue embed`). Adds archive-backed zsh completions for conversation ids (with provider/title descriptions), `open <target>`, tag/tool filters, and comma-aware provider completion. Showcase CLI verification switches to the public `polylogue` executable; terminal snapshot baselines refresh to match. Verification: pytest over unit CLI contracts plus integration cli_query_mode / cli_tags_surface suites, ruff clean, and live manual probes against the default archive root.
… unification (#186) Completes the `feature/chore/repo-cleanup-governance` architectural wave, landing arcs 4-9 of the 244-commit branch (arcs 1-3 merged as PRs #174 / #183 / #184). Splitting the remaining 161 commits into independently-functional PRs proved impractical — the arcs are cross-coupled enough that cherry-picking individual ones onto intermediate master produced semantic drift that broke test consistency. Merged as one coherent step. Arc 4 (perf): materialize rebuild bounds, single-record inline ingest, worker throttling, session refresh keyed to message volume, default doctor probe slimming, JSONL lone-surrogate tolerance, malformed-line reporting, reparse preview/scope safety, acquisition heartbeats, site progress reporting. Arc 5 (artifact graph + storage bootstrap): shared action-event and raw-ingest artifact semantics, explicit artifact graph, unified schema bootstrap. Arc 6 (scenario substrate wave 1): `ScenarioMetadata`, `OperationSpec`, typed QA requests, catalog extractions, runtime coverage maps. Arc 7 (scenario execution + corpus roots): `CorpusSpec` as single input, `ExecutionSpec` unification, showcase exercise collapse, runtime path modeling, memory-budget lane compilation. Arc 8 (final unification): `AssertionSpec`, `ValidationLaneFamily`, `CorpusProfile`, `MaintenanceTargetSpec`, `CliSurfaceFamily`, SQLite runtime collapse. Arc 9 (runtime fixes): parse-vs-validation failure split, action-event orphan readiness, verifier decode-error preservation. Three conflicts during cherry-pick: CLAUDE.md transclusion paths (`.claude/` → `.agent/`), `async_sqlite_schema.py` format drift, `schema_upgrade.py` deletion accepted. Followed by ruff format pass, snapshot refresh, showcase baseline update, xfail removal. Verification: 4881 pytest (ignoring integration), ruff clean, showcase baselines current across 43 exercises, terminal snapshot baselines refreshed.
Live vetting against a real archive exposed a cluster of user-facing CLI regressions: raw tracebacks leaking through plain mode, help text advertising flag positions the parser rejected, `stats` silently dropping grouped mode, role counts hardcoded to zero, synthetic ChatGPT conversation ids malformed, and the machine envelope's `command` field corrupted by option payloads. Root fixes rather than per-symptom patches. The root CLI error boundary now renders `PolylogueError` as Click user errors across plain and JSON machine-main — no more raw stack traces. Machine-mode detection hardens across `list`, `open`, `tags`, `products`, `schema`, and query verbs; the pre-scan command extractor no longer treats option values as command words. `stats` grows a local `--limit` option so it stops relying on the root verb, and `aggregate_message_stats` reports real role and word counts instead of zeros. Help text and similarity-error hints point at the actual commands (`polylogue run embed`, not the old `polylogue embed`). Adds archive-backed zsh completions for conversation ids (with provider/title descriptions), `open <target>`, tag/tool filters, and comma-aware provider completion. Showcase CLI verification switches to the public `polylogue` executable; terminal snapshot baselines refresh to match. Verification: pytest over unit CLI contracts plus integration cli_query_mode / cli_tags_surface suites, ruff clean, and live manual probes against the default archive root.
… unification (#186) Completes the `feature/chore/repo-cleanup-governance` architectural wave, landing arcs 4-9 of the 244-commit branch (arcs 1-3 merged as PRs #174 / #183 / #184). Splitting the remaining 161 commits into independently-functional PRs proved impractical — the arcs are cross-coupled enough that cherry-picking individual ones onto intermediate master produced semantic drift that broke test consistency. Merged as one coherent step. Arc 4 (perf): materialize rebuild bounds, single-record inline ingest, worker throttling, session refresh keyed to message volume, default doctor probe slimming, JSONL lone-surrogate tolerance, malformed-line reporting, reparse preview/scope safety, acquisition heartbeats, site progress reporting. Arc 5 (artifact graph + storage bootstrap): shared action-event and raw-ingest artifact semantics, explicit artifact graph, unified schema bootstrap. Arc 6 (scenario substrate wave 1): `ScenarioMetadata`, `OperationSpec`, typed QA requests, catalog extractions, runtime coverage maps. Arc 7 (scenario execution + corpus roots): `CorpusSpec` as single input, `ExecutionSpec` unification, showcase exercise collapse, runtime path modeling, memory-budget lane compilation. Arc 8 (final unification): `AssertionSpec`, `ValidationLaneFamily`, `CorpusProfile`, `MaintenanceTargetSpec`, `CliSurfaceFamily`, SQLite runtime collapse. Arc 9 (runtime fixes): parse-vs-validation failure split, action-event orphan readiness, verifier decode-error preservation. Three conflicts during cherry-pick: CLAUDE.md transclusion paths (`.claude/` → `.agent/`), `async_sqlite_schema.py` format drift, `schema_upgrade.py` deletion accepted. Followed by ruff format pass, snapshot refresh, showcase baseline update, xfail removal. Verification: 4881 pytest (ignoring integration), ruff clean, showcase baselines current across 43 exercises, terminal snapshot baselines refreshed.
Live vetting against a real archive exposed a cluster of user-facing CLI regressions: raw tracebacks leaking through plain mode, help text advertising flag positions the parser rejected, `stats` silently dropping grouped mode, role counts hardcoded to zero, synthetic ChatGPT conversation ids malformed, and the machine envelope's `command` field corrupted by option payloads. Root fixes rather than per-symptom patches. The root CLI error boundary now renders `PolylogueError` as Click user errors across plain and JSON machine-main — no more raw stack traces. Machine-mode detection hardens across `list`, `open`, `tags`, `products`, `schema`, and query verbs; the pre-scan command extractor no longer treats option values as command words. `stats` grows a local `--limit` option so it stops relying on the root verb, and `aggregate_message_stats` reports real role and word counts instead of zeros. Help text and similarity-error hints point at the actual commands (`polylogue run embed`, not the old `polylogue embed`). Adds archive-backed zsh completions for conversation ids (with provider/title descriptions), `open <target>`, tag/tool filters, and comma-aware provider completion. Showcase CLI verification switches to the public `polylogue` executable; terminal snapshot baselines refresh to match. Verification: pytest over unit CLI contracts plus integration cli_query_mode / cli_tags_surface suites, ruff clean, and live manual probes against the default archive root.
… unification (#186) Completes the `feature/chore/repo-cleanup-governance` architectural wave, landing arcs 4-9 of the 244-commit branch (arcs 1-3 merged as PRs #174 / #183 / #184). Splitting the remaining 161 commits into independently-functional PRs proved impractical — the arcs are cross-coupled enough that cherry-picking individual ones onto intermediate master produced semantic drift that broke test consistency. Merged as one coherent step. Arc 4 (perf): materialize rebuild bounds, single-record inline ingest, worker throttling, session refresh keyed to message volume, default doctor probe slimming, JSONL lone-surrogate tolerance, malformed-line reporting, reparse preview/scope safety, acquisition heartbeats, site progress reporting. Arc 5 (artifact graph + storage bootstrap): shared action-event and raw-ingest artifact semantics, explicit artifact graph, unified schema bootstrap. Arc 6 (scenario substrate wave 1): `ScenarioMetadata`, `OperationSpec`, typed QA requests, catalog extractions, runtime coverage maps. Arc 7 (scenario execution + corpus roots): `CorpusSpec` as single input, `ExecutionSpec` unification, showcase exercise collapse, runtime path modeling, memory-budget lane compilation. Arc 8 (final unification): `AssertionSpec`, `ValidationLaneFamily`, `CorpusProfile`, `MaintenanceTargetSpec`, `CliSurfaceFamily`, SQLite runtime collapse. Arc 9 (runtime fixes): parse-vs-validation failure split, action-event orphan readiness, verifier decode-error preservation. Three conflicts during cherry-pick: CLAUDE.md transclusion paths (`.claude/` → `.agent/`), `async_sqlite_schema.py` format drift, `schema_upgrade.py` deletion accepted. Followed by ruff format pass, snapshot refresh, showcase baseline update, xfail removal. Verification: 4881 pytest (ignoring integration), ruff clean, showcase baselines current across 43 exercises, terminal snapshot baselines refreshed.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 817fcfddc6
ℹ️ 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".
|
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. |
Summary
PR 2/9. Stacked on
feature/chore/stack-01-governance.First wave of CLI-surface fixes found during live vetting. Every plain-mode
PolylogueErrornow renders as a Click user error rather than a raw traceback, and the machine envelope is consistent across every query verb.Problem
Live vetting against a real archive exposed a cluster of user-facing regressions on the CLI query surface:
polylogue --plain stats --by provider --format jsonraised a full traceback ending inDatabaseErroron stale schema, instead of a structured envelope.polylogue --plain query --helpadvertised an option placement that the real parser rejected (Error: No such option: --provider).polylogue stats --by providersilently dropped grouped mode because the positionalstatsverb forcedstats_only=True.polylogue stats --format jsonignored the requested output format in the SQL-backed stats path.polylogue --plain --similar "debug parser" listtold users to runpolylogue embed— an old command. Canonical ispolylogue run embed.polylogue --format json list -n 1emitted plain early-failure behavior instead of a structured runtime envelope.json/1as command words, corrupting the machine envelope'scommandfield.polylogue stats --format jsonreportedmessages_total=137whilemessages_user=0andmessages_assistant=0— role counts were hardcoded to zero, and the filtered branch dropped its temp id table before the word-count query.polylogue --format json list -n 10showed malformed ChatGPT conversation ids likechatgpt:synthetic-55392 synthetic-55392 synbecause synthetic tree generation left the top-level ChatGPTidfield as schema-generated text.open --print-path <conversation-id>failed withGot unexpected extra argumentwhen given a directprovider:id.polylogue stats --by provider --limit 10required--limitbefore the verb because thestatsverb relied on root for--limit.polylogue --plain tags --format jsonfailed withNo such option: --format.python -m polyloguerather than the publicpolylogueexecutable.Solution
PolylogueErroras Click user errors instead of tracebacks.stats_onlyfalse when--byis present; passoutput_formatthrough SQL-backed stats; emit structured JSON/YAML/CSV for archive-wide stats.polylogue run embed.--format jsonacrosslist,open,tags,products,schema, and query mode; harden the pre-scan command extractor.aggregate_message_statsto report real role counts and word counts.provider:idtoken inopenthrough the exactconv_idfilter.statsa local--limit/-noption and forward it into the shared query params.--format jsonontagsin addition to--json.open <target>,--tag/--exclude-tag,--tool/--exclude-tool, comma-aware provider completion.polylogueexecutable and refresh the full help baseline.invalid optionsnapshot.Verification
pytest -q --ignore=tests/integrationpytest -q tests/unit/cli/test_click_app.py tests/unit/cli/test_machine_main.py tests/unit/cli/test_machine_contract.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_exec.py tests/unit/cli/test_products.py tests/unit/cli/test_check.py tests/integration/test_cli_query_mode.py tests/integration/test_cli_tags_surface.pyruff check polylogue tests devtoolspolylogue --format json list -n 1,polylogue --plain stats --by provider --format json,polylogue --plain open --print-path claude-code:<id>,polylogue --plain tags --format json.Commits on this branch: 30 (delta against
feature/chore/stack-01-governance).Stack
Base:
feature/chore/stack-01-governance. Next:feature/fix/stack-03-runtime-repair.