@muggleai/works 5.24.0 → 5.25.0-staging.185

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-GLTZIZVT.js → chunk-53MCWNVE.js} +56 -32
  4. package/dist/{chunk-FEHTWWVH.js → chunk-C6OEDLIP.js} +273 -5
  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-V7DVV6KO.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
@@ -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
 
@@ -26,42 +26,46 @@ This skill touches the user's local machine — processes, ports, directories ou
26
26
 
27
27
  ## PID Tracking
28
28
 
29
- All launched processes are tracked in `/tmp/muggle-test-prepare.json`:
29
+ Every launched process is tracked by the **checkout it runs from**, one file per checkout, so parallel sessions never share — or tear down — each other's state:
30
+
31
+ ```
32
+ ~/.muggle-ai/prepare/running/<source-key>.json services started from that checkout
33
+ ~/.muggle-ai/prepare/logs/<source-key>/<name>.log their logs
34
+ ```
35
+
36
+ `<source-key>` is the checkout root's absolute path, made filename-safe exactly as the E2E instructions key is ([e2e-instructions](./steps/e2e-instructions.md#resolve-the-saved-file)).
30
37
 
31
38
  ```json
32
39
  {
33
- "session_started": "2025-01-15T10:30:00Z",
34
- "testing_scope": "frontend",
35
- "excluded_services": [
36
- {"name": "payment-gateway", "reason": "Needs production certificates"}
37
- ],
40
+ "source": "/Users/user/Github/app/.claude/worktrees/feat-x",
38
41
  "services": [
39
42
  {
40
- "name": "backend-api",
41
- "dir": "/Users/user/Github/backend-api",
43
+ "name": "frontend",
44
+ "dir": "/Users/user/Github/app/.claude/worktrees/feat-x/web",
42
45
  "command": "npm run dev",
43
46
  "pid": 12345,
44
- "port": 3001,
45
- "log": "/tmp/muggle-prepare-backend-api.log"
47
+ "port": 3999,
48
+ "headSha": "9f8e7d6c5b4a39281706f5e4d3c2b1a098f7e6d5",
49
+ "startedAt": "2026-10-22T10:30:00Z",
50
+ "log": "/Users/user/.muggle-ai/prepare/logs/-Users-user-Github-app-.claude-worktrees-feat-x/frontend.log"
46
51
  }
47
52
  ]
48
53
  }
49
54
  ```
50
55
 
51
- `testing_scope` records what the user is testing (from [scope](./steps/scope.md)). `excluded_services` records services the user said can't run locally (from [viability-check](./steps/viability-check.md)).
56
+ `headSha` is the commit the checkout had out when the service started — what [check-running](./steps/check-running.md) compares against before trusting a listener. These files are machine-wide and readable by every session: they are how one session learns that a port belongs to another.
52
57
 
53
- This file is **ephemeral runtime state**, not the saved recipe. The durable plan lives in `~/.muggle-ai/prepare-plans.json`, under the entry keyed on this stack, and is consulted in [reuse-plan](./steps/reuse-plan.md) before any other stage. The two files never merge. The `test-prepare-runner` agent writes this file during execution; the triage below and Cleanup read it.
58
+ This is **ephemeral runtime state**, not the saved recipe. The durable plan lives in `~/.muggle-ai/prepare-plans.json`, under the entry keyed on this stack, and is consulted in [reuse-plan](./steps/reuse-plan.md) before any other stage. The two never merge. The `test-prepare-runner` agent writes the tracking files during execution; Cleanup reads them.
54
59
 
55
60
  The prose companion to the plan is `~/.muggle-ai/e2e-instructions/<key>.md`, written by [e2e-instructions](./steps/e2e-instructions.md), holding startup order, manual steps, and local gotchas. The plan remains the single source of truth for each service's start command; the markdown never restates one.
56
61
 
57
62
  **Everything this skill saves is machine-local, user-level data and lives under the Muggle home directory — never inside the user's project.** A project directory is shared, versioned, and cloned onto machines set up differently; a local run recipe is none of those things. Both files are keyed on the same stack identity, so they stay in lockstep.
58
63
 
59
- **On every invocation**, check this file first. If it exists with live PIDs (verify with `kill -0`), `AskUserQuestion`:
60
- - Option 1: "Keep them running — skip to testing"
61
- - Option 2: "Tear down and start fresh"
62
- - Option 3: "Add more services to the running set"
64
+ **On every invocation**, prune dead PIDs from the tracking files silently (verify with `kill -0`). Whether a live service is kept is never asked: [check-running](./steps/check-running.md) keeps one still serving its checkout's current HEAD and restarts one serving older code.
65
+
66
+ ## Code freshness
63
67
 
64
- Prune dead PIDs silently.
68
+ Every service runs code built on the latest base: the caller's own checkout, synced onto `origin/<base>`, for the repo under test; a base checkout pinned to the latest `origin/<default>` for every other repo. [rebase-check](./steps/rebase-check.md) and [resolve-sources](./steps/resolve-sources.md) run on **every** invocation, replays included — a saved recipe makes the start commands reusable, never the code they start.
65
69
 
66
70
  ## Preferences
67
71
 
@@ -69,7 +73,7 @@ Gates run per [`preference-gates/README.md`](../muggle-preferences/preference-ga
69
73
 
70
74
  | Preference | Gates |
71
75
  |------------|-------|
72
- | `autoRebase` | [rebase-check](./steps/rebase-check.md) — rebase onto `origin/<default>` before starting dev servers |
76
+ | `autoRebase` | [rebase-check](./steps/rebase-check.md) — rebase onto `origin/<base>` without asking before starting dev servers; not rebasing stops the run |
73
77
  | `reusePreparePlan` | [reuse-plan](./steps/reuse-plan.md) — reuse the saved prepare plan for this stack, or rediscover; also [e2e-instructions](./steps/e2e-instructions.md), which goes stale for the same reason |
74
78
  | `autoSelectLocalHost` | [check-running](./steps/check-running.md) — reuse the recorded dev-server URL silently, or confirm it each run |
75
79
 
@@ -85,13 +89,16 @@ Decide stages, in order; read each detail file when you reach it:
85
89
  |:------|:--------|
86
90
  | [replay-or-learn](./steps/replay-or-learn.md) | Replay the saved recipe, or learn a new one |
87
91
  | [derive-service-graph](./steps/derive-service-graph.md) | Derive services from workspace manifests |
88
- | [rebase-check](./steps/rebase-check.md) | Rebase onto default branch |
92
+ | [rebase-check](./steps/rebase-check.md) | Sync every checkout under test onto the latest base — replays too |
93
+ | [resolve-sources](./steps/resolve-sources.md) | Pick the checkout each service runs from — replays too |
89
94
  | [scope](./steps/scope.md) | Frontend / backend / full stack |
90
95
  | [viability-check](./steps/viability-check.md) | Exclude services that can't run locally |
91
96
  | [identify-services](./steps/identify-services.md) | Confirm the derived graph; fill the gaps |
92
97
  | [e2e-instructions](./steps/e2e-instructions.md) | Startup order, manual steps, local gotchas |
93
98
 
94
- The Decide phase's output is the **resolved prepare plan**: `services[]` (name, dir, start command, expected port, `external` flag, approval granted), `testingScope`, `excludedServices[]`, the recorded dev-server URL, the E2E run instructions, and resolved gate outcomes.
99
+ The Decide phase's output is the **resolved prepare plan**: `services[]` (name, run directory from [resolve-sources](./steps/resolve-sources.md), start command, expected port, `external` flag, approval granted), `testingScope`, `excludedServices[]`, the recorded dev-server URL, the E2E run instructions, and resolved gate outcomes.
100
+
101
+ A replay runs [rebase-check](./steps/rebase-check.md) and [resolve-sources](./steps/resolve-sources.md) before dispatching — they ask nothing unless a checkout cannot be brought up to date.
95
102
 
96
103
  **Execute (agent).** Dispatch the `test-prepare-runner` agent (subagent type `muggle:test-prepare-runner`; bare `test-prepare-runner` where the plugin namespace is absent), synchronously, passing the resolved plan; it returns `READY` / `DEGRADED` plus the readiness table. The agent's own definition lists its stage files; in a harness with no agent/subagent facility, run the execute-phase stages ([check-running](./steps/check-running.md) through [readiness-report](./steps/readiness-report.md)) inline instead.
97
104
 
@@ -103,13 +110,14 @@ The agent also returns the problems it hit and what cleared them. On a learning
103
110
 
104
111
  Triggered when the user says "stop services", "tear down", "clean up", "I'm done testing", another skill signals run complete, or this skill is re-invoked with "tear down and start fresh". Runs in-session, not in the agent.
105
112
 
106
- 1. Read `/tmp/muggle-test-prepare.json`
113
+ Cleanup stops only what runs from the caller's own checkout. Another checkout's services may be mid-run in a peer session, and base-checkout services are shared — they stay up unless the user explicitly asks to stop everything.
114
+
115
+ 1. Read the caller's checkout's tracking file (see [PID Tracking](#pid-tracking))
107
116
  2. Skip services marked `external: true`
108
117
  3. For each managed service: `kill <pid>` (SIGTERM)
109
118
  4. Wait ~2 s, verify with `kill -0`
110
119
  5. If still alive: `kill -9 <pid>`
111
- 6. `rm -f /tmp/muggle-prepare-*.log`
112
- 7. `rm -f /tmp/muggle-test-prepare.json`
120
+ 6. Delete that checkout's log directory and tracking file
113
121
 
114
122
  Report:
115
123
 
@@ -126,12 +134,15 @@ Stopped 3 services:
126
134
 
127
135
  After a test run, the caller can re-invoke for cleanup or leave services running for the next run.
128
136
 
129
- **Directory overrides.** A caller testing changes that span several repos at once may pass `directoryOverrides`: a map from a service's repo (its usual directory, or `owner/repo`) to the checkout that service must start from this run — typically a worktree on a feature branch. Apply them to the resolved plan before execution:
137
+ **The caller's checkout.** Invoke from the checkout under test — the worktree the change lives in. Its repo is the repo under test, and its services start from that checkout; every other repo's services start from that repo's base checkout ([resolve-sources](./steps/resolve-sources.md)). Pass `base` when the change targets a branch other than the remote default.
130
138
 
131
- - An overridden service starts from the override directory, with its recorded start command. Its install and env-file steps run there too.
132
- - An overridden service already listening counts as running only when its process's working directory is inside the override directory (`lsof -p <pid> -a -d cwd` on POSIX). Otherwise it is the wrong checkout: stop it and start it from the override, under the same approval rules as any restart.
139
+ **Directory overrides.** A caller testing changes that span several repos at once may pass `directoryOverrides`: a map from a service's repo (its usual directory, or `owner/repo`) to the checkout that service must start from this run — typically a worktree on a feature branch. Each override makes its repo a repo under test, exactly like the caller's own checkout:
140
+
141
+ - An overridden service starts from the override directory, with its recorded start command. Its install and env-file steps run there too, and [rebase-check](./steps/rebase-check.md) syncs the override first.
142
+ - An overridden service already listening counts as running only when [check-running](./steps/check-running.md) proves it serves the override's current HEAD. Otherwise it is the wrong checkout: it is never tested against, and is restarted from the override under the same approval rules as any restart.
133
143
  - Overrides are per-run. They never enter the saved recipe — a worktree path is not this stack's durable layout.
134
- - The readiness table names the directory each service runs from, so the caller can confirm every override took.
144
+
145
+ The readiness table names the directory and commit each service runs from, so the caller can confirm its own code is the code being served.
135
146
 
136
147
  ## Guardrails
137
148
 
@@ -142,11 +153,13 @@ After a test run, the caller can re-invoke for cleanup or leave services running
142
153
  - **Never start a process the user didn't approve** — approvals are granted in Decide and travel in the plan; the agent starts nothing outside it.
143
154
  - **Never read file contents outside confirmed directories** — folder names are discoverable; file contents require explicit user selection.
144
155
  - **Never write a credential into the E2E run instructions** — plaintext notes are not a secret store, and this is the file a user pastes when asking why their stack won't start. Record the env-var or secret name, never its value.
145
- - **Never leave orphan processes untracked** — every background PID goes into the tracking file.
156
+ - **Never leave orphan processes untracked** — every background PID goes into its checkout's tracking file.
146
157
  - **Never kill a process the user started independently** — `external: true` survives cleanup.
158
+ - **Never kill or test against another checkout's service** — a listener tracked under a different checkout belongs to a peer session; see [check-running](./steps/check-running.md).
159
+ - **Never start code that is not on the latest base** — no replay, preference, or approval skips [rebase-check](./steps/rebase-check.md) or [resolve-sources](./steps/resolve-sources.md).
147
160
  - **Never assume start commands** — verify via indicator file; confirm with user.
148
161
  - **Bail early on non-viable services** — don't start what can't run locally.
149
- - **Idempotent** — already-tracked alive services are kept; [smoke-test](./steps/smoke-test.md) still runs against them.
162
+ - **Idempotent** — a tracked, alive service still serving its checkout's current HEAD is kept; [smoke-test](./steps/smoke-test.md) still runs against it.
150
163
  - **Port-listening is never enough** — smoke-test (HTTP + body sniff + log tail) is mandatory before the final report.
151
164
  - **Clean Restart is the recommended fix** — first option in the smoke-test diagnose-and-fix loop; lint/build/missing-deps issues need nuke-and-reinstall.
152
165
  - **Fresh install is automatic** — [fresh-install](./steps/fresh-install.md) notifies, doesn't ask.
@@ -13,29 +13,44 @@ The resolved host fixes the **expected** dev-server port for the detection below
13
13
 
14
14
  ## Detect listening services
15
15
 
16
- Run port detection and (when an app declares a backend URL) backend-health probe per [`../../_shared/dev-server-readiness.md`](../../_shared/dev-server-readiness.md). Cross-reference hits against selected service directories.
16
+ Run port detection and (when an app declares a backend URL) backend-health probe per [`../../_shared/dev-server-readiness.md`](../../_shared/dev-server-readiness.md).
17
17
 
18
- > "**backend-api** is already listening on port 3001 (PID 54321) — looks good."
18
+ ## Prove what each listener serves
19
19
 
20
- If **all** required services are running, skip straight to [smoke-test](./smoke-test.md) — don't trust port-listening alone.
20
+ A port that answers proves nothing about which code answers it — a peer session's dev server, or last week's, answers just as well. Judge every listener on a service's port against the tracking files ([PID Tracking](../SKILL.md#pid-tracking)) and the service's run directory and commit from [resolve-sources](./resolve-sources.md):
21
21
 
22
- If some are running, acknowledge and continue to [start-commands](./start-commands.md) only for the missing ones. **Exception:** when this stage is entered via the [reuse-plan](./reuse-plan.md) short-circuit, the missing entries already have their `command` populated in `/tmp/muggle-test-prepare.json` from the reused plan — skip `start-commands` and go straight to [env-file](./env-file.md). For already-running services:
23
- - Option 1: "It's fine, keep it"
24
- - Option 2: "Restart it"
22
+ | Listener | Verdict |
23
+ | :------- | :------ |
24
+ | A tracking entry with this port, a live PID, `dir` = the run directory and `headSha` = the commit it must serve | **Proven** — keep it. A base-checkout service a peer started is proven the same way, and shared |
25
+ | The plan marks the service `external: true` | **Vouched** — the user confirmed in Decide that they run it from this checkout; keep it, never kill it |
26
+ | Tracked under the run directory's checkout at an older `headSha` | **Stale** — restart it per [start-services](./start-services.md) |
27
+ | Tracked under a different checkout, PID alive | **A peer's** — never test against it, never kill it; [Port already held](#port-already-held) |
28
+ | Untracked | **Unknown code** — when the plan approves a restart for this service, treat it as stale: Clean Restart it through [smoke-test](./smoke-test.md)'s loop (kill → [fresh-install](./fresh-install.md) → [start-services](./start-services.md) → re-test). Otherwise [Port already held](#port-already-held) |
25
29
 
26
- Mark kept services as `external: true` in the tracking file so cleanup leaves them alone.
30
+ An approved restart settles whose port it is. When the restart cannot free or claim the port — the old process survives the kill, or the port keeps answering with code this run did not start — the service is broken, not contested: it stays in the smoke-test loop and ends `DEGRADED` with that diagnosis, never `needs-input`. `DEGRADED` already stops the caller from testing, so nothing foreign is ever reported `READY`. [Port already held](#port-already-held) is only for a peer's service, or for unknown code the plan gives no restart approval for.
31
+
32
+ > "**backend-api** on port 3001 (PID 54321) serves `api/.claude/worktrees/base-main` @ `a1b2c3d` — proven."
33
+
34
+ If **all** required services are proven or vouched, skip straight to [smoke-test](./smoke-test.md) — don't trust port-listening alone.
35
+
36
+ Otherwise continue to [start-commands](./start-commands.md) only for the services still missing. **Exception:** when this stage is entered via the [reuse-plan](./reuse-plan.md) short-circuit, the missing entries already carry their `command` from the reused plan — skip `start-commands` and go straight to [env-file](./env-file.md).
27
37
 
28
38
  ## Port already held
29
39
 
30
- When the user wants a port held by a process they did **not** select (typically a stale dev server from a sibling worktree):
40
+ When a port the run needs is held by a process this run may not touch — a peer's service, or unknown code with no restart approved:
41
+
42
+ The held process is likely something the user — or a parallel session — is still using. Don't auto-decide. In the agent, return `needs-input:` naming the port, the PID, and the checkout its tracking entry names (or "untracked"); the skill asks:
31
43
 
32
44
  The held process is likely something the user is still using — a current test or dev server they value more than this prepare run. Don't auto-decide; leave the kill-vs-pause call to them.
33
45
 
34
- > "Port 3999 is held by PID 87421 (you didn't select this process — it may be a test or dev server you're still using). How do you want to proceed?"
46
+ > "Port 3999 is held by PID 87421, serving `app/.claude/worktrees/feat-y` — not this change's code. How do you want to proceed?"
35
47
 
36
48
  - Option 1: "Use the next available port" (recommended — non-destructive, leaves the existing process running)
37
- - Option 2: "Force-kill PID 87421 and claim port 3999" (kill-switch — only if you don't need that process)
49
+ - Option 2: "Force-kill PID 87421 and claim port 3999" (kill-switch — only if nobody needs that process)
38
50
  - Option 3: "Pause — leave it running, I'll finish up and re-run prepare later"
51
+ - Option 4: "It's mine — I started it from `<run directory>`" (untracked listeners only) → mark the service `external: true` in the plan and record the listener in the run directory's tracking file at its current HEAD
52
+
53
+ Testing against a listener nobody can tie to this change's checkout is never an option: its results describe someone else's code.
39
54
 
40
55
  **Option 1**: probe `3999 + N` for `N = 1, 2, …` until nothing listens. Record the new port and any env file edit (`PORT=` in `.env.local` etc.). Dev server may need restart to pick up.
41
56
 
@@ -24,7 +24,7 @@ One file per stack:
24
24
  ~/.muggle-ai/e2e-instructions/<key>.md
25
25
  ```
26
26
 
27
- `<key>` is the absolute path of the working directory's parent — the same stack identity the global prepare plan keys its entries on — reduced to a filename-safe token by replacing every path separator, and any drive-letter colon, with `-`. Derive it from the resolved absolute path rather than assuming a separator character; they differ per platform.
27
+ `<key>` is the stack key from [reuse-plan](./reuse-plan.md) — the same stack identity the global prepare plan keys its entries on — reduced to a filename-safe token by replacing every path separator, and any drive-letter colon, with `-`. A file saved under an older key is adopted and renamed the same way the plan entry is. Derive it from the resolved absolute path rather than assuming a separator character; they differ per platform.
28
28
 
29
29
  Missing → no saved instructions; run the capture below.
30
30
 
@@ -2,11 +2,14 @@
2
2
 
3
3
  The env file is **per-repo** — don't hardcode `.env.local`. Detect by scanning `package.json` `scripts/*` for `.env*` literals and known port vars (`PORT=`, `VITE_PORT=`); check framework config (`next.config.*`, `vite.config.*`).
4
4
 
5
- When a dependency on an env file exists:
5
+ When a dependency on an env file exists, for each service's run directory ([resolve-sources](./resolve-sources.md)):
6
6
 
7
- 1. Check `<cwd>/<envfile>` exists — if yes, no-op.
8
- 2. If absent, `git worktree list --porcelain` and check each sibling for the same filename.
9
- 3. If found:
7
+ 1. Check `<run-dir>/<envfile>` exists — if yes, no-op.
8
+ 2. If absent and the repo's main working tree has it at the same sub-directory, copy it — notify, don't ask: it is the user's own config for this repo, and a fresh worktree or base checkout never carries one.
9
+
10
+ > "Copied `<envfile>` into `<run-dir>` from the main working tree."
11
+
12
+ 3. Otherwise `git worktree list --porcelain` and check each sibling for the same filename. If found:
10
13
 
11
14
  > "`<envfile>` is missing in this worktree but exists at `<sibling>/<envfile>`. Copy it before starting services?"
12
15
 
@@ -15,4 +18,4 @@ When a dependency on an env file exists:
15
18
 
16
19
  4. If not found anywhere, report and ask.
17
20
 
18
- Skip silently when no env file is referenced.
21
+ Never overwrite an env file that exists. Skip silently when no env file is referenced.
@@ -3,15 +3,17 @@
3
3
  Only after every service passes [smoke-test](./smoke-test.md) or is skipped.
4
4
 
5
5
  ```
6
- Service PID Port Status Smoke Test
7
- ─────────────────────────────────────────────────────────────────
8
- backend-api 12345 3001 Running ✓
9
- auth-service 12346 8080 Running ✓
10
- frontend 12347 3000 Running ✓
11
- ─────────────────────────────────────────────────────────────────
6
+ Service PID Port Source Commit Smoke Test
7
+ ──────────────────────────────────────────────────────────────────────────────────────────────────────
8
+ backend-api 12345 3001 ~/Github/api/.claude/worktrees/base-main a1b2c3d ✓
9
+ auth-service 12346 8080 ~/Github/auth/.claude/worktrees/base-main 4d5e6f7 (2 behind) ✓
10
+ frontend 12347 3000 ~/Github/app/.claude/worktrees/feat-x 9f8e7d6 ✓
11
+ ──────────────────────────────────────────────────────────────────────────────────────────────────────
12
12
  All services verified. Ready for E2E.
13
13
  ```
14
14
 
15
+ `Source` is the run directory's checkout and `Commit` the HEAD it serves — what the caller checks to confirm its own change is the code under test. A base checkout that could not be refreshed this run (a peer's run held the lock) shows how far it trails `origin/<default>`.
16
+
15
17
  Surface skipped services so the caller knows the gap:
16
18
 
17
19
  ```
@@ -21,7 +23,7 @@ Skipped: payment-gateway — HTTP 500 on /
21
23
  If you launched the services:
22
24
 
23
25
  ```
24
- Logs: /tmp/muggle-prepare-*.log
26
+ Logs: ~/.muggle-ai/prepare/logs/<source-key>/
25
27
  Cleanup: say "stop services" or re-invoke this skill.
26
28
  ```
27
29
 
@@ -31,19 +33,21 @@ Only on a learning run, and only once the user has accepted the gate in [confirm
31
33
 
32
34
  A replay run writes nothing here; it already has the recipe.
33
35
 
34
- Build the JSON from the in-memory tracking file, dropping runtime fields:
36
+ Build the JSON from the resolved plan, keeping only the durable fields:
35
37
 
36
- ```bash
37
- jq '{
38
- version: 1,
39
- updated: now | todate,
40
- testing_scope: .testing_scope,
41
- excluded_services: .excluded_services,
42
- services: [.services[] | {name, dir, command, port}]
43
- }' /tmp/muggle-test-prepare.json
38
+ ```json
39
+ {
40
+ "version": 1,
41
+ "updated": "<now, ISO-8601>",
42
+ "testing_scope": "<testingScope>",
43
+ "excluded_services": [{ "name": "…", "reason": "…" }],
44
+ "services": [{ "name": "…", "dir": "…", "command": "…", "port": 3000 }]
45
+ }
44
46
  ```
45
47
 
46
- Upsert it under the stack's key — the absolute path of the working directory's parent — in `~/.muggle-ai/prepare-plans.json`, creating the file as `{}` if missing. The plan is machine-local, user-level data: it never goes inside the user's project, and resolving it requires no version-control tool.
48
+ Each service's `dir` names its **repo**, never a checkout: the repo's main working-tree root plus the service's sub-directory — never a linked worktree or base-checkout path, which is a per-run choice [resolve-sources](./resolve-sources.md) makes again every time.
49
+
50
+ Upsert it under the stack key ([reuse-plan](./reuse-plan.md)) in `~/.muggle-ai/prepare-plans.json`, creating the file as `{}` if missing. The plan is machine-local, user-level data: it never goes inside the user's project.
47
51
 
48
52
  Then print, once:
49
53
 
@@ -52,7 +56,7 @@ Then print, once:
52
56
  (Disable with `/muggle-preferences reusePreparePlan`.)
53
57
  ```
54
58
 
55
- If this run short-circuited via [reuse-plan](./reuse-plan.md), don't rewrite — but **do** refresh `updated` and any `command` that was re-derived during validation. Skip the announcement on the refresh path.
59
+ If this run short-circuited via [reuse-plan](./reuse-plan.md), don't rewrite — but **do** refresh `updated`, any `command` re-derived during validation, any legacy `dir` normalized by [resolve-sources](./resolve-sources.md#legacy-plan-entries), and an adopted entry's key. Skip the announcement on the refresh path.
56
60
 
57
61
  ## Save the E2E run instructions
58
62
 
@@ -1,3 +1,15 @@
1
1
  # Rebase check
2
2
 
3
- Gated by `autoRebase`. Fire per [`../../_shared/sync-branch-with-base.md`](../../_shared/sync-branch-with-base.md) when `behind > 0`. Otherwise skip silently.
3
+ Runs on every invocation — learning runs and replays alike — before anything is checked or started: a saved recipe reuses start commands, never code.
4
+
5
+ Check each **checkout under test** — the caller's own checkout, plus every `directoryOverrides` checkout — and sync it per [`../../_shared/sync-branch-with-base.md`](../../_shared/sync-branch-with-base.md), which owns the verdicts and the `autoRebase` gate. Use the caller's `base` when it passed one:
6
+
7
+ ```bash
8
+ muggle checkout-freshness --cwd "<checkout>" --base "<base>" --json
9
+ ```
10
+
11
+ - `FRESH` / `NOT_APPLICABLE` → continue.
12
+ - `BEHIND_BASE` → rebase per the gate. Declined or `never` → stop the run before anything starts and report the checkout and `behindBy`.
13
+ - `FOREIGN_BASE` → stop, naming the inherited commits.
14
+
15
+ A stop on a replay is a [hard block](./confirm-recipe.md#hard-block): resolve it with the user. Every other repo's services run from a base checkout, which [resolve-sources](./resolve-sources.md) refreshes instead of syncing.
@@ -4,14 +4,14 @@ One decision, made before anything else: does a prepare recipe already exist for
4
4
 
5
5
  Resolve the recipe location per [confirm-recipe](./confirm-recipe.md).
6
6
 
7
- - **Recipe exists** → **replay run**. Skip straight to the execute phase and run it. No scan, no interview, no questions. The whole point of having learned is not to ask again.
7
+ - **Recipe exists** → **replay run**. Run [rebase-check](./rebase-check.md) and [resolve-sources](./resolve-sources.md), then go straight to the execute phase. No scan, no interview, no questions. The whole point of having learned is not to ask again.
8
8
  - **No recipe** → **learning run**. Run the Decide stages in order, then the single gate at the end.
9
9
 
10
10
  A recipe the user declined to save is the same as no recipe: the next run learns again. Declining is not a permanent no, it just means nothing was written.
11
11
 
12
12
  ## What a replay is allowed to do
13
13
 
14
- Execute the recorded steps, in the recorded order, using the recorded commands. When a step fails, consult the recipe's recorded resolutions **first** — a problem solved before is solved the same way again, without asking.
14
+ Execute the recorded steps, in the recorded order, using the recorded commands — from the checkouts [resolve-sources](./resolve-sources.md) picked this run, never the directories the recipe was learned in. When a step fails, consult the recipe's recorded resolutions **first** — a problem solved before is solved the same way again, without asking.
15
15
 
16
16
  Only a [hard block](./confirm-recipe.md#hard-block) permits a replay to deviate or prompt.
17
17
 
@@ -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 +0,0 @@
1
- export { ACTION_SCRIPT_FILE_NAME, DEFAULT_PREFERENCES, ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS, ElectronAppPlatform, ElectronAppReleaseStream, HTML_VIEW_OFFER_LINE, 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, 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, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, toolRequiresAuth, validatePreference, verifyFileChecksum, writePreferences, writePreferencesWithMetadata, writeRunViewHtml } from './chunk-FEHTWWVH.js';