Skip to content

[Feature] Docs: efficient pull/push/content-check for coding agents (change feed, ETags, upsert by path, partial reads) #747

Closed

Description

@pikann

Summary

Follow-up to Discussion #722, proposed by @msammu07 and approved for implementation.

Problem

Coding agents (Claude Code, Codex, several sessions at once) that use Paca Docs as a shared store for plans and specs pay a high cost on every operation, because everything goes through the whole document:

  • Reading: read_doc always returns the full document. There is no outline, section read or line range.
  • Searching: search_docs returns one excerpt per doc, with no line numbers, no context and no regex. It matches only within a single BlockNote text run, so a phrase that crosses formatting (foo **bar**) is not found. On the server it runs jsonb_path_query + ILIKE over every document, with no index.
  • Writing: write_doc needs the full content, so changing one checkbox costs the whole doc in output tokens (a 19.5 KB plan is about 5k tokens per push). Markdown ↔ BlockNote conversion is lossy, so unedited content drifts on each rewrite.
  • Path lookups: Plans/2026-11-08 my-plan is resolved one folder per HTTP call.
  • Multiple agents: there is no protection against lost updates (last write silently wins), and no cheap way to tell if a doc changed since it was last read.

Proposed solution

Proposed scope

1. Content check (hash + conditional requests)

  • Store content_hash per document, computed on write.
  • GET returns it as ETag; If-None-Match → 304 Not Modified.
  • PATCH accepts If-Match; returns 412 if the doc changed since the caller read it.
  • A write with identical content is a no-op: no new snapshot, updated_at unchanged.

2. Pull (change feed + export)

  • GET /projects/:id/docs/changes?since=<cursor> returns changed docs (id, folder path, title, updated_at, content_hash) plus tombstones for deleted/moved docs.
  • Bulk Markdown export for the first pull.
  • Visibility changes must be in the feed: a doc the caller loses access to, without any edit, must show up as a tombstone, or a managed local mirror would keep stale content. This needs a defined retention contract. Removing the managed file cannot revoke copies an agent already made, and the docs should say so. (Raised by @Sadrak2017.)
  • Permissions apply: the feed and export only contain what the caller's key may read.

3. Push (upsert by path)

  • PUT /projects/:id/docs/by-path creates or updates in one call, with no folder walking.
  • Optional source metadata (repository, file path, commit) so Paca knows a doc is a managed copy.
  • The web UI marks managed copies ("edited in ") and can lock them against accidental overwrite.

4. Nice-to-have, can be split out

  • MCP partial reads and edits: outline (headings with line numbers), section / line-range reads, grep_docs (all matches with line numbers and context), and edit_doc (replace an exact string and rewrite only the changed blocks, keeping unchanged blocks' stored JSON).
  • Faster, more accurate search: a plain-text/Markdown rendering generated on write, with a trigram or full-text index, so search matches across formatting runs and returns line numbers.
  • GET /projects/:id/docs/by-path?path=….
  • Change notifications for agents (SSE, webhook or MCP resource subscription), building on the existing realtime doc events.

Acceptance criteria

  • An up-to-date client runs pull: one request, "nothing changed", no doc content transferred.
  • After a doc is edited, moved and deleted in the web UI, the next pull updates, moves and removes the local file.
  • After a caller loses read access to a doc without it being edited, the next pull reports it as removed.
  • Two agents read the same doc and both write with If-Match: the second gets 412.
  • Pushing identical content creates no snapshot and leaves updated_at unchanged.
  • Changing one line without sending the whole doc leaves untouched blocks byte-for-byte identical in storage.
  • A search for a phrase crossing bold/italic formatting finds the doc and reports the line.

Alternatives considered

No response

Area

Product behavior

Additional context

Notes

  • The real-time collaborative editing work (live cursors/sync) should not conflict, but implementation needs to account for how it writes doc content and snapshots.
  • @msammu07 has offered to implement; the maintainer has said to go ahead.

Activity

  1. added
    enhancement
    on Nov 14, 2026
  2. pullfrog commented on Nov 14, 2026

    @pullfrog
    Contributor
  3. msammu07 commented on Nov 15, 2026

    @msammu07
    Contributor

    Implemented

    All seven acceptance criteria are met. Not built: change notifications for agents.

    The feature is implemented; this issue can be closed.

  4. pikann commented on Nov 15, 2026

    @pikann
    ContributorAuthor

    Thank you so much for your contributions, @msammu07

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions