Repository navigation
fix(machines): let the own-Ovis update token open only its two requests (#2054) - #2193
Conversation
…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.
|
Warning Review limit reachedYou'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. View limit details
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. Comment |
|
Merging 0daa538 after a strict authentication review. omo-native-code-reviewer and Codex both pass this head. With the bridge token, only |
…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.
What
Closes #2054: the last LOW items of its follow-ups from #2048. #2071 had already fixed both MEDIUMs and three LOWs.
GET /api/updates?anything=1,HEAD/POST /api/updates, andGET/PUT /api/updates/installall passed its gate. It now opens exactlyGET /api/updatesandPOST /api/updates/install, each with no query string (server/index.ts,bridgeUpdatePath). The only caller,ownOffer/runOwnUpdateinserver/machines.ts, sends exactly those two requests.ownOvisAction/ownUpdateFailureget the unit test the issue asked for (src/components/MachineSidebar.test.ts). The server half of that item (the job'sremote_ovis) is already asserted since fix(machines): keep reconnecting to a PC's own Ovis while it restarts #2071.Left out, and why
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.updatable: falsewithsetup, andremote_ovisis 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.jobsmap. 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:
ownOfferreads/api/accesswith the bridge token, which never opened that route. A token-gated own Ovis therefore loses its relayed port and its https link.Verification
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.curl -iand the bridge token:GET /api/updates-> 200 andPOST /api/updates/install-> 202. With?anything=1,HEAD,POST /api/updates,GET /api/updates/installorPOST /api/updates/install?x=1-> 401.ownOvisActiontest: a mutation where it returns the offer unconditionally makes it fail.bun run check fastgreen (typecheck, build, unit 7957 pass).?(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_VERSIONis unchanged: only the release PR raises it.