@muggleai/works 5.25.0-staging.191 → 5.25.0

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.
@@ -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.25.0-staging.191"
12
+ "version": "5.25.0"
13
13
  }
14
14
  ]
15
15
  }
@@ -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.25.0-staging.191",
4
+ "version": "5.25.0",
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.25.0-staging.191",
7
+ "@muggleai/works@5.25.0",
8
8
  "serve"
9
9
  ],
10
10
  "env": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muggle",
3
- "version": "5.25.0-staging.191",
3
+ "version": "5.25.0",
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.25.0-staging.191",
5
+ "version": "5.25.0",
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.25.0-staging.191",
7
+ "@muggleai/works@5.25.0",
8
8
  "serve"
9
9
  ]
10
10
  }
@@ -35,10 +35,10 @@ 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/skill-emit MCP tools) | `guardrail-record-tests.sh` | record | a unit-test command passed, an E2E run happened (execute/replay call, or the muggle-test skill's own telemetry emit — which registers a clean SKIP verdict too), 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` / `walkthroughPosted` / `walkthroughSkipped` session state |
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` (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 | — | record `lastInvokedSkillName` + `mandatoryStages`, and name the declared files as required reading at the moment of use |
41
+ | `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
42
  | `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
43
  | `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
44
  | `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 |
@@ -62,7 +62,7 @@
62
62
  ]
63
63
  },
64
64
  {
65
- "matcher": "mcp__.*muggle.*(execute|replay|telemetry_skill_emit)",
65
+ "matcher": "mcp__.*muggle.*(execute|replay)",
66
66
  "hooks": [
67
67
  {
68
68
  "type": "command",
@@ -78,7 +78,7 @@
78
78
  ]
79
79
  },
80
80
  {
81
- "matcher": "mcp__.*muggle.*(execute|replay|telemetry-skill-emit)",
81
+ "matcher": "mcp__.*muggle.*(execute|replay)",
82
82
  "hooks": [
83
83
  {
84
84
  "type": "command",
@@ -9,10 +9,9 @@ set -uo pipefail
9
9
  # Fires after every Bash call and every muggle execute/replay, so a keyword
10
10
  # pre-filter for test runners and the muggle E2E tool names keeps Node off the
11
11
  # hot path. Only a `test` command (npm/pnpm/yarn/jest/vitest/pytest/go/cargo),
12
- # a muggle execute/replay/test-generation event, a muggle-test skill telemetry
13
- # emit (registers a clean-SKIP verdict as an E2E run), a skip marker, or a PR
14
- # publish carrying a rendered walkthrough reaches guardrails.mjs, which then
15
- # inspects the output for pass/fail and updates state. Degrades to {}.
12
+ # a muggle execute/replay/test-generation event, a skip marker, or a PR publish
13
+ # carrying a rendered walkthrough reaches guardrails.mjs, which then inspects
14
+ # the output for pass/fail and updates state. Degrades to {}.
16
15
  #
17
16
  # Each arm reads only the field guardrails.mjs judges it by — the command, or the
18
17
  # tool's name. Against the whole payload, a jest config in a command's output or
@@ -33,7 +32,7 @@ GUARDRAIL_SUBCOMMAND="record-tests"
33
32
 
34
33
  guardrail_wants() {
35
34
  guardrail_fields_match command '(pnpm|npm|yarn)[[:space:]]+(run[[:space:]]+)?test|jest|vitest|pytest|go[[:space:]]+test|cargo[[:space:]]+test|MUGGLE_[A-Z0-9_]+_SKIP|gh[[:space:]]+pr[[:space:]]+(comment|create|edit)|issues/comments/[0-9]' \
36
- || guardrail_fields_match tool_name 'muggle.*(execute|test[-_]generation|replay)|muggle[-_]local[-_]telemetry[-_]skill[-_]emit'
35
+ || guardrail_fields_match tool_name 'muggle.*(execute|test[-_]generation|replay)'
37
36
  }
38
37
 
39
38
  if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
@@ -5,6 +5,8 @@ set -uo pipefail
5
5
  # and, when its SKILL.md declares `mandatoryStages`, returns those files as
6
6
  # required reading at the moment of use. The Stop gate
7
7
  # (guardrail-stage-gate.sh) blocks the turn end while any of them is unread.
8
+ # For a muggle-test skill telemetry emit it also records the E2E run, so the
9
+ # emit has one writer and no lost write to race for.
8
10
  #
9
11
  # Skill calls are rare, so the pre-filter is a file test rather than a keyword
10
12
  # scan: the invoked name is pulled out of the payload and Node runs only when it
@@ -1955,6 +1955,11 @@ function terminalGate() {
1955
1955
  const reason = decision.blockCount === 1 ? `Do not end the turn yet. PR ${pendingPrList} went terminal (merged/closed) but the post-merge handoff has not run. Finalize the watcher slot, tear down per autoCleanup, then offer next options to the user ${nextOptionsOfferMethod()} \u2014 release, queued work, deferred items. Only that offer clears this gate.` : `Post-merge handoff still owed for PR ${pendingPrList} (reminder ${decision.blockCount}/${MAX_PR_TERMINAL_BLOCKS}): finalize + tear down, then offer the next options ${nextOptionsOfferMethod()}.`;
1956
1956
  return blockStop(reason, host);
1957
1957
  }
1958
+ function startWalkthroughScanOnGateArming(stateBefore, committed) {
1959
+ if (isWalkthroughGateArmed(committed) && !isWalkthroughGateArmed(stateBefore)) {
1960
+ startBackgroundJob("scan-walkthroughs" /* ScanWalkthroughs */, [sessionId], input.cwd);
1961
+ }
1962
+ }
1958
1963
  function recordTests() {
1959
1964
  const cmd = input.tool_input?.command ?? "";
1960
1965
  const stateBefore = readState(sessionId);
@@ -1977,9 +1982,7 @@ function recordTests() {
1977
1982
  return failedRunId ? applyFailedRun(withWalkthroughSkip, failedRunId) : withWalkthroughSkip;
1978
1983
  };
1979
1984
  const next = commitState(sessionId, record) ?? record(readState(sessionId));
1980
- if (isWalkthroughGateArmed(next) && !isWalkthroughGateArmed(stateBefore)) {
1981
- startBackgroundJob("scan-walkthroughs" /* ScanWalkthroughs */, [sessionId], input.cwd);
1982
- }
1985
+ startWalkthroughScanOnGateArming(stateBefore, next);
1983
1986
  if (acceptedSkip) recordSkipReasonOnPrs(next, acceptedSkip);
1984
1987
  if (judgedSkip && !judgedSkip.accepted) {
1985
1988
  return envelope("PostToolUse", explainRejection(judgedSkip), host);
@@ -1999,8 +2002,16 @@ function skillStages() {
1999
2002
  const skillName = resolveSkillNameFromToolInput(input.tool_input);
2000
2003
  if (!skillName) return "{}";
2001
2004
  const stagePaths = resolveSkillStagePaths(skillName, resolvePluginSkillsRoot());
2002
- const invoke = (state) => applySkillInvocation(state, skillName, stagePaths);
2005
+ const emittedRun = {
2006
+ unitTestPassed: false,
2007
+ e2eRan: isE2ERun(input),
2008
+ e2eSkipped: false,
2009
+ e2eSkipCycleScoped: false
2010
+ };
2011
+ const stateBefore = readState(sessionId);
2012
+ const invoke = (state) => applyRecordedRun(applySkillInvocation(state, skillName, stagePaths), emittedRun);
2003
2013
  const next = commitState(sessionId, invoke) ?? invoke(readState(sessionId));
2014
+ startWalkthroughScanOnGateArming(stateBefore, next);
2004
2015
  const unread = unreadMandatoryStages(next);
2005
2016
  if (unread.length === 0) return "{}";
2006
2017
  const ctx = `The ${skillName} skill declares required reading: ${unread.map(stageLabel).join(", ")}. Read those files now, before working through the skill's steps \u2014 they carry mandatory steps SKILL.md only links to, and treating them as optional elaboration is how those steps get silently dropped. A Stop gate holds the turn open until they are opened.`;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "release": "5.18.0",
3
- "buildId": "run-191-1",
4
- "commitSha": "79ee6e3c690d77c9b32351f388da83ec1461f4fe",
5
- "buildTime": "2026-10-24T16:41:22Z",
3
+ "buildId": "run-193-1",
4
+ "commitSha": "d5a825598bf9a2595279ea5795c620f4b6196cb5",
5
+ "buildTime": "2026-10-24T20:09:35Z",
6
6
  "serviceName": "muggle-ai-works-mcp"
7
7
  }
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.25.0-staging.191",
4
+ "version": "5.25.0",
5
5
  "description": "13 years of Microsoft hyperscale engineering, packaged as a harness for your AI coding agent.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -61,7 +61,7 @@
61
61
  "muggleConfig": {
62
62
  "electronAppVersion": "1.13.9",
63
63
  "downloadBaseUrl": "https://github.com/multiplex-ai/muggle-ai-works/releases/download",
64
- "runtimeTargetDefault": "staging",
64
+ "runtimeTargetDefault": "production",
65
65
  "checksumsByStream": {
66
66
  "production": {
67
67
  "win32-x64": "807123fb84ba60a0fa38addd4477663e1f69a7bd3080639241b75ac3f25e3a82",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "muggle",
3
3
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
4
- "version": "5.25.0-staging.191",
4
+ "version": "5.25.0",
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.25.0-staging.191",
7
+ "@muggleai/works@5.25.0",
8
8
  "serve"
9
9
  ],
10
10
  "env": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muggle",
3
- "version": "5.25.0-staging.191",
3
+ "version": "5.25.0",
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.25.0-staging.191",
5
+ "version": "5.25.0",
6
6
  "author": {
7
7
  "name": "Muggle AI",
8
8
  "email": "support@muggle-ai.com"
package/plugin/.mcp.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.25.0-staging.191",
7
+ "@muggleai/works@5.25.0",
8
8
  "serve"
9
9
  ]
10
10
  }
@@ -35,10 +35,10 @@ 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/skill-emit MCP tools) | `guardrail-record-tests.sh` | record | a unit-test command passed, an E2E run happened (execute/replay call, or the muggle-test skill's own telemetry emit — which registers a clean SKIP verdict too), 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` / `walkthroughPosted` / `walkthroughSkipped` session state |
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` (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 | — | record `lastInvokedSkillName` + `mandatoryStages`, and name the declared files as required reading at the moment of use |
41
+ | `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
42
  | `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
43
  | `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
44
  | `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 |
@@ -62,7 +62,7 @@
62
62
  ]
63
63
  },
64
64
  {
65
- "matcher": "mcp__.*muggle.*(execute|replay|telemetry_skill_emit)",
65
+ "matcher": "mcp__.*muggle.*(execute|replay)",
66
66
  "hooks": [
67
67
  {
68
68
  "type": "command",
@@ -78,7 +78,7 @@
78
78
  ]
79
79
  },
80
80
  {
81
- "matcher": "mcp__.*muggle.*(execute|replay|telemetry-skill-emit)",
81
+ "matcher": "mcp__.*muggle.*(execute|replay)",
82
82
  "hooks": [
83
83
  {
84
84
  "type": "command",
@@ -9,10 +9,9 @@ set -uo pipefail
9
9
  # Fires after every Bash call and every muggle execute/replay, so a keyword
10
10
  # pre-filter for test runners and the muggle E2E tool names keeps Node off the
11
11
  # hot path. Only a `test` command (npm/pnpm/yarn/jest/vitest/pytest/go/cargo),
12
- # a muggle execute/replay/test-generation event, a muggle-test skill telemetry
13
- # emit (registers a clean-SKIP verdict as an E2E run), a skip marker, or a PR
14
- # publish carrying a rendered walkthrough reaches guardrails.mjs, which then
15
- # inspects the output for pass/fail and updates state. Degrades to {}.
12
+ # a muggle execute/replay/test-generation event, a skip marker, or a PR publish
13
+ # carrying a rendered walkthrough reaches guardrails.mjs, which then inspects
14
+ # the output for pass/fail and updates state. Degrades to {}.
16
15
  #
17
16
  # Each arm reads only the field guardrails.mjs judges it by — the command, or the
18
17
  # tool's name. Against the whole payload, a jest config in a command's output or
@@ -33,7 +32,7 @@ GUARDRAIL_SUBCOMMAND="record-tests"
33
32
 
34
33
  guardrail_wants() {
35
34
  guardrail_fields_match command '(pnpm|npm|yarn)[[:space:]]+(run[[:space:]]+)?test|jest|vitest|pytest|go[[:space:]]+test|cargo[[:space:]]+test|MUGGLE_[A-Z0-9_]+_SKIP|gh[[:space:]]+pr[[:space:]]+(comment|create|edit)|issues/comments/[0-9]' \
36
- || guardrail_fields_match tool_name 'muggle.*(execute|test[-_]generation|replay)|muggle[-_]local[-_]telemetry[-_]skill[-_]emit'
35
+ || guardrail_fields_match tool_name 'muggle.*(execute|test[-_]generation|replay)'
37
36
  }
38
37
 
39
38
  if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
@@ -5,6 +5,8 @@ set -uo pipefail
5
5
  # and, when its SKILL.md declares `mandatoryStages`, returns those files as
6
6
  # required reading at the moment of use. The Stop gate
7
7
  # (guardrail-stage-gate.sh) blocks the turn end while any of them is unread.
8
+ # For a muggle-test skill telemetry emit it also records the E2E run, so the
9
+ # emit has one writer and no lost write to race for.
8
10
  #
9
11
  # Skill calls are rare, so the pre-filter is a file test rather than a keyword
10
12
  # scan: the invoked name is pulled out of the payload and Node runs only when it
@@ -1955,6 +1955,11 @@ function terminalGate() {
1955
1955
  const reason = decision.blockCount === 1 ? `Do not end the turn yet. PR ${pendingPrList} went terminal (merged/closed) but the post-merge handoff has not run. Finalize the watcher slot, tear down per autoCleanup, then offer next options to the user ${nextOptionsOfferMethod()} \u2014 release, queued work, deferred items. Only that offer clears this gate.` : `Post-merge handoff still owed for PR ${pendingPrList} (reminder ${decision.blockCount}/${MAX_PR_TERMINAL_BLOCKS}): finalize + tear down, then offer the next options ${nextOptionsOfferMethod()}.`;
1956
1956
  return blockStop(reason, host);
1957
1957
  }
1958
+ function startWalkthroughScanOnGateArming(stateBefore, committed) {
1959
+ if (isWalkthroughGateArmed(committed) && !isWalkthroughGateArmed(stateBefore)) {
1960
+ startBackgroundJob("scan-walkthroughs" /* ScanWalkthroughs */, [sessionId], input.cwd);
1961
+ }
1962
+ }
1958
1963
  function recordTests() {
1959
1964
  const cmd = input.tool_input?.command ?? "";
1960
1965
  const stateBefore = readState(sessionId);
@@ -1977,9 +1982,7 @@ function recordTests() {
1977
1982
  return failedRunId ? applyFailedRun(withWalkthroughSkip, failedRunId) : withWalkthroughSkip;
1978
1983
  };
1979
1984
  const next = commitState(sessionId, record) ?? record(readState(sessionId));
1980
- if (isWalkthroughGateArmed(next) && !isWalkthroughGateArmed(stateBefore)) {
1981
- startBackgroundJob("scan-walkthroughs" /* ScanWalkthroughs */, [sessionId], input.cwd);
1982
- }
1985
+ startWalkthroughScanOnGateArming(stateBefore, next);
1983
1986
  if (acceptedSkip) recordSkipReasonOnPrs(next, acceptedSkip);
1984
1987
  if (judgedSkip && !judgedSkip.accepted) {
1985
1988
  return envelope("PostToolUse", explainRejection(judgedSkip), host);
@@ -1999,8 +2002,16 @@ function skillStages() {
1999
2002
  const skillName = resolveSkillNameFromToolInput(input.tool_input);
2000
2003
  if (!skillName) return "{}";
2001
2004
  const stagePaths = resolveSkillStagePaths(skillName, resolvePluginSkillsRoot());
2002
- const invoke = (state) => applySkillInvocation(state, skillName, stagePaths);
2005
+ const emittedRun = {
2006
+ unitTestPassed: false,
2007
+ e2eRan: isE2ERun(input),
2008
+ e2eSkipped: false,
2009
+ e2eSkipCycleScoped: false
2010
+ };
2011
+ const stateBefore = readState(sessionId);
2012
+ const invoke = (state) => applyRecordedRun(applySkillInvocation(state, skillName, stagePaths), emittedRun);
2003
2013
  const next = commitState(sessionId, invoke) ?? invoke(readState(sessionId));
2014
+ startWalkthroughScanOnGateArming(stateBefore, next);
2004
2015
  const unread = unreadMandatoryStages(next);
2005
2016
  if (unread.length === 0) return "{}";
2006
2017
  const ctx = `The ${skillName} skill declares required reading: ${unread.map(stageLabel).join(", ")}. Read those files now, before working through the skill's steps \u2014 they carry mandatory steps SKILL.md only links to, and treating them as optional elaboration is how those steps get silently dropped. A Stop gate holds the turn open until they are opened.`;