@muggleai/works 5.24.0-staging.164 → 5.24.0-staging.166

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 (52) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/{chunk-YVR2MCR2.js → chunk-CUL7GQDB.js} +47 -10
  3. package/dist/{chunk-6AAGQQDL.js → chunk-OPJUT6PX.js} +34 -45
  4. package/dist/cli.js +2 -2
  5. package/dist/index.js +2 -2
  6. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  7. package/dist/plugin/.codex-plugin/plugin.json +1 -1
  8. package/dist/plugin/.cursor-plugin/plugin.json +1 -1
  9. package/dist/plugin/scripts/guardrails.mjs +132 -6
  10. package/dist/plugin/scripts/pr-watch-arm.sh +3 -3
  11. package/dist/plugin/scripts/pr-watch-fetch.sh +2 -2
  12. package/dist/plugin/scripts/pr-watch-loop.sh +2 -2
  13. package/dist/plugin/scripts/pr-watch-state.jq +8 -2
  14. package/dist/plugin/skills/_shared/pr-followup-helpers/classify.md +2 -0
  15. package/dist/plugin/skills/do/address-reviews.md +12 -8
  16. package/dist/plugin/skills/do/cycle-size.md +33 -0
  17. package/dist/plugin/skills/do/e2e-acceptance.md +7 -1
  18. package/dist/plugin/skills/do/e2e-repair.md +4 -0
  19. package/dist/plugin/skills/do/fix-ci.md +3 -3
  20. package/dist/plugin/skills/do/impact-analysis.md +11 -0
  21. package/dist/plugin/skills/do/open-prs/forward.md +4 -0
  22. package/dist/plugin/skills/do/open-prs/update.md +7 -4
  23. package/dist/plugin/skills/do/pre-flight.md +6 -3
  24. package/dist/plugin/skills/do/resolve-conflicts.md +2 -2
  25. package/dist/plugin/skills/do/wave-e2e.md +85 -0
  26. package/dist/plugin/skills/muggle-do/SKILL.md +4 -2
  27. package/dist/plugin/skills/muggle-test-prepare/SKILL.md +7 -0
  28. package/dist/release-manifest.json +3 -3
  29. package/dist/{src-OHWBRW4X.js → src-3I5BNAZ7.js} +1 -1
  30. package/package.json +1 -1
  31. package/plugin/.claude-plugin/plugin.json +1 -1
  32. package/plugin/.codex-plugin/plugin.json +1 -1
  33. package/plugin/.cursor-plugin/plugin.json +1 -1
  34. package/plugin/scripts/guardrails.mjs +132 -6
  35. package/plugin/scripts/pr-watch-arm.sh +3 -3
  36. package/plugin/scripts/pr-watch-fetch.sh +2 -2
  37. package/plugin/scripts/pr-watch-loop.sh +2 -2
  38. package/plugin/scripts/pr-watch-state.jq +8 -2
  39. package/plugin/skills/_shared/pr-followup-helpers/classify.md +2 -0
  40. package/plugin/skills/do/address-reviews.md +12 -8
  41. package/plugin/skills/do/cycle-size.md +33 -0
  42. package/plugin/skills/do/e2e-acceptance.md +7 -1
  43. package/plugin/skills/do/e2e-repair.md +4 -0
  44. package/plugin/skills/do/fix-ci.md +3 -3
  45. package/plugin/skills/do/impact-analysis.md +11 -0
  46. package/plugin/skills/do/open-prs/forward.md +4 -0
  47. package/plugin/skills/do/open-prs/update.md +7 -4
  48. package/plugin/skills/do/pre-flight.md +6 -3
  49. package/plugin/skills/do/resolve-conflicts.md +2 -2
  50. package/plugin/skills/do/wave-e2e.md +85 -0
  51. package/plugin/skills/muggle-do/SKILL.md +4 -2
  52. package/plugin/skills/muggle-test-prepare/SKILL.md +7 -0
@@ -33,11 +33,11 @@ Run the rebase from [`../_shared/sync-branch-with-base.md`](../_shared/sync-bran
33
33
 
34
34
  ### Step 3 — Verify the resolution
35
35
 
36
- Build (typecheck + lint on the changed surface) + unit suite must pass. Run E2E per [`e2e-acceptance.md`](e2e-acceptance.md) when app logic changed and the session carries validation context. A rebase that does not verify is rolled back → escalate per Step 5. **Never push an unverified rebase.**
36
+ Build (typecheck + lint on the changed surface) + unit suite must pass. Size the rebase per [`cycle-size.md`](cycle-size.md) with `pre_cycle_sha = rebase_sha` — the comparison spans everything the base brought in. A full rebase runs E2E per [`e2e-acceptance.md`](e2e-acceptance.md) before the push; a minor one skips it and declares `NO_APP_LOGIC_CHANGE` after Step 4's force-push. A rebase that does not verify is rolled back → escalate per Step 5. **Never push an unverified rebase.**
37
37
 
38
38
  ### Step 4 — Force-push + respawn
39
39
 
40
- Force-push per [`../_shared/vcs/common/push-to-branch.md`](../_shared/vcs/common/push-to-branch.md) (tool-agnostic instruction; handles the signing gate for rebased commits and directs to provider-specific force-push paths). Use `git push --force-with-lease` for the force operation. Append the new SHA to `last_seen.pushed_shas`; increment `last_seen.conflict_resolve_attempts[rebase_key]` **and** `last_seen.catch_up_rebases` — all whole-file rewrites (Read → change field → Write) per [`../_shared/session-state-writes.md`](../_shared/session-state-writes.md), never the Edit tool. The second counter is unkeyed on purpose: `rebase_key` carries the base tip, so it mints a fresh budget every time the base moves and cannot bound a PR on an active base. Increment it on every push here, including one that later escalates, or a branch that fails the same way twenty times reads as having spent nothing. Respawn the watcher per [`respawn-watcher.md`](respawn-watcher.md). Its next tick re-checks the branch against its base on the new head — the rebase is its own verify loop, bounded by the per-SHA attempt budget.
40
+ Force-push per [`../_shared/vcs/common/push-to-branch.md`](../_shared/vcs/common/push-to-branch.md) (tool-agnostic instruction; handles the signing gate for rebased commits and directs to provider-specific force-push paths). Use `git push --force-with-lease` for the force operation. Append the new SHA to `last_seen.pushed_shas`; increment `last_seen.conflict_resolve_attempts[rebase_key]` **and** `last_seen.catch_up_rebases` — all whole-file rewrites (Read → change field → Write) per [`../_shared/session-state-writes.md`](../_shared/session-state-writes.md), never the Edit tool. The second counter is unkeyed on purpose: `rebase_key` carries the base tip, so it mints a fresh budget every time the base moves and cannot bound a PR on an active base. Increment it on every push here, including one that later escalates, or a branch that fails the same way twenty times reads as having spent nothing. Finish the tail [`cycle-size.md`](cycle-size.md) picked — a full rebase reposts the walkthrough, a minor one declares the skip — then respawn the watcher per [`respawn-watcher.md`](respawn-watcher.md). Its next tick re-checks the branch against its base on the new head — the rebase is its own verify loop, bounded by the per-SHA attempt budget.
41
41
 
42
42
  ### Step 5 — Escalate (can't resolve / budget spent)
43
43
 
@@ -0,0 +1,85 @@
1
+ # Wave E2E — one run across a multi-repo wave
2
+
3
+ A multi-repo task ships as a **wave**: one PR per repo, all carrying parts of the same change. Testing each PR alone against the other repos' default branches tests a stack that will never exist — the frontend PR runs against a backend that lacks its new endpoint, and both walkthroughs report failures neither PR will have once the wave lands.
4
+
5
+ So a wave is tested as one: start every repo's service from its wave branch, run **one** E2E pass against the combined stack, and post that single result to every PR in the wave.
6
+
7
+ ## When a cycle is a wave
8
+
9
+ All of these hold, decided at pre-flight and recorded in `state.md`:
10
+
11
+ - Two or more repos carry changes this cycle.
12
+ - Each changed repo gets exactly **one** PR — no stacked PRs, no second PR in the same repo.
13
+ - Validation is `local-e2e`.
14
+ - Every wave repo that serves part of the stack can run locally. A repo that only ships a library or config consumed by another wave repo is still a wave member; it just contributes no service of its own.
15
+
16
+ Anything else is not a wave: each PR runs Stage 6 on its own, as before. Two PRs in one repo, or one repo whose service cannot start locally, fall back to per-PR runs — record the reason in `state.md` as `Wave: off — <reason>`.
17
+
18
+ ## What pre-flight records
19
+
20
+ Under `## Pre-flight answers`, alongside `Repos:`:
21
+
22
+ ```markdown
23
+ - Wave: on
24
+ - Wave members:
25
+ - <owner/repo-a> → <worktree path a> (branch <branch>)
26
+ - <owner/repo-b> → <worktree path b> (branch <branch>)
27
+ ```
28
+
29
+ Stage 7 appends each member's PR number to its line once the PRs exist.
30
+
31
+ The worktree path is where that repo's wave branch is checked out — the path its service must start from. Record it per repo; never derive it later from the branch name.
32
+
33
+ ## Stage 6 — run once for the whole wave
34
+
35
+ Run [`e2e-acceptance.md`](e2e-acceptance.md) **once**, not once per repo, with these changes:
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.
39
+ 3. **Select test cases against the union of diffs.** Steps 1.5–3 read impact analysis for every wave repo. A test case is relevant when any member's change touches its flow. `EMPTY_DIFF` applies only when every member's diff is empty.
40
+ 4. **Run each selected test case once** against the combined stack. Do not repeat a case per repo.
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.
42
+
43
+ The report carries one extra metadata block:
44
+
45
+ ```markdown
46
+ **Wave:**
47
+ - <owner/repo-a> @ <head sha> → PR #<n> (filled in at Stage 7)
48
+ - <owner/repo-b> @ <head sha> → PR #<n>
49
+ ```
50
+
51
+ The SHAs are what the run tested. A result is only valid for the PRs at those SHAs.
52
+
53
+ ## Stage 7 — post the same result to every PR
54
+
55
+ [`open-prs/forward.md`](open-prs/forward.md) runs per repo as usual, with the wave ordering:
56
+
57
+ 1. **Open every PR first**, before settling any walkthrough. Each PR's walkthrough names its siblings, so all PR numbers must exist before the first one is written.
58
+ 2. **Body.** Add a `## Wave` section to each PR's body, after `## Validation`: one line per sibling PR (`owner/repo#n`), and the line `Tested together — merge all PRs in this wave together.`
59
+ 3. **Title.** Every PR in the wave takes the same E2E prefix. A wave run with failures retitles every member `[E2E FAILING]`, not only the implicated one — the run tested them as one change.
60
+ 4. **Walkthrough.** Settle each PR's designated walkthrough comment with the **same** E2E report through [`muggle-pr-visual-walkthrough`](../muggle-pr-visual-walkthrough/SKILL.md) Mode A, passing that PR's number and repo explicitly — Mode A otherwise looks up the PR from the current branch, which in a multi-repo cycle is the wrong repo. The runs, screenshots, and dashboard links are identical on every PR; only the PR it is posted to differs.
61
+ 5. **Record the PR numbers** on the `Wave members` lines in `state.md` (`… (branch <branch>) → PR #<n>`), so a later cycle on any one PR can find its siblings. Every slot a wave PR's watcher runs from gets the same `Wave` block.
62
+
63
+ ## Stage 7.5 — repair across the wave
64
+
65
+ [`e2e-repair.md`](e2e-repair.md) runs once for the wave, not per PR:
66
+
67
+ - A `repair` disposition fixes the code in the failure's `implicatedRepo`. An `unknown` attribution is `ask`, never a guess at a repo.
68
+ - After any pass, re-run the wave E2E above (same stack, the touched member's service restarted on its new commit) over the affected test cases, then refresh **every** wave PR's walkthrough and title through [`open-prs/update.md`](open-prs/update.md) — the evidence changed for all of them, even the PRs whose code did not.
69
+ - Clearance holds for the wave as a whole. Stage 8 dispatches one watcher per wave PR only once the wave clears.
70
+
71
+ ## Later cycles on one wave PR
72
+
73
+ When the watcher dispatches an address-reviews or fix-ci cycle on one PR whose `state.md` records `Wave: on`:
74
+
75
+ - A full cycle ([`cycle-size.md`](cycle-size.md)) re-runs the wave E2E in Stage 6, with every sibling's service started from its PR's current head — not from the default branch. Fetch each sibling's head into its recorded worktree first.
76
+ - Post the new result to the PR under review and refresh each sibling's walkthrough too, since the run tested them together and the earlier result on the siblings is now stale.
77
+ - A minor cycle runs no E2E. Its `NO_APP_LOGIC_CHANGE` skip settles only the PR under review, with the wave's last run kept beneath it, and the siblings' walkthroughs stay as they are: no app logic changed, so that run still describes the whole wave.
78
+ - A sibling already merged or closed leaves the wave: test against the base branch for that repo, and drop it from the `## Wave` section on the next refresh.
79
+
80
+ ## Invariants
81
+
82
+ - One E2E run per full wave cycle, none for a minor one; never one per repo.
83
+ - Every wave service starts from its member's worktree, verified by process cwd — a listening port proves nothing about the branch.
84
+ - Every wave PR carries the same walkthrough, the same E2E title prefix, and a `## Wave` section naming its siblings.
85
+ - Not a wave → each PR runs Stage 6 alone, with the reason recorded.
@@ -25,6 +25,8 @@ Runs an autonomous dev cycle from requirements to PR. **Fire and review:** user
25
25
  | 7.5 | E2E repair loop | [`../do/e2e-repair.md`](../do/e2e-repair.md) |
26
26
  | 8 | Hand off to watcher | [`../muggle-pr-followup/SKILL.md`](../muggle-pr-followup/SKILL.md) |
27
27
 
28
+ **Multi-repo waves.** When a task spans several repos with one PR each, the PRs form a wave: every repo's service starts from its branch, Stage 6 runs **one** E2E pass against the combined stack, and that same result is posted to every PR in the wave. See [`../do/wave-e2e.md`](../do/wave-e2e.md); pre-flight decides whether a cycle is a wave.
29
+
28
30
  Stage 7 dispatches one watcher per opened PR as its last action, gated on Stage 7.5's clearance — a cycle with unrepaired E2E failures never reaches a watcher.
29
31
 
30
32
  ## Execution protocol (non-negotiable)
@@ -47,14 +49,14 @@ Do not create or update a PR until each line holds, or is waived by a one-line r
47
49
  - Build clean — typecheck + lint on changed files
48
50
  - New/changed logic carries unit tests (authored in Stage 3; Stage 5 only runs the suite)
49
51
  - Unit suite run, PASS recorded
50
- - E2E verdict recorded with `runId` per `autoE2ETest` — or `[E2E FAILING]`, or `SKIPPED` citing one of the verified skip codes (`NO_WEB_SURFACE`, `DEV_SERVER_UNREACHABLE`, `EMPTY_DIFF`, `MUGGLE_AUTH_DOWN`, `NO_PR`, `USER_WAIVED`). Free-text reasons are rejected by the gate
52
+ - E2E verdict recorded with `runId` per `autoE2ETest` — or `[E2E FAILING]`, or `SKIPPED` citing a verified skip code from [`../do/e2e-acceptance.md`](../do/e2e-acceptance.md), where each code's verification rule lives. Free-text reasons are rejected by the gate
51
53
  - UI changes verified in a real browser with evidence (screenshot path or muggle `runId`); `curl` + `grep` is not verification
52
54
 
53
55
  Opening a PR with an unchecked, unwaived line is a cycle failure.
54
56
 
55
57
  ## Address-reviews flow
56
58
 
57
- When invoked with the directive (PR URL + slug + review ids), routes to [`../do/address-reviews.md`](../do/address-reviews.md). Shares stages 3–6 + walkthrough with the forward pipeline; skips pre-flight, requirements, and PR creation. See the orchestrator for the cycle's exact step order, classification rules, and respawn logic.
59
+ When invoked with the directive (PR URL + slug + review ids), routes to [`../do/address-reviews.md`](../do/address-reviews.md). Shares stages 3–5 with the forward pipeline, then sizes the cycle from its diff per [`../do/cycle-size.md`](../do/cycle-size.md): a full cycle adds stage 6 and a fresh walkthrough, a minor one skips E2E under a verified `NO_APP_LOGIC_CHANGE`. Skips pre-flight, requirements, and PR creation. See the orchestrator for the cycle's exact step order, classification rules, and respawn logic.
58
60
 
59
61
  ## Input routing
60
62
 
@@ -126,6 +126,13 @@ Stopped 3 services:
126
126
 
127
127
  After a test run, the caller can re-invoke for cleanup or leave services running for the next run.
128
128
 
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:
130
+
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.
133
+ - 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.
135
+
129
136
  ## Guardrails
130
137
 
131
138
  - **Never invent or default a host/port** — the dev-server URL is a recorded value, not a guess. Read it from the last-host cache via `muggle-local-last-host-get` (the [`autoSelectLocalHost`](../muggle-preferences/preference-gates/autoSelectLocalHost.md) cache) before probing ports; a framework default like `:3000` is never a fallback. The cache's own storage location belongs to that tool — don't restate it here. See [check-running](./steps/check-running.md).
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "release": "5.18.0",
3
- "buildId": "run-164-1",
4
- "commitSha": "aaa121164529b0e696c2ee4acb014f561ca1432a",
5
- "buildTime": "2026-10-22T17:30:09Z",
3
+ "buildId": "run-166-1",
4
+ "commitSha": "1b8c88d9616829f6271384d1e46d7b84ed59ec56",
5
+ "buildTime": "2026-10-22T20:10:32Z",
6
6
  "serviceName": "muggle-ai-works-mcp"
7
7
  }
@@ -1 +1 @@
1
- export { ACTION_SCRIPT_FILE_NAME, DEFAULT_PREFERENCES, 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, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, 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, getDataDir, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, isElectronAppInstalled, isFirstRun, loadApiKeyData, loadCredentials, local_exports as localQa, markOnboardingCompleted, mcp_exports as mcp, needsOnboarding, openBrowserUrl, performLogin, performLogout, pollDeviceCode, e2e_exports as qa, readPreferencesMetadata, readRunView, reconcileProjectPreferences, recordOnboardingSkip, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppPathOrNull, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, toolRequiresAuth, validatePreference, verifyFileChecksum, writePreferences, writePreferencesWithMetadata, writeRunViewHtml } from './chunk-YVR2MCR2.js';
1
+ export { ACTION_SCRIPT_FILE_NAME, DEFAULT_PREFERENCES, 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, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, 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, getDataDir, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, isElectronAppInstalled, isFirstRun, loadApiKeyData, loadCredentials, local_exports as localQa, markOnboardingCompleted, mcp_exports as mcp, needsOnboarding, openBrowserUrl, performLogin, performLogout, pollDeviceCode, e2e_exports as qa, readPreferencesMetadata, readRunView, reconcileProjectPreferences, recordOnboardingSkip, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppPathOrNull, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, toolRequiresAuth, validatePreference, verifyFileChecksum, writePreferences, writePreferencesWithMetadata, writeRunViewHtml } from './chunk-CUL7GQDB.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-staging.164",
4
+ "version": "5.24.0-staging.166",
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",
@@ -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-staging.164",
4
+ "version": "5.24.0-staging.166",
5
5
  "author": {
6
6
  "name": "Muggle AI",
7
7
  "email": "support@muggle-ai.com"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muggle",
3
- "version": "5.24.0-staging.164",
3
+ "version": "5.24.0-staging.166",
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-staging.164",
5
+ "version": "5.24.0-staging.166",
6
6
  "author": {
7
7
  "name": "Muggle AI",
8
8
  "email": "support@muggle-ai.com"
@@ -193,6 +193,7 @@ var GuardrailBackgroundJob = /* @__PURE__ */ ((GuardrailBackgroundJob2) => {
193
193
  GuardrailBackgroundJob2["ReserveWalkthroughComment"] = "reserve-walkthrough-comment";
194
194
  GuardrailBackgroundJob2["SettleWalkthroughSkipped"] = "settle-walkthrough-skipped";
195
195
  GuardrailBackgroundJob2["SettleWalkthroughUnreasoned"] = "settle-walkthrough-unreasoned";
196
+ GuardrailBackgroundJob2["SettleWalkthroughNoAppLogicChange"] = "settle-walkthrough-no-app-logic-change";
196
197
  return GuardrailBackgroundJob2;
197
198
  })(GuardrailBackgroundJob || {});
198
199
 
@@ -703,12 +704,14 @@ function applyRecordedRun(state, run) {
703
704
  let next = state;
704
705
  if (run.unitTestPassed) {
705
706
  next = { ...next, unitTestsGreen: true, e2eRun: false };
707
+ if (next.e2eSkipCycleScoped === true) next = { ...next, e2eSkipped: false, e2eSkipCycleScoped: false };
706
708
  }
707
709
  if (run.e2eRan) {
708
710
  next = { ...next, e2eRun: true, e2eBlockCount: 0 };
709
711
  }
710
712
  if (run.e2eSkipped) {
711
- next = { ...next, e2eSkipped: true };
713
+ const isEnvironmentSkipHeld = next.e2eSkipped === true && next.e2eSkipCycleScoped !== true;
714
+ next = { ...next, e2eSkipped: true, e2eSkipCycleScoped: !isEnvironmentSkipHeld && run.e2eSkipCycleScoped === true };
712
715
  }
713
716
  return next;
714
717
  }
@@ -785,6 +788,9 @@ var REPORT_SENTINEL = "muggle-pr-section";
785
788
  var WALKTHROUGH_SLOT_MARKER = "<!-- muggle-pr-walkthrough:v1 -->";
786
789
  var WALKTHROUGH_SKIPPED_MARKER = "<!-- muggle-pr-walkthrough-status:skipped -->";
787
790
  var WALKTHROUGH_COMMENT_HEADING = "### Muggle AI \u2014 PR visual walkthrough";
791
+ var REPORT_SENTINEL_TAG = new RegExp(`<!--\\s*${REPORT_SENTINEL}[^>]*-->\\s*`, "g");
792
+ var LAST_FULL_RUN_OPENING = "<details><summary>Last full E2E run on this PR</summary>";
793
+ var SHORT_SHA_LENGTH = 7;
788
794
  var GH_COMMENT_TIMEOUT_MS = 1e4;
789
795
 
790
796
  // src/guardrails/prReportPost.ts
@@ -933,6 +939,7 @@ var E2eSkipCode = /* @__PURE__ */ ((E2eSkipCode3) => {
933
939
  E2eSkipCode3["MuggleAuthDown"] = "MUGGLE_AUTH_DOWN";
934
940
  E2eSkipCode3["NoPr"] = "NO_PR";
935
941
  E2eSkipCode3["UserWaived"] = "USER_WAIVED";
942
+ E2eSkipCode3["NoAppLogicChange"] = "NO_APP_LOGIC_CHANGE";
936
943
  return E2eSkipCode3;
937
944
  })(E2eSkipCode || {});
938
945
 
@@ -940,14 +947,34 @@ var E2eSkipCode = /* @__PURE__ */ ((E2eSkipCode3) => {
940
947
  var E2E_SKIP_DECLARATION = /^\s*echo\s+["']?MUGGLE_E2E_SKIP:(.*)$/;
941
948
  var SKIP_CODE_TOKEN = /^[\s:]*([A-Za-z_]+)/;
942
949
  var E2E_SKIP_CODES = Object.values(E2eSkipCode);
950
+ var NON_APP_PATH_SUMMARY = "docs, tests, lint/format config, or CI config";
943
951
  var E2E_SKIP_CODE_CLAIMS = {
944
952
  ["NO_WEB_SURFACE" /* NoWebSurface */]: "the repo ships no web surface to drive",
945
953
  ["DEV_SERVER_UNREACHABLE" /* DevServerUnreachable */]: "the named dev server does not answer",
946
954
  ["EMPTY_DIFF" /* EmptyDiff */]: "the branch carries no diff against its base",
947
955
  ["MUGGLE_AUTH_DOWN" /* MuggleAuthDown */]: "the stored Muggle session is missing or expired",
948
956
  ["NO_PR" /* NoPr */]: "no pull request was handled this session",
949
- ["USER_WAIVED" /* UserWaived */]: "the user waived E2E in their own words"
957
+ ["USER_WAIVED" /* UserWaived */]: "the user waived E2E in their own words",
958
+ ["NO_APP_LOGIC_CHANGE" /* NoAppLogicChange */]: `every path changed since the named commit is ${NON_APP_PATH_SUMMARY}`
950
959
  };
960
+ var CYCLE_SCOPED_SKIP_CODES = ["NO_APP_LOGIC_CHANGE" /* NoAppLogicChange */];
961
+ var PRE_CYCLE_SHA_TOKEN = /^([0-9a-f]{7,40})(?![0-9a-z_])/i;
962
+ var NON_APP_PATH_PATTERNS = [
963
+ /\.(md|markdown|rst)$/i,
964
+ /(^|\/)[^/]+\.(test|spec)\.[^/]+$/,
965
+ /(^|\/)(__tests__|__snapshots__|__mocks__)\//,
966
+ /(^|\/)test_[^/]+\.py$/,
967
+ /(^|\/)[^/]+_test\.(py|go)$/,
968
+ /^tests?\//,
969
+ /(^|\/)\.(eslintrc|prettierrc|stylelintrc)(\.[a-z]+)?$/,
970
+ /(^|\/)(eslint|prettier|stylelint)\.config\.[cm]?[jt]s$/,
971
+ /(^|\/)\.(eslint|prettier|stylelint)ignore$/,
972
+ /(^|\/)\.markdownlint[^/]*$/,
973
+ /(^|\/)(biome\.jsonc?|\.editorconfig)$/,
974
+ /^\.github\/workflows\//,
975
+ /^\.gitlab-ci\.yml$/
976
+ ];
977
+ var MAX_NAMED_APP_LOGIC_PATHS = 5;
951
978
  var USER_WAIVE_PHRASE = "SKIP E2E";
952
979
  var DEV_SERVER_PROBE_TIMEOUT_MS = 2e3;
953
980
  var GIT_PROBE_TIMEOUT_MS = 5e3;
@@ -976,6 +1003,18 @@ var WEB_SURFACE_CONFIG_FILES = [
976
1003
  var OAUTH_SESSION_FILE = /^oauth-session[\w.-]*\.json$/;
977
1004
  var MUGGLE_HOME_DIR_NAME = ".muggle-ai";
978
1005
 
1006
+ // src/e2e-skip/noAppLogicChange.ts
1007
+ function parseNoAppLogicChangeDetail(detail) {
1008
+ const stated = detail.trim();
1009
+ const preCycleSha = stated.match(PRE_CYCLE_SHA_TOKEN)?.[1];
1010
+ if (!preCycleSha) return null;
1011
+ const reason = stated.slice(preCycleSha.length).replace(/^[\s:,;.-]+/, "").trim();
1012
+ return { preCycleSha, reason };
1013
+ }
1014
+ function isNonAppPath(repoRelativePath) {
1015
+ return NON_APP_PATH_PATTERNS.some((pattern) => pattern.test(repoRelativePath));
1016
+ }
1017
+
979
1018
  // src/pr-walkthrough/comment.ts
980
1019
  function renderReservedComment() {
981
1020
  return `${WALKTHROUGH_SLOT_MARKER}
@@ -999,6 +1038,34 @@ ${WALKTHROUGH_COMMENT_HEADING}
999
1038
 
1000
1039
  **No E2E run, and no verified reason given.** The session ended still owing an acceptance run and cited no skip code that Muggle could verify. Treat this PR as unvalidated by E2E.`;
1001
1040
  }
1041
+ var shortSha = (sha) => sha.slice(0, SHORT_SHA_LENGTH);
1042
+ function renderNoAppLogicChangeComment(declared, headSha, lastFullRun) {
1043
+ const cycleStart = declared.preCycleSha.toLowerCase();
1044
+ const head = headSha?.toLowerCase() ?? null;
1045
+ const isHeadPastCycleStart = head !== null && !head.startsWith(cycleStart) && !cycleStart.startsWith(head);
1046
+ const headline = isHeadPastCycleStart ? `**E2E skipped \u2014 no app-logic change in \`${shortSha(head)}\`.**` : `**E2E skipped \u2014 no app-logic change since \`${shortSha(cycleStart)}\`.**`;
1047
+ const qualifier = declared.reason ? ` \u2014 ${declared.reason}` : "";
1048
+ const evidence = lastFullRun ? `${LAST_FULL_RUN_OPENING}
1049
+
1050
+ ${lastFullRun}
1051
+
1052
+ </details>` : "_No full E2E run is on record for this PR._";
1053
+ return `${WALKTHROUGH_SLOT_MARKER}
1054
+ ${WALKTHROUGH_SKIPPED_MARKER}
1055
+ ${WALKTHROUGH_COMMENT_HEADING}
1056
+
1057
+ ${headline} Muggle verified \`${"NO_APP_LOGIC_CHANGE" /* NoAppLogicChange */}\` \u2014 every path changed since \`${shortSha(cycleStart)}\` is ${NON_APP_PATH_SUMMARY}${qualifier}.
1058
+
1059
+ ` + evidence;
1060
+ }
1061
+ function lastFullRunOf(body) {
1062
+ const status = classifyComment(body);
1063
+ if (status === "reported" /* Reported */) return body.replace(REPORT_SENTINEL_TAG, "").trim();
1064
+ if (status !== "skipped" /* Skipped */) return null;
1065
+ const start = body.indexOf(LAST_FULL_RUN_OPENING);
1066
+ if (start === -1) return null;
1067
+ return body.slice(start + LAST_FULL_RUN_OPENING.length).replace(/\s*<\/details>\s*$/, "").trim();
1068
+ }
1002
1069
  function classifyComment(body) {
1003
1070
  if (body.includes(REPORT_SENTINEL)) return "reported" /* Reported */;
1004
1071
  if (!body.includes(WALKTHROUGH_SLOT_MARKER)) return "not-designated" /* NotDesignated */;
@@ -1043,6 +1110,13 @@ function listPrComments(pr, run) {
1043
1110
  return null;
1044
1111
  }
1045
1112
  }
1113
+ function readPrHeadSha(pr, run) {
1114
+ try {
1115
+ return run(["api", `repos/${pr.repo}/pulls/${pr.prNumber}`, "--jq", ".head.sha"])?.trim() || null;
1116
+ } catch {
1117
+ return null;
1118
+ }
1119
+ }
1046
1120
  function writeJson(args, payload, run) {
1047
1121
  try {
1048
1122
  return run(args, JSON.stringify(payload)) !== null;
@@ -1096,6 +1170,19 @@ function settleWith(prUrl, body, run) {
1096
1170
  function settleWalkthroughCommentAsSkipped(prUrl, code, detail, run = defaultGhRunner) {
1097
1171
  return settleWith(prUrl, renderSkippedComment(code, detail), run);
1098
1172
  }
1173
+ function settleWalkthroughCommentForNoAppLogicChange(prUrl, detail, run = defaultGhRunner) {
1174
+ const pr = parsePrUrl(prUrl);
1175
+ const declared = parseNoAppLogicChangeDetail(detail);
1176
+ if (!pr || !declared) return false;
1177
+ const comments = listPrComments(pr, run);
1178
+ if (comments === null) return false;
1179
+ const designated = comments.find(
1180
+ (comment) => classifyComment(comment.body) !== "not-designated" /* NotDesignated */
1181
+ );
1182
+ const lastFullRun = designated ? lastFullRunOf(designated.body) : null;
1183
+ const body = renderNoAppLogicChangeComment(declared, readPrHeadSha(pr, run), lastFullRun);
1184
+ return designated ? patchPrComment(pr, designated.id, body, run) : postPrComment(pr, body, run);
1185
+ }
1099
1186
  function settleWalkthroughCommentAsUnreasoned(prUrl, run = defaultGhRunner) {
1100
1187
  return settleWith(prUrl, renderUnreasonedSkipComment(), run);
1101
1188
  }
@@ -1203,13 +1290,39 @@ var verifyUserWaived = (context) => {
1203
1290
  if (waived) return verified;
1204
1291
  return refuted(`no user turn in the transcript contains "${USER_WAIVE_PHRASE}"`);
1205
1292
  };
1293
+ var namePaths = (paths) => {
1294
+ const named = paths.slice(0, MAX_NAMED_APP_LOGIC_PATHS).join(", ");
1295
+ const unnamed = paths.length - MAX_NAMED_APP_LOGIC_PATHS;
1296
+ return unnamed > 0 ? `${named} and ${unnamed} more` : named;
1297
+ };
1298
+ var verifyNoAppLogicChange = (context, detail) => {
1299
+ if (!context.cwd) return refuted("no working directory was available to inspect");
1300
+ const declared = parseNoAppLogicChangeDetail(detail);
1301
+ if (!declared) {
1302
+ return refuted("the detail names no pre-cycle commit \u2014 cite it as NO_APP_LOGIC_CHANGE: <sha> <what changed>");
1303
+ }
1304
+ const sha = declared.preCycleSha;
1305
+ const diff = context.probe.runGit(
1306
+ ["diff", "--name-only", "--no-renames", "-z", `${sha}^{commit}`, "HEAD"],
1307
+ context.cwd
1308
+ );
1309
+ if (diff === null) return refuted(`${sha} does not resolve to a commit here, or its diff to HEAD could not be read`);
1310
+ const changedPaths = diff.split("\0").filter(Boolean);
1311
+ if (changedPaths.length === 0) {
1312
+ return refuted(`HEAD carries no change since ${sha} \u2014 declare the skip once the cycle's commits are on HEAD`);
1313
+ }
1314
+ const appLogicPaths = changedPaths.filter((path) => !isNonAppPath(path));
1315
+ if (appLogicPaths.length > 0) return refuted(`app-logic paths changed since ${sha}: ${namePaths(appLogicPaths)}`);
1316
+ return verified;
1317
+ };
1206
1318
  var VERIFIERS = {
1207
1319
  ["NO_WEB_SURFACE" /* NoWebSurface */]: verifyNoWebSurface,
1208
1320
  ["DEV_SERVER_UNREACHABLE" /* DevServerUnreachable */]: verifyDevServerUnreachable,
1209
1321
  ["EMPTY_DIFF" /* EmptyDiff */]: verifyEmptyDiff,
1210
1322
  ["MUGGLE_AUTH_DOWN" /* MuggleAuthDown */]: verifyMuggleAuthDown,
1211
1323
  ["NO_PR" /* NoPr */]: verifyNoPr,
1212
- ["USER_WAIVED" /* UserWaived */]: verifyUserWaived
1324
+ ["USER_WAIVED" /* UserWaived */]: verifyUserWaived,
1325
+ ["NO_APP_LOGIC_CHANGE" /* NoAppLogicChange */]: verifyNoAppLogicChange
1213
1326
  };
1214
1327
  function verifyDeclaredSkip(skip, context) {
1215
1328
  return VERIFIERS[skip.code](context, skip.detail);
@@ -1760,10 +1873,12 @@ function recordTests() {
1760
1873
  const cmd = input.tool_input?.command ?? "";
1761
1874
  const stateBefore = readState(sessionId);
1762
1875
  const judgedSkip = judgeE2eSkip(input, stateBefore);
1876
+ const acceptedSkip = judgedSkip?.accepted ? judgedSkip.skip : null;
1763
1877
  const run = {
1764
1878
  unitTestPassed: isTestCommand(cmd) && testsPassed(input),
1765
1879
  e2eRan: isE2ERun(input),
1766
- e2eSkipped: judgedSkip?.accepted === true
1880
+ e2eSkipped: acceptedSkip !== null,
1881
+ e2eSkipCycleScoped: acceptedSkip !== null && CYCLE_SCOPED_SKIP_CODES.includes(acceptedSkip.code)
1767
1882
  };
1768
1883
  const walkthroughPosted = detectWalkthroughPost(input);
1769
1884
  const failedRunId = detectFailedRunId(input);
@@ -1779,13 +1894,17 @@ function recordTests() {
1779
1894
  if (isWalkthroughGateArmed(next) && !isWalkthroughGateArmed(stateBefore)) {
1780
1895
  startBackgroundJob("scan-walkthroughs" /* ScanWalkthroughs */, [sessionId], input.cwd);
1781
1896
  }
1782
- if (judgedSkip?.accepted) recordSkipReasonOnPrs(next, judgedSkip.skip);
1897
+ if (acceptedSkip) recordSkipReasonOnPrs(next, acceptedSkip);
1783
1898
  if (judgedSkip && !judgedSkip.accepted) {
1784
1899
  return envelope("PostToolUse", explainRejection(judgedSkip), host);
1785
1900
  }
1786
1901
  return "{}";
1787
1902
  }
1788
1903
  function recordSkipReasonOnPrs(state, skip) {
1904
+ if (skip.code === "NO_APP_LOGIC_CHANGE" /* NoAppLogicChange */) {
1905
+ startBackgroundJob("settle-walkthrough-no-app-logic-change" /* SettleWalkthroughNoAppLogicChange */, [skip.detail], input.cwd);
1906
+ return;
1907
+ }
1789
1908
  for (const prUrl of state.prsHandled) {
1790
1909
  startBackgroundJob("settle-walkthrough-skipped" /* SettleWalkthroughSkipped */, [prUrl, skip.code, skip.detail]);
1791
1910
  }
@@ -2074,11 +2193,18 @@ function settleWalkthroughUnreasonedJob() {
2074
2193
  if (prUrl) settleWalkthroughCommentAsUnreasoned(prUrl);
2075
2194
  return "{}";
2076
2195
  }
2196
+ function settleWalkthroughNoAppLogicChangeJob() {
2197
+ const [detail] = jobArgs;
2198
+ const prUrl = defaultPrWalkthroughLookup.branchPrUrl();
2199
+ if (prUrl && detail) settleWalkthroughCommentForNoAppLogicChange(prUrl, detail);
2200
+ return "{}";
2201
+ }
2077
2202
  var backgroundJobs = {
2078
2203
  ["scan-walkthroughs" /* ScanWalkthroughs */]: scanWalkthroughsJob,
2079
2204
  ["reserve-walkthrough-comment" /* ReserveWalkthroughComment */]: reserveWalkthroughCommentJob,
2080
2205
  ["settle-walkthrough-skipped" /* SettleWalkthroughSkipped */]: settleWalkthroughSkippedJob,
2081
- ["settle-walkthrough-unreasoned" /* SettleWalkthroughUnreasoned */]: settleWalkthroughUnreasonedJob
2206
+ ["settle-walkthrough-unreasoned" /* SettleWalkthroughUnreasoned */]: settleWalkthroughUnreasonedJob,
2207
+ ["settle-walkthrough-no-app-logic-change" /* SettleWalkthroughNoAppLogicChange */]: settleWalkthroughNoAppLogicChangeJob
2082
2208
  };
2083
2209
  var runSubcommand = isBackgroundJob(sub) ? backgroundJobs[sub] : handlers[sub] ?? (() => "{}");
2084
2210
  process.stdout.write(runSubcommand());
@@ -62,7 +62,7 @@ fi
62
62
  watch_read_state_fields "$state_line"
63
63
  pr_state="${STATE_FIELDS[0]-}"
64
64
  head_sha="${STATE_FIELDS[1]-}"
65
- base_sha="${STATE_FIELDS[2]-}"
65
+ base_tip_sha="${STATE_FIELDS[2]-}"
66
66
  mergeable="${STATE_FIELDS[3]-}"
67
67
  latest_review="${STATE_FIELDS[4]-}"
68
68
  latest_comment="${STATE_FIELDS[5]-}"
@@ -82,11 +82,11 @@ if [ "${pending_checks:-0}" -eq 0 ] 2>/dev/null && [ "${failed_checks:-0}" -gt 0
82
82
  ci_red_floor="$head_sha"
83
83
  fi
84
84
 
85
- # Same for staleness: keyed on the head/base pair, so it re-arms when either moves.
85
+ # Same for staleness: keyed on the head/base-tip pair, so it re-arms when either moves.
86
86
  rebase_floor=""
87
87
  behind_count="$(watch_fetch_behind_count "$repo" "$base_branch" "$head_sha" "$slot")"
88
88
  if [ "$mergeable" = "CONFLICTING" ] || { [ -n "$behind_count" ] && [ "$behind_count" -gt 0 ] 2>/dev/null; }; then
89
- rebase_floor="${head_sha}..${base_sha}"
89
+ rebase_floor="${head_sha}..${base_tip_sha}"
90
90
  fi
91
91
 
92
92
  thread_count=0
@@ -16,7 +16,7 @@ query($owner: String!, $name: String!, $number: Int!) {
16
16
  pullRequest(number: $number) {
17
17
  state
18
18
  headRefOid
19
- baseRefOid
19
+ baseRef { target { oid } }
20
20
  mergeable
21
21
  commits(last: 1) {
22
22
  nodes {
@@ -48,7 +48,7 @@ query($owner: String!, $name: String!, $number: Int!) {
48
48
  }
49
49
 
50
50
  # behind_by needs its own call — see watch_wake_rebase for why no field on the
51
- # PR carries it. The loop makes it only when the head/base pair moved, so the
51
+ # PR carries it. The loop makes it only when the head/base-tip pair moved, so the
52
52
  # steady state stays one request per iteration.
53
53
  watch_fetch_behind_count() {
54
54
  local repo="$1" base_branch="$2" head_sha="$3" slot="$4"
@@ -152,7 +152,7 @@ while :; do
152
152
  watch_read_state_fields "$state_line"
153
153
  pr_state="${STATE_FIELDS[0]-}"
154
154
  head_sha="${STATE_FIELDS[1]-}"
155
- base_sha="${STATE_FIELDS[2]-}"
155
+ base_tip_sha="${STATE_FIELDS[2]-}"
156
156
  mergeable="${STATE_FIELDS[3]-}"
157
157
  latest_review="${STATE_FIELDS[4]-}"
158
158
  latest_comment="${STATE_FIELDS[5]-}"
@@ -201,7 +201,7 @@ while :; do
201
201
  floor_ci_red="$head_sha"
202
202
  fi
203
203
 
204
- rebase_key="${head_sha}..${base_sha}"
204
+ rebase_key="${head_sha}..${base_tip_sha}"
205
205
  if [ "$rebase_key" != "$watermark_rebase" ] && [ "$rebase_key" != "$floor_rebase" ]; then
206
206
  behind_count=$(watch_fetch_behind_count "$repo" "$base_branch" "$head_sha" "$slot")
207
207
  if watch_wake_rebase "$pr_number" "$mergeable" "$behind_count" "$rebase_key" ""; then
@@ -4,8 +4,14 @@
4
4
  # which is how the echo wake below survived unnoticed.
5
5
  #
6
6
  # Field order is the contract pr-watch-loop.sh reads positionally:
7
- # state, headRefOid, baseRefOid, mergeable, latest-review, latest-comment,
7
+ # state, headRefOid, base-tip, mergeable, latest-review, latest-comment,
8
8
  # unresolved-thread-ids, pending-checks, failed-checks, check-digest
9
+ #
10
+ # base-tip is where the base branch points now, the base half of the rebase key.
11
+ # Not baseRefOid: GitHub moves that only when the head is pushed, so a key built
12
+ # from it stays equal to an escalated or floored key however far the base
13
+ # advances, and the branch never wakes again. A deleted base branch projects as
14
+ # an empty field rather than a missing one, so no later field shifts.
9
15
 
10
16
  def loop_marked: ((.body // "") | contains("<!-- muggle-do:bot -->"));
11
17
 
@@ -40,7 +46,7 @@ def loop_marked: ((.body // "") | contains("<!-- muggle-do:bot -->"));
40
46
  [
41
47
  $pr.state,
42
48
  $pr.headRefOid,
43
- $pr.baseRefOid,
49
+ ($pr.baseRef.target.oid // ""),
44
50
  $pr.mergeable,
45
51
  (([$pr.reviews.nodes[] | select(is_echo_review | not) | .databaseId] | max) // 0),
46
52
  (($liveComments | map(select(loop_marked | not) | .databaseId) | max) // 0),
@@ -23,6 +23,8 @@ Only reviews that survive the self-loop check proceed to classify below.
23
23
 
24
24
  Default to **actionable**. CI catches wrong attempts; reviewers correct on the next round. Escalation is a round-trip with an absent user — reserve it.
25
25
 
26
+ Classification decides only whether to act. How much of the cycle runs is decided later, by the caller, from the diff the work produced — never from how the review was worded or how many comments it carried.
27
+
26
28
  Reply shape (all replies for one review reference the same SHA):
27
29
 
28
30
  - **threaded** (default): `Done in <sha> — <attribution>. (Review #<review_id>, cycle <status>.)`
@@ -82,23 +82,27 @@ The actionable reviews together carry a flat list of change items, one per line
82
82
 
83
83
  #### 4b. Apply design + code-logic changes
84
84
 
85
- Invoke [`build.md`](build.md) with the review-derived requirements: for each comment, what to change and where. `build.md` makes the edits in the working tree but does not commit.
85
+ Record `pre_cycle_sha` per [`cycle-size.md`](cycle-size.md) before the first edit. Invoke [`build.md`](build.md) with the review-derived requirements: for each comment, what to change and where. `build.md` makes the edits in the working tree but does not commit.
86
86
 
87
87
  If `build.md` reports that the requested work requires rethinking the design (e.g. the requested change conflicts with a load-bearing invariant), exit early per Step 7 (design-adjustment escalation).
88
88
 
89
- #### 4c. Create or update unit tests
89
+ #### 4c. Size the cycle
90
+
91
+ Invoke [`impact-analysis.md`](impact-analysis.md) with `pre_cycle_sha` — the forward pipeline's Stage 4, plus the cycle's own diff. Its `cycleSize` picks the tail per [`cycle-size.md`](cycle-size.md): **minor** runs 4d → 4f → 4g, **full** runs 4d → 4e → 4f → 4g, and an empty `cycleFiles` goes straight to 4g. The Step 2 classification never sizes the cycle — a one-line comment can need the full tail and a long review the minor one.
92
+
93
+ #### 4d. Create or update unit tests
90
94
 
91
95
  Invoke [`unit-tests.md`](unit-tests.md). Cover the surface that just changed; respect existing test conventions.
92
96
 
93
- #### 4d. Run ONE E2E acceptance pass
97
+ #### 4e. Run ONE E2E acceptance pass (full cycle only)
94
98
 
95
- Invoke [`e2e-acceptance.md`](e2e-acceptance.md). One pass covering all related test cases for this PR, not one per comment. The stage reads the persisted validation context (seeded by pre-flight or by bootstrap Step 6.5); a poll-only session with no context (e.g. auto-track) is reported `SKIPPED`. The persisted `Validation` strategy is the standing decision — no per-tick `autoE2ETest` prompt. See [`e2e-acceptance.md`](e2e-acceptance.md) Step 0 and [`../_shared/resolve-e2e-validation-context.md`](../_shared/resolve-e2e-validation-context.md).
99
+ Invoke [`e2e-acceptance.md`](e2e-acceptance.md). One pass covering all related test cases for this PR, not one per comment. When `state.md` records `Wave: on`, the pass runs against the wave stack — siblings started from their PRs' current heads — and the refreshed walkthrough goes to every sibling too, per [`wave-e2e.md`](wave-e2e.md#later-cycles-on-one-wave-pr). The stage reads the persisted validation context (seeded by pre-flight or by bootstrap Step 6.5); a poll-only session with no context (e.g. auto-track) is reported `SKIPPED`. The persisted `Validation` strategy is the standing decision — no per-tick `autoE2ETest` prompt. See [`e2e-acceptance.md`](e2e-acceptance.md) Step 0 and [`../_shared/resolve-e2e-validation-context.md`](../_shared/resolve-e2e-validation-context.md). A minor cycle skips this step, wave or not.
96
100
 
97
- #### 4e. Create or update the PR
101
+ #### 4f. Create or update the PR
98
102
 
99
- Invoke [`open-prs/update.md`](open-prs/update.md) (pass the PR URL + slug + existing PR number). It pushes, refreshes title/description on state change, posts a fresh walkthrough comment, and appends the new SHA to `last_seen.pushed_shas[]`. Capture the new `head_sha`.
103
+ Invoke [`open-prs/update.md`](open-prs/update.md) (pass the PR URL + slug + existing PR number, the cycle size, and `pre_cycle_sha`). It pushes, refreshes title/description on state change, settles the walkthrough comment — a fresh walkthrough for a full cycle, the `NO_APP_LOGIC_CHANGE` skip for a minor one — and appends the new SHA to `last_seen.pushed_shas[]`. Capture the new `head_sha`.
100
104
 
101
- #### 4f. Post per-comment inline replies
105
+ #### 4g. Post per-comment inline replies
102
106
 
103
107
  Invoke [`per-comment-replies.md`](per-comment-replies.md) with the actionable reviews (`gitlab`: discussions) and the new SHA. One reply per comment, in its own thread, describing what was done for it. The reply is the whole of it — neither provider's threads get resolved by the loop.
104
108
 
@@ -129,7 +133,7 @@ Emit one event per [`../_shared/telemetry-events/muggle-do-cycle.md`](../_shared
129
133
  - `"mixed"` — both branches ran.
130
134
  - `"no-op"` — every input id was already in `escalated_review_ids` (the watcher shouldn't have dispatched, but defensive coverage).
131
135
 
132
- Emit additional events as Steps fired them (escalation event in Step 3; resolve-reminder event in Step 4g).
136
+ Emit additional events as Steps fired them (escalation event in Step 3; resolve-reminder event in Step 5.5).
133
137
 
134
138
  ## Design-adjustment escalation (Step 4b early exit)
135
139