Skip to content

feat(T13842): read-only docs projection preview (previewDocUpdateThroughSections) - #2358

Merged
kryptobaseddev merged 1 commit into
mainfrom
fix/T13842-docs-preview-api
Oct 17, 2026
Merged

kryptobaseddev merged 1 commit into
mainfrom
fix/T13842-docs-preview-api

Conversation

@kryptobaseddev

Copy link
Copy Markdown
Owner

Why

review-2253 blocked #2338's ordering, where the projection commits before docs-update writes its row. Lead chose option (a): compute the merged text without committing, write the blob and row from it, then commit the projection. This PR adds the read-only entry point that #2338 stacks on.

What

previewDocUpdateThroughSections(projectRoot, input: ProjectDocUpdateInput): Promise<DocUpdatePreview> in packages/core/src/docs/section-write-path.ts, returning { mergedText, wouldAdvance, conflicts }.

  • It runs the exact projection (merge, adopt, version append, head upsert) inside the same BEGIN IMMEDIATE transaction, then rolls it back via an internal PreviewRollback. So wouldAdvance is the real head.advanced, not an estimate.
  • It acquires no leases.
  • The version uids in conflicts name rolled-back rows, so callers should use only sectionId.
  • A content-addressed blob may remain as a harmless orphan.
  • projectDocUpdateThroughSections is unchanged; both functions share a private projectDocUpdate(…, preview).

Evidence

  • New test in section-write-path.test.ts, "T13842: previewDocUpdateThroughSections returns the merged text the projection lands, and writes nothing". It covers a stale-base append merge: the preview's merged text equals what the real projection then lands, and the version count, head uid, section state and leases are all unchanged after the preview.
  • Local runs before the owner's no-local-heavy-runs directive: section-write-path.test.ts 30/30 on current main, core tsc --noEmit with 0 errors, and gate 38 --base origin/main OK. Biome is clean on both files. GitHub CI is the authoritative evidence.

🤖 Generated with Claude Code

…tion preview

Runs the exact projection inside its transaction and rolls it back, so
docs-update can write the fetch-visible row from the merged text before
the projection commits (review-2253 on #2338, option a). No leases are
acquired; conflict version uids name rolled-back rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kryptobaseddev
kryptobaseddev merged commit 34fe85d into main Oct 17, 2026
41 checks passed
@kryptobaseddev
kryptobaseddev deleted the fix/T13842-docs-preview-api branch October 17, 2026 19:17
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