Skip to content

feat: add idempotency outcome to tag mutation payloads (#862) - #978

Merged
Sinity merged 1 commit into
masterfrom
worktree-agent-a331c94f
May 9, 2026
Merged

Sinity merged 1 commit into
masterfrom
worktree-agent-a331c94f

Conversation

@Sinity

@Sinity Sinity commented May 9, 2026

Copy link
Copy Markdown
Owner

Summary

Add outcome field to MutationResultPayload and MCPMutationStatusPayload
so callers can distinguish the four tag-mutation states without parsing the
status/detail fields.

Problem

add_tag and remove_tag returned status="ok" without indicating whether
the operation was genuinely new or a no-op on already-present/absent tags.
Callers had to parse the detail string ("already_present",
"tag_not_present") to understand what happened. This made it hard to build
reliable automation on top of the mutation API.

Solution

Added outcome: str | None field to both MutationResultPayload and
MCPMutationStatusPayload in polylogue/mcp/payloads.py. The field is
None-by-default and omitted from serialization when None (backward
compatible).

Computed in polylogue/mcp/server_mutation_tools.py:

Operation Condition outcome
add_tag tag was added "added"
add_tag tag already present "no_op"
remove_tag tag was removed "removed"
remove_tag tag not present "not_present"

CLI output in polylogue/cli/commands/tags.py includes outcome in both
human-readable and --format json modes.

New tests in tests/unit/mcp/test_tag_idempotency.py cover all four outcomes
plus conversation-not-found and serialization roundtrip.

Verification

9 passed in 11.89s  tests/unit/mcp/test_tag_idempotency.py
129 passed in 14.08s  (all tag-related unit tests across mcp/cli/storage)
mypy --strict: no issues found in 4 source files
ruff format/check: clean

Refs #862

🤖 Generated with Claude Code

Add `outcome` field to `MutationResultPayload` and
`MCPMutationStatusPayload` so callers can distinguish the four
tag-mutation states without parsing the status/detail fields:

  add_tag(conv, tag)   where tag absent   → outcome="added"
  add_tag(conv, tag)   where tag present  → outcome="no_op"
  remove_tag(conv, tag) where tag present  → outcome="removed"
  remove_tag(conv, tag) where tag absent  → outcome="not_present"

Outcome is computed in `server_mutation_tools.py` and surfaced in both
MCP JSON responses and CLI human-readable output. The field is optional
(omitted from serialize when None) so backward compat is preserved.

Refs #862

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings May 9, 2026 11:25
@coderabbitai

coderabbitai Bot commented May 9, 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 10 minutes and 24 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: 4e4958bd-9880-4b9e-bfc4-bdcb1b8130ef

📥 Commits

Reviewing files that changed from the base of the PR and between 2287b23 and 200a942.

📒 Files selected for processing (4)
  • polylogue/cli/commands/tags.py
  • polylogue/mcp/payloads.py
  • polylogue/mcp/server_mutation_tools.py
  • tests/unit/mcp/test_tag_idempotency.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-agent-a331c94f

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.

@Sinity
Sinity merged commit 9c7692d into master May 9, 2026
7 of 8 checks passed
@Sinity
Sinity deleted the worktree-agent-a331c94f branch May 9, 2026 11:31
@Sinity
Sinity removed the request for review from Copilot May 9, 2026 11:48
Sinity added a commit that referenced this pull request May 9, 2026
#862) (#991)

## Summary
Routes CLI and MCP tag mutations through a shared operation contract,
surfacing idempotency outcome from PR #978. API and daemon tag paths
also adapted.

## Certification

### WORK
Centralize tag mutation operations across surfaces (remaining AC of
#862)

### REALIZATION
1. polylogue/surfaces/payloads.py: shared mutation contract
2. polylogue/cli/commands/tags.py +
polylogue/mcp/server_mutation_tools.py: routed through contract
3. test: tests/unit/mcp/test_tag_idempotency.py + test_tool_contracts.py

### DECLARATION
I declare the WORK item to be fully realized. Verified by: pytest.

Refs #862
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.

1 participant