claude-code-session-manager 0.143.0 → 0.144.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 +3 -1
- package/dist/assets/AppSettings-Z68gQiVE.js +2 -0
- package/dist/assets/{History-DTttbvPb.js → History-C3E6y_7t.js} +2 -2
- package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +5 -0
- package/dist/assets/{Panel-B_D4Bg7L.js → Panel-CnfWs46Z.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-CP0Wsg-H.js +26 -0
- package/dist/assets/Scheduler-D8un7N3B.js +16 -0
- package/dist/assets/{SkillReferenceGraph-D1b2aiol.js → SkillReferenceGraph-DRtZV1Al.js} +1 -1
- package/dist/assets/{Skills-cfV7sgk6.js → Skills-Bg5O2Hyn.js} +23 -23
- package/dist/assets/{TiptapBody-DVXtEIVy.js → TiptapBody-BdzoBmqu.js} +27 -27
- package/dist/assets/{Toggle-CYajnSdx.js → Toggle-Dt5K1OXt.js} +1 -1
- package/dist/assets/{VoiceButton-DJ4gGRuE.js → VoiceButton-CTLyRgdF.js} +1 -1
- package/dist/assets/{historyTotals-D3MoHY2U.js → historyTotals-B2_KWBga.js} +1 -1
- package/dist/assets/{index-CdTppjKR.js → index-446b69rr.js} +698 -697
- package/dist/assets/{index-DVHIHoJf.css → index-BJ5TJvmz.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +439 -436
- package/package.json +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +14 -13
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +16 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +87 -0
- package/scripts/README.md +1 -1
- package/scripts/scheduler-mcp-server.cjs +77 -0
- package/src/main/adminRouteRegistry.cjs +6 -0
- package/src/main/agentLibrary.cjs +60 -11
- package/src/main/agentsIpc.cjs +19 -0
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +109 -0
- package/src/main/health.cjs +59 -17
- package/src/main/index.cjs +4 -0
- package/src/main/ipcSchemas.cjs +50 -1
- package/src/main/lib/claude/agentArmory.cjs +128 -0
- package/src/main/lib/claude/agentModelResolve.cjs +3 -2
- package/src/main/lib/claude/agentSnapshot.cjs +24 -3
- package/src/main/lib/claude/builtinTools.cjs +110 -0
- package/src/main/lib/claude/environmentProfiles.cjs +1 -1
- package/src/main/lib/claude/headlessMcpServers.cjs +138 -0
- package/src/main/lib/claude/jobSandboxPolicy.cjs +8 -2
- package/src/main/lib/claude/personaToolScope.cjs +77 -6
- package/src/main/lib/epic/epicDepsSync.cjs +66 -0
- package/src/main/lib/epic/epicOutsideRead.cjs +38 -1
- package/src/main/lib/epic/epicSettle.cjs +48 -4
- package/src/main/lib/epic/epicSpawnPlan.cjs +3 -1
- package/src/main/lib/epic/epicValidationHook.cjs +9 -1
- package/src/main/lib/epic/planReviewInput.cjs +123 -0
- package/src/main/lib/epic/restorableSessions.cjs +1 -0
- package/src/main/lib/epic/scriptStartedBy.cjs +71 -0
- package/src/main/lib/externalContract.cjs +12 -0
- package/src/main/lib/feedback-remote/createdProjects.cjs +291 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +24 -2
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +24 -3
- package/src/main/lib/feedback-remote/pendingReplies.cjs +8 -4
- package/src/main/lib/feedback-remote/projectCreate.cjs +415 -0
- package/src/main/lib/feedback-remote/replyClaims.cjs +15 -6
- package/src/main/lib/feedback-remote/serviceMcpSession.cjs +29 -1
- package/src/main/lib/feedback-remote/serviceMcpTools.cjs +43 -2
- package/src/main/lib/feedback-remote/servicePairLocalRoutes.cjs +91 -0
- package/src/main/lib/feedback-remote/servicePairings.cjs +47 -7
- package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +99 -1
- package/src/main/lib/git/gitWorktree.cjs +1 -1
- package/src/main/lib/git/worktreeDeps.cjs +9 -3
- package/src/main/lib/mcpToolCatalog.cjs +43 -5
- package/src/main/lib/mcpToolsProbe.cjs +19 -2
- package/src/main/lib/packs/packCatalog.cjs +98 -5
- package/src/main/lib/persona-macro/agentPersonaSchema.cjs +6 -0
- package/src/main/lib/persona-macro/builtinMacros.cjs +6 -4
- package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +9 -0
- package/src/main/lib/persona-macro/personaLoadout.cjs +58 -0
- package/src/main/lib/persona-macro/personaMerge.cjs +11 -3
- package/src/main/lib/persona-macro/personaUpgrade.cjs +96 -0
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +1 -1
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +94 -0
- package/src/main/lib/prd/prdCreate.cjs +48 -5
- package/src/main/lib/prd/prdFrontmatter.cjs +5 -2
- package/src/main/lib/prd/prdMcpReachWarnings.cjs +44 -0
- package/src/main/lib/prd/prdSandboxWarnings.cjs +49 -0
- package/src/main/lib/process/peerChatSession.cjs +165 -0
- package/src/main/lib/project-pages/videoScriptPress.cjs +6 -0
- package/src/main/lib/project-pages/videoScriptRunRoute.cjs +24 -4
- package/src/main/lib/promptSessionSchema.cjs +2 -0
- package/src/main/lib/scheduler/baselineGate.cjs +31 -2
- package/src/main/lib/scheduler/planRecordHarvest.cjs +104 -12
- package/src/main/lib/scheduler/planReleaseRoute.cjs +110 -0
- package/src/main/lib/scheduler/planReviewSchema.cjs +182 -0
- package/src/main/lib/scheduler/planReviewStats.cjs +63 -0
- package/src/main/lib/scheduler/planReviewStore.cjs +128 -0
- package/src/main/lib/scheduler/sandboxEnvironmentLimit.cjs +141 -0
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
- package/src/main/lib/scheduler/upgradeDrain.cjs +32 -5
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +12 -2
- package/src/main/lib/tasks/memoryConsolidation.cjs +109 -37
- package/src/main/lib/tasks/taskAdminRoutes.cjs +26 -14
- package/src/main/lib/tasks/taskRun.cjs +3 -1
- package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +178 -0
- package/src/main/projectPages.cjs +22 -14
- package/src/main/pty.cjs +3 -0
- package/src/main/runVerify.cjs +3 -2
- package/src/main/scheduler/planReviewHold.cjs +140 -0
- package/src/main/scheduler/prdParser.cjs +1 -0
- package/src/main/scheduler/reviewLadder.cjs +2 -0
- package/src/main/scheduler/utilizationHold.cjs +7 -2
- package/src/main/scheduler.cjs +532 -78
- package/src/main/seedAgentPersonas.cjs +11 -6
- package/src/main/seedStatus.cjs +1 -1
- package/src/main/templates/PRD_AUTHORING.md +16 -1
- package/src/main/webRemote.cjs +47 -7
- package/src/preload/api.d.ts +71 -1
- package/src/preload/apiSurface.json +28 -0
- package/src/preload/index.cjs +9 -0
- package/src/seed/agents/architect.md +28 -43
- package/src/seed/agents/dev-lead.md +3 -1
- package/src/seed/agents/md-network-curator.md +27 -0
- package/src/seed/agents/plan-reviewer.md +47 -0
- package/src/seed/agents/validator.md +2 -1
- package/dist/assets/AppSettings-BO4jDVGO.js +0 -2
- package/dist/assets/HomeClaudeConfig-DADP5bfn.js +0 -3
- package/dist/assets/ProjectClaudeConfig-DPnDJKcr.js +0 -26
- package/dist/assets/Scheduler-CNLjn90m.js +0 -16
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* planReviewSchema.cjs — the JSON Schema the plan-reviewer returns through
|
|
5
|
+
* `claude -p --json-schema`, a strict parser, and an allOk predicate.
|
|
6
|
+
* Mirrors validatorVerdictSchema.cjs: the CLI enforces the simple schema
|
|
7
|
+
* (enums + required); parsePlanReview adds the cross-field rules (PRD slugs
|
|
8
|
+
* match `expected`, amend|block needs findings, no unknown keys).
|
|
9
|
+
*
|
|
10
|
+
* Pure: no I/O, never throws, never mutates its input.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** @typedef {'Critical'|'Important'|'Minor'} Severity */
|
|
14
|
+
/** @typedef {'ok'|'amend'|'block'} Decision */
|
|
15
|
+
/** @typedef {{ severity: Severity, check: string, text: string, suggestedEdit?: string, field?: string }} PrdFinding */
|
|
16
|
+
/** @typedef {{ prd: string, decision: Decision, findings: PrdFinding[] }} PrdReview */
|
|
17
|
+
/** @typedef {{ severity: Severity, check: string, text: string }} PlanFinding */
|
|
18
|
+
/** @typedef {{ prds: PrdReview[], planFindings: PlanFinding[] }} PlanReview */
|
|
19
|
+
/** @typedef {{ ok: true, value: PlanReview } | { ok: false, error: string }} ParseResult */
|
|
20
|
+
|
|
21
|
+
const PLAN_REVIEW_CHECKS = [
|
|
22
|
+
'provable-criterion',
|
|
23
|
+
'failure-path',
|
|
24
|
+
'edge-case',
|
|
25
|
+
'vacuous-by-sibling',
|
|
26
|
+
'depends-on',
|
|
27
|
+
'gate-green-at-base',
|
|
28
|
+
'http-criterion',
|
|
29
|
+
'doc-after-code',
|
|
30
|
+
];
|
|
31
|
+
const SEVERITIES = ['Critical', 'Important', 'Minor'];
|
|
32
|
+
const DECISIONS = ['ok', 'amend', 'block'];
|
|
33
|
+
|
|
34
|
+
const PLAN_REVIEW_SCHEMA = {
|
|
35
|
+
type: 'object',
|
|
36
|
+
required: ['prds', 'planFindings'],
|
|
37
|
+
properties: {
|
|
38
|
+
prds: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
items: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
required: ['prd', 'decision', 'findings'],
|
|
43
|
+
properties: {
|
|
44
|
+
prd: { type: 'string' },
|
|
45
|
+
decision: { type: 'string', enum: DECISIONS },
|
|
46
|
+
findings: {
|
|
47
|
+
type: 'array',
|
|
48
|
+
items: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
required: ['severity', 'check', 'text'],
|
|
51
|
+
properties: {
|
|
52
|
+
severity: { type: 'string', enum: SEVERITIES },
|
|
53
|
+
check: { type: 'string', enum: PLAN_REVIEW_CHECKS },
|
|
54
|
+
text: { type: 'string' },
|
|
55
|
+
suggestedEdit: { type: 'string' },
|
|
56
|
+
field: { type: 'string' },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
planFindings: {
|
|
64
|
+
type: 'array',
|
|
65
|
+
items: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
required: ['severity', 'check', 'text'],
|
|
68
|
+
properties: {
|
|
69
|
+
severity: { type: 'string', enum: SEVERITIES },
|
|
70
|
+
check: { type: 'string', enum: PLAN_REVIEW_CHECKS },
|
|
71
|
+
text: { type: 'string' },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** @param {unknown} v @returns {v is Record<string, unknown>} */
|
|
79
|
+
function isPlainObject(v) {
|
|
80
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {Record<string, unknown>} obj
|
|
85
|
+
* @param {string[]} required
|
|
86
|
+
* @param {string[]} allowed
|
|
87
|
+
* @param {string} where
|
|
88
|
+
* @returns {string|null}
|
|
89
|
+
*/
|
|
90
|
+
function checkKeys(obj, required, allowed, where) {
|
|
91
|
+
for (const k of required) if (!(k in obj)) return `${where}: missing ${k}`;
|
|
92
|
+
for (const k of Object.keys(obj)) if (!allowed.includes(k)) return `${where}: unexpected key ${k}`;
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {unknown} f
|
|
98
|
+
* @param {string} where
|
|
99
|
+
* @param {boolean} prdLevel
|
|
100
|
+
* @returns {string|null}
|
|
101
|
+
*/
|
|
102
|
+
function checkFinding(f, where, prdLevel) {
|
|
103
|
+
if (!isPlainObject(f)) return `${where}: not an object`;
|
|
104
|
+
const keyErr = checkKeys(
|
|
105
|
+
f,
|
|
106
|
+
['severity', 'check', 'text'],
|
|
107
|
+
prdLevel ? ['severity', 'check', 'text', 'suggestedEdit', 'field'] : ['severity', 'check', 'text'],
|
|
108
|
+
where,
|
|
109
|
+
);
|
|
110
|
+
if (keyErr) return keyErr;
|
|
111
|
+
if (!SEVERITIES.includes(/** @type {string} */ (f.severity))) return `${where}.severity: not one of ${SEVERITIES.join(', ')}`;
|
|
112
|
+
if (!PLAN_REVIEW_CHECKS.includes(/** @type {string} */ (f.check))) return `${where}.check: unknown check ${String(f.check)}`;
|
|
113
|
+
if (typeof f.text !== 'string') return `${where}.text: not a string`;
|
|
114
|
+
if (f.suggestedEdit !== undefined && typeof f.suggestedEdit !== 'string') return `${where}.suggestedEdit: not a string`;
|
|
115
|
+
if (f.field !== undefined && typeof f.field !== 'string') return `${where}.field: not a string`;
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* parsePlanReview(value, { expected }) → { ok, value | error }.
|
|
121
|
+
* `expected` is the list (array or Set) of PRD slugs the review must cover
|
|
122
|
+
* exactly: none missing, none extra, none duplicated.
|
|
123
|
+
* @param {unknown} value
|
|
124
|
+
* @param {{ expected?: Iterable<string>|null }} [opts]
|
|
125
|
+
* @returns {ParseResult}
|
|
126
|
+
*/
|
|
127
|
+
function parsePlanReview(value, opts = {}) {
|
|
128
|
+
try {
|
|
129
|
+
if (!isPlainObject(value)) return { ok: false, error: 'review: not an object' };
|
|
130
|
+
const keyErr = checkKeys(value, ['prds', 'planFindings'], ['prds', 'planFindings'], 'review');
|
|
131
|
+
if (keyErr) return { ok: false, error: keyErr };
|
|
132
|
+
if (!Array.isArray(value.prds)) return { ok: false, error: 'prds: not an array' };
|
|
133
|
+
if (!Array.isArray(value.planFindings)) return { ok: false, error: 'planFindings: not an array' };
|
|
134
|
+
/** @type {Set<string>} */
|
|
135
|
+
const seen = new Set();
|
|
136
|
+
for (let i = 0; i < value.prds.length; i++) {
|
|
137
|
+
const where = `prds[${i}]`;
|
|
138
|
+
const p = value.prds[i];
|
|
139
|
+
if (!isPlainObject(p)) return { ok: false, error: `${where}: not an object` };
|
|
140
|
+
const pe = checkKeys(p, ['prd', 'decision', 'findings'], ['prd', 'decision', 'findings'], where);
|
|
141
|
+
if (pe) return { ok: false, error: pe };
|
|
142
|
+
if (typeof p.prd !== 'string' || !p.prd) return { ok: false, error: `${where}.prd: not a non-empty string` };
|
|
143
|
+
if (seen.has(p.prd)) return { ok: false, error: `${where}.prd: duplicate ${p.prd}` };
|
|
144
|
+
seen.add(p.prd);
|
|
145
|
+
if (!DECISIONS.includes(/** @type {string} */ (p.decision))) {
|
|
146
|
+
return { ok: false, error: `${where}.decision: not one of ${DECISIONS.join(', ')}` };
|
|
147
|
+
}
|
|
148
|
+
if (!Array.isArray(p.findings)) return { ok: false, error: `${where}.findings: not an array` };
|
|
149
|
+
for (let j = 0; j < p.findings.length; j++) {
|
|
150
|
+
const err = checkFinding(p.findings[j], `${where}.findings[${j}]`, true);
|
|
151
|
+
if (err) return { ok: false, error: err };
|
|
152
|
+
}
|
|
153
|
+
if (p.decision !== 'ok' && p.findings.length === 0) {
|
|
154
|
+
return { ok: false, error: `${where}: decision ${p.decision} needs at least one finding` };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
for (let i = 0; i < value.planFindings.length; i++) {
|
|
158
|
+
const err = checkFinding(value.planFindings[i], `planFindings[${i}]`, false);
|
|
159
|
+
if (err) return { ok: false, error: err };
|
|
160
|
+
}
|
|
161
|
+
if (opts && opts.expected) {
|
|
162
|
+
const exp = new Set(opts.expected);
|
|
163
|
+
for (const slug of exp) if (!seen.has(slug)) return { ok: false, error: `prds: missing ${slug}` };
|
|
164
|
+
for (const slug of seen) if (!exp.has(slug)) return { ok: false, error: `prds: unexpected ${slug}` };
|
|
165
|
+
}
|
|
166
|
+
return { ok: true, value: /** @type {PlanReview} */ (/** @type {unknown} */ (value)) };
|
|
167
|
+
} catch (err) {
|
|
168
|
+
return { ok: false, error: `review: ${err instanceof Error ? err.message : String(err)}` };
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* True only when every PRD decision is ok and planFindings is empty.
|
|
174
|
+
* @param {PlanReview} review
|
|
175
|
+
* @returns {boolean}
|
|
176
|
+
*/
|
|
177
|
+
function isAllOk(review) {
|
|
178
|
+
if (!review || !Array.isArray(review.prds) || !Array.isArray(review.planFindings)) return false;
|
|
179
|
+
return review.planFindings.length === 0 && review.prds.every((p) => p && p.decision === 'ok');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
module.exports = { PLAN_REVIEW_SCHEMA, PLAN_REVIEW_CHECKS, parsePlanReview, isAllOk };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* planReviewStats.cjs — pure aggregate comparing an Epic's reviewed plans (a
|
|
5
|
+
* stored plan-review record with a release) against its unreviewed ones, on
|
|
6
|
+
* review findings accepted/rejected, validator findings, REFUTED verdicts and
|
|
7
|
+
* fixes[] escapes (missKind spec-gap | missing-test).
|
|
8
|
+
*
|
|
9
|
+
* A plan is a validate slug. A PRD belongs to a reviewed plan when it appears
|
|
10
|
+
* in that record's reviews[].review.prds[].prd (bare slug). Every other verdict
|
|
11
|
+
* or fix is unreviewed; unreviewed `plans` counts the distinct `validator` slugs (else `plan`) a
|
|
12
|
+
* verdict entry carries; a record with no stored review or a timeout release is not reviewed (entries with none add to the totals only).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const ESCAPE_KINDS = new Set(['spec-gap', 'missing-test']);
|
|
16
|
+
const isObj = (v) => v != null && typeof v === 'object' && !Array.isArray(v);
|
|
17
|
+
const bare = (s) => String(s).replace(/^\d+-/, '');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {{ planReviews?: any[], verdictFiles?: any[], fixes?: any[] }} [input]
|
|
21
|
+
*/
|
|
22
|
+
function planReviewStats({ planReviews, verdictFiles, fixes } = {}) {
|
|
23
|
+
const reviewed = { plans: 0, acceptedFindings: 0, rejectedFindings: 0, validatorFindings: 0, refuted: 0, escapes: 0 };
|
|
24
|
+
const unreviewed = { plans: 0, validatorFindings: 0, refuted: 0, escapes: 0 };
|
|
25
|
+
const member = new Map(); // bare prd slug -> validateSlug of a reviewed plan
|
|
26
|
+
|
|
27
|
+
for (const rec of Array.isArray(planReviews) ? planReviews : []) {
|
|
28
|
+
if (!isObj(rec) || !isObj(rec.release)) continue;
|
|
29
|
+
if (!Array.isArray(rec.reviews) || rec.reviews.length === 0) continue;
|
|
30
|
+
if (rec.release.by === 'timeout') continue;
|
|
31
|
+
reviewed.plans += 1;
|
|
32
|
+
const acc = rec.release.accepted;
|
|
33
|
+
if (Number.isFinite(acc)) reviewed.acceptedFindings += acc;
|
|
34
|
+
if (Array.isArray(rec.release.rejected)) reviewed.rejectedFindings += rec.release.rejected.length;
|
|
35
|
+
for (const r of Array.isArray(rec.reviews) ? rec.reviews : []) {
|
|
36
|
+
const prds = isObj(r) && isObj(r.review) && Array.isArray(r.review.prds) ? r.review.prds : [];
|
|
37
|
+
for (const p of prds) if (isObj(p) && typeof p.prd === 'string') member.set(bare(p.prd), rec.validateSlug);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const unreviewedPlanKeys = new Set();
|
|
42
|
+
for (const v of Array.isArray(verdictFiles) ? verdictFiles : []) {
|
|
43
|
+
if (!isObj(v) || typeof v.prd !== 'string') continue;
|
|
44
|
+
const target = member.has(bare(v.prd)) ? reviewed : unreviewed;
|
|
45
|
+
if (target === unreviewed) {
|
|
46
|
+
const raw = typeof v.validator === 'string' && v.validator ? v.validator : v.plan;
|
|
47
|
+
const key = typeof raw === 'string' && raw ? bare(raw) : null;
|
|
48
|
+
if (key) unreviewedPlanKeys.add(key);
|
|
49
|
+
}
|
|
50
|
+
target.validatorFindings += Array.isArray(v.findings) ? v.findings.length : 0;
|
|
51
|
+
if (v.verdict === 'REFUTED') target.refuted += 1;
|
|
52
|
+
}
|
|
53
|
+
unreviewed.plans = unreviewedPlanKeys.size;
|
|
54
|
+
|
|
55
|
+
for (const f of Array.isArray(fixes) ? fixes : []) {
|
|
56
|
+
if (!isObj(f) || typeof f.prd !== 'string' || !ESCAPE_KINDS.has(f.missKind)) continue;
|
|
57
|
+
(member.has(bare(f.prd)) ? reviewed : unreviewed).escapes += 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { reviewed, unreviewed };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = { planReviewStats };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* planReviewStore.cjs — read/write `plan-records/<epic>/<validate-slug>.plan-review.json`:
|
|
5
|
+
* the independent plan review(s), the round count, and the release record.
|
|
6
|
+
* Writes go through opsPath + writeJsonAtomic as the plan-records namespace's
|
|
7
|
+
* owner ('scheduler'). Unsafe ids/slugs are refused before any path is built.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const fs = require('node:fs');
|
|
11
|
+
const { opsPath, assertOpsWrite } = require('../opsOwnership.cjs');
|
|
12
|
+
const { writeJsonAtomic } = require('../util/atomicFs.cjs');
|
|
13
|
+
const { EPIC_ID_RE } = require('./planRecordHarvest.cjs');
|
|
14
|
+
|
|
15
|
+
const NAMESPACE = 'plan-records';
|
|
16
|
+
const WRITER = 'scheduler';
|
|
17
|
+
const SUFFIX = '.plan-review.json';
|
|
18
|
+
const SLUG_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
19
|
+
const RELEASE_BY = ['planner', 'auto', 'timeout'];
|
|
20
|
+
|
|
21
|
+
function safeIds(epicId, validateSlug) {
|
|
22
|
+
return typeof epicId === 'string' && EPIC_ID_RE.test(epicId)
|
|
23
|
+
&& typeof validateSlug === 'string' && SLUG_RE.test(validateSlug)
|
|
24
|
+
&& !validateSlug.includes('..');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function assertSafe(epicId, validateSlug) {
|
|
28
|
+
if (!safeIds(epicId, validateSlug)) {
|
|
29
|
+
throw new Error('planReviewStore: unsafe epicId or validateSlug');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Absolute record path; throws on an unsafe epicId/slug. */
|
|
34
|
+
function planReviewPath(cwd, epicId, validateSlug) {
|
|
35
|
+
assertSafe(epicId, validateSlug);
|
|
36
|
+
return opsPath(cwd, NAMESPACE, epicId, `${validateSlug}${SUFFIX}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function readFile(file) {
|
|
40
|
+
try {
|
|
41
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
42
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : null;
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The record, or null when missing, malformed, or the ids are unsafe. */
|
|
49
|
+
function readPlanReview(cwd, epicId, validateSlug) {
|
|
50
|
+
if (!safeIds(epicId, validateSlug)) return null;
|
|
51
|
+
return readFile(planReviewPath(cwd, epicId, validateSlug));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function writeRecord(cwd, record) {
|
|
55
|
+
const file = planReviewPath(cwd, record.epicId, record.validateSlug);
|
|
56
|
+
assertOpsWrite(file, WRITER);
|
|
57
|
+
await writeJsonAtomic(file, record);
|
|
58
|
+
return file;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Append one review round; the record's `round` becomes the saved round. */
|
|
62
|
+
async function savePlanReviewResult({
|
|
63
|
+
cwd, epicId, validateSlug, round, reviewer, runId, model, review,
|
|
64
|
+
} = {}) {
|
|
65
|
+
assertSafe(epicId, validateSlug);
|
|
66
|
+
const prior = readPlanReview(cwd, epicId, validateSlug);
|
|
67
|
+
const reviews = prior && Array.isArray(prior.reviews) ? prior.reviews.slice() : [];
|
|
68
|
+
const n = Number.isFinite(round) ? round : reviews.length + 1;
|
|
69
|
+
reviews.push({ round: n, at: new Date().toISOString(), reviewer, runId, model, review });
|
|
70
|
+
const record = {
|
|
71
|
+
...(prior || {}),
|
|
72
|
+
validateSlug,
|
|
73
|
+
epicId,
|
|
74
|
+
round: n,
|
|
75
|
+
reviews,
|
|
76
|
+
release: prior && prior.release ? prior.release : null,
|
|
77
|
+
};
|
|
78
|
+
if (n === 2) record.rereviewRequested = false;
|
|
79
|
+
await writeRecord(cwd, record);
|
|
80
|
+
return record;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Record the release once. An already-released record is left untouched. */
|
|
84
|
+
async function recordPlanRelease({
|
|
85
|
+
cwd, epicId, validateSlug, by, rejected = [], accepted = 0,
|
|
86
|
+
} = {}) {
|
|
87
|
+
assertSafe(epicId, validateSlug);
|
|
88
|
+
if (!RELEASE_BY.includes(by)) throw new Error(`planReviewStore: bad release actor '${by}'`);
|
|
89
|
+
const prior = readPlanReview(cwd, epicId, validateSlug);
|
|
90
|
+
if (prior && prior.release) return { alreadyReleased: true };
|
|
91
|
+
const record = {
|
|
92
|
+
...(prior || {}),
|
|
93
|
+
validateSlug,
|
|
94
|
+
epicId,
|
|
95
|
+
round: prior && Number.isFinite(prior.round) ? prior.round : 0,
|
|
96
|
+
reviews: prior && Array.isArray(prior.reviews) ? prior.reviews : [],
|
|
97
|
+
release: {
|
|
98
|
+
at: new Date().toISOString(),
|
|
99
|
+
by,
|
|
100
|
+
rejected: (Array.isArray(rejected) ? rejected : []).map((r) => ({
|
|
101
|
+
finding: String(r && r.finding != null ? r.finding : ''),
|
|
102
|
+
reason: String(r && r.reason != null ? r.reason : ''),
|
|
103
|
+
})),
|
|
104
|
+
accepted: Number.isFinite(accepted) ? accepted : 0,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
await writeRecord(cwd, record);
|
|
108
|
+
return record;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Every readable record in an Epic's folder; [] for unsafe id/missing folder. */
|
|
112
|
+
function readPlanReviewFiles(cwd, epicId) {
|
|
113
|
+
if (typeof epicId !== 'string' || !EPIC_ID_RE.test(epicId)) return [];
|
|
114
|
+
const dir = opsPath(cwd, NAMESPACE, epicId);
|
|
115
|
+
let names;
|
|
116
|
+
try { names = fs.readdirSync(dir); } catch { return []; }
|
|
117
|
+
const out = [];
|
|
118
|
+
for (const name of names.sort()) {
|
|
119
|
+
if (!name.endsWith(SUFFIX)) continue;
|
|
120
|
+
const rec = readFile(`${dir}/${name}`);
|
|
121
|
+
if (rec) out.push(rec);
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = {
|
|
127
|
+
planReviewPath, readPlanReview, savePlanReviewResult, recordPlanRelease, readPlanReviewFiles,
|
|
128
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pure classifier: did the OS job sandbox itself refuse something the job
|
|
5
|
+
* tried? Such a failure is an environment limit, not a code defect — an
|
|
6
|
+
* auto-fix investigation runs in the same sandbox and hits the same wall
|
|
7
|
+
* (Self 1313 -> 1313-fix). Deliberately narrow: each pattern needs the
|
|
8
|
+
* sandbox-specific symptom AND its object on one line, so an ordinary EACCES
|
|
9
|
+
* in user code or the bare word "sandbox" never matches.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const PATTERNS = [
|
|
13
|
+
['claude-dir-write', /^(?=[^\n]*(?:denied|EPERM|EACCES|read-only|not permitted|\bblocked\b|\bblocks\b))[^\n]*?(?:sandbox[^\n]{0,80}\.claude\/|\.claude\/[^\n]{0,80}sandbox)|(?:Operation not permitted|Permission denied|Errno 30|Read-only file system|read-only filesystem)[^\n]{0,160}\.claude\/|\.claude\/[^\n]{0,160}(?:Operation not permitted|Permission denied|Errno 30|Read-only file system|read-only filesystem)/im],
|
|
14
|
+
['unix-socket', /(?:Operation not permitted)[^\n]{0,80}AF_UNIX|AF_UNIX[^\n]{0,80}Operation not permitted/i],
|
|
15
|
+
['readonly-tmp', /(?:Errno 30|Read-only file system)[^\n]{0,80}\/tmp|\/tmp[^\n]{0,80}(?:Errno 30|Read-only file system)/i],
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const MAX_BLOCK_LINES = 60;
|
|
19
|
+
const TRACEBACK_START = /^Traceback \(most recent call last\):/;
|
|
20
|
+
const ERROR_LINE = /(?:Operation not permitted|Errno 30|Read-only file system)/i;
|
|
21
|
+
|
|
22
|
+
const ENVIRONMENT_LIMIT_MESSAGE =
|
|
23
|
+
'environment limit (job sandbox), not a code bug — see PRD_AUTHORING.md#job-sandbox-limits';
|
|
24
|
+
|
|
25
|
+
/** @returns {null | { kind: 'claude-dir-write'|'unix-socket'|'readonly-tmp', evidence: string }} */
|
|
26
|
+
function detectSandboxEnvironmentLimit(text) {
|
|
27
|
+
if (typeof text !== 'string' || !text) return null;
|
|
28
|
+
for (const [kind, re] of PATTERNS) {
|
|
29
|
+
const m = re.exec(text);
|
|
30
|
+
if (m) return { kind, evidence: m[0].slice(0, 200) };
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Plain per-line detection (single-line matches only). */
|
|
36
|
+
function detectPerLine(text) {
|
|
37
|
+
if (typeof text !== 'string' || !text) return null;
|
|
38
|
+
for (const line of text.split(/\r?\n/)) {
|
|
39
|
+
const hit = detectSandboxEnvironmentLimit(line);
|
|
40
|
+
if (hit) return hit;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Bash tool_result bodies only: per-line detection, then a traceback-block
|
|
47
|
+
* scan. Anchor on an error line, look back to the nearest
|
|
48
|
+
* "Traceback (most recent call last):" (at most MAX_BLOCK_LINES lines) and
|
|
49
|
+
* classify unix-socket if AF_UNIX is in that block, readonly-tmp if /tmp is.
|
|
50
|
+
* A block ends at its exception line (the first non-indented line after the
|
|
51
|
+
* header), so a later unrelated line never joins it; each new header opens a
|
|
52
|
+
* fresh block (chained tracebacks work). Linear: one pass tracking the block start.
|
|
53
|
+
*/
|
|
54
|
+
function detectBashBody(text) {
|
|
55
|
+
if (typeof text !== 'string' || !text) return null;
|
|
56
|
+
const lines = text.split(/\r?\n/);
|
|
57
|
+
const direct = detectPerLine(text);
|
|
58
|
+
if (direct) return direct;
|
|
59
|
+
let start = -1;
|
|
60
|
+
for (let i = 0; i < lines.length; i++) {
|
|
61
|
+
if (TRACEBACK_START.test(lines[i])) { start = i; continue; }
|
|
62
|
+
if (start < 0 || lines[i].trim() === '' || /^\s/.test(lines[i])) continue;
|
|
63
|
+
// First non-indented line after the header is the exception line: the block ends here.
|
|
64
|
+
const blockStart = start;
|
|
65
|
+
start = -1;
|
|
66
|
+
if (!ERROR_LINE.test(lines[i]) || i - blockStart > MAX_BLOCK_LINES) continue;
|
|
67
|
+
const block = lines.slice(blockStart, i + 1).join('\n');
|
|
68
|
+
if (/Operation not permitted/i.test(lines[i]) && block.includes('AF_UNIX')) {
|
|
69
|
+
return { kind: 'unix-socket', evidence: lines[i].slice(0, 200) };
|
|
70
|
+
}
|
|
71
|
+
if (/Errno 30|Read-only file system/i.test(lines[i]) && block.includes('/tmp')) {
|
|
72
|
+
return { kind: 'readonly-tmp', evidence: lines[i].slice(0, 200) };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Detect a sandbox refusal in a stream-json log tail. Only text the sandbox
|
|
80
|
+
* itself produced is considered: decoded Bash tool_result content, and the
|
|
81
|
+
* executor's `SCHEDULER_VERDICT: FAIL <reason>` from the final result text.
|
|
82
|
+
* Text a job merely read (Read tool_result) or quoted (assistant text) is ignored.
|
|
83
|
+
* @param {string} text
|
|
84
|
+
* @returns {null | { kind: 'claude-dir-write'|'unix-socket'|'readonly-tmp', evidence: string }}
|
|
85
|
+
*/
|
|
86
|
+
function sandboxLimitFromStreamJson(text) {
|
|
87
|
+
if (typeof text !== 'string' || !text) return null;
|
|
88
|
+
const bashIds = new Set();
|
|
89
|
+
let hit = null;
|
|
90
|
+
let resultText = null;
|
|
91
|
+
let structuredOutput;
|
|
92
|
+
for (const raw of text.split('\n')) {
|
|
93
|
+
const line = raw.trim();
|
|
94
|
+
if (!line || line[0] !== '{') continue;
|
|
95
|
+
let ev;
|
|
96
|
+
try { ev = JSON.parse(line); } catch { continue; }
|
|
97
|
+
if (!ev || typeof ev !== 'object') continue;
|
|
98
|
+
if (ev.type === 'result' && typeof ev.result === 'string') {
|
|
99
|
+
resultText = ev.result;
|
|
100
|
+
const so = ev.structured_output ?? ev.structuredOutput;
|
|
101
|
+
if (so && typeof so === 'object' && !Array.isArray(so)) structuredOutput = so;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const content = ev.message && Array.isArray(ev.message.content) ? ev.message.content : null;
|
|
105
|
+
if (!content) continue;
|
|
106
|
+
for (const item of content) {
|
|
107
|
+
if (!item || typeof item !== 'object') continue;
|
|
108
|
+
if (ev.type === 'assistant' && item.type === 'tool_use' && item.name === 'Bash' && item.id) {
|
|
109
|
+
bashIds.add(item.id);
|
|
110
|
+
} else if (ev.type === 'user' && item.type === 'tool_result' && bashIds.has(item.tool_use_id)) {
|
|
111
|
+
if (hit || item.is_error !== true) continue;
|
|
112
|
+
const body = typeof item.content === 'string'
|
|
113
|
+
? item.content
|
|
114
|
+
: Array.isArray(item.content)
|
|
115
|
+
? item.content.filter((b) => b && b.type === 'text').map((b) => b.text ?? '').join('')
|
|
116
|
+
: '';
|
|
117
|
+
hit = detectBashBody(body);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (hit) return hit;
|
|
122
|
+
if (resultText || structuredOutput) {
|
|
123
|
+
// Lazy require: runVerify.cjs is large.
|
|
124
|
+
const { scanSentinelReason } = require('../../runVerify.cjs');
|
|
125
|
+
return detectPerLine(scanSentinelReason({ resultText, ...(structuredOutput ? { structuredOutput } : {}) }, []));
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Finalize stamp/clear decision for a job row.
|
|
132
|
+
* @returns {{ environmentLimit: object|null, error: string|null }}
|
|
133
|
+
*/
|
|
134
|
+
function environmentLimitStamp(sandboxLimit, status) {
|
|
135
|
+
if (sandboxLimit && (status === 'failed' || status === 'needs_review')) {
|
|
136
|
+
return { environmentLimit: sandboxLimit, error: ENVIRONMENT_LIMIT_MESSAGE };
|
|
137
|
+
}
|
|
138
|
+
return { environmentLimit: null, error: null };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = { detectSandboxEnvironmentLimit, sandboxLimitFromStreamJson, environmentLimitStamp, ENVIRONMENT_LIMIT_MESSAGE };
|
|
@@ -115,6 +115,8 @@ const ScheduleJobSchema = z
|
|
|
115
115
|
// quietMachineWaitMs without the machine going quiet — tells a reader the
|
|
116
116
|
// job's measurements ran under contention, not on a quiet machine.
|
|
117
117
|
quietLeaseDegraded: z.boolean().optional(),
|
|
118
|
+
// Set when the job sandbox itself refused the run (sandboxEnvironmentLimit.cjs); auto-fix skips such rows.
|
|
119
|
+
environmentLimit: z.object({ kind: z.string(), evidence: z.string() }).optional(),
|
|
118
120
|
// Salvaged uncommitted diff patch path (PRD 1098).
|
|
119
121
|
salvagePatch: z.string().nullable().optional(),
|
|
120
122
|
// Artifact evidence captured before the job worktree was removed, bound
|
|
@@ -74,6 +74,16 @@ function retireRestartRequest(file = schedulerPaths.restartRequestPath()) {
|
|
|
74
74
|
try { fs.unlinkSync(file); } catch (e) { if (e?.code !== 'ENOENT') throw e; }
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/** Never throws: { ok: true } or { ok: false, error } (for the forced-reboot path). */
|
|
78
|
+
function retireRestartRequestBestEffort(file = schedulerPaths.restartRequestPath()) {
|
|
79
|
+
try {
|
|
80
|
+
retireRestartRequest(file);
|
|
81
|
+
return { ok: true };
|
|
82
|
+
} catch (e) {
|
|
83
|
+
return { ok: false, error: e?.code || e?.message || String(e) };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
77
87
|
// ---------- pure state machine ----------
|
|
78
88
|
|
|
79
89
|
/**
|
|
@@ -88,20 +98,31 @@ function queueBusyCount(jobs, extraInFlight = 0) {
|
|
|
88
98
|
return n + (Number.isFinite(extraInFlight) ? extraInFlight : 0);
|
|
89
99
|
}
|
|
90
100
|
|
|
101
|
+
/** True when a request's requestedAt is earlier than bootedAt; unparsable/missing either → false. Pure. */
|
|
102
|
+
function requestPredatesBoot(request, bootedAt) {
|
|
103
|
+
const requestedMs = Date.parse(request?.requestedAt ?? '');
|
|
104
|
+
const bootedMs = typeof bootedAt === 'string' ? Date.parse(bootedAt) : NaN;
|
|
105
|
+
return Number.isFinite(requestedMs) && Number.isFinite(bootedMs) && requestedMs < bootedMs;
|
|
106
|
+
}
|
|
107
|
+
|
|
91
108
|
/**
|
|
92
|
-
* evaluateDrain({request, queueSnapshot, drainState, now, deadlineMs}) → {action, reason}
|
|
109
|
+
* evaluateDrain({request, queueSnapshot, drainState, now, deadlineMs, bootedAt}) → {action, reason}
|
|
93
110
|
*
|
|
94
111
|
* queueSnapshot: { running, investigating } counts (in-memory investigations
|
|
95
112
|
* already folded in by the caller). drainState: the machine `drain` field
|
|
96
|
-
* (null / {active}).
|
|
113
|
+
* (null / {active}). bootedAt: this process's boot time (ISO); a missing or
|
|
114
|
+
* unparsable value skips the predates-boot rule. Pure — no IO, no clock.
|
|
97
115
|
*
|
|
98
116
|
* no request, or request already completed → none (abort if a stale drain is still active)
|
|
117
|
+
* pending request written before bootedAt → abort (the restart it asked for already
|
|
118
|
+
* happened: force reboot, manual
|
|
119
|
+
* relaunch, or a crash before the stamp)
|
|
99
120
|
* deadline passed → abort
|
|
100
121
|
* request pending, drain not yet active → pause (engage drain)
|
|
101
122
|
* drain active, anything running/investigating → wait
|
|
102
123
|
* drain active, zero busy → restart
|
|
103
124
|
*/
|
|
104
|
-
function evaluateDrain({ request, queueSnapshot, drainState, now, deadlineMs = DEFAULT_DRAIN_DEADLINE_MS } = {}) {
|
|
125
|
+
function evaluateDrain({ request, queueSnapshot, drainState, now, deadlineMs = DEFAULT_DRAIN_DEADLINE_MS, bootedAt } = {}) {
|
|
105
126
|
const active = Boolean(drainState && drainState.active);
|
|
106
127
|
if (!request || request.drainCompletedAt) {
|
|
107
128
|
return active && !request
|
|
@@ -109,6 +130,9 @@ function evaluateDrain({ request, queueSnapshot, drainState, now, deadlineMs = D
|
|
|
109
130
|
: { action: 'none', reason: request ? 'request-complete' : 'no-request' };
|
|
110
131
|
}
|
|
111
132
|
const requestedMs = Date.parse(request.requestedAt ?? '');
|
|
133
|
+
if (requestPredatesBoot(request, bootedAt)) {
|
|
134
|
+
return { action: 'abort', reason: 'request-predates-boot' };
|
|
135
|
+
}
|
|
112
136
|
if (Number.isFinite(requestedMs) && now - requestedMs >= deadlineMs) {
|
|
113
137
|
return { action: 'abort', reason: 'deadline' };
|
|
114
138
|
}
|
|
@@ -118,12 +142,13 @@ function evaluateDrain({ request, queueSnapshot, drainState, now, deadlineMs = D
|
|
|
118
142
|
}
|
|
119
143
|
|
|
120
144
|
/**
|
|
121
|
-
* bootDrainAction({drainState, request}) → 'clear' | 'keep' | 'none'.
|
|
145
|
+
* bootDrainAction({drainState, request, bootedAt}) → 'clear' | 'keep' | 'none'.
|
|
122
146
|
* A drain whose request is complete (the restart happened) or gone is stale.
|
|
123
147
|
*/
|
|
124
|
-
function bootDrainAction({ drainState, request } = {}) {
|
|
148
|
+
function bootDrainAction({ drainState, request, bootedAt } = {}) {
|
|
125
149
|
if (!drainState || !drainState.active) return 'none';
|
|
126
150
|
if (!request || request.drainCompletedAt) return 'clear';
|
|
151
|
+
if (requestPredatesBoot(request, bootedAt)) return 'clear';
|
|
127
152
|
return 'keep';
|
|
128
153
|
}
|
|
129
154
|
|
|
@@ -168,9 +193,11 @@ module.exports = {
|
|
|
168
193
|
requestRestart,
|
|
169
194
|
stampDrainCompleted,
|
|
170
195
|
retireRestartRequest,
|
|
196
|
+
retireRestartRequestBestEffort,
|
|
171
197
|
queueBusyCount,
|
|
172
198
|
evaluateDrain,
|
|
173
199
|
bootDrainAction,
|
|
200
|
+
requestPredatesBoot,
|
|
174
201
|
effectivePaused,
|
|
175
202
|
installedBuildDiffers,
|
|
176
203
|
markRestarting,
|
|
@@ -26,7 +26,7 @@ const { HTTP_RETRY_ATTEMPTS, HTTP_RETRY_DELAY_MS } = require('./criteriaChecks.c
|
|
|
26
26
|
/** @typedef {{ id: string, met: boolean, evidence: string, missKind?: MissKind }} Criterion */
|
|
27
27
|
/** @typedef {{ severity: Severity, text: string, file?: string, missKind?: MissKind }} Finding */
|
|
28
28
|
/** @typedef {{ prd: string, verdict: 'VERIFIED'|'REFUTED', reason: string, criteria: Criterion[], findings: Finding[] }} VerdictEntry */
|
|
29
|
-
/** @typedef {{ schedulerVerdict: 'PASS'|'FAIL', failReason?: string, verdicts: VerdictEntry[] }} ValidatorVerdict */
|
|
29
|
+
/** @typedef {{ schedulerVerdict: 'PASS'|'FAIL', failReason?: string, lessons?: string[], verdicts: VerdictEntry[] }} ValidatorVerdict */
|
|
30
30
|
/** @typedef {{ slug: string, verdict: 'verified'|'refuted', reason: string, missKinds: MissKind[] }} VerdictRow */
|
|
31
31
|
/** @typedef {{ ids: string[], failedIds?: string[] }} ExpectedCriteria */
|
|
32
32
|
/** @typedef {Record<string, ExpectedCriteria> | Map<string, ExpectedCriteria>} ExpectedMap */
|
|
@@ -68,6 +68,12 @@ const VALIDATOR_VERDICT_SCHEMA = {
|
|
|
68
68
|
description: 'PASS when the validator run itself completed; FAIL when it could not judge the plan.',
|
|
69
69
|
},
|
|
70
70
|
failReason: { type: 'string', description: 'Why the run is FAIL.' },
|
|
71
|
+
lessons: {
|
|
72
|
+
type: 'array',
|
|
73
|
+
maxItems: 3,
|
|
74
|
+
description: 'Optional: at most 3 lessons a future run would need; usually omitted.',
|
|
75
|
+
items: { type: 'string', maxLength: 200 },
|
|
76
|
+
},
|
|
71
77
|
verdicts: {
|
|
72
78
|
type: 'array',
|
|
73
79
|
items: {
|
|
@@ -261,7 +267,7 @@ function checkExpectedCriteria(entry, exp, where) {
|
|
|
261
267
|
function parseValidatorVerdict(value, opts = {}) {
|
|
262
268
|
try {
|
|
263
269
|
if (!isPlainObject(value)) return { ok: false, error: 'verdict: not an object' };
|
|
264
|
-
const keyErr = checkKeys(value, ['schedulerVerdict', 'verdicts'], ['schedulerVerdict', 'failReason', 'verdicts'], 'verdict');
|
|
270
|
+
const keyErr = checkKeys(value, ['schedulerVerdict', 'verdicts'], ['schedulerVerdict', 'failReason', 'lessons', 'verdicts'], 'verdict');
|
|
265
271
|
if (keyErr) return { ok: false, error: keyErr };
|
|
266
272
|
if (value.schedulerVerdict !== 'PASS' && value.schedulerVerdict !== 'FAIL') {
|
|
267
273
|
return { ok: false, error: 'schedulerVerdict: not PASS or FAIL' };
|
|
@@ -269,6 +275,10 @@ function parseValidatorVerdict(value, opts = {}) {
|
|
|
269
275
|
if (value.failReason !== undefined && typeof value.failReason !== 'string') {
|
|
270
276
|
return { ok: false, error: 'failReason: not a string' };
|
|
271
277
|
}
|
|
278
|
+
if (value.lessons !== undefined) {
|
|
279
|
+
if (!Array.isArray(value.lessons) || value.lessons.length > 3) return { ok: false, error: 'lessons: not an array of at most 3' };
|
|
280
|
+
if (value.lessons.some((l) => typeof l !== 'string' || l.length > 200)) return { ok: false, error: 'lessons: each must be a string of at most 200 chars' };
|
|
281
|
+
}
|
|
272
282
|
if (!Array.isArray(value.verdicts)) return { ok: false, error: 'verdicts: not an array' };
|
|
273
283
|
const expected = opts && (opts.expected instanceof Map || isPlainObject(opts.expected)) ? opts.expected : null;
|
|
274
284
|
/** @type {Set<string>} */
|