Repository navigation
feat(plotwise): interactive learning-video mode on MiniMax H3 Max - #144
Merged
Merged
Conversation
A new builtin mode, **plotwise** (skill 0.4.0): custom-tailored, branching learning-video courses shot on MiniMax H3 Max via fal.ai. The learner names a topic, settles the visual style on a style board by confirming a 5-second sample, and then plays the course like a visual novel — continue along the spine, take the one detour offered, or ask a question — while a program shoots it ahead of them. **Preparation is where the agent's judgment goes; play is a program.** - `plan-course` (Claude Code workflow) lands a grounded outline first — each beat with code-rendered figures, citations and verification runs as `evidence[]` — and grounds beat by beat; other backends follow the same stages by hand. - `write-screenplay.mjs` writes the whole main line in one structured call: one scene per beat, 1–6 chained 5–15 s shots as long as the content needs, one detour brief per scene. - `play-manager.mjs` is a long-lived process that owns play: a planning queue (detour and question scripts) and a video queue (H3 slots), scheduling by distance from the learner, pruning and remote cancellation on choice, one narration re-shoot per shot, the shots concatenated into the scene, every state change under the course lock. The viewer writes choices to `state/choice.json`; no model runs on the click path; the director only answers questions and restarts the manager. - Every knowledge visual is a code-rendered reference figure (never a keyframe); the video model is trusted with delivery and atmosphere, never with facts. Narration is transcribed and checked word for word. ### Viewer Stage with a double-buffered single-soundtrack player, shot-synced captions, an interlude between scenes (last frame, a recap line, what comes next, shot progress), a rail that derives the learner's main line, the course map, an evidence panel, honest waiting states (phase, clock, stale, failed, manager heartbeat), and a style board plus preparing screen in one cinema frame. ### Shared scripts and runtime - `modes/_shared/scripts/fal-queue.mjs` — fal queue client with bounded retries and remote cancellation; `generate-video.mjs` moved onto it (loudness −16 LUFS, faststart, one audio format per clip, letterboxed references, idle-timed download). - Bun floor raised to 1.3.14 (Bun ≤ 1.3.13 deadlocks the server under file-watcher churn, oven-sh/bun#26762); `/content/*` Range responses served through Node read streams (Bun 1.4.0's sliced `Bun.file().stream()` returns the whole file); the file watcher ignores Python environments; the WebSocket client re-fetches the workspace on reconnect. ### Measured (three blind trials on Codex, 480P) - Opening scene ready 53–74 s after the manager starts; a 36–48 s scene lands 50–100 s after it is queued on three slots; choices land in 0.2–4 s; a learner's question becomes a finished scene in 71–146 s; first frame at T0+6:22 (sample 88 s, grounding ~2 min, screenplay ~1 min). - Content stayed correct and continuous across four main scenes, a detour and a question scene; figures reproduced legibly. - Every defect the trials found is fixed in this branch (manager daemonization, prune through the detour's return edge, numeric narration QA, mixed-sample-rate concat, reference aspect limits, question scheduling, the workspace snapshot shipping every clip as base64, stale clocks, false alarms). ### Follow-ups (not in this PR) - Core: the `/api/files` snapshot and `content_update` should never carry binary or multi-megabyte content (a mode with a wide `watchPatterns` reproduces the 1.2 GB snapshot); the mode-level fix is in. - 768P latency is unmeasured: fal's CDN delivered 6 KB/s from the test machine that night; the pipeline supports it (`resolution` init param). - Showcase images, hosted-player whitelist, npm pack size check at bump. ## Test plan - `bun run test` with an isolated `PNEUMA_HOME`: 4481 pass, 5 skip, 0 fail (six tests read the machine's `~/.pneuma/settings.json` locale otherwise). - `bun run typecheck` clean. - Manager scheduling pinned with fake dependencies (`modes/plotwise/__tests__/play-manager.test.ts`); concat pinned with real ffmpeg clips of mixed sample rates; `--detach` pinned as a spawned process. - Three end-to-end blind trials with a learner agent driving the browser (reports and screenshots kept outside the repo). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…sty, setup Codex reviewed PR #144 and found seventeen things; this is all of them except the showcase imagery, which /showcase generates separately. Paid work: - the manager shoots exactly `lookahead` scenes ahead: `distance <= videoAhead`, not `videoAhead + 1` (one whole step of scenes was shot that the learner might never reach); the same for planAhead; - fal-queue cancels the remote job before it reports a deadline or a poll it can no longer read, and a submit is retried only when the failure proves no job was created (an HTTP 5xx/429, or a connection that never opened) — fal has no idempotency key, so a request that left and lost its answer is reported, never sent twice. Play-loop correctness: - a job leaving a queue schedules a reconcile (debounced) instead of the job's own tail doing it: a retry of a scene being shot could not re-queue it, because the tail still saw its key as active; - a retry of a ready scene is a new take of every shot, and a single-shot scene's finalize no longer renames video.mp4 onto itself; - narration that cannot be transcribed fails the shot honestly after two attempts; the clip stays on disk as `unchecked` and a retry checks it first rather than pay for another render; - the figure budget is MAX_REFS less the continuity frame less the course's recurring characters: the manager fails a shot over it, naming the split, and the screenplay validator caps by the same number (`figureBudget`); - the viewer clears every requested scene that gained a clip, not only the one on stage, and sends `courseComplete` once when play.state turns complete so the director writes summary.md (SKILL: Finale). Setup and state: - the OpenRouter key is declared required — there is no fallback; - a failed style sample is shown on the catalog too, and it ends the wait the learner was in; - `course-edit evidence` replaces a beat's problems with this commit's instead of accumulating every problem ever reported; - plan-course lands the outline once more by hand when the agent did not, then stops rather than ground into a void; - the WebSocket client applies an empty workspace snapshot on reconnect. Debris: produce-segment.mjs and write-script.mjs are gone (the manager and the screenplay replaced them in 0.4.0), references and comments follow; the seed course drops the n2b branch that had no clip; showcase.json describes 0.4 (scenes, one sample on the board); the evolution directive and action copy speak of scenes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Owner
Author
Review follow-up (816cb33)All seventeen findings from the Codex review are applied in one commit; the PR is meant to be squash-merged. Paid work
Play-loop correctness
Setup and state
Debris
Not in this commit: showcase images (hero + highlights) — Tests: 4489 pass / 5 skip / 0 fail with an isolated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A new builtin mode, plotwise (skill 0.4.0): custom-tailored, branching learning-video courses shot on MiniMax H3 Max via fal.ai. The learner names a topic, settles the visual style on a style board by confirming a 5-second sample, and then plays the course like a visual novel — continue along the spine, take the one detour offered, or ask a question — while a program shoots it ahead of them.
Preparation is where the agent's judgment goes; play is a program.
plan-course(Claude Code workflow) lands a grounded outline first — each beat with code-rendered figures, citations and verification runs asevidence[]— and grounds beat by beat; other backends follow the same stages by hand.write-screenplay.mjswrites the whole main line in one structured call: one scene per beat, 1–6 chained 5–15 s shots as long as the content needs, one detour brief per scene.play-manager.mjsis a long-lived process that owns play: a planning queue (detour and question scripts) and a video queue (H3 slots), scheduling by distance from the learner, pruning and remote cancellation on choice, one narration re-shoot per shot, the shots concatenated into the scene, every state change under the course lock. The viewer writes choices tostate/choice.json; no model runs on the click path; the director only answers questions and restarts the manager.Viewer
Stage with a double-buffered single-soundtrack player, shot-synced captions, an interlude between scenes (last frame, a recap line, what comes next, shot progress), a rail that derives the learner's main line, the course map, an evidence panel, honest waiting states (phase, clock, stale, failed, manager heartbeat), and a style board plus preparing screen in one cinema frame.
Shared scripts and runtime
modes/_shared/scripts/fal-queue.mjs— fal queue client with bounded retries and remote cancellation;generate-video.mjsmoved onto it (loudness −16 LUFS, faststart, one audio format per clip, letterboxed references, idle-timed download)./content/*Range responses served through Node read streams (Bun 1.4.0's slicedBun.file().stream()returns the whole file); the file watcher ignores Python environments; the WebSocket client re-fetches the workspace on reconnect.Measured (three blind trials on Codex, 480P)
Follow-ups (not in this PR)
/api/filessnapshot andcontent_updateshould never carry binary or multi-megabyte content (a mode with a widewatchPatternsreproduces the 1.2 GB snapshot); the mode-level fix is in.resolutioninit param).Test plan
bun run testwith an isolatedPNEUMA_HOME: 4481 pass, 5 skip, 0 fail (six tests read the machine's~/.pneuma/settings.jsonlocale otherwise).bun run typecheckclean.modes/plotwise/__tests__/play-manager.test.ts); concat pinned with real ffmpeg clips of mixed sample rates;--detachpinned as a spawned process.🤖 Generated with Claude Code