Repository navigation
fix(cli): route apply_modifiers tag mutations through custom repo when supplied (#1012) - #1017
Conversation
…n supplied (#1012) ## Problem ``apply_modifiers`` always routed ``add_tags`` through ``env.polylogue.add_tag`` even when the caller passed a custom ``repo`` argument. ``env.polylogue.add_tag`` enforces conversation-existence in the polylogue archive (raises ``ConversationNotFoundError`` if the conversation isn't there). The batch/test path that supplies a ``repo`` directly — most notably the Hypothesis test ``test_apply_modifiers_contract`` (#1012) — has fictional summaries that were never persisted, so every property example failed with ``ConversationNotFoundError`` for ``conv-000000``. The metadata path already routed correctly through ``repo`` (line 108); only the tag path bypassed the supplied repo, leaving the two paths asymmetric. ## Solution - ``polylogue/cli/query_actions.py::apply_modifiers`` — track whether the caller supplied a custom ``repo``; when they did, send tag mutations directly through ``repo.add_tag``. With no custom repo, fall back to ``env.polylogue.add_tag`` so the shared facade still enforces idempotency and conversation-existence checks for interactive CLI use. - Docstring now names the contract: custom-repo callers carry their own existence guarantee; default callers get the facade's checks. The fix originated as orphan commit ``b6b75442`` on a defunct ``worktree-agent-a81e3a2a`` worktree branch (post-merge cleanup of the ``refactor(mutations): centralize tag operations`` PR #991 that never got its own follow-up PR). Recovered during a worktree-cleanup audit. ## Verification - ``nix develop -c pytest tests/unit/cli/test_query_exec_laws.py::test_apply_modifiers_contract`` → 1 passed (60 Hypothesis examples, deadline-disabled). - ``nix develop -c devtools verify --quick`` → all checks passed. Closes part of #1012 (the ``test_apply_modifiers_contract`` xfail). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ 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 (1)
✨ Finishing Touches🧪 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.
Pull request overview
This PR fixes CLI query mutation behavior so apply_modifiers() routes tag mutations through a caller-supplied repo instead of always using env.polylogue.add_tag, addressing failures in the test_apply_modifiers_contract Hypothesis contract when operating on non-archived summaries.
Changes:
- Extend
apply_modifiers()documentation to clarify the routing behavior and the failure mode from mixing mutation paths. - Track whether a custom
repowas supplied and routeadd_tagsthroughrepo.add_tag()in that case. - Preserve the existing default behavior of routing through
env.polylogue.add_tag()when no custom repo is provided.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if mutation.add_tags: | ||
| for tag in mutation.add_tags: | ||
| result = await env.polylogue.add_tag(result_id(conv), tag) | ||
| if result: | ||
| if custom_repo: | ||
| await repo.add_tag(result_id(conv), tag) | ||
| tags_added += 1 | ||
| else: | ||
| result = await env.polylogue.add_tag(result_id(conv), tag) | ||
| if result: | ||
| tags_added += 1 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0cbe40e474
ℹ️ 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
Closes part of #1012.
apply_modifiersalways routedadd_tagsthroughenv.polylogue.add_tageven when the caller passed a customrepoargument, causing everytest_apply_modifiers_contractHypothesis example to fail withConversationNotFoundErrorbecause the strategy-built summaries were never persisted to the polylogue archive.The metadata path already routed correctly through
repo(line 108); only the tag path bypassed the supplied repo, leaving the two paths asymmetric.Solution
polylogue/cli/query_actions.py::apply_modifiersnow tracks whether the caller supplied a customrepo; when they did, tag mutations are sent directly throughrepo.add_tag. With no custom repo, the call still falls back toenv.polylogue.add_tagso interactive CLI use keeps the facade's idempotency and conversation-existence checks.The fix originated as orphan commit
b6b75442on a defunctworktree-agent-a81e3a2aworktree branch (post-merge cleanup of PR #991 that never got its own follow-up PR). Recovered during a worktree-cleanup audit and integrated as a focused PR.Verification
nix develop -c pytest tests/unit/cli/test_query_exec_laws.py::test_apply_modifiers_contract→ 1 passed (60 Hypothesis examples).nix develop -c devtools verify --quick→ all checks passed.The
@pytest.mark.xfailmarker added in PR #1013 should be removed once this lands and the test re-runs cleanly on master. The other two xfails tracked by #1012 (test_tags_command_plain_paths_cover_empty_hint_and_tabular_counts,test_prose_only_drops_claude_code_protocol_artifacts) are independent of this fix; see #1016 for the latter.