@muggleai/works 5.26.0-staging.207 → 5.26.0-staging.209

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 (74) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli.js +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  5. package/dist/plugin/.codex-mcp.json +1 -1
  6. package/dist/plugin/.codex-plugin/plugin.json +1 -1
  7. package/dist/plugin/.cursor-plugin/plugin.json +1 -1
  8. package/dist/plugin/.mcp.json +1 -1
  9. package/dist/plugin/agents/acceptance-tester.md +18 -2
  10. package/dist/plugin/hooks/README.md +7 -5
  11. package/dist/plugin/hooks/codex-hooks.json +4 -4
  12. package/dist/plugin/hooks/hooks.json +3 -3
  13. package/dist/plugin/scripts/guardrail-record-delegation.sh +25 -0
  14. package/dist/plugin/scripts/guardrail-walkthrough-gate.sh +6 -6
  15. package/dist/plugin/scripts/guardrail-watch-follow-through-gate.sh +48 -0
  16. package/dist/plugin/scripts/guardrails.mjs +443 -64
  17. package/dist/plugin/scripts/pr-watch-arm.sh +64 -37
  18. package/dist/plugin/scripts/pr-watch-due.sh +31 -0
  19. package/dist/plugin/scripts/pr-watch-events.sh +20 -6
  20. package/dist/plugin/scripts/pr-watch-loop.sh +21 -2
  21. package/dist/plugin/scripts/pr-watch-verdict.mjs +197 -0
  22. package/dist/plugin/skills/_shared/ci-check-to-command.md +2 -1
  23. package/dist/plugin/skills/do/background-e2e.md +89 -0
  24. package/dist/plugin/skills/do/e2e-acceptance.md +4 -0
  25. package/dist/plugin/skills/do/e2e-repair.md +1 -1
  26. package/dist/plugin/skills/do/fix-ci.md +24 -8
  27. package/dist/plugin/skills/do/open-prs/forward.md +3 -3
  28. package/dist/plugin/skills/do/pre-flight.md +4 -3
  29. package/dist/plugin/skills/do/resolve-conflicts.md +7 -3
  30. package/dist/plugin/skills/do/wave-e2e.md +3 -3
  31. package/dist/plugin/skills/do/wave-or-stream.md +51 -0
  32. package/dist/plugin/skills/muggle-do/SKILL.md +6 -2
  33. package/dist/plugin/skills/muggle-pr-followup/SKILL.md +1 -1
  34. package/dist/plugin/skills/muggle-pr-followup/arm-watcher.md +5 -3
  35. package/dist/plugin/skills/muggle-pr-followup/blocked-tick.md +2 -0
  36. package/dist/plugin/skills/muggle-pr-followup/contract.md +40 -25
  37. package/dist/plugin/skills/muggle-pr-followup/state-schemas.md +22 -8
  38. package/dist/release-manifest.json +3 -3
  39. package/package.json +1 -1
  40. package/plugin/.claude-plugin/plugin.json +1 -1
  41. package/plugin/.codex-mcp.json +1 -1
  42. package/plugin/.codex-plugin/plugin.json +1 -1
  43. package/plugin/.cursor-plugin/plugin.json +1 -1
  44. package/plugin/.mcp.json +1 -1
  45. package/plugin/agents/acceptance-tester.md +18 -2
  46. package/plugin/hooks/README.md +7 -5
  47. package/plugin/hooks/codex-hooks.json +4 -4
  48. package/plugin/hooks/hooks.json +3 -3
  49. package/plugin/scripts/guardrail-record-delegation.sh +25 -0
  50. package/plugin/scripts/guardrail-walkthrough-gate.sh +6 -6
  51. package/plugin/scripts/guardrail-watch-follow-through-gate.sh +48 -0
  52. package/plugin/scripts/guardrails.mjs +443 -64
  53. package/plugin/scripts/pr-watch-arm.sh +64 -37
  54. package/plugin/scripts/pr-watch-due.sh +31 -0
  55. package/plugin/scripts/pr-watch-events.sh +20 -6
  56. package/plugin/scripts/pr-watch-loop.sh +21 -2
  57. package/plugin/scripts/pr-watch-verdict.mjs +197 -0
  58. package/plugin/skills/_shared/ci-check-to-command.md +2 -1
  59. package/plugin/skills/do/background-e2e.md +89 -0
  60. package/plugin/skills/do/e2e-acceptance.md +4 -0
  61. package/plugin/skills/do/e2e-repair.md +1 -1
  62. package/plugin/skills/do/fix-ci.md +24 -8
  63. package/plugin/skills/do/open-prs/forward.md +3 -3
  64. package/plugin/skills/do/pre-flight.md +4 -3
  65. package/plugin/skills/do/resolve-conflicts.md +7 -3
  66. package/plugin/skills/do/wave-e2e.md +3 -3
  67. package/plugin/skills/do/wave-or-stream.md +51 -0
  68. package/plugin/skills/muggle-do/SKILL.md +6 -2
  69. package/plugin/skills/muggle-pr-followup/SKILL.md +1 -1
  70. package/plugin/skills/muggle-pr-followup/arm-watcher.md +5 -3
  71. package/plugin/skills/muggle-pr-followup/blocked-tick.md +2 -0
  72. package/plugin/skills/muggle-pr-followup/contract.md +40 -25
  73. package/plugin/skills/muggle-pr-followup/state-schemas.md +22 -8
  74. /package/dist/{chunk-HGN35NEP.js → chunk-PQVRAFNE.js} +0 -0
@@ -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.26.0-staging.207"
12
+ "version": "5.26.0-staging.209"
13
13
  }
14
14
  ]
15
15
  }
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { runCli } from './chunk-HGN35NEP.js';
2
+ import { runCli } from './chunk-PQVRAFNE.js';
3
3
  import './chunk-ZR7KLGHQ.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-HGN35NEP.js';
1
+ export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-PQVRAFNE.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-ZR7KLGHQ.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.26.0-staging.207",
4
+ "version": "5.26.0-staging.209",
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.26.0-staging.207",
7
+ "@muggleai/works@5.26.0-staging.209",
8
8
  "serve"
9
9
  ],
10
10
  "env": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muggle",
3
- "version": "5.26.0-staging.207",
3
+ "version": "5.26.0-staging.209",
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.26.0-staging.207",
5
+ "version": "5.26.0-staging.209",
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.26.0-staging.207",
7
+ "@muggleai/works@5.26.0-staging.209",
8
8
  "serve"
9
9
  ]
10
10
  }
@@ -30,6 +30,8 @@ The orchestrator provides a dispatch prompt with:
30
30
 
31
31
  - **What to do:** Run tests, import tests, manage preferences, check status, or repair.
32
32
  - **For testing:** Target URL and what to test — a feature description, acceptance criteria, or "run regression on recent changes."
33
+ - **For a background change run:** one change's brief — its session directory, repo, worktree, branch, head SHA, validation target, project, scope, and the absolute path of the stage file to execute. Read that file and execute its steps yourself, starting the app from the brief's worktree; its tool calls are the run. Every value you need is in the brief — the conversation that wrote it is not available to you.
34
+ - **For a background wave run:** the same brief, carrying every member of the wave — a change split across repos whose PRs only work together — each with its own repo, worktree, branch, head SHA and PR, plus the wave stage file. Start every member's services from that member's worktree, run each test case once against the combined stack, and name the member each failure implicates. A brief whose PRs are unrelated changes is a stream, not a wave: test only the one change it names, and leave its siblings to their own runs.
33
35
  - **For import:** Path to test files or documents to import.
34
36
  - **For preferences:** Which preference to view or change, or "show all."
35
37
  - **For status/repair:** No additional input needed.
@@ -81,6 +83,16 @@ For each **passed** test, list the name only:
81
83
  ### {Test Name} — PASS
82
84
  ```
83
85
 
86
+ ### When Running a Background Change Run
87
+
88
+ Return the report in the Output format of the stage file the brief named, followed by one line naming what the run tested — one line per member for a wave run, and each failed test naming its `implicatedRepo` (the member whose change the failing step points at, or `unknown`):
89
+
90
+ ```
91
+ Tested: {owner/repo}@{head sha}
92
+ ```
93
+
94
+ The orchestrator posts the report only while every listed SHA is still its branch head, and only to that change's PRs — for a wave, the same report to every member's PR. A run that could not start reports its verdict and reason in the same format — never return without a report.
95
+
84
96
  ### When Importing Tests
85
97
 
86
98
  Report:
@@ -108,5 +120,9 @@ Report:
108
120
  3. **Describe problems from the user's perspective.** "The checkout button is not clickable after adding an item to the cart" — not "onClick handler missing on Button component in CartPage.tsx."
109
121
  4. **Do not modify application code.** Report findings; coding agents act on them.
110
122
  5. **Do not decide when to run.** The orchestrator dispatches; you execute and report.
111
- 6. **Do not choose local vs remote.** The `muggle-test` skill handles routing based on the target URL and user preferences.
112
- 7. **Use skills, not raw MCP tools.** The orchestrator pastes the full skill text into your dispatch prompt. Follow the skill's instructions exactly.
123
+ 6. **Do not choose local vs remote.** The `muggle-test` skill handles routing based on the target URL and user preferences; in a background change run, the brief's validation target decides.
124
+ 7. **Use skills, not raw MCP tools.** The orchestrator pastes the full skill text into your dispatch prompt. Follow the skill's instructions exactly. A background change run is the one exception: the stage file its brief names is the procedure, and its MCP calls are its steps.
125
+ 8. **Never dispatch another agent or fork.** Run every step in your own context. A run handed further down escapes the orchestrator's one-local-run-at-a-time queue and lands on the browser alongside the next run; two studio runs at once corrupt each other.
126
+ 9. **Never run alongside another local run.** Before your first local execution, list the local run results; if a run is still executing, return `BLOCKED — another local run in flight` instead of starting one.
127
+ 10. **Never write to a PR or the repo.** No commits, pushes, PR edits, comments, walkthrough posts, or watcher arms — the orchestrator owns every PR write, because only it knows which change a PR belongs to.
128
+ 11. **Never declare a skip marker in a background change run.** Return the skip code in the report; the orchestrator declares it from the PR's own worktree, where it settles that PR alone.
@@ -20,7 +20,7 @@ A guardrail emits one of two strengths:
20
20
  - **Advise** — `additionalContext` (PostToolUse/UserPromptSubmit) or a plain Stop message. A soft nudge the model can ignore.
21
21
  - **Enforce** — a `Stop` `decision: "block"` that refuses to end the turn, or a `PreToolUse` `permissionDecision: "deny"` that refuses a tool call. The model cannot proceed until the condition is met.
22
22
 
23
- Enforcement is reserved for the handoffs that were being skipped: the E2E acceptance run, posting a deterministically-rendered report, and the post-merge handoff. Each enforcing gate carries an escape so it can't trap a turn — the E2E gate accepts an explicit skip declaration (`echo "MUGGLE_E2E_SKIP: <reason>"`, session-durable) and hard-releases after `MAX_E2E_BLOCKS` (3) blocks; the report gate only denies a body it can positively see is a hand-written report and fails open otherwise; the post-merge gate hard-releases after `MAX_PR_TERMINAL_BLOCKS` (3) blocks, and only the AskUserQuestion next-options offer clears it — nothing else resets its counter.
23
+ Enforcement is reserved for the handoffs that were being skipped: the E2E acceptance run, posting a deterministically-rendered report, and the post-merge handoff. Each enforcing gate carries an escape so it can't trap a turn — the E2E gate accepts an explicit skip declaration (`echo "MUGGLE_E2E_SKIP: <reason>"`, session-durable) and hard-releases after `MAX_E2E_BLOCKS` (3) blocks; the report gate only denies a body it can positively see is a hand-written report and fails open otherwise; the post-merge gate hard-releases after `MAX_PR_TERMINAL_BLOCKS` (3) blocks, and only the AskUserQuestion next-options offer clears it — nothing else resets its counter. The watcher follow-through gate is the one with no block budget, because a budget the session can wait out is the very hold it must not take: its escape is doing the work, or the user's own `HOLD WATCH #<pr-number>`.
24
24
 
25
25
  ## Mechanism
26
26
 
@@ -35,21 +35,23 @@ Pre-filters are bash builtins only (`guardrail-lib.sh`), so an irrelevant event
35
35
  | Hook event | Wrapper | Strength | Condition | Preference | Effect |
36
36
  | :--------- | :------ | :------- | :-------- | :--------- | :----- |
37
37
  | `PostToolUse` (Bash) | `guardrail-pr-opened.sh` | advise | a `gh pr create`/`gh pr ready` just succeeded | `autoWatchPR` | start a `muggle-pr-followup` watcher on the new PR |
38
- | `PostToolUse` (Bash + muggle execute/replay MCP tools) | `guardrail-record-tests.sh` | record | a unit-test command passed, an E2E run happened (execute/replay call), or an `echo "MUGGLE_E2E_SKIP: <reason>"` marker declared E2E un-runnable, or a walkthrough carrying the `build-pr-section` sentinel was posted / declared un-postable via `echo "MUGGLE_WALKTHROUGH_SKIP: <reason>"` | — | set `unitTestsGreen` / `e2eRun` / `e2eSkipped` / `walkthroughPosted` / `walkthroughSkipped` session state |
38
+ | `PostToolUse` (Bash + muggle execute/replay MCP tools) | `guardrail-record-tests.sh` | record | a unit-test command passed, an E2E run happened (execute/replay call), or an `echo "MUGGLE_E2E_SKIP: <reason>"` marker declared E2E un-runnable, or a walkthrough carrying the `build-pr-section` sentinel was posted / declared un-postable via `echo "MUGGLE_WALKTHROUGH_SKIP: <reason>"` | — | set `unitTestsGreen` / `e2eRun` / `e2eSkipped` / `walkthroughPostedPrUrls` / `walkthroughSkipped` session state. A post settles only the PR its output names (`gh pr comment`/`create` print it; a `gh api` comment edit returns `html_url`); a post whose output names none is timestamped (`walkthroughPostedAt`), and a scan begun after it decides. An accepted skip records the working tree it was verified in and settles only that tree's change: the PRs opened from it (`prWorkingTrees`, tracked in `e2eSkipCoveredPrs`) and its checked-out branch's PR |
39
39
  | `PostToolUse` (Bash) | `guardrail-pr-terminal.sh` | advise | a PR just went terminal — a `gh pr merge`/`gh pr close` success line or the `TERMINAL pr=N` line the watch scripts print in a shell result (never bare `"state":"MERGED"` metadata). Not registered on `Monitor`: a Monitor call returns before its script prints anything, so its result never carries that line | — | record `terminalPending`, direct the post-merge handoff: finalize the watcher slot, tear down per `autoCleanup`, offer next options via AskUserQuestion |
40
40
  | `PostToolUse` (AskUserQuestion) | `guardrail-offer-ran.sh` | record | a next-options offer ran while a terminal PR was pending | — | clear `terminalPending` — the only exit for the post-merge Stop gate |
41
+ | `PostToolUse` (Agent, Task) | `guardrail-record-delegation.sh` | record | a `muggle:acceptance-tester` was launched into the background — its response carries no finished report yet | — | append to `e2eDelegations` with the PR URLs its brief names; for a bounded window the E2E and debug-path gates hold off, and the walkthrough gate sets those PRs aside, so the session is never steered into a second browser run alongside the agent's. Shares the AskUserQuestion group's dispatch |
41
42
  | `PostToolUse` (Skill + muggle telemetry-skill-emit) | `guardrail-skill-stages.sh` | advise | a skill this plugin ships was invoked; its `SKILL.md` frontmatter may declare `mandatoryStages`. Registered on the skill's own MCP announcement too, so the declaration still lands if the Skill payload ever stops carrying a name. A muggle-test announcement is also an E2E run (the clean SKIP verdict), recorded here alone: the state store drops a write that cannot take the session's lock in time, so a second writer for one emit could lose either record | — | record `lastInvokedSkillName` + `mandatoryStages` (and `e2eRun` for a muggle-test announcement), and name the declared files as required reading at the moment of use |
42
43
  | `PostToolUse` (Read) | `guardrail-record-stage-read.sh` | record | a markdown file under a `skills/` directory was opened | — | append to `stagesRead` — how the stage gate tells a stage that was read from one that was skipped |
43
44
  | `PostToolUse` (Bash + muggle telemetry-event-emit / user-feedback-create) | `guardrail-record-stage-signals.sh` | record | a Step 6f `pre-execution-classification` emit, debug-path evidence for a failed run (a `*-failure-classified\|resolved` emit or feedback naming it), or a `MUGGLE_STAGE_SKIP` / `MUGGLE_CLASSIFY_SKIP` / `MUGGLE_DEBUG_SKIP` marker | — | set `classifiedTestCaseIds` / `debuggedRuns` / the matching skip flag |
44
45
  | `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 |
45
46
  | `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 |
46
47
  | `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 |
47
- | `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) |
48
+ | `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 |
48
49
  | `Stop` | `guardrail-terminal-gate.sh` | **enforce** | a PR went terminal this session and the AskUserQuestion next-options offer hasn't run since | — | **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) |
49
50
  | `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 |
50
- | `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 an E2E skip was accepted and a PR in play 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 an accepted E2E skip, 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 (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. 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 and stays open until one lands |
51
+ | `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 |
52
+ | `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 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 from the same tree. 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 |
51
53
  | `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) |
52
- | `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) |
54
+ | `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 |
53
55
  | `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 |
54
56
  | `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 |
55
57
  | `UserPromptSubmit` | `guardrail-build-router.sh` | advise | a build/implement/fix request (first one this session) | `autoRouteBuildToMuggleDo` | route the work through `muggle-do` (build delegated to superpowers) |
@@ -102,10 +102,10 @@
102
102
  "hooks": [
103
103
  {
104
104
  "type": "command",
105
- "command": "env MUGGLE_HOOK_HOST=codex bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-offer-ran.sh\"",
105
+ "command": "env MUGGLE_HOOK_HOST=codex bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-offer-ran.sh guardrail-record-delegation.sh",
106
106
  "async": false,
107
107
  "timeout": 10,
108
- "commandWindows": "node \"${CLAUDE_PLUGIN_ROOT}\\scripts\\codex-hook-windows.mjs\" \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-offer-ran.sh\""
108
+ "commandWindows": "node \"${CLAUDE_PLUGIN_ROOT}\\scripts\\codex-hook-windows.mjs\" \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-offer-ran.sh guardrail-record-delegation.sh"
109
109
  }
110
110
  ]
111
111
  }
@@ -115,10 +115,10 @@
115
115
  "hooks": [
116
116
  {
117
117
  "type": "command",
118
- "command": "env MUGGLE_HOOK_HOST=codex bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-e2e-gate.sh guardrail-terminal-gate.sh guardrail-watch-gate.sh guardrail-build-followthrough-gate.sh guardrail-walkthrough-gate.sh guardrail-comment-reply-gate.sh guardrail-stage-gate.sh guardrail-debug-path-gate.sh guardrail-capability-claim.sh",
118
+ "command": "env MUGGLE_HOOK_HOST=codex bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-e2e-gate.sh guardrail-terminal-gate.sh guardrail-watch-gate.sh guardrail-watch-follow-through-gate.sh guardrail-build-followthrough-gate.sh guardrail-walkthrough-gate.sh guardrail-comment-reply-gate.sh guardrail-stage-gate.sh guardrail-debug-path-gate.sh guardrail-capability-claim.sh",
119
119
  "async": false,
120
120
  "timeout": 10,
121
- "commandWindows": "node \"${CLAUDE_PLUGIN_ROOT}\\scripts\\codex-hook-windows.mjs\" \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-e2e-gate.sh guardrail-terminal-gate.sh guardrail-watch-gate.sh guardrail-build-followthrough-gate.sh guardrail-walkthrough-gate.sh guardrail-comment-reply-gate.sh guardrail-stage-gate.sh guardrail-debug-path-gate.sh guardrail-capability-claim.sh"
121
+ "commandWindows": "node \"${CLAUDE_PLUGIN_ROOT}\\scripts\\codex-hook-windows.mjs\" \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-e2e-gate.sh guardrail-terminal-gate.sh guardrail-watch-gate.sh guardrail-watch-follow-through-gate.sh guardrail-build-followthrough-gate.sh guardrail-walkthrough-gate.sh guardrail-comment-reply-gate.sh guardrail-stage-gate.sh guardrail-debug-path-gate.sh guardrail-capability-claim.sh"
122
122
  }
123
123
  ]
124
124
  }
@@ -133,11 +133,11 @@
133
133
  ]
134
134
  },
135
135
  {
136
- "matcher": "AskUserQuestion",
136
+ "matcher": "AskUserQuestion|Agent|Task",
137
137
  "hooks": [
138
138
  {
139
139
  "type": "command",
140
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-offer-ran.sh\"",
140
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-offer-ran.sh guardrail-record-delegation.sh",
141
141
  "async": false,
142
142
  "timeout": 1
143
143
  }
@@ -149,7 +149,7 @@
149
149
  "hooks": [
150
150
  {
151
151
  "type": "command",
152
- "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-e2e-gate.sh guardrail-terminal-gate.sh guardrail-watch-gate.sh guardrail-build-followthrough-gate.sh guardrail-walkthrough-gate.sh guardrail-comment-reply-gate.sh guardrail-stage-gate.sh guardrail-debug-path-gate.sh guardrail-capability-claim.sh",
152
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/guardrail-dispatch.sh\" guardrail-e2e-gate.sh guardrail-terminal-gate.sh guardrail-watch-gate.sh guardrail-watch-follow-through-gate.sh guardrail-build-followthrough-gate.sh guardrail-walkthrough-gate.sh guardrail-comment-reply-gate.sh guardrail-stage-gate.sh guardrail-debug-path-gate.sh guardrail-capability-claim.sh",
153
153
  "async": false,
154
154
  "timeout": 1
155
155
  }
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ set -uo pipefail
3
+
4
+ # Background acceptance-tester observer (PostToolUse/Agent|Task). Records that
5
+ # a change's E2E was handed to a muggle:acceptance-tester running in the
6
+ # background, so the E2E, walkthrough and debug-path Stop gates hold off rather
7
+ # than steer the main session into a second browser run alongside the agent's.
8
+ # Emits no directive.
9
+ #
10
+ # Pre-filter: most dispatches are other agents, so only a payload naming the
11
+ # acceptance-tester spawns Node. Degrades to {}.
12
+
13
+ guardrail_script_dir="${BASH_SOURCE[0]%/*}"
14
+ [[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
15
+ . "$guardrail_script_dir/guardrail-lib.sh"
16
+
17
+ GUARDRAIL_SUBCOMMAND="record-delegation"
18
+
19
+ guardrail_wants() {
20
+ guardrail_payload_matches 'acceptance-tester'
21
+ }
22
+
23
+ if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
24
+ guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
25
+ fi
@@ -11,11 +11,11 @@ set -uo pipefail
11
11
  # it fires on EVERY turn end. There is no command payload to key off, so the
12
12
  # pre-filter reads the same per-session state file guardrails.mjs uses and only
13
13
  # spawns Node when the gate could actually fire — i.e. an acceptance run or an
14
- # unsettled skip is recorded and the walkthrough is neither posted nor skipped.
15
- # On the overwhelming majority of turns (no E2E this session) the state file is
16
- # absent or carries neither, so we return {} in-shell and never pay Node
17
- # cold-start — which also means the gate's `gh` lookups only ever run on turns
18
- # that could genuinely owe a walkthrough. Degrades to {}.
14
+ # unsettled skip is recorded and the walkthrough is neither verified on every
15
+ # PR nor skipped. On the overwhelming majority of turns (no E2E this session)
16
+ # the state file is absent or carries neither, so we return {} in-shell and
17
+ # never pay Node cold-start — which also means the gate's `gh` lookups only
18
+ # ever run on turns that could genuinely owe a walkthrough. Degrades to {}.
19
19
 
20
20
  guardrail_script_dir="${BASH_SOURCE[0]%/*}"
21
21
  [[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
@@ -25,7 +25,7 @@ GUARDRAIL_SUBCOMMAND="walkthrough-gate"
25
25
 
26
26
  guardrail_wants() {
27
27
  guardrail_load_state || return 1
28
- guardrail_state_has '"walkthroughPosted": true' && return 1
28
+ guardrail_state_has '"walkthroughsVerified": true' && return 1
29
29
  guardrail_state_has '"walkthroughReleased": true' && return 1
30
30
  guardrail_state_has '"walkthroughSkipped": true' && return 1
31
31
  guardrail_state_has '"e2eRun": true' && return 0
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+ set -uo pipefail
3
+
4
+ # watcher follow-through gate (Stop). When a muggle-pr-followup watch this
5
+ # session owns has recorded due work — a rebase on a stale branch, a fix on a red
6
+ # head — and no attempt for it is recorded, block the turn end and name the
7
+ # dispatch. Released only by the attempt itself, a new head, or the user's own
8
+ # HOLD WATCH #<pr-number>: a session once sat on both for a day, re-arming its
9
+ # watch and asking "needs input" at every wake, and every prose rule against it
10
+ # held only as long as the session agreed with it.
11
+ #
12
+ # Synchronous (only a sync Stop hook can block the turn end) and fires on every
13
+ # turn end, so the pre-filter is bash builtins only: a glob over the slots for a
14
+ # non-empty watch-due.env (the watch loop empties it when nothing is due) whose
15
+ # owner.json names this session. No slot has one on nearly every turn, so Node
16
+ # never starts. The attempt counters, preferences, and the hold are judged in
17
+ # guardrails.mjs, from local files alone — no provider call. Degrades to {}.
18
+
19
+ guardrail_script_dir="${BASH_SOURCE[0]%/*}"
20
+ [[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
21
+ . "$guardrail_script_dir/guardrail-lib.sh"
22
+
23
+ GUARDRAIL_SUBCOMMAND="watch-follow-through-gate"
24
+
25
+ guardrail_wants() {
26
+ guardrail_payload_field session_id || return 1
27
+ local session_id="$GUARDRAIL_FIELD_VALUE"
28
+ [[ -n $session_id ]] || return 1
29
+ guardrail_resolve_home
30
+ # A backslash in a glob escapes the next character, so a native Windows HOME
31
+ # would match nothing; forward slashes name the same directory.
32
+ local sessions_dir="${GUARDRAIL_HOME//\\//}/.muggle-ai/muggle-do/sessions"
33
+ local due_file slot_dir owner_json
34
+ for due_file in "$sessions_dir"/*/watch-due.env; do
35
+ [[ -s $due_file ]] || continue
36
+ slot_dir="${due_file%/watch-due.env}"
37
+ [[ $slot_dir == *.stopped ]] && continue
38
+ [[ -f $slot_dir/owner.json ]] || continue
39
+ owner_json=""
40
+ IFS= read -r -d '' owner_json <"$slot_dir/owner.json" || true
41
+ [[ $owner_json == *"\"$session_id\""* ]] && return 0
42
+ done
43
+ return 1
44
+ }
45
+
46
+ if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
47
+ guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
48
+ fi