Skip to content

fix(updates): clear remote failures once the target is current - #548

Merged
nixuuu merged 1 commit into
devfrom
fix/stale-remote-update-failure
Nov 12, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/stale-remote-update-failure

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

An interrupted remote app update can leave a failed journal and a stopped Update all run visible after the target is already current. Reconcile those records with the target's version or a completed Up to date check, so obsolete failures stop driving the Updates header and sidebar badge.

Restart recovery accepts the requested version or any newer SemVer version, including an interrupted journal saved before restarting. Returning on the old version remains a failure. Relevant failures offer Request again and Dismiss on web and mobile. Dismissals require the current request or run ID, remain owner-scoped, and survive gateway/app restarts. Dismissing a stopped run also acknowledges its matching app failure; it never acknowledges a newer request.

Reconciliation persists the result without starting queued later steps. Linked-computer action responses replace cached snapshots, and clients reject reads started before a newer action. Contracts are additive; frozen canopy.update.v1 is unchanged. Mobile edits are TypeScript only, with no native configuration changes.

Caller audit: web popover, linked-computer settings, mobile rows and stopped-run dismissal preserve the request IDs returned in snapshots. Electron has no separate renderer dismissal IPC; control commands carry the target-local ID unchanged to its journal. Linked-app dismissal now also accepts a plain UUID scoped to the explicitly selected direct peer of this owner. Existing qualified IDs retain their suffix, so another computer's ID is rejected; the target still checks its exact current failed request. Integration coverage exercises both forms, mismatched requests, foreign computer suffixes, cache replacement and the target journal acknowledgement.

Validation

  • Added gateway/desktop integration coverage for equal/newer version recovery, old-version failure, completed Up to date checks, retry success, durable owner-scoped dismissal, linked snapshot replacement, and gateway replacement without launching later steps. Updated the existing orchestration fixture to report the installed version on success. No web UI tests added.
  • Rebased onto the requested origin/dev (f7ad51cc). bun install and bun run gen:check passed with a clean working tree. Changed-file lint/formatting and whitespace review passed. Static self-review covered persistence, request identity, owner boundaries, restart classification, cache ordering, stopped-run safety, and copy.
  • Focused local verification passed: bun test tests/integration/stale-app-updates.test.ts tests/integration/desktop-updates.test.ts tests/integration/update-center.test.ts — 27 pass, 0 fail, 139 assertions. Fixtures ran sequentially. The linked-computer suite stays on CI because it needs two gateways. The maintainer explicitly requested no local full check:tmp; full static/typecheck/test/build validation runs in GitHub CI.
  • Real-browser review passed at 1280×800 and 390×844 in light/dark, with short, typical and long names. Reviewed the production sidebar/popover using controlled snapshots: a relevant failure retains Request again and Dismiss plus the other row; equal/newer target versions and a reconciled stopped run remove the old failure, header and red badge. Clicking row Dismiss through the real client request path preserved the qualified ID and replaced the snapshot using a mocked acknowledgement. Backend durability/ownership were verified separately by real gRPC integration tests. The web shell intentionally had no live gateway; its connection warning/502s were expected fixture-environment noise. No web UI test suite was added. Browser tab and local web server were stopped after review.
  • EAS production-profile fingerprints match the dev baseline on both platforms: iOS 6ddec9ef559ee0095ac33e94ff9418a942053b17; Android 5f6eae3ab278f1cd543e9ed763f923a319b65ec9. Mobile remains JS/TS-only; no native runtime change.
  • CI log follow-up kept rejected downgrades as failures, restored refreshes after replacing a linked action snapshot, and corrected the linked/request and persisted-settings test setup. Linked-app dismiss accepts both ID forms while retaining foreign-target and stale-request rejection.

Copy audit — docs/copy.md §8

Before → after Reason
Failure with no acknowledgement → Request again and Dismiss Offer recovery and acknowledgement while keeping other update rows visible.
Generic update icon label → Request update again on {computer name} for a failed request Give the retry icon a concrete accessible action.
No resolved/dismissed result → Resolved and Dismissed in mobile history Explain terminal results without protocol terms.
No dismissal precondition → Choose the current failed update to dismiss. / Choose the current stopped updates to dismiss. State the action when the selected request is obsolete.
No dismissal outcome → The app update was dismissed. Request it again to continue. / Pair this desktop app again to dismiss its update. Explain the state and next action in plain English.
  • New text uses sentence case, plain glossary terms, imperative actions, and the sentence-length limits. Action labels/statuses have no trailing punctuation; sentences have periods.
  • Error messages name the condition or the required action. Existing restart confirmation is reused. No new empty state, external-data warning, or humorous copy is introduced.
  • Each action and outcome has one purpose. No new explanatory copy repeats a badge or tooltip. Important information stays visible or in existing expandable details.
  • Meaning does not depend on red text or an icon alone: failures retain text, retry icons have labels, and Dismiss has a visible label.
  • Short/typical/long-name checks at desktop/phone widths and light/dark visual review passed. Names truncate cleanly, error text wraps, recovery actions remain available, both rows stay visible and there is no horizontal overflow.

Attribution

The exact-version restart classification was introduced by #70 (16648d37b), and #210 (155406fc7) introduced the linked-app orchestration that retains the stopped result. Both predate #536; #536 is context rather than the introducing change.

Fixes: #70
Fixes: #210
Related: #536

@nixuuu
nixuuu force-pushed the fix/stale-remote-update-failure branch 4 times, most recently from 16c5904 to 73cf6be Compare November 12, 2026 08:52
Reconcile desktop journals, persisted gateway history and client snapshots with current versions or completed feed checks. Add durable owner-scoped dismissal and restart integration coverage.

Fixes: #70
Fixes: #210
Related: #536
@nixuuu
nixuuu force-pushed the fix/stale-remote-update-failure branch from 73cf6be to ae8b652 Compare November 12, 2026 11:55
@nixuuu
nixuuu marked this pull request as ready for review November 12, 2026 12:02
@nixuuu
nixuuu merged commit f76cfb2 into dev Nov 12, 2026
11 checks passed
@nixuuu
nixuuu deleted the fix/stale-remote-update-failure branch November 12, 2026 12:05
nixuuu added a commit that referenced this pull request Nov 12, 2026
An update or restart can surface an authentication failure as “Pair
again” even when the saved computer identity has not changed. Reconnect
now treats RPC authentication failures as retryable and requires
repeated, locally verified TLS pin mismatches before requesting new
trust. A successful handshake with the saved identity clears stale
pairing state.

## Investigation

- The dial catch classified **every**
`ConnectError(Code.Unauthenticated)` as a pin mismatch. That includes
invalid certificate validity, a peer rejecting the client pin, and hello
validation; on a manual route it persisted `pairing_required`, and on
LAN it deleted the route. This behavior exists in the original linking
implementation (#13), before the reported release range.
- Reviewed `v0.2.0-nightly.120..v0.2.0-nightly.137` and the `.133` →
`.137` diff, including #547, #548, #559, #562, #565, #566 and #546. The
full desktop hello grew from 32 capabilities to 33 in #559; both
releases reject more than 32 as `Unauthenticated: Invalid computer
identity` after pinned TLS succeeds. Merged #574 fixes this capability
overflow, including compatibility with the older validator. This branch
is rebased onto that fix in `dev`. Full source evidence:
#573 (comment).
- Identity and the 20-year certificate are persisted in
`computer_identity`; the private key uses the existing encrypted secrets
key. Desktop keeps the same Canopy data directory, database,
app/keychain name and `secrets.enc` across versions and channel changes.
Keychain/decryption failure stops startup rather than replacing the
identity. Reinstalling while preserving that data preserves trust;
deleting it creates a new identity.
- Production starts computer links, including loading identity and
peers, before opening Network access. There is no demonstrated
listener-before-store race in that path. The new readiness guard also
makes an early or stopping link service explicitly return `Unavailable`.
- `manual` means entered by the user, including a LAN/Tailscale address;
it is separate from the network's address type. A bad manual path must
not override another route or an incoming connection proving the saved
pin. The capability-count rejection is source-proven for the reported
version pair's full desktop configuration; incident logs would still be
needed to attribute every earlier report or explain successful
re-pairing.

## Changes

- Use a local `CertificatePinMismatch` signal emitted only after TLS
proof of possession and validation of a different self-signed
certificate. Override ConnectError's inherited structural
`Symbol.hasInstance` check so ordinary RPC errors cannot impersonate
this local class. Without this override the new LAN test correctly
caught a real route-deletion bug, not test timing. Invalid/expired
certificates remain rejected without declaring an identity change.
- Exhaust routes first. Require the same different certificate at the
same manual route in two consecutive failed rounds. A matching pinned
TLS connection or ready incoming link outweighs stale addresses. Only a
verified pin mismatch removes a discovered LAN route. Saved pins are
never replaced automatically.
- Clear confirmation evidence after pinned TLS verification, a
successful handshake, explicit pairing, route edits and unlink. Existing
successful handshake recovery also clears a persisted `pairing_required`
after restart.
- Use the shared reason “{name}'s identity changed. Pair again to trust
it.” for linked computer availability and app updates, including the
relay's name when its identity changed. Remove the contradictory
automatic-retry explanation for that state. Add stable auth-failure
classifications to diagnostics without logging certificates, keys,
addresses or RPC payloads.
- Document persistence and recovery. No proto changes, protocol bump or
migration.

## Regression coverage

Added gateway↔gateway integration scenarios using independent databases
and real TLS listeners:

1. Repeated startup `Unauthenticated` on manual and LAN routes preserves
trust and resumes; verify the LAN route remains after each attempt. RPC
error text cannot impersonate a local pin mismatch, and failed TLS
connections cannot confirm a manual route's identity change.
2. An early listener returns `Unavailable` for both `Pair` and `Connect`
until ready.
3. Both gateway/core restarts reuse persisted identities/certificates
and reconnect; a protocol-1 `.133` hello without new capabilities links
with a `.137` hello and resumes after upgrading.
4. A real new key requires confirmed pairing, receives no RPC, never
replaces the pin, and has consistent availability/update explanations.
5. A persisted stale pairing state heals after restart; a valid
alternate route outweighs a stale manual address with another key.

The older-version scenario exercises the compatible wire
hello/capability set, not archived app binaries. Installer and OS
keychain behavior was inspected in source, not exercised on
macOS/Windows.

## Validation

- After maintainer clearance, ran only the two authorized test files,
sequentially, at `nice -n 19`, using `TMPDIR=/var/tmp` and `bun run
check:tmp`: `linked-pairing-recovery.test.ts` **10 pass**,
`linked-capability-compatibility.test.ts` **3 pass**. Both
temp-directory checks passed. The original LAN failure reproduced before
the fix (8 pass / 1 fail); the strengthened assertion confirmed deletion
immediately after the first auth failure.
- Changed-file formatting and lint passed; `git diff --check` is clean.
Earlier dependency install and repository formatting/lint checks passed
before the original push.
- CI validates generation, full typechecking, all test shards and builds
for the rebased head. Browser verification remains pending; the UI
change reuses existing components and only changes status explanations.

## Copy audit (§8)

“{name} must be paired again” / “Link it again…” / “unavailable, trying
again automatically” → “{name}'s identity changed. Pair again to trust
it.” The text states the verified problem and the explicit trust action,
uses two short sentences and avoids TLS jargon. The compact action badge
remains “Pair again”. Names are interpolated as whole values and
existing wrapping/layout remains in place; short/long-name checks at
desktop/phone widths have not been run yet.

Related: #13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant