Skip to content

Add edit_comment action to modify_reviews for comment task state transitions#39

Open
yan-xdt wants to merge 2 commits into
perforce:mainfrom
yan-xdt:feat/edit-comment-task-state
Open

Add edit_comment action to modify_reviews for comment task state transitions#39
yan-xdt wants to merge 2 commits into
perforce:mainfrom
yan-xdt:feat/edit-comment-task-state

Conversation

@yan-xdt

@yan-xdt yan-xdt commented Jul 7, 2026

Copy link
Copy Markdown

Motivation

modify_reviews currently exposes add_comment (which Swarm's create-comment endpoint restricts to taskState = open|comment) but no way to edit a comment afterwards. As a result, the task workflow states addressed and verified are unreachable through the MCP server, even though the Swarm REST API supports them via POST /api/v11/comments/{id}/edit. Agent-driven review flows (author fixes a task -> reviewer verifies it) currently have to fall back to calling the Swarm API directly.

Changes

  • models: new EDIT_COMMENT action; TaskState extended with addressed/verified; validation keeps add_comment restricted to open|comment (matching the create-comment endpoint), and edit_comment requires comment_id plus at least one of body/task_state. review_id is not required for edit_comment since the endpoint is comment-scoped.
  • services: edit_comment() wrapping POST /api/v11/comments/{id}/edit, sending only the fields provided (body, taskState, notify), following the same auth/response handling as the existing comment methods.
  • handlers: dispatch branch for edit_comment.
  • tools: edit_comment added to the modify_reviews action literal; task_state literal extended, with descriptions noting Swarm's constraints (only the comment author may edit; open -> verified requires an intermediate addressed step).
  • README: action list entry.

Notes

  • Purely additive; no behavior change for existing actions other than the stricter (previously unenforced) task_state validation on add_comment, which now fails fast instead of letting Swarm reject the request.
  • All modified modules pass python -m py_compile; the change mirrors the existing add_review_comment/mark_comment_as_read implementation patterns.

🤖 Generated with Claude Code

yan-xdt and others added 2 commits July 6, 2026 21:50
Wraps POST /api/v11/comments/{id}/edit so agents can update a comment's
body and flip its taskState (open -> addressed -> verified), which was
previously unreachable via MCP (add_comment only accepts open|comment).

- models: EDIT_COMMENT action, TaskState addressed/verified, per-action
  task_state validation (add_comment still restricted to open|comment),
  edit_comment requires comment_id and at least one of body/task_state
- services: edit_comment() posting only provided fields
- handlers: dispatch branch (review_id not required; the endpoint is
  comment-scoped)
- tools: expose action + extended task_state literal, doc updates

Co-Authored-By: Claude Fable 5 <[email protected]>
End-to-end testing against a production Swarm (API v11) showed the
server accepts any taskState transition (including open -> verified
directly), so describe open -> addressed -> verified as the documented
convention rather than an enforced constraint, and note the 403 on
editing another user's comment.

Co-Authored-By: Claude Fable 5 <[email protected]>
@yan-xdt

yan-xdt commented Jul 7, 2026

Copy link
Copy Markdown
Author

Validated this end-to-end against a production Swarm (API v11) with a real review, driving all calls through the MCP tools. Results:

  • edit_comment with task_state: open -> addressed -> verified works as intended (each step reflected in subsequent comments queries; updated changes while edited stays null for state-only edits).
  • Interesting finding: the server also accepted open -> verified directly (and verified -> open) — Swarm does not enforce the documented intermediate-step ordering server-side. I've adjusted the tool/service docstrings in 0b64192 to describe the ordering as the documented convention rather than a hard constraint.
  • Body-only edit works and sets edited; body is a full replacement.
  • Editing another user's comment returns HTTP 403 ("Only the comment author can edit the body of a comment"), surfaced cleanly as a status: error result.

🤖 Generated with Claude Code

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