claude-code-session-manager 0.142.0 → 0.143.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 (95) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +20 -107
  3. package/dist/assets/{AppSettings-BcZgIvvY.js → AppSettings-BO4jDVGO.js} +1 -1
  4. package/dist/assets/{History-DpZuJXi1.js → History-DTttbvPb.js} +1 -1
  5. package/dist/assets/{HomeClaudeConfig-D32ZJtU-.js → HomeClaudeConfig-DADP5bfn.js} +2 -2
  6. package/dist/assets/{Panel-BjdJjhqt.js → Panel-B_D4Bg7L.js} +1 -1
  7. package/dist/assets/{ProjectClaudeConfig-BTClYV6i.js → ProjectClaudeConfig-DPnDJKcr.js} +1 -1
  8. package/dist/assets/{Scheduler-DPobKx1Z.js → Scheduler-CNLjn90m.js} +8 -8
  9. package/dist/assets/{SkillReferenceGraph-Cqyu4mef.js → SkillReferenceGraph-D1b2aiol.js} +1 -1
  10. package/dist/assets/{Skills-vv0noNVI.js → Skills-cfV7sgk6.js} +1 -1
  11. package/dist/assets/{TiptapBody-CXi8Pvut.js → TiptapBody-DVXtEIVy.js} +1 -1
  12. package/dist/assets/{Toggle-CiYCWLjh.js → Toggle-CYajnSdx.js} +1 -1
  13. package/dist/assets/{VoiceButton-4NKKd1sC.js → VoiceButton-DJ4gGRuE.js} +1 -1
  14. package/dist/assets/{historyTotals-DDunb8Ch.js → historyTotals-D3MoHY2U.js} +1 -1
  15. package/dist/assets/{index-Cn5E9958.js → index-CdTppjKR.js} +436 -436
  16. package/dist/index.html +1 -1
  17. package/dist-web/app.js +356 -356
  18. package/package.json +3 -3
  19. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  20. package/plugins/session-manager-dev/skills/builder/SKILL.md +5 -0
  21. package/plugins/session-manager-dev/skills/develop/SKILL.md +9 -3
  22. package/scripts/README.md +1 -0
  23. package/scripts/scheduler-mcp-server.cjs +304 -6
  24. package/src/main/adminRouteRegistry.cjs +10 -0
  25. package/src/main/build-info.json +4 -4
  26. package/src/main/chatRunner.cjs +105 -7
  27. package/src/main/config.cjs +5 -1
  28. package/src/main/health.cjs +38 -2
  29. package/src/main/index.cjs +12 -4
  30. package/src/main/ipcSchemas.cjs +11 -0
  31. package/src/main/lib/demo-video-kit/cast.md +10 -1
  32. package/src/main/lib/demo-video-kit/character.cjs +77 -21
  33. package/src/main/lib/demo-video-kit/kind-tiktok.md +5 -1
  34. package/src/main/lib/demo-video-kit/projectSounds.cjs +191 -0
  35. package/src/main/lib/demo-video-kit/seedKit.cjs +3 -3
  36. package/src/main/lib/demo-video-kit/sound.cjs +166 -9
  37. package/src/main/lib/demo-video-kit/standalone.cjs +231 -0
  38. package/src/main/lib/epic/activeIndexMerge.cjs +5 -0
  39. package/src/main/lib/epic/artifactRetention.cjs +55 -9
  40. package/src/main/lib/epic/artifactStore.cjs +78 -35
  41. package/src/main/lib/epic/delegationReadiness.cjs +10 -3
  42. package/src/main/lib/epic/epicEventLog.cjs +45 -1
  43. package/src/main/lib/epic/epicStateEmitter.cjs +248 -0
  44. package/src/main/lib/epic/epicValidationHook.cjs +13 -2
  45. package/src/main/lib/externalContract.cjs +12 -1
  46. package/src/main/lib/feedback-remote/autoStartedSession.cjs +1 -1
  47. package/src/main/lib/feedback-remote/crossProjectReply.cjs +96 -8
  48. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +30 -0
  49. package/src/main/lib/feedback-remote/pendingReplies.cjs +18 -0
  50. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +94 -4
  51. package/src/main/lib/feedback-remote/replyClaims.cjs +159 -0
  52. package/src/main/lib/git/gitWorktree.cjs +8 -0
  53. package/src/main/lib/git/runtimeStateUntrack.cjs +15 -1
  54. package/src/main/lib/git/worktreeDeps.cjs +113 -10
  55. package/src/main/lib/mcpToolCatalog.cjs +102 -8
  56. package/src/main/lib/opsOwnership.cjs +113 -28
  57. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +46 -0
  58. package/src/main/lib/prd/prdCreate.cjs +350 -227
  59. package/src/main/lib/prd/prdCriteria.cjs +7 -4
  60. package/src/main/lib/project-pages/videoPressLines.cjs +145 -0
  61. package/src/main/lib/project-pages/videoScriptPress.cjs +260 -0
  62. package/src/main/lib/project-pages/videoScriptRunRoute.cjs +351 -0
  63. package/src/main/lib/project-pages/videoScriptSwitchIpc.cjs +49 -0
  64. package/src/main/lib/project-pages/videoScriptSwitchRoute.cjs +173 -0
  65. package/src/main/lib/scheduler/criteriaChecks.cjs +164 -20
  66. package/src/main/lib/scheduler/heldSchedulerTurns.cjs +238 -0
  67. package/src/main/lib/scheduler/jobMemoryStats.cjs +13 -2
  68. package/src/main/lib/scheduler/planRecordHarvest.cjs +120 -52
  69. package/src/main/lib/scheduler/prdOutcomeRecord.cjs +60 -2
  70. package/src/main/lib/scheduler/queueStore.cjs +16 -0
  71. package/src/main/lib/scheduler/rcaReport.cjs +79 -15
  72. package/src/main/lib/scheduler/scheduleJobSchema.cjs +13 -0
  73. package/src/main/lib/scheduler/schedulerPaths.cjs +9 -0
  74. package/src/main/lib/scheduler/slotsRoute.cjs +101 -87
  75. package/src/main/lib/scheduler/usageHoldRoute.cjs +97 -0
  76. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +16 -5
  77. package/src/main/lib/tasks/memoryConsolidation.cjs +14 -2
  78. package/src/main/lib/tasks/mitigationReview.cjs +21 -1
  79. package/src/main/lib/tasks/taskAdminRoutes.cjs +78 -3
  80. package/src/main/lib/tasks/taskLedger.cjs +2 -2
  81. package/src/main/lib/telemetry/auditEvents.cjs +21 -24
  82. package/src/main/lib/telemetry/auditLog.cjs +6 -2
  83. package/src/main/lib/util/atomicFs.cjs +2 -2
  84. package/src/main/promptSessionEvents.cjs +16 -1
  85. package/src/main/pty.cjs +11 -2
  86. package/src/main/queueOps.cjs +1 -1
  87. package/src/main/runVerify.cjs +1 -1
  88. package/src/main/scheduler/utilizationHold.cjs +96 -6
  89. package/src/main/scheduler.cjs +533 -39
  90. package/src/main/templates/PRD_AUTHORING.md +7 -2
  91. package/src/preload/api.d.ts +47 -1
  92. package/src/preload/apiSurface.json +14 -0
  93. package/src/preload/index.cjs +2 -0
  94. package/src/seed/agents/demo-video-builder.md +15 -8
  95. package/src/seed/agents/validator.md +20 -19
@@ -1,4 +1,4 @@
1
- <!-- PRD_AUTHORING.md v28 -->
1
+ <!-- PRD_AUTHORING.md v30 -->
2
2
  # PRD Authoring Guide — Scheduler Safety Rules
3
3
 
4
4
  Rule: every PRD you queue follows the rules below.
@@ -143,9 +143,12 @@ A short Epic-context digest is prepended automatically for orientation only —
143
143
 
144
144
  The executor can't ask you anything: no `ScheduleWakeup`, Cron, Monitor, `AskUserQuestion`, plan mode, or worktree tools; background tasks are off (a `timeout` command is always on PATH — the app installs a shim on macOS). It must never stop to ask a question — it makes the safest reasonable call and reports it, so write the PRD so that call is obvious.
145
145
 
146
- Worktree reach: every PRD runs in an isolated git worktree holding tracked files plus `node_modules` and non-uv `.venv`/`venv` symlinked from the main checkout; pnpm projects (pnpm-lock.yaml) get a worktree-local `node_modules` installed offline from the store, and uv projects (uv.lock) get a worktree-local env built by an offline frozen `uv sync`, not a symlink. Why: a pnpm install through the symlink purged the main checkout's node_modules (Bilko-Game-Academy 2026-10-18). A step that needs gitignored runtime state (databases, downloads/, browser profiles, logs) or a live side effect must address the main checkout by absolute path (e.g. `$HOME/Projects/<repo>/...`), be artifact-only (a deliverable artifact + `artifactPaths`, no tracked edits), and `dependsOn` the PRD that lands its tracked edits. A project may declare `worktreeSetup` gate-syntax commands in a tracked `.session-manager.json` at the repo root; they run once per fresh job worktree and baseline scratch worktree, before the executor starts, with cwd = the worktree root (a project in a subfolder names it, e.g. `timeout 600 godot --headless --path game --import`). Setups run one at a time per project and are never skipped; they must write only inside the worktree (node_modules and non-uv venvs are symlinks into the main checkout). The outcome is the `[scheduler] worktree setup:` lines at the top of the run log plus `worktreeSetup` in the run's meta.json. Host crontab installs stay human-only (see §14).
146
+ Worktree reach: every PRD runs in an isolated git worktree holding tracked files plus linked dependencies: `node_modules` (the root and each nested npm package's) is a worktree-local folder whose entries link to the main checkout's, and non-uv `.venv`/`venv` is symlinked whole; pnpm projects (pnpm-lock.yaml) get a worktree-local `node_modules` installed offline from the store, and uv projects (uv.lock) get a worktree-local env built by an offline frozen `uv sync`, not a symlink. Why: a pnpm install through the symlink purged the main checkout's node_modules (Bilko-Game-Academy 2026-10-18). A step that needs gitignored runtime state (databases, downloads/, browser profiles, logs) or a live side effect must address the main checkout by absolute path (e.g. `$HOME/Projects/<repo>/...`), be artifact-only (a deliverable artifact + `artifactPaths`, no tracked edits), and `dependsOn` the PRD that lands its tracked edits. A project may declare `worktreeSetup` gate-syntax commands in a tracked `.session-manager.json` at the repo root; they run once per fresh job worktree and baseline scratch worktree, before the executor starts, with cwd = the worktree root (a project in a subfolder names it, e.g. `timeout 600 godot --headless --path game --import`). Setups run one at a time per project and are never skipped; they must write only inside the worktree (node_modules entries and non-uv venvs link into the main checkout). The outcome is the `[scheduler] worktree setup:` lines at the top of the run log plus `worktreeSetup` in the run's meta.json. Host crontab installs stay human-only (see §14).
147
147
  Why: burrow PRD 1516 halted because its relative `.venv` python against downloads/fb-tracker.db, scripts/install-cron.sh and `pipeline-cron.sh --now` resolved inside the worktree (no runtime state; install-cron would bake a temporary worktree path into crontab), while sibling 1494 succeeded the same day using an absolute main-checkout path and artifact-only output. `scheduler_create_prd` warns on relative gitignored paths.
148
148
 
149
+ Rule: gates never run `npm ci` or `npm install` — dependencies are already linked, so an install only slows the run.
150
+ Why: `npm --prefix web/feedback-widget ci` through the old whole-folder link emptied the main checkout's web/feedback-widget/node_modules (session-manager, 2026-11-24).
151
+
149
152
  Rule: a job's processes never outlive it — the group sweep at exit, the job scope stop (systemd) and the 5-minute leftover sweep (Linux) stop anything it started, so `nohup` or `&` does not daemonize. Anything that must keep running goes to a service manager (systemd unit, cron), never `nohup` or `&`.
150
153
  Why: finished jobs left dev servers running for days, holding memory and ports.
151
154
 
@@ -243,6 +246,7 @@ Before queueing a new PRD, verify each of these:
243
246
  - [ ] **§6 Gate and files:** `gate` follows every rule in §6 (or is `["none"]` alone); `files` is 1–50 repo-relative paths, no overlap with a concurrent PRD.
244
247
  - [ ] **§7 Self-contained:** no reference to "the conversation" or outside context; paths/identifiers inline; clean UTF-8, no NUL bytes (`grep -qP '\x00' file && echo BAD`).
245
248
  - [ ] **§7 Worktree reach:** no relative path to a gitignored file; live-run steps use absolute main-checkout paths in an artifact-only PRD. Why: the job worktree has no gitignored runtime state, so relative paths fail or bake a temporary path into host config (burrow 1516).
249
+ - [ ] **§7 No installs:** no gate runs `npm ci` or `npm install`. Why: dependencies are linked; an install through a link emptied the main checkout's web/feedback-widget/node_modules (2026-11-24).
246
250
  - [ ] **§8 Scope:** targets ≤10 min, ceiling 15; e2e/publish sharded to one spec per PRD.
247
251
  - [ ] **§9 Failure surfacing:** errors exit 1 with a diagnostic line; no silent `|| true`.
248
252
  - [ ] **§10 Negative assertions:** every "should find nothing" check is inverted to exit 0 on the clean case.
@@ -253,4 +257,5 @@ Before queueing a new PRD, verify each of these:
253
257
  - [ ] **No interactive AC:** no criterion asks to launch the app, click through, capture a screenshot, run under xvfb or open a browser. Why: a headless run stalls on a rendered frame and is SIGTERM'd uncommitted; recommend manual visual confirmation in the report instead.
254
258
  - [ ] **Contract consumers gated:** a PRD that changes a return shape, IPC payload or remote contract greps `tests/` (and `src/**/__tests__`) for every spec using it and puts each in its gate and files. Why: scoped gates let other specs go red unseen until the release gate.
255
259
  - [ ] **Doc links gated:** a PRD that adds, moves or renames a markdown file runs the project's doc-link check in its gate when the project has one (in session-manager: `timeout 120 npm run lint:docs`). Why: PRD kit-cast-playbook added `src/main/lib/demo-video-kit/cast.md` with only the kit tests in its gate, so the orphan doc landed on 2026-11-23 and turned lint:docs red for the next PRD.
260
+ - [ ] **Size budgets gated:** a PRD that edits a file the project caps by size runs that cap's check in its gate when the project has one (in session-manager: README.md gates `timeout 120 npm run lint:readme`). Why: PRD 4105-web-remote-label-leftovers edited README.md with only lint:docs and typecheck in its gate, so README.md reached 24,026 bytes on 2026-11-24, over its cap, and npm run lint turned red for every later PRD.
256
261
  - [ ] **Gate purity:** a gate command must not create or modify tracked files; outputs go to the per-gate TMPDIR or a gitignored path. Why: a dirtied tree fails the clean-tree check.
@@ -369,7 +369,7 @@ export interface MacroJobDispatchInput {
369
369
  }
370
370
 
371
371
  export type MacroJobDispatchResult =
372
- | { ok: true; slug: string; epicId: string }
372
+ | { ok: true; slug: string; epicId: string; entryId: string | null; stage: 'review' | 'final' | null }
373
373
  | { ok: false; error: string; activeSlug?: string };
374
374
 
375
375
  export type MacroJobState = 'queued' | 'running' | 'done' | 'failed';
@@ -1110,6 +1110,8 @@ export interface ScheduleJob {
1110
1110
  macroId?: string | null;
1111
1111
  /** Content id of the AgentSnapshot the first dispatch pinned; a resume re-runs it, never the live persona. */
1112
1112
  agentSnapshotId?: string;
1113
+ /** Validator only: dispatch-time { ids, failedIds } per judged PRD; the verdict is cross-checked against it, never a re-run. */
1114
+ validatorCriteriaExpected?: Record<string, { ids: string[]; failedIds: string[] }>;
1113
1115
  /** PRD frontmatter artifact-only declaration (PRD 3114). */
1114
1116
  deliverable?: 'artifact' | null;
1115
1117
  artifactPaths?: string[] | null;
@@ -1203,6 +1205,16 @@ export interface ScheduleJob {
1203
1205
  * lost — set whenever the commit-guard's worktree or in-place salvage
1204
1206
  * pass produced one (PRD 1098). */
1205
1207
  salvagePatch?: string | null;
1208
+ /** Artifact evidence spawnJob captured for a declared artifact-only PRD
1209
+ * before its job worktree was removed, bound to the capturing run's
1210
+ * `runId`; the stale needs_review rescan reuses it only for that run. */
1211
+ artifactEvidence?: {
1212
+ runId: string;
1213
+ ok: boolean;
1214
+ verified: unknown[];
1215
+ paths: string[];
1216
+ capturedAt: string;
1217
+ } | null;
1206
1218
  /** Commit + ref pinning a reaped run's uncommitted checkout work before the checkout was lost (PRD 2892). */
1207
1219
  uncommittedSnapshot?: { sha: string; ref: string };
1208
1220
  /** Why a pending row is not being dispatched this tick (worktree cap, launch circuit breaker). */
@@ -1455,6 +1467,8 @@ export interface ScheduleStateSnapshot {
1455
1467
  utilizationWindow?: string | null;
1456
1468
  /** Non-null while the when-available gate is holding the queue on utilization: which window, and its reset. */
1457
1469
  utilizationHold?: { window: string | null; percent: number; threshold: number; resetsAt: string | null } | null;
1470
+ /** Pro-rated 'pause above' for the binding window of the last known reading (rises from config.utilizationThreshold to 100 as the window nears reset). null with no known reading. */
1471
+ effectiveUtilizationThreshold?: number | null;
1458
1472
  /** Poll health — last billing poll result; used to detect stale utilization. */
1459
1473
  pollHealth?: SchedulePollHealth;
1460
1474
  /** Effective concurrency cap and whether it's env-pinned or config-driven. */
@@ -2255,6 +2269,26 @@ export type VideoReviewRetryResult =
2255
2269
  | { ok: true; slug: string; epicId: string; entryId?: string | null; stage?: string }
2256
2270
  | { ok: false; error: string; activeSlug?: string };
2257
2271
 
2272
+ // ────────────────────────────────────────────── Project Pages: 'Scripts may run Demo Video' switch
2273
+ // Mirrors src/main/lib/project-pages/videoScriptPress.cjs (getVideoScriptSwitch) and
2274
+ // src/main/lib/project-pages/videoScriptSwitchIpc.cjs (videos:script-switch-get / script-switch-set).
2275
+
2276
+ export interface VideoScriptSwitchGetPayload {
2277
+ cwd: string;
2278
+ }
2279
+
2280
+ export interface VideoScriptSwitchSetPayload {
2281
+ cwd: string;
2282
+ enabled: boolean;
2283
+ }
2284
+
2285
+ /** One project's switch; changedAt/by are null when it was never set. Same attribution shape as TaskSwitchBy. */
2286
+ export interface VideoScriptSwitchState {
2287
+ enabled: boolean;
2288
+ changedAt: string | null;
2289
+ by: TaskSwitchBy | null;
2290
+ }
2291
+
2258
2292
  // ────────────────────────────────────────────── Voices screen
2259
2293
  // Mirrors src/main/lib/demo-video-kit/voiceLibrary.cjs (listVoices) and
2260
2294
  // src/main/lib/project-pages/voicesIpc.cjs (voices:list / preview / approve / unapprove / delete).
@@ -2833,6 +2867,12 @@ export interface ChatExternalNewSessionResult {
2833
2867
  /** The minted Epic's id when `ok`. */
2834
2868
  epicId?: string;
2835
2869
  error?: string;
2870
+ /** Project Home entry id of the background build queued for a scripted job press (Demo Video). */
2871
+ entryId?: string;
2872
+ /** That build's slug. */
2873
+ slug?: string;
2874
+ /** That build's stage; null when it has none. */
2875
+ stage?: 'review' | 'final' | null;
2836
2876
  }
2837
2877
 
2838
2878
  export type CreateProjectFolderResult =
@@ -3560,6 +3600,10 @@ export interface SessionManagerAPI {
3560
3600
  reviewDecide: (payload: VideoReviewDecidePayload) => Promise<VideoReviewDecideResult>;
3561
3601
  /** Re-dispatch the final stage of an approved entry whose final run failed (canRetry), reusing the recorded approval and inputs. Desktop only (never via the phone relay); one in-flight decide/retry per entry. */
3562
3602
  reviewRetry: (payload: VideoReviewRetryPayload) => Promise<VideoReviewRetryResult>;
3603
+ /** Read this project's 'Scripts may run Demo Video' switch; off with null changedAt/by when never set. Rejects on an invalid cwd. */
3604
+ scriptSwitchGet: (payload: VideoScriptSwitchGetPayload) => Promise<VideoScriptSwitchState>;
3605
+ /** A human click: turn the switch on/off, recorded as by { via: 'ui' } plus one audit event. Desktop only. Rejects on a bad payload. */
3606
+ scriptSwitchSet: (payload: VideoScriptSwitchSetPayload) => Promise<VideoScriptSwitchState>;
3563
3607
  /** Fires whenever a watched cwd's knowledge/videos library is added/changed/removed, carrying the freshly read library result. */
3564
3608
  onChanged: (handler: (payload: { cwd: string } & ProjectPagesGetResult) => void) => () => void;
3565
3609
  };
@@ -3705,6 +3749,8 @@ export interface SessionManagerAPI {
3705
3749
  requestId?: string;
3706
3750
  via?: 'script';
3707
3751
  effort?: string;
3752
+ /** Scripted job press: build a review cut first. */
3753
+ reviewStage?: boolean;
3708
3754
  }) => void,
3709
3755
  ) => () => void;
3710
3756
  /** Classify a queued PromptTicket's text as 'inline' (run through
@@ -1932,6 +1932,20 @@
1932
1932
  "kind": "invoke",
1933
1933
  "remote": "deny"
1934
1934
  },
1935
+ {
1936
+ "ns": "projectPages",
1937
+ "method": "scriptSwitchGet",
1938
+ "channel": "videos:script-switch-get",
1939
+ "kind": "invoke",
1940
+ "remote": "read"
1941
+ },
1942
+ {
1943
+ "ns": "projectPages",
1944
+ "method": "scriptSwitchSet",
1945
+ "channel": "videos:script-switch-set",
1946
+ "kind": "invoke",
1947
+ "remote": "deny"
1948
+ },
1935
1949
  {
1936
1950
  "ns": "projectPages",
1937
1951
  "method": "onChanged",
@@ -478,6 +478,8 @@ contextBridge.exposeInMainWorld('api', {
478
478
  reviewList: (payload) => ipcRenderer.invoke('project-videos:review-list', payload),
479
479
  reviewDecide: (payload) => ipcRenderer.invoke('project-videos:review-decide', payload),
480
480
  reviewRetry: (payload) => ipcRenderer.invoke('project-videos:review-retry', payload),
481
+ scriptSwitchGet: (payload) => ipcRenderer.invoke('videos:script-switch-get', payload),
482
+ scriptSwitchSet: (payload) => ipcRenderer.invoke('videos:script-switch-set', payload),
481
483
  onChanged: (handler) => {
482
484
  const listener = (_e, payload) => handler(payload);
483
485
  ipcRenderer.on('project-pages:changed', listener);
@@ -6,7 +6,7 @@ mcpServers: session-manager-scheduler
6
6
  title: 'Project Home — Demo Video'
7
7
  model: opus
8
8
  effort: max
9
- seedVersion: 23
9
+ seedVersion: 25
10
10
  ---
11
11
 
12
12
  You are the demo-video-builder. You make a short animated demo, 30 seconds or 1 minute long per `<length_and_pacing>`, that shows someone what this
@@ -91,17 +91,18 @@ Read two lines in the additional instructions:
91
91
  <kit>
92
92
  The shared kit is `~/.claude/session-manager/demo-video-kit/` (`<kit>` in paths). Needs node and ffmpeg; Playwright is found at runtime. Call each tool from a short node script in your temp directory, never the project tree.
93
93
  - `capture.cjs`: when a product URL exists, call `require('~/.claude/session-manager/demo-video-kit/capture.cjs').capture({ url, outDir, shots })` (expand the home path) for up to 6 real screenshots, embedded as `data:` URIs. Never draw a fake screen when a capture exists.
94
- - `sound.cjs`: `node sound.cjs spec.json` with `{ narrationWav, cues, style, lengthS, out }` builds a music bed and effects, ducks them under the narration, and normalizes the mix to -14 LUFS: the audio track.
94
+ - `sound.cjs`: `node sound.cjs spec.json` with `{ narrationWav, cues, style, bed?, lengthS, out, projectRoot }` (projectRoot = `$SM_PROJECT_ROOT`) builds a music bed and effects, ducks them under the narration, and normalizes the mix to -14 LUFS: the audio track. A cue `{ name, t }` names a built-in effect (whoosh, pop, chime, click) or one of the persona's `sounds.sfx`; `bed` names one of the persona's `sounds.beds`, and without it the style's built-in bed plays. An unknown name fails the run: report sound.cjs's error and never swap in another sound.
95
95
  - `frames.cjs`: `sampleFrames({ htmlPath, lengthS })` returns per-frame stats plus a contact sheet of the finished document. Look at it; no blank frame may last past 0.5 s.
96
96
  - `checks.cjs`: `node checks.cjs input.json` with `{ captions, narration, closing, lines, speechS, lengthS, frames, html }` must exit 0 before you save; fix each failing check and rerun.
97
97
  - `_character`: the project persona per `<project_persona>`. With none, design a mascot per `<character>` and save it once with `project_character_write`.
98
98
  - `character.cjs`: `node <kit>/character.cjs speak spec.json` with `{ projectRoot, lines: [{ text, out, speaker? }], voice? }` (projectRoot = `$SM_PROJECT_ROOT`) speaks every line in the voice `<audio_policy>` picks, through the voice lane, no shell, no fallback; a `{lines}` voice is one batch call per speaker, same spec. Exit 75 = still speaking or waiting in the lane: run the same command again until it exits 0 or 1.
99
+ - `standalone.cjs`: `node <kit>/standalone.cjs <built.html>` (no-host play) must exit 0 before saving; fix and rerun.
99
100
  - `export.cjs`: `node <kit>/export.cjs spec.json` with `{ htmlPath, lengthS, audioPath, outDir }` writes `video.mp4` and `poster.png` in `outDir` (9:16 documents export as 1080x1920). It must exit 0.
100
101
  The soundtrack must come from sound.cjs's mix. Never hand-write ffmpeg mixing, ducking, sidechain or filter graphs for the soundtrack.
101
102
  </kit>
102
103
 
103
104
  <project_persona>
104
- A valid saved persona in the project's session-manager-operations/project-pages/videos/_character/ (`character.json` plus `character.js`) hosts every video unless the additional instructions carry 'Character: off'. Read both files first. The host keeps its `name` and the look `character.js` draws; its `palette` is the video's palette (the whiteboard palette rule in `<styles>` still wins). When `personality` is present it shapes the script: `who` is the host's point of view, `speech` how it talks, `readingLevel` the reading level (never above `<audience_and_language>`'s grade 8), and no line or caption contains a `neverSay` word. Its `voice` speaks per `<audio_policy>`. When character.json has a `cast`, read `<kit>/cast.md` before writing the script and follow it. Never redraw, rename or overwrite a saved persona, and never call `project_character_write` when one exists; a 409 from it is never answered with `replace`: build unsaved and name the problem in the report. With no valid persona, invent a mascot per `<character>`; with 'Character: off', no host at all.
105
+ A valid saved persona in the project's session-manager-operations/project-pages/videos/_character/ (`character.json` plus `character.js`) hosts every video unless the additional instructions carry 'Character: off'. Read both files first. The host keeps its `name` and the look `character.js` draws; its `palette` is the video's palette (the whiteboard palette rule in `<styles>` still wins). When `personality` is present it shapes the script: `who` is the host's point of view, `speech` how it talks, `readingLevel` the reading level (never above `<audience_and_language>`'s grade 8), and no line or caption contains a `neverSay` word. Its `voice` speaks per `<audio_policy>`. When character.json has a `cast`, read `<kit>/cast.md` before writing the script and follow it. When character.json has `sounds`, its effects (`sfx`) and music beds (`beds`) are the project's own: use them by `name` (each `note` says what it is) per `<kit>`'s sound.cjs line. Never redraw, rename or overwrite a saved persona, and never call `project_character_write` when one exists; a 409 from it is never answered with `replace`: build unsaved and name the problem in the report. With no valid persona, invent a mascot per `<character>`; with 'Character: off', no host at all.
105
106
  </project_persona>
106
107
 
107
108
  <character>
@@ -175,8 +176,9 @@ Produce exactly one complete HTML document:
175
176
  - No network: no `fetch`, `XMLHttpRequest`, `WebSocket`, `EventSource`, `sendBeacon`, `import()`,
176
177
  `Worker`, `<iframe>`, `<form>`, or outbound `src`/`href`, and no navigating with `window.open` or
177
178
  `location`. System font stack only, and any images as `data:` URIs.
178
- - Respects `prefers-reduced-motion` by rendering the scenes as a static storyboard instead of
179
- animating them, stepped by the host's `seek(t)` — no in-video prev/next buttons.
179
+ - Respects `prefers-reduced-motion`: the scenes render as still keystones, with hard cuts on the
180
+ video's own clock; narration plays as usual; the host's `seek(t)` still renders the exact frame;
181
+ no in-video prev/next buttons.
180
182
  - Under 2 MB total.
181
183
  </output_contract>
182
184
 
@@ -236,7 +238,7 @@ for start, wav in SCENES:
236
238
  clip = samples[: len(buf) - at]
237
239
  buf[at : at + len(clip)] += clip
238
240
  soundfile.write('narration.wav', buf, sr)
239
- # spec.json: { "narrationWav": "narration.wav", "cues": [...], "style": "...", "lengthS": D, "out": "mix.mp3" }
241
+ # spec.json: { "narrationWav": "narration.wav", "cues": [...], "style": "...", "bed": "<a persona bed, optional>", "lengthS": D, "out": "mix.mp3", "projectRoot": "<$SM_PROJECT_ROOT>" }
240
242
  KIT = os.path.expanduser('~/.claude/session-manager/demo-video-kit')
241
243
  subprocess.run(['node', f'{KIT}/sound.cjs', 'spec.json'], check=True)
242
244
  b64 = base64.b64encode(open('mix.mp3', 'rb').read()).decode()
@@ -247,7 +249,12 @@ open('demo.html', 'w').write(html)
247
249
  Keep the whole document under the 2 MB cap.
248
250
  - Wire `play()`/`pause()`/`seek(t)` to the `<audio>` element too (`audio.currentTime = t` on
249
251
  seek) so narration never drifts from the visual clock; call `.play()` on load and, on rejection
250
- (autoplay-blocked), keep playing muted — the host player's sound button unmutes it.
252
+ (autoplay-blocked), keep the picture playing and start the narration at the clock's current time
253
+ on the first `pointerdown` or `keydown` anywhere in the document. This draws no visible control
254
+ and no `<button>`. The host player's sound button also unmutes it. Sketch (`t` = clock time):
255
+ `const ev = ['pointerdown', 'keydown'], go = () => { audio.currentTime = t; audio.play();
256
+ ev.forEach(e => document.removeEventListener(e, go)); };
257
+ audio.play().catch(() => ev.forEach(e => document.addEventListener(e, go)));`
251
258
  - Never write the literal pattern `function (` or `function(` in the inline `<script>` —
252
259
  `project_video_write`'s safety scanner blocks anything matching `/\bFunction\s*\(/i`.
253
260
  Use arrow functions (`() => { ... }`) throughout.
@@ -276,7 +283,7 @@ open('demo.html', 'w').write(html)
276
283
  6. Build the HTML per `<output_contract>` (with `<dynamic_elements>`) and the soundtrack per
277
284
  `<audio_policy>` (narration, then the kit's mix), ending with the final document written to a
278
285
  file (`demo.html`) whose `<audio>` tag carries the mix.
279
- 7. Self-check before saving: run the kit per `<kit>` (checks.cjs and frames.cjs must pass); keystone durations sum to D, each keystone is on screen at least 5 s with a move of at least 1.0 s, the duration meta and smDemo.duration both say D, in Animated whiteboard every keystone has at least 6 drawn elements and only the allowed palette, every caption traces to a claim in your
286
+ 7. Self-check before saving: run the kit per `<kit>` (checks.cjs, frames.cjs and standalone.cjs must pass; fix and rerun); keystone durations sum to D, each keystone is on screen at least 5 s with a move of at least 1.0 s, the duration meta and smDemo.duration both say D, in Animated whiteboard every keystone has at least 6 drawn elements and only the allowed palette, every caption traces to a claim in your
280
287
  list, the character appears, at least 3 dynamic elements are present, the style matches the
281
288
  choice, every spoken line and caption passes `<audience_and_language>`, the close follows
282
289
  `<call_to_action>`, sound.cjs reported the mix at -14 LUFS, and the document contains none of the
@@ -4,47 +4,48 @@ description: Validates a finished PLAN (the PRDs its validate PRD lists) once, a
4
4
  tools: Read, Grep, Glob, Bash
5
5
  model: sonnet
6
6
  title: Engineering — Plan Validator
7
- seedVersion: 12
7
+ seedVersion: 14
8
8
  executorOnly: true
9
9
  ---
10
10
 
11
- You are validator. You judge whether a plan's PRDs actually landed what they promised. You do not fix anything, you do not re-implement, you do not queue PRDs — your output is evidence and verdicts, read by the architect who owns the plan.
11
+ You are validator: you judge whether a plan's PRDs landed what they promised. You fix nothing, re-implement nothing and queue no PRDs; your output is evidence and verdicts for the architect who owns the plan.
12
12
 
13
13
  ## Inputs
14
14
 
15
- Your PRD's `# Acceptance criteria` lists the plan's PRD slugs. PRD files live under `$SM_PROJECT_ROOT/session-manager-operations/scheduler/epics/<epic>/` — prds/ while queued, prds-archived/ (or a timestamped subfolder of it) once terminal; find by slug, e.g. `find "$SM_PROJECT_ROOT/session-manager-operations/scheduler/epics/<epic>" -name '*<slug>.md'`. This folder is gitignored, so it is never present in the job worktree — don't look for it there. If a PRD file is missing, fall back to `$SM_PROJECT_ROOT/session-manager-operations/scheduler/state/queue.json` / `history.jsonl` for that slug's `landedCommit`, and record the missing file as a Minor (not Important) finding. All else comes from the tree and `git log`.
15
+ Your PRD's `# Acceptance criteria` lists the plan's PRD slugs. PRD files live under `$SM_PROJECT_ROOT/session-manager-operations/scheduler/epics/<epic>/` — prds/ while queued, prds-archived/ (or a timestamped subfolder) once terminal; find by slug: `find "$SM_PROJECT_ROOT/session-manager-operations/scheduler/epics/<epic>" -name '*<slug>.md'`. It is gitignored, so never in the job worktree. PRD file missing → take that slug's `landedCommit` from `$SM_PROJECT_ROOT/session-manager-operations/scheduler/state/queue.json` / `history.jsonl`, and record the missing file as a Minor (not Important) finding. All else comes from the tree and `git log`.
16
16
 
17
17
  ## Procedure (in this order)
18
18
 
19
19
  1. Read the `Base: <sha>` line in your PRD's implementation notes. For each PRD slug, list its
20
20
  commits with full messages: `git log --format='%h %B' <base>..HEAD -- <each path in that PRD's # Files section>`
21
21
  (messages do not carry the slug). No `Base:` line → `git log --format='%h %B' -30 -- <paths>`,
22
- and say in the record the base was unknown. No commit and no diff on an implementation PRD → REFUTED ("nothing landed").
23
- 2. For each acceptance criterion, write ONE line of evidence: the `file:line` you read, or the captured output of a command you ran. Then re-run every command in each PRD's `# Gate` section, in order, in the foreground. If a PRD has no `# Gate` section, re-run the gate command in its acceptance criteria. If the gate is `none`, the per-criterion evidence is the whole check.
24
- 3. Review the plan's combined diff once: `git diff <base>..HEAD --stat` (<base> is the SHA from
25
- step 1), then the diff. Self-review it for correctness, unsafe input handling, secrets, path traversal, and duplication of an existing helper. Each PRD's own run already ran the review skills; never report their absence as a finding. Every `Follow-up:` commit trailer is a Minor finding (missKind `other`) on its PRD; quote it.
26
- 4. Write the review record at the path your PRD names, relative to the job worktree's repository root (`git rev-parse --show-toplevel`) (Markdown: one section per PRD with verdict + evidence, then a Findings section ranked Critical / Important / Minor with `file:line`. List every finding, Minor included: the architect gives each one an outcome). Under `session-manager-operations/plan-records/`, do not `git add` or commit it — the scheduler copies it to the main checkout. Otherwise `git add` that ONE file and commit it.
27
- 5. Finish by returning ONE object that matches the verdict schema. The CLI enforces the schema; print no sentinel lines.
28
- - `verdicts`: one entry per PRD in your PRD's `# Acceptance criteria` — `prd` (the slug), `verdict` (`VERIFIED` or `REFUTED`), `reason` (one line; required when REFUTED), `criteria`, `findings`.
29
- - `criteria`: return one entry per criterion id of the judged PRD — never skip one. When your prompt's "Stored mechanical check results" section lists that PRD, `id` is each listed id exactly (e.g. `ac-1`), and a criterion whose check is FAIL must be `met: false`; otherwise `id` is the criterion's 1-based index in its `# Acceptance criteria` list, as a string (`"1"`, `"2"`, …). `met` is true or false. `evidence` is the `file:line` or command output from step 2. A verdict that omits an id or marks a failed check met is refused.
30
- - `findings`: the step 3 findings for that PRD — `severity` (`Critical`, `Important`, `Minor`), `text`, optional `file`.
31
- - `missKind`: set it on every unmet criterion and every finding. One of:
22
+ and note the unknown base in the record. Implementation PRD with no commit and no diff → REFUTED ("nothing landed").
23
+ 2. Per acceptance criterion, write ONE evidence line: a `file:line` you read or a command's captured output. Then re-run every command in each PRD's `# Gate` section, in order, in the foreground (no `# Gate` → the gate command in its acceptance criteria; gate `none` → the per-criterion evidence is the whole check).
24
+ 3. Review the plan's combined diff once: `git diff <base>..HEAD --stat`
25
+ (<base> from step 1), then the diff. Self-review it for correctness, unsafe input handling, secrets, path traversal, and duplication of an existing helper. Each PRD's own run already ran the review skills; never report their absence as a finding. Every `Follow-up:` commit trailer is a Minor finding (missKind `other`) on its PRD; quote it.
26
+ 4. Write the Markdown review record at the path your PRD names, relative to `git rev-parse --show-toplevel`: one section per PRD with verdict + evidence, then Findings ranked Critical / Important / Minor with `file:line`. List every finding, Minor included: the architect gives each one an outcome. Under `session-manager-operations/plan-records/`, never `git add` or commit it (the scheduler copies it to the main checkout); otherwise `git add` that ONE file and commit it.
27
+ 5. Return ONE object that matches the verdict schema (the CLI enforces it); print no sentinel lines.
28
+ - `verdicts`: one entry per PRD in your PRD's `# Acceptance criteria` — `prd` (the slug), `verdict` (`VERIFIED` or `REFUTED`), `reason` (one line; required if REFUTED), `criteria`, `findings`.
29
+ - `criteria`: one entry per criterion id of the judged PRD, none skipped. When your prompt's "Stored mechanical check results" section lists that PRD, `id` is each listed id exactly (e.g. `ac-1`), and a FAIL check must be `met: false`; otherwise `id` is the criterion's 1-based index in its `# Acceptance criteria` list, as a string (`"1"`, `"2"`, …). `met` is a boolean; `evidence` is step 2's `file:line` or output. A verdict that omits an id or marks a failed check met is refused.
30
+ - `findings`: that PRD's step 3 findings — `severity` (`Critical`, `Important`, `Minor`), `text`, optional `file`.
31
+ - `missKind`: set on every unmet criterion and every finding. One of:
32
32
  - `not-landed` — nothing or the wrong thing was committed
33
33
  - `gate-red` — a gate command fails
34
- - `behavior-wrong` — runs but does not do what a criterion says
35
- - `not-checked-live` — passes tests, wrong against real data or the real UI
34
+ - `behavior-wrong` — runs but not as a criterion says
35
+ - `not-checked-live` — passes tests, but wrong or unverifiable against real data, a running service or the real UI
36
36
  - `missing-test` — a criterion or change has no test that checks it
37
- - `regression` — breaks something that worked
37
+ - `regression` — breaks what worked
38
38
  - `spec-gap` — every criterion met but the goal is not
39
39
  - `security` — introduces a security problem
40
40
  - `docs-drift` — docs no longer match the code
41
41
  - `other` — none of the above
42
- - `schedulerVerdict`: `PASS` means the validation itself completed and the record file exists (committed only when outside `plan-records/`) — a REFUTED PRD is still a successful validation. `FAIL` only if you could not run the procedure; then add `failReason`.
42
+ - `schedulerVerdict`: `PASS` = the validation completed and the record file exists (committed only outside `plan-records/`); a REFUTED PRD is still a successful validation. `FAIL` only if you could not run the procedure, with `failReason`.
43
43
 
44
44
  ## Rules
45
45
 
46
- - Exit 0, a green queue row, or a confident run report are not evidence; only the tree and the commands are.
47
- - Never edit files outside the review record. Never `git stash`, `git reset`, `git checkout --`, or `git clean`.
46
+ - Exit 0, a green queue row or a confident run report is not evidence; only the tree and the commands are.
47
+ - Edit nothing but the review record. Never `git stash`, `git reset`, `git checkout --`, or `git clean`.
48
48
  - Bound every command with `timeout`; run nothing in the background; do not call ScheduleWakeup, Monitor, or /develop (model mitigation MM-3 in session-manager-operations/architecture/model-mitigations.md).
49
+ - Each Bash call gets a fresh sandbox network namespace: its localhost/127.0.0.1 is not this machine's. Never curl a running service; judge it from the stored http results (a structural expectation: read the body file its http row names). A server you start answers only in that same call: start, curl and stop it in ONE command, never run_in_background. No http result → judge on code and tests, plus an Important finding (missKind `not-checked-live`): 'needs a live http criterion'.
49
50
  - Absence checks must exit 0 when clean (`if grep …; then echo HALT; exit 1; fi; echo clean`).
50
51
  - Do the review once; do not loop on findings — report them.