Skip to content

Renaming a file no longer rewrites the destination when the move…#270

Merged
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync
Jun 25, 2026
Merged

Renaming a file no longer rewrites the destination when the move…#270
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync

Conversation

@inkeep-oss-sync

Copy link
Copy Markdown
Contributor

Renaming a file no longer rewrites the destination when the move already placed the final bytes there. A managed rename moves the file and then writes the reconciled content; previously that second write was unconditional, so a rename that did not change the file's content still wrote the destination twice. The rename spine now skips the rewrite when the reconciled content already matches what is on disk, so a no-content-change rename writes the destination exactly once. Renames that rewrite wiki-link references still write the destination twice — the move places the old bytes, then the link rewrite overwrites them — because that second write is doing real work.

* fix(open-knowledge): write a renamed file's destination once, not twice

A managed file rename moved the file, placing the source's bytes at the
destination, and then unconditionally rewrote the destination with the
reconciled content even when that content was byte-identical to what the
move had just placed. Every rename therefore performed two full disk writes
to the destination, and a rename that rewrote wiki-link references also
briefly left the pre-rewrite bytes on disk where an external reader could
observe them.

Add a shared writeFileIfContentDiffers helper (raw-byte equality) and route
the three synchronous rename-spine write sites through it: syncRenamedDocsToDisk,
writeManagedRenameDocumentToDisk, and the doc-to-file source write. registerWrite
stays unconditional at every site so the file watcher's self-suppression for the
moved destination is preserved. A no-content-change rename now writes the
destination exactly once; renames that genuinely rewrite content still write the
final bytes.

The byte-exact predicate is deliberate and distinct from persistence.ts's
markdownSemanticallyUnchanged (which compares normalizeBridge-normalized
content): byte equality under-skips relative to semantic equality, so it can
only ever leave an occasional redundant write, never suppress a needed one.

Adds an integration test asserting the single-write contract, with a
process-scoped OTel tracer lifecycle so it stays order-independent under the
single-process integration suite.

* address review: forward-state comment-discipline phrasing in rename guard

GitOrigin-RevId: 64289447a99935673a260d62ca77bc56beb53de4

@inkeep-internal-ci inkeep-internal-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval from agents-private public-mirror-sync (run: https://github.com/inkeep/agents-private/actions/runs/28191922114). Source of truth is the monorepo; direct edits on inkeep/open-knowledge are overwritten on next sync.

@inkeep-oss-sync
inkeep-oss-sync Bot merged commit 7b44c6e into main Jun 25, 2026
1 check passed
@inkeep-oss-sync
inkeep-oss-sync Bot deleted the copybara/sync branch June 25, 2026 18:34
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