Repository navigation
Conversation
…ly after it succeeds, and install.ps1 trusts that stamp scripts/plugin-launch.ts wrote .ovis/server/from-source before bun install and the build, so a build cut off in bun install, or over the packages and client of an earlier build, looked like a choice already built. It now also writes .ovis/server/source-build: "started" before the first step, and the version and the checkout's commit only once every step returned 0. install.ps1's repair reads that stamp (a checkout without one, built by an older launcher, is still judged by its packages and client), and passes over a stop that fails only with neither a release binary nor a built client. install.ps1 and install.sh say the installed commit when OVIS_REF does not move an installed Ovis.
…orded server runs, and the stamp adds to the output check Review round on #3923: - With no release binary cached, the stop runs with OVIS_FROM_SOURCE=1, so it goes to scripts/plugin.ts with no release look-up that could fail first (offline, or its downloads failing). - A failed stop is passed over only with no release binary, no built client, and no server recorded as running: server.pid and server.owner (pid and Windows creation time), which scripts/plugin.ts's start writes and its stop reads, in the state dir herdr gives the plugin under either id or ~\.local\state. A running one (an earlier server over a build cut off after vite emptied dist, then another in bun install) stops the run, named by its pid. - A checkout counts as built only with the packages and the client, and a stamp, if any, of the version and the installed commit, or of the version alone (written where git could not tell the commit). - The installed commit is read with git without Run-Tool: a folder git cannot read no longer fails a rerun that needs no build, and a repair there says why it cannot check the ref. - The tolerance line says what is known, not a cause; install.sh's variable is prefixed.
… (throwaway, for #3923)
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
Owner
Author
|
Throwaway debug for #3923, read and closed: the star block's gh call ran with PATH past cmd.exe's 8191 characters. |
devswha
added a commit
that referenced
this pull request
Nov 15, 2026
…ly after it succeeds, and install.ps1 trusts that stamp (#3923) Follow-up to #3916 (install.ps1's repair of a branch install), before the next release. It fixes the two places where #3916's changelog fragment said more than the code did. Both were named in #3916's last reviews, and I checked each one against origin/main before changing anything. Commits two and three are review rounds: t87 at c695d61, then dori's delta review and t87 at c86d601. ## What changes 1. **A from-source build counts as finished only after it succeeds** (`scripts/plugin-launch.ts`, all platforms). The launcher wrote `.ovis/server/from-source` *before* `bun install` and the build. Two things went wrong because of that: - A build cut off in `bun install` made every rerun stop at a stop that could not load its packages. - A later build that was cut off looked finished, because an earlier complete build had left `node_modules` and `dist/index.html` behind. **What each file means:** - `.ovis/server/from-source`: **unchanged.** It means "this checkout runs from source" for the version it names. The launcher writes it before the build, and every `install` removes it first. The launcher still reads only this file. - `.ovis/server/source-build`: **new.** Each `install` removes it first. When the source path is taken, it says `started` before the marker and before `bun install`. It is replaced by `<version> <commit>` only after `bun install`, the build and the PTY-host step have all returned 0. Where git cannot read the commit, it holds the version alone. - **install.ps1** counts a checkout as built only when all of these hold: - the marker names `package.json`'s version; - `node_modules` and `dist\\index.html` are there; - the stamp is absent (an **old checkout**, built by today's launcher: still taken as built, so the update does not rebuild it), or is `<version> <installed commit>`, or is the version alone where install.ps1's own git cannot read the commit either. Where install.ps1's git *can* read HEAD, a version-alone stamp means one rebuild, and that rebuild stamps the commit. Accepting the version alone there would keep accepting a checkout that has moved since. The git-less launcher case still works: its build is taken as finished wherever the installer cannot read the commit either. **The stop before a rebuild, and one rule for a live server:** - With a cached release binary, the stop goes to it. If that stop fails, the run is refused, as before. - Without a cached binary, the stop runs with `OVIS_FROM_SOURCE=1`, straight into `scripts/plugin.ts` with no release look-up. If that stop fails, the failure is passed over: a leftover `dist\\index.html` no longer refuses on its own. That was the dead end dori found: a rebuild over an earlier finished build, cut off in `bun install`, was refused on every rerun. - Then, **whether the stop ran, failed or had nothing to run it with**, install.ps1 asks the record `scripts/plugin.ts` keeps of its server: `server.pid` and `server.owner` (pid and Windows creation time). It looks in herdr's plugin state dir under either id, in `HERDR_PLUGIN_STATE_DIR`, and in `~\\.local\\state` for a server started by hand. A live one refuses the build. - A successful stop takes the record away (`plugin.ts`'s stop removes `server.pid`), so this costs a healthy repair nothing. The tests below cover that: the release binary's server and a source server, both stopped and then built. - **The refusal** names the process. It suggests `Stop-Process -Id N` only when the creation time was compared and matched. Otherwise it says the record names a process that could not be verified as the Ovis server. - **A pid now held by another process** (the creation time differs) is not the server, so it does not refuse: the recorded server is provably gone. I kept this against Codex's MEDIUM at c86d601. Refusing would only block a repair with nothing running. Every release writes `server.pid` (since v0.1.0), and `server.owner` since v0.4.20; a record without `server.owner` counts as unverified. Vite 8.3.4 empties `dist` in `renderStart`, before chunks are rendered and written, so a cut-off build can leave no client while an earlier server still runs. Route (A) (release out of reach) and route (B) (two interruptions) are both covered by the record. 2. **`OVIS_REF` over an installed Ovis that needs no build is now mentioned.** install.ps1 used to print only "already installed". install.sh did the same, on its plugin and herdr-core paths. Both now print one line, with no network call: `the installed … is at commit <12>; OVIS_REF does not move an installed … (INSTALL.md, Update)`. - install.sh leaves the commit out when herdr names no plugin root. Before, `git -C ""` read the commit of whatever directory the installer ran in. - install.ps1 reads HEAD with `git … 2>$null` under a local `$ErrorActionPreference = 'Continue'`. A folder that is no git checkout no longer fails a rerun, and git's message stays off the console. 3. **install.ps1 no longer grows PATH on every run** (the cause of GitHub's red "Native Windows install" at c86d601, twice). install.ps1 put `%USERPROFILE%\.bun\bin;%LOCALAPPDATA%\Programs\Herdr\bin` in front of `$env:PATH` on every run. `windows-install.test.ps1` runs the installer many times in one process, so PATH grew 84 characters a run. - Measured on windows-latest with debug output, from a throwaway draft (#3925, closed and deleted): 2692 characters at the start, 8132 just before the star test's `refuses` case, 8216 inside it. - Past cmd.exe's 8191, gh's `.cmd` stand-in exited 255 with no output, so the installer saw no `404` and printed only the link. The case just before it ran at 8132 and passed. - This PR's new cases added the runs that crossed the limit. The VM's shorter PATH and user name never got there. - Now the pair is put first only when PATH does not already start with it. A first run is unchanged, and a rerun in the same session (a user's `irm … | iex` twice) no longer grows it. The changelog: I amended `changelog.d/windows-branch-install-from-source.md`. It is #3902's fragment, still unfolded, and holds both sentences, rewrapped near 100 columns. **Faults that remain after this PR:** - **A live server that left no record where install.ps1 reads**, over a built client, is built under. That covers a server not started through `scripts/plugin.ts` (for example `bun run start` in the checkout) and one started with a `HERDR_PLUGIN_STATE_DIR` other than herdr's. - Every released version writes `server.pid`, so this is never a server a release's start made. - On Windows, `bun install` then fails on the files the server holds open. The installer's failure then says a server no stop reached may still run from the checkout, and gives `Get-CimInstance Win32_Process | Where-Object CommandLine -like '*<checkout>*'` to find it and `Stop-Process` to stop it. The marker is taken back, so herdr's start path is as it was. - **With a cached release binary, a failed stop refuses every rerun, even where nothing runs**, in two states: - **A kept binary of another version over broken or missing packages.** The launcher does not run another version's binary, so the stop goes to the sources and cannot load. This is #3916's review LOW, unchanged. Recovery: remove the checkout's `.ovis\\server\\bin` and run the installer again. The stop then goes to the sources, is passed over unless a live server is recorded, and the build runs. - **A binary of this version whose stop finds a pid record it cannot verify** (the pid taken by another process since): `plugin.ts` stop says "could not verify the recorded Ovis process" and exits 1. Recovery: delete that `server.pid` in `%LOCALAPPDATA%\\herdr\\plugins\\devswha.ovis`, then run again. I did not change behaviour there in this round. This PR touches `install.*`, a `.ps1` and `scripts/plugin*`, so it waits for GitHub's own checks (Native Windows install, Real Windows install), not only a local gate. ## Validation **This round (820454a over c86d601):** - **`scripts/windows-install.test.ps1` in the Windows VM**, Windows PowerShell 5.1, a scratch copy whose `Assert` reports and continues, stopped after the repair section: - c86d601's install.ps1: 65 pass, **8 fail**. - This head's: 73 pass, 0 fail. Cases that flip (they fail at c86d601 and pass here): | case | expected now | at c86d601 | |---|---|---| | a build cut off in bun install over the client of an earlier one | stop fails, passed over, built and stamped | refused ("Could not stop…"), on every rerun | | the same, the server recorded without its creation time | refused, names the pid, no `Stop-Process` | refused with `Stop-Process -Id` | | a stamp of the version alone, which this installer's git can read the commit of | rebuilt | kept | | a server recorded as running with nothing to stop it with (no packages, no release binary) | refused, no launcher call | built under it (`install 1`) | | a failed build after a stop that could not run | the failure names the checkout to find a server by, marker taken back | "…and Ovis is stopped" | New cases that pass on both heads: - The counterpart of the first case with a recorded live server: refused, with `Stop-Process -Id`. - "a release binary's server recorded as running, stopped by its stop": built, so a successful stop clears the record and a healthy repair goes on. - The version-alone stamp where install.ps1's git cannot read HEAD either: kept. The test now uses its own herdr state dir (`XDG_STATE_HOME`) for its whole run, restored at the end. Without that, the unconditional record check found the VM's own Ovis: pid 8856, creation time verified, in `%LOCALAPPDATA%\\herdr\\plugins\\devswha.ovis`. That is live evidence that the check reads a real server's record. - **GitHub's red job, reproduced in the VM:** the real file as GitHub runs it (Windows PowerShell 5.1, `CI=true`, desktop session), with PATH padded so it reaches the runner's length. - c86d601 fails in the star block ("A yes must star once": the same lost `404`, one case earlier than on the runner because the padding is a little larger). - This head passes every section, exit 0. - Unpadded, c86d601 passes in the VM, which is why the VM's pr-check was green there. - **The full, unchanged test file in the VM's desktop session** (`Invoke-InSession`): every section printed PASS. - **git's stderr, in the VM, against a folder that is no git checkout, under `$ErrorActionPreference = 'Stop'`:** - Windows PowerShell 5.1.26100 (ConsoleHost): `2>$null` alone **throws** "fatal: not a git repository". The new form gives exit 128, an empty commit, and no error. - pwsh 7.6.9: the new form gives the same; `2>$null` alone does not throw. - `scripts/install-star.test.ts` (Linux): 44 pass, 0 fail. The new "says no commit when herdr names no plugin root, rather than the one of the directory it runs in" fails with c86d601's install.sh. - `scripts/plugin-launch.test.ts` and `scripts/changelog-fold.test.ts`: 25 pass, 0 fail. `sh -n` and `dash -n install.sh`: OK. - `bun run check fast` on 820454a, through heavy-run: passed (exit 0): workflow syntax, generated files, typecheck, build, and unit tests (17562 pass, 0 fail, 54 skip; heavy-run slot 12, 530 s). - The VM's `pr-check.ps1 -Pr 3923` at 820454a: in a PR comment. **Earlier rounds:** - c86d601: VM 54 → 61, 0 fail; routes (A) and (B); stamp plus outputs. - c695d61: origin/main 39 / 10 fail → 49 / 0; the real launcher in the VM with partial `node_modules`. **Not run:** - macOS. - `bun run check full`. - A real cut-off `bun install`. - A real build under a real unrecorded server: the bun-install-fails-on-open-files walk is the stand-in case "a failed build after a stop that could not run". - shellcheck and PSScriptAnalyzer: not on this PC, and the repo has no lint script for them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Throwaway draft for #3923's red Native Windows install: prints the star block's values on GitHub's runner. Closed and deleted once read. Do not review or merge.