sibyl-core 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sibyl_core-0.2.0/.gitignore +89 -0
- sibyl_core-0.2.0/PKG-INFO +250 -0
- sibyl_core-0.2.0/README.md +220 -0
- sibyl_core-0.2.0/pyproject.toml +91 -0
- sibyl_core-0.2.0/src/sibyl_core/__init__.py +46 -0
- sibyl_core-0.2.0/src/sibyl_core/_version.py +85 -0
- sibyl_core-0.2.0/src/sibyl_core/auth/__init__.py +23 -0
- sibyl_core-0.2.0/src/sibyl_core/auth/context.py +33 -0
- sibyl_core-0.2.0/src/sibyl_core/auth/jwt.py +165 -0
- sibyl_core-0.2.0/src/sibyl_core/auth/passwords.py +52 -0
- sibyl_core-0.2.0/src/sibyl_core/config.py +124 -0
- sibyl_core-0.2.0/src/sibyl_core/errors.py +71 -0
- sibyl_core-0.2.0/src/sibyl_core/graph/__init__.py +23 -0
- sibyl_core-0.2.0/src/sibyl_core/graph/batch.py +380 -0
- sibyl_core-0.2.0/src/sibyl_core/graph/client.py +623 -0
- sibyl_core-0.2.0/src/sibyl_core/graph/communities.py +1510 -0
- sibyl_core-0.2.0/src/sibyl_core/graph/entities.py +1890 -0
- sibyl_core-0.2.0/src/sibyl_core/graph/mock_llm.py +120 -0
- sibyl_core-0.2.0/src/sibyl_core/graph/relationships.py +641 -0
- sibyl_core-0.2.0/src/sibyl_core/graph/search_interface.py +241 -0
- sibyl_core-0.2.0/src/sibyl_core/graph/summarize.py +445 -0
- sibyl_core-0.2.0/src/sibyl_core/logging/__init__.py +60 -0
- sibyl_core-0.2.0/src/sibyl_core/logging/colors.py +48 -0
- sibyl_core-0.2.0/src/sibyl_core/logging/config.py +125 -0
- sibyl_core-0.2.0/src/sibyl_core/logging/formatters.py +183 -0
- sibyl_core-0.2.0/src/sibyl_core/models/__init__.py +154 -0
- sibyl_core-0.2.0/src/sibyl_core/models/agents.py +364 -0
- sibyl_core-0.2.0/src/sibyl_core/models/entities.py +223 -0
- sibyl_core-0.2.0/src/sibyl_core/models/projects.py +18 -0
- sibyl_core-0.2.0/src/sibyl_core/models/responses.py +75 -0
- sibyl_core-0.2.0/src/sibyl_core/models/sources.py +187 -0
- sibyl_core-0.2.0/src/sibyl_core/models/tasks.py +411 -0
- sibyl_core-0.2.0/src/sibyl_core/models/tools.py +119 -0
- sibyl_core-0.2.0/src/sibyl_core/retrieval/__init__.py +80 -0
- sibyl_core-0.2.0/src/sibyl_core/retrieval/bm25.py +380 -0
- sibyl_core-0.2.0/src/sibyl_core/retrieval/dedup.py +524 -0
- sibyl_core-0.2.0/src/sibyl_core/retrieval/fusion.py +313 -0
- sibyl_core-0.2.0/src/sibyl_core/retrieval/hybrid.py +395 -0
- sibyl_core-0.2.0/src/sibyl_core/retrieval/reranking.py +414 -0
- sibyl_core-0.2.0/src/sibyl_core/retrieval/temporal.py +252 -0
- sibyl_core-0.2.0/src/sibyl_core/tasks/__init__.py +47 -0
- sibyl_core-0.2.0/src/sibyl_core/tasks/dependencies.py +439 -0
- sibyl_core-0.2.0/src/sibyl_core/tasks/estimation.py +219 -0
- sibyl_core-0.2.0/src/sibyl_core/tasks/manager.py +403 -0
- sibyl_core-0.2.0/src/sibyl_core/tasks/workflow.py +814 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/__init__.py +85 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/add.py +561 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/admin.py +1391 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/conflicts.py +373 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/core.py +67 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/explore.py +598 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/health.py +117 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/helpers.py +485 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/manage.py +1180 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/responses.py +150 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/search.py +488 -0
- sibyl_core-0.2.0/src/sibyl_core/tools/temporal.py +446 -0
- sibyl_core-0.2.0/src/sibyl_core/utils/__init__.py +39 -0
- sibyl_core-0.2.0/src/sibyl_core/utils/metadata.py +210 -0
- sibyl_core-0.2.0/src/sibyl_core/utils/resilience.py +222 -0
- sibyl_core-0.2.0/tests/__init__.py +1 -0
- sibyl_core-0.2.0/tests/conftest.py +1037 -0
- sibyl_core-0.2.0/tests/test_auth.py +759 -0
- sibyl_core-0.2.0/tests/test_conflicts.py +492 -0
- sibyl_core-0.2.0/tests/test_conftest.py +307 -0
- sibyl_core-0.2.0/tests/test_graph_batch.py +477 -0
- sibyl_core-0.2.0/tests/test_graph_client.py +304 -0
- sibyl_core-0.2.0/tests/test_graph_entities.py +1770 -0
- sibyl_core-0.2.0/tests/test_graph_relationships.py +1332 -0
- sibyl_core-0.2.0/tests/test_metadata.py +477 -0
- sibyl_core-0.2.0/tests/test_models.py +73 -0
- sibyl_core-0.2.0/tests/test_reranking.py +387 -0
- sibyl_core-0.2.0/tests/test_retrieval.py +1097 -0
- sibyl_core-0.2.0/tests/test_retrieval_advanced.py +1079 -0
- sibyl_core-0.2.0/tests/test_temporal.py +723 -0
- sibyl_core-0.2.0/tests/test_tools.py +1466 -0
- sibyl_core-0.2.0/tests/test_tools_manage.py +1218 -0
- sibyl_core-0.2.0/tests/test_utils.py +950 -0
- sibyl_core-0.2.0/tests/test_workflow.py +1051 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
/lib/
|
|
14
|
+
/lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.venv/
|
|
25
|
+
venv/
|
|
26
|
+
ENV/
|
|
27
|
+
env/
|
|
28
|
+
|
|
29
|
+
# Node
|
|
30
|
+
node_modules/
|
|
31
|
+
|
|
32
|
+
# VitePress
|
|
33
|
+
docs/.vitepress/cache/
|
|
34
|
+
docs/.vitepress/dist/
|
|
35
|
+
|
|
36
|
+
# IDE
|
|
37
|
+
.idea/
|
|
38
|
+
.vscode/
|
|
39
|
+
*.swp
|
|
40
|
+
*.swo
|
|
41
|
+
*~
|
|
42
|
+
|
|
43
|
+
# Testing
|
|
44
|
+
.coverage
|
|
45
|
+
coverage.xml
|
|
46
|
+
.pytest_cache/
|
|
47
|
+
htmlcov/
|
|
48
|
+
.tox/
|
|
49
|
+
.nox/
|
|
50
|
+
|
|
51
|
+
# MyPy
|
|
52
|
+
.mypy_cache/
|
|
53
|
+
.dmypy.json
|
|
54
|
+
dmypy.json
|
|
55
|
+
|
|
56
|
+
# Ruff
|
|
57
|
+
.ruff_cache/
|
|
58
|
+
|
|
59
|
+
# Environment
|
|
60
|
+
.env
|
|
61
|
+
.env.local
|
|
62
|
+
|
|
63
|
+
# Docker
|
|
64
|
+
falkordb_data/
|
|
65
|
+
|
|
66
|
+
# Kubernetes / Tilt
|
|
67
|
+
infra/local/secrets.yaml
|
|
68
|
+
.tiltbuild/
|
|
69
|
+
tilt_modules/
|
|
70
|
+
|
|
71
|
+
# OS
|
|
72
|
+
.DS_Store
|
|
73
|
+
Thumbs.db
|
|
74
|
+
|
|
75
|
+
# Logs
|
|
76
|
+
*.log
|
|
77
|
+
logs/
|
|
78
|
+
|
|
79
|
+
.serena
|
|
80
|
+
.coverage.*
|
|
81
|
+
|
|
82
|
+
# moon
|
|
83
|
+
.moon/cache
|
|
84
|
+
.moon/docker
|
|
85
|
+
|
|
86
|
+
# Backups and database dumps
|
|
87
|
+
backups/
|
|
88
|
+
*.sql
|
|
89
|
+
!docs/schemas/*.sql
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sibyl-core
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Core library for Sibyl - domain models, graph operations, and knowledge retrieval
|
|
5
|
+
Project-URL: Homepage, https://github.com/hyperb1iss/sibyl
|
|
6
|
+
Project-URL: Repository, https://github.com/hyperb1iss/sibyl
|
|
7
|
+
Author-email: Stefanie Jane <stef@hyperbliss.tech>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
Keywords: ai-agents,collective-intelligence,graph-rag,knowledge-graph
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Typing :: Typed
|
|
16
|
+
Requires-Python: >=3.13
|
|
17
|
+
Requires-Dist: anyio>=4.0
|
|
18
|
+
Requires-Dist: crawl4ai>=0.7.8
|
|
19
|
+
Requires-Dist: graphiti-core[anthropic,falkordb]>=0.24
|
|
20
|
+
Requires-Dist: httpx>=0.27
|
|
21
|
+
Requires-Dist: mistune>=3.0
|
|
22
|
+
Requires-Dist: passlib>=1.7
|
|
23
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
24
|
+
Requires-Dist: pydantic>=2.0
|
|
25
|
+
Requires-Dist: pyjwt>=2.10
|
|
26
|
+
Requires-Dist: python-dotenv>=1.0
|
|
27
|
+
Requires-Dist: python-louvain>=0.16
|
|
28
|
+
Requires-Dist: structlog>=24.0
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# sibyl-core
|
|
32
|
+
|
|
33
|
+
Core library for Sibyl — domain models, graph operations, retrieval algorithms, and tool
|
|
34
|
+
implementations. Shared foundation for the API server and CLI.
|
|
35
|
+
|
|
36
|
+
## Quick Reference
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Install
|
|
40
|
+
uv add sibyl-core
|
|
41
|
+
|
|
42
|
+
# Development
|
|
43
|
+
moon run core:lint # Ruff check
|
|
44
|
+
moon run core:typecheck # Pyright
|
|
45
|
+
moon run core:test # Pytest
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## What's Here
|
|
49
|
+
|
|
50
|
+
- **models/** — Domain entities (Task, Project, Epic, Agent, Source, etc.)
|
|
51
|
+
- **graph/** — FalkorDB/Graphiti client, entity management
|
|
52
|
+
- **retrieval/** — Hybrid search (semantic + BM25), fusion, deduplication
|
|
53
|
+
- **tools/** — MCP tool implementations (search, explore, add, manage)
|
|
54
|
+
- **tasks/** — Workflow engine, dependency resolution
|
|
55
|
+
- **auth/** — JWT primitives, password hashing
|
|
56
|
+
|
|
57
|
+
## Structure
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
src/sibyl_core/
|
|
61
|
+
├── models/
|
|
62
|
+
│ ├── entities.py # Entity, EntityType, base classes
|
|
63
|
+
│ ├── tasks.py # Task, Project, Epic, Milestone
|
|
64
|
+
│ ├── agents.py # AgentRecord, WorktreeRecord, ApprovalRecord, Checkpoint
|
|
65
|
+
│ ├── sources.py # Source, Document
|
|
66
|
+
│ └── responses.py # API response models
|
|
67
|
+
├── graph/
|
|
68
|
+
│ ├── client.py # GraphClient (connection, write lock)
|
|
69
|
+
│ ├── entities.py # EntityManager (CRUD, search)
|
|
70
|
+
│ └── relationships.py # RelationshipManager
|
|
71
|
+
├── retrieval/
|
|
72
|
+
│ ├── hybrid.py # Hybrid search orchestration
|
|
73
|
+
│ └── fusion.py # Score fusion (RRF)
|
|
74
|
+
├── tools/
|
|
75
|
+
│ ├── search.py # Semantic search
|
|
76
|
+
│ ├── explore.py # Graph navigation
|
|
77
|
+
│ ├── add.py # Entity creation
|
|
78
|
+
│ └── manage.py # Task workflow, admin
|
|
79
|
+
└── tasks/
|
|
80
|
+
├── workflow.py # State machine, transitions
|
|
81
|
+
└── manager.py # Task operations
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
### Models
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from sibyl_core.models import (
|
|
90
|
+
Entity, EntityType, Task, TaskStatus, Project, Epic,
|
|
91
|
+
AgentRecord, AgentStatus, WorktreeRecord, ApprovalRecord,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
task = Task(
|
|
95
|
+
name="Implement OAuth",
|
|
96
|
+
content="Add Google and GitHub OAuth",
|
|
97
|
+
project_id="proj_abc",
|
|
98
|
+
status=TaskStatus.TODO,
|
|
99
|
+
)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Agent Models
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from sibyl_core.models import (
|
|
106
|
+
AgentRecord, AgentStatus, AgentType,
|
|
107
|
+
WorktreeRecord, WorktreeStatus,
|
|
108
|
+
ApprovalRecord, ApprovalType, ApprovalStatus,
|
|
109
|
+
AgentCheckpoint,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# Agent record (persistent state)
|
|
113
|
+
agent = AgentRecord(
|
|
114
|
+
name="OAuth Implementation Agent",
|
|
115
|
+
status=AgentStatus.WORKING,
|
|
116
|
+
agent_type=AgentType.IMPLEMENTER,
|
|
117
|
+
task_id="task_abc",
|
|
118
|
+
tokens_used=15000,
|
|
119
|
+
cost_usd=0.45,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# Git worktree for isolation
|
|
123
|
+
worktree = WorktreeRecord(
|
|
124
|
+
agent_id="agent_xyz",
|
|
125
|
+
path="/worktrees/agent-xyz",
|
|
126
|
+
branch="agent/oauth-impl",
|
|
127
|
+
status=WorktreeStatus.ACTIVE,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
# Human-in-the-loop approval
|
|
131
|
+
approval = ApprovalRecord(
|
|
132
|
+
agent_id="agent_xyz",
|
|
133
|
+
approval_type=ApprovalType.FILE_WRITE,
|
|
134
|
+
summary="Write to config.py",
|
|
135
|
+
status=ApprovalStatus.PENDING,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
# Session checkpoint for resume
|
|
139
|
+
checkpoint = AgentCheckpoint(
|
|
140
|
+
agent_id="agent_xyz",
|
|
141
|
+
session_id="sess_123",
|
|
142
|
+
conversation_summary="Implementing OAuth...",
|
|
143
|
+
current_step="Writing auth module",
|
|
144
|
+
)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Graph Client
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from sibyl_core.graph import GraphClient, EntityManager
|
|
151
|
+
|
|
152
|
+
client = await GraphClient.create()
|
|
153
|
+
manager = EntityManager(client, group_id=str(org_id))
|
|
154
|
+
|
|
155
|
+
# CRUD
|
|
156
|
+
await manager.create(entity)
|
|
157
|
+
entity = await manager.get_by_id("entity_abc")
|
|
158
|
+
results = await manager.search("authentication patterns", limit=20)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Write Concurrency
|
|
162
|
+
|
|
163
|
+
All writes use the write lock to prevent FalkorDB corruption:
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
async with client.write_lock:
|
|
167
|
+
await client.execute_write_org(org_id, query, **params)
|
|
168
|
+
|
|
169
|
+
# Or use EntityManager (handles locking internally)
|
|
170
|
+
await manager.create(entity)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Task Workflow
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from sibyl_core.tasks import TaskManager
|
|
177
|
+
|
|
178
|
+
manager = TaskManager(entity_manager)
|
|
179
|
+
await manager.start_task(task_id)
|
|
180
|
+
await manager.complete_task(task_id, learnings="Key insight...")
|
|
181
|
+
await manager.block_task(task_id, reason="Waiting on API")
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Entity Types
|
|
185
|
+
|
|
186
|
+
| Type | Description |
|
|
187
|
+
|------|-------------|
|
|
188
|
+
| `pattern` | Reusable coding patterns |
|
|
189
|
+
| `episode` | Temporal learnings |
|
|
190
|
+
| `task` | Work items with workflow |
|
|
191
|
+
| `project` | Container for tasks |
|
|
192
|
+
| `epic` | Feature-level grouping |
|
|
193
|
+
| `source` | Documentation sources |
|
|
194
|
+
| `document` | Crawled content |
|
|
195
|
+
| `agent` | AI agent records |
|
|
196
|
+
| `worktree` | Git worktree isolation |
|
|
197
|
+
| `approval` | Human approval requests |
|
|
198
|
+
| `checkpoint` | Agent session state |
|
|
199
|
+
|
|
200
|
+
## Relationship Types
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from sibyl_core.models import RelationshipType
|
|
204
|
+
|
|
205
|
+
# Knowledge
|
|
206
|
+
RelationshipType.APPLIES_TO, REQUIRES, CONFLICTS_WITH, SUPERSEDES
|
|
207
|
+
|
|
208
|
+
# Task
|
|
209
|
+
RelationshipType.BELONGS_TO, DEPENDS_ON, BLOCKS, REFERENCES
|
|
210
|
+
|
|
211
|
+
# Agent
|
|
212
|
+
RelationshipType.WORKS_ON, USES_WORKTREE, CHECKPOINTED_AS, REQUESTED_BY
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Configuration
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
SIBYL_OPENAI_API_KEY=sk-... # Required (embeddings)
|
|
219
|
+
SIBYL_FALKORDB_HOST=localhost
|
|
220
|
+
SIBYL_FALKORDB_PORT=6380
|
|
221
|
+
SIBYL_ANTHROPIC_API_KEY=... # Optional (agents)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Key Patterns
|
|
225
|
+
|
|
226
|
+
**Multi-tenancy:** Every operation requires org context
|
|
227
|
+
```python
|
|
228
|
+
manager = EntityManager(client, group_id=str(org.id))
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Node labels:** Graphiti creates `Episodic` and `Entity` nodes
|
|
232
|
+
```cypher
|
|
233
|
+
WHERE (n:Episodic OR n:Entity) AND n.entity_type = $type
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Creation paths:** LLM-powered (`create`) vs direct (`create_direct`)
|
|
237
|
+
```python
|
|
238
|
+
await manager.create(entity) # Slower, richer extraction
|
|
239
|
+
await manager.create_direct(entity) # Faster, no LLM
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Testing
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# With mock LLM (fast, deterministic)
|
|
246
|
+
SIBYL_MOCK_LLM=true uv run pytest tests/
|
|
247
|
+
|
|
248
|
+
# Live model tests (costs money)
|
|
249
|
+
uv run pytest tests/live --live-models
|
|
250
|
+
```
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# sibyl-core
|
|
2
|
+
|
|
3
|
+
Core library for Sibyl — domain models, graph operations, retrieval algorithms, and tool
|
|
4
|
+
implementations. Shared foundation for the API server and CLI.
|
|
5
|
+
|
|
6
|
+
## Quick Reference
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
# Install
|
|
10
|
+
uv add sibyl-core
|
|
11
|
+
|
|
12
|
+
# Development
|
|
13
|
+
moon run core:lint # Ruff check
|
|
14
|
+
moon run core:typecheck # Pyright
|
|
15
|
+
moon run core:test # Pytest
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## What's Here
|
|
19
|
+
|
|
20
|
+
- **models/** — Domain entities (Task, Project, Epic, Agent, Source, etc.)
|
|
21
|
+
- **graph/** — FalkorDB/Graphiti client, entity management
|
|
22
|
+
- **retrieval/** — Hybrid search (semantic + BM25), fusion, deduplication
|
|
23
|
+
- **tools/** — MCP tool implementations (search, explore, add, manage)
|
|
24
|
+
- **tasks/** — Workflow engine, dependency resolution
|
|
25
|
+
- **auth/** — JWT primitives, password hashing
|
|
26
|
+
|
|
27
|
+
## Structure
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
src/sibyl_core/
|
|
31
|
+
├── models/
|
|
32
|
+
│ ├── entities.py # Entity, EntityType, base classes
|
|
33
|
+
│ ├── tasks.py # Task, Project, Epic, Milestone
|
|
34
|
+
│ ├── agents.py # AgentRecord, WorktreeRecord, ApprovalRecord, Checkpoint
|
|
35
|
+
│ ├── sources.py # Source, Document
|
|
36
|
+
│ └── responses.py # API response models
|
|
37
|
+
├── graph/
|
|
38
|
+
│ ├── client.py # GraphClient (connection, write lock)
|
|
39
|
+
│ ├── entities.py # EntityManager (CRUD, search)
|
|
40
|
+
│ └── relationships.py # RelationshipManager
|
|
41
|
+
├── retrieval/
|
|
42
|
+
│ ├── hybrid.py # Hybrid search orchestration
|
|
43
|
+
│ └── fusion.py # Score fusion (RRF)
|
|
44
|
+
├── tools/
|
|
45
|
+
│ ├── search.py # Semantic search
|
|
46
|
+
│ ├── explore.py # Graph navigation
|
|
47
|
+
│ ├── add.py # Entity creation
|
|
48
|
+
│ └── manage.py # Task workflow, admin
|
|
49
|
+
└── tasks/
|
|
50
|
+
├── workflow.py # State machine, transitions
|
|
51
|
+
└── manager.py # Task operations
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
### Models
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from sibyl_core.models import (
|
|
60
|
+
Entity, EntityType, Task, TaskStatus, Project, Epic,
|
|
61
|
+
AgentRecord, AgentStatus, WorktreeRecord, ApprovalRecord,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
task = Task(
|
|
65
|
+
name="Implement OAuth",
|
|
66
|
+
content="Add Google and GitHub OAuth",
|
|
67
|
+
project_id="proj_abc",
|
|
68
|
+
status=TaskStatus.TODO,
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Agent Models
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from sibyl_core.models import (
|
|
76
|
+
AgentRecord, AgentStatus, AgentType,
|
|
77
|
+
WorktreeRecord, WorktreeStatus,
|
|
78
|
+
ApprovalRecord, ApprovalType, ApprovalStatus,
|
|
79
|
+
AgentCheckpoint,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Agent record (persistent state)
|
|
83
|
+
agent = AgentRecord(
|
|
84
|
+
name="OAuth Implementation Agent",
|
|
85
|
+
status=AgentStatus.WORKING,
|
|
86
|
+
agent_type=AgentType.IMPLEMENTER,
|
|
87
|
+
task_id="task_abc",
|
|
88
|
+
tokens_used=15000,
|
|
89
|
+
cost_usd=0.45,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# Git worktree for isolation
|
|
93
|
+
worktree = WorktreeRecord(
|
|
94
|
+
agent_id="agent_xyz",
|
|
95
|
+
path="/worktrees/agent-xyz",
|
|
96
|
+
branch="agent/oauth-impl",
|
|
97
|
+
status=WorktreeStatus.ACTIVE,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Human-in-the-loop approval
|
|
101
|
+
approval = ApprovalRecord(
|
|
102
|
+
agent_id="agent_xyz",
|
|
103
|
+
approval_type=ApprovalType.FILE_WRITE,
|
|
104
|
+
summary="Write to config.py",
|
|
105
|
+
status=ApprovalStatus.PENDING,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Session checkpoint for resume
|
|
109
|
+
checkpoint = AgentCheckpoint(
|
|
110
|
+
agent_id="agent_xyz",
|
|
111
|
+
session_id="sess_123",
|
|
112
|
+
conversation_summary="Implementing OAuth...",
|
|
113
|
+
current_step="Writing auth module",
|
|
114
|
+
)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Graph Client
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from sibyl_core.graph import GraphClient, EntityManager
|
|
121
|
+
|
|
122
|
+
client = await GraphClient.create()
|
|
123
|
+
manager = EntityManager(client, group_id=str(org_id))
|
|
124
|
+
|
|
125
|
+
# CRUD
|
|
126
|
+
await manager.create(entity)
|
|
127
|
+
entity = await manager.get_by_id("entity_abc")
|
|
128
|
+
results = await manager.search("authentication patterns", limit=20)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Write Concurrency
|
|
132
|
+
|
|
133
|
+
All writes use the write lock to prevent FalkorDB corruption:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
async with client.write_lock:
|
|
137
|
+
await client.execute_write_org(org_id, query, **params)
|
|
138
|
+
|
|
139
|
+
# Or use EntityManager (handles locking internally)
|
|
140
|
+
await manager.create(entity)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Task Workflow
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from sibyl_core.tasks import TaskManager
|
|
147
|
+
|
|
148
|
+
manager = TaskManager(entity_manager)
|
|
149
|
+
await manager.start_task(task_id)
|
|
150
|
+
await manager.complete_task(task_id, learnings="Key insight...")
|
|
151
|
+
await manager.block_task(task_id, reason="Waiting on API")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Entity Types
|
|
155
|
+
|
|
156
|
+
| Type | Description |
|
|
157
|
+
|------|-------------|
|
|
158
|
+
| `pattern` | Reusable coding patterns |
|
|
159
|
+
| `episode` | Temporal learnings |
|
|
160
|
+
| `task` | Work items with workflow |
|
|
161
|
+
| `project` | Container for tasks |
|
|
162
|
+
| `epic` | Feature-level grouping |
|
|
163
|
+
| `source` | Documentation sources |
|
|
164
|
+
| `document` | Crawled content |
|
|
165
|
+
| `agent` | AI agent records |
|
|
166
|
+
| `worktree` | Git worktree isolation |
|
|
167
|
+
| `approval` | Human approval requests |
|
|
168
|
+
| `checkpoint` | Agent session state |
|
|
169
|
+
|
|
170
|
+
## Relationship Types
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from sibyl_core.models import RelationshipType
|
|
174
|
+
|
|
175
|
+
# Knowledge
|
|
176
|
+
RelationshipType.APPLIES_TO, REQUIRES, CONFLICTS_WITH, SUPERSEDES
|
|
177
|
+
|
|
178
|
+
# Task
|
|
179
|
+
RelationshipType.BELONGS_TO, DEPENDS_ON, BLOCKS, REFERENCES
|
|
180
|
+
|
|
181
|
+
# Agent
|
|
182
|
+
RelationshipType.WORKS_ON, USES_WORKTREE, CHECKPOINTED_AS, REQUESTED_BY
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Configuration
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
SIBYL_OPENAI_API_KEY=sk-... # Required (embeddings)
|
|
189
|
+
SIBYL_FALKORDB_HOST=localhost
|
|
190
|
+
SIBYL_FALKORDB_PORT=6380
|
|
191
|
+
SIBYL_ANTHROPIC_API_KEY=... # Optional (agents)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Key Patterns
|
|
195
|
+
|
|
196
|
+
**Multi-tenancy:** Every operation requires org context
|
|
197
|
+
```python
|
|
198
|
+
manager = EntityManager(client, group_id=str(org.id))
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Node labels:** Graphiti creates `Episodic` and `Entity` nodes
|
|
202
|
+
```cypher
|
|
203
|
+
WHERE (n:Episodic OR n:Entity) AND n.entity_type = $type
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Creation paths:** LLM-powered (`create`) vs direct (`create_direct`)
|
|
207
|
+
```python
|
|
208
|
+
await manager.create(entity) # Slower, richer extraction
|
|
209
|
+
await manager.create_direct(entity) # Faster, no LLM
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Testing
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# With mock LLM (fast, deterministic)
|
|
216
|
+
SIBYL_MOCK_LLM=true uv run pytest tests/
|
|
217
|
+
|
|
218
|
+
# Live model tests (costs money)
|
|
219
|
+
uv run pytest tests/live --live-models
|
|
220
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# sibyl-core - Shared library for Sibyl knowledge graph operations
|
|
2
|
+
# Domain models, graph client, retrieval, tools, auth primitives
|
|
3
|
+
|
|
4
|
+
[build-system]
|
|
5
|
+
requires = ["hatchling"]
|
|
6
|
+
build-backend = "hatchling.build"
|
|
7
|
+
|
|
8
|
+
[tool.hatch.version]
|
|
9
|
+
path = "../../../VERSION"
|
|
10
|
+
pattern = "(?P<version>.+)"
|
|
11
|
+
|
|
12
|
+
[project]
|
|
13
|
+
name = "sibyl-core"
|
|
14
|
+
dynamic = ["version"]
|
|
15
|
+
description = "Core library for Sibyl - domain models, graph operations, and knowledge retrieval"
|
|
16
|
+
readme = "README.md"
|
|
17
|
+
license = "Apache-2.0"
|
|
18
|
+
requires-python = ">=3.13"
|
|
19
|
+
authors = [{ name = "Stefanie Jane", email = "stef@hyperbliss.tech" }]
|
|
20
|
+
keywords = ["ai-agents", "knowledge-graph", "graph-rag", "collective-intelligence"]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 3 - Alpha",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"License :: OSI Approved :: Apache Software License",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Typing :: Typed",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
dependencies = [
|
|
31
|
+
# Knowledge Graph
|
|
32
|
+
"graphiti-core[falkordb,anthropic]>=0.24",
|
|
33
|
+
# Data & Validation
|
|
34
|
+
"pydantic>=2.0",
|
|
35
|
+
"pydantic-settings>=2.0",
|
|
36
|
+
# Auth primitives (JWT, password hashing)
|
|
37
|
+
"passlib>=1.7",
|
|
38
|
+
"pyjwt>=2.10",
|
|
39
|
+
# Async & HTTP
|
|
40
|
+
"anyio>=4.0",
|
|
41
|
+
"httpx>=0.27",
|
|
42
|
+
# Logging
|
|
43
|
+
"structlog>=24.0",
|
|
44
|
+
# Environment
|
|
45
|
+
"python-dotenv>=1.0",
|
|
46
|
+
# Content processing
|
|
47
|
+
"crawl4ai>=0.7.8",
|
|
48
|
+
"mistune>=3.0",
|
|
49
|
+
# Graph analysis
|
|
50
|
+
"python-louvain>=0.16",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[dependency-groups]
|
|
54
|
+
dev = [
|
|
55
|
+
"pyright",
|
|
56
|
+
"pytest",
|
|
57
|
+
"pytest-asyncio",
|
|
58
|
+
"ruff",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[project.urls]
|
|
62
|
+
Homepage = "https://github.com/hyperb1iss/sibyl"
|
|
63
|
+
Repository = "https://github.com/hyperb1iss/sibyl"
|
|
64
|
+
|
|
65
|
+
[tool.hatch.build.targets.wheel]
|
|
66
|
+
packages = ["src/sibyl_core"]
|
|
67
|
+
|
|
68
|
+
[tool.hatch.build.targets.sdist]
|
|
69
|
+
include = ["/src", "/tests", "/README.md"]
|
|
70
|
+
|
|
71
|
+
[tool.ruff]
|
|
72
|
+
line-length = 100
|
|
73
|
+
src = ["src", "tests"]
|
|
74
|
+
|
|
75
|
+
[tool.ruff.lint]
|
|
76
|
+
select = ["E", "F", "I", "UP", "B", "SIM", "RUF"]
|
|
77
|
+
ignore = ["E501"]
|
|
78
|
+
|
|
79
|
+
[tool.ruff.lint.isort]
|
|
80
|
+
known-first-party = ["sibyl_core"]
|
|
81
|
+
|
|
82
|
+
[tool.pyright]
|
|
83
|
+
include = ["src"]
|
|
84
|
+
pythonVersion = "3.13"
|
|
85
|
+
typeCheckingMode = "standard"
|
|
86
|
+
|
|
87
|
+
# =============================================================================
|
|
88
|
+
# UV Workspace (inherits from root)
|
|
89
|
+
# =============================================================================
|
|
90
|
+
# This package is part of the sibyl-workspace
|
|
91
|
+
# Dependencies on other workspace members use workspace = true
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
sibyl-core: Core library for Sibyl knowledge graph operations.
|
|
3
|
+
|
|
4
|
+
This package provides:
|
|
5
|
+
- Domain models (Entity, Task, Project, etc.)
|
|
6
|
+
- Graph client and entity management (FalkorDB/Graphiti)
|
|
7
|
+
- Hybrid retrieval (semantic + keyword search)
|
|
8
|
+
- Core tools (search, explore, add)
|
|
9
|
+
- Task workflow engine
|
|
10
|
+
- Auth primitives (JWT, password hashing)
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from sibyl_core._version import __version__, get_version
|
|
14
|
+
from sibyl_core.config import CoreConfig, core_config
|
|
15
|
+
from sibyl_core.errors import (
|
|
16
|
+
ConventionsMCPError,
|
|
17
|
+
EntityCreationError,
|
|
18
|
+
EntityNotFoundError,
|
|
19
|
+
GraphConnectionError,
|
|
20
|
+
GraphError,
|
|
21
|
+
IngestionError,
|
|
22
|
+
InvalidTransitionError,
|
|
23
|
+
SearchError,
|
|
24
|
+
SibylError,
|
|
25
|
+
ValidationError,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
# Errors
|
|
30
|
+
"ConventionsMCPError",
|
|
31
|
+
# Config
|
|
32
|
+
"CoreConfig",
|
|
33
|
+
"EntityCreationError",
|
|
34
|
+
"EntityNotFoundError",
|
|
35
|
+
"GraphConnectionError",
|
|
36
|
+
"GraphError",
|
|
37
|
+
"IngestionError",
|
|
38
|
+
"InvalidTransitionError",
|
|
39
|
+
"SearchError",
|
|
40
|
+
"SibylError",
|
|
41
|
+
"ValidationError",
|
|
42
|
+
# Version
|
|
43
|
+
"__version__",
|
|
44
|
+
"core_config",
|
|
45
|
+
"get_version",
|
|
46
|
+
]
|