Repository navigation
Closed
Labels
enhancementNew feature or request
Description
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_docalways returns the full document. There is no outline, section read or line range. - Searching:
search_docsreturns 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 runsjsonb_path_query+ILIKEover every document, with no index. - Writing:
write_docneeds 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-planis 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_hashper document, computed on write. GETreturns it asETag;If-None-Match→304 Not Modified.PATCHacceptsIf-Match; returns412if the doc changed since the caller read it.- A write with identical content is a no-op: no new snapshot,
updated_atunchanged.
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-pathcreates or updates in one call, with no folder walking.- Optional
sourcemetadata (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), andedit_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
pullupdates, moves and removes the local file. - After a caller loses read access to a doc without it being edited, the next
pullreports it as removed. - Two agents read the same doc and both write with
If-Match: the second gets412. - Pushing identical content creates no snapshot and leaves
updated_atunchanged. - 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.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
pullfrog commentedon Nov 14, 2026
msammu07 commentedon Nov 15, 2026
Implemented
content_hash, returned asETag.If-None-Matchgives304,If-Matchgives412when the document changed, and a write with identical content creates no snapshot and leavesupdated_atunchanged. (feat(api): add a document content hash with ETag, If-Match and no-op writes #751, fix(api): accept a document ETag with a compression suffix in If-Match #759)PUT /docs/by-pathcreates or updates in one call, with optionalsourcemetadata;GET /docs/by-pathreads by path. (feat(api): read and write documents by path, with managed-copy metadata and change notes #754)pullandpushin@paca-ai/paca-mcp. (feat(mcp): add pull and push commands for documents #769)read_docoutline, section and line range;grep_docs;edit_doc, which rewrites only the changed blocks. (feat(mcp): read, grep and edit parts of a document #770)pullmerges local edits with changes made in Paca. (feat(mcp): edit documents through the local mirror with a three-way merge #773)All seven acceptance criteria are met. Not built: change notifications for agents.
The feature is implemented; this issue can be closed.
pikann commentedon Nov 15, 2026
Thank you so much for your contributions, @msammu07