@muggleai/works 5.24.0 → 5.25.0-staging.184

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +1 -0
  3. package/dist/{chunk-FEHTWWVH.js → chunk-BJGZAKBB.js} +234 -5
  4. package/dist/{chunk-GLTZIZVT.js → chunk-CE5HUVNQ.js} +26 -2
  5. package/dist/cli.js +2 -2
  6. package/dist/index.js +2 -2
  7. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  8. package/dist/plugin/.codex-mcp.json +1 -1
  9. package/dist/plugin/.codex-plugin/plugin.json +1 -1
  10. package/dist/plugin/.cursor-plugin/plugin.json +1 -1
  11. package/dist/plugin/.mcp.json +1 -1
  12. package/dist/plugin/agents/test-prepare-runner.md +3 -3
  13. package/dist/plugin/skills/_shared/dev-loop/run.md +4 -1
  14. package/dist/plugin/skills/_shared/post-merge-cleanup.md +7 -6
  15. package/dist/plugin/skills/_shared/pr-branch-worktree.md +7 -6
  16. package/dist/plugin/skills/_shared/sync-branch-with-base.md +39 -4
  17. package/dist/plugin/skills/_shared/use-worktrees.md +12 -6
  18. package/dist/plugin/skills/do/e2e-acceptance.md +1 -1
  19. package/dist/plugin/skills/do/pre-flight.md +1 -1
  20. package/dist/plugin/skills/do/wave-e2e.md +2 -2
  21. package/dist/plugin/skills/muggle-preferences/preference-gates/autoRebase.md +3 -3
  22. package/dist/plugin/skills/muggle-test/execute-local.md +2 -2
  23. package/dist/plugin/skills/muggle-test-feature-local/SKILL.md +3 -8
  24. package/dist/plugin/skills/muggle-test-prepare/SKILL.md +42 -29
  25. package/dist/plugin/skills/muggle-test-prepare/steps/check-running.md +25 -10
  26. package/dist/plugin/skills/muggle-test-prepare/steps/e2e-instructions.md +1 -1
  27. package/dist/plugin/skills/muggle-test-prepare/steps/env-file.md +8 -5
  28. package/dist/plugin/skills/muggle-test-prepare/steps/readiness-report.md +22 -18
  29. package/dist/plugin/skills/muggle-test-prepare/steps/rebase-check.md +13 -1
  30. package/dist/plugin/skills/muggle-test-prepare/steps/replay-or-learn.md +2 -2
  31. package/dist/plugin/skills/muggle-test-prepare/steps/resolve-sources.md +39 -0
  32. package/dist/plugin/skills/muggle-test-prepare/steps/reuse-plan.md +7 -5
  33. package/dist/plugin/skills/muggle-test-prepare/steps/smoke-test.md +2 -2
  34. package/dist/plugin/skills/muggle-test-prepare/steps/start-services.md +4 -4
  35. package/dist/release-manifest.json +3 -3
  36. package/dist/src-BYDDPSF6.js +1 -0
  37. package/package.json +2 -2
  38. package/plugin/.claude-plugin/plugin.json +1 -1
  39. package/plugin/.codex-mcp.json +1 -1
  40. package/plugin/.codex-plugin/plugin.json +1 -1
  41. package/plugin/.cursor-plugin/plugin.json +1 -1
  42. package/plugin/.mcp.json +1 -1
  43. package/plugin/agents/test-prepare-runner.md +3 -3
  44. package/plugin/skills/_shared/dev-loop/run.md +4 -1
  45. package/plugin/skills/_shared/post-merge-cleanup.md +7 -6
  46. package/plugin/skills/_shared/pr-branch-worktree.md +7 -6
  47. package/plugin/skills/_shared/sync-branch-with-base.md +39 -4
  48. package/plugin/skills/_shared/use-worktrees.md +12 -6
  49. package/plugin/skills/do/e2e-acceptance.md +1 -1
  50. package/plugin/skills/do/pre-flight.md +1 -1
  51. package/plugin/skills/do/wave-e2e.md +2 -2
  52. package/plugin/skills/muggle-preferences/preference-gates/autoRebase.md +3 -3
  53. package/plugin/skills/muggle-test/execute-local.md +2 -2
  54. package/plugin/skills/muggle-test-feature-local/SKILL.md +3 -8
  55. package/plugin/skills/muggle-test-prepare/SKILL.md +42 -29
  56. package/plugin/skills/muggle-test-prepare/steps/check-running.md +25 -10
  57. package/plugin/skills/muggle-test-prepare/steps/e2e-instructions.md +1 -1
  58. package/plugin/skills/muggle-test-prepare/steps/env-file.md +8 -5
  59. package/plugin/skills/muggle-test-prepare/steps/readiness-report.md +22 -18
  60. package/plugin/skills/muggle-test-prepare/steps/rebase-check.md +13 -1
  61. package/plugin/skills/muggle-test-prepare/steps/replay-or-learn.md +2 -2
  62. package/plugin/skills/muggle-test-prepare/steps/resolve-sources.md +39 -0
  63. package/plugin/skills/muggle-test-prepare/steps/reuse-plan.md +7 -5
  64. package/plugin/skills/muggle-test-prepare/steps/smoke-test.md +2 -2
  65. package/plugin/skills/muggle-test-prepare/steps/start-services.md +4 -4
  66. package/dist/src-3MQ2UWSP.js +0 -1
@@ -0,0 +1,39 @@
1
+ # Resolve service sources
2
+
3
+ Decide which checkout every service runs from. Runs on every invocation, right after [rebase-check](./rebase-check.md); the recipe names each service's repo, never the checkout to run.
4
+
5
+ ## Repos under test
6
+
7
+ The repo containing the caller's working directory is a **repo under test**; its checkout is that directory's checkout root (`git rev-parse --show-toplevel`) — a linked worktree or the main working tree alike. Each `directoryOverrides` entry adds another, with the override as its checkout.
8
+
9
+ ## Run directory
10
+
11
+ A plan entry's `dir` is the repo's main working-tree root plus the service's sub-directory inside it. Its **run directory**:
12
+
13
+ | Service's repo | Runs from |
14
+ | :------------- | :-------- |
15
+ | A repo under test | `<that checkout>/<sub-directory>` |
16
+ | Any other repo | `<main-root>/.claude/worktrees/base-<default>/<sub-directory>` — the repo's **base checkout** |
17
+
18
+ A repo's main working tree is a run directory only when it is the caller's own checkout. Otherwise what it has checked out is whatever its last user left there — the reason a recipe's services drift months behind.
19
+
20
+ ## Base checkout
21
+
22
+ A detached worktree pinned to the latest `origin/<default>`, shared by every session on this machine: sibling services always run the main line, and two sessions needing the same backend share one process instead of fighting over its port.
23
+
24
+ 1. `git -C <main-root> fetch --no-tags origin "+refs/heads/<default>:refs/remotes/origin/<default>"`
25
+ 2. Missing → `git -C <main-root> worktree add --detach <main-root>/.claude/worktrees/base-<default> origin/<default>`
26
+ 3. HEAD ≠ `origin/<default>` → `git -C <base-checkout> checkout --detach --force origin/<default>` — only while the local execution lock is free or held by the caller: `~/.muggle-ai/local-execution.lock` absent, or its `holderCwd` is the caller's checkout. A peer's run in flight keeps the base where it is; the readiness table then shows how far it trails, and the next invocation refreshes it.
27
+
28
+ Nothing is ever committed in a base checkout; `--force` discards stray edits.
29
+
30
+ ## Legacy plan entries
31
+
32
+ An entry saved before this rule names a checkout directly. Normalize it in memory, and in the saved plan on its next write:
33
+
34
+ - A path inside a linked worktree (`…/.claude/worktrees/<name>/…`, or one whose `git rev-parse --git-common-dir` is not its own `.git`) → its repo's main working-tree root plus the remaining sub-directory.
35
+ - A path that no longer exists → cut at `/.claude/worktrees/`; the prefix is the main root. Gone with no such segment → drop the entry, per [reuse-plan](./reuse-plan.md).
36
+
37
+ ## Output
38
+
39
+ For each service: its run directory, whether it is under test or from a base checkout, and the commit it must serve (`git -C <run-dir> rev-parse HEAD`). These travel in the resolved plan; [check-running](./check-running.md) proves every listener against them.
@@ -1,6 +1,6 @@
1
1
  # Resolving the saved plan
2
2
 
3
- How [replay-or-learn](./replay-or-learn.md) finds the machine-readable half of the recipe. A previously saved **prepare plan** is the durable recipe for this stack, paired with the prose half in `~/.muggle-ai/e2e-instructions/<key>.md`. Distinct from the ephemeral `/tmp/muggle-test-prepare.json` tracker — that file holds live PIDs/logs and is rebuilt every run.
3
+ How [replay-or-learn](./replay-or-learn.md) finds the machine-readable half of the recipe. A previously saved **prepare plan** is the durable recipe for this stack, paired with the prose half in `~/.muggle-ai/e2e-instructions/<key>.md`. Distinct from the ephemeral per-checkout tracking files ([PID Tracking](../SKILL.md#pid-tracking)) — those hold live PIDs and logs.
4
4
 
5
5
  Finding a plan means this is a **replay run**: execute it, ask nothing. Finding none means a **learning run**.
6
6
 
@@ -8,7 +8,9 @@ Finding a plan means this is a **replay run**: execute it, ask nothing. Finding
8
8
 
9
9
  In order; first hit wins.
10
10
 
11
- 1. **Saved plan.** If `~/.muggle-ai/prepare-plans.json` exists, read the entry keyed on this stack — the absolute path of the working directory's parent. If present → load that entry's value. The plan is machine-local and is never read from, or written to, the user's project.
11
+ 1. **Saved plan.** If `~/.muggle-ai/prepare-plans.json` exists, read the entry keyed on this stack. If present → load that entry's value. The plan is machine-local and is never read from, or written to, the user's project.
12
+
13
+ **Stack key** — the absolute main working-tree root of the repo containing the working directory (the first `worktree` line of `git worktree list --porcelain`), so every worktree of one clone shares one recipe; outside any repo, the working directory's parent. No entry under the key → adopt an older entry whose services name this repo (by main root or by a path inside one of its worktrees) and re-key it on the next write.
12
14
  2. **No plan found** → exit this step; the workflow continues at [rebase-check](./rebase-check.md).
13
15
 
14
16
  A loaded plan is a JSON object with `version`, `updated`, `testing_scope`, `excluded_services`, `services`. Reject and treat as "no plan" if `version != 1` or `services` is empty.
@@ -35,12 +37,12 @@ Per [`muggle-preferences/preference-gates/README.md`](../../muggle-preferences/p
35
37
 
36
38
  ## Reuse path
37
39
 
38
- 1. **Validate per service entry.** For each `{name, dir, command, port}`:
40
+ 1. **Validate per service entry.** Normalize legacy entries per [resolve-sources](./resolve-sources.md#legacy-plan-entries) first. For each `{name, dir, command, port}`:
39
41
  - `dir` exists → keep. Else drop the entry and log `"Dropped <name>: directory <dir> no longer exists"`.
40
42
  - The indicator file that produced `command` still exists in `dir` (e.g. `package.json` for an `npm`/`node` command; see the indicator table in [start-commands](./start-commands.md)) → keep. Else re-derive **just that one entry** by running the indicator-detection from [start-commands](./start-commands.md) against `dir`, and replace its `command`. Log `"Re-derived <name>: <old> → <new>"`.
41
43
  2. **All entries dropped** → discard the plan; continue at [rebase-check](./rebase-check.md). Otherwise proceed with surviving + re-derived entries.
42
- 3. **Hydrate** `/tmp/muggle-test-prepare.json` with the surviving entries (no PIDs yet, `testing_scope` from the plan, `excluded_services` from the plan).
43
- 4. **Short-circuit** to [check-running](./check-running.md). The skipped stages are [scope](./scope.md), [viability-check](./viability-check.md), [identify-services](./identify-services.md), [start-commands](./start-commands.md), [e2e-instructions](./e2e-instructions.md) — the reused plan and its companion supply their answers. Carry the loaded instructions forward unchanged; the user is not re-asked. When the companion is absent, run [e2e-instructions](./e2e-instructions.md) once to capture it, then continue the short-circuit. The remaining stages run normally: [env-file](./env-file.md), [fresh-install](./fresh-install.md), [start-services](./start-services.md) (only for entries not already listening), [smoke-test](./smoke-test.md), [readiness-report](./readiness-report.md).
44
+ 3. **Hydrate** the resolved plan with the surviving entries (`testing_scope` and `excluded_services` from the plan).
45
+ 4. **Short-circuit** through [rebase-check](./rebase-check.md) and [resolve-sources](./resolve-sources.md) to [check-running](./check-running.md). The skipped stages are [scope](./scope.md), [viability-check](./viability-check.md), [identify-services](./identify-services.md), [start-commands](./start-commands.md), [e2e-instructions](./e2e-instructions.md) — the reused plan and its companion supply their answers. Carry the loaded instructions forward unchanged; the user is not re-asked. When the companion is absent, run [e2e-instructions](./e2e-instructions.md) once to capture it, then continue the short-circuit. The remaining stages run normally: [env-file](./env-file.md), [fresh-install](./fresh-install.md), [start-services](./start-services.md) (only for entries not already listening), [smoke-test](./smoke-test.md), [readiness-report](./readiness-report.md).
44
46
 
45
47
  ## Rediscover path
46
48
 
@@ -1,12 +1,12 @@
1
1
  # Comprehensive smoke test
2
2
 
3
- Runs for **every** service in the tracking file, including `external: true`. Port-listening is not proof a service works — a stale dev server binds and returns 200 with a webpack error overlay.
3
+ Runs for **every** service in the resolved plan, including `external: true`. Port-listening is not proof a service works — a stale dev server binds and returns 200 with a webpack error overlay.
4
4
 
5
5
  All three probes must pass:
6
6
 
7
7
  1. **HTTP** — `GET <serviceUrl>`, 3 s timeout, accept `2xx`/`3xx` (one redirect).
8
8
  2. **Body sniff** — match response body against broken-build markers in [`../../_shared/dev-server-readiness.md`](../../_shared/dev-server-readiness.md) → "Body sniff patterns".
9
- 3. **Log tail** — scan last 200 lines of `/tmp/muggle-prepare-<service-name>.log` for failure patterns after the latest ready signal. Skip for `external: true` (no log).
9
+ 3. **Log tail** — scan last 200 lines of the service's `log` (its tracking entry, [PID Tracking](../SKILL.md#pid-tracking)) for failure patterns after the latest ready signal. Skip for `external: true` (no log).
10
10
 
11
11
  Use the primitives in `dev-server-readiness.md`. Don't re-implement.
12
12
 
@@ -1,13 +1,13 @@
1
1
  # Start services
2
2
 
3
- For each service, launch in the background through the shipped process cap: wrap the service's start command as `node <plugin-root>/scripts/guard-run.mjs --service -- <command>` (resolve `<plugin-root>` from `CLAUDE_PLUGIN_ROOT`). The wrapper is plain node and picks the cap mechanism per OS itself, so the instruction is the same everywhere; it kernel-bounds the service's process tree (a runaway spawn loop dies at the cap, not the machine) while letting the service outlive this session. From the Bash tool:
3
+ For each service, launch from its run directory ([resolve-sources](./resolve-sources.md)) in the background through the shipped process cap: wrap the service's start command as `node <plugin-root>/scripts/guard-run.mjs --service -- <command>` (resolve `<plugin-root>` from `CLAUDE_PLUGIN_ROOT`). The wrapper is plain node and picks the cap mechanism per OS itself, so the instruction is the same everywhere; it kernel-bounds the service's process tree (a runaway spawn loop dies at the cap, not the machine) while letting the service outlive this session. From the Bash tool:
4
4
 
5
5
  ```bash
6
- cd "<service-dir>" && nohup node "${CLAUDE_PLUGIN_ROOT}/scripts/guard-run.mjs" --service -- <command> > /tmp/muggle-prepare-<service-name>.log 2>&1 &
6
+ cd "<run-dir>" && nohup node "${CLAUDE_PLUGIN_ROOT}/scripts/guard-run.mjs" --service -- <command> > "<log>" 2>&1 &
7
7
  echo $!
8
8
  ```
9
9
 
10
- Capture the PID. Write all service entries to `/tmp/muggle-test-prepare.json`.
10
+ `<log>` is the service's log path under its checkout's log directory ([PID Tracking](../SKILL.md#pid-tracking)); create the directory first. Capture the PID and write the service's entry — with `headSha` from `git -C <run-dir> rev-parse HEAD` and `startedAt` — to the tracking file of the checkout it runs from. Never write an entry into another checkout's file.
11
11
 
12
12
  **Startup verification** — confirm PID alive (`kill -0 <pid> 2>/dev/null`), then run the two-stage readiness probe per [`../../_shared/dev-server-readiness.md`](../../_shared/dev-server-readiness.md) against the log. Cap log-tail at 60 s. Halt on whatever surfaces.
13
13
 
@@ -20,4 +20,4 @@ If a PID dies immediately, consult the recipe's recorded resolutions for this se
20
20
  - Option 1: "Skip it and continue with the others"
21
21
  - Option 2: "Let me fix it — I'll re-invoke later"
22
22
 
23
- **Port discovery** — if the port wasn't known upfront, re-scan listening ports after startup. Record in tracking file. If not found within ~10 s, mark port unknown.
23
+ **Port discovery** — if the port wasn't known upfront, re-scan listening ports after startup. Record it in the service's tracking entry. If not found within ~10 s, mark port unknown.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "release": "5.18.0",
3
- "buildId": "run-183-1",
4
- "commitSha": "b07a9bb4f2f438ccb0fffc84977117ff472dbb7e",
5
- "buildTime": "2026-10-23T17:25:02Z",
3
+ "buildId": "run-184-1",
4
+ "commitSha": "277d13740371fad962c52db835b2c8591d2e310a",
5
+ "buildTime": "2026-10-23T18:05:26Z",
6
6
  "serviceName": "muggle-ai-works-mcp"
7
7
  }
@@ -0,0 +1 @@
1
+ export { ACTION_SCRIPT_FILE_NAME, BASE_REMOTE_NAME, BLOCKING_FRESHNESS_VERDICTS, BRANCH_CREATION_REFLOG_PREFIX, CheckoutFreshnessVerdict, DEFAULT_PREFERENCES, ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS, ElectronAppPlatform, ElectronAppReleaseStream, HTML_VIEW_OFFER_LINE, MAX_LISTED_INHERITED_COMMITS, ONBOARDING_BLANKET_OPTIONS, ONBOARDING_CHOICE_GROUPS, ONBOARDING_MAX_OFFERS, ONBOARDING_PRIMER_BULLETS, ONBOARDING_PRIMER_HEADLINE, ONBOARDING_TOGGLE_GROUPS, ONBOARDING_TOGGLE_PROMPT, ONBOARDING_UNSELECTED_TOGGLE_VALUE, OnboardingBlanketChoice, OnboardingGroupKind, PREFERENCES_FILE_NAME, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_SCHEMA, PREFERENCES_VERSION, PREFERENCE_ALLOWED_VALUES, PreferenceKey, PreferenceValue, ProjectPreferencesReconcileOutcome, RUN_SESSIONS_DIR_NAME, RUN_VIEW_DASHBOARD_LINK_LABEL, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, buildElectronAppDirName, buildElectronAppReleaseAssetUrl, buildElectronAppReleaseTag, buildOnboardingPlan, calculateFileChecksum, completeOnboarding, createApiKeyWithToken, createChildLogger, deleteApiKeyData, deleteCredentials, e2e_exports as e2e, evaluateCheckoutFreshness, formatPreferencesOneLiner, getActiveElectronAppReleaseStream, getActiveRuntimeTarget, getApiKey, getApiKeyFilePath, getAuthService, getBundledElectronAppVersion, getCallerCredentials, getCallerCredentialsAsync, getChecksumForPlatform, getConfig, getCredentialsFilePath, getDashboardBaseUrl, getDataDir, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, isElectronAppInstalled, isElectronAppPlatform, isFirstRun, loadApiKeyData, loadCredentials, local_exports as localQa, markOnboardingCompleted, mcp_exports as mcp, needsOnboarding, openBrowserUrl, parseElectronAppDirName, performLogin, performLogout, pollDeviceCode, e2e_exports as qa, readPreferencesMetadata, readRunView, reconcileProjectPreferences, recordOnboardingSkip, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppExecutablePath, resolveElectronAppPathOrNull, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, runGitCommand, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, toDisplayRef, toolRequiresAuth, validatePreference, verifyFileChecksum, writePreferences, writePreferencesWithMetadata, writeRunViewHtml } from './chunk-BJGZAKBB.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@muggleai/works",
3
3
  "mcpName": "io.github.multiplex-ai/muggle",
4
- "version": "5.24.0",
4
+ "version": "5.25.0-staging.184",
5
5
  "description": "13 years of Microsoft hyperscale engineering, packaged as a harness for your AI coding agent.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -61,7 +61,7 @@
61
61
  "muggleConfig": {
62
62
  "electronAppVersion": "1.13.9",
63
63
  "downloadBaseUrl": "https://github.com/multiplex-ai/muggle-ai-works/releases/download",
64
- "runtimeTargetDefault": "production",
64
+ "runtimeTargetDefault": "staging",
65
65
  "checksumsByStream": {
66
66
  "production": {
67
67
  "win32-x64": "807123fb84ba60a0fa38addd4477663e1f69a7bd3080639241b75ac3f25e3a82",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "muggle",
3
3
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
4
- "version": "5.24.0",
4
+ "version": "5.25.0-staging.184",
5
5
  "author": {
6
6
  "name": "Muggle AI",
7
7
  "email": "support@muggle-ai.com"
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.24.0",
7
+ "@muggleai/works@5.25.0-staging.184",
8
8
  "serve"
9
9
  ],
10
10
  "env": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muggle",
3
- "version": "5.24.0",
3
+ "version": "5.25.0-staging.184",
4
4
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
5
5
  "author": {
6
6
  "name": "Muggle AI",
@@ -2,7 +2,7 @@
2
2
  "name": "muggle",
3
3
  "displayName": "Muggle AI",
4
4
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
5
- "version": "5.24.0",
5
+ "version": "5.25.0-staging.184",
6
6
  "author": {
7
7
  "name": "Muggle AI",
8
8
  "email": "support@muggle-ai.com"
package/plugin/.mcp.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.24.0",
7
+ "@muggleai/works@5.25.0-staging.184",
8
8
  "serve"
9
9
  ]
10
10
  }
@@ -12,10 +12,10 @@ You bring a local dev stack to verified readiness for E2E testing: detect what's
12
12
 
13
13
  The dispatch prompt carries the resolved prepare plan:
14
14
 
15
- - `services[]` — name, dir, start command, expected port, `external` flag, approval already granted.
15
+ - `services[]` — name, dir, start command, expected port, `external` flag, approval already granted. `dir` is the run directory the skill's resolve-sources stage chose this run — the change's own checkout, or a base checkout on the latest default branch; start and judge each service from it, never from anywhere else.
16
16
  - `testingScope` and `excludedServices[]` (with reasons).
17
17
  - The recorded dev-server URL (from the `autoSelectLocalHost` resolution) — never invent or default a host/port; a framework default like `:3000` is not a fallback.
18
- - Resolved gate values the stages read (`autoRebase` outcome already applied or explicitly skipped upstream).
18
+ - Resolved gate values the stages read (`autoRebase` outcome already applied upstream, with the checkout synced onto its base).
19
19
  - The E2E run instructions — startup order, manual steps, local gotchas — already captured from the user. Honour the recorded startup order when starting services, and write the instructions out per the readiness-report stage. Absent means the skill had nothing to record; never invent them.
20
20
 
21
21
  ## Stages
@@ -34,7 +34,7 @@ Where a stage file offers the user a choice, take the branch the plan resolved;
34
34
 
35
35
  ## PID tracking
36
36
 
37
- Track every launched process in `/tmp/muggle-test-prepare.json` exactly per the skill's schema (`session_started`, `testing_scope`, `excluded_services`, `services[]` with pid/port/log). Processes the user started independently stay `external: true` and are never killed. Prune dead PIDs silently.
37
+ Track every launched process in the tracking file of the checkout it runs from, exactly per the skill's [PID Tracking](../skills/muggle-test-prepare/SKILL.md#pid-tracking) schema (`services[]` with pid/port/headSha/log). Never write into, or kill a process recorded in, another checkout's file — that is a parallel session's server. Processes the user started independently stay `external: true` and are never killed. Prune dead PIDs silently.
38
38
 
39
39
  ## Output contract
40
40
 
@@ -10,7 +10,8 @@ The caller resolves these before the loop and supplies them per test case:
10
10
 
11
11
  - `mode` — `replay` or `regen`, already chosen (by the user, or by [`../failure-mode-handling.md`](../failure-mode-handling.md) for change-driven callers).
12
12
  - `localUrl` — local execution target. Local-only; never changes the cloud project or test definitions.
13
- - `cwd` — absolute path of the active working tree (PR-branch worktree if one exists, else repo root). Drives the cross-worktree single-flight lock so concurrent runs serialize.
13
+ - `cwd` — absolute path of the active working tree (PR-branch worktree if one exists, else repo root). Drives the cross-worktree single-flight lock so concurrent runs serialize, and names the checkout the execute tools check for freshness.
14
+ - `baseBranch` — the change's base, only when it is not the remote default (a stacked change, a PR into a release branch). Omitted, the tools check `cwd` against the remote default.
14
15
  - `testCase` / `cloudTestCaseId` — the cloud test case and its id.
15
16
  - `showUi` — from the caller's `showElectronBrowser` resolution: omit for visible, `false` for headless.
16
17
 
@@ -32,3 +33,5 @@ Per test case, branch on `mode`:
32
33
  2. `muggle-local-execute-test-generation` with `testCase`, `localUrl`, `cwd`, `showUi`, `freshSession` (omit it so the stored flag decides; pass it only to override for this run, per [`fresh-session.md`](fresh-session.md)), `timeoutMs`.
33
34
 
34
35
  Store the returned `runId`, tagged with its `mode`. If a run fails, log it and continue the batch — never abort. Read the result per [`failures.md`](failures.md), then [`publish.md`](publish.md).
36
+
37
+ **A refused run is not a failure.** A result headed `Run refused — checkout is not on the latest …` launched nothing and has no `runId`: the `cwd` checkout lacks its base's latest commit (`BEHIND_BASE`) or carries another branch's commits (`FOREIGN_BASE`). Sync it per [`../sync-branch-with-base.md`](../sync-branch-with-base.md), re-invoke [`muggle-test-prepare`](../../muggle-test-prepare/SKILL.md) so the dev server serves the synced code, and run the case again. Never route it through failure handling or count it as a result.
@@ -37,11 +37,12 @@ A worktree's dependency dir (`node_modules`, and nested workspace copies) is oft
37
37
  `git worktree remove` refuses for two unrelated reasons, and **both texts lead to the same forbidden flag** — one because it is the obvious fix, the other because git prints it as the suggestion. Clear each cause at its source; neither is a reason to reconsider the flag.
38
38
 
39
39
  1. **Never `--force`.** It is the one flag that follows links.
40
- 2. Clear the dependency and build dirs first, nested workspace ones included (`packages/*/node_modules`, `dist`). A plain `git worktree remove` fails with `Directory not empty` while they remain, and the obvious fix for that error is exactly the forbidden flag.
40
+ 2. Stop the services environment prep started from this worktree (step 6 names their tracker) — a running dev server holds files open, and on Windows the removal then fails.
41
+ 3. Clear the dependency and build dirs first, nested workspace ones included (`packages/*/node_modules`, `dist`). A plain `git worktree remove` fails with `Directory not empty` while they remain, and the obvious fix for that error is exactly the forbidden flag.
41
42
  - A **link** → unlink it first with the host OS's unlink, removing the link only and never its target.
42
43
  - A **real directory** → delete it in place.
43
44
  Check which it is before deleting; the two are indistinguishable from a listing but not from a `rm -r`.
44
- 3. Clear the worktree's own dirty state — what the merge already landed, and nothing else. While anything remains, removal fails with `contains modified or untracked files, use --force to delete it`, an error that prescribes the forbidden flag in its own text.
45
+ 4. Clear the worktree's own dirty state — what the merge already landed, and nothing else. While anything remains, removal fails with `contains modified or untracked files, use --force to delete it`, an error that prescribes the forbidden flag in its own text.
45
46
 
46
47
  Expect this on any cycle that pushed through a server-side signed commit: that mutation writes to the remote only, so the worktree keeps the edits as modifications of a commit it never made locally. The dirt is this cycle's own landed work, not something the user left behind.
47
48
 
@@ -50,8 +51,8 @@ A worktree's dependency dir (`node_modules`, and nested workspace copies) is oft
50
51
  - **Untracked files** — never on the base, so no diff can clear them. Delete only the paths this procedure itself created: the dependency and build dirs cleared above. Anything else stops the sequence and is reported by name; an untracked file is the one thing in the worktree with no copy anywhere.
51
52
 
52
53
  **Never `git clean -x`.** `-x` is what reaches the ignored dependency dir, and clean recurses through a link exactly as a forced remove does — it undoes the unlink above under a different name.
53
- 4. Then plain `git worktree remove {worktreePath}`.
54
- 5. `git worktree prune` to drop the administrative entry when the directory went away out from under git.
54
+ 5. Then plain `git worktree remove {worktreePath}`.
55
+ 6. `git worktree prune` to drop the administrative entry when the directory went away out from under git.
55
56
 
56
57
  **Verify:** the path is gone, it no longer appears in `git worktree list`, the removal ran without `--force`, **and** the shared dependency tree the links pointed at still exists. That last check is the one that catches a link-follow.
57
58
 
@@ -87,9 +88,9 @@ Clear it only when `prs.json` records a terminal state. A slot for a still-open
87
88
 
88
89
  ## 6. Clear this run's prepare artifacts
89
90
 
90
- The PID tracker and per-service logs written during environment prep — `/tmp/muggle-test-prepare.json` and `/tmp/muggle-prepare-*.log`.
91
+ The services environment prep started from the merged change's worktree, with their tracker and logs — that worktree's tracking file and log directory, per [`muggle-test-prepare`'s PID Tracking](../muggle-test-prepare/SKILL.md#pid-tracking). Stop any tracked PID still alive (step 2 normally already has), then delete both.
91
92
 
92
- **Only this run's.** Artifacts belonging to another session are not yours to delete; it may be mid-prepare with services running. When the tracker is absent no services are tracked, so any remaining logs are orphaned — report them rather than removing them.
93
+ **Only this run's worktree.** Another checkout's tracker belongs to another session, which may be mid-prepare with services running; a base checkout's services are shared by every session. Neither is yours to stop or delete.
93
94
 
94
95
  Cloud results always stay.
95
96
 
@@ -8,10 +8,10 @@ A skill receives a GitHub PR URL of the form `github.com/<org>/<repo>/pull/<n>`
8
8
 
9
9
  ## Steps
10
10
 
11
- 1. **Resolve the PR's head branch:**
12
- `gh pr view <n> --repo <org>/<repo> --json headRefName -q .headRefName`
11
+ 1. **Resolve the PR's head and base branches:**
12
+ `gh pr view <n> --repo <org>/<repo> --json headRefName,baseRefName`
13
13
  2. **Sanitize the branch name** for filesystem use — replace `/` and other path separators with `-`. Example: `claude/regen-test-replay-flow-ZSScQ` → `claude-regen-test-replay-flow-ZSScQ`.
14
- 3. **Build the target worktree path:** `<repo>/.claude/worktrees/<sanitized-branch>`.
14
+ 3. **Build the target worktree path:** `<repo>/.claude/worktrees/<sanitized-branch>`, where `<repo>` is the clone's main working tree (the first `worktree` line of `git worktree list --porcelain`) even when the session stands in another worktree.
15
15
  4. **Materialize the worktree:**
16
16
  - If the target path does NOT exist:
17
17
  - `git -C <repo> fetch origin <branch>`
@@ -19,10 +19,11 @@ A skill receives a GitHub PR URL of the form `github.com/<org>/<repo>/pull/<n>`
19
19
  - If the target path EXISTS (reused from a prior run):
20
20
  - `git -C <target-path> fetch`
21
21
  - `git -C <target-path> reset --hard origin/<branch>` — picks up new pushes, drops any local cruft.
22
- 5. **Use the worktree path as the working directory** for the rest of the run, including:
23
- - Passing it as the **`cwd` parameter** to `muggle-local-execute-test-generation` and `muggle-local-execute-replay`. This is required, not optional — see `_shared/failure-mode-handling.md` and the lock identity discussion in those tools' MCP source.
22
+ 5. **Bring it onto the latest base.** A PR branch opened days ago lacks everything merged since; testing it as-is tests code that will never ship. Sync the worktree onto `origin/<baseRefName>` per [`sync-branch-with-base.md`](sync-branch-with-base.md), passing `baseRefName` as the base. This rebase is local and test-only — **never push it**; the next run's `reset --hard` discards it. A rebase that conflicts means the PR cannot merge as it stands: report the conflicted files and stop rather than testing either side alone.
23
+ 6. **Use the worktree path as the working directory** for the rest of the run, including:
24
+ - Passing it as the **`cwd` parameter** to `muggle-local-execute-test-generation` and `muggle-local-execute-replay`. This is required, not optional — see `_shared/failure-mode-handling.md` and the lock identity discussion in those tools' MCP source. When `baseRefName` is not the remote default, pass it as `baseBranch` too: the tools refuse a loopback run whose `cwd` lacks its base's latest commit.
24
25
  - Resolving any `npm install` / dev-server start commands inside the worktree (it has its own `node_modules/` and `.env*` files).
25
- 6. **Tell the user** where the worktree lives so they can clean it up later with `git -C <repo> worktree remove <target-path>`.
26
+ 7. **Tell the user** where the worktree lives so they can clean it up later with `git -C <repo> worktree remove <target-path>`.
26
27
 
27
28
  ## Invariants
28
29
 
@@ -6,15 +6,27 @@ Bring the working branch up to date with the branch it merges into — before a
6
6
 
7
7
  `base` is the branch the work merges into, which is not automatically the remote default — pre-flight lets the user target a different branch, and once a change exists its `baseRefName` is authoritative. A caller holding a base passes it in; fall back to the remote default only when no target was chosen.
8
8
 
9
- **Fire only when `behind > 0`:**
9
+ ## Checking freshness
10
+
11
+ `muggle checkout-freshness` fetches the base and returns one verdict. Run it in the checkout:
10
12
 
11
13
  ```bash
12
- git fetch origin
13
14
  base="${base:-$(git symbolic-ref refs/remotes/origin/HEAD --short | sed 's|origin/||')}"
14
- behind=$(git rev-list --count "HEAD..origin/${base}")
15
+ muggle checkout-freshness --base "${base}" --json
15
16
  ```
16
17
 
17
- Pass `{behind}` and `{base}` to the picker prompts. On `always`:
18
+ | Verdict | Meaning | Action |
19
+ | :------ | :------ | :----- |
20
+ | `FRESH` | HEAD contains `origin/${base}` | None |
21
+ | `NOT_APPLICABLE` | Not a git checkout, no `origin`, or no such base | None — nothing to check |
22
+ | `BEHIND_BASE` | HEAD lacks `behindBy` commits of `origin/${base}` | [Rebase](#rebasing) |
23
+ | `FOREIGN_BASE` | The branch was cut from another branch's unmerged commits (`inheritedCommits`) | [Stop](#foreign-base) |
24
+
25
+ Pass `{behind}` (the report's `behindBy`) and `{base}` to the picker prompts. A report with `hasFetchFailed: true` judged against the last fetched base — say so in one line and act on the verdict.
26
+
27
+ ## Rebasing
28
+
29
+ On `always`:
18
30
 
19
31
  1. Capture the rollback point: `pre_rebase_sha=$(git rev-parse HEAD)`.
20
32
  2. `git rebase origin/${base}`.
@@ -22,6 +34,29 @@ Pass `{behind}` and `{base}` to the picker prompts. On `always`:
22
34
  - `never` → `git rebase --abort`; stop and report, naming the conflicted files. Never auto-resolve.
23
35
  - `always` → hand off to [`resolve-rebase-conflicts.md`](resolve-rebase-conflicts.md) with `pre_rebase_sha` to resolve the conflicts, then run the [`verify-or-rollback-gate.md`](verify-or-rollback-gate.md) with `pre_rebase_sha`; it either proceeds or restores `pre_rebase_sha` and escalates.
24
36
 
37
+ A dev server already running from this checkout still serves the pre-rebase code: restart it before testing.
38
+
39
+ ## Before a dev server or E2E run
40
+
41
+ The code under test always contains the latest `origin/${base}`. `autoRebase` decides only whether the rebase happens without asking, never whether stale code runs:
42
+
43
+ - `always` → rebase.
44
+ - `ask` → Picker 1. `Rebase first` rebases; `Don't rebase` stops the run.
45
+ - `never` → stop the run.
46
+
47
+ A stop names the checkout, the verdict and `behindBy`, and starts nothing. There is no run-as-is: a stale tree produces false failures and false greens, and the local execute tools refuse a stale loopback run regardless, so running as-is only moves the failure later.
48
+
49
+ ## Foreign base
50
+
51
+ `FOREIGN_BASE` stops the run or push whatever `autoRebase` says — a rebase would carry the inherited commits along. Report the branch they came from and `inheritedCommits`. The fix is a decision about someone else's work, so it is the user's:
52
+
53
+ - Recreate the branch with `origin/${base}` as its explicit start point and carry over only the change's own commits.
54
+ - Or, when the change deliberately stacks on that branch, name it as the base and re-check.
55
+
56
+ ## Before a push
57
+
58
+ `BEHIND_BASE` → rebase per `autoRebase`; on `never` the push goes ahead as-is, and the remote's merge checks own that decision. `FOREIGN_BASE` → [stop](#foreign-base).
59
+
25
60
  ## Branches already on the remote
26
61
 
27
62
  The rebase rewrites history, so a branch the remote already has needs a force-push to land it. Never force-push from here. A caller in that position hands the sync to its own rebase mode, which owns the per-SHA attempt budget and the verify-or-rollback gate wrapped around the force-push.
@@ -10,13 +10,18 @@ Use this for feature development, local validation, and PR iteration.
10
10
 
11
11
  ## Start new change work
12
12
 
13
- 1. Update the base branch (usually `main`).
14
- 2. Create a new worktree and branch:
13
+ Every new branch starts at the latest `origin/<base>` — never at HEAD, never at a local branch. The directory a session stands in may be a detached main checkout months old, or a sibling worktree on someone else's feature branch; a branch created without a start point silently inherits that code. A local `<base>` branch is no better: it is often checked out, stale, in another worktree.
14
+
15
+ 1. Resolve `<main-root>` — the clone's main working tree, the first `worktree` line of `git worktree list --porcelain` — and `<base>` (the change's target branch; the remote default when none was chosen).
16
+ 2. Fetch and create from the remote-tracking ref:
15
17
  ```bash
16
- git worktree add <repo>/.claude/worktrees/<sanitized-branch> -b <branch>
18
+ git -C <main-root> fetch --no-tags origin "+refs/heads/<base>:refs/remotes/origin/<base>"
19
+ git -C <main-root> worktree add <main-root>/.claude/worktrees/<sanitized-branch> -b <branch> origin/<base>
17
20
  ```
18
- 3. Install dependencies and run setup in that worktree.
19
- 4. Keep all edits and commits for the change in that same worktree.
21
+ Under `<main-root>` even when the session stands in another worktree, so worktrees never nest.
22
+ 3. Confirm with `muggle checkout-freshness --cwd <worktree>` — it must report `FRESH`.
23
+ 4. Install dependencies and run setup in that worktree.
24
+ 5. Keep all edits and commits for the change in that same worktree.
20
25
 
21
26
  ## Test in the worktree
22
27
 
@@ -27,7 +32,7 @@ Use this for feature development, local validation, and PR iteration.
27
32
 
28
33
  ## E2E + worktree checklist
29
34
 
30
- 1. Confirm command cwd, checked-out branch, and server source are the same worktree.
35
+ 1. Confirm command cwd, checked-out branch, and server source are the same worktree, and that the worktree is still on the latest base per [`sync-branch-with-base.md`](sync-branch-with-base.md).
31
36
  2. Start the app from that worktree and verify readiness first (see [`dev-server-readiness.md`](dev-server-readiness.md)).
32
37
  3. Run local E2E acceptance checks in that same session.
33
38
  4. Isolate test data across parallel branches (separate users/accounts/orgs or resettable fixtures).
@@ -39,6 +44,7 @@ Use this for feature development, local validation, and PR iteration.
39
44
  - **Port collision:** Multiple branches share a dev-server port.
40
45
  - **Shared mutable state:** Parallel runs mutate the same account or fixtures.
41
46
  - **Stale server:** Old process still serves previous branch code.
47
+ - **Inherited base:** A branch created from whatever HEAD the session stood on carries that checkout's age or another branch's commits.
42
48
 
43
49
  ## Pull request workflow
44
50
 
@@ -69,7 +69,7 @@ For a `local-e2e` block, use `localUrl`, `projectId`, and the working-tree path
69
69
 
70
70
  A `local-e2e` cycle runs these before any `muggle-local-execute-*` call, every cycle — even when pre-flight already reported the app ready, since a server can die while stages 2–5 run and a healthy one fast-exits:
71
71
 
72
- 1. **Dev-server + backend readiness** — invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md), the readiness/service-start owner (idempotent fast-exit when healthy; probes via `dev-server-readiness.md` and starts what is down). Still not ready after its start attempts → the readiness halt below.
72
+ 1. **Dev-server + backend readiness** — invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) from the cycle's worktree, passing the PR target as `base` — the readiness/service-start owner (idempotent fast-exit when healthy; probes via `dev-server-readiness.md` and starts what is down). It syncs the worktree onto the latest base before starting anything, and serves every other repo from its latest default branch. Its readiness table must show the cycle's worktree as the `Source` of the changed repo's services, at the worktree's current HEAD; any other source is not ready. Still not ready after its start attempts → the readiness halt below.
73
73
  2. **Auth** — `muggle-remote-auth-status` must be `authenticated`; else escalate.
74
74
  3. **Identity tenant/domain match** — if test credentials were marked `existing`, confirm the repo's configured identity tenant/domain matches the recorded tenant/domain. Mismatch → halt.
75
75
 
@@ -34,7 +34,7 @@ Before asking anything, gather every fact you can resolve without the user:
34
34
  8. **Auth0 tenant in use for local dev.** Grep the repo's env file for `*AUTH0_DOMAIN*`; record the tenant. This tells the user whether the staging-tenant test user will work or not.
35
35
  9. **Branch hygiene signals** for the `autoUseWorktree` and `autoRebase` gates (see [`../_shared/use-worktrees.md`](../_shared/use-worktrees.md), [`../_shared/sync-branch-with-base.md`](../_shared/sync-branch-with-base.md)):
36
36
  - Is the current checkout already a worktree? `git -C <repo> rev-parse --is-inside-work-tree` plus `git -C <repo> worktree list`.
37
- - How many commits behind `origin/<default>`? `git -C <repo> fetch origin && git -C <repo> rev-list --count "HEAD..origin/$(git -C <repo> symbolic-ref refs/remotes/origin/HEAD --short | sed 's|origin/||')"`.
37
+ - Is the current checkout on the latest base? `muggle checkout-freshness --cwd <repo> --json` fetches and reports the verdict and `behindBy`. However stale or foreign the current checkout, a new worktree starts from `origin/<base>`, never from it.
38
38
  10. **`autoE2ETest` preference.** Read the session-context preferences line. Unset → treat as `always` (this gate's default — opposite of the system-wide `ask` default). `ask` → surface in Q13. `always` → no question; stage 6 runs.
39
39
  11. **Wave candidate?** Two or more candidate repos, one PR each, and validation leaning `local-e2e` → the cycle is a wave per [`wave-e2e.md`](wave-e2e.md): the repos' services start together from their branches and one E2E run covers every PR. Record each repo's worktree path for the `Wave members` block. Not a wave → note why.
40
40
  12. **CI check present?** For each GitHub repo, whether `.github/workflows/muggle-walkthrough.yml` exists on its default branch. Missing and [`autoInstallCiWorkflow`](../muggle-preferences/preference-gates/autoInstallCiWorkflow.md) resolves to `ask` → surface in Q14.
@@ -34,8 +34,8 @@ The worktree path is where that repo's wave branch is checked out — the path i
34
34
 
35
35
  Run [`e2e-acceptance.md`](e2e-acceptance.md) **once**, not once per repo, with these changes:
36
36
 
37
- 1. **Start the wave stack.** Invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) with the wave members as `directoryOverrides` (repo → worktree path): every service whose repo is a wave member starts from that member's worktree path, not from the repo's usual checkout. Services from repos outside the wave start as the saved recipe says.
38
- 2. **Confirm each wave service runs the wave branch.** A port that answers is not enough — the process on it may be a dev server the user left running from the default checkout. Check the readiness table: every wave service must report its member's worktree as its directory. A service that doesn't → halt and escalate with the table; never test a wave against a service running another branch.
37
+ 1. **Start the wave stack.** Invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) with the wave members as `directoryOverrides` (repo → worktree path): every service whose repo is a wave member starts from that member's worktree path, synced onto its base first, not from the repo's usual checkout. Services from repos outside the wave start from that repo's base checkout on its latest default branch.
38
+ 2. **Confirm each wave service runs the wave branch.** A port that answers is not enough — the process on it may be a dev server the user left running from the default checkout. Check the readiness table: every wave service must report its member's worktree as its `Source`, at that worktree's current HEAD. A service that doesn't → halt and escalate with the table; never test a wave against a service running another branch.
39
39
  3. **Merge every member's scope.** Steps 1.5–3 read impact analysis for every wave repo, and the run's scope is the union of each member's `e2eScope`: a test case several members scope runs once, and a new case two members plan for the same criterion is created once. `EMPTY_DIFF` applies only when every member's diff is empty.
40
40
  4. **Run each selected test case once** against the combined stack. Do not repeat a case per repo.
41
41
  5. **Attribute failures.** For each Failed entry, name the member whose change the failing step implicates (`implicatedRepo: <owner/repo>`), or `unknown` when the evidence does not point at one. Stage 7.5 repairs in that repo.
@@ -1,11 +1,11 @@
1
1
  # `autoRebase`
2
2
 
3
- Sync onto `origin/{base}` before dev servers / E2E and before a push, or run as-is. Substitute `{behind}` and `{base}`.
3
+ Sync onto `origin/{base}` before dev servers / E2E and before a push, without asking. Stale code is never tested: before a dev server or E2E run, not rebasing stops the run. Substitute `{behind}` and `{base}`.
4
4
 
5
5
  **Picker 1** — header `Rebase first`, question `"Branch is {behind} commits behind origin/{base} — rebase first?"`
6
6
  - `Rebase first` — `Pull in the base branch's changes so the run reflects the merged main line.` → `always`
7
- - `Run as-is` — `Skip the rebase.` → `never`
7
+ - `Don't rebase` — `Leave the branch as it is. A dev server or E2E run stops instead of testing stale code; a push goes ahead.` → `never`
8
8
 
9
9
  **Silent action**
10
10
  - `always` → `Rebasing onto origin/{base} ({behind} behind)`
11
- - `never` → `Running as-is ({behind} behind origin/{base})`
11
+ - `never` → `Not rebasing ({behind} behind origin/{base}) — a dev server or E2E run stops here`
@@ -10,7 +10,7 @@
10
10
 
11
11
  ## Local environment readiness
12
12
 
13
- Before anything else, invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) — the readiness/service-start owner (idempotent; halt on what it surfaces). The URL gate below only *selects* the target; prepare is what guarantees something is listening and compiled.
13
+ Before anything else, invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) from `cwd` — the readiness/service-start owner (idempotent; halt on what it surfaces). It syncs `cwd` onto the latest base before starting anything, and serves every other repo from its latest default branch. The URL gate below only *selects* the target; prepare is what guarantees the right code is listening and compiled. Confirm its readiness table shows `cwd` as the `Source` of this repo's services, at `cwd`'s current HEAD — a different source means the run would test someone else's code; halt.
14
14
 
15
15
  Then read `~/.muggle-ai/e2e-instructions/<key>.md` when it exists — this stack's recorded startup order, manual steps, and local gotchas. Use it to interpret what you see: a gotcha listed there explains a symptom that would otherwise read as a failure. Absent is normal.
16
16
 
@@ -40,7 +40,7 @@ Execute each test case via the shared loop in [`../_shared/dev-loop/run.md`](../
40
40
 
41
41
  Caller glue:
42
42
  - `mode` per test case is the input from the router; `localUrl` from the pre-flight question; `showUi` from the `showElectronBrowser` resolution.
43
- - `cwd` is the input from the router — it drives the cross-worktree single-flight lock so concurrent muggle-test runs from different branches serialize.
43
+ - `cwd` is the input from the router — it drives the cross-worktree single-flight lock so concurrent muggle-test runs from different branches serialize, and the execute tools refuse it when it is not on the latest base. For a PR whose base is not the remote default, pass its `baseRefName` as `baseBranch`.
44
44
  - On a failed run, continue the batch; the router routes failures through the debug path after this path returns.
45
45
 
46
46
  ## Collect results
@@ -26,12 +26,12 @@ The local URL only changes where the browser opens; it does not change the remot
26
26
  Three gates apply, each per the standard procedure in [`preference-gates/README.md`](../muggle-preferences/preference-gates/README.md):
27
27
 
28
28
  - `autoUseWorktree` at pre-flight (see [`_shared/use-worktrees.md`](../_shared/use-worktrees.md)).
29
- - `autoRebase` before Step 7 (Execute) when `behind > 0` (see [`_shared/sync-branch-with-base.md`](../_shared/sync-branch-with-base.md)).
29
+ - `autoRebase` before any service starts — `muggle-test-prepare` syncs the checkout first — and again before Step 7 (Execute) when the base moved meanwhile, re-invoking `muggle-test-prepare` after that rebase so the dev server serves it. Stale code is never tested (see [`_shared/sync-branch-with-base.md`](../_shared/sync-branch-with-base.md)).
30
30
  - `autoCleanup` after the PR is merged (see [`_shared/post-merge-cleanup.md`](../_shared/post-merge-cleanup.md)).
31
31
 
32
32
  ## Local environment prerequisites
33
33
 
34
- Before any workflow step, invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md). Halt on what it surfaces.
34
+ Before any workflow step, invoke [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) from the checkout under test. Halt on what it surfaces — a checkout it cannot bring onto the latest base included.
35
35
 
36
36
  Then read `~/.muggle-ai/e2e-instructions/<key>.md` when it exists — this stack's recorded startup order, manual steps, and local gotchas. A gotcha listed there explains a symptom that would otherwise read as a failure. Absent is normal.
37
37
 
@@ -112,12 +112,7 @@ Prompt for projects: "Pick the project to group this test into:"
112
112
 
113
113
  ### 3. Ensure Local Services Are Ready
114
114
 
115
- Before detecting the local URL, verify that the services the user needs are actually running. Use the `muggle:muggle-test-prepare` integration contract:
116
-
117
- 1. Check if `/tmp/muggle-test-prepare.json` exists.
118
- 2. If it exists, verify tracked PIDs are alive with `kill -0`.
119
- 3. If all live → services are ready, proceed to Step 4 (Local URL).
120
- 4. If the file is missing or has stale PIDs → invoke the `muggle:muggle-test-prepare` skill via the `Skill` tool to get services started. Once it completes, proceed to Step 4.
115
+ Before detecting the local URL, invoke the `muggle:muggle-test-prepare` skill via the `Skill` tool from the checkout under test — every run, even when services look up. Live PIDs prove nothing about which code they serve: prepare syncs this checkout onto the latest base, starts sibling services from base checkouts on the latest default branch, and keeps a running service only when it still serves the right commit. It fast-exits when everything is proven. Once it reports ready, check its readiness table: this checkout's services must show this checkout as their `Source` at its current HEAD. Then proceed to Step 4.
121
116
 
122
117
  This step is especially important when the user's app depends on sibling services (a backend API, an auth service, etc.) that may not be running yet. The prepare skill handles discovery, startup, and cleanup so this skill doesn't have to.
123
118