Skip to content

desktop/src-tauri/crates/core/src/exchange.rs

Comment 1, line 1

desktop/src-tauri/crates/core/src/exchange.rs:1

//! Historical source exchange rules (M1a, data-contract.md#provenance):

Comment 2, line 2

desktop/src-tauri/crates/core/src/exchange.rs:2

//! versioned exports and merge decisions for duplicates, newer revisions, disjoint contributions and conflicts.

Comment 3, line 3

desktop/src-tauri/crates/core/src/exchange.rs:3

//!

Comment 4, line 4

desktop/src-tauri/crates/core/src/exchange.rs:4

//! Boundaries:

Comment 5, line 5

desktop/src-tauri/crates/core/src/exchange.rs:5

//! - this module defines formats, builds exports and resolves records; aggregate writes live in exchange_import;

Comment 6, line 6

desktop/src-tauri/crates/core/src/exchange.rs:6

//! - display CSV/charts are not lossless reimport packages;

Comment 7, line 7

desktop/src-tauri/crates/core/src/exchange.rs:7

//! - batch_id prevents duplicate import operations without replacing source-record identity;

Comment 8, line 8

desktop/src-tauri/crates/core/src/exchange.rs:8

//! - exports may redact hostname labels while retaining stable source keys.

Comment 9, line 19

desktop/src-tauri/crates/core/src/exchange.rs:19

/// Full or incremental export; omission from an incremental package is not deletion.

Comment 10, line 20

desktop/src-tauri/crates/core/src/exchange.rs:20

/// Explicit deletions declare removed source-record keys.

Comment 11, line 26

desktop/src-tauri/crates/core/src/exchange.rs:26

/// Lower-bound event timestamp in milliseconds; None imposes no incremental lower bound.

Comment 12, line 28

desktop/src-tauri/crates/core/src/exchange.rs:28

/// Deleted keys as (source_instance_id, source_record_key).

Comment 13, line 29

desktop/src-tauri/crates/core/src/exchange.rs:29

/// Empty declarations mean no deletion.

Comment 14, line 38

desktop/src-tauri/crates/core/src/exchange.rs:38

/// Deletion reason, such as observed source cleanup, without message content.

Comment 15, line 42

desktop/src-tauri/crates/core/src/exchange.rs:42

/// Source host registration: hostname labels may be redacted, while host_id stays unchanged.

Comment 16, line 50

desktop/src-tauri/crates/core/src/exchange.rs:50

/// Original source-instance registration; an importing machine must not replace its ownership.

Comment 17, line 60

desktop/src-tauri/crates/core/src/exchange.rs:60

/// Selected field coverage/capability JSON without message content.

Comment 18, line 66

desktop/src-tauri/crates/core/src/exchange.rs:66

/// Source plus record key identifies an exchange event; values and coverage travel with it.

Comment 19, line 93

desktop/src-tauri/crates/core/src/exchange.rs:93

/// Eight nullable token fields; preserve unknowns without filling zeros.

Comment 20, line 95

desktop/src-tauri/crates/core/src/exchange.rs:95

/// Event quality category: complete, partial, estimated or unknown, distinct from per-field quality.

Comment 21, line 103

desktop/src-tauri/crates/core/src/exchange.rs:103

/// Values correspond to usage_events columns; null means unknown.

Comment 22, line 143

desktop/src-tauri/crates/core/src/exchange.rs:143

/// Daily/sealed partitions preserve source/revision when details are deleted.

Comment 23, line 168

desktop/src-tauri/crates/core/src/exchange.rs:168

/// Retained hourly rows merge by timezone/day/hour/dimensions.

Comment 24, line 219

desktop/src-tauri/crates/core/src/exchange.rs:219

/// Complete export package.

Comment 25, line 224

desktop/src-tauri/crates/core/src/exchange.rs:224

/// Batch identity prevents repeated imports without replacing record identity.

Comment 26, line 231

desktop/src-tauri/crates/core/src/exchange.rs:231

/// All daily partitions, including recent days with retained details; aggregate imports use them

Comment 27, line 232

desktop/src-tauri/crates/core/src/exchange.rs:232

/// without adding records again, and desktop aggregate exports omit records.

Comment 28, line 235

desktop/src-tauri/crates/core/src/exchange.rs:235

/// Hourly history remains available after detail deletion.

Comment 29, line 242

desktop/src-tauri/crates/core/src/exchange.rs:242

/// Export request.

Comment 30, line 246

desktop/src-tauri/crates/core/src/exchange.rs:246

/// Event range [from_ms, to_ms) in milliseconds.

Comment 31, line 249

desktop/src-tauri/crates/core/src/exchange.rs:249

/// None selects all sources; Some([]) selects none.

Comment 32, line 251

desktop/src-tauri/crates/core/src/exchange.rs:251

/// True omits hostname labels from exports.

Comment 33, line 257

desktop/src-tauri/crates/core/src/exchange.rs:257

/// Build an export through read-only queries.

Comment 34, line 266

desktop/src-tauri/crates/core/src/exchange.rs:266

/// Aggregate-only desktop exchange omits raw request/session identities.

Comment 35, line 302

desktop/src-tauri/crates/core/src/exchange.rs:302

// The package uses the local host; each source retains its original host ownership on reexport.

Comment 36, line 327

desktop/src-tauri/crates/core/src/exchange.rs:327

// Register included source instances and their original origin_host_id metadata.

Comment 37, line 384

desktop/src-tauri/crates/core/src/exchange.rs:384

// Event details.

Comment 38, line 444

desktop/src-tauri/crates/core/src/exchange.rs:444

// All daily partitions, including recent unsealed days, retain source/revision/coverage counts.

Comment 39, line 502

desktop/src-tauri/crates/core/src/exchange.rs:502

// Export only retained hourly rows; import merges by revision.

Comment 40, line 606

desktop/src-tauri/crates/core/src/exchange.rs:606

/// Existing record metadata for an import merge decision.

Comment 41, line 616

desktop/src-tauri/crates/core/src/exchange.rs:616

/// Merge result, following the data rules.

Comment 42, line 619

desktop/src-tauri/crates/core/src/exchange.rs:619

/// Add a new record with independent coverage;

Comment 43, line 620

desktop/src-tauri/crates/core/src/exchange.rs:620

/// still deduplicate mirrored events rather than summing solely because source IDs differ.

Comment 44, line 622

desktop/src-tauri/crates/core/src/exchange.rs:622

/// Same source/key/revision/content is a duplicate; repeated exchange does not add usage.

Comment 45, line 624

desktop/src-tauri/crates/core/src/exchange.rs:624

/// Replace after revoking the old contribution when revision/lifecycle establishes a newer correction;

Comment 46, line 625

desktop/src-tauri/crates/core/src/exchange.rs:625

/// otherwise record Conflict without choosing by token magnitude.

Comment 47, line 627

desktop/src-tauri/crates/core/src/exchange.rs:627

/// Conflicting content with unresolved ordering retains the existing record and marks conflict.

Comment 48, line 631

desktop/src-tauri/crates/core/src/exchange.rs:631

/// Reuse ingest resolution: revision first, then lifecycle;

Comment 49, line 632

desktop/src-tauri/crates/core/src/exchange.rs:632

/// conflicting content at the same level remains a conflict.

Comment 50, line 670

desktop/src-tauri/crates/core/src/exchange.rs:670

/// Build an EventInput for resolution of identity/revision/lifecycle/content hash.

Comment 51, line 671

desktop/src-tauri/crates/core/src/exchange.rs:671

/// This comparison does not read usage, so the temporary event has empty token fields.