Skip to content

feat(flatpak): a new window replaces a notesd of an older build (plan 0008, G3) - #106

Merged
bketelsen merged 9 commits into
mainfrom
feat/g3-update-replaces-notesd
Oct 28, 2026
Merged

bketelsen merged 9 commits into
mainfrom
feat/g3-update-replaces-notesd

Conversation

@frostyard-machines

Copy link
Copy Markdown
Contributor

Plan 0008, gap G3: after flatpak update, the notesd that runs stays at the old build until logout, and new windows use it. This PR makes a new window replace it, only forward. Design: ADR-0032 (Proposed), after frostmail ADR-0046 and frostmail#126, which built the same for maild.

What changes

  • Contract (schema/rpc/rpc.yaml, additive in protocol 1): rpc.hello gains an optional build (the app-commit of [Instance] in /.flatpak-info); new rpc.shutdown, callers local only (lodge's callers get methodNotFound).
  • notesd: -build prints the instance's build; rpc.shutdown answers, then stops notesd as SIGTERM does (requests in hand are cancelled and awaited; sync, vaults, store and lock stop in order; exit 0).
  • notesctl: hello --build; shutdown (one 30 s deadline; returns when the socket is silent and the data directory's lock is free).
  • Launcher (packaging/flatpak/frostnotes.sh): every wait is bounded (timeout); when a notesd answers, it compares notesctl hello --build with flatpak-spawn --latest-version notesd -build, runs notesctl shutdown when they differ, and starts notesd with flatpak-spawn --latest-version. The portal-failure message is unchanged (G5 reads it).
  • Smoke test: a notesd of build A is replaced by one of build B, and a note written before survives; a notesd of the latest build is kept.
  • Docs: ADR-0032, design/app.md (The Flatpak, "Updates"), specs/rpc-protocol.md, specs/lodge-app.md, plan 0008 G3 status, the index.

No write is lost

A write cut by the stop is whole or absent (atomic file write, one transaction; a file that reached the disk is indexed by the next scan). The app keeps unsaved text, reconnects and saves again on the same base; a new test in internal/vault/write_test.go shows that a repeated write on the same base merges with no conflict.

Limits

  • The update that brings this change still keeps the old notesd until logout (it has no rpc.shutdown); later updates use it.
  • No automated test reaches a real portal: plan 0008's Phase 3 item 5 checks it on a desktop with the second release.

Checks

  • make check passes (under umask 022; TestFileRefusesReadableFile fails under umask 077 on a clean main too).
  • go test -race on cmd, rpcserver, vault; sh -n and shellcheck 0.11.0 on both scripts; the smoke test passed on the host with built notesd and notesctl.
  • The app is not changed; Vitest and the Flatpak build run in CI.

ADR-0032 is Proposed: merging this PR accepts it, or Brian says otherwise.

An update replaces the running notesd: rpc.shutdown (local callers) answers and then
stops notesd as SIGTERM does; rpc.hello names the Flatpak build (app-commit of
.flatpak-info); notesd -build prints it; notesctl hello --build and notesctl
shutdown (bounded, waits for the socket to go silent and the data lock to free).
…(G3)

The launcher compares notesctl hello --build with notesd -build run through
flatpak-spawn --latest-version, stops a notesd of another build with notesctl
shutdown, and starts the latest. Every wait is bounded. The smoke test covers
the replacement, a kept notesd of the latest build and an unknown latest build.
Design (the Flatpak: updates), specs (rpc.shutdown, hello's build) and plan 0008's G3 status.
Test that a write repeated after a lost answer changes nothing.
…oss-review)

A command substitution waits for EOF on its pipe, and flatpak-spawn hands the
pipe to the portal and the new sandbox, which the timeout does not kill. The
query now writes to a temporary file in the state directory. The smoke test
adds a query that leaves a detached process on its output.
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Oct 28, 2026
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Cross-review: reviewer openai/gpt-6.1-sol; coder github-copilot/claude-sonnet-5.5 (ADR-0032 and 2 small fixes by github-copilot/claude-opus-5.5). Initial review at 072ef9b in 2 batches (code, docs): 4 blocking points (the latest-build query could block the window on a portal-held pipe; a timing-dependent test; the docs overstated what a stop does to requests in hand; a missing back-link), all fixed. Re-review 1 at 86b0edd: Ready, 1 low point (smoke-test PID race), fixed. Re-review 2 at d830c58: Ready, Blocking: none; 1 low point left: if the fake's detached process takes over 5 s to start, the test fails and a sleep 60 may outlive it. CI green at d830c58.

@bketelsen
bketelsen merged commit d433dc0 into main Oct 28, 2026
9 checks passed
@bketelsen
bketelsen deleted the feat/g3-update-replaces-notesd branch October 28, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants