claude-code-session-manager 0.144.0 → 0.146.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.
Files changed (66) hide show
  1. package/dist/assets/{AppSettings-Z68gQiVE.js → AppSettings-BXfkoKQq.js} +2 -2
  2. package/dist/assets/{History-C3E6y_7t.js → History-l7pBt_vO.js} +1 -1
  3. package/dist/assets/HomeClaudeConfig-DtFwZxTx.js +5 -0
  4. package/dist/assets/{Panel-CnfWs46Z.js → Panel-C5hihgUD.js} +1 -1
  5. package/dist/assets/{ProjectClaudeConfig-CP0Wsg-H.js → ProjectClaudeConfig-B3pODrM-.js} +1 -1
  6. package/dist/assets/{Scheduler-D8un7N3B.js → Scheduler-IU9wo8_u.js} +1 -1
  7. package/dist/assets/{SkillReferenceGraph-DRtZV1Al.js → SkillReferenceGraph-Bmen0OOC.js} +1 -1
  8. package/dist/assets/{Skills-Bg5O2Hyn.js → Skills-jYVxqJr2.js} +1 -1
  9. package/dist/assets/{TiptapBody-BdzoBmqu.js → TiptapBody-Dp2gtbb-.js} +1 -1
  10. package/dist/assets/{Toggle-Dt5K1OXt.js → Toggle-C_0yUCS5.js} +1 -1
  11. package/dist/assets/{VoiceButton-CTLyRgdF.js → VoiceButton-BRPzqDa-.js} +1 -1
  12. package/dist/assets/{historyTotals-B2_KWBga.js → historyTotals-pAv-MFnY.js} +1 -1
  13. package/dist/assets/{index-446b69rr.js → index-C6nhp7m_.js} +496 -496
  14. package/dist/index.html +1 -1
  15. package/dist-web/app.js +427 -427
  16. package/package.json +1 -1
  17. package/plugins/session-manager-dev/skills/develop/SKILL.md +11 -6
  18. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +1 -1
  19. package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +8 -4
  20. package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +13 -8
  21. package/scripts/scheduler-mcp-server.cjs +4 -3
  22. package/src/main/adminRouteRegistry.cjs +1 -1
  23. package/src/main/build-info.json +4 -4
  24. package/src/main/chatRunner.cjs +35 -5
  25. package/src/main/config.cjs +12 -0
  26. package/src/main/index.cjs +2 -2
  27. package/src/main/ipcSchemas.cjs +5 -0
  28. package/src/main/lib/claude/claudeJsonApproval.cjs +129 -0
  29. package/src/main/lib/claude/headlessMcpServers.cjs +1 -1
  30. package/src/main/lib/claude/personaToolScope.cjs +23 -8
  31. package/src/main/lib/demo-video-kit/resumableRun.cjs +36 -15
  32. package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
  33. package/src/main/lib/epic/epicOutsideRead.cjs +43 -8
  34. package/src/main/lib/epic/epicSpawnCwd.cjs +1 -0
  35. package/src/main/lib/epic/planReviewInput.cjs +5 -6
  36. package/src/main/lib/epic/scriptStartedBy.cjs +19 -4
  37. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +219 -48
  38. package/src/main/lib/feedback-remote/localAdminHttp.cjs +5 -1
  39. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +6 -3
  40. package/src/main/lib/feedback-remote/serviceMcpTools.cjs +23 -3
  41. package/src/main/lib/feedback-remote/servicePairings.cjs +48 -0
  42. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +11 -6
  43. package/src/main/lib/git/gitWorktree.cjs +17 -0
  44. package/src/main/lib/mcpToolCatalog.cjs +6 -3
  45. package/src/main/lib/opsOwnership.cjs +2 -0
  46. package/src/main/lib/prd/prdCreate.cjs +2 -1
  47. package/src/main/lib/prd/prdMcpReachWarnings.cjs +3 -1
  48. package/src/main/lib/prd/prdSandboxWarnings.cjs +1 -1
  49. package/src/main/lib/scheduler/planReleaseRoute.cjs +53 -5
  50. package/src/main/lib/scheduler/planReviewStore.cjs +24 -2
  51. package/src/main/lib/scheduler/rcaReport.cjs +1 -0
  52. package/src/main/lib/scheduler/reviewNotice.cjs +3 -1
  53. package/src/main/lib/scheduler/terminalRunOutcome.cjs +1 -0
  54. package/src/main/lib/tasks/memoryConsolidation.cjs +21 -12
  55. package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +131 -11
  56. package/src/main/runVerify.cjs +107 -3
  57. package/src/main/scheduler/gitTreeGuard.cjs +6 -0
  58. package/src/main/scheduler/planReviewHold.cjs +11 -5
  59. package/src/main/scheduler/prdPaths.cjs +10 -1
  60. package/src/main/scheduler.cjs +230 -27
  61. package/src/main/templates/PRD_AUTHORING.md +2 -2
  62. package/src/main/webRemote.cjs +22 -0
  63. package/src/preload/api.d.ts +8 -0
  64. package/src/preload/apiSurface.json +11 -0
  65. package/src/preload/index.cjs +2 -0
  66. package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +0 -5
@@ -18,6 +18,65 @@ const MAX_TRANSCRIPTS = 200;
18
18
  const MAX_LESSON_LINES = 3;
19
19
  const MAX_LESSON_CHARS = 200;
20
20
  const HEAD_BYTES = 64 * 1024;
21
+ const HISTORY_CHUNK = 256 * 1024;
22
+ const HISTORY_SLACK_ROWS = 200;
23
+ const DAY_MS = 24 * 60 * 60 * 1000;
24
+
25
+ /**
26
+ * Read a JSONL history file backwards in fixed chunks (bounded memory) and
27
+ * return parsed rows newest-first, stopping at the first row finished before
28
+ * sinceMs (after a bounded slack of HISTORY_SLACK_ROWS further rows, so a few
29
+ * out-of-order rows are still collected), or the file start. No row/byte cap
30
+ * can stop inside the window. Returns { rows, partial }; partial = a read error
31
+ * cut the scan short.
32
+ */
33
+ function readHistorySince(file, sinceMs, chunkBytes = HISTORY_CHUNK) {
34
+ const out = [];
35
+ let partial = false;
36
+ let slack = -1; // -1 = no pre-window row seen yet
37
+ let fd;
38
+ try {
39
+ fd = fs.openSync(file, 'r');
40
+ let pos = fs.fstatSync(fd).size;
41
+ let carry = Buffer.alloc(0);
42
+ let done = false;
43
+ const take = (line) => {
44
+ const t = line.trim();
45
+ if (!t) return;
46
+ let row;
47
+ try { row = JSON.parse(t); } catch { return; }
48
+ if (!row || typeof row !== 'object') return;
49
+ const f = toMs(row.finishedAt);
50
+ if (slack >= 0) {
51
+ if (slack-- <= 0) { done = true; return; }
52
+ }
53
+ if (f !== null && f < sinceMs) { if (slack < 0) slack = HISTORY_SLACK_ROWS; return; }
54
+ out.push(row);
55
+ };
56
+ while (pos > 0 && !done) {
57
+ const len = Math.min(chunkBytes, pos);
58
+ pos -= len;
59
+ const chunk = Buffer.alloc(len);
60
+ fs.readSync(fd, chunk, 0, len, pos);
61
+ const buf = Buffer.concat([chunk, carry]);
62
+ let end = buf.length;
63
+ let nl = buf.lastIndexOf(0x0a, end - 1);
64
+ while (nl >= 0 && !done) {
65
+ take(buf.toString('utf8', nl + 1, end));
66
+ end = nl;
67
+ nl = end > 0 ? buf.lastIndexOf(0x0a, end - 1) : -1;
68
+ }
69
+ carry = Buffer.from(buf.subarray(0, end));
70
+ }
71
+ if (!done && pos === 0 && carry.length) take(carry.toString('utf8'));
72
+ } catch (e) {
73
+ // A missing history file is just empty; any other error is a partial read.
74
+ if (!(e && e.code === 'ENOENT')) partial = true;
75
+ } finally {
76
+ if (fd !== undefined) try { fs.closeSync(fd); } catch { /* ignore */ }
77
+ }
78
+ return { rows: out, partial };
79
+ }
21
80
 
22
81
  function toMs(v) {
23
82
  if (typeof v === 'number' && Number.isFinite(v)) return v;
@@ -51,6 +110,17 @@ function defaultDeps() {
51
110
  },
52
111
  mainRootOf: (cwd) => require('../cwdClassify.cjs').worktreeMainRootOf(cwd),
53
112
  readJobs: () => require('../scheduler/queueStore.cjs').readMergedSync().jobs,
113
+ // Finished jobs leave the queue for the per-project history shard.
114
+ readHistory: (cwd, sinceMs) => {
115
+ const { projectHistoryPath } = require('../scheduler/queueStore.cjs');
116
+ return readHistorySince(projectHistoryPath(cwd), sinceMs);
117
+ },
118
+ // The project key gitWorktree mints into <root>/<key>/<name> (same function).
119
+ worktreeKeyOf: (cwd) => {
120
+ const { worktreeDirFor } = require('../git/gitWorktree.cjs');
121
+ return path.basename(path.dirname(worktreeDirFor('epic', cwd, 'x')));
122
+ },
123
+ runsDir: () => require('../scheduler/schedulerPaths.cjs').runsDir(),
54
124
  readResultText: (logPath) => require('../../scheduler.cjs').extractResultTextFromLog(logPath),
55
125
  readStructured: (logPath) => require('../../scheduler.cjs').extractStructuredOutputFromLog(logPath),
56
126
  };
@@ -67,7 +137,18 @@ function belongsToProject(sessionCwd, root, d) {
67
137
  if (norm(sessionCwd) === norm(root)) return true;
68
138
  let main = null;
69
139
  try { main = d.mainRootOf(sessionCwd); } catch { main = null; }
70
- return !!main && norm(main) === norm(root);
140
+ if (main && norm(main) === norm(root)) return true;
141
+ return deadWorktreeOf(sessionCwd, root, d);
142
+ }
143
+
144
+ /** Dead managed worktree (git admin gone): match the project key in its path. */
145
+ function deadWorktreeOf(sessionCwd, root, d) {
146
+ const parts = path.resolve(sessionCwd).split(path.sep);
147
+ const i = parts.findIndex((p) => p === 'session-manager-epic-worktrees' || p === 'session-manager-job-worktrees');
148
+ if (i < 0 || !parts[i + 1]) return false;
149
+ let key = null;
150
+ try { key = d.worktreeKeyOf(root); } catch { key = null; }
151
+ return !!key && parts[i + 1] === key;
71
152
  }
72
153
 
73
154
  /**
@@ -78,7 +159,7 @@ function listProjectTranscripts({ cwd, sinceMs, untilMs, deps } = {}) {
78
159
  const d = withDefaults(deps);
79
160
  const range = { since: sinceMs, until: untilMs };
80
161
  const found = [];
81
- if (!cwd || typeof cwd !== 'string') return { transcripts: [], truncated: 0, total: 0, range };
162
+ if (!cwd || typeof cwd !== 'string') return { transcripts: [], truncated: 0, total: 0, perDay: [], range };
82
163
  const enc = encodeCwd(cwd);
83
164
  for (const folder of d.readdir(d.projectsDir) || []) {
84
165
  // Cheap name filter first: the project's own folder (or a sibling sharing its
@@ -102,8 +183,30 @@ function listProjectTranscripts({ cwd, sinceMs, untilMs, deps } = {}) {
102
183
  for (const f of inWin) found.push({ path: f.file, sessionId: f.name.slice(0, -'.jsonl'.length), mtimeMs: f.mtimeMs, cwd: sessionCwd });
103
184
  }
104
185
  found.sort((a, b) => b.mtimeMs - a.mtimeMs || (a.path < b.path ? -1 : 1));
105
- const transcripts = found.slice(0, MAX_TRANSCRIPTS);
106
- return { transcripts, truncated: found.length - transcripts.length, total: found.length, range };
186
+ // Spread the cap over the window's days: round-robin one transcript per day
187
+ // (newest day first, newest first within a day) so unused share passes on.
188
+ const days = new Map();
189
+ for (const f of found) {
190
+ const k = Math.floor((f.mtimeMs - sinceMs) / DAY_MS);
191
+ if (!days.has(k)) days.set(k, []);
192
+ days.get(k).push(f);
193
+ }
194
+ const order = [...days.keys()].sort((a, b) => b - a);
195
+ const kept = new Map(order.map((k) => [k, 0]));
196
+ let n = 0;
197
+ for (let round = 0; n < MAX_TRANSCRIPTS; round++) {
198
+ let any = false;
199
+ for (const k of order) {
200
+ if (n >= MAX_TRANSCRIPTS) break;
201
+ if (round < days.get(k).length) { kept.set(k, round + 1); n++; any = true; }
202
+ }
203
+ if (!any) break;
204
+ }
205
+ const transcripts = [];
206
+ for (const k of order) transcripts.push(...days.get(k).slice(0, kept.get(k)));
207
+ transcripts.sort((a, b) => b.mtimeMs - a.mtimeMs || (a.path < b.path ? -1 : 1));
208
+ const perDay = order.map((k) => ({ dayStartMs: sinceMs + k * DAY_MS, total: days.get(k).length, kept: kept.get(k) }));
209
+ return { transcripts, truncated: found.length - transcripts.length, total: found.length, perDay, range };
107
210
  }
108
211
 
109
212
  function clip(s) {
@@ -144,17 +247,34 @@ function collectLessons({ cwd, sinceMs, untilMs, deps } = {}) {
144
247
  const range = { since: sinceMs, until: untilMs };
145
248
  const lessons = [];
146
249
  if (!cwd || typeof cwd !== 'string') return { lessons, range };
147
- let jobs = [];
148
- try { jobs = d.readJobs(cwd) || []; } catch { jobs = []; }
250
+ let live = [];
251
+ try { live = d.readJobs(cwd) || []; } catch { live = []; }
252
+ let hist = [];
253
+ let lessonsPartial = false;
254
+ try {
255
+ const h = d.readHistory(cwd, sinceMs);
256
+ if (Array.isArray(h)) hist = h;
257
+ else if (h && Array.isArray(h.rows)) { hist = h.rows; lessonsPartial = !!h.partial; }
258
+ } catch { hist = []; lessonsPartial = true; }
259
+ const seen = new Set();
260
+ const jobs = [];
261
+ for (const j of [...live, ...hist]) {
262
+ if (!j || typeof j !== 'object') continue;
263
+ const id = j.id ?? j.runId;
264
+ if (id != null) { if (seen.has(id)) continue; seen.add(id); }
265
+ jobs.push(j);
266
+ }
149
267
  for (const job of jobs) {
150
- if (!job || typeof job !== 'object' || !job.finishedAt) continue;
268
+ if (!job || typeof job !== 'object' || !job.finishedAt || !job.runId || !job.slug) continue;
151
269
  if (!belongsToProject(job.cwd, cwd, d)) continue;
152
270
  if (!inWindow(toMs(job.finishedAt), sinceMs, untilMs)) continue;
153
271
  const jobId = job.id ?? job.runId ?? null;
154
272
  const slug = job.slug ?? null;
273
+ let logPath = null;
274
+ try { logPath = path.join(d.runsDir(), String(job.runId), `${job.slug}.log`); } catch { continue; }
155
275
  if (job.agentType === 'validator') {
156
276
  let so = null;
157
- try { so = d.readStructured(job.logPath); } catch { so = null; }
277
+ try { so = d.readStructured(logPath); } catch { so = null; }
158
278
  if (!so || typeof so !== 'object') continue;
159
279
  const top = lessonsFromField(so.lessons);
160
280
  if (top.length) lessons.push({ slug, jobId, source: 'validator', lines: top });
@@ -164,15 +284,15 @@ function collectLessons({ cwd, sinceMs, untilMs, deps } = {}) {
164
284
  }
165
285
  } else {
166
286
  let text = null;
167
- try { text = d.readResultText(job.logPath); } catch { text = null; }
287
+ try { text = d.readResultText(logPath); } catch { text = null; }
168
288
  const lines = parseLessonsBlock(text);
169
289
  if (lines.length) lessons.push({ slug, jobId, source: 'dev-lead', lines });
170
290
  }
171
291
  }
172
- return { lessons, range };
292
+ return lessonsPartial ? { lessons, range, lessonsPartial: true } : { lessons, range };
173
293
  }
174
294
 
175
295
  module.exports = {
176
- listProjectTranscripts, collectLessons, parseLessonsBlock, inWindow,
296
+ listProjectTranscripts, collectLessons, readHistorySince, HISTORY_SLACK_ROWS, parseLessonsBlock, inWindow,
177
297
  MAX_TRANSCRIPTS, MAX_LESSON_LINES, MAX_LESSON_CHARS,
178
298
  };
@@ -30,6 +30,7 @@
30
30
  * abandoned_background_task → 'needs_review'
31
31
  * run_commit_not_landed → 'needs_review' (PASS but transcript SHA unreachable)
32
32
  * pass_no_commit_already_shipped → historical rows only; no longer emitted
33
+ * pass_no_commit_plan_review → null (plan-reviewer's structured review is the deliverable)
33
34
  *
34
35
  * Time complexity: O(N·L) where N = log line count, L = avg content line count.
35
36
  * The log is read once with readFileSync (700 KB typical; well within Node.js
@@ -99,14 +100,15 @@ function extractContent(item) {
99
100
  *
100
101
  * O(N) where N = log line count.
101
102
  *
102
- * @returns {{ events: object[], resultEvent: object|null, error: string|null }}
103
+ * @returns {{ events: object[], resultEvent: object|null, error: string|null, transcriptCommitLanded?: boolean, transcriptCommitShas: string[], transcriptCommitOutputShas: string[] }}
104
+ * transcriptCommitOutputShas: SHAs git printed in the tool_result of a Bash `git commit` call (a claim, not proof).
103
105
  */
104
106
  function parseLog(logPath) {
105
107
  let text;
106
108
  try {
107
109
  text = fs.readFileSync(logPath, 'utf8');
108
110
  } catch (e) {
109
- return { events: [], resultEvent: null, error: e.message, transcriptCommitShas: [] };
111
+ return { events: [], resultEvent: null, error: e.message, transcriptCommitShas: [], transcriptCommitOutputShas: [] };
110
112
  }
111
113
 
112
114
  const events = [];
@@ -192,7 +194,79 @@ function parseLog(logPath) {
192
194
  }
193
195
  }
194
196
 
195
- return { events, resultEvent, error: null, transcriptCommitLanded, transcriptCommitShas: [...transcriptCommitShaSet] };
197
+ return {
198
+ events,
199
+ resultEvent,
200
+ error: null,
201
+ transcriptCommitLanded,
202
+ transcriptCommitShas: [...transcriptCommitShaSet],
203
+ transcriptCommitOutputShas: collectCommitOutputShas(events),
204
+ };
205
+ }
206
+
207
+ const GIT_COMMIT_CMD_RE = /\bgit\s+(?:-C\s+\S+\s+)?commit\b/;
208
+ const COMMIT_SUMMARY_RE = /^\[[^\]\s]+(?: \(root-commit\))? ([0-9a-f]{7,40})\]/i;
209
+ const SHA_SUBJECT_RE = /^([0-9a-f]{7,40}) (.+)$/i;
210
+
211
+ const COMMIT_MESSAGE_ARG_RE = /(?:^|\s)(?:-[abd-su-zABDEG-Z]*m|--message)(?:=|\s+|(?=["']))(?:"?\$\(cat <<-?\s*['"]?(\w+)['"]?\n([\s\S]*?)\n\s*\1\s*\)"?|"((?:[^"\\]|\\.)*)"|'([^']*)')/g;
212
+
213
+ /**
214
+ * First lines (trimmed) of every commit-message argument in a git command.
215
+ * Accepted forms: `-m` / `--message` with a space or `=` before the value;
216
+ * short-flag clusters ending in m (e.g. `-am`, `-qam`), excluding clusters with a
217
+ * value-taking letter (C, c, F, t) before the m, so `-Cm` is not a message flag;
218
+ * a value attached to the flag (`-m"subj"`, `-m'subj'`); and `$(cat <<EOF ... EOF)`
219
+ * heredoc values (first non-empty line).
220
+ * @param {string} command
221
+ * @returns {string[]}
222
+ */
223
+ function commitMessageSubjects(command) {
224
+ /** @type {string[]} */
225
+ const out = [];
226
+ if (typeof command !== 'string') return out;
227
+ for (const m of command.matchAll(COMMIT_MESSAGE_ARG_RE)) {
228
+ let body = m[2] !== undefined ? m[2] : m[3] !== undefined ? m[3].replace(/\\(.)/g, '$1') : (m[4] || '');
229
+ const first = body.split('\n').map((l) => l.trim()).find((l) => l.length > 0);
230
+ if (first) out.push(first);
231
+ }
232
+ return out;
233
+ }
234
+
235
+ /**
236
+ * SHAs git printed in the tool_result of a Bash call running `git commit`.
237
+ * A CLAIM only — the scheduler must check it against the run's own HEAD range.
238
+ * @param {any[]} events
239
+ * @returns {string[]}
240
+ */
241
+ function collectCommitOutputShas(events) {
242
+ /** @type {Map<string, string>} */
243
+ const commitCmds = new Map();
244
+ for (const ev of events) {
245
+ if (ev.kind === 'tool_use' && ev.toolName === 'Bash' && ev.toolUseId
246
+ && typeof ev.command === 'string' && GIT_COMMIT_CMD_RE.test(ev.command)) {
247
+ commitCmds.set(ev.toolUseId, ev.command);
248
+ }
249
+ }
250
+ /** @type {Set<string>} */
251
+ const shas = new Set();
252
+ if (commitCmds.size === 0) return [];
253
+ for (const ev of events) {
254
+ if (ev.kind !== 'tool_result') continue;
255
+ const cmd = commitCmds.get(ev.toolUseId);
256
+ if (cmd === undefined || typeof ev.content !== 'string') continue;
257
+ const subjects = commitMessageSubjects(cmd);
258
+ for (const raw of ev.content.split('\n')) {
259
+ const ln = raw.trim();
260
+ const m1 = COMMIT_SUMMARY_RE.exec(ln);
261
+ if (m1) { shas.add(m1[1].toLowerCase()); continue; }
262
+ const m2 = SHA_SUBJECT_RE.exec(ln);
263
+ if (m2) {
264
+ const subject = m2[2].trim();
265
+ if (subject.length >= 8 && subjects.includes(subject)) shas.add(m2[1].toLowerCase());
266
+ }
267
+ }
268
+ }
269
+ return [...shas];
196
270
  }
197
271
 
198
272
  // Stable, narrow substrings of the harness's auto-background tool_result text
@@ -304,6 +378,20 @@ function scanSentinel(resultEvent, events) {
304
378
  return null;
305
379
  }
306
380
 
381
+ /**
382
+ * Did a plan-reviewer run return its structured review? Shape only — a plain
383
+ * object carrying a `prds` array; the harvest validates the full schema.
384
+ * @param {{agentType?: string}|null|undefined} queueEntry
385
+ * @param {{structuredOutput?: unknown}|null|undefined} resultEvent
386
+ * @returns {boolean}
387
+ */
388
+ function isPlanReviewStructured(queueEntry, resultEvent) {
389
+ if (queueEntry?.agentType !== 'plan-reviewer') return false;
390
+ const so = resultEvent?.structuredOutput;
391
+ if (!so || typeof so !== 'object' || Array.isArray(so)) return false;
392
+ return Array.isArray(/** @type {{prds?: unknown}} */ (so).prds);
393
+ }
394
+
307
395
  /**
308
396
  * 'pass' | 'fail' from a result event's structured_output.schedulerVerdict
309
397
  * (validator runs under `--json-schema`), else null.
@@ -856,6 +944,21 @@ async function verifyRun({
856
944
  // (abandoned_background_task) so the auto-fix investigation checks the
857
945
  // working tree for already-written work first, instead of re-planning the
858
946
  // whole PRD from a wrong "stopped on a clarifying question" premise.
947
+ // A plan-reviewer's ONLY deliverable is its PLAN_REVIEW_SCHEMA structured
948
+ // output (FINISH_PLAN_REVIEWER_LINE: no commit, no file, no verdict line);
949
+ // harvestPlanReview saves it. Shape check only (a `prds` array): the
950
+ // harvest's parsePlanReview validates the schema and saves a malformed
951
+ // review as a failed round, which only happens once the job completes.
952
+ // Missing output falls through to the no_verdict_sentinel path below.
953
+ if (sentinel === null && !commitEvidence && exitCode === 0 && isPlanReviewStructured(queueEntry, resultEvent)) {
954
+ return conclude(
955
+ 'pass_no_commit_plan_review',
956
+ 'plan-reviewer returned its structured review (PLAN_REVIEW_SCHEMA); no commit or verdict line is expected',
957
+ null,
958
+ extras,
959
+ );
960
+ }
961
+
859
962
  if (sentinel === null && !commitEvidence) {
860
963
  if (hasAbandonedBackgroundTask(events)) {
861
964
  issues.push({
@@ -1060,6 +1163,7 @@ module.exports = {
1060
1163
  isPolicyDenial,
1061
1164
  checkDeps,
1062
1165
  parseLog,
1166
+ commitMessageSubjects,
1063
1167
  scanSentinel,
1064
1168
  scanHaltLine,
1065
1169
  scanSentinelReason,
@@ -473,6 +473,12 @@ function strandedCommitVerdict({ worktreeHead, landedCommit } = {}) {
473
473
  * main checkout with concurrent jobs, so a HEAD move there may be someone else's
474
474
  * integration — credit comes only from this run's own integration result. An
475
475
  * in-place run keeps the HEAD-delta / time-window behaviour.
476
+ *
477
+ * `transcriptCommitShas` carries two evidence sources, unioned by the caller:
478
+ * the harness-reported commit shas (parseLog `transcriptCommitShas`) and the
479
+ * shas git printed for the run's own `git commit` call (parseLog
480
+ * `transcriptCommitOutputShas`). Both are claims: credit goes only to a commit
481
+ * inside `rangeCommits` (headBefore..headAtExit).
476
482
  */
477
483
  function resolveRunCommitAttribution({
478
484
  ranInWorktree, integratedSha, headBefore, headAtExit, committedInWindow,
@@ -9,6 +9,8 @@
9
9
  *
10
10
  * Record fields read (all optional): `release` (non-null object, as planReviewStore.recordPlanRelease writes it = released),
11
11
  * `firstReviewAt` / `reviews[0].at` (hold start when a review exists).
12
+ * Hold-start fields, in order: review record, then validator row `queuedAt`
13
+ * (stamped at enqueue), `planReviewHeldAt`, `createdAt`.
12
14
  */
13
15
 
14
16
  const { bareSlug } = require('../lib/prd/depSlugResolve.cjs');
@@ -78,11 +80,15 @@ function isReleased(record) {
78
80
  }
79
81
 
80
82
  function holdStartMs(validateRow, record) {
81
- const first = record?.firstReviewAt ?? record?.reviews?.[0]?.at;
82
- const t = Date.parse(first ?? '');
83
- if (Number.isFinite(t)) return t;
84
- const c = Date.parse(validateRow.createdAt ?? '');
85
- return Number.isFinite(c) ? c : null;
83
+ const candidates = [
84
+ record?.firstReviewAt, record?.reviews?.[0]?.at,
85
+ validateRow?.queuedAt, validateRow?.planReviewHeldAt, validateRow?.createdAt,
86
+ ];
87
+ for (const c of candidates) {
88
+ const t = Date.parse(c ?? '');
89
+ if (Number.isFinite(t)) return t;
90
+ }
91
+ return null;
86
92
  }
87
93
 
88
94
  /**
@@ -322,6 +322,14 @@ async function resolveBareSlugFile(slug, cwd) {
322
322
  * regular `.md` files are read. Never rejects. Returns Map<inputSlug, text>.
323
323
  */
324
324
  async function readEpicPrdTexts(cwd, epicId, slugs) {
325
+ const files = await readEpicPrdFiles(cwd, epicId, slugs);
326
+ const out = new Map();
327
+ for (const [k, v] of files) out.set(k, v.text);
328
+ return out;
329
+ }
330
+
331
+ /** Same lookup as readEpicPrdTexts, but Map<inputSlug, { text, path }> so path and text cannot disagree. */
332
+ async function readEpicPrdFiles(cwd, epicId, slugs) {
325
333
  const out = new Map();
326
334
  try {
327
335
  if (typeof cwd !== 'string' || !cwd || !Array.isArray(slugs) || slugs.length === 0) return out;
@@ -360,7 +368,7 @@ async function readEpicPrdTexts(cwd, epicId, slugs) {
360
368
  }
361
369
  }
362
370
  if (!file) continue;
363
- try { out.set(slug, await fsp.readFile(file, 'utf8')); } catch { /* unreadable — no entry */ }
371
+ try { out.set(slug, { text: await fsp.readFile(file, 'utf8'), path: file }); } catch { /* unreadable — no entry */ }
364
372
  }
365
373
  } catch { /* never rejects */ }
366
374
  return out;
@@ -622,6 +630,7 @@ module.exports = {
622
630
  safeSlugPath,
623
631
  resolveBareSlugFile,
624
632
  readEpicPrdTexts,
633
+ readEpicPrdFiles,
625
634
  resolveSlugOrReason,
626
635
  jobMatchesSlugAndCwd,
627
636
  unknownSlugMessage,