Repository navigation
refactor(build): the shell build takes its policies from shared - #3717
Conversation
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
Two reviewers at this head: Claude (Opus) CLEAR, Codex Terra CLEAR with no findings. Move only. The page policy and the static-asset policy values that the frontend shell build ( Checked by the merge pass: Left, both LOW (Claude, read):
Reports: |
## Summary
The server can be built into one compiled binary, `ovis-server <entry>`,
that serves every entry the server starts:
`serve`, `managed`, `supervisor`, `remote`, `machine`, `plugin`,
`askpass` and `windows-launch`
(`server/entries.ts`, `server/main.ts`). `bun scripts/build-server.ts
<platform> <dir>` builds it for linux-x64,
linux-arm64, darwin-arm64, darwin-x64 and windows-x64 (`--compile
--minify --bytecode --format=esm`, the file worker
as a second entry, no source maps). Every child process the server
starts from its own code, and every lookup of
`dist/`, the version, the PTY hosts and the statusline helper, now works
both from source and from the binary. Run
from source, nothing changes. `/api/health` also reports the server's
own `version` to callers that get its full
answer.
The binary holds minified JavaScript and Bun bytecode. It keeps the
source out of what is published, but it does
not hide the code: anyone who unpacks the file can read it.
## Why
Todo 4 of the relay-fleet plan: releases, remote bundles, installers and
updates (todos 5, 6 and 7) ship and run
this one binary instead of a source checkout with Bun and
`node_modules`. Todo 7 reads the running server's version
from `/api/health`.
## Read first
- **`server/dispatch.ts`, `/api/health`:** `version` is added where
`security` already goes:
`access.level === "full"`. That covers every caller that gets the full
answer:
- this PC on loopback while no token is set (`local`)
- the token (`token`)
- a paired device that drives or only watches (`device`, `relay`)
- a Tailscale owner (`tailscale`)
- a Portal sign-in (`portal`)
- anyone on the network (not through Tailscale Funnel) while the install
is still open, with no token and nothing paired (`open`)
A caller refused a token or a pairing gets the reduced answer without
it, and `?scope=bridge` does not carry it.
The value is `package.json`'s, the same import the rest of the server
uses. In the binary it is embedded at
build time.
- **`server/windows-launch.ts`:** it `import()`s the file path it is
given. This crosses no privilege boundary:
- It runs as the user who starts it, with that user's rights, and loads
only a file that user names.
- Anyone who can run `ovis-server windows-launch <file>` can already run
that file with Bun, or with
`BUN_BE_BUN=1 ovis-server <file>`.
- Its one caller is the scheduled task `windows-herdr-start.ts`
registers for the current user (interactive
token, ordinary rights). That task names the private launcher written
into a folder only that user and SYSTEM
may read.
- **The PowerShell action string in `server/windows-herdr-start.ts`:**
`$action.Arguments = [string]$payload.prefix + '"' + $launcher + '"'`.
- From source the payload carries no `prefix`, so the action is `bun.exe
"<launcher>"` as before.
- In the binary it is `ovis-server.exe windows-launch "<launcher>"`,
because a task action cannot set
`BUN_BE_BUN`.
- Both actions were captured in the Windows 11 VM; the source action
matched origin/main's character for
character.
## Left to later todos
- Updates in the binary: `/api/updates` stays unmanaged there (the
updater needs a git checkout). This belongs to
todo 7, as do the source updater's Bun build steps.
- `node-pty` beside the binary for the Node PTY fallback, and the remote
bundles, desktop app and release jobs
that carry the binary: todo 5.
- Installers and the plugin fetching the binary: todo 6.
## Known equivalent mutants
`process.argv.splice(1, 1)` and `splice(0, 1)` in `server/main.ts` (in
place of `splice(2, 1)`) pass the
tests. They leave every argument an entry reads unchanged, and no entry
reads its own `argv[0]` or `argv[1]`.
Dropping the splice, `splice(2, 2)` and `splice(3, 1)` are all caught.
## Review
This changes an HTTP contract (`/api/health` gains `version`) and how a
Windows scheduled task is started, so it
waits for a real review (AGENTS.md, "Maintainer workflow").
Builds on #3717 (merged).
## Validation
Ran:
- `bun run check fast` on b9be7e6e1, this branch rebased onto main
599653f: exit 0 (unit 16172 pass, 0 fail,
54 skip in 909 files), run by the independent verifier in a fresh
detached worktree. The executor's own run on the
branch rebased onto #3717's head gave the same counts; that head and
main differ only in
`scripts/copilot-chat-browser-qa.ts` and `server/opencode-native.ts`.
The pushed head differs from b9be7e6e1 only
in the wording of `changelog.d/health-version.md`; the changelog and
convention tests were run again on it.
- Touched test files, three times each: `server/entries.test.ts`,
`server/dispatch.test.ts`, `server/static.test.ts`,
`server/static-encoding.test.ts`, `server/conventions.test.ts`,
`scripts/conventions.test.ts`,
`scripts/shell-build.test.ts`.
- The fixture of `server/static-encoding.test.ts` fails without
`entries.ts` and without `shared/web-policy.ts`.
The new tests fail under each mutation of the entry table, the command
line, the server and assets roots, the
argv handling and the Windows prefix.
- Binary acceptance on Linux (linux-x64 binary, sha256
`e9876c62181b463c8e7fea5f65ca1f65f541adb39dad650d00d54e769bedee34`), run
against an isolated herdr and a throwaway
HOME:
- `ovis-server managed` brings up managed, supervisor and serve.
- `/api/health` answers 200 with `version` 0.5.3 for the owner, and
without `version` for an unauthenticated
caller.
- `/api/fs/stat` answers 200 through the file worker, and `/` is served
from `OVIS_ASSETS`.
- `ovis-server nosuch` exits 2 and lists the entries; `ovis-server
machine` exits 1 with its refusal.
- No `.ts` file sits in the output folder, and the worktree is clean
after the build.
- Windows 11 VM (`winvm`), in the desktop session through
`Invoke-InSession.ps1`, in a fresh `%TEMP%` folder
that was then removed:
- The source-mode scheduled-task action matched origin/main's.
- The windows-x64 binary's `remote` entry started herdr through the task
(`windows-launch`, last result
267009, still running).
- The bridge answered `/api/health` with 200 and `version` 0.5.3.
Skipped:
- `bun run check full` (integration and browser lanes). The
integration-lane files covering the touched code
(`server/pty/host.test.ts`, `server/pty/session.test.ts`) were run
directly instead.
- Browser regressions: none applies, because `src/` changes only a type
(`HealthInfo.version`) and no shared
UI component changes.
Summary
scripts/shell-build.ts) imported its page policy and static-asset policy values from server files. They now live inshared/web-policy.ts;server/static.tsandserver/file-view.tsre-export them, so every existing importer is unchanged.server/orrelay/.dist-shell/_headersanddist-shell/_redirectsare byte-identical before and after.Why
Notes for review
server/static-encoding.test.tscopiesstatic.tsalone into a temp folder; it now copiesshared/web-policy.tsbeside it.scripts/.Validation
bun run check fast(exit 0) on the rebased commit;bun test scripts/conventions.test.ts;bun run build:shell;cmpof_headersand_redirectsbuilt on the parent and on this commit.bun run check full, browser regressions (no file undersrc/changed).