You are already running inside the megaplan harness for this step. Do the requested planning/review/execution work directly. Do NOT invoke the megaplan CLI, do NOT read or activate the megaplan skill, do NOT start nested megaplan plans, and do NOT recurse into another planning harness. Treat mentions of megaplan in the repository or environment as implementation context only.
WRITE ACCESS CONTRACT: You are running with auto-approved writes inside a writable workspace. Treat the working directory as fully writable. Do NOT preemptively skip or block tasks on permission, sandbox, or read-only grounds. Attempt every required edit; only report failure AFTER a real OS-level rejection from a specific shell command. Do not infer 'read-only' from absence of activity; absence is not denial. If a single shell command unexpectedly fails, retry with a different invocation before concluding the environment is restricted.
You are creating an implementation plan for the following idea.
code
Idea:
Implement a clean asset-slots contract for AI-generated Sequence Creator components. Replace loose imageAssetKeys/videoAssetKeys for new generated sequence components with explicit ASSET_SLOTS metadata and slot-based params. Number allowed assets in prompts; save assetSlots/default bindings with resources; materialize slot key bindings to URLs; add Sequence Creator slot pickers for generated/library components; make library preview and Insert/Replace use current slot assignments; validate media type/cardinality/missing assets; update edge templates/validators/frontend parsing/types/materialization/preview/save/load/tests. No MP4 preview caching. Backwards compatibility is not important.
code
Assistant
{"plan":"I’ll inspect the relevant Sequence Creator, edge template, type, and test files first, then turn that into a concrete plan with questions and assumptions. I’ll avoid prior planning artifacts and stop once the implementation touch points are clear.","questions":[],"success_criteria":[],"assumptions":[]}
Assistant
{"plan":"The initial search found the core shape: generated sequence component prompts/validators are under supabase/functions/ai-generate-sequence-component, frontend materialization and metadata under src/tools/video-editor/sequences, and Sequence Creator UI/service/store under src/tools/video-editor/components/SequenceCreator plus state/sequenceCreatorStore.ts. I’m reading those files now to anchor the plan to actual insertion points.","questions":[],"success_criteria":[],"assumptions":[]}
Assistant
{"plan":"The UI already has two separate param editors: trusted JSON sequences use SequenceParamEditor, generated code uses ControlsManifestLayout or CodePathParamEditor, and previews currently patch imageAssetKeys/images directly. I’m checking dynamic registry/resource loading next so the plan covers save/load/materialization, not only the panel.","questions":[],"success_criteria":[],"assumptions":[]}
Assistant
User
Assistant
Project directory:
/Users/user_c042661f/Documents/reigh-workspace/reigh-app
No prior clarification artifact exists. Identify ambiguities, ask clarifying questions, and state your assumptions inside the plan output.
Requirements:
- If the engineering brief suggests an approach, use it as your starting hypothesis — but before committing, consider if there's a simpler or more fundamental fix. The brief is well-researched input, not a final answer.
- If the brief is absent, incomplete, or says "skip", inspect the repository yourself before planning.
- Stay focused on the requested idea. If repo exploration surfaces unrelated issues or docs, ignore them and return to the task.
- Prefer source code, tests, and directly relevant config files. Avoid `.megaplan/`, prior plan artifacts, and unrelated `docs/` or ops/deployment material unless the task explicitly depends on them.
- Stop exploring once you have enough evidence to name the concrete touch points and validation path. Do not keep browsing after you can write the plan.
- Produce a concrete implementation plan in markdown.
- Define observable success criteria as objects with `criterion` (string) and `priority` (`must`, `should`, or `info`):
- `must` — hard gate. The reviewer will block on failure. Use for correctness, functional requirements, and verifiable outcomes (e.g., "all existing tests pass", "API returns 200 for valid input"). Every `must` criterion must have a clear yes/no answer.
- `should` — quality target. The reviewer flags but does not block. Use for subjective goals, numeric guidelines, and best-effort improvements (e.g., "file under ~300 lines", "no deeply nested conditionals", "each function has a single responsibility").
- `info` — documented for humans, reviewer skips. Use for criteria that cannot be verified in this pipeline (e.g., "13 manual smoke tests pass", "stakeholder sign-off obtained").
- Each success criterion should include a `requires` field listing the capabilities needed for verification. Valid capability strings: `run_shell`, `read_files`, `run_tests`, `parse_diff`, `read_build_output`, `run_linter` (container), `drive_browser`, `inspect_runtime_ui`, `observe_runtime_logs`, `subjective_judgment`, `verify_physical_device` (human). `must` criteria MUST have non-empty `requires`. Example: `{"criterion": "All tests pass", "priority": "must", "requires": ["run_tests"]}`.
- Use the `questions` field for ambiguities that would materially change implementation.
- Use the `assumptions` field for defaults you are making so planning can proceed now.
- Prefer cheap validation steps early.
- Keep the plan proportional to the task. A 1-line fix needs a 2-step plan (apply fix + run tests), not a 5-step investigation.
- If user notes answer earlier questions, incorporate them into the draft plan instead of re-asking them.
- Fix the problem fully. Do not limit scope just to avoid breaking existing tests — update the tests too if needed.
- Prefer the simplest, most direct fix. No fallbacks, type conversions, or defensive wrappers without concrete evidence they are needed.
- If the task or issue hints suggest a specific approach, follow it. Only deviate with concrete counter-evidence.
Plan template — simple format (adapt to the actual repo and scope):
md
# Implementation Plan: [Title]
## Overview
Summarize the goal, current repository shape, and the constraints that matter.
## Main Phase
### Step 1: Audit the current behavior (`megaplan/prompts.py`)
**Scope:** Small
1. **Inspect** the current implementation and call out the exact insertion points (`megaplan/prompts.py:29`).
### Step 2: Add the first change (`megaplan/evaluation.py`)
**Scope:** Medium
1. **Implement** the smallest viable change with exact file references (`megaplan/evaluation.py:1`).
2. **Capture** any tricky behavior with a short example.
```python
issues = validate_plan_structure(plan_text)
```
### Step 3: Wire downstream behavior (`megaplan/handlers.py`, `megaplan/workers.py`)
**Scope:** Medium
1. **Update** the runtime flow in the touched files (`megaplan/handlers.py:400`, `megaplan/workers.py:199`).
### Step 4: Prove the change (`tests/test_evaluation.py`, `tests/test_megaplan.py`)
**Scope:** Small
1. **Run** the cheapest targeted checks first (`tests/test_evaluation.py:1`).
2. **Finish** with broader verification once the wiring is in place (`tests/test_megaplan.py:1`).
## Execution Order
1. Update prompts and mocks before enforcing stricter validation.
2. Land higher-risk wiring after the validator and tests are ready.
## Validation Order
1. Start with focused unit tests.
2. Run the broader suite after the flow changes are in place.
For complex plans, use multiple phases:
md
## Phase 1: Foundation — Dependencies, DB, Types
### Step 1: Install dependencies (`package.json`)
...
### Step 2: Create database migration (`supabase/migrations/`)
...
## Phase 2: Core Integration
### Step 3: Port the main component (`src/components/`)
...
Template guidance:
Simple plans: use ## Main Phase with ### Step N: sections underneath.
Complex plans: use multiple ## Phase N: sections, each containing ### Step N: steps. Step numbers are global (not per-phase).
The flat ## Step N: format (without phases) also works for backwards compatibility.
Key invariants: one H1 title, one ## Overview, numbered step sections (### Step N: or ## Step N:), and at least one ordering section.
{"plan":"# Implementation Plan: Asset Slots for AI-Generated Sequence Components\n\n## Overview\nThe current implementation lets AI-generated sequence components declare loose params.imageAssetKeys / params.videoAssetKeys, then the host conventionally materializes them to params.images / params.videos. That behavior appears in supabase/functions/ai-generate-sequence-component/templates.ts, supabase/functions/ai-generate-sequence-component/sequence-component-validation.ts, src/tools/video-editor/sequences/materialize.ts, src/tools/video-editor/components/SequenceCreator/CodePathPreview.tsx, src/tools/video-editor/components/SequenceCreator/CodePathParamEditor.tsx, and src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.tsx.\n\nThe cleaner fix is to make generated components self-describing with explicit slot metadata, persist that slot contract on sequence-component resources, and treat user choices as params.assetSlotBindings (or an equivalent single slot-binding param) rather than top-level loose image/video arrays. Existing built-in trusted sequences can keep descriptor-driven asset-list params unless the product wants to migrate them too. Backwards compatibility is explicitly not required, so new generated components and saved generated resources should use the slot contract only.\n\n## Phase 1: Define the Contract — Types, Shapes, and Naming\n\n### Step 1: Add shared asset-slot types (src/tools/video-editor/sequences/assetSlots.ts, src/features/resources/hooks/useResources.ts)\nScope: Medium\n1. Create a focused asset slot module with types and helpers for:\n - SequenceAssetSlot: { id, label, mediaType: 'image' | 'video', minItems?, maxItems?, required?, defaultAssetKeys? }.\n - SequenceAssetSlotBindings: Record<string, string[]> keyed by slot id.\n - normalizeAssetSlots, normalizeAssetSlotBindings, and validateAssetSlotBindings.\n2. PersistassetSlots?: unknown[] on SequenceComponentMetadata in src/features/resources/hooks/useResources.ts alongside controlsManifest.\n3. ExtendSequenceComponentResource flow in src/tools/video-editor/lib/sequence-component-catalog.ts only if needed by types; the current metadata spread likely carries the new field automatically.\n\n### Step 2: Choose the slot param name and URL materialization shape (src/tools/video-editor/sequences/assetSlots.ts)\nScope: Small\n1. Useparams.assetSlotBindings as the persisted key-binding object for generated components.\n2. Materialize to params.assetSlots as a runtime object shaped like Record<slotId, string[]>, where each array contains resolved URLs in binding order.\n3. ReserveassetSlots as host-injected URL data, not a user-authored schema field.\n4. Document this in code comments near the contract helpers because the name collision risk is high.\n\n## Phase 2: Edge Generation Contract and Validation\n\n### Step 3: Update prompts to require ASSET_SLOTS metadata (supabase/functions/ai-generate-sequence-component/templates.ts)\nScope: Medium\n1. Replace the current asset-key prompt block with a slot-based contract:\n - Metadata lines include // ASSET_SLOTS: [...] between DEFAULTS and CONTROLS.\n - Number allowed assets in the user prompt with media type and label, for example 1. [image] asset-a — Shot name.\n - Instruct the model to put default selected keys in DEFAULTS.assetSlotBindings, not imageAssetKeys or videoAssetKeys.\n - Instruct render code to read URLs from params.assetSlots.<slotId>.\n2. Keep URL arrays excluded from CONTROLS; slot pickers own them.\n3. Remove prompt guidance that asks for imageAssetKeys, videoAssetKeys, images, or videos for generated components.\n\n### Step 4: Parse and return assetSlots from generated code (supabase/functions/ai-generate-sequence-component/templates.ts, supabase/functions/ai-generate-sequence-component/index.ts)\nScope: Medium\n1. ExtendExtractedSequenceComponentMeta with assetSlots: unknown[].\n2. RequireASSET_SLOTS to parse as a JSON array. Allow [] when no media is needed or no allowed assets exist.\n3. IncludeassetSlots in the edge response shape and frontend service response type.\n4. Fail generation if ASSET_SLOTS is missing, since backwards compatibility is not required for new generated components.\n\n### Step 5: Validate slot metadata and bindings on the edge (supabase/functions/ai-generate-sequence-component/sequence-component-validation.ts, new edge helper if useful)\nScope: Medium\n1. Reject generated schema/defaults/code that declare or use loose imageAssetKeys, videoAssetKeys, images, or videos for generated components.\n2. Validate every slot has a stable JS-safe id, label, media type, sane cardinality, and no duplicate ids.\n3. ValidateDEFAULTS.assetSlotBindings references only declared slots and only allowed asset keys of the slot’s media type.\n4. Validate required slots and minItems / maxItems against defaults when allowed assets exist.\n5. Allow code references to params.assetSlots and params.assetSlotBindings without requiring both to be user-facing controls.\n\n## Phase 3: Frontend Service, Store, Save, and Load\n\n### Step 6: Add generated-component asset slots to frontend types (src/tools/video-editor/components/SequenceCreator/sequenceGenerationService.ts, src/tools/video-editor/state/sequenceCreatorStore.ts)\nScope: Medium\n1. ExtendSequenceComponentGenerationResponse, RunSequenceComponentGenerationResult, and GeneratedComponent with assetSlots?: unknown[].\n2. Normalize edge-returned slot metadata client-side before accepting the result.\n3. Keep current user-edited slot bindings inside generatedComponent.defaultsJson.assetSlotBindings so preview, save, load, Insert, and Replace read one source of truth.\n\n### Step 7: Save and load slot metadata with resources (src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.tsx, src/features/resources/hooks/useResources.ts)\nScope: Medium\n1. IncludeassetSlots in the resource metadata built by persistGeneratedComponent.\n2. When loading or previewing a library resource, populate generatedComponent.assetSlots from the resource.\n3. When reusing an existing library component for Insert/Replace, use the current in-panel defaultsJson.assetSlotBindings, not the original resource defaults, so library slot picker changes apply.\n4. Do not add MP4 preview cache fields or flows.\n\n## Phase 4: Materialization and Runtime Preview\n\n### Step 8: Replace convention-based generated-component materialization (src/tools/video-editor/sequences/materialize.ts)\nScope: Medium\n1. Add slot-based materialization that resolves params.assetSlotBindings from registry keys to params.assetSlots URL arrays.\n2. Validate missing registry entries and wrong media type when registry metadata is available.\n3. Preserve descriptor-driven materialization for trusted built-in sequence params like image-jump.imageAssetKeys -> images unless explicitly migrated later.\n4. Remove generic convention materialization for loose imageAssetKeys / videoAssetKeys on custom generated components.\n\n### Step 9: Update code-path preview to use slots (src/tools/video-editor/components/SequenceCreator/CodePathPreview.tsx)\nScope: Medium\n1. AcceptassetSlots and current assetSlotBindings in preview props.\n2. Resolve bindings against allowedAssets into runtime params.assetSlots.\n3. Stop injecting imageAssetKeys, assetKeys, assetUrls, or images fallback for generated components.\n4. Use the first bound image/video only for clip.asset compatibility when the generated component relies on clip.asset; otherwise keep media access through params.assetSlots.\n\n## Phase 5: Slot Picker UI and Validation\n\n### Step 10: Build a reusable slot picker (src/tools/video-editor/components/SequenceCreator/AssetSlotPicker.tsx)\nScope: Medium\n1. Render one section per declared slot with media-type filtered candidates from allowedAssets.\n2. Support cardinality by slot: single-select when maxItems === 1, multi-select otherwise.\n3. Show missing required slots and over/under cardinality inline.\n4. Write changes to defaultsJson.assetSlotBindings through the existing generated component state update.\n\n### Step 11: Wire slot pickers into generated and library flows (src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.tsx)\nScope: Medium\n1. Render the slot picker above ControlsManifestLayout / CodePathParamEditor for generated components and loaded library components.\n2. Validate slot bindings before enabling Insert/Replace for generated/library components.\n3. Make library Preview use the current slot assignments, not raw resource defaults.\n4. Make Insert/Replace use current slot assignments for both freshly generated and loaded library components.\n\n### Step 12: Keep trusted JSON sequence editing stable (src/tools/video-editor/components/PropertiesPanel/SequenceParamEditor.tsx)\nScope: Small\n1. Leave built-in trusted asset-list params functional for existing trusted sequence drafts.\n2. Optionally improve SequenceParamEditor asset-list editing to use the same picker component only if it can be done without broadening the slot contract to built-ins.\n\n## Phase 6: Tests and Verification\n\n### Step 13: Add edge tests (supabase/functions/ai-generate-sequence-component/sequence-component-validation.test.ts, template extraction tests if present)\nScope: Medium\n1. Assert valid ASSET_SLOTS plus DEFAULTS.assetSlotBindings passes.\n2. Assert missing ASSET_SLOTS, duplicate slots, wrong media type, over max, under min, unknown slot id, and unknown asset key fail.\n3. Assert loose imageAssetKeys / videoAssetKeys / images / videos are rejected for generated components.\n\n### Step 14: Add frontend unit tests (src/tools/video-editor/sequences/materialize.test.ts, src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.test.tsx, src/tools/video-editor/components/SequenceCreator/CodePathPreview tests if practical)\nScope: Medium\n1. TestassetSlotBindings materializes to assetSlots URLs without mutating persisted params.\n2. Test unresolved or wrong-media bindings surface validation failures.\n3. Test Sequence Creator generated-component slot picker changes update preview and are used by Insert/Replace.\n4. Test loading a library component preserves assetSlots metadata and Insert/Replace uses edited bindings.\n5. Retire tests that expect generated components to use loose image/video asset key conventions.\n\n### Step 15: Run focused validation first, then broader checks\nScope: Small\n1. Run targeted frontend tests first:\n bash\n npx vitest run --config config/testing/vitest.config.ts src/tools/video-editor/sequences/materialize.test.ts src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.test.tsx\n \n2. Run Deno edge tests for the generated sequence component function:\n bash\n deno test supabase/functions/ai-generate-sequence-component/\n \n3. Run typecheck/build-level validation:\n bash\n npm run build\n \n4. Run lints if time permits after targeted behavior is green:\n bash\n npm run lint\n npm run lint:edge\n \n\n## Execution Order\n1. Define the shared slot contract and metadata types before changing prompts or UI.\n2. Update edge prompts/parsing/validation next so new generations produce the right shape.\n3. Wire frontend service/store/save/load after the response shape is stable.\n4. Add materialization and preview support before enabling UI slot pickers.\n5. Add validation gates before enabling Insert/Replace with generated or library components.\n6. Update tests alongside each layer, with old [REDACTED] assertions removed rather than preserved.\n\n## Validation Order\n1. Start with pure helper tests for slot normalization and materialization.\n2. Run edge validator tests once ASSET_SLOTS parsing is implemented.\n3. Run Sequence Creator panel tests for preview, library load, Insert, and Replace behavior.\n4. Finish with npm run build, then lint commands if the implementation touches broad type surfaces.","questions":["Should built-in trusted sequence types such as image-jump and resource-card also migrate from descriptor asset-list params to the new ASSET_SLOTS contract, or should slots apply only to AI-generated DB-stored sequence components?","What exact runtime shape should generated components read: params.assetSlots.hero[0], params.assetSlots.hero.urls[0], or a different object that includes key plus URL metadata?","Should slot bindings allow the same asset key to be selected multiple times for one slot, or should duplicates be rejected at validation time?","Should minItems be enforced when no allowed assets are available, or only when the user has selected/attached/uploaded assets?","Are video slots expected to preview with raw video URLs in Remotion Player only, with no MP4 preview caching and no generated thumbnails?"] ,"success_criteria":[{"criterion":"New AI-generated sequence component responses include parsed assetSlots metadata and no longer rely on loose imageAssetKeys or videoAssetKeys for generated components.","priority":"must","requires":["read_files","run_tests"]},{"criterion":"Edge validation rejects missing/invalid ASSET_SLOTS, invalid default slot bindings, wrong media types, missing required slots, cardinality violations, unknown asset keys, and generated-component use of loose image/video key conventions.","priority":"must","requires":["run_tests","read_build_output"]},{"criterion":"Sequence component resources persist and reload assetSlots metadata, and library Preview/Load/Insert/Replace use the current slot bindings rather than original resource defaults.","priority":"must","requires":["run_tests","read_files"]},{"criterion":"Materialization resolves params.assetSlotBindings registry keys to runtime params.assetSlots URL arrays without mutating persisted params.","priority":"must","requires":["run_tests","parse_diff"]},{"criterion":"Sequence Creator exposes media-type-filtered slot pickers for generated and library components and blocks Insert/Replace when required slots are missing or cardinality/media-type validation fails.","priority":"must","requires":["run_tests","inspect_runtime_ui"]},{"criterion":"No MP4 preview caching fields, jobs, resource metadata, or preview cache code paths are introduced.","priority":"must","requires":["read_files","parse_diff"]},{"criterion":"Existing trusted built-in sequence asset-list behavior remains covered unless the implementation explicitly migrates those components too.","priority":"must","requires":["run_tests","parse_diff"]},{"criterion":"Targeted Sequence Creator, materialization, and edge validator tests pass.","priority":"must","requires":["run_tests"]},{"criterion":"The TypeScript build passes after the contract change.","priority":"must","requires":["run_shell","read_build_output"]},{"criterion":"Slot contract helpers stay small and centralized rather than scattering ad hoc slot parsing across the panel, preview, and materializer.","priority":"should","requires":["read_files","subjective_judgment"]},{"criterion":"The slot picker UI uses existing app controls and visual patterns, with clear inline validation and no nested card-heavy redesign.","priority":"should","requires":["inspect_runtime_ui","subjective_judgment"]},{"criterion":"Full manual smoke test covers generating a custom image component, changing slots, previewing, saving, loading from library, inserting, replacing, and rendering timeline preview.","priority":"info","requires":["inspect_runtime_ui"]}],"assumptions":["Backwards compatibility is not required for newly generated or saved generated sequence components; old generated resources may stop editing cleanly unless manually regenerated.","The slot contract applies first to AI-generated DB-stored sequence components; trusted built-in sequence descriptors can remain on their existing asset-list params unless clarified otherwise.","params.assetSlotBindings will be the persisted key-binding param and params.assetSlots will be host-injected resolved URL arrays at preview/render time.","The resources table stores flexible JSON metadata, so adding assetSlots to SequenceComponentMetadata should not require a database migration.","Allowed asset payloads already include enough media type information to validate image versus video slot bindings on both edge and frontend.","No MP4 preview caching means previews should use existing URLs directly in the browser/Remotion Player and should not introduce cache generation, cache keys, or resource preview artifacts."]}
You are already running inside the megaplan harness for this step. Do the requested planning/review/execution work directly. Do NOT invoke the megaplan CLI, do NOT read or activate the megaplan skill, do NOT start nested megaplan plans, and do NOT recurse into another planning harness. Treat mentions of megaplan in the repository or environment as implementation context only.
WRITE ACCESS CONTRACT: You are running with auto-approved writes inside a writable workspace. Treat the working directory as fully writable. Do NOT preemptively skip or block tasks on permission, sandbox, or read-only grounds. Attempt every required edit; only report failure AFTER a real OS-level rejection from a specific shell command. Do not infer 'read-only' from absence of activity; absence is not denial. If a single shell command unexpectedly fails, retry with a different invocation before concluding the environment is restricted.
You are revising an implementation plan after critique and gate feedback.
Implement a clean asset-slots contract for AI-generated Sequence Creator components. Replace loose imageAssetKeys/videoAssetKeys for new generated sequence components with explicit ASSET_SLOTS metadata and slot-based params. Number allowed assets in prompts; save assetSlots/default bindings with resources; materialize slot key bindings to URLs; add Sequence Creator slot pickers for generated/library components; make library preview and Insert/Replace use current slot assignments; validate media type/cardinality/missing assets; update edge templates/validators/frontend parsing/types/materialization/preview/save/load/tests. No MP4 preview caching. Backwards compatibility is not important.
code
Current plan (markdown):
# Implementation Plan: Asset Slots for AI-Generated Sequence Components
Overview
The current implementation lets AI-generated sequence components declare loose params.imageAssetKeys / params.videoAssetKeys, then the host conventionally materializes them to params.images / params.videos. That behavior appears in supabase/functions/ai-generate-sequence-component/templates.ts, supabase/functions/ai-generate-sequence-component/sequence-component-validation.ts, src/tools/video-editor/sequences/materialize.ts, src/tools/video-editor/components/SequenceCreator/CodePathPreview.tsx, src/tools/video-editor/components/SequenceCreator/CodePathParamEditor.tsx, and src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.tsx.
The cleaner fix is to make generated components self-describing with explicit slot metadata, persist that slot contract on sequence-component resources, and treat user choices as params.assetSlotBindings (or an equivalent single slot-binding param) rather than top-level loose image/video arrays. Existing built-in trusted sequences can keep descriptor-driven asset-list params unless the product wants to migrate them too. Backwards compatibility is explicitly not required, so new generated components and saved generated resources should use the slot contract only.
Phase 1: Define the Contract — Types, Shapes, and Naming
SequenceAssetSlotBindings: Record<string, string[]> keyed by slot id.
normalizeAssetSlots, normalizeAssetSlotBindings, and validateAssetSlotBindings.
PersistassetSlots?: unknown[] on SequenceComponentMetadata in src/features/resources/hooks/useResources.ts alongside controlsManifest.
ExtendSequenceComponentResource flow in src/tools/video-editor/lib/sequence-component-catalog.ts only if needed by types; the current metadata spread likely carries the new field automatically.
Step 2: Choose the slot param name and URL materialization shape (src/tools/video-editor/sequences/assetSlots.ts)
Scope: Small
Useparams.assetSlotBindings as the persisted key-binding object for generated components.
Materialize to params.assetSlots as a runtime object shaped like Record<slotId, string[]>, where each array contains resolved URLs in binding order.
ReserveassetSlots as host-injected URL data, not a user-authored schema field.
Document this in code comments near the contract helpers because the name collision risk is high.
Phase 2: Edge Generation Contract and Validation
Step 3: Update prompts to require ASSET_SLOTS metadata (supabase/functions/ai-generate-sequence-component/templates.ts)
Scope: Medium
Replace the current asset-key prompt block with a slot-based contract:
Metadata lines include // ASSET_SLOTS: [...] between DEFAULTS and CONTROLS.
Number allowed assets in the user prompt with media type and label, for example 1. [image] asset-a — Shot name.
Instruct the model to put default selected keys in DEFAULTS.assetSlotBindings, not imageAssetKeys or videoAssetKeys.
Instruct render code to read URLs from params.assetSlots.<slotId>.
Keep URL arrays excluded from CONTROLS; slot pickers own them.
Remove prompt guidance that asks for imageAssetKeys, videoAssetKeys, images, or videos for generated components.
Step 4: Parse and return assetSlots from generated code (supabase/functions/ai-generate-sequence-component/templates.ts, supabase/functions/ai-generate-sequence-component/index.ts)
Scope: Medium
ExtendExtractedSequenceComponentMeta with assetSlots: unknown[].
RequireASSET_SLOTS to parse as a JSON array. Allow [] when no media is needed or no allowed assets exist.
IncludeassetSlots in the edge response shape and frontend service response type.
Fail generation if ASSET_SLOTS is missing, since backwards compatibility is not required for new generated components.
Step 5: Validate slot metadata and bindings on the edge (supabase/functions/ai-generate-sequence-component/sequence-component-validation.ts, new edge helper if useful)
Scope: Medium
Reject generated schema/defaults/code that declare or use loose imageAssetKeys, videoAssetKeys, images, or videos for generated components.
Validate every slot has a stable JS-safe id, label, media type, sane cardinality, and no duplicate ids.
ValidateDEFAULTS.assetSlotBindings references only declared slots and only allowed asset keys of the slot’s media type.
Validate required slots and minItems / maxItems against defaults when allowed assets exist.
Allow code references to params.assetSlots and params.assetSlotBindings without requiring both to be user-facing controls.
ExtendSequenceComponentGenerationResponse, RunSequenceComponentGenerationResult, and GeneratedComponent with assetSlots?: unknown[].
Normalize edge-returned slot metadata client-side before accepting the result.
Keep current user-edited slot bindings inside generatedComponent.defaultsJson.assetSlotBindings so preview, save, load, Insert, and Replace read one source of truth.
Step 7: Save and load slot metadata with resources (src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.tsx, src/features/resources/hooks/useResources.ts)
Scope: Medium
IncludeassetSlots in the resource metadata built by persistGeneratedComponent.
When loading or previewing a library resource, populate generatedComponent.assetSlots from the resource.
When reusing an existing library component for Insert/Replace, use the current in-panel defaultsJson.assetSlotBindings, not the original resource defaults, so library slot picker changes apply.
Add slot-based materialization that resolves params.assetSlotBindings from registry keys to params.assetSlots URL arrays.
Validate missing registry entries and wrong media type when registry metadata is available.
Preserve descriptor-driven materialization for trusted built-in sequence params like image-jump.imageAssetKeys -> images unless explicitly migrated later.
Remove generic convention materialization for loose imageAssetKeys / videoAssetKeys on custom generated components.
Step 9: Update code-path preview to use slots (src/tools/video-editor/components/SequenceCreator/CodePathPreview.tsx)
Scope: Medium
AcceptassetSlots and current assetSlotBindings in preview props.
Resolve bindings against allowedAssets into runtime params.assetSlots.
Stop injecting imageAssetKeys, assetKeys, assetUrls, or images fallback for generated components.
Use the first bound image/video only for clip.asset compatibility when the generated component relies on clip.asset; otherwise keep media access through params.assetSlots.
Phase 5: Slot Picker UI and Validation
Step 10: Build a reusable slot picker (src/tools/video-editor/components/SequenceCreator/AssetSlotPicker.tsx)
Scope: Medium
Render one section per declared slot with media-type filtered candidates from allowedAssets.
Support cardinality by slot: single-select when maxItems === 1, multi-select otherwise.
Show missing required slots and over/under cardinality inline.
Write changes to defaultsJson.assetSlotBindings through the existing generated component state update.
Step 11: Wire slot pickers into generated and library flows (src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.tsx)
Scope: Medium
Render the slot picker above ControlsManifestLayout / CodePathParamEditor for generated components and loaded library components.
Validate slot bindings before enabling Insert/Replace for generated/library components.
Make library Preview use the current slot assignments, not raw resource defaults.
Make Insert/Replace use current slot assignments for both freshly generated and loaded library components.
Optionally improve SequenceParamEditor asset-list editing to use the same picker component only if it can be done without broadening the slot contract to built-ins.
Assert valid ASSET_SLOTS plus DEFAULTS.assetSlotBindings passes.
Assert missing ASSET_SLOTS, duplicate slots, wrong media type, over max, under min, unknown slot id, and unknown asset key fail.
Assert loose imageAssetKeys / videoAssetKeys / images / videos are rejected for generated components.
Step 14: Add frontend unit tests (src/tools/video-editor/sequences/materialize.test.ts, src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.test.tsx, src/tools/video-editor/components/SequenceCreator/CodePathPreview tests if practical)
Scope: Medium
TestassetSlotBindings materializes to assetSlots URLs without mutating persisted params.
Test unresolved or wrong-media bindings surface validation failures.
Test Sequence Creator generated-component slot picker changes update preview and are used by Insert/Replace.
Test loading a library component preserves assetSlots metadata and Insert/Replace uses edited bindings.
Retire tests that expect generated components to use loose image/video asset key conventions.
Step 15: Run focused validation first, then broader checks
Scope: Small
Run targeted frontend tests first:
bash
npx vitest run --config config/testing/vitest.config.ts src/tools/video-editor/sequences/materialize.test.ts src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.test.tsx
Run Deno edge tests for the generated sequence component function:
bash
deno test supabase/functions/ai-generate-sequence-component/
Run typecheck/build-level validation:
bash
npm run build
Run lints if time permits after targeted behavior is green:
bash
npm run lint
npm run lint:edge
Execution Order
Define the shared slot contract and metadata types before changing prompts or UI.
Update edge prompts/parsing/validation next so new generations produce the right shape.
Wire frontend service/store/save/load after the response shape is stable.
Add materialization and preview support before enabling UI slot pickers.
Add validation gates before enabling Insert/Replace with generated or library components.
Update tests alongside each layer, with old [REDACTED] assertions removed rather than preserved.
Validation Order
Start with pure helper tests for slot normalization and materialization.
Run edge validator tests once ASSET_SLOTS parsing is implemented.
Run Sequence Creator panel tests for preview, library load, Insert, and Replace behavior.
Finish with npm run build, then lint commands if the implementation touches broad type surfaces.
code
Current plan metadata:
{
"version": 1,
"timestamp": "2026-05-05T22:53:57Z",
"hash": "sha256:53ff6e60fa93d05a2936bd0a3a821a1f8671803de3a4c07b14a4359af83de3a3",
"questions": [
"Should built-in trusted sequence types such as image-jump and resource-card also migrate from descriptor asset-list params to the new ASSET_SLOTS contract, or should slots apply only to AI-generated DB-stored sequence components?",
"What exact runtime shape should generated components read: params.assetSlots.hero[0], params.assetSlots.hero.urls[0], or a different object that includes key plus URL metadata?",
"Should slot bindings allow the same asset key to be selected multiple times for one slot, or should duplicates be rejected at validation time?",
"Should minItems be enforced when no allowed assets are available, or only when the user has selected/attached/uploaded assets?",
"Are video slots expected to preview with raw video URLs in Remotion Player only, with no MP4 preview caching and no generated thumbnails?"
],
"success_criteria": [
{
"criterion": "New AI-generated sequence component responses include parsed assetSlots metadata and no longer rely on loose imageAssetKeys or videoAssetKeys for generated components.",
"priority": "must",
"requires": [
"read_files",
"run_tests"
]
},
{
"criterion": "Edge validation rejects missing/invalid ASSET_SLOTS, invalid default slot bindings, wrong media types, missing required slots, cardinality violations, unknown asset keys, and generated-component use of loose image/video key conventions.",
"priority": "must",
"requires": [
"run_tests",
"read_build_output"
]
},
{
"criterion": "Sequence component resources persist and reload assetSlots metadata, and library Preview/Load/Insert/Replace use the current slot bindings rather than original resource defaults.",
"priority": "must",
"requires": [
"run_tests",
"read_files"
]
},
{
"criterion": "Materialization resolves params.assetSlotBindings registry keys to runtime params.assetSlots URL arrays without mutating persisted params.",
"priority": "must",
"requires": [
"run_tests",
"parse_diff"
]
},
{
"criterion": "Sequence Creator exposes media-type-filtered slot pickers for generated and library components and blocks Insert/Replace when required slots are missing or cardinality/media-type validation fails.",
"priority": "must",
"requires": [
"run_tests",
"inspect_runtime_ui"
]
},
{
"criterion": "No MP4 preview caching fields, jobs, resource metadata, or preview cache code paths are introduced.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": "Existing trusted built-in sequence asset-list behavior remains covered unless the implementation explicitly migrates those components too.",
"priority": "must",
"requires": [
"run_tests",
"parse_diff"
]
},
{
"criterion": "Targeted Sequence Creator, materialization, and edge validator tests pass.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "The TypeScript build passes after the contract change.",
"priority": "must",
"requires": [
"run_shell",
"read_build_output"
]
},
{
"criterion": "Slot contract helpers stay small and centralized rather than scattering ad hoc slot parsing across the panel, preview, and materializer.",
"priority": "should",
"requires": [
"read_files",
"subjective_judgment"
]
},
{
"criterion": "The slot picker UI uses existing app controls and visual patterns, with clear inline validation and no nested card-heavy redesign.",
"priority": "should",
"requires": [
"inspect_runtime_ui",
"subjective_judgment"
]
},
{
"criterion": "Full manual smoke test covers generating a custom image component, changing slots, previewing, saving, loading from library, inserting, replacing, and rendering timeline preview.",
"priority": "info",
"requires": [
"inspect_runtime_ui"
]
}
],
"assumptions": [
"Backwards compatibility is not required for newly generated or saved generated sequence components; old generated resources may stop editing cleanly unless manually regenerated.",
"The slot contract applies first to AI-generated DB-stored sequence components; trusted built-in sequence descriptors can remain on their existing params unless clarified otherwise.",
" will be the persisted key-binding param and will be host-injected resolved URL arrays at preview/render time.",
"The resources table stores flexible JSON metadata, so adding to should not require a database migration.",
"Allowed asset payloads already include enough media type information to validate image versus video slot bindings on both edge and frontend.",
"No MP4 preview caching means previews should use existing URLs directly in the browser/Remotion Player and should not introduce cache generation, cache keys, or resource preview artifacts."
],
"structure_warnings": []
}
code
Gate summary:
{
"passed": false,
"criteria_check": {
"count": 12,
"items": [
{
"criterion": "New AI-generated sequence component responses include parsed assetSlots metadata and no longer rely on loose imageAssetKeys or videoAssetKeys for generated components.",
"priority": "must",
"requires": [
"read_files",
"run_tests"
]
},
{
"criterion": "Edge validation rejects missing/invalid ASSET_SLOTS, invalid default slot bindings, wrong media types, missing required slots, cardinality violations, unknown asset keys, and generated-component use of loose image/video key conventions.",
"priority": "must",
"requires": [
"run_tests",
"read_build_output"
]
},
{
"criterion": "Sequence component resources persist and reload assetSlots metadata, and library Preview/Load/Insert/Replace use the current slot bindings rather than original resource defaults.",
"priority": "must",
"requires": [
"run_tests",
"read_files"
]
},
{
"criterion": "Materialization resolves params.assetSlotBindings registry keys to runtime params.assetSlots URL arrays without mutating persisted params.",
"priority": "must",
"requires": [
"run_tests",
"parse_diff"
]
},
{
"criterion": "Sequence Creator exposes media-type-filtered slot pickers for generated and library components and blocks Insert/Replace when required slots are missing or cardinality/media-type validation fails.",
"priority": "must",
"requires": [
"run_tests",
"inspect_runtime_ui"
]
},
{
"criterion": "No MP4 preview caching fields, jobs, resource metadata, or preview cache code paths are introduced.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": "Existing trusted built-in sequence asset-list behavior remains covered unless the implementation explicitly migrates those components too.",
"priority": "must",
"requires": [
"run_tests",
"parse_diff"
]
},
{
"criterion": "Targeted Sequence Creator, materialization, and edge validator tests pass.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "The TypeScript build passes after the contract change.",
"priority": "must",
"requires": [
"run_shell",
"read_build_output"
]
},
{
"criterion": "Slot contract helpers stay small and centralized rather than scattering ad hoc slot parsing across the panel, preview, and materializer.",
"priority": "should",
"requires": [
"read_files",
"subjective_judgment"
]
},
{
"criterion": "The slot picker UI uses existing app controls and visual patterns, with clear inline validation and no nested card-heavy redesign.",
"priority": "should",
"requires": [
"inspect_runtime_ui",
"subjective_judgment"
]
},
{
"criterion": "Full manual smoke test covers generating a custom image component, changing slots, previewing, saving, loading from library, inserting, replacing, and rendering timeline preview.",
"priority": "info",
"requires": [
"inspect_runtime_ui"
]
}
]
},
"preflight_results": {
"project_dir_exists": true,
"project_dir_writable": true,
"success_criteria_present": true,
"claude_available": true,
"codex_available": true
},
"unresolved_flags": [
{
"id": "FLAG-001",
"concern": "Asset slot validator contract: is host-injected runtime data, but the existing generated-code validator requires every reference to be declared in SCHEMA and DEFAULTS; the plan does not explicitly update that validator rule.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": " in iterates collected params references and calls and . The plan tells generated render code to read while reserving as host-injected URL data.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "FLAG-002",
"concern": "Controls manifest validators not explicitly in scope: both frontend and edge manifest validators must reserve /possibly , or generated code that reads slot URLs will fail controls cross-coverage.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": " and currently reserve only , , , and ; Step 5's concrete file list omits both controls-manifest validator files even though Step 3/5 require reads outside CONTROLS.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "FLAG-003",
"concern": "Runtime materialization lacks slot metadata at the current caller boundary: receives clip type, params, and registry only, but validating slot ids, cardinality, and media type for DB-stored generated components needs the saved schema.",
"category": "correctness",
"severity_hint": "uncertain",
"evidence": " exposes and . The plan says to persist slot metadata on resources and validate bindings in materialization, but does not state how resource metadata reaches these functions during timeline render.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "FLAG-004",
"concern": "Save-time smoke render is not slot-aware: generated components that assume required URLs may fail the existing smoke-render gate before they can be saved or inserted.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": " calls ; passes and does not materialize allowed assets or slot bindings.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "issue_hints",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked the current edge prompt and validator contract in , , and . The plan requires generated code to read while also reserving as host-injected runtime data, but it does not explicitly say to exempt from the schema/defaults coverage validator; today every reference must exist in both SCHEMA.properties and DEFAULTS, so following the plan literally can reject the new generated code shape.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": "Checked the current edge prompt and validator contract in , , and . The plan requires generated code to read while also reserving as host-injected runtime data, but it does not explicitly say to exempt from the schema/defaults coverage validator; today every reference must exist in both SCHEMA.properties and DEFAULTS, so following the plan literally can reject the new generated code shape.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "correctness-1",
"concern": "Are the proposed changes technically correct?: Checked and its caller in . The smoke render currently passes directly as with no allowed assets and no materialized URL params; if the new prompt tells components to render from , the save-on-insert smoke gate can fail or force generated code to defensively avoid required media, and the plan does not mention updating the smoke gate to materialize slot bindings.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "Checked and its caller in . The smoke render currently passes directly as with no allowed assets and no materialized URL params; if the new prompt tells components to render from , the save-on-insert smoke gate can fail or force generated code to defensively avoid required media, and the plan does not mention updating the smoke gate to materialize slot bindings.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "correctness-2",
"concern": "Are the proposed changes technically correct?: Checked frontend registry asset metadata in and . The materializer can validate slot media type only by inferring from registry MIME strings or from the Sequence Creator ; the plan says to validate wrong media type when registry metadata is available, but it should make the inference source explicit because does not have a normalized field.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "Checked frontend registry asset metadata in and . The materializer can validate slot media type only by inferring from registry MIME strings or from the Sequence Creator ; the plan says to validate wrong media type when registry metadata is available, but it should make the inference source explicit because does not have a normalized field.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "scope",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked and around allowed asset handling. The edge input currently derives a flat array and the prompt prints only JSON keys, so numbering allowed assets with media type and labels requires a broader edge input shape than the plan names; otherwise edge validation cannot reliably enforce slot media types or produce the requested numbered prompt list from .",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": "Checked and around allowed asset handling. The edge input currently derives a flat array and the prompt prints only JSON keys, so numbering allowed assets with media type and labels requires a broader edge input shape than the plan names; otherwise edge validation cannot reliably enforce slot media types or produce the requested numbered prompt list from .",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "all_locations",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked both copies of the controls-manifest validator: and . Both currently reserve only , , , and ; the plan talks about allowing / references, but its concrete Step 5 file list names and an optional new helper, not these manifest validators, so a generated component that reads would still fail CONTROLS cross-coverage unless those files are included.",
"category": "completeness",
"severity_hint": "likely-significant",
"evidence": "Checked both copies of the controls-manifest validator: and . Both currently reserve only , , , and ; the plan talks about allowing / references, but its concrete Step 5 file list names and an optional new helper, not these manifest validators, so a generated component that reads would still fail CONTROLS cross-coverage unless those files are included.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
},
{
"id": "callers",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked callers through and : they pass only , , and the resolved registry. If slot validation needs declared metadata from the DB resource, this caller contract does not currently supply it; the plan's Step 8 says to resolve but does not specify how the materializer will obtain the per-clip slot schema outside Sequence Creator preview.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "Checked callers through and : they pass only , , and the resolved registry. If slot validation needs declared metadata from the DB resource, this caller contract does not currently supply it; the plan's Step 8 says to resolve but does not specify how the materializer will obtain the per-clip slot schema outside Sequence Creator preview.",
"raised_in": "critique_v1.json",
"status": "open",
"severity": "significant",
"verified": false
}
],
"recommendation": "ITERATE",
"rationale": "The plan is directionally right but not execution-ready. There are 10 unresolved significant flags, several with concrete file-level evidence showing the current plan would fail validation or runtime paths if followed literally. The main gaps are not philosophical tradeoffs: they are missing implementation surfaces for generated-code params coverage, both controls-manifest validators, materialization caller contracts, save-time smoke rendering, and allowed asset metadata shape. These should be folded into the plan before execution.",
"signals_assessment": "Weighted score is 11.0 on iteration 1 with all significant flags still open and no resolved flags. Preflight is healthy: the project exists, is writable, and required tooling appears available. Because the critique is fresh rather than churned, and the issues are concrete plan-quality gaps rather than unresolvable constraints, the right next step is one revision pass rather than proceed, escalate, or tiebreak.",
"warnings": [
"Do not proceed until the plan explicitly updates so host-injected is exempt from SCHEMA/DEFAULTS user-param coverage while remains persisted defaults data.",
"Add both controls-manifest validators to the concrete scope: and .",
"Resolve the materialization caller contract before implementation: either pass declared through /clip config paths or move slot validation to a layer that has resource metadata.",
"Make save-time smoke render slot-aware by materializing default slot bindings from allowed assets before calling the headless render path.",
"Specify the allowed asset input shape on the edge so prompt numbering and media-type validation can use stable media type and label metadata, not only flat keys."
],
"settled_decisions": [
{
"id": "slot-runtime-shape",
"decision": "Persist as key arrays and inject as URL arrays at runtime.",
"rationale": "This matches the plan assumptions and avoids mixing persisted registry keys with host-resolved URLs."
},
{
"id": "builtin-sequence-scope",
"decision": "Keep trusted built-in descriptor-driven params working; apply first to AI-generated DB-stored sequence components.",
"rationale": "The plan and assumptions explicitly avoid migrating built-ins in this pass, reducing blast radius."
},
{
"id": "no-mp4-preview-cache",
"decision": "Do not add MP4 preview cache fields, jobs, or resource metadata.",
"rationale": "This is a hard success criterion and no critique requires violating it."
}
],
"override_forced": false,
"orchestrator_guidance": "First iteration; follow gate recommendation: ITERATE. Verify unresolved flags against the plan and project code before accepting.",
"robustness": "standard",
"signals": {
"iteration": 1,
"idea": "Implement a clean asset-slots contract for AI-generated Sequence Creator components. Replace loose imageAssetKeys/videoAssetKeys for new generated sequence components with explicit ASSET_SLOTS metadata and slot-based params. Number allowed assets in prompts; save assetSlots/default bindings with resources; materialize slot key bindings to URLs; add Sequence Creator slot pickers for generated/library components; make library preview and Insert/Replace use current slot assignments; validate media type/cardinality/missing assets; update edge templates/validators/frontend parsing/types/materialization/preview/save/load/tests. No MP4 preview caching. Backwards compatibility is not important.",
"significant_flags": 10,
"unresolved_flags": [
{
"id": "FLAG-001",
"concern": "Asset slot validator contract: is host-injected runtime data, but the existing generated-code validator requires every reference to be declared in SCHEMA and DEFAULTS; the plan does not explicitly update that validator rule.",
"category": "correctness",
"severity": "significant",
"status": "open"
},
{
"id": "FLAG-002",
"concern": "Controls manifest validators not explicitly in scope: both frontend and edge manifest validators must reserve /possibly , or generated code that reads slot URLs will fail controls cross-coverage.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "FLAG-003",
"concern": "Runtime materialization lacks slot metadata at the current caller boundary: receives clip type, params, and registry only, but validating slot ids, cardinality, and media type for DB-stored generated components needs the saved schema.",
"category": "correctness",
"severity": "significant",
"status": "open"
},
{
"id": "FLAG-004",
"concern": "Save-time smoke render is not slot-aware: generated components that assume required URLs may fail the existing smoke-render gate before they can be saved or inserted.",
"category": "correctness",
"severity": "significant",
"status": "open"
},
{
"id": "issue_hints",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked the current edge prompt and validator contract in , , and . The plan requires generated code to read while also reserving as host-injected runtime data, but it does not explicitly say to exempt from the schema/defaults coverage validator; today every reference must exist in both SCHEMA.properties and DEFAULTS, so following the plan literally can reject the new generated code shape.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "correctness-1",
"concern": "Are the proposed changes technically correct?: Checked and its caller in . The smoke render currently passes directly as with no allowed assets and no materialized URL params; if the new prompt tells components to render from , the save-on-insert smoke gate can fail or force generated code to defensively avoid required media, and the plan does not mention updating the smoke gate to materialize slot bindings.",
"category": "correctness",
"severity": "significant",
"status": "open"
},
{
"id": "correctness-2",
"concern": "Are the proposed changes technically correct?: Checked frontend registry asset metadata in and . The materializer can validate slot media type only by inferring from registry MIME strings or from the Sequence Creator ; the plan says to validate wrong media type when registry metadata is available, but it should make the inference source explicit because does not have a normalized field.",
"category": "correctness",
"severity": "significant",
"status": "open"
},
{
"id": "scope",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked and around allowed asset handling. The edge input currently derives a flat array and the prompt prints only JSON keys, so numbering allowed assets with media type and labels requires a broader edge input shape than the plan names; otherwise edge validation cannot reliably enforce slot media types or produce the requested numbered prompt list from .",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "all_locations",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked both copies of the controls-manifest validator: and . Both currently reserve only , , , and ; the plan talks about allowing / references, but its concrete Step 5 file list names and an optional new helper, not these manifest validators, so a generated component that reads would still fail CONTROLS cross-coverage unless those files are included.",
"category": "completeness",
"severity": "significant",
"status": "open"
},
{
"id": "callers",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked callers through and : they pass only , , and the resolved registry. If slot validation needs declared metadata from the DB resource, this caller contract does not currently supply it; the plan's Step 8 says to resolve but does not specify how the materializer will obtain the per-clip slot schema outside Sequence Creator preview.",
"category": "correctness",
"severity": "significant",
"status": "open"
}
],
"resolved_flags": [],
"weighted_score": 11.0,
"weighted_history": [],
"plan_delta_from_previous": null,
"recurring_critiques": [],
"scope_creep_flags": [],
"loop_summary": "Iteration 1. Weighted score trajectory: 11.0. Plan deltas: n/a. Recurring critiques: 0. Resolved flags: 0. Open significant flags: 10.",
"debt_overlaps": [],
"escalated_debt_subsystems": []
},
"flag_resolutions": [],
"resolved_flag_ids": [],
"resolution_summary": "",
"reprompted": false
}
code
Open significant flags:
[
{
"id": "FLAG-001",
"severity": "significant",
"status": "open",
"concern": "Asset slot validator contract: params.assetSlots is host-injected runtime data, but the existing generated-code validator requires every params.X reference to be declared in SCHEMA and DEFAULTS; the plan does not explicitly update that validator rule.",
"evidence": "validateSequenceComponentCode() in supabase/functions/ai-generate-sequence-component/sequence-component-validation.ts iterates collected params references and calls assertObjectHasKey(schemaProperties, paramName, ...) and assertObjectHasKey(defaults, paramName, ...). The plan tells generated render code to read params.assetSlots.<slotId> while reserving assetSlots as host-injected URL data."
},
{
"id": "FLAG-002",
"severity": "significant",
"status": "open",
"concern": "Controls manifest validators not explicitly in scope: both frontend and edge manifest validators must reserve assetSlots/possibly assetSlotBindings, or generated code that reads slot URLs will fail controls cross-coverage.",
"evidence": "controls-manifest-validation.ts and controlsManifest.ts currently reserve only imageAssetKeys, videoAssetKeys, images, and videos; Step 5's concrete file list omits both controls-manifest validator files even though Step 3/5 require params.assetSlots reads outside CONTROLS."
},
{
"id": "FLAG-003",
"severity": "significant",
"status": "open",
"concern": "Runtime materialization lacks slot metadata at the current caller boundary: materializeSequenceParams() receives clip type, params, and registry only, but validating slot ids, cardinality, and media type for DB-stored generated components needs the saved assetSlots schema.",
"evidence": "src/tools/video-editor/sequences/materialize.ts exposes materializeSequenceParams(clipType, params, registry) and materializeSequenceConfig(config). The plan says to persist slot metadata on resources and validate bindings in materialization, but does not state how resource metadata reaches these functions during timeline render."
},
{
"id": "FLAG-004",
"severity": "significant",
"status": "open",
"concern": "Save-time smoke render is not slot-aware: generated components that assume required params.assetSlots URLs may fail the existing smoke-render gate before they can be saved or inserted.",
"evidence": "persistGeneratedComponent() calls smokeRenderSequenceComponent({ code, schemaJson, defaultsJson, fps }); headlessRender.ts passes params = input.defaultsJson ?? {} and does not materialize allowed assets or slot bindings."
},
{
"id": "issue_hints",
"severity": "significant",
"status": "open",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked the current edge prompt and validator contract in , , and . The plan requires generated code to read while also reserving as host-injected runtime data, but it does not explicitly say to exempt from the schema/defaults coverage validator; today every reference must exist in both SCHEMA.properties and DEFAULTS, so following the plan literally can reject the new generated code shape.",
"evidence": "Checked the current edge prompt and validator contract in , , and . The plan requires generated code to read while also reserving as host-injected runtime data, but it does not explicitly say to exempt from the schema/defaults coverage validator; today every reference must exist in both SCHEMA.properties and DEFAULTS, so following the plan literally can reject the new generated code shape."
},
{
"id": "correctness-1",
"severity": "significant",
"status": "open",
"concern": "Are the proposed changes technically correct?: Checked and its caller in . The smoke render currently passes directly as with no allowed assets and no materialized URL params; if the new prompt tells components to render from , the save-on-insert smoke gate can fail or force generated code to defensively avoid required media, and the plan does not mention updating the smoke gate to materialize slot bindings.",
"evidence": "Checked and its caller in . The smoke render currently passes directly as with no allowed assets and no materialized URL params; if the new prompt tells components to render from , the save-on-insert smoke gate can fail or force generated code to defensively avoid required media, and the plan does not mention updating the smoke gate to materialize slot bindings."
},
{
"id": "correctness-2",
"severity": "significant",
"status": "open",
"concern": "Are the proposed changes technically correct?: Checked frontend registry asset metadata in and . The materializer can validate slot media type only by inferring from registry MIME strings or from the Sequence Creator ; the plan says to validate wrong media type when registry metadata is available, but it should make the inference source explicit because does not have a normalized field.",
"evidence": "Checked frontend registry asset metadata in and . The materializer can validate slot media type only by inferring from registry MIME strings or from the Sequence Creator ; the plan says to validate wrong media type when registry metadata is available, but it should make the inference source explicit because does not have a normalized field."
},
{
"id": "scope",
"severity": "significant",
"status": "open",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked and around allowed asset handling. The edge input currently derives a flat array and the prompt prints only JSON keys, so numbering allowed assets with media type and labels requires a broader edge input shape than the plan names; otherwise edge validation cannot reliably enforce slot media types or produce the requested numbered prompt list from .",
"evidence": "Checked and around allowed asset handling. The edge input currently derives a flat array and the prompt prints only JSON keys, so numbering allowed assets with media type and labels requires a broader edge input shape than the plan names; otherwise edge validation cannot reliably enforce slot media types or produce the requested numbered prompt list from ."
},
{
"id": "all_locations",
"severity": "significant",
"status": "open",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked both copies of the controls-manifest validator: and . Both currently reserve only , , , and ; the plan talks about allowing / references, but its concrete Step 5 file list names and an optional new helper, not these manifest validators, so a generated component that reads would still fail CONTROLS cross-coverage unless those files are included.",
"evidence": "Checked both copies of the controls-manifest validator: and . Both currently reserve only , , , and ; the plan talks about allowing / references, but its concrete Step 5 file list names and an optional new helper, not these manifest validators, so a generated component that reads would still fail CONTROLS cross-coverage unless those files are included."
},
{
"id": "callers",
"severity": "significant",
"status": "open",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked callers through and : they pass only , , and the resolved registry. If slot validation needs declared metadata from the DB resource, this caller contract does not currently supply it; the plan's Step 8 says to resolve but does not specify how the materializer will obtain the per-clip slot schema outside Sequence Creator preview.",
"evidence": "Checked callers through and : they pass only , , and the resolved registry. If slot validation needs declared metadata from the DB resource, this caller contract does not currently supply it; the plan's Step 8 says to resolve but does not specify how the materializer will obtain the per-clip slot schema outside Sequence Creator preview."
}
]
code
Requirements:
- Before addressing individual flags, check: does any flag suggest the plan is targeting the wrong code or the wrong root cause? If so, consider whether the plan needs a new approach rather than adjustments. Explain your reasoning.
- Update the plan to address the significant issues.
- Keep the plan readable and executable.
- Return flags_addressed with the exact flag IDs you addressed.
- Include `changes_summary` as a short plain-English summary of what changed in the revision. If there were no concrete flags, say that explicitly (for example: `No critique flags were raised; refined wording and kept the plan aligned for execution.`).
- Preserve or improve success criteria quality. Each criterion must have a `priority` of `must`, `should`, or `info`. Promote or demote priorities if critique feedback reveals a criterion was over- or under-weighted.
- Each success criterion should include a `requires` field listing the capabilities needed for verification. Valid capability strings: `run_shell`, `read_files`, `run_tests`, `parse_diff`, `read_build_output`, `run_linter` (container), `drive_browser`, `inspect_runtime_ui`, `observe_runtime_logs`, `subjective_judgment`, `verify_physical_device` (human). `must` criteria MUST have non-empty `requires`. Example: `{"criterion": "All tests pass", "priority": "must", "requires": ["run_tests"]}`.
- Verify that the plan remains aligned with the user's original intent, not just internal plan quality.
- Remove unjustified scope growth. If critique raised scope creep, narrow the plan back to the original idea unless the broader work is strictly required.
- Maintain the structural template: H1 title, ## Overview, phase sections with numbered step sections, ## Execution Order or ## Validation Order.
- CRITICAL: Your entire revised plan markdown (all sections) must be output as the `plan` field in the structured output. The prose response must not contain the plan text.
- CRITICAL: Return only the structured JSON object for the schema fields `plan`, `changes_summary`, `flags_addressed`, `assumptions`, `success_criteria`, and `questions`. Do not add commentary before or after the JSON object.
Plan template — simple format (adapt to the actual repo and scope):
md
# Implementation Plan: [Title]
## Overview
Summarize the goal, current repository shape, and the constraints that matter.
## Main Phase
### Step 1: Audit the current behavior (`megaplan/prompts.py`)
**Scope:** Small
1. **Inspect** the current implementation and call out the exact insertion points (`megaplan/prompts.py:29`).
### Step 2: Add the first change (`megaplan/evaluation.py`)
**Scope:** Medium
1. **Implement** the smallest viable change with exact file references (`megaplan/evaluation.py:1`).
2. **Capture** any tricky behavior with a short example.
```python
issues = validate_plan_structure(plan_text)
```
### Step 3: Wire downstream behavior (`megaplan/handlers.py`, `megaplan/workers.py`)
**Scope:** Medium
1. **Update** the runtime flow in the touched files (`megaplan/handlers.py:400`, `megaplan/workers.py:199`).
### Step 4: Prove the change (`tests/test_evaluation.py`, `tests/test_megaplan.py`)
**Scope:** Small
1. **Run** the cheapest targeted checks first (`tests/test_evaluation.py:1`).
2. **Finish** with broader verification once the wiring is in place (`tests/test_megaplan.py:1`).
## Execution Order
1. Update prompts and mocks before enforcing stricter validation.
2. Land higher-risk wiring after the validator and tests are ready.
## Validation Order
1. Start with focused unit tests.
2. Run the broader suite after the flow changes are in place.
For complex plans, use multiple phases:
md
## Phase 1: Foundation — Dependencies, DB, Types
### Step 1: Install dependencies (`package.json`)
...
### Step 2: Create database migration (`supabase/migrations/`)
...
## Phase 2: Core Integration
### Step 3: Port the main component (`src/components/`)
...
Template guidance:
Simple plans: use ## Main Phase with ### Step N: sections underneath.
Complex plans: use multiple ## Phase N: sections, each containing ### Step N: steps. Step numbers are global (not per-phase).
The flat ## Step N: format (without phases) also works for backwards compatibility.
Key invariants: one H1 title, one ## Overview, numbered step sections (### Step N: or ## Step N:), and at least one ordering section.
{
"plan": "# Implementation Plan: Asset Slots for AI-Generated Sequence Components\n\n## Overview\nThe root approach is still correct: the issue is not in timeline media assets generally, but in the generated Sequence Creator component contract. The critique shows the first plan was missing several boundary changes required by that contract: generated-code param coverage, both controls-manifest validators, runtime access to saved slot metadata, slot-aware smoke rendering, and a richer edge allowed-asset payload. This revision keeps the scope focused on AI-generated DB-stored sequence components and does not migrate trusted built-in sequence asset-list params.\n\nCurrent generated components use loose params.imageAssetKeys / params.videoAssetKeys, with frontend convention materialization to params.images / params.videos. The new contract is: persist params.assetSlotBindings as registry-key arrays, persist component-level assetSlots metadata on sequence-component resources, and inject runtime params.assetSlots as Record<slotId, string[]> URL arrays. assetSlots is host-injected and must be exempt from user-param coverage and controls-manifest coverage; assetSlotBindings is persisted defaults data and slot-picker owned, not a normal control.\n\n## Phase 1: Contract Foundation\n\n### Step 1: Add shared asset-slot helpers (src/tools/video-editor/sequences/assetSlots.ts, src/features/resources/hooks/useResources.ts)\nScope: Medium\n1. CreateassetSlots.ts with:\n - SequenceAssetSlot: { id, label, mediaType: 'image' | 'video', minItems?, maxItems?, required?, defaultAssetKeys? }.\n - SequenceAssetSlotBindings: Record<string, string[]>.\n - ResolvedSequenceAssetSlots: Record<string, string[]> URL arrays.\n - normalizeAssetSlots, normalizeAssetSlotBindings, validateAssetSlotBindings, materializeAssetSlotBindings, and inferRegistryAssetMediaType.\n2. Infer registry media type from ResolvedAssetRegistryEntry.type MIME-ish strings first, then URL/file extension only as a fallback. In Sequence Creator preview/UI, prefer AllowedSequenceAsset.mediaType, because that is already normalized.\n3. AddassetSlots?: unknown[] to SequenceComponentMetadata in src/features/resources/hooks/useResources.ts.\n4. Keep trusted built-in sequence descriptors unchanged; this module supports generated DB components first.\n\n### Step 2: Make the slot param contract explicit (src/tools/video-editor/sequences/assetSlots.ts)\nScope: Small\n1. Persist key choices in params.assetSlotBindings.\n2. Inject runtime URLs in params.assetSlots as Record<slotId, string[]>.\n3. Reserve both names from user controls: assetSlots is host-injected runtime data; assetSlotBindings is edited only by slot pickers.\n4. Reject generated-component use of loose imageAssetKeys, videoAssetKeys, images, and videos.\n\n## Phase 2: Edge Prompt, Parsing, and Validators\n\n### Step 3: Pass rich allowed assets to edge prompt/validation (supabase/functions/ai-generate-sequence-component/index.ts, supabase/functions/ai-generate-sequence-component/templates.ts)\nScope: Medium\n1. Normalizeallowed_assets on the edge into objects containing key, mediaType, label, and optional source context; keep allowedAssetKeys only as a derived convenience.\n2. Number allowed assets in prompts using the normalized objects, for example 1. [image] asset-a - Shot name.\n3. Pass normalized allowed assets into template construction and slot validation so media-type checks do not depend on a flat key list.\n\n### Step 4: Require ASSET_SLOTS metadata in generated code (supabase/functions/ai-generate-sequence-component/templates.ts)\nScope: Medium\n1. Update output requirements to include // ASSET_SLOTS: [...] between DEFAULTS and CONTROLS.\n2. Instruct the model to declare slots in ASSET_SLOTS, put default registry keys in DEFAULTS.assetSlotBindings, and render from params.assetSlots.<slotId>.\n3. Remove prompt guidance for generated components that asks for imageAssetKeys, videoAssetKeys, images, or videos.\n4. AllowASSET_SLOTS: [] for components that genuinely do not use media or when no allowed media is available.\n\n### Step 5: Parse and return slot metadata (supabase/functions/ai-generate-sequence-component/templates.ts, supabase/functions/ai-generate-sequence-component/index.ts, src/tools/video-editor/components/SequenceCreator/sequenceGenerationService.ts)\nScope: Medium\n1. Extend extraction metadata and edge response types with assetSlots.\n2. RequireASSET_SLOTS to parse as a JSON array for new generated components.\n3. ReturnassetSlots to the frontend and normalize it before accepting a successful code-path generation.\n\n### Step 6: Update generated-code and controls-manifest validators (supabase/functions/ai-generate-sequence-component/sequence-component-validation.ts, supabase/functions/ai-generate-sequence-component/controls-manifest-validation.ts, src/tools/video-editor/sequences/controlsManifest.ts)\nScope: Medium\n1. Exemptparams.assetSlots from SCHEMA/DEFAULTS coverage in validateSequenceComponentCode() because it is host-injected runtime data.\n2. Permitparams.assetSlotBindings in SCHEMA/DEFAULTS only as persisted binding data, while excluding it from CONTROLS cross-coverage.\n3. AddassetSlots and assetSlotBindings to reserved/managed params in both edge and frontend controls-manifest validators.\n4. Reject loose generated-component media params: imageAssetKeys, videoAssetKeys, images, and videos in schema/defaults/code for the code-path endpoint.\n5. Add slot validation on the edge: duplicate slot ids, invalid ids, invalid media type, invalid cardinality, unknown binding slot, unknown asset key, wrong media type, missing required slots, and min/max violations.\n\n## Phase 3: Frontend State, Save, Load, and Runtime Metadata\n\n### Step 7: Carry asset slots through generated-component state (src/tools/video-editor/components/SequenceCreator/sequenceGenerationService.ts, src/tools/video-editor/state/sequenceCreatorStore.ts)\nScope: Medium\n1. ExtendRunSequenceComponentGenerationResult and GeneratedComponent with normalized assetSlots.\n2. Keep edited bindings in generatedComponent.defaultsJson.assetSlotBindings as the single source of truth for preview, smoke render, save, Insert, and Replace.\n3. Clear stale generated component slot state when JSON-path drafts replace code-path state.\n\n### Step 8: Save and reload slot metadata with resources (src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.tsx, src/tools/video-editor/hooks/useSequenceResources.ts)\nScope: Medium\n1. IncludeassetSlots in the SequenceComponentMetadata saved by persistGeneratedComponent.\n2. When loading or previewing a library resource, populate generatedComponent.assetSlots from resource metadata.\n3. When reusing a library component for Insert/Replace, synthesize the draft from current generatedComponent.defaultsJson, not raw resource defaults, so current slot picker assignments are applied.\n4. Do not add MP4 preview cache fields, jobs, thumbnails, or resource metadata.\n\n### Step 9: Make dynamic runtime materialization slot-aware (src/tools/video-editor/sequences/materialize.ts, src/tools/video-editor/sequences/SequenceComponentRegistryContext.tsx, src/tools/video-editor/compositions/TimelineRenderer.tsx)\nScope: Medium\n1. Extend dynamic sequence registry entries to include assetSlots from each SequenceComponentResource.\n2. Plumb dynamic entries or a clipType -> assetSlots lookup into materialization call sites that render DB-stored sequence components.\n3. UpdatematerializeSequenceParams / materializeSequenceConfig to accept optional slot metadata lookup while preserving current trusted descriptor-driven materialization for built-ins.\n4. Materializeparams.assetSlotBindings to params.assetSlots only when slot metadata is available for the clip type.\n5. Validate slot id/cardinality/media type during materialization with registry media-type inference; warn and omit invalid URL injections rather than mutating persisted params.\n6. Remove generic generated-component convention materialization from imageAssetKeys / videoAssetKeys to images / videos.\n\n## Phase 4: Preview, Smoke Render, and Slot Picker UI\n\n### Step 10: Update code-path preview to use slot bindings (src/tools/video-editor/components/SequenceCreator/CodePathPreview.tsx)\nScope: Medium\n1. AcceptassetSlots and current assetSlotBindings in preview props.\n2. Resolve bindings against allowedAssets using normalized media types and inject params.assetSlots.\n3. Stop injecting imageAssetKeys, assetKeys, assetUrls, images, or videos fallbacks for generated components.\n4. Setclip.asset from the first resolved slot URL only as compatibility data; generated component media rendering should use params.assetSlots.\n\n### Step 11: Make smoke render slot-aware (src/tools/video-editor/sequences/headlessRender.ts, src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.tsx)\nScope: Medium\n1. ExtendsmokeRenderSequenceComponent input to accept pre-materialized params or assetSlots plus allowed asset registry.\n2. Before calling the smoke gate in persistGeneratedComponent, materialize current defaultsJson.assetSlotBindings into params.assetSlots using current allowedAssets / allowedRegistry.\n3. Keep the smoke gate strict: required slots must be valid before save-on-insert or save-on-replace proceeds.\n4. Add tests proving a component that reads params.assetSlots.hero[0] can pass smoke render when the slot has a valid binding.\n\n### Step 12: Build and wire slot pickers (src/tools/video-editor/components/SequenceCreator/AssetSlotPicker.tsx, src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.tsx)\nScope: Medium\n1. Render one picker section per slot for generated and library components.\n2. Filter candidates by slot media type using AllowedSequenceAsset.mediaType.\n3. Support single-select when maxItems === 1 and multi-select otherwise; reject duplicates by default.\n4. Show inline required/min/max/wrong-media validation messages.\n5. Write changes to generatedComponent.defaultsJson.assetSlotBindings.\n6. Disable Insert/Replace for generated/library components when slot validation fails.\n7. Make library Preview, generated Preview, Insert, and Replace all read current slot assignments.\n\n### Step 13: Keep trusted JSON sequence editing stable (src/tools/video-editor/components/PropertiesPanel/SequenceParamEditor.tsx)\nScope: Small\n1. Leave trusted built-in asset-list params such as image-jump.imageAssetKeys and resource-card.previewAssetKeys working.\n2. Do not migrate built-ins into ASSET_SLOTS in this pass.\n\n## Phase 5: Tests and Verification\n\n### Step 14: Add edge tests (supabase/functions/ai-generate-sequence-component/sequence-component-validation.test.ts, related template/extraction tests)\nScope: Medium\n1. Assert valid ASSET_SLOTS plus DEFAULTS.assetSlotBindings passes.\n2. Assert code can read params.assetSlots.hero without declaring assetSlots in SCHEMA/DEFAULTS.\n3. Assert controls validators allow params.assetSlots / params.assetSlotBindings outside CONTROLS.\n4. Assert missing ASSET_SLOTS, duplicate slot ids, wrong media type, unknown keys, unknown slots, and cardinality failures are rejected.\n5. Assert loose generated-component imageAssetKeys / videoAssetKeys / images / videos are rejected.\n\n### Step 15: Add frontend tests (src/tools/video-editor/sequences/materialize.test.ts, src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.test.tsx, src/tools/video-editor/components/SequenceCreator/ControlsManifestLayout.test.tsx or new picker tests)\nScope: Medium\n1. Test slot bindings materialize to URL arrays without mutating persisted params.\n2. Test dynamic DB sequence materialization receives saved resource slot metadata and validates cardinality/media type.\n3. Test generated and library slot picker changes update preview props and are used by Insert/Replace.\n4. Test save-time smoke render receives materialized slot URLs.\n5. Test trusted built-in sequence asset-list materialization remains covered.\n\n### Step 16: Run focused validation, then broader checks\nScope: Small\n1. Run focused frontend tests first:\n bash\n npx vitest run --config config/testing/vitest.config.ts src/tools/video-editor/sequences/materialize.test.ts src/tools/video-editor/components/SequenceCreator/SequenceCreatorPanel.test.tsx\n \n2. Run Deno edge tests:\n bash\n deno test supabase/functions/ai-generate-sequence-component/\n \n3. Run build/type validation:\n bash\n npm run build\n \n4. Run lint checks after behavior is green:\n bash\n npm run lint\n npm run lint:edge\n \n\n## Execution Order\n1. Land shared slot helpers and metadata types first.\n2. Update edge allowed-asset normalization, prompt contract, parser, generated-code validator, and both controls-manifest validators before expecting model output to pass.\n3. Wire frontend response/store/resource persistence after the edge shape is stable.\n4. Plumb saved assetSlots metadata into dynamic runtime materialization before enforcing runtime slot validation.\n5. Update preview and smoke render before enabling Insert/Replace gates.\n6. Add slot picker UI last, using the helper validation already covered by tests.\n\n## Validation Order\n1. Start with helper and validator tests because they are cheapest and catch contract mistakes early.\n2. Run materialization tests once dynamic slot metadata reaches the materializer.\n3. Run Sequence Creator panel tests for generated preview, library preview, smoke render, Insert, and Replace.\n4. Finish with edge Deno tests, npm run build, and lint checks.",
"changes_summary": "Revised the plan to close the critique gaps: it now explicitly exempts host-injected params.assetSlots from generated-code schema/default coverage, updates both controls-manifest validators, passes richer allowed asset metadata through the edge, plumbs saved assetSlots metadata into runtime materialization, makes smoke render slot-aware, and specifies media-type inference sources. Scope remains limited to AI-generated DB-stored sequence components; built-in sequence asset-list params stay unchanged.",
"flags_addressed": [
"FLAG-001",
"FLAG-002",
"FLAG-003",
"FLAG-004",
"issue_hints",
"correctness-1",
"correctness-2",
"scope",
"all_locations",
"callers"
],
"assumptions": [
"The slot contract applies to AI-generated DB-stored sequence components only; trusted built-in descriptor-driven asset-list params remain in place.",
"params.assetSlotBindings is persisted as registry-key arrays and params.assetSlots is host-injected as Record<slotId, string[]> URL arrays.",
"params.assetSlots is exempt from SCHEMA/DEFAULTS coverage because it is runtime data; params.assetSlotBindings is persisted defaults data but is managed by slot pickers, not controls.",
"Duplicate asset keys within a single slot binding are rejected by default unless a later product decision explicitly needs repeated uses.",
"When no allowed assets exist, ASSET_SLOTS: [] is valid; required/minItems enforcement applies when a component declares media slots and valid allowed assets are available.",
"Frontend runtime media type is inferred from normalized AllowedSequenceAsset.mediaType inside Sequence Creator and from registry type MIME-ish values during timeline materialization.",
"The resources table stores flexible JSON metadata, so adding assetSlots to SequenceComponentMetadata does not require a database migration.",
"No MP4 preview caching, generated preview files, cache keys, or thumbnail jobs are introduced."
],
"success_criteria": [
{
"criterion": "New AI-generated sequence component responses include parsed assetSlots metadata, default params.assetSlotBindings, and no generated-component reliance on loose imageAssetKeys or videoAssetKeys.",
"priority": "must",
"requires": [
"read_files",
"run_tests"
]
},
{
"criterion": "Generated-code validation allows host-injected params.assetSlots without requiring SCHEMA/DEFAULTS entries, while still validating normal user params.",
"priority": "must",
"requires": [
"run_tests",
"read_files"
]
},
{
"criterion": "Both edge and frontend controls-manifest validators reserve assetSlots and assetSlotBindings so generated code can read slot URLs without requiring controls entries.",
"priority": "must",
"requires": [
"run_tests",
"parse_diff"
]
},
{
"criterion": "Edge validation rejects invalid ASSET_SLOTS, invalid default bindings, wrong media types, missing required slots, cardinality violations, unknown asset keys, unknown slot ids, and generated-component use of loose image/video key conventions.",
"priority": "must",
"requires": [
"run_tests",
"read_build_output"
]
},
{
"criterion": "The edge prompt numbers allowed assets with media type and label metadata derived from allowed_assets, not only from a flat key list.",
"priority": "must",
"requires": [
"read_files",
"run_tests"
]
},
{
"criterion": "Sequence component resources persist and reload assetSlots metadata, and library Preview/Load/Insert/Replace use current in-panel slot bindings rather than original resource defaults.",
"priority": "must",
"requires": [
"run_tests",
"read_files"
]
},
{
"criterion": "Runtime materialization receives saved DB component slot metadata and resolves params.assetSlotBindings to params.assetSlots URL arrays without mutating persisted params.",
"priority": "must",
"requires": [
"run_tests",
"parse_diff"
]
},
{
"criterion": "Save-time smoke render materializes current slot bindings before rendering, so components that read required params.assetSlots.<slotId> can pass when bindings are valid.",
"priority": "must",
"requires": [
"run_tests",
"read_files"
]
},
{
"criterion": "Sequence Creator exposes media-type-filtered slot pickers for generated and library components and blocks Insert/Replace when required slots are missing or cardinality/media-type validation fails.",
"priority": "must",
"requires": [
"run_tests",
"inspect_runtime_ui"
]
},
{
"criterion": "No MP4 preview caching fields, jobs, resource metadata, generated thumbnails, or preview cache code paths are introduced.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": "Existing trusted built-in sequence asset-list behavior remains covered and unchanged.",
"priority": "must",
"requires": [
"run_tests",
"parse_diff"
]
},
{
"criterion": "Targeted Sequence Creator, materialization, controls-manifest, and edge validator tests pass.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "The TypeScript build passes after the contract change.",
"priority": "must",
"requires": [
"run_shell",
"read_build_output"
]
},
{
"criterion": "Slot contract helpers stay centralized rather than duplicating slot parsing across panel, preview, smoke render, and materializer code.",
"priority": "should",
"requires": [
"read_files",
"subjective_judgment"
]
},
{
"criterion": "The slot picker UI follows existing Sequence Creator styling with clear inline validation and no broad redesign.",
"priority": "should",
"requires": [
"inspect_runtime_ui",
"subjective_judgment"
]
},
{
"criterion": "Manual smoke test covers generating a custom image component, changing slots, previewing, saving, loading from library, inserting, replacing, and rendering timeline preview.",
"priority": "info",
"requires": [
"inspect_runtime_ui"
]
}
],
"questions": [
"Should repeated selection of the same asset in one slot ever be supported for intentional timing/reuse, or is duplicate rejection acceptable for this first implementation?",
"Should required/minItems validation fail when a component declares a media slot but the user has no allowed assets, or should generation be required to emit ASSET_SLOTS: [] in that situation?"
]
}