claude-code-session-manager 0.133.1 → 0.135.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 (98) hide show
  1. package/dist/assets/AgentLibrary-DRlcF1YD.js +2 -0
  2. package/dist/assets/{AppSettings-DwnfV9-4.js → AppSettings-CBhYHKGI.js} +2 -2
  3. package/dist/assets/{Button-CObXxw7b.js → Button-DtBUGvGI.js} +1 -1
  4. package/dist/assets/{DocumentEditorPane-CgB5IuOY.js → DocumentEditorPane-C82c7Qtl.js} +1 -1
  5. package/dist/assets/{Extensions-Fuhshcl6.js → Extensions-Kn-oUD2_.js} +2 -2
  6. package/dist/assets/{History-DbUV4jxK.js → History-B4c3Uz9u.js} +2 -2
  7. package/dist/assets/{Library-COr79GyT.js → Library-1RpLT-aH.js} +1 -1
  8. package/dist/assets/{ListDetail-DY53nXya.js → ListDetail-xr0oxNkv.js} +1 -1
  9. package/dist/assets/{Panel-D7NX5iP8.js → Panel-O8XPrpJu.js} +1 -1
  10. package/dist/assets/{ProjectClaudeConfig-DuWzM8qA.js → ProjectClaudeConfig-DBGhhzg2.js} +5 -5
  11. package/dist/assets/{ProvenanceBadge-AnwE1p5X.js → ProvenanceBadge-DSaizfZL.js} +1 -1
  12. package/dist/assets/Scheduler-D2_5NyiR.js +16 -0
  13. package/dist/assets/{Settings-tt0VZCyz.js → Settings-Clgqb3Lq.js} +2 -2
  14. package/dist/assets/{SkillReferenceGraph-D_rxqWgq.js → SkillReferenceGraph-D80RA7kR.js} +1 -1
  15. package/dist/assets/{Skills-BVQPJZaF.js → Skills-DNG7tHSf.js} +10 -10
  16. package/dist/assets/{SourceChip-DC5XD8KC.js → SourceChip-D-Imzszd.js} +1 -1
  17. package/dist/assets/{SystemPrompt-XnvP0_cS.js → SystemPrompt-CGlOpUQA.js} +1 -1
  18. package/dist/assets/{TiptapBody-B_TNEADm.js → TiptapBody-CJFGfBdz.js} +28 -28
  19. package/dist/assets/{Toggle-CxQO8pGN.js → Toggle-0Ff0bPa_.js} +1 -1
  20. package/dist/assets/{ViewTabs-CEjnWPD9.js → ViewTabs-BCMYQwo_.js} +1 -1
  21. package/dist/assets/{VoiceButton-B-6gdmKe.js → VoiceButton-JzyC6DAB.js} +1 -1
  22. package/dist/assets/geist-sans-latin-300-normal-C3kkMBb6.woff2 +0 -0
  23. package/dist/assets/geist-sans-latin-400-normal-gapTbOY8.woff2 +0 -0
  24. package/dist/assets/geist-sans-latin-500-normal-uokXdC-Q.woff2 +0 -0
  25. package/dist/assets/geist-sans-latin-600-normal-DFOURf8L.woff2 +0 -0
  26. package/dist/assets/geist-sans-latin-700-normal-BmN9tIp5.woff2 +0 -0
  27. package/dist/assets/{historyTotals-dT8vcKzX.js → historyTotals-B01WPBwh.js} +1 -1
  28. package/dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  29. package/dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  30. package/dist/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  31. package/dist/assets/{index-5QIl5Kcd.css → index-CjQ_p5y7.css} +1 -1
  32. package/dist/assets/index-rt7pTODX.js +3116 -0
  33. package/dist/assets/newsreader-latin-400-italic-CEihAR-f.woff2 +0 -0
  34. package/dist/assets/newsreader-latin-400-normal-BFBkh4jY.woff2 +0 -0
  35. package/dist/assets/newsreader-latin-500-normal-B66TYsaK.woff2 +0 -0
  36. package/dist/assets/newsreader-latin-600-normal-30OJ_TG_.woff2 +0 -0
  37. package/dist/assets/newsreader-latin-700-normal-rIgV_oaK.woff2 +0 -0
  38. package/dist/index.html +2 -5
  39. package/dist-web/app.css +1 -1
  40. package/dist-web/app.js +409 -404
  41. package/dist-web/index.html +0 -3
  42. package/package.json +1 -1
  43. package/plugins/session-manager-dev/skills/develop/standards.md +1 -1
  44. package/scripts/scheduler-mcp-server.cjs +31 -0
  45. package/src/main/agentLibrary.cjs +27 -4
  46. package/src/main/build-info.json +4 -4
  47. package/src/main/chatRunner.cjs +9 -0
  48. package/src/main/config.cjs +22 -0
  49. package/src/main/crashDiagnostics.cjs +10 -2
  50. package/src/main/index.cjs +34 -25
  51. package/src/main/ipcSchemas.cjs +6 -0
  52. package/src/main/lib/agent-cli/agentCliEvents.cjs +8 -0
  53. package/src/main/lib/demo-video-kit/capture.cjs +4 -37
  54. package/src/main/lib/demo-video-kit/character.cjs +20 -2
  55. package/src/main/lib/demo-video-kit/checks.cjs +82 -1
  56. package/src/main/lib/demo-video-kit/frames.cjs +3 -28
  57. package/src/main/lib/demo-video-kit/playwrightLoader.cjs +67 -0
  58. package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
  59. package/src/main/lib/demo-video-kit/sound.cjs +5 -2
  60. package/src/main/lib/epic/epicMint.cjs +1 -3
  61. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +37 -4
  62. package/src/main/lib/epic/restorableSessions.cjs +88 -0
  63. package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +56 -1
  64. package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +21 -3
  65. package/src/main/lib/feedback-remote/remoteAssets.cjs +25 -1
  66. package/src/main/lib/mcpToolCatalog.cjs +15 -0
  67. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +10 -1
  68. package/src/main/lib/persona-macro/builtinMacros.cjs +3 -2
  69. package/src/main/lib/persona-macro/macroJobDispatch.cjs +3 -2
  70. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +22 -0
  71. package/src/main/lib/prd/listPrdsSingleFlight.cjs +79 -0
  72. package/src/main/lib/prd/prdAgentType.cjs +17 -7
  73. package/src/main/lib/prd/prdFrontmatter.cjs +25 -1
  74. package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
  75. package/src/main/lib/telemetry/crashTelemetry.cjs +10 -5
  76. package/src/main/lib/telemetry/telemetryBoot.cjs +77 -4
  77. package/src/main/lib/telemetry/telemetryClient.cjs +54 -9
  78. package/src/main/lib/telemetry/telemetryConsent.cjs +3 -0
  79. package/src/main/lib/telemetry/telemetryCounters.cjs +7 -2
  80. package/src/main/lib/telemetry/telemetrySettings.cjs +5 -0
  81. package/src/main/promptSessionEvents.cjs +7 -1
  82. package/src/main/pty.cjs +2 -2
  83. package/src/main/runVerify.cjs +2 -2
  84. package/src/main/scheduler/prdParser.cjs +18 -2
  85. package/src/main/scheduler.cjs +156 -18
  86. package/src/main/seedAgentPersonas.cjs +24 -0
  87. package/src/main/seedStatus.cjs +5 -2
  88. package/src/main/telemetryIpc.cjs +1 -5
  89. package/src/main/templates/PRD_AUTHORING.md +2 -2
  90. package/src/preload/api.d.ts +37 -16
  91. package/src/preload/apiSurface.json +7 -0
  92. package/src/preload/index.cjs +3 -1
  93. package/src/seed/agents/demo-video-builder.md +7 -2
  94. package/src/seed/agents/project-home-builder.md +4 -2
  95. package/dist/assets/AgentLibrary-BTIBmZkM.js +0 -2
  96. package/dist/assets/Scheduler-BHfx0rXd.js +0 -16
  97. package/dist/assets/index-BLORXCcT.js +0 -3111
  98. package/src/main/lib/telemetry/telemetryBacklog.cjs +0 -607
@@ -71,7 +71,9 @@ function mintEventId() {
71
71
  * validation pass is what may later move it to 'verified'/'refuted'. `agentType`
72
72
  * (the job's agent) and `digestKey` (the settle digest's stable key) ride the
73
73
  * same meta arg and are copied the same way, as is `notice` (PRD 2950 — a
74
- * marker like 'job-not-queued' the renderer turns into a distinct notice). All
74
+ * marker like 'job-not-queued', or PRD 3116's 'build-done'/'build-failed', the
75
+ * renderer turns into a distinct notice) and `buildOutput` (PRD 3116 — `{ kind,
76
+ * id, title }` of a macro build's saved entry). All
75
77
  * keys are added to the event object only when present in `meta`, never as
76
78
  * `undefined`-valued keys, so events appended without them serialize
77
79
  * identically to before.
@@ -104,6 +106,10 @@ async function appendResponseEventWithReason(cwd, sourcePromptId, text, meta = {
104
106
  if (meta && meta.agentType) event.agentType = meta.agentType;
105
107
  if (meta && meta.digestKey) event.digestKey = meta.digestKey;
106
108
  if (meta && meta.notice) event.notice = meta.notice;
109
+ if (meta && meta.buildOutput && typeof meta.buildOutput === 'object') {
110
+ const { kind, id, title } = meta.buildOutput;
111
+ event.buildOutput = { kind, id, title };
112
+ }
107
113
  data.events[sourcePromptId] = [...events, event];
108
114
  await config.writeJson(path, data, { writer: 'scheduler' });
109
115
  broadcast(EVENT_APPENDED_CHANNEL, { cwd, promptSessionId: sourcePromptId, event });
package/src/main/pty.cjs CHANGED
@@ -169,7 +169,7 @@ class PtyManager {
169
169
  // is acceptable for a dev reload.
170
170
  //
171
171
  // Telemetry: this branch deliberately does NOT call
172
- // telemetryCounters.trackSessionOpen() (see below, after the real spawn).
172
+ // telemetryCounters.trackSessionOpen({ surface: 'terminal' }) (see below, after the real spawn).
173
173
  // Tab = claudeSessionId is a 1:1 mapping (CLAUDE.md domain model) — a
174
174
  // reattach is the SAME session process still running, not a new one, so
175
175
  // counting it here would double-count every renderer reload and every
@@ -300,7 +300,7 @@ class PtyManager {
300
300
  return { pid: null, cwd, reattached: false, error: String(err?.message || 'spawn-failed') };
301
301
  }
302
302
  console.log('[pty] spawned pid=', proc.pid, 'for tabId=', tabId);
303
- telemetryCounters.trackSessionOpen();
303
+ telemetryCounters.trackSessionOpen({ surface: 'terminal' });
304
304
 
305
305
  const spawnedAt = Date.now();
306
306
  let gotData = false;
@@ -44,7 +44,7 @@
44
44
  const fs = require('node:fs');
45
45
  const path = require('node:path');
46
46
  const { execFileSync } = require('node:child_process');
47
- const { parsePrdFile } = require('./lib/prd/prdFrontmatter.cjs');
47
+ const { parsePrdFile, isArtifactOnlyDeclaration } = require('./lib/prd/prdFrontmatter.cjs');
48
48
  const { isSatisfiedDepRow } = require('./lib/prd/depSlugResolve.cjs');
49
49
 
50
50
  const VERDICTS_SCHEMA_VERSION = 1;
@@ -907,7 +907,7 @@ async function verifyRun({
907
907
  if (!mergeMainVerified && !priorRunVerified) {
908
908
  let fm = null;
909
909
  try { fm = parsePrdFile(prdFullText).frontmatter; } catch { fm = null; }
910
- if (fm && fm.deliverable === 'artifact' && Array.isArray(fm.artifactPaths) && fm.artifactPaths.length > 0) {
910
+ if (isArtifactOnlyDeclaration(fm)) {
911
911
  const check = artifactsCheck({
912
912
  cwd: [queueEntry?.cwd, worktreeDir],
913
913
  paths: fm.artifactPaths,
@@ -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, PRD_EFFORT_LEVELS } = require('../lib/prd/prdFrontmatter.cjs');
20
+ const { splitFrontmatter, parseInlineList, 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');
@@ -45,6 +45,17 @@ let prdDirMtime = -1;
45
45
  let prdDirFiles = null; // sorted absolute paths
46
46
  const prdFileCache = new Map(); // path -> { mtimeMs, ino, parsed }
47
47
 
48
+ /**
49
+ * `artifactPaths: [a, b]` → ['a', 'b'] — the inline-list form only, same
50
+ * shape prdFrontmatter.cjs's parsePrdFile (runVerify's artifact exemption,
51
+ * executeJob's finish variant) recognizes. Empty / absent / malformed → null.
52
+ */
53
+ function parseArtifactPaths(raw) {
54
+ if (typeof raw !== 'string') return null;
55
+ const list = parseInlineList(raw);
56
+ return list && list.length > 0 ? list : null;
57
+ }
58
+
48
59
  /**
49
60
  * Parse a PRD file from disk without any caching. Reads bytes once, decodes
50
61
  * frontmatter, and folds in the parallel-group number from the filename when
@@ -65,7 +76,7 @@ async function parsePrdRaw(filePath) {
65
76
  // read — prdAgentType.cjs's header): a persona renamed/deleted after this
66
77
  // PRD was written must not stop the PRD from loading. Best-effort only —
67
78
  // never lets a logging failure affect parsing.
68
- if (fm.agentType && cwd) reportDanglingAgentTypeOnce(cwd, fm.agentType);
79
+ if (fm.agentType && cwd) reportDanglingAgentTypeOnce(cwd, fm.agentType, { filePath });
69
80
 
70
81
  return {
71
82
  slug: base,
@@ -133,6 +144,11 @@ async function parsePrdRaw(filePath) {
133
144
  planId: (typeof fm.planId === 'string' && /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(fm.planId)) ? fm.planId : null,
134
145
  // Macro press that minted this PRD (prdFrontmatter.cjs MACRO_ID_RE); malformed reads as absent.
135
146
  macroId: (typeof fm.macroId === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(fm.macroId.trim())) ? fm.macroId.trim() : null,
147
+ // Artifact-only declaration (PRD 3114): copied onto queue rows so the
148
+ // row-based artifact-only checks in scheduler.cjs see it. Exactly
149
+ // 'artifact' else null; artifactPaths = non-empty strings, else null.
150
+ deliverable: (typeof fm.deliverable === 'string' && fm.deliverable.trim() === 'artifact') ? 'artifact' : null,
151
+ artifactPaths: parseArtifactPaths(fm.artifactPaths),
136
152
  effort: (typeof fm.effort === 'string' && PRD_EFFORT_LEVELS.includes(fm.effort.trim())) ? fm.effort.trim() : null,
137
153
  // Opt-in exclusive-lease flag (PRD 1107, quietMachineLease.cjs +
138
154
  // schedulerBatch.cjs's pickNextBatch). Only a literal `true` opts in —
@@ -70,13 +70,15 @@ const { decideVerifyDowngrade } = require('./lib/scheduler/refireCap.cjs');
70
70
  const { finalizeReasonFor } = require('./lib/scheduler/finalizeReason.cjs');
71
71
  const { shouldRunFlatSweep, FLAT_SWEEP_INTERVAL_MS } = require('./lib/scheduler/flatSweepThrottle.cjs');
72
72
  const { appendError } = require('./lib/telemetry/opsErrorLog.cjs');
73
+ const { createSingleFlight, listKeyFor, flatString, flattenPrdEntry } = require('./lib/prd/listPrdsSingleFlight.cjs');
73
74
  const { readTail } = require('./lib/util/fileTail.cjs');
74
75
  const {
75
76
  claudePidAlive, classifyRunOutcome, resolveReapGateOutcome, ORPHAN_REQUEUE_CAP, selectReapableJobs,
76
77
  findLiveProcessForJob, logHasOutput, resolvePidlessGateOutcome, resolveCommitGuardOutcome,
77
78
  readSpawnedPidFromLog, readLogMtimeMs, isClaudeArgv,
78
79
  } = require('./lib/scheduler/reaperHelpers.cjs');
79
- const { resolveProjectRoot, ensureRuntimeIgnores, RUNTIME_NAMESPACES } = require('./lib/opsOwnership.cjs');
80
+ const { resolveProjectRoot, ensureRuntimeIgnores, RUNTIME_NAMESPACES, opsPath } = require('./lib/opsOwnership.cjs');
81
+ const { BUILTIN_MACROS } = require('./lib/persona-macro/builtinMacros.cjs');
80
82
  const { sweepStrandedJobBranches } = require('./lib/git/branchSweep.cjs');
81
83
  const { detectRateLimitInLog } = require('./lib/claude/rateLimitDetect.cjs');
82
84
  const { stripAppOwnedChurn } = require('./lib/scheduler/jobDirtFilter.cjs');
@@ -191,7 +193,7 @@ const { reconcileEpicWorktreesOnBoot } = require('./lib/epic/epicWorktreeBoot.cj
191
193
  const queueStore = require('./lib/scheduler/queueStore.cjs');
192
194
  const supervisorRecord = require('./lib/scheduler/jobSupervisorRecord.cjs');
193
195
  const adoptedRunSupervisor = require('./lib/scheduler/adoptedRunSupervisor.cjs');
194
- const { splitFrontmatter, parsePrdFile, serializePrdFile } = require('./lib/prd/prdFrontmatter.cjs');
196
+ const { splitFrontmatter, parsePrdFile, serializePrdFile, isArtifactOnlyDeclaration } = require('./lib/prd/prdFrontmatter.cjs');
195
197
  const { applyStructuredPrdPatch } = require('./lib/prd/prdBodyPatch.cjs');
196
198
  const { resolvePersonaDefaultEstimate, DEFAULT_PRD_AGENT_TYPE } = require('./lib/prd/prdAgentType.cjs');
197
199
  const { resolveDepSlug, findNearMatches } = require('./lib/prd/depSlugResolve.cjs');
@@ -304,7 +306,14 @@ const BASH_MAX_TIMEOUT_MS = 900_000; // 15 min — must stay below IDLE_OUTPUT_K
304
306
  // `git add <path>`, the SCHEDULER_VERDICT lines, `/code-review medium --fix`
305
307
  // and the "Never call /code-review with no level, or at xhigh, max or ultra"
306
308
  // ban — PRD 2887: a level-less call took the session's max effort and outlived
307
- // the job budget) — keep them exact. No line
309
+ // the job budget) — keep them exact.
310
+ //
311
+ // `isArtifactOnly: true` (PRD 3109) adds one VERDICT bullet and one COMMIT
312
+ // sentence for a PRD whose frontmatter declares deliverable: artifact +
313
+ // artifactPaths: it commits nothing by design, and runVerify already accepts
314
+ // its no-commit PASS (pass_no_commit_artifact_verified). Without the variant
315
+ // Self job 826-project-home-build saved its page, ran a green gate, and still
316
+ // printed a false FAIL for the missing commit (parked in needs_review). No line
308
317
  // of this text may START with SCHEDULER_VERDICT: or FOREIGN_WIP_PATHS: —
309
318
  // runVerify's scanners are line-anchored.
310
319
  function buildFinishHead(verifyStepNum) {
@@ -369,7 +378,20 @@ const FINISH_FIX_PLAN_VERDICT_LINE = `
369
378
  An auto fix plan whose steps changed no file has nothing to commit
370
379
  and prints PASS when the gate is green. Do not invent a commit to have one.`;
371
380
 
372
- function buildFinishTail({ verifyStepNum, commitStepNum, verdictStepNum, isFixPlan = false }) {
381
+ // Artifact-only VERDICT bullet + COMMIT sentence (PRD 3109): a PRD with
382
+ // deliverable: artifact + artifactPaths commits nothing by design, and
383
+ // runVerify's artifact exemption already accepts its no-commit PASS — so say
384
+ // so, or "PASS needs a landed commit" yields a false FAIL after a green gate.
385
+ const FINISH_ARTIFACT_ONLY_VERDICT_LINE = `
386
+ - This job is artifact-only: its PRD declares deliverable: artifact.
387
+ It commits nothing by design, so no commit is expected. When the
388
+ gate is green and the tree is clean, print PASS. Never print FAIL
389
+ for the missing commit, and do not invent a commit to have one.`;
390
+
391
+ const FINISH_ARTIFACT_ONLY_COMMIT_LINE = `
392
+ This job is artifact-only: its output is git-excluded, so there is nothing to stage. Skip the commit and go to the next step.`;
393
+
394
+ function buildFinishTail({ verifyStepNum, commitStepNum, verdictStepNum, isFixPlan = false, isArtifactOnly = false }) {
373
395
  return `${verifyStepNum}. VERIFY — run every command in the PRD's \`# Gate\` section, in order, in the
374
396
  foreground. Each must exit 0. If the PRD has no \`# Gate\` section, run the
375
397
  project's own typecheck, lint and test commands instead. The project's
@@ -389,13 +411,13 @@ ${commitStepNum}. COMMIT — stage only the exact paths you created or changed f
389
411
  Never commit any file under these folders, even when the PRD names it:
390
412
  ${FINISH_RUNTIME_FOLDERS}
391
413
  Why: those folders hold the app's live state. A commit of them breaks the
392
- running scheduler for every checkout that pulls it.
414
+ running scheduler for every checkout that pulls it.${isArtifactOnly ? FINISH_ARTIFACT_ONLY_COMMIT_LINE : ''}
393
415
  ${verdictStepNum}. VERDICT LINE — end your final report with exactly one of these lines.
394
416
  Put nothing after it, except the FOREIGN_WIP_PATHS line described below.
395
417
  SCHEDULER_VERDICT: PASS
396
418
  SCHEDULER_VERDICT: FAIL <one-line reason>
397
419
  SCHEDULER_VERDICT: BLOCKED_BY_FOREIGN_WIP
398
- - Print PASS only when the gate is green AND the commit from step ${commitStepNum} landed.${isFixPlan ? FINISH_FIX_PLAN_VERDICT_LINE : ''}
420
+ - Print PASS only when the gate is green AND the commit from step ${commitStepNum} landed.${isFixPlan ? FINISH_FIX_PLAN_VERDICT_LINE : ''}${isArtifactOnly ? FINISH_ARTIFACT_ONLY_VERDICT_LINE : ''}
399
421
  - Print FAIL when the gate is red or the commit could not land. Also print
400
422
  FAIL when a step needs something this run cannot reach (live runtime
401
423
  state, credentials, an account or dashboard action, a host install): do
@@ -438,14 +460,20 @@ in your final report.`;
438
460
  * `isFixPlan: true` (auto fix-plan jobs only) adds one VERDICT bullet: a fix
439
461
  * plan that changed no file has nothing to commit and prints PASS on a green
440
462
  * gate. Omitted/false leaves the text unchanged.
463
+ * `isArtifactOnly: true` (PRDs whose own frontmatter has deliverable:
464
+ * artifact + non-empty artifactPaths — PRD 3109) adds one VERDICT bullet
465
+ * (after the fix-plan bullet when both are set) and one COMMIT sentence: the
466
+ * job commits nothing by design and prints PASS on a green gate with a clean
467
+ * tree, never FAIL for the missing commit. Self job 826 printed exactly that
468
+ * false FAIL. Omitted/false leaves the text unchanged.
441
469
  */
442
- function buildFinishProtocol({ reviewInRun = true, isFixPlan = false } = {}) {
470
+ function buildFinishProtocol({ reviewInRun = true, isFixPlan = false, isArtifactOnly = false } = {}) {
443
471
  if (reviewInRun) {
444
472
  return buildFinishHead(3) + FINISH_REVIEW_STEPS_IN_RUN
445
- + buildFinishTail({ verifyStepNum: 3, commitStepNum: 4, verdictStepNum: 5, isFixPlan });
473
+ + buildFinishTail({ verifyStepNum: 3, commitStepNum: 4, verdictStepNum: 5, isFixPlan, isArtifactOnly });
446
474
  }
447
475
  return buildFinishHead(2) + FINISH_REVIEW_STEP_DEFERRED
448
- + buildFinishTail({ verifyStepNum: 2, commitStepNum: 3, verdictStepNum: 4, isFixPlan });
476
+ + buildFinishTail({ verifyStepNum: 2, commitStepNum: 3, verdictStepNum: 4, isFixPlan, isArtifactOnly });
449
477
  }
450
478
 
451
479
  const FINISH_PROTOCOL = buildFinishProtocol({ reviewInRun: true });
@@ -1850,6 +1878,8 @@ async function reconcilePass(state) {
1850
1878
  bodyPreview: p.body.split('\n').slice(0, 6).join('\n'),
1851
1879
  agentType: p.agentType ?? job.agentType ?? null,
1852
1880
  macroId: p.macroId ?? job.macroId ?? null,
1881
+ deliverable: p.deliverable ?? job.deliverable ?? null,
1882
+ artifactPaths: p.artifactPaths ?? job.artifactPaths ?? null,
1853
1883
  effort: p.effort ?? job.effort ?? null,
1854
1884
  };
1855
1885
  // Adopt path: a row parked 'quarantined' (no createdVia provenance when
@@ -1975,6 +2005,8 @@ async function reconcilePass(state) {
1975
2005
  bodyPreview: p.body.split('\n').slice(0, 6).join('\n'),
1976
2006
  agentType: p.agentType ?? inv.row?.agentType ?? null,
1977
2007
  macroId: p.macroId ?? inv.row?.macroId ?? null,
2008
+ deliverable: p.deliverable ?? inv.row?.deliverable ?? null,
2009
+ artifactPaths: p.artifactPaths ?? inv.row?.artifactPaths ?? null,
1978
2010
  effort: p.effort ?? inv.row?.effort ?? null,
1979
2011
  };
1980
2012
  const reason = `reconcile: repaired invalid status ${JSON.stringify(oldStatus)}`;
@@ -2128,6 +2160,8 @@ async function reconcilePass(state) {
2128
2160
  bodyPreview: p.body.split('\n').slice(0, 6).join('\n'),
2129
2161
  agentType: p.agentType ?? null,
2130
2162
  macroId: p.macroId ?? null,
2163
+ deliverable: p.deliverable ?? null,
2164
+ artifactPaths: p.artifactPaths ?? null,
2131
2165
  effort: p.effort ?? null,
2132
2166
  status: 'pending',
2133
2167
  // Enqueue time (PRD 1086/1087): the cross-project fairness tiebreak and
@@ -3192,9 +3226,9 @@ function applyOrphanOutcome(job, outcome, killNote = '', confirmedLandedCommit =
3192
3226
 
3193
3227
  function applyOrphanOutcomeInner(job, outcome, killNote, confirmedLandedCommit, snap, now) {
3194
3228
  // A reported 'success' completes only on landed-commit evidence, or for a
3195
- // DECLARED artifact-only PRD (`deliverable: artifact` + artifactPaths — same
3196
- // check as runVerify's artifact exemption) where no commit is legitimate.
3197
- const artifactOnly = job.deliverable === 'artifact' && Array.isArray(job.artifactPaths) && job.artifactPaths.length > 0;
3229
+ // DECLARED artifact-only PRD (`deliverable: artifact` + artifactPaths — the
3230
+ // shared isArtifactOnlyDeclaration predicate) where no commit is legitimate.
3231
+ const artifactOnly = isArtifactOnlyDeclaration(job);
3198
3232
  if (outcome === 'success' && (confirmedLandedCommit || artifactOnly)) {
3199
3233
  if (confirmedLandedCommit) {
3200
3234
  transitionJob(job, 'completed', { reason: `boot orphan reconciliation: run succeeded, landedCommit ${confirmedLandedCommit} resolves`, source: 'applyOrphanOutcome:landed' });
@@ -3449,6 +3483,77 @@ function armSettleAfterValidatorBudgetKill(job, { scheduleSettle = defaultSchedu
3449
3483
  }
3450
3484
  }
3451
3485
 
3486
+ // PRD 3116: a macro's background-build PRD (frontmatter `macroId`) ends with
3487
+ // a DONE/FAILED notice naming what was saved, not the generic "PRD finished"
3488
+ // line — the generic line read as "idle" and owners typed into the Epic to
3489
+ // "start" a build that had already finished.
3490
+ const MACRO_ARTIFACT_RE = /^session-manager-operations\/project-pages\/(videos|knowledge)\/([a-z0-9-]+)\/index\.html$/;
3491
+ const MACRO_META_MAX_BYTES = 256 * 1024;
3492
+
3493
+ function macroLabelFor(prd) {
3494
+ const builtin = BUILTIN_MACROS.find((m) => m && m.id === prd.macroId);
3495
+ if (builtin && typeof builtin.label === 'string' && builtin.label) return builtin.label;
3496
+ const title = typeof prd.title === 'string' ? prd.title.replace(/:\s*background build\s*$/i, '').trim() : '';
3497
+ return title || prd.macroId;
3498
+ }
3499
+
3500
+ /**
3501
+ * readMacroBuildOutput(cwd, prd) → { kind, id, title, meta } | null
3502
+ * Never throws. The entry id must match /^[a-z0-9-]+$/; the meta.json path is
3503
+ * built with opsPath, never from the raw frontmatter string.
3504
+ */
3505
+ function readMacroBuildOutput(cwd, prd) {
3506
+ try {
3507
+ if (!cwd) return null;
3508
+ const first = Array.isArray(prd.artifactPaths) ? prd.artifactPaths[0] : null;
3509
+ if (typeof first !== 'string') return null;
3510
+ const m = MACRO_ARTIFACT_RE.exec(first.trim());
3511
+ if (!m) return null;
3512
+ const dir = m[1];
3513
+ const id = m[2];
3514
+ const metaPath = opsPath(cwd, 'project-pages', dir, id, 'meta.json');
3515
+ const st = fs.statSync(metaPath);
3516
+ if (!st.isFile() || st.size > MACRO_META_MAX_BYTES) return null;
3517
+ const meta = JSON.parse(fs.readFileSync(metaPath, 'utf8'));
3518
+ if (!meta || typeof meta !== 'object' || typeof meta.title !== 'string' || !meta.title.trim()) return null;
3519
+ return { kind: dir === 'videos' ? 'video' : 'knowledge', id, title: meta.title.trim(), meta };
3520
+ } catch {
3521
+ return null;
3522
+ }
3523
+ }
3524
+
3525
+ /**
3526
+ * macroBuildNotice(job, prd) → { message, notice, buildOutput? } | null
3527
+ * null for any PRD without a `macroId`, or a status other than completed/failed.
3528
+ */
3529
+ function macroBuildNotice(job, prd) {
3530
+ if (!prd || typeof prd.macroId !== 'string' || !prd.macroId) return null;
3531
+ if (job.status !== 'completed' && job.status !== 'failed') return null;
3532
+ const label = macroLabelFor(prd);
3533
+ if (job.status === 'failed') {
3534
+ const reason = job.error || job.verifierVerdict || job.status;
3535
+ return {
3536
+ message: `FAILED — ${label}: the background build failed (${reason}). Press it again in Project Home to retry.`,
3537
+ notice: 'build-failed',
3538
+ };
3539
+ }
3540
+ const out = readMacroBuildOutput(job.cwd, prd);
3541
+ if (!out) return { message: `DONE — ${label} finished.`, notice: 'build-done' };
3542
+ const buildOutput = { kind: out.kind, id: out.id, title: out.title };
3543
+ if (out.kind === 'video') {
3544
+ return {
3545
+ message: `DONE — ${label}: “${out.title}” is saved (${out.meta.lengthS} s · ${out.meta.style}). Watch it in Project Home ▸ Videos.`,
3546
+ notice: 'build-done',
3547
+ buildOutput,
3548
+ };
3549
+ }
3550
+ return {
3551
+ message: `DONE — ${label}: “${out.title}” is saved. Read it in Project Home ▸ Pages.`,
3552
+ notice: 'build-done',
3553
+ buildOutput,
3554
+ };
3555
+ }
3556
+
3452
3557
  /**
3453
3558
  * notifyOriginatingTab(job) → void
3454
3559
  *
@@ -3507,6 +3612,8 @@ async function notifyOriginatingTab(job, {
3507
3612
  message = `PRD ${job.slug} was skipped: its PRD source could not be found on disk. Blocked dependents: ${shown}${more}.`
3508
3613
  + ' If the PRD file exists, run scheduler_reset_job with force:true; if it was intentionally removed, archive it with scheduler_archive_prd.';
3509
3614
  }
3615
+ const macroNotice = macroBuildNotice(job, prd);
3616
+ if (macroNotice) message = macroNotice.message;
3510
3617
 
3511
3618
  // The EPIC this check-in belongs to. Deliberately does NOT consider
3512
3619
  // `sourceTabId` — that is a Terminal tab id, not an Epic id, and
@@ -3608,6 +3715,8 @@ async function notifyOriginatingTab(job, {
3608
3715
  outcome: job.status,
3609
3716
  validation: 'unvalidated',
3610
3717
  ...(typeof job.agentType === 'string' ? { agentType: job.agentType } : {}),
3718
+ ...(macroNotice ? { notice: macroNotice.notice } : {}),
3719
+ ...(macroNotice && macroNotice.buildOutput ? { buildOutput: macroNotice.buildOutput } : {}),
3611
3720
  }).catch((e) => {
3612
3721
  console.error('[scheduler] notifyOriginatingTab appendResponseEvent error', job?.slug, e);
3613
3722
  return false;
@@ -4883,7 +4992,20 @@ async function executeJob(job, runDir, defaultCwd, onPid, execCwd, resumeTarget
4883
4992
  // Always route through composeExecutorPrompt (even with an empty digest)
4884
4993
  // so the finish protocol is appended in the prompt's tail exactly once,
4885
4994
  // after any digest fence rather than concatenated ahead of it.
4886
- prompt = composeExecutorPrompt({ prdBody: prompt, digestText, finishProtocol: buildFinishProtocol({ reviewInRun, isFixPlan: resolveIsFixPlan(job.slug, job.isFixPlan) }) });
4995
+ // Artifact-only finish variant (PRD 3109): read from the PRD FILE's own
4996
+ // frontmatter — queue rows and parsePrd()'s result carry no
4997
+ // deliverable/artifactPaths, so job.* would always be false. Uses the shared
4998
+ // isArtifactOnlyDeclaration predicate; any read/parse failure → false.
4999
+ let isArtifactOnly = false;
5000
+ if (prdPath) {
5001
+ try {
5002
+ const fm = parsePrdFile(await fsp.readFile(prdPath, 'utf8')).frontmatter;
5003
+ isArtifactOnly = isArtifactOnlyDeclaration(fm);
5004
+ } catch {
5005
+ isArtifactOnly = false;
5006
+ }
5007
+ }
5008
+ prompt = composeExecutorPrompt({ prdBody: prompt, digestText, finishProtocol: buildFinishProtocol({ reviewInRun, isFixPlan: resolveIsFixPlan(job.slug, job.isFixPlan), isArtifactOnly }) });
4887
5009
 
4888
5010
  // Foreign-WIP manifest (starry-night-ships PRD 148 postmortem): the
4889
5011
  // scheduler already knows, at spawn time, which dirty paths this job did
@@ -8958,7 +9080,6 @@ async function reapDeadRunningJobs() {
8958
9080
  // -1 commit count or a missing checkout (runMadeCommit null) or an
8959
9081
  // unreadable status (dirt null) keeps the pre-guard behaviour.
8960
9082
  if (runMadeCommit !== null && dirt !== null) {
8961
- const artifactPaths = row.artifactPaths;
8962
9083
  const guardVerdict = commitGuardVerdict({
8963
9084
  newlyDirty: dirt,
8964
9085
  siblingRunning: false,
@@ -8966,7 +9087,7 @@ async function reapDeadRunningJobs() {
8966
9087
  jobSelfCommitted: runMadeCommit,
8967
9088
  legitimateNoOp: false,
8968
9089
  isFixPlanJob: resolveIsFixPlan(d.slug, row.isFixPlan),
8969
- artifactVerified: row.deliverable === 'artifact' && Array.isArray(artifactPaths) && artifactPaths.length > 0,
9090
+ artifactVerified: isArtifactOnlyDeclaration(row),
8970
9091
  verifyResult: null,
8971
9092
  salvagePatch,
8972
9093
  });
@@ -10999,7 +11120,9 @@ function registerScheduleHandlers() {
10999
11120
  }
11000
11121
  }));
11001
11122
 
11002
- ipcMain.handle('schedule:list-prds', async () => listPrdsInternal());
11123
+ // Optional { cwd } scopes the scan to one project; concurrent calls with the
11124
+ // same cwd key share one in-flight scan (PRD 3063 — heap OOM loop).
11125
+ ipcMain.handle('schedule:list-prds', async (_e, payload) => listPrdsShared({ cwd: payload?.cwd }));
11003
11126
 
11004
11127
  // Return last N completed/failed jobs from queue.json, newest first.
11005
11128
  // Purely additive: no schema change, no archive-folder read needed.
@@ -11607,12 +11730,17 @@ async function listPrdsInternal({ cwd: rawCwd } = {}) {
11607
11730
  dependsOn: parsed.dependsOn ?? null,
11608
11731
  agentType: parsed.agentType ?? null,
11609
11732
  macroId: parsed.macroId ?? null,
11733
+ deliverable: parsed.deliverable ?? null,
11734
+ artifactPaths: parsed.artifactPaths ?? null,
11610
11735
  effort: parsed.effort ?? null,
11611
11736
  disposition: parsed.disposition ?? null,
11612
11737
  planId: parsed.planId ?? null,
11613
11738
  mtimeMs: stat.mtimeMs,
11614
11739
  archived,
11615
11740
  };
11741
+ // Flat copies only: sliced strings into the parsed file text kept
11742
+ // every scanned PRD body alive (2026-11-08 heap snapshot, PRD 3063).
11743
+ flattenPrdEntry(entry);
11616
11744
  out.push(entry);
11617
11745
  } catch (e) {
11618
11746
  logs.writeLine({ level: 'warn', scope: 'scheduler', message: 'list-prds: skipping unparseable file', meta: { name, error: e?.message } });
@@ -11662,7 +11790,7 @@ async function listPrdsInternal({ cwd: rawCwd } = {}) {
11662
11790
  if (i < archivedStart) {
11663
11791
  entry.status = liveStatusBySlug.get(entry.slug) ?? null;
11664
11792
  } else {
11665
- entry.archivedStatus = prdPaths.resolveArchivedPrdStatus(entry.slug, liveStatusBySlug, histBySlug);
11793
+ entry.archivedStatus = flatString(prdPaths.resolveArchivedPrdStatus(entry.slug, liveStatusBySlug, histBySlug));
11666
11794
  entry.status = entry.archivedStatus;
11667
11795
  }
11668
11796
  }
@@ -11671,6 +11799,15 @@ async function listPrdsInternal({ cwd: rawCwd } = {}) {
11671
11799
  return out;
11672
11800
  }
11673
11801
 
11802
+ // Single-flight front door for listPrdsInternal (PRD 3063): concurrent calls
11803
+ // with the same normalized cwd (absent cwd = one machine-wide key) await ONE
11804
+ // in-flight scan; the slot clears on settle, so a later call rescans and a
11805
+ // rejected scan is retried by the next caller.
11806
+ const listPrdsShared = createSingleFlight(
11807
+ (arg) => listPrdsInternal(arg),
11808
+ (arg) => listKeyFor(normalizeListCwd(arg?.cwd)),
11809
+ );
11810
+
11674
11811
  // remote — in-process (non-IPC) scheduler accessors, used by prdCreate.cjs
11675
11812
  // and other main-process callers. (Named for the retired web-remote relay,
11676
11813
  // its original consumer; kept because it still has in-process callers.)
@@ -11881,7 +12018,7 @@ const remote = {
11881
12018
  // long as the underlying PRD set doesn't change mid-page.
11882
12019
  async listPrds(filter = {}) {
11883
12020
  const filterCwd = normalizeListCwd(filter.cwd);
11884
- const all = await listPrdsInternal({ cwd: filterCwd });
12021
+ const all = await listPrdsShared({ cwd: filterCwd });
11885
12022
  const filtered = all.filter((entry) => {
11886
12023
  if (filterCwd && entry.cwd !== filterCwd) return false;
11887
12024
  if (filter.epicId && entry.epicId !== filter.epicId) return false;
@@ -12379,6 +12516,7 @@ module.exports = {
12379
12516
  prdArchivedSkipResult,
12380
12517
  spawnJob,
12381
12518
  listPrdsInternal,
12519
+ listPrdsShared,
12382
12520
  heartbeatTick,
12383
12521
  appendHeartbeat,
12384
12522
  QUARANTINE_ESCALATE_MS,
@@ -127,6 +127,29 @@ function readMarker() {
127
127
  }
128
128
  }
129
129
 
130
+ /**
131
+ * This seeder's own marker → 'done' | 'pending' | 'failed' | 'exhausted', read by
132
+ * seedStatus.cjs. Owned here because only this file knows its marker format: done means
133
+ * every name in PERSONAS is in `seeded`, whatever `attempts` is. A legacy `{ done: true }`
134
+ * marker (no `seeded` array) still reads as done. Parses the raw file itself rather than
135
+ * going through readMarker(), which maps legacy done to LEGACY_DONE_PERSONAS and would
136
+ * report it as not done. Never throws — absent or unparseable reads as 'pending'.
137
+ */
138
+ function markerStatus() {
139
+ try {
140
+ const m = JSON.parse(fs.readFileSync(markerPath(), 'utf8').trim());
141
+ const done = Array.isArray(m.seeded)
142
+ ? PERSONAS.every((n) => m.seeded.includes(n))
143
+ : Boolean(m.done);
144
+ if (done) return 'done';
145
+ const attempts = Number(m.attempts) || 0;
146
+ if (attempts >= MAX_ATTEMPTS) return 'exhausted';
147
+ return attempts > 0 ? 'failed' : 'pending';
148
+ } catch {
149
+ return 'pending';
150
+ }
151
+ }
152
+
130
153
  function writeMarker(state) {
131
154
  try {
132
155
  writeJsonSync(markerPath(), { ...state, ts: new Date().toISOString() });
@@ -383,6 +406,7 @@ module.exports = {
383
406
  normalizeNewlines,
384
407
  sameFmValue,
385
408
  markerPath,
409
+ markerStatus,
386
410
  MAX_ATTEMPTS,
387
411
  PERSONAS,
388
412
  };
@@ -22,7 +22,10 @@ const SEEDERS = {
22
22
  'agent-personas': seedAgentPersonas,
23
23
  };
24
24
 
25
- /** One seeder's marker → 'done' | 'pending' | 'failed' | 'exhausted'. */
25
+ /**
26
+ * Default reader for `{ done, attempts }` markers → 'done' | 'pending' | 'failed' | 'exhausted'.
27
+ * A seeder whose marker has another shape exports its own `markerStatus()` instead.
28
+ */
26
29
  function statusFromMarker(mod) {
27
30
  try {
28
31
  const raw = fs.readFileSync(mod.markerPath(), 'utf8').trim();
@@ -52,7 +55,7 @@ function getSeedStatus() {
52
55
  const out = {};
53
56
  for (const [id, mod] of Object.entries(SEEDERS)) {
54
57
  const fix = FIXES[id];
55
- out[id] = { status: statusFromMarker(mod), fix: typeof fix === 'function' ? fix() : fix };
58
+ out[id] = { status: typeof mod.markerStatus === 'function' ? mod.markerStatus() : statusFromMarker(mod), fix: typeof fix === 'function' ? fix() : fix };
56
59
  }
57
60
  return out;
58
61
  }
@@ -10,7 +10,6 @@ const otel = require('./otel.cjs');
10
10
  const otelSettings = require('./otelSettings.cjs');
11
11
  const telemetrySettings = require('./lib/telemetry/telemetrySettings.cjs');
12
12
  const telemetryClient = require('./lib/telemetry/telemetryClient.cjs');
13
- const telemetryBacklog = require('./lib/telemetry/telemetryBacklog.cjs');
14
13
  const telemetryConsent = require('./lib/telemetry/telemetryConsent.cjs');
15
14
 
16
15
  /**
@@ -39,10 +38,7 @@ function registerTelemetryHandlers({ ipcMain }) {
39
38
  const saved = await telemetryConsent.applyConsentUpdate(cfg, { telemetrySettings, telemetryClient });
40
39
  return { ok: true, config: saved, status: telemetryClient.status() };
41
40
  }));
42
- ipcMain.handle('telemetry:status', () => ({
43
- ...telemetryClient.status(),
44
- backlog: telemetryBacklog.lastRunSummary(),
45
- }));
41
+ ipcMain.handle('telemetry:status', () => telemetryClient.status());
46
42
  ipcMain.handle('telemetry:config-path', () => telemetrySettings.storePath());
47
43
  ipcMain.handle('telemetry:recent-records', () => telemetryClient.recentRecords());
48
44
  ipcMain.handle('telemetry:flush-now', () => telemetryClient.flush('manual'));
@@ -1,4 +1,4 @@
1
- <!-- PRD_AUTHORING.md v19 -->
1
+ <!-- PRD_AUTHORING.md v20 -->
2
2
  # PRD Authoring Guide — Scheduler Safety Rules
3
3
 
4
4
  Rule: every PRD you queue follows the rules below.
@@ -189,7 +189,7 @@ timeout 120 python -m pytest tests/test_repro.py::test_bug 2>&1 | tail -3 || tru
189
189
  timeout 300 pytest -q # LAST thing the run does
190
190
  ```
191
191
 
192
- The scheduler appends a finish protocol after your PRD's own steps — you never write it: review, then the `# Gate` commands (§6), then commit only the exact paths you created or changed for this PRD, then the verdict line — `SCHEDULER_VERDICT: PASS` once the gate is green and the commit landed, else `SCHEDULER_VERDICT: FAIL <one-line reason>`. Never print `PASS` on a red gate.
192
+ The scheduler appends a finish protocol after your PRD's own steps — you never write it: review, then the `# Gate` commands (§6), then commit only the exact paths you created or changed for this PRD, then the verdict line — `SCHEDULER_VERDICT: PASS` once the gate is green and the commit landed (an artifact-only PRD, §5, lands no commit by design and prints `PASS` once the gate is green and the tree is clean), else `SCHEDULER_VERDICT: FAIL <one-line reason>`. Never print `PASS` on a red gate.
193
193
 
194
194
  ---
195
195