Skip to content

Bug: Fragment Divergence & Text Search Breakage After comment.add #5

Description

@lpcode808

When adding a comment via /api/agent/<slug>/ops with comment.add, the internal document state becomes corrupted with HTML annotations. Subsequent API operations (edit/v2, suggestion.add, find_replace_in_block) all fail with FRAGMENT_DIVERGENCE or ANCHOR_NOT_FOUND errors because text search can't find content that exists in clean markdown.

Steps to Reproduce

  1. Create a Proof document with text: "Hello whwat is this for"
  2. Add a comment anchoring to that text:
curl -X POST "https://www.proofeditor.ai/api/agent/<slug>/ops" \
  -H "Authorization: Bearer <token>" \
  -H "X-Agent-Id: claude-code-haiku" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "comment.add",
    "by": "ai:claude-code-haiku",
    "quote": "Hello whwat is this for",
    "text": "This is a comment"
  }'
  1. Attempt subsequent edit with /edit/v2:
curl -X POST "https://www.proofeditor.ai/api/agent/<slug>/edit/v2" \
  -H "Authorization: Bearer <token>" \
  -H "X-Agent-Id: claude-code-haiku" \
  -d '{
    "by": "ai:claude-code-haiku",
    "baseRevision": 2,
    "operations": [
      {"op": "insert_after", "ref": "b1", "blocks": [{"markdown": "New content"}]}
    ]
  }'

Result

FRAGMENT_DIVERGENCE error. Snapshot shows HTML annotations in markdown: <span data-proof="comment" ...>Hellowhwat is this for</span>

Root Cause

Comment annotations corrupt the canonical markdown representation. Text search fails because it searches plain text but snapshot returns annotated HTML.

Impact

  • Cannot chain comment + edit operations
  • Document becomes read-only for programmatic edits after comment added
  • Breaks agent workflows mixing comments and content changes

Environment

  • Hosted Proof (proofeditor.ai) - 2026-03-11
  • Verified with /api/agent/ endpoints

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions