Commit Graph

335 Commits

Author SHA1 Message Date
giles
414cbddd66 Fix VideoSource import path 2026-02-03 00:02:23 +00:00
giles
89b2fd3d2e Add debug logging to resolve_asset 2026-02-03 00:00:30 +00:00
giles
3d5a08a7dc Don't overwrite pre-registered primitives in _load_primitives 2026-02-02 23:59:38 +00:00
giles
d8360e5945 Use Celery task logger for debug 2026-02-02 23:56:13 +00:00
giles
44066e9bdd Use warnings for debug output 2026-02-02 23:54:18 +00:00
giles
b2be9ff976 Clear Python bytecode cache on worker start 2026-02-02 23:51:55 +00:00
giles
32474380fa Add module load debug 2026-02-02 23:46:22 +00:00
giles
5bd055f031 Use print for debug output 2026-02-02 23:44:34 +00:00
giles
cbdae70b66 Add more debug logging for primitive override 2026-02-02 23:41:05 +00:00
giles
2d520cf256 Allow admin token auth for stream endpoint
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 23:37:57 +00:00
giles
e6dd6e851c Add debug logging for CID video source resolution
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 23:34:08 +00:00
giles
2081092ce8 Add ADMIN_TOKEN for admin endpoints and allow token-based auth
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 23:28:19 +00:00
giles
d20eef76ad Fix completed runs not appearing in list + add purge-failed endpoint
- Update save_run_cache to also update actor_id, recipe, inputs on conflict
- Add logging for actor_id when saving runs to run_cache
- Add admin endpoint DELETE /runs/admin/purge-failed to delete all failed runs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 23:24:39 +00:00
giles
581da68b3b Add streaming endpoint to runs router
- Add /runs/stream POST endpoint for streaming recipes
- Accepts recipe_sexp, sources_sexp, audio_sexp
- Submits to run_stream Celery task

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 19:18:47 +00:00
giles
bb458aa924 Replace batch DAG system with streaming architecture
- Remove legacy_tasks.py, hybrid_state.py, render.py
- Remove old task modules (analyze, execute, execute_sexp, orchestrate)
- Add streaming interpreter from test repo
- Add sexp_effects with primitives and video effects
- Add streaming Celery task with CID-based asset resolution
- Support both CID and friendly name references for assets
- Add .dockerignore to prevent local clones from conflicting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 19:10:11 +00:00
giles
270eeb3fcf Add artdag-effects to gitignore
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:46:15 +00:00
giles
f290c9f01e Mount source code volume for development hot-reload
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:38:06 +00:00
gilesb
396bacc89b Add debug logging for plan file lookup 2026-01-13 05:10:59 +00:00
gilesb
b599b59d44 Use IPFS CID as primary output_cid instead of cache_id hash 2026-01-13 05:01:26 +00:00
gilesb
cf83952a19 Fix add_file to accept both Path and string 2026-01-13 04:44:11 +00:00
gilesb
ca2d4a17a4 Fix: use DATABASE_URL instead of separate DB_* vars 2026-01-13 04:38:02 +00:00
gilesb
4f3eccd4d3 Fix async database calls from sync context
- Use dedicated thread with new event loop for database operations
- Create new database connection per operation to avoid pool conflicts
- Handles both async and sync calling contexts correctly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 04:31:04 +00:00
gilesb
d685518c4c Remove Redis fallbacks - database only, no silent failures
- Database is the ONLY source of truth for cache_id -> ipfs_cid
- Removed Redis caching layer entirely
- Failures will raise exceptions instead of warning and continuing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 04:23:28 +00:00
gilesb
529c173722 Use database for cache_id -> ipfs_cid mapping
- Database (cache_items table) is now source of truth
- Redis used as fast cache on top
- Mapping persists across restarts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 04:22:28 +00:00
gilesb
d7d7cd28c2 Store cache items by IPFS CID, index by cache_id
- Files in /data/cache/nodes/ are now stored by IPFS CID only
- cache_id parameter creates index from cache_id -> IPFS CID
- Removed deprecated node_id parameter behavior
- get_by_cid(cache_id) still works via index lookup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 04:20:34 +00:00
gilesb
c46fcd2308 Make IPFS upload failures fatal - no local hash fallback
IPFS CIDs are the primary identifiers. If IPFS upload fails,
the operation must fail rather than silently using local hashes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 04:17:34 +00:00
gilesb
2c3f943e5a Save plan_cid to database immediately after plan creation
- Add plan_cid column to pending_runs table schema
- Add update_pending_run_plan() function to save plan_cid
- Update get_pending_run() to return plan_cid
- Save plan_cid right after storing plan to IPFS (before execution)
- Plan is now available even if run fails

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 04:13:10 +00:00
gilesb
7813eb081a Fail run if output cannot be uploaded to IPFS
- Upload final output to IPFS after execution completes
- Return success=False if IPFS upload fails
- Previously the run would succeed with output_ipfs_cid=None

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 03:57:36 +00:00
gilesb
0f4817e3a8 Fix get_file to accept both Path and string arguments
All callers were passing str(path) but the function expected Path objects,
causing 'str' object has no attribute 'parent' errors when fetching from IPFS.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 03:45:56 +00:00
gilesb
3ee4dc1efb Restore effect:identity executor shortcut
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 03:18:26 +00:00
gilesb
c5d70f61c8 Add debug logging for effect executor lookup
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 03:11:33 +00:00
gilesb
c3d6427883 Fix effect loading from IPFS and improve COMPOUND handling
- Remove effect:identity shortcut executor so effects load from IPFS by CID
- COMPOUND nodes now fall back to generic EFFECT executor for dynamic effects
- EFFECT nodes also fall back to generic executor when specific not found
- Update test assertions to match current implementation
- Raise error instead of silently skipping when effect executor not found

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 03:04:52 +00:00
gilesb
ad15ef1ce7 Add explicit EFFECT node handling with case-insensitive lookup
- EFFECT nodes now handled explicitly like SOURCE, COMPOUND, SEQUENCE
- Case-insensitive node type matching throughout
- Fallback executor lookup tries both upper and original case

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 02:21:30 +00:00
gilesb
164f1291ac Add SEQUENCE node handling for concatenating clips
Uses FFmpeg concat demuxer. Falls back to re-encoding if
stream copy fails (different codecs/formats).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 02:20:04 +00:00
gilesb
59c72500ac Fix status: check task result success flag, not just Celery success
Celery task "succeeds" (no exception) but may return {"success": False}.
Now we check the task result's success field AND output_cid before
marking run as completed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 02:13:03 +00:00
gilesb
84d465b264 Include failed runs in list_runs output
Failed runs were not showing in UI/CLI because list_runs only
included runs with status "pending" or "running", excluding "failed".

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 02:10:58 +00:00
gilesb
f28edf7ab6 Fix DogExecutor to use new process() API instead of effect_dog()
The dog effect was updated to use process() but DogExecutor
was still importing the old effect_dog() function.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 02:05:15 +00:00
gilesb
be4d0da84f Fix case sensitivity bug: S-expression node types are lowercase
Bug: S-expression plans produce lowercase node types (source, compound)
but code was checking uppercase (SOURCE, COMPOUND).

Fix: Use .upper() for node type comparisons.

Add TestNodeTypeCaseSensitivity tests to catch this regression.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 01:58:34 +00:00
gilesb
bfe96a431c Fail recipe if no output produced, add tests
- execute_recipe now returns success=False if output_cid is None
- Add TestRecipeOutputRequired tests to catch missing output
- Recipe must produce valid output to be considered successful

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 01:55:23 +00:00
gilesb
e1c0ebc0a2 Add integration tests for S-expression plan execution
Tests cover:
- SOURCE node resolution (fixed CID vs user input)
- COMPOUND node filter chain handling
- Cache lookup by code-addressed cache_id vs IPFS CID
- All plan step types (SOURCE, EFFECT, COMPOUND, SEQUENCE)
- Error handling for missing inputs

These tests would have caught the bugs:
- "No executor for node type: SOURCE"
- "No executor for node type: COMPOUND"
- Cache lookup failures by code-addressed hash

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 01:53:35 +00:00
gilesb
6c4b850487 Add COMPOUND node handling and fix cache lookups by code-addressed hash
- Add COMPOUND node handling in execute_recipe for collapsed effect chains
- Index cache entries by node_id (cache_id) when different from IPFS CID
- Fix test_cache_manager.py to unpack put() tuple returns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 01:47:20 +00:00
gilesb
d08fbfc0bd Fix SOURCE node resolution for user inputs in execute_recipe
- SOURCE nodes with :input true now resolve CID from input_hashes
- Tries multiple name formats: exact, lowercase-dashes, lowercase-underscores
- Only return "completed" status for runs with actual output
- Add integration tests for SOURCE CID resolution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 01:36:48 +00:00
gilesb
bf188f4671 Remove dead code: execute_level, render_dog_from_cat, duplicate file_hash
- Remove execute_level() from tasks/execute.py (defined but never called)
- Remove render_dog_from_cat() from legacy_tasks.py (test convenience, never used)
- Remove duplicate file_hash() from legacy_tasks.py, import from cache_manager
- Remove unused hashlib import

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 01:21:55 +00:00
gilesb
d603485d40 Refactor to S-expression based execution with code-addressed cache IDs
Major changes:
- Add execute_recipe task that uses S-expression planner
- Recipe S-expression unfolds into plan S-expression with code-addressed cache IDs
- Cache IDs computed from Merkle tree of plan structure (before execution)
- Add ipfs_client.add_string() for storing S-expression plans
- Update run_service.create_run() to use execute_recipe when recipe_sexp available
- Add _sexp_to_steps() to parse S-expression plans for UI visualization
- Plan endpoint now returns both sexp content and parsed steps

The code-addressed hashing means each plan step's cache_id is:
  sha3_256({node_type, config, sorted(input_cache_ids)})

This creates deterministic "buckets" for computation results computed
entirely from the plan structure, enabling automatic cache reuse.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 00:27:24 +00:00
gilesb
2c27eacb12 Convert DAG nodes dict to steps list in get_run_plan()
The CLI expects {"steps": [...]} but DAG format stores {"nodes": {...}}.
Added _dag_to_steps() to convert between formats, including topological
sorting so sources appear first.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 00:00:00 +00:00
gilesb
1ad8fe9890 Fix plan storage path to match get_by_cid lookup
Store plan directly in CACHE_DIR/{cid} instead of CACHE_DIR/legacy/{cid},
which matches what cache_manager.get_by_cid() checks at line 396-398.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 23:50:46 +00:00
gilesb
3e3df6ff2a Code-addressed node IDs and remove JSON index files
- Compiler now generates SHA3-256 hashes for node IDs
- Each hash includes type, config, and input hashes (Merkle tree)
- Same plan = same hashes = automatic cache reuse

Cache changes:
- Remove index.json - filesystem IS the index
- Files at {cache_dir}/{hash}/output.* are source of truth
- Per-node metadata.json for optional stats (not an index)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 22:38:50 +00:00
gilesb
faf794ef35 Use IPFS as universal fallback for content lookup
When content isn't found in local cache, fetch directly from IPFS
using the CID. IPFS is the source of truth for all content-addressed data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 21:20:28 +00:00
gilesb
a4bf0eae24 Add filesystem fallback when artdag Cache lookup fails
The artdag Cache object doesn't persist state across process restarts,
so cache.get(node_id) returns None even when files exist on disk.

Now we check the filesystem directly at {cache_dir}/nodes/{node_id}/output.*
when the in-memory cache lookup fails but we have a valid node_id from
the Redis index.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 21:18:20 +00:00
gilesb
9a1ed2adea Fetch source content from IPFS if not in local cache
When the Celery worker can't find source content in the local cache,
fetch it from IPFS using the CID. This ensures workers can execute
DAGs even when they don't share the same filesystem as the web server.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 21:15:08 +00:00