Allow network commands to select stored names

Leaving a configured network required copying its opaque id even when its
name identified exactly one saved network. Resolve exact, case-sensitive
names from the existing local state alongside full ids and unique id prefixes.
Use the shared resolver for leave, stop, start, secret and broadcast so the
same selector has the same meaning throughout the CLI. IPC and storage still
operate on the resolved id; release and offline-removal behavior are unchanged.

Refuse ambiguous names and name/id-prefix collisions before any mutation,
listing matching names and full ids without secrets. Full ids take precedence
to provide a definitive escape from ambiguity. Preserve copied id ellipses
without stripping literal ellipses from network names.

Update help and examples. Make administrator-friendly, predictable CLI behavior
a core requirement in AGENTS.md, including actionable errors and no guessing
which resource a destructive command should affect.

Validation on Windows: cargo fmt --all -- --check and workspace/all-target
Clippy with -D warnings passed. Release workspace/all-target tests: 318 passed,
including real-process online/offline leave-by-name, preservation of other
networks, ambiguous/unknown selectors, and consistent name selection across
commands. Two existing Windows SQLite wipe failures were explicitly skipped
(a_wipe_removes_everything_and_the_next_start_is_a_stranger and
wiping_twice_is_as_ordinary_as_wiping_once). The public-DHT smoke test and
forwarding benchmark remain ignored by default. Tests use isolated state;
the user's running agent and configured networks were not changed.
This commit is contained in:
ab committed 2026-09-22 19:00:08 +03:00
1 parent c724981bfd
commit db9015b26c
6 files changed
+261 -75

No files matched your search

+6 -4
View File
@@ -8,14 +8,16 @@ control session. It is not a network-wide vote or signed shared configuration.
```sh
tsunagi join -n games --no-broadcast
tsunagi join -n games --broadcast
tsunagi network broadcast <network-id-or-prefix> off
tsunagi network broadcast <network-id-or-prefix> on
tsunagi network broadcast <network-id-or-prefix>
tsunagi network broadcast games off
tsunagi network broadcast games on
tsunagi network broadcast games
```
Joining without either flag preserves the saved choice. The `network broadcast`
command can change a running network immediately or configure it while the
agent is stopped. `status` reports the local setting. There is no global `up`
agent is stopped. It accepts the exact network name, full id or a unique id
prefix; ambiguous selectors list candidates without changing anything.
`status` reports the local setting. There is no global `up`
override: starting the agent preserves every network's independent policy.
## Delivery
+5
View File
@@ -108,6 +108,11 @@ with no secret invents one, prints it in full and prints a line the other
side can paste unchanged; a bare name this device already knows resumes
that network instead of inventing another of the same name; and a network
can be stopped and started again with its secret and its place intact.
Network selection accepts exact names consistently across commands. Leave-by-name
is tested with a live agent and with offline state, preserving other networks;
duplicate and unknown names change nothing and full ids resolve ambiguity.
Selector unit tests cover case-sensitive names, Unicode/ellipsis names, copied
id prefixes and collisions between names and ids without revealing secrets.
`crates/tsunagi-cli/tests/dns_service.rs` runs the real binary: the resolver
comes up with no interface to attach it to, the listener is not rebuilt on