Skip to content

feat(plotwise): interactive learning-video mode on MiniMax H3 Max - #144

Merged
pandazki merged 2 commits into
mainfrom
mode/interactive-learning
Sep 3, 2026
Merged

pandazki merged 2 commits into
mainfrom
mode/interactive-learning

Conversation

@pandazki

@pandazki pandazki commented Sep 3, 2026

Copy link
Copy Markdown
Owner

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 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

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).

🤖 Generated with Claude Code

pandazki and others added 2 commits September 3, 2026 11:14
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>
@pandazki

pandazki commented Sep 3, 2026

Copy link
Copy Markdown
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

  • The manager shoots exactly lookahead scenes ahead (distance <= videoAhead; one whole extra step was being shot before).
  • fal-queue.mjs cancels the remote job before it reports a deadline or a poll it can no longer read. A submit is retried only when the failure proves no job was created (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 and never sent twice — that is the ceiling of what the client can do.

Play-loop correctness

  • Reconcile is scheduled when a key leaves a queue, not from the job's own tail (which still saw its key as active): a scene retried while it was being shot is re-queued once the abort settles.
  • A retry of a ready scene is a new take of every shot; a single-shot scene no longer renames video.mp4 onto itself.
  • Narration that cannot be transcribed fails the shot after two attempts; the clip stays as unchecked and a retry checks it before paying again.
  • Figure budget = 4 − continuity frame − recurring characters, enforced at the shoot and capped by the screenplay validator (figureBudget).
  • The viewer clears every requested scene that gained a clip and sends courseComplete once, so the director writes summary.md.

Setup and state

  • OpenRouter key declared required (no fallback exists); a failed style sample stays visible on the catalog; course-edit evidence replaces a beat's problems; plan-course lands the outline once more by hand, then stops; the WebSocket client applies an empty snapshot on reconnect.

Debris

  • produce-segment.mjs and write-script.mjs deleted with their mentions; the seed drops the clip-less n2b branch; showcase.json now describes 0.4.

Not in this commit: showcase images (hero + highlights) — /showcase generates them separately.

Tests: 4489 pass / 5 skip / 0 fail with an isolated PNEUMA_HOME; typecheck clean; the style-board notice verified in a browser on a --viewing fixture.

@pandazki
pandazki merged commit 48015f6 into main Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant