Skip to content

Tighten the Worker's local and test setup - #438

Merged
kixelated merged 10 commits into
mainfrom
quest/m2/worker-dev
Nov 3, 2026
Merged

kixelated merged 10 commits into
mainfrom
quest/m2/worker-dev

Conversation

@kixelated

@kixelated kixelated commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m2/worker-dev.md: parallel agents can run seeded servers without signing each other out, the seed fills the agent cards' raw output, the seeded server's wiring is smoke-checked, the project/inbox/jobs/push tests run against the shared fake GitHub, and a daily job runs each Worker test case in its own process.

Changes

  • Session cookies. Browsers share localhost's cookies across ports. The seeded server's entry Worker (cloudflare/dev/serve.ts) now prefixes every cookie the app sets with seeded-<port>., and passes the app only cookies with that prefix, stripped. Two servers sharing one cookie jar keep separate sessions. Signing out of one leaves the other signed in, and the inbox WebSocket still upgrades through the entry Worker. All three were checked by hand with curl on ports 8791 and 8792.

  • Seeded raw output. dev/seed.ts uploads raw output through the real append store a runner's uploads use: a transcript long enough to page ("Load more"), a short one, and one marked as having reached the cap. test/seed.test.ts reads all three, plus a job with no output.

  • Static assets. At the current wrangler/miniflare pins, the seeded server already serves build/public (/site.css, /app.js, /sw.js, the theme, the manifest). moq-dev/quest#258 most likely hit an older pin; moq-dev/quest#280 bumped wrangler and miniflare since. To keep it working, bun run seeded --check starts the server on a free port and checks over its socket that:

    • /site.css serves the built stylesheet
    • the session cookie carries the port prefix
    • /inbox accepts that cookie
    • /inbox rejects the same session under another server's cookie name

    just worker-test now runs this check (about 6 s). A mutation run that dropped the assets and the prefix failed both checks.

  • Shared fake. maintainerOf() in test/project-fixtures.ts now runs fakeGitHub over a fresh per-test world(). Its 16 hand-rolled knobs are gone; tests edit GitHub state instead (roles, closed issues and pulls, branch tips, signatures, review commits, merge refusals, merge methods, labels, timeline, landing).

    • inbox, jobs, push, inbox-reads, and the project setup-route tests now use the fake.
    • Injected races and outages go through intercept, or through a small failing() helper for repeated failures.
    • Push services stay an interception in front of the fake.
    • The fake gained faithful GitHub behavior: a configurable default branch everywhere it had hard-coded main, per-login roles (admin, triage, custom, or none → 404), private, archived, a detected license, allowed merge methods (405 when disallowed), file contents at any commit, and SPDX answers for the license asked about. Commit, tree, and head IDs now derive from the repository ID, so a rename or transfer keeps them.
  • Each test alone. cloudflare/scripts/isolated.ts lists every case with vitest list and runs each location (file:line) in its own vitest run process, a few at a time. A location that matches no test fails. Run it with just worker-test-isolated [--jobs N] [filters…]. .github/workflows/isolated.yml runs it daily and on dispatch, with contents: read only and no secrets or write credentials.

Choices made without asking

  • Cookie isolation lives only in the dev entry Worker, not in Better Auth's production config, so production cookie names and the login tests are unchanged.

  • The isolated job runs daily at 06:23 UTC. It would take roughly 25 minutes on a 4-core hosted runner, with a 120-minute timeout. Cases declared on one line, such as a loop's, run together in one process.

  • Two hand-written mocks stay in projects.test.ts, because the fake doesn't model their flows:

    • The picker listing. It needs several installations, including another App's and a suspended one, plus exact per-request authorization lists.
    • The service-level github() harness. It injects malformed trees, blobs, GraphQL errors, and SPDX data, and checks subrequest budgets.

    The Plan scoped the move to "where it models their flows". Login tests keep their OAuth mocks.

  • Moving the tests surfaced three tests that passed only because the old mock threw on every webhook's background read. Two now fail that read on purpose (GraphQL 502), as their scenario needs. In the push test, the world now holds issue quest: plan converging MoQ onto standalone Quest #3, as GitHub would, so the expected badge count is 4.

Validation

After merging main at ee96a82e (head 4457a19b): the land fixer's resolution of the project-fixtures.ts conflict with f3b1d044, rebuilt by quest land apply because GitHub refused the fixer's push (this PR adds a workflow), then a merge of the rest of main whose only conflict was the quest/m2/README.md link list (main deleted the gate-ownership link, this PR the worker-dev link; both dropped):

  • just check: pass.
  • just test: pass (CLI 1035 passed, 5 skipped; Worker 531 passed; seeded-server check OK).
  • quest check --base origin/main: 65 documents ok.

After merging main at 94b442f7 (main's new head-approval inbox test ported onto the fake: signed() signs the head's commit in the world, and the outsider is a read-role other(); the fake keeps main's merge-queue and check-run additions alongside the configurable default branch):

  • just check: pass.
  • just test: pass (CLI 990 passed, 2 skipped; Worker 491 passed; seeded-server check OK).

Before the merge:

  • just check: pass.
  • just test: pass (CLI 936 passed, 2 skipped; Worker 475 passed; seeded-server check OK).
  • just worker-test-isolated --jobs 8: all 371 locations passed on their own (before the migration). After the migration, the inbox, jobs, push, projects, and seed locations (194) passed on their own again.
  • The migrated files passed 4 shuffled runs with different seeds.

Follow-ups

  • Optional: model several App installations in the fake, then move the picker tests and the service-level enrollment harness onto it (exact request lists and malformed responses would go through intercept).

Review

  • Head 4457a19ba9434dfb0591c545dc049d326f4d725a: local review skipped under the guide's exemptions, by Claude Code (Opus 5.5). Since the reviewed head 94b442f7, the branch gained only the land fixer's recorded mechanical fixes (f6953a1c, and edf4bf96 rebuilt from its handback), which port main's owner IDs and review query onto the shared fake in test code, and a merge of main whose one conflict was a quest link list. Comparing git diff <base> <head> for both heads, the PR's own changes differ only in those test adaptations and the dropped link.
  • Earlier: Codex (quest review), gpt-6.1-sol, medium effort. Head 94b442f765299695cad2bdeef42d6cf132ab9eee (merge of main), round 1: no findings. Head d21ca7f9c3298f7b20364e25619062aeb74bfd95, round 1: no findings.

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

kixelated and others added 6 commits November 2, 2026 19:43
Quest-Claim: c04f2edf89b5868e
…e-check the seeded server

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…les per commit in the fake GitHub

The fake answered as if every default branch were `main`, every repository
public and MIT-licensed with every merge method, every role maintain, write,
or read, and every commit holding the default branch's files. Tests that need
otherwise mocked `fetch` themselves.

- Honor `defaultBranch` everywhere the fake named `main`, and follow a listed
  default branch for `/commits/<default>`.
- Add per-login `roles` (including null for a 404), `private`, `archived`,
  `license`, and `mergeMethods`, which refuses a disallowed merge as GitHub does.
- Answer `/contents/<path>?ref=` from the ref's tree, written trees included.
- Answer SPDX for the license asked, approving all but source-available ones.
- Derive objects from the repository ID, so a rename or transfer keeps them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hared GitHub fake

`maintainerOf` answered GitHub with a hand-written mock and knobs. It now builds
a fresh fake world per test that matches the observations it seeds, and tests
state GitHub changes as world edits: roles, a closed issue or pull request, a
moved head, a commit without a flake, reviews, labels and timeline, merge
refusals, and allowed merge methods. Races and outages wrap the fake with
`intercept` or a persistent failure. The project setup routes and the
sign-in-again and link-account pages use the fake too.

Webhook reads that used to fail on unmodeled requests now succeed, so the
tests that relied on an unread webhook fail its read explicitly, and the
world holds the issue a notified webhook names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 3, 2026 04:24
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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 42 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f9e37ea4-23b5-423b-bf39-673726a1dd52
Commits

Reviewing files that changed from the base of the PR and between ee96a82 and 4457a19.

Files selected for processing: 16
  • .github/workflows/isolated.yml
  • cloudflare/README.md
  • cloudflare/dev/github.ts
  • cloudflare/dev/seed.ts
  • cloudflare/dev/serve.ts
  • cloudflare/package.json
  • cloudflare/scripts/isolated.ts
  • cloudflare/test/inbox.test.ts
  • cloudflare/test/jobs.test.ts
  • cloudflare/test/project-fixtures.ts
  • cloudflare/test/projects.test.ts
  • cloudflare/test/push.test.ts
  • cloudflare/test/seed.test.ts
  • justfile
  • quest/m2/README.md
  • quest/m2/worker-dev.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

# Conflicts:
#	cloudflare/dev/github.ts
#	cloudflare/test/inbox.test.ts
@kixelated
kixelated added this pull request to the merge queue Nov 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 3, 2026
@moq-bot

moq-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

quest land watch: the merge queue removed this pull request at 94b442f because it conflicts with main (merge_conflict).

The land fixer works on it in the background, and the watcher re-enqueues it at the back of the queue once it is fixed or judged flaky, or hands it back here with what it needs.

(written by quest land watch)

@moq-bot
moq-bot Bot enabled auto-merge November 3, 2026 17:37
@moq-bot

moq-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

quest land watch: armed auto-merge on this pull request at f6953a1, so it joins the back of the merge queue once its required checks pass, with the land fixer's fix (codex / Codex): Merged base and re·solved fixture conflicts preserving shared fake GitHub and owner IDs; cd cloudflare && WRANGLER_SEND_METRICS=false CI=true bun run check and bun run test passed (509 tests and seeded server check)..

(written by quest land watch)

@moq-bot
moq-bot Bot added this pull request to the merge queue Nov 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 3, 2026
@moq-bot

moq-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

quest land watch: the merge queue removed this pull request at f6953a1 because it conflicts with main (merge_conflict).

The land fixer works on it in the background, and the watcher re-enqueues it at the back of the queue once it is fixed or judged flaky, or hands it back here with what it needs.

(written by quest land watch)

@moq-bot

moq-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

codex / Codex land fixer: fixer push refused: remote: Permission to moq-dev/quest.git denied to moq-bot[bot]. fatal: unable to access 'https://github.com/moq-dev/quest.git/': The requested URL returned error: 403. Recommendation: run /quest-iterate before picking it again.

	plugins: [
		// Bun loads Markdown assets as text (bunfig.toml); load them the same way here.
		{
			name: "markdown-text",
			transform(code, id) {
				if (id.endsWith(".md")) return { code: `export default ${JSON.stringify(code)};`, map: null };
			},
		},
	],
	test: {
		// Git reads none of the caller's own configuration, such as commit signing
		// with a key or program the fixtures cannot reach; each fixture sets its identity.
		// Git for Windows maps "/dev/null" to its null device but rejects os.devNull's "\\.\nul".
		env: { GIT_CONFIG_GLOBAL: "/dev/null" },
		...(live
			? { include: ["test/live/**/*.test.ts"], testTimeout: 30 * 60_000, hookTimeout: 60_000 }
			: { include: ["test/**/*.test.ts"], exclude: [...configDefaults.exclude, "test/live/**"] }),
	},
});

 succeeded in 111259ms:
$ vitest run

 RUN  v5.0.5 /work

bash "/tmp/quest-test-jk7Lxs/phase.sh"
Terminated                 command time -o /dev/null "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-jk7Lxs/leaf.js"
error: recipe `phase` failed on line 2 with exit code 143
bash "/tmp/quest-test-0vuinH/phase.sh"
Hangup                     command time -o /dev/null "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-0vuinH/leaf.js"
error: recipe `phase` failed on line 2 with exit code 129
"/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "--config=/work/bunfig.toml" "/work/src/cli/bin.ts" "worktree" "run" "work" "--" "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-AI130s/leaf.js"
bash "/tmp/quest-test-GhLH9C/phase.sh"
Terminated                 command time -o /dev/null "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-GhLH9C/leaf.js"
error: recipe `phase` failed on line 2 with exit code 143
bash "/tmp/quest-test-NC5QTV/phase.sh"
Terminated                 command time -o /dev/null "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-NC5QTV/leaf.js"
error: recipe `phase` failed on line 2 with exit code 143
"/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "--config=/work/bunfig.toml" "/work/src/cli/bin.ts" "gate" "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-qYsPWF/leaf.js"
error: recipe `run` failed on line 2 with exit code 143
"/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "--config=/work/bunfig.toml" "/work/src/cli/bin.ts" "worktree" "run" "work" "--" "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-7Zl1j0/leaf.js"
error: recipe `phase` failed on line 2 with exit code 143
"/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "--config=/work/bunfig.toml" "/work/src/cli/bin.ts" "gate" "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-Q1YdGc/leaf.js"
error: recipe `phase` failed on line 2 with exit code 129
bash "/tmp/quest-test-Xr108o/phase.sh"
Terminated                 command time -o /dev/null "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-Xr108o/leaf.js"
error: recipe `phase` failed on line 2 with exit code 143
bash "/tmp/quest-test-JIn4qE/phase.sh"
Hangup                     command time -o /dev/null "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-JIn4qE/leaf.js"
error: recipe `phase` failed on line 2 with exit code 129
bash "/tmp/quest-test-wY3YjT/phase.sh"
Terminated                 command time -o /dev/null "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-wY3YjT/leaf.js"
error: recipe `phase` failed on line 2 with exit code 143
bash "/tmp/quest-test-0mp8mX/phase.sh"
Terminated                 command time -o /dev/null "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-0mp8mX/leaf.js"
error: recipe `phase` failed on line 2 with exit code 143
"/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "--config=/work/bunfig.toml" "/work/src/cli/bin.ts" "gate" "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-FyxCiu/leaf.js"
error: recipe `phase` failed on line 2 with exit code 143
"/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "--config=/work/bunfig.toml" "/work/src/cli/bin.ts" "gate" "/nix/store/2mxhj3nrvxxqm6gf6rwnrvz048zqdclp-bun-1.4.2/bin/bun" "/tmp/quest-test-YzTxfH/leaf.js"
error: recipe `phase` failed on line 2 with exit code 129

 Test Files  28 passed (28)
      Tests  1016 passed | 2 skipped (1018)
   Start at  10:10:13
   Duration  111.16s (tests 87%, transform 9%, import 3%)


exec
/bin/bash -lc "python3 - <<'PY'
import json
from pathlib import Path
result=[{
    'number':438,
    'action':'fixed',
    'head':'b0f686d008653914672c566842527540aa6433aa',
    'reason':'Merged base and resolved the project-fixtures conflict using the shared fake GitHub with existing review support; passed root bun run build, bun run check, bun run test (1016 tests), and cloudflare bun run check, bun run test (519 tests and seeded-server check).',
    'failure':'Merge conflict in cloudflare/test/project-fixtures.ts',
    'blame':True
}]
Path('quest-land-result.json').write_text(json.dumps(result,indent=2)+'\\n')
PY
 git status --short && git log -1 --format='%H %P' pr-438 && git diff --check" in /work
 succeeded in 0ms:
?? quest-land-result.json
b0f686d008653914672c566842527540aa6433aa f6953a1cd8682d46117ae6c069e711d4f5215d8a f3b1d044fd48767fefb67af0077ce5abc48d4d1e

codex
Fixed #438 on `pr-438` at `b0f686d008653914672c566842527540aa6433aa`, resolving the fixture conflict while preserving both sides’ intent.

Builds and checks passed; 1,535 tests and the seeded-server check passed.

Wrote [quest-land-result.json](/work/quest-land-result.json) and left it uncommitted.
tokens used
57,348
Fixed #438 on `pr-438` at `b0f686d008653914672c566842527540aa6433aa`, resolving the fixture conflict while preserving both sides’ intent.

Builds and checks passed; 1,535 tests and the seeded-server check passed.

Wrote [quest-land-result.json](/work/quest-land-result.json) and left it uncommitted.
fixer result written

GitHub refused the fixer's push, so its validated resolution travels in this comment: PR head f6953a1cd8682d46117ae6c069e711d4f5215d8a, base f3b1d044fd48767fefb67af0077ce5abc48d4d1e, resolved tree 39f2e4b9576a9f71f171184a66b9ac1f9d374561. A maintainer session rebuilds the commit with quest land apply 438, reviews it, pushes it to the PR branch, and picks the PR again.

(written by codex / Codex)

The quest land fixer's resolution, rebuilt by `quest land apply` after the daemon handed it back unpushed.
@kixelated
kixelated added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 36d0429 Nov 3, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m2/worker-dev branch November 3, 2026 19:11
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