Repository navigation
refactor(cli): strict command floor + remove dead export (#1842) - #1885
Conversation
Problem: `find` was never a real keyword — it fell through the query parser as a literal search term, so `polylogue find repo:x` searched for the word "find" too. And any unquoted bare root silently became a search, so a mistyped command ran a query instead of erroring. What changed: - `_split_query_mode_args` strips a leading `find` and marks the query explicit (a later `find` stays a literal term). - `QueryFirstGroupBase.invoke` refuses an unsignalled bare root — no `find`, no `--` escape, no field syntax, no quoted whitespace — with a hint pointing at `find` / quoting, folding in the existing did-you-mean subcommand suggestion so `lst` still suggests `list`. - Tests that drove search via bare words now use `find`; added `TestStrictCommandFloor` pinning the acceptance matrix (find stripped, find+then dispatch, multi/single bare-root hints, field-expression and quoted-whitespace roots still search, `--` escape forces a query). Ref #1842 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Problem: polylogue/cli/commands/export.py defined `export_command` but it was never registered in ROOT_COMMANDS — unreachable dead code. The live bulk-export logic lives in cli/bulk_export.py (the `read --all` path), so nothing depends on it. What changed: - Delete export.py (verified: no production importer, no test imports the symbol; `insights export` is a different command). - Rewrite docs/export.md and docs/getting-started.md `export` / `bulk-export` examples onto the surviving `read` verb (`--id <id> read`, `... read --all`). - Regenerate topology projection/status for the removed module. Ref #1842 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughRemoves the standalone ChangesCLI strict command floor and export removal
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fdf6d15e60
ℹ️ 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.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@tests/unit/cli/test_click_app.py`:
- Around line 397-453: Add a new regression test method to the
TestStrictCommandFloor class that verifies a non-leading "find" token is treated
as a literal query term. The test should invoke the CLI with a query where
"find" appears after other search terms (not as the leading command), mock
execute_query_request, assert that the mock was called (indicating it was
processed as a query), and verify that "find" remains in the query parameters.
This complements the existing test_find_keyword_is_stripped_from_query test
which only validates leading-"find" stripping.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0f802ffe-1479-4501-b763-82d1fe079de3
📒 Files selected for processing (9)
docs/export.mddocs/getting-started.mddocs/plans/topology-target.yamldocs/topology-status.mdpolylogue/cli/commands/export.pypolylogue/cli/query_group.pytests/unit/cli/test_click_app.pytests/unit/cli/test_embed_activation.pytests/unit/cli/test_query_exec_laws.py
💤 Files with no reviewable changes (1)
- polylogue/cli/commands/export.py
Problem (Codex P2 on #1885): after a leading `find` is stripped, the next token — if it is a verb word like `read`/`list`/`stats` — dispatched that action over an empty query instead of being searched. `find read` read every session rather than searching for the word "read". What changed: in `_split_query_mode_args`, a verb token is treated as the verb only when reached via `then` or after a query term already exists. After an explicit `find` with nothing collected and no `then`, the verb word becomes a literal query term (`find QUERY [then ACTION]` semantics). Added regression tests: `find read` searches "read"; a non-leading `find` stays a literal term (CodeRabbit nitpick). Ref #1842 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Addressed both review findings in adc96ed:
New tests: |
|
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
First slice of the #1842 command-floor program: make
finda real keyword,enforce the strict bare-query floor, and remove the orphaned dead
exportcommand. This is the foundation PR — no capability is removed (the verbs that
must absorb the old analytics/mark commands are not touched here; those are
later port-before-delete PRs).
Problem
findwas never a keyword._split_query_mode_argslet it fall through as aliteral query term, so
polylogue find repo:xsearched for the word "find".The grammar was documented in
--helpbut not implemented.command ran a query instead of giving an actionable error.
polylogue/cli/commands/export.pydefinedexport_commandbut was never inROOT_COMMANDS— unreachable dead code. (Live bulk-export lives incli/bulk_export.py, theread --allpath.)Solution
findkeyword (query_group.py): strip a leadingfindand mark thequery explicit; a later
findstays a literal term.QueryFirstGroupBase.invoke): an unsignalled bare root —no
find, no--escape, no field syntax (:), no quoted-whitespace token —raises a hint pointing at
find/ quoting, folding in the existinglooks_like_subcommand_typodid-you-mean (solst→polylogue list).Explicit/expression/quoted roots still search:
polylogue foo/polylogue foo bar→ hintpolylogue find foo bar/polylogue 'repo:x'/polylogue 'machine learning'→ searchpolylogue find id:abc then read→ dispatchexportremoval: deleteexport.py; rewritedocs/export.mdanddocs/getting-started.mdexamples onto thereadverb; regenerate topology.find; newTestStrictCommandFloorpins the acceptance matrix.
Verification
devtools test tests/unit/cli→ 1802 passed (-n 8).devtools test tests/integration/test_cli_query_mode.py→ 5 passed, 13 skipped (no regression).devtools verify --quick→ exit 0 (ruff format/lint, mypy --strict, render-all --check, doc-command + public-surface audits).devtools render-all --check→ in sync after topology regen.#1842 handoff checklist
Ref #1842
Summary by CodeRabbit
Bug Fixes
Documentation
read(single-session via--id <id> read, batch via--all read).findsubcommand for searches.Tests
findexplicitly and added coverage for stricter “command floor” behavior.