Commit Graph
100 Commits
Author SHA1 Message Date
Greg ShuflinandClaude Opus 5 ecb7e41c7a AGENTS.md: scope the build detail to the trees that need it
Build Debug APK / build (push) Successful in 3m42s
The root file loads into every session, and about a quarter of it was
build guidance that only applies inside one directory. The Android block
(the three `just doctor` toolchain cases) and the two-detekt-recipes
block now live in android/AGENTS.md; the gpui block (check-gui-nix,
build-gui-nix, and why rust-analyzer.json sets checkOnSave: false) lives
in rust/gui-app/AGENTS.md. Each is reached by a one-line pointer from the
root, and each opens by saying it is scoped and that the root file still
holds the project-wide rules. 21.5k chars down to 15.5k — roughly 1.5k
tokens back in every session, whatever the session is about.

Both new files get a CLAUDE.md symlink beside them, the same arrangement
the root already uses, so Claude Code picks them up when it works under
those directories while AGENTS.md stays the name on disk.

The split has one seam worth knowing about: the Kotlin lint entry warns
that a suddenly-slow `just lint-kotlin` means rust/lib/build.rs is
rebuilding, and that file sits outside android/, so the warning is not
loaded when you are the one editing build.rs. It stays in android/ anyway
because that is where someone hits the symptom.

Also dropped four lines the codebase already answers: the camelCase and
explicit-types conventions, the standard --tests invocation for a single
Gradle test, and an Architecture: line that still said JNI where the rest
of the file describes uniffi.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y7prPWuHReKauUzU34qyCh
2026-08-26 10:21:31 -07:00
Greg Shuflin 6db689fab0 epochs: syn ensemble renew-membership and rejoin
Build Debug APK / build (push) Successful in 5m9s
The CLI surface, and the shared state the other modalities will render.

renew-membership is the lost-or-stolen path, deliberately its own command
rather than a flag on revoke: the two are separate decisions and one is far
more expensive. Its confirmation's job is the blast radius, so it counts live
gossip neighbours rather than the roster total — reachable *right now* is
exactly what decides who gets renewed with this command and who is stranded
needing the keyphrase entered on them. It says that, and that losing the
keyphrase now strands those nodes permanently, before it asks.

rejoin is the way back. Needs the keyphrase and nothing else; no peer has to be
reachable, which is the property that makes it the fallback rather than the
optimisation.

EnsembleStatus grows current_epoch, this_node_epoch and
this_node_epoch_is_stale, so every modality can say 'your membership is out of
date' from one projection. The stale state is kept distinct from revoked
throughout: being revoked is something someone did on purpose, being left
behind is what happens to a device that was switched off at the wrong moment,
and only the second has a way back the user did not have to intend.

Both commands are refused over the loopback listener, same rule as retire and
revoke.

All the new copy went into copy::revocation as it was written rather than into
the screens — the rule from earlier today, applied on the way in for once.
2026-08-26 04:25:11 -07:00
Greg Shuflin 2bc9839a21 epochs: how a bump travels, and how a node left behind gets back
Three channels, mirroring how a revocation already moves.

Gossip carries EpochBump for promptness, verified against this node's own
ensemble key rather than against whoever relayed it — the property that makes
a revocation relayable, and needed here for the same reason: a node about to be
locked out must not be able to suppress the record by refusing to pass it on.

doc-sync's RevocationBatch becomes MembershipBatch and carries bumps beside the
deny-list. Same subject, same nodes want it at the same moment, and a bump is
109 bytes. Applied in ascending order so a node several epochs behind lands on
the newest rather than stopping at the first one it can apply.

The delivery protocol carries both too, and the ALPN becomes /syn/membership/1
because that is now what it is. Folding them together is the answer to the open
question the doc left: the two need the *same* exemption for the same reason —
a node refused everywhere, whether revoked or an epoch behind, has to be able
to reach something, and the only thing it may reach is a channel whose sole
effect is to hand over signed state it verifies itself. One exemption to reason
about beats two.

Minting: bump_epoch takes the keyphrase, moves the epoch, and re-certifies this
node in the same breath so the node holding the keyphrase does not lock itself
out by using it. recertify is the way back for a node that was offline through
a bump — with a verified record in hand it knows the epoch, and minting a cert
at it is purely local. Nothing is transported and no peer need be reachable,
which is what the doc predicted and what makes the fallback the part that
matters.

Not yet wired: nothing offers either of these to a user. Surfaces next.
2026-08-26 04:13:44 -07:00
Greg Shuflin 235b382074 epochs: the record, the store, and the gate it feeds
Phase 3b's mechanism, in the shape phase 2 established for revocations.

DelegationCert gains epoch: u32 inside its signed payload, so the number cannot
be edited after the fact and the fingerprint covers it. The payload version
goes to 2, which invalidates every cert issued before now — every node
re-registers, which is what an epoch bump does anyway, and the project takes
breaking changes to wire formats.

ensemble::epoch::EpochBump is a signed statement that the ensemble has moved,
and it is the *only* thing that advances an epoch. The tempting alternative —
treat a cert claiming a higher epoch as proof you are behind — has to be
refused, and that refusal shapes everything else: certs are minted locally by
whoever holds the keyphrase, so one bogus number fed to a legitimate user
re-registering would push the ensemble past every honestly-issued cert and lock
out every node at once.

stores::epoch::EpochStore holds the highest bump verified, and only ever moves
forwards. Replaying an older record is exactly what an attacker would try and
also what an honest peer does when it relays everything it holds, so a stale
bump is discarded rather than being an error. Whole records are kept, like the
deny-list keeps whole revocations and for the same reason: this node relays
bumps it did not mint, and a receiver verifies the signature itself.

admission checks the epoch before the deny-list — it is cheaper, and a stale
cert is what a *legitimate* node arrives with after being offline through a
bump, so naming that case is what lets the other end say 'your membership is
out of date' rather than refusing bare. A node whose own cert fell behind stops
serving and dialling, so it says that once instead of collecting refusals from
every peer.

Not yet wired: nothing propagates a bump and nothing mints one. Next.
2026-08-26 04:00:05 -07:00
Greg Shuflin 7735fd532b docs: say when an epoch bump happens, and what missing one feels like
3b described the mechanism and the trade-off but not the two things anyone
building it would have to decide first.

**When it moves.** Never automatically, and never as a side effect of an
ordinary revocation — phase 2 covers the common case, and bumping there charges
every other node a re-certification for a threat that is not present. The epoch
moves when the user says a device is out of their control, which is a claim
only they can make: a node that stops answering looks identical either way. The
natural place to ask is the revoke dialog, for a reason worth noticing —
revoking a peer already requires the keyphrase, which is exactly and only what
a bump needs. The dialog must say how many nodes will need the keyphrase
entered on them, and that the keyphrase is load-bearing again, before it
commits.

**What missing one feels like.** The case to design for is the phone in a
drawer, not the attacker. Refused everywhere, told why, handed the bump record
over a path that admits a stale caller — phase 2's exemption in the same shape
and safe for the same reason — and back in by entering the keyphrase locally.

Working that through changed two things.

A cert cannot establish the epoch. The mirror of "below the current epoch is
invalid" — that above it proves you are stale — has to be refused: certs are
minted locally by whoever holds the keyphrase, so a user tricked into
re-registering against a bogus epoch would push the ensemble past every
honestly-issued cert and lock out every node at once. The epoch advances only
on a signed EpochBump record, travelling exactly as a revocation does.

And it mostly closes the re-certification transport question. No cert needs
transporting: a node with a verified bump knows the epoch, and minting at it is
local. Pushing certs from the revoking node is an optimisation for reachable
nodes, and the fallback is the part that covers the offline ones.

Also corrected: the closing paragraph claimed the two mechanisms layer on the
same case. They do not. A bump evicts by itself; what the deny-list goes on
covering is revocations between bumps. And neither covers a device that took
the keyphrase too.

Repointed the audit's drifted line references by name, and marked its two
amplifier items with what §3a since did to them — one fixed outright, one no
longer decided with.
2026-08-26 03:12:18 -07:00
Greg Shuflin e6d7960177 TODO: point linkage scope at the branch where an attempt sits
Build Debug APK / build (push) Successful in 3m40s
The work is on linkage-security rather than here: parked deliberately, because
the capability model it needed to make scopes work may be more machinery than
the current browser extension warrants, and may not fit the linkages that
exist only as sketches.
2026-08-26 02:58:40 -07:00
Greg Shuflin a7e7c601be podcast: a search term reaches the API whole
Build Debug APK / build (push) Successful in 5m40s
search_podcasts built its URL with format!("…byterm?q={query}"), putting the
user's raw text where a URL has its own syntax. A search for "AT&T" arrived as
q=AT with a stray T parameter after it; anything past a # arrived truncated,
because a fragment is never sent at all. Spaces survived only because
Url::parse happens to percent-encode them.

RequestBuilder::query does the encoding, which meant turning on reqwest's
"query" feature — free, since its encoder is already in the tree via other
crates.

The sibling URL a few lines down interpolates a feed id and a max count, both
i64, and is left alone: a number has no characters to escape.

Five cases pinned against the built request rather than a sent one — this is
about how the URL is assembled, and the test should not touch the network.
2026-08-26 02:46:36 -07:00
Greg Shuflin 4ecf8aee1e copy: the podcast placeholder promised something the search cannot do
Android's search field said "Enter podcast name or URL". Both modalities call
the same agents::podcast::search_podcasts, which hits Podcast Index's
search/byterm — a term search. A pasted feed URL goes to it as a search term
and finds nothing. Subscribing by URL is not something this screen does
anywhere, so the shared placeholder is the desktop's wording.

Two things found while checking that, recorded in TODO.md rather than fixed
here:

The sync-configuration message difference is not an error. The desktop's
"see the status above" is accurate — render_remote_status shows
"Editing {node} — unreachable: {reason}" in the section above it. What the
difference exposes is that Android has no such status line at all: it never
names the node it is editing and never says the connection succeeded, only
that it failed. On the one screen whose edits leave the device, silence on
success is the wrong default. copy::settings::remote_config_unreachable takes
the reason as an Option so both modalities stay correct; closing that gap is
what would let Android pass None.

And search_podcasts interpolates the query straight into the URL, so a search
containing & or # is truncated or misparsed before it leaves the process —
"AT&T" searches for "AT". Same class as the lint-sql-params rule: a value
put into a string that has its own syntax.
2026-08-26 02:46:36 -07:00
Greg Shuflin 97d5abcff5 copy: the general audit — notes, documents, humans, linkages, settings
The rest of the sweep, found by comparing every user-visible string literal
across the four modalities and looking for near-matches. Grouped by subject,
since one subject reaches several screens on several modalities.

incoming_change — the alert-don't-apply banner. CLAUDE.md's first design
principle names three of these as worked examples and every one had written its
own sentence, including two spellings of the apostrophe. That is the wrong
thing to leave to a screen: the banner's job is to say what the user gives up
either way, which is a claim about the merge rules and not a matter of local
phrasing. The two subjects are named rather than passed as free text, and the
button words travel with them.

note_body_absent — the headline was identical on three modalities; the last
sentence of the detail was not, because the TUI cannot offer to start the note
over. That is a capability difference, so it is a parameter now rather than two
paragraphs that happen to end differently.

documents — the purge warning, the delete-locally title, the placement scope
line, the directory-import prompt. These say how far a destructive action
reaches, and three screens each spelling that out is three chances to make
three different promises. The descendant-count clause was written out four
times, identically, which is how it stayed identical: by luck.

humans — validation messages, which earn sharing for a reason most copy
doesn't: it is the app telling someone they did something wrong, and two
devices disagreeing about what is wrong is worse than either wording alone.

linkages, settings, pomodoro — the smaller ones. 'Nothing is linked to this
node yet.' had lost its 'yet' on the CLI; the node-key explainer was two
sentences on the desktop and a truncation of them on Android.

One divergence is kept and made deliberate: reading another node's sync
configuration fails with the reason on Android and without it on the desktop,
which carries it in a status line above. That is a real difference rather than
a disagreement, so it is an Option parameter and the stem is shared.

What the audit still reports is a tail of per-screen error banners — 'Failed to
load notebooks' against 'Failed to load pictures' — which are different
messages that merely rhyme.
2026-08-26 02:46:36 -07:00
Greg Shuflin 68a0f6c6ac copy: busy messages, empty states, and the asset-sync outcome
Three subjects where every modality had written its own version.

busy — six screens across four modalities had their own sentence for 'that is
already running', in two tenses and three capitalisations. The tense was
carrying meaning, so it is kept and made explicit rather than flattened:
busy::running is a refusal (the click did nothing) and busy::was_running is a
deferral (the click landed on work already under way, and its result is the one
you get). The FFI's two Busy errors go through it too, so Android's exception
text matches what the desktop shows.

empty — the jobs list and the roster. 'Nothing here' is exactly the message
someone compares across two devices when working out whether something synced,
so the two devices now say the same words. The TUI loses its parenthesised
abbreviations for these two, which read as a different answer rather than the
same one.

asset_sync — the four-way outcome of pulling a document's content. All three
modalities had independently reasoned their way to the same distinction —
'nothing was missing' is only a claim about the ensemble if a peer actually
answered the catalogue phase — and each had written that reasoning into a
comment beside its own phrasing. The derivation moves to copy.rs, which is
where it belonged: the interesting part is not the words but which of four
outcomes applies, and that is one judgement about the same snapshot fields
every time.

Android reaches the last two through empty_state_copy() and
asset_sync_summary() in ffi/free_fns.rs.
2026-08-26 02:46:36 -07:00
Greg Shuflin 59249196aa revocation 3a: authorship is not possession, and origin_node never was an amplifier
Phase 3a asked for two fixes. One was already done and the other was a
mis-diagnosis, so this closes it smaller than it was written.

The timestamp half is closed already, by p2p::wire_time: every peer-supplied
stamp decodes at one point, and one more than a day ahead of this node's clock
is rejected along with the field carrying it — rejected rather than clamped,
because clamping to now makes a bogus write the newest write, which is the
outcome the bound exists to prevent. That is the half that mattered, since
timestamps are what every merge rule compares.

origin_node is not a merge input at all. Properties and artifacts compare
modified_at, set elements compare their own add/remove stamps, tombstones
compare deleted_at. A lie about origin cannot win a comparison or suppress a
write. And the prescribed fix — derive it from the authenticated sender — would
have been a regression: doc-sync is transitive by design, so a record routinely
arrives from a peer that did not write it, and overwriting the claim with the
sender attributes every relayed edit to its relayer.

What was real is what consumed it. node_status::artifact_presence_for_node
inferred that an artifact's author still held its content, and put a Present on
the presence grid — which is what a user reads before deciding what is safe to
delete locally. That inference was unverifiable, and wrong about honest nodes
besides: a node that wrote an artifact and later reclaimed its content still
read as holding it.

So the inference goes, not the field. With no evidence an artifact now reads
exactly as the blob beside it always has, from the one row that came from the
node itself: it references the document, so Ref — 'it should have this' —
otherwise Unknown. Possession is asserted only from NodeContentStore, which is
written against the authenticated sender.

origin_node stays as provenance, documented once at Document::origin_node and
pointed at from the other seven fields and the eight wire records: safe to
show, unsafe to decide with.
2026-08-26 02:46:36 -07:00
Greg Shuflin e085ba683d copy: revocation says the same thing on every modality
I shipped four paraphrases of the same sentences. The desktop said a retired
node "prints" a record, Android and the TUI said it "shows" one; the revoke
dialog explained itself in three different ways; the self-revoked banner had
four wordings across GUI, Android, TUI and CLI.

copy::revocation is now the single definition, and every modality imports it —
the three Rust ones directly, Android through revocation_copy() in
ffi/free_fns.rs alongside placeholder_copy and action_labels. The sentences
that carry a node's name are their own exported functions, since a record of
constants cannot interpolate.

These are load-bearing rather than decorative: they are what tells someone that
revoking a node does *not* wipe it, that a retirement nobody heard can still be
repaired, and what "wipe now" costs. Four answers to that is four answers.

CLAUDE.md gains the rule, including the part I got wrong — paraphrase across
modalities is the same defect as duplication and harder to spot, and the
derivation belongs in copy.rs too, not just the strings.
2026-08-26 02:46:36 -07:00
Greg Shuflin 05db9b7530 tui: revoke a member, and import a record carried here by hand
x opens a keyphrase prompt for the selected member; i opens one for a
revocation record. Both go to the daemon on a worker thread like ping and sync
do, and both are followed by the quiet reload, so the row becomes revoked
without wiping the answer the user just asked for.

A prompt takes every key, q included. A keyphrase has letters in it, and the
one that used to quit the app is one of them.

The keyphrase names its node when the prompt opens rather than re-reading the
selection when it is sent. A peer announcing itself mid-keyphrase reorders the
roster under the cursor, and a revocation landing on whichever row the
selection had drifted to would be the worst possible version of a sync
disrupting what the user is doing.

Shown in the clear, matching how syn init and syn ensemble register read it: a
20-word bytewords phrase typed blind is a phrase typed wrong, and what this
defends against is a sibling node minting a revocation on its own, not someone
behind the terminal. Esc drops it rather than stashing it.

The minted record is kept per member and shown in full in the detail pane.
Nothing serves a record back once it is on the deny-list — the store holds its
bytes but no command returns them — so the moment it is minted is the only
chance to keep it. An imported one is not kept: it came from the user, and the
node it names may not be on this roster at all.

Ping and sync now refuse a revoked member rather than spending a dial to be
turned away at admission. Retiring *this* node stays out: it ends by deleting
the store this screen is reading, so it belongs to syn ensemble retire, which
can stop the daemon first. The refusal says so.
2026-08-26 02:46:36 -07:00
Greg Shuflin 35782c5290 podcasts: delete a dead downloader, and say what Play actually does
Build Debug APK / build (push) Successful in 3m49s
episode.rs claimed "no audio is streamed yet" while its Play has been handing
the enclosure URL to the transport bar as an AudioSource::Stream — the doc
predates the streaming work and read as if the screen were still a stub.

agents::podcast::fetch_episode_audio had no callers in any crate. It is also
the wrong shape for the offline-copy feature that would have wanted it: a
whole enclosure in a Vec<u8> is the memory profile TODO.md already flags for
BlobStore::store, so leaving it lying around invites building on it.
2026-08-26 02:01:19 -07:00
Greg Shuflin c7221f49a8 TODO: drop what's built, and fix what had gone stale
- The unified now-playing view across agents is ADR 0045, implemented on both
  modalities; its one unrelated nested bullet (configurable sidebar order)
  moves up to Agents rather than leaving with it.
- Pop-out windows exist (gui-app/src/popout.rs). The Android half of that
  bullet was a musing about a concept a phone doesn't have.
- Android's Notes screen has the incoming-body conflict UI the Android visual
  style item was still waiting on — IncomingBody.alertFor, which CLAUDE.md
  now cites as the Android worked example of alert-don't-apply.
- The Collection-card sync rollup has its mechanism (content_ledger::
  subtree_content, whose doc comment names this TODO); what is left is the
  media library screens adopting it, which the content-placement item already
  says more precisely. Deduped rather than deleted.
- Hierarchical documents display: both modalities expand a row's children in
  place.
- Podcast episode position tracking is a synced artifact; the half that is
  left is an offline copy, so the item says that and names the memory-hungry
  dead function nobody should build on. The feed-refresh item gains the trap
  that the desktop's Refresh button doesn't refetch the feed.
- Android's test inventory was three files ago; the Reliability item pointed
  at a heading that no longer exists under that name.
2026-08-26 01:54:49 -07:00
Greg Shuflin 8cdf08d304 docs: retire the change-signals TODO into the ADRs that own it
Build Debug APK / build (push) Successful in 5m34s
The work is done: every screen on every modality follows the store, and the
polls this started as are gone. What was left in TODO.md was either a fact
about the design or a deliberate exception, and both belong where someone
reading the design will meet them rather than in a list of things to do.

ADR 0041 gains "Where this ended up": the in-memory P2P state no store
channel can announce, the players that must never follow one, the record
screen in edit mode, the Sync tab's multi-second walk, and the timers that
were never polls. Its amendment now names SyncStagingStore as the one store
still to be held to the rule.

ADR 0031 gains the design that is actually owed — what a *form* needs that a
single-value guard doesn't cover: a per-field "keep mine" that doesn't revert
four fields nobody disagreed about, and an alert that can say which fields
moved. The two stopgap call sites point there now instead of at TODO.md.
2026-08-26 01:25:40 -07:00
Greg Shuflin 39c6f45b1c humans: the detail screen follows the store, and a local edit wins
Build Debug APK / build (push) Successful in 5m16s
A person can be edited on another node, and an interaction with them written
by anyone else who was there; neither reached an open detail screen on either
modality. The timeline now follows the store whatever the mode — an
interaction is its own document, shared with its attendees, and lives outside
this form — and the profile follows it while it is being read.

In edit mode the arrival is dropped and the staged edit stands. That is the
expedient answer and not the right one: the rule asks for the arrival to be
announced, for each choice's cost to be named, and for the save that would
overwrite the other node's version to wait. Both call sites say so, and TODO
records what the real design has to do — including that a form is not a text
buffer, so "keep mine" cannot mean overwriting four fields the user never
touched.
2026-08-26 01:12:48 -07:00
Greg Shuflin 54f4dbd373 stores: SettingsStore announces, and so should every store
A remote administrator can set this node's sync policy over p2p::node_admin,
and the tabs showing that policy had no way to hear it — not on a change, and
on the desktop not even on a tab switch, since the policies were read once
when the screen was built.

SettingsStore now carries a ChangeSignal on a new ChangeChannel::Settings,
marked from every write path rather than the ones judged interesting: what a
screen shows is not a store's business to predict, and predicting it wrong is
what this bug was. The desktop Settings screen and Android's Sync settings
follow it for their switches and menus. The desktop's text fields are left
alone on purpose — they hold what the user has typed and not saved.

ADR 0041 said to add a channel only when a screen asks for one. That rule is
amended there: announcing into an empty room costs a counter nobody reads,
while not announcing costs a screen quietly showing something that has stopped
being true.
2026-08-26 01:09:06 -07:00
Greg Shuflin 2a3930f10c docs: live player state is local to the node playing it
The progress artifact is what crosses nodes; playing/paused, the current
second, and the volume do not. Worth stating outright because the feature is
described as "pause on the phone, resume on the desktop", which is one letter
away from a phone that starts the desktop playing — and because a screen that
follows the store is a short step from a screen that seeks under whoever is
listening.

Written where the players are designed rather than in an ADR: it is a
standing rule about what these widgets may do, not a decision being taken
once.
2026-08-26 00:57:39 -07:00
Greg Shuflin 35a3d7872a TODO: the podcast detail screens are done on both modalities 2026-08-26 00:45:50 -07:00
Greg Shuflin a064c3fac6 gui: the podcast detail screen follows the store
The desktop mirror of the Android change: episodes persisted by another node
sync here as documents, and this screen showed whatever it had read when it
was opened. It now re-reads on the Documents channel — the episode list, the
listen positions and queue membership attached to it (a position from the
phone is the everyday case), and whether the feed is subscribed, which is what
makes its episodes persist at all.

Only what is persisted: load_episodes falls back to the Podcast Index API when
the store has nothing, and that is a thing to do when the user asks for a
list, not on every document a sync commits. Nothing stored is no news rather
than an empty list to apply, since that is what an unsubscribed feed browsed
from search looks like.

Android could apply most arrivals outright because its list is keyed by
episode and Compose re-finds the row under the user's finger. gpui draws this
one by index, so it takes the answer agents::snippets gives for the same
newest-first shape: SyncGuarded holds the re-read, the body's scroll offset
says whether the user is at the top with nothing over it, and otherwise a
"2 new episodes — Show" line at the head of the list waits for them.
2026-08-26 00:44:16 -07:00
Greg Shuflin 0266ac4c68 docs: record what the Jobs screen and popped-out windows now do
ADR 0041's Android paragraph named JobsView as the ungated exception; it is
still the exception, but for a number rather than a full reload, and "on
display" now includes a window of its own. Retires the TODO item, and replaces
it with the Settings screen — the last desktop screen reading only when shown,
and the one whose reason is a missing announcement rather than a costly read:
nothing bumps a channel when a settings row is written.
2026-08-26 00:38:56 -07:00
Greg Shuflin 6f983c195a gui: the Jobs screen pays a COUNT off screen, not a full reload
It publishes the rail's "N running", so it is the one screen that can't stop
when it goes off display — and it took that as licence to do everything on
every job event. A large import reports progress every few megabytes, and each
report cost both tabs, a peer-name lookup, a get_title per referenced
document, and a settings read, all to produce a number.

Off screen it now costs one COUNT(*) (JobStore::count_active, from the store
rather than the runner's in-memory map, since another process sharing the
store can move it). The full reload happens while the screen is in front of
the user — which now includes a window of its own — and on arrival, the way
the Documents screen already reloads on navigation. One `running` field
carries the number either way, so the badge and the Active tab cannot disagree
once the screen is up.
2026-08-26 00:38:24 -07:00
Greg Shuflin d7269d950b gui: a popped-out screen is on display, and follows the store
watch_on_screen asked the sidebar for its current view, which is the main
window's — so a screen the user had deliberately put in a window of its own
stopped re-reading the moment they navigated the window behind it. The screen
most likely to be watched while work happens elsewhere was the one that went
stale, and nothing reloaded it on the way back, because there is no way back
to a window that never left.

The sidebar already mirrors the popped-out set for the rail's own marks, so
is_on_display answers both halves in one place and the accessor that only
answered one is gone.
2026-08-26 00:38:17 -07:00
Greg Shuflin 7e9ee00527 android: the podcast detail screen follows the store
Episodes arriving from another node are the ordinary case for this screen —
a second device fetched the feed, and the child documents it persisted synced
here — and until now it showed whatever the API answered when it was opened.

It watches the Documents channel and re-reads three things: the feed record
behind the header, whether the feed is subscribed (which is what turns
episode persistence on, and can happen on another node), and the persisted
episodes themselves.

An episode list is the newest-first shape CLAUDE.md's rule is most pointed
about: an arrival belongs at the top, which is where it pushes what the user
is reading down. What absorbs most of that is DocumentList's keyed items — a
LazyColumn re-finds the row that was under their finger and holds it still
while the new ones land above it — so the settled-or-hold question narrows to
the rows themselves, and IncomingEpisodes.arrivalOf is that rule: an arrival
keeping every episode on screen in the order it has them goes on outright;
one that drops or reorders one is held behind ChangedElsewhereStrip. Nothing
persisted is no news at all, since that is what an unsubscribed feed browsed
from search looks like.

The detail and info routes now read their podcast out of the repository's
collected flow rather than a one-shot getPodcast(), so a title or cover art
arriving reaches the header too.
2026-08-26 00:17:16 -07:00
Greg Shuflin 07fe09670f just: a recipe for the Kotlin unit tests, which can take a filter
There was none — Kotlin tests were run as `just gradlew test`, the raw
incantation the justfile exists to codify, and CLAUDE.md documented
`--tests` against it. Under AGP 9 that combination cannot work: `test` is a
lifecycle task owning no test executor, so it rejects the option and leaves
no way to run a single test; it also runs both variants' suites, which is the
same tests twice. `unit-tests-kotlin` runs testDebugUnitTest and forwards
args, matching unit-tests-rust/-gui.
2026-08-26 00:11:45 -07:00
Greg Shuflin dd75cc8e0c android: the podcast library follows the store
Its subscriptions were the one Android list still waiting to be navigated
back to. The screen now takes a nativeLib and hands it OnStoreChange on the
Documents channel, and PodcastRepository grows reloadPodcasts() — the seam
every other screen already had as a reload counter.

A reload here rebuilds the whole subscription map, and the Documents channel
is coarse, so it runs on any commit a sync makes. Two things keep that cheap:
Podcast now compares by what it draws rather than by id alone, so a rebuild
that changed nothing publishes nothing through the StateFlow and recomposes
nothing; and a re-read carries the cover art bytes it already holds for a feed
whose art URL hasn't moved, rather than reading the blob again per row and
making every row decode its bitmap afresh. Art absent now is still asked for,
since it may arrive with a later sync.
2026-08-25 23:40:26 -07:00
Greg Shuflin 86c0601e25 cli: this node is not its own audience
Build Debug APK / build (push) Successful in 5m19s
peer_nodes records this node like any other announcement, so the roster the
retirement confirmation counts includes it. "Wait for one of its 1 known
peer(s)" on a one-node ensemble is false, and the wait it describes never
happens — the daemon's own audience() filters correctly and answers Alone. Only
the sentence was wrong; now it is not.
2026-08-25 23:31:59 -07:00
Greg Shuflin 1f2f6e0a1b docs: phase 2 is built, and three things the implementation settled
NODE_REVOCATION.md moves phase 2 to implemented and closes three open
questions with what was actually decided rather than what was proposed:

- Where the acknowledgement protocol lives: its own ALPN, with the deny-list
  exemption expressed as an associated const that defaults to Refuse — so a
  protocol added later is gated without its author knowing the exemption
  exists.
- A retirement screen on a headless node: the daemon delivers and the CLI
  wipes, because delivery needs the daemon's live endpoint and the wipe cannot
  run while the daemon holds the store open.
- Clock skew on revoked_at_secs: this is where revocations part company with
  tombstones. A tombstone's stamp decides whether it wins a merge, so an
  unbelievable one is refused; a revocation's decides nothing, so it costs the
  record its date and not its effect. Refusing it would let a peer with a
  broken clock keep a revoked node admitted.

The retirement section is rewritten where the design reached for the opposite
of what got built. It had a retirement apply its own record locally at signing
time, and be abandonable until the first acknowledgement. Both were wrong: the
store that would hold the row is the one the wipe destroys, and a row left
behind by a retirement that never reached a peer leaves a node refusing every
connection with no way back. So it writes nothing, and once confirmed it cannot
be abandoned.

TODO.md loses what is now done. 'Revoke a node from an ensemble' becomes phase
3 — the lost-or-stolen case — and the reset entry becomes what is actually left
about it: reset still tells nobody, and keeping two controls is a decision
worth revisiting.
2026-08-25 23:31:59 -07:00
Greg Shuflin 8d92c4b8f1 android: revoked nodes on the roster, the keyphrase dialog, and a retirement screen
The FFI grows four calls: revokePeer, importRevocation, beginRetirement, and
pushRetirementRound. The first two mint or accept a record and gossip it
best-effort; the last two are the retirement split into a start and one round
of delivery per call, so a screen can stay in front of the user and say what it
is trying rather than blocking inside a wait it cannot interrupt.

On the roster: a revoked member keeps its row and is marked, and its Ping and
Sync controls are replaced by the date — both would be refused at admission
anyway. A node that finds its own credential revoked says so above its own
identity. Under the roster is the paste target for a record carried here by
hand.

'Revoke this node…' is on the node screen rather than a roster row: the row
already carries a name, an id, a coverage meter and two controls, and this is
not something to put a thumb's width from Sync. The keyphrase is its
confirmation.

Retirement is a top-level route reached by clearing the back stack, and it
swallows the system back button. That is what 'cannot be abandoned' looks like
in navigation. It signs, gossips, pushes round after round, and ends at
NodeReset.perform — the wipe half was already written there. The record is on
screen from the moment it is signed, and 'Wipe now' is always offered with what
it costs beside it.

Settings gains it above Reset, with copy that finally names the difference:
reset deletes the same data but tells nobody, so the other nodes go on
admitting a credential that never expires.
2026-08-25 23:31:59 -07:00
Greg Shuflin d016ec0ffa cli: --now does not ask a second time
The first confirmation already said this would sign, shout it over gossip
without waiting, and delete. Asking "wipe anyway?" after that re-litigates a
decision the user has made, which is how a second prompt trains people to hit
y. The question is only worth asking when the user *did* wait and the wait ran
out.
2026-08-25 23:31:59 -07:00
Greg Shuflin ef8ab981ec sync: the peer walk skips a revoked credential
ensemble_peers_freshest_first is deliberately an ordering and not a filter — a
node that has been off for a week is still a member, and silently skipping it
turns "your laptop was asleep" into "your laptop no longer syncs".

A revoked credential is the one case where the guess is not a guess. The user
said that node is no longer a member, admission refuses it in both directions,
and dialling it every pass can only end in a refusal. The filter is by cert
fingerprint, so a node that registers again — which mints it a fresh cert — is
back in the walk with nothing to un-do.
2026-08-25 23:31:59 -07:00
Greg Shuflin 06340a30af desktop: a paste target under the roster for a revocation carried here by hand
The repair path for a node that was retired with nobody listening. A record is
~140 self-authenticating bytes, so any path is a delivery path — it does not
have to be the network and it does not have to be prompt. Verified exactly as
one off the wire is; nothing is trusted for having been typed.

Under the roster rather than behind a menu: a user arriving with a record off a
wiped phone is looking at the list of nodes it is about to name. Says when a
record was not news, which is the normal outcome of importing one gossip
already delivered.
2026-08-25 23:31:59 -07:00
Greg Shuflin 6db6d463f7 desktop: the retirement screen, and the danger-zone control that leads to it
Settings → System → Danger Zone gains 'Retire this node…'. It asks once —
nothing else supplies a confirmation here, unlike revoking a peer, where the
keyphrase is the confirmation — and then hands the request up to
SynchronicityView, which replaces the entire window with the retirement
screen. No rail, no content pane, no palette: the mode is the whole screen,
and this node is on its way out.

The screen signs, gossips, and then offers the record to each peer in turn,
round after round, saying which it tried and what each said. One peer
committing it is enough. It cannot be cancelled — by the time it is up the
user has confirmed and p2p::admission::Retiring is one-way — but 'Wipe now' is
always there, with what it costs stated next to it rather than in a footnote.

The record is on screen from the moment it is signed, not only on the
emergency path: after the wipe there is no getting it back, and any path is a
delivery path for 140 self-authenticating bytes.

It ends by quitting rather than returning anywhere. There is no screen worth
returning to, and the next launch finds an empty store directory and offers
onboarding, which is the truth. That also sidesteps having to swap a live
Arc<Store> out from under every open view and the embedded daemon socket.

Deliberately not a Job, and a deliberate exception to the instant-feedback
invariant: jobs persist into the store the wipe deletes, so a retirement Job
would record its terminal state in a database its own success destroys.

ensemble::retirement splits into begin() and push_round() so a surface that
stays in front of the user can drive the wait itself. retire_node() is now
those two in a loop, and remains what the daemon calls.
2026-08-25 23:31:59 -07:00
Greg Shuflin b1ab99cca2 desktop: revoked nodes on the roster, and the keyphrase dialog that puts them there
A revoked member keeps its row and is marked, rather than disappearing: a node
that vanishes from a list is indistinguishable from one that is merely
offline, and those two want opposite reactions. Its name dims, it carries an
explicit 'revoked', and its action block says when instead of offering Ping and
Sync — both of which this node's own admission check would refuse anyway.

'Revoke…' opens a dialog that asks for the ensemble keyphrase. The keyphrase is
the confirmation, which is why there is no second 'are you sure' in front of
it. Minting runs on the background executor and the gossip broadcast on the
tokio runtime; a broadcast that fails is logged and not surfaced, because the
record is already on this node's deny-list and doc-sync carries it.

A node that finds its own credential revoked now says so at the top of the
screen, above its own identity. Without that the only symptoms are a gossip
count stuck at zero and every action failing.

The roster comes out from under CONTENT_MAX_WIDTH while I am here. Its fixed
columns already summed past 1040 and painted over the edge; it is a table
whose columns are the information, which is the case CLAUDE.md exempts from
the reading-column cap. Membership, which is a label/value list, stays capped.
The action block widens to fit four buttons and its status slot.
2026-08-25 23:31:59 -07:00
Greg Shuflin a3e5c43bc5 cli: revoke, import-revocation, and a retirement that stops the daemon before it wipes
Three subcommands and the daemon commands under them.

  syn ensemble revoke <NODE_ID>   prompts for the keyphrase; store-only, so it
                                  works with or without a daemon
  syn ensemble import-revocation  the repair path, verified not trusted
  syn ensemble retire             the whole flow

Retirement is split across two processes because it has to be. Delivery needs
the daemon's live endpoint; the wipe cannot run while the daemon holds the
store open. So the daemon signs, gossips, and pushes until a peer commits —
and this process stops it, confirms the socket is gone, and deletes. Which
also puts the destructive half in front of the person who typed the command.

The record is printed before anything else and whatever the outcome: after the
wipe there is no getting it back, and it is what repairs a retirement nobody
heard. --now skips the wait, --timeout bounds it, and a wait that runs out
asks whether to wipe anyway rather than deciding.

Declining that leaves the node serving nothing but revocation delivery until
the daemon restarts, which abandons the retirement — the retiring state is in
memory and nothing was written down. The command says so.

Also: syn ensemble members marks revoked nodes rather than dropping them (a
node that vanishes is indistinguishable from one that is merely offline), and
says loudly when this node's own credential is the revoked one.

Retire and revoke are refused over the loopback listener, same rule as
pairing: a bearer token granted to read documents must not destroy the store
it reads from. The keyphrase crosses the socket in a newtype whose Debug
redacts, because the daemon logs every command it receives.
2026-08-25 23:31:59 -07:00
Greg Shuflin d455843aa6 retirement: a state held in memory, written down nowhere
A retirement signs a revocation for this node's own cert and hands it to a
peer. It no longer puts one on this node's own deny-list, which was what
'stop syncing' used to be made of.

There is nothing to gain from writing it: the store that would hold the row
is the one the wipe is about to destroy. And there is something to lose — a
retirement that never reached a peer would leave the row behind, and the node
would come back refusing every connection with no way back short of
re-registering.

So p2p::admission::Retiring replaces it: an in-memory flag, threaded to both
halves of the handshake, set once by P2PNode::begin_retirement and never
cleared. While it is set the node serves and dials nothing but revocation
delivery, which is the one thing it still has to do. It dies with the process,
so a killed retirement leaves a node that simply did not retire.

It is deliberately one-way. Once the user has confirmed, a retirement waiting
for an acknowledgement cannot be abandoned; the ways out are the wipe and
killing the process.

ensemble::retirement::retire_node is the run all four modalities will share:
begin, sign, gossip, push until a peer commits, report. It stops short of the
wipe, which differs per host and belongs to the caller.
2026-08-25 23:31:59 -07:00
Greg Shuflin e206fff9a9 revocation: put it on the roster every modality already renders
EnsembleMemberInfo gains is_revoked and a pre-formatted revoked_at_display, so
the desktop, Android, the daemon's JSON protocol, and through it the CLI and
TUI all show the same thing without any of them computing it. A revoked member
stays on the list rather than vanishing from it: a node that disappears is
indistinguishable from one that is merely offline, and 'this node was retired'
is the more useful of the two things a blank row could mean.

this_node_is_revoked is its own field on EnsembleStatus rather than something a
frontend digs out of members, because it is not a detail of a row -- it is the
state of the whole screen, and every modality has to say it plainly instead of
leaving the user to read an endless string of connection failures.

Keyed by node, not by cert, because that is the question a roster row asks; a
node revoked, re-registered and revoked again takes the newest. A failure to
read the deny-list degrades to 'nothing revoked' rather than failing the whole
status, the same trade document coverage beside it already makes.
2026-08-25 23:31:59 -07:00
Greg Shuflin 7b15ed1c3d revocation: the delivery protocol, and the three ways one is minted
/syn/revocation/1 exists because gossip's broadcast returns when iroh-gossip
takes the payload, not when anyone applied it -- so there is nothing there for
a retiring node to wait on. It commits before it replies: the other order lets
a node wipe itself on an acknowledgement for a record the peer then loses,
which is the failure the wait exists to prevent, while this order fails
harmlessly as a retry.

It is the one protocol whose REVOKED_PEERS is Admit, and it has to be. A peer
refuses the retiring node from the instant it applies the record, so a gated
delivery would make a lost acknowledgement unrecoverable. Admitting a revoked
caller is safe because a record is verified on its own signature and not on the
caller's standing -- what is relaxed is who may speak, not what is believed.

Minting, in ensemble::retire: retire_this_node signs for this node's own cert
with no keyphrase; revoke_peer signs for another's with the ensemble key, and
refuses a keyphrase that is not this ensemble's; import_revocation accepts a
record carried here by hand and verifies it exactly as one off the wire.

peer_nodes grows a cert_fingerprint, filled from each verified announcement,
because a revocation names a cert and the roster only knew the node. A peer
seen only in the pkarr registry has no cert to name, and says so.
2026-08-25 23:31:59 -07:00
Greg Shuflin 946902d395 revocation: two channels, gossip for now and doc-sync for durably
A GossipMessage::Revocation carries no delegation cert beside it, unlike its
neighbours there: a record verifies entirely from its own contents against the
ensemble key the receiver already holds, so a cert would add nothing and a
record has to stay relayable by nodes that were not party to it.

A RevocationBatch rides between SyncHeader and DocumentTombstoneBatch, and is
the channel that carries the guarantee. Gossip reaches whoever is listening
now; a node offline when a sibling retired learns here, from whichever peer it
next syncs with -- which need never have met the node that minted the record.
Unpaginated and unconditional: 170 bytes per device the user has ever retired,
and filtering by the request's cursor would be meaningless for a set that has
no relationship to one.

Revocations part company with tombstones on a bad clock. A tombstone with an
unbelievable stamp is refused outright, because the stamp is what decides
whether it wins. A revocation's is not -- the deny-list is keyed by cert
fingerprint -- so an unbelievable stamp costs the record its date and not its
effect. Refusing it would let a peer with a broken clock keep a revoked node
admitted, which is the one direction that must not fail.

Sync protocol version 17: the two builds disagree about what message follows
the header.
2026-08-25 23:31:59 -07:00
Greg Shuflin 954800600f admission: refuse a revoked cert, in both directions
The deny-list check, beside the three cryptographic ones, read from the store
per connection like the membership next to it -- so a revocation arriving over
gossip takes effect on the next connection rather than the next restart.

The handshake becomes mutual to make the client half possible at all. A
deny-list is keyed by cert fingerprint, and nothing on the wire named the
server's, so a client could only ever be refused, never refuse; checking by
node key instead would make revocation permanent for a key and destroy the
re-admission path this design deliberately keeps cheap. The server now returns
its own delegation cert with its verdict and the client runs the same four
checks against it. Every ALPN bumps for the wire change.

A node whose own cert is revoked stops taking part rather than discovering per
connection that everyone refuses it: checked before the dial, and before the
admission stream is accepted.

EnsembleProtocol::REVOKED_PEERS carries the one exemption -- revocation
delivery, which has to reach a revoked node in both directions or a lost
acknowledgement is unrecoverable. It defaults to Refuse, so a protocol added
later is gated without its author knowing the constant exists.

DelegationCert::create_at is crate-internal and exists for the tests: a second
distinct cert for one node cannot be made by editing created_at_secs, which is
inside the signature.
2026-08-25 23:31:59 -07:00
Greg Shuflin 4f85d2db68 revocation: the record, and the deny-list it feeds
The signed statement that a delegation cert is dead, in the two authorities
docs/NODE_REVOCATION.md 2 specifies. A self-signed record is signed by the
revoked node's own key and verifies under the node it names, which is what
confines it to its own signer -- a member cannot produce one about a sibling,
because there is no key it could sign it with. An ensemble-signed record
verifies under the ensemble key and may name anybody's cert. The authority tag
is inside the signed payload, so neither can be relabelled as the other, and
the ensemble pubkey is too, so a record cannot be replayed into another
ensemble the same node key belongs to.

What it names is a cert fingerprint -- blake3 over the bytes the cert is signed
across -- not a node key forever. Admission checks a cert, so that is what a
deny-list can enforce; and re-admission becomes a plain register, which mints a
fresh cert no standing record names.

The store keeps the signer's exact bytes rather than a verdict, because every
node relays revocations it did not mint and the next receiver verifies the same
signature this one did. Append-only: a record that can be dropped is one an
attacker can wait out.

to_blob/from_blob are the same encoding in base64, for carrying a revocation
off a device by hand. Decoding is structural; verify is the only gate.
2026-08-25 23:31:59 -07:00
Greg Shuflin 46d0d41c18 docs: retirement is a screen, not a job, and a one-node ensemble skips it
Backgrounding a retirement gets you the failure the flow exists to prevent: a
device handed over un-wiped by a user who believes otherwise. The invariant it
sets aside exists so a user can go do something else, and here there is nothing
else -- the operation's purpose is to make this node cease to exist. The
machinery would fight it besides: JobStore persists into the same store
wipe_contents deletes, so a retirement job would record its terminal state in a
database its own success destroys.

So the retirement screen is the mechanism. It signs, pushes, shows what it is
waiting for, runs the wipe, and carries the emergency wipe-now beside the wait.

Adds the state machine that follows from that. The first acknowledgement is the
point of no return: before it, leaving abandons the retirement and discards the
record, since signing is cheap and repeatable; after it, the ensemble knows and
the only coherent thing is to finish.

A one-node ensemble has no audience, so it does not open a wait that cannot
resolve, does not push, and does not sign a record nobody will ever apply --
retire and reset are the same act there. The roster is the signal.
2026-08-25 23:31:59 -07:00
Greg Shuflin cce4debd68 docs: retirement waits for delivery, or the user says not to
Whether a node's wipe blocks on a peer acknowledging its self-revocation is
the user's call: on a bad link, or a device being handed over in ten minutes,
wiping without delivery and repairing the ensemble's record later is the right
trade. The choice sits on the reset confirmation rather than in Settings,
because what decides it -- a reachable peer right now -- is known then and not
weeks earlier.

Waiting is a tracked Job per the instant-feedback invariant, abandonable into
the immediate path, and one acknowledging peer is the bar: the record is
self-authenticating and rides doc-sync transitively, so one honest holder
reaches everyone.

Two protocol constraints fall out. Gossip cannot be what the wipe waits on --
broadcast returns when iroh-gossip takes the payload, not when anyone applied
it -- so delivery needs a request/response that replies after committing.
And that path must not be gated by the deny-list, or it eats itself: the peer
refuses the retiring node from the instant it applies the record, so a lost
acknowledgement would be unrecoverable. Serving it to a revoked caller is safe,
since the record is verified on its own signature and the most such a caller
can do is prove itself revoked again.

Repair path for the no-wait case: the record is ~140 bytes and
self-authenticating, so it is shown before the wipe and can be imported into
any surviving node later, without the keyphrase and without the device.
2026-08-25 23:31:59 -07:00
Greg Shuflin 77a6e24bc4 docs: revocation is ensemble state, not a DHT record
Rewrites NODE_REVOCATION.md phase 2 around two findings.

pkarr cannot carry a revocation record. Writing the registry needs the
ensemble secret, which nothing persists, so a self-revocation cannot be
published there at all; and a revoked node can roll the registry back
without holding any key, because mainline rejects a stale sequence number
only when the receiving DHT node still holds a previous item, those items
live in a 1000-entry LRU on volunteers, and nothing here republishes. The
byte budget was the least of it.

Revocation records travel over gossip and doc-sync instead, the same
division of labour purge intents already use, and are stored locally as
the deny-list admission consults.

Adds the self-signed authority: a retiring node signs its own revocation
with its own key, needing no keyphrase. That is what makes decommissioning
work from the device being decommissioned, and it answers the objection
standing against 'A reset node is never removed from its ensemble' -- such
a record is not forgeable by a sibling, for the same reason NodeAnnouncement
and PurgeIntent carry node-key signatures beside their certs.

Both authorities revoke a cert hash rather than a node key forever, which
makes re-admission a plain re-register and needs no un-revocation record.
2026-08-25 23:31:59 -07:00
Greg Shuflin 873f7ee400 Android: one logcat tag for the Rust side, and say what it is
Build Debug APK / build (push) Successful in 5m1s
Forwarded records were tagged with the Rust module path they came from, so
`adb logcat -s <the app>` returned silence and a raised verbosity looked
broken. The per-module tags that cost us buy nothing back: logcat's filterspec
splits at the first colon, so `iroh_gossip::net:V` parses as tag
`iroh_gossip` with priority `:` and is rejected — a tag containing `::` is
unaddressable.

So: one fixed tag for everything crossing the FFI boundary, with the record's
target moved to the head of the message where grep still reaches it. The
backend is held privately rather than installed via `android_logger::init_once`,
which would take the `log` global and cut our runtime filtering out of the path.

The tag is exported over uniffi and shown under Log Verbosity in Settings —
which tag to filter on is not guessable from outside the process.
2026-08-25 16:26:09 -07:00
Greg Shuflin 9127726ddb SQL: a value goes in a ?, and a lint that says so
Build Debug APK / build (push) Successful in 3m49s
`SyncRequest.since` is an `Option<String>` the *requesting peer* chooses, and
it reached `format!(" AND modified_at >= '{s}'")` verbatim in three sync
queries. rusqlite compiles only the first statement, so this was not
`; DROP TABLE` — but closing the quote and appending `OR '1'='1` defeats the
document-scope filter, and a correlated subquery is a boolean oracle over every
table in store.db, `secrets` included. That is strictly more than syncing
already grants an admitted member.

Two layers. At the boundary, `wire_time::wire_since` parses the value as
RFC3339 and re-renders it, so what travels onward is this node's own string and
never the peer's bytes; a malformed `since` fails the request rather than
quietly widening it to the whole catalogue. In the store, `SyncScope` replaces
the four hand-written `WHERE` tails those queries each built for themselves —
it hands back a predicate and the values to bind together, so there is no way
to use it that puts a caller's string into SQL text. An empty id scope now
means "no documents" instead of `IN ()`, which was a syntax error.

The rest of the tree got the same treatment while it was open: the search
queries' doc-type and provenance filters, and the set-element backfill, all
emit `?`s now. `placeholders(n)` is the one way to build a list of them.

And `just lint-sql-params`, because the bug is invisible at the call site —
whether that `format!` is a security hole depends entirely on where `s` came
from, which the line does not say. It flags an interpolation wrapped in SQL
quotes, or sitting where only a value can go, in any file that mentions
rusqlite; it deliberately does not flag an interpolated identifier or fragment,
which would mean a marker on nearly every query and no one reading any of them.
Three sites are left, all splicing one CASE expression built from closed enums,
each carrying a `// sql-literal-ok:` with its reason.
2026-08-25 03:13:31 -07:00
Greg Shuflin 3b646e4104 Bound the timestamps a peer supplies, at one decode point
Every merge rule here is last-write-wins over a stamp the *sender* wrote, so a
value far enough in the future wins every subsequent comparison for that
property on every node it reaches, and no later honest edit can displace it.
One transient bad write became permanent corruption. Tombstones were worse:
only the strictly newer of two is kept, so a far-future one could never be
superseded at all, and a far-future document tombstone additionally blocked
its id from ever being recreated and cascaded to the document's children.

Incoming stamps now decode through one function, `p2p::wire_time::
wire_timestamp`, which refuses anything more than 24 hours ahead of this
node's clock. Whatever field carried it is dropped and the rest of the record
still lands — a peer with a wrong clock should cost its own edits, not the
ability of a document to sync at all. The exception is a record's own
`modified_at`, which is its sync cursor: there is nothing sane to apply the
rest under, so the record is skipped whole. A far-future set-element *removal*
reads as no removal, which is the recoverable direction.

That helper also replaces ten near-identical inline decodes across doc_sync,
artifact_sync and gossip — three of which already called a shared helper and
seven of which had drifted away from it. All ten fell back to `Utc::now()` for
a value `timestamp_opt` rejected, which quietly promoted a malformed stamp to
the newest write in the store; that is now a rejection too.

Rejections are counted and reported once per batch, naming the peer and the
furthest-ahead stamp. A node whose clock is a year out sends a bad stamp on
every property of every document, and a line per field would bury the single
fact worth knowing.

24 hours is deliberately wide. Real skew across a phone, a laptop and a VPS is
seconds; a day covers a flat battery or a whole-day timezone error while
staying far short of what a bug or a hostile peer produces. The two errors are
not symmetric — rejecting an honest write throws away data.
2026-08-25 03:13:31 -07:00
Greg Shuflin 9768b6c014 gui: a row's presence is its subtree's, not its own
Build Debug APK / build (push) Successful in 4m51s
A Collection has no blob-backed artifact of its own — a podcast feed's content
is entirely in its episodes, a comic's in its pages. rows_present_locally asked
only about the row, found no refs, and answered 'here', so every collection in
the library read as fully present whether or not a single child had downloaded.
TODO.md carried this as 'aggregate sync rollup on a Collection card'; it is the
same complaint as the one that started this redesign, one level up.

content_ledger::subtree_content rolls each listed row up over its own subtree.
One recursive CTE collects every subtree at once (DocumentStore::descendants_of,
the descendant counterpart of ancestors_of) rather than walking per row — a page
holding both a comic and its series would otherwise walk three hundred pages
twice — and the cost stays bounded by what is on screen rather than by the
library.

The boolean becomes four states. Partly-here is the one it could never express,
and it is where collections normally live; such a row says '3 of 10' rather
than a word, since the numbers are the whole content of 'partly here'. A row
with no content at all renders nothing: a notebook is not 'Not here', it simply
has nothing this column is about, and a word there would be noise on every note.

Also corrected on the way through: the old check counted Thumbnail refs, so a
document whose cover art had not arrived read as missing its content. The
rollup is content-plane only. availability.rs keeps counting thumbnails, and
should — it answers 'can this be opened at all', where a missing cover is a
missing artifact even though policy never governs it.
2026-08-25 03:03:25 -07:00
Greg Shuflin 0e83ac8336 copy: the user-facing word is artifact
Every rendered string in the content-placement work said file(s). An artifact
is not a file — it is versioned, content-addressed, attached to a document,
lives in the ensemble rather than on a machine, may be held by several nodes or
none, and merges rather than clobbers. Borrowing the file mental model imports
exactly the assumptions that break here, the file model being the one where you
resolve a conflict by picking a copy. Field names stay files_*; no user reads
those.

Two findings beyond the rename.

SyncPolicy's own descriptions said document. Mirror read 'every document of
this type is kept on this node' — describing something unconditionally true
already, and not the thing being chosen. That is the origin of 'it's unclear
whether this applies to documents or artifacts', the complaint that started
this redesign, sitting in the copy under the picker the whole time.

The eviction dialogs' three sentences existed in three copies — the desktop's
delete dialog, its reclaim dialog, and Android's — which had drifted. Rendered
once in copy::eviction and carried on EvictionPlanItem, so a screen reads a
field rather than retyping a sentence about destroying data.

Also: PeerSyncCopy now has two artifact counts, separated by verb rather than
by noun — content-plane artifacts are 'fetched' (bytes arrived), catalogue-plane
ones are 'synced' (a value reconciled). The test asserts both precisely, since
if the two lines were only distinguishable by careful reading that would be a
fact about the copy rather than about the test.
2026-08-25 03:03:25 -07:00
Greg Shuflin 4f92afcb2e Android: a node reset that leaves nothing running, and nothing plaintext
Build Debug APK / build (push) Successful in 5m24s
The native wipe is only half of a reset on Android. Left behind were the
foreground P2P service (START_STICKY, with a retry loop ready to bring a node
back up), the scheduler's WorkManager tick — which the platform persists
across process death, so it went on waking the app to sync a node that no
longer existed — playback running in its own MediaSessionService out of a
decrypted file, that file and every other decrypted PDF and audio temp in the
app cache, and process-wide UI state describing documents that were gone.

`NodeReset` is now the one place that does all of it, in an order that
matters: playback and the scheduler stop before the wipe so nothing is reading
a cache file or starting a sync mid-delete; the wipe runs next and is
authoritative; stopping the P2P service comes after, where its own
`stopP2PNode` finds nothing to do rather than blocking the main thread on a
network shutdown. It runs off the click handler's thread, which it never did
before, and under NonCancellable, because a reset that stops halfway is the
bug this is fixing.

Two supporting fixes. `start_p2p_node` re-reads the store's keypair before
publishing a node, so a service retry that read the identity just before a
reset cannot put it back on the network seconds after the wipe. And Kotlin's
`ChangeCursor.moved` compares for difference rather than greater-than, as ADR
0041 says it must and as the Rust side already did — a counter only ever falls
because the store was replaced, and under the old rule every open screen would
have waited deaf, still showing the destroyed node.

The confirmation dialog now says what is actually destroyed, and says that the
other nodes are not told.
2026-08-25 02:25:51 -07:00
Greg Shuflin 6cee174144 reset_node: stop the node, then wipe everything the store directory holds
`reset_node` wiped the blob store and deleted `store.db`, and left the rest
of a node behind: the P2P node ran on, announcing the identity the user had
just asked to destroy and answering every ALPN against an unlinked database;
`stream-cache/` kept its plaintext audio, being a sibling of the blob store
rather than inside it; `store.db-wal` kept whatever had not been checkpointed,
which SQLite will happily recover into a freshly created file of the same
name; and the JobRunner's dedup map carried `(kind, subject)` entries for
documents that no longer existed into the new store.

Reset now stops the network first, cancels the in-flight work second, and only
then deletes — and it deletes by enumerating the store directory rather than
naming the pieces it knows about, since a wipe with a list to keep up to date
is a wipe that misses whatever was added since. The advisory lock file is the
one deliberate exception.

Leaving the ensemble is still not part of this: the other nodes go on listing
this one. That is node revocation, and stays future work.
2026-08-25 02:25:51 -07:00
Greg Shuflin 2f76e588db docs: settle the per-node policy default and the sleeping-node directive
Build Debug APK / build (push) Successful in 5m9s
Two of the redesign's open decisions, closed.

Defaults: KeepOnOpen on desktop, Stream on mobile. A desktop that holds nothing
until told is exactly the configuration that produces 'syncing doesn't work';
a phone that quietly accumulates every PDF it opens is the one that produces a
full device. Needs a seam that does not exist — SyncPolicy::default() is one
value for every platform, and the default belongs to the node, decided once at
initialization from what kind of node it is.

Sleeping nodes: a decision to mirror must not be lost. trigger_sync is a live
round trip, so a peer asleep at that moment never hears it and converges on its
own clock instead — and a phone asleep when you press the button is the common
case. Queue the directive. What the right behaviour actually is against a real
sleeping phone (how long a directive stays valid, whether a later local policy
change supersedes it, whether a pending queue should be visible) is a question
for experiment, and the queue is what makes those experiments possible.

TODO.md carries both as work, with the questions the queue exists to answer
written down rather than left to be rediscovered.
2026-08-25 02:12:39 -07:00
Greg Shuflin 5d6d5936d4 gui: desktop widgets reflect their job, not the click that started it
TODO.md's "done on Android, and the desktop is now the one behind". A
per-widget AsyncActionState records *this screen's call*, so a content fetch
begun by the background scheduler, by another screen, or by a peer's
TriggerSync left the button idle and cheerfully offering to start a second
copy — and forgot on navigation, because the state lived in the view rather
than in the job store.

job_binding is the desktop counterpart of Android's jobs/JobBinding.kt: a
widget names its own (kind, subject) and gets back the live row, whoever
started it. Per-view rather than the process-wide singleton Android needs — a
gpui view already owns state and a subscription, and the JobRunner underneath
is shared, so two views holding one agree by construction.

The Placement table's buttons and the Ensemble screen's Sync are on it. The
two differ in one way worth keeping straight: the Placement actions start
their job synchronously, so they refresh the index and the row is real
immediately; sync_with_peer starts its job inside the spawned task, so that
row has a genuine gap and keeps a "starting" flag to cover it. A flag that
says "trust me" is the fallback, not the mechanism.

What a screen still owns is the *result* — "Pushed 3 document(s)", "Sync
failed: …". A job carries a state and a progress message, not the sentence a
particular screen wants afterwards. The activity line beside a busy control is
the job's own words via copy::job_activity, shared with Android so a widget and
the Jobs screen never give two accounts of one transfer.
2026-08-25 02:11:54 -07:00
Greg Shuflin 4243db67ea docs: the user-facing word is artifact, and why that is the interesting claim
An earlier draft of the redesign argued for 'files' in the policy surfaces,
since artifact is the codebase's word rather than a user's. Overruled, and the
reasoning is worth recording.

An artifact is not a file in the sense a computer user already has. A file is a
path on a disk one machine owns; you move it, you copy it, you lose track of
which copy is current. An artifact is versioned, content-addressed, attached to
a document, 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 elsewhere. Borrowing the file model is wrong in each
of those respects, and wrong in the direction that produces the bugs this
system exists to avoid — the file model is the one where you resolve a conflict
by picking a copy.

Teaching an unfamiliar word costs once. Teaching a familiar word that quietly
means something else costs forever, in misunderstandings that present as the
software being broken.

Step 7 carries the rename; steps 1-6's copy says file(s) and is wrong pending
it.
2026-08-25 02:00:40 -07:00
Greg Shuflin 53239c6259 gui+android: one Placement table, and the FFI that feeds it
Android's document detail screen had the same split the desktop just lost: a
'Sync to this node' card with its own 'Keep here:' picker, sitting above a
'Sync to other node' list whose every row had another one. Now one table with
this node as row 0, matching the desktop.

The rows come from a single new FFI call rather than being assembled in Kotlin
from ensemble members, this node's override, and per-node document status.
Those three were being composed into one table anyway, and composing them
per-modality is how the two drift — which the stored/reclaimable lines had
already done once. The content and summary strings come from copy:: for the
same reason, and the desktop moves onto them here too.

The button says Download or Push now, never one word for both: they move bytes
in opposite directions, and 'Sync' there would be the ambiguity this table
exists to remove. Each is bound to the job for what it starts — ContentFetch
for this node, Push for a peer — so work begun by the scheduler or a remote
TriggerSync reads as what it is rather than as an idle button.

Kotlin verified: compileDebugKotlin and detektDebug with type resolution. Not
run on a device.
2026-08-25 01:50:16 -07:00
Greg Shuflin 406d4240cd gui: one Placement table on the document detail screen
The Sync tab asked the same question twice, in two controls that looked
unrelated: a 'Keep here:' picker floating above a 'Sync to other node' table
whose every row had its own 'Keep here:' picker. Which node a given control
configured was the screen's hardest question, and it did not need to be a
question at all.

Now one table with this node as row 0 — node, id, content held, version,
Pin/Exclude, and one button. The two action handlers collapse the same way:
run_row_action pulls on row 0 and pushes on a peer, set_row_override writes
locally on row 0 and through node_admin on a peer. The row offers exactly one
button and the user reads it as 'make this node's copy match'; which verb that
is follows from which row it is, and never needs stating twice. It is still
labelled Download or Push now rather than one word for both — they move bytes
in opposite directions, and 'Sync' there would be the ambiguity this table
exists to remove.

The Content column is the readout sync-management.md specified and never got.
Three answers, deliberately different sentences because they call for
different actions: a count, 'all N', or '—' for a peer no evidence has ever
been recorded about — which is not the same as holding nothing. Its tooltip
gives the oldest confirmation among the files counted, so it promises a floor
rather than implying the row was checked just now.

The version column reads '—' for this node: it exists to say whether a peer
has the version we have, and here those are the same thing.

reload_placement runs after anything that moves content — a pull, a push, a
local delete — and merges rather than replaces, since a row may have a push in
flight or a confirmed remote override, neither of which is in the store and
both of which the user is still reading.
2026-08-25 01:33:55 -07:00
Greg Shuflin 3e3e460ed0 content_ledger: where one document's content sits, across the ensemble
Build Debug APK / build (push) Successful in 3m52s
The backing computation for the Placement table (redesign step 4), which
merges the document detail screen's 'Keep here' and 'Sync to other node'
sections — the same question asked twice in two widgets — into one table with
this node as row 0.

Scoped to the subtree, because every action on that screen already recurses:
counting only the named document would report 'no files' for a podcast feed or
a comic, whose content lives entirely in children, which are exactly the
documents this screen is most often open on.

The local row and the peer rows are different kinds of claim and the types say
so. This node's is read from its blob store and needs no confirming. A peer's
is evidence from node_content_status, so it carries the *oldest* confirmation
among the files counted — newest would let one file checked a minute ago vouch
for a hundred last seen in June — and a peer with no evidence is absent rather
than zero, since 'never asked' and 'holds nothing' call for different actions.
This node is excluded from the peer rows, which would otherwise list it twice,
the second time as evidence about the one node that needs none.

One bulk possession query rather than one per file, using the holders_of added
earlier: a comic's pages would make the naive version a hundred round trips on
a screen that opens on a click.
2026-08-25 01:25:04 -07:00
Greg Shuflin 4247a57605 Create a new test ensemble key
Build Debug APK / build (push) Successful in 3m57s
2026-08-25 01:23:33 -07:00
Greg Shuflin 0135ebe4d4 log: our own lines survive Android's default verbosity
Build Debug APK / build (push) Successful in 4m0s
LogVerbosity::Normal — the default — maps to Warn, which silences every info!
this codebase writes. That cost a real debugging round: a logcat capture of a
minutes-long sync came back full of SELinux noise and quinn warnings with not
one line from the code under investigation, and no way to tell 'the fix isn't
built' from 'the fix is built and muted'.

Our targets now floor at Info regardless of verbosity; Verbose/Verbose2 still
raise them further. iroh keeps its old level, since iroh is the reason a low
default exists at all — this buys diagnosability without reopening the spam it
guards against, and Normal still admits a handful of lines per sync rather than
a stream.

Also updates the emulator TODO with what that capture did show: interface
enumeration refused by the app sandbox (netlink_route_socket, sysfs net), and
QUIC sends failing EIO to a global IPv6 destination from a deprecated
site-local source. Those fit together — blind to its interfaces, the node picks
an unusable local address — and would explain why Android-initiated syncs drag
while desktop-initiated ones finish in half a second. Worth noting the SELinux
domain is untrusted_app, which is every sideloaded app, not only emulators.
2026-08-25 01:15:36 -07:00
Greg Shuflin f7ebe46487 TODO: reset_node leaves a running node, and plaintext, behind
Reported from Android: after Reset node the app flashes state from the previous
store and the ensemble behaves oddly, enough that wiping the app's storage from
Android's own settings became the reliable way to start clean.

Reading reset_node, three things outlive it. The P2P node is never stopped and
captured its own Arc<Store> at start, so after a reset the process is still
joined to the old ensemble's gossip, still announcing the old node key, and
still answering every ALPN — against a SQLite handle whose file has been
unlinked. The stream cache survives, and it holds plaintext audio: it is a
sibling of the blob store, so wipe_all_blobs never sees it. And in-memory state
on both sides of the FFI survives, which is the likeliest reason the UI flashes
what it does.

Filed under Security rather than Reliability because the first and second are
security properties: an identity the user believes they destroyed is still on
the network, and decrypted content outlives the wipe meant to remove it.

Note only — no fix here.
2026-08-25 00:58:43 -07:00
Greg Shuflin 13af946653 ensemble: one pkarr client for the process, not one per lookup
Every registry lookup built a fresh pkarr::Client. That is not a handle to a
remote service — building one stands up a Mainline DHT node: its own UDP
socket, its own routing table, and a cold bootstrap through the well-known
routers before it can resolve anything. A node's log shows the cost plainly:
three 'Mainline DHT listening address' lines on three ports within six
seconds, each followed about three seconds later by the same two-member
answer. Almost all of that three seconds is bootstrap, not lookup.

It was not only a slow start. The gossip bootstrap retry loop repeats the
lookup for the life of the process, so a new DHT node was churned into the
network on every retry, forever, on every node.

Now one shared client, which is what a DHT wants anyway: a routing table gets
better the longer it lives, and the client's own cache can answer a repeat
lookup without touching the network. Four call sites move onto it — gossip
bootstrap, the bootstrap retry loop, ensemble join's membership publish, and
the CLI's two diagnostics.

A build failure is deliberately not cached: it is usually a socket the OS
would not hand over, which can pass, and caching it would leave discovery off
for the life of the process.

The fetch is now timed, because that is the number that says whether this
holds — a first lookup still pays bootstrap, later ones should not, and a
steady three seconds every time means something is building a client per call
again.
2026-08-25 00:49:51 -07:00
Greg Shuflin 8649c92029 sync: let a phone be told to reconcile at all
'Sync both ways' against an Android node exchanged catalogues and then failed
to make it fetch anything, reporting 'this node hasn't finished starting up yet
— try again shortly'. Nothing was starting up. The node-admin handler holds its
JobRunner in a cell filled after P2PNode::start, and only gui-app's scheduler
driver and the daemon's server ever filled it — Android never did, so every
TriggerSync, ListJobs and CancelJob aimed at a phone was refused, permanently,
with a message promising that waiting would help.

Wired in start_p2p_node, before the P2pRuntime is published, so there is no
window at all. The runner is cloned rather than newly constructed: JobRunner's
dedup map is Arc<Mutex<..>> inside, so a clone is the same runner, while a
fresh one would silently stop deduplicating across this seam.

This is what step 2's directive rested on, so on Android it did not rest on
anything. Caught by the timing instrumentation from the previous commits, in a
GUI-initiated sync that otherwise completed in half a second.

Also documents the failure mode where it can bite again: a modality that
forgets to wire its runner does not fail loudly, it refuses every remote
trigger with a string that reads as transient.
2026-08-25 00:40:48 -07:00
Greg Shuflin f16b0e8ecc sync: report a slow connection at a level a phone can see
The dial/handshake timing added in the previous commit was debug-level, which
on Android means invisible: its verbosity has no debug rung — Normal maps to
Warn, Verbose to Info, Verbose2 to Trace — so reading it would have meant
turning on everything iroh says as well.

Promoted past a one-second threshold instead of raised outright. Self-limiting:
a node mirroring a library opens a connection per document and a line each
would drown the log, but a connection that takes more than a second is no
longer a rounding error against the work it was opened to do, and is worth a
word.
2026-08-24 23:47:15 -07:00
Greg Shuflin cae8576663 sync: say where a pass spent its time
A sync of one podcast and twenty lightweight episode documents between two
nodes — a fresh ensemble, both members live — took minutes, and nothing
recorded is able to say which part. The summary counts documents and files; the
Jobs screen has start and finish times per job but not per phase; and the three
phases fail slowly in unrelated ways, so one elapsed number could not tell them
apart anyway.

sync_with_peer now logs its catalogue exchange, remote trigger, and content
passes separately, run_all_passes logs its three passes, and run_catalogue_pass
logs per peer including the failing case.

EnsembleEndpoint::connect logs dial and handshake apart, at debug, for every
protocol. That is the number I most expect to matter and the one nothing
exposed: this cost is paid per *protocol*, not per byte, and a single 'sync
both ways' opens doc-sync, then node-admin, then artifact-sync, then blob-sync.
Against a directly-reachable peer it is milliseconds; from an emulator behind
two NATs, reachable only by relay, it may be the entire wall clock.

Diagnostic only — no behaviour change.
2026-08-24 23:14:38 -07:00
Greg Shuflin 891c0e0632 p2p: bound every dial, and try the peers gossip heard from most recently first
Reported: subscribing to one podcast on a phone — one feed document, ~20
lightweight episode children, no content — and syncing to the desktop took
many minutes. The data is trivial; the time was going somewhere else.

Two causes, both about the peer walk rather than the transfer.

doc_sync was the only protocol dialling without a timeout. blob_sync bounds a
connect at 15s and node_admin at 10s; doc_sync had nothing, so a catalogue sync
against a peer listed in gossip but no longer answering ran until its caller's
budget expired — three minutes, per peer, in the scheduler's walk. The bound
goes on EnsembleEndpoint::connect, which every protocol dials through, rather
than on a third call site.

And the peer list is not what its name said. reachable_ensemble_peers performed
no reachability check: gossip rows are never pruned, so nodes retired long ago
are still in it, and callers walk it in series. Renamed to
ensemble_peers_freshest_first and ordered by last_seen_at, so the live peer is
reached before a dead one's dial budget is spent.

Ordering, not filtering, on purpose: a node that has been off for a week is
still a member and may well answer, and skipping it would turn 'your laptop was
asleep' into 'your laptop no longer syncs'. The worst case is still
peers × budget because the walk is serial — TODO.md carries what is left, with
the pruning question noted as really being node decommissioning.

Found while reproducing with the two-node test harness, which surfaced the
other half of the story: that ensemble had four members, not two.
2026-08-24 23:04:09 -07:00
Greg Shuflin b754adecf6 stores: bulk holder lookup for a set of content keys
Groundwork for the document detail Placement table (redesign step 4), which
needs 'which nodes hold this subtree's files' — one query rather than the
per-key nodes_holding loop, since a comic's pages or an album's tracks would
make that a hundred round trips on a screen that opens on a click.

Unused so far.
2026-08-24 22:49:10 -07:00
Greg Shuflin 6a5463f7f8 Update test ensemble key
Build Debug APK / build (push) Successful in 3m53s
2026-08-24 22:38:09 -07:00
Greg ShuflinandClaude Opus 5 0aa62e40c9 docs: record the open question about where the desktop transport sits
Build Debug APK / build (push) Successful in 4m8s
The bottom-left action row is what the design document draws, and it is what
shipped. The alternative — a vertically-centred left flank beside the artwork,
secondary mirrored right, a three-region stack between them, and a pane around
80px instead of 130px — is deferred rather than declined.

What decides it is the visualization slot, which is currently empty. With the
transport inside the stack, turning a visualization on pushes it down by the
slot's full height, which is the design document's own "landmarks don't shift"
invariant being broken by the layout written to protect it. On a flank it moves
by half that. Arguing about how much that costs against a region nothing draws
in is not worth doing, so it waits until there is something to look at.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUguiyAywfkRPDSFju4u5K
2026-08-24 22:28:26 -07:00
Greg Shuflin d3b539c6e9 sync: put the deficit on screen, for this node and for any peer
Build Debug APK / build (push) Successful in 5m11s
A policy row showed stored bytes and nothing else, which makes Mirror
unfalsifiable: a policy that is working and a policy that binds to no
documents at all render identically. That is the readout missing from the
reported failure — 'I set that node to mirror my music and no music arrived'.

Each row now carries its content ledger, and the three states it distinguishes
have three different fixes:

  0 of 1340 file(s) held  +  1340 file(s) missing   pending; wait, or Sync
  No files of this type                             the policy matches nothing
  0 of 1340 file(s) held  (no deficit line)         an Exclude up the tree

Telling the last two apart needs a denominator, so TypeLedger gains
files_total/bytes_total — one more accumulator in a walk that was already
visiting every row.

SyncConfig carries TypeLedger per type instead of a bare byte count (ALPN
/syn/node-admin/2), so a *remote* row shows the same numbers. That is the
premise of remote administration finally being met: choosing what another node
should hold is guesswork without seeing what it holds now.

Both modalities render from one copy::ContentRowCopy. Two things fall out of
that: eviction::reclaimable_bytes_by_type and its FFI are gone, since the
ledger's bytes_unwanted was the same number reached by a second code path; and
the remote row stops saying 'N stored on this node' about a different node.

Two bugs fixed on the way. Android patched a changed policy in place instead of
re-reading, which for a deficit is exactly the misreading these lines prevent —
and its initial load ran getSyncPolicies() on the main thread, which now walks
the ledger. Both go through Dispatchers.IO.

Also: From<StoreError> for SyncError delegates to the wrapped error rather than
flattening, so the ledger's cross-store reads keep reporting Busy as retryable
instead of as a bug.
2026-08-24 22:28:09 -07:00
Greg Shuflin ecc0d76b5e content_ledger: say accurately when a type row can be all zeroes
by_type gets a row for any type with a blob-backed content artifact, which
includes one whose content is neither here nor wanted. Absence and zeroes mean
the same thing to every caller; the doc comment claimed only the first
happened.
2026-08-24 22:28:09 -07:00
Greg Shuflin ad9b711840 sync: take the peer's name off the summary, not the screen's own row
sync_with_peer already resolves a display name for the peer, and its fallback
(a short id) reads better inside "X is syncing its own side" than the Ensemble
screen's "(unnamed)" placeholder. Also squares the doc's ContentLedger sketch
with the type that shipped.
2026-08-24 22:28:09 -07:00
Greg Shuflin d3a737b323 docs: record the sync-model correction where the old rule is stated
sync-management.md's 'every node satisfies its own policy by pulling' was
written as both a transport invariant and a product rule. The first is right
and unchanged; the second made 'make the server hold all my music' something
a user could set but not act on. Correct it in place, in the section that
states it, rather than leaving the correction only in the newer doc.

Also drops the phase-5 note describing the gap that closed, marks steps 1-2
of the redesign done, and lists steps 3-7 in TODO.md.
2026-08-24 22:28:09 -07:00
Greg Shuflin b67b5a94fe sync: 'Sync' means both nodes now, and reports files first
Two changes that only make sense together.

Directing a peer. sync_with_peer exchanged catalogues bidirectionally and
then ran content passes computed against the *local* node's wants, so setting
a peer's policy to Mirror from here and pressing Sync did exactly what it was
built to do and nothing the user asked for: the catalogue crossed and no
content moved, because the only node computing wants was this one. It now
sends node_admin::trigger_sync after the catalogue exchange and before its own
content pass — before, because a peer made to wait out a multi-minute download
here looks, from its own screen, identical to a peer that was never told. The
outcome rides back as RemoteReconcile so a frontend can distinguish 'wait' from
'that node never heard you'; the button says 'Sync both ways'.

This demotes sync-management.md's 'every node satisfies its own policy by
pulling' from product rule to transport invariant. Pull is still how content
moves and no node pushes uninvited — what changes is that instructing a peer
is a first-class act rather than an implementation detail behind a picker.
TriggerSync can still only cause fetching, never eviction.

Reporting. Four frontends hand-rolled this status line, all leading with a
document count and three calling blob transfers 'artifacts'. A catalogue sync
moves document rows whether or not a byte of content follows, so 'synced 1340
doc(s)' was a confident, accurate sentence printed in exactly the situation
reported as broken. copy::PeerSyncCopy is the one formatter; the file count
leads and is shown even at zero, because zero was the missing answer. Android
takes the whole line from Rust instead of concatenating its own.

Also: sync_with_peer had no guard against targeting the local node, which
reachable_ensemble_peers can return — harmless before, a node ordering itself
around over the network once a remote trigger is attached.

Kotlin unverified beyond detekt; no device in this sandbox.
2026-08-24 22:28:09 -07:00
Greg Shuflin 35ae5fc34a sync: one content ledger where three disagreeing walks were
The content plane was tallied three times over the same rows, in three
modules. Store::local_content_bytes_by_type counted every blob-backed
artifact including Thumbnail; eviction::reclaimable_bytes_by_type counted
only PrimaryContent/Attachment — so the two numbers printed on one
SyncPolicyControl row were computed over different sets. The third,
scheduler::compute_wants, was private and its result never shown, which is
why a Mirror policy that had silently bound to nothing (wrong type, an
Exclude up the tree) looked exactly like one that was working.

content_ledger::content_ledger walks once and answers all three: bytes_here,
bytes_missing (the deficit, itemized as the scheduler's content-pass work
list), bytes_unwanted. Thumbnails are out of all of them — they ride the
catalogue plane, so a dashboard under a policy picker overstated what the
policy governs by including them. The resolution rule (nearest
ancestor-or-self override, else the type policy) and its helpers move here
too, so 'want' and 'keep' can no longer drift apart in separate copies.

The deficit is not surfaced yet; that is step 3. This is the one walk it
will read from. Desktop settings now pays for one walk per Sync-tab visit
instead of two.
2026-08-24 22:28:09 -07:00
Greg Shuflin 79a7b6827d docs: a UX redesign of the sync system, denominated in content
The two-plane model in sync-management.md is built and correct; what was
never designed is how a person sees whether it is being honoured. Three
faults follow from that: an action on one node cannot satisfy an intent set
for another (pull-only, but the UI never says which node a button commands),
nothing anywhere reports a deficit (compute_wants is private and its result
unshown, so Mirror is unfalsifiable), and every count is denominated in
documents while every failure is a file that did not arrive.

Proposes a public ContentLedger (held/missing/reclaimable, one walk),
Reconcile-with-peer that also fires TriggerSync on the peer, one Placement
table per document replacing the Keep-here/Push-now split, and a vocabulary
that says files where policy governs files.
2026-08-24 22:28:09 -07:00
Greg ShuflinandClaude Opus 5 1ae685b83e player: no number in the glyph; 15 seconds each way
Build Debug APK / build (push) Successful in 5m30s
The skip interval is heading for a user setting, and an icon with "10" drawn
into it is a second place that number lives — the one place that can't follow
the setting. Android was picking between Material's numbered Replay5/10/30 and
Forward5/10/30 by matching on the configured seconds, with an unnumbered
fallback for anything else; that fallback was the honest case all along.

Both players now draw a plain circular arrow either way — lucide
`rotate-ccw`/`rotate-cw` on the desktop, Material's `Replay` and the same glyph
mirrored on Android, so the pair reads as one icon pointing two ways rather
than as two unrelated ones.

The interval is written where it can be derived from the value that produces
it: `step_label` behind a tooltip on the desktop (transport buttons had none;
without the number in the glyph they need one), and `stepDescription` as the
content description on Android. Neither can go stale against the button.

Default is now 15 seconds each way rather than back-10/forward-30, and it sits
in the agent — `SKIP_BACK_SECS`/`SKIP_FORWARD_SECS` and `SKIP_SECONDS` — so
making it configurable is a matter of where the value comes from and nothing
else.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUguiyAywfkRPDSFju4u5K
2026-08-24 19:07:46 -07:00
Greg ShuflinandClaude Opus 5 43d759aa52 docs: ADR 0046 — the player's regions are fixed, its contents are configured
ADR 0045 got Music and Podcasts onto one player per modality but said nothing
about what a player *is*, so each one kept the shape its first tenant happened
to have. This records the shape: four regions in a fixed order, an agent
configuring what goes inside them and never where they sit, and the invariants
that order exists to protect — metadata centred over the scrubber, the
visualization slot directly above the timeline, the primary transport anchored
so an optional control can't move it, play/pause filled because size alone
doesn't carry "strongest control".

It also records the two things that look like drift and aren't: the desktop and
mobile time/transport arrangements differ because ~340dp of phone width can't
hold two time labels either side of a usable scrubber, and `Visualization`
ships with only `None` because the value of the slot is that filling it later
touches no layout.

Also renumbers 0045 in its own heading and in the index, where it still said
0044 — the number 0044 already belongs to ensemble-private node names.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUguiyAywfkRPDSFju4u5K
2026-08-24 18:52:40 -07:00
Greg ShuflinandClaude Opus 5 dcc2904f1c android: one audio player, four regions, configured by capabilities
The mirror of the desktop change. Android had the opposite problem: not one
player that had grown two tenants, but two players that had never been one.
`EpisodePlayerScreen` carried a scrubber, time row and transport inline at its
foot; `MusicScreen` carried a private `MusicPlayerBar` doing the same job in a
different order, with a differently-shaped play button and its own idea of what
"loading" looks like. Nothing was shared but `MediaSlider`.

`ui/PlayerControls.kt` is now the one player, laid out as the design principles'
regions in a fixed order — artwork, metadata, visualization, timeline, primary
transport, secondary actions — with `PlayerCapabilities` deciding what goes
inside a region and never where it sits. `PODCAST_PLAYER` and `MUSIC_PLAYER` are
two values of that type, sitting in the screens that host them.

Where it deliberately differs from the desktop, and why: the desktop puts the
elapsed and trailing times either side of the scrubber and anchors the transport
to the left of a wide row. Neither survives a phone — ~340dp of content width
minus two time labels leaves the scrubber a stub, and a left-anchored transport
puts the play button under nobody's thumb. So the times sit below a full-width
scrubber and the transport is centred, which is the same width-driven split the
app already makes between two-column and stacked label/value lists.

The primary pair is a `TransportStep`, as on the desktop:

- Podcasts get `Skip(10)`/`Skip(30)`, handled inside the widget through
  `onSeek`, replacing the screen's own back-10/forward-10 buttons.
- Music gets `Adjacent`, and gains Previous/Next for the first time.
  `MusicScreen` captures the track list the tap came from (`playbackContext`),
  so browsing off to another artist mid-song doesn't redefine what that song's
  Next means, and `adjacencyOf` greys the pair out at either end and for a
  track with no surrounding list at all. Stepping while playing keeps playing.

The secondary cluster is a `@Composable RowScope.()` slot rather than a field.
That is what keeps `PlaybackSpeedControl` podcast-only and inside `podcast/ui/`
per ADR 0045 — the shared player never learns what is in the slot — and it is
the Compose-idiomatic spelling of a region whose contents belong to the host.

Also here:

- Play/pause is a `FilledIconButton` at 64dp against 52dp flanks. "Play/pause
  should be the strongest visual control" doesn't survive being one more
  outlined glyph in a row of them, and both are well past the 48dp target.
- Podcasts' trailing time counts down (`TrailingTime.REMAINING`).
- `formatDuration` moves from `podcast/ui/PodcastUtils.kt` to `ui/MediaTime.kt`,
  with `formatRemaining` beside it. A player shared by every audio agent must
  not reach into one of its own tenants' packages for a clock.
- The step glyphs map to Material's numbered replay/forward icons for 5/10/30s
  and fall back to an unnumbered circular arrow otherwise, rather than to a
  glyph claiming the wrong number. The content description states the real
  interval either way.
- Music's blob-availability line moves out of the player to a strip above it —
  the same move ADR 0045 records for the desktop's Stream-policy fetch line.

`Visualization` ships with only `NONE`, as on the desktop: the region is real
and its place in the order is fixed, nothing draws in it yet, and adding
something touches the enum and one composable rather than the layout.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUguiyAywfkRPDSFju4u5K
2026-08-24 18:51:27 -07:00
Greg ShuflinandClaude Opus 5 1220e4608c gui: the audio player is four regions and a capability set
docs/audio-player-ui-design-principles.md describes one player shared by Music
and Podcasts, laid out as four regions in a fixed order — metadata,
visualization, timeline, actions — configured by capabilities rather than by a
mode. The desktop had a single horizontal row instead: a 240px metadata column
on the left, the scrubber flexing in the middle, and every control the agent
offered piled at the right, so adding the rate pill moved the play button.

The bar is now a column, and each region is its own function:

        Primary metadata          centred over the scrubber, not over
       Secondary metadata         the transport cluster

       Optional visualization     collapses to nothing when absent

 elapsed ━━━━━●━━━━━ remaining

 [ back  ▶  forward ]      [ rate  stop ]

The actions row is `justify_between`, not centred: the primary cluster is
anchored left so a secondary control appearing or disappearing on the right
cannot move the button the user reaches for without looking. Play/pause is
accent-filled (`transport_button_primary`) and larger than what flanks it —
"play/pause should be the strongest visual control" doesn't survive being one
more grey glyph in a row of them.

`SpeedControl::{Shown, Hidden}` becomes `PlayerCapabilities`: artwork,
visualization, trailing_time, primary_actions, secondary_actions — one field
per region, in the order the regions appear. `PlayerControls` knows nothing
about music or podcasts; `music_player()` and `podcast_player()` are two values
of the same type, and the diff between them is the whole difference between the
agents' transports.

The primary pair is a `TransportStep`, and the two agents genuinely differ:

- `Skip(secs)` seeks *within* the track, handled in the bar — podcasts get
  back-10/forward-30. A relative seek is transport; the owner has no opinion.
- `Adjacent` steps *between* tracks, emitted as PreviousRequested/NextRequested
  — only Music knows what the next track is. It captures the track list it was
  activated from (`playback_context`), so browsing off to another artist while
  a song plays doesn't redefine what that song's Next means, and it reports
  `NowPlaying::adjacency` so the pair greys out at either end and for a track
  with no surrounding list at all. Stepping while playing keeps playing;
  stepping while paused just moves the selection.

Also from the principles, and from what the old bar got wrong:

- The trailing time can count down (`TrailingTime::Remaining`). Podcasts do:
  an hour-long episode's total length is a fact the user already knows.
- `format_time` gains an hours field. `M:SS` rendered an 83-minute episode as
  `83:20`, which reads as neither a clock time nor a duration.
- The scrubber's hit strip is 24px around a 4px groove. The interactive area
  has to be substantially larger than the visible line; it was 20px with the
  groove positioned by hand-tuned offsets, which is now derived from the
  strip's height so widening the target can't un-centre the line.
- Music's bar shows album art for the first time. It has the cover decoded
  already for the library the track was picked out of, so `NowPlaying::image`
  became a `TrackArt` of `Url` (podcasts, fetched by gpui) or `Decoded`
  (music), rather than Music re-encoding an image it is holding.

The player is capped at `CONTENT_MAX_WIDTH` and centred. Uncapped on a
maximized 4K window the elapsed and remaining times sit a metre apart with the
metadata stranded between them and the two ends stop reading as one player.

`Visualization` ships with only `None`. The region is real and its place in the
order is fixed; nothing draws in it yet. A spectrum analyzer means tapping the
rodio sample stream, which is its own change, and adding it touches this enum
and `render_visualization` and no layout.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUguiyAywfkRPDSFju4u5K
2026-08-24 18:38:54 -07:00
Greg Shuflin a92b3c154b audio: assert 1x is transparent, not merely non-empty
Build Debug APK / build (push) Successful in 4m59s
The unity-tempo test asserted only that SoundTouch emitted more than
40k frames for 44.1k of input — true of an output 10% short, or one
resampled to a different rate, or one that had passed through a stray
pitch shift. It would not have caught the class of bug it exists for.

Assert the property instead: at 1x the stretch stage should be as if it
weren't in the chain — identical length, and audio that matches the
input. Measured against a real MP3 the error is a flat -69 dB floor,
worst 100 ms window -67 dB, so the 40 dB floor asserted here is wide
enough never to flake and tight enough to catch a real regression.

The measurement is also the answer to "1x sounds muddy on the desktop":
it doesn't, to within a noise floor far below the source's own coding
noise.
2026-08-24 18:18:54 -07:00
Greg Shuflin 091fe3f6f4 audio: report the decoded format against the device's on every load
Chasing a report that podcasts play slow meant reconstructing, from
scratch, what rate the file decoded at and what rate the output device
had negotiated — the two numbers that between them explain every
uniform-speed-and-pitch complaint, and the two nobody could see. Log
them, with the applied rate, once per load at info (`-v`).

They routinely differ: rodio negotiated 44.1k on a machine whose
PipeWire graph is locked to 48k, and the mixer resamples between them.
That is fine and measures exact — which is the point of printing it,
so the next such report starts from the numbers instead of a bisect.
2026-08-24 18:18:54 -07:00
Greg Shuflin 0f4e618362 podcasts: an episode the bar merely holds is not a paused episode
Opening an episode screen hands its track to the shared transport bar as
*pending* (PlayerControls::set_pending) so the bottom bar's Play works
without the in-page Play being pressed first. Three screens read that as
playback: they compared their episode id against now_playing_document_id
and, finding a match with is_playing() false, rendered the episode's own
Play button as a disabled "Paused" — the moment the screen opened, before
anything had played, and inert when clicked.

Split the two states apart with PlayerControls::has_audio_session (the
predicate set_pending already computed inline) and pair it with the id
match at all three call sites. The episode and queue buttons stop being
inert in the bargain: where the bar really is holding the track they now
read Pause/Resume and toggle it, rather than reporting a status.
2026-08-24 18:18:54 -07:00
Greg Shuflin fba51142e4 Some audio player design principles 2026-08-24 18:18:54 -07:00
Greg Shuflin ca44c1afd5 gui: put Music and Podcasts behind the one transport bar
The desktop had two players. `components/player_controls.rs` was written for
Podcasts; `agents/music.rs` carried its own copy of the same bar — metadata
column, play/stop buttons, scrubber, time labels, position ticker, MediaSession
wiring — about 350 lines, and drifting: no rate control, no loading state, and
a hard-coded "Unknown Artist · Unknown Album" where the podcast bar showed real
metadata.

They diverged over one thing only, which is how audio is *sourced*: podcasts
have a URL to stream, Music has already resolved a track out of the blob store
or off a peer and wants the decoder built only when the user presses Play. So
that is the seam, and nothing else is per-agent.

The lib's MusicPlaybackRuntime is split. What remains is music::SelectedTrack —
a resolved track and nothing else, owning no AudioPlayer and driving nothing;
its play/pause/stop/seek/position functions are gone, because a transport was
never its job. music::ensure_sink_loaded is the bridge: the caller hands over
its own player at the moment playback starts, which is what keeps selection
lazy — browsing a library still never opens the audio output device.

NowPlaying's audio_url becomes an AudioSource of Stream / Resolved / Silent,
and PlayerControls grows a load() beside play() and set_pending(): put this
track in the bar, silent, replacing whatever was there. That is what selecting
a track in a library means, and neither of the other two said it. The rate
control is opted out of rather than removed (SpeedControl::Hidden) — a rate
control over a song is a novelty, and the shared bar shouldn't grow one just
because its other tenant needs it.

Two fixes fell out of the merge rather than being ported:

- the ticker's audio snapshot now happens on the background executor. Music's
  own ticker had moved it there deliberately (a decode holds that lock for
  hundreds of ms, and a main-thread wait on it stutters the window); the
  podcast ticker had not, and would have inherited the stall.
- set_pending no longer flushes progress. Folding it onto load() would have
  had it emit end-of-track PositionChanged for an episode that had just
  reported Finished, writing a position over what the owner acted on.

Music also gains what only the podcast bar had: a real subtitle (its codec
line), a loading state, and playback errors shown on the bar the user pressed
Play on rather than in the list they came from. ADR 0044 records the rule.
2026-08-24 18:18:54 -07:00
Greg Shuflin f4faadbc68 android: per-agent audio handles, and a speed control for podcasts
Two faults in the same transport, fixed together because they are the same
fault: state that belongs to one agent leaking into another.

**Shared playback state.** Playing a podcast and then opening Music showed the
Music bar sitting at the podcast's position — greyed out, because Music had no
track of its own, but scrubbed to somebody else's playback. One
AudioPlayerManager is right (the device plays one thing at a time, and the
ExoPlayer lives in a MediaSessionService so it outlives every screen), but
*what is loaded* belongs to whichever agent loaded it. So agents now take an
AgentAudioPlayer keyed to their PlaybackSource: it reads as idle whenever
another agent owns the transport, and every command is a no-op then too, so a
coroutine still running on a screen the user has left cannot reach into what
replaced it. Loading claims the transport — the one operation that is meant to
take it. A reader that wants the app-wide truth (the home screen's live-state
slot, which asks whose row is playing) takes AudioPlayerProvider.transport.

PlaybackState grows a title so the Music bar can name what is playing after the
screen that started it was rebuilt, and stops naming it the moment a podcast
takes the transport.

**Playback speed.** Android had no rate control at all, where the desktop has
had one since player_controls.rs. PlaybackSpeedControl is its counterpart: a
pill opening a menu of the same presets, the feed's remembered rate, and a
Custom… slider, with the desktop's semantics — a preset changes the session,
a confirmed custom rate is what the feed remembers. Persisted through a new
PodcastFfi::save_custom_speed onto the PodcastFeedCustomSpeed property the
desktop already writes and syncs, so a rate set on either node is the rate the
next episode starts at on the other.

Deliberately podcast-only. The rate is set on every load — reset to 1x by
loadUri — because ExoPlayer's speed is a property of the player, not the item,
and would otherwise carry a podcast's 1.5x onto the next song.
2026-08-24 18:18:54 -07:00
Greg Shuflin 459f1cdfed TODO: drop the relay-URL sealing item; sealing it would hide nothing
Build Debug APK / build (push) Successful in 3m40s
The item asked whether gossip's plaintext relay_url is a location leak.
It is not one worth closing:

- The value today is one of iroh's four default n0 relays, chosen by
  latency (use1-1/usw1-1/euc1-1/aps1-1.relay.n0.iroh.link), so it
  discloses a continental region, not a provider or a machine.
- More decisively, iroh already publishes each node's home relay *and*
  every discovered direct socket address under the node pubkey, in the
  clear, to dns.iroh.link and — since we opted into DhtAddressLookup —
  the mainline DHT. Node pubkeys come free from the ensemble registry,
  which is world-readable given only the ensemble public key. The
  observer the item posited already has IP addresses; a sealed region
  behind that is no wall at all.

Also fixes a stale hostname in the self-hosting item: iroh's prod
defaults dropped the iroh-canary label.
2026-08-24 16:54:58 -07:00
Greg ShuflinandClaude Opus 5 6e13f74d0a security: the pkarr registry stops carrying node names
Build Debug APK / build (push) Successful in 3m56s
The ensemble registry is a DNS packet on the mainline DHT, fetched with
nothing but the ensemble public key -- which syn ensemble info prints and the
pkdns bootstrap link embeds. Every entry carried name_len || name_bytes in the
clear, so a device label, and through it its owner, was world-readable to
anyone who had ever seen that key, a removed node included.

Sealing it there was the wrong trade. publish_membership runs only during
ensemble init/register, while the ensemble secret is briefly in memory, and no
code path ever rewrites the record -- so the name in it was a snapshot from
join time that no later rename reached. It cost privacy to publish a value
that was already drifting, and it cost packet budget: variable-length entries
meant how many members fit in pkarr's 1000 bytes depended on how long people's
laptops were called. Entries are now fixed-size at 105 bytes, and six still
fit.

The roster loses nothing gossip does not replace: names arrive sealed over the
topic and persist in peer_nodes, so a member reads as (unnamed) only until it
first announces itself. The version byte stays at 1 and the decoder takes a
fixed-length prefix, ignoring whatever follows, so a record published by an
older build still bootstraps -- its trailing name simply never read. A test
covers exactly that, since losing it would cost existing ensembles their
bootstrap.

syn ensemble dht-peers and ensemble info list registry entries without names
rather than borrowing one gossip happened to supply: those listings are what
is *published*, and a placeholder is the honest answer.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gkup9bGFrnEaBVG8TQTJrS
2026-08-24 14:35:59 -07:00
Greg ShuflinandClaude Opus 5 a33f20d7eb security: seal node names on the gossip wire
Gossip is deliberately not admission-gated -- GATED_ALPNS says why: it
authenticates per message instead -- and the topic is
derive_topic(ensemble_pubkey). So anyone who learns the ensemble *public* key,
which syn ensemble info prints and the pkdns link embeds, can join the swarm
and read every node name in the ensemble, rebroadcast every 60 seconds.
Signatures made those announcements unforgeable; they never made them private.

NodeAnnouncement.node_name is now a SealedName: base64url of nonce ||
ChaCha20-Poly1305(name), under blake3::derive_key over the default vault key.
That key is already derived from the ensemble *secret* and already stored on
every member wrapped under its own node key, so every member can open a name
and holding the public key cannot -- no new key material, no distribution
step, nothing new on disk. A separate derivation rather than the vault key
itself keeps a sealed name and a document blob from being interchangeable
inputs to the same AEAD.

Load-bearing details, each with a test: the signature covers the sealed bytes
rather than the plaintext, so a receiver checks authenticity before and
independently of decrypting; the node pubkey is the AEAD's associated data, so
a sealed name cannot be lifted onto another member's announcement; the
plaintext is padded to a 16-byte multiple, so 'phone' and 'laptop' are the
same size on the wire; every failure -- no key, over-long name, RNG -- yields
an announcement with no name at all rather than a plaintext fallback; and a
name this node cannot open leaves the peer unnamed, not rejected, since the
cert and signature have already established a member said this.

The three-node gossip integration test now names node B and asserts A shows
that name, so the round trip is covered over a real link and not only in
process. Opened names are stored in the clear in peer_nodes -- that is this
node's own disk, guarded by stores::permissions.

NodeRuntime::start loads and decrypts the default vault key before starting
P2P rather than after, since gossip needs the key derived from it. A node
without one is a node without an ensemble, which this already refused to start
for; it now refuses before opening an endpoint.

TODO gains the question this leaves open: relay_url still travels in the
clear in the same announcement, and it is coarse location data.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gkup9bGFrnEaBVG8TQTJrS
2026-08-24 14:35:49 -07:00
Greg ShuflinandClaude Opus 5 b9e26f75de security: /version stops disclosing the node name; pairing hands it over instead
The loopback listener's module doc claimed every field of /version was already
public. True of node_pubkey, which is published to the mainline DHT. Not true
of node_name: 'Greg's work laptop' is not a credential, but it is about a
person -- their name, their employer, how many machines they own -- and that
route answers any process that can open a socket to loopback.

The field had exactly one consumer, the extension's node picker, and pairing
can serve it: redeeming a code read off this node's own screen is the moment a
caller stops being anonymous. So /pair answers node_name, the extension keeps
it on the stored linkage, and a node it has not linked shows as 'Daemon' or
'Desktop app' plus its pubkey. Unlink drops the name with the token, which is
the honest rendering.

Disambiguating several nodes on one machine -- ADR 0017's reason for putting
identity in this response -- is node_pubkey's job either way, and it does it
whatever the node is called.

ADR 0044 records the policy this is the first third of: a node name is
ensemble-private. The other two sites, the pkarr registry and gossip
announcements, follow in the next commits.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gkup9bGFrnEaBVG8TQTJrS
2026-08-24 14:35:34 -07:00
Greg Shuflin 71b9c16954 gui: cap the four remaining uncapped detail screens, and stop forking the idiom
Build Debug APK / build (push) Successful in 3m54s
**Correction to the commit that added `detail_form`.** Its message said
`CONTENT_MAX_WIDTH` "already existed and documented exactly this problem, with
no consumers". The second half is wrong: it has eleven call sites across eight
files, and a documented house shape in `sizing`'s module docs. The claim came
from grepping `CONTENT_WIDTH`, which is not a substring of `CONTENT_MAX_WIDTH`
and therefore matched nothing. That commit is already on master@origin, so
this corrects it forward rather than rewriting it.

The consequence was a forked idiom: `detail_form::reading_column` wrapped the
body in an extra capped div, where every other screen puts a plain
`.max_w(CONTENT_MAX_WIDTH)` on the scrolling body itself. One idiom with a
dozen call sites beats two with thirteen, so `reading_column` is gone and
`human.rs` uses the house shape. `labeled_row`/`row_label` stay -- the
label/value grid is genuinely new -- and the module now says width is not its
job and points at where that lives.

**The sweep.** Every `overflow_y_scroll`/`uniform_list` in gui-app, against
whether its file caps. Four screens were detail-shaped and uncapped:

- `agents/jobs.rs` -- a job row is `justify_between`, so its label and its
  state/progress sit at opposite ends of the window.
- `agents/podcasts/queue.rs` -- controls stranded from the episode they act
  on, the same shape the subscriptions list beside it already fixed.
- `agents/podcasts/episode.rs`, `agents/podcasts/detail.rs` -- detail bodies.

Deliberately left uncapped, and why: the document table, presence view and
media library are grids where width *is* the information; `agent_sidebar`,
`hierarchical_sidebar`, `scrollbar` and `settings/widgets` are already narrow
or are components that should let their host decide; `settings/mod.rs` is a
shell whose three tabs each cap themselves.

Left as an open question rather than changed: `agents/notes/mod.rs`'s editor
and preview panes, and `components/markup_view.rs`. Both are prose surfaces
where a measure cap is arguably right and arguably not, markup_view is a
component with several consumers, and Split mode already halves the width --
that is a typographic decision to make deliberately, not a sweep's business.

CLAUDE.md's rule is rewritten to describe the real idiom, and gains the
uncapped cases.

Verified: cargo check/clippy --all-targets clean, 218 tests pass, just
lint-gui-layout clean. Not visually inspected -- four screens changed width.
2026-08-24 13:46:21 -07:00
Greg Shuflin 8b7e39bc3c CLAUDE.md: a label/value list is two-column on desktop, stacked on Android
Build Debug APK / build (push) Successful in 5m0s
Records a divergence rather than introducing one -- the previous commits left
the desktop profile as a label/value grid and Android's stacked, and without
this that reads as drift for the next person to compare the two.

The reasoning is width, not platform taste. A desktop `reading_column` is
1040px and leaves the value ~870 beside a 160px label column; a phone's
content width is ~330-380dp, leaving 156-208, which wraps long values to
three lines and makes each row taller than the stacked version it would
replace. That is the same split the desktop and mobile versions of the same
apps make -- macOS and GNOME Contacts are two-column, iOS and Google Contacts
stack.

Written as "don't make them match", because the tidying instinct is the
failure mode here. The genuinely open question is a tablet or foldable, not a
phone: the app has no adaptive-layout machinery at all (no WindowSizeClass,
no BoxWithConstraints), so Android's choice is unconditional today, and
introducing that machinery is worth doing on its own merits before it is
worth doing for this.

Pointers at both ends -- `read_only_row` and `ReadOnlyField` each name the
other -- so someone reading either screen finds the reasoning without having
to already know the rule exists.

Verified: just check-gui-nix and just lint-kotlin clean.
2026-08-24 13:35:36 -07:00
Greg Shuflin 191cf88cf9 humans: pin the Android profile's action bar to the bottom of the screen
Edit, Save and Cancel were the last children of the scrolling column, so on a
profile with a few facts on it you had to scroll past every one of them to
reach the button that leaves the mode you are in. They are the screen's exit,
not its last field.

`SubAppScreen`'s content slot is already a `ColumnScope`, so this needs no
extra nesting: the scrolling body takes `weight(1f)` instead of
`fillMaxSize()` and the bar follows it as an unweighted sibling, taking its
intrinsic height at the bottom. `HistoryTab` grows the customary
`modifier: Modifier = Modifier` for the same reason (last, with a default --
detekt's ModifierWithoutDefault and LambdaParameterEventTrailing both have
opinions here, and only the conventional order satisfies both).

The error line moves out of the scroll flow with it, as `PinnedError`. It was
the worst-placed thing on the screen: the failure that matters most is a save
the store refused, which happens at the moment the user is furthest from
wherever the message sat. This also gets the History tab an error surface at
all -- it returned before ever reaching the line that rendered `error`, so a
failure to load or log an interaction was silently dropped.

Verified: just gradlew compileDebugKotlin / test / assembleDebug, just
lint-kotlin (detektDebug, type resolution) all clean. Not visually inspected
-- needs a look on device.
2026-08-24 13:21:58 -07:00
Greg Shuflin 5a82db8009 humans: Android gets the editable fact values and the entry-row fix
Build Debug APK / build (push) Successful in 5m5s
The two model-level halves of the previous commit, which are bugs rather than
desktop layout taste and so belong on both frontends.

- A fact's value is a field in edit mode; its key stays fixed, for the same
  reason as on the desktop (the pair is the artifact id, so a rename is a
  delete plus an add, and `diffStaged` already emits exactly that). An
  emptied value deletes the fact.
- Save commits a filled entry row. Both entry rows move out of
  FactsSection/ContactSection into the screen, as `FactEntryState`/
  `ContactEntryState`, because Save has to be able to see them -- a fact typed
  in full and left in the row was silently dropped. `stageInto` folds a row
  into its staged list, and a row with one of two fields filled stops Save
  with a message on the field instead of vanishing. Still `remember(editing)`,
  so a cancelled edit discards them.
- The contact protocol picker's selection moves up with them, since staging a
  contact method now needs it at Save time.

The label/value grid and the width cap are deliberately not mirrored: the
first is still being looked at on the desktop, and the second is a 4K-monitor
problem a phone does not have.

Verified: just gradlew compileDebugKotlin, just gradlew test, just
lint-kotlin all clean. Not visually inspected -- needs a look on device.
2026-08-24 13:02:30 -07:00
Greg Shuflin d9015d7360 humans: editable fact values, a capped reading column, a label/value grid
Four things the desktop screen got wrong, from a look at it on a 4K display.

**Fact values are editable.** A fact row was read-only with a Remove button,
so correcting a typo meant deleting the row and retyping both halves. The
value is now a field; the *key* stays fixed, because the (key, value) pair is
what the store derives the artifact id from -- "renaming" one is a delete plus
an add, and a text field there would promise an in-place edit that does not
exist. An edited value reaches `save_current` as exactly that remove/add pair,
which `diff_staged` already produces without knowing it was an edit. Clearing
a value deletes the fact: a blank value is not a fact, and clearing the field
is the obvious way to say so.

`FactEdit` (key + live `TextInput`) is what the form holds; `orig_facts` stays
plain `FactRow` data, and `staged_facts` reads the fields back for the diff.

**Save commits a filled entry row.** Typing a fact in full and pressing Save
lost it -- only Add staged it. Save now folds both entry rows in first. A row
with one of its two fields filled is an unfinished edit and *stops* Save with
a message on the field rather than being dropped, which is the same bug in
quieter clothes. `add_fact`/`add_contact` return whether Save may proceed.

**The form no longer spans the window.** Every row stretched the full width,
so on a 4K monitor the Add and Remove buttons sat 2400px from their labels.
`sizing::layout::CONTENT_MAX_WIDTH` already existed and documented exactly
this problem, with no consumers; `components::detail_form::reading_column` is
the general way to take it, applied here to both tabs. The module explains why
`max_w` is right there and not the banned `flex_1`-plus-`max_w`: the column
sets no `flex_1`, so its width is ordinary cross-axis sizing resolved before
its children are placed. The `flex_1` stays on the scroll container outside it.
CLAUDE.md gains the rule, and `LABEL_COLUMN_WIDTH` joins the sizing tokens.

**View mode is a label/value grid.** Label in a fixed left column, value
beside it -- the property-list shape used wherever values are short (macOS and
GNOME Contacts, Notion, Linear). Values on this screen are one line apiece, so
stacking doubled the screen's vertical run to align things already aligned.
Two exceptions: an empty collection collapses to a single "Not recorded" row
rather than a heading with an apology under it, and Notes keeps its label
above full-width prose, since a paragraph in the value column gets a measure
too narrow to read -- which is why it also moves to the end of the form. Edit
mode stays stacked: an input needs the width. A fact key with several values
is written once with its values stacked beside it.

Verified: cargo check/clippy --all-targets clean, 218 tests pass, just
lint-gui-layout clean. Not visually inspected -- needs a look.
2026-08-24 13:02:30 -07:00
Greg Shuflin ac87464e37 CLAUDE.md: editing is a mode, and the mode is the whole screen
Writes down the rule the previous two commits implement, as TODO.md's Humans
entry asked ("a note in CLAUDE.md that all editable fields should work this
way"), and removes that entry.

The substance beyond "have an edit mode" is the three things that went wrong
on the Humans screen and would go wrong again unprompted:

- Collections on a form are staged like its fields, whatever the store does
  underneath. "Each row is its own artifact, so there's nothing to batch
  behind Save" is the reasoning both frontends independently used to write
  facts and contact methods straight through, and it is a fact about storage
  rather than a licence -- it makes Save mean two different things on one
  form and leaves a removal unrecoverable.
- Cancel and reload are one code path, because they are one act. Named
  because the desktop's fields live in TextInput entities rather than in the
  screen's own struct, so a Cancel that dropped only the staged collections
  would have left a cancelled rename on screen.
- Not everything on a screen is part of its form. An interaction is its own
  document shared with its other attendees, so it is written when the user
  says to write it and stays outside the mode. The test is field-of-record
  versus record-of-its-own, not "is it on this screen".
2026-08-24 13:02:30 -07:00
Greg Shuflin 2933946a44 humans: the Android profile is a mode too, matching the desktop
The same change as the previous commit, on the same screen's Compose half,
which had independently arrived at the same split model: singleton fields
behind Save, facts and contact methods written straight through on add and
remove ("Collections are persisted immediately, separately from the Save
button"). Both are staged now, and the profile has a view mode.

- An `editing` flag over the whole profile column. Each section draws its
  own two appearances rather than there being a read-only copy of the column
  beside an editable one -- same reasoning as the desktop's.
- `FactRow`/`ContactRow` replace the FFI records as the screen's state.
  `HumanProfile.facts` arrives grouped by key but is laid out and diffed one
  row per value, so it is flattened on arrival. A staged `ContactRow` has a
  null `uri`: which protocols are openable is dispatch the Rust side owns
  and a frontend must not invent a link, so a contact method isn't tappable
  until Save has been through and the canonical value comes back.
- The `collectionsReloadToken` effect becomes a plain `reloadToken` that
  re-reads the whole profile. Both exits from edit mode use it -- Save, so
  the form shows what the store made of the write, and Cancel, so it shows
  what was there before. Discarding the staged edit *is* reloading, so there
  is one path rather than a separate revert to keep in step.
- `saveProfile` does the diff and the writes, sequenced with `result {}` /
  `bind()` (ADR 0022) rather than a chain of `getOrThrow`. First failure
  stops the run, the caller reports it, and the form stays in edit mode with
  everything still staged.
- Entry fields in both sections are `remember(editing)`, so half-typed text
  is discarded along with the rest of a cancelled edit.
- `diffStaged`/`sameContact` mirror the Rust helpers of the same names, down
  to contact identity being protocol + value rather than the whole row.

Verified: just gradlew compileDebugKotlin, just gradlew test, just
lint-kotlin (detektDebug, type resolution) all clean; the regenerated uniffi
bindings carry the new ActionLabels.edit field. Not visually inspected --
needs a look on device.
2026-08-24 13:02:30 -07:00
Greg Shuflin 3cfae3f7bf humans: the desktop profile is a mode, and Save writes all of it
The Humans detail screen had two different save models on one form. The six
singleton fields staged behind Save, as did circles; facts and contact
methods were written straight to the store the instant they were added or
removed, on the reasoning that each is its own artifact row with nothing to
batch. True of the storage, wrong as a model: some of what you changed was
already committed and the rest was not, and there was no way to back out of
a removal. Commit pymrpswkquov made Save *look* live after such a change by
setting the dirty flag from the reload; that treated the symptom.

Facts and contact methods are now staged like everything else, diffed
against an orig_* snapshot on Save exactly as circles always were, and the
screen gains the edit/view mode TODO.md has been asking for:

- `DetailMode::{View, Edit}` on `Detail`. A person opens read-only; the
  action bar under the profile says Edit while reading and Save/Cancel while
  editing. Every section renders its own two appearances rather than there
  being a parallel render_profile_view/render_profile_edit pair, so the two
  cannot drift in order or wording.
- `reload_detail` replaces `refresh_collections`/`refresh_contacts`: one
  re-read of the whole profile, resetting the TextInput/TextArea entities
  too. That is what makes Cancel mean cancel -- the singleton fields live in
  those entities, not in `Detail`, so dropping the staged collections alone
  would leave a cancelled rename on screen. `set_content` emits no change
  event, so seeding the fields doesn't re-dirty the form.
- `diff_staged` is the one rule behind Save for all three collections, with
  `same_contact` supplying contact-method identity (protocol + value, the
  pair the store derives the id from -- not the label). Entries on both
  sides are written by neither list: re-saving an untouched profile must not
  restamp modified_at on rows nobody touched.
- A failed store write leaves edit mode up with everything still staged and
  says why beside the button, instead of only reaching the log.
- Empty fields and empty collections read "Not recorded" rather than a blank
  under a label, so view mode says what Edit would let you fill in.

Adds `copy::action::EDIT` (and its ActionLabels FFI field) now that two
frontends say the word.

Verified: cargo check/clippy --all-targets on gui-app clean, 218 tests pass
(9 new, covering the diff), just lint-gui-layout clean, cargo nextest across
the workspace 1142 passed.
2026-08-24 13:02:30 -07:00
Greg Shuflin e302f67270 humans: adding/removing a fact or contact method activates Save
Both platforms already write a fact/contact method straight to the store
the instant it's added or removed -- deliberately, per each platform's
own comments ("Collections are persisted immediately, separately from
the Save button" on Android; "written immediately... unlike the singleton
fields" on the desktop). Neither ever touched the dirty/canSave flag,
which is scoped only to the six singleton profile fields (plus, on the
desktop, staged circle add/remove) -- correct in the narrow sense that
there's genuinely nothing left for Save to persist for a fact, but it
left Save looking inert right after a change that had, in fact, already
gone through. Reported as confusing on both platforms (same design,
independently arrived at) -- worth fixing even though no data was ever
at risk.

gui-app (rust/gui-app/src/agents/human.rs): refresh_collections (the
add_fact/remove_fact reload, also called by the save handler) and
refresh_contacts (the add_contact/remove_contact reload) now set
`d.dirty = true`. The save handler's own `d.dirty = false`, which already
ran immediately after its own refresh_collections call, still wins for a
real save -- refresh_contacts is never called from there, so nothing
needs to undo it on that path.

Android (HumanDetailScreen.kt): the collectionsReloadToken effect (the
equivalent reload, fired by both FactsSection and ContactSection's
onAdd/onRemove) now sets `dirty = true` alongside reloading `facts`/
`contactMethods`.

Clicking Save afterward is a harmless no-op for the fact/contact itself
(it was already durable) -- it just re-writes the unchanged singleton
fields and diffs an empty circle change, then clears dirty, same as any
other save.

Removes the TODO.md entry this closes ("on Android adding new 'facts'
fields doesn't expose the save button").

Verified: cargo check --workspace, cargo clippy -p gui-app clean
(pre-existing unrelated warnings in lib aside), cargo test -p gui-app
--bin syn-gui (209 passed), cargo fmt; just lint-kotlin (detektDebug,
with type resolution) and just lint-kotlin-fast both clean, including a
successful compileDebugKotlin; just fmt-kotlin.
2026-08-24 13:02:30 -07:00
Greg ShuflinandClaude Opus 5 20b3933df8 chore: clear the standing clippy warnings in syn-cli and the lib
Build Debug APK / build (push) Successful in 4m7s
Six useless_borrows_in_formatting in cli-app/commands.rs and two
unnecessary_sort_by in the lib. All mechanical, no behaviour change:

- Dropped the redundant & on format! arguments, inlining the captures where
  that left a bare positional. The nested format! for the pkdns URL becomes a
  resolver_url local -- removing its & alone just trades the lint for
  format_in_format_args.
- sort_by(|a, b| b.k.cmp(&a.k)) -> sort_by_key(|x| Reverse(x.k)) in podcast's
  episode list and snippets' list. Both keys are Copy (Timestamp, and
  Option<Timestamp>), so this is not the clone-per-comparison version of that
  rewrite. Ordering is unchanged, None included: it is Option's smallest value
  and so still lands last once reversed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gkup9bGFrnEaBVG8TQTJrS
2026-08-24 13:02:12 -07:00