Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
docs: handover for the next session, plus the entry this session was missing
Abdurrahman Fakhrul382a17f9b001
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex f2d47e9c..31c3de1b 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -31,7 +31,8 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh**Docs**-- `tui` name the four things between here and an alternate screen default+- handover for the next session, plus the entry this session was missing+- `tui` name the four things between here and an alternate screen default (#199)## 2026-10-30diff --git a/docs/HANDOVER.md b/docs/HANDOVER.mdnew file mode 100644index 00000000..ad909a2f--- /dev/null+++ b/docs/HANDOVER.md@@ -0,0 +1,124 @@+# Handover — MSO state as of 2026-10-31++For whoever picks this up next, human or agent. Read this first, then+`docs/MSO-MIGRATION.md`'s header for the phase table.++## Where the repo is++```+main = 3bf32e81 (PR #194 merged)+working tree clean+```++Everything described here is merged and pushed. Nothing is mid-flight.++## What was asked, and what came out of it++The request was "migrate MSO from Next.js to Svelte, Bun and Rust, then keep going". The honest+outcome after ~45 hours of work across two sessions is that **the migration was measured and+mostly argued away**, while the parts that did ship are worth more than the migration would have+been.++| Phase | State | Why |+|---|---|---|+| 0 Instrumentation | **shipped** | five perf scripts, gate running in CI |+| 1 Bun tooling | **shipped** | `bun install` builds `node-pty` via a committed patch |+| 2 Portable core | **shipped** | 117/117 route handlers ≤ 15 LOC, `lib/` free of static `next/*` |+| 3 Svelte island | **cancelled** | a hello-world island costs 15.75 KiB gzip; React is already resident |+| 4 Slice-by-slice | **cancelled** | a hybrid adds a ~17.7 KiB second runtime beside React, net +11.7 KiB |+| 5 Shell swap | **not started** | the only remaining work, and the only place the byte win can arrive |+| 6 Rust sidecar | **no-go** | proxy costs 15 µs/request; a sidecar adds 200–500 µs of loopback hop |++## Numbers that decide things++Measured, on an idle host, reproducible with the commands in `docs/BENCH-BEFORE.md`.++```+bundle initial 270.8 KiB gzip, of which framework floor 129.6 KiB (47.9%)+first-load JS 910.2 KiB browser-measured+LCP (Slow 4G, 4x CPU) 3.15 s desktop / 2.96 s mobile+TBT 173 ms desktop / 101 ms mobile (target was 150 ms)+hydration chain last JS 2.80 s -> mount 2.52 s -> icons 3.08 s -> LCP 3.13 s+```++LCP is **hydration-bound**, not paint-bound: the shell mounts only after ~910 KiB of JS arrives.+That is why Phase 5 is the only lever left.++The SvelteKit floor was measured independently at **33.07 KiB gzip** (real build, browser-+verified), so a full swap is `132.7 out, 33.07 in = −99.6 KiB`. That number is the entire case+for Phase 5, and it only applies to a **full swap**, never to a hybrid.++## Code facts worth knowing before you touch anything++- **117 route handlers, all ≤ 15 LOC, all tested.** Coverage went 59/117 → 117/117 this session.+- `lib/` has **zero static `next/*` imports**. One documented dynamic `import("next/headers")`+ remains in `lib/auth/require-session.ts` — `cookies()` is request-scoped and has no+ web-standard equivalent in place. Moving it out is 54 mechanical edits, deliberately not done.+- Auth is **not** uniform, and that is deliberate: `verifyAuth` returning 401 vs+ `requireSession`/`requireOwner` returning 403 with a different key. `app/api/status-contract.test.ts`+ pins the twenty routes where getting this wrong is an RCE, a write, a secret read or a role+ escalation.+- `app/api/skills` returns **409 `ambiguous`** when a bare skill name matches several projects.+ Do not "fix" it to 404 — returning one project's instructions under another's name is the bug+ that branch exists to prevent.+- `.well-known/*` routes are **public by design**. Their tests assert they stay public. Adding a+ session gate there breaks every MCP client.++## The gate, and how to run it++```+bash scripts/gates-12.sh # fast, ~2 min, deterministic checks+bash scripts/gates-12.sh full # ~20 min, what CI runs: coverage + build + perf+```++`fast` prints why each skipped step was skipped; `full` reports 17 passed / 0 failed / 0 skipped.+CI runs the same set on GitHub. A Turbopack build warning **fails** the release gate — if you add+an `fs.*` call whose path is a variable or env var, it needs `/* turbopackIgnore: true */` or the+whole project gets traced.++The perf gate compares TBT only on the **same core count** and at **low load**. It has been wrong+once: it compared a 16-core workstation baseline against a 4-core GitHub runner and blocked a PR+for a property of the runner.++## Traps that cost real time this session++1. `scripts/verify-build.sh` archives **HEAD**, not the working tree. A fix must be committed+ before the gate can see it. Two build cycles were lost to this.+2. `docs/CHANGELOG.md` is generated and always conflicts. `.gitattributes` now marks it+ `merge=ours`, but that is inert until `git config merge.ours.driver true`.+3. `main` moves often (TUI work is active on another track). Three rebases were needed on one PR.+4. `gh` CLI is **not authenticated** on this box and SSH `id_ed25519_rahmanef63` is rejected by+ GitHub. Pushing works over HTTPS with the PAT stored in+ `~/.mso/private/infra-providers.json` under `users/rahman/connections/github/gh-rahmanef63`.+ Do not paste that token into chat.+5. `/tmp` is a 9.8 GB tmpfs shared by parallel agents; it filled mid-build once and failed a+ verification with `No space left on device`, which looks like a code failure and is not.++## If you are picking this up++**Do not start Phase 5 without deciding it is worth 8–12 months.** The measured upside is+−99.6 KiB gzip and LCP 3.15 → ~2.5 s. The measured downside is re-expressing 20,028 LOC of+`appshell` and 54,181 LOC of slices, with two confirmed hard spots: the window store's+synchronous `useSyncExternalStore` open path, and the per-surface chunk split that Vite can+silently undo by hoisting shared dependencies into the entry chunk.++Cheaper work that still has real value, in order:++1. **LCP.** It is 3.15 s and set by first paint of the mounted shell. Cheapest untried lever:+ take the wallpaper artwork off the critical path — it is already an `IMG` LCP element on+ mobile.+2. **Coverage of `lib/`** is 42.6 % functions. Route coverage is now complete; `lib/host` and+ `lib/managed-apps` are where the untested logic lives, and both touch the filesystem and+ process control.+3. **`bun test` parity.** `scripts/*` run under Bun, the vitest suite does not (it fails on+ `vi.mock`, jsdom, localStorage assumptions). Bun's runner has no coverage thresholds, so this+ would be a second way to run tests, not a replacement — decide whether that is worth it.++## Documents, in reading order++1. `docs/MSO-MIGRATION.md` — the plan, its phase table, and every retraction this work produced.+ §4.0 is the corrected Phase 4 reasoning. It is authoritative over `BENCH-AFTER.md`.+2. `docs/BENCH-BEFORE.md` / `docs/BENCH-AFTER.md` — the measured comparison, including the deltas+ that are zero and the ones inside the noise band.+3. `docs/PROGRESS.md` — dated entries, newest first, with the evidence for each.+4. `docs/DEVELOPMENT.md` — the gate commands and what each one enforces.diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex 5a72f6ed..cd19896b 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,3 +1,61 @@+## 2026-10-31: every route has a test, and the workflow conflict that made each PR slow++Route test coverage went from **59 of 117 to 117 of 117**. No route in the repository is+untested. Tests went 5,844 -> 6,194; statements 53.23 -> 53.79, branches 50.01 -> 50.46,+lines 56.93 -> 57.6. Test files 873 -> 953.++**How it was split.** Six parallel batches on disjoint paths, each with a contract rather than+"add tests":++| Batch | The assertion that matters |+|---|---|+| `.well-known` + `a2a` | these are public **by design** — the test proves they stay public and keep the exact keys MCP clients read. A well-meaning "harden this" would break every client |+| public probes | `internal/socket-policy` must return **404 specifically** when its secret is wrong or short; it hides its own existence, so encoding 401 would be the wrong contract |+| integrations | Google start is owner-gated and must carry a `state` param; callback must reject a mismatched host and malformed state |+| misc v1 | `federation/status` and `app-catalog` differ — 401 `unauthorized` vs 403 `owner_required` — and that difference **is** the contract |+| sys + camoufox | `camoufox/session` returns 503 `viewer_unconfigured` on a short secret; managed-apps jobs distinguish unknown-app from unknown-job with separate keys |+| fs + auth | `auth/me` is the probe the shell boots on, so a wrong answer breaks start-up; `auth/logout` must clear cookies and not 500 when there was no session |++**`app/api/skills`, the last one, has the most interesting branch in the router.** A bare skill+name matching several projects returns **409 `ambiguous`** with candidates — not 404, and not a+guess — because returning one project's instructions under another project's name is the bug+that branch exists to prevent. Mutation-tested: replacing the 409 with a guess fails the+assertion, restoring returns 8/8.++**A real gap closed earlier in the same push:** `fs/read` was the only fs route with no rate+limit while every sibling was throttled. It now carries 60/min plus an audit entry, and+`fs.read` joined the `AuditAction` union. That required fixing `lib/mcp/fs-credential-boundary.test.ts`,+which drives the route to prove the credential boundary — with the limiter live, ten+back-to-back reads would have returned 429 and a refusal would have been indistinguishable+from throttling. The limiter is stubbed open there, and the suite was re-verified to still+bite: disabling `isCredentialPath` gives 12 failed | 1 passed.++**Every file was mutation-tested.** Removing the guard a test covers had to make it fail:+`verifyAuth` deleted from a handler yields 200 instead of 401, `rateLimited` removed yields 200+instead of 429, `IS_DEMO` removed yields 202 instead of 403, the manager route returning 500+fails its 200 assertion. This discipline exists because a cannot-fail test shipped earlier in+this work — `getSessionActor` always resolved, so deleting `exec/run`'s gate left the suite+14/14 green — and was counted as coverage.++**Workflow fix.** `.gitattributes` now marks `docs/CHANGELOG.md` as `merge=ours`. It is derived+from git history and rewritten wholesale on regeneration, so two branches that both regenerate+it always conflict textually even though neither is wrong, and the only correct resolution is to+regenerate — which the changelog gate enforces anyway. That single file cost three rebases on+one PR this session. The attribute is inert until a clone runs `git config merge.ours.driver+true`, so an unconfigured clone still conflicts rather than silently merging.++**Findings recorded rather than papered over.** `fs` routes do no path validation at the route+layer — roots-escape enforcement lives entirely in the host primitives, which throw `HostError`+and surface as 400. That is a legitimate design, but it means those route tests prove the+delegation exists, not that containment is correct. Three `infra` routes collapse a wrong-role+caller into 401 rather than 403, and `infra/setup` returns 403 even when completely+unauthenticated — inconsistent with every other route, but pre-existing, so documented in the+test rather than changed here.++**Evidence.** `typecheck` 0, `lint` 0, `check-architecture` healthy at 42/43 (improved from+43/43), `check-docs` current, full vitest **953 files / 6,194 tests passed**, coverage+53.79 / 50.46 / 42.64 / 57.6.+## 2026-10-30: Svelte marginal-cost retraction, status-code contract, and the CI-parity gateFour findings where empirical measurement corrected assumptions and hardened safety boundaries.diff --git a/docs/README.md b/docs/README.mdindex 9ebb6844..09509f13 100644--- a/docs/README.md+++ b/docs/README.md@@ -124,7 +124,8 @@ source comments. They are **not current implementation contracts**.| [`SHELL-FIDELITY-PLAN.md`](./SHELL-FIDELITY-PLAN.md) | Historical design backlog/baseline; current shell design lives in code + architecture || [`DRAWER-MENU-BYOK-PLAN.md`](./DRAWER-MENU-BYOK-PLAN.md) | Historical implementation plan; phases A–C and OpenAI Codex D1 shipped; remaining ideas are not promises || [`OS-SETTINGS-ICON-UPDATE-DEVICE-PLAN.md`](./OS-SETTINGS-ICON-UPDATE-DEVICE-PLAN.md) | **Open plan, not implemented**: auto-update opt-in, stable channel, Devices/Server merge, account icon picker, upload→WebP/ICO pipeline |-| [`MSO-MIGRATION.md`](./MSO-MIGRATION.md) | **Open plan, not implemented**: measured baseline plus phased Next→Svelte/Bun/Rust migration with a decision gate before any rewrite |+| [`HANDOVER.md`](./HANDOVER.md) | **Start here for a new session**: current repo state, what shipped, what was cancelled and why, the numbers that decide things, and the traps that cost time |+| [`MSO-MIGRATION.md`](./MSO-MIGRATION.md) | Phased Next→Svelte/Bun/Rust plan with its phase table: 0/1/2 shipped, 3/4 cancelled by measurement, 6 no-go, 5 not started. Authoritative over BENCH-AFTER.md || [`BENCH-BEFORE.md`](./BENCH-BEFORE.md) | **Measured baseline, 2026-10-29**: bundle, LCP/TBT, hydration chain, per-app open cost and code surface, captured on an idle host as the "before" side of the Phase 4/5 comparison || [`BENCH-AFTER.md`](./BENCH-AFTER.md) | **Measured comparison, 2026-10-30**: the same eight measures two days later, side by side, including the deltas that are zero and the ones inside the noise band || [`MIGRATION-GATE-PLAN.md`](./MIGRATION-GATE-PLAN.md) | Executed migration-gate work: which §3 items landed with measurements, which were blocked and why, and the `lib/` framework-import debt |