Narrative Agent Split Implementation Log
Created: 2026-05-29 07:32 UTC
Date/time started: 2026-05-29 09:10 UTC
Date/time completed: 2026-05-29 12:35 UTC
Status
Implementation completed. Code, docs, and targeted verification were updated for the split between preview-only narrative generation and post-approval scene-detail expansion.
Delivery Flow
flowchart TD
contracts["Split contracts and agent definitions"] --> preview["Preview workflow emits VoiceoverScriptJson"]
preview --> review["narrative-review persists approvedScript only"]
review --> expand["Expansion workflow emits NarrativeSceneDetails"]
expand --> downstream["Visuals, slides, direction, compile consume expanded scenes"]
downstream --> verify["Typecheck and targeted tests"]
verify --> docs["Core/state docs and implementation log updated"]
Completed Tasks
- Added explicit preview and expansion narrative contracts, with compatibility helpers for legacy
narrativeScenes - Split the narrative agent into preview-generation and scene-expansion actions
- Refactored the narrative subworkflow into preview generation plus post-approval expansion
- Reworked the master presentation workflow around a preview-only
narrative-reviewsuspend boundary - Added deterministic skip gating for
IntentAgentandKnowledgeOrchestrator - Narrowed persisted review state and resume payloads to approved-script review semantics
- Retargeted visuals, slides, direction, compiler, and scene persistence to expanded-scene ownership
- Updated action-layer parsing and preview/resume UI flow to use
approvedScript - Updated core and state docs to match the new workflow
- Ran targeted verification and recorded remaining risks
Files Changed
src/lib/anuva/contracts-v1.tssrc/lib/anuva/voiceover-script.tssrc/lib/anuva/orchestration-service.tssrc/mastra/schemas/scene.schema.tssrc/mastra/agents/presentationvideo-agent-contracts.tssrc/mastra/agents/narrative.agent.tssrc/mastra/runtime.tssrc/mastra/workflows/sub/narrative.workflow.tssrc/mastra/workflows/sub/rag.workflow.tssrc/mastra/workflows/sub/visuals.workflow.tssrc/mastra/workflows/sub/slides.workflow.tssrc/mastra/workflows/sub/direction.workflow.tssrc/mastra/workflows/presentationvideo.workflow.tssrc/mastra/tools/compiler/index.tssrc/mastra/tools/presentation/index.tssrc/app/(frontend)/app/presentation/actions.tssrc/components/anuvax/presentation-video/presentation-video-page.tsxtests/unit/anuva-contracts.test.tstests/integration/helpers/mock-runtime.tstests/integration/presentation-compile.integration.test.tsdocs/core/PresentationVideoWorkflow.mddocs/state/WorkflowMap.mddocs/state/ServerActionsMap.mddocs/changes/2026-05-29-0732-narrative-agent-split/ImplementationPlan.mddocs/changes/2026-05-29-0732-narrative-agent-split/ImplementationLog.md
Code Changes
VoiceoverScriptJsonremains the preview and approved-script contract- Added
NarrativeSceneDetailsas the post-approval semantic-expansion contract presentationVideoAgentDefinitionsnow exposesnarrativePreviewandnarrativeExpansionnarrative.workflow.tsnow separates preview generation from expansion and forces approved preview text to remain the hard input during expansionpresentationvideo.workflow.tsnow:- derives
skipIntentAgentfrom explicit normalized input - derives
skipKnowledgePlanningfrom uploaded-only sources - suspends at
narrative-reviewwithvoiceoverPreviewandapprovedScript - resumes into expansion using approval plus identity inputs only
visualsWorkflownow ownsrecommendedVisualTypeandvisualGenerationPrompt- Slide and direction flows now consume expanded narrative scene details instead of mixed preview/semantic narrative output
- Workflow-scene persistence now stores narrative-owned semantic fields from expansion and visual-owned fields from visuals
Docs Changes
- Updated
docs/core/PresentationVideoWorkflow.mdto document the preview-first, expansion-after-approval architecture - Updated
docs/state/WorkflowMap.mdto reflect the new workflow boundaries and skip gates - Updated
docs/state/ServerActionsMap.mdto reflectapprovedScriptpreview responses and narrowed resume input - Reviewed
docs/state/KnownGaps.md; no new shared-system gap required documentation for this change
Verification
Commands run:
pnpm typecheck— passedpnpm exec vitest run --config ./vitest.config.mts tests/integration/presentation-compile.integration.test.ts tests/unit/anuva-contracts.test.ts— passedpnpm exec biome check 'src/app/(frontend)/app/presentation/actions.ts' 'src/mastra/workflows/sub/rag.workflow.ts' 'src/mastra/workflows/presentationvideo.workflow.ts' 'src/mastra/workflows/sub/narrative.workflow.ts' 'docs/changes/2026-05-29-0732-narrative-agent-split/ImplementationPlan.md' 'docs/changes/2026-05-29-0732-narrative-agent-split/ImplementationLog.md'— passed after formatting/import cleanuppnpm lint— failed on pre-existing repo-wide issues in untouched files includingdocs/web/stylesheets.css,docs/_stale/archive/globals.css, andsrc/payload-types.ts
Verification focus:
- Preview responses now suspend with
approvedScriptrather than semanticnarrativeScenes - Resume path no longer accepts edited preview scenes
- Expansion preserves approved preview text while adding
caption,sceneQuery, andvoScriptSection - Visual ownership moved to
visualsWorkflowforrecommendedVisualTypeandvisualGenerationPrompt - Downstream compile paths still pass targeted integration coverage
Deviations From Plan
docs/state/KnownGaps.mdwas reviewed but not edited because the change did not introduce a new persistent architectural gap beyond the scoped remaining risks captured herenarrativeSceneListSchemawas retained as a compatibility alias to reduce churn while converting downstream consumers incrementally
Remaining Risks
- Legacy suspended runs that persisted unusually malformed
narrativeScenesmay still fail compatibility conversion if required preview fields are missing or invalid - Skip gating is deterministic but currently tied to normalized request/source shape; if future callers send ambiguous partial input, they may still invoke
IntentAgentor knowledge planning more often than desired - Visual ownership is cleaner now, but prompt quality across preview and expansion should still be watched for semantic drift in real user runs
- Full-repo lint remains noisy because of unrelated existing issues outside the touched surface, so
pnpm lintis not yet a clean release gate for this change in isolation