Skip to content

fix(cli): route apply_modifiers tag mutations through custom repo when supplied (#1012) - #1017

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/apply-modifiers-custom-repo-1012
May 11, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/apply-modifiers-custom-repo-1012

Conversation

@Sinity

@Sinity Sinity commented May 11, 2026

Copy link
Copy Markdown
Owner

Summary

Closes part of #1012. apply_modifiers always routed add_tags through env.polylogue.add_tag even when the caller passed a custom repo argument, causing every test_apply_modifiers_contract Hypothesis example to fail with ConversationNotFoundError because 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_modifiers now tracks whether the caller supplied a custom repo; when they did, tag mutations are sent directly through repo.add_tag. With no custom repo, the call still falls back to env.polylogue.add_tag so interactive CLI use keeps the facade's idempotency and conversation-existence checks.

The fix originated as orphan commit b6b75442 on a defunct worktree-agent-a81e3a2a worktree 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.xfail marker 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.

…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]>
Copilot AI review requested due to automatic review settings May 11, 2026 01:17
@coderabbitai

coderabbitai Bot commented May 11, 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 23 minutes and 12 seconds before requesting another review.

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 @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: bf6ee50d-b038-4737-97c1-c6a60978a09f

📥 Commits

Reviewing files that changed from the base of the PR and between 50f23b3 and 0cbe40e.

📒 Files selected for processing (1)
  • polylogue/cli/query_actions.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/apply-modifiers-custom-repo-1012

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 repo was supplied and route add_tags through repo.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.

Comment on lines 121 to +129
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread polylogue/cli/query_actions.py Resolved
@Sinity
Sinity merged commit 8eae31e into master May 11, 2026
8 checks passed
@Sinity
Sinity deleted the feature/fix/apply-modifiers-custom-repo-1012 branch May 11, 2026 01:46
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants