Skip to content

aw-sync: return and persist a SyncReport — a pass is a side effect, so nothing can report what it did #695

Description

@ErikBjare

A sync pass is modelled as a side effect rather than as a function that returns what it did. That single choice is why sync failures are structurally invisible, and it is cheap to reverse.

Today

The information mostly already exists and is discarded. sync_one computes new_events_count per bucket and logs it; sync_run knows which peers it found. None of it survives the call.

This is the mechanism behind #682: a daemon ran 102 consecutive passes importing nothing, logging Pulling... each time. Not that nobody looked — there was nothing to look at.

Proposal

Return a SyncReport from sync_run, aggregate it in pull_all/push, and persist the latest one:

pub struct SyncReport {
    pub started: DateTime<Utc>,
    pub finished: DateTime<Utc>,
    pub mode: SyncMode,
    pub peers: Vec<PeerReport>,   // one per peer considered
    pub pushed: Vec<BucketReport>,
}

pub struct PeerReport {
    pub device_id: String,
    pub hostname: String,
    pub path: PathBuf,
    pub outcome: PeerOutcome,     // Imported | Skipped(reason) | Failed(error)
    pub buckets: Vec<BucketReport>,
}

pub struct BucketReport {
    pub bucket_id: String,
    pub events_new: i64,
    pub resumed_at: Option<DateTime<Utc>>,
}

Then:

Scope boundary

This covers facts about what a pass did. It deliberately does not cover facts the sync folder cannot currently express — "which device is this peer", "when did it last push", "is a peer missing that used to be here". Those need per-device metadata in the folder (the manifest discussed in ActivityWatch/activitywatch#302 / #691) and are out of scope here.

Worth doing first precisely because it is small, has no format implications, and unblocks three other issues.

Credit: found in a design review of aw-sync.

Related: #684, #687, #688, #682, ActivityWatch/aw-android#274.

cc @TimeToBuildBob

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions