Skip to content

fix(machines): let the own-Ovis update token open only its two requests (#2054) - #2193

Merged
devswha merged 1 commit into
mainfrom
fix/own-ovis-update-followups
Oct 28, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/own-ovis-update-followups

Conversation

@devswha

@devswha devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner

What

Closes #2054: the last LOW items of its follow-ups from #2048. #2071 had already fixed both MEDIUMs and three LOWs.

  • Bridge-token grant (auth): on a PC's own Ovis, the bridge token the connecting app holds was checked by pathname only, so GET /api/updates?anything=1, HEAD/POST /api/updates, and GET/PUT /api/updates/install all passed its gate. It now opens exactly GET /api/updates and POST /api/updates/install, each with no query string (server/index.ts, bridgeUpdatePath). The only caller, ownOffer/runOwnUpdate in server/machines.ts, sends exactly those two requests.
  • ownOvisAction / ownUpdateFailure get the unit test the issue asked for (src/components/MachineSidebar.test.ts). The server half of that item (the job's remote_ovis) is already asserted since fix(machines): keep reconnecting to a PC's own Ovis while it restarts #2071.

Left out, and why

  • An offered release still older than this app is installed unasked. The offer names a release version, but this app checks the bridge's bundle version (REMOTE_BUNDLE_VERSION). Refusing by release version would block updates whose bundle does match. Today it ends in a clear refusal once, with no loop. A real fix needs the offer to carry its bundle version.
  • Card wording for setup + updatable / update_bridge + non-updatable. After fix(machines): keep reconnecting to a PC's own Ovis while it restarts #2071, neither state is reached: a refused own update sets updatable: false with setup, and remote_ovis is read anew on every try. The conflict card's "bridge" wording would need a new field telling it the conflict is with an own Ovis.
  • A test reads the manager's private jobs map. That is the repo-wide way the machine tests wait for a job's end (machines.test.ts, machine-diagnostics.test.ts). Changing it means adding a public completion signal, which is a separate refactor.

Found in review, older than this change and filed as #2191: ownOffer reads /api/access with the bridge token, which never opened that route. A token-gated own Ovis therefore loses its relayed port and its https link.

Verification

  • Regression test in server/api.contract.test.ts ("lets the connection server's bridge token read the update status and install the offer, and nothing else of it"): it fails on main (GET /api/updates?anything=1 -> 200) and passes with the fix.
  • Live server (port 0, stateDir from mkdtemp, HERDR_SOCKET pointed at a missing socket), checked with curl -i and the bridge token: GET /api/updates -> 200 and POST /api/updates/install -> 202. With ?anything=1, HEAD, POST /api/updates, GET /api/updates/install or POST /api/updates/install?x=1 -> 401.
  • ownOvisAction test: a mutation where it returns the offer unconditionally makes it fail.
  • bun run check fast green (typecheck, build, unit 7957 pass).
  • Reviews: omo-native-code-reviewer PASS and Codex Sol 6.1 Fast xhigh PASS, with no CRITICAL/HIGH/MEDIUM. The LOW notes were a bare ? (no query, nothing exposed) and Own-Ovis offer: the bridge token cannot read /api/access, so a token-gated PC loses its real port and https link #2191.

This touches authentication, so per AGENTS.md it waits for a real review. REMOTE_BUNDLE_VERSION is unchanged: only the release PR raises it.

…ts (#2054)

The bridge-token grant on a PC's own Ovis matched the pathname alone, so
GET /api/updates?anything=1, HEAD/POST /api/updates and GET or PUT
/api/updates/install all passed its gate. It now opens only GET
/api/updates and POST /api/updates/install, each with no query string.

Also gives ownOvisAction and ownUpdateFailure the unit test #2054 asked for.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0272085 and 0daa538.

Files selected for processing: 4
  • changelog.d/own-ovis-update-token-scope.md
  • server/api.contract.test.ts
  • server/index.ts
  • src/components/MachineSidebar.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Merging 0daa538 after a strict authentication review. omo-native-code-reviewer and Codex both pass this head. With the bridge token, only GET /api/updates and POST /api/updates/install, with no query, still work. About 30 other requests are refused: other methods, query strings, trailing slashes, encoded paths, aliases and other update routes. The install hook ran only for the two allowed requests, and other credentials are unaffected. The required checks are green; Native Windows install first failed on the windows-plugin.test.ts flake and passed on rerun. CodeRabbit did not review this head. The LOW notes go to a follow-up issue.

@devswha
devswha merged commit 1795933 into main Oct 28, 2026
27 of 28 checks passed
@devswha
devswha deleted the fix/own-ovis-update-followups branch October 28, 2026 05:59
devswha added a commit that referenced this pull request Oct 28, 2026
…arent number pulls in nothing (#2202)

## Change

**What was wrong.** On Windows CI, "starts after its launcher exits,
stops its owned tree and restarts on Windows" sometimes failed at "wait
up to ten seconds for the Windows-owned process tree to disappear"
(#2185, run 40635841024; #2193, run 40638822136). `stop` itself had
succeeded: it exited 0, and `run("stop")` asserts that. The test then
waited for its own list of "owned" processes, and that list was wrong.
It held 128 and 123 pids, starting with boot-time system pids. It also
held the test runner's own pid (8248 and 2228). The earlier test in the
same file prints that number in "stopped Ovis (pid N)", because it
records `process.pid`. The runner started before the server, so it can
never be part of the server's tree, and it never exits.

The test built that list with a plain parent walk (unchanged since
#330). Windows keeps a dead parent's number on its children and gives
that number to new processes. When a process in the server's tree got a
number that long-lived processes still named as their parent, the walk
pulled them in, and everything below them.

**Is #2166 the cause?** No. #2166 (the plugin lifecycle lock) does not
change what `stop` waits for, and `stop` returned 0 in both failures.
Its Windows wait already uses `descendantProcesses` (`scripts/plugin.ts`
`stopInTurn`), the reuse-aware walk that skips a process older than its
parent. The test's walk had this hole since #330. Whether it shows up
depends on which numbers the runner hands out. Two hits half an hour
apart, right after #2166 merged, look like timing on the hosted runners
rather than something #2166 did, but that is not proven.

**Fix (test only).** The test builds the owned tree with
`descendantProcesses`, the walk `stop` uses. After the 10 s deadline, it
also drops a member whose number now belongs to a process with a
different start time. A member with a missing start time, or a failed
table read, stays on the list, so the check still fails closed. No
product code changes.

## Validation

- **The mechanism on a real PC (home-window, Windows 11), from a scratch
script that is not committed:** in a table of 418 processes, one stale
parent number (1200) took the plain walk to 293 processes, including the
bun process running the check. The reuse-aware walk reached 289 and left
it out.
- **home-window loops** (fresh clone under `%TEMP%`, throwaway profile,
app data and temp folders, `HERDR_TEST_MODE=unit`, removed afterwards
with no bun or herdr process left): the fixed test passed 30 of 30 runs.
The unfixed test also passed 10 of 10 there. The failure needs a
server-tree process to land on one of the few stale parent numbers, so
it did not happen on this PC in 10 tries. The failures above and the
walk comparison are the evidence for the cause, not a local
reproduction.
- `bun run check fast`: green at the head commit (7968 unit tests pass,
0 fail).
- The Native Windows install job on this PR: see the reruns below.

## Reviews

- **omo-native-code-reviewer:** APPROVE, no CRITICAL, HIGH or MEDIUM. It
confirmed from the CI logs that the runner's pid is `process.pid` from
the earlier test, and that the order of the list matches a walk from
boot-time system processes down to the runner. It found no way for the
new check to pass while an owned process still runs. LOW notes: the test
and `stop` now share one walk (it keeps its own unit test in
`server/shell-agent.test.ts`); a backwards clock step between a parent's
and a child's start; a reused number costing an extra table read within
the 90 s timeout.
- **Codex (gpt-6.1-sol, fast, xhigh):** PASS, no CRITICAL, HIGH or
MEDIUM. One LOW: if an owned number is reused and the final table read
then fails, the test still fails, which is fail-closed.

CodeRabbit: test-only change, so no review requested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Own-Ovis update: follow-ups from #2048

1 participant