@muggleai/works 5.28.0 → 5.29.0-staging.256

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 (53) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +1 -1
  3. package/dist/{chunk-N3G4AX6M.js → chunk-XEKNDWXD.js} +7 -4
  4. package/dist/cli.js +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  7. package/dist/plugin/.codex-mcp.json +1 -1
  8. package/dist/plugin/.codex-plugin/plugin.json +1 -1
  9. package/dist/plugin/.cursor-plugin/plugin.json +1 -1
  10. package/dist/plugin/.mcp.json +1 -1
  11. package/dist/plugin/hooks/README.md +3 -3
  12. package/dist/plugin/scripts/guardrail-dispatch.sh +6 -0
  13. package/dist/plugin/scripts/guardrail-e2e-gate.sh +24 -0
  14. package/dist/plugin/scripts/guardrail-lib.sh +1 -0
  15. package/dist/plugin/scripts/guardrails.mjs +119 -45
  16. package/dist/plugin/scripts/pr-watch-arm.sh +14 -10
  17. package/dist/plugin/scripts/pr-watch-events.sh +14 -5
  18. package/dist/plugin/scripts/pr-watch-fetch.sh +1 -1
  19. package/dist/plugin/scripts/pr-watch-loop.sh +6 -5
  20. package/dist/plugin/scripts/pr-watch-state.jq +15 -5
  21. package/dist/plugin/scripts/pr-watch-verdict.mjs +22 -7
  22. package/dist/plugin/skills/_shared/ci-check-to-command.md +1 -1
  23. package/dist/plugin/skills/do/e2e-acceptance.md +1 -1
  24. package/dist/plugin/skills/do/fix-ci.md +9 -1
  25. package/dist/plugin/skills/muggle-pr-followup/arm-watcher.md +2 -2
  26. package/dist/plugin/skills/muggle-pr-followup/bootstrap.md +2 -0
  27. package/dist/plugin/skills/muggle-pr-followup/contract.md +2 -2
  28. package/dist/plugin/skills/muggle-pr-followup/state-schemas.md +12 -12
  29. package/dist/release-manifest.json +3 -3
  30. package/package.json +2 -2
  31. package/plugin/.claude-plugin/plugin.json +1 -1
  32. package/plugin/.codex-mcp.json +1 -1
  33. package/plugin/.codex-plugin/plugin.json +1 -1
  34. package/plugin/.cursor-plugin/plugin.json +1 -1
  35. package/plugin/.mcp.json +1 -1
  36. package/plugin/hooks/README.md +3 -3
  37. package/plugin/scripts/guardrail-dispatch.sh +6 -0
  38. package/plugin/scripts/guardrail-e2e-gate.sh +24 -0
  39. package/plugin/scripts/guardrail-lib.sh +1 -0
  40. package/plugin/scripts/guardrails.mjs +119 -45
  41. package/plugin/scripts/pr-watch-arm.sh +14 -10
  42. package/plugin/scripts/pr-watch-events.sh +14 -5
  43. package/plugin/scripts/pr-watch-fetch.sh +1 -1
  44. package/plugin/scripts/pr-watch-loop.sh +6 -5
  45. package/plugin/scripts/pr-watch-state.jq +15 -5
  46. package/plugin/scripts/pr-watch-verdict.mjs +22 -7
  47. package/plugin/skills/_shared/ci-check-to-command.md +1 -1
  48. package/plugin/skills/do/e2e-acceptance.md +1 -1
  49. package/plugin/skills/do/fix-ci.md +9 -1
  50. package/plugin/skills/muggle-pr-followup/arm-watcher.md +2 -2
  51. package/plugin/skills/muggle-pr-followup/bootstrap.md +2 -0
  52. package/plugin/skills/muggle-pr-followup/contract.md +2 -2
  53. package/plugin/skills/muggle-pr-followup/state-schemas.md +12 -12
@@ -9,7 +9,7 @@
9
9
  "name": "muggleai",
10
10
  "source": "./plugin",
11
11
  "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.",
12
- "version": "5.28.0"
12
+ "version": "5.29.0-staging.256"
13
13
  }
14
14
  ]
15
15
  }
package/README.md CHANGED
@@ -165,7 +165,7 @@ Nested GitLab namespaces of any depth are handled — the project path is everyt
165
165
 
166
166
  ### The pull-request walkthrough check
167
167
 
168
- When a PR is opened from a session running this plugin, Muggle reserves a comment for the acceptance walkthrough and holds the turn open until it's settled — by the walkthrough, or by a stated reason acceptance testing doesn't apply. A PR that changes only docs, tests, lint/format config, or CI config needs neither: its comment opens already settled as skipped.
168
+ When a PR is opened from a session running this plugin, Muggle reserves a comment for the acceptance walkthrough and holds the turn open until it's settled. The comment moves through three stages, edited in place: **waiting for the E2E feasibility check**; then **E2E running — waiting for the report** or **E2E not feasible** with the reason; then the E2E report. A PR that changes only docs, tests, lint/format config, or CI config opens straight at its reason. A session that ends without a run or a reason leaves the comment at the stage it reached, and the check stays unsettled.
169
169
 
170
170
  A PR opened any other way — the web UI, a teammate without the plugin — never passes through that session, so the same check also runs in GitHub Actions. It fails while the comment is still empty, and whenever the walkthrough reports a failed or inconclusive test case; the check's summary names each one with its failing step and a link to the run. While a new E2E run is underway on the PR, the check stays in progress until that run's walkthrough replaces the previous one. When the Muggle PR watcher sees it red, it repairs the cases, re-runs the whole suite, and re-settles the comment.
171
171
 
@@ -360,6 +360,7 @@ function parentIsAlive(pid) {
360
360
  var REPORT_SENTINEL = "muggle-pr-section";
361
361
  var WALKTHROUGH_SLOT_MARKER = "<!-- muggle-pr-walkthrough:v1 -->";
362
362
  var WALKTHROUGH_SKIPPED_MARKER = "<!-- muggle-pr-walkthrough-status:skipped -->";
363
+ var RETIRED_UNREASONED_SKIP_HEADLINE = "**No E2E run, and no verified reason given.**";
363
364
  var WALKTHROUGH_COMMENT_HEADING = "### Muggle AI \u2014 PR visual walkthrough";
364
365
  var RERUN_NOTICE_OPENING = "<!-- muggle-pr-walkthrough-rerun -->";
365
366
  var SHORT_SHA_LENGTH = 7;
@@ -3303,14 +3304,14 @@ function renderReservedComment() {
3303
3304
  return `${WALKTHROUGH_SLOT_MARKER}
3304
3305
  ${WALKTHROUGH_COMMENT_HEADING}
3305
3306
 
3306
- _Awaiting the E2E acceptance run. Muggle edits this comment in place when the run finishes \u2014 or records why E2E does not apply to this change._`;
3307
+ **Waiting for the E2E feasibility check.** This comment updates in place \u2014 next with the E2E run in progress or why E2E is not feasible for this change, then with the E2E report.`;
3307
3308
  }
3308
3309
  function renderDependencyBotComment(login) {
3309
3310
  return `${WALKTHROUGH_SLOT_MARKER}
3310
3311
  ${WALKTHROUGH_SKIPPED_MARKER}
3311
3312
  ${WALKTHROUGH_COMMENT_HEADING}
3312
3313
 
3313
- **No E2E run \u2014 not applicable.** A dependency update opened by \`${login}\`; no coding session ran on it.`;
3314
+ **E2E not feasible.** A dependency update opened by \`${login}\`; no coding session ran on it.`;
3314
3315
  }
3315
3316
  var shortSha = (sha) => sha.slice(0, SHORT_SHA_LENGTH);
3316
3317
  function renderNoAppLogicChangeComment(declared, headSha, lastFullRun) {
@@ -3340,7 +3341,9 @@ function isRerunInProgress(bodies) {
3340
3341
  function classifyComment(body) {
3341
3342
  if (body.includes(REPORT_SENTINEL)) return "reported" /* Reported */;
3342
3343
  if (!body.includes(WALKTHROUGH_SLOT_MARKER)) return "not-designated" /* NotDesignated */;
3343
- if (body.includes(WALKTHROUGH_SKIPPED_MARKER)) return "skipped" /* Skipped */;
3344
+ if (body.includes(WALKTHROUGH_SKIPPED_MARKER) && !body.includes(RETIRED_UNREASONED_SKIP_HEADLINE)) {
3345
+ return "skipped" /* Skipped */;
3346
+ }
3344
3347
  return "pending" /* Pending */;
3345
3348
  }
3346
3349
  function walkthroughVerdict(bodies) {
@@ -3514,7 +3517,7 @@ var OUTCOME_CONCLUSIONS = {
3514
3517
  };
3515
3518
  var FIXED_SUMMARIES = {
3516
3519
  ["settled" /* Settled */]: "This PR's Muggle AI walkthrough comment is settled \u2014 every E2E acceptance case passed, or it states why E2E does not apply.",
3517
- ["rerun-in-progress" /* RerunInProgress */]: "A new E2E acceptance run is in progress on this PR. The walkthrough comment still shows the previous run; this check settles when the new run's walkthrough replaces it.",
3520
+ ["rerun-in-progress" /* RerunInProgress */]: "An E2E acceptance run is in progress on this PR. This check settles when the run's walkthrough replaces the comment.",
3518
3521
  ["unsettled" /* Unsettled */]: "This PR's Muggle AI walkthrough comment is still empty. Run the E2E acceptance suite and post the walkthrough into it (/muggle:muggle-test), or record why E2E does not apply to this change.",
3519
3522
  ["unreadable" /* Unreadable */]: "The PR's comments could not be read, so the walkthrough duty could not be judged."
3520
3523
  };
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { runCli } from './chunk-N3G4AX6M.js';
2
+ import { runCli } from './chunk-XEKNDWXD.js';
3
3
  import './chunk-YMFQHBLJ.js';
4
4
 
5
5
  // src/cli/main.ts
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-N3G4AX6M.js';
1
+ export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-XEKNDWXD.js';
2
2
  export { createChildLogger, e2e_exports as e2e, getConfig, getLocalQaTools, getLogger, getQaTools, local_exports as localQa, mcp_exports as mcp, e2e_exports as qa, src_exports as shared } from './chunk-YMFQHBLJ.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.28.0",
4
+ "version": "5.29.0-staging.256",
5
5
  "author": {
6
6
  "name": "Muggle AI",
7
7
  "email": "support@muggle-ai.com"
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.28.0",
7
+ "@muggleai/works@5.29.0-staging.256",
8
8
  "serve"
9
9
  ],
10
10
  "env": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muggle",
3
- "version": "5.28.0",
3
+ "version": "5.29.0-staging.256",
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.28.0",
5
+ "version": "5.29.0-staging.256",
6
6
  "author": {
7
7
  "name": "Muggle AI",
8
8
  "email": "support@muggle-ai.com"
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.28.0",
7
+ "@muggleai/works@5.29.0-staging.256",
8
8
  "serve"
9
9
  ]
10
10
  }
@@ -47,14 +47,14 @@ Pre-filters are bash builtins only (`guardrail-lib.sh`), so an irrelevant event
47
47
  | `PostToolUse` (Bash) | `guardrail-record-comment-replies.sh` | record | an unresolved-thread fetch named review threads still awaiting an answer (classified by the `<!-- muggle-do:bot -->` marker, never the author login), a threaded reply the provider **confirmed** answered comments in one, or a `MUGGLE_REPLY_SKIP` marker deferred them | — | claim each thread and cover the comments answered, in the per-PR ledger beside the muggle-do slot |
48
48
  | `PreToolUse` (Bash, `if` a command names `gh`/`glab`) | `guardrail-report-format.sh` | **enforce** | a `gh pr comment\|create\|edit` body — or a `gh api … issues/comments/<id>` PATCH editing one — reads like an E2E report but lacks the `build-pr-section` sentinel | — | **deny** — render via `muggle build-pr-section` instead |
49
49
  | `PreToolUse` (muggle local execute/replay) | `guardrail-classify-gate.sh` | **enforce** | `muggle-test` is the skill in play and the target test case has no `pre-execution-classification` this session | — | **deny** — run Step 6f first (it calls `muggle-remote-test-script-list`, which is where the run learns the case has never passed) or record a legitimate skip via `MUGGLE_CLASSIFY_SKIP`. Scoped to `muggle-test`, so the single-target skills that legitimately skip classification are untouched; fails open when the test case can't be resolved |
50
- | `PreToolUse` (muggle local execute/replay) | `guardrail-walkthrough-rerun.sh` | record | a browser run is about to start in a working tree (the tool call's `cwd`) whose branch has a PR, and that PR's walkthrough comment already shows a run or a skip | — | a detached job puts a "new E2E run in progress" banner, with its UTC start time, on top of the walkthrough the run will replace. The comment underneath is untouched; the walkthrough check stays in progress until the run's own walkthrough replaces the whole body, banner included, and the walkthrough gate counts the PR as still owing that walkthrough. A reserved placeholder or a comment already bannered is left alone |
51
- | `Stop` | `guardrail-e2e-gate.sh` | **enforce** | unit tests passed this session, no E2E ran yet, and no skip was recorded | `autoE2ETest` | **block** the turn until E2E runs via `muggle-test` or a `MUGGLE_E2E_SKIP` marker records a legitimate skip (full message once, one-line reminders after; releases after 3 blocks). Quiet while a background acceptance-tester is in flight |
50
+ | `PreToolUse` (muggle local execute/replay) | `guardrail-walkthrough-rerun.sh` | record | a browser run is about to start in a working tree (the tool call's `cwd`) whose branch has a PR with a walkthrough comment | — | a detached job marks the comment with the run in progress and its UTC start time: a feasibility-check placeholder becomes "E2E running — waiting for the report"; a comment that already shows a run or a skip gets a "new E2E run in progress" banner on top, left untouched underneath. The walkthrough check stays in progress until the run's own walkthrough replaces the whole body, and the walkthrough gate counts the PR as still owing that walkthrough. A comment already marked is left alone |
51
+ | `Stop` | `guardrail-e2e-gate.sh` | **enforce** | unit tests passed this session, no E2E ran yet, and no skip was recorded | `autoE2ETest` | **block** the turn until E2E runs via `muggle-test` or a `MUGGLE_E2E_SKIP` marker records a legitimate skip (full message once, one-line reminders after; releases after 3 blocks, leaving the PR's walkthrough comment unsettled). Quiet while a background acceptance-tester is in flight |
52
52
  | `Stop` | `guardrail-terminal-gate.sh` | **enforce** | a PR went terminal this session and the next-options offer hasn't run since — an AskUserQuestion, or, while the session owns an open PR's watch slot, a closing message that asks the user | — | **block** the turn until the post-merge handoff runs (full message once, one-line reminders after; releases after 3 blocks; nothing but the offer resets the counter) |
53
53
  | `Stop` | `guardrail-watch-gate.sh` | **enforce** | a PR opened this session that is still open and has no live watch — no session slot for it is terminal, stopped by its owner, or carries a `watch-heartbeat` touched within 15 minutes; a slot that is only seeded does not count | `autoWatchPR` | **block** the turn until the watch is armed per `muggle-pr-followup`'s `arm-watcher.md` or a `MUGGLE_WATCH_SKIP` marker records a legitimate skip (releases after 3 blocks). A PR clears once the session sees it go terminal or a provider lookup reports it merged or closed — what lets a PR whose slot post-merge cleanup deleted through. The lookup runs in a detached scan queued at turn end; a PR it has not reached yet still blocks, and one it could not reach fails open |
54
54
  | `Stop` | `guardrail-watch-follow-through-gate.sh` | **enforce** | a `muggle-pr-followup` watch this session owns (the slot's `owner.json`) recorded due work in `watch-due.env` — a branch behind or conflicting with its base, or a head whose checks settled red — and `last_seen.json` records no attempt for it: no `conflict_resolve_attempts` entry for the rebase key (enforced under `autoRebase=always` while catch-up budget is left), no `ci_fix_attempts` entry for the red head. An escalation entry with no attempt behind it counts for nothing, and re-arming the watch changes nothing | `autoRebase` | **block** the turn, naming each PR and its `/muggle-do rebase` or `fix ci` dispatch. No release after N blocks: only a recorded attempt, a newer head in the slot's `prs.json`, or the user's literal `HOLD WATCH #<pr-number>` clears it. The hold must come from a turn the user typed — never a tool result, a loaded skill, a hook's message, a task notification, a compaction summary, or the agent's own text — and is kept for the session once read. Reads local files only, never a provider: the pre-filter is a builtins glob for a non-empty `watch-due.env` whose `owner.json` names the session, so Node starts only when a slot has due work |
55
55
  | `Stop` | `guardrail-walkthrough-gate.sh` | **enforce** | an E2E acceptance run happened this session and a PR in play — opened this session or on the working branch — carries no walkthrough in its body or comments, or only one under a "new E2E run in progress" banner; or an E2E skip was accepted and a PR it covers still shows the empty placeholder instead of the skip's record | `postPRVisualWalkthrough` | **block** the turn until the walkthrough is posted via `muggle-pr-visual-walkthrough` or a `MUGGLE_WALKTHROUGH_SKIP` marker records a legitimate skip. For a PR an accepted E2E skip covers, the block hands over the foreground `settle-walkthrough-skipped <pr> <session>` command, which prints `{"settled":true}` once the PR reads back the skip, and re-queues the detached write; a PR the skip does not cover is a different change and is told to run its own E2E or declare its own skip from its tree (releases after 3 blocks; an unreachable PR fails open to not-owed). A skip accepted before its PR existed is written straight into the PR's slot when it opens for the same repo and branch. The provider lookups run in a detached scan, queued when the gate arms, when a PR opens, and at each turn end; the gate decides on the last scan for the session's current PRs, begun after the last observed post, and stays open until one lands. Each PR is checked for its own walkthrough: a post to one PR settles only that one, and opening another re-arms the check. A PR whose own background run is in flight is set aside |
56
56
  | `Stop` | `guardrail-stage-gate.sh` | **enforce** | a skill invoked this session declared `mandatoryStages` and one of those files was never opened | — | **block** the turn until the stages are read or a `MUGGLE_STAGE_SKIP` marker records a legitimate skip (releases after 3 blocks) |
57
- | `Stop` | `guardrail-debug-path-gate.sh` | **enforce** | a local execution returned a non-passing run this session and nothing routed it through `_shared/debug-failed-run.md` | — | **block** the turn until the run is diagnosed (its `*-failure-classified` emit or feedback naming it) or a `MUGGLE_DEBUG_SKIP: <runId> <reason>` marker clears that run (releases after 3 blocks). Quiet while a background acceptance-tester is in flight — its failed runs land in this session's state and it debugs them itself |
57
+ | `Stop` | `guardrail-debug-path-gate.sh` | **enforce** | a local execution returned a non-passing run this session and nothing routed it through `_shared/debug-failed-run.md` | — | **block** the turn until the run is diagnosed (its `*-failure-classified` emit or feedback naming it) or a `MUGGLE_DEBUG_SKIP: <runId> <reason>` marker clears that run (releases after 3 blocks, leaving the PR's walkthrough comment unsettled). Quiet while a background acceptance-tester is in flight — its failed runs land in this session's state and it debugs them itself |
58
58
  | `Stop` | `guardrail-comment-reply-gate.sh` | **enforce** | this session claimed a review thread and left one of its comments uncovered | — | **block** the turn until each comment gets its threaded reply per `do/per-comment-replies.md` or a `MUGGLE_REPLY_SKIP: <comment-id> <reason>` marker defers it (releases after 3 blocks). The claim is the signal, not a push, so a round that answers a question with no code change is caught too; a thread another session claimed never blocks this one |
59
59
  | `Stop` | `guardrail-capability-claim.sh` | **enforce** | the closing turn tells the user a login- or code-gated flow can't be tested, reached, or verified | — | **block** once, citing `_shared/identity-and-inbox.md`: the managed profile's live inbox, provisioned number, stored TOTP secret, credentials, and CAPTCHA solver clear exactly that blocker. Reads the claim out of the transcript, since a Stop payload carries no message text. Per-sentence matching, and a sentence naming a voice call, an OAuth-only provider, or a deployment with no number provisioned never fires — those limits are real. Nudges once per session, then stays quiet, so a misread costs one turn |
60
60
  | `UserPromptSubmit` | `guardrail-build-router.sh` | advise | a build/implement/fix request (first one this session), or a direct `/muggle-do` / `/mdo` forward invocation | `autoRouteBuildToMuggleDo` | route the work through `muggle-do` (build delegated to superpowers); a direct invocation gets no advice. Either arms the build follow-through Stop gate |
@@ -23,8 +23,14 @@ guardrail_read_payload
23
23
  firing_subcommands=()
24
24
  for gate_script in "$@"; do
25
25
  GUARDRAIL_SUBCOMMAND=""
26
+ unset -f guardrail_shell_verdict
26
27
  . "$guardrail_script_dir/$gate_script" || continue
27
28
  if [[ -n $GUARDRAIL_SUBCOMMAND ]] && guardrail_wants; then
29
+ # A gate that can answer in-shell blocks the turn here, before Node's cold start can outlast the hook's cap;
30
+ # the gates after it run on the turn end that follows.
31
+ if declare -F guardrail_shell_verdict >/dev/null && guardrail_shell_verdict; then
32
+ exit 0
33
+ fi
28
34
  firing_subcommands+=("$GUARDRAIL_SUBCOMMAND")
29
35
  fi
30
36
  done
@@ -28,6 +28,30 @@ guardrail_wants() {
28
28
  && ! guardrail_state_has '"e2eRun": true'
29
29
  }
30
30
 
31
+ # Returns the block guardrails.mjs rendered ahead of time (writeE2eStopVerdict), without starting Node, while the
32
+ # budget it shares with Node's own blocks lasts. A Stop hook that outlives its one-second cap is dropped and the turn
33
+ # ends unblocked, and Node's cold start alone has taken seconds on a loaded Windows machine, so a block that waits on
34
+ # Node is one that can silently never land. Returns 1, leaving the decision and the release to Node, when nothing is
35
+ # rendered or the budget is spent.
36
+ guardrail_shell_verdict() {
37
+ local verdict_file="${GUARDRAIL_STATE_FILE%.json}.e2e-stop-verdict"
38
+ local shell_blocks_file="${GUARDRAIL_STATE_FILE%.json}.e2e-shell-blocks"
39
+ [[ -f $verdict_file ]] || return 1
40
+ local verdict=""
41
+ IFS= read -r -d '' verdict <"$verdict_file" || true
42
+ local max_blocks="${verdict%%$'\n'*}"
43
+ local hook_output="${verdict#*$'\n'}"
44
+ [[ $max_blocks =~ ^[0-9]+$ && -n $hook_output && $hook_output != "$verdict" ]] || return 1
45
+ local recorded_blocks_pattern='"e2eBlockCount"[[:space:]]*:[[:space:]]*([0-9]+)'
46
+ local recorded_blocks=0
47
+ [[ $GUARDRAIL_STATE =~ $recorded_blocks_pattern ]] && recorded_blocks="${BASH_REMATCH[1]}"
48
+ local shell_blocks=""
49
+ [[ -f $shell_blocks_file ]] && { IFS= read -r -d '' shell_blocks <"$shell_blocks_file" || true; }
50
+ ((recorded_blocks + ${#shell_blocks} < max_blocks)) || return 1
51
+ { printf 'x' >>"$shell_blocks_file"; } 2>/dev/null || return 1
52
+ printf '%s' "$hook_output"
53
+ }
54
+
31
55
  if guardrail_is_hook_script; then
32
56
  guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
33
57
  fi
@@ -154,6 +154,7 @@ guardrail_run_node() {
154
154
  guardrail_run_standalone() {
155
155
  guardrail_read_payload
156
156
  if guardrail_wants; then
157
+ declare -F guardrail_shell_verdict >/dev/null && guardrail_shell_verdict && return 0
157
158
  guardrail_run_node "$1"
158
159
  else
159
160
  printf '{}'
@@ -105,6 +105,10 @@ var SUBAGENT_DISPATCH_TOOL_NAMES = ["Agent", "Task"];
105
105
  var ACCEPTANCE_TESTER_SUBAGENT_TYPE = /(?:^|:)acceptance-tester$/;
106
106
  var ACCEPTANCE_REPORT_MARKERS = ["## Test Summary", "**Overall:**"];
107
107
  var DELEGATED_E2E_WINDOW_MS = 60 * 6e4;
108
+ var E2E_STOP_VERDICT_SUFFIX = ".e2e-stop-verdict";
109
+ var E2E_SHELL_BLOCKS_SUFFIX = ".e2e-shell-blocks";
110
+ var AUTO_E2E_TEST_PREFERENCE_KEY = "autoE2ETest";
111
+ var POST_PR_VISUAL_WALKTHROUGH_PREFERENCE_KEY = "postPRVisualWalkthrough";
108
112
 
109
113
  // src/guardrails/store/fileLock.ts
110
114
  function isProcessAlive(pid) {
@@ -220,6 +224,25 @@ function readPrStateScan(sessionId2, dirOverride) {
220
224
  function writePrStateScan(sessionId2, scan, dirOverride) {
221
225
  writeAtomically(fileFor(sessionId2, dirOverride, PR_STATE_SCAN_SUFFIX), scan, dirOverride);
222
226
  }
227
+ function writeE2eStopVerdict(sessionId2, maxBlocks, hookOutput, dirOverride) {
228
+ mkdirSync(baseDir(dirOverride), { recursive: true });
229
+ const target = fileFor(sessionId2, dirOverride, E2E_STOP_VERDICT_SUFFIX);
230
+ const staging = `${target}.${process.pid}.tmp`;
231
+ writeFileSync(staging, `${maxBlocks}
232
+ ${hookOutput}`);
233
+ renameSync(staging, target);
234
+ writeFileSync(fileFor(sessionId2, dirOverride, E2E_SHELL_BLOCKS_SUFFIX), "", { flag: "a" });
235
+ }
236
+ function readE2eShellBlockCount(sessionId2, dirOverride) {
237
+ try {
238
+ return readFileSync(fileFor(sessionId2, dirOverride, E2E_SHELL_BLOCKS_SUFFIX), "utf-8").length;
239
+ } catch {
240
+ return 0;
241
+ }
242
+ }
243
+ function clearE2eShellBlocks(sessionId2, dirOverride) {
244
+ rmSync(fileFor(sessionId2, dirOverride, E2E_SHELL_BLOCKS_SUFFIX), { force: true });
245
+ }
223
246
  var lockFor = (sessionId2, dirOverride) => `${fileFor(sessionId2, dirOverride)}.lock`;
224
247
  function commitUnderHeldLock(sessionId2, mutate, dirOverride) {
225
248
  const current = readState(sessionId2, dirOverride);
@@ -280,7 +303,6 @@ var GuardrailBackgroundJob = /* @__PURE__ */ ((GuardrailBackgroundJob2) => {
280
303
  GuardrailBackgroundJob2["ReserveWalkthroughComment"] = "reserve-walkthrough-comment";
281
304
  GuardrailBackgroundJob2["SettleWalkthroughSkipped"] = "settle-walkthrough-skipped";
282
305
  GuardrailBackgroundJob2["SettleBranchWalkthroughSkipped"] = "settle-branch-walkthrough-skipped";
283
- GuardrailBackgroundJob2["SettleWalkthroughUnreasoned"] = "settle-walkthrough-unreasoned";
284
306
  GuardrailBackgroundJob2["SettleWalkthroughNoAppLogicChange"] = "settle-walkthrough-no-app-logic-change";
285
307
  GuardrailBackgroundJob2["NoteWalkthroughRerun"] = "note-walkthrough-rerun";
286
308
  GuardrailBackgroundJob2["ScanWatchPrStates"] = "scan-watch-pr-states";
@@ -629,6 +651,7 @@ function applyE2eSkipScope(state, verifiedChange) {
629
651
  var REPORT_SENTINEL = "muggle-pr-section";
630
652
  var WALKTHROUGH_SLOT_MARKER = "<!-- muggle-pr-walkthrough:v1 -->";
631
653
  var WALKTHROUGH_SKIPPED_MARKER = "<!-- muggle-pr-walkthrough-status:skipped -->";
654
+ var RETIRED_UNREASONED_SKIP_HEADLINE = "**No E2E run, and no verified reason given.**";
632
655
  var WALKTHROUGH_COMMENT_HEADING = "### Muggle AI \u2014 PR visual walkthrough";
633
656
  var REPORT_SENTINEL_TAG = new RegExp(`<!--\\s*${REPORT_SENTINEL}[^>]*-->\\s*`, "g");
634
657
  var LAST_FULL_RUN_OPENING = "<details><summary>Last full E2E run on this PR</summary>";
@@ -1024,7 +1047,15 @@ function renderReservedComment() {
1024
1047
  return `${WALKTHROUGH_SLOT_MARKER}
1025
1048
  ${WALKTHROUGH_COMMENT_HEADING}
1026
1049
 
1027
- _Awaiting the E2E acceptance run. Muggle edits this comment in place when the run finishes \u2014 or records why E2E does not apply to this change._`;
1050
+ **Waiting for the E2E feasibility check.** This comment updates in place \u2014 next with the E2E run in progress or why E2E is not feasible for this change, then with the E2E report.`;
1051
+ }
1052
+ function renderRunningComment(startedAt) {
1053
+ return `${WALKTHROUGH_SLOT_MARKER}
1054
+ ${WALKTHROUGH_COMMENT_HEADING}
1055
+
1056
+ ${RERUN_NOTICE_OPENING}
1057
+ **E2E running \u2014 waiting for the report.** Started ${formatUtcMinute(startedAt)}. This comment becomes the E2E report when the run finishes.
1058
+ ${RERUN_NOTICE_CLOSING}`;
1028
1059
  }
1029
1060
  function renderSkippedComment(code, detail) {
1030
1061
  const stated = detail.trim();
@@ -1034,24 +1065,17 @@ function renderSkippedComment(code, detail) {
1034
1065
  ${WALKTHROUGH_SKIPPED_MARKER}
1035
1066
  ${WALKTHROUGH_COMMENT_HEADING}
1036
1067
 
1037
- **No E2E run.** Muggle verified \`${code}\` \u2014 ${E2E_SKIP_CODE_CLAIMS[code]}${qualifier}.`;
1068
+ **E2E not feasible.** Muggle verified \`${code}\` \u2014 ${E2E_SKIP_CODE_CLAIMS[code]}${qualifier}.`;
1038
1069
  }
1039
1070
  function renderNotApplicableComment(reason) {
1040
1071
  return `${WALKTHROUGH_SLOT_MARKER}
1041
1072
  ${WALKTHROUGH_SKIPPED_MARKER}
1042
1073
  ${WALKTHROUGH_COMMENT_HEADING}
1043
1074
 
1044
- **No E2E run \u2014 not applicable.** ${reason.replace(/\.$/, "")}.
1075
+ **E2E not feasible.** ${reason.replace(/\.$/, "")}.
1045
1076
 
1046
1077
  _The coding agent judged that a browser run cannot exercise this change (\`${"NOT_APPLICABLE" /* NotApplicable */}\`). Muggle did not verify this reason._`;
1047
1078
  }
1048
- function renderUnreasonedSkipComment() {
1049
- return `${WALKTHROUGH_SLOT_MARKER}
1050
- ${WALKTHROUGH_SKIPPED_MARKER}
1051
- ${WALKTHROUGH_COMMENT_HEADING}
1052
-
1053
- **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.`;
1054
- }
1055
1079
  var shortSha = (sha) => sha.slice(0, SHORT_SHA_LENGTH);
1056
1080
  function renderNoAppLogicChangeComment(declared, headSha, lastFullRun) {
1057
1081
  const cycleStart = declared.preCycleSha.toLowerCase();
@@ -1101,7 +1125,9 @@ ${RERUN_NOTICE_CLOSING}
1101
1125
  function classifyComment(body) {
1102
1126
  if (body.includes(REPORT_SENTINEL)) return "reported" /* Reported */;
1103
1127
  if (!body.includes(WALKTHROUGH_SLOT_MARKER)) return "not-designated" /* NotDesignated */;
1104
- if (body.includes(WALKTHROUGH_SKIPPED_MARKER)) return "skipped" /* Skipped */;
1128
+ if (body.includes(WALKTHROUGH_SKIPPED_MARKER) && !body.includes(RETIRED_UNREASONED_SKIP_HEADLINE)) {
1129
+ return "skipped" /* Skipped */;
1130
+ }
1105
1131
  return "pending" /* Pending */;
1106
1132
  }
1107
1133
  function walkthroughVerdict(bodies) {
@@ -1813,10 +1839,14 @@ function applyStateMutation(state, mutation) {
1813
1839
  function commitStateMutation(sessionId2, mutation, observedState) {
1814
1840
  if (observedState && applyStateMutation(observedState, mutation) === observedState) return observedState;
1815
1841
  const committed = commitState(sessionId2, (state) => applyStateMutation(state, mutation));
1816
- if (committed) return committed;
1842
+ if (committed) return withShellBlocksReset(committed);
1817
1843
  deferStateMutation(sessionId2, mutation);
1818
1844
  startBackgroundJob("commit-deferred-state" /* CommitDeferredState */, [sessionId2]);
1819
- return applyStateMutation(readState(sessionId2), mutation);
1845
+ return withShellBlocksReset(applyStateMutation(readState(sessionId2), mutation));
1846
+ }
1847
+ function withShellBlocksReset(state) {
1848
+ if (state.e2eRun === true) clearE2eShellBlocks(state.sessionId);
1849
+ return state;
1820
1850
  }
1821
1851
  function commitDeferredSessionState(sessionId2) {
1822
1852
  commitDeferredStateMutations(sessionId2, applyStateMutation);
@@ -1922,19 +1952,52 @@ function isE2ERun(input2) {
1922
1952
  if (MUGGLE_E2E_RUN_TOOL.test(input2.tool_name ?? "")) return true;
1923
1953
  return MUGGLE_SKILL_EMIT_TOOL.test(input2.tool_name ?? "") && input2.tool_input?.skillName === MUGGLE_TEST_SKILL_NAME;
1924
1954
  }
1955
+
1956
+ // src/guardrails/e2eOwedReason.ts
1957
+ var describePreference = (preferenceKey, configuredValue) => `${preferenceKey}=${configuredValue ?? "unset"}`;
1958
+ function buildE2eOwedReason(input2) {
1959
+ const isE2eMandated = input2.isE2eMandatedByUser;
1960
+ const isWalkthroughMandated = input2.postPRVisualWalkthrough === ALWAYS_PREFERENCE_VALUE;
1961
+ const preferenceSummary = `${describePreference(AUTO_E2E_TEST_PREFERENCE_KEY, input2.autoE2ETest)}, ${describePreference(POST_PR_VISUAL_WALKTHROUGH_PREFERENCE_KEY, input2.postPRVisualWalkthrough)} (~/.muggle-ai/preferences.json)`;
1962
+ const walkthroughStep = isWalkthroughMandated ? `, then post the run's walkthrough to the PR via ${input2.walkthroughSkill}` : "";
1963
+ const offeredSkipCodes = isE2eMandated ? E2E_SKIP_CODES.filter((skipCode) => skipCode !== "NOT_APPLICABLE" /* NotApplicable */) : E2E_SKIP_CODES;
1964
+ const skipClause = `To skip, run \`echo "MUGGLE_E2E_SKIP: <CODE>: <detail>"\` citing one of ${offeredSkipCodes.join(", ")}. Muggle verifies each code itself, so one that does not hold leaves this gate blocked.`;
1965
+ if (input2.blockCount > 1) {
1966
+ return `E2E acceptance run still owed (reminder ${input2.blockCount}/${input2.maxBlocks}; ${preferenceSummary}): run ${input2.muggleTestSkill}${walkthroughStep}, or cite a verifiable code via \`echo "MUGGLE_E2E_SKIP: <CODE>: <detail>"\`.`;
1967
+ }
1968
+ const owedSentence = `Do not end the turn yet. This session went unit-green or opened a PR, but no E2E acceptance run has happened. Preferences: ${preferenceSummary}. `;
1969
+ if (isE2eMandated) {
1970
+ return owedSentence + `That is the user's standing answer: do not ask them whether to test, and do not end the turn handing the decision back. Run change-driven E2E now via ${input2.muggleTestSkill}${walkthroughStep}, then finish. ${skipClause} A judgment that the change is not worth a run is not a skip.`;
1971
+ }
1972
+ return owedSentence + `Run change-driven E2E now via ${input2.muggleTestSkill}${walkthroughStep}, then finish. ${skipClause} Only when no verifiable code fits and a browser run genuinely cannot exercise the change, cite ${"NOT_APPLICABLE" /* NotApplicable */} with the reason \u2014 the PR shows it as your unverified judgment.`;
1973
+ }
1925
1974
  function parseMaxCatchUpRebases(configuredValue) {
1926
1975
  if (configuredValue === UNBOUNDED_PREFERENCE_VALUE) return null;
1927
1976
  const spelled = typeof configuredValue === "number" ? String(configuredValue) : configuredValue;
1928
1977
  return typeof spelled === "string" && POSITIVE_INTEGER.test(spelled) ? Number(spelled) : void 0;
1929
1978
  }
1979
+ var readUserPreferences = (homeDir) => asRecord(readJsonRecord(join(homeDir, ...USER_PREFERENCES_PATH_SEGMENTS)).preferences);
1980
+ function readPreferenceLayers(homeDir, pluginRoot) {
1981
+ return [readUserPreferences(homeDir), readJsonRecord(join(pluginRoot, ...PREFERENCE_DEFAULTS_PATH_SEGMENTS))];
1982
+ }
1983
+ function pickPreferenceValue(preferenceLayers, preferenceKey) {
1984
+ const configuredValue = preferenceLayers.map((layer) => layer[preferenceKey]).find((layerValue) => layerValue != null);
1985
+ return typeof configuredValue === "string" ? configuredValue : void 0;
1986
+ }
1987
+ function resolvePreferenceValue(preferenceKey, homeDir = homedir(), pluginRoot = resolvePluginRoot()) {
1988
+ return pickPreferenceValue(readPreferenceLayers(homeDir, pluginRoot), preferenceKey);
1989
+ }
1990
+ function resolveUserPreferenceValue(preferenceKey, homeDir = homedir()) {
1991
+ return pickPreferenceValue([readUserPreferences(homeDir)], preferenceKey);
1992
+ }
1930
1993
  function resolveWatchPreferences(homeDir = homedir(), pluginRoot = resolvePluginRoot()) {
1931
- const shippedDefaults = readJsonRecord(join(pluginRoot, ...PREFERENCE_DEFAULTS_PATH_SEGMENTS));
1932
- const userPreferences = asRecord(readJsonRecord(join(homeDir, ...USER_PREFERENCES_PATH_SEGMENTS)).preferences);
1933
- const autoRebase = userPreferences[AUTO_REBASE_PREFERENCE_KEY] ?? shippedDefaults[AUTO_REBASE_PREFERENCE_KEY];
1994
+ const preferenceLayers = readPreferenceLayers(homeDir, pluginRoot);
1995
+ const [userPreferences, shippedDefaults] = preferenceLayers;
1996
+ const autoRebase = pickPreferenceValue(preferenceLayers, AUTO_REBASE_PREFERENCE_KEY);
1934
1997
  const userCap = parseMaxCatchUpRebases(userPreferences[MAX_CATCH_UP_REBASES_PREFERENCE_KEY]);
1935
1998
  const shippedCap = parseMaxCatchUpRebases(shippedDefaults[MAX_CATCH_UP_REBASES_PREFERENCE_KEY]);
1936
1999
  return {
1937
- autoRebase: typeof autoRebase === "string" ? autoRebase : void 0,
2000
+ autoRebase,
1938
2001
  maxCatchUpRebases: userCap !== void 0 ? userCap : shippedCap ?? null
1939
2002
  };
1940
2003
  }
@@ -2059,19 +2122,16 @@ function settleWalkthroughCommentForNoAppLogicChange(prUrl, detail, run = defaul
2059
2122
  const body = renderNoAppLogicChangeComment(declared, readPrHeadSha(pr, run), lastFullRun);
2060
2123
  return designated ? patchPrComment(pr, designated.id, body, run) : postPrComment(pr, body, run);
2061
2124
  }
2062
- function noteWalkthroughRerunStarted(prUrl, run = defaultGhRunner, startedAt = /* @__PURE__ */ new Date()) {
2125
+ function noteE2eRunStarted(prUrl, run = defaultGhRunner, startedAt = /* @__PURE__ */ new Date()) {
2063
2126
  const pr = parsePrUrl(prUrl);
2064
2127
  if (!pr) return false;
2065
2128
  const comments = listPrComments(pr, run);
2066
2129
  if (comments === null) return false;
2067
2130
  const designated = designatedComment(comments);
2068
2131
  if (!designated) return false;
2069
- if (classifyComment(designated.body) === "pending" /* Pending */) return false;
2070
2132
  if (hasRerunNotice(designated.body)) return false;
2071
- return patchPrComment(pr, designated.id, withRerunNotice(designated.body, startedAt), run);
2072
- }
2073
- function settleWalkthroughCommentAsUnreasoned(prUrl, run = defaultGhRunner) {
2074
- return settleWith(prUrl, renderUnreasonedSkipComment(), run);
2133
+ const body = classifyComment(designated.body) === "pending" /* Pending */ ? renderRunningComment(startedAt) : withRerunNotice(designated.body, startedAt);
2134
+ return patchPrComment(pr, designated.id, body, run);
2075
2135
  }
2076
2136
 
2077
2137
  // src/e2e-skip/parseSkipDeclaration.ts
@@ -2216,7 +2276,12 @@ var verifyNoAppLogicChange = (context, detail) => {
2216
2276
  if (appLogicPaths.length > 0) return refuted(`app-logic paths changed since ${sha}: ${namePaths(appLogicPaths)}`);
2217
2277
  return verified;
2218
2278
  };
2219
- var verifyNotApplicable = (_context, detail) => {
2279
+ var verifyNotApplicable = (context, detail) => {
2280
+ if (context.userAutoE2ETest === ALWAYS_PREFERENCE_VALUE) {
2281
+ return refuted(
2282
+ `autoE2ETest=always in ~/.muggle-ai/preferences.json, so a judgment that the change needs no run is not a skip the user allows \u2014 run the E2E, or cite a code Muggle can verify`
2283
+ );
2284
+ }
2220
2285
  const words = detail.trim().split(/\s+/).filter(Boolean).length;
2221
2286
  if (words >= MIN_NOT_APPLICABLE_REASON_WORDS) return verified;
2222
2287
  return refuted(
@@ -2261,12 +2326,14 @@ function explainRejection(judged) {
2261
2326
  return `The skip cited ${judged.claimedCode}, but that could not be verified: ${judged.failure}. E2E is still owed \u2014 cite a code that holds, or run it.`;
2262
2327
  }
2263
2328
  function judgeE2eSkip(input2, state, probes = defaultSkipProbes) {
2329
+ const homeDir = homedir();
2264
2330
  return resolveSkipDeclaration(input2.tool_input?.command ?? "", {
2265
2331
  cwd: input2.cwd,
2266
2332
  prsHandled: state.prsHandled,
2267
2333
  transcriptPath: input2.transcript_path,
2268
- homeDir: homedir(),
2269
- probe: probes
2334
+ homeDir,
2335
+ probe: probes,
2336
+ userAutoE2ETest: resolveUserPreferenceValue(AUTO_E2E_TEST_PREFERENCE_KEY, homeDir)
2270
2337
  });
2271
2338
  }
2272
2339
 
@@ -2688,6 +2755,7 @@ function prOpened() {
2688
2755
  prUrl: url,
2689
2756
  prChange
2690
2757
  });
2758
+ renderE2eStopVerdict(stateAfterOpen);
2691
2759
  const declaredSkip = isPrCoveredBySkip(stateAfterOpen, url) ? stateAfterOpen.e2eSkipDeclaration : void 0;
2692
2760
  if (declaredSkip) {
2693
2761
  startBackgroundJob("settle-walkthrough-skipped" /* SettleWalkthroughSkipped */, [url, declaredSkip.code, declaredSkip.detail]);
@@ -2766,6 +2834,7 @@ function recordTests() {
2766
2834
  failedRunId: detectFailedRunId(input)
2767
2835
  };
2768
2836
  const next = commitStateMutation(sessionId, outcome);
2837
+ if (outcome.run.unitTestPassed) renderE2eStopVerdict(next);
2769
2838
  startWalkthroughScanOnGateArming(stateBefore, next, walkthroughPosted);
2770
2839
  if (acceptedSkip) recordSkipReasonOnPrs(next, acceptedSkip);
2771
2840
  if (judgedSkip && !judgedSkip.accepted) {
@@ -2869,19 +2938,30 @@ function debugPathGate() {
2869
2938
  const reason = decision.blockCount === 1 ? `Do not end the turn yet. These runs failed and never went through the debug path: ${runList}. muggle-test Step 7C makes that mandatory \u2014 route each through _shared/debug-failed-run.md: gather the attempted steps and the failing screenshot, diagnose the bucket per _shared/failure-mode-handling.md \xA7B/\xA7C with its classified telemetry emit, and present the offer in which "give feedback & rerun" is always available. A summarized-and-dropped failure is the run a reviewer most needs to see. If a run genuinely cannot be debugged, run \`echo "MUGGLE_DEBUG_SKIP: <runId> <reason>"\` \u2014 that clears just that run.` : `Failed runs still owe the debug path (reminder ${decision.blockCount}/${MAX_DEBUG_BLOCKS}): ${runList}. Route each through _shared/debug-failed-run.md, or record a legitimate skip via \`echo "MUGGLE_DEBUG_SKIP: <runId> <reason>"\`.`;
2870
2939
  return blockStop(reason, host);
2871
2940
  }
2941
+ function e2eOwedReason(blockCount) {
2942
+ return buildE2eOwedReason({
2943
+ blockCount,
2944
+ maxBlocks: MAX_E2E_BLOCKS,
2945
+ autoE2ETest: resolvePreferenceValue(AUTO_E2E_TEST_PREFERENCE_KEY),
2946
+ postPRVisualWalkthrough: resolvePreferenceValue(POST_PR_VISUAL_WALKTHROUGH_PREFERENCE_KEY),
2947
+ isE2eMandatedByUser: resolveUserPreferenceValue(AUTO_E2E_TEST_PREFERENCE_KEY) === ALWAYS_PREFERENCE_VALUE,
2948
+ muggleTestSkill: muggleSkill("/muggle:muggle-test"),
2949
+ walkthroughSkill: muggleSkill("/muggle:muggle-pr-visual-walkthrough")
2950
+ });
2951
+ }
2952
+ function renderE2eStopVerdict(state) {
2953
+ if (!shouldRunE2E(state)) return;
2954
+ writeE2eStopVerdict(sessionId, MAX_E2E_BLOCKS, blockStop(e2eOwedReason(1), host));
2955
+ }
2872
2956
  function e2eGate() {
2873
2957
  const state = readState(sessionId);
2874
- const decision = e2eGateDecision(state);
2875
- if (decision.action === "release" /* Release */) {
2876
- for (const prUrl of state.prsHandled) {
2877
- startBackgroundJob("settle-walkthrough-unreasoned" /* SettleWalkthroughUnreasoned */, [prUrl]);
2878
- }
2879
- return releaseGate("e2eReleased");
2880
- }
2958
+ const shellBlockCount = readE2eShellBlockCount(sessionId);
2959
+ const decision = e2eGateDecision({ ...state, e2eBlockCount: (state.e2eBlockCount ?? 0) + shellBlockCount });
2960
+ if (decision.action === "release" /* Release */) return releaseGate("e2eReleased");
2881
2961
  if (decision.action === "none" /* None */) return "{}";
2882
- recordGateBlock("e2eBlockCount", decision.blockCount);
2883
- const reason = decision.blockCount === 1 ? `Do not end the turn yet. This session went unit-green or opened a PR, but no E2E acceptance run has happened. Per the autoE2ETest preference (default: always), run change-driven E2E now via ${muggleSkill("/muggle:muggle-test")}, then finish. To skip, run \`echo "MUGGLE_E2E_SKIP: <CODE>: <detail>"\` citing one of ${E2E_SKIP_CODES.join(", ")}. Muggle verifies each code itself, so one that does not hold leaves this gate blocked. Only when no verifiable code fits and a browser run genuinely cannot exercise the change, cite ${"NOT_APPLICABLE" /* NotApplicable */} with the reason \u2014 the PR shows it as your unverified judgment.` : `E2E acceptance run still owed (reminder ${decision.blockCount}/${MAX_E2E_BLOCKS}): run ${muggleSkill("/muggle:muggle-test")}, or cite a verifiable code via \`echo "MUGGLE_E2E_SKIP: <CODE>: <detail>"\`.`;
2884
- return blockStop(reason, host);
2962
+ recordGateBlock("e2eBlockCount", decision.blockCount - shellBlockCount);
2963
+ renderE2eStopVerdict(state);
2964
+ return blockStop(e2eOwedReason(decision.blockCount), host);
2885
2965
  }
2886
2966
  function watchGate() {
2887
2967
  const state = readState(sessionId);
@@ -2933,7 +3013,7 @@ function watchFollowThroughGate() {
2933
3013
  const holdInstruction = `Only the user can hold it: their own message containing \`${WATCH_HOLD_PHRASE_PREFIX}<pr-number>\` for that PR. Ask if you must; never decide it for them.`;
2934
3014
  const reason = decision.blockCount === 1 ? `Do not end the turn yet. A muggle-pr-followup watch this session owns found work due that nothing acted on:
2935
3015
  ${owedList}
2936
- autoRebase=always makes a due rebase binding, and how long a CI run or an eval takes is never a reason to wait. Act now \u2014 if the tick finds actionable review feedback it dispatches that first. A recorded attempt (conflict_resolve_attempts / ci_fix_attempts) or a new head clears this; an escalation entry with no attempt behind it does not, and neither does re-arming the watch. ${holdInstruction}` : `Watcher work still owed (reminder ${decision.blockCount}):
3016
+ autoRebase=always makes a due rebase binding, and how long a CI run or an eval takes is never a reason to wait. Act now: run the cycle the tick dispatches \u2014 if it finds actionable review feedback it dispatches that first. That cycle's first step records its attempt (conflict_resolve_attempts / ci_fix_attempts), which, like a new head, clears this. Writing the count without running the cycle \u2014 or for an E2E run queued for a different PR \u2014 leaves the PR red and the watch quiet. An escalation entry with no attempt behind it does not clear this, and neither does re-arming the watch. ${holdInstruction}` : `Watcher work still owed (reminder ${decision.blockCount}):
2937
3017
  ${owedList}
2938
3018
  ${holdInstruction}`;
2939
3019
  return blockStop(reason, host);
@@ -3162,11 +3242,6 @@ function settleBranchWalkthroughSkippedJob() {
3162
3242
  if (prUrl) settleWalkthroughCommentAsSkipped(prUrl, code, detail ?? "");
3163
3243
  return "{}";
3164
3244
  }
3165
- function settleWalkthroughUnreasonedJob() {
3166
- const [prUrl] = jobArgs;
3167
- if (prUrl) settleWalkthroughCommentAsUnreasoned(prUrl);
3168
- return "{}";
3169
- }
3170
3245
  function settleWalkthroughNoAppLogicChangeJob() {
3171
3246
  const [detail] = jobArgs;
3172
3247
  const prUrl = defaultPrWalkthroughLookup.branchPrUrl();
@@ -3175,7 +3250,7 @@ function settleWalkthroughNoAppLogicChangeJob() {
3175
3250
  }
3176
3251
  function noteWalkthroughRerunJob() {
3177
3252
  const prUrl = defaultPrWalkthroughLookup.branchPrUrl();
3178
- if (prUrl) noteWalkthroughRerunStarted(prUrl);
3253
+ if (prUrl) noteE2eRunStarted(prUrl);
3179
3254
  return "{}";
3180
3255
  }
3181
3256
  function scanWatchPrStatesJob() {
@@ -3197,7 +3272,6 @@ var backgroundJobs = {
3197
3272
  ["reserve-walkthrough-comment" /* ReserveWalkthroughComment */]: reserveWalkthroughCommentJob,
3198
3273
  ["settle-walkthrough-skipped" /* SettleWalkthroughSkipped */]: settleWalkthroughSkippedJob,
3199
3274
  ["settle-branch-walkthrough-skipped" /* SettleBranchWalkthroughSkipped */]: settleBranchWalkthroughSkippedJob,
3200
- ["settle-walkthrough-unreasoned" /* SettleWalkthroughUnreasoned */]: settleWalkthroughUnreasonedJob,
3201
3275
  ["settle-walkthrough-no-app-logic-change" /* SettleWalkthroughNoAppLogicChange */]: settleWalkthroughNoAppLogicChangeJob,
3202
3276
  ["note-walkthrough-rerun" /* NoteWalkthroughRerun */]: noteWalkthroughRerunJob,
3203
3277
  ["scan-watch-pr-states" /* ScanWatchPrStates */]: scanWatchPrStatesJob,