Skip to main content

Core library for Sibyl - domain models, graph operations, and knowledge retrieval

Project description

sibyl-core

Core library for Sibyl — domain models, graph operations, retrieval algorithms, and tool implementations. Shared foundation for the API server and CLI.

Quick Reference

# Install
uv add sibyl-core

# Development
moon run core:lint        # Ruff check
moon run core:typecheck   # Pyright
moon run core:test        # Pytest

What's Here

  • models/ — Domain entities (Task, Project, Epic, Agent, Source, etc.)
  • graph/ — FalkorDB/Graphiti client, entity management
  • retrieval/ — Hybrid search (semantic + BM25), fusion, deduplication
  • tools/ — MCP tool implementations (search, explore, add, manage)
  • tasks/ — Workflow engine, dependency resolution
  • auth/ — JWT primitives, password hashing

Structure

src/sibyl_core/
├── models/
│   ├── entities.py       # Entity, EntityType, base classes
│   ├── tasks.py          # Task, Project, Epic, Milestone
│   ├── agents.py         # AgentRecord, WorktreeRecord, ApprovalRecord, Checkpoint
│   ├── sources.py        # Source, Document
│   └── responses.py      # API response models
├── graph/
│   ├── client.py         # GraphClient (connection, write lock)
│   ├── entities.py       # EntityManager (CRUD, search)
│   └── relationships.py  # RelationshipManager
├── retrieval/
│   ├── hybrid.py         # Hybrid search orchestration
│   └── fusion.py         # Score fusion (RRF)
├── tools/
│   ├── search.py         # Semantic search
│   ├── explore.py        # Graph navigation
│   ├── add.py            # Entity creation
│   └── manage.py         # Task workflow, admin
└── tasks/
    ├── workflow.py       # State machine, transitions
    └── manager.py        # Task operations

Usage

Models

from sibyl_core.models import (
    Entity, EntityType, Task, TaskStatus, Project, Epic,
    AgentRecord, AgentStatus, WorktreeRecord, ApprovalRecord,
)

task = Task(
    name="Implement OAuth",
    content="Add Google and GitHub OAuth",
    project_id="proj_abc",
    status=TaskStatus.TODO,
)

Agent Models

from sibyl_core.models import (
    AgentRecord, AgentStatus, AgentType,
    WorktreeRecord, WorktreeStatus,
    ApprovalRecord, ApprovalType, ApprovalStatus,
    AgentCheckpoint,
)

# Agent record (persistent state)
agent = AgentRecord(
    name="OAuth Implementation Agent",
    status=AgentStatus.WORKING,
    agent_type=AgentType.IMPLEMENTER,
    task_id="task_abc",
    tokens_used=15000,
    cost_usd=0.45,
)

# Git worktree for isolation
worktree = WorktreeRecord(
    agent_id="agent_xyz",
    path="/worktrees/agent-xyz",
    branch="agent/oauth-impl",
    status=WorktreeStatus.ACTIVE,
)

# Human-in-the-loop approval
approval = ApprovalRecord(
    agent_id="agent_xyz",
    approval_type=ApprovalType.FILE_WRITE,
    summary="Write to config.py",
    status=ApprovalStatus.PENDING,
)

# Session checkpoint for resume
checkpoint = AgentCheckpoint(
    agent_id="agent_xyz",
    session_id="sess_123",
    conversation_summary="Implementing OAuth...",
    current_step="Writing auth module",
)

Graph Client

from sibyl_core.graph import GraphClient, EntityManager

client = await GraphClient.create()
manager = EntityManager(client, group_id=str(org_id))

# CRUD
await manager.create(entity)
entity = await manager.get_by_id("entity_abc")
results = await manager.search("authentication patterns", limit=20)

Write Concurrency

Write concurrency is handled by FalkorDB's BlockingConnectionPool (50 connections, 60s timeout). No application-level locking is required.

# Direct writes are safe - connection pool handles concurrency
await client.execute_write_org(org_id, query, **params)

# Or use EntityManager
await manager.create(entity)

Task Workflow

from sibyl_core.tasks import TaskManager

manager = TaskManager(entity_manager)
await manager.start_task(task_id)
await manager.complete_task(task_id, learnings="Key insight...")
await manager.block_task(task_id, reason="Waiting on API")

Entity Types

Type Description
pattern Reusable coding patterns
episode Temporal learnings
task Work items with workflow
project Container for tasks
epic Feature-level grouping
source Documentation sources
document Crawled content
agent AI agent records
worktree Git worktree isolation
approval Human approval requests
checkpoint Agent session state

Relationship Types

from sibyl_core.models import RelationshipType

# Knowledge
RelationshipType.APPLIES_TO, REQUIRES, CONFLICTS_WITH, SUPERSEDES

# Task
RelationshipType.BELONGS_TO, DEPENDS_ON, BLOCKS, REFERENCES

# Agent
RelationshipType.WORKS_ON, USES_WORKTREE, CHECKPOINTED_AS, REQUESTED_BY

Configuration

SIBYL_OPENAI_API_KEY=sk-...         # Required (embeddings)
SIBYL_FALKORDB_HOST=localhost
SIBYL_FALKORDB_PORT=6380
SIBYL_ANTHROPIC_API_KEY=...         # Optional (agents)

Key Patterns

Multi-tenancy: Every operation requires org context

manager = EntityManager(client, group_id=str(org.id))

Node labels: Graphiti creates Episodic and Entity nodes

WHERE (n:Episodic OR n:Entity) AND n.entity_type = $type

Creation paths: LLM-powered (create) vs direct (create_direct)

await manager.create(entity)         # Slower, richer extraction
await manager.create_direct(entity)  # Faster, no LLM

Testing

# With mock LLM (fast, deterministic)
SIBYL_MOCK_LLM=true uv run pytest tests/

# Live model tests (costs money)
uv run pytest tests/live --live-models

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sibyl_core-0.3.0.tar.gz (227.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sibyl_core-0.3.0-py3-none-any.whl (180.4 kB view details)

Uploaded Python 3

File details

Details for the file sibyl_core-0.3.0.tar.gz.

File metadata

  • Download URL: sibyl_core-0.3.0.tar.gz
  • Upload date:
  • Size: 227.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sibyl_core-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6c12afe8d6e6a81c096bfef60772bff23bbed1a4fc37d6770028b59bd165ad16
MD5 0603b538503179709107214cf2e04a15
BLAKE2b-256 9f044b5dcc76329d7484c767dbed14864df85ced97d0bd6ea8e483098594a7e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sibyl_core-0.3.0.tar.gz:

Publisher: publish.yml on hyperb1iss/sibyl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sibyl_core-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: sibyl_core-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 180.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sibyl_core-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fb0116a75ab4ca15ea01d4c0e686c1a8d6a4e4fa3e6a1212df51dc6740e6d87
MD5 b38a7c0d04da39789f27254768ddc0c6
BLAKE2b-256 9a2f31df5c4418c5f164b4e114d75d3c81f033c624690fb32364eeb43ae4414d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sibyl_core-0.3.0-py3-none-any.whl:

Publisher: publish.yml on hyperb1iss/sibyl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page