Rewrites every British spelling found in the codebase to American: neighbour, colour, catalogue, behaviour, honour, flavour, grey, judgement, acknowledgement, licence, defence, organise/optimise/initialise/recognise/ analyse, artefact, cancelled/cancelling, labelled/labelling, modelled/ modelling, and centre/centred/centring all become their American forms — consistently in prose (docs, ADRs, comments) and in identifiers, including the FFI-shared CatalogueSync/Cancelled enum variants and catalogue_* fields that cross the Rust/Kotlin boundary. Left untouched: external API names that only look like a spelling variant (kotlinx.coroutines.CancellationException/NonCancellable, Compose Material3's labelLarge) and the EFF diceware wordlist used for key derivation. Adds a Code Style rule to AGENTS.md/CLAUDE.md requiring American spelling in user-facing copy and documentation going forward, with that same carve-out. Verified: cargo build --workspace, all 1410 Rust tests, Kotlin compile, fmt-rust/fmt-kotlin, lint-kotlin-fast (detekt), and the lint-gui-layout/ lint-sql-params/lint-p2p-admission custom checks all pass clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017fHWzCF6oNiCV4ue1bBf1t
23 KiB
Content Placement: a UX redesign of the sync system
A revision of the user-facing half of docs/sync-management.md. That
document's model — two planes, per-node policy, pull-only reconciliation — is
right and is built. What it did not design is how a person sees whether
the model is being honored, and that omission is why the system reads as
broken even where it works.
Nothing here changes the wire protocols or the plane split. It changes what is counted, what is named, and which node an action is understood to command.
Status: all seven steps of §4 are built, each carrying its own note on what
landed and what it left behind. Three things the redesign touched are still
open, and they live in TODO.md rather than here: the per-node default policy,
presence rollups beyond the Documents list, and a deficit badge on each ensemble
member row. §1 describes the state that prompted this and is deliberately left
in the present tense as the diagnosis — read §4 for what has since changed.
1. What was actually wrong
Three separate faults, routinely mistaken for one bug ("artifact sync doesn't work").
1.1 An action on node A can never satisfy an intent set for node B
docs/sync-management.md's "What happens to SyncDisposition" decided that
every node satisfies its own policy by pulling. That is a good decision
and the code implements it faithfully. But the UI offers, on node A:
- a per-type policy table that can be pointed at node B (Settings → Sync
policy, node selector —
settings/sync.rs), and - a per-member "Sync" button (Settings → Ensemble —
settings/ensemble/mod.rs:318) that callsscheduler::sync_with_peer(lib/src/scheduler/mod.rs:151).
sync_with_peer runs a bidirectional catalog exchange, then runs passes 2
and 3 against the local node's own wants. So setting B's Music policy to
Mirror on A and then pressing Sync on A produces exactly what was reported:
B's document hierarchy fills in (doc-sync is bidirectional), and no audio
moves, because nothing on that path ever asks B to compute its own wants.
The remedy already exists — node_admin::trigger_sync
(lib/src/p2p/node_admin.rs:445) — but it is reachable only from a "Sync now"
button next to a status line on the Settings → Sync policy tab
(settings/sync.rs:235), desktop only, and only while a remote node is
selected in a picker the user had to find first. The one control that looks
like "make these two nodes agree" is the one that cannot.
The user's model is not wrong. The architecture's is not wrong either. The UI simply never tells anyone that an action is addressed to a node.
1.2 Nothing anywhere reports a deficit
compute_wants (lib/src/scheduler/mod.rs:671) already answers the only
question that matters — what does this node want and not have? — and it is
private, called from one place, and its result is never shown.
Every readout in the app counts what is present:
SyncPolicyControlshowsbytes_stored, and its doc comment still says the missing half "needs the scheduler's not-yet-built 'wants' computation (phase 3)". Phase 3 landed; the comment did not.node_admin::SyncConfig(lib/src/p2p/node_admin.rs:124) shipscontent_bytes_by_typeand no counterpart, so a remote node's row is structurally incapable of showing a deficit.- The document detail Sync tab (
agents/documents/detail_view.rs:1492) has a button, a sentence of explanation, and an override picker — no content-presence readout at all, despitesync-management.md's mock leading withContent: 2 of 2 files stored locally.
The consequence is that Mirror is unfalsifiable from the UI. A policy that
took effect and a policy that silently binds to nothing (wrong type, an
Exclude on an ancestor, a scheduler that hasn't ticked) look identical: a
picker set to Mirror, and a byte count that is whatever it is.
sync_prefs.rs's module doc compounds this — it still claims "Neither is
consulted by the sync engine yet", which is now false.
1.3 Everything is denominated in documents; what fails to arrive is content
"synced 214 doc(s)", documents_pushed, wanted_documents,
descendant_count. The unit of every message is the document. The unit of
every failure is a file that isn't here. A user watching "synced 1,340
doc(s)" scroll past while no music plays has been told, accurately, about the
wrong plane.
Add to this that the desktop's widgets don't reflect job state (TODO.md,
"Widgets reflect job state in place: done on Android, and the desktop is now
the one behind"): work started by the scheduler or by a remote TriggerSync
leaves every button idle and offering to start it again. So even when
reconciliation is running, the screen says nothing is happening.
1.4 Nine surfaces, three verbs, two objects
Controls that move or govern content today:
| Where | Control | Object | Node it commands |
|---|---|---|---|
| Settings → Sync policy | per-type policy | type | selected node |
| Settings → Sync policy | Reclaim… | type | this node |
| Settings → Sync policy | Background sync on/interval | — | this node |
| Settings → Sync policy | "Sync now" (remote) | — | selected remote node |
| Settings → Ensemble | per-member "Sync" | — | this node (pulls) |
| Doc detail → Sync | "Sync to this node" | document subtree | this node |
| Doc detail → Sync | "Keep here" Follow/Pin/Exclude | document subtree | this node |
| Doc detail → Sync | per-peer Push now + override | document subtree | that peer |
| Doc detail → Overview | per-artifact "Sync" | one artifact | this node |
Three verbs (sync, push, keep), two objects (documents, artifacts), and a "node it commands" column that is invisible on every row. The per-artifact button at the bottom is the one users end up trusting, because it is the only one whose scope is small enough to verify by eye — which is how "I have to hit sync artifacts on every document by hand" becomes the workflow.
2. The conceptual fix
Three axes are currently spelled with one word. Separate them, and name each in the UI:
- Intent — declarative, durable, per node: this node should hold X.
(
SyncPolicy,Pin/Exclude.) - Placement — observed, derived: this node does / does not hold X. (Today: unnamed and unshown.)
- Reconciliation — the act of closing the gap between the two, performed by the node with the intent, on its own or when told to.
Once placement is a visible quantity, reconciliation stops needing to be a verb the user aims. The user states an intent for a node, sees a deficit appear, and presses one thing to close it — from whichever node they happen to be holding.
And the unit of all three is content: blob-backed artifacts
(PrimaryContent, Attachment), which is what the two-plane split already
says is the only policy-governed thing. Notes, playback positions, tags,
thumbnails ride the catalog plane unconditionally and must never appear in
a policy UI — showing them there is what makes people ask whether policy
"applies to documents or artifacts."
On the word: artifact, deliberately
An earlier draft of this section argued for "files" in the policy surfaces, on the grounds that "artifact" is the codebase's word and not a user's. That is overruled, and the reasoning is worth writing down, because it is the more interesting claim.
An artifact is not a file in the sense a computer user already has. A file is a path on a disk that one machine owns; you move it, you copy it, you lose track of which copy is current. An artifact is a versioned, content-addressed thing attached to a document, which exists in the ensemble rather than on a machine, may be held by several nodes or none, merges rather than clobbers, and can be present as a value while its bytes are somewhere else entirely. Calling it a file borrows a mental model that is wrong in every one of those respects — and wrong in the direction that produces the bugs this whole system exists to avoid, because the file model is the one where you fix a conflict by picking a copy.
So the user-facing word is artifact, everywhere: the deficit counts
artifacts, Mirror mirrors artifacts, the Placement table's column counts
artifacts. Teaching an unfamiliar word is a real cost, paid once. Teaching a
familiar word that quietly means something else is paid forever, in
misunderstandings that look like the software being broken.
The Placement table's column heading stays Content, which names the plane rather than the unit and is what the policy actually governs; the counts inside it are artifacts.
Implemented. The field names stay files_* — that is the codebase's own word
for the content plane's unit, and no user reads them — but every rendered
string says artifact.
3. The redesign
3.1 One computation: the content ledger
Promote compute_wants into a public, per-node ledger in lib — as built,
rust/lib/src/content_ledger.rs:
pub struct ContentLedger {
pub by_type: BTreeMap<DocumentType, TypeLedger>,
/// The deficit, itemized — the scheduler's content-pass work list.
pub wants: Vec<Want>,
}
pub struct TypeLedger {
/// Everything of this type the catalog knows about. The denominator.
pub files_total: u32, pub bytes_total: u64,
/// On disk right now, whatever policy says.
pub files_here: u32, pub bytes_here: u64,
/// Wanted and missing — the deficit.
pub files_missing: u32, pub bytes_missing: u64,
/// Here, but no longer wanted kept. A subset of `here`.
pub files_unwanted: u32, pub bytes_unwanted: u64,
}
Pairs rather than a partition, because they answer independent questions:
unwanted is a subset of here, missing is disjoint from here, and both
are subsets of total. The itemized wants and the files_missing count come
off the same walk, so the number on screen and the work the scheduler does
cannot disagree — which is the property the three separate walks could not
offer.
total is what makes the row diagnostic rather than merely informative: "0 of
1,340 files held" and "No files of this type" are the difference between a
transfer that hasn't happened and a policy that matches nothing, and without a
denominator both render as zero.
Then:
SyncPolicyControlrenders the lines: "1,204 of 1,340 file(s) held (12.1 GB of 14.4 GB)" and, beneath it, "136 file(s) missing (2.3 GB)".node_admin::SyncConfigcarriesTypeLedgerper type instead ofcontent_bytes_by_type, so a remote node's row shows the same numbers. From the phone: "helios · Music · Mirror · 0 of 1,340 file(s) held · 1,340 file(s) missing (61 GB)" — the single readout that would have made the reported problem self-diagnosing.- The Ensemble member row could show a peer's total deficit as a badge; that
needs a
GetSyncConfiground trip per row on a screen that does no network work per row today, so it is left in TODO.md rather than done here.
The walk stats the blob store once per blob-backed artifact reference — no SQL join is possible against a filesystem-backed store — so it is not a hot path. The Sync tab is already a multi-second walk that TODO.md says to keep on-demand; it now does one where it did two. Keep it on-demand and cache per (node, tab visit); revisit if it needs to be live.
3.2 A user directs any node; pull is how it is carried out
sync-management.md made "every node satisfies its own policy by pulling"
both a transport invariant and a product rule. It is a good transport
invariant and a bad product rule: it left "make the server hold all my music"
with no way to be acted on, only set and waited out.
The correction, now written into sync-management.md's "What happens to
SyncDisposition": a user may direct any node to hold content, from any
node. Pull is the mechanism — the target is instructed and fetches under its
own policy, and no node pushes content uninvited. What changes is that
instructing a peer is a first-class act instead of an implementation detail
behind a picker.
-
Ensemble → per-member "Sync" becomes "Sync both ways", and does both halves: the catalog exchange and this node's own content pull, plus a best-effort
node_admin::trigger_sync(peer)so the peer runs its own three passes. Sent before the local content pass, not after — a peer made to wait out a multi-minute download here would look, from its own screen, exactly like a peer that was never told.Safe by construction:
TriggerSynccan only cause fetching. The design doc's phase-5 rule — remote requests never evict — already holds. -
The Settings → Sync policy remote "Sync now" stays, but stops being the only door.
-
Buttons whose scope is one node's pull say so: "Download to this node", not "Sync to this node".
-
Result strings lead with files, not documents, and say what the other node was told: "3 file(s) fetched; 1340 doc(s) synced; helios is syncing its own side". Success speaks as well as failure here, because it is the only place a user can learn the button commands two nodes — until step 3 puts a deficit on screen, at which point the reassurance is redundant.
3.3 Collapse nine surfaces to three
A. Settings → Content (renames "Sync policy"). One node selector, one table, three numbers per row, Reclaim where it applies, background-sync settings for the local node. Everything type-level, for any node, in one place. Unchanged in structure from today — it just gains the deficit and loses the ambiguity in its title.
B. Document detail → one Placement table. Today the Sync tab splits "Keep here" (this node) from "Sync to other node" (peers), which are the same question asked twice in two different widgets. Make it one table where this node is simply row 0:
Placement 3 files · 38.4 MiB
node files here keep?
this node 3 of 3 [Follow ▾] [Download]
helios 3 of 3 [Pin ▾] [Push now]
phone 0 of 3 [Exclude ▾] [Push now]
files here is the ledger scoped to this subtree — the readout
sync-management.md specified and that was never built. It is also what makes
the per-artifact buttons stop being load-bearing: a glance says whether the
subtree landed.
C. Jobs — unchanged, but the desktop needs to catch up to Android's
job-bound widgets (TODO.md) so a scheduler- or TriggerSync-started fetch
stops rendering as an idle button.
3.4 Make placement visible without opening documents
Add a content-presence glyph to the Documents list and the media library rows,
derived from the same ledger: ✓ all wanted files here, ◐ partial, · none
wanted. A library of 1,340 tracks showing · on every row while Music is set
to Mirror is a diagnosis in one screenful. Cheap to compute alongside the
ledger; must not be a per-row query.
4. Build order
Each step is independently useful, and the first two are most of the value.
-
ContentLedgerinlib— done.content_ledger::content_ledgerreplaces the privatecompute_wants,eviction::reclaimable_bytes_by_type's parallel walk, andStore::local_content_bytes_by_type(deleted). One walk, three numbers, and the policy-resolution rule now lives in one place so "want" and "keep" cannot drift apart. Thumbnails left the content plane's tallies, which is why a type's "bytes stored" figure will read lower than before — the two numbers on that row are now commensurable. -
Sync-both-ways — done.
scheduler::sync_with_peersendsnode_admin::trigger_syncafter the catalog exchange and before its own content pass, and reports the outcome asRemoteReconcileon the summary. One shared formatter (copy::PeerSyncCopy) replaced four hand-rolled status lines across the GUI, TUI, CLI, and Android, all of them leading with a document count and three of them calling blob transfers "artifacts". Android now takes the whole line from Rust rather than concatenating its own. Also fixed in passing:sync_with_peerhad no guard against targeting the local node, which with a remote trigger attached would have been a node ordering itself around over the network. -
Deficit on screen — done.
SyncConfigcarriesTypeLedgerper type instead of a bare byte count (a node-admin ALPN bump), so a remote row shows what that node holds and what its policy is still missing — which is half of deciding what it should hold. Both modalities render three lines from one sharedcopy::ContentRowCopy, givingMirrora falsifiable readout for the first time: "0 of 1,340 files held" + "1,340 files missing" (pending) reads differently from "No files of this type" (the policy matches nothing) and from "0 of 1,340 files held" with no deficit (anExcludeup the tree).The
files_totaldenominator is new — without it the last two of those three states are indistinguishable.eviction::reclaimable_bytes_by_typeand its FFI went away: the ledger'sbytes_unwantedwas already the same number, and Android was rendering it through a second code path.Fixed on the way through: the remote row said "N stored on this node" about a different node, and Android's local rows patched a changed policy in place without re-reading the stats — which for a deficit would have been the exact misreading these lines exist to prevent.
-
Document detail Placement table — done (desktop + Android).
content_ledger::document_placementcomputes it, subtree-scoped since every action on that screen already recurses. Both modalities render one table with this node as row 0; the two action handlers collapse the same way, one entry point each branching on which row it is.Two distinctions the types now carry rather than the UI guessing at: this node's holding is blob-store fact while a peer's is
node_content_statusevidence (so a peer row shows the oldest confirmation among the files counted, and a peer with no evidence renders "—" rather than 0 — "never asked" and "holds nothing" call for different actions); and the version column is blank for this node, since it exists to say whether a peer has the version we have.Android reads the assembled rows over one new FFI call rather than composing ensemble members, this node's override, and per-node status in Kotlin — that composition is how the two modalities drift.
-
Desktop job-bound widgets — done.
job_bindingis the desktop counterpart of Android'sJobBinding.kt; the Placement table's buttons and the Ensemble screen's Sync read the live job rather than this screen's own click. -
Presence in list views — done (desktop). A row's presence is now a rollup over its subtree rather than a boolean about the row itself, which is what a collection needs: a podcast feed has no content of its own, so asking only about the row reported "here" for every feed in the library whether or not a single episode had downloaded. A partly-held row says its numbers — "3 of 10" is the whole content of "partly here". Thumbnails left the count, so a document whose cover art hasn't arrived no longer reads as missing its content.
Not done: the media library screens (music, comics, pictures) still use their own per-item availability, and Android's lists are untouched.
-
Vocabulary — done. Every rendered string says artifact:
PeerSyncCopy,ContentRowCopy,placement_content/placement_summary, and the eviction dialogs. Field names stayfiles_*; no user reads them.Two things fell out beyond a rename.
SyncPolicy's own descriptions said "document" —Mirrorread "every document of this type is kept on this node", describing something already unconditionally true and not the thing being chosen. That wording is the origin of "it's unclear whether this applies to documents or artifacts", which is what prompted this redesign; it now says artifact. And the eviction dialogs' three sentences existed in three copies (both desktop dialogs and Android) which had already drifted — they are rendered once incopy::evictionand ride onEvictionPlanItem, so a screen reads a field instead of retyping a string.Still open, and listed in TODO.md rather than here: the per-node default policy (
KeepOnOpendesktop,Streammobile), which needs a seamSyncPolicy::default()does not have.(The stale doc comments this step was going to fix —
sync_prefs.rs's "consulted by the sync engine yet",SyncPolicyControl's "not-yet-built wants computation" — went with steps 1-2, since those steps are what made them false.sync-management.mdpoints here now.)
5. Decisions I'd want from you
-
"Files" vs "artifacts" in policy UISettled: artifact, and not as a concession to the codebase's vocabulary — an artifact genuinely is not a file, and borrowing the file mental model imports exactly the assumptions that break here. See §2. -
Should Ensemble → Reconcile fireSettled: yes, and the pull-only rule is demoted to a transport invariant (§3.2). The button is labeled "Sync both ways" so it is not commanding another node from an ambiguous label.TriggerSyncon the peer? -
IsSettled:Streamstill the right default for every type?KeepOnOpenon the desktop,Streamon mobile. A desktop that holds nothing until told is exactly the configuration that produces "syncing doesn't work", while a phone that quietly accumulates every PDF it opens is the configuration that produces a full device. No first-run wizard needed for either.Needs a seam that does not exist:
SyncPolicy::default()is one value for every platform. The default belongs to the node, decided once at initialization from what kind of node it is, rather than to the enum — which also leaves room for the "phone"/"server" profiles under Open questions. -
ShouldSettled in principle: a decision to mirror must not be lost. Step 2 covers the reachable case — the peer is told and pulls — and does nothing for a peer asleep at that moment, where the instruction simply evaporates and that node converges on its own clock. A phone asleep when you press the button is the common case, not the exotic one.Mirroron a remote node be a push from here rather than a pull there?Queue the directive as the near-term answer, so pressing the button is durable rather than best-effort. What the right behavior is against a real sleeping phone — how long a queued directive stays valid, whether it survives the target's policy changing underneath it, whether the user should see a pending queue at all — is a question for experiment rather than argument, and the queue is what makes those experiments possible.
See TODO.md's "Queue a sync directive for a node that is asleep".