Repository navigation
test(copilot): the quit test's timeout outlasts both quit deadlines, and the recording says only that later events may not have arrived - #3927
Conversation
…and the recording says only that later events may not have arrived
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
One reviewer: the owner's test-only pull request (two lines in server/copilot.contract.test.ts): one reviewer by facts.md. Merge pass note for #3927 at 0fc2a54 (test-only, two lines in server/copilot.contract.test.ts). The follow-up asked at #3924's merge. One reviewer (Codex, by the skill's rule for the owner's test-only pull request), by reading.
|
…the launcher stamps the commit its build started from (#3928) Follow-up to #3923 (merged as c9084e0), before the next release. It covers small points from #3923's last reviews (the merge pass's two review tables, dori's receipt) and from CodeRabbit's two threads on #3923. Most of them are install.ps1 refusals that now name a recovery that works. The second commit answers the reviews of a5ea99e: dori's block, and t87's two reports. This PR does not change when the installer builds, stops or refuses, except where a point says so: - point 4b: the repair's stop is told herdr's state dir; - point 7: the launcher's stamp; - point 8: which commit counts as the installed one, and which stamps are accepted where it cannot be read; - point 9: the trees a release binary is tied to. ## What changes 1. **An unverifiable record whose pid another process holds now names the file to delete** (install.ps1, `Get-RecordedServer` and the refusal). "Unverifiable" means `server.owner` is missing or cannot be read. - Before: when the stop could not run (broken or missing packages, no release binary), every rerun refused with "check what it is before stopping it", and nothing ever cleared the record. - Now: `Get-RecordedServer` gives back the `server.pid` file it read. The refusal names that file's full path and says to delete it if the process is not Ovis, then run again. 2. **A failed stop through a kept release binary now names its recovery** (the refusal "Could not stop the Ovis the release's binary runs"). One recovery for each state: - **The kept binary is of another version** (or its `ovis-server.json` cannot be read). Now: remove `<checkout>\.ovis\server\bin`, then run again. - **A binary of this version that fails its check** (signature, executable or bundled client: `scripts/server-install.ts` `verifiedInstall`), with the release out of reach, and no server recorded as running. The stop never reached a server. Now it says so and gives the same recovery: remove the folder. *(second commit)* - **The binary is of this version, and its stop cannot verify a live pid** (the pid in `server.pid` is another process's now, or the record has no creation time). Now the refusal names that `server.pid` and says to delete it if the process is not Ovis. - **A verified server that the stop failed to stop.** As before, plus "It runs as process N (Stop-Process -Id N stops it)". 3. **"Ovis is stopped" is said only after a stop that stopped one.** `scripts/plugin.ts`'s stop exits 0 both for a server it stopped (stdout `stopped Ovis (pid N)`) and for none (`Ovis is not running`). install.ps1 now reads that line; there is no new protocol. A build that fails after a stop that stopped nothing keeps the "an Ovis no stop reached may still run … `Get-CimInstance`" advice. 4. **A server started by hand.** - **(a) Its refusal says what it is.** A record in `~\.local\state\ovis` or `\herdr-web-ui` belongs to any hand-started Ovis, from any checkout. The refusal now reads "An Ovis started by hand is recorded as running in `<dir>`". - **(b) The repair's stop no longer stops it.** *(second commit)* The stop is now told `HERDR_PLUGIN_STATE_DIR = <herdr state>\plugins\<id>`, as herdr's own stop and the installer's legacy move are (the caller's value is kept when it has one). - Run without it, `scripts/plugin.ts` takes a live record in `~\.local\state` first. With packages that load, it stopped a hand-started server, possibly another checkout's, before any refusal. - Now that server is left running, and the record check refuses with (a). - The record holds nothing that names its checkout (`server.pid`: the pid; `server.owner`: pid and creation time), so the installer refuses it rather than guessing. 5. **The changelog fragment** (`windows-branch-install-from-source.md`, #3902's, still unfolded): every sentence now holds. The installer stops a server that herdr's start recorded, where the checkout can run that stop. Where a recorded server still runs (one started by hand among them), or the kept binary cannot run the stop, nothing is built, and it says what to stop or remove. 6. **A failed build where no stop could run and no record was found** prints a short line instead of the long `Get-CimInstance` advice. 7. **The launcher's finished stamp names the commit the build started from** (`scripts/plugin-launch.ts`, from CodeRabbit's thread on #3923 at `:94`). - HEAD is read before the build and again after it. The stamp becomes `<version> <commit>` only when both reads agree; otherwise it stays `started`, with one line on stderr. The launcher still returns 0: the build did succeed, and herdr's own build step runs the same launcher. - *(second commit)* install.ps1 re-reads the stamp after its build. When it is still `started`, it says that the checkout moved while it was built, that herdr's next start still runs that build as it is, and that a run with `OVIS_REF` naming the commit the checkout is at now builds that one. 8. **One rule for the installed commit: a checkout's top level only.** `git -C <dir> rev-parse HEAD` reads the repository that *contains* `<dir>`. - All three readers now ask `git rev-parse --show-prefix` first and read HEAD only when it prints nothing: install.sh `ref_not_moved`, install.ps1 `$installedCommit`, and *(second commit)* the launcher's `headCommit()`. So a plugin folder inside another repository has no commit, and its launcher stamps the version alone. - I used `--show-prefix` instead of comparing `--show-toplevel` with the folder as resolved paths. It gives the same answer without comparing Windows path spellings (8.3 names, junctions, slashes, case). - *(second commit)* **Where install.ps1 cannot read the commit, it accepts any stamp whose first word is this version.** That covers `<version> <commit of the repository around it>`, which #3923's launcher (and a5ea99e's) already wrote in a nested folder. install.ps1 is fetched fresh on every `irm | iex`, so those users would otherwise hit a refusal the moment this merged. Where it *can* read the commit, nothing changes: the stamp must name it, so a moved checkout is rebuilt once. - Only a nested or git-less folder whose build really is unfinished (`started`, or packages or client missing) is still refused, because the installer cannot tell whether that folder is `$Ref`. That refusal now gives its recovery: stop Ovis, run `$env:OVIS_FROM_SOURCE = '1'; bun '<root>\scripts\plugin-launch.ts' install`, then run again. The launcher builds the folder as it is and stamps the version alone, which the next run accepts. 9. **The release binary's source trees are this folder's own** *(second commit, same family)*. `sourceTrees` (`scripts/server-manifest.ts`) read `HEAD:server`, which git resolves from the repository's top level. In a folder inside another repository, that named the surrounding repository's `server/`. It now reads `HEAD:./server` and `HEAD:./shared`. A tree id names content, so it holds at any depth; it needs no top-level rule, only the folder's own path. **Readers of the commit that keep their rule, and why:** `scripts/plugin-runtime.ts`, `server/managed.ts` and install.sh's release lookup (`install.sh:324`) compare HEAD with the `source_revision` that `server/updater.ts` wrote from its own `git rev-parse HEAD`. They form one writer–reader pair, read at the same depth, and never meet the stamp or the installers' commit. Moving only the readers to the top-level rule would split them from the updater. What the updater does in a folder inside another repository is its own question, outside this PR. ## States touched | state | before | after | |---|---|---| | unverifiable record (no `server.owner`), live pid of another process, stop cannot run | refused on every rerun, "check what it is before stopping it" | refused, names `<dir>\server.pid` to delete if it is not Ovis; deleting it lets the next run build | | kept release binary of another version over broken packages | "Could not stop … Stop it (stop-windows, or restart herdr)" on every rerun | names `<checkout>\.ovis\server\bin` to remove; removing it lets the next run build | | kept binary of this version failing its check, release out of reach, no record | the same dead end | says no server is recorded and the binary failed its check; names the folder to remove; removing it lets the next run build | | kept binary of this version, stop cannot verify a recorded live pid | the same dead end | names that `server.pid` to delete if that process is not Ovis; deleting it lets the next run build | | hand-started server recorded in `~\.local\state`, packages that load the stop | the repair's stop stopped it (any checkout's), then built | left running; refused: "An Ovis started by hand is recorded as running in `<dir>`" | | the same, the stop cannot load | "Ovis still runs from this checkout" | "An Ovis started by hand is recorded as running in `<dir>`" | | build fails after a stop that found no server | "and Ovis is stopped" | "an Ovis no stop reached may still run …" with the `Get-CimInstance` line | | build fails, nothing to run a stop with, no record | the long `Get-CimInstance` advice | a short line | | HEAD moved during the launcher's build | stamp `<version> <new commit>` | stamp stays `started`; install.ps1 says so | | nested plugin folder (inside another repository), finished build | commit of the repository around it printed and compared | no commit; launcher stamps `<version>`; accepted | | nested folder with a stamp `<version> <outer commit>` from #3923's launcher | accepted (both sides read the outer commit) | accepted (any stamp of this version, where the commit cannot be read) | | nested folder, build unfinished | refused ("is it a git checkout?") at a5ea99e | refused with the recovery (build it with its launcher); following it, the next run accepts it | | release binary's source trees in a nested folder | the outer repository's `server/` and `shared/` | the folder's own | ## Faults that remain - **A build left `started` because HEAD moved is still used by the next plain start on every platform.** The start reads only the marker. That is no worse than main, where the stamp claimed the new commit and nobody noticed. install.ps1 now says it, and its next run with `OVIS_REF` naming the commit rebuilds it. A rebuild at start (herdr's start hook, possibly over a running server) is its own change. - **With no git on PATH, the launcher fails on every command**, in `sourceTrees` (`Bun.spawnSync` throws ENOENT), before it stamps anything, as on main. Follow-up: catch the spawn error there and return `{ error }`. - **A live server that left no record where install.ps1 reads is built under**, as #3923's body says. The `Get-CimInstance` line a failed build prints finds it; it matches on `CommandLine`, so it can also list an editor or shell opened on the folder. - **The commit readers of the updater pair keep any depth**: `plugin-runtime.ts`, `managed.ts`, `install.sh:324`, `updater.ts` (see above). ## Validation On 260f292 (the second commit, over a5ea99e). origin/main moved meanwhile to fd6ca75 (#3927, a copilot test, no overlap); not rebased, so that this push needs no force-push. **This round:** - **`scripts/windows-install.test.ps1` in the Windows VM**, Windows PowerShell 5.1.26100, in the VM's desktop session (`Invoke-InSession`), with `CI=true`, run as ci.yml runs it, in a clone of a5ea99e with this commit's `install.ps1` and test file: - unpadded (PATH 335 characters at the start): every section printed PASS, exit 0; - **PATH padded to 2710 characters at the start**: every section printed PASS, exit 0. - **Counts, the whole file**, from a scratch copy whose `Assert` counts and continues, with this commit's test file: | install.ps1 | pass | fail | |---|---|---| | c9084e0 (main), round 1 | 174 | 10 | | a5ea99e (this PR's first commit) | 189 | 9 | | 260f292 (this commit) | 195 | 3 | The 3 failures in every row are the gh-ordering negative control, which relies on `Assert` throwing (an artifact of the counting copy; the real file passes that section). At a5ea99e these new cases fail: - "the same, with packages that load the stop: it is left running": the stop stopped the hand-started server and the run built (2 assertions); - "the same, stamped by an earlier launcher with the commit of the repository around it": "git could not read the commit…", the HIGH; - "a build cut off in a folder inside another git checkout": no recovery named; - "a kept release binary of this version that fails its check, the release out of reach": "Stop it … or restart herdr"; - "a build during which the checkout moved to another commit": nothing said. "the same, stamped with the version alone by the launcher" passes at a5ea99e too, since that form was already accepted there. Each refusal case with a recovery does what the message says and asserts the next run builds, or, for the nested folder, accepts the folder with the stamp the launcher wrote (`1.2.3`). - The stand-in's stop now reads only the state dir it is told (else `~\.local\state`'s while a pid is recorded there, else herdr's), as `scripts/plugin.ts` does. The stand-in launcher stamps the version alone where the git stand-in reads no commit, leaves `started` when HEAD moves, and fails for a kept binary that fails its check. The git stand-in's first line is `$global:LASTEXITCODE = 0` (line 33), which also covers its `--show-prefix` answer (dori's LOW; no change needed). - **TS tests** (Linux, `HERDR_TEST_MODE=unit`): `plugin-launch.test.ts`, `install-star.test.ts`, `changelog-fold.test.ts`, `server-manifest.test.ts`: 99 pass, 0 fail. The new tests fail without their change: - "stamps the version alone for a folder that is not a checkout's top level…", against a5ea99e's HEAD-only `headCommit` in a scratch copy: 14 pass, 1 fail; - "the git trees … are the folder's own server/ and shared/…", against the old `HEAD:server`: 26 pass, 1 fail. - `sh -n` and `dash -n install.sh`: OK. - **`bun run check fast`** through heavy-run (slot 10, 522 s): exit 0, unit tests 17566 pass, 0 fail, 54 skip. - The VM's `pr-check.ps1` at this head: in a PR comment. **Round 1 (a5ea99e):** VM counts c9084e0 174/10 → a5ea99e 181/3 with that round's test file; the real file passed unpadded and padded; 71 TS tests; `check fast` exit 0 (17564 pass); VM pr-check PASS; Native Windows install and Real Windows install passed. **Not run:** macOS; `bun run check full`; the real launcher with HEAD moved during a real `bun install` (the test stands in for git); a real cut-off build, a real Ovis release binary failing its check, or a real hand-started Ovis in the VM (the states are made with the test's stand-ins, and its own process as the recorded server); a real plugin folder nested in another repository on Windows (the git stand-in answers `--show-prefix`; the launcher's rule is run with real git on Linux); shellcheck and PSScriptAnalyzer.
Change
Two changes to one test in
server/copilot.contract.test.ts, "binds only the reported UUID to the foreground process's home and rejects old cursors after a switch". Both were asked for by the merge pass on #3924. No deadline and no assertion changed.(later events may not have arrived yet).The arithmetic
:quit, measured on passing runs (a printing scratch copy, the CI way, three whole-file runs)On top of that sum, each deadline needs one more loop turn (an RPC and a 50 ms sleep) and the error itself needs two RPCs and a log read. The forced run below took 23.88 s, which matches the sum. At 20 s the timeout fired 3.9 s early. 30 s leaves about 6 s for a slower runner, and it is the timeout the test just above this one in the same file already uses. Passing runs are unaffected: 2.04 to 2.61 s in the ten runs below.
Forced failure, before and after
A scratch copy of the file (not committed) changes three things. The acknowledgement is held back, so the full 2 s bound runs out. The first deadline's loop keeps waiting until 50 ms before its deadline, so the stand-in leaves only at the end of the first 10 s. The second deadline's condition is forced to stay true, so that deadline expires. Each run was the whole file, the CI way, in a 2-core heavy slot (Node 22.23.3, herdr 0.9.3).
After (this branch): the test fails with the deadline's error and its recording after 23.88 s, inside the 30 s timeout:
Before (main's file, same forcing): the test failed on its own timeout. The deadline's error came about 4 s later, as an "Unhandled error between tests" printed after later tests had already started, so it was attributed to no test:
The brief's literal forcing (only the acknowledgement held back and the second deadline forced; the stand-in leaves at once) ends in the deadline's error on both files, after 13.62 s on main and 13.59 s here. That path never reached 20 s, so it was not the one at risk.
Validation
server/copilot.contract.test.ts, the whole file, at 45f5e5c1c (this commit on 016cb60; the branch was then rebased onto c9084e0, whose fix(install): the plugin's launcher stamps a source build finished only after it succeeds, and install.ps1 trusts that stamp #3923 touches only install and plugin-launcher files, so the test file and everything it imports are the same), run 10 times the CI way in a 2-core slot of~/.ovis-toolchain/heavy-run.sh(HERDR_TEST_MODE=integration bun scripts/check.ts run bun test --timeout 15000 ./server/copilot.contract.test.ts, Node 22.23.3, herdr 0.9.3): 10/10 runs passed all 8 tests. The changed test took 2.04 to 2.61 s. "retries failed Copilot page reads..." passed in all ten runs.bun run typecheck: exit 0.HERDR_TEST_MODE=unit bun test server/conventions.test.ts: 16 pass, exit 0.bun run check fast(in the heavy slot): exit 0 at 45f5e5c1c (530 s; local Node v24.18.0, with the check's warning that CI uses Node 22), and exit 0 again at the rebased head 0fc2a54 (517 s).bun run check full, the browser lanes, and the other integration files. This change touches only one test file's timeout and one message string.