diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 13ff19e5..328c2326 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -71,29 +71,3 @@ jobs: - name: Check that the gate admits and owns its command's descendants shell: bash run: bash scripts/gate-check.sh "$RUNNER_TEMP/quest-lifecycle-install/bin/quest" - - windows: - name: native Windows (${{ matrix.runner }}) - if: github.event_name != 'pull_request' - strategy: - fail-fast: false - matrix: - runner: [windows-2022, windows-11-arm] - runs-on: ${{ matrix.runner }} - timeout-minutes: 15 - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - # Nix doesn't run here; package.json's packageManager pins the flake's Bun. - - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 - with: - bun-version-file: package.json - - run: bun install --frozen-lockfile - - name: Check CLI and core - run: bun run check - - name: Run the core and CLI suite - run: bun run test - - run: bun run build - - name: Verify native setup and removal without symlinks - run: bun scripts/lifecycle-check.mjs dist/quest.js diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..63d5e5d3 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,44 @@ +name: Windows + +# The native Windows suite runs nightly on main, outside pull requests and the +# merge queue, so a Windows regression may land and the next run catches it. +# GitHub reports a failed scheduled run only to the account that last changed +# the cron schedule (with Actions notifications on), not to the repository's +# watchers; that is the maintainer, whose account lands the workflow. +on: + schedule: + - cron: "23 8 * * *" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: windows-${{ github.ref }} + cancel-in-progress: true + +jobs: + windows: + name: native Windows (${{ matrix.runner }}) + strategy: + fail-fast: false + matrix: + runner: [windows-2022, windows-11-arm] + runs-on: ${{ matrix.runner }} + timeout-minutes: 15 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + # Nix doesn't run here; package.json's packageManager pins the flake's Bun. + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version-file: package.json + - run: bun install --frozen-lockfile + - name: Check CLI and core + run: bun run check + - name: Run the core and CLI suite + run: bun run test + - run: bun run build + - name: Verify native setup and removal without symlinks + run: bun scripts/lifecycle-check.mjs dist/quest.js diff --git a/quest/m1/README.md b/quest/m1/README.md index 2a897ce1..b7db80e4 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -30,6 +30,5 @@ earlier "Later work" milestone became m2. - [Launch material](/quest/m1/launch.md) - README, quickstart, demo, comparison, and launch-post drafts - [Workers in a 5-minute cache](/quest/m1/worker-cache.md) - re-plan #276's worker/coordinator split and gate tickets, after confirming the cache premise - [Retire Decisions needed](/quest/m1/decisions-needed.md) - only `## Waiting` hands a draft back, once no open draft uses the old heading -- [Native Windows suite](/quest/m1/windows-suite.md) - the native Windows jobs pass, running nightly and on dispatch instead of on every push - [Bun EFAULT report](/quest/m1/bun-efault.md) - report concurrent `rmSync` `EFAULT` on Windows, and drop the workaround once Bun fixes it - [Review harness check](/quest/m1/review-harness.md) - recurring each milestone: newest pinned review models, and the live sandbox test passes diff --git a/quest/m1/windows-suite.md b/quest/m1/windows-suite.md deleted file mode 100644 index e3ac085b..00000000 --- a/quest/m1/windows-suite.md +++ /dev/null @@ -1,77 +0,0 @@ -# [S] The native Windows suite passes nightly - -## Goal - -Check's `native Windows` jobs run nightly against `main` and on -`workflow_dispatch`, not on pull requests or in the merge group, and they -pass on both `windows-2022` and `windows-11-arm`. A Windows regression may -land; the next nightly run catches it, and GitHub's notification for a -failed scheduled run is the signal. - -## Plan - -Decided 2026-11-03 (coordinator, /quest-complete follow-ups, under the -user's 2026-11-02 instruction to decide follow-ups from evidence): plan it. -The user chose to land [moq-dev/quest#437](https://github.com/moq-dev/quest/pull/437) -and fix these failures separately. - -Decided 2026-11-03 (user, /quest-complete, on -[moq-dev/quest#455](https://github.com/moq-dev/quest/pull/455)), moving it -from m0 to m1 since Windows isn't a priority: - -- How should a Windows regression be caught before it lands? - - Run on ready PRs (recommended), not picked - - Require in the merge group, not picked - - Main only, cancelling in progress only on PRs, not picked - - ✅ Other: "I don't really care about windows, it's fine if we catch - issues nightly." - -Evidence, gathered 2026-11-03: - -- `main`'s Check has failed on every completed push since `ef8c4b50` - (15:45Z), only in its native Windows jobs. The latest, - [run 41696344037](https://github.com/moq-dev/quest/actions/runs/41696344037) - on `ee96a82e`, has 7 failures: - - `test/runner.test.ts` › "pick the other vendor…": the test expects a - `:`-joined `PATH`, while `reviewerFor` correctly joins with - `path.delimiter` (`src/runner/review.ts:51`). From - [moq-dev/quest#417](https://github.com/moq-dev/quest/pull/417). - - `test/move.test.ts` › three `quest check --fix` tests expect LF where - Windows writes CRLF. From - [moq-dev/quest#427](https://github.com/moq-dev/quest/pull/427). - - `test/worktree.test.ts` › "initializes nested submodules…" and "ignores - inherited Git location variables…" expect `original\n` and read - `original\r\n`. "fails explicitly without a supported backend" calls - the synchronous `run` helper for `worktree create`, which is now async - ("use await main for asynchronous CLI commands"). The test skips on - Linux, and only Windows runs the suite elsewhere. All three first fail - on `ee96a82e`, after - [moq-dev/quest#445](https://github.com/moq-dev/quest/pull/445) and - [#437](https://github.com/moq-dev/quest/pull/437). -- Today the Windows jobs run on every push to `main` and on dispatch - (`if: github.event_name != 'pull_request'` in - `.github/workflows/check.yml`). Check's `cancel-in-progress` cancels most - of those pushes in a busy hour, so a failure surfaces only on the last - push of a burst. The queue build (`.github/workflows/queue-build.yml`) - runs on Linux only. -- Install check's Windows jobs failing against v0.1.0 is a different cause: - v0.1.0 has no Windows assets. The next release covers it - ([Release with worktree hooks](/quest/m1/release.md)). - -Work: - -- Fix the 7 failures where each one's cause lies, so the first nightly run - starts green: compare text with line endings normalized wherever Git or - Quest may write CRLF on Windows, use `path.delimiter` in the `PATH` - expectation, and await `main` for `worktree create`. Keep each test's - assertion; never skip a test on Windows to pass. -- Run the Windows jobs on a nightly `schedule` against `main` and on - `workflow_dispatch`. Prefer nightly only, dropping them from pushes to - `main`, as the simpler and cheaper choice; keep push runs only if the - work finds a concrete reason. Whether they stay in `check.yml` or move to - a workflow of their own is this quest's call, whichever keeps the - triggers simplest. -- Rely on GitHub's failure notification for scheduled runs, which goes to - whoever last changed the workflow's cron. Add no issue filing, chat - alert, or other reporting. -- Dispatch the Windows jobs on the PR's head and record that both pass. diff --git a/src/cli/worktree-hook.ts b/src/cli/worktree-hook.ts index 81f4f95f..789dbea8 100644 --- a/src/cli/worktree-hook.ts +++ b/src/cli/worktree-hook.ts @@ -127,6 +127,13 @@ function pullRequest(cwd: string, name: string): string | undefined { return git(cwd, "rev-parse", "--verify", "--quiet", `${local}^{commit}`); } +/** The checkout whose submodule `checkout` is, or undefined for a top-level one. */ +function superproject(checkout: string): string | undefined { + // Git prints it with forward slashes on Windows, so canonical paths compare against it. + const path = git(checkout, "rev-parse", "--show-superproject-working-tree"); + return path ? canonical(path) : undefined; +} + /** Claude's name for a workflow agent's worktree, `-`, which carries no agent ID. */ const WORKFLOW_CHECKOUT = /^wf_[0-9a-f]{8}-[0-9a-f]{3}-[0-9]+$/; @@ -142,7 +149,7 @@ async function subagentCheckout(worktrees: Worktrees, input: HookInput): Promise while (path && !record) { const checkout = path; record = await waiting(() => worktrees.registered(checkout)); - path = git(checkout, "rev-parse", "--show-superproject-working-tree") || undefined; + path = superproject(checkout); } const agent = field(input, "agent_id"); if (record?.name === `agent-${agent}`) return record; @@ -178,7 +185,7 @@ export async function claudeHook( const main = mainCheckout(project); let enclosing = cwd; while (mainCheckout(enclosing) !== main) { - const parent = git(enclosing, "rev-parse", "--show-superproject-working-tree"); + const parent = superproject(enclosing); if (!parent) break; enclosing = parent; } diff --git a/src/cli/worktree.ts b/src/cli/worktree.ts index 38c52fc6..7f2b1f37 100644 --- a/src/cli/worktree.ts +++ b/src/cli/worktree.ts @@ -230,12 +230,26 @@ function changes(root: string, ignored: boolean): string[] { .split("\0") .filter(Boolean); } -/** Initialized submodule checkouts, including nested ones. NULs preserve spaces and newlines. */ -function submodules(root: string): string[] { - return git(root, "submodule", "foreach", "--quiet", "--recursive", 'printf "%s\\0" "$toplevel/$sm_path"') +/** The repository's submodule paths from its index, initialized or not. */ +function gitlinks(repository: string): string[] { + const paths = git(repository, "ls-files", "--stage", "-z") .split("\0") - .filter(Boolean) - .map(canonical); + .filter((record) => record.startsWith("160000 ")) + .map((record) => join(repository, record.slice(record.indexOf("\t") + 1))); + // A conflicted gitlink has an entry per stage. + return [...new Set(paths)]; +} +/** + * Initialized submodule checkouts, each followed by its own nested ones. Read from the index, since + * `git submodule` is a shell script that costs seconds on Windows. + */ +function submodules(root: string): string[] { + return gitlinks(root) + .filter((path) => existsSync(join(path, ".git"))) + .flatMap((path) => { + const module = canonical(path); + return [module, ...submodules(module)]; + }); } /** Module stores survive deinit; removing this worktree deletes their refs too. */ @@ -257,9 +271,7 @@ function clean(root: string): { modules: string[]; stores: Set } { const found = changes(root, false); if (found.length) throw new Error(`checkout has modified or untracked files: ${found.slice(0, 20).join(", ")}`); for (const repository of [root, ...modules]) { - for (const record of git(repository, "ls-files", "--stage", "-z").split("\0")) { - if (!record.startsWith("160000 ")) continue; - const path = join(repository, record.slice(record.indexOf("\t") + 1)); + for (const path of gitlinks(repository)) { if (entry(path)?.isDirectory() && !existsSync(join(path, ".git")) && readdirSync(path).length) throw new Error(`uninitialized submodule contains files: ${path}`); } @@ -637,7 +649,8 @@ export class Worktrees { }); try { // Cloning can need the network; the reservation stays charged without holding the shared lock. - await gitAsync(record.path, "submodule", "update", "--init", "--recursive"); + if (gitlinks(record.path).length) + await gitAsync(record.path, "submodule", "update", "--init", "--recursive"); for (const module of submodules(record.path)) { const untracked = (ref: string) => git(module, "rev-list", "-n1", ref, "--not", "--remotes").trim(); const fetch = (refs: string[]) => diff --git a/test/move.test.ts b/test/move.test.ts index d582b070..68cd9990 100644 --- a/test/move.test.ts +++ b/test/move.test.ts @@ -351,7 +351,8 @@ describe("quest check --fix", () => { /** * A feature branch that adds quest three linking one and two, while main makes `change`; - * returns the tree checked out on the feature branch, before any merge. + * returns the tree checked out on the feature branch, before any merge. Checking out the + * feature branch writes quest three with CRLF where core.autocrlf is set, as on Windows runners. */ async function diverged(change: (tree: Tree) => Promise | void): Promise { const tree = Tree.committed(); @@ -379,7 +380,7 @@ describe("quest check --fix", () => { const out = await quest(tree, "check", "--fix"); expect(out).toEqual({ code: 0, stdout: "M quest/m0/epic/three.md\nquest: 5 documents ok\n", stderr: "" }); - expect(tree.read("quest/m0/epic/three.md")).toBe( + expect(tree.read("quest/m0/epic/three.md").replaceAll("\r\n", "\n")).toBe( "# [S] Three\n\n## Goal\n\nMore.\n\n## Related\n\n- [Two](/quest/m0/epic/two.md) - similar\n", ); // The edit is left for the merge's author to stage. @@ -407,7 +408,7 @@ describe("quest check --fix", () => { const out = await quest(tree, "check", "--fix"); expect(out.code).toBe(1); expect(out.stdout).toBe("M quest/m0/epic/README.md\nM quest/m0/epic/second.md\nM quest/m0/epic/three.md\n"); - expect(tree.read("quest/m0/epic/three.md")).toBe( + expect(tree.read("quest/m0/epic/three.md").replaceAll("\r\n", "\n")).toBe( "# [S] Three\n\n## Goal\n\nMore.\n\n## Related\n\n- [Two](/quest/m0/epic/two.md) - similar\n" + "- [Nope](/quest/m0/epic/nope.md)\n\n## Plan\n\nAfter [one](/quest/m0/epic/one.md).\n", ); diff --git a/test/runner.test.ts b/test/runner.test.ts index 230fe236..c4115fa3 100644 --- a/test/runner.test.ts +++ b/test/runner.test.ts @@ -11,7 +11,7 @@ import { symlinkSync, writeFileSync, } from "node:fs"; -import { dirname, join, resolve } from "node:path"; +import { delimiter, dirname, join, resolve } from "node:path"; import { pathToFileURL } from "node:url"; import { describe, expect, test, vi } from "vitest"; @@ -2355,7 +2355,7 @@ describe("runner reviews", () => { env: { ...env, CLAUDE_CONFIG_DIR: "/runner/accounts/claude", - PATH: "/nix/store/claude/bin:/usr/bin", + PATH: ["/nix/store/claude/bin", "/usr/bin"].join(delimiter), }, }); expect(() => reviewerFor(openai, [openai, limited], home, env, 1000)).toThrow(Unreviewable); diff --git a/test/worktree.test.ts b/test/worktree.test.ts index 31d2f8ec..f31ae43b 100644 --- a/test/worktree.test.ts +++ b/test/worktree.test.ts @@ -80,6 +80,8 @@ afterEach(() => { // Cases run up to 20 real Git processes. Process creation on the Windows ARM runner // costs ~80-250 ms while other test files start, so the 5 s unit-test default is too short. +// Cases that create checkouts with submodules clone each nested repository, running +// 100-300 Git processes, so they get 60 s. describe("worktrees", { timeout: 20_000 }, () => { it("prunes declared scratch in place and keeps source, Git state, and untracked files", async () => { const { repo, worktrees } = fixture(); @@ -316,7 +318,8 @@ describe("worktrees", { timeout: 20_000 }, () => { git(repo, "commit", "-am", "submodule"); const record = await worktrees.create(repo, "nested", 10_000_000, "HEAD", ["sub/nested/inner/cache"]); const nested = join(record.path, "sub", "nested", "inner"); - expect(readFileSync(join(nested, "file"), "utf8")).toBe("original\n"); + // Git checks text out with CRLF where core.autocrlf is set, as on Windows runners. + expect(readFileSync(join(nested, "file"), "utf8").replaceAll("\r\n", "\n")).toBe("original\n"); const direct = (await claudeHook( { hook_event_name: "WorktreeCreate", cwd: nested, name: "direct" }, worktrees, @@ -369,7 +372,7 @@ describe("worktrees", { timeout: 20_000 }, () => { worktrees.restore(record.id); expect(existsSync(join(nested, "cache"))).toBe(false); expect(readFileSync(join(nested, "file"), "utf8")).toBe("local work"); - }); + }, 60_000); it("ignores inherited Git location variables that select a submodule", async () => { const { root, repo, worktrees } = fixture(); vi.stubEnv("GIT_ALLOW_PROTOCOL", "file"); @@ -389,14 +392,14 @@ describe("worktrees", { timeout: 20_000 }, () => { repo, ))!.trim(); expect(path).toBe(join(canonical(repo), ".worktrees", "agent-located")); - expect(readFileSync(join(path, "sub", "file"), "utf8")).toBe("original\n"); + expect(readFileSync(join(path, "sub", "file"), "utf8").replaceAll("\r\n", "\n")).toBe("original\n"); const [record] = worktrees.status().records; expect(record.repository).toBe(canonical(repo)); // Removal inspects the checkout itself, not the submodule the variables name. writeFileSync(join(path, "file"), "local work"); await expect(worktrees.remove(record.id)).rejects.toThrow("checkout has modified or untracked files: M file"); expect(readFileSync(join(path, "file"), "utf8")).toBe("local work"); - }); + }, 60_000); it("charges cloned module stores and keeps one that serves another worktree", async () => { const { root, repo, worktrees } = fixture(); vi.stubEnv("GIT_ALLOW_PROTOCOL", "file"); @@ -418,7 +421,7 @@ describe("worktrees", { timeout: 20_000 }, () => { git(join(record.path, "sub"), "worktree", "remove", elsewhere); await worktrees.remove(record.id); expect(existsSync(record.path)).toBe(false); - }); + }, 60_000); it("protects a live creation without giving interrupted-checkout removal advice", async () => { const { repo, worktrees } = fixture(); const creation = worktrees.create(repo, "live", 10_000_000); @@ -448,7 +451,7 @@ describe("worktrees", { timeout: 20_000 }, () => { } await worktrees.remove(record.id); expect(existsSync(record.path)).toBe(false); - }); + }, 60_000); it("keeps a partly initialized creation charged and gives recovery advice for its lock and submodules", async () => { const { root, repo, worktrees } = fixture(); vi.stubEnv("GIT_ALLOW_PROTOCOL", "file"); @@ -466,7 +469,7 @@ describe("worktrees", { timeout: 20_000 }, () => { expect(() => worktrees.release(record.id)).toThrow("git worktree unlock"); expect(() => worktrees.release(record.id)).toThrow("--force for submodules"); expect(worktrees.status().allocated).toBe(10_000_000); - }); + }, 60_000); it("keeps nested submodule files and commits, including branches whose HEAD is back at the pin", async () => { const { root, repo, worktrees } = fixture(); vi.stubEnv("GIT_ALLOW_PROTOCOL", "file"); @@ -530,7 +533,7 @@ describe("worktrees", { timeout: 20_000 }, () => { ); await worktrees.remove(record.id); expect(existsSync(record.path)).toBe(false); - }); + }, 60_000); it("serializes reservations across independent repositories and preserves failed allocations", async () => { const { root, repo, home, worktrees } = fixture(); const second = repository(join(root, "second")); @@ -781,7 +784,12 @@ describe("supervised runs", { timeout: 20_000 }, () => { it.skipIf(process.platform === "linux")("fails explicitly without a supported backend", async () => { const { repo, home } = fixture(); vi.stubEnv("QUEST_WORKTREE_HOME", home); - expect(run("--root", repo, "worktree", "create", "cli", "--reserve", "10000000").code).toBe(0); + expect( + await main(["--root", repo, "worktree", "create", "cli", "--reserve", "10000000"], { + stdout: () => {}, + stderr: () => {}, + }), + ).toBe(0); let stderr = ""; const code = await main(["worktree", "run", "cli", "--", "git", "status"], { stdout: () => {},