Skip to content

CI: give the overlay rail harness the vite it needs, and tighten the wildcard-host detector - #9654

Merged
danielhanchen merged 1 commit into
mainfrom
ci-overlay-rail-vite-toolchain
Aug 24, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-overlay-rail-vite-toolchain

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Two CI guards, one broken since yesterday and one weaker than it looks. Both diagnosed against the runs rather than guessed at.

The overlay rail step has never worked on a warm cache

Overlay rail shadow gutter, other engines (Playwright) has failed on every studio-ui-smoke run since #9246 added it, and passed on #9246's own run. Identical commit content, opposite result, so it reads as flake. It is not.

The harness serves its own vite through npm run dev in studio/frontend. That job never installs the frontend dev dependencies. It installs Studio, and studio/setup.sh installs them only when it has to build the frontend. The frontend-dist cache exists precisely to stop that build, and frontend-dist-restore asserts the installer reported the frontend up to date. So:

  • cache miss: setup.sh builds, node_modules exists, the step passes
  • cache hit: no node_modules, npm run dev exits 127 with sh: 1: vite: not found, the step fails

#9246's run logged Cache not found for input keys: fe-dist-Linux-4b4d8135.... The runs since log Cache hit for the same key.

The harness is not at fault, and neither is its use in studio-frontend-ci.yml, where npm ci has already run. Only the new step's assumption was wrong. Its comment says the step sits on that shard because "WebKit's install is already paid for", which is true of the browsers and not of the toolchain.

So the shard installs the dependencies itself, conditional on the binary rather than unconditional: on the cold-cache path setup.sh has already put them there, and npm ci would delete and refetch them for nothing. The step then checks the binary arrived, because a silent install would surface later as a Playwright timeout instead of a missing toolchain.

I kept the step where it is rather than moving it to studio-frontend-ci.yml. Moving it would trade an npm ci for a playwright install firefox webkit, and the reason the step is on this shard in the first place is that those two browsers are already there.

start_vite now names the cause

"vite exited with code 127" reads as a vite crash. The toolchain was never installed, and no retry or port change helps. A missing toolchain and a broken one are different failures and must not look the same, so start_vite refuses up front with the cause and the remedy, including why a dist-cache job in particular ends up without one. This is what made the failure look like flake for a day.

The wildcard-host detector let a real shape through

Separately, the detector added in #9623 anchored on a command at the start of a line:

/^[[:space:]]*(\$[[:space:]]*)?unsloth[[:space:]]+studio([[:space:]]|$)/

Documented commands are regularly prefixed, and UNSLOTH_STUDIO_PASSWORD='x' unsloth studio --host=0.0.0.0 in the Launch section passed the guard. Confirmed by injecting it into README.md: exit 0 before, exit 1 now. It matches the command anywhere on the line instead.

Twelve fixtures pin the detector itself. Every negative assertion in that file passes when the detector sees nothing, so a detector that quietly stops matching turns the whole file green while guarding nothing:

PASS: detector: bare wildcard bind
PASS: detector: long flag
PASS: detector: long flag with =
PASS: detector: trailing flags after the bind
PASS: detector: shell-prompt prefix
PASS: detector: inline env assignment prefix
PASS: detector: indented inside a fenced block
PASS: detector: loopback default is not a wildcard
PASS: detector: an explicit loopback bind is not a wildcard
PASS: detector: a longer address starting 0.0.0.0 is not the wildcard
PASS: detector: another program's wildcard bind is not ours
PASS: detector: an empty window finds nothing

To be clear about #9623 itself: its rescoping was right. The README moved the -H 0.0.0.0 opt-in out of #### Launch and into #### Remote HTTPS & LAN Access in e264bba, which is a better home for it, so the guard's assumption about where the text lived was the thing that was wrong, not the README. This only tightens the detector it introduced.

Checked

tests/sh/test_install_host_defaults.sh: 23 passed, 0 failed on a clean tree. Mutation-tested, all four caught, and clean again afterwards:

injected into README before after
unsloth studio -H 0.0.0.0 in Launch caught caught
UNSLOTH_STUDIO_PASSWORD='x' unsloth studio --host=0.0.0.0 in Launch missed caught
$ unsloth studio -H 0.0.0.0 in Launch caught caught
opt-in deleted from the Studio quickstart caught caught

_require_frontend_toolchain verified both directions: it raises on a tree with no node_modules, start_vite refuses before spawning npm, and it accepts a tree carrying vite or the Windows vite.cmd. shellcheck clean at -S warning, ruff clean, bash -n clean, and the workflow parses with the install step ordered ahead of the overlay rail step.

…it is missing

`Overlay rail shadow gutter, other engines` has failed on every studio-ui-smoke
run since #9246 added it, and passed on #9246 itself. The difference is the
frontend-dist cache.

The harness serves its own vite via `npm run dev` in studio/frontend. That job
never installs the frontend dev dependencies: it installs Studio, and setup.sh
installs them only when it has to build the frontend. The frontend-dist cache
exists precisely to stop that build, and the restore action asserts the
installer reported the frontend up to date. So on a cache miss setup.sh builds,
node_modules exists and the step passes; on a hit there is no node_modules,
`npm run dev` exits 127 with `sh: 1: vite: not found`, and the step fails.
#9246's own run missed the cache. Every run since has hit it.

The harness is right and its use in studio-frontend-ci.yml is right, where
`npm ci` has already run. Only the new step's assumption was wrong: what that
shard has already paid for is the WebKit and Firefox install, not a frontend
toolchain.

So the shard installs the dependencies itself, conditional on the binary rather
than unconditional, because on the cold-cache path setup.sh has already put them
there and `npm ci` would delete and refetch them. The step then checks the binary
actually arrived, since a silent install would surface later as a Playwright
timeout rather than as a missing toolchain.

start_vite now refuses up front with the cause and the remedy. "vite exited with
code 127" reads as a vite crash; the toolchain was never installed, and the two
must not look the same. This is what made the failure look like flake: identical
job, identical commit, green or red depending on a cache key.

While here, the wildcard-host detector added in #9623 only matched a command at
the start of a line, so `UNSLOTH_STUDIO_PASSWORD=... unsloth studio -H 0.0.0.0`
in the Launch section passed the guard. It now matches the command anywhere on
the line. Twelve fixtures pin what the detector must catch and must not, because
every negative assertion in that file passes when the detector sees nothing: a
detector that quietly stops matching turns the whole file green while guarding
nothing.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56a4bccd63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

raise RuntimeError(
f"{host}:{port} is already serving. Stop it, or move this harness with SMOKE_PORT."
)
_require_frontend_toolchain()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the lifecycle test's toolchain independence

On a fresh checkout without studio/frontend/node_modules, this new precondition makes test_start_vite_picks_the_platform_process_group fail before reaching its mocked Popen. That test explicitly promises that everything is monkeypatched and requires neither npm nor frontend dependencies, so focused lifecycle tests and clean Python-only test runs now fail unless an unrelated npm ci has run first. Mock this preflight in the lifecycle fixture or test the preflight separately while keeping the process-group unit test isolated.

Useful? React with 👍 / 👎.

if [ -x node_modules/.bin/vite ]; then
echo "vite already present from the frontend build; not reinstalling"
else
npm ci --no-fund --no-audit

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply the frontend install-script gate to this npm ci

On the warm-cache path this newly added npm ci runs under setup-node's bundled npm without the repository's pre-install supply-chain scan or --strict-allow-scripts. The hardened install in .github/workflows/studio-frontend-ci.yml lines 99-136 explicitly upgrades npm because Node 22 bundles npm 10, scans before installation because a compromised tarball's prepare/postinstall executes during npm ci, and then enforces the allowlist. As written, every banner shard bypasses those protections and executes any lifecycle script introduced through the lockfile; use the same guarded install sequence here, or --ignore-scripts if this Vite-only harness does not need lifecycle scripts.

Useful? React with 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member Author

Independently confirmed the overlay-rail half, and it matches your diagnosis exactly. Recording the evidence here so nobody re-opens the infra theory.

Job 97391286915, step 31:

RuntimeError: vite exited with code 127 before serving http://127.0.0.1:5197/smoke-overlay-rail.html?nostrict

> [email protected] dev
> vite --host 127.0.0.1 --port 5197 --strictPort

sh: 1: vite: not found

Two things rule out the infra reading that the same log invites. That job carries E: Failed to fetch ... libcurl4-openssl-dev_8.5.0-2ubuntu10.11_amd64.deb 404 Not Found, and WebKit needs libcurl, so a broken apt mirror looks like a plausible cause. It is not:

  • Linux deps (step 3) and Install Playwright browsers (step 14) both concluded success.
  • Step 30, Update banner layout, other engines, runs for engine in firefox webkit and passed: [banner] 1433 checks, 0 failed. WebKit launched and drove a full suite one step earlier.

So no browser was ever reached. The step died in npm run dev before Playwright started.

Confirming the mechanism you describe, from the same log: Cache hit for: fe-dist-Linux-4b4d8135b0e287da756578d9377bfaf237da0c9dd0612286ffc96edc764f8043, then restored a prebuilt frontend; setup.sh will report it up to date. studio/setup.sh takes the step "frontend" "up to date" return at line 1121 and never reaches substep "building frontend..." at line 1265, so the npm install never runs and node_modules never exists. Worth being precise that this is a skipped build rather than a cleanup: the rm -rf node_modules at studio/setup.sh:1317 is only on the bun-failure path, so on a cache hit nothing is removed, it is simply never created. Same outcome, and your conditional-on-the-binary install is the right shape for it, since the cold-cache path already has them.

Verified locally that the install is sufficient: npm ci --ignore-scripts --no-fund --no-audit in studio/frontend adds 1047 packages in 14s and npm run dev -- --version reports vite/8.0.16. --ignore-scripts is safe here, the lockfile has three packages with install scripts (@biomejs/biome, msw, vite/node_modules/fsevents) and none of them is on the vite dev-server path. start_vite runs with cwd = FRONTEND, so working-directory: studio/frontend puts them where it looks.

_require_frontend_toolchain is the right call. #9622 fixes the same step and this supersedes it.

On the second half, the test_install_host_defaults.sh changes. The twelve detector fixtures are a genuinely good idea and I have taken them into #9655, extended to twenty. Two things I would still flag:

  • The README half keeps both heading slices from CI: keep the host-default README guard scoped to Studio docs #9623, /^#### Launch$/ and /^### Unsloth Studio \(web UI\)$/. Renaming those three headings and changing nothing else takes the file red with FAIL: README: Launch section exists and FAIL: README: Studio quickstart documents a wildcard-host opt-in. That slice has now broken twice on correct README edits and the file is edited directly and often.
  • The four installer assertions still use the literal needle. Injecting unsloth studio -p 8888 -H 0.0.0.0 into studio/setup.sh's launch hint still gives PASS: studio/setup.sh: launch hint has no '-H 0.0.0.0', because the flag is no longer adjacent to the subcommand. Same for install.sh, install.ps1 and the generated launcher.

#9655 handles both: it parses the README's fenced blocks with no heading involved, and it derives the -H / --host spellings from the typer.Option in unsloth_cli/commands/studio.py so one detector covers the README and all four installer windows.

We overlap only on tests/sh/test_install_host_defaults.sh. Cleanest split is for this PR to keep the overlay-rail work, which #9655 does not touch at all, and drop the test-file half; otherwise whichever lands second needs a manual resolution rather than a clean merge.

@danielhanchen
danielhanchen merged commit f2fa54f into main Aug 24, 2026
27 of 28 checks passed
@danielhanchen
danielhanchen deleted the ci-overlay-rail-vite-toolchain branch August 24, 2026 22:36
oobabooga pushed a commit to vineethsaivs/unsloth that referenced this pull request Aug 24, 2026
…efusal (unslothai#9656)

unslothai#9654 added an up-front toolchain refusal to start_vite so a job with no
node_modules fails with the cause instead of 'vite exited with code 127'. That
is right, and the two process-group tests were simply not updated for the new
precondition: they exercise which process-group flag the platform gets, they
already stub the sibling _port_is_taken precondition for the same reason, and
this file's own docstring promises nothing here touches npm or a real install.

So the tests get a synthetic frontend tree in tmp_path with a vite shim, not a
stubbed-out check. A stub would keep them green if the refusal were deleted;
a tree makes the check run and pass on its merits.

Adds the tests the refusal never had: it must reject a tree with no toolchain
BEFORE anything is spawned, accept the bun and Windows shims as well as the
POSIX name, and report a missing checkout as its own failure.
rhsCZ pushed a commit to rhsCZ/unsloth that referenced this pull request Aug 25, 2026
Picks up unslothai#9654 and unslothai#9656, which clear the overlay rail shard, and the Apertus
mapping fix. No conflicts.
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.

1 participant