No description
Find a file
randogoth e7d36879cb Add the aggregation engine and a local sync cycle
The core of M1: everything needed to reconcile source calendars against an
aggregate, short of getting events in and out over the network.

- ical: surgical line-level editing. Each logical line keeps a byte range into
  the original, so untouched lines are emitted verbatim and only edited ones are
  rebuilt. Parsing and re-serialising would drop every property we do not model.
- ical: content hashing excludes DTSTAMP and LAST-MODIFIED. Servers rewrite them
  on every store, so hashing them would report a change on every cycle forever.
- provenance: aggregate UIDs derived as blake3(aggregate, source, source_uid),
  length-prefixed so field boundaries cannot collide. Deriving rather than
  recording makes the state file a cache, and makes our own mirrors recognisable,
  which is what stops writes echoing back around.
- mirror: the transforms. An aggregate copy must be scheduling inert, so writing
  it never mails invitations for a meeting already invited from its source.
  Google can suppress notification and keeps real attendees; CalDAV cannot, so
  the guest list is demoted to inert data and a declined meeting is marked
  TRANSP:TRANSPARENT. Writing an edit back uses the source as donor for what the
  demotion removed, so editing a time cannot silently drop the guests.
- reconcile: pure decision engine. Only the source changed updates the mirror,
  only the aggregate changed writes back, both changed keeps the source and logs
  a conflict.
- Mass-deletion guard takes an absolute floor as well as a fraction: a share
  alone is meaningless at small counts, where deleting the only event is 100%.
- sync refuses to run when an aggregate's configured target differs from the
  recorded one, before reconciling. Otherwise the new empty target would read as
  an aggregate whose every event was deleted, and delete propagation would then
  remove them from every source.

Found by end-to-end testing: writing an item already present under a different
filename created a duplicate rather than replacing it, because filenames are
derived from the UID while pimsync picks its own. Writes now carry the path they
supersede. Covered by a regression test.

79 tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-10 09:55:06 +03:00
src Add the aggregation engine and a local sync cycle 2026-09-10 09:55:06 +03:00
.gitignore Scaffold calcalist: repo, toolchain, config model and doctor 2026-09-10 09:31:32 +03:00
Cargo.lock Add the aggregation engine and a local sync cycle 2026-09-10 09:55:06 +03:00
Cargo.toml Add the aggregation engine and a local sync cycle 2026-09-10 09:55:06 +03:00
devbox.json Scaffold calcalist: repo, toolchain, config model and doctor 2026-09-10 09:31:32 +03:00
devbox.lock Scaffold calcalist: repo, toolchain, config model and doctor 2026-09-10 09:31:32 +03:00
SPECS.md Scaffold calcalist: repo, toolchain, config model and doctor 2026-09-10 09:31:32 +03:00
TODO.md Add the aggregation engine and a local sync cycle 2026-09-10 09:55:06 +03:00