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
Engineering brief produced from the codebase and task details:
### Task Summary
Wire ArtAgents into reigh-app's sprint-08 bidirectional editing platform across six phases: (1) swap AA's hand-rolled Remotion comp to <TimelineComposition> from @banodoco/timeline-composition, (2) build a Python DataProvider + Supabase client that POSTs to timeline-import (write) and reigh-data-fetch (read) with expected_version retry, (3) build a banodoco worker that consumes delegateToBanodocoAgent task envelopes and writes back via timeline-import, (4) collapse AA's parallel placement schema/CLI so verbs operate on reigh-app project IDs, (5) support SequenceDraft-shaped tasks via @banodoco/timeline-schema, (6) add renderer parity tests using sprint-08's createAgentWorkflowTimelineFixture/createEmbedDemoTimelineFixture. Resolve five open contracts (worker reception model, JWT/service-role lifecycle, asset upload contract, render lifecycle, sequence schema) during execution. Honor 12 settled decisions from .megaplan/epic_bidirectional_editing.md.
### Key Evidence
- AA's renderer is a 496-line hand-rolled <TimelineComposition> in remotion/src/Root.tsx that ignores the already-installed @banodoco/timeline-composition v0.0.5 package. The package exports a real <TimelineComposition> from typescript/src/TimelineComposition.tsx with EFFECT_REGISTRY/CLIP_TYPE_ALIASES dispatch, ThemeProvider, AudioTrack/VisualClip, and getTimelineDurationInFrames — the swap drops the hand-rolled clip rendering and delegates entirely. (source: remotion/src/Root.tsx; remotion/node_modules/@banodoco/timeline-composition/typescript/src/{index.ts,TimelineComposition.tsx}; remotion/package.json; relevance: high)
Assistant
I have enough context. Now let me write the implementation plan.
Assistant
API Error: Stream idle timeout - partial response received
Version reconcile is required before parity tests are meaningful: AA pins @banodoco/timeline-composition v0.0.5 (GitHub archive tag); reigh-app sprint-08 uses a local file path at v0.0.2. Brief explicitly flags this — must ship a fresh tag both sides consume or AA reverts to local path during dev. (source: .megaplan/epic_bidirectional_editing.md (Phase 1 'Reconcile @banodoco/timeline-composition versioning'); relevance: high)
AA's project subsystem is built around a parallel placement schema that SD-006 says to collapse. artagents/core/project/schema.py defines build_project_timeline/build_placement/validate_project_timeline keyed on a local timeline.json with a placements[] list and source/run REF_KINDS. artagents/core/project/materialize.py converts placements -> Banodoco TimelineConfig. artagents/core/project/cli.py exposes create/source add/timeline place-source/place-run/remove/materialize. All of this becomes either local-cache-only (sources/, runs/ retained for provenance) or is deleted; the new CLI must operate on reigh-app project UUIDs via reigh-data-fetch + timeline-import + @banodoco/timeline-ops. (source: artagents/core/project/{schema.py,materialize.py,cli.py,project.py,timeline.py}; SD-001/SD-005/SD-006; relevance: high)
Read path already exists in skeletal form. artagents/packs/builtin/reigh_data/run.py is a working POST client to the reigh-data-fetch Edge Function with env-driven URL/PAT discovery (REIGH_DATA_FETCH_URL / REIGH_API_URL / SUPABASE_URL; REIGH_PAT). It returns project/shot/task/timeline payloads via a single endpoint. Reuse this for the SupabaseDataProvider's read methods; do not rebuild env discovery. (source: artagents/packs/builtin/reigh_data/run.py:108-145; relevance: high)
Write path does not exist. There is no existing client for the timeline-import edge function. The current reigh-app handoff (artagents/packs/builtin/open_in_reigh/run.py) is a file-copy helper that explicitly admits it 'never opens a Supabase connection' and only prints UPSERT SQL templates. SD-009 mandates: user JWT for ownership-bound CLI calls, service-role key only for the AA worker's final timeline-import write. New code lives somewhere like artagents/core/reigh/{supabase_client.py,data_provider.py,timeline_import.py}. (source: artagents/packs/builtin/open_in_reigh/run.py:1-83; SD-009; relevance: high)
Schema source of truth is already wired in. The repo imports from banodoco_timeline_schema (installed at remotion/node_modules/@banodoco/timeline-schema/python/banodoco_timeline_schema/) for TimelineConfig/TimelineClip/Theme/AssetEntry plus validate_timeline. tests/test_timeline_roundtrip_fixture.py asserts AA's allowlists match the shared JSON Schema. Sequence support (Phase 5) should add SequenceDraft validation via this same package — extend the python package or import from a Python sequences submodule sprint-08 ships; if absent, mirror via Zod->JSON-Schema codegen step. (source: artagents/timeline.py:24-100; tests/test_timeline_roundtrip_fixture.py:147-198; remotion/node_modules/@banodoco/timeline-schema/python/banodoco_timeline_schema/init.py; relevance: high)
Open contract #1 (worker reception model) is unresolved in the repo. Brief states delegateToBanodocoAgent.ts:160-167 POSTs to ORCHESTRATOR_TASK_ENQUEUE_URL with task_type=banodoco_timeline_generate, worker_pool=banodoco; AA must decide HTTP push endpoint vs poll-queue model and where to write status updates so pollBanodocoTaskStatus (delegateToBanodocoAgent.ts:242-300) sees them. No reigh-app/orchestrator code is locally accessible — the worker design needs the discovery spike called out in the brief, ideally before writing the worker module. (source: .megaplan/epic_bidirectional_editing.md 'Open contracts to nail down', items 1, 2, 4; relevance: high)
Provenance carry-fields are already in the shared schema (source_uuid, generation, pool_id, clip_order). SD-003 explicitly rejects adding a new source: SourceRef|RunRef field. AA's worker, when emitting clips that originate from a local run/source, must populate source_uuid and generation (opaque dict) so reigh-app's TIMELINE_CLIP_FIELDS allowlist preserves them. SD-008 adds a baseline-snapshot sha256 stored in AA's local run record for drift detection on regenerate. (source: SD-003, SD-008; artagents/timeline.py:43-72 (SharedTimelineClip already lists source_uuid, generation, pool_id, clip_order); relevance: high)
Top-level dispatcher already has an extension seam at artagents/pipeline.py — handles 'projects', 'reigh-data', 'thread' etc. The CLI collapse and new worker entrypoint slot in here. The projects branch will switch to a thin reigh-app-backed CLI; a new worker branch (or daemon entrypoint outside the gateway) is needed for the banodoco worker. (source: artagents/pipeline.py:15-72; relevance: medium)
Existing tests pin behavior that will be deleted or rewritten. tests/test_project_cli.py asserts the create/source/place-source/materialize/remove flow end-to-end; tests/test_project_materialize.py and test_project_schema.py pin the placement schema; tests/test_project_runs.py pins run records (keep). After collapse these need rewrite to assert reigh-app-backed verbs (mock reigh-data-fetch + timeline-import). test_timeline_roundtrip_fixture.py and test_open_in_reigh.py and test_reigh_data.py already pin the shared schema parity and Edge-Function semantics — keep. (source: tests/test_project_cli.py:28-80; tests/test_project_materialize.py; tests/test_project_schema.py; tests/test_project_runs.py; tests/test_timeline_roundtrip_fixture.py; relevance: high)
Settled decisions to honor verbatim: SD-001 (Supabase canonical, AA local = cache+provenance), SD-002 (renderer swap mandatory), SD-003 (no new source ref field), SD-004 (worker pool required), SD-005 (CLI talks via timeline-ops + edge functions), SD-006 (collapse placement schema; keep sources/runs/), SD-007 (expected_version retry cap N=3), SD-008 (baseline-snapshot digest), SD-009 (user JWT vs service-role split), SD-010 (build against public SDK src/tools/video-editor/index.ts), SD-011 (sprint sequence), SD-012 (two-way authoring required). (source: .megaplan/plans/wire-artagents-into-reigh-app-20260504-1033/state.json imported_decisions[]; relevance: high)
AA's domain wrapper for Banodoco timelines is artagents/timeline.py — exposes Timeline, load_timeline/save_timeline, validate_timeline/validate_registry, _CLIP_ALLOWED, _TIMELINE_TOP_ALLOWED, _TRACK_ALLOWED. The new SupabaseDataProvider should round-trip TimelineConfig through these helpers (not reinvent JSON shape) so the round-trip fixture test stays green. (source: artagents/timeline.py:1-100; tests/test_timeline_roundtrip_fixture.py:53-59; relevance: medium)
code
### Relevant Code
| File | Functions | Why |
| --- | --- | --- |
| remotion/src/Root.tsx | TimelineComposition, RenderClip, AdosCard, AdosLowerThird, CornerLogo, Root, getTimelineDurationInFrames, getCanvas | Phase 1 swap target. Replace 496 lines of hand-rolled comp + AdosCard/AdosLowerThird/CornerLogo helpers with delegation to from @banodoco/timeline-composition. Keep only the Composition wrapper, defaultProps, and calculateMetadata — re-using the package's getTimelineDurationInFrames where possible. |
| remotion/package.json | - | Pin reconciliation. Currently @banodoco/timeline-composition v0.0.5 (GitHub tag); reigh-app sprint-08 uses local file:.. at v0.0.2. Coordinate either a fresh shared tag or a local-path dev mode; doc warns parity tests are meaningless until aligned. |
| artagents/core/project/cli.py | main, build_parser, _cmd_create, _cmd_show, _cmd_source_add, _cmd_timeline_show, _cmd_timeline_place_source, _cmd_timeline_place_run, _cmd_timeline_remove, _cmd_materialize | Phase 4 CLI collapse. Drop place-source/place-run/remove/materialize subcommands. Add list/show/edit verbs that take reigh-app project UUIDs and call reigh-data-fetch (read) + timeline-import (write) using @banodoco/timeline-ops semantics for in-memory edits. Add expected_version retry (cap N=3, SD-007). |
| artagents/core/project/schema.py | build_project_timeline, build_placement, validate_project_timeline, validate_placement, validate_reference, source_ref, run_ref | Phase 4 schema collapse. Delete placement-related symbols (TIMELINE_SCHEMA_VERSION, build_project_timeline, build_placement, validate_project_timeline, validate_placement, validate_reference, REF_KINDS, source_ref, run_ref). Keep project.json + source.json + run.json schemas (they back the local provenance cache). The local timeline.json file becomes obsolete. |
| artagents/core/project/materialize.py | materialize_project_timeline, materialize_project_timeline_payload, require_run_clip, _clip_from_source_placement, _clip_from_run_placement, write_materialized_project_timeline | Phase 4 deletion target. Placement -> TimelineConfig conversion is replaced by 'fetch via reigh-data-fetch, apply timeline-ops, push via timeline-import'. Helper functions like require_run_clip may survive if needed by the worker for run-clip lookup. |
| artagents/core/project/project.py | create_project, load_project_timeline, save_project_timeline, show_project, _touch_project | Phase 4 trim. create_project still creates the local provenance directories (sources/, runs/) but should stop writing timeline.json. load_project_timeline/save_project_timeline (the local file ops) get deleted. show_project's timeline summary derives from a fetched reigh-app timeline if a project is mapped, otherwise reports cache state. |
| artagents/core/project/timeline.py | add_placement, remove_placement, load_timeline | Phase 4 deletion candidate. Currently provides add_placement/remove_placement/load_timeline against the local timeline.json. With placement schema gone, this whole module is removed; its tests rewrite to assert ops-via-timeline-import instead. |
| artagents/packs/builtin/reigh_data/run.py | resolve_api_url, resolve_pat, fetch_reigh_data, _candidate_env_files, _env_first | Phase 2 read-side reuse. Already implements env discovery + reigh-data-fetch POST client. Refactor _candidate_env_files / _env_first / resolve_api_url / resolve_pat into a shared module so the new SupabaseDataProvider, the worker, and the CLI all share env handling. |
| artagents/packs/builtin/open_in_reigh/run.py | main, build_parser, source_paths, probe_target, maybe_copy_files, print_manual_handoff | Phase 2/4 supersession. Manual file-copy handoff is replaced by direct timeline-import push. Keep the SQL-template helper as an opt-in escape hatch (--print-sql) but route normal flow through the new SupabaseDataProvider.write(). |
| artagents/timeline.py | load_timeline, save_timeline, validate_timeline, validate_registry, _TIMELINE_TOP_ALLOWED, _CLIP_ALLOWED, _TRACK_ALLOWED | Schema authority. The DataProvider must pass fetched timelines through validate_timeline / load_timeline / save_timeline so byte-equivalence (test_timeline_roundtrip_fixture.py) and allowlist parity stay intact. Don't reinvent TimelineConfig handling in the Supabase client. |
| artagents/pipeline.py | main, _run_default_brief_orchestrator, _print_entrypoint_help | Top-level dispatcher. Add a 'worker' (or 'banodoco-worker') subcommand for the delegateToBanodocoAgent consumer. The existing 'projects' branch keeps its name but its handler points at the rewritten reigh-app-backed CLI module. |
| artagents/core/executor/cli.py | main, build_parser, _cmd_run | Phase 4 CLI surface. Existing executor 'run' verb has --project flag (currently project slug). It needs to accept reigh-app project UUIDs and route writes through timeline-import (SD-005). Keep the slug path for offline/cache mode if helpful. |
| artagents/core/project/run.py | write_run_record, require_run_record | Provenance store. Run records (run.json + per-run timeline.json + assets.json) survive the collapse as local provenance cache. The worker writes baseline_snapshot (sha256 of clip-as-AA-wrote-it, SD-008) into run records so drift detection works on regenerate. |
| artagents/core/project/source.py | add_source, require_source | Provenance store. Source records survive. The new SupabaseDataProvider.uploadAsset() (Phase 2 / open contract #3) writes the asset to render-outputs / generations bucket and persists the local source.json with the bucket key for traceability. |
| tests/test_project_cli.py | test_projects_cli_create_show_source_place_materialize_and_remove | Test rewrite. Currently asserts placement create/place-source/materialize/remove. Replace with reigh-data-fetch + timeline-import flow (mock urllib.request to a fake Supabase endpoint), assert expected_version retry, assert local cache invariants. |
| tests/test_project_materialize.py | - | Likely deleted with placement-materialize. If kept, assertions move to TimelineConfig assembly via timeline-ops on a fetched timeline rather than local placements. |
| tests/test_project_schema.py | - | Reduces to project.json/source.json/run.json schema tests; placement assertions removed. |
| tests/test_project_runs.py | - | Stays. Run record provenance tests still relevant; add baseline_snapshot digest coverage (SD-008). |
| tests/test_timeline_roundtrip_fixture.py | test_round_trip_is_byte_equivalent, test_unknown_top_level_field_is_preserved, test_allowlist_parity_with_shared_schema | Stays as the schema-parity gate. The Supabase client must round-trip through artagents.timeline so this test continues to pass byte-equivalence. |
| tests/test_reigh_data.py | - | Stays. Continues to pin reigh-data-fetch client semantics; new tests for the SupabaseDataProvider extend rather than replace these. |
| tests/test_open_in_reigh.py | - | Update. The file-copy and --print-sql paths stay, but the new default flow goes through the SupabaseDataProvider; add a test that the default mode rejects placement-style local timeline.json once the schema is collapsed. |
| remotion/node_modules/@banodoco/timeline-composition/typescript/src/TimelineComposition.tsx | TimelineComposition, renderVisualClipContent, renderVisualSequence | Read-only reference. Confirms package surface (ThemeProvider, EFFECT_REGISTRY dispatch, AudioTrack, VisualClip, getClipDurationInFrames, transitions). Drives Phase 1 swap shape. |
| remotion/node_modules/@banodoco/timeline-schema/python/banodoco_timeline_schema/init.py | - | Read-only reference. Confirms Python types AssetEntry/Theme/ThemeOverrides/TimelineClip/TimelineConfig/TimelineOutput plus validate_timeline are available. Phase 5 extends this with SequenceDraft import or codegen. |
code
### Test Expectations
- [pass_to_pass] remotion/__smoke__/bundle.mjs (smoke): Remotion bundle compiles after Root.tsx is reduced to a <TimelineComposition> delegation. Run `npm -w remotion run smoke` after Phase 1.
[pass_to_pass] tests/test_timeline_roundtrip_fixture.py::TimelineRoundTripFixtureTest::test_round_trip_is_byte_equivalent: examples/hype.timeline.full.json survives a load/save round-trip byte-equivalent. Must keep passing through the schema collapse and Supabase client work.
[pass_to_pass] tests/test_timeline_roundtrip_fixture.py::TimelineRoundTripFixtureTest::test_allowlist_parity_with_shared_schema: AA's _TIMELINE_TOP_ALLOWED / _CLIP_ALLOWED / _TRACK_ALLOWED match @banodoco/timeline-schema's JSON Schema. Adding sequence-aware fields must not break parity.
[pass_to_pass] tests/test_reigh_data.py: reigh-data-fetch client semantics. Stays green as the SupabaseDataProvider extends it.
[fail_to_pass] tests/test_project_cli.py::test_projects_cli_create_show_source_place_materialize_and_remove: Currently asserts the placement-style flow that SD-006 collapses. Test must be rewritten to assert the new reigh-app-backed CLI verbs (list/show/edit via mocked reigh-data-fetch + timeline-import) with expected_version retry coverage.
[fail_to_pass] tests/test_project_materialize.py: Placement -> TimelineConfig materialize. Deleted or rewritten as fetch+ops+push.
[fail_to_pass] tests/test_project_schema.py: Placement schema validation. Reduced to project/source/run schema tests.
[pass_to_pass] tests/test_project_runs.py: Run record provenance schema. Add baseline_snapshot sha256 coverage (SD-008) without breaking existing assertions.
[pass_to_pass] tests/test_open_in_reigh.py: File-copy and --print-sql escape-hatch paths. Stay green; add coverage that the default flow now pushes via timeline-import.
[fail_to_pass] tests/test_supabase_data_provider.py (new): New unit tests for SupabaseDataProvider: fetch via reigh-data-fetch, push via timeline-import, expected_version conflict retry (cap N=3), JWT vs service-role header selection.
[fail_to_pass] tests/test_banodoco_worker.py (new): New tests for the banodoco worker: accepts BanodocoTaskPayload envelope (intent, brief_inputs, theme_id, expected_version, scope, user_jwt, project_id, timeline_id, correlation_id), dispatches by intent, surfaces status updates the orchestrator can poll.
[fail_to_pass] tests/test_sequence_support.py (new): Worker handles SequenceDraft-shaped tasks via @banodoco/timeline-schema validation; falls back to 'unsupported sequence' when clipType is not in LOCAL_SEQUENCE_REGISTRY / THEME_PACKAGE_REGISTRY.
[fail_to_pass] tests/test_renderer_parity.py (new): Renderer parity smoke: uses createAgentWorkflowTimelineFixture / createEmbedDemoTimelineFixture (or a JSON export of them) to render via AA's Remotion entry; compares hash to a reigh-app golden.
code
### Constraints
- Do not introduce a new source: SourceRef|RunRef field on TimelineClip — SD-003 explicitly rejects this. Use the existing source_uuid + generation carry-fields instead.
Do not reintroduce or extend the parallel placement schema (artagents/core/project/schema.py:build_placement and friends). SD-006 collapses it; sources/ and runs/ directories survive only as local provenance cache.
Do not import from reigh-app internals. SD-010 mandates building against the public SDK at src/tools/video-editor/index.ts (sprint-08, @publicContract). DataProvider, TimelineVersionConflictError, TimelineNotFoundError, fixture constructors come from there.
Do not put the service-role key on the user-JWT path. SD-009: user JWT for ownership-bound CLI calls; service-role only for the AA worker's final timeline-import write. Mirrors reigh-app's SD-022.
Do not break tests/test_timeline_roundtrip_fixture.py — byte-equivalent round-trip and allowlist parity with @banodoco/timeline-schema are gating invariants.
Do not author one-way (AA composes only). SD-012 requires two-way authoring: both reigh-app and AA must be able to write.
Do not skip the @banodoco/timeline-composition version reconcile. AA's v0.0.5 vs reigh-app sprint-08's local-path v0.0.2 must converge on a shared tag before parity tests are meaningful — flagged as a Phase 1 blocker by the doc.
Do not silently bypass expected_version. SD-007: timeline-import push retries on conflict with cap N=3, surfaces failure to caller on exhaustion.
Do not delete sources/ and runs/ directories during the placement-schema collapse. Per SD-006 they remain as local provenance cache; only the placement schema and local timeline.json-as-source-of-truth go.
Do not lose AA-generated provenance on round-trip. New clips emitted via the worker must populate source_uuid, generation, pool_id, clip_order so reigh-app's TIMELINE_CLIP_FIELDS allowlist preserves them. Add baseline_snapshot sha256 to AA's local run record for SD-008 drift detection.
Do not invoke megaplan, the megaplan skill, or nested planning loops — explicit per harness directive.
code
Wire ArtAgents into reigh-app's sprint-08 bidirectional editing platform: swap AA's Remotion comp to from @banodoco/timeline-composition, implement a Python DataProvider + Supabase client that talks to timeline-import (write) and reigh-data-fetch (read), build the banodoco worker that consumes delegateToBanodocoAgent task envelopes (correlation_id, expected_version, user_jwt) and writes back via timeline-import, collapse AA's CLI to operate on reigh-app project IDs (no more parallel placement schema), support sequence-shaped tasks via @banodoco/timeline-schema's SequenceDraft, and verify renderer parity using sprint-08's createAgentWorkflowTimelineFixture/createEmbedDemoTimelineFixture. Resolve the 5 open contracts (worker reception model, JWT+service-role lifecycle, asset upload contract, render lifecycle, sequence schema) during execution. Honor the 12 settled decisions imported from the doc.
Prior doc imported via --from-doc:
.megaplan/epic_bidirectional_editing.md
Imported decisions:
SD-001: Reigh-app's Supabase is the canonical store. AA's local directory is cache + provenance only
rationale: Avoid two-source-of-truth sync bugs. Reigh-app's timelines table + edge functions are already the platform.
load_bearing: True
SD-002: Both tools render via @banodoco/timeline-composition. AA's Root.tsx swaps in <TimelineComposition>
rationale: Pixel parity requires shared component code. Both run Remotion in headless Chromium; same components → same pixels.
load_bearing: True
SD-003: AA does not introduce a new source: SourceRef | RunRef field. Existing source_uuid + generation carry-fields are sufficient
rationale: source_uuid is already on TimelineClip and already preserved by reigh-app's allowlist. Adding a structured ref duplicates information already available.
load_bearing: True
SD-004: AA implements a banodoco worker pool that consumes delegateToBanodocoAgent tasks
rationale: This is the only way reigh-app's agent loop can delegate work to AA. Without it, sprint-7's delegation pathway has nothing to delegate to.
load_bearing: True
SD-005: AA's CLI verbs talk to reigh-app via reigh-data-fetch (read) and timeline-import (write), using @banodoco/timeline-ops for in-memory edits
rationale: Aligns AA with the same primitives reigh-app uses internally. Avoids hand-rolled clip-list mutation.
load_bearing: True
SD-006: AA's parallel placement schema (shipped in add-a-project-projecttimeline-20260503-2303) is collapsed. sources/, runs/ directories survive as local provenance cache; the placement schema and local timeline.json-as-source-of-truth are discarded
rationale: There is no separate AA timeline format. AA edits Banodoco-shaped timelines via the shared platform.
load_bearing: True
SD-007: Concurrent edits handled by expected_version on timeline-import. AA retries with cap N=3 on conflict, surfacing to user on exhaustion
rationale: Mirrors reigh-app's useTimelinePersistence retry pattern. Same primitive on both sides.
load_bearing: False
SD-008: When reigh-app edits a clip with source_uuid set, AA preserves user edits on regenerate via baseline-snapshot digest
rationale: AA stores sha256 of clip-as-it-wrote-it. On regenerate, compares to current; if matches, replace; if differs, log drift and preserve user edits.
load_bearing: False
SD-009: Auth: user JWT for ownership-bound CLI calls; service-role key only for AA worker's final timeline-import write (matching reigh-app's SD-022)
rationale: User JWT authorizes intent; service-role performs the trusted DB write. Same model reigh-app uses.
load_bearing: True
SD-010: Build against reigh-app's public SDK (src/tools/video-editor/index.ts, sprint-08, marked @publicContract), not internal modules. AA's integration seam is the DataProvider interface
rationale: Sprint-08 explicitly froze a public surface and surfaced DataProvider as the contract for external persistence implementations. AA's Python client implements (or mirrors) this interface so tests, embed scenarios, and Supabase paths share the same shape. Importing internals risks breakage on every reigh-app release.
load_bearing: True
SD-011: Sprint sequence: renderer swap → Supabase client → worker → CLI collapse → sequence support → parity tests. Single-sprint scope
rationale: Phases are largely independent; renderer swap unblocks parity tests, worker unblocks integration tests with reigh-app's delegateToBanodocoAgent. Total ~10–12 days focused work.
load_bearing: False
SD-012: One-way authoring (AA composes, reigh-app renders only) is rejected
rationale: Violates user's hard requirement that both tools must author.
load_bearing: True
Planning guidance for imported decisions:
For each imported decision with load_bearing: true, include a success criterion with priority: 'must' referencing the SD-NNN id.
For each imported decision with load_bearing: false, include a success criterion with priority: 'info' referencing the SD-NNN id.
code
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.
Dataset releases
Not yet included in a published release.
### Suggested Approach
Honour the SD-011 phase order, but front-load two discovery spikes before code so the worker design isn't rewritten twice. PHASE 0 (~half day, before Phase 1): freeze the @banodoco/timeline-composition version (cut a v0.0.6 tag both AA and reigh-app sprint-08 consume, OR temporarily switch AA to a workspace file:.. path matching reigh-app); resolve open contracts #1 (worker reception model — HTTP push vs poll-queue and ack envelope) and #4 (render lifecycle / realtime channel) by reading delegateToBanodocoAgent.ts:160-300 and pollBanodocoTaskStatus, document the answers in a top-of-module docstring on the new worker file. PHASE 1 — Renderer swap: rewrite remotion/src/Root.tsx to a ~30-line file: <Composition id=\"TimelineComposition\" component={TimelineComposition} defaultProps={...} calculateMetadata={({props}) => ({width, height, fps, durationInFrames: getTimelineDurationInFrames(props.timeline, fps)})} />, importing from @banodoco/timeline-composition. Delete the AdosCard/AdosLowerThird/CornerLogo helpers — those become theme-package effects. Run remotion smoke; render a hype fixture; compare hash to a reigh-app golden if available, otherwise visual diff. PHASE 2 — Supabase client: add artagents/core/reigh/{env.py,supabase_client.py,data_provider.py,timeline_import.py}. env.py extracts _candidate_env_files/_env_first from packs/builtin/reigh_data/run.py into a shared helper. supabase_client.py wraps urllib.request POSTs with auth header selection (user JWT vs service-role per call site). data_provider.py implements a Python mirror of the sprint-08 DataProvider interface (fetch, persist, uploadAsset) calling reigh-data-fetch and timeline-import; raise TimelineVersionConflictError analogue on 409 and retry up to N=3 with re-fetch + re-apply (SD-007). Resolve open contract #3 (asset upload contract) by reading the render-outputs RLS migration and DataProvider.uploadAsset signature; pick a single bucket + signed-URL pattern. PHASE 3 — Worker: artagents/core/worker/banodoco_worker.py exposes a polling loop or HTTP endpoint matching the answer from Phase 0 spike. It accepts the BanodocoTaskPayload envelope, dispatches by intent to existing executors (hype, logo_ideas, etc. via the orchestrator registry), writes back via the SupabaseDataProvider with the supplied correlation_id and expected_version, and emits status transitions queued -> running -> complete/failed via the resolved render-lifecycle channel. Add a `worker` subcommand to artagents/pipeline.py. Service-role key gates only the timeline-import write (SD-009). PHASE 4 — CLI collapse: rewrite artagents/core/project/cli.py to expose `list / show <uuid> / edit <uuid>` plus thin wrappers for add-clip / move-clip / set-theme that compose @banodoco/timeline-ops semantics in Python (port the small ops or call out to a node helper). Delete artagents/core/project/{timeline.py,materialize.py} and the placement symbols in schema.py; keep project.py, source.py, run.py for the local provenance cache (sources/, runs/). Update artagents/core/executor/cli.py so --project accepts a reigh-app UUID and writes back via SupabaseDataProvider. Rewrite tests/test_project_cli.py + delete or rewrite tests/test_project_materialize.py and test_project_schema.py. PHASE 5 — Sequence support: extend the worker to recognize SequenceDraft-shaped tasks; import the schema from banodoco_timeline_schema (or codegen Python types from the Zod source if missing); validate, then materialize via a small Python applySequenceDraftToTimeline equivalent or an out-of-process node call to the sprint-08 sequences module; fall back to an explicit \"unsupported sequence\" failure when the clipType is not in LOCAL_SEQUENCE_REGISTRY / THEME_PACKAGE_REGISTRY (open contract #5 resolution). PHASE 6 — Parity tests: add tests/test_renderer_parity.py that exports the sprint-08 fixtures (createAgentWorkflowTimelineFixture, createEmbedDemoTimelineFixture) to JSON via a small node helper, renders via AA's Remotion entry headless, and asserts hash match against a reigh-app golden. Add tests/test_supabase_data_provider.py, tests/test_banodoco_worker.py, tests/test_sequence_support.py for unit coverage. Update tests/test_open_in_reigh.py and tests/test_project_runs.py for SD-008 baseline_snapshot. Throughout, preserve source_uuid/generation/pool_id/clip_order on every clip the worker writes (SD-003) and never reintroduce a structured ref field. Document each open-contract resolution in the module docstring of the file that owns it so future agents see the why.
The engineering brief above was produced by analyzing the codebase. Use it as a strong starting point, but the suggested approach is a hypothesis — verify it's the best fix, not just a valid one.
Idea:
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):