@muggleai/works 5.26.0-staging.208 → 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.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/.codex-mcp.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/plugin/.cursor-plugin/plugin.json +1 -1
- package/dist/plugin/.mcp.json +1 -1
- package/dist/plugin/agents/acceptance-tester.md +18 -2
- package/dist/plugin/hooks/README.md +5 -4
- package/dist/plugin/hooks/codex-hooks.json +2 -2
- package/dist/plugin/hooks/hooks.json +2 -2
- package/dist/plugin/scripts/guardrail-record-delegation.sh +25 -0
- package/dist/plugin/scripts/guardrail-walkthrough-gate.sh +6 -6
- package/dist/plugin/scripts/guardrails.mjs +161 -32
- package/dist/plugin/skills/do/background-e2e.md +89 -0
- package/dist/plugin/skills/do/e2e-acceptance.md +4 -0
- package/dist/plugin/skills/do/e2e-repair.md +1 -1
- package/dist/plugin/skills/do/open-prs/forward.md +3 -3
- package/dist/plugin/skills/do/pre-flight.md +4 -3
- package/dist/plugin/skills/do/wave-e2e.md +3 -3
- package/dist/plugin/skills/do/wave-or-stream.md +51 -0
- package/dist/plugin/skills/muggle-do/SKILL.md +6 -2
- package/dist/release-manifest.json +3 -3
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-mcp.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/.cursor-plugin/plugin.json +1 -1
- package/plugin/.mcp.json +1 -1
- package/plugin/agents/acceptance-tester.md +18 -2
- package/plugin/hooks/README.md +5 -4
- package/plugin/hooks/codex-hooks.json +2 -2
- package/plugin/hooks/hooks.json +2 -2
- package/plugin/scripts/guardrail-record-delegation.sh +25 -0
- package/plugin/scripts/guardrail-walkthrough-gate.sh +6 -6
- package/plugin/scripts/guardrails.mjs +161 -32
- package/plugin/skills/do/background-e2e.md +89 -0
- package/plugin/skills/do/e2e-acceptance.md +4 -0
- package/plugin/skills/do/e2e-repair.md +1 -1
- package/plugin/skills/do/open-prs/forward.md +3 -3
- package/plugin/skills/do/pre-flight.md +4 -3
- package/plugin/skills/do/wave-e2e.md +3 -3
- package/plugin/skills/do/wave-or-stream.md +51 -0
- package/plugin/skills/muggle-do/SKILL.md +6 -2
- /package/dist/{chunk-HOKMW4AL.js → chunk-PQVRAFNE.js} +0 -0
|
@@ -78,6 +78,12 @@ var CALL_FAILURE_SIGNALS = [
|
|
|
78
78
|
var FORGE_TERMINAL_CMD = /\b(?:gh\s+pr\s+(?:merge|close|reopen)|glab\s+mr\s+(?:merge|close|reopen))\b/;
|
|
79
79
|
var WATCH_TERMINAL_CMD = /pr-watch-(?:loop|arm)\.sh/;
|
|
80
80
|
var MERGED_GATE_OUTPUT_SEPARATOR = "\n\n";
|
|
81
|
+
var GITHUB_PR_URL = /https:\/\/github\.com\/[^/\s]+\/[^/\s]+\/pull\/\d+/;
|
|
82
|
+
var GITLAB_MR_URL = /https?:\/\/[^/\s]+\/[^\s]+\/-\/merge_requests\/\d+/;
|
|
83
|
+
var SUBAGENT_DISPATCH_TOOL_NAMES = ["Agent", "Task"];
|
|
84
|
+
var ACCEPTANCE_TESTER_SUBAGENT_TYPE = /(?:^|:)acceptance-tester$/;
|
|
85
|
+
var ACCEPTANCE_REPORT_MARKERS = ["## Test Summary", "**Overall:**"];
|
|
86
|
+
var DELEGATED_E2E_WINDOW_MS = 60 * 6e4;
|
|
81
87
|
|
|
82
88
|
// src/guardrails/store/fileLock.ts
|
|
83
89
|
function isProcessAlive(pid) {
|
|
@@ -210,6 +216,7 @@ var GuardrailBackgroundJob = /* @__PURE__ */ ((GuardrailBackgroundJob2) => {
|
|
|
210
216
|
GuardrailBackgroundJob2["ScanWalkthroughs"] = "scan-walkthroughs";
|
|
211
217
|
GuardrailBackgroundJob2["ReserveWalkthroughComment"] = "reserve-walkthrough-comment";
|
|
212
218
|
GuardrailBackgroundJob2["SettleWalkthroughSkipped"] = "settle-walkthrough-skipped";
|
|
219
|
+
GuardrailBackgroundJob2["SettleBranchWalkthroughSkipped"] = "settle-branch-walkthrough-skipped";
|
|
213
220
|
GuardrailBackgroundJob2["SettleWalkthroughUnreasoned"] = "settle-walkthrough-unreasoned";
|
|
214
221
|
GuardrailBackgroundJob2["SettleWalkthroughNoAppLogicChange"] = "settle-walkthrough-no-app-logic-change";
|
|
215
222
|
GuardrailBackgroundJob2["ScanWatchPrStates"] = "scan-watch-pr-states";
|
|
@@ -248,8 +255,6 @@ function isShellToolCall(input2) {
|
|
|
248
255
|
}
|
|
249
256
|
|
|
250
257
|
// src/guardrails/prOpened.ts
|
|
251
|
-
var PR_URL = /https:\/\/github\.com\/[^/\s]+\/[^/\s]+\/pull\/\d+/;
|
|
252
|
-
var MR_URL = /https?:\/\/[^/\s]+\/[^\s]+\/-\/merge_requests\/\d+/;
|
|
253
258
|
var CREATE_CMD = /\bgh\s+pr\s+(create|ready)\b/;
|
|
254
259
|
var MR_CREATE_CMD = /\bglab\s+mr\s+create\b|\bglab\s+mr\s+update\b.*--ready\b/;
|
|
255
260
|
function detectPrOpened(input2) {
|
|
@@ -258,7 +263,7 @@ function detectPrOpened(input2) {
|
|
|
258
263
|
if (!CREATE_CMD.test(cmd) && !MR_CREATE_CMD.test(cmd)) return null;
|
|
259
264
|
const out = `${input2.tool_response?.stdout ?? ""}
|
|
260
265
|
${input2.tool_response?.output ?? ""}`;
|
|
261
|
-
const m = out.match(
|
|
266
|
+
const m = out.match(GITHUB_PR_URL) ?? out.match(GITLAB_MR_URL);
|
|
262
267
|
return m ? m[0] : null;
|
|
263
268
|
}
|
|
264
269
|
|
|
@@ -638,6 +643,38 @@ function classificationGateDecision(state, input2) {
|
|
|
638
643
|
return { deny: true, testCaseId };
|
|
639
644
|
}
|
|
640
645
|
|
|
646
|
+
// src/guardrails/prUrls.ts
|
|
647
|
+
function extractPrUrls(text) {
|
|
648
|
+
const githubPrUrls = [...text.matchAll(new RegExp(GITHUB_PR_URL.source, "g"))];
|
|
649
|
+
const gitlabMrUrls = [...text.matchAll(new RegExp(GITLAB_MR_URL.source, "g"))];
|
|
650
|
+
return [...new Set([...githubPrUrls, ...gitlabMrUrls].map((match) => match[0]))];
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// src/guardrails/delegatedE2e.ts
|
|
654
|
+
function carriesAcceptanceReport(input2) {
|
|
655
|
+
const response = JSON.stringify(input2.tool_response ?? "");
|
|
656
|
+
return ACCEPTANCE_REPORT_MARKERS.some((marker) => response.includes(marker));
|
|
657
|
+
}
|
|
658
|
+
function detectBackgroundAcceptanceDispatch(input2) {
|
|
659
|
+
if (!SUBAGENT_DISPATCH_TOOL_NAMES.includes(input2.tool_name ?? "")) return null;
|
|
660
|
+
if (!ACCEPTANCE_TESTER_SUBAGENT_TYPE.test(input2.tool_input?.subagent_type ?? "")) return null;
|
|
661
|
+
if (callFailed(input2) || carriesAcceptanceReport(input2)) return null;
|
|
662
|
+
return extractPrUrls(input2.tool_input?.prompt ?? "");
|
|
663
|
+
}
|
|
664
|
+
function liveDelegations(state, now) {
|
|
665
|
+
return (state.e2eDelegations ?? []).filter((delegation) => now - delegation.dispatchedAt < DELEGATED_E2E_WINDOW_MS);
|
|
666
|
+
}
|
|
667
|
+
function applyE2eDelegation(state, delegation) {
|
|
668
|
+
return { ...state, e2eDelegations: [...liveDelegations(state, delegation.dispatchedAt), delegation] };
|
|
669
|
+
}
|
|
670
|
+
function isE2eDelegationInFlight(state, now) {
|
|
671
|
+
return liveDelegations(state, now).length > 0;
|
|
672
|
+
}
|
|
673
|
+
function withoutDelegatedPrs(prUrls, state, now) {
|
|
674
|
+
const delegatedPrUrls = new Set(liveDelegations(state, now).flatMap((delegation) => delegation.prUrls));
|
|
675
|
+
return prUrls.filter((prUrl) => !delegatedPrUrls.has(prUrl));
|
|
676
|
+
}
|
|
677
|
+
|
|
641
678
|
// src/guardrails/debugPath.ts
|
|
642
679
|
var DEBUG_SKIP_MARKER = /^\s*echo\s+["']?MUGGLE_DEBUG_SKIP\b/;
|
|
643
680
|
var serialize = (input2) => `${JSON.stringify(input2.tool_input ?? {})}
|
|
@@ -691,10 +728,10 @@ function undebuggedFailedRuns(state) {
|
|
|
691
728
|
const debugged = new Set(state.debuggedRuns ?? []);
|
|
692
729
|
return (state.failedRuns ?? []).filter((runId) => !debugged.has(runId));
|
|
693
730
|
}
|
|
694
|
-
function debugGateDecision(state, maxBlocks = MAX_DEBUG_BLOCKS) {
|
|
731
|
+
function debugGateDecision(state, maxBlocks = MAX_DEBUG_BLOCKS, now = Date.now()) {
|
|
695
732
|
const blockCount = state.debugBlockCount ?? 0;
|
|
696
733
|
const undebugged = undebuggedFailedRuns(state);
|
|
697
|
-
if (state.debugSkipped === true || undebugged.length === 0) {
|
|
734
|
+
if (state.debugSkipped === true || undebugged.length === 0 || isE2eDelegationInFlight(state, now)) {
|
|
698
735
|
return { action: "none" /* None */, blockCount, undebugged };
|
|
699
736
|
}
|
|
700
737
|
if (blockCount >= maxBlocks) {
|
|
@@ -823,9 +860,11 @@ function applyRecordedRun(state, run) {
|
|
|
823
860
|
}
|
|
824
861
|
return next;
|
|
825
862
|
}
|
|
826
|
-
function e2eGateDecision(state, maxBlocks = MAX_E2E_BLOCKS) {
|
|
863
|
+
function e2eGateDecision(state, maxBlocks = MAX_E2E_BLOCKS, now = Date.now()) {
|
|
827
864
|
const blockCount = state.e2eBlockCount ?? 0;
|
|
828
|
-
if (!shouldRunE2E(state)
|
|
865
|
+
if (!shouldRunE2E(state) || isE2eDelegationInFlight(state, now)) {
|
|
866
|
+
return { action: "none" /* None */, blockCount };
|
|
867
|
+
}
|
|
829
868
|
if (blockCount >= maxBlocks) return { action: "release" /* Release */, blockCount };
|
|
830
869
|
return { action: "block" /* Block */, blockCount: blockCount + 1 };
|
|
831
870
|
}
|
|
@@ -855,7 +894,7 @@ var SHORT_SHA_LENGTH = 7;
|
|
|
855
894
|
var GH_COMMENT_TIMEOUT_MS = 1e4;
|
|
856
895
|
|
|
857
896
|
// src/pr-walkthrough/gh.ts
|
|
858
|
-
var
|
|
897
|
+
var GITHUB_PR_URL2 = /^https:\/\/github\.com\/([^/\s]+)\/([^/\s]+)\/pull\/(\d+)/;
|
|
859
898
|
var GH_CALLS_ENV = "MUGGLE_GUARDRAIL_GH_CALLS";
|
|
860
899
|
var defaultGhRunner = (args, input2) => {
|
|
861
900
|
if (process.env[GH_CALLS_ENV] === "off") return null;
|
|
@@ -874,7 +913,7 @@ var defaultGhRunner = (args, input2) => {
|
|
|
874
913
|
}
|
|
875
914
|
};
|
|
876
915
|
function parsePrUrl(prUrl) {
|
|
877
|
-
const parts = prUrl.match(
|
|
916
|
+
const parts = prUrl.match(GITHUB_PR_URL2);
|
|
878
917
|
if (!parts) return null;
|
|
879
918
|
return { repo: `${parts[1]}/${parts[2]}`, prNumber: Number(parts[3]) };
|
|
880
919
|
}
|
|
@@ -1324,14 +1363,53 @@ function detectWalkthroughPost(input2, read = defaultFileReader) {
|
|
|
1324
1363
|
if (callFailed(input2)) return false;
|
|
1325
1364
|
return collectPrPostText(cmd, input2.cwd, read).includes(REPORT_SENTINEL);
|
|
1326
1365
|
}
|
|
1327
|
-
function
|
|
1328
|
-
|
|
1329
|
-
|
|
1366
|
+
function detectWalkthroughPostTargets(input2) {
|
|
1367
|
+
return extractPrUrls(`${input2.tool_response?.stdout ?? ""}
|
|
1368
|
+
${input2.tool_response?.output ?? ""}`);
|
|
1369
|
+
}
|
|
1370
|
+
function applyWalkthroughPosted(state, posted, postedAt, targetPrUrls) {
|
|
1371
|
+
if (!posted) return state;
|
|
1372
|
+
if (targetPrUrls.length === 0) return { ...state, walkthroughPostedAt: postedAt };
|
|
1373
|
+
const postedPrUrls = /* @__PURE__ */ new Set([...state.walkthroughPostedPrUrls ?? [], ...targetPrUrls]);
|
|
1374
|
+
return { ...state, walkthroughPostedPrUrls: [...postedPrUrls] };
|
|
1330
1375
|
}
|
|
1331
1376
|
function applyWalkthroughSkip(state, skipped) {
|
|
1332
1377
|
if (!skipped || state.walkthroughSkipped === true) return state;
|
|
1333
1378
|
return { ...state, walkthroughSkipped: true };
|
|
1334
1379
|
}
|
|
1380
|
+
function normalizeWorkingTree(cwd) {
|
|
1381
|
+
if (!cwd) return void 0;
|
|
1382
|
+
const forwardSlashed = resolve(cwd).replace(/\\/g, "/").replace(/\/+$/, "");
|
|
1383
|
+
return process.platform === "win32" ? forwardSlashed.toLowerCase() : forwardSlashed;
|
|
1384
|
+
}
|
|
1385
|
+
function isOpenedFromSkipTree(state, prUrl) {
|
|
1386
|
+
const skipTree = state.e2eSkipVerifiedInTree;
|
|
1387
|
+
return skipTree !== void 0 && state.prWorkingTrees?.[prUrl] === skipTree;
|
|
1388
|
+
}
|
|
1389
|
+
function withCoveredPrs(state, prUrls) {
|
|
1390
|
+
const covered = new Set(state.e2eSkipCoveredPrs ?? []);
|
|
1391
|
+
const uncovered = prUrls.filter((prUrl) => !covered.has(prUrl));
|
|
1392
|
+
if (uncovered.length === 0) return state;
|
|
1393
|
+
return { ...state, e2eSkipCoveredPrs: [...covered, ...uncovered] };
|
|
1394
|
+
}
|
|
1395
|
+
function isPrCoveredBySkip(state, prUrl) {
|
|
1396
|
+
return (state.e2eSkipCoveredPrs ?? []).includes(prUrl);
|
|
1397
|
+
}
|
|
1398
|
+
function applyPrOpenedToSkipScope(state, prUrl, openedFromTree) {
|
|
1399
|
+
if (!openedFromTree) return state;
|
|
1400
|
+
const recorded = { ...state, prWorkingTrees: { ...state.prWorkingTrees, [prUrl]: openedFromTree } };
|
|
1401
|
+
return isOpenedFromSkipTree(recorded, prUrl) && recorded.e2eSkipDeclaration ? withCoveredPrs(recorded, [prUrl]) : recorded;
|
|
1402
|
+
}
|
|
1403
|
+
function applyE2eSkipScope(state, verifiedInTree) {
|
|
1404
|
+
if (!verifiedInTree || !state.e2eSkipDeclaration) return state;
|
|
1405
|
+
const scoped = { ...state, e2eSkipVerifiedInTree: verifiedInTree };
|
|
1406
|
+
return withCoveredPrs(
|
|
1407
|
+
scoped,
|
|
1408
|
+
scoped.prsHandled.filter((prUrl) => isOpenedFromSkipTree(scoped, prUrl))
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// src/guardrails/walkthroughOwed.ts
|
|
1335
1413
|
function runGh(args) {
|
|
1336
1414
|
const timeoutMs = boundedChildTimeoutMs(GH_LOOKUP_TIMEOUT_MS);
|
|
1337
1415
|
if (timeoutMs === null) return null;
|
|
@@ -1364,10 +1442,10 @@ function scanForOwedWalkthroughs(state, lookup = defaultPrWalkthroughLookup) {
|
|
|
1364
1442
|
const candidates = new Set(state.prsHandled);
|
|
1365
1443
|
const branchPrUrl = lookup.branchPrUrl();
|
|
1366
1444
|
if (branchPrUrl) candidates.add(branchPrUrl);
|
|
1367
|
-
const acceptsSkip = state.e2eRun !== true;
|
|
1368
1445
|
const owed = [];
|
|
1369
1446
|
const verified2 = [];
|
|
1370
1447
|
for (const prUrl of candidates) {
|
|
1448
|
+
const acceptsSkip = state.e2eRun !== true || isPrCoveredBySkip(state, prUrl);
|
|
1371
1449
|
if (lookup.prCarriesWalkthrough(prUrl, acceptsSkip)) verified2.push(prUrl);
|
|
1372
1450
|
else owed.push(prUrl);
|
|
1373
1451
|
}
|
|
@@ -1376,11 +1454,22 @@ function scanForOwedWalkthroughs(state, lookup = defaultPrWalkthroughLookup) {
|
|
|
1376
1454
|
function isWalkthroughGateArmed(state) {
|
|
1377
1455
|
const isSkipUnsettled = state.e2eSkipDeclaration !== void 0 && state.e2eSkipSettledOnPrs !== true;
|
|
1378
1456
|
const isOwed = state.e2eRun === true || isSkipUnsettled;
|
|
1379
|
-
return isOwed && state.
|
|
1457
|
+
return isOwed && state.walkthroughsVerified !== true && state.walkthroughSkipped !== true;
|
|
1380
1458
|
}
|
|
1381
1459
|
function isWalkthroughScanCurrent(scan, state) {
|
|
1382
1460
|
const scanned = new Set(scan.prsHandled);
|
|
1383
|
-
|
|
1461
|
+
const coversHandledPrs = scanned.size === new Set(state.prsHandled).size && state.prsHandled.every((prUrl) => scanned.has(prUrl));
|
|
1462
|
+
const postedAt = state.walkthroughPostedAt;
|
|
1463
|
+
const followsLastPost = postedAt === void 0 || (scan.startedAt ?? 0) >= postedAt;
|
|
1464
|
+
return coversHandledPrs && followsLastPost;
|
|
1465
|
+
}
|
|
1466
|
+
function withoutPostedPrs(prUrls, state) {
|
|
1467
|
+
const postedPrUrls = new Set(state.walkthroughPostedPrUrls ?? []);
|
|
1468
|
+
return prUrls.filter((prUrl) => !postedPrUrls.has(prUrl));
|
|
1469
|
+
}
|
|
1470
|
+
function applyPrOpenedToWalkthroughs(state) {
|
|
1471
|
+
if (state.walkthroughsVerified !== true && state.e2eSkipSettledOnPrs !== true) return state;
|
|
1472
|
+
return { ...state, walkthroughsVerified: false, e2eSkipSettledOnPrs: false };
|
|
1384
1473
|
}
|
|
1385
1474
|
function walkthroughGateDecision(state, owedPrUrls, maxBlocks = MAX_WALKTHROUGH_BLOCKS) {
|
|
1386
1475
|
const blockCount = state.walkthroughBlockCount ?? 0;
|
|
@@ -2164,8 +2253,12 @@ function prOpened() {
|
|
|
2164
2253
|
if (!url) return "{}";
|
|
2165
2254
|
if (readState(sessionId).prsHandled.includes(url)) return "{}";
|
|
2166
2255
|
markPrHandled(sessionId, url);
|
|
2167
|
-
const
|
|
2168
|
-
const
|
|
2256
|
+
const openedFromTree = normalizeWorkingTree(input.cwd);
|
|
2257
|
+
const stateAfterOpen = commitState(
|
|
2258
|
+
sessionId,
|
|
2259
|
+
(state) => applyPrOpenedToSkipScope(applyPrOpenedToWalkthroughs(state), url, openedFromTree)
|
|
2260
|
+
) ?? readState(sessionId);
|
|
2261
|
+
const declaredSkip = isPrCoveredBySkip(stateAfterOpen, url) ? stateAfterOpen.e2eSkipDeclaration : void 0;
|
|
2169
2262
|
if (declaredSkip) {
|
|
2170
2263
|
startBackgroundJob("settle-walkthrough-skipped" /* SettleWalkthroughSkipped */, [url, declaredSkip.code, declaredSkip.detail]);
|
|
2171
2264
|
} else {
|
|
@@ -2175,7 +2268,7 @@ function prOpened() {
|
|
|
2175
2268
|
startBackgroundJob("scan-walkthroughs" /* ScanWalkthroughs */, [sessionId], input.cwd);
|
|
2176
2269
|
}
|
|
2177
2270
|
const slotNote = declaredSkip ? `Its Muggle AI visual-walkthrough comment is being settled with the E2E skip already recorded this session (${declaredSkip.code}); the turn cannot end until the PR shows it.
|
|
2178
|
-
` : `Its Muggle AI visual-walkthrough comment is reserved and empty \u2014 settle it
|
|
2271
|
+
` : `Its Muggle AI visual-walkthrough comment is reserved and empty \u2014 settle it with the E2E run of this PR's own change (a wave's PRs share one run; any other PR gets its own), or by recording why E2E does not apply from this PR's working tree.
|
|
2179
2272
|
`;
|
|
2180
2273
|
const ctx = `A pull request was just opened: ${url}
|
|
2181
2274
|
` + slotNote + `Per the autoWatchPR preference, a muggle-pr-followup watcher should handle its incoming reviews. If autoWatchPR=always, start it now by invoking ${muggleSkill("/muggle:muggle-pr-followup")} with the PR URL; if =ask, offer it to the user; if =never, do nothing.`;
|
|
@@ -2218,8 +2311,8 @@ function terminalGate() {
|
|
|
2218
2311
|
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()}.`;
|
|
2219
2312
|
return blockStop(reason, host);
|
|
2220
2313
|
}
|
|
2221
|
-
function startWalkthroughScanOnGateArming(stateBefore, committed) {
|
|
2222
|
-
if (isWalkthroughGateArmed(committed) && !isWalkthroughGateArmed(stateBefore)) {
|
|
2314
|
+
function startWalkthroughScanOnGateArming(stateBefore, committed, hasPosted = false) {
|
|
2315
|
+
if (isWalkthroughGateArmed(committed) && (hasPosted || !isWalkthroughGateArmed(stateBefore))) {
|
|
2223
2316
|
startBackgroundJob("scan-walkthroughs" /* ScanWalkthroughs */, [sessionId], input.cwd);
|
|
2224
2317
|
}
|
|
2225
2318
|
}
|
|
@@ -2235,17 +2328,25 @@ function recordTests() {
|
|
|
2235
2328
|
e2eSkipCycleScoped: acceptedSkip !== null && CYCLE_SCOPED_SKIP_CODES.includes(acceptedSkip.code)
|
|
2236
2329
|
};
|
|
2237
2330
|
const walkthroughPosted = detectWalkthroughPost(input);
|
|
2331
|
+
const walkthroughPostTargets = walkthroughPosted ? detectWalkthroughPostTargets(input) : [];
|
|
2238
2332
|
const failedRunId = detectFailedRunId(input);
|
|
2333
|
+
const isDeclaredHere = acceptedSkip !== null && !CYCLE_SCOPED_SKIP_CODES.includes(acceptedSkip.code);
|
|
2239
2334
|
const record = (state) => {
|
|
2240
|
-
const
|
|
2335
|
+
const declared = applyE2eSkipDeclaration(applyRecordedRun(state, run), acceptedSkip);
|
|
2336
|
+
const recorded = isDeclaredHere ? applyE2eSkipScope(declared, normalizeWorkingTree(input.cwd)) : declared;
|
|
2241
2337
|
const withWatchSkip = applyWatchSkip(recorded, isWatchSkipMarker(cmd));
|
|
2242
2338
|
const withBuildSkip = applyBuildSkip(withWatchSkip, isBuildSkipMarker(cmd));
|
|
2243
|
-
const withWalkthroughPost = applyWalkthroughPosted(
|
|
2339
|
+
const withWalkthroughPost = applyWalkthroughPosted(
|
|
2340
|
+
withBuildSkip,
|
|
2341
|
+
walkthroughPosted,
|
|
2342
|
+
Date.now(),
|
|
2343
|
+
walkthroughPostTargets
|
|
2344
|
+
);
|
|
2244
2345
|
const withWalkthroughSkip = applyWalkthroughSkip(withWalkthroughPost, isWalkthroughSkipMarker(cmd));
|
|
2245
2346
|
return failedRunId ? applyFailedRun(withWalkthroughSkip, failedRunId) : withWalkthroughSkip;
|
|
2246
2347
|
};
|
|
2247
2348
|
const next = commitState(sessionId, record) ?? record(readState(sessionId));
|
|
2248
|
-
startWalkthroughScanOnGateArming(stateBefore, next);
|
|
2349
|
+
startWalkthroughScanOnGateArming(stateBefore, next, walkthroughPosted);
|
|
2249
2350
|
if (acceptedSkip) recordSkipReasonOnPrs(next, acceptedSkip);
|
|
2250
2351
|
if (judgedSkip && !judgedSkip.accepted) {
|
|
2251
2352
|
return envelope("PostToolUse", explainRejection(judgedSkip), host);
|
|
@@ -2257,9 +2358,17 @@ function recordSkipReasonOnPrs(state, skip) {
|
|
|
2257
2358
|
startBackgroundJob("settle-walkthrough-no-app-logic-change" /* SettleWalkthroughNoAppLogicChange */, [skip.detail], input.cwd);
|
|
2258
2359
|
return;
|
|
2259
2360
|
}
|
|
2260
|
-
for (const prUrl of state.prsHandled) {
|
|
2361
|
+
for (const prUrl of state.prsHandled.filter((handledPrUrl) => isPrCoveredBySkip(state, handledPrUrl))) {
|
|
2261
2362
|
startBackgroundJob("settle-walkthrough-skipped" /* SettleWalkthroughSkipped */, [prUrl, skip.code, skip.detail]);
|
|
2262
2363
|
}
|
|
2364
|
+
startBackgroundJob("settle-branch-walkthrough-skipped" /* SettleBranchWalkthroughSkipped */, [skip.code, skip.detail], input.cwd);
|
|
2365
|
+
}
|
|
2366
|
+
function recordDelegation() {
|
|
2367
|
+
const prUrls = detectBackgroundAcceptanceDispatch(input);
|
|
2368
|
+
if (prUrls === null) return "{}";
|
|
2369
|
+
const delegate = (state) => applyE2eDelegation(state, { dispatchedAt: Date.now(), prUrls });
|
|
2370
|
+
updateState(sessionId, delegate);
|
|
2371
|
+
return "{}";
|
|
2263
2372
|
}
|
|
2264
2373
|
function skillStages() {
|
|
2265
2374
|
const skillName = resolveSkillNameFromToolInput(input.tool_input);
|
|
@@ -2421,21 +2530,25 @@ function walkthroughGate() {
|
|
|
2421
2530
|
const scan = readWalkthroughScan(sessionId);
|
|
2422
2531
|
startBackgroundJob("scan-walkthroughs" /* ScanWalkthroughs */, [sessionId], input.cwd);
|
|
2423
2532
|
if (!scan || !isWalkthroughScanCurrent(scan, state)) return "{}";
|
|
2424
|
-
const
|
|
2425
|
-
if (
|
|
2426
|
-
if (scan.verified.length > 0) {
|
|
2427
|
-
writeState(
|
|
2533
|
+
const unposted = withoutPostedPrs(scan.owed, state);
|
|
2534
|
+
if (unposted.length === 0) {
|
|
2535
|
+
if (scan.verified.length + scan.owed.length > 0) {
|
|
2536
|
+
writeState(state.e2eRun === true ? { ...state, walkthroughsVerified: true } : { ...state, e2eSkipSettledOnPrs: true });
|
|
2428
2537
|
}
|
|
2429
2538
|
return "{}";
|
|
2430
2539
|
}
|
|
2431
|
-
const decision = walkthroughGateDecision(state,
|
|
2540
|
+
const decision = walkthroughGateDecision(state, withoutDelegatedPrs(unposted, state, Date.now()));
|
|
2432
2541
|
if (decision.action === "release" /* Release */) return releaseGate("walkthroughReleased");
|
|
2433
2542
|
if (decision.action !== "block" /* Block */) return "{}";
|
|
2434
2543
|
state.walkthroughBlockCount = decision.blockCount;
|
|
2435
2544
|
writeState(state);
|
|
2545
|
+
const declaredSkip = state.e2eSkipDeclaration;
|
|
2546
|
+
const skipOwedPrUrls = declaredSkip ? decision.owed.filter((prUrl) => isPrCoveredBySkip(state, prUrl)) : [];
|
|
2547
|
+
if (declaredSkip && skipOwedPrUrls.length > 0) {
|
|
2548
|
+
return blockOnUnsettledSkip(declaredSkip, skipOwedPrUrls, decision.blockCount);
|
|
2549
|
+
}
|
|
2436
2550
|
const prList = decision.owed.join(", ");
|
|
2437
|
-
|
|
2438
|
-
const reason = decision.blockCount === 1 ? `Do not end the turn yet. An E2E acceptance run happened this session but no visual walkthrough has reached ${prList}. Per the postPRVisualWalkthrough preference (default: always), post it now via ${muggleSkill("/muggle:muggle-pr-visual-walkthrough")} \u2014 include the failed runs, which are the ones reviewers most need to see. If this result genuinely should not be posted (postPRVisualWalkthrough=never, someone else's PR, nothing renderable), tell the user why and run \`echo "MUGGLE_WALKTHROUGH_SKIP: <reason>"\` \u2014 that records the skip and keeps this gate quiet for the rest of the session.` : `Walkthrough still owed for ${prList} (reminder ${decision.blockCount}/${MAX_WALKTHROUGH_BLOCKS}): post via ${muggleSkill("/muggle:muggle-pr-visual-walkthrough")}, or record a legitimate skip via \`echo "MUGGLE_WALKTHROUGH_SKIP: <reason>"\`.`;
|
|
2551
|
+
const reason = decision.blockCount === 1 ? `Do not end the turn yet. No visual walkthrough or skip record has reached ${prList}. Each PR carries the run of its own change \u2014 a wave's PRs share one run, every other PR gets its own \u2014 so never post one change's run to another change's PR. If this PR's change was tested, post that run now per the postPRVisualWalkthrough preference (default: always) via ${muggleSkill("/muggle:muggle-pr-visual-walkthrough")} \u2014 include the failed runs, which are the ones reviewers most need to see. If it was not, run E2E for it first: inline via ${muggleSkill("/muggle:muggle-test")}, or in a background muggle:acceptance-tester per do/background-e2e.md while other work continues \u2014 or, where E2E cannot apply to it, declare the skip from that PR's own working tree, since a skip settles only the PRs of the tree it was verified in. If this result genuinely should not be posted (postPRVisualWalkthrough=never, someone else's PR, nothing renderable), tell the user why and run \`echo "MUGGLE_WALKTHROUGH_SKIP: <reason>"\` \u2014 that records the skip and keeps this gate quiet for the rest of the session.` : `Walkthrough still owed for ${prList} (reminder ${decision.blockCount}/${MAX_WALKTHROUGH_BLOCKS}): post that PR's own run via ${muggleSkill("/muggle:muggle-pr-visual-walkthrough")}, run E2E for it first if its change was never tested, or record a legitimate skip via \`echo "MUGGLE_WALKTHROUGH_SKIP: <reason>"\`.`;
|
|
2439
2552
|
return blockStop(reason, host);
|
|
2440
2553
|
}
|
|
2441
2554
|
function blockOnUnsettledSkip(owedSkip, owedPrUrls, blockCount) {
|
|
@@ -2565,6 +2678,7 @@ var handlers = {
|
|
|
2565
2678
|
"pr-terminal": prTerminal,
|
|
2566
2679
|
"offer-ran": offerRan,
|
|
2567
2680
|
"record-tests": recordTests,
|
|
2681
|
+
"record-delegation": recordDelegation,
|
|
2568
2682
|
"e2e-gate": e2eGate,
|
|
2569
2683
|
"terminal-gate": terminalGate,
|
|
2570
2684
|
"watch-gate": watchGate,
|
|
@@ -2587,9 +2701,15 @@ var handlers = {
|
|
|
2587
2701
|
var jobArgs = process.argv.slice(3);
|
|
2588
2702
|
function scanWalkthroughsJob() {
|
|
2589
2703
|
const scannedSessionId = jobArgs[0] ?? "unknown";
|
|
2704
|
+
const startedAt = Date.now();
|
|
2590
2705
|
const state = readState(scannedSessionId);
|
|
2591
2706
|
const scan = scanForOwedWalkthroughs(state);
|
|
2592
|
-
writeWalkthroughScan(scannedSessionId, {
|
|
2707
|
+
writeWalkthroughScan(scannedSessionId, {
|
|
2708
|
+
prsHandled: state.prsHandled,
|
|
2709
|
+
owed: scan.owed,
|
|
2710
|
+
verified: scan.verified,
|
|
2711
|
+
startedAt
|
|
2712
|
+
});
|
|
2593
2713
|
return "{}";
|
|
2594
2714
|
}
|
|
2595
2715
|
function reserveWalkthroughCommentJob() {
|
|
@@ -2605,6 +2725,14 @@ function settleWalkthroughSkippedJob() {
|
|
|
2605
2725
|
settleWalkthroughCommentAsSkipped(prUrl, skip.code, skip.detail);
|
|
2606
2726
|
return JSON.stringify({ settled: isWalkthroughSettledOnPr(prUrl) });
|
|
2607
2727
|
}
|
|
2728
|
+
function settleBranchWalkthroughSkippedJob() {
|
|
2729
|
+
const [codeArg, detail] = jobArgs;
|
|
2730
|
+
const code = E2E_SKIP_CODES.find((skipCode) => skipCode === codeArg);
|
|
2731
|
+
if (!code) return "{}";
|
|
2732
|
+
const prUrl = defaultPrWalkthroughLookup.branchPrUrl();
|
|
2733
|
+
if (prUrl) settleWalkthroughCommentAsSkipped(prUrl, code, detail ?? "");
|
|
2734
|
+
return "{}";
|
|
2735
|
+
}
|
|
2608
2736
|
function settleWalkthroughUnreasonedJob() {
|
|
2609
2737
|
const [prUrl] = jobArgs;
|
|
2610
2738
|
if (prUrl) settleWalkthroughCommentAsUnreasoned(prUrl);
|
|
@@ -2630,6 +2758,7 @@ var backgroundJobs = {
|
|
|
2630
2758
|
["scan-walkthroughs" /* ScanWalkthroughs */]: scanWalkthroughsJob,
|
|
2631
2759
|
["reserve-walkthrough-comment" /* ReserveWalkthroughComment */]: reserveWalkthroughCommentJob,
|
|
2632
2760
|
["settle-walkthrough-skipped" /* SettleWalkthroughSkipped */]: settleWalkthroughSkippedJob,
|
|
2761
|
+
["settle-branch-walkthrough-skipped" /* SettleBranchWalkthroughSkipped */]: settleBranchWalkthroughSkippedJob,
|
|
2633
2762
|
["settle-walkthrough-unreasoned" /* SettleWalkthroughUnreasoned */]: settleWalkthroughUnreasonedJob,
|
|
2634
2763
|
["settle-walkthrough-no-app-logic-change" /* SettleWalkthroughNoAppLogicChange */]: settleWalkthroughNoAppLogicChangeJob,
|
|
2635
2764
|
["scan-watch-pr-states" /* ScanWatchPrStates */]: scanWatchPrStatesJob
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Background E2E — one acceptance run per change, off the main thread
|
|
2
|
+
|
|
3
|
+
A session that fixes several unrelated bugs opens several PRs, and each needs the E2E run of its own change: a walkthrough rendered from another change's run vouches for code that run never exercised. Running each Stage 6 inline also stalls the session on the browser while the next fix waits. So each change's Stage 6 runs in a background `muggle:acceptance-tester`, and the main session moves on to the next change.
|
|
4
|
+
|
|
5
|
+
## Changes
|
|
6
|
+
|
|
7
|
+
A **change** is what gets one E2E run and one report: a whole wave, or one PR of a stream. How a session's PRs group into waves and streams is defined once, in [`wave-or-stream.md`](wave-or-stream.md); this lane runs every change of a stream, a wave included.
|
|
8
|
+
|
|
9
|
+
- Each change has its own session directory (`state.md`, `iterations/`), branch and worktree — one per member for a wave. Pre-flight splits a request that bundles unrelated fixes this way ([`pre-flight.md`](pre-flight.md)).
|
|
10
|
+
- Changes cannot share a checkout: the background run tests one change's tree while the session edits another's. Every change gets a worktree, whatever `autoUseWorktree` says.
|
|
11
|
+
|
|
12
|
+
## Lane
|
|
13
|
+
|
|
14
|
+
`state.md` records the lane Stage 6 runs in:
|
|
15
|
+
|
|
16
|
+
- `E2E lane: background` — the session has other work in front of it when this change reaches Stage 6: another change still being built, queued, or in its own run.
|
|
17
|
+
- `E2E lane: inline` — a lone change with nothing else to do. Handing it off buys nothing and costs the run the session's context.
|
|
18
|
+
|
|
19
|
+
Decide the lane when the change reaches Stage 6, not at pre-flight; a change that ran inline in an earlier cycle can run in the background now.
|
|
20
|
+
|
|
21
|
+
## One local run at a time
|
|
22
|
+
|
|
23
|
+
Local runs share one studio browser and the stack's ports, and two studio runs at once corrupt each other — both report infra failures that read as product signal. So:
|
|
24
|
+
|
|
25
|
+
- At most one local acceptance-tester is in flight from this session. Further changes queue in the order they reached Stage 6.
|
|
26
|
+
- No inline local run starts while a background one is in flight, and the main session neither starts nor stops services meanwhile — the agent owns the local stack for its run.
|
|
27
|
+
- A run against a preview or staging URL drives the cloud rather than the local studio and needs no queue.
|
|
28
|
+
|
|
29
|
+
Each change's `state.md` tracks its place: `E2E dispatch: queued` → `running — dispatched <ISO-8601>` → `reported — <verdict> (<runIds>)`.
|
|
30
|
+
|
|
31
|
+
## Brief
|
|
32
|
+
|
|
33
|
+
The agent knows only its brief. Pass every value itself, never a pointer to the conversation:
|
|
34
|
+
|
|
35
|
+
- The change's slug and absolute session directory.
|
|
36
|
+
- Repo, worktree path, branch, base branch, and the head SHA under test — for a wave, one entry per member, from its `Wave members` block.
|
|
37
|
+
- The PR URL when the PR already exists (a repair re-run, or a PR opened outside `muggle-do`) — for a wave, every member's. Muggle reads PR URLs from the brief to know which PR's walkthrough is waiting on this run, so leave none out and add none that belong to another change.
|
|
38
|
+
- `Validation`, `localUrl`, `projectId`, and test-credential status from `state.md`.
|
|
39
|
+
- The `e2eScope` from impact analysis, verbatim; a Stage 7.5 re-run passes only its affected test cases.
|
|
40
|
+
- The acceptance criteria from `requirements.md`.
|
|
41
|
+
- `wallTimeBudgetSec`.
|
|
42
|
+
- The absolute path of [`e2e-acceptance.md`](e2e-acceptance.md) as the stage to execute — plus [`wave-e2e.md`](wave-e2e.md) for a wave — with the rules in the two sections below.
|
|
43
|
+
|
|
44
|
+
Dispatch it as `subagent_type: "muggle:acceptance-tester"` (bare `acceptance-tester` where the plugin namespace is absent), in the background. A harness with no background agents runs every change's Stage 6 inline, one after another.
|
|
45
|
+
|
|
46
|
+
## The agent's run
|
|
47
|
+
|
|
48
|
+
1. Start the stack from the change's worktree: [`muggle-test-prepare`](../muggle-test-prepare/SKILL.md) with the worktree as the directory override for the repo's services — for a wave, every member's worktree for its own repo's services, per [`wave-e2e.md`](wave-e2e.md) Stage 6. Confirm by process cwd that each service runs its worktree — a port that answers may be serving another change's branch.
|
|
49
|
+
2. Execute `e2e-acceptance.md` from Step 0.5 through Step 7 over the brief's scope, in its own context. A wave runs each case once against the combined stack and names each failure's `implicatedRepo`.
|
|
50
|
+
3. Append the Stage 6 marker to the change's `iterations/<NNN>.md`: that file's report, plus `Tested: <owner/repo>@<sha>` — one line per member for a wave.
|
|
51
|
+
4. Return the same report as its final message.
|
|
52
|
+
|
|
53
|
+
## What the agent never does
|
|
54
|
+
|
|
55
|
+
- Dispatch another agent or fork. It runs every step itself; a re-delegated run escapes the queue and lands on the browser alongside the next one.
|
|
56
|
+
- Edit code, commit, push, open or edit a PR, post or edit a comment, or arm a watcher. Every PR write stays in the main session, the one place that knows which change a PR belongs to.
|
|
57
|
+
- Declare a skip marker. A `SKIPPED` verdict returns its code; the main session declares it from the PR's worktree, where it is verified and where it settles that PR alone.
|
|
58
|
+
- Stop the stack it started.
|
|
59
|
+
|
|
60
|
+
## When the report returns
|
|
61
|
+
|
|
62
|
+
On the agent's completion notification, the main session:
|
|
63
|
+
|
|
64
|
+
1. **Checks freshness.** Every `Tested:` line must name its branch's current head. A branch that moved since dispatch — any member's, for a wave — makes the report stale: queue the change again and post nothing.
|
|
65
|
+
2. **Records it** — `E2E dispatch: reported — …` in `state.md`.
|
|
66
|
+
3. **Continues that change from Stage 7**, in its worktree. [`open-prs/forward.md`](open-prs/forward.md) opens its PR with this report — every member's PR for a wave, in the wave order of [`wave-e2e.md`](wave-e2e.md) Stage 7; when a PR already exists, the report settles that PR's walkthrough through Mode A with its number and repo passed explicitly — never from the current branch, since the session's cwd may be another change's worktree.
|
|
67
|
+
4. **Runs Stage 7.5** inline. A repair pass's re-run returns to this lane, behind any local run in flight.
|
|
68
|
+
5. **Arms the change's watcher** once 7.5 clears (Stage 8).
|
|
69
|
+
6. **Dispatches the next queued change.**
|
|
70
|
+
|
|
71
|
+
An agent that ends without a report is dispatched once more; a second miss runs that change's Stage 6 inline.
|
|
72
|
+
|
|
73
|
+
## PRs opened outside `muggle-do`
|
|
74
|
+
|
|
75
|
+
A session that fixed bugs by hand and opened each PR itself follows the same lane, one acceptance-tester per PR. With no pre-flight or impact analysis, the main session resolves the run first: `muggle-test`'s change detection and test-case selection over that PR's diff against its base, its questions answered in the main session — the agent has no user to ask. The brief then carries the selected test cases, project and URL in place of `e2eScope`, and names [`../_shared/dev-loop/run.md`](../_shared/dev-loop/run.md) as the procedure. The main session posts the returned report to that PR through [`muggle-pr-visual-walkthrough`](../muggle-pr-visual-walkthrough/SKILL.md) Mode A, number and repo explicit.
|
|
76
|
+
|
|
77
|
+
## Enforcement
|
|
78
|
+
|
|
79
|
+
- Dispatching a background acceptance-tester holds the E2E and debug-path Stop gates off for a bounded window, and for that window the walkthrough gate sets aside the PRs its brief names — the session is never steered into a second browser run alongside the agent's.
|
|
80
|
+
- A walkthrough posted to one PR settles that PR only; every other PR the session opened is still checked for its own.
|
|
81
|
+
- A skip declaration settles only the PRs of the working tree it is declared in — the PRs opened from it and its branch's PR, never another change's.
|
|
82
|
+
- Every PR's walkthrough check stays red until its slot is settled, so a change whose run never came back cannot pass as tested.
|
|
83
|
+
|
|
84
|
+
## Invariants
|
|
85
|
+
|
|
86
|
+
- One run and one report per change per full cycle; a wave is one change.
|
|
87
|
+
- At most one local acceptance run in flight from the session.
|
|
88
|
+
- Every PR write happens in the main session.
|
|
89
|
+
- A report settles only the PRs of the change it tested, at the SHA it tested.
|
|
@@ -67,6 +67,10 @@ For a `local-e2e` block, use `localUrl`, `projectId`, and the working-tree path
|
|
|
67
67
|
|
|
68
68
|
`state.md` records `Wave: on` → this stage runs **once for the whole wave**, not per repo, per [`wave-e2e.md`](wave-e2e.md): the wave stack starts from every member's worktree, test cases are selected against the union of diffs, each case runs once, and each failure names its `implicatedRepo`. The steps below apply with those changes.
|
|
69
69
|
|
|
70
|
+
### Step 0.45: Background lane
|
|
71
|
+
|
|
72
|
+
When other work is in front of the session as this change reaches Stage 6, the main session runs none of the steps below: it records `E2E lane: background`, queues the change, and dispatches a background `acceptance-tester` to execute them per [`background-e2e.md`](background-e2e.md). Executing as that agent, follow its rules — in particular, a `SKIPPED` exit returns its code in the report and runs no `MUGGLE_E2E_SKIP` echo; the main session declares it from the PR's worktree once the report returns.
|
|
73
|
+
|
|
70
74
|
### Step 0.5: Readiness check
|
|
71
75
|
|
|
72
76
|
A `local-e2e` cycle runs these before any `muggle-local-execute-*` call, every cycle — even when pre-flight already reported the app ready, since a server can die while stages 2–5 run and a healthy one fast-exits:
|
|
@@ -78,7 +78,7 @@ One question, listing each unrepairable failure with its bucket, failing step, a
|
|
|
78
78
|
|
|
79
79
|
## Step 5: Close the loop
|
|
80
80
|
|
|
81
|
-
After a `repair`, `regenerate`, or `retry` pass, re-run [`e2e-acceptance.md`](e2e-acceptance.md) over the affected test cases only, increment `repairIteration`, and return to Step 0.
|
|
81
|
+
After a `repair`, `regenerate`, or `retry` pass, re-run [`e2e-acceptance.md`](e2e-acceptance.md) over the affected test cases only, increment `repairIteration`, and return to Step 0. A change whose `state.md` records `E2E lane: background` re-runs through that lane ([`background-e2e.md`](background-e2e.md)), queued behind any local run in flight, with this PR's URL in the brief.
|
|
82
82
|
|
|
83
83
|
The loop is bounded at **3** repair iterations, the same bound the cycle guardrail already applies to E2E failures. On the third exhausted iteration, waive automatically: retitle `[E2E FAILING]`, record the surviving failures in `result.md`, and clear to Stage 8. A PR a reviewer can see is worth more than a loop that never terminates.
|
|
84
84
|
|
|
@@ -12,7 +12,7 @@ Forward pipeline's Stage 7. Invoked by `/muggle-do` after stages 1–6 of a fres
|
|
|
12
12
|
|
|
13
13
|
- Per-repo: name, path, branch.
|
|
14
14
|
- Requirements: goal, acceptance criteria.
|
|
15
|
-
- **Optional** E2E acceptance report from stage 6. Produced by [`../e2e-acceptance.md`](../e2e-acceptance.md); schema in [`../../muggle-pr-visual-walkthrough/SKILL.md`](../../muggle-pr-visual-walkthrough/SKILL.md).
|
|
15
|
+
- **Optional** E2E acceptance report from stage 6. Produced by [`../e2e-acceptance.md`](../e2e-acceptance.md) — inline, or returned by this change's background acceptance-tester ([`../background-e2e.md`](../background-e2e.md)); schema in [`../../muggle-pr-visual-walkthrough/SKILL.md`](../../muggle-pr-visual-walkthrough/SKILL.md). Only this change's own report: a sibling change's run never settles this PR.
|
|
16
16
|
|
|
17
17
|
## Wave cycles
|
|
18
18
|
|
|
@@ -48,8 +48,8 @@ Forward pipeline's Stage 7. Invoked by `/muggle-do` after stages 1–6 of a fres
|
|
|
48
48
|
- `gitlab` → open the change via [`../../_shared/vcs/gitlab/mr-create.md`](../../_shared/vcs/gitlab/mr-create.md): `glab mr create --source-branch <branch> --target-branch <base> --title "..." --description "..."`. Capture the MR URL and iid.
|
|
49
49
|
|
|
50
50
|
6. **Settle the designated walkthrough comment.** Creating the PR reserves one comment for the walkthrough, marked `muggle-pr-walkthrough` and empty until settled — the PR's walkthrough check fails while it stays that way.
|
|
51
|
-
- E2E report exists → fire [`postPRVisualWalkthrough`](../../muggle-preferences/preference-gates/postPRVisualWalkthrough.md); on skip, leave the comment to the gate's own skip record. Otherwise invoke [`../../muggle-pr-visual-walkthrough/SKILL.md`](../../muggle-pr-visual-walkthrough/SKILL.md) Mode A with the PR number — it fills the reserved comment in place.
|
|
52
|
-
- No E2E report (validation was `unit-only` or `skip`) → now that the PR exists, re-declare the skip Stage 6 recorded with the same code: `echo "MUGGLE_E2E_SKIP: <CODE>: <detail>"`, codes per [`../e2e-acceptance.md`](../e2e-acceptance.md). An accepted code settles the
|
|
51
|
+
- E2E report exists → fire [`postPRVisualWalkthrough`](../../muggle-preferences/preference-gates/postPRVisualWalkthrough.md); on skip, leave the comment to the gate's own skip record. Otherwise invoke [`../../muggle-pr-visual-walkthrough/SKILL.md`](../../muggle-pr-visual-walkthrough/SKILL.md) Mode A with the PR number and repo passed explicitly — it fills the reserved comment in place. Explicit because a session carrying several changes may sit in another change's worktree, where the current branch's PR is the wrong one.
|
|
52
|
+
- No E2E report (validation was `unit-only` or `skip`), or a `SKIPPED` report → now that the PR exists, re-declare the skip Stage 6 recorded with the same code, from this PR's worktree: `echo "MUGGLE_E2E_SKIP: <CODE>: <detail>"`, codes per [`../e2e-acceptance.md`](../e2e-acceptance.md). An accepted code settles only the PRs of that worktree's change — the PRs opened from it and its checked-out branch's PR; a free-text reason is rejected and leaves it unsettled. A PR whose title says `[UNIT-ONLY]` still owes reviewers the why. The write runs detached, so confirm it landed: the walkthrough Stop gate holds the turn while the PR still shows the placeholder, and its block names a foreground command that prints `{"settled":true}` once the PR reads back the skip — run it, never a hand-written PATCH.
|
|
53
53
|
|
|
54
54
|
7. **Overflow comment:** if the walkthrough skill returned a non-null `comment`, post it once using the provider resolved in Step 5 — `github` per [`../../_shared/vcs/github/top-level-comment.md`](../../_shared/vcs/github/top-level-comment.md), `gitlab` per [`../../_shared/vcs/gitlab/mr-note.md`](../../_shared/vcs/gitlab/mr-note.md). End the posted body with the signature line (command `/muggle-do`) per [`../../_shared/vcs/post-signature.md`](../../_shared/vcs/post-signature.md). Never post when `comment` is `null`.
|
|
55
55
|
|
|
@@ -36,7 +36,7 @@ Before asking anything, gather every fact you can resolve without the user:
|
|
|
36
36
|
- Is the current checkout already a worktree? `git -C <repo> rev-parse --is-inside-work-tree` plus `git -C <repo> worktree list`.
|
|
37
37
|
- Is the current checkout on the latest base? `muggle checkout-freshness --cwd <repo> --json` fetches and reports the verdict and `behindBy`. However stale or foreign the current checkout, a new worktree starts from `origin/<base>`, never from it.
|
|
38
38
|
10. **`autoE2ETest` preference.** Read the session-context preferences line. Unset → treat as `always` (this gate's default — opposite of the system-wide `ask` default). `ask` → surface in Q13. `always` → no question; stage 6 runs.
|
|
39
|
-
11. **Wave
|
|
39
|
+
11. **Wave or stream?** Group the task's PRs per [`wave-or-stream.md`](wave-or-stream.md). Parts of one change across repos form a **wave** ([`wave-e2e.md`](wave-e2e.md)): record each member's worktree path for the `Wave members` block, or `Wave: off — <reason>` when one fails a wave condition. Unrelated fixes — "fix these three bugs" — form a **stream**: one change per fix, each with its own slug, session directory, branch, worktree, PR and E2E run ([`background-e2e.md`](background-e2e.md)). When unsure, a stream. The questionnaire's answers apply to every change unless a fix names another repo; state the grouping in Q1's options so the user sees how many PRs ship and which share a run.
|
|
40
40
|
12. **CI check present?** For each GitHub repo, whether `.github/workflows/muggle-walkthrough.yml` exists on its default branch. Missing and [`autoInstallCiWorkflow`](../muggle-preferences/preference-gates/autoInstallCiWorkflow.md) resolves to `ask` → surface in Q14.
|
|
41
41
|
|
|
42
42
|
## The consolidated questionnaire
|
|
@@ -44,7 +44,7 @@ Before asking anything, gather every fact you can resolve without the user:
|
|
|
44
44
|
Present **one `AskUserQuestion`** (or the platform's structured-selection equivalent) that collects every remaining decision. Use detected values as defaults whenever possible. Questions to include, in this order:
|
|
45
45
|
|
|
46
46
|
1. **Task scope clarification** — only if the task description is genuinely ambiguous. Offer 2–3 interpretations as options plus "Other — type a clarification." If the task is unambiguous, omit.
|
|
47
|
-
2. **Repo(s) to modify** — pre-selected with the best silent match. "Confirm <repo>" / "Change repo" / "Multi-repo (list them)". When multi-repo
|
|
47
|
+
2. **Repo(s) to modify** — pre-selected with the best silent match. "Confirm <repo>" / "Change repo" / "Multi-repo (list them)". When multi-repo, state in the option whether the PRs ship as a wave — one change, tested together in one E2E run — or a stream of independent changes, each tested on its own, per step 11 and [`wave-or-stream.md`](wave-or-stream.md) — no separate question.
|
|
48
48
|
3. **Branch name** — default: `users/<user>/<slug>` derived from the task. "Use default" / "Use different name (type)".
|
|
49
49
|
4. **Validation strategy** — the single most important question. Options:
|
|
50
50
|
- **Local E2E** (Muggle Test Electron against a running localhost) — default if a dev server was detected.
|
|
@@ -81,6 +81,7 @@ After the user answers, write **`state.md`** with every resolved value, verbatim
|
|
|
81
81
|
- Repos: <repo1>, <repo2>
|
|
82
82
|
- Wave: <on | off — reason | N/A (single repo)>
|
|
83
83
|
- Wave members: <one line per repo when on — `<owner/repo> → <worktree path> (branch <branch>)`; see wave-e2e.md>
|
|
84
|
+
- Sibling changes: <slugs of this session's other changes, or none; see background-e2e.md>
|
|
84
85
|
- Branch: <branch-name>
|
|
85
86
|
- Validation: <strategy>
|
|
86
87
|
- Local URL: <url or N/A>
|
|
@@ -113,4 +114,4 @@ Return control to the muggle-do driver with a one-line summary: `pre-flight comp
|
|
|
113
114
|
- Exactly **one** user turn. Zero follow-up questions inside this stage.
|
|
114
115
|
- Silent detection **must** run before the questionnaire — never ask for a value you can detect.
|
|
115
116
|
- Every detected value is a default, not a lock — the user can always override via "Type a different …".
|
|
116
|
-
- Missing `state.md` or `iterations/001.md` at the end of this stage is a stage failure.
|
|
117
|
+
- Missing `state.md` or `iterations/001.md` at the end of this stage is a stage failure. Several changes → one session directory each, all written before Stage 2 starts on the first.
|
|
@@ -6,14 +6,14 @@ So a wave is tested as one: start every repo's service from its wave branch, run
|
|
|
6
6
|
|
|
7
7
|
## When a cycle is a wave
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
What makes PRs a wave rather than a stream of independent changes is defined in [`wave-or-stream.md`](wave-or-stream.md): the PRs need each other to work. A wave additionally needs all of these, decided at pre-flight and recorded in `state.md`:
|
|
10
10
|
|
|
11
11
|
- Two or more repos carry changes this cycle.
|
|
12
12
|
- Each changed repo gets exactly **one** PR — no stacked PRs, no second PR in the same repo.
|
|
13
13
|
- Validation is `local-e2e`.
|
|
14
14
|
- Every wave repo that serves part of the stack can run locally. A repo that only ships a library or config consumed by another wave repo is still a wave member; it just contributes no service of its own.
|
|
15
15
|
|
|
16
|
-
Anything else is not a wave: each PR runs Stage 6 on its own, as
|
|
16
|
+
Anything else is not a wave: each PR is a change of its own and runs Stage 6 on its own — in the background when other work is in flight, per [`background-e2e.md`](background-e2e.md). A wave can run in that background lane too, as one change: its brief carries every member ([`wave-or-stream.md`](wave-or-stream.md#the-acceptance-testers-brief)). Two PRs in one repo, or one repo whose service cannot start locally, fall back to per-PR runs — record the reason in `state.md` as `Wave: off — <reason>`.
|
|
17
17
|
|
|
18
18
|
## What pre-flight records
|
|
19
19
|
|
|
@@ -57,7 +57,7 @@ The SHAs are what the run tested. A result is only valid for the PRs at those SH
|
|
|
57
57
|
1. **Open every PR first**, before settling any walkthrough. Each PR's walkthrough names its siblings, so all PR numbers must exist before the first one is written.
|
|
58
58
|
2. **Body.** Add a `## Wave` section to each PR's body, after `## Validation`: one line per sibling PR (`owner/repo#n`), and the line `Tested together — merge all PRs in this wave together.`
|
|
59
59
|
3. **Title.** Every PR in the wave takes the same E2E prefix. A wave run with failures retitles every member `[E2E FAILING]`, not only the implicated one — the run tested them as one change.
|
|
60
|
-
4. **Walkthrough.** Settle each PR's designated walkthrough comment with the **same** E2E report through [`muggle-pr-visual-walkthrough`](../muggle-pr-visual-walkthrough/SKILL.md) Mode A, passing that PR's number and repo explicitly — Mode A otherwise looks up the PR from the current branch, which in a multi-repo cycle is the wrong repo. The runs, screenshots, and dashboard links are identical on every PR; only the PR it is posted to differs.
|
|
60
|
+
4. **Walkthrough.** Settle each PR's designated walkthrough comment with the **same** E2E report through [`muggle-pr-visual-walkthrough`](../muggle-pr-visual-walkthrough/SKILL.md) Mode A, passing that PR's number and repo explicitly — Mode A otherwise looks up the PR from the current branch, which in a multi-repo cycle is the wrong repo. The runs, screenshots, and dashboard links are identical on every PR; only the PR it is posted to differs. A `SKIPPED` wave run is re-declared from each member's worktree in turn: a declaration settles only the PR of the tree it runs in.
|
|
61
61
|
5. **Record the PR numbers** on the `Wave members` lines in `state.md` (`… (branch <branch>) → PR #<n>`), so a later cycle on any one PR can find its siblings. Every slot a wave PR's watcher runs from gets the same `Wave` block.
|
|
62
62
|
|
|
63
63
|
## Stage 7.5 — repair across the wave
|