@muggleai/works 5.38.0-staging.349 → 5.38.0-staging.350
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/{chunk-A3V2UKAB.js → chunk-RMPZ7ZQC.js} +34 -0
- 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/visual-walkthrough-builder.md +16 -4
- package/dist/plugin/scripts/pr-watch-arm.sh +5 -1
- package/dist/plugin/scripts/pr-watch-events.sh +12 -0
- package/dist/plugin/scripts/pr-watch-floors.sh +5 -4
- package/dist/plugin/scripts/pr-watch-loop.sh +8 -1
- package/dist/plugin/scripts/pr-watch-verdict.mjs +21 -6
- package/dist/plugin/skills/do/e2e-acceptance.md +2 -0
- package/dist/plugin/skills/do/e2e-repair.md +27 -6
- package/dist/plugin/skills/do/fix-ci.md +13 -7
- package/dist/plugin/skills/muggle-pr-followup/arm-watcher.md +1 -1
- package/dist/plugin/skills/muggle-pr-followup/blocked-tick.md +3 -1
- package/dist/plugin/skills/muggle-pr-followup/contract.md +2 -2
- package/dist/plugin/skills/muggle-pr-followup/output-templates/blocked-reminder.md +5 -1
- package/dist/plugin/skills/muggle-pr-followup/state-schemas.md +4 -0
- package/dist/plugin/skills/muggle-pr-visual-walkthrough/SKILL.md +14 -2
- package/dist/plugin/skills/muggle-pr-visual-walkthrough/e2e-report-assembly.md +1 -0
- 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/visual-walkthrough-builder.md +16 -4
- package/plugin/scripts/pr-watch-arm.sh +5 -1
- package/plugin/scripts/pr-watch-events.sh +12 -0
- package/plugin/scripts/pr-watch-floors.sh +5 -4
- package/plugin/scripts/pr-watch-loop.sh +8 -1
- package/plugin/scripts/pr-watch-verdict.mjs +21 -6
- package/plugin/skills/do/e2e-acceptance.md +2 -0
- package/plugin/skills/do/e2e-repair.md +27 -6
- package/plugin/skills/do/fix-ci.md +13 -7
- package/plugin/skills/muggle-pr-followup/arm-watcher.md +1 -1
- package/plugin/skills/muggle-pr-followup/blocked-tick.md +3 -1
- package/plugin/skills/muggle-pr-followup/contract.md +2 -2
- package/plugin/skills/muggle-pr-followup/output-templates/blocked-reminder.md +5 -1
- package/plugin/skills/muggle-pr-followup/state-schemas.md +4 -0
- package/plugin/skills/muggle-pr-visual-walkthrough/SKILL.md +14 -2
- package/plugin/skills/muggle-pr-visual-walkthrough/e2e-report-assembly.md +1 -0
|
@@ -482,6 +482,19 @@ var MissingRunSummarySchema = z.object({
|
|
|
482
482
|
isRecorded: z.literal(false)
|
|
483
483
|
});
|
|
484
484
|
var RunSummarySchema = z.discriminatedUnion("isRecorded", [RecordedRunSummarySchema, MissingRunSummarySchema]);
|
|
485
|
+
var RepairHoldKindEnum = /* @__PURE__ */ ((RepairHoldKindEnum2) => {
|
|
486
|
+
RepairHoldKindEnum2["TemporaryBlocker"] = "temporary-blocker";
|
|
487
|
+
RepairHoldKindEnum2["OwnerDecision"] = "owner-decision";
|
|
488
|
+
RepairHoldKindEnum2["BudgetSpent"] = "budget-spent";
|
|
489
|
+
return RepairHoldKindEnum2;
|
|
490
|
+
})(RepairHoldKindEnum || {});
|
|
491
|
+
var RepairHoldSchema = z.object({
|
|
492
|
+
kind: z.nativeEnum(RepairHoldKindEnum),
|
|
493
|
+
bucket: z.string().min(1),
|
|
494
|
+
rootCause: z.string().min(1),
|
|
495
|
+
reason: z.string().min(1),
|
|
496
|
+
unblockedBy: z.string().min(1)
|
|
497
|
+
});
|
|
485
498
|
var TEST_SHORT_ID_FIELDS = {
|
|
486
499
|
testCaseShortId: z.string().min(1).optional(),
|
|
487
500
|
replayShortId: z.string().min(1).optional()
|
|
@@ -521,6 +534,7 @@ var FailedTestSchema = z.object({
|
|
|
521
534
|
// A run of the same test case on the PR's base the author says failed too; build-pr-section verifies it before
|
|
522
535
|
// the walkthrough credits it.
|
|
523
536
|
baselineRunId: z.string().min(1).optional(),
|
|
537
|
+
repairHold: RepairHoldSchema.optional(),
|
|
524
538
|
artifactsDir: z.string().min(1).optional(),
|
|
525
539
|
useCaseName: z.string().min(1).optional(),
|
|
526
540
|
description: z.string().min(1).optional(),
|
|
@@ -539,6 +553,7 @@ var InconclusiveTestSchema = z.object({
|
|
|
539
553
|
status: z.literal("inconclusive"),
|
|
540
554
|
steps: z.array(StepSchema),
|
|
541
555
|
reason: z.string().min(1),
|
|
556
|
+
repairHold: RepairHoldSchema.optional(),
|
|
542
557
|
artifactsDir: z.string().min(1).optional(),
|
|
543
558
|
useCaseName: z.string().min(1).optional(),
|
|
544
559
|
description: z.string().min(1).optional(),
|
|
@@ -570,6 +585,13 @@ var RUN_SUMMARY_VERDICT_STATUS_LABELS = {
|
|
|
570
585
|
["bug_detected" /* BugDetected */]: "\u274C Bug detected",
|
|
571
586
|
["goal_unachievable" /* GoalUnachievable */]: "\u26A0\uFE0F Goal unachievable"
|
|
572
587
|
};
|
|
588
|
+
var REPAIR_HOLD_HEADING = "**Not auto-repaired**";
|
|
589
|
+
var REPAIR_HOLD_MARKER = "\u23F8\uFE0F";
|
|
590
|
+
var REPAIR_HOLD_KIND_LABELS = {
|
|
591
|
+
["temporary-blocker" /* TemporaryBlocker */]: "temporary blocker",
|
|
592
|
+
["owner-decision" /* OwnerDecision */]: "needs the owner's decision",
|
|
593
|
+
["budget-spent" /* BudgetSpent */]: "repair budget spent"
|
|
594
|
+
};
|
|
573
595
|
var MISSING_RUN_SUMMARY_TEXT = "\u26A0\uFE0F **No summary step** \u2014 the run ended before it summarized its result; open the run on Muggle AI for its last state.";
|
|
574
596
|
var TEST_DETAILS_DIVIDER = "---";
|
|
575
597
|
var SHORT_ID_LABEL_SEPARATOR = " \xB7 ";
|
|
@@ -935,6 +957,7 @@ function renderOverview(report) {
|
|
|
935
957
|
}
|
|
936
958
|
const numbering = buildTestNumbering(latestRuns);
|
|
937
959
|
lines.push(...renderNeedsAttention(buildE2eResultRecord(latestRuns.map((entry) => entry.test))));
|
|
960
|
+
lines.push(...renderRepairHolds(latestRuns));
|
|
938
961
|
lines.push("");
|
|
939
962
|
const anyGrouped = latestRuns.some((entry) => Boolean(entry.test.useCaseName));
|
|
940
963
|
if (!anyGrouped) {
|
|
@@ -961,6 +984,17 @@ function renderNeedsAttention(record) {
|
|
|
961
984
|
...record.unpassed.map((unpassed) => renderUnpassedCaseBullet(unpassed, "see details", `#${testAnchor(unpassed)}`))
|
|
962
985
|
];
|
|
963
986
|
}
|
|
987
|
+
function renderRepairHolds(latestRuns) {
|
|
988
|
+
const heldLines = latestRuns.flatMap((entry) => {
|
|
989
|
+
const repairHold = entry.test.status === "passed" ? void 0 : entry.test.repairHold;
|
|
990
|
+
return repairHold ? [renderRepairHoldBullet(entry.test, repairHold)] : [];
|
|
991
|
+
});
|
|
992
|
+
if (heldLines.length === 0) return [];
|
|
993
|
+
return ["", REPAIR_HOLD_HEADING, "", ...heldLines];
|
|
994
|
+
}
|
|
995
|
+
function renderRepairHoldBullet(test, repairHold) {
|
|
996
|
+
return `- ${REPAIR_HOLD_MARKER} **${testLabel(test)}** \u2014 \`${singleLine(repairHold.bucket)}\`: ${escapeFreeText(singleLine(repairHold.rootCause))} \xB7 not auto-fixed (${REPAIR_HOLD_KIND_LABELS[repairHold.kind]}): ${escapeFreeText(singleLine(repairHold.reason))} \xB7 unblocks: ${escapeFreeText(singleLine(repairHold.unblockedBy))}`;
|
|
997
|
+
}
|
|
964
998
|
function renderUseCaseGroup(useCaseName, members, numbering) {
|
|
965
999
|
const groupCounts = countTests(members);
|
|
966
1000
|
const isAllPassed = groupCounts.passed === groupCounts.total;
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-
|
|
1
|
+
export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-RMPZ7ZQC.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-OIFLV2QN.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"description": "Acceptance test agent for coding agents: real-browser tests, with screenshots on the PR.",
|
|
4
|
-
"version": "5.38.0-staging.
|
|
4
|
+
"version": "5.38.0-staging.350",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Muggle AI",
|
|
7
7
|
"email": "support@muggle-ai.com"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"displayName": "Muggle AI",
|
|
4
4
|
"description": "Acceptance test agent for coding agents: real-browser tests, with screenshots on the PR.",
|
|
5
|
-
"version": "5.38.0-staging.
|
|
5
|
+
"version": "5.38.0-staging.350",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Muggle AI",
|
|
8
8
|
"email": "support@muggle-ai.com"
|
package/dist/plugin/.mcp.json
CHANGED
|
@@ -12,9 +12,9 @@ You render and (in Mode A) post the Muggle Test E2E visual walkthrough. The disp
|
|
|
12
12
|
|
|
13
13
|
The dispatch prompt carries:
|
|
14
14
|
|
|
15
|
-
- `mode` — `post` (Mode A), `render-for-new-pr` (Mode B),
|
|
16
|
-
- `prNumber` + repo —
|
|
17
|
-
- The `E2eReport` JSON inline, **or** the run identifiers (`projectId`, per-test `runId`/`testCaseId` list) to assemble it from.
|
|
15
|
+
- `mode` — `post` (Mode A), `render-for-new-pr` (Mode B), `embed` (Mode C), or `status` (Mode D).
|
|
16
|
+
- `prNumber` + repo — Modes A and D, already verified to exist.
|
|
17
|
+
- The `E2eReport` JSON inline, **or** the run identifiers (`projectId`, per-test `runId`/`testCaseId` list) to assemble it from. Mode D takes the cycle status instead — `headSha`, `changes`, `running`, `lastVerdict` — and skips Render.
|
|
18
18
|
|
|
19
19
|
When assembling from identifiers, follow [`../skills/muggle-pr-visual-walkthrough/e2e-report-assembly.md`](../skills/muggle-pr-visual-walkthrough/e2e-report-assembly.md). The `E2eReport` schema, required fields, and the inconclusive rule live there and in the CLI's Zod schema (`src/cli/pr-section/types.ts`) — a run that couldn't produce pass/fail is `inconclusive` with a `reason`, never dropped.
|
|
20
20
|
|
|
@@ -50,6 +50,18 @@ While a run is in flight, the comment carries a "new E2E run in progress" banner
|
|
|
50
50
|
|
|
51
51
|
Report back: PR URL, whether an overflow comment was involved, and whether this was a fresh post or an update.
|
|
52
52
|
|
|
53
|
+
**Mode D (`status`)** — find the walkthrough comment exactly as Mode A does; none → stop, posting nothing. Otherwise put this block at the top of its body, replacing any earlier one, and PATCH it back, the rest of the body untouched:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
<!-- muggle-pr-walkthrough-cycle -->
|
|
57
|
+
> **E2E cycle in progress** on `<headSha, 7 chars>` — <running, or "waiting for the next job">
|
|
58
|
+
> - `<sha, 7 chars>` <subject> ← one line per change; omitted when none
|
|
59
|
+
> Last verdict: <lastVerdict>
|
|
60
|
+
<!-- /muggle-pr-walkthrough-cycle -->
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
That block is the one piece of the comment this agent writes itself. Never sign it again or touch the CLI's markdown below it; the next Mode A settle replaces the whole body, block included. Report back one line: updated, or no comment found.
|
|
64
|
+
|
|
53
65
|
**Modes B/C (`render-for-new-pr` / `embed`)** — do not post, do not touch `gh`. Return the CLI output verbatim as your report:
|
|
54
66
|
|
|
55
67
|
```
|
|
@@ -61,7 +73,7 @@ comment:
|
|
|
61
73
|
|
|
62
74
|
## Guardrails
|
|
63
75
|
|
|
64
|
-
- Never hand-write or modify the walkthrough markdown — the CLI is the single source of truth. No custom tables, no added "Verdict" lines, no `Tested on:`/`Project:` footers; the CLI computes the verdict and emits per-test dashboard links.
|
|
76
|
+
- Never hand-write or modify the walkthrough markdown — the CLI is the single source of truth. Mode D's status block is the one exception, and it sits above the CLI's markdown, never inside it. No custom tables, no added "Verdict" lines, no `Tested on:`/`Project:` footers; the CLI computes the verdict and emits per-test dashboard links.
|
|
65
77
|
- Never invent report fields — missing `projectId`, `viewUrl`, or `screenshotUrl` → `needs-input:`, never a placeholder.
|
|
66
78
|
- Never post the overflow comment when `comment` is null.
|
|
67
79
|
- Never create a PR, never choose a mode — both belong to the dispatcher.
|
|
@@ -123,6 +123,7 @@ last_seen_file="${slot}/last_seen.json"
|
|
|
123
123
|
rebase_attempted=0
|
|
124
124
|
ci_settled=0
|
|
125
125
|
blocked_digest_floor=""
|
|
126
|
+
ci_retry_at=""
|
|
126
127
|
rebase_budget_exhausted=0
|
|
127
128
|
unhandled_review_ids=""
|
|
128
129
|
unhandled_conversation_ids=""
|
|
@@ -135,6 +136,7 @@ while IFS= read -r evidence_line; do
|
|
|
135
136
|
REBASE_ATTEMPTED=*) rebase_attempted="${evidence_line#REBASE_ATTEMPTED=}" ;;
|
|
136
137
|
CI_SETTLED=*) ci_settled="${evidence_line#CI_SETTLED=}" ;;
|
|
137
138
|
BLOCKED_CIDIGEST=*) blocked_digest_floor="${evidence_line#BLOCKED_CIDIGEST=}" ;;
|
|
139
|
+
CI_RETRY_AT=*) ci_retry_at="${evidence_line#CI_RETRY_AT=}" ;;
|
|
138
140
|
REBASE_BUDGET_EXHAUSTED=*) rebase_budget_exhausted="${evidence_line#REBASE_BUDGET_EXHAUSTED=}" ;;
|
|
139
141
|
UNHANDLED_REVIEW_IDS=*) unhandled_review_ids="${evidence_line#UNHANDLED_REVIEW_IDS=}" ;;
|
|
140
142
|
UNHANDLED_CONVERSATION_IDS=*) unhandled_conversation_ids="${evidence_line#UNHANDLED_CONVERSATION_IDS=}" ;;
|
|
@@ -237,6 +239,7 @@ conversation_floor="$(floor_capped_at "$conversation_floor" "$conversation_floor
|
|
|
237
239
|
printf 'REBASED="%s"\n' "$rebase_floor"
|
|
238
240
|
printf 'BLOCKED_CIDIGEST="%s"\n' "$blocked_digest_floor"
|
|
239
241
|
printf 'REBASE_HELD="%s"\n' "$rebase_held"
|
|
242
|
+
printf 'CI_RETRY_AT="%s"\n' "$ci_retry_at"
|
|
240
243
|
} > "${slot}/watch-watermark.env"
|
|
241
244
|
|
|
242
245
|
# The loop fires only above both this watermark and watch-reported.env, so a
|
|
@@ -257,7 +260,8 @@ if [ -f "${slot}/${MUGGLE_PR_WATCH_REPORTED_FILE}" ] && [ -n "$has_unhandled_fee
|
|
|
257
260
|
"$(watch_read_slot_value "$slot" "$MUGGLE_PR_WATCH_REPORTED_FILE" CIRED)" \
|
|
258
261
|
"$(watch_read_slot_value "$slot" "$MUGGLE_PR_WATCH_REPORTED_FILE" REBASED)" \
|
|
259
262
|
"$(watch_read_slot_value "$slot" "$MUGGLE_PR_WATCH_REPORTED_FILE" BLOCKED_CIDIGEST)" \
|
|
260
|
-
"$(watch_read_slot_value "$slot" "$MUGGLE_PR_WATCH_REPORTED_FILE" BLOCKED_FOR)"
|
|
263
|
+
"$(watch_read_slot_value "$slot" "$MUGGLE_PR_WATCH_REPORTED_FILE" BLOCKED_FOR)" \
|
|
264
|
+
"$(watch_read_slot_value "$slot" "$MUGGLE_PR_WATCH_REPORTED_FILE" CI_RETRY_AT)"
|
|
261
265
|
fi
|
|
262
266
|
|
|
263
267
|
# Unhandled feedback goes on the due record with the arm read's lists, so the
|
|
@@ -162,3 +162,15 @@ watch_wake_blocked_resume() {
|
|
|
162
162
|
[ "$digest" != "$blocked_digest" ] || return 1
|
|
163
163
|
echo "EVENT pr=$pr ci digest moved while blocked — resume check"
|
|
164
164
|
}
|
|
165
|
+
|
|
166
|
+
# A red head's repair wait on a temporary blocker — an outage or usage limit —
|
|
167
|
+
# running out. Nothing on the PR moves when a provider recovers, so without this
|
|
168
|
+
# the block holds until someone pushes. It fires once per retry time: the next
|
|
169
|
+
# wait a failed retry records carries a later one.
|
|
170
|
+
watch_wake_ci_retry_due() {
|
|
171
|
+
local pr="$1" now="$2" retry_at="$3" floor="$4"
|
|
172
|
+
[ -n "$retry_at" ] || return 1
|
|
173
|
+
[ "$retry_at" != "$floor" ] || return 1
|
|
174
|
+
[ "$now" -ge "$retry_at" ] 2>/dev/null || return 1
|
|
175
|
+
echo "EVENT pr=$pr repair wait elapsed — retry the E2E repair"
|
|
176
|
+
}
|
|
@@ -50,11 +50,12 @@ watch_slot_has_key() {
|
|
|
50
50
|
# conversation-comment ids and the unresolved threads a loop's last poll saw —
|
|
51
51
|
# every one of them either reported or already floored — and the red head,
|
|
52
52
|
# rebase key and blocked digest it reported, with the block (`blocked_for`, that
|
|
53
|
-
# block's watermark digest) the digest was reported under
|
|
53
|
+
# block's watermark digest) the digest was reported under, and the repair-wait
|
|
54
|
+
# retry time it reported elapsed.
|
|
54
55
|
watch_record_reported() {
|
|
55
|
-
local slot="$1" review="$2" comment="$3" conversation="$4" threads="$5" ci_red="$6" rebase="$7" blocked_digest="$8" blocked_for="$9"
|
|
56
|
-
printf 'REV=%s\nCOM=%s\nCONV=%s\nTHREADS="%s"\nCIRED="%s"\nREBASED="%s"\nBLOCKED_CIDIGEST="%s"\nBLOCKED_FOR="%s"\n' \
|
|
57
|
-
"$review" "$comment" "$conversation" "$threads" "$ci_red" "$rebase" "$blocked_digest" "$blocked_for" \
|
|
56
|
+
local slot="$1" review="$2" comment="$3" conversation="$4" threads="$5" ci_red="$6" rebase="$7" blocked_digest="$8" blocked_for="$9" ci_retry_at="${10-}"
|
|
57
|
+
printf 'REV=%s\nCOM=%s\nCONV=%s\nTHREADS="%s"\nCIRED="%s"\nREBASED="%s"\nBLOCKED_CIDIGEST="%s"\nBLOCKED_FOR="%s"\nCI_RETRY_AT="%s"\n' \
|
|
58
|
+
"$review" "$comment" "$conversation" "$threads" "$ci_red" "$rebase" "$blocked_digest" "$blocked_for" "$ci_retry_at" \
|
|
58
59
|
> "${slot}/${MUGGLE_PR_WATCH_REPORTED_FILE}"
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -108,6 +108,7 @@ floor_ci_red=$(read_reported CIRED)
|
|
|
108
108
|
floor_rebase=$(read_reported REBASED)
|
|
109
109
|
floor_blocked_digest=$(read_reported BLOCKED_CIDIGEST)
|
|
110
110
|
floor_blocked_for=$(read_reported BLOCKED_FOR)
|
|
111
|
+
floor_ci_retry_at=$(read_reported CI_RETRY_AT)
|
|
111
112
|
|
|
112
113
|
read_watermark() {
|
|
113
114
|
watch_read_slot_value "$slot" watch-watermark.env "$1"
|
|
@@ -168,6 +169,7 @@ while :; do
|
|
|
168
169
|
watermark_rebase=$(read_watermark REBASED)
|
|
169
170
|
watermark_blocked_digest=$(read_watermark BLOCKED_CIDIGEST)
|
|
170
171
|
watermark_rebase_held=$(read_watermark REBASE_HELD)
|
|
172
|
+
watermark_ci_retry_at=$(read_watermark CI_RETRY_AT)
|
|
171
173
|
|
|
172
174
|
state_line=$(watch_fetch_state "$repo" "$pr_number" "$slot" "$state_projection")
|
|
173
175
|
# One quick retry before counting a strike: a single flaky call should not
|
|
@@ -285,11 +287,16 @@ while :; do
|
|
|
285
287
|
has_reported=1
|
|
286
288
|
fi
|
|
287
289
|
|
|
290
|
+
if watch_wake_ci_retry_due "$pr_number" "$(date +%s)" "$watermark_ci_retry_at" "$floor_ci_retry_at"; then
|
|
291
|
+
floor_ci_retry_at="$watermark_ci_retry_at"
|
|
292
|
+
has_reported=1
|
|
293
|
+
fi
|
|
294
|
+
|
|
288
295
|
if [ -n "$has_reported" ]; then
|
|
289
296
|
watch_record_reported "$slot" "$(higher_id "$latest_review" "$reported_review")" \
|
|
290
297
|
"$(higher_id "$latest_comment" "$reported_comment")" \
|
|
291
298
|
"$(higher_id "$latest_conversation" "$reported_conversation")" "$unresolved_threads" \
|
|
292
|
-
"$floor_ci_red" "$floor_rebase" "$floor_blocked_digest" "$floor_blocked_for"
|
|
299
|
+
"$floor_ci_red" "$floor_rebase" "$floor_blocked_digest" "$floor_blocked_for" "$floor_ci_retry_at"
|
|
293
300
|
exit 0
|
|
294
301
|
fi
|
|
295
302
|
|
|
@@ -58,9 +58,20 @@ function isCiHeadEscalated(lastSeenEntry, headSha) {
|
|
|
58
58
|
function isCiHeadBudgetSpent(lastSeenEntry, headSha) {
|
|
59
59
|
return ciFixAttemptsFor(lastSeenEntry, headSha) >= MAX_CI_FIX_ATTEMPTS_PER_HEAD;
|
|
60
60
|
}
|
|
61
|
-
function isCiHeadSettled(lastSeenEntry, headSha) {
|
|
61
|
+
function isCiHeadSettled(lastSeenEntry, headSha, nowEpochSeconds) {
|
|
62
|
+
if (isCiRepairWaitElapsed(lastSeenEntry, headSha, nowEpochSeconds)) return false;
|
|
62
63
|
return isCiHeadEscalated(lastSeenEntry, headSha) || isCiHeadBudgetSpent(lastSeenEntry, headSha);
|
|
63
64
|
}
|
|
65
|
+
function ciRepairWaitRetryAt(lastSeenEntry, headSha) {
|
|
66
|
+
const repairWait = lastSeenEntry.ci_wait;
|
|
67
|
+
if (headSha === "" || repairWait?.head_sha !== headSha || typeof repairWait.retry_at !== "string") return void 0;
|
|
68
|
+
const retryAtMilliseconds = Date.parse(repairWait.retry_at);
|
|
69
|
+
return Number.isFinite(retryAtMilliseconds) ? Math.floor(retryAtMilliseconds / 1e3) : void 0;
|
|
70
|
+
}
|
|
71
|
+
function isCiRepairWaitElapsed(lastSeenEntry, headSha, nowEpochSeconds) {
|
|
72
|
+
const retryAt = ciRepairWaitRetryAt(lastSeenEntry, headSha);
|
|
73
|
+
return retryAt !== void 0 && nowEpochSeconds >= retryAt;
|
|
74
|
+
}
|
|
64
75
|
function isRebaseBudgetExhausted(lastSeenEntry, maxCatchUpRebases) {
|
|
65
76
|
const catchUpRebases = lastSeenEntry.catch_up_rebases;
|
|
66
77
|
return maxCatchUpRebases !== null && typeof catchUpRebases === "number" && catchUpRebases >= maxCatchUpRebases;
|
|
@@ -121,13 +132,15 @@ function resolveUnhandledFeedback(lastSeenEntry, observation) {
|
|
|
121
132
|
}
|
|
122
133
|
|
|
123
134
|
// src/pr-watch/armFloors.ts
|
|
124
|
-
function resolveArmFloorEvidence(lastSeenEntry, headSha, rebaseKey, maxCatchUpRebases, feedbackObservation) {
|
|
135
|
+
function resolveArmFloorEvidence(lastSeenEntry, headSha, rebaseKey, maxCatchUpRebases, feedbackObservation, nowEpochSeconds = Math.floor(Date.now() / 1e3)) {
|
|
125
136
|
const blockedCiDigest = lastSeenEntry.blocked?.fingerprint?.ci_digest;
|
|
137
|
+
const ciRetryAt = ciRepairWaitRetryAt(lastSeenEntry, headSha);
|
|
126
138
|
return {
|
|
127
139
|
isRebaseKeyAttempted: rebaseKey !== "" && isRebaseKeyAttempted(lastSeenEntry, rebaseKey),
|
|
128
|
-
isCiHeadSettled: headSha !== "" && isCiHeadSettled(lastSeenEntry, headSha),
|
|
140
|
+
isCiHeadSettled: headSha !== "" && isCiHeadSettled(lastSeenEntry, headSha, nowEpochSeconds),
|
|
129
141
|
isRebaseBudgetExhausted: isRebaseBudgetExhausted(lastSeenEntry, maxCatchUpRebases),
|
|
130
142
|
blockedCiDigest: typeof blockedCiDigest === "string" && !LINE_BREAK.test(blockedCiDigest) ? blockedCiDigest : "",
|
|
143
|
+
ciRetryAt: ciRetryAt === void 0 ? "" : String(ciRetryAt),
|
|
131
144
|
unhandledFeedback: resolveUnhandledFeedback(lastSeenEntry, feedbackObservation)
|
|
132
145
|
};
|
|
133
146
|
}
|
|
@@ -169,6 +182,7 @@ function resolveWatchTickVerdict(lastSeenEntry, observation, preferences) {
|
|
|
169
182
|
if (isRebaseKeyBudgetLeft && !isRebaseKeyEscalated(lastSeenEntry, rebaseKey)) return "dispatch-rebase" /* DispatchRebase */;
|
|
170
183
|
}
|
|
171
184
|
if (observation.ciBucket === "red" /* Red */) {
|
|
185
|
+
if (isCiRepairWaitElapsed(lastSeenEntry, headSha, observation.nowEpochSeconds)) return "dispatch-fix-ci" /* DispatchFixCi */;
|
|
172
186
|
const isCiHeadBudgetLeft = ciFixAttemptsFor(lastSeenEntry, headSha) < MAX_CI_FIX_ATTEMPTS_PER_HEAD;
|
|
173
187
|
if (isCiHeadBudgetLeft && !isCiHeadEscalated(lastSeenEntry, headSha)) return "dispatch-fix-ci" /* DispatchFixCi */;
|
|
174
188
|
}
|
|
@@ -199,7 +213,7 @@ ${PR_WATCH_VERDICT_USAGE}
|
|
|
199
213
|
`,
|
|
200
214
|
exitCode: USAGE_EXIT_CODE
|
|
201
215
|
});
|
|
202
|
-
function runPrWatchVerdictCommand(commandLine, lastSeenJson, resolvePreferences) {
|
|
216
|
+
function runPrWatchVerdictCommand(commandLine, lastSeenJson, resolvePreferences, nowEpochSeconds = Math.floor(Date.now() / 1e3)) {
|
|
203
217
|
const [subcommand, ...flagTokens] = commandLine;
|
|
204
218
|
const flags = parseVerdictArguments(flagTokens);
|
|
205
219
|
const prKey = flags[PR_KEY_FLAG];
|
|
@@ -212,12 +226,13 @@ function runPrWatchVerdictCommand(commandLine, lastSeenJson, resolvePreferences)
|
|
|
212
226
|
bodyOnlyReviewIds: parseFeedbackIdList(flags[BODY_REVIEWS_FLAG] ?? ""),
|
|
213
227
|
conversationCommentIds: parseFeedbackIdList(flags[CONVERSATION_COMMENTS_FLAG] ?? ""),
|
|
214
228
|
unansweredThreadComments: parseUnansweredThreadComments(flags[UNANSWERED_THREADS_FLAG] ?? "")
|
|
215
|
-
});
|
|
229
|
+
}, nowEpochSeconds);
|
|
216
230
|
const { unhandledFeedback } = evidence;
|
|
217
231
|
return {
|
|
218
232
|
stdout: `REBASE_ATTEMPTED=${evidence.isRebaseKeyAttempted ? 1 : 0}
|
|
219
233
|
CI_SETTLED=${evidence.isCiHeadSettled ? 1 : 0}
|
|
220
234
|
BLOCKED_CIDIGEST=${evidence.blockedCiDigest}
|
|
235
|
+
CI_RETRY_AT=${evidence.ciRetryAt}
|
|
221
236
|
REBASE_BUDGET_EXHAUSTED=${evidence.isRebaseBudgetExhausted ? 1 : 0}
|
|
222
237
|
UNHANDLED_REVIEW_IDS=${unhandledFeedback.reviewIds.join(" ")}
|
|
223
238
|
UNHANDLED_CONVERSATION_IDS=${unhandledFeedback.conversationCommentIds.join(" ")}
|
|
@@ -235,7 +250,7 @@ CONVERSATION_FLOOR_CEILING=${unhandledFeedback.conversationFloorCeiling ?? ""}
|
|
|
235
250
|
if (!headSha || !rebaseKey) return usageFailure(`--${HEAD_FLAG} and --${REBASE_KEY_FLAG} are required`);
|
|
236
251
|
const verdict = resolveWatchTickVerdict(
|
|
237
252
|
lastSeenEntry,
|
|
238
|
-
{ headSha, rebaseKey, isRebaseDue: flags[REBASE_DUE_FLAG] === REBASE_DUE_YES, ciBucket },
|
|
253
|
+
{ headSha, rebaseKey, isRebaseDue: flags[REBASE_DUE_FLAG] === REBASE_DUE_YES, ciBucket, nowEpochSeconds },
|
|
239
254
|
resolvePreferences()
|
|
240
255
|
);
|
|
241
256
|
return { stdout: `VERDICT=${verdict}
|
|
@@ -140,6 +140,8 @@ For each scoped test case, run the shared loop in [`../_shared/dev-loop/run.md`]
|
|
|
140
140
|
|
|
141
141
|
Inputs to the loop: `mode` from the script-exists check, `localUrl`/project from Step 1.7, `cwd` = the working tree recorded in `state.md`.
|
|
142
142
|
|
|
143
|
+
A re-run inside a repair cycle also posts the cycle's status when it starts and when it finishes, per [`../muggle-pr-visual-walkthrough/SKILL.md`](../muggle-pr-visual-walkthrough/SKILL.md#cycle-progress).
|
|
144
|
+
|
|
143
145
|
Each record's run is its own report entry carrying its `runSettingsId` and `resolutionLabel`. A record skipped because its primary failed is an Inconclusive entry with reason `primary failed`, not a skipped test case.
|
|
144
146
|
|
|
145
147
|
### Step 5: Run the deliverable checks
|
|
@@ -51,10 +51,12 @@ Map each bucket to exactly one disposition. Buckets are defined in [`../_shared/
|
|
|
51
51
|
| `stale-script` (replay) | `regenerate` | Selectors moved; the product is fine. Regenerating is self-healing, not a code change. |
|
|
52
52
|
| `transient` (regen) | `retry` | Once, then re-bucket the second result. A twice-transient failure is `infra`. |
|
|
53
53
|
| `test-precondition` (either) | `repair-test` | The product is right for the data it has; the test asserts on state it never created. Repair the test case, never the product. |
|
|
54
|
-
| `infra` (either) | `
|
|
54
|
+
| `infra` (either) | `wait` | The runner or a provider failed — a Muggle Test bug, an outage, a usage limit. Nothing in this repo fixes it, and the owner has nothing to decide, so it is waited out and retried ([Unrepaired cases](#unrepaired-cases)). |
|
|
55
55
|
| `agent-course` (regen) | `ask` | The agent needs steering, which is the user's `muggle-feedback` call to make. |
|
|
56
56
|
| `unclassified` | `ask` | No bucket, no automatic action. |
|
|
57
57
|
|
|
58
|
+
**An outage overrides the bucket.** A run failed by an outage outside the repo — an API usage-limit or quota error, a provider down or overloaded on every run, the Muggle cloud unreachable — takes `wait` like `infra`, whatever its bucket. Retrying into the outage spends the iteration budget on nothing. An app that does not answer is Step 0's readiness halt, not this.
|
|
59
|
+
|
|
58
60
|
A `repair` disposition requires a named defect: the failing step, expected-versus-actual, and the code path it implicates. A `repair-test` disposition requires one too: the asserted state, the evidence the account lacks it (the frame, the record list), and the test-case change that would create it. Without one either is `ask`, whatever the bucket said.
|
|
59
61
|
|
|
60
62
|
**A failure the diff cannot explain may predate it.** When a `product-defect` or `product-uxux` failure names no code path the diff touched, replay the same test case against a checkout of the base before repairing anything: a worktree at the base tip's full SHA, with its own stack claim and services, under the same runSettings record. A change to the Studio itself needs a Studio build whose release manifest names a commit on the base: the run records that commit, and a build that names none cannot be credited. If that run fails the same way, its disposition is `baseline` — the defect is on the base, not this change's to fix — and the entry carries that run's id as `baselineRunId` into the walkthrough report ([`../muggle-pr-visual-walkthrough/e2e-report-assembly.md`](../muggle-pr-visual-walkthrough/e2e-report-assembly.md)). If it passes, the change caused the failure and the original disposition stands. A `baseline` entry is never re-run or waived; when every remaining failure is `baseline`, the loop clears.
|
|
@@ -67,12 +69,13 @@ An Inconclusive entry Stage 6 recorded as `primary failed` never executed either
|
|
|
67
69
|
|
|
68
70
|
## Step 3: Act
|
|
69
71
|
|
|
70
|
-
Process dispositions in order — `retry`, then `regenerate`, then `repair-test`, then `repair` — so cheap self-healing runs before any code change.
|
|
72
|
+
Process dispositions in order — `retry`, then `regenerate`, then `repair-test`, then `repair` — so cheap self-healing runs before any code change. After each job — a root cause found, a repair pushed, a re-run started or finished, a case left waiting — post the cycle's status per [`../muggle-pr-visual-walkthrough/SKILL.md`](../muggle-pr-visual-walkthrough/SKILL.md#cycle-progress), in the background.
|
|
71
73
|
|
|
72
74
|
- **`retry`** — re-execute the case unchanged through the Stage 6 loop. Re-bucket the result and fold it back into Step 2.
|
|
73
75
|
- **`regenerate`** — regenerate the script for that test case, then re-replay. One regeneration per test case per iteration, matching Stage 6's own cap.
|
|
74
76
|
- **`repair-test`** — update the test case with `muggle-remote-test-case-update` so it produces the state it asserts on: a setup step that creates the record, a seeded precondition, or a prerequisite test case it chains after. Keep the assertion as written — an edit that stops checking the behavior is not a repair. Then regenerate its script and re-run. No product code changes, so nothing is pushed.
|
|
75
77
|
- **`repair`** — re-enter [`build.md`](build.md) with the named defects as this iteration's requirements amendment, then run [`unit-tests.md`](unit-tests.md) and refresh the PR through [`open-prs/update.md`](open-prs/update.md). Impact analysis does not re-run; the change is scoped to a known defect.
|
|
78
|
+
- **`wait`** — nothing this pass; the case goes to [Unrepaired cases](#unrepaired-cases).
|
|
76
79
|
- **`ask`** — collect every `ask` failure and present **one** `AskUserQuestion` (Step 4). Never one picker per failure.
|
|
77
80
|
|
|
78
81
|
## Step 4: The user decision
|
|
@@ -86,7 +89,7 @@ One question, listing each unrepairable failure with its bucket, failing step, a
|
|
|
86
89
|
|
|
87
90
|
A case `state.md` already records as waived never reaches the question again.
|
|
88
91
|
|
|
89
|
-
**Unattended runs.** When the cycle was started autonomously there is nobody to ask, and nobody's waiver to record. Do not skip the loop — run Steps 1–3 in full, then leave a surviving `ask` as an **open decision**, never a waiver:
|
|
92
|
+
**Unattended runs.** When the cycle was started autonomously there is nobody to ask, and nobody's waiver to record. Do not skip the loop — run Steps 1–3 in full, then leave a surviving `ask` as an **open decision**, never a waiver, and every unrepaired case on the PR per [Unrepaired cases](#unrepaired-cases):
|
|
90
93
|
|
|
91
94
|
1. Write the decision into `state.md`, replacing any earlier one:
|
|
92
95
|
```
|
|
@@ -97,7 +100,7 @@ A case `state.md` already records as waived never reaches the question again.
|
|
|
97
100
|
```
|
|
98
101
|
2. Retitle the PR `[E2E FAILING]` and emit the escalation event.
|
|
99
102
|
3. End the turn's final message with the decision request — one line per case naming its bucket, then the four options.
|
|
100
|
-
4. Clear to Stage 8 as `decision-pending
|
|
103
|
+
4. Clear to Stage 8 as `decision-pending` — or `waiting` when every unrepaired case is a `wait`, which writes no decision. The armed watcher sees the walkthrough check red, fix-ci finds this decision or wait for the head and escalates without repeating the repair, and the watcher's blocked reminder carries the cases and options until the user answers.
|
|
101
104
|
|
|
102
105
|
A readiness halt (Step 0) is not an `ask` and never becomes a decision. Silently arming the watcher on a red run, or waiving one nobody looked at, is the failure this stage exists to prevent.
|
|
103
106
|
|
|
@@ -111,6 +114,22 @@ After a `repair`, `repair-test`, `regenerate`, or `retry` pass, re-run [`e2e-acc
|
|
|
111
114
|
|
|
112
115
|
The loop is bounded at **3** repair iterations, the same bound the cycle guardrail already applies to E2E failures. On the third exhausted iteration, the surviving failures go to Step 4 as `ask`, each with its last bucket — the question when attended, the open decision when not.
|
|
113
116
|
|
|
117
|
+
## Unrepaired cases
|
|
118
|
+
|
|
119
|
+
A failing case is repaired by default. Leaving one unrepaired takes a strong reason, and there are three, each a `repairHold.kind` in the walkthrough report:
|
|
120
|
+
|
|
121
|
+
| Kind | Reason | Unblocked by |
|
|
122
|
+
| :--- | :----- | :----------- |
|
|
123
|
+
| `temporary-blocker` | Runner or provider infrastructure outside the repo — a provider down, an API usage limit or quota, the Muggle cloud or runner failing — failed the runs or the repair (disposition `wait`). | The blocker clearing. The repair resumes on its own. |
|
|
124
|
+
| `owner-decision` | A call only the owner can make: design or product direction, an `agent-course` steer, an unclassified failure (disposition `ask`). | The owner's answer to the decision. |
|
|
125
|
+
| `budget-spent` | The repair budget ran out with the case still failing — Step 5's 3 iterations, or fix-ci's per-head cycles. | The owner's direction, or a new push. |
|
|
126
|
+
|
|
127
|
+
Anything else is not a reason: repair the case.
|
|
128
|
+
|
|
129
|
+
**The PR says why.** A cycle that leaves any case unrepaired settles the walkthrough comment before it ends, through [`../muggle-pr-visual-walkthrough/SKILL.md`](../muggle-pr-visual-walkthrough/SKILL.md) Mode A, each unrepaired entry carrying `repairHold` ([`../muggle-pr-visual-walkthrough/e2e-report-assembly.md`](../muggle-pr-visual-walkthrough/e2e-report-assembly.md)): its `bucket` and `rootCause`, the `kind`, the `reason` it is not being fixed now, and `unblockedBy` — e.g. `Anthropic usage limit until 2026-11-16 09:00 UTC; repair resumes automatically`. The report is the cycle's latest run, else the walkthrough's runs reassembled from its hidden record. A `state.md` entry or a session message is not enough: the PR's reader sees failures and no reason. Never leave the report silent.
|
|
130
|
+
|
|
131
|
+
**A temporary blocker is a wait, not a stop.** It never becomes a decision request; the owner has nothing to decide. Record it in `last_seen.ci_wait` ([`../muggle-pr-followup/state-schemas.md`](../muggle-pr-followup/state-schemas.md#last_seenjson)): `head_sha`, the blocker as `reason`, and `retry_at` — the reset time the provider's error names, else one hour from now. When `retry_at` passes, the watcher re-dispatches the repair with no prompt from anyone. An `owner-decision` or `budget-spent` case stays escalated under the watcher's one-reminder rule.
|
|
132
|
+
|
|
114
133
|
## Telemetry
|
|
115
134
|
|
|
116
135
|
Steps 1–3 emit the `*-classified` / `*-resolved` pair per [`../_shared/failure-mode-handling.md`](../_shared/failure-mode-handling.md) section D, with `userAction` set to the disposition this stage took (`repair`, `repair-test`, `regenerate`, `retry`) rather than a human pick. A failure that reaches Step 4 records the user's actual choice.
|
|
@@ -126,12 +145,14 @@ Every waive the user picked, and every open decision left for them, also emits `
|
|
|
126
145
|
**Regenerated:** test case → new script id
|
|
127
146
|
**Waived:** test case → bucket → the user's words
|
|
128
147
|
**Decision pending:** test case → bucket → failing step
|
|
148
|
+
**Waiting:** test case → blocker → retry time
|
|
129
149
|
**Verdict out:** `<verdict after the final re-run>`
|
|
130
|
-
**Clearance:** `green` | `waived — <reason>` | `decision-pending`
|
|
150
|
+
**Clearance:** `green` | `waived — <reason>` | `decision-pending` | `waiting`
|
|
131
151
|
|
|
132
152
|
## Invariants
|
|
133
153
|
|
|
134
|
-
- Stage 8 is unreachable while clearance is unresolved — the only exits are green, waived by the user,
|
|
154
|
+
- Stage 8 is unreachable while clearance is unresolved — the only exits are green, waived by the user, decision-pending, or waiting.
|
|
155
|
+
- No case is left unrepaired without one of the three reasons in [Unrepaired cases](#unrepaired-cases), stated on the PR's walkthrough.
|
|
135
156
|
- No waiver without the user's own pick or words; an unattended run or a spent iteration budget leaves a decision, never a waiver.
|
|
136
157
|
- No bucket auto-repairs without a named defect; `repair-test` changes the test case, never product code.
|
|
137
158
|
- One `AskUserQuestion` per stage run, never one per failure.
|
|
@@ -30,6 +30,8 @@ From `~/.muggle-ai/muggle-do/sessions/<slug>/`: `prs.json` (PR + local checkout
|
|
|
30
30
|
|
|
31
31
|
Check out the PR branch in the session's working tree (per `state.md`). Capture `red_sha = prs.json[0].head_sha` — this cycle's `pre_cycle_sha` ([`cycle-size.md`](cycle-size.md)).
|
|
32
32
|
|
|
33
|
+
**A due repair wait.** When `last_seen.ci_wait` names `red_sha` and its `retry_at` has passed, the watcher dispatched this cycle to resume a repair a temporary blocker stopped ([`e2e-repair.md`](e2e-repair.md#unrepaired-cases)). Before the increment, in one whole-file rewrite: delete `ci_wait`, drop `red_sha` from `ci_escalated_shas`, and set `ci_fix_attempts[red_sha]` to 0 — the blocker, not a failed repair, spent those attempts.
|
|
34
|
+
|
|
33
35
|
Then increment `last_seen.ci_fix_attempts[red_sha]` — before any fix, re-run or escalation, as a whole-file rewrite (Read → change field → Write) per [`../_shared/session-state-writes.md`](../_shared/session-state-writes.md), never the Edit tool. Every dispatched cycle is an attempt, including one that only re-runs a check or escalates without pushing. That count is the only record the watcher and its turn-end gate accept that this red head was acted on; an escalation written without it is ignored and fix-ci is dispatched again ([`../muggle-pr-followup/state-schemas.md`](../muggle-pr-followup/state-schemas.md#last_seenjson)).
|
|
34
36
|
|
|
35
37
|
The increment opens a cycle this turn carries through Step 5 or Step 6 — it never stands in for one. The single exception is a red `muggle-walkthrough` whose E2E run for **this** PR is already queued or running (its `state.md` shows `E2E dispatch: queued` or `running`): that run is the cycle, and its report settles the comment. Writing the count for a PR with no such run, or because another PR's run is in flight, clears the turn-end gate while the PR stays red; the watch never asks again until the head moves, and the PR can merge red.
|
|
@@ -46,12 +48,14 @@ How long a check takes to run — a 45-minute eval included — is never a reaso
|
|
|
46
48
|
|
|
47
49
|
The check run's summary says which red this is ([`../_shared/ci-check-to-command.md`](../_shared/ci-check-to-command.md)): **did not pass** — the walkthrough reports failed or inconclusive cases — takes items 1–5; **still empty** — no walkthrough posted — takes the empty-comment branch below. A walkthrough whose E2E run is in progress keeps the check pending, never red.
|
|
48
50
|
|
|
49
|
-
1. **Read why.** Fetch the check run's summary per [`../_shared/vcs/github/pr-checks.md`](../_shared/vcs/github/pr-checks.md) and record its `completed_at`. It names every failed or inconclusive case, its failing step, and its run. Take the test case ids from the walkthrough comment's hidden `<!-- muggle-e2e-result:v1 {…} -->` record — the newest comment carrying one. A comment settled by a `NO_APP_LOGIC_CHANGE` skip — a rebase or a minor cycle on this head — carries the last full run beneath it, and its failures stand: the skip clears nothing, so they take this same path. Drop every case `state.md` records as `E2E waived:`; if none remain, go to Step 6.
|
|
50
|
-
2. **Repair each case** per [`e2e-repair.md`](e2e-repair.md) Steps 1–3: root-cause to a bucket, then retry, regenerate, repair the test (`test-precondition`), or repair the code. This stage is unattended, so a case whose disposition is `ask` is recorded for Step 6 with its bucket and failing step — never a picker, never a waiver.
|
|
51
|
+
1. **Read why.** Fetch the check run's summary per [`../_shared/vcs/github/pr-checks.md`](../_shared/vcs/github/pr-checks.md) and record its `completed_at`. It names every failed or inconclusive case, its failing step, and its run. Take the test case ids from the walkthrough comment's hidden `<!-- muggle-e2e-result:v1 {…} -->` record — the newest comment carrying one. A comment settled by a `NO_APP_LOGIC_CHANGE` skip — a rebase or a minor cycle on this head — carries the last full run beneath it, and its failures stand: the skip clears nothing, so they take this same path. Drop every case `state.md` records as `E2E waived:`; if none remain, go to Step 6. Drop the cases `state.md`'s `## E2E decision` lists for this head too: the repair already ran on them and the user owes the answer. If none remain, go to Step 6. A `last_seen.ci_wait` on this head whose `retry_at` has not passed means its blocker still holds: go to Step 6.
|
|
52
|
+
2. **Repair each case** per [`e2e-repair.md`](e2e-repair.md) Steps 1–3: root-cause to a bucket, then retry, regenerate, repair the test (`test-precondition`), or repair the code. This stage is unattended, so a case whose disposition is `ask` is recorded for Step 6 with its bucket and failing step — never a picker, never a waiver. A `wait` case is recorded for Step 6 with its blocker.
|
|
51
53
|
3. **Re-run the whole suite** through [`e2e-acceptance.md`](e2e-acceptance.md) — every test case the walkthrough listed, passing ones included. The walkthrough is replaced wholesale and the check judges all of it, so a re-run scoped to the failures would post a walkthrough that drops the cases that passed.
|
|
52
54
|
4. **Order the settle after the push.** If Step 2 changed code, run Steps 3–4 below first, so the new head carries the fix. Then settle the walkthrough comment with the re-run's report via [`../muggle-pr-visual-walkthrough/SKILL.md`](../muggle-pr-visual-walkthrough/SKILL.md) Mode A; editing the comment re-runs the check against the head. With no code change (only retries and regenerations) there is nothing to push — the comment edit alone re-runs the check.
|
|
53
55
|
5. **Wait for the fresh verdict** before Step 5's respawn: poll the check run until one completes later than the `completed_at` recorded in item 1, for up to 5 minutes. A watcher respawned sooner reads the stale red verdict and spends a fix attempt on a run already repaired. On timeout, respawn anyway — the per-SHA budget still bounds it.
|
|
54
56
|
|
|
57
|
+
After each job in items 1–4, post the cycle's status per [`../muggle-pr-visual-walkthrough/SKILL.md`](../muggle-pr-visual-walkthrough/SKILL.md#cycle-progress), in the background — never waiting on it. A cycle that ends in Step 6 posts it once more, blocked or waiting.
|
|
58
|
+
|
|
55
59
|
An empty-comment failure (no run ever posted) skips items 1–2. Pick the branch from `state.md`:
|
|
56
60
|
|
|
57
61
|
- **This PR's E2E run queued or running** (`E2E dispatch: queued` or `running`) → wait: that run posts the walkthrough, and the Step 1 exception covers this cycle. Never run a second suite or write into the comment the walkthrough builder is about to fill.
|
|
@@ -90,12 +94,14 @@ Respawn the watcher per [`respawn-watcher.md`](respawn-watcher.md). CI on the ne
|
|
|
90
94
|
|
|
91
95
|
### Step 6 — Escalate (budget spent or out of scope)
|
|
92
96
|
|
|
93
|
-
When the failing checks are all out of scope, a non-deterministic check is red again after its re-run on this head (Step 2.6), Step 2.5 left a walkthrough case it could not repair (an `ask`, an open decision on this head, or only waived cases), this is the head's third cycle (`ci_fix_attempts[red_sha]` reached 3 in Step 1) and it could not push a fix, or Step 1 found the budget already spent:
|
|
97
|
+
When the failing checks are all out of scope, a non-deterministic check is red again after its re-run on this head (Step 2.6), Step 2.5 left a walkthrough case it could not repair (an `ask`, a `wait`, an open decision on this head, or only waived cases), this is the head's third cycle (`ci_fix_attempts[red_sha]` reached 3 in Step 1) and it could not push a fix, or Step 1 found the budget already spent:
|
|
94
98
|
|
|
95
99
|
1. Add `red_sha` to `last_seen.ci_escalated_shas` so the SHA is not re-fixed. This cycle's Step 1 attempt is what makes the entry count.
|
|
96
|
-
2. Emit one terminal message naming the unresolved checks. When `muggle-walkthrough` is among them with cases not waived, the message is the E2E decision request instead — per [`e2e-repair.md`](e2e-repair.md) Step 4's unattended form: each case with its bucket and failing step, then the four options (repair with direction, feedback and rerun, waive, stop). Write that decision to `state.md`'s `## E2E decision` block, and the same cases to `last_seen.e2e_decision` (`head_sha` plus one `{name, testCaseId, bucket, failedStep}` per case, whole-file rewrite) — the watcher's blocked reminder reads it to put the decision in front of the owner. Only waived cases left → `last_seen.e2e_decision` lists them with `waived: true`, and no question is asked again.
|
|
97
|
-
3.
|
|
98
|
-
4. **
|
|
100
|
+
2. Emit one terminal message naming the unresolved checks. When `muggle-walkthrough` is among them with `ask` cases not waived, the message is the E2E decision request instead — per [`e2e-repair.md`](e2e-repair.md) Step 4's unattended form: each case with its bucket and failing step, then the four options (repair with direction, feedback and rerun, waive, stop). Write that decision to `state.md`'s `## E2E decision` block, and the same cases to `last_seen.e2e_decision` (`head_sha` plus one `{name, testCaseId, bucket, failedStep}` per case, whole-file rewrite) — the watcher's blocked reminder reads it to put the decision in front of the owner. Only waived cases left → `last_seen.e2e_decision` lists them with `waived: true`, and no question is asked again.
|
|
101
|
+
3. **Waiting cases** — a temporary blocker stopped them, so write `last_seen.ci_wait` per [`e2e-repair.md`](e2e-repair.md#unrepaired-cases) in the same whole-file rewrite, and no decision. The terminal message names the blocker and when the repair resumes; with only waiting cases it asks nothing.
|
|
102
|
+
4. **Settle the walkthrough** whenever `muggle-walkthrough` stays red, the spent-budget path included: every unrepaired case carries its `repairHold` per [`e2e-repair.md`](e2e-repair.md#unrepaired-cases) — `temporary-blocker` for a wait, `owner-decision` for an `ask`, `budget-spent` for a head whose budget ran out.
|
|
103
|
+
5. Emit the cycle event with `outcome: "ci-escalated"` (Step 7).
|
|
104
|
+
6. **Respawn the watcher** per [`respawn-watcher.md`](respawn-watcher.md). Escalation stops fix-ci from re-dispatching this SHA — but the poller must keep running: it reminds on the `ci_escalated` block and catches a new push, a new review, or the user's own fix. Skipping respawn here is the silent-stop bug the helper exists to prevent.
|
|
99
105
|
|
|
100
106
|
### Step 7 — Telemetry
|
|
101
107
|
|
|
@@ -104,6 +110,6 @@ Emit one `muggle-do:cycle` event ([`../_shared/telemetry-events/muggle-do-cycle.
|
|
|
104
110
|
## Guardrails
|
|
105
111
|
|
|
106
112
|
- Max 3 fix attempts per SHA; out-of-scope checks escalate immediately rather than churn. A walkthrough repair or a re-run that pushes nothing keeps the head SHA, so the same budget bounds it.
|
|
107
|
-
- A red walkthrough never ends silent or self-waived: it is repaired, or
|
|
113
|
+
- A red walkthrough never ends silent or self-waived: it is repaired, waits on a temporary blocker the watcher retries on its own, or escalates with a decision request the watcher keeps in front of the owner — and the PR's walkthrough names why for every case left unrepaired. Only the user's own words waive a case.
|
|
108
114
|
- A non-deterministic check is re-run once per head before it escalates — never escalated on its first red, never re-run twice on one head.
|
|
109
115
|
- No PR replies; the fix commit is the response.
|
|
@@ -38,7 +38,7 @@ The `DRAIN` lines it prints, in the watch's output, are the outstanding work as
|
|
|
38
38
|
|
|
39
39
|
**Never author a per-slot `watch.sh`.** The loop ships as [`../../scripts/pr-watch-loop.sh`](../../scripts/pr-watch-loop.sh), with its wake conditions in [`../../scripts/pr-watch-events.sh`](../../scripts/pr-watch-events.sh) and its state projection in [`../../scripts/pr-watch-state.jq`](../../scripts/pr-watch-state.jq); arming runs it and passes arguments. Writing the loop from this prose was how it drifted — each arm produced an independent derivation, and a derivation that quietly dropped a wake still ran, still heartbeat, still logged, and simply never fired for the signal it lost. Two slots on one machine ended up without the behind-base wake, which left their PRs unmergeable under watchers that looked healthy. The prose below says *why* each wake exists; the shipped files are the only definition of *what* fires. A slot holding a legacy generated `watch.sh` keeps it until re-armed, at which point the supersede guard retires the old loop.
|
|
40
40
|
|
|
41
|
-
The task's description is `PR #<n> — <title>`. Description and command both matter: some task surfaces show one, some the other, and a slot-bearing command keeps the watch identifiable everywhere a raw script blob would not. One background task per PR at a time: it is the watch's visible handle, showing as a running task while the PR is polled, and replaced by a fresh one after each report. Its loop checks about every 60 seconds, re-reading the watermark and touching the slot's `watch-heartbeat` file each iteration — the liveness beacon that tells [`reconcile.md`](reconcile.md) a quiet watch is still alive; on a newer submitted review, a newer thread comment (`gitlab`: a newer discussion note), a newer human conversation comment (`github`: a top-level PR comment muggle did not post and no bot wrote), a thread newly unresolved (`gitlab`: discussion), **the head SHA's checks settling red** (no check pending and one or more in the `fail` bucket per [`../_shared/vcs/common/ci-rollup.md`](../_shared/vcs/common/ci-rollup.md)), **the branch falling behind or conflicting with its base** (`behind_by > 0` or the conflict signal per [`../_shared/vcs/common/branch-standing.md`](../_shared/vcs/common/branch-standing.md)), or — **only while the watch is blocked** (`BLOCKED_CIDIGEST` non-empty) — **the head's CI digest changing in any way** (not just to red) — it prints one line per finding and **exits**, recording what it reported in `watch-reported.env` ([`state-schemas.md`](state-schemas.md#watch-reportedenv)) so no later loop reports the same occurrence again. The review, comment, conversation and thread floors are monotonic ids; the other three are not. The CI-red floor is the **red key** — the head SHA plus each failed check's run id — because the check rollup is non-monotonic: it flips green↔red and resets on every push, so the key fires once per red verdict and a later push re-arms it on the new SHA. The run ids matter because a settled walkthrough comment or a rerun publishes a new run on the same head; when that run is red too, it is the verdict fix-ci is waiting on, and a head-only floor swallowed it. The rebase floor (`REBASED`) is the **`rebase_key`** — `<head_sha>..<base_tip_sha>` — because staleness is a function of both sides: keying on the pair fires once per newly-due pair and re-arms when either the head or the base moves, where a head-only key would wedge permanently the first time the base advances (the head cannot change while nobody pushes). A head whose checks are still **pending** is never a red wake, and a branch with `behind_by == 0` and `mergeable == UNKNOWN` is never a rebase wake: pending checks may yet go green and conflict state is still computing, and the tick would idle on either (Steps 5–6) regardless. The blocked-CI signal is different in kind — a **resume** probe, live only while the watch is blocked: it wakes on any move of the head's CI digest (the same bucket-plus-sorted-name/conclusion signature the blocked fingerprint records — [`blocked-tick.md`](blocked-tick.md)) away from `BLOCKED_CIDIGEST`, so a block waiting on a green pass, a rerun, or an external deploy check resumes as promptly as one waiting on red. Quiet iterations print nothing and cost nothing — no model tokens are spent while the watch is quiet.
|
|
41
|
+
The task's description is `PR #<n> — <title>`. Description and command both matter: some task surfaces show one, some the other, and a slot-bearing command keeps the watch identifiable everywhere a raw script blob would not. One background task per PR at a time: it is the watch's visible handle, showing as a running task while the PR is polled, and replaced by a fresh one after each report. Its loop checks about every 60 seconds, re-reading the watermark and touching the slot's `watch-heartbeat` file each iteration — the liveness beacon that tells [`reconcile.md`](reconcile.md) a quiet watch is still alive; on a newer submitted review, a newer thread comment (`gitlab`: a newer discussion note), a newer human conversation comment (`github`: a top-level PR comment muggle did not post and no bot wrote), a thread newly unresolved (`gitlab`: discussion), **the head SHA's checks settling red** (no check pending and one or more in the `fail` bucket per [`../_shared/vcs/common/ci-rollup.md`](../_shared/vcs/common/ci-rollup.md)), **the branch falling behind or conflicting with its base** (`behind_by > 0` or the conflict signal per [`../_shared/vcs/common/branch-standing.md`](../_shared/vcs/common/branch-standing.md)), or — **only while the watch is blocked** (`BLOCKED_CIDIGEST` non-empty) — **the head's CI digest changing in any way** (not just to red), or **a repair wait's `CI_RETRY_AT` passing** ([`state-schemas.md`](state-schemas.md#watch-watermarkenv)) — it prints one line per finding and **exits**, recording what it reported in `watch-reported.env` ([`state-schemas.md`](state-schemas.md#watch-reportedenv)) so no later loop reports the same occurrence again. The review, comment, conversation and thread floors are monotonic ids; the other three are not. The CI-red floor is the **red key** — the head SHA plus each failed check's run id — because the check rollup is non-monotonic: it flips green↔red and resets on every push, so the key fires once per red verdict and a later push re-arms it on the new SHA. The run ids matter because a settled walkthrough comment or a rerun publishes a new run on the same head; when that run is red too, it is the verdict fix-ci is waiting on, and a head-only floor swallowed it. The rebase floor (`REBASED`) is the **`rebase_key`** — `<head_sha>..<base_tip_sha>` — because staleness is a function of both sides: keying on the pair fires once per newly-due pair and re-arms when either the head or the base moves, where a head-only key would wedge permanently the first time the base advances (the head cannot change while nobody pushes). A head whose checks are still **pending** is never a red wake, and a branch with `behind_by == 0` and `mergeable == UNKNOWN` is never a rebase wake: pending checks may yet go green and conflict state is still computing, and the tick would idle on either (Steps 5–6) regardless. The blocked-CI signal is different in kind — a **resume** probe, live only while the watch is blocked: it wakes on any move of the head's CI digest (the same bucket-plus-sorted-name/conclusion signature the blocked fingerprint records — [`blocked-tick.md`](blocked-tick.md)) away from `BLOCKED_CIDIGEST`, so a block waiting on a green pass, a rerun, or an external deploy check resumes as promptly as one waiting on red. Quiet iterations print nothing and cost nothing — no model tokens are spent while the watch is quiet.
|
|
42
42
|
|
|
43
43
|
Each poll also rewrites the slot's `watch-due.env` whenever the due work changes — the rebase key found due, the head whose checks settled red, and the unhandled feedback the arm recorded, or an empty file when none — so the session's turn-end gate can see work the watch reported without a provider call ([`state-schemas.md`](state-schemas.md#watch-dueenv)).
|
|
44
44
|
|
|
@@ -35,11 +35,13 @@ Every subsequent tick while `last_seen.blocked` is present: recompute the finger
|
|
|
35
35
|
- **Unchanged** → still blocked. Stay **silent** — the reminder went out when the block was flagged. Increment `last_seen.idle_tick_count`, append a `blocked reason=<reason>` line to `followup.log`, emit a `tick` event with `idle: true`, `blocked: true`. Exit.
|
|
36
36
|
`reason: "rebase_budget_exhausted"` is the one exception to the gate: treat it as **Unchanged** whatever the fingerprint says. The budget was spent by the base advancing, so resuming on a fingerprint move would hand the PR straight back into the unbounded rebase loop the cap exists to end. It clears only when the owner raises [`maxCatchUpRebases`](../muggle-preferences/preference-gates/maxCatchUpRebases.md) or the PR goes terminal.
|
|
37
37
|
|
|
38
|
+
A `ci_escalated` block whose head carries a `last_seen.ci_wait` ([`state-schemas.md`](state-schemas.md#last_seenjson)) waits on a temporary blocker, not on the owner: once its `retry_at` has passed, treat the tick as **Changed** whatever the fingerprint says. The loop's retry wake brings that tick on time, and the verdict then dispatches the repair.
|
|
39
|
+
|
|
38
40
|
- **Changed** → clear `last_seen.blocked`, clear the watch-watermark's `BLOCKED_CIDIGEST` to empty (whole-file rewrite — disarms the loop's blocked-resume probe now that the watch is unblocked), and **fall through to [`contract.md`](contract.md) Step 3** to re-evaluate against the moved state this same tick: a dispatch hands the PR to the cycle (its exit settles the watch); a transient idle changes nothing; idling back into a block re-flags per Step 7 — a new block, which sends its own single reminder (and re-arms `BLOCKED_CIDIGEST` afresh).
|
|
39
41
|
|
|
40
42
|
## Invariants
|
|
41
43
|
|
|
42
44
|
- One reminder per block — sent when flagged, never repeated while the same block holds. A re-flag after a resume is a new block and sends its own single reminder.
|
|
43
45
|
- The watch never stops — a blocked PR stays visibly watched at the normal `1m` cadence; only a terminal PR or an explicit teardown ends it.
|
|
44
|
-
- The block clears the instant any fingerprint component moves, caught at the next wake or tick — except `rebase_budget_exhausted`, which only the owner clears.
|
|
46
|
+
- The block clears the instant any fingerprint component moves, caught at the next wake or tick — except `rebase_budget_exhausted`, which only the owner clears. A repair wait clears it on its own when its `retry_at` passes.
|
|
45
47
|
- The blocked path never posts to the PR.
|