claude-code-session-manager 0.139.0 → 0.141.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -4
- package/dist/assets/AppSettings-DExeJhqQ.js +2 -0
- package/dist/assets/History-DJMiuXyK.js +2 -0
- package/dist/assets/{HomeClaudeConfig-CGD2Onjv.js → HomeClaudeConfig-CTp2tkZ4.js} +2 -2
- package/dist/assets/{Panel-Csyd9HbD.js → Panel-Bf1Cf8UL.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-C-jlYpC_.js → ProjectClaudeConfig-BWPpypf9.js} +1 -1
- package/dist/assets/Scheduler-cyr61UAC.js +16 -0
- package/dist/assets/{SkillReferenceGraph-DcscPXAG.js → SkillReferenceGraph-Ba4TkX2C.js} +1 -1
- package/dist/assets/{Skills-BpGRKOcY.js → Skills-C1v91GEO.js} +26 -26
- package/dist/assets/{TiptapBody-DSU3769X.js → TiptapBody-BrcWVpiW.js} +1 -1
- package/dist/assets/{ViewTabs-C0PRZx4_.js → ViewTabs-DXhOWFG0.js} +1 -1
- package/dist/assets/{VoiceButton-D2rMurNg.js → VoiceButton-qivnDV6K.js} +1 -1
- package/dist/assets/{historyTotals-TcIQs2sh.js → historyTotals-CMCPTKqC.js} +1 -1
- package/dist/assets/index-B2TQz3nd.js +3121 -0
- package/dist/assets/{index-BCySPdtU.css → index-DKXdXfka.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +423 -426
- package/package.json +5 -2
- package/plugins/AGENTS.md +60 -0
- package/plugins/CLAUDE.md +1 -60
- package/plugins/session-manager-dev/skills/builder/SKILL.md +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +29 -19
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +5 -4
- package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +4 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +16 -12
- package/plugins/session-manager-dev/skills/maintaining-md-network/migrate-to-agents-md.md +15 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +50 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +10 -10
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +117 -112
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdDuplicates.cjs +182 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs +340 -0
- package/scripts/README.md +1 -0
- package/scripts/hooks/guard-tool-risk.cjs +91 -0
- package/scripts/hooks/lib/guard-tool-risk-policy.cjs +217 -0
- package/scripts/ops-sweep.cjs +53 -23
- package/scripts/scheduler-mcp-server.cjs +205 -18
- package/src/main/build-info.json +4 -4
- package/src/main/config.cjs +112 -8
- package/src/main/docEdit.cjs +6 -1
- package/src/main/files.cjs +7 -27
- package/src/main/health.cjs +48 -15
- package/src/main/historyAggregator.cjs +88 -5
- package/src/main/historyDashboard.cjs +69 -4
- package/src/main/index.cjs +56 -2
- package/src/main/ipcSchemas.cjs +122 -16
- package/src/main/lib/AGENTS.md +54 -0
- package/src/main/lib/CLAUDE.md +1 -54
- package/src/main/lib/agent-cli/adapters/codex.cjs +5 -2
- package/src/main/lib/agent-cli/agentCliIpc.cjs +18 -2
- package/src/main/lib/agent-cli/agentCliSessionStore.cjs +1 -0
- package/src/main/lib/agent-cli/agentCliTurn.cjs +20 -2
- package/src/main/lib/agent-cli/geminiContextDefaults.cjs +94 -0
- package/src/main/lib/claude/effectiveModelInfo.cjs +90 -20
- package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -0
- package/src/main/lib/claude/personaToolScope.cjs +12 -6
- package/src/main/lib/claude/rateLimitDetect.cjs +13 -2
- package/src/main/lib/claude/runClaudeP.cjs +6 -1
- package/src/main/lib/claude/toolRiskIpc.cjs +177 -0
- package/src/main/lib/claude/toolRiskMarks.cjs +373 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +27 -6
- package/src/main/lib/ephemeralCwd.cjs +37 -2
- package/src/main/lib/epic/delegationReadiness.cjs +42 -9
- package/src/main/lib/epic/epicAdminRoutes.cjs +25 -5
- package/src/main/lib/epic/epicOutsideRead.cjs +118 -1
- package/src/main/lib/epic/epicOutsideState.cjs +2 -2
- package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
- package/src/main/lib/epic/epicValidationHook.cjs +24 -4
- package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
- package/src/main/lib/externalContract.cjs +31 -5
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +55 -1
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +106 -11
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +47 -19
- package/src/main/lib/feedback-remote/needsYouStore.cjs +6 -2
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +98 -1
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +5 -0
- package/src/main/lib/git/branchSweep.cjs +209 -4
- package/src/main/lib/git/gitWorktree.cjs +41 -5
- package/src/main/lib/guardShims.cjs +1 -1
- package/src/main/lib/historyRollup.cjs +26 -0
- package/src/main/lib/insideHome.cjs +27 -1
- package/src/main/lib/mcpToolCatalog.cjs +132 -13
- package/src/main/lib/mdDocCensus.cjs +59 -78
- package/src/main/lib/mdDocRefs.cjs +71 -93
- package/src/main/lib/mdNetworkScan.cjs +245 -250
- package/src/main/lib/mdReviewRecord.cjs +22 -9
- package/src/main/lib/memoryMdNetwork.cjs +5 -12
- package/src/main/lib/opsOwnership.cjs +18 -2
- package/src/main/lib/opsRetentionSettings.cjs +28 -4
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +90 -20
- package/src/main/lib/persona-macro/macroJobIpc.cjs +144 -46
- package/src/main/lib/persona-macro/macroJobStatus.cjs +87 -9
- package/src/main/lib/persona-macro/macroLibrary.cjs +95 -5
- package/src/main/lib/persona-macro/personaImportHealth.cjs +78 -17
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +96 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
- package/src/main/lib/prd/depSlugResolve.cjs +104 -4
- package/src/main/lib/prd/prdAdminRoutes.cjs +35 -2
- package/src/main/lib/prd/prdCreate.cjs +377 -23
- package/src/main/lib/prd/prdDisposition.cjs +11 -2
- package/src/main/lib/prd/prdFrontmatter.cjs +121 -3
- package/src/main/lib/process/loginItem.cjs +171 -0
- package/src/main/lib/process/loginItemPlan.cjs +193 -0
- package/src/main/lib/project-pages/playerBridge.cjs +4 -0
- package/src/main/lib/project-pages/videoReview.cjs +268 -0
- package/src/main/lib/project-pages/videoReviewIpc.cjs +229 -0
- package/src/main/lib/scheduler/cpuSample.cjs +131 -4
- package/src/main/lib/scheduler/fixPlanSlug.cjs +4 -3
- package/src/main/lib/scheduler/loadGate.cjs +24 -6
- package/src/main/lib/scheduler/planRecordHarvest.cjs +108 -0
- package/src/main/lib/scheduler/planRecordRetention.cjs +144 -0
- package/src/main/lib/scheduler/preflightCheck.cjs +97 -0
- package/src/main/lib/scheduler/queueStore.cjs +7 -0
- package/src/main/lib/scheduler/rcaReport.cjs +21 -1
- package/src/main/lib/scheduler/reaperHelpers.cjs +35 -5
- package/src/main/lib/scheduler/reviewNotice.cjs +39 -0
- package/src/main/lib/scheduler/runLogRetention.cjs +104 -3
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
- package/src/main/lib/scheduler/schedulerBatch.cjs +25 -48
- package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
- package/src/main/lib/scheduler/sessionSlots.cjs +176 -21
- package/src/main/lib/scheduler/validationQuality.cjs +282 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +254 -0
- package/src/main/lib/tasks/taskAdminRoutes.cjs +641 -0
- package/src/main/lib/tasks/taskIpc.cjs +80 -0
- package/src/main/lib/tasks/taskLedger.cjs +502 -0
- package/src/main/lib/tasks/taskRun.cjs +313 -0
- package/src/main/lib/tasks/taskSwitch.cjs +120 -0
- package/src/main/loginItemIpc.cjs +35 -0
- package/src/main/loopEfficiencyHandlers.cjs +10 -1
- package/src/main/projectPages.cjs +6 -15
- package/src/main/promptSessionEvents.cjs +9 -1
- package/src/main/queueOps.cjs +260 -3
- package/src/main/runVerify.cjs +53 -25
- package/src/main/scheduler/AGENTS.md +26 -0
- package/src/main/scheduler/CLAUDE.md +1 -26
- package/src/main/scheduler/budget.cjs +239 -9
- package/src/main/scheduler/cancelDependents.cjs +154 -0
- package/src/main/scheduler/prdParser.cjs +19 -1
- package/src/main/scheduler/reviewLadder.cjs +36 -3
- package/src/main/scheduler/starvation.cjs +89 -18
- package/src/main/scheduler.cjs +1080 -89
- package/src/main/supervisor.cjs +5 -1
- package/src/main/templates/PRD_AUTHORING.md +14 -1
- package/src/main/validationQualityHandlers.cjs +199 -0
- package/src/main/webRemote.cjs +10 -2
- package/src/preload/api.d.ts +364 -21
- package/src/preload/apiSurface.json +89 -10
- package/src/preload/index.cjs +23 -2
- package/src/seed/agents/validator.md +19 -8
- package/dist/assets/AppSettings-CUfWY9vN.js +0 -2
- package/dist/assets/History-DDnqaLyw.js +0 -2
- package/dist/assets/Scheduler-NLs08fx7.js +0 -16
- package/dist/assets/index-C-d0DCre.js +0 -3124
|
@@ -6,13 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
+
const crypto = require('node:crypto');
|
|
9
10
|
const fsp = require('node:fs/promises');
|
|
10
11
|
const path = require('node:path');
|
|
11
12
|
const { claudePidAlive } = require('../lib/scheduler/reaperHelpers.cjs');
|
|
12
13
|
const queueHistory = require('../lib/scheduler/queueHistory.cjs');
|
|
13
14
|
const { listArchivedPrdDirs } = require('../lib/prd/prdLocations.cjs');
|
|
14
15
|
const { LEGAL_TRANSITIONS } = require('../lib/scheduler/scheduleJobTransitions.cjs');
|
|
15
|
-
const {
|
|
16
|
+
const {
|
|
17
|
+
DEFAULT_PROJECT_CWD, DEP_HISTORY_FAIL_OPEN, enqueueTimestamp, findBlockingDep,
|
|
18
|
+
} = require('../lib/scheduler/schedulerBatch.cjs');
|
|
19
|
+
const { makeDepResolver, isCancelledRow, isSatisfiedDepRow } = require('../lib/prd/depSlugResolve.cjs');
|
|
16
20
|
const {
|
|
17
21
|
JOB_OVERRUN_FACTOR: JOB_OVERRUN_FACTOR_DEFAULT,
|
|
18
22
|
JOB_OVERRUN_FLOOR_MS: JOB_OVERRUN_FLOOR_MS_DEFAULT,
|
|
@@ -39,6 +43,19 @@ const JOB_BUDGET_FACTOR = numEnvOverride('SM_JOB_BUDGET_FACTOR', 1, JOB_BUDGET_F
|
|
|
39
43
|
const JOB_BUDGET_FLOOR_MS = numEnvOverride('SM_JOB_BUDGET_FLOOR_MINUTES', 60_000, JOB_BUDGET_FLOOR_MS_DEFAULT);
|
|
40
44
|
const JOB_BUDGET_CEILING_MS = numEnvOverride('SM_JOB_BUDGET_CEILING_MINUTES', 60_000, JOB_BUDGET_CEILING_MS_DEFAULT);
|
|
41
45
|
|
|
46
|
+
/**
|
|
47
|
+
* isNonProblemRow(row) — a row that is NOT waiting on anyone: completed,
|
|
48
|
+
* skipped, or a `failed` row a human cancelled (isCancelledRow — `cancelledAt`
|
|
49
|
+
* or an error starting 'cancelled via admin API'). A cancel is a decision,
|
|
50
|
+
* not a fault; counting it as a parked problem flagged Self's closed Epic
|
|
51
|
+
* (cancelled 1012-1016) as stalled every ~8 minutes (2026-11-22).
|
|
52
|
+
*/
|
|
53
|
+
function isNonProblemRow(row) {
|
|
54
|
+
if (!row) return false;
|
|
55
|
+
if (row.status === 'completed' || row.status === 'skipped') return true;
|
|
56
|
+
return row.status === 'failed' && isCancelledRow(row);
|
|
57
|
+
}
|
|
58
|
+
|
|
42
59
|
/**
|
|
43
60
|
* computeStallSummary(state) → { stalled, total, running, pending, byProject }
|
|
44
61
|
*
|
|
@@ -68,25 +85,29 @@ function computeStallSummary(state) {
|
|
|
68
85
|
let running = 0;
|
|
69
86
|
let pending = 0;
|
|
70
87
|
const byProject = {};
|
|
88
|
+
// Per-project "holds at least one parked problem row" — tracked beside the
|
|
89
|
+
// status counts (not as a count key) so the counts stay a pure status tally.
|
|
90
|
+
const problemByProject = new Map();
|
|
71
91
|
for (const j of jobs) {
|
|
72
92
|
if (j.status === 'running') running += 1;
|
|
73
93
|
if (j.status === 'pending') pending += 1;
|
|
74
94
|
const key = j.cwd || '(unknown)';
|
|
75
95
|
byProject[key] = byProject[key] || {};
|
|
76
96
|
byProject[key][j.status] = (byProject[key][j.status] || 0) + 1;
|
|
97
|
+
if (j.status !== 'running' && j.status !== 'pending' && !isNonProblemRow(j)) problemByProject.set(key, true);
|
|
77
98
|
}
|
|
78
99
|
for (const inv of invalidJobs) {
|
|
79
100
|
const key = inv.row?.cwd || '(unknown)';
|
|
80
101
|
byProject[key] = byProject[key] || {};
|
|
81
102
|
byProject[key].invalid = (byProject[key].invalid || 0) + 1;
|
|
103
|
+
problemByProject.set(key, true);
|
|
82
104
|
}
|
|
83
105
|
const total = jobs.length + invalidJobs.length;
|
|
84
|
-
// A drained queue (every row completed/skipped) is idle, not
|
|
85
|
-
// stall needs at least one parked problem row (failed/
|
|
86
|
-
// quarantined/invalid) that is waiting on someone.
|
|
87
|
-
const isProblemStatus = (st) => st !== 'completed' && st !== 'skipped';
|
|
106
|
+
// A drained queue (every row completed/skipped/cancelled) is idle, not
|
|
107
|
+
// stalled — a stall needs at least one parked problem row (failed/
|
|
108
|
+
// needs_review/quarantined/invalid) that is waiting on someone.
|
|
88
109
|
const stalled = total > 0 && running === 0 && pending === 0 && !state?.paused
|
|
89
|
-
&& (invalidJobs.length > 0 || jobs.some((j) =>
|
|
110
|
+
&& (invalidJobs.length > 0 || jobs.some((j) => j.status !== 'running' && j.status !== 'pending' && !isNonProblemRow(j)));
|
|
90
111
|
for (const key of Object.keys(byProject)) {
|
|
91
112
|
const counts = byProject[key];
|
|
92
113
|
const projRunning = counts.running || 0;
|
|
@@ -94,13 +115,208 @@ function computeStallSummary(state) {
|
|
|
94
115
|
const projTotal = Object.keys(counts)
|
|
95
116
|
.filter((k) => k !== 'stalled')
|
|
96
117
|
.reduce((sum, k) => sum + counts[k], 0);
|
|
97
|
-
|
|
98
|
-
.
|
|
99
|
-
counts.stalled = projTotal > 0 && projRunning === 0 && projPending === 0 && !state?.paused && projProblem;
|
|
118
|
+
counts.stalled = projTotal > 0 && projRunning === 0 && projPending === 0 && !state?.paused
|
|
119
|
+
&& problemByProject.get(key) === true;
|
|
100
120
|
}
|
|
101
121
|
return { stalled, total, running, pending, byProject };
|
|
102
122
|
}
|
|
103
123
|
|
|
124
|
+
/** Statuses a dependency can sit in that will never clear on their own. */
|
|
125
|
+
const DEAD_DEP_STATUSES = new Set(['failed', 'cancelled', 'unresolved', 'skipped', 'needs_review', 'quarantined']);
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* classifyPendingHolds(jobs, { satisfiedSlugsByCwd, holds, now, thresholdMs, loadGated })
|
|
129
|
+
* → [{ slug, cwd, ageMs, cause, dep?, depSlug?, depStatus?, rootSlug?, rootStatus?, overlapWith? }]
|
|
130
|
+
*
|
|
131
|
+
* Pure, no IO. Every `pending` row that has waited longer than `thresholdMs`
|
|
132
|
+
* (age from schedulerBatch.enqueueTimestamp) gets ONE cause, checked in order:
|
|
133
|
+
* - 'dependency' — findBlockingDep names a dep (the same resolver
|
|
134
|
+
* dispatch uses). `depSlug`/`depStatus` name the
|
|
135
|
+
* resolved blocking ROW ('cancelled' for a human cancel,
|
|
136
|
+
* 'unresolved' with depSlug null when no row/record
|
|
137
|
+
* exists). `rootSlug`/`rootStatus` follow pending
|
|
138
|
+
* blockers down the chain to the row actually stuck.
|
|
139
|
+
* - 'files-overlap' — the picker's `holds` carries a files-overlap record.
|
|
140
|
+
* - 'load-gate' — the last tick was load-deferred (`loadGated`).
|
|
141
|
+
* - 'concurrency' — otherwise: eligible, simply waiting for a slot.
|
|
142
|
+
* `satisfiedSlugsByCwd` is budget.computeDepHistorySatisfaction's map (a
|
|
143
|
+
* DEP_HISTORY_FAIL_OPEN value fails that project open, as dispatch does).
|
|
144
|
+
*/
|
|
145
|
+
function classifyPendingHolds(jobs, opts = {}) {
|
|
146
|
+
const {
|
|
147
|
+
satisfiedSlugsByCwd = new Map(), holds = [], now = Date.now(), thresholdMs = 0, loadGated = false,
|
|
148
|
+
} = opts;
|
|
149
|
+
const all = Array.isArray(jobs) ? jobs : [];
|
|
150
|
+
const byCwd = new Map();
|
|
151
|
+
for (const j of all) {
|
|
152
|
+
const cwd = j.cwd || DEFAULT_PROJECT_CWD;
|
|
153
|
+
if (!byCwd.has(cwd)) byCwd.set(cwd, []);
|
|
154
|
+
byCwd.get(cwd).push(j);
|
|
155
|
+
}
|
|
156
|
+
const holdBySlug = new Map();
|
|
157
|
+
for (const h of holds ?? []) if (h?.slug && !holdBySlug.has(h.slug)) holdBySlug.set(h.slug, h);
|
|
158
|
+
|
|
159
|
+
const out = [];
|
|
160
|
+
for (const [cwd, projectJobs] of byCwd) {
|
|
161
|
+
const sat = satisfiedSlugsByCwd instanceof Map ? satisfiedSlugsByCwd.get(cwd) : undefined;
|
|
162
|
+
const failOpen = sat === DEP_HISTORY_FAIL_OPEN;
|
|
163
|
+
const resolver = makeDepResolver(projectJobs, failOpen ? new Set() : (sat ?? new Set()), { failOpen });
|
|
164
|
+
const blockerOf = (job) => {
|
|
165
|
+
const dep = findBlockingDep(job, projectJobs, null, resolver);
|
|
166
|
+
if (!dep) return null;
|
|
167
|
+
const { rows } = resolver.resolve(dep, job);
|
|
168
|
+
const row = rows.find((r) => !isSatisfiedDepRow(r)) ?? null;
|
|
169
|
+
if (!row) return { dep, row: null, depSlug: null, depStatus: 'unresolved' };
|
|
170
|
+
return { dep, row, depSlug: row.slug, depStatus: isCancelledRow(row) ? 'cancelled' : row.status };
|
|
171
|
+
};
|
|
172
|
+
for (const job of projectJobs) {
|
|
173
|
+
if (job.status !== 'pending') continue;
|
|
174
|
+
const ageMs = now - enqueueTimestamp(job);
|
|
175
|
+
if (!(ageMs >= thresholdMs)) continue;
|
|
176
|
+
const base = { slug: job.slug, cwd, ageMs: Number.isFinite(ageMs) ? ageMs : null };
|
|
177
|
+
const blocker = blockerOf(job);
|
|
178
|
+
if (blocker) {
|
|
179
|
+
// Follow pending blockers to the root actually stuck (cycle-safe).
|
|
180
|
+
let root = blocker;
|
|
181
|
+
let cycle = false;
|
|
182
|
+
const seen = new Set([job.slug]);
|
|
183
|
+
while (root.row && root.row.status === 'pending') {
|
|
184
|
+
if (seen.has(root.row.slug)) { cycle = true; break; }
|
|
185
|
+
seen.add(root.row.slug);
|
|
186
|
+
const next = blockerOf(root.row);
|
|
187
|
+
if (!next) break;
|
|
188
|
+
root = next;
|
|
189
|
+
}
|
|
190
|
+
out.push({
|
|
191
|
+
...base,
|
|
192
|
+
cause: 'dependency',
|
|
193
|
+
dep: blocker.dep,
|
|
194
|
+
depSlug: blocker.depSlug,
|
|
195
|
+
depStatus: blocker.depStatus,
|
|
196
|
+
rootSlug: root.depSlug,
|
|
197
|
+
rootStatus: cycle ? 'cycle' : root.depStatus,
|
|
198
|
+
});
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const hold = holdBySlug.get(job.slug);
|
|
202
|
+
if (typeof hold?.reason === 'string' && hold.reason.startsWith('files-overlap')) {
|
|
203
|
+
out.push({ ...base, cause: 'files-overlap', overlapWith: hold.reason.slice('files-overlap:'.length) || null });
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
out.push({ ...base, cause: loadGated ? 'load-gate' : 'concurrency' });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* findDependencyStalledProjects(jobs, classified) → { [cwd]: [{ slug, dep, depSlug, depStatus }] }
|
|
214
|
+
*
|
|
215
|
+
* Pure. A project is dependency-stalled when it has pending rows, nothing
|
|
216
|
+
* running, and EVERY pending row is classified 'dependency' whose chain ends
|
|
217
|
+
* at a row that will never clear on its own (DEAD_DEP_STATUSES — failed,
|
|
218
|
+
* cancelled, unresolved, ...). computeStallSummary can't see this: it needs
|
|
219
|
+
* 0 pending, and the Self incident held 16 pending rows behind a cancelled dep.
|
|
220
|
+
*/
|
|
221
|
+
function findDependencyStalledProjects(jobs, classified) {
|
|
222
|
+
const pendingByCwd = new Map();
|
|
223
|
+
const runningCwds = new Set();
|
|
224
|
+
for (const j of Array.isArray(jobs) ? jobs : []) {
|
|
225
|
+
const cwd = j.cwd || DEFAULT_PROJECT_CWD;
|
|
226
|
+
if (j.status === 'running') runningCwds.add(cwd);
|
|
227
|
+
if (j.status === 'pending') pendingByCwd.set(cwd, (pendingByCwd.get(cwd) || 0) + 1);
|
|
228
|
+
}
|
|
229
|
+
const heldByCwd = new Map();
|
|
230
|
+
for (const c of classified ?? []) {
|
|
231
|
+
if (c.cause !== 'dependency' || !DEAD_DEP_STATUSES.has(c.rootStatus)) continue;
|
|
232
|
+
if (!heldByCwd.has(c.cwd)) heldByCwd.set(c.cwd, []);
|
|
233
|
+
heldByCwd.get(c.cwd).push({ slug: c.slug, dep: c.dep, depSlug: c.depSlug, depStatus: c.depStatus });
|
|
234
|
+
}
|
|
235
|
+
const out = {};
|
|
236
|
+
for (const [cwd, held] of heldByCwd) {
|
|
237
|
+
if (runningCwds.has(cwd)) continue;
|
|
238
|
+
if (held.length !== pendingByCwd.get(cwd)) continue;
|
|
239
|
+
out[cwd] = held;
|
|
240
|
+
}
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** A dependency hold this old on a failed/cancelled row earns a Needs-you item. */
|
|
245
|
+
const DEP_HOLD_NOTICE_MS = 30 * 60_000;
|
|
246
|
+
/** Root statuses a Needs-you dep-hold notice is posted for (a human can fix these in one click). */
|
|
247
|
+
const DEP_HOLD_NOTICE_STATUSES = new Set(['failed', 'cancelled']);
|
|
248
|
+
const DEP_HOLD_NOTICE_ID_PREFIX = 'stall-dep-hold:';
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* depHoldNoticeId(cwd, blockerSlug) → string
|
|
252
|
+
* Stable Needs-you id for one (project, blocking row) pair. The cwd is hashed
|
|
253
|
+
* (a path can hold characters the Needs-you id pattern refuses); the slug is
|
|
254
|
+
* kept readable, with any refused character replaced by '-'.
|
|
255
|
+
*/
|
|
256
|
+
function depHoldNoticeId(cwd, blockerSlug) {
|
|
257
|
+
const h = crypto.createHash('sha1').update(String(cwd)).digest('hex').slice(0, 12);
|
|
258
|
+
const slug = String(blockerSlug).replace(/[^A-Za-z0-9._:/@-]/g, '-').slice(0, 160);
|
|
259
|
+
return `${DEP_HOLD_NOTICE_ID_PREFIX}${h}:${slug}`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* selectDepHoldNotices(classified, prevOpen, { thresholdMs }) → { post, withdraw }
|
|
264
|
+
*
|
|
265
|
+
* Pure. Given classifyPendingHolds output and the ids of dep-hold notices
|
|
266
|
+
* already open (a Set or array), decide which (cwd, blocking slug) pairs need
|
|
267
|
+
* a Needs-you post and which open notices must be withdrawn:
|
|
268
|
+
* - post: a pair NOT already open where at least one pending row has been
|
|
269
|
+
* held over `thresholdMs` by a chain whose root is a failed or cancelled
|
|
270
|
+
* row → { id, cwd, blockerSlug, blockerStatus, heldSlugs } (heldSlugs =
|
|
271
|
+
* every row that pair currently holds, sorted). Once open it is never
|
|
272
|
+
* re-posted in the same episode.
|
|
273
|
+
* - withdraw: an open id for which no pending row is held by that blocker
|
|
274
|
+
* any more (any age — a younger re-hold keeps the episode open).
|
|
275
|
+
*/
|
|
276
|
+
function selectDepHoldNotices(classified, prevOpen, opts = {}) {
|
|
277
|
+
const { thresholdMs = DEP_HOLD_NOTICE_MS } = opts;
|
|
278
|
+
const open = new Set(prevOpen ?? []);
|
|
279
|
+
const held = new Map();
|
|
280
|
+
for (const c of classified ?? []) {
|
|
281
|
+
if (c?.cause !== 'dependency' || !c.rootSlug || !DEP_HOLD_NOTICE_STATUSES.has(c.rootStatus)) continue;
|
|
282
|
+
const id = depHoldNoticeId(c.cwd, c.rootSlug);
|
|
283
|
+
if (!held.has(id)) {
|
|
284
|
+
held.set(id, { id, cwd: c.cwd, blockerSlug: c.rootSlug, blockerStatus: c.rootStatus, heldSlugs: [], due: false });
|
|
285
|
+
}
|
|
286
|
+
const entry = held.get(id);
|
|
287
|
+
entry.heldSlugs.push(c.slug);
|
|
288
|
+
if (Number.isFinite(c.ageMs) && c.ageMs >= thresholdMs) entry.due = true;
|
|
289
|
+
}
|
|
290
|
+
const post = [];
|
|
291
|
+
for (const entry of held.values()) {
|
|
292
|
+
if (!entry.due || open.has(entry.id)) continue;
|
|
293
|
+
const { due, ...rest } = entry;
|
|
294
|
+
post.push({ ...rest, heldSlugs: [...rest.heldSlugs].sort() });
|
|
295
|
+
}
|
|
296
|
+
const withdraw = [...open].filter((id) => !held.has(id));
|
|
297
|
+
return { post, withdraw };
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* formatDepHoldNotice({ cwd, blockerSlug, blockerStatus, heldSlugs }) → { title, why }
|
|
302
|
+
* Pure. The Needs-you text: which rows are held, by which row in which
|
|
303
|
+
* state, and the one-click fix (reset it, or archive/dismiss it).
|
|
304
|
+
*/
|
|
305
|
+
function formatDepHoldNotice({ cwd, blockerSlug, blockerStatus, heldSlugs }) {
|
|
306
|
+
const project = path.basename(String(cwd)) || String(cwd);
|
|
307
|
+
const n = heldSlugs.length;
|
|
308
|
+
const title = `Scheduler: ${n} PRD${n === 1 ? '' : 's'} in ${project} held by ${blockerStatus} ${blockerSlug}`
|
|
309
|
+
.replace(/[\r\n]+/g, ' ').slice(0, 200);
|
|
310
|
+
const shown = heldSlugs.slice(0, 20).join(', ') + (n > 20 ? `, and ${n - 20} more` : '');
|
|
311
|
+
const why = [
|
|
312
|
+
`${n} pending PRD${n === 1 ? '' : 's'} in ${cwd} cannot run: ${shown} ${n === 1 ? 'waits' : 'wait'} `
|
|
313
|
+
+ `(directly or down the dependsOn chain) on ${blockerSlug}, which is ${blockerStatus}.`,
|
|
314
|
+
`Fix: in the Scheduler tab, Reset ${blockerSlug} to run it again, or archive/dismiss it `
|
|
315
|
+
+ 'so its dependents stop waiting on it. This item closes by itself once nothing is held by it.',
|
|
316
|
+
].join(' ').slice(0, 1000);
|
|
317
|
+
return { title, why };
|
|
318
|
+
}
|
|
319
|
+
|
|
104
320
|
/**
|
|
105
321
|
* findStaleQuarantinedJobs(jobs, now, thresholdMs) → [{ slug, cwd, ageMs }]
|
|
106
322
|
*
|
|
@@ -518,6 +734,11 @@ async function computeDepHistorySatisfaction(state) {
|
|
|
518
734
|
try {
|
|
519
735
|
for (const slug of await queueHistory.completedSlugsForCwd(cwd)) satisfied.add(slug);
|
|
520
736
|
for (const dir of listArchivedPrdDirs(cwd)) {
|
|
737
|
+
// Only prds-archived/ means "shipped". A dismissed cancelled PRD lives
|
|
738
|
+
// in the sibling prds-cancelled/ (queueOps.dismissCancelled) and must
|
|
739
|
+
// NEVER satisfy a dependsOn — guard by name so a future change to
|
|
740
|
+
// listArchivedPrdDirs cannot start counting it (PRD 3492).
|
|
741
|
+
if (path.basename(dir) !== 'prds-archived') continue;
|
|
521
742
|
let entries;
|
|
522
743
|
try { entries = await fsp.readdir(dir, { withFileTypes: true }); } catch { continue; }
|
|
523
744
|
for (const ent of entries) {
|
|
@@ -731,6 +952,15 @@ module.exports = {
|
|
|
731
952
|
JOB_BUDGET_FLOOR_MS,
|
|
732
953
|
JOB_BUDGET_CEILING_MS,
|
|
733
954
|
computeStallSummary,
|
|
955
|
+
isCancelledRow,
|
|
956
|
+
isNonProblemRow,
|
|
957
|
+
classifyPendingHolds,
|
|
958
|
+
findDependencyStalledProjects,
|
|
959
|
+
DEP_HOLD_NOTICE_MS,
|
|
960
|
+
DEP_HOLD_NOTICE_ID_PREFIX,
|
|
961
|
+
depHoldNoticeId,
|
|
962
|
+
selectDepHoldNotices,
|
|
963
|
+
formatDepHoldNotice,
|
|
734
964
|
findStaleQuarantinedJobs,
|
|
735
965
|
findOverrunningJobs,
|
|
736
966
|
computeJobBudgetMs,
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* cancelDependents.cjs — pure planning for remote.cancelJob's dependents
|
|
5
|
+
* choice (PRD 3499). Cancelling a row with pending dependents used to leave
|
|
6
|
+
* every dependent pointing at a dead (failed) row — the 2026-11-22 Self stall.
|
|
7
|
+
* cancelJob now refuses unless the caller says what happens to them:
|
|
8
|
+
*
|
|
9
|
+
* cascade — cancel every pending dependent, transitively
|
|
10
|
+
* repoint — replace the dep on the target with `to` (resolved to a full slug)
|
|
11
|
+
* clear — drop the dep on the target
|
|
12
|
+
*
|
|
13
|
+
* No I/O here: scheduler.cjs reads the queue, calls these, then applies the
|
|
14
|
+
* edits (updatePrd for repoint/clear, one mutate for cascade + target).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const { makeDepResolver, resolveDepSlug } = require('../lib/prd/depSlugResolve.cjs');
|
|
18
|
+
const { wouldCreateCycle } = require('../lib/prd/prdDisposition.cjs');
|
|
19
|
+
|
|
20
|
+
const DEPENDENTS_ACTIONS = Object.freeze(['cascade', 'repoint', 'clear']);
|
|
21
|
+
|
|
22
|
+
function projectRows(jobs, cwd) {
|
|
23
|
+
return (Array.isArray(jobs) ? jobs : []).filter((j) => j && (cwd == null || j.cwd === cwd));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function findTarget(rows, slug) {
|
|
27
|
+
return rows.find((j) => j.slug === slug) ?? null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The deps of `dependent` that resolve to `target` under the shared run-time
|
|
32
|
+
* rule (exact slug, else bare name with Epic preference).
|
|
33
|
+
*/
|
|
34
|
+
function depsNamingTarget(resolver, dependent, target) {
|
|
35
|
+
const out = [];
|
|
36
|
+
for (const dep of Array.isArray(dependent.dependsOn) ? dependent.dependsOn : []) {
|
|
37
|
+
if (resolver.resolve(dep, dependent).rows.includes(target)) out.push(dep);
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Pending rows of `cwd` whose dependsOn resolves to the row `slug`. Rows of
|
|
44
|
+
* other projects never count, even with a matching bare name. Returns
|
|
45
|
+
* [{ slug, deps }] in queue order; [] when the target is not in that cwd.
|
|
46
|
+
*/
|
|
47
|
+
function findPendingDependents(jobs, slug, cwd) {
|
|
48
|
+
const rows = projectRows(jobs, cwd);
|
|
49
|
+
const target = findTarget(rows, slug);
|
|
50
|
+
if (!target) return [];
|
|
51
|
+
const resolver = makeDepResolver(rows);
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const j of rows) {
|
|
54
|
+
if (j === target || j.status !== 'pending') continue;
|
|
55
|
+
const deps = depsNamingTarget(resolver, j, target);
|
|
56
|
+
if (deps.length > 0) out.push({ slug: j.slug, deps });
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Every pending dependent of `slug`, transitively (BFS order, target excluded). */
|
|
62
|
+
function findTransitiveDependents(jobs, slug, cwd) {
|
|
63
|
+
const seen = new Set([slug]);
|
|
64
|
+
const order = [];
|
|
65
|
+
const queue = [slug];
|
|
66
|
+
while (queue.length > 0) {
|
|
67
|
+
const cur = queue.shift();
|
|
68
|
+
for (const d of findPendingDependents(jobs, cur, cwd)) {
|
|
69
|
+
if (seen.has(d.slug)) continue;
|
|
70
|
+
seen.add(d.slug);
|
|
71
|
+
order.push(d.slug);
|
|
72
|
+
queue.push(d.slug);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return order;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* planDependentsUpdate(jobs, slug, choice, cwd?) →
|
|
80
|
+
* { ok: true, action, to, dependents: string[], edits: [...] }
|
|
81
|
+
* | { ok: false, error }
|
|
82
|
+
* `choice` is { action, to? }; `cwd` defaults to `choice.cwd`, else the target
|
|
83
|
+
* row's own cwd. Edits:
|
|
84
|
+
* cascade → { slug, action: 'cancel', reason } (transitive set)
|
|
85
|
+
* repoint → { slug, action: 'setDependsOn', dependsOn, previous }
|
|
86
|
+
* clear → { slug, action: 'setDependsOn', dependsOn, previous }
|
|
87
|
+
*/
|
|
88
|
+
function planDependentsUpdate(jobs, slug, choice, cwd) {
|
|
89
|
+
const action = choice?.action;
|
|
90
|
+
if (!DEPENDENTS_ACTIONS.includes(action)) {
|
|
91
|
+
return { ok: false, error: `dependents.action must be one of ${DEPENDENTS_ACTIONS.join(', ')}` };
|
|
92
|
+
}
|
|
93
|
+
const all = Array.isArray(jobs) ? jobs : [];
|
|
94
|
+
const scopeCwd = cwd ?? choice?.cwd ?? all.find((j) => j?.slug === slug)?.cwd ?? null;
|
|
95
|
+
const rows = projectRows(all, scopeCwd);
|
|
96
|
+
const target = findTarget(rows, slug);
|
|
97
|
+
if (!target) return { ok: false, error: `unknown slug "${slug}"` };
|
|
98
|
+
|
|
99
|
+
if (action === 'cascade') {
|
|
100
|
+
const dependents = findTransitiveDependents(rows, slug, scopeCwd);
|
|
101
|
+
const reason = `cancelled via admin API (cascade: depends on cancelled ${slug})`;
|
|
102
|
+
return {
|
|
103
|
+
ok: true, action, to: null, dependents,
|
|
104
|
+
edits: dependents.map((s) => ({ slug: s, action: 'cancel', reason })),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const direct = findPendingDependents(rows, slug, scopeCwd);
|
|
109
|
+
const dependents = direct.map((d) => d.slug);
|
|
110
|
+
let resolvedTo = null;
|
|
111
|
+
if (action === 'repoint') {
|
|
112
|
+
const to = typeof choice.to === 'string' ? choice.to.trim() : '';
|
|
113
|
+
if (!to) return { ok: false, error: 'dependents.action "repoint" requires dependents.to' };
|
|
114
|
+
const matches = resolveDepSlug(to, rows.map((r) => r.slug));
|
|
115
|
+
if (matches.length === 0) {
|
|
116
|
+
return { ok: false, error: `dependents.to "${to}" does not resolve to any queued PRD in this project` };
|
|
117
|
+
}
|
|
118
|
+
if (matches.length > 1) {
|
|
119
|
+
return { ok: false, error: `dependents.to "${to}" is ambiguous (matches ${matches.join(', ')}) — pass the full NN-prefixed slug` };
|
|
120
|
+
}
|
|
121
|
+
resolvedTo = matches[0];
|
|
122
|
+
if (resolvedTo === slug) {
|
|
123
|
+
return { ok: false, error: `dependents.to "${to}" resolves to the job being cancelled (${slug})` };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const bySlug = new Map(rows.map((r) => [r.slug, r]));
|
|
128
|
+
const edits = [];
|
|
129
|
+
for (const d of direct) {
|
|
130
|
+
const row = bySlug.get(d.slug);
|
|
131
|
+
const previous = Array.isArray(row.dependsOn) ? [...row.dependsOn] : [];
|
|
132
|
+
const drop = new Set(d.deps);
|
|
133
|
+
const next = [];
|
|
134
|
+
for (const dep of previous) {
|
|
135
|
+
const replacement = drop.has(dep) ? resolvedTo : dep;
|
|
136
|
+
if (replacement != null && !next.includes(replacement)) next.push(replacement);
|
|
137
|
+
}
|
|
138
|
+
if (action === 'repoint') {
|
|
139
|
+
const cycleRows = rows.map((r) => ({ slug: r.slug, dependsOn: r.dependsOn ?? [] }));
|
|
140
|
+
if (wouldCreateCycle(cycleRows, d.slug, next)) {
|
|
141
|
+
return { ok: false, error: `repointing ${d.slug} to ${resolvedTo} would create a dependency cycle` };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
edits.push({ slug: d.slug, action: 'setDependsOn', dependsOn: next, previous });
|
|
145
|
+
}
|
|
146
|
+
return { ok: true, action, to: resolvedTo, dependents, edits };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
module.exports = {
|
|
150
|
+
DEPENDENTS_ACTIONS,
|
|
151
|
+
findPendingDependents,
|
|
152
|
+
findTransitiveDependents,
|
|
153
|
+
planDependentsUpdate,
|
|
154
|
+
};
|
|
@@ -17,7 +17,7 @@ const fs = require('node:fs');
|
|
|
17
17
|
const fsp = require('node:fs/promises');
|
|
18
18
|
const os = require('node:os');
|
|
19
19
|
const path = require('node:path');
|
|
20
|
-
const { splitFrontmatter, parseInlineList, PRD_EFFORT_LEVELS } = require('../lib/prd/prdFrontmatter.cjs');
|
|
20
|
+
const { splitFrontmatter, parseInlineList, parseFixes, parsePreflightValue, PRD_EFFORT_LEVELS } = require('../lib/prd/prdFrontmatter.cjs');
|
|
21
21
|
const { deriveEpicIdFromPrdPath } = require('../lib/prd/prdLocations.cjs');
|
|
22
22
|
const { parseFilesSection } = require('../lib/prd/prdGateFiles.cjs');
|
|
23
23
|
const { reportDanglingAgentTypeOnce } = require('../lib/prd/prdAgentType.cjs');
|
|
@@ -112,6 +112,9 @@ async function parsePrdRaw(filePath) {
|
|
|
112
112
|
// queue row is completed (a slug with no row is treated as already
|
|
113
113
|
// done/archived, matching retireCompletedSlugs semantics).
|
|
114
114
|
dependsOn: parseDependsOn(fm.dependsOn),
|
|
115
|
+
// Earlier PRDs this one repairs ({ prd, missKind, reason }[]); null when
|
|
116
|
+
// absent/malformed/empty. reconcile() copies it onto the queue row.
|
|
117
|
+
fixes: (() => { const l = typeof fm.fixes === 'string' ? parseFixes(fm.fixes) : null; return l && l.length ? l : null; })(),
|
|
115
118
|
// Declared touch-list from the body's `# Files` section ([] when absent).
|
|
116
119
|
files: parseFilesSection(body),
|
|
117
120
|
// Provenance stamp (PRD-authoring lockdown): set only by prdCreate.cjs's
|
|
@@ -150,6 +153,9 @@ async function parsePrdRaw(filePath) {
|
|
|
150
153
|
deliverable: (typeof fm.deliverable === 'string' && fm.deliverable.trim() === 'artifact') ? 'artifact' : null,
|
|
151
154
|
artifactPaths: parseArtifactPaths(fm.artifactPaths),
|
|
152
155
|
effort: (typeof fm.effort === 'string' && PRD_EFFORT_LEVELS.includes(fm.effort.trim())) ? fm.effort.trim() : null,
|
|
156
|
+
// Optional precondition command (preflightCheck.cjs); reconcile copies it
|
|
157
|
+
// onto the queue row so spawnJob can hold the job while it exits non-zero.
|
|
158
|
+
preflight: typeof fm.preflight === 'string' ? parsePreflightValue(rawFrontmatterValue(text, 'preflight')) : null,
|
|
153
159
|
// Opt-in exclusive-lease flag (PRD 1107, quietMachineLease.cjs +
|
|
154
160
|
// schedulerBatch.cjs's pickNextBatch). Only a literal `true` opts in —
|
|
155
161
|
// matches prdFrontmatter.cjs's applyKey semantics for this field.
|
|
@@ -163,6 +169,18 @@ async function parsePrdRaw(filePath) {
|
|
|
163
169
|
};
|
|
164
170
|
}
|
|
165
171
|
|
|
172
|
+
/**
|
|
173
|
+
* The unstripped value of one frontmatter key. splitFrontmatter strips a
|
|
174
|
+
* value's outer quotes, which breaks a JSON-string `preflight` with escaped
|
|
175
|
+
* inner quotes; parsePreflightValue needs the raw form.
|
|
176
|
+
*/
|
|
177
|
+
function rawFrontmatterValue(text, key) {
|
|
178
|
+
const end = text.indexOf('\n---', 4);
|
|
179
|
+
const block = end === -1 ? '' : text.slice(4, end);
|
|
180
|
+
const m = block.match(new RegExp(`^${key}\\s*:\\s*(.*?)\\s*$`, 'm'));
|
|
181
|
+
return m ? m[1] : '';
|
|
182
|
+
}
|
|
183
|
+
|
|
166
184
|
/** `[a, b]` / `a, b` / `a` → ['a','b']; anything else → []. */
|
|
167
185
|
function parseDependsOn(raw) {
|
|
168
186
|
if (!raw || typeof raw !== 'string') return [];
|
|
@@ -441,13 +441,29 @@ function isStrandedAutoFixPark(job, jobsInProject) {
|
|
|
441
441
|
return !liveOrQueuedChild;
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
+
/**
|
|
445
|
+
* Pure predicate, no I/O: a needs_review row that is itself a fix plan
|
|
446
|
+
* (resolveIsFixPlan — persisted isFixPlan stamp, else the slug heuristic)
|
|
447
|
+
* and never went through auto-fix. selectAutoFixTargets excludes fix plans
|
|
448
|
+
* (no recursion), so autoFixAttempted is never set and none of the other
|
|
449
|
+
* doors admit it — rung 6 never runs and its dependsOn chain waits forever
|
|
450
|
+
* (starry-night-2 852-fix-ios-asc-profile, sentinel_fail, 2026-11-22).
|
|
451
|
+
* Exported for tests.
|
|
452
|
+
*/
|
|
453
|
+
function isFixPlanParkWithoutAutoFix(job) {
|
|
454
|
+
if (!job || job.status !== 'needs_review') return false;
|
|
455
|
+
if (job.autoFixAttempted === true) return false;
|
|
456
|
+
return resolveIsFixPlan(job.slug, job.isFixPlan);
|
|
457
|
+
}
|
|
458
|
+
|
|
444
459
|
/**
|
|
445
460
|
* Pure predicate, no I/O: is this needs_review row eligible for the bounded
|
|
446
461
|
* auto-resolve ladder at all — either because its auto-fix path is genuinely
|
|
447
462
|
* spent (isExhaustedAutoFix), because it was parked by a GUARD verdict that
|
|
448
463
|
* never entered auto-fix in the first place (isGuardParkedWithoutAutoFix),
|
|
449
|
-
*
|
|
450
|
-
* recording any outcome (isStrandedAutoFixPark)
|
|
464
|
+
* because its auto-fix investigation ran but was stranded before
|
|
465
|
+
* recording any outcome (isStrandedAutoFixPark), or because it is a fix plan
|
|
466
|
+
* that auto-fix never admits (isFixPlanParkWithoutAutoFix). All four classes share ONE
|
|
451
467
|
* ladder (applyNeedsReviewAutoResolve) rather than a duplicated one — the
|
|
452
468
|
* ladder itself doesn't care which door a row came through, only whether it
|
|
453
469
|
* now carries completion evidence (job.looksDone). `jobsInProject` is only
|
|
@@ -457,7 +473,10 @@ function isStrandedAutoFixPark(job, jobsInProject) {
|
|
|
457
473
|
*/
|
|
458
474
|
function isEligibleForNeedsReviewAutoResolve(job, jobsInProject = []) {
|
|
459
475
|
if (isRefireCapped(job)) return false;
|
|
460
|
-
return isExhaustedAutoFix(job)
|
|
476
|
+
return isExhaustedAutoFix(job)
|
|
477
|
+
|| isGuardParkedWithoutAutoFix(job)
|
|
478
|
+
|| isStrandedAutoFixPark(job, jobsInProject)
|
|
479
|
+
|| isFixPlanParkWithoutAutoFix(job);
|
|
461
480
|
}
|
|
462
481
|
|
|
463
482
|
/**
|
|
@@ -495,9 +514,21 @@ function isFixPlanDead(job, jobsInProject) {
|
|
|
495
514
|
const fixSlug = fixSlugFor(job);
|
|
496
515
|
const child = (jobsInProject || []).find((j) => j.slug === fixSlug);
|
|
497
516
|
if (!child) return false;
|
|
517
|
+
// A child waiting on its own red preflight is not dead: the precondition,
|
|
518
|
+
// not the plan, is the blocker — reopening it would spend a probe for nothing.
|
|
519
|
+
if (hasActivePreflightHold(child)) return false;
|
|
498
520
|
return DEAD_FIX_CHILD_STATUSES.has(child.status);
|
|
499
521
|
}
|
|
500
522
|
|
|
523
|
+
/**
|
|
524
|
+
* Pure predicate: the row is waiting on its own red `preflight` (a
|
|
525
|
+
* preflightHold is armed). Such a row spends nothing on the model ladder —
|
|
526
|
+
* no investigation probe, no dead-fix-plan reopen. Exported for tests.
|
|
527
|
+
*/
|
|
528
|
+
function hasActivePreflightHold(job) {
|
|
529
|
+
return !!(job && job.preflightHold && typeof job.preflightHold === 'object');
|
|
530
|
+
}
|
|
531
|
+
|
|
501
532
|
/**
|
|
502
533
|
* Pure predicate: is this job eligible for the boot re-verify self-heal? Only
|
|
503
534
|
* needs_review jobs with a run log (own or backfilled via resolveRunId) AND a
|
|
@@ -1107,10 +1138,12 @@ module.exports = {
|
|
|
1107
1138
|
GUARD_VERDICT_EVIDENCE_ELIGIBLE,
|
|
1108
1139
|
isGuardParkedWithoutAutoFix,
|
|
1109
1140
|
isStrandedAutoFixPark,
|
|
1141
|
+
isFixPlanParkWithoutAutoFix,
|
|
1110
1142
|
isEligibleForNeedsReviewAutoResolve,
|
|
1111
1143
|
isPlanUnqueued,
|
|
1112
1144
|
DEAD_FIX_CHILD_STATUSES,
|
|
1113
1145
|
isFixPlanDead,
|
|
1146
|
+
hasActivePreflightHold,
|
|
1114
1147
|
NO_ATTRIBUTABLE_COMMIT_VERDICTS,
|
|
1115
1148
|
healRefusalReason,
|
|
1116
1149
|
isFailedUnverifiedShaped,
|