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>
This commit is contained in:
parent
ef399db4d8
commit
e7d36879cb
12 changed files with 3253 additions and 20 deletions
35
TODO.md
35
TODO.md
|
|
@ -16,17 +16,20 @@ sync semantics these items implement.
|
|||
|
||||
Core modules:
|
||||
|
||||
- [ ] `state.rs` — JSON sidecar, atomic temp + fsync + rename; records each aggregate's
|
||||
- [x] `state.rs` — JSON sidecar, atomic temp + fsync + rename; records each aggregate's
|
||||
resolved target endpoint id **and** backend type
|
||||
- [ ] `vdir.rs` — read and write vdir directories
|
||||
- [ ] `ical.rs` — surgical line-level `.ics` editing (UID rewrite, property injection),
|
||||
- [x] `vdir.rs` — read and write vdir directories
|
||||
- [x] `ical.rs` — surgical line-level `.ics` editing (UID rewrite, property injection),
|
||||
respecting RFC 5545 folding; no parse-and-reserialize
|
||||
- [ ] `provenance.rs` — deterministic `blake3(aggregate_id, source_id, source_uid)` UIDs
|
||||
- [ ] `reconcile.rs` — the aggregation engine; pure, no I/O
|
||||
- [x] `provenance.rs` — deterministic `blake3(aggregate_id, source_id, source_uid)` UIDs
|
||||
- [x] `mirror.rs` — the to-aggregate and to-source transforms (added; not in the
|
||||
original plan, which folded these into `reconcile`)
|
||||
- [x] `reconcile.rs` — the aggregation engine; pure, no I/O
|
||||
- [x] `sync.rs` — one cycle over the local vdirs, applying what `reconcile` decides
|
||||
- [ ] `pimsync.rs` — generate `pimsync.conf` (with `on_empty skip` and `on_delete skip`),
|
||||
drive one-shot `pimsync sync`
|
||||
- [ ] `google/auth.rs`, `google/api.rs`, `google/convert.rs`
|
||||
- [ ] Reintroduce `SchedulingSuppression` in `config.rs` (removed in M0 as dead code)
|
||||
- [x] Reintroduce `SchedulingSuppression` in `config.rs` (removed in M0 as dead code)
|
||||
|
||||
Safety-critical behaviour:
|
||||
|
||||
|
|
@ -34,21 +37,25 @@ Safety-critical behaviour:
|
|||
guests are on a mail sink we control and confirm no mail is emitted; repeat for
|
||||
update and delete under `sendUpdates=none`. The Google attendee path depends on
|
||||
it. Fallback if it fails: the same demotion transform used for CalDAV.
|
||||
- [ ] `sync` refuses to run on aggregate target drift, before reconciliation
|
||||
- [x] `sync` refuses to run on aggregate target drift, before reconciliation
|
||||
- [ ] `aggregate retarget` — flush unrouted creations against the old target, then
|
||||
re-materialise; keep old orphans by default
|
||||
- [ ] Mass-deletion guard (`max_delete_fraction`), overridable with `--force`
|
||||
- [ ] Echo suppression: derived UIDs are never re-ingested as source events
|
||||
- [x] Mass-deletion guard (`max_delete_fraction`), overridable with `--force`, with an
|
||||
absolute floor so deleting a couple of events is never refused
|
||||
- [x] Echo suppression: derived UIDs are never re-ingested as source events
|
||||
|
||||
Tests:
|
||||
|
||||
- [ ] `reconcile` table-driven cases: create/update/delete each direction, both-sides-changed,
|
||||
- [x] `reconcile` table-driven cases: create/update/delete each direction, both-sides-changed,
|
||||
routing, echo suppression, mass-delete abort
|
||||
- [ ] `ical` round-trip fixtures: recurring with overrides, all-day, TZID, unknown `X-` props
|
||||
- [x] `ical` round-trip fixtures: recurring with overrides, all-day, TZID, unknown `X-` props
|
||||
- [ ] Integration against Radicale plus a `file://` WebCal fixture; assert idempotence
|
||||
- [ ] Safety: no live `ATTENDEE`/`ORGANIZER` on a CalDAV-targeted mirror, `VALARM` intact,
|
||||
`PARTSTAT: DECLINED` maps to `TRANSP: TRANSPARENT`, emptying a source aborts
|
||||
- [ ] Retarget: drift makes `sync` exit non-zero having written nothing and losing no source event
|
||||
- [x] Safety (unit level): no live `ATTENDEE`/`ORGANIZER` on a CalDAV-targeted mirror,
|
||||
`VALARM` intact, `PARTSTAT: DECLINED` maps to `TRANSP: TRANSPARENT`, bulk deletion aborts
|
||||
- [ ] Safety (integration): the same against a real Radicale instance with an SMTP sink,
|
||||
proving no mail is emitted
|
||||
- [ ] Retarget: drift makes `sync` exit non-zero having written nothing and losing no source
|
||||
event (verified by hand end to end; still needs an automated test)
|
||||
|
||||
## M2 — interface and packaging
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue