Client: one Rust client for every app, slice 1 (#426) #481

Open
kayg wants to merge 2 commits from issue/426-client-2 into dev
Owner

For #426, N7. This adds the shared Rust device client and proves the first slice on Linux. The CLI is calternal-client because the existing server binary is already calternal.

The ADRs are:

  • 0040: One Rust client for every app. Rust owns the Installation session, SQLite store, offline queue, journal sync and yrs editing; UniFFI exposes async calls to thin adapters.
  • 0041: macOS uses Mac Catalyst, amending 0009.
  • 0042: Apple platforms 26.0+, with apps/ios, apps/watchos, apps/macos and packages/apple.

The client API is:

  • Client::open(server, database), begin_login(), finish_login(device_code, device).
  • list_notes(limit, offset), resolve_note(id_or_title), show_note(id_or_title), append_note(id, text).
  • sync(), next_changes(), pending_count(), pending_note_ids().
  • Owned NoteSummary, Change and DeviceCode records and typed ClientError values cross UniFFI.

CLI commands are login, notes list, notes show, notes append and watch. List reads are local; notes list --sync first catches up. Device sign-in adds start, approve and token routes behind the existing auth crate, plus a browser approval page. Each CLI gets a revocable Installation token.

SQLite commits yrs state and pending work before sending. The client retries state-vector differences and clears pending work only after the server's durable acknowledgement. Tests cover concurrent writers, cancellation, reconnect, large documents, per-user sign-in isolation and a deleted note whose queued edit must remain recoverable. The existing server test helper now owns child cleanup before its first readiness probe and retries TCP resets only during health checks.

On this shared Linux host, with 100,000 local note rows and the default page of 100, debug build:

  • Library: p50 0.250 ms, p95 0.376 ms, maximum 2.188 ms over 100 warm samples.
  • CLI, including startup and output: p50 6.182 ms, p95 12.990 ms, maximum 17.289 ms over 30 warm samples.

These measure the local page, not initial download or printing all 100,000 notes. Initial sync replays the retained journal to repair the server's asynchronous list projection. An authoritative snapshot cursor can remove that cost in a later server slice.

Validation: cargo fmt --all --check; cargo clippy --workspace --all-targets -- -D warnings; cargo test --workspace (460 passed, 3 ignored); explicitly named real_server_login_list_read_append and offline_append_restarts_and_syncs_once; explicit 100k performance test; UniFFI Swift generation on Linux. Generated Swift, header and module map stay in a temporary directory. The optional swift-format executable was unavailable.

Queued edits whose note is deleted or whose lineage changes remain readable by id. Explicit sync reports the conflict after updating other notes; the live stream continues. A richer recovery UI and one persistent socket for editor rooms are recommended next slices. No Swift app is added here.

A rendered Chromium proof also passes: real browser passkey setup, approval of the CLI Installation, local CLI list/read, and a CLI append appearing in the actual web editor without reload; API readback matches. The expected pre-sign-in /api/v1/actions 401 is classified, with no page errors or other console errors. The ASCII marker was used because this host's Skia font fallback aborts on the crab emoji; Unicode appends pass Rust/server/peer tests, and browser emoji rendering remains unverified here.

Replaces #480. Only change: ADR 0041 is now proposed. The macOS toolkit is decided by a Catalyst vs AppKit spike (kayg).

🤖 Generated with Claude Code

https://claude.ai/code/session_019QGa6qjALuHyi8H1naGp6b

For #426, N7. This adds the shared Rust device client and proves the first slice on Linux. The CLI is calternal-client because the existing server binary is already calternal. The ADRs are: - 0040: One Rust client for every app. Rust owns the Installation session, SQLite store, offline queue, journal sync and yrs editing; UniFFI exposes async calls to thin adapters. - 0041: macOS uses Mac Catalyst, amending 0009. - 0042: Apple platforms 26.0+, with apps/ios, apps/watchos, apps/macos and packages/apple. The client API is: - Client::open(server, database), begin_login(), finish_login(device_code, device). - list_notes(limit, offset), resolve_note(id_or_title), show_note(id_or_title), append_note(id, text). - sync(), next_changes(), pending_count(), pending_note_ids(). - Owned NoteSummary, Change and DeviceCode records and typed ClientError values cross UniFFI. CLI commands are login, notes list, notes show, notes append and watch. List reads are local; notes list --sync first catches up. Device sign-in adds start, approve and token routes behind the existing auth crate, plus a browser approval page. Each CLI gets a revocable Installation token. SQLite commits yrs state and pending work before sending. The client retries state-vector differences and clears pending work only after the server's durable acknowledgement. Tests cover concurrent writers, cancellation, reconnect, large documents, per-user sign-in isolation and a deleted note whose queued edit must remain recoverable. The existing server test helper now owns child cleanup before its first readiness probe and retries TCP resets only during health checks. On this shared Linux host, with 100,000 local note rows and the default page of 100, debug build: - Library: p50 0.250 ms, p95 0.376 ms, maximum 2.188 ms over 100 warm samples. - CLI, including startup and output: p50 6.182 ms, p95 12.990 ms, maximum 17.289 ms over 30 warm samples. These measure the local page, not initial download or printing all 100,000 notes. Initial sync replays the retained journal to repair the server's asynchronous list projection. An authoritative snapshot cursor can remove that cost in a later server slice. Validation: cargo fmt --all --check; cargo clippy --workspace --all-targets -- -D warnings; cargo test --workspace (460 passed, 3 ignored); explicitly named real_server_login_list_read_append and offline_append_restarts_and_syncs_once; explicit 100k performance test; UniFFI Swift generation on Linux. Generated Swift, header and module map stay in a temporary directory. The optional swift-format executable was unavailable. Queued edits whose note is deleted or whose lineage changes remain readable by id. Explicit sync reports the conflict after updating other notes; the live stream continues. A richer recovery UI and one persistent socket for editor rooms are recommended next slices. No Swift app is added here. A rendered Chromium proof also passes: real browser passkey setup, approval of the CLI Installation, local CLI list/read, and a CLI append appearing in the actual web editor without reload; API readback matches. The expected pre-sign-in /api/v1/actions 401 is classified, with no page errors or other console errors. The ASCII marker was used because this host's Skia font fallback aborts on the crab emoji; Unicode appends pass Rust/server/peer tests, and browser emoji rendering remains unverified here. Replaces #480. Only change: ADR 0041 is now *proposed*. The macOS toolkit is decided by a Catalyst vs AppKit spike (kayg). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_019QGa6qjALuHyi8H1naGp6b
Client: one Rust client for every app, slice 1 (#426)
Some checks failed
CI / server (pull_request) Successful in 29s
CI / rust (pull_request) Successful in 3m4s
CI / web (pull_request) Failing after 47m19s
81491beee9
ADR 0041: macOS toolkit is proposed, decided by a Catalyst vs AppKit spike (#426)
Some checks failed
CI / server (pull_request) Successful in 26s
CI / rust (pull_request) Successful in 1m59s
CI / web (pull_request) Failing after 46m56s
20a23d9ff5
kayg: not set in stone; no mobile UI on the desktop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QGa6qjALuHyi8H1naGp6b
Author
Owner

stale? #931 leaves revival of the Rust client slice undecided; there is no evidence that the requested client work is complete.

stale? #931 leaves revival of the Rust client slice undecided; there is no evidence that the requested client work is complete.
Author
Owner

housekeeping #1009: needs-decision.

Rust client direction remains undecided in #931; no live source branch matches the PR head. The client slice is absent from dev, so this is not a landed closure.

original head: 20a23d9ff5b45b6c310266022e784dcb8197627b. against dev cd7f84432febfc63b788fbb9b9f9950452982d74, git cherry reports 2 unmatched and 0 equivalent patches. the landing audit lists each candidate missing commit and stable patch match in pr-481.md; unmatched patches can include superseded behavior.

left open, source branch unchanged. no rebase or new test claim for this decision lane.

housekeeping #1009: needs-decision. Rust client direction remains undecided in #931; no live source branch matches the PR head. The client slice is absent from dev, so this is not a landed closure. original head: `20a23d9ff5b45b6c310266022e784dcb8197627b`. against dev `cd7f84432febfc63b788fbb9b9f9950452982d74`, git cherry reports 2 unmatched and 0 equivalent patches. the [landing audit](https://git.kayg.org/attachments/fe3c09dc-dea3-47a0-92e2-b44a777083e5) lists each candidate missing commit and stable patch match in `pr-481.md`; unmatched patches can include superseded behavior. left open, source branch unchanged. no rebase or new test claim for this decision lane.
Some checks failed
CI / server (pull_request) Successful in 26s
CI / rust (pull_request) Successful in 1m59s
CI / web (pull_request) Failing after 46m56s
This pull request has changes conflicting with the target branch.
  • Cargo.lock
  • crates/auth/src/lib.rs
  • docs/adr/0040-one-rust-client-for-every-app.md
  • docs/adr/README.md
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'issue/426-client-2:issue/426-client-2'
git switch 'issue/426-client-2'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'dev'
git merge --no-ff 'issue/426-client-2'
git switch 'issue/426-client-2'
git rebase 'dev'
git switch 'dev'
git merge --ff-only 'issue/426-client-2'
git switch 'issue/426-client-2'
git rebase 'dev'
git switch 'dev'
git merge --no-ff 'issue/426-client-2'
git switch 'dev'
git merge --squash 'issue/426-client-2'
git switch 'dev'
git merge --ff-only 'issue/426-client-2'
git switch 'dev'
git merge 'issue/426-client-2'
git push origin 'dev'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!481
No description provided.