tahoe-lafs / magic-folder

Tahoe-LAFS-based file synchronization
Other
25 stars 7 forks source link

enhancement: add events for conflicts #755

Open crwood opened 4 months ago

crwood commented 4 months ago

https://github.com/tahoe-lafs/magic-folder/pull/752 adds support for resolving conflicts via the web API and CLI, however, detecting that a conflict has occurred in the first place requires an amount of manual intervention that may be undesirable to developers and/or end users. Presently (AFAICT), detecting that a conflict has occurred requires either a) periodically checking/polling the /v1/magic-folder/<folder-name>/conflicts HTTP endpoint (which, at higher frequencies, can be wasteful on computing resources) or b) stumbling upon (and/or manually searching for) .conflict-<participant> tagged file extensions (which takes users away from other things and is thus wasteful on brain cycles).

Given that conflicts are typically both exceptional (i.e., somewhat rare) and important to end users (since they challenge local assumptions about the "true" or current working contents of a file), it would arguably be preferable if "conflicted" states were be detectable immediately (i.e., instead of on a timer) and easily (i.e., instead of via manual intervention/accident) so that users can be informed of such states as closely as possible to the action that caused them and be prompted to take necessary action (e.g., to resolve).

Or, in user story form:

_"As a user who belongs to a folder in which multiple participants might modify a file, I want to be notified immediately if any modifications conflict with those of another so that I can take appropriate action (e.g., to resolve the conflict) as early as possible to prevent future confusion."_

_"As a user who belongs to a folder in which multiple participants might modify a file, I want to be notified automatically if any modifications conflict with those of another so that I can focus on my work and not spend time manually checking for conflicts."_

"As a developer who wants to make Magic-Folder friendlier to humans, I want a simple streaming API that informs me of any/all events that might impact the integrity of user-data or require user intervention so that such things can be reported to users as soon as possible."

"As a developer who wants to make Magic-Folder friendlier to computers, I want a simple streaming API that informs me of any/all events that might impact the integrity of user-data or require user intervention so that I don't have to periodically poll multiple multiple endpoints or track state that is already tracked elsewhere."

crwood commented 4 months ago

In order to resolve the above, the existing "events" API could perhaps be expanded to emit new message "kinds" describing relevant conflict-related events -- perhaps something along the lines of:

{
  "kind": "conflict-detected",
  "folder": "Cat Pics",
  "timestamp": 1718386958.4481108,
  "relpath": "Classics/Garfield.jpg",
  "participants": ["Alice", "Bob"]
}

(For signaling that a conflict was detected)

...and:

{
  "kind": "conflict-resolved",
  "folder": "Cat Pics",
  "timestamp": 1718386975.57682,
  "relpath": "Post-Modern/Cat'thulu.png",
  "participants": ["Alice", "Bob"],
  "resolution": "Bob"
}

(For signaling that a conflict was successfully resolved)

These are just (non-exhaustive) examples; there may be better way(s) to express the above conditions -- and/or other revelant events to cover.