Repository navigation
test(relay): the new-PC press check polls for a join instead of a fixed wait - #4547
Conversation
…ed wait The fixed-waits ratchet (#4537) and this script (#4540) merged side by side, so main's conventions test fails on the script's one marked fixed wait. The quiet period before the press is now a bounded poll that fails on the first join or relay connection, which also reports sooner. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
Merged through main is red (1d71a71), and this PR's head passes the failing checks: allowed as a main fix (Fast checks). Test-only fix for main's red conventions test (the #4537 ratchet met #4540's fixed wait). CI green on the PR; no review requested for a test-only change. |
…integration lane (#4552) ## What Test bundle B6 of the test-suite plan (T8): `server/machine-profile.contract.test.ts` (105 tests, ~172 s in CI) alone decided when the integration lane ended. It is split, move-only, into two files of about equal runtime: - `server/machine-profile-lifecycle.contract.test.ts` (42 tests): start and refusal rules, state-folder ownership, folder and socket safety, an ordinary server beside a profile. - `server/machine-profile-api.contract.test.ts` (63 tests; git sees it as the rename): herdr socket selection, `/api/session` and `/api/machines`, who can reach the profile, how failed herdr calls are worded. - `server/machine-profile.test-helpers.ts`: the setup both halves use, moved unchanged with `export` added (like `server/websocket.test-helpers.ts`). Helpers only one half uses stay in that half. - `scripts/ci-test-timings.json`: the old entry (152) becomes `machine-profile-api` 77 and `machine-profile-lifecycle` 67, by the measured ratio. `scripts/ci-tests.ts` already routes every `*.contract.test.ts` to the integration suite. - `server/conventions.test.ts`: the "start the server only through entryCommand" rule skips `*.test-helpers.ts` as it already skips `*.test.ts`. Moving `launch()` into the shared helper tripped it; a test helper runs from a checkout and is never compiled into the binary, which is what the rule protects. No production code changes. ## Evidence **Same tests, same results.** The original file on the unchanged base (origin/main 1d71a71) through `bun run check run` (its own herdr session), against both new files run at the same time, each on its own session: | | pass | skip | fail | tests | |---|---|---|---|---| | original file | 100 | 1 | 4 | 105 | | both new files | 100 | 1 | 4 | 105 | The (result, test name) pairs match exactly. The skip is the Windows-only test. The 4 failures fail identically on the base and only on this PC: herdr session discovery skips sockets under the required `TMPDIR` in `~/.cache` (`throwawayPath`); they pass in CI (main run 45279571403 had 0 failures). **Time (local, loaded P620)** | Run | Seconds | |---|---| | original file alone | 188.4 | | lifecycle half | 83.4 | | api half | 96.0 | | both halves at once | 96.1 | **Integration lane.** Replaying main run 45279571403's per-file times through the runner's longest-first queue (8 shards): before 171.7 s (the real run ended at 172.0 s, with the old file alone keeping shard 1 busy for 171.7 s while the other shards ended about 161.6 s); after about 162.0 s. The floor is now the total work over 8 shards (161.8 s); the next longest file is `server/pending-input.contract.test.ts` at 154.1 s, so no single file decides the lane's end any more. This PR's own Integration job gives the measured after-time. **Move-only.** `git diff --color-moved=zebra origin/main...HEAD` marks 535 of 572 added and 535 of 553 removed lines as moved; the rest are imports, `export` keywords, one copied `afterEach` cleanup line, a comment on where the Windows test lives, the two timings entries and the conventions filter. No test body changed. ## Validation - `bun run typecheck`: ok. `scripts/ci-test-timings.test.ts`, `server/conventions.test.ts`: pass. - `bun run check fast` (P620, 225 s): typecheck, build, generated files ok; unit 24,886 pass, 160 skip, **1 fail**: `scripts/conventions.test.ts` "waits marked fixed" on `scripts/relay-new-pc-press-regression.ts:180`, which fails on `origin/main` itself (1d71a71) and is fixed by #4547; this PR does not touch that file. The branch takes main in once #4547 lands. - Integration lane: not run whole locally (the 4 discovery tests fail on this PC on the base too); the two halves were timed in parallel above and this PR's Integration job runs them in CI.
…pe, worktree focus and agy temp links (#4550) ## What Test bundle B5 of the test-suite plan: regression tests for four fixes that went in without one (two of them regressed before). Tests only; no production file changes. | # | Fix | Test | |---|---|---| | A1 | #4159 `scripts/build-cache.ts` re-checks the cache after taking the lock | `scripts/build-cache.test.ts`: two real `build-cache.ts` jobs on one key, ordered by gate files (`fs.watch`, no sleep). Job 2 misses the cache, meets job 1's lock, and is paused just before its retry; job 1 stores its build and releases. Both exit 0, one build in total, job 2's `dist/` restored from the cache. | | A2 | #3028 Changes keeps its scope when Files moves to another pane/PC | new `src/components/FilesDialog.test.tsx`: render `FilesDialog`, pick Branch, compare with `main`, rerender with another `paneId`, then the stale pane's answer arrives: Branch stays pressed and the stale file is not shown. | | A3 | #1222 the new worktree dialog focuses the Branch field | `src/components/WorktreeDialog.test.tsx`: in create mode focus is on the Branch input with its suggested value fully selected. | | A4 | #2030 agy catalog under a symlinked temp dir (macOS `/var -> /private/var`) | `server/agy.test.ts`: a new row of the WAL-catalog table runs the reader with `TMPDIR`/`TEMP`/`TMP` pointing at a symlink. | ## Evidence: each test goes red when its fix is reverted Each mutation was written into the production file, the test run, and the original bytes restored (sha256 checked; production diff is empty). | # | Revert | Result | |---|---|---| | A1 | `if (owner && restored())` -> `if (false && ...)` (no look under the lock) | red: builds `[1, 1]` instead of `[1, 0]` | | A2 | put back `key={`${machineId}:${paneId}`}` on `<RepoChanges>` (the key cbdcafa removed) | red: scope falls back to Working tree | | A3 | move `ref={first}` from the Branch input to the Name input (pre-#1222) | red: focus and selection on the Name input | | A4 | remove `snapshot = realpathSync(snapshot)` in `server/agy.ts` | red: only the symlinked row fails with `AgyUnavailable`; the other three rows stay green. **This reproduces on Linux too**: SQLite's `SQLITE_OPEN_NOFOLLOW` refuses a path with a symlinked directory component, so Linux CI guards #2030. | ## Validation - `bun test scripts/build-cache.test.ts src/components/FilesDialog.test.tsx src/components/WorktreeDialog.test.tsx server/agy.test.ts`: all new tests pass. - `bun scripts/typecheck.ts`: exit 0. - `bun run check fast` (P620, 241 s): typecheck, build, generated files ok; unit 24,890 pass, 160 skip, **1 fail**: `scripts/conventions.test.ts` "waits marked fixed" on `scripts/relay-new-pc-press-regression.ts:180`, which fails on `origin/main` itself (1d71a71) and is fixed by #4547; this PR does not touch that file. The branch takes main in once #4547 lands. - Browser regressions that name FilesDialog or the worktree dialog (`file-viewer-regression`, `files-panel-demo-regression`, `repo-diff-browser-qa`, `ui-regression`, `phone-worktree-sheet-regression`, ...): not run locally since no component code changes; they run in this PR's Integration and browser job (CI runner image).
…wo unused modules (#4548) ## What Test cleanup, bundle B3 of the test-suite plan: tests that leaned on prose and docs, and two modules nothing uses. - **R1** `scripts/install-ovis-command.test.ts`: drop "does not promise that another ovis is never hidden". It only checked that CHANGELOG lacks a phrase and that the guide has a sentence; no code reads either. The guide's Uninstall command stays covered by running it (the test just above). - **R2** `src/lib/markdownHtml.test.ts`: the parser test read the real README, so a README edit (logo path, width, links) could break a parser test. It now parses a README-shaped HTML header written in the test (centered logo with a width, `<h1>`, badges, a language row with a `.md` file link, a website link). Every parser assertion stays. - **R3** `src/lib/textPreview.test.ts`: the "ordinary document of the load limit's size stays well under the Preview limit" check read the head of the real CHANGELOG, which changes every release. It now builds a changelog of the same size (release headings, wrapped list items with code and links). The first check (short list items past the limit) is unchanged. - **R5** remove `src/lib/koreanParticle.ts` (and its test) and `src/lib/account/deviceKey.ts`: nothing imports them (`registerSigningBytes` lives in `shared/account-records.ts`, which `src/lib/account/service.ts` uses). `src/lib/account/deviceKey.test.ts` stays: it tests the account service path, not that file. The stale `koreanParticle.test.ts` entry leaves `scripts/ci-test-timings.json`. No production behaviour or UI changes. ## Evidence: the rewritten tests still fail when the parser breaks Each mutation applied to the production file, the test file run, then the file restored byte for byte (`git status` clean afterwards). | Mutation | Result | |---|---| | M1 `shared/markdownHtml.ts:129` drops the image `width` | `reads a README's HTML header as centered markdown, never as tag text` fails (1 fail, 5 pass) | | M2 `shared/markdownHtml.ts:86` reads `.md` links as plain text | the README header test and `links only to safe addresses and files` fail (2 fail) | | M3 `src/lib/textPreview.ts` counts one element per character of text | `puts a file of the load limit's short list items past what a Preview draws` fails on the generated changelog (1 fail) | ## Validation - `bun test src/lib/markdownHtml.test.ts src/lib/textPreview.test.ts src/lib/account/deviceKey.test.ts scripts/install-ovis-command.test.ts scripts/ci-test-timings.test.ts`: 73 pass, 0 fail. - `bun run check fast` (P620, 256 s): workflow syntax, generated types/themes, typecheck, build ok; unit 24,884 pass, 160 skip, **1 fail**: `scripts/conventions.test.ts` "waits marked fixed" on `scripts/relay-new-pc-press-regression.ts:180`. That failure is on `origin/main` itself (1d71a71, #4537's new ratchet met #4540's marked wait) and is fixed by #4547; this PR does not touch that file. Once #4547 lands this branch takes main in. - Skipped: browser regressions (no UI or component change) and the integration lane (no server change).
…tion is on, and list a PC's other ways in My PCs (#4543) ## What A device connected to a PC through the Ovis relay no longer moves by itself to a direct carrier (the PC's same Wi-Fi address or its Tailscale address). The relay goes by the relay; the other ways are offered separately. 1. **Direct connections are off by default.** A PC that never chose keeps relay connections on the relay and does not open the direct listener (`server/relay/service.ts` `directEnabled`). 2. **The Settings switch is renamed to what it does.** Settings → Devices and PCs → More settings → Devices and access (where the row already was): label and switch **Direct connection** (ko 직접 연결, ja 直接接続, zh 直接连接), one line under it: off, "Relay connections stay on the relay."; on, "The Ovis app on a phone that reaches this PC on the same Wi-Fi or over Tailscale moves to a direct connection: faster, and this PC listens for it on those addresses." (a browser always stays on the relay). It governs the Tailscale carrier too, so "Same Wi-Fi" is gone from its name; Settings search still finds it by Wi-Fi, Tailscale, LAN, same Wi-Fi or home network in every language (`keywords`). 3. **My PCs lets the person pick the way.** A row saved by several ways (relay + Tailscale/address/SSH, put together by #4511) gets a **More ways** disclosure beside its link: a round chevron button named "More ways to open {name}", `aria-expanded`, closed by default. Open, it lists the other saved ways one per line with `OtherWayButton` (way tag, then Open and the whole host, wrapping after a dot via `atDots`, never cut). Each line opens that way with the checks a row of that way has: a Tailscale way asks whether Tailscale is on and shows the Tailscale-off card when it is not; the way the app keeps open goes back to it. The row's own tap is unchanged (the relay). Rows of one way are unchanged, to the pixel: a row with nothing beside its link spans the whole row, so a row of several does not narrow the others. On a row of saved ways alone (no relay), the way the app keeps open is the one the row shows and goes back to, and More ways lists the rest. #4511's rule holds: an address way never renames, re-states or redirects the relay row; choosing it is an explicit tap on a line that shows its host. Same at 390 px and at 1024 px and wider. Design reference: the Tailscale app's machine view, which lists every address that reaches a machine under that machine, each whole; this folds them under the row in place so My PCs stays one screen. 4. **Nothing else about how a carrier is chosen changes when the switch is on.** The transport race, probes, planned switch and the remote-PC dialer are untouched; their tests now turn the switch on first, as an owner would. ### What "never chose" means `relay/direct.json` has only ever been written by `setDirect`, the `POST /api/relay/direct` handler behind the Settings switch (since #3152, the PR that added it; nothing else writes it). So the file does tell a default from a choice: **no file is no choice**. No extra marker is needed. | `relay/direct.json` | Before | Now | | --- | --- | --- | | missing (new install) | on | **off** | | missing (existing install that only ever had the default) | on | **off** (the change, said in the changelog fragment) | | `{"on":true}` (the owner turned it off, then on again) | on | on | | `{"on":false}` (the owner turned it off) | off | off | | unreadable | off | off | Reading the default writes nothing, so a later change of default still sees "no choice". ## What this closes With the switch off the PC does not listen for direct carriers on its LAN or Tailscale addresses: `DirectCarrier` (`server/relay/direct.ts`), the WebSocket listener behind the gates of `server/relay/direct-gate.ts` on each private IPv4 address and the Tailscale IPv4 address (port 7319 by default), is never constructed, and `AUTH_OK` names no carrier. Verified by the new contract test `direct connections with the relay > bind no listener on a PC that never turned them on` (`server/relay/direct.contract.test.ts`): with the relay online through a real Bun relay and the listener's preferred port fixed to a free port, a WebSocket to that port is refused, `GET /api/health` carries no `direct_exposure`, `GET /api/relay` says `{ on: false, carriers: [] }`, and a phone that offers `direct-carrier` and `direct-tailnet` gets `directCarriers: []`; then, as a positive control, `setDirect(true)` binds that same port and the same WebSocket opens. ## What it costs On the same Wi-Fi, a relay connection is now slower than before (it stays on the relay) unless the person opens the PC by its Tailscale or address way (now one tap away under More ways in My PCs, where the phone app saved it) or turns Direct connection on. Existing installs that never touched the switch lose the direct path after the update; the changelog fragment says so in one sentence. A PC added through the relay to another PC also stays on the relay unless the target PC's owner turned it on (docs/remote-pcs.md). ## Validation - Red first: the four `relay/direct.json` cases and the listener test (`server/relay/direct.contract.test.ts`; 3 red before the change, the explicit-choice case was already green and stays as a guard), the Settings row's words in en and ko (`src/components/RelayPanel.test.ts`), the My PCs disclosure at phone width and wide (`src/components/RelayShell.test.tsx`: lists the other ways with whole hosts, closed at first, opens the chosen way, relay tap unchanged, one-way rows have none, a row of saved ways alone lists the ways its tap does not open, Tailscale off gives the Tailscale-off card). The route mark is unchanged; `src/components/ConnectionRouteMark.test.tsx` passes as is. - `dori heavy relayonly -- bun run check fast`: green (24777 pass, 0 fail). - `bun test server/relay/ server/relay-pc.contract.test.ts src/lib/relay/`: 1058 pass, 0 fail. - Review round (head 13f7681): `dori heavy relayonly -- bun run check fast` green (24779 pass). In the CI runner image, fresh clone of that head: `relay-direct-demo-regression`, the new `my-pcs-ways-regression` (a row of one way keeps its whole width beside a row of several, measured in a real browser at 390 and 1440, and it fails at 304 px against 356 px without the fix; More ways closed at first with its controlled list on the page; whole hosts; Tailscale off gives the card; the row's tap unchanged), `ui-access-regression`, `add-pc-more-relay-regression`, `relay-shell-browser-qa`, `relay-account-pcs-regression`, `relay-offline-reasons-regression`: all exit 0. `my-pcs-ways-regression` is added to `scripts/ci-browser.sh`. - Final head ead9f34 changes only `scripts/my-pcs-ways-regression.ts` (reduced motion instead of a marked fixed wait, which main's new ratchet from #4537 refuses): `bun run check fast` green on it (24779 pass). On a merge of this head with current main, in the CI runner image: `my-pcs-ways-regression` and `relay-new-pc-press-regression` (on main since) pass; main's conventions and browser-lane tests on that merge fail only on main's own fixed wait in `relay-new-pc-press-regression.ts`, which #4547 fixes. - First round: browser regressions in the CI runner image (`herdr-ci-runner:local`, fresh clone from a bundle, `bun run build:shell`, through `dori heavy relayonly`): `relay-direct-demo-regression` (updated: off by default, the new label and both lines, no sideways scroll, 390/1280 light/dark), `ui-access-regression` (relay panel), `relay-shell-browser-qa`, `add-pc-more-relay-regression`: all exit 0. They ran on the first commit of this branch; the amend after them only added the switch-on step to `src/lib/relay/transport.direct.test.ts`. - Skipped: `relay-new-pc-press-regression` is not on main. - Screenshots (390 and 1280, light, before/after): the Settings row off and on, and a My PCs row with the disclosure closed and open, kept locally with the QA reports. ## Known limits - The on line no longer says which networks the PC listens on right now, or "On, but this PC has no home network address to listen on right now": the row carries the one sentence asked for. `GET /api/relay` still lists the carriers, and the header notice on the PC's own address still names the host. - More ways exists only where rows are put together, which is the phone app (a browser has only relay rows). The privacy policy's "Direct connections" paragraph (on by default) changes in a separate PR, #4553, because a merge to main publishes the site at once: that one should merge with the release that ships this. This PR changes a default and a network listener, so it waits for an independent review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…et their waits instead of sleeping (#4554) ## What Test bundle B4 (part) of the test-suite plan: tests that really waited now set the wait, and "nothing happened" checks wait for a signal instead of a sleep. T3 (`scripts/plugin.ts`) and T7 (`server/prompt.ts` clock) are not in this PR. - **T4 + R9, `install.sh` / `scripts/install-star.test.ts`.** The star question's read timeout and the gh watcher's 10 s / 2 s come from `OVIS_STAR_READ_TIMEOUT_SECONDS` (default 20), `OVIS_STAR_GH_TIMEOUT_SECONDS` (default 10) and `OVIS_STAR_GH_KILL_GRACE_SECONDS` (default 2); with none set the installer runs exactly as before. The tests set them small and prove outcomes: with nobody at the terminal the read ends by its timeout (status 142, not an answer or EOF), the install goes on (exit 0) and stars nothing; a gh that hangs or ignores TERM is gone and the install goes on. The wall-clock assertion (read lasted 19-27 s, run under 40 s) and its perl clock stamps are deleted, and so is the source-grep test on the literal `read -r -t 20` (the bash stand-in now recognises the read by its `ovis-star` `$0`; every answered test asserts the exact read status, which is null if the stand-in stops matching). The stubborn gh stand-in sets its TERM trap before writing its pid (with a 1 s watcher TERM could arrive first). - **T5, `scripts/compressed-assets.test.ts`.** Instead of building the whole app (~20-30 s) it runs real `vite.build` with the two production plugins (`compressedAssets()`, `serviceWorkerBuild()`) on a small fixture, `scripts/fixtures/compressed-assets/`: an entry with first-screen JS and CSS, a lazily imported chunk, and `public/sw.js`. Every assertion of the old test stays; added: each `.br` must differ from the other quality's output, so a fixture too small to tell 5 from 11 apart fails instead of passing vacuously. - **R8.** `server/prompt.contract.test.ts` (3 sites, `sleep 300` then "nothing chosen"): after the refused answer returns, the test types a barrier key into the same pane and waits (bounded) until the menu stand-in has read it; any Enter the server sent for the refused answer is read before it, so only choices logged before the barrier are checked. `src/components/AccountSection.signInAddsPc.test.tsx` (2 sites, `sleep 20`): one waits for the screen state set at the decision point (removal done + "Add this PC to my account" offered); the other holds the PC's `/api/account/status` answer, waits until it was asked, releases it inside `act`, then asserts. - Ratchets go down: `scripts/fixed-sleeps.json` drops `server/prompt.contract.test.ts` (3 -> 0), `scripts/fixed-waits.json` lowers the AccountSection file 8 -> 6. No UI change. The installer's behaviour with no variables set is unchanged. ## Evidence: break the protected behaviour, the tests go red (then restored byte for byte, sha256 checked) | Mutation | Result | |---|---| | `install.sh` star read ignores its timeout | "goes on by itself when nobody is at the terminal" (both) red: installer never ends within 45 s | | `install.sh` watcher never KILLs a gh that ignores TERM | "kills a gh that ignores TERM" red (timeout) | | `install.sh` watcher never TERMs a hanging gh | "goes on with the link when gh does not answer" red (timeout) | | `scripts/compressed-assets.ts` lazy chunks at the startup quality | red: `nested/detail-*.js at quality 5` mismatch | | `scripts/compressed-assets.ts` startup chunks at the lazy quality | red: `nested/index-*.css at quality 11` mismatch | | `server/dispatch.ts` (temporary) presses Enter after a refused 409 answer | all three prompt tests red, the extra choice logged before the barrier (`server/prompt.ts` untouched) | | `src/components/AccountSection.tsx` a sign-in again counts as one that adds this PC | red in the bounded wait for the offer state | | `src/components/AccountSection.tsx` a PC already in another account is offered | red: "Add this PC to my account" shown after the PC's answer | ## Seconds per touched file (same machine, base 1d71a71 vs this branch) | File | Before | After | |---|---|---| | scripts/install-star.test.ts | 21.3 | 2.7 | | scripts/compressed-assets.test.ts | 33.6 | 0.3 | | server/prompt.contract.test.ts | 30.0 | 26.4 | | src/components/AccountSection.signInAddsPc.test.tsx | 4.2 | 3.6 | ## Validation - Focused: install-star 48 pass, compressed-assets 1 pass, prompt.contract 20 pass, AccountSection.signInAddsPc 12 pass; `bun run typecheck` ok. - `bun run check fast` (P620, 231 s): typecheck, build, generated files ok; unit 24,885 pass, 160 skip, **1 fail**: `scripts/conventions.test.ts` "waits marked fixed" on `scripts/relay-new-pc-press-regression.ts:180`, which fails on `origin/main` itself (1d71a71) and is fixed by #4547; this PR does not touch that file. The branch takes main in once #4547 lands. - Skipped: browser regressions (no UI change).
…ldest supported client (#4557) ## Summary The store apps are moving to carry the whole client (the hosted shell, `dist-shell`) inside the app instead of loading it from `https://app.ovis.sh` (the Android native side is another PR; iOS follows). This PR is the client and server side: the client behaves correctly when it runs as the app's own copy, and a PC can tell an app that is too old to update. - **One contract module.** `src/lib/appShell.ts` is the only place that reads `window.__ovisAppShell = { bundled: true, platform, appVersion, build }`, which the app sets at document start on the pages it serves from its own files. Without it (a browser, an installed web app, a hosted or preview-shell app build) nothing changes; the unit tests and the browser regression's hosted cases prove that. - **No service worker in the app's own copy.** It registers none, and the first time it finds the ones a hosted build left (one per PC's scope, any of which would open a PC's page from its kept hosted copy) it unregisters them, deletes their caches, and loads a page one of them served once more. IndexedDB and web storage (the pairings, the settings) are never touched. - **No "newer copy" reload in the app's own copy.** A PC newer than the client opens in it (`updateFlow.ts`); the app-updated line offers no reload (`updateNotes.ts`); `freshShellNext` asks no worker. - **The floor.** `min_supported_client` in the relay `WELCOME` is now one constant, `MIN_SUPPORTED_CLIENT_VERSION` in `server/relay/client-floor.ts` (still `0.4.20`: not raised here), used by `link.ts` and `direct.ts`. The client reads it on both carriers (`RelayServerInfo.minSupportedClient`). Below it, the app's own copy shows a blocking **Update the app** screen for that PC: title, one sentence, one button to the store page for `platform`, and Back to the other PCs, which still open. A hosted page keeps today's behaviour (one reload onto the newer hosted copy). - **The mirror for releases.** `server/relay/store-app-versions.json` lists the store builds live on each store with the day each went live and the client it carries; `server/relay/client-floor.test.ts` fails a floor raised above a client both stores have carried for 14 days. - **The reverse skew check.** `scripts/relay-client-skew-regression.ts [<tag>]` builds the shell of a release tag in a worktree and opens this checkout's PC through the relay with it: pair, attach a terminal, type, read the output back. Default tag: the oldest client a store build carries; while none carries one, the latest release. - **The rule, written down**: `docs/development.md` ("The phone app's client", and a line in the release steps), `docs/native-app.md` ("The app carries its client"), `docs/relay.md` (Versions, error table) and one trap line in `server/AGENTS.md`. ## Places an app origin or a service worker was involved (before → after) | Place | Before | After | |---|---|---| | `src/lib/relay/directSocket.ts` `nativeDirectSocket` | asks the `OvisDirect` plugin only when `location.origin === "https://app.ovis.sh"` | asks it from that origin, or from the app's own copy at any origin (`directPageAllowed(origin, appShell())`). Not a weakening of any PC-page protection: this is a client-side courtesy gate, and the plugin's native gate (main frame of the app only) is unchanged and still decides | | `src/lib/account/service.ts` `shellAccountServiceOf` | `nativeApp \|\| origin === GLOBAL_APP` | unchanged: `nativeApp` (the `OvisAuth` plugin) already covers the app at any origin | | `shared/relay-regions.ts` `regionalAppUrl` | never moves a native app | unchanged | | `src/pwa.ts` | registers `/sw.js`, or `/s/<id>/sw.js` in the hosted shell | unchanged without the contract; with it registers none and runs `retireServiceWorkers` at once | | `src/lib/shellMode.ts` | `shellServiceWorker`, `requestFreshShell` | adds `retireServiceWorkers` and the `FILES_CACHE` name (also used by `userFonts.ts`); a controlled page reloads once (also when another page retired its worker), never a page that is itself a reload | | `src/lib/relay/updateFlow.ts` `reloadPage` / `freshShellNext` | `reloadPage` asks the worker to update, then reloads; `freshShellNext` writes the fresh-shell marker | `reloadPage` is no longer reached from the app's own copy; `freshShellNext` returns at once there | | `src/lib/updates.ts` / `updateNotes.ts` `reloadReason` | "App updated" when the build's revision differs from the PC's | never "updated"/"restart" for the app's own copy; a failed chunk still offers its reload | The demo checks (fixed in 2e746a2): `src/lib/connectionRoute.ts:32` and `src/components/SettingsDialog.tsx:1340` took any `capacitor:` page for the phone app's demo, so the iOS app's own copy at `capacitor://app.ovis.sh` would have lost a relay PC's route mark and been called the demo in Settings. Today the demo was told apart by that protocol alone. Now the demo's own transport (`site/demo/transport.ts`, which every demo build loads before the client: the website's, the phone apps', the test lane's) sets `window.__ovisDemo = true`, and `src/lib/demo.ts` `demoBuild()` is what both read: Settings' Change PC calls only a marked page the demo; the route mark leaves out only a marked page inside the native app (the website demo keeps its mark, as before). Tests: `src/lib/demo.test.ts`, `src/lib/connectionRoute.test.ts` (the bundled shell at `capacitor://app.ovis.sh` with the relay is "relay"), `src/components/SettingsDialog.changePc.test.ts`. ## Origin checks in `server/` and `relay/` for the iOS app's own origin Commits for the independent review: the relay, `relayHeaders`, direct-carrier and `sameOrigin` tests are in 9e44ce1 (with that commit's review fixes, in other files: `server/ws-proxy-origin.test.ts`, `server/relay/session.contract.test.ts`, `server/relay/direct.contract.test.ts`, `relay/bun.test.ts`), and d37b559 adds the regional app origin. No server or relay code changes. The iOS app's own copy runs at `capacitor://app.ovis.sh`, and its fetches and sockets carry that `Origin`. Nothing in `server/` or `relay/` accepts the hosted origin (`https://app.ovis.sh`) by name, so nothing accepts the new one either and no code changed. Tests now pin each place for `https://app.ovis.sh`, `capacitor://app.ovis.sh` and `capacitor://localhost` alike: | Place | `https://app.ovis.sh` (today) | `capacitor://app.ovis.sh` | Test | |---|---|---|---| | Relay socket admission (`relay/core.ts` `admit`, shared by the Worker and the Bun relay) | not read: let through | not read: let through (as `capacitor://localhost` or none) | `relay/bun.test.ts` | | Requests through the relay to a PC (`server/relay/session.ts` `relayHeaders`) | replaced by `https://relay.ovis.invalid`, same-origin | the same | `server/relay/session.contract.test.ts` | | Direct carrier (`server/relay/direct.ts:280`, `direct-gate.ts:201`) | refused (any `Origin`); only the plugin's socket, which names none, opens it | refused, the same | `server/relay/direct.contract.test.ts` | | A PC's own `/ws` and its controls (`server/machine-security.ts` `sameOrigin`, by address or Tailscale) | refused: only the PC's own origin | refused, the same | `server/ws-proxy-origin.test.ts` | | CORS allow lists | none in `server/` or `relay/` (the hosted site's `build.json` is `*`, the account service answers `*`) | the same | — | What a released PC (0.5.9) does when the iOS app's own copy reaches it, probed against a v0.5.9 tree with this branch's client: - **Relay: works.** Paired with `Origin: capacitor://app.ovis.sh`, `GET /api/health` 200 through the mux; it names `min_supported_client` 0.4.20, and 0.5.9 is above `MIN_SERVER_VERSION` (0.4.21), so no "Update Ovis on…". - **Direct: falls back to the relay.** The PC refuses any socket that names an `Origin` and signs in the plugin's socket (no `Origin`) at once. The iOS plugin's own gate (`OvisDirectPlugin.swift:317`, `DirectCallGate`) answers only an `https` main frame of `app.ovis.sh`, so until the iOS PR lets the app's own origin through, the plugin refuses the call and the transport goes on through the relay. - **Tailscale or address: works, untouched.** The app loads the PC's own client from the PC, whose origin is its own. The PC refuses `capacitor://app.ovis.sh` on its own `/ws` and controls (403), as it refuses the hosted origin. ## Which ways of opening a PC carry the floor | Way | Handshake with the floor | What happens | |---|---|---| | Relay (incl. the account's open-all path) | `WELCOME.min_supported_client` (`server/relay/link.ts`) | read, enforced for the app's own copy | | Direct carrier (same network / Tailscale, `OvisDirect`) | the same `WELCOME` (`server/relay/direct.ts`) | read, enforced | | By address, Tailscale address, SSH | none | the WebView loads the PC's own client from the PC, so client and server never differ; nothing to compare | | Another PC through this PC (`server/relay-pc.ts`) | that PC's `WELCOME` reaches this PC's server, not the app | not read; out of scope (a server-side read would be the place) | ## Store versions file From `app/store/ios.md` and `app/store/android.md`: iOS 1.0.2 (11), on the App Store since 2026-11-20; Android 1.0.5 (13), live on Google Play, dated 2026-11-21 (the day the docs first recorded it live, #4382; it was sent to review on 2026-11-20 and the console date was not in the repo). Both load the hosted shell (`client: null`), so they allow no floor above the first relay release (0.4.21). ## Validation - Red first: each unit test below failed before its change (`appShell`, `skew`, `updateFlow`, `directSocket`, `shellMode`, `updateNotes`, `RelayShellScreens`, `client-floor`, the direct and service contract tests). - `bun run check fast`: typecheck, build, generated files green; unit 24908 pass, **1 fail: `scripts/conventions.test.ts` "waits marked fixed"**, which fails on `origin/main` (1d71a71) too: `scripts/relay-new-pc-press-regression.ts:180` vs the ratchet of #4537. #4547 fixes it. Run with a short `TMPDIR`: under a long one `server/ssh-account-add.test.ts` fails on a too-long unix socket path, unrelated. - Browser, real Chrome (`scripts/relay-shell-browser-qa.ts`, new section in its skew block; this checkout's servers only): the contract injected with `addInitScript`; a PC whose floor is above the shell → **Update the app** with the Google Play link, no app, no reload, the same again after a reload in Korean; Back, then a newer PC under the floor opens with no reload; a hosted page's registered and controlling worker → with the contract: unregistered, its caches deleted, one more load from the app, the pairing and settings kept, none registered again. Locally green, plus the CI runner image runs below. - CI runner image (`herdr-ci-runner:local`, fresh clone from a bundle, `bun run check run` per script): `relay-shell-browser-qa.ts` (155 s), `relay-e2e-regression.ts`, `pwa-update-browser-qa.ts`, `revision-bound-update-demo-regression.ts`, `terminal-served-font-regression.ts` (the files cache name moved), `relay-media-browser-qa.ts`, `ui-contexts-regression.ts` (its update-notice checks: `update-notice-regression.ts` is a module of it) and `relay-client-skew-regression.ts v0.5.9`: all exit 0. - Origin parity: `relay/bun.test.ts`, `server/relay/direct.contract.test.ts`, `server/relay/session.contract.test.ts`, `server/ws-proxy-origin.test.ts` (127 pass); the v0.5.9 probe above was run once by hand and is not committed. - CodeRabbit's five findings are fixed in the second commit (default skew tag at or above the floor, one language initializer, a stored value checked across retirement, an exit on an unscoped Update the app, the orphaned-worker reload), and `relay-shell-browser-qa.ts` passed again locally after them. - After the demo and lane commits: `bun run check fast` green on the branch rebased onto main (24918 pass; `main` now has #4547); in the runner image from a clone with no tags: `relay-client-skew-regression.ts` (fetched v0.5.9 from the public repository, 56 s), `relay-shell-browser-qa.ts`, `settings-pages-demo-regression.ts`, `setup-dialog-demo-regression.ts`, `boot-loading-demo-regression.ts`: all exit 0. - Reverse skew by hand on this PC: `relay-client-skew-regression.ts v0.5.9` and `v0.5.0` both pass against this checkout's server (pair, terminal, `echo skew-ok` seen in the page and in herdr's `pane.read`). - Screenshots of the screen (390 px, light, en and ko) are kept with the QA reports, not attached. ## Known limits - The reverse skew check runs in the browser lane (fb4ef34): `scripts/ci-browser.sh` runs it and it left the manual list. A checkout without the tag (CI's shallow one, a merge gate's clone) lists and fetches it from the public repository, so no workflow changed; it costs one more `bun install` and `build:shell` of the tag (about 1 minute in the runner image). - A PC that raises its floor while the app is connected is only held at the next admission (a reconnect does not re-check). - The account controller's background calls to a PC (its account steps) are not gated by the floor; they fail as any refused call does. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus <[email protected]>
…igning in again (#4546) ## What changed The account service is changing so that adding a PC takes a sign-in from the last ten minutes **or an older own sign-in that proves the key it registered** (one key per sign-in, made non-extractable by WebCrypto right after the sign-in, `signin_key`). This PR is the client side. Only the phone app and app.ovis.sh register such a key, for a sign-in made there outside a pairing, so that is where the proof is made; on a PC's own window, in the desktop app and for a sign-in made from a pairing screen an old sign-in is asked to **Sign in again**, as before. - **The proof** (private to `AccountService`) asks `POST /v1/pcs/challenge` and signs it with this sign-in's registered key: ECDSA P-256 / SHA-256, raw r||s, base64url, over `ovis-pc-add/1` plus purpose, account, server_id, listing_id, challenge_id and challenge, each a 4-byte big-endian length and its UTF-8 bytes (`shared/account-records.ts` `pcAddSigningBytes`, checked against a fixed vector that matches the service's function byte for byte). None is made when this sign-in registered no key, or when the service gives no challenge (404, or 403 `own_sign_in_required` for a device code's sign-in). - **`admitPc` and `putPc` send `key_proof` by themselves** when the stored sign-in is more than nine minutes old by this device's clock, or of unknown age; a fresh sign-in sends none and asks no challenge. The sign-in's time is kept on the session (`signed_in_at`, set by `sessionOf`, carried by every refresh). Purposes: `admit` (over the PC's current listing) and `list` (a `PUT` of a PC the account does not list yet, over `""`). `putPc` proves only for an add a person pressed (`prove`): the card's **Add**, **Add and pair**, the enrollment of a pairing just made from its confirm, and the own page's and SSH adds (which hold no key in production). Opening a saved pairing signs nothing, and an upkeep `PUT` of a listed PC proves nothing. The proof's directory read and challenge go through the same send-again as the `PUT`, and a challenge spent on the way (400 `challenge_invalid`) is made anew once. `confirmPc` has no production caller and sends no proof. - **Fallbacks**, one proof attempt per press and never a loop: no key, no challenge route (404), a 400 `invalid_request` to a body with a proof (told as `session_not_fresh`), or a signature the service judges by age alone all end in the existing **Sign in again**. - **A listing refused for the sign-in itself** (`session_not_fresh` on the `PUT`, once the service enforces its `list` rule for a sign-in with no key) no longer reads as a generic failure: **Add this PC to my account** says to sign in again and offers this page's own sign-in again in place, then presses again as that sign-in's account; a phone's **Add and pair** maps it to its sign-in screen (`sign-in-first`), which goes on with the same pairing, instead of "sign out and back in". - **The card shows who is asking**: under the PC's name (shown as one plain line, `accountLabel`), the system and place the service saw (`asking_os`, `asking_country`, `asking_city`: "Linux · Seoul, South Korea", only what is known). For a listing that asks to join (`asking_until` a string) it shows **Expires in N min** (at most 10) until the service's window (never past ten minutes from the listing), and once that passed, or the admit answers 409 `listing_expired`, **This request ran out. To add this PC, start again on the PC.** with **No** alone. An unconfirmed PC with `asking_until` null (a sign-in code's listing made while Step 2 was off, which may be a PC in use) or absent keeps the card as on `main`: **Add** and **No** for ten minutes, then **Remove from my account**. 409 `listing_changed`, or a `session_not_fresh` after which the listing reads as replaced (a proof signs the listing it read), reads the listing again instead of asking a sign-in. **No** works for a sign-in of any age (the service no longer asks a fresh one to decline a listing that asks to join); against an older service it still offers **Sign in again**. - **A PC sends its `os` with its listing**: `ovis add` from the PC's platform, a PC's own page from the browser's user agent (as its link-page sign-in already does). The add over SSH lists the other PC with this PC's own sign-in, which the service never marks as asking, so it sends none. - **The CLI** signs in with a device code (the link-page session), which neither needs nor can make a proof; it is unaffected apart from `os`, and its advice names both of the card's labels (**No or Remove from my account**). - **`shared/account-service-fake.ts`** models the new rules: the challenge route, `key_proof` on the admit, a confirm and a new PC's `PUT`, `session_not_fresh` only for an old sign-in without a holding proof, `listing_expired`, the `asking_*` fields, **No** at any age, and an admit whose signed listing was replaced while the proof was checked (409 `listing_changed`); `pcAddProofs = false` is the service before the change and `listProofRequired = false` the service's list rule while it is off. Two CLI tests that press **Add** as the CLI's own ten minutes end run against the service before (the new one refuses an **Add** that late). - Docs: `docs/account.md` ("Fresh, or proved with the sign-in's key", the card, Who is asking, what this does not protect against), `docs/relay.md`, `docs/guide.md`. Changelog fragment. ## What the proof does and does not stop A copied access or refresh token alone can no longer add a PC once its sign-in is ten minutes old. A script running in the app's page, or a copy of the whole browser profile, still can: the key is the app's non-extractable WebCrypto key in its IndexedDB. ## Safe to merge before the account service deploy Against the deployed service every new call falls back: the challenge route answers 404, so no proof is sent and the admit and listing behave exactly as today (an old sign-in gets **Sign in again** as before); the card shows no who-is-asking line and no time left without the fields, and keeps `main`'s card; **No** with an old sign-in still offers **Sign in again**. The service ships its `list` rule switched off at first, so an old sign-in with no key still lists a PC as today. ## Validation - `dori heavy keyproof -- bun run check fast` on 87828a9 (this branch merged with `main` after #4542, #4543 and #4547): green (25014 pass, 0 fail; workflow syntax, generated types and themes, typecheck, build, unit tests). - Unit tests (those of the new behaviour fail against `main`'s client): the signing bytes against a fixed vector (cross-checked once against the service's own function, not committed); `src/lib/account/pcAddProof.test.ts` (fresh / old / unknown age / no key / another sign-in's key / a device code's sign-in / the fallbacks / `list` and upkeep / a listing that is no press signs nothing / a spent challenge made anew once / the send-again reaching the read and the challenge); the card (`UnconfirmedPcNotices.test.tsx`: who is asking, time left and its cap, ran out by the service's window, `listing_expired`, `listing_changed`, a replaced listing behind a `session_not_fresh`, `asking_until` null and absent keeping `main`'s card, the name without bidi controls, an old sign-in's Add with its key and with the service before, No at any age); **Add and pair** and enrollment with an old sign-in (a key, no key, the service before, a saved pairing signing nothing); one press from the PC's own window and the add over SSH with a fresh and an old sign-in (no key, as in production); the refused listing's in-place **Sign in again** on **Add this PC**; the fake's rules; the CLI's `os`. - Browser regressions that drive the add, in the CI runner image (`herdr-ci-runner:local`, from a git bundle of the first head): `scripts/relay-panel-regression.ts` and `scripts/relay-shell-browser-qa.ts` (after `build:shell`), both exit 0. No browser script drives the unconfirmed card itself; the card is covered by its component tests and the screenshots. Not run again for the review fixes, which touch neither screen. - Screenshots of the card at 390 px, light, from a throwaway harness that mounts the card over the fake account service (no real session): who is asking, and ran out, in English and Korean. - Not run against a real account service: the staging deploy of the service change is pending, so the device check (an old sign-in's Add in the phone app, **Add and pair**, the challenge's 404 fallback against the deployed service) waits for it. - Known baseline failure, same on a clean `origin/main` checkout on this PC: four herdr-session discovery cases in `server/machine-profile.contract.test.ts` (outside `check fast`). ## Known limits - An enrollment whose `PUT` is refused for an old sign-in with no key (only once the service turns its `list` rule on, and only when the PC was not listed first by **Add and pair**, e.g. opening a saved pairing) still ends in **Account setup is incomplete** with **Try again**; a new sign-in then completes it. Offering **Add this PC to your account?** there is more than a small change and is not in this PR. - The add over SSH treats a refused listing as a refused admit: since #4542 both offer **Sign in again** in place and go on with the new sign-in (this PC's own window registers no key, so it never proves). - The age is judged by this device's clock, with a minute's margin under the service's ten; a clock moved back makes an old sign-in look fresh, which then falls back to **Sign in again**. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus <[email protected]>
… own origin (#4558) ## What The Android app carries the hosted shell (`dist-shell`: home's Connect a PC / My PCs and every relay PC's page) and serves it from its assets **at the hosted origin itself** (`BuildConfig.APP_ORIGIN`, `https://app.ovis.sh` in a store build) with no network. Someone who updates from a build that loaded the shell from the network keeps that origin's storage: sign-in, keys, pairings. - **Packaging** (`app/scripts/bundled-shell.ts`, called by `build-web.ts`): `OVIS_APP_SHELL=bundled|hosted`. If unset, it is `bundled` for the production origin (a store build) and `hosted` when `OVIS_APP_URL` is set (the owner's preview app and the QA twin, which keep working as they do today). `OVIS_APP_SHELL_DIR` names the dist-shell to carry; if it is unset, the shell is built from the checkout, as the demo is. The copy goes to `app/bundled-shell/` (`shell/` + `shell-policy.json` with `page` and `render`), written once for both platforms outside `app/www`, so `cap sync` leaves it alone and `https://localhost` never serves it. The Android build adds it as an assets folder of its own; the iOS app can reference the same folder (the iOS PR stacks on this one and adds no packaging of its own). Sidecars, `_headers`, `_redirects` and `.well-known/` are left out. The policies are **read back from that copy's own `_headers`**. `shell-build.ts` now writes them from one `shellPolicies()`, and a test reads them back from `shellHeaders()`, so the app and Pages cannot disagree. The build fails if the copy is over 64 MB (31 MB today). - **Switch**: `BuildConfig.SHELL_BUNDLED`. Gradle refuses `assemble/bundle/package/install/signRelease` of a hosted build whose application ID is the store's, and any app bundle of a hosted build. `checkHostedOrigin` fails a bundled build that carries no shell, and a hosted build that still holds one from another run. - **Serving**: the activity **keeps `server.url` = the hosted origin**, as in a hosted build. Only the answers change. `shouldInterceptRequest` (the activity's client, plus an early client installed from `HerdrShellPlugin.load` before Capacitor loads the first page) and the `ServiceWorkerController` client (Capacitor's own is turned off for it) answer every request to that origin from the copy, the way Pages does (`BundledShell.route`): - `/s/<id>/~render` → `render.html` with the render host's policy alone - `/s/<id>/manifest.webmanifest` → the manifest - anything else under `/s/` → the shell - a file → that file - a missing `/assets/*` → 404 - anything else → the shell Every answer carries the shell's CSP (`~render` gets the render policy). Only GET and HEAD are answered. Capacitor's own `/_capacitor_*` paths stay with its local server. - **Stale workers**: - **Boot page**: the first bundled start after the shell came from the network opens `/_ovis/boot` first. That page sits outside every `/s/` scope, so no worker controls it. It unregisters every worker, deletes the caches except `ovis-files-v1`, tells native through a one-shot `OvisBoot` listener, then replaces itself with the page that was asked for. IndexedDB is never touched. - **Retiring `sw.js`**: every `sw.js` answers a worker that unregisters itself (see Choices). - **Contract**: `window.__ovisAppShell = { bundled: true, platform: "android", appVersion, build }` (frozen) is injected at document start on the hosted origin alone, as the client PR (#4557) asks: never a PC's own page, the render host (its sandbox has no origin), the app's own pages or the demo. A hosted build injects nothing. The client's "Update the app" button (a `target=_blank` link to the Play page) is a main-frame link to another origin, which `MainActivity` hands to the system; checked on the device (below). - **Home**: in a bundled build the app starts on the bundled `/#pcs`. There is no 8-second clock. Once the 20 seconds a PC gets are up, the cover lifts instead of falling back. A main-frame failure still gives way to the app's own page. The hosted-home path is unchanged for `hosted`. This starts from the spike patch. Its approach (`setHostname` with no `server.url`) is replaced by keeping `server.url`, because that keeps every gate as it was in the hosted build by construction (table below). The spike's `RouteProcessor`/asset-path plumbing is gone. ## Gates Hosted means today's build. Bundled-before-fix means the spike patch (`setHostname("app.ovis.sh")`, no `server.url`), which is what `bridge.getServerUrl()`-keyed gates do once the shell is served from assets without this PR's design. Line numbers are at this PR's head. | Gate | File:line | Hosted | Bundled before fix (spike) | Bundled after fix | |---|---|---|---|---| | Capacitor bridge origin rules and document-start bridge script | Capacitor `Bridge.setAllowedOriginRules` / `loadWebView` (`server.url` set in `MainActivity.java:403`) | `{https://localhost, APP_ORIGIN}` | `{https://app.ovis.sh}`: the app's own pages and the shell share one origin | same as hosted | | `OvisDirectPlugin.allowed` (`getServerUrl() == APP_ORIGIN`) | `OvisDirectPlugin.java:91` | allowed on home and relay PC pages, `not_allowed` on the app's own page | `not_allowed` everywhere | same as hosted (device: `features` → `{tailnet:true}` on home and `/s/<id>/`, `not_allowed` on own page) | | `OvisDirect.open` page-URL check | `OvisDirectPlugin.java:126` | APP_ORIGIN host only | same | same | | `OvisSshPlugin.fromAppPage` (list, setUp, rename, phoneKey, copy, share, known, forgetHostKey, remove) | `OvisSshPlugin.java:71` | own page only | **allowed for home and every relay PC page** (widening) | same as hosted (device: `list` and `forgetHostKey` refused on home and `/s/<id>/`, allowed on own page) | | `OvisSsh.add` from a PC page | `OvisSshPlugin.java:86` | PC pages go through `setupOpener` (hosted origin: setup screen over the page) | every page takes the own-page path | same as hosted | | `OvisPush` getSubscription / subscribe / unsubscribe / register, keyed by `getServerUrl()` | `OvisPushPlugin.java:45, :74, :131, :137` | subscribe works on home and relay pages under key `https://app.ovis.sh`; `no_pc` on own page | `no_pc` everywhere; per-origin endpoints unreachable | same as hosted, same key (device: `subscribe(bad key)` → `invalid_key` past the PC gate on home and `/s/<id>/`, `no_pc` on own page) | | `HerdrShellPlugin.showingConnectScreen` (`takeLink`, `openSshSetup`, getState ids) | `HerdrShellPlugin.java:178` | true on the app's own page only | **true on every shell page** (`takeLink` would hand a pending pairing link to a relay PC page) | same as hosted | | `HerdrShell.forget` of an SSH PC (takes its keys) | `HerdrShellPlugin.java:225` | refused from PC pages | **allowed from relay PC pages** (widening) | same as hosted | | `HerdrErrorPage` listener origins (`appOrigin`) | `MainActivity.java:447, :474` | `https://localhost`: error.html alone | **`https://app.ovis.sh`**: home and every relay PC page could read the last PC and failure, and send retry/changePc | same as hosted (device: `HerdrErrorPage` undefined on home and `/s/<id>/`; answers on error.html) | | `/_ovis/retry`, `/_ovis/change-pc` | `MainActivity.java:507` | only from `https://localhost/error.html` | error.html served at the shell's origin (copied into the shell) | same as hosted | | Sign-in step checks (`!appOrigin.equals`) | `MainActivity.java:523, :594` | own origin = localhost | own origin = app.ovis.sh | same as hosted | | `OvisBars` listener | `MainActivity.java:461` | `{appOrigin, origin}` | collapses to one origin | same as hosted | | `~render` frame | `BundledShell.route` | production Pages **308-redirects** `/s/<id>/~render` to `/render`, which carries the shell policy, so `render.html` never runs (see "Found outside scope") | `render.html` | `render.html` under `sandbox allow-scripts`: opaque origin; no Capacitor, no listeners, no fetch, no storage (device) | | New: `OvisBoot` listener | `MainActivity.java:725-728` | none | none | only in the activity of a start that runs the boot page, APP_ORIGIN main frame at `/_ovis/boot`; dropped once heard; its one effect is to skip the next start's clean-up. Device: undefined on every probed page | | New: `window.__ovisAppShell` | `MainActivity.java:721` | none | none | data only, no capability; on the hosted origin alone (device: present on home and `/s/<id>/`, absent on the app's own page, error.html and inside `~render`) | Device gate matrix (hosted build vs bundled build, each page kind): **0 differing answers** apart from `getState.back`, which follows the current PC. ## Device check (emulator of my own, QA twin `sh.ovis.app.previewqa`, Android 16, WebView 133) 1. The hosted build (versionCode 14) loaded production `https://app.ovis.sh` (the document over h2, files over h2/h3). It wrote a marker and a non-extractable ECDSA key into a scratch IndexedDB, and opened a fake relay PC scope `/s/feedc0de…/`. Its hosted worker registered and kept the hosted shell (`index-DmmTyaFLRL.js`, cache `ovis-v4-sheep-…` with a fresh `/`). 2. With the network **off** (airplane mode, wifi and data off; ping unreachable), the bundled build (15) was installed over it. On its first start it opened that scope and the page ran the **bundled script** (`index-BDvsMom_pw.js`): `navigator.serviceWorker.controller` null, no registrations, `workerStart` 0, the shell caches gone, `ovis-files-v1` kept. The marker was there and the key still signed and verified (`exportKey` refused). The `ovis-account` and `ovis-relay` databases were still there. `window.__ovisAppShell` was set and frozen. The boot flag was stored, and `OvisBoot` was not visible to the page. 3. `/` (home `/#pcs`): bundled script, no worker, marker and key intact. 4. CSP: - The document's header equals the carried page policy, and an inserted inline script and a `data:` script were both refused (`script-src-elem`). - `~render`'s header equals the render policy. 5. A worker registered at `/s/<id>/sw.js` from the bundled page (the retiring worker) was gone 3 s later. 6. A cold start after the boot went straight to the page (no boot listener). With the network **on**, two cold starts and two navigations showed every same-origin request answered by the app (no `nextHopProtocol`, no remote address). Only `account.ovis.sh` went to the network. 7. The client's "Update the app" link (`<a target=_blank href="https://play.google.com/store/apps/details?id=sh.ovis.app">`, clicked on `/s/<id>/`) left the WebView: Chrome came to the front (this emulator image has no Play Store) and the WebView stayed on the PC's page. 8. Gate matrix on: the app's own page (`https://localhost/`, reached through the offline fallback in the hosted build and a main-frame 404 in the bundled one), `error.html`, shell home, `/s/<id>/`, and `~render`. The answers match (table above). The evidence (console output, screenshots of the fake id and the offline home, the gates matrix, the probes and the Gradle guard runs) is on the maintainer's PC under `~/.dori-sa/reports/preview-qa/fix2/bundle-android/`. The device run also caught two bugs in my first version, both fixed here: - moving the start path out of the PC branch crashed the app's own page; - the first page raced Capacitor's own client, which answers the hosted origin from the **network**: offline, home fell back to the app's own page; online, it would have loaded the hosted copy. The early client in `HerdrShellPlugin.load` closes that race. A repeat of the failing sequence passed three times out of three. ## Choices - **`sw.js`**: a retiring worker. It calls `skipWaiting`, and on activate it unregisters itself and deletes the caches except `ovis-files-v1`. It has no fetch handler. Alternatives considered: - **The shell's `sw.js`** would keep a worker, with its kept-shell fallback, alive in an app that registers none. - **A 404** does not remove an existing registration: the browser keeps the active worker when an update check fails. With the retiring worker, a worker the boot page missed goes on its next update check, and a worker that a stale hosted copy re-registers while it runs once goes the same way. - **Own pages' origin**: kept on `https://localhost`, because `server.url` is unchanged. error.html, its listener, `/_ovis/retry`, the connect page and the demo stay where they were, and the shell is in an assets folder Capacitor does not serve there. A PC page navigating its main frame to `https://localhost/…` is handed to the browser (seen on the device, both builds). - **Demo sharing**: not shared. 427 files have identical bytes but different names (a 10- against an 8-character hash), so sharing would need a name map in the app for 9 MB. The APK grows +13.4 MB (54.5 → 67.9 MB debug). - **The client's `/` first (PLAN, contract item 4)**: I kept the native boot page rather than opening `/` first. It runs before whatever the first page is (home, a saved relay PC, a link or an alert that opens `/s/<id>/`) and does what the client does at `/` (unregister every worker, delete the caches but `ovis-files-v1`), so the first `/s/<id>/` load is never a stale worker's; the client's own retirement then finds nothing. - **Push keys**: unchanged. They are keyed by `getServerUrl()`, which is still `https://app.ovis.sh`, so the endpoints the hosted build registered are the ones the bundled build reads and reuses. Nothing migrates and nothing registers again. ## For the release workflow (follow-up, not in this PR) 1. Download the tag's `dist-shell.tar.gz`, verify it against the release's SHA-256, and unpack it into an empty directory. 2. Run `cd app && OVIS_APP_SHELL=bundled OVIS_APP_SHELL_DIR=<that dir> bun run build:web && bunx cap sync android`, with **no** `OVIS_APP_URL`. 3. Run `cd android && ./gradlew bundleRelease` with `OVIS_UPLOAD_PROPERTIES`, after raising `versionCode`. Gradle refuses the bundle if the shell is hosted, and `checkHostedOrigin` fails if no shell was copied. ## Review round (head `2a37b00a4`) An independent review of `a3238250e` found no HIGH issue and no page kind gaining a native capability. Each finding and what changed: - **M1, the origin decision**: `BundledShell.serve` decided "hosted origin" with `PCStore.sameOrigin`, which parses with `java.net.URI`. URLs that WebView keeps raw (`|^{}` and a backtick in a query, `[]` in a path) failed to parse, counted as another origin, and fell through to Capacitor's local server and from there to the **network**. - The decision is now read from the request's parts (`BundledShell.onOrigin(scheme, host, port, origin)`: scheme and host without case, a missing port as the scheme's own, IPv6 brackets ignored), in the page client, the early client and the worker client alike. - Every request to that origin is answered from the copy, with a 404 where no route fits. - `MainActivity`'s main-frame origin check (`:547-548`) reads the parts too, so such a navigation is no longer sent to the external browser. - Device, network ON: `fetch("/assets/none.js?a=|b^{}`")` → 404 and `<img src="/s/<id>/[x].png?q=|">` → error event, both answered by the app (no remote address, no `nextHopProtocol`), with 0 network responses during the probe. - **M2, a verified shell for the store**: - `build-web` takes the release's `dist-shell.tar.gz` with its SHA-256 and tag (`OVIS_APP_SHELL_ARCHIVE`, `_SHA256`, `_TAG`). It checks the sum before unpacking and refuses anything but plain files and folders, as `release.yml` does. - `shell-provenance.json` records `release` (tag, sha256, revision), `folder` or `checkout`. - Gradle packages the store app (its ID in a release build, or any app bundle) only from a `release` whose `index.html` finds every `/assets/` file it starts with. - The copy is cleared before packing, and has a 14 MB floor beside the 64 MB ceiling. - `app/store/android.md` now builds from the tag's archive. A debug build from the checkout still works and is marked `checkout`. - Gradle checks run by hand: - `-m bundleRelease` with a folder's shell: refused; - with the release-style archive: accepted; - with the archive and one index asset removed: refused (`gradle-guards.txt`). - **L1, boot redirect**: `location.replace(asked.href)` after the origin check. The JS tests now cover `https://app.ovis.sh//evil.example/x`, `/.//evil.example/x` and `/s/..//evil.example/x`: each stays on the origin. - **L2, fail closed**: a bundled build whose shell cannot be served (a WebView without the features it needs, or a missing, malformed or empty `shell-policy.json`) opens the app's own `error.html` at `https://localhost` and says why. Where the WebView is the cause, the message is "update Android System WebView"; otherwise it is "reinstall". It never loads the network shell. Change PC there leads to the app's own page. `checkHostedOrigin` validates the JSON. - **L3**: the contract script is guarded with `window === window.top` and injected only on `APP_ORIGIN`. Docs fixed. - **L4**: a failed or slow boot clean-up is tried once more. After a second failure it never goes on to a `/s/` page an old worker could serve, only to `/`, which no worker controls. The flag stays unset, so the next start tries again. - **L5**: `X-Content-Type-Options: nosniff` is on every answer. `/_capacitor_file_/`, `/_capacitor_content_/` and the HTTP interceptor path are a 404 on the hosted origin, because nothing in the client uses them. - **L6, evidence**: the whole device check was re-run on the pushed head `2a37b00a4`. All evidence was regenerated from one hosted APK and one bundled APK, both built from that commit; their sha256 values are in `apks.txt`. The bundled APK carries the shell of the release-style archive (provenance `release v0.0.0-qa.1`, revision `2a37b00a4`). The gates matrix shows 0 differing answers, and `__ovisAppShell` is present only on home and `/s/<id>/`. The retiring `sw.js` is fetched from the bundle with the network ON (status 200, retiring body, CSP and nosniff, `nextHopProtocol` empty). - **Tests added**: - JVM (`BundledShellTest`, 17 tests): - the origin decision with unparsable and foreign URLs; - `plan()`: every answer carries the CSP, nosniff and no-cache; the render policy appears only on the render route; HEAD has no body; a missing file falls back; - `policiesOf()`: its failure modes; - the reasons `error.html` shows. - TS: - provenance, archive SHA-256 and link refusal, the index-asset check, the floor, clearing before packing; - the boot script's retry and fallback. - **Client agreement**: the boot page replaces contract item 4 of #4557 ("open `/` first") on Android. I told the client builder that their retirement must reload only if the page itself was controlled, so the two never double-reload, and wrote both items as FINAL in the plan. - **Owed, not in this PR**: an instrumented androidTest showing that no request to `APP_ORIGIN` reaches a MockWebServer on cold start, recreate, iframe and service worker. It needs DNS for the hosted origin pointed at the mock server and a mock-server dependency, which is more than half a day. - This branch merges `origin/main` and #4564 (the hosted render-host fix), with `shellPolicies()` resolving the conflict. ## Commits 1. `a3238250e`: the first version (packaging and Android together). 2. `ca57f74a1`: the shell folder moved to `app/bundled-shell` for both apps, the contract on the hosted origin alone, the tests split into packaging and Android parts. 3. Merges of `origin/main` and #4564. 4. `2a37b00a4`: the review fixes above. The device check was run on this head. ## Validation - `bun test scripts/app-bundled-shell.test.ts scripts/app-shell.test.ts scripts/shell-build.test.ts scripts/pages-static.test.ts`: pass. The new tests cover: - the switch's defaults; - the pack filter, budget and refusal; - the policies read back from `shellHeaders()` against `shellPolicies()`; - `writeNativeOrigin`; - the Gradle lines; - the boot page's and retiring worker's JavaScript, run from the Java source: same-origin targets only, a foreign target refused, unregister plus cache delete, no "cleaned" when a worker stays or the clean-up fails or hangs. - `./gradlew :app:testDebugUnitTest` (JDK 21) on the final code: all pass, including the new `BundledShellTest` (12: routes as Pages, render host, workers, 404s for unclean paths, methods, types, contract, boot address) and `HomeTest` (bundled clock). - Gradle guards run by hand: - `-m assembleRelease` and `-m bundleRelease` of a hosted build with the store ID: refused; - `assembleRelease` with the QA twin's ID: allowed; - `bundleRelease` with the QA twin's ID: refused; - `checkHostedOrigin` with a missing or left-over shell: refused. - `bun run check fast` on this branch with current `main` (#4547, which fixed the conventions ratchet) merged in: green (24902 pass, 0 fail). An earlier run's `server/ssh-account-add.test.ts` failure came only from a long `TMPDIR` making a unix socket path too long. - The packaging alone (commit 1's tree on current `main`): its tests and `bun run typecheck` pass. - Device check above. Skipped: a physical phone, iOS, a real account sign-in across the upgrade (a marker and a non-extractable key stood in), and the old-WebView fallback path. ## Known limits - A WebView without document-start scripts or message listeners loads the shell from the network, as before. - `/s/<id>` with no slash gets the shell rather than Pages' 301, because an intercepted answer cannot redirect. - `bun run build:web` builds the shell (about 20 s) when no `OVIS_APP_SHELL_DIR` is given, for iOS builders too, although iOS does not carry it yet. - The client side of the contract (no worker, no reload for a newer hosted copy, the "Update the app" screen) is the client PR's job. Until it lands, a bundled client registers the retiring worker, which removes itself, and `reloadOnce` reloads onto the same copy at most once per shell/server pair. ## Found outside scope - **Production render host is broken**: `curl -sI https://app.ovis.sh/s/<id>/~render` answers `308 location: /render`. Pages' pretty-URL rule turns the `_redirects` 200 rewrite to `/render.html` into a redirect, and `/render` carries the shell policy. So `render.html`'s inline script never runs and drawn pages never render on app.ovis.sh, in browsers and in the hosted app. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus <[email protected]>
…#4553) ## What The privacy policy's "Direct connections" section, in English and Korean, said direct connections are on by default with the relay and named the old switch ("Same Wi-Fi direct connection" under My devices). #4543 makes them off by default: the PC listens on its home network and Tailscale addresses only once its owner turns on **Direct connection** under Settings → Devices and PCs → More settings → Devices and access, and a connection through the relay stays on the relay until then. This says so, names the switch and its place, and moves the effective date to November 24, 2026 in both languages, as `ovis-site/README.md` ("Keep in step with the app") asks before the release that changes the listener. ## Why a separate PR A merge to main that touches `ovis-site/` deploys the site at once (`.github/workflows/pages.yml`, `ovis-site/README.md` "Deploy"), so this should merge with the release that ships #4543, not before it. The merge pass may move the effective date to that release's day. ## Validation - `bun test scripts/ovis-site.test.ts`: 26 pass. - `dori heavy relayonly -- bun run check fast`: red on one test that is main's own, not this PR's: `scripts/conventions.test.ts` "waits marked fixed" flags `scripts/relay-new-pc-press-regression.ts:180` (on main since #4537 ratcheted marked fixed waits; #4547 fixes it). Everything else passed. - `app/store/ios.md` says only that the app opens direct connections (`OvisDirect`), not that they are on by default, so it stays. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: devswha <[email protected]>
What
scripts/conventions.test.ts("waits marked fixed") fails on main: #4540 addedscripts/relay-new-pc-press-regression.tswith one marked fixed wait, and #4537 added the ratchetthat allows none in a new file. The two merged side by side, so every PR that includes main now
fails Fast checks.
The quiet period before the press ("nothing reaches the PC until the sheet is pressed") is now a
loop bounded by a deadline that fails on the first join or relay connection, instead of one
1.5 s wait followed by a single check. Same coverage, and a regression is reported sooner.
Validation
bun test --timeout 60000 scripts/conventions.test.ts: 40 pass (it failed on main withscripts/relay-new-pc-press-regression.ts: 1 marked fixed waits, baseline 0).bun run check fastand the browser script itself (CI's browser job runs it).Test-only change; no review requested.
🤖 Generated with Claude Code