M1-sync-contract #125
pt-act
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Proposal
Summary
Make the filesystem sync conflict contract a first-class, discoverable guarantee, and add
one observability signal for the case where reconciliation silently discards local data.
Background and motivation
docs/02_sync_protocol.mddescribes bidirectional sync as DO-authoritativelast-writer-wins, and the "Conflict semantics" section notes that when an upstream entry
of a different node type lands where the receiver has a subtree, the receiver removes the
local node tree and applies the upstream entry — "local-only children under the
conflicting path are discarded without separate tombstones."
The sync engine has grown a lot of machinery around that core in recent weeks — deferred
command synchronization, path-aware push cursors, node_modules inclusion,
ignorelists,reconnect fencing keyed by runtime identity. All of it increases the number of paths an
upstream apply can take, while the discard behavior at the heart of reconciliation is
unchanged and still completely silent:
removeInodeTreeAtPathinpackages/dofs/src/sync/apply.tsremoves the local subtree with no tombstones and nosignal, so the one real data-loss path in the system is invisible to callers and operators.
Two gaps for consumers:
same-path writes on both sides are stated only inside the design doc, not on the
public
fs/Workspacesurface — easy to miss when building on the API.dropped, so a container command that clobbered local-only files is indistinguishable,
after the fact, from a run where nothing was lost.
Who is affected: anyone building on
@cloudflare/computerwho writes to the workspacefrom both the DO and a running command/container.
Goals
clearly-titled block inside "Conflict semantics", cross-referenced from
packages/computer/README.md(which currently describes the two stores syncing acrossthe capnweb WebSocket without linking the conflict contract).
e.g. a stable, greppable log line carrying
path,fromType,toType, and thediscarded-child count. Log-only; no behavior change.
drift.
resolution/merge. (If safe concurrent same-path writes are ever wanted, that's a
separate feature proposal.)
Example
Upstream pushes a file at
/w/awhere the receiver has a directory/w/a/containing alocal-only
/w/a/b.txt. After apply,/w/ais a file and/w/a/b.txtis gone. Todaythat happens with no signal anywhere; the proposal is to emit one discard event and to
document the behavior on the public surface.
We have a working implementation of the signal plus its regression tests
(
packages/dofs/src/sync/apply.ts/apply.test.ts) that applies cleanly on currentmain. Per the contribution policy we have not opened a PR — happy to if the maintainerswould like one.
All reactions