sibyld 1.0.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.
Files changed (372) hide show
  1. sibyld-1.0.0/.gitignore +103 -0
  2. sibyld-1.0.0/PKG-INFO +228 -0
  3. sibyld-1.0.0/README.md +177 -0
  4. sibyld-1.0.0/pyproject.toml +314 -0
  5. sibyld-1.0.0/src/sibyl/__init__.py +32 -0
  6. sibyld-1.0.0/src/sibyl/ai/__init__.py +1 -0
  7. sibyld-1.0.0/src/sibyl/ai/llm/__init__.py +11 -0
  8. sibyld-1.0.0/src/sibyl/ai/llm/budget.py +219 -0
  9. sibyld-1.0.0/src/sibyl/ai/llm/config_source.py +191 -0
  10. sibyld-1.0.0/src/sibyl/ai/llm/routes.py +344 -0
  11. sibyld-1.0.0/src/sibyl/ai/llm/service.py +26 -0
  12. sibyld-1.0.0/src/sibyl/api/__init__.py +31 -0
  13. sibyld-1.0.0/src/sibyl/api/app.py +338 -0
  14. sibyld-1.0.0/src/sibyl/api/context_audit.py +321 -0
  15. sibyld-1.0.0/src/sibyl/api/decorators.py +95 -0
  16. sibyld-1.0.0/src/sibyl/api/dependencies.py +107 -0
  17. sibyld-1.0.0/src/sibyl/api/errors.py +417 -0
  18. sibyld-1.0.0/src/sibyl/api/event_types.py +32 -0
  19. sibyld-1.0.0/src/sibyl/api/idempotency.py +108 -0
  20. sibyld-1.0.0/src/sibyl/api/pubsub.py +31 -0
  21. sibyld-1.0.0/src/sibyl/api/rate_limit.py +54 -0
  22. sibyld-1.0.0/src/sibyl/api/raw_capture_events.py +45 -0
  23. sibyld-1.0.0/src/sibyl/api/readiness.py +120 -0
  24. sibyld-1.0.0/src/sibyl/api/routes/__init__.py +62 -0
  25. sibyld-1.0.0/src/sibyl/api/routes/admin.py +1152 -0
  26. sibyld-1.0.0/src/sibyl/api/routes/auth.py +1724 -0
  27. sibyld-1.0.0/src/sibyl/api/routes/backups.py +447 -0
  28. sibyld-1.0.0/src/sibyl/api/routes/context.py +336 -0
  29. sibyld-1.0.0/src/sibyl/api/routes/crawler.py +916 -0
  30. sibyld-1.0.0/src/sibyl/api/routes/entities.py +1991 -0
  31. sibyld-1.0.0/src/sibyl/api/routes/epics.py +309 -0
  32. sibyld-1.0.0/src/sibyl/api/routes/graph.py +641 -0
  33. sibyld-1.0.0/src/sibyl/api/routes/ingestion.py +452 -0
  34. sibyld-1.0.0/src/sibyl/api/routes/jobs.py +341 -0
  35. sibyld-1.0.0/src/sibyl/api/routes/logs.py +133 -0
  36. sibyld-1.0.0/src/sibyl/api/routes/memory.py +2764 -0
  37. sibyld-1.0.0/src/sibyl/api/routes/metrics.py +684 -0
  38. sibyld-1.0.0/src/sibyl/api/routes/org_invitations.py +156 -0
  39. sibyld-1.0.0/src/sibyl/api/routes/org_members.py +121 -0
  40. sibyld-1.0.0/src/sibyl/api/routes/orgs.py +181 -0
  41. sibyld-1.0.0/src/sibyl/api/routes/project_members.py +159 -0
  42. sibyld-1.0.0/src/sibyl/api/routes/rag.py +747 -0
  43. sibyld-1.0.0/src/sibyl/api/routes/resolve.py +292 -0
  44. sibyld-1.0.0/src/sibyl/api/routes/search.py +402 -0
  45. sibyld-1.0.0/src/sibyl/api/routes/session.py +279 -0
  46. sibyld-1.0.0/src/sibyl/api/routes/settings.py +347 -0
  47. sibyld-1.0.0/src/sibyl/api/routes/setup.py +402 -0
  48. sibyld-1.0.0/src/sibyl/api/routes/synthesis.py +213 -0
  49. sibyld-1.0.0/src/sibyl/api/routes/tasks.py +1005 -0
  50. sibyld-1.0.0/src/sibyl/api/routes/telemetry.py +63 -0
  51. sibyld-1.0.0/src/sibyl/api/routes/users.py +359 -0
  52. sibyld-1.0.0/src/sibyl/api/schemas/__init__.py +340 -0
  53. sibyld-1.0.0/src/sibyl/api/schemas/admin.py +264 -0
  54. sibyld-1.0.0/src/sibyl/api/schemas/common.py +30 -0
  55. sibyld-1.0.0/src/sibyl/api/schemas/context.py +99 -0
  56. sibyld-1.0.0/src/sibyl/api/schemas/crawler.py +167 -0
  57. sibyld-1.0.0/src/sibyl/api/schemas/entities.py +167 -0
  58. sibyld-1.0.0/src/sibyl/api/schemas/explore.py +67 -0
  59. sibyld-1.0.0/src/sibyl/api/schemas/graph.py +51 -0
  60. sibyld-1.0.0/src/sibyl/api/schemas/ingestion.py +138 -0
  61. sibyld-1.0.0/src/sibyl/api/schemas/memory.py +549 -0
  62. sibyld-1.0.0/src/sibyl/api/schemas/metrics.py +100 -0
  63. sibyld-1.0.0/src/sibyl/api/schemas/rag.py +159 -0
  64. sibyld-1.0.0/src/sibyl/api/schemas/search.py +112 -0
  65. sibyld-1.0.0/src/sibyl/api/schemas/sessions.py +52 -0
  66. sibyld-1.0.0/src/sibyl/api/schemas/synthesis.py +229 -0
  67. sibyld-1.0.0/src/sibyl/api/schemas/temporal.py +51 -0
  68. sibyld-1.0.0/src/sibyl/api/websocket.py +423 -0
  69. sibyld-1.0.0/src/sibyl/auth/__init__.py +56 -0
  70. sibyld-1.0.0/src/sibyl/auth/api_key_common.py +103 -0
  71. sibyld-1.0.0/src/sibyl/auth/authorization.py +276 -0
  72. sibyld-1.0.0/src/sibyl/auth/context.py +5 -0
  73. sibyld-1.0.0/src/sibyl/auth/dependencies.py +271 -0
  74. sibyld-1.0.0/src/sibyl/auth/errors.py +175 -0
  75. sibyld-1.0.0/src/sibyl/auth/http.py +23 -0
  76. sibyld-1.0.0/src/sibyl/auth/jit.py +48 -0
  77. sibyld-1.0.0/src/sibyl/auth/jwt.py +23 -0
  78. sibyld-1.0.0/src/sibyl/auth/locks.py +36 -0
  79. sibyld-1.0.0/src/sibyl/auth/mcp_auth.py +81 -0
  80. sibyld-1.0.0/src/sibyl/auth/mcp_oauth.py +738 -0
  81. sibyld-1.0.0/src/sibyl/auth/middleware.py +35 -0
  82. sibyld-1.0.0/src/sibyl/auth/oauth_state.py +81 -0
  83. sibyld-1.0.0/src/sibyl/auth/oidc.py +295 -0
  84. sibyld-1.0.0/src/sibyl/auth/passwords.py +21 -0
  85. sibyld-1.0.0/src/sibyl/auth/primitives.py +51 -0
  86. sibyld-1.0.0/src/sibyl/auth/rls.py +66 -0
  87. sibyld-1.0.0/src/sibyl/auth/session_cache.py +107 -0
  88. sibyld-1.0.0/src/sibyl/auth/silent_refresh.py +32 -0
  89. sibyld-1.0.0/src/sibyl/backup_ids.py +10 -0
  90. sibyld-1.0.0/src/sibyl/banner.py +50 -0
  91. sibyld-1.0.0/src/sibyl/cache.py +496 -0
  92. sibyld-1.0.0/src/sibyl/cli/__init__.py +15 -0
  93. sibyld-1.0.0/src/sibyl/cli/auth_flow.py +835 -0
  94. sibyld-1.0.0/src/sibyl/cli/bootstrap.py +301 -0
  95. sibyld-1.0.0/src/sibyl/cli/common.py +222 -0
  96. sibyld-1.0.0/src/sibyl/cli/db.py +1610 -0
  97. sibyld-1.0.0/src/sibyl/cli/export.py +307 -0
  98. sibyld-1.0.0/src/sibyl/cli/generate.py +502 -0
  99. sibyld-1.0.0/src/sibyl/cli/main.py +418 -0
  100. sibyld-1.0.0/src/sibyl/cli/migrate.py +2420 -0
  101. sibyld-1.0.0/src/sibyl/cli/up_cmd.py +339 -0
  102. sibyld-1.0.0/src/sibyl/config.py +760 -0
  103. sibyld-1.0.0/src/sibyl/coordination/__init__.py +54 -0
  104. sibyld-1.0.0/src/sibyl/coordination/_local/__init__.py +1 -0
  105. sibyld-1.0.0/src/sibyl/coordination/_local/broker.py +808 -0
  106. sibyld-1.0.0/src/sibyl/coordination/_local/events.py +45 -0
  107. sibyld-1.0.0/src/sibyl/coordination/_local/locks.py +93 -0
  108. sibyld-1.0.0/src/sibyl/coordination/_local/pending.py +115 -0
  109. sibyld-1.0.0/src/sibyl/coordination/_local/scheduler.py +138 -0
  110. sibyld-1.0.0/src/sibyl/coordination/_redis/__init__.py +1 -0
  111. sibyld-1.0.0/src/sibyl/coordination/_redis/broker.py +860 -0
  112. sibyld-1.0.0/src/sibyl/coordination/_redis/events.py +144 -0
  113. sibyld-1.0.0/src/sibyl/coordination/_redis/locks.py +197 -0
  114. sibyld-1.0.0/src/sibyl/coordination/_redis/pending.py +117 -0
  115. sibyld-1.0.0/src/sibyl/coordination/_redis/scheduler.py +16 -0
  116. sibyld-1.0.0/src/sibyl/coordination/broker.py +316 -0
  117. sibyld-1.0.0/src/sibyl/coordination/events.py +49 -0
  118. sibyld-1.0.0/src/sibyl/coordination/locks.py +78 -0
  119. sibyld-1.0.0/src/sibyl/coordination/pending.py +65 -0
  120. sibyld-1.0.0/src/sibyl/coordination/scheduler.py +42 -0
  121. sibyld-1.0.0/src/sibyl/core_runtime_ports.py +306 -0
  122. sibyld-1.0.0/src/sibyl/crawler/__init__.py +106 -0
  123. sibyld-1.0.0/src/sibyl/crawler/chunker.py +589 -0
  124. sibyld-1.0.0/src/sibyl/crawler/discovery.py +305 -0
  125. sibyld-1.0.0/src/sibyl/crawler/embedder.py +294 -0
  126. sibyld-1.0.0/src/sibyl/crawler/graph_integration.py +913 -0
  127. sibyld-1.0.0/src/sibyl/crawler/llms_parser.py +228 -0
  128. sibyld-1.0.0/src/sibyl/crawler/local.py +212 -0
  129. sibyld-1.0.0/src/sibyl/crawler/pipeline.py +615 -0
  130. sibyld-1.0.0/src/sibyl/crawler/service.py +956 -0
  131. sibyld-1.0.0/src/sibyl/crawler/tagger.py +179 -0
  132. sibyld-1.0.0/src/sibyl/crypto.py +149 -0
  133. sibyld-1.0.0/src/sibyl/email/__init__.py +20 -0
  134. sibyld-1.0.0/src/sibyl/email/client.py +239 -0
  135. sibyld-1.0.0/src/sibyl/email/templates.py +248 -0
  136. sibyld-1.0.0/src/sibyl/embedded.py +127 -0
  137. sibyld-1.0.0/src/sibyl/generator/__init__.py +31 -0
  138. sibyld-1.0.0/src/sibyl/generator/base.py +107 -0
  139. sibyld-1.0.0/src/sibyl/generator/config.py +137 -0
  140. sibyld-1.0.0/src/sibyl/generator/llm.py +426 -0
  141. sibyld-1.0.0/src/sibyl/generator/relationships.py +331 -0
  142. sibyld-1.0.0/src/sibyl/generator/scenarios.py +175 -0
  143. sibyld-1.0.0/src/sibyl/generator/stress.py +317 -0
  144. sibyld-1.0.0/src/sibyl/generator/templates.py +528 -0
  145. sibyld-1.0.0/src/sibyl/ingestion/__init__.py +78 -0
  146. sibyld-1.0.0/src/sibyl/ingestion/cataloger.py +465 -0
  147. sibyld-1.0.0/src/sibyl/ingestion/chunker.py +226 -0
  148. sibyld-1.0.0/src/sibyl/ingestion/extractor.py +339 -0
  149. sibyld-1.0.0/src/sibyl/ingestion/parser.py +301 -0
  150. sibyld-1.0.0/src/sibyl/ingestion/pipeline.py +374 -0
  151. sibyld-1.0.0/src/sibyl/ingestion/relationships.py +254 -0
  152. sibyld-1.0.0/src/sibyl/ingestion/storage.py +329 -0
  153. sibyld-1.0.0/src/sibyl/jobs/__init__.py +137 -0
  154. sibyld-1.0.0/src/sibyl/jobs/backup.py +733 -0
  155. sibyld-1.0.0/src/sibyl/jobs/consolidation.py +414 -0
  156. sibyld-1.0.0/src/sibyl/jobs/crawl.py +284 -0
  157. sibyld-1.0.0/src/sibyl/jobs/entities.py +1217 -0
  158. sibyld-1.0.0/src/sibyl/jobs/memory_extraction.py +629 -0
  159. sibyld-1.0.0/src/sibyl/jobs/pending.py +287 -0
  160. sibyld-1.0.0/src/sibyl/jobs/privacy.py +38 -0
  161. sibyld-1.0.0/src/sibyl/jobs/queue.py +358 -0
  162. sibyld-1.0.0/src/sibyl/jobs/raw_changefeed.py +380 -0
  163. sibyld-1.0.0/src/sibyl/jobs/raw_promotion.py +692 -0
  164. sibyld-1.0.0/src/sibyl/jobs/reflection.py +654 -0
  165. sibyld-1.0.0/src/sibyl/jobs/source_imports.py +991 -0
  166. sibyld-1.0.0/src/sibyl/jobs/worker.py +366 -0
  167. sibyld-1.0.0/src/sibyl/locks.py +86 -0
  168. sibyld-1.0.0/src/sibyl/main.py +260 -0
  169. sibyld-1.0.0/src/sibyl/persistence/auth_archive.py +573 -0
  170. sibyld-1.0.0/src/sibyl/persistence/auth_common.py +79 -0
  171. sibyld-1.0.0/src/sibyl/persistence/auth_runtime.py +142 -0
  172. sibyld-1.0.0/src/sibyl/persistence/backups_common.py +133 -0
  173. sibyld-1.0.0/src/sibyl/persistence/backups_runtime.py +29 -0
  174. sibyld-1.0.0/src/sibyl/persistence/content_archive.py +531 -0
  175. sibyld-1.0.0/src/sibyl/persistence/content_common.py +188 -0
  176. sibyld-1.0.0/src/sibyl/persistence/content_runtime.py +109 -0
  177. sibyld-1.0.0/src/sibyl/persistence/graph_runtime.py +1358 -0
  178. sibyld-1.0.0/src/sibyl/persistence/operations_runtime.py +47 -0
  179. sibyld-1.0.0/src/sibyl/persistence/organization_common.py +104 -0
  180. sibyld-1.0.0/src/sibyl/persistence/organization_runtime.py +51 -0
  181. sibyld-1.0.0/src/sibyl/persistence/settings_runtime.py +29 -0
  182. sibyld-1.0.0/src/sibyl/persistence/settings_types.py +19 -0
  183. sibyld-1.0.0/src/sibyl/persistence/setup_common.py +13 -0
  184. sibyld-1.0.0/src/sibyl/persistence/surreal/__init__.py +25 -0
  185. sibyld-1.0.0/src/sibyl/persistence/surreal/auth.py +775 -0
  186. sibyld-1.0.0/src/sibyl/persistence/surreal/auth_runtime/__init__.py +271 -0
  187. sibyld-1.0.0/src/sibyl/persistence/surreal/auth_runtime/_common.py +1190 -0
  188. sibyld-1.0.0/src/sibyl/persistence/surreal/auth_runtime/api_keys.py +391 -0
  189. sibyld-1.0.0/src/sibyl/persistence/surreal/auth_runtime/audit.py +335 -0
  190. sibyld-1.0.0/src/sibyl/persistence/surreal/auth_runtime/device_authorization.py +343 -0
  191. sibyld-1.0.0/src/sibyl/persistence/surreal/auth_runtime/login.py +483 -0
  192. sibyld-1.0.0/src/sibyl/persistence/surreal/auth_runtime/password_reset.py +213 -0
  193. sibyld-1.0.0/src/sibyl/persistence/surreal/auth_runtime/projects.py +910 -0
  194. sibyld-1.0.0/src/sibyl/persistence/surreal/auth_runtime/sessions.py +368 -0
  195. sibyld-1.0.0/src/sibyl/persistence/surreal/auth_runtime/users.py +441 -0
  196. sibyld-1.0.0/src/sibyl/persistence/surreal/backups.py +435 -0
  197. sibyld-1.0.0/src/sibyl/persistence/surreal/content.py +2484 -0
  198. sibyld-1.0.0/src/sibyl/persistence/surreal/organization_runtime.py +2052 -0
  199. sibyld-1.0.0/src/sibyl/persistence/surreal/setup.py +185 -0
  200. sibyld-1.0.0/src/sibyl/persistence/surreal/system_settings.py +108 -0
  201. sibyld-1.0.0/src/sibyl/runtime_services.py +232 -0
  202. sibyld-1.0.0/src/sibyl/server.py +2038 -0
  203. sibyld-1.0.0/src/sibyl/services/__init__.py +8 -0
  204. sibyld-1.0.0/src/sibyl/services/document_adapters.py +783 -0
  205. sibyld-1.0.0/src/sibyl/services/raw_capture_live.py +127 -0
  206. sibyld-1.0.0/src/sibyl/services/recall_limits.py +97 -0
  207. sibyld-1.0.0/src/sibyl/services/settings.py +442 -0
  208. sibyld-1.0.0/src/sibyl/services/surreal_connectivity.py +106 -0
  209. sibyld-1.0.0/src/sibyl/services/telemetry.py +173 -0
  210. sibyld-1.0.0/src/sibyl/services/work_item_workflow.py +327 -0
  211. sibyld-1.0.0/src/sibyl/surreal_runtime_startup.py +149 -0
  212. sibyld-1.0.0/tests/__init__.py +1 -0
  213. sibyld-1.0.0/tests/ai/llm/test_budget.py +175 -0
  214. sibyld-1.0.0/tests/ai/llm/test_config_source.py +113 -0
  215. sibyld-1.0.0/tests/ai/test_llm_settings_api.py +200 -0
  216. sibyld-1.0.0/tests/conftest.py +114 -0
  217. sibyld-1.0.0/tests/evals/__init__.py +9 -0
  218. sibyld-1.0.0/tests/evals/runner.py +36 -0
  219. sibyld-1.0.0/tests/evals/test_metrics.py +306 -0
  220. sibyld-1.0.0/tests/generator/test_llm.py +78 -0
  221. sibyld-1.0.0/tests/harness/__init__.py +90 -0
  222. sibyld-1.0.0/tests/harness/context.py +292 -0
  223. sibyld-1.0.0/tests/harness/helpers.py +326 -0
  224. sibyld-1.0.0/tests/harness/mocks.py +277 -0
  225. sibyld-1.0.0/tests/test_api_app_startup.py +93 -0
  226. sibyld-1.0.0/tests/test_api_entities_create_task_fields.py +135 -0
  227. sibyld-1.0.0/tests/test_api_entities_raw_capture.py +336 -0
  228. sibyld-1.0.0/tests/test_api_raw_captures.py +289 -0
  229. sibyld-1.0.0/tests/test_api_tasks_validation.py +159 -0
  230. sibyld-1.0.0/tests/test_archive_imports.py +35 -0
  231. sibyld-1.0.0/tests/test_auth_api_key_scopes_rest.py +177 -0
  232. sibyld-1.0.0/tests/test_auth_api_keys.py +44 -0
  233. sibyld-1.0.0/tests/test_auth_authorization.py +210 -0
  234. sibyld-1.0.0/tests/test_auth_context.py +13 -0
  235. sibyld-1.0.0/tests/test_auth_cookie_config.py +44 -0
  236. sibyld-1.0.0/tests/test_auth_dependencies.py +375 -0
  237. sibyld-1.0.0/tests/test_auth_errors.py +158 -0
  238. sibyld-1.0.0/tests/test_auth_flow_replay.py +466 -0
  239. sibyld-1.0.0/tests/test_auth_http.py +17 -0
  240. sibyld-1.0.0/tests/test_auth_invitation_token.py +9 -0
  241. sibyld-1.0.0/tests/test_auth_jwt.py +82 -0
  242. sibyld-1.0.0/tests/test_auth_mcp_token_verifier.py +161 -0
  243. sibyld-1.0.0/tests/test_auth_oauth_state.py +35 -0
  244. sibyld-1.0.0/tests/test_auth_passwords.py +44 -0
  245. sibyld-1.0.0/tests/test_auth_rls.py +54 -0
  246. sibyld-1.0.0/tests/test_auth_runtime.py +43 -0
  247. sibyld-1.0.0/tests/test_auth_session_cache.py +65 -0
  248. sibyld-1.0.0/tests/test_auth_settings.py +409 -0
  249. sibyld-1.0.0/tests/test_auth_signup_locks.py +126 -0
  250. sibyld-1.0.0/tests/test_auth_slugify.py +7 -0
  251. sibyld-1.0.0/tests/test_auth_users_sessions_cookie.py +45 -0
  252. sibyld-1.0.0/tests/test_backups_routes.py +270 -0
  253. sibyld-1.0.0/tests/test_cache.py +358 -0
  254. sibyld-1.0.0/tests/test_cli_bootstrap.py +101 -0
  255. sibyld-1.0.0/tests/test_cli_db.py +361 -0
  256. sibyld-1.0.0/tests/test_cli_export.py +203 -0
  257. sibyld-1.0.0/tests/test_cli_generate.py +28 -0
  258. sibyld-1.0.0/tests/test_cli_main.py +244 -0
  259. sibyld-1.0.0/tests/test_cli_migrate.py +1339 -0
  260. sibyld-1.0.0/tests/test_cli_up_cmd.py +204 -0
  261. sibyld-1.0.0/tests/test_communities.py +983 -0
  262. sibyld-1.0.0/tests/test_config_security.py +199 -0
  263. sibyld-1.0.0/tests/test_content_runtime.py +618 -0
  264. sibyld-1.0.0/tests/test_coordination_local.py +789 -0
  265. sibyld-1.0.0/tests/test_coordination_scheduler.py +145 -0
  266. sibyld-1.0.0/tests/test_core_runtime_ports.py +29 -0
  267. sibyld-1.0.0/tests/test_crawler_chunker.py +635 -0
  268. sibyld-1.0.0/tests/test_crawler_embedder.py +99 -0
  269. sibyld-1.0.0/tests/test_crawler_graph_integration.py +803 -0
  270. sibyld-1.0.0/tests/test_crawler_local.py +49 -0
  271. sibyld-1.0.0/tests/test_crawler_pipeline.py +208 -0
  272. sibyld-1.0.0/tests/test_crawler_safe_fetch.py +192 -0
  273. sibyld-1.0.0/tests/test_decorators.py +109 -0
  274. sibyld-1.0.0/tests/test_dedup.py +649 -0
  275. sibyld-1.0.0/tests/test_dependencies.py +187 -0
  276. sibyld-1.0.0/tests/test_device_auth.py +154 -0
  277. sibyld-1.0.0/tests/test_document_adapters.py +206 -0
  278. sibyld-1.0.0/tests/test_e2e_workflows.py +545 -0
  279. sibyld-1.0.0/tests/test_email_client.py +188 -0
  280. sibyld-1.0.0/tests/test_embedded.py +31 -0
  281. sibyld-1.0.0/tests/test_error_envelope.py +138 -0
  282. sibyld-1.0.0/tests/test_error_factories.py +334 -0
  283. sibyld-1.0.0/tests/test_error_sanitization.py +70 -0
  284. sibyld-1.0.0/tests/test_graph_communities_lod.py +285 -0
  285. sibyld-1.0.0/tests/test_graph_runtime.py +169 -0
  286. sibyld-1.0.0/tests/test_harness.py +303 -0
  287. sibyld-1.0.0/tests/test_ingestion_storage.py +74 -0
  288. sibyld-1.0.0/tests/test_integration_graphrag.py +433 -0
  289. sibyld-1.0.0/tests/test_jit_provisioning.py +86 -0
  290. sibyld-1.0.0/tests/test_jobs_backup.py +330 -0
  291. sibyld-1.0.0/tests/test_jobs_consolidation.py +493 -0
  292. sibyld-1.0.0/tests/test_jobs_crawl.py +172 -0
  293. sibyld-1.0.0/tests/test_jobs_entities.py +492 -0
  294. sibyld-1.0.0/tests/test_jobs_memory_extraction.py +442 -0
  295. sibyld-1.0.0/tests/test_jobs_privacy.py +50 -0
  296. sibyld-1.0.0/tests/test_jobs_queue.py +519 -0
  297. sibyld-1.0.0/tests/test_jobs_raw_changefeed.py +316 -0
  298. sibyld-1.0.0/tests/test_jobs_raw_promotion.py +659 -0
  299. sibyld-1.0.0/tests/test_jobs_reflection.py +257 -0
  300. sibyld-1.0.0/tests/test_jobs_source_imports.py +1189 -0
  301. sibyld-1.0.0/tests/test_jobs_worker.py +42 -0
  302. sibyld-1.0.0/tests/test_locks.py +444 -0
  303. sibyld-1.0.0/tests/test_main_startup.py +96 -0
  304. sibyld-1.0.0/tests/test_mcp_oauth_multi_org_selection.py +201 -0
  305. sibyld-1.0.0/tests/test_mcp_oauth_session_refresh.py +238 -0
  306. sibyld-1.0.0/tests/test_metrics.py +1578 -0
  307. sibyld-1.0.0/tests/test_models.py +61 -0
  308. sibyld-1.0.0/tests/test_models_sources.py +284 -0
  309. sibyld-1.0.0/tests/test_models_tasks.py +407 -0
  310. sibyld-1.0.0/tests/test_oidc.py +166 -0
  311. sibyld-1.0.0/tests/test_operations_runtime.py +32 -0
  312. sibyld-1.0.0/tests/test_organization_runtime.py +2216 -0
  313. sibyld-1.0.0/tests/test_pending_registry.py +410 -0
  314. sibyld-1.0.0/tests/test_rag_api.py +733 -0
  315. sibyld-1.0.0/tests/test_rag_org_filtering.py +206 -0
  316. sibyld-1.0.0/tests/test_rate_limiting.py +97 -0
  317. sibyld-1.0.0/tests/test_raw_capture_events.py +50 -0
  318. sibyld-1.0.0/tests/test_raw_capture_live.py +100 -0
  319. sibyld-1.0.0/tests/test_readiness.py +160 -0
  320. sibyld-1.0.0/tests/test_recall_limits.py +98 -0
  321. sibyld-1.0.0/tests/test_retrieval.py +222 -0
  322. sibyld-1.0.0/tests/test_route_access_seams.py +62 -0
  323. sibyld-1.0.0/tests/test_route_ordering.py +79 -0
  324. sibyld-1.0.0/tests/test_routes_admin.py +757 -0
  325. sibyld-1.0.0/tests/test_routes_auth.py +1327 -0
  326. sibyld-1.0.0/tests/test_routes_context.py +1104 -0
  327. sibyld-1.0.0/tests/test_routes_crawler_graph_link.py +50 -0
  328. sibyld-1.0.0/tests/test_routes_crawler_sources.py +190 -0
  329. sibyld-1.0.0/tests/test_routes_crawler_status.py +72 -0
  330. sibyld-1.0.0/tests/test_routes_entities.py +741 -0
  331. sibyld-1.0.0/tests/test_routes_entities_read.py +665 -0
  332. sibyld-1.0.0/tests/test_routes_entities_write.py +650 -0
  333. sibyld-1.0.0/tests/test_routes_epics.py +118 -0
  334. sibyld-1.0.0/tests/test_routes_graph.py +376 -0
  335. sibyld-1.0.0/tests/test_routes_ingestion.py +550 -0
  336. sibyld-1.0.0/tests/test_routes_jobs.py +290 -0
  337. sibyld-1.0.0/tests/test_routes_logs.py +218 -0
  338. sibyld-1.0.0/tests/test_routes_memory.py +2790 -0
  339. sibyld-1.0.0/tests/test_routes_org_invitations.py +170 -0
  340. sibyld-1.0.0/tests/test_routes_org_members.py +207 -0
  341. sibyld-1.0.0/tests/test_routes_orgs.py +196 -0
  342. sibyld-1.0.0/tests/test_routes_project_members.py +229 -0
  343. sibyld-1.0.0/tests/test_routes_resolve.py +197 -0
  344. sibyld-1.0.0/tests/test_routes_search.py +480 -0
  345. sibyld-1.0.0/tests/test_routes_session.py +238 -0
  346. sibyld-1.0.0/tests/test_routes_synthesis.py +315 -0
  347. sibyld-1.0.0/tests/test_routes_tasks.py +561 -0
  348. sibyld-1.0.0/tests/test_server_accessible_projects.py +1275 -0
  349. sibyld-1.0.0/tests/test_settings_api_key_loading.py +172 -0
  350. sibyld-1.0.0/tests/test_settings_routes.py +129 -0
  351. sibyld-1.0.0/tests/test_settings_service.py +157 -0
  352. sibyld-1.0.0/tests/test_setup_routes.py +232 -0
  353. sibyld-1.0.0/tests/test_silent_refresh.py +155 -0
  354. sibyld-1.0.0/tests/test_source_recovery.py +378 -0
  355. sibyld-1.0.0/tests/test_surreal_auth_persistence.py +912 -0
  356. sibyld-1.0.0/tests/test_surreal_auth_runtime.py +3080 -0
  357. sibyld-1.0.0/tests/test_surreal_connectivity.py +139 -0
  358. sibyld-1.0.0/tests/test_surreal_content_debug.py +59 -0
  359. sibyld-1.0.0/tests/test_surreal_content_persistence.py +2364 -0
  360. sibyld-1.0.0/tests/test_surreal_live_runtime.py +525 -0
  361. sibyld-1.0.0/tests/test_surreal_runtime_startup.py +140 -0
  362. sibyld-1.0.0/tests/test_surreal_setup.py +350 -0
  363. sibyld-1.0.0/tests/test_tasks_dependencies.py +991 -0
  364. sibyld-1.0.0/tests/test_tasks_estimation.py +192 -0
  365. sibyld-1.0.0/tests/test_tasks_manager.py +749 -0
  366. sibyld-1.0.0/tests/test_tasks_workflow.py +847 -0
  367. sibyld-1.0.0/tests/test_telemetry_routes.py +228 -0
  368. sibyld-1.0.0/tests/test_tools_core.py +979 -0
  369. sibyld-1.0.0/tests/test_tools_manage.py +994 -0
  370. sibyld-1.0.0/tests/test_users_routes.py +247 -0
  371. sibyld-1.0.0/tests/test_websocket.py +368 -0
  372. sibyld-1.0.0/tests/test_work_item_workflow.py +281 -0
@@ -0,0 +1,103 @@
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
+ !apps/web/src/app/(main)/settings/admin/backups/
89
+ !apps/web/src/app/(main)/settings/admin/backups/page.tsx
90
+ *.sql
91
+ !docs/schemas/*.sql
92
+
93
+ # generated docs
94
+ docs/research/*
95
+ !docs/research/rust-port/
96
+ docs/research/rust-port/*
97
+ !docs/research/rust-port/INVENTORY.md
98
+
99
+ # Local strategy and planning notes (kept on disk, referenced by Sibyl memory)
100
+ docs/architecture/COMPETITIVE_ANALYSIS_*.md
101
+ docs/architecture/DATA_MODEL_*_2026-*.md
102
+ docs/architecture/LAUNCH_AND_MONETIZATION_*
103
+ docs/architecture/SAAS_HOSTING_STRATEGY_*.md
sibyld-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.4
2
+ Name: sibyld
3
+ Version: 1.0.0
4
+ Summary: Sibyl daemon - knowledge graph and task workflow server
5
+ Project-URL: Homepage, https://github.com/hyperb1iss/sibyl
6
+ Project-URL: Repository, https://github.com/hyperb1iss/sibyl
7
+ Project-URL: Issues, https://github.com/hyperb1iss/sibyl/issues
8
+ Author-email: Stefanie Jane <stef@hyperbliss.tech>
9
+ License-Expression: Apache-2.0
10
+ Keywords: developer-tools,graph-rag,knowledge-graph,persistent-memory,semantic-search,task-workflow
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.13
18
+ Requires-Dist: argon2-cffi>=25.1.0
19
+ Requires-Dist: arq>=0.26.3
20
+ Requires-Dist: authlib<1.8,>=1.7.2
21
+ Requires-Dist: email-validator>=2.3.0
22
+ Requires-Dist: fastapi>=0.115.0
23
+ Requires-Dist: google-genai>=2.8.0
24
+ Requires-Dist: greenlet>=3.3.0
25
+ Requires-Dist: itsdangerous<3,>=2.2
26
+ Requires-Dist: mcp>=1.27.2
27
+ Requires-Dist: pyjwt[crypto]<3,>=2.13.0
28
+ Requires-Dist: pyyaml>=6.0
29
+ Requires-Dist: rich>=13.0
30
+ Requires-Dist: sibyl-core[crawler,embeddings,graph,graphrag,llm]==1.0.0
31
+ Requires-Dist: slowapi>=0.1.9
32
+ Requires-Dist: starlette>=1.3.1
33
+ Requires-Dist: surrealdb<3.0,>=2.0.0
34
+ Requires-Dist: tomli-w>=1.2.0
35
+ Requires-Dist: typer>=0.26.7
36
+ Requires-Dist: uvicorn[standard]>=0.38
37
+ Provides-Extra: docs
38
+ Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
39
+ Requires-Dist: mkdocs>=1.6; extra == 'docs'
40
+ Requires-Dist: mkdocstrings[python]>=0.27; extra == 'docs'
41
+ Provides-Extra: generator
42
+ Requires-Dist: anthropic>=0.75; extra == 'generator'
43
+ Provides-Extra: graphrag
44
+ Requires-Dist: networkx>=3.0; extra == 'graphrag'
45
+ Requires-Dist: python-louvain>=0.16; extra == 'graphrag'
46
+ Provides-Extra: graphrag-leiden
47
+ Requires-Dist: igraph>=0.11; extra == 'graphrag-leiden'
48
+ Requires-Dist: leidenalg>=0.10; extra == 'graphrag-leiden'
49
+ Requires-Dist: networkx>=3.0; extra == 'graphrag-leiden'
50
+ Description-Content-Type: text/markdown
51
+
52
+ # Sibyl API Server
53
+
54
+ `sibyld` is the FastAPI + FastMCP server behind Sibyl's knowledge graph, agent memory loop, task
55
+ workflow, search, synthesis, and real-time updates.
56
+
57
+ ## Quick Reference
58
+
59
+ ```bash
60
+ # Install the embedded daemon without the web UI
61
+ curl -fsSL https://raw.githubusercontent.com/hyperb1iss/sibyl/main/install.sh | sh -s -- --daemon
62
+
63
+ # Start server from the monorepo
64
+ moon run api:serve # or: uv run sibyld serve
65
+
66
+ # Start worker (Redis coordination only)
67
+ moon run api:worker # or: uv run sibyld worker
68
+
69
+ # Quality checks
70
+ moon run api:test # Run tests
71
+ moon run api:lint # Lint
72
+ moon run api:typecheck # Type check
73
+ ```
74
+
75
+ ## What's Here
76
+
77
+ - **MCP Server:** eleven tools for search, context packs, exploration, capture, memory, synthesis,
78
+ and management
79
+ - **REST API:** 29 routers covering entities, tasks, projects, memory, synthesis, sources, auth,
80
+ settings, and admin
81
+ - **Auth System:** JWT sessions, GitHub OAuth, API keys with scopes, MCP OAuth clients, RBAC,
82
+ SMTP-backed password reset
83
+ - **Background Jobs:** in-process local runtime or Redis-backed `arq` workers, including the nightly
84
+ reflection dream-cycle
85
+ - **WebSocket:** Real-time updates for entities and tasks
86
+
87
+ ## Architecture
88
+
89
+ ```
90
+ Sibyl API (port 3334)
91
+ ├── /api/* → FastAPI REST endpoints
92
+ ├── /api/openapi.json → OpenAPI schema
93
+ ├── /mcp → MCP server (streamable-http, 11 tools)
94
+ ├── /api/ws → WebSocket for real-time updates
95
+ └── Lifespan → Background jobs + coordination broker
96
+ ```
97
+
98
+ ## Key Directories
99
+
100
+ | Directory | Purpose |
101
+ | --------------- | ------------------------------------------------------------------------------------------------ |
102
+ | `api/routes/` | REST endpoints (29 routers: tasks, entities, memory, synthesis, crawler, ingestion, auth, admin) |
103
+ | `ai/` | DB-backed LLM settings, model validation routes, runtime invalidation |
104
+ | `auth/` | JWT, sessions, API keys, RBAC, MCP OAuth clients |
105
+ | `persistence/` | SurrealDB-native runtimes for auth, content, graph, and backups |
106
+ | `crawler/` | Documentation crawl and ingestion pipeline |
107
+ | `ingestion/` | Source import pipeline (mailbox and other adapters) |
108
+ | `jobs/` | Background jobs (reflection dream-cycle, crawl, backups) |
109
+ | `coordination/` | Local and Redis brokers for jobs, locks, and pub/sub |
110
+ | `email/` | Transactional email delivery |
111
+ | `generator/` | Synthetic test-data generation |
112
+
113
+ ## Configuration
114
+
115
+ **Required:**
116
+
117
+ ```bash
118
+ SIBYL_JWT_SECRET=... # Auth (required in production; dev auto-generates)
119
+ SIBYL_ANTHROPIC_API_KEY=... # Required when LLM provider=anthropic
120
+ # SIBYL_OPENAI_API_KEY=sk-... # Required when LLM provider=openai
121
+ # SIBYL_GEMINI_API_KEY=... # Required when LLM provider=gemini
122
+
123
+ # Embeddings: choose OpenAI or Gemini
124
+ SIBYL_EMBEDDING_PROVIDER=openai # openai | gemini
125
+ SIBYL_OPENAI_API_KEY=sk-... # Required when embedding provider=openai
126
+ # SIBYL_GEMINI_API_KEY=... # Required when embedding provider=gemini
127
+ ```
128
+
129
+ **Optional:**
130
+
131
+ ```bash
132
+ SIBYL_STORE=surreal # default; legacy is migration/source-side only
133
+ SIBYL_COORDINATION_BACKEND=auto # auto | local | redis
134
+ SIBYL_SURREAL_URL=ws://127.0.0.1:8000/rpc
135
+ SIBYL_SURREAL_USERNAME=root
136
+ SIBYL_SURREAL_PASSWORD=root
137
+ SIBYL_REDIS_HOST=127.0.0.1 # only needed for Redis coordination
138
+ SIBYL_REDIS_PORT=6381
139
+ SIBYL_LLM_PROVIDER=anthropic # anthropic | openai
140
+ SIBYL_LLM_MODEL=claude-haiku-4-5
141
+ SIBYL_LLM_CRAWLER_MODEL=claude-haiku-4-5
142
+ SIBYL_LLM_SYNTHESIS_MODEL=claude-sonnet-4-6
143
+ SIBYL_LLM_TEMPERATURE=0
144
+ SIBYL_LLM_TIMEOUT_SECONDS=60
145
+ SIBYL_EMBEDDING_MODEL=text-embedding-3-small
146
+ SIBYL_EMBEDDING_DIMENSIONS=1536
147
+ SIBYL_GRAPH_EMBEDDING_PROVIDER=openai
148
+ SIBYL_GRAPH_EMBEDDING_MODEL=text-embedding-3-small
149
+ SIBYL_GRAPH_EMBEDDING_DIMENSIONS=1024
150
+ ```
151
+
152
+ PostgreSQL settings are only for historical archive rehearsal commands that explicitly restore a
153
+ retained `postgres.sql` payload against an operator-managed database. They are not part of default
154
+ Surreal runtime startup.
155
+
156
+ Gemini keys can also be supplied through `GEMINI_API_KEY` or `GOOGLE_API_KEY`. Changing embedding
157
+ provider, model, or dimensions changes vector spaces; re-crawl sources and rebuild graph indexes
158
+ before mixing old and new search results.
159
+
160
+ LLM settings are instance-wide. Environment variables win over database settings field by field;
161
+ env-backed fields return `409 LOCKED_BY_ENV` on write. Database settings are managed under:
162
+
163
+ ```text
164
+ GET /api/settings/ai/llm
165
+ PUT /api/settings/ai/llm/{surface}
166
+ POST /api/settings/ai/llm/{surface}/test
167
+ POST /api/settings/ai/keys/{provider}/test
168
+ POST /api/settings/ai/models/{model_alias}/test
169
+ GET /api/settings/ai/registry?kind=llm
170
+ ```
171
+
172
+ Crawler extraction and synthesis generation call `sibyl_core.ai` rather than provider SDKs directly.
173
+ Custom model IDs are accepted as database settings with an `unverified_model` warning; validate them
174
+ with the model test endpoint before using them in production flows.
175
+
176
+ ## CLI Commands
177
+
178
+ ```bash
179
+ sibyld serve # Start the HTTP server
180
+ sibyld serve -t stdio # Start a stdio server (MCP subprocess mode)
181
+ sibyld worker # Start the job worker (local mode exits cleanly)
182
+ sibyld up # Start data services + API
183
+ sibyld down # Stop all services
184
+ sibyld db backup # Back up the graph database
185
+ sibyld migrate import ... # Import a migration archive
186
+ sibyld generate realistic # Generate sample data
187
+ ```
188
+
189
+ ## Runtime Modes
190
+
191
+ For single-machine Surreal development, run `sibyld serve` or `sibyld up` with
192
+ `SIBYL_STORE=surreal`. The default `coordination_backend=auto` resolves to `local`, so background
193
+ jobs, pending state, locks, pub/sub, and schedules all stay in-process with no Redis requirement.
194
+
195
+ Redis remains available for distributed or multi-process dev. Set `SIBYL_COORDINATION_BACKEND=redis`
196
+ when you want the `arq` worker model, then run `sibyld worker` or `moon run api:worker` separately.
197
+
198
+ ## Key Patterns
199
+
200
+ **Multi-tenancy:** Every operation requires org context.
201
+
202
+ ```python
203
+ manager = EntityManager(client, group_id=str(org.id))
204
+ ```
205
+
206
+ Write concurrency: the SurrealDB driver serializes WebSocket operations per client. Clone graph
207
+ drivers per organization rather than sharing one driver across org scopes.
208
+
209
+ **SurrealDB access model:** The API server, worker, CLI, and schema bootstrap flows use configured
210
+ SurrealDB system credentials (`SIBYL_SURREAL_USERNAME` / `SIBYL_SURREAL_PASSWORD`) so they can run
211
+ migrations, background jobs, and admin workflows. Route code must keep explicit org, project, and
212
+ principal predicates because system users sit above table-level permissions.
213
+
214
+ Auth and content schema migrations also define table permissions for future scoped Surreal record
215
+ users. Tenant-owned tables accept rows where `organization_id` (or `organizations.uuid`) matches
216
+ either `$token.org` from an external JWT access method or `$auth.organization_id` from a Surreal
217
+ record session. Secret-heavy and global tables, such as API keys, sessions, OAuth tokens, system
218
+ settings, and telemetry rollups, remain `PERMISSIONS NONE` for direct scoped DB access.
219
+
220
+ **Request context:** Auth middleware injects user and org.
221
+
222
+ ```python
223
+ from sibyl.auth.dependencies import get_current_user, get_current_organization
224
+ ```
225
+
226
+ ## Dependencies
227
+
228
+ Depends on `sibyl-core` for models, graph client, AI substrate, and tool implementations.
sibyld-1.0.0/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # Sibyl API Server
2
+
3
+ `sibyld` is the FastAPI + FastMCP server behind Sibyl's knowledge graph, agent memory loop, task
4
+ workflow, search, synthesis, and real-time updates.
5
+
6
+ ## Quick Reference
7
+
8
+ ```bash
9
+ # Install the embedded daemon without the web UI
10
+ curl -fsSL https://raw.githubusercontent.com/hyperb1iss/sibyl/main/install.sh | sh -s -- --daemon
11
+
12
+ # Start server from the monorepo
13
+ moon run api:serve # or: uv run sibyld serve
14
+
15
+ # Start worker (Redis coordination only)
16
+ moon run api:worker # or: uv run sibyld worker
17
+
18
+ # Quality checks
19
+ moon run api:test # Run tests
20
+ moon run api:lint # Lint
21
+ moon run api:typecheck # Type check
22
+ ```
23
+
24
+ ## What's Here
25
+
26
+ - **MCP Server:** eleven tools for search, context packs, exploration, capture, memory, synthesis,
27
+ and management
28
+ - **REST API:** 29 routers covering entities, tasks, projects, memory, synthesis, sources, auth,
29
+ settings, and admin
30
+ - **Auth System:** JWT sessions, GitHub OAuth, API keys with scopes, MCP OAuth clients, RBAC,
31
+ SMTP-backed password reset
32
+ - **Background Jobs:** in-process local runtime or Redis-backed `arq` workers, including the nightly
33
+ reflection dream-cycle
34
+ - **WebSocket:** Real-time updates for entities and tasks
35
+
36
+ ## Architecture
37
+
38
+ ```
39
+ Sibyl API (port 3334)
40
+ ├── /api/* → FastAPI REST endpoints
41
+ ├── /api/openapi.json → OpenAPI schema
42
+ ├── /mcp → MCP server (streamable-http, 11 tools)
43
+ ├── /api/ws → WebSocket for real-time updates
44
+ └── Lifespan → Background jobs + coordination broker
45
+ ```
46
+
47
+ ## Key Directories
48
+
49
+ | Directory | Purpose |
50
+ | --------------- | ------------------------------------------------------------------------------------------------ |
51
+ | `api/routes/` | REST endpoints (29 routers: tasks, entities, memory, synthesis, crawler, ingestion, auth, admin) |
52
+ | `ai/` | DB-backed LLM settings, model validation routes, runtime invalidation |
53
+ | `auth/` | JWT, sessions, API keys, RBAC, MCP OAuth clients |
54
+ | `persistence/` | SurrealDB-native runtimes for auth, content, graph, and backups |
55
+ | `crawler/` | Documentation crawl and ingestion pipeline |
56
+ | `ingestion/` | Source import pipeline (mailbox and other adapters) |
57
+ | `jobs/` | Background jobs (reflection dream-cycle, crawl, backups) |
58
+ | `coordination/` | Local and Redis brokers for jobs, locks, and pub/sub |
59
+ | `email/` | Transactional email delivery |
60
+ | `generator/` | Synthetic test-data generation |
61
+
62
+ ## Configuration
63
+
64
+ **Required:**
65
+
66
+ ```bash
67
+ SIBYL_JWT_SECRET=... # Auth (required in production; dev auto-generates)
68
+ SIBYL_ANTHROPIC_API_KEY=... # Required when LLM provider=anthropic
69
+ # SIBYL_OPENAI_API_KEY=sk-... # Required when LLM provider=openai
70
+ # SIBYL_GEMINI_API_KEY=... # Required when LLM provider=gemini
71
+
72
+ # Embeddings: choose OpenAI or Gemini
73
+ SIBYL_EMBEDDING_PROVIDER=openai # openai | gemini
74
+ SIBYL_OPENAI_API_KEY=sk-... # Required when embedding provider=openai
75
+ # SIBYL_GEMINI_API_KEY=... # Required when embedding provider=gemini
76
+ ```
77
+
78
+ **Optional:**
79
+
80
+ ```bash
81
+ SIBYL_STORE=surreal # default; legacy is migration/source-side only
82
+ SIBYL_COORDINATION_BACKEND=auto # auto | local | redis
83
+ SIBYL_SURREAL_URL=ws://127.0.0.1:8000/rpc
84
+ SIBYL_SURREAL_USERNAME=root
85
+ SIBYL_SURREAL_PASSWORD=root
86
+ SIBYL_REDIS_HOST=127.0.0.1 # only needed for Redis coordination
87
+ SIBYL_REDIS_PORT=6381
88
+ SIBYL_LLM_PROVIDER=anthropic # anthropic | openai
89
+ SIBYL_LLM_MODEL=claude-haiku-4-5
90
+ SIBYL_LLM_CRAWLER_MODEL=claude-haiku-4-5
91
+ SIBYL_LLM_SYNTHESIS_MODEL=claude-sonnet-4-6
92
+ SIBYL_LLM_TEMPERATURE=0
93
+ SIBYL_LLM_TIMEOUT_SECONDS=60
94
+ SIBYL_EMBEDDING_MODEL=text-embedding-3-small
95
+ SIBYL_EMBEDDING_DIMENSIONS=1536
96
+ SIBYL_GRAPH_EMBEDDING_PROVIDER=openai
97
+ SIBYL_GRAPH_EMBEDDING_MODEL=text-embedding-3-small
98
+ SIBYL_GRAPH_EMBEDDING_DIMENSIONS=1024
99
+ ```
100
+
101
+ PostgreSQL settings are only for historical archive rehearsal commands that explicitly restore a
102
+ retained `postgres.sql` payload against an operator-managed database. They are not part of default
103
+ Surreal runtime startup.
104
+
105
+ Gemini keys can also be supplied through `GEMINI_API_KEY` or `GOOGLE_API_KEY`. Changing embedding
106
+ provider, model, or dimensions changes vector spaces; re-crawl sources and rebuild graph indexes
107
+ before mixing old and new search results.
108
+
109
+ LLM settings are instance-wide. Environment variables win over database settings field by field;
110
+ env-backed fields return `409 LOCKED_BY_ENV` on write. Database settings are managed under:
111
+
112
+ ```text
113
+ GET /api/settings/ai/llm
114
+ PUT /api/settings/ai/llm/{surface}
115
+ POST /api/settings/ai/llm/{surface}/test
116
+ POST /api/settings/ai/keys/{provider}/test
117
+ POST /api/settings/ai/models/{model_alias}/test
118
+ GET /api/settings/ai/registry?kind=llm
119
+ ```
120
+
121
+ Crawler extraction and synthesis generation call `sibyl_core.ai` rather than provider SDKs directly.
122
+ Custom model IDs are accepted as database settings with an `unverified_model` warning; validate them
123
+ with the model test endpoint before using them in production flows.
124
+
125
+ ## CLI Commands
126
+
127
+ ```bash
128
+ sibyld serve # Start the HTTP server
129
+ sibyld serve -t stdio # Start a stdio server (MCP subprocess mode)
130
+ sibyld worker # Start the job worker (local mode exits cleanly)
131
+ sibyld up # Start data services + API
132
+ sibyld down # Stop all services
133
+ sibyld db backup # Back up the graph database
134
+ sibyld migrate import ... # Import a migration archive
135
+ sibyld generate realistic # Generate sample data
136
+ ```
137
+
138
+ ## Runtime Modes
139
+
140
+ For single-machine Surreal development, run `sibyld serve` or `sibyld up` with
141
+ `SIBYL_STORE=surreal`. The default `coordination_backend=auto` resolves to `local`, so background
142
+ jobs, pending state, locks, pub/sub, and schedules all stay in-process with no Redis requirement.
143
+
144
+ Redis remains available for distributed or multi-process dev. Set `SIBYL_COORDINATION_BACKEND=redis`
145
+ when you want the `arq` worker model, then run `sibyld worker` or `moon run api:worker` separately.
146
+
147
+ ## Key Patterns
148
+
149
+ **Multi-tenancy:** Every operation requires org context.
150
+
151
+ ```python
152
+ manager = EntityManager(client, group_id=str(org.id))
153
+ ```
154
+
155
+ Write concurrency: the SurrealDB driver serializes WebSocket operations per client. Clone graph
156
+ drivers per organization rather than sharing one driver across org scopes.
157
+
158
+ **SurrealDB access model:** The API server, worker, CLI, and schema bootstrap flows use configured
159
+ SurrealDB system credentials (`SIBYL_SURREAL_USERNAME` / `SIBYL_SURREAL_PASSWORD`) so they can run
160
+ migrations, background jobs, and admin workflows. Route code must keep explicit org, project, and
161
+ principal predicates because system users sit above table-level permissions.
162
+
163
+ Auth and content schema migrations also define table permissions for future scoped Surreal record
164
+ users. Tenant-owned tables accept rows where `organization_id` (or `organizations.uuid`) matches
165
+ either `$token.org` from an external JWT access method or `$auth.organization_id` from a Surreal
166
+ record session. Secret-heavy and global tables, such as API keys, sessions, OAuth tokens, system
167
+ settings, and telemetry rollups, remain `PERMISSIONS NONE` for direct scoped DB access.
168
+
169
+ **Request context:** Auth middleware injects user and org.
170
+
171
+ ```python
172
+ from sibyl.auth.dependencies import get_current_user, get_current_organization
173
+ ```
174
+
175
+ ## Dependencies
176
+
177
+ Depends on `sibyl-core` for models, graph client, AI substrate, and tool implementations.