Files
lanspread/IMPL_DECISIONS.md
T
ddidderr e711cf3454 fix(peer): settle current-protocol local state cleanup
The follow-up backlog had drifted into three settled peer/runtime issues: the
legacy game-list fallback contradicted the one-wire-version policy, the Tauri
shell still re-derived local install state from disk after peer snapshots, and
`Availability::Downloading` existed even though active operations are already
reported through a separate operation table.

Remove the legacy `AnnounceGames` request and fallback service. Discovery now
ignores peers that do not advertise the current protocol and a peer id, and
library changes are sent through the current delta path only. This keeps the
runtime aligned with the documented current-build-only interoperability model.

Make peer `LocalGamesUpdated` snapshots authoritative for local fields in the
Tauri database. The GUI-side catalog still owns static metadata such as names,
sizes, and descriptions, but downloaded, installed, local version, and
availability now come from the peer runtime instead of a second whole-library
filesystem scan. Snapshot reconciliation also pins the missing-begin and
missing-finish lifecycle cases in tests.

Collapse availability back to the settled `Ready` and `LocalOnly` states.
Aggregation now counts only `Ready` peers as download sources, and the frontend
no longer carries a dead `Downloading` enum value.

The core peer also exposes the small non-GUI hooks needed by scripted callers:
startup options for state and mDNS, a local-ready event, direct connection, peer
snapshots, and an explicit post-download install policy. Those hooks reuse the
same current protocol path and do not add compatibility shims.

Test Plan:
- `git diff --check`
- `just fmt`
- `just clippy`
- `just test`

Refs: BACKLOG.md, FINDINGS.md, IMPL_DECISIONS.md
2026-05-16 18:32:24 +02:00

37 lines
2.3 KiB
Markdown

# Implementation Decisions
- Added a `just test` recipe so unit tests can be run through the repository's
required `just ...` command surface instead of invoking `cargo test`
directly.
- Renamed the frontend success event to `game-install-finished`; the old
unpack name no longer matched the transactional install/update lifecycle.
- Implemented watcher rescans by reusing the existing `.lanspread/library_index.json`
cache and updating a single game entry in that index. This satisfies the
per-ID optimized rescan requirement without adding a second cache format.
- Split full startup recovery from ordinary settled refreshes. Startup and real
`SetGameDir` changes run recovery plus a scan; install/update/uninstall
completion only rescans the affected game after operation tracking has been
cleared.
- Rejected path-changing `SetGameDir` while operations are active. Same-path
refreshes are allowed and deliberately skip full recovery so they cannot sweep
download transients for in-flight work.
- Kept a separate `active_downloads` cancellation-token map next to the single
`active_operations` table. The operation table is the authoritative state for
gates; the token map is only cancellation plumbing for in-flight downloads.
- Treated a downloaded-but-not-installed game as immediately installable from
Tauri by sending `PeerCommand::InstallGame` directly. A not-downloaded game
still uses `GetGame`, and the peer auto-installs after the sentinel commit.
- Removed the dead internal `PeerCommand::UpdateGame` path. The UI update button
now sends `FetchLatestFromPeers`, which skips local manifest serving and asks
latest-version peers for fresh file metadata before the normal download and
update transaction runs.
- Removed the unreachable `Availability::Downloading` protocol value. Active
operations are reported separately, and local summaries emit only settled
availability.
- Threaded availability through the UI-facing `Game` payload so `LocalOnly`
rendering follows backend state instead of reverse-engineering it from
`installed && !downloaded`.
- Removed Tauri's parallel whole-library filesystem scan. The UI database keeps
bundled catalog metadata, while peer `LocalGamesUpdated` snapshots now own
`downloaded`, `installed`, `local_version`, and `availability`.