Skip to content

feat: task dependency CRUD — create/update deps via CLI and API#2

Merged
hyperb1iss merged 3 commits intohyperb1iss:mainfrom
0pfleet:feat/task-dependency-crud
Apr 14, 2026
Merged

feat: task dependency CRUD — create/update deps via CLI and API#2
hyperb1iss merged 3 commits intohyperb1iss:mainfrom
0pfleet:feat/task-dependency-crud

Conversation

@0pfleet
Copy link
Copy Markdown
Contributor

@0pfleet 0pfleet commented Feb 13, 2026

Summary

Closes the #1 gap identified in the Sibyl audit: users cannot build dependency chains after task creation. The dependency reader (graph traversal, cycle detection, topological sorting via sibyl explore dependencies) was complete, but the writer was missing.

  • PATCH /tasks/{task_id} now accepts add_depends_on / remove_depends_on for post-creation dependency management
  • sibyl task create --depends-on task_aaa,task_bbb wires dependencies at creation time via the dedicated POST /tasks endpoint
  • sibyl task update task_xxx --add-dep task_yyy --remove-dep task_zzz mutates dependencies after creation
  • New RelationshipManager.delete_between() helper for targeted DEPENDS_ON edge removal in a single Cypher query

Motivation

Sibyl had a full dependency reader but an incomplete writer:

  • POST /tasks accepted depends_on at creation, but the CLI never wired it (used generic POST /entities instead)
  • PATCH /tasks had no dependency mutation support at all
  • No way to add/remove dependencies after task creation

What changed

File Change
sibyl_core/graph/relationships.py Add delete_between() — single-query edge deletion between two nodes
sibyl/api/routes/tasks.py Add add_depends_on/remove_depends_on to UpdateTaskRequest, handle in sync + async paths
sibyl/jobs/queue.py Pass dep params through to worker
sibyl/jobs/entities.py Handle dep mutations in async worker job
sibyl_cli/client.py Add create_task() method (dedicated endpoint), add dep params to update_task()
sibyl_cli/task.py Add --depends-on, --add-dep, --remove-dep flags; switch create to POST /tasks

Design decisions

  • CLI create switched from POST /entities to POST /tasks: The generic endpoint queued a worker job that called create_direct() anyway (no LLM extraction for tasks). The dedicated endpoint does the same thing inline, eliminating the worker round-trip and pending state complexity. The --sync flag was removed as it's no longer needed.
  • delete_between() returns count (not bool): Follows the pattern of delete_for_entity() — bulk-style operations return count, scalar operations (delete()) return bool.
  • _build_update_data() extracted as helper: The PATCH handler hit PLR0915 (too many statements) after adding dep handling. Extracting the field mapping keeps it clean.

Test plan

  • ruff check passes on all 3 packages (core, api, cli)
  • ty check — no new type errors (11 pre-existing warnings in unrelated files)
  • pytest sibyl-core — 769 passed
  • pytest api — 1229 passed, 1 failed (pre-existing: test_tools_manage tries live FalkorDB connection)
  • Manual smoke test after install:
    sibyl task create --title "Test dep" --depends-on task_aaa,task_bbb
    sibyl task update task_xxx --add-dep task_yyy
    sibyl task update task_xxx --remove-dep task_yyy
    sibyl explore dependencies task_xxx

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • Added task dependency management: users can now add and remove task dependencies during task creation and updates.
    • New task creation capability with support for assignees, tags, priority, complexity, and dependencies.
    • Extended CLI with new dependency management options (--add-dep, --remove-dep) for streamlined task workflows.

0pfleet and others added 3 commits February 12, 2026 23:13
Adds a targeted relationship deletion method that removes relationships
of a specific type between two entities in a single Cypher query.
Used by the dependency CRUD to remove DEPENDS_ON edges without needing
to fetch-filter-delete.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds add_depends_on/remove_depends_on fields to UpdateTaskRequest,
enabling dependency management after task creation. Both sync and async
(worker) paths handle DEPENDS_ON relationship creation and deletion.

Extracts _build_update_data() helper to stay under PLR0915 statement
limit after adding the new fields.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- create: Add --depends-on flag, switch from generic POST /entities to
  dedicated POST /tasks endpoint (create_direct, no worker queue)
- update: Add --add-dep and --remove-dep flags for post-creation
  dependency management
- client: Add create_task() method, add dep params to update_task()

The create command now uses the task-specific endpoint which handles
BELONGS_TO and DEPENDS_ON relationships synchronously, eliminating the
need for the --sync flag.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 13, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e9bfd845-bdc2-4e81-bcb6-4c6c67a07f82

📥 Commits

Reviewing files that changed from the base of the PR and between bae58ad and f2da371.

📒 Files selected for processing (6)
  • apps/api/src/sibyl/api/routes/tasks.py
  • apps/api/src/sibyl/jobs/entities.py
  • apps/api/src/sibyl/jobs/queue.py
  • apps/cli/src/sibyl_cli/client.py
  • apps/cli/src/sibyl_cli/task.py
  • packages/python/sibyl-core/src/sibyl_core/graph/relationships.py

📝 Walkthrough

Walkthrough

This PR adds task dependency mutation capabilities by extending the API update request with add_depends_on and remove_depends_on fields, refactoring update data construction to centralize field mapping, and implementing corresponding relationship management operations across the job queue, entity handling, and core graph layers.

Changes

Cohort / File(s) Summary
API Route Updates
apps/api/src/sibyl/api/routes/tasks.py
Extended UpdateTaskRequest with add_depends_on and remove_depends_on fields. Refactored field mapping into _build_update_data() helper. Modified update_task to accept dependency mutations in async job arguments and treat dependency-only changes as valid updates.
Job Processing
apps/api/src/sibyl/jobs/entities.py, apps/api/src/sibyl/jobs/queue.py
Extended update_task job and enqueue_update_task to accept and forward add_depends_on and remove_depends_on parameters. Added conditional RelationshipManager creation for dependency mutations. Implemented DEPENDS_ON relationship creation and deletion for each listed dependency. Skip entity update when only dependency changes are present.
CLI Client & Commands
apps/cli/src/sibyl_cli/client.py, apps/cli/src/sibyl_cli/task.py
Added SibylClient.create_task() method to POST new tasks with explicit fields. Extended SibylClient.update_task() to accept add_depends_on and remove_depends_on. Added --add-dep and --remove-dep CLI options to task update command with corresponding validation and response messaging.
Core Graph Operations
packages/python/sibyl-core/src/sibyl_core/graph/relationships.py
Added RelationshipManager.delete_between(source_id, target_id, relationship_type) method to delete specific relationships between two entities with validation and error handling.

Sequence Diagram

sequenceDiagram
    participant Client
    participant API as API Routes
    participant Queue as Job Queue
    participant JobProcessor as Job Processor
    participant EntityMgr as Entity Manager
    participant RelMgr as Relationship Manager
    participant DB as Database

    Client->>API: PATCH /tasks (add_depends_on, remove_depends_on)
    API->>API: Build update payload with dependencies
    API->>Queue: enqueue_update_task(add_depends_on, remove_depends_on)
    Queue->>JobProcessor: pool.enqueue_job(update_task)
    
    JobProcessor->>JobProcessor: Process dependency mutations
    
    alt Has add_depends_on
        JobProcessor->>RelMgr: Create DEPENDS_ON relationships
        RelMgr->>DB: Create DEPENDS_ON for each dependency
        DB-->>RelMgr: Success
    end
    
    alt Has remove_depends_on
        JobProcessor->>RelMgr: delete_between() for each dependency
        RelMgr->>DB: DELETE DEPENDS_ON relationships
        DB-->>RelMgr: Count deleted
    end
    
    alt Has field updates beyond dependencies
        JobProcessor->>EntityMgr: Update task entity fields
        EntityMgr->>DB: Update task attributes
        DB-->>EntityMgr: Success
    end
    
    JobProcessor->>DB: Broadcast websocket update
    DB-->>Client: Task updated
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 hops with glee
Dependencies dance in the rabbit's care,
Add and remove them with elegant flair,
Through layers of jobs they flow so free,
The graph now knows its harmony! 🌿✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hyperb1iss hyperb1iss marked this pull request as ready for review April 14, 2026 16:48
@hyperb1iss hyperb1iss merged commit 84575fb into hyperb1iss:main Apr 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants