shellbrain 0.1.29__tar.gz → 0.1.30__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 (519) hide show
  1. shellbrain-0.1.30/PKG-INFO +119 -0
  2. shellbrain-0.1.30/README.md +105 -0
  3. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/__main__.py +1 -1
  4. shellbrain-0.1.29/app/periphery/admin/init_errors.py → shellbrain-0.1.30/app/core/entities/admin_errors.py +1 -1
  5. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/entities/associations.py +22 -13
  6. shellbrain-0.1.30/app/core/entities/backups.py +45 -0
  7. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/entities/episodes.py +28 -0
  8. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/entities/evidence.py +15 -7
  9. shellbrain-0.1.30/app/core/entities/identity.py +69 -0
  10. shellbrain-0.1.30/app/core/entities/ids.py +18 -0
  11. shellbrain-0.1.30/app/core/entities/inner_agents.py +66 -0
  12. shellbrain-0.1.30/app/core/entities/knowledge_builder.py +100 -0
  13. shellbrain-0.1.30/app/core/entities/machine_config.py +83 -0
  14. shellbrain-0.1.30/app/core/entities/memories.py +146 -0
  15. shellbrain-0.1.30/app/core/entities/runtime_context.py +35 -0
  16. shellbrain-0.1.30/app/core/entities/scenarios.py +67 -0
  17. shellbrain-0.1.30/app/core/entities/settings.py +156 -0
  18. {shellbrain-0.1.29/app/core/contracts → shellbrain-0.1.30/app/core}/errors.py +18 -3
  19. shellbrain-0.1.30/app/core/policies/concepts/__init__.py +1 -0
  20. shellbrain-0.1.30/app/core/policies/concepts/relation_rules.py +68 -0
  21. shellbrain-0.1.30/app/core/policies/concepts/search.py +90 -0
  22. shellbrain-0.1.30/app/core/policies/episodes/__init__.py +1 -0
  23. shellbrain-0.1.30/app/core/policies/episodes/event_content.py +18 -0
  24. shellbrain-0.1.30/app/core/policies/episodes/knowledge_building.py +71 -0
  25. shellbrain-0.1.30/app/core/policies/memories/__init__.py +1 -0
  26. shellbrain-0.1.30/app/core/policies/memories/add_plan.py +107 -0
  27. shellbrain-0.1.29/app/periphery/validation/semantic_validation.py → shellbrain-0.1.30/app/core/policies/memories/link_rules.py +54 -11
  28. shellbrain-0.1.30/app/core/policies/memories/update_plan.py +116 -0
  29. shellbrain-0.1.30/app/core/policies/retrieval/__init__.py +0 -0
  30. {shellbrain-0.1.29/app/core/policies/read_policy → shellbrain-0.1.30/app/core/policies/retrieval}/bm25.py +20 -6
  31. shellbrain-0.1.29/app/core/policies/read_policy/context_pack_builder.py → shellbrain-0.1.30/app/core/policies/retrieval/context_pack.py +30 -9
  32. shellbrain-0.1.30/app/core/policies/retrieval/expansion.py +133 -0
  33. {shellbrain-0.1.29/app/core/policies/read_policy → shellbrain-0.1.30/app/core/policies/retrieval}/fusion_rrf.py +18 -8
  34. {shellbrain-0.1.29/app/core/policies/read_policy → shellbrain-0.1.30/app/core/policies/retrieval}/lexical_query.py +3 -1
  35. shellbrain-0.1.30/app/core/policies/retrieval/scoring.py +105 -0
  36. shellbrain-0.1.30/app/core/ports/__init__.py +1 -0
  37. shellbrain-0.1.30/app/core/ports/db/__init__.py +1 -0
  38. shellbrain-0.1.30/app/core/ports/db/concept_repositories.py +89 -0
  39. shellbrain-0.1.30/app/core/ports/db/episode_repositories.py +119 -0
  40. shellbrain-0.1.30/app/core/ports/db/guidance.py +21 -0
  41. shellbrain-0.1.30/app/core/ports/db/knowledge_builder.py +59 -0
  42. shellbrain-0.1.30/app/core/ports/db/memory_repositories.py +94 -0
  43. shellbrain-0.1.30/app/core/ports/db/problem_runs.py +26 -0
  44. shellbrain-0.1.30/app/core/ports/db/retrieval_repositories.py +86 -0
  45. {shellbrain-0.1.29/app/core/interfaces → shellbrain-0.1.30/app/core/ports/db}/unit_of_work.py +14 -8
  46. shellbrain-0.1.30/app/core/ports/embeddings/__init__.py +1 -0
  47. {shellbrain-0.1.29/app/core/interfaces → shellbrain-0.1.30/app/core/ports/embeddings}/retrieval.py +5 -0
  48. shellbrain-0.1.30/app/core/ports/host_apps/__init__.py +2 -0
  49. shellbrain-0.1.30/app/core/ports/host_apps/inner_agents.py +155 -0
  50. shellbrain-0.1.30/app/core/ports/local_state/__init__.py +1 -0
  51. shellbrain-0.1.30/app/core/ports/reporting/__init__.py +1 -0
  52. shellbrain-0.1.30/app/core/ports/reporting/metrics.py +32 -0
  53. shellbrain-0.1.30/app/core/ports/system/__init__.py +1 -0
  54. shellbrain-0.1.30/app/core/use_cases/admin/__init__.py +1 -0
  55. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/core/use_cases}/admin/analytics_diagnostics.py +6 -2
  56. shellbrain-0.1.30/app/core/use_cases/admin/backfill_model_usage/__init__.py +19 -0
  57. shellbrain-0.1.30/app/core/use_cases/admin/backfill_model_usage/backfill_model_usage.py +81 -0
  58. shellbrain-0.1.30/app/core/use_cases/admin/backfill_model_usage/request.py +24 -0
  59. shellbrain-0.1.30/app/core/use_cases/admin/backfill_model_usage/result.py +31 -0
  60. shellbrain-0.1.30/app/core/use_cases/admin/create_backup.py +18 -0
  61. shellbrain-0.1.29/app/periphery/admin/doctor.py → shellbrain-0.1.30/app/core/use_cases/admin/diagnose_runtime.py +116 -85
  62. shellbrain-0.1.29/app/periphery/admin/analytics.py → shellbrain-0.1.30/app/core/use_cases/admin/generate_analytics_report.py +159 -65
  63. shellbrain-0.1.30/app/core/use_cases/admin/initialize_runtime.py +330 -0
  64. shellbrain-0.1.30/app/core/use_cases/admin/restore_backup.py +32 -0
  65. shellbrain-0.1.30/app/core/use_cases/admin/verify_backup.py +21 -0
  66. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/use_cases/build_guidance.py +7 -4
  67. shellbrain-0.1.30/app/core/use_cases/concepts/__init__.py +0 -0
  68. shellbrain-0.1.30/app/core/use_cases/concepts/add/__init__.py +24 -0
  69. shellbrain-0.1.30/app/core/use_cases/concepts/add/execute.py +59 -0
  70. shellbrain-0.1.30/app/core/use_cases/concepts/add/request.py +84 -0
  71. shellbrain-0.1.30/app/core/use_cases/concepts/add/result.py +21 -0
  72. shellbrain-0.1.30/app/core/use_cases/concepts/containment_checks.py +26 -0
  73. shellbrain-0.1.30/app/core/use_cases/concepts/reference_checks.py +111 -0
  74. shellbrain-0.1.30/app/core/use_cases/concepts/show/__init__.py +14 -0
  75. shellbrain-0.1.30/app/core/use_cases/concepts/show/execute.py +30 -0
  76. shellbrain-0.1.30/app/core/use_cases/concepts/show/request.py +34 -0
  77. shellbrain-0.1.30/app/core/use_cases/concepts/show/result.py +20 -0
  78. shellbrain-0.1.30/app/core/use_cases/concepts/update/__init__.py +38 -0
  79. shellbrain-0.1.30/app/core/use_cases/concepts/update/execute.py +357 -0
  80. shellbrain-0.1.30/app/core/use_cases/concepts/update/request.py +304 -0
  81. shellbrain-0.1.30/app/core/use_cases/concepts/update/result.py +21 -0
  82. shellbrain-0.1.30/app/core/use_cases/concepts/views.py +207 -0
  83. shellbrain-0.1.30/app/core/use_cases/episodes/__init__.py +1 -0
  84. shellbrain-0.1.30/app/core/use_cases/episodes/events/__init__.py +5 -0
  85. shellbrain-0.1.30/app/core/use_cases/episodes/events/request.py +41 -0
  86. shellbrain-0.1.30/app/core/use_cases/episodes/sync_discovered_host_session.py +53 -0
  87. shellbrain-0.1.30/app/core/use_cases/episodes/sync_episode/__init__.py +15 -0
  88. shellbrain-0.1.30/app/core/use_cases/episodes/sync_episode/request.py +74 -0
  89. shellbrain-0.1.30/app/core/use_cases/episodes/sync_episode/result.py +35 -0
  90. shellbrain-0.1.30/app/core/use_cases/episodes/sync_episode/sync_episode.py +142 -0
  91. shellbrain-0.1.30/app/core/use_cases/knowledge_builder/__init__.py +1 -0
  92. shellbrain-0.1.30/app/core/use_cases/knowledge_builder/build_knowledge/__init__.py +17 -0
  93. shellbrain-0.1.30/app/core/use_cases/knowledge_builder/build_knowledge/execute.py +282 -0
  94. shellbrain-0.1.30/app/core/use_cases/knowledge_builder/build_knowledge/request.py +30 -0
  95. shellbrain-0.1.30/app/core/use_cases/knowledge_builder/build_knowledge/result.py +61 -0
  96. shellbrain-0.1.30/app/core/use_cases/knowledge_builder/teach_knowledge/__init__.py +19 -0
  97. shellbrain-0.1.30/app/core/use_cases/knowledge_builder/teach_knowledge/execute.py +337 -0
  98. shellbrain-0.1.30/app/core/use_cases/knowledge_builder/teach_knowledge/request.py +47 -0
  99. shellbrain-0.1.30/app/core/use_cases/knowledge_builder/teach_knowledge/result.py +69 -0
  100. shellbrain-0.1.30/app/core/use_cases/memories/__init__.py +0 -0
  101. shellbrain-0.1.30/app/core/use_cases/memories/add/__init__.py +14 -0
  102. shellbrain-0.1.30/app/core/use_cases/memories/add/execute.py +45 -0
  103. shellbrain-0.1.30/app/core/use_cases/memories/add/request.py +133 -0
  104. shellbrain-0.1.30/app/core/use_cases/memories/add/result.py +34 -0
  105. shellbrain-0.1.30/app/core/use_cases/memories/effect_plan.py +122 -0
  106. shellbrain-0.1.29/app/periphery/validation/integrity_validation.py → shellbrain-0.1.30/app/core/use_cases/memories/reference_checks.py +93 -67
  107. shellbrain-0.1.30/app/core/use_cases/memories/update/__init__.py +26 -0
  108. shellbrain-0.1.30/app/core/use_cases/memories/update/execute.py +90 -0
  109. shellbrain-0.1.30/app/core/use_cases/memories/update/request.py +135 -0
  110. shellbrain-0.1.30/app/core/use_cases/memories/update/result.py +61 -0
  111. shellbrain-0.1.30/app/core/use_cases/metrics/__init__.py +1 -0
  112. shellbrain-0.1.29/app/periphery/admin/agent_behavior_analysis.py → shellbrain-0.1.30/app/core/use_cases/metrics/analyze_agent_behavior.py +133 -155
  113. shellbrain-0.1.29/app/periphery/metrics/service.py → shellbrain-0.1.30/app/core/use_cases/metrics/build_snapshot.py +111 -48
  114. shellbrain-0.1.30/app/core/use_cases/metrics/generate_dashboard.py +82 -0
  115. shellbrain-0.1.30/app/core/use_cases/plan_execution.py +167 -0
  116. shellbrain-0.1.30/app/core/use_cases/retrieval/__init__.py +0 -0
  117. shellbrain-0.1.30/app/core/use_cases/retrieval/build_context/__init__.py +13 -0
  118. shellbrain-0.1.30/app/core/use_cases/retrieval/build_context/execute.py +783 -0
  119. shellbrain-0.1.30/app/core/use_cases/retrieval/context_pack_pipeline.py +121 -0
  120. {shellbrain-0.1.29/app/core/policies/read_policy → shellbrain-0.1.30/app/core/use_cases/retrieval}/expansion.py +51 -19
  121. shellbrain-0.1.30/app/core/use_cases/retrieval/read/__init__.py +29 -0
  122. shellbrain-0.1.30/app/core/use_cases/retrieval/read/execute.py +53 -0
  123. shellbrain-0.1.30/app/core/use_cases/retrieval/read/request.py +114 -0
  124. shellbrain-0.1.30/app/core/use_cases/retrieval/read/result.py +20 -0
  125. {shellbrain-0.1.29/app/core/use_cases → shellbrain-0.1.30/app/core/use_cases/retrieval}/read_concepts.py +162 -32
  126. shellbrain-0.1.30/app/core/use_cases/retrieval/recall/__init__.py +22 -0
  127. shellbrain-0.1.30/app/core/use_cases/retrieval/recall/execute.py +41 -0
  128. shellbrain-0.1.30/app/core/use_cases/retrieval/recall/request.py +58 -0
  129. shellbrain-0.1.30/app/core/use_cases/retrieval/recall/result.py +29 -0
  130. shellbrain-0.1.30/app/core/use_cases/retrieval/seed_retrieval.py +120 -0
  131. shellbrain-0.1.30/app/core/use_cases/scenarios/__init__.py +1 -0
  132. shellbrain-0.1.30/app/core/use_cases/scenarios/record/__init__.py +15 -0
  133. shellbrain-0.1.30/app/core/use_cases/scenarios/record/execute.py +248 -0
  134. shellbrain-0.1.30/app/core/use_cases/scenarios/record/request.py +46 -0
  135. shellbrain-0.1.30/app/core/use_cases/scenarios/record/result.py +29 -0
  136. shellbrain-0.1.30/app/entrypoints/__init__.py +1 -0
  137. shellbrain-0.1.30/app/entrypoints/cli/__init__.py +1 -0
  138. shellbrain-0.1.30/app/entrypoints/cli/error_responses.py +10 -0
  139. shellbrain-0.1.30/app/entrypoints/cli/handlers/__init__.py +0 -0
  140. shellbrain-0.1.30/app/entrypoints/cli/handlers/cli_operation.py +86 -0
  141. shellbrain-0.1.30/app/entrypoints/cli/handlers/dependencies.py +93 -0
  142. shellbrain-0.1.30/app/entrypoints/cli/handlers/human/__init__.py +0 -0
  143. shellbrain-0.1.30/app/entrypoints/cli/handlers/human/admin.py +143 -0
  144. shellbrain-0.1.30/app/entrypoints/cli/handlers/human/admin_dependencies.py +34 -0
  145. shellbrain-0.1.30/app/entrypoints/cli/handlers/human/init.py +43 -0
  146. shellbrain-0.1.30/app/entrypoints/cli/handlers/human/metrics.py +38 -0
  147. shellbrain-0.1.30/app/entrypoints/cli/handlers/human/upgrade.py +11 -0
  148. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/__init__.py +0 -0
  149. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/concepts/__init__.py +0 -0
  150. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/concepts/add.py +89 -0
  151. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/concepts/show.py +85 -0
  152. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/concepts/update.py +91 -0
  153. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/episodes/__init__.py +0 -0
  154. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/episodes/events.py +295 -0
  155. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/episodes/selection.py +106 -0
  156. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/episodes/serialization.py +25 -0
  157. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/memories/__init__.py +0 -0
  158. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/memories/add.py +155 -0
  159. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/memories/update.py +151 -0
  160. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/memories/utility_vote_evidence.py +98 -0
  161. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/retrieval/__init__.py +0 -0
  162. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/retrieval/execution.py +44 -0
  163. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/retrieval/read.py +95 -0
  164. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/scenarios/__init__.py +1 -0
  165. shellbrain-0.1.30/app/entrypoints/cli/handlers/internal_agent/scenarios/record.py +96 -0
  166. shellbrain-0.1.30/app/entrypoints/cli/handlers/result_envelopes.py +105 -0
  167. shellbrain-0.1.29/app/core/use_cases/manage_session_state.py → shellbrain-0.1.30/app/entrypoints/cli/handlers/session_state.py +24 -13
  168. shellbrain-0.1.30/app/entrypoints/cli/handlers/working_agent/__init__.py +0 -0
  169. shellbrain-0.1.30/app/entrypoints/cli/handlers/working_agent/recall.py +101 -0
  170. shellbrain-0.1.30/app/entrypoints/cli/handlers/working_agent/teach.py +143 -0
  171. shellbrain-0.1.30/app/entrypoints/cli/main.py +19 -0
  172. shellbrain-0.1.30/app/entrypoints/cli/operation_command.py +43 -0
  173. shellbrain-0.1.30/app/entrypoints/cli/parser/__init__.py +5 -0
  174. shellbrain-0.1.30/app/entrypoints/cli/parser/builder.py +797 -0
  175. shellbrain-0.1.30/app/entrypoints/cli/presenters/__init__.py +1 -0
  176. shellbrain-0.1.30/app/entrypoints/cli/presenters/init.py +50 -0
  177. shellbrain-0.1.30/app/entrypoints/cli/presenters/metrics.py +26 -0
  178. shellbrain-0.1.30/app/entrypoints/cli/request_parsing/__init__.py +1 -0
  179. shellbrain-0.1.30/app/entrypoints/cli/request_parsing/concepts.py +68 -0
  180. shellbrain-0.1.30/app/entrypoints/cli/request_parsing/episodes.py +36 -0
  181. shellbrain-0.1.30/app/entrypoints/cli/request_parsing/hydration.py +121 -0
  182. shellbrain-0.1.30/app/entrypoints/cli/request_parsing/memories.py +81 -0
  183. shellbrain-0.1.30/app/entrypoints/cli/request_parsing/payload_validation.py +440 -0
  184. shellbrain-0.1.30/app/entrypoints/cli/request_parsing/prepared.py +30 -0
  185. shellbrain-0.1.30/app/entrypoints/cli/request_parsing/retrieval.py +84 -0
  186. shellbrain-0.1.30/app/entrypoints/cli/request_parsing/scenarios.py +38 -0
  187. shellbrain-0.1.30/app/entrypoints/cli/request_parsing/teach.py +32 -0
  188. shellbrain-0.1.30/app/entrypoints/cli/runner.py +426 -0
  189. shellbrain-0.1.30/app/entrypoints/cli/runtime.py +33 -0
  190. shellbrain-0.1.30/app/entrypoints/host_hooks/__init__.py +1 -0
  191. shellbrain-0.1.30/app/entrypoints/host_hooks/claude_session_start.py +11 -0
  192. shellbrain-0.1.30/app/entrypoints/host_hooks/cursor_statusline.py +9 -0
  193. shellbrain-0.1.30/app/entrypoints/jobs/__init__.py +1 -0
  194. shellbrain-0.1.30/app/entrypoints/jobs/episode_sync.py +24 -0
  195. shellbrain-0.1.30/app/infrastructure/db/__init__.py +1 -0
  196. shellbrain-0.1.30/app/infrastructure/db/admin/__init__.py +1 -0
  197. shellbrain-0.1.30/app/infrastructure/db/admin/app_role_safety.py +32 -0
  198. shellbrain-0.1.30/app/infrastructure/db/admin/backups/__init__.py +1 -0
  199. {shellbrain-0.1.29/app/periphery/admin → shellbrain-0.1.30/app/infrastructure/db/admin/backups}/destructive_guard.py +5 -1
  200. shellbrain-0.1.29/app/periphery/admin/backup.py → shellbrain-0.1.30/app/infrastructure/db/admin/backups/logical_backup.py +45 -41
  201. shellbrain-0.1.30/app/infrastructure/db/admin/backups/manifest_store.py +39 -0
  202. {shellbrain-0.1.29/app/periphery/admin → shellbrain-0.1.30/app/infrastructure/db/admin/backups}/restore.py +4 -1
  203. shellbrain-0.1.30/app/infrastructure/db/admin/connection.py +59 -0
  204. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/db}/admin/instance_guard.py +12 -4
  205. shellbrain-0.1.30/app/infrastructure/db/admin/migrations.py +96 -0
  206. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/db}/admin/privileges.py +5 -3
  207. shellbrain-0.1.30/app/infrastructure/db/admin/provisioning/__init__.py +1 -0
  208. shellbrain-0.1.30/app/infrastructure/db/admin/provisioning/docker_prerequisites.py +37 -0
  209. shellbrain-0.1.29/app/periphery/admin/external_runtime.py → shellbrain-0.1.30/app/infrastructure/db/admin/provisioning/external_postgres.py +35 -16
  210. shellbrain-0.1.30/app/infrastructure/db/admin/provisioning/init_effects.py +20 -0
  211. shellbrain-0.1.29/app/periphery/admin/managed_runtime.py → shellbrain-0.1.30/app/infrastructure/db/admin/provisioning/managed_local.py +61 -25
  212. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/db}/admin/storage_setup.py +22 -8
  213. shellbrain-0.1.30/app/infrastructure/db/runtime/__init__.py +1 -0
  214. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/models/associations.py +61 -11
  215. shellbrain-0.1.30/app/infrastructure/db/runtime/models/concepts.py +505 -0
  216. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/models/episodes.py +53 -10
  217. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/models/evidence.py +4 -2
  218. shellbrain-0.1.30/app/infrastructure/db/runtime/models/experiences.py +88 -0
  219. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/models/instance_metadata.py +1 -1
  220. shellbrain-0.1.30/app/infrastructure/db/runtime/models/knowledge_builder.py +127 -0
  221. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/models/memories.py +46 -5
  222. shellbrain-0.1.30/app/infrastructure/db/runtime/models/problem_runs.py +106 -0
  223. shellbrain-0.1.30/app/infrastructure/db/runtime/models/registry.py +33 -0
  224. shellbrain-0.1.30/app/infrastructure/db/runtime/models/telemetry.py +500 -0
  225. shellbrain-0.1.30/app/infrastructure/db/runtime/models/utility.py +48 -0
  226. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/models/views.py +257 -15
  227. shellbrain-0.1.30/app/infrastructure/db/runtime/queries/__init__.py +1 -0
  228. shellbrain-0.1.30/app/infrastructure/db/runtime/queries/agent_behavior.py +163 -0
  229. shellbrain-0.1.29/app/periphery/admin/analytics_queries.py → shellbrain-0.1.30/app/infrastructure/db/runtime/queries/analytics.py +12 -4
  230. shellbrain-0.1.29/app/periphery/metrics/queries.py → shellbrain-0.1.30/app/infrastructure/db/runtime/queries/metrics.py +10 -6
  231. shellbrain-0.1.30/app/infrastructure/db/runtime/queries/metrics_adapter.py +54 -0
  232. shellbrain-0.1.30/app/infrastructure/db/runtime/queries/model_usage_backfill.py +43 -0
  233. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/repos/relational/associations_repo.py +13 -4
  234. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/repos/relational/concepts_repo.py +142 -142
  235. shellbrain-0.1.30/app/infrastructure/db/runtime/repos/relational/episodes_repo.py +481 -0
  236. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/repos/relational/evidence_repo.py +31 -6
  237. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/repos/relational/experiences_repo.py +2 -2
  238. shellbrain-0.1.30/app/infrastructure/db/runtime/repos/relational/knowledge_builder_repo.py +205 -0
  239. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/repos/relational/memories_repo.py +24 -12
  240. shellbrain-0.1.30/app/infrastructure/db/runtime/repos/relational/problem_runs_repo.py +96 -0
  241. shellbrain-0.1.30/app/infrastructure/db/runtime/repos/relational/read_policy_repo.py +225 -0
  242. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/repos/relational/telemetry_repo.py +112 -29
  243. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/repos/relational/utility_repo.py +2 -2
  244. shellbrain-0.1.30/app/infrastructure/db/runtime/repos/semantic/keyword_retrieval_repo.py +151 -0
  245. shellbrain-0.1.30/app/infrastructure/db/runtime/repos/semantic/semantic_retrieval_repo.py +307 -0
  246. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/uow.py +29 -14
  247. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure}/embeddings/local_provider.py +5 -2
  248. shellbrain-0.1.30/app/infrastructure/embeddings/prewarm.py +98 -0
  249. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure}/embeddings/query_vector_search.py +10 -3
  250. shellbrain-0.1.30/app/infrastructure/host_apps/__init__.py +1 -0
  251. shellbrain-0.1.30/app/infrastructure/host_apps/assets/__init__.py +15 -0
  252. shellbrain-0.1.30/app/infrastructure/host_apps/assets/claude.py +110 -0
  253. shellbrain-0.1.30/app/infrastructure/host_apps/assets/codex.py +87 -0
  254. shellbrain-0.1.30/app/infrastructure/host_apps/assets/cursor.py +77 -0
  255. shellbrain-0.1.30/app/infrastructure/host_apps/assets/cursor_statusline_config.py +148 -0
  256. shellbrain-0.1.30/app/infrastructure/host_apps/assets/inspection.py +25 -0
  257. shellbrain-0.1.30/app/infrastructure/host_apps/assets/managed_markdown.py +150 -0
  258. shellbrain-0.1.30/app/infrastructure/host_apps/assets/managed_tree.py +105 -0
  259. shellbrain-0.1.30/app/infrastructure/host_apps/assets/packaged_assets.py +17 -0
  260. shellbrain-0.1.30/app/infrastructure/host_apps/assets/paths.py +30 -0
  261. shellbrain-0.1.30/app/infrastructure/host_apps/assets/service.py +60 -0
  262. shellbrain-0.1.30/app/infrastructure/host_apps/assets/types.py +25 -0
  263. shellbrain-0.1.30/app/infrastructure/host_apps/identity/__init__.py +1 -0
  264. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/host_apps}/identity/claude_hook_install.py +45 -15
  265. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/host_apps}/identity/claude_runtime.py +5 -1
  266. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/host_apps}/identity/codex_runtime.py +4 -2
  267. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/host_apps}/identity/compatibility.py +1 -2
  268. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/host_apps}/identity/cursor_statusline.py +39 -12
  269. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/host_apps}/identity/resolver.py +60 -13
  270. shellbrain-0.1.30/app/infrastructure/host_apps/inner_agents/__init__.py +2 -0
  271. shellbrain-0.1.30/app/infrastructure/host_apps/inner_agents/codex_cli.py +497 -0
  272. shellbrain-0.1.30/app/infrastructure/host_apps/inner_agents/output_parser.py +136 -0
  273. shellbrain-0.1.30/app/infrastructure/host_apps/inner_agents/prompt.py +972 -0
  274. shellbrain-0.1.30/app/infrastructure/host_apps/transcripts/__init__.py +1 -0
  275. {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.30/app/infrastructure/host_apps/transcripts}/claude_code.py +50 -29
  276. {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.30/app/infrastructure/host_apps/transcripts}/codex.py +62 -28
  277. {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.30/app/infrastructure/host_apps/transcripts}/cursor.py +108 -37
  278. {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.30/app/infrastructure/host_apps/transcripts}/model_usage.py +57 -19
  279. {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.30/app/infrastructure/host_apps/transcripts}/normalization.py +5 -3
  280. {shellbrain-0.1.29/app/periphery/telemetry → shellbrain-0.1.30/app/infrastructure/host_apps/transcripts}/session_selection.py +20 -21
  281. {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.30/app/infrastructure/host_apps/transcripts}/source_discovery.py +20 -11
  282. {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.30/app/infrastructure/host_apps/transcripts}/tool_filter.py +26 -8
  283. shellbrain-0.1.30/app/infrastructure/local_state/__init__.py +1 -0
  284. shellbrain-0.1.30/app/infrastructure/local_state/init_lock.py +114 -0
  285. shellbrain-0.1.29/app/periphery/admin/machine_state.py → shellbrain-0.1.30/app/infrastructure/local_state/machine_config_store.py +27 -86
  286. shellbrain-0.1.30/app/infrastructure/local_state/operation_registration.py +44 -0
  287. shellbrain-0.1.29/app/periphery/admin/repo_state.py → shellbrain-0.1.30/app/infrastructure/local_state/repo_registration_store.py +15 -5
  288. shellbrain-0.1.30/app/infrastructure/local_state/session_state_file_store.py +201 -0
  289. shellbrain-0.1.30/app/infrastructure/process/__init__.py +0 -0
  290. shellbrain-0.1.30/app/infrastructure/process/episode_sync/__init__.py +1 -0
  291. shellbrain-0.1.30/app/infrastructure/process/episode_sync/autostart.py +17 -0
  292. {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.30/app/infrastructure/process/episode_sync}/launcher.py +7 -5
  293. shellbrain-0.1.29/app/periphery/episodes/poller_lock.py → shellbrain-0.1.30/app/infrastructure/process/episode_sync/lock_file.py +73 -19
  294. shellbrain-0.1.30/app/infrastructure/process/episode_sync/poller.py +409 -0
  295. shellbrain-0.1.30/app/infrastructure/process/episode_sync/status_store.py +35 -0
  296. shellbrain-0.1.30/app/infrastructure/reporting/__init__.py +1 -0
  297. shellbrain-0.1.30/app/infrastructure/reporting/metrics/__init__.py +1 -0
  298. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/reporting}/metrics/artifacts.py +7 -3
  299. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/reporting}/metrics/pager.py +31 -7
  300. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/reporting}/metrics/render_html.py +44 -18
  301. shellbrain-0.1.30/app/infrastructure/system/__init__.py +1 -0
  302. shellbrain-0.1.30/app/infrastructure/system/clock.py +16 -0
  303. shellbrain-0.1.30/app/infrastructure/system/id_generator.py +16 -0
  304. shellbrain-0.1.29/app/periphery/admin/upgrade.py → shellbrain-0.1.30/app/infrastructure/system/package_upgrade.py +8 -2
  305. shellbrain-0.1.30/app/infrastructure/telemetry/__init__.py +0 -0
  306. shellbrain-0.1.30/app/infrastructure/telemetry/inner_agent_records.py +78 -0
  307. shellbrain-0.1.30/app/infrastructure/telemetry/operation_invocations.py +125 -0
  308. shellbrain-0.1.30/app/infrastructure/telemetry/operation_polling.py +19 -0
  309. shellbrain-0.1.30/app/infrastructure/telemetry/read_records.py +179 -0
  310. shellbrain-0.1.30/app/infrastructure/telemetry/recall_records.py +94 -0
  311. shellbrain-0.1.30/app/infrastructure/telemetry/recorder.py +68 -0
  312. shellbrain-0.1.29/app/core/entities/telemetry.py → shellbrain-0.1.30/app/infrastructure/telemetry/records.py +59 -15
  313. shellbrain-0.1.30/app/infrastructure/telemetry/sink.py +210 -0
  314. shellbrain-0.1.30/app/infrastructure/telemetry/storage_protocols.py +63 -0
  315. shellbrain-0.1.29/app/periphery/telemetry/sync_summary.py → shellbrain-0.1.30/app/infrastructure/telemetry/sync_records.py +7 -3
  316. shellbrain-0.1.30/app/infrastructure/telemetry/write_records.py +234 -0
  317. shellbrain-0.1.30/app/settings/__init__.py +1 -0
  318. {shellbrain-0.1.29/app/config → shellbrain-0.1.30/app/settings}/defaults/thresholds.yaml +1 -1
  319. shellbrain-0.1.30/app/settings/internal-agents/defaults.yaml +33 -0
  320. shellbrain-0.1.30/app/startup/__init__.py +0 -0
  321. shellbrain-0.1.30/app/startup/admin.py +104 -0
  322. {shellbrain-0.1.29/app/boot → shellbrain-0.1.30/app/startup}/admin_db.py +9 -5
  323. shellbrain-0.1.30/app/startup/admin_dependencies.py +36 -0
  324. shellbrain-0.1.30/app/startup/admin_diagnose.py +72 -0
  325. shellbrain-0.1.30/app/startup/analytics.py +60 -0
  326. shellbrain-0.1.30/app/startup/backup.py +52 -0
  327. shellbrain-0.1.30/app/startup/cli.py +153 -0
  328. shellbrain-0.1.30/app/startup/cli_runtime.py +37 -0
  329. {shellbrain-0.1.29/app/boot → shellbrain-0.1.30/app/startup}/config.py +3 -3
  330. {shellbrain-0.1.29/app/boot → shellbrain-0.1.30/app/startup}/create_policy.py +21 -13
  331. shellbrain-0.1.30/app/startup/db.py +71 -0
  332. {shellbrain-0.1.29/app/boot → shellbrain-0.1.30/app/startup}/embeddings.py +7 -5
  333. shellbrain-0.1.30/app/startup/episode_poller.py +24 -0
  334. shellbrain-0.1.30/app/startup/episode_sync_launcher.py +21 -0
  335. shellbrain-0.1.30/app/startup/host_hooks.py +24 -0
  336. shellbrain-0.1.30/app/startup/internal_agent_config.py +55 -0
  337. shellbrain-0.1.30/app/startup/internal_agents.py +100 -0
  338. shellbrain-0.1.30/app/startup/knowledge_builder.py +44 -0
  339. shellbrain-0.1.30/app/startup/metrics.py +64 -0
  340. shellbrain-0.1.30/app/startup/migrations.py +57 -0
  341. shellbrain-0.1.30/app/startup/model_usage_backfill.py +41 -0
  342. shellbrain-0.1.30/app/startup/operation_dependencies.py +118 -0
  343. {shellbrain-0.1.29/app/boot → shellbrain-0.1.30/app/startup}/read_policy.py +62 -60
  344. shellbrain-0.1.30/app/startup/repo_context.py +77 -0
  345. shellbrain-0.1.30/app/startup/repos.py +19 -0
  346. shellbrain-0.1.30/app/startup/retrieval.py +3 -0
  347. shellbrain-0.1.30/app/startup/runtime_admin.py +335 -0
  348. shellbrain-0.1.29/app/config/loader.py → shellbrain-0.1.30/app/startup/settings.py +16 -4
  349. shellbrain-0.1.30/app/startup/thresholds.py +30 -0
  350. {shellbrain-0.1.29/app/boot → shellbrain-0.1.30/app/startup}/update_policy.py +20 -7
  351. {shellbrain-0.1.29/app/boot → shellbrain-0.1.30/app/startup}/use_cases.py +2 -2
  352. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/env.py +1 -1
  353. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260312_0003_drop_create_confidence.py +1 -1
  354. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260318_0006_usage_telemetry_schema.py +1 -1
  355. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260414_0010_model_usage_telemetry.py +1 -1
  356. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260414_0011_usage_problem_tokens_multi_solution_metrics.py +1 -1
  357. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260415_0012_read_pack_cost_and_read_roi.py +1 -1
  358. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260422_0015_problem_runs.py +1 -1
  359. shellbrain-0.1.30/migrations/versions/20260508_0016_recall_telemetry.py +96 -0
  360. shellbrain-0.1.30/migrations/versions/20260511_0017_inner_agent_invocations.py +87 -0
  361. shellbrain-0.1.30/migrations/versions/20260513_0018_knowledge_build_runs.py +66 -0
  362. shellbrain-0.1.30/migrations/versions/20260515_0019_scenario_records.py +132 -0
  363. shellbrain-0.1.30/migrations/versions/20260516_0020_knowledge_build_observability.py +166 -0
  364. shellbrain-0.1.30/migrations/versions/20260519_0021_knowledge_build_watermark_stable.py +42 -0
  365. shellbrain-0.1.30/migrations/versions/20260519_0022_update_evidence_links.py +71 -0
  366. shellbrain-0.1.30/migrations/versions/20260519_0023_explicit_teach_trigger.py +48 -0
  367. shellbrain-0.1.30/migrations/versions/20260519_0024_read_retrieval_latency_indexes.py +34 -0
  368. shellbrain-0.1.30/migrations/versions/20260519_0025_repair_recall_source_input_section_constraint.py +54 -0
  369. shellbrain-0.1.30/migrations/versions/20260519_0026_repair_knowledge_build_trigger_constraint.py +52 -0
  370. shellbrain-0.1.30/onboarding_assets/claude/CLAUDE.md +50 -0
  371. shellbrain-0.1.30/onboarding_assets/claude/skills/shellbrain/SKILL.md +175 -0
  372. {shellbrain-0.1.29/app → shellbrain-0.1.30}/onboarding_assets/claude/skills/shellbrain-usage-review/SKILL.md +2 -1
  373. shellbrain-0.1.30/onboarding_assets/codex/AGENTS.md +50 -0
  374. shellbrain-0.1.30/onboarding_assets/codex/clean-architecture/SKILL.md +290 -0
  375. shellbrain-0.1.30/onboarding_assets/codex/clean-code/SKILL.md +243 -0
  376. shellbrain-0.1.30/onboarding_assets/codex/shellbrain/SKILL.md +180 -0
  377. shellbrain-0.1.30/onboarding_assets/codex/shellbrain/agents/openai.yaml +6 -0
  378. shellbrain-0.1.30/onboarding_assets/codex/shellbrain/references/request-shapes.md +108 -0
  379. shellbrain-0.1.30/onboarding_assets/codex/shellbrain/references/session-workflow.md +189 -0
  380. {shellbrain-0.1.29/app → shellbrain-0.1.30}/onboarding_assets/codex/shellbrain-usage-review/SKILL.md +2 -1
  381. shellbrain-0.1.30/onboarding_assets/cursor/skills/shellbrain/SKILL.md +175 -0
  382. {shellbrain-0.1.29/app → shellbrain-0.1.30}/onboarding_assets/cursor/skills/shellbrain-usage-review/SKILL.md +2 -1
  383. {shellbrain-0.1.29 → shellbrain-0.1.30}/pyproject.toml +15 -11
  384. shellbrain-0.1.30/shellbrain.egg-info/PKG-INFO +119 -0
  385. shellbrain-0.1.30/shellbrain.egg-info/SOURCES.txt +438 -0
  386. shellbrain-0.1.30/shellbrain.egg-info/entry_points.txt +2 -0
  387. shellbrain-0.1.30/shellbrain.egg-info/top_level.txt +3 -0
  388. shellbrain-0.1.29/PKG-INFO +0 -116
  389. shellbrain-0.1.29/README.md +0 -102
  390. shellbrain-0.1.29/app/boot/__init__.py +0 -1
  391. shellbrain-0.1.29/app/boot/db.py +0 -45
  392. shellbrain-0.1.29/app/boot/migrations.py +0 -115
  393. shellbrain-0.1.29/app/boot/repos.py +0 -15
  394. shellbrain-0.1.29/app/boot/retrieval.py +0 -3
  395. shellbrain-0.1.29/app/boot/thresholds.py +0 -19
  396. shellbrain-0.1.29/app/config/__init__.py +0 -1
  397. shellbrain-0.1.29/app/core/contracts/__init__.py +0 -1
  398. shellbrain-0.1.29/app/core/contracts/concepts.py +0 -212
  399. shellbrain-0.1.29/app/core/contracts/requests.py +0 -252
  400. shellbrain-0.1.29/app/core/contracts/responses.py +0 -15
  401. shellbrain-0.1.29/app/core/entities/identity.py +0 -48
  402. shellbrain-0.1.29/app/core/entities/memory.py +0 -54
  403. shellbrain-0.1.29/app/core/entities/runtime_context.py +0 -19
  404. shellbrain-0.1.29/app/core/interfaces/__init__.py +0 -1
  405. shellbrain-0.1.29/app/core/interfaces/config.py +0 -28
  406. shellbrain-0.1.29/app/core/interfaces/repos.py +0 -371
  407. shellbrain-0.1.29/app/core/policies/_shared/__init__.py +0 -1
  408. shellbrain-0.1.29/app/core/policies/_shared/executor.py +0 -132
  409. shellbrain-0.1.29/app/core/policies/_shared/side_effects.py +0 -9
  410. shellbrain-0.1.29/app/core/policies/create_policy/__init__.py +0 -1
  411. shellbrain-0.1.29/app/core/policies/create_policy/pipeline.py +0 -96
  412. shellbrain-0.1.29/app/core/policies/read_policy/__init__.py +0 -1
  413. shellbrain-0.1.29/app/core/policies/read_policy/pipeline.py +0 -86
  414. shellbrain-0.1.29/app/core/policies/read_policy/scoring.py +0 -61
  415. shellbrain-0.1.29/app/core/policies/read_policy/seed_retrieval.py +0 -54
  416. shellbrain-0.1.29/app/core/policies/update_policy/__init__.py +0 -1
  417. shellbrain-0.1.29/app/core/policies/update_policy/pipeline.py +0 -80
  418. shellbrain-0.1.29/app/core/use_cases/create_memory.py +0 -26
  419. shellbrain-0.1.29/app/core/use_cases/manage_concepts.py +0 -460
  420. shellbrain-0.1.29/app/core/use_cases/read_memory.py +0 -28
  421. shellbrain-0.1.29/app/core/use_cases/record_episode_sync_telemetry.py +0 -19
  422. shellbrain-0.1.29/app/core/use_cases/record_model_usage_telemetry.py +0 -20
  423. shellbrain-0.1.29/app/core/use_cases/record_operation_telemetry.py +0 -32
  424. shellbrain-0.1.29/app/core/use_cases/sync_episode.py +0 -158
  425. shellbrain-0.1.29/app/core/use_cases/update_memory.py +0 -40
  426. shellbrain-0.1.29/app/onboarding_assets/claude/CLAUDE.md +0 -43
  427. shellbrain-0.1.29/app/onboarding_assets/claude/skills/shellbrain-session-start/SKILL.md +0 -151
  428. shellbrain-0.1.29/app/onboarding_assets/codex/AGENTS.md +0 -43
  429. shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start/SKILL.md +0 -158
  430. shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start/agents/openai.yaml +0 -6
  431. shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start/references/request-shapes.md +0 -197
  432. shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start/references/session-workflow.md +0 -249
  433. shellbrain-0.1.29/app/onboarding_assets/cursor/skills/shellbrain-session-start/SKILL.md +0 -93
  434. shellbrain-0.1.29/app/periphery/admin/__init__.py +0 -1
  435. shellbrain-0.1.29/app/periphery/admin/init.py +0 -662
  436. shellbrain-0.1.29/app/periphery/admin/model_usage_backfill.py +0 -123
  437. shellbrain-0.1.29/app/periphery/cli/__init__.py +0 -1
  438. shellbrain-0.1.29/app/periphery/cli/handlers.py +0 -905
  439. shellbrain-0.1.29/app/periphery/cli/hydration.py +0 -142
  440. shellbrain-0.1.29/app/periphery/cli/main.py +0 -1049
  441. shellbrain-0.1.29/app/periphery/cli/schema_validation.py +0 -218
  442. shellbrain-0.1.29/app/periphery/db/__init__.py +0 -1
  443. shellbrain-0.1.29/app/periphery/db/models/concepts.py +0 -247
  444. shellbrain-0.1.29/app/periphery/db/models/experiences.py +0 -33
  445. shellbrain-0.1.29/app/periphery/db/models/problem_runs.py +0 -60
  446. shellbrain-0.1.29/app/periphery/db/models/registry.py +0 -20
  447. shellbrain-0.1.29/app/periphery/db/models/telemetry.py +0 -230
  448. shellbrain-0.1.29/app/periphery/db/models/utility.py +0 -19
  449. shellbrain-0.1.29/app/periphery/db/repos/relational/episodes_repo.py +0 -242
  450. shellbrain-0.1.29/app/periphery/db/repos/relational/read_policy_repo.py +0 -219
  451. shellbrain-0.1.29/app/periphery/db/repos/semantic/keyword_retrieval_repo.py +0 -63
  452. shellbrain-0.1.29/app/periphery/db/repos/semantic/semantic_retrieval_repo.py +0 -111
  453. shellbrain-0.1.29/app/periphery/episodes/__init__.py +0 -1
  454. shellbrain-0.1.29/app/periphery/episodes/poller.py +0 -338
  455. shellbrain-0.1.29/app/periphery/identity/__init__.py +0 -1
  456. shellbrain-0.1.29/app/periphery/metrics/__init__.py +0 -1
  457. shellbrain-0.1.29/app/periphery/onboarding/__init__.py +0 -2
  458. shellbrain-0.1.29/app/periphery/onboarding/host_assets.py +0 -572
  459. shellbrain-0.1.29/app/periphery/session_state/__init__.py +0 -1
  460. shellbrain-0.1.29/app/periphery/session_state/file_store.py +0 -100
  461. shellbrain-0.1.29/app/periphery/telemetry/operation_summary.py +0 -392
  462. shellbrain-0.1.29/app/periphery/validation/__init__.py +0 -1
  463. shellbrain-0.1.29/shellbrain.egg-info/PKG-INFO +0 -116
  464. shellbrain-0.1.29/shellbrain.egg-info/SOURCES.txt +0 -223
  465. shellbrain-0.1.29/shellbrain.egg-info/entry_points.txt +0 -2
  466. shellbrain-0.1.29/shellbrain.egg-info/top_level.txt +0 -1
  467. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/__init__.py +0 -0
  468. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/__init__.py +0 -0
  469. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/entities/__init__.py +0 -0
  470. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/entities/concepts.py +0 -0
  471. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/entities/facts.py +0 -0
  472. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/entities/guidance.py +0 -0
  473. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/entities/session_state.py +0 -0
  474. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/entities/utility.py +0 -0
  475. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/policies/__init__.py +0 -0
  476. /shellbrain-0.1.29/app/core/interfaces/embeddings.py → /shellbrain-0.1.30/app/core/ports/embeddings/provider.py +0 -0
  477. {shellbrain-0.1.29/app/core/interfaces → shellbrain-0.1.30/app/core/ports/local_state}/session_state_store.py +0 -0
  478. {shellbrain-0.1.29/app/core/interfaces → shellbrain-0.1.30/app/core/ports/system}/clock.py +0 -0
  479. {shellbrain-0.1.29/app/core/interfaces → shellbrain-0.1.30/app/core/ports/system}/idgen.py +0 -0
  480. {shellbrain-0.1.29 → shellbrain-0.1.30}/app/core/use_cases/__init__.py +0 -0
  481. /shellbrain-0.1.29/app/periphery/cli/presenter_json.py → /shellbrain-0.1.30/app/entrypoints/cli/presenters/json.py +0 -0
  482. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure}/__init__.py +0 -0
  483. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/engine.py +0 -0
  484. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/models/__init__.py +0 -0
  485. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/models/metadata.py +0 -0
  486. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/repos/__init__.py +0 -0
  487. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/repos/relational/__init__.py +0 -0
  488. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/repos/semantic/__init__.py +0 -0
  489. {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.30/app/infrastructure/db/runtime}/session.py +0 -0
  490. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure}/embeddings/__init__.py +0 -0
  491. /shellbrain-0.1.29/app/boot/home.py → /shellbrain-0.1.30/app/infrastructure/local_state/paths.py +0 -0
  492. {shellbrain-0.1.29/app/periphery → shellbrain-0.1.30/app/infrastructure/reporting}/metrics/browser.py +0 -0
  493. {shellbrain-0.1.29/app/config → shellbrain-0.1.30/app/settings}/defaults/create_policy.yaml +0 -0
  494. {shellbrain-0.1.29/app/config → shellbrain-0.1.30/app/settings}/defaults/read_policy.yaml +0 -0
  495. {shellbrain-0.1.29/app/config → shellbrain-0.1.30/app/settings}/defaults/runtime.yaml +0 -0
  496. {shellbrain-0.1.29/app/config → shellbrain-0.1.30/app/settings}/defaults/update_policy.yaml +0 -0
  497. /shellbrain-0.1.29/app/boot/_dsn_resolution.py → /shellbrain-0.1.30/app/startup/dsn_resolution.py +0 -0
  498. /shellbrain-0.1.29/app/periphery/telemetry/__init__.py → /shellbrain-0.1.30/app/startup/runtime_context.py +0 -0
  499. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/__init__.py +0 -0
  500. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260226_0001_initial_schema.py +0 -0
  501. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260312_0002_add_hard_invariants.py +0 -0
  502. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260313_0004_episode_sync_hardening.py +0 -0
  503. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260313_0005_evidence_episode_event_refs.py +0 -0
  504. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260319_0007_identity_session_guidance.py +0 -0
  505. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260320_0008_instance_metadata_and_backup_safety.py +0 -0
  506. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260410_0009_frontier_memory_family.py +0 -0
  507. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260421_0013_concept_context_graph.py +0 -0
  508. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/20260422_0014_concept_read_telemetry.py +0 -0
  509. {shellbrain-0.1.29/app → shellbrain-0.1.30}/migrations/versions/__init__.py +0 -0
  510. {shellbrain-0.1.29/app → shellbrain-0.1.30}/onboarding_assets/__init__.py +0 -0
  511. {shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start → shellbrain-0.1.30/onboarding_assets/codex/shellbrain}/assets/shellbrain-large.svg +0 -0
  512. {shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-usage-review → shellbrain-0.1.30/onboarding_assets/codex/shellbrain}/assets/shellbrain-small.svg +0 -0
  513. {shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-usage-review → shellbrain-0.1.30/onboarding_assets/codex/shellbrain}/assets/shellbrain_logo.png +0 -0
  514. {shellbrain-0.1.29/app → shellbrain-0.1.30}/onboarding_assets/codex/shellbrain-usage-review/agents/openai.yaml +0 -0
  515. {shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start → shellbrain-0.1.30/onboarding_assets/codex/shellbrain-usage-review}/assets/shellbrain-small.svg +0 -0
  516. {shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start → shellbrain-0.1.30/onboarding_assets/codex/shellbrain-usage-review}/assets/shellbrain_logo.png +0 -0
  517. {shellbrain-0.1.29 → shellbrain-0.1.30}/setup.cfg +0 -0
  518. {shellbrain-0.1.29 → shellbrain-0.1.30}/shellbrain.egg-info/dependency_links.txt +0 -0
  519. {shellbrain-0.1.29 → shellbrain-0.1.30}/shellbrain.egg-info/requires.txt +0 -0
@@ -0,0 +1,119 @@
1
+ Metadata-Version: 2.4
2
+ Name: shellbrain
3
+ Version: 0.1.30
4
+ Summary: Repo-scoped Shellbrain CLI with explicit evidence-backed writes.
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: SQLAlchemy<3.0,>=2.0
8
+ Requires-Dist: alembic<2.0,>=1.13
9
+ Requires-Dist: pydantic<3.0,>=2.7
10
+ Requires-Dist: PyYAML<7.0,>=6.0
11
+ Requires-Dist: psycopg[binary]<4.0,>=3.1
12
+ Requires-Dist: pgvector<1.0,>=0.3
13
+ Requires-Dist: sentence-transformers<4.0,>=3.0
14
+
15
+ <p align="center">
16
+ <img src="https://raw.githubusercontent.com/cucupac/shellbrain/main/docs/assets/shellbrain_logo_badge.png" alt="ShellBrain logo" height="88">
17
+ </p>
18
+
19
+ <h3 align="center">ShellBrain</h3>
20
+
21
+ <p align="center">Long-term Memory for AI Agents.</p>
22
+
23
+ Agents forget across sessions. They rediscover the same problems, repeat the same mistakes, and relearn what you already taught them. **ShellBrain makes their work compound.**
24
+
25
+ ### Recall in one command.
26
+ Episodic, empirical, conceptual. Three categories, one retrieval surface.
27
+
28
+ ---
29
+
30
+ ## Architecture
31
+
32
+ **Episodic knowledge** is the _evidence_ layer.
33
+ - What actually happened in the session: your prompts, the agent's steps, tool calls, and outputs.
34
+
35
+ **Empirical knowledge** is the concrete _extracted_ layer.
36
+ - An ontology of problems, solutions, failed tactics, facts, preferences, changes.
37
+ - This is **case-based reasoning** in a semantic graph.
38
+
39
+ **Conceptual konwledge** is the _abstractive_ layer.
40
+ - A **higher-level concept graph** with claims, relations, and implementations that link back to the concrete layer.
41
+ - **Progressive disclosure.** agents get oriented first, then ask for depth only where tasks require it.
42
+
43
+ The episodic layer is truth. Empirical memory extracts. Concept memory abstracts. **Each layer is grounded in the one beneath it.**
44
+
45
+ ---
46
+
47
+ ## How agents use ShellBrain
48
+
49
+ **Working agents call `recall`.** That is the normal interface they have to think about. One command, **one _carefully curated_ compact brief**, with sources cited.
50
+
51
+ ```bash
52
+ shellbrain recall --json '{"query":"what context matters for this migration lock timeout?","current_problem":{"goal":"fix the migration hang","surface":"db admin","obstacle":"lock timeout","hypothesis":"none yet"}}'
53
+ ```
54
+
55
+ Lower-level commands exist for inner agents.
56
+ - `read`, `events`, `concept show`, `memory add`, `memory update`, `concept add`, `concept update`
57
+
58
+ When a user explicitly says to store or teach Shellbrain something, working agents can call `teach`. It stores the statement as evidence and immediately runs Shellbrain's teach agent.
59
+
60
+ **Working agents focus on only their work.**
61
+
62
+ ---
63
+
64
+ ## Principled and Disciplined
65
+
66
+ Memory that is grounded in evidence, small in scope, and asked for rather than pushed is memory that compounds. Everything else is noise for working agents.
67
+
68
+ **A memory layer that cannot justify itself should not persist.**
69
+
70
+ ---
71
+
72
+ ## Install
73
+
74
+ ```bash
75
+ curl -L shellbrain.ai/install | bash
76
+ ```
77
+
78
+ **Works for Codex, Claude Code, and Cursor.** The installer runs `shellbrain init` for you. Repos register themselves on first use.
79
+
80
+ Requirements.
81
+ - macOS or Linux, Python 3.11+, Docker for the managed local Postgres+pgvector runtime.
82
+
83
+ ### Upgrade for latest capabilities
84
+
85
+ ```bash
86
+ shellbrain upgrade
87
+ ```
88
+
89
+ The install script also works as an upgrade path: `curl -L shellbrain.ai/upgrade | bash`. Manual alternative: `pipx upgrade shellbrain && shellbrain init`.
90
+
91
+ ---
92
+
93
+ ## How to Use ShellBrain
94
+
95
+ Use Shellbrain in your agent of choice. Then, just work normally.
96
+
97
+ **Claude Code:** *Use `/shellbrain` to remember Shellbrain recall at the right task boundaries.*
98
+
99
+ **Codex:** *Use $shellbrain to remember Shellbrain recall at the right task boundaries.*
100
+
101
+ **Cursor:** *Use `/shellbrain` to remember Shellbrain recall at the right task boundaries.*
102
+
103
+ ---
104
+
105
+ ## Repair
106
+
107
+ `shellbrain admin doctor` to inspect. `shellbrain init` to repair if doctor flags it. Do not rerun init every session — it is not a no-op.
108
+
109
+ ---
110
+
111
+ ## Docs
112
+
113
+ - [shellbrain.ai/humans](https://shellbrain.ai/humans/) — install, upgrade, getting started
114
+ - [shellbrain.ai/agents](https://shellbrain.ai/agents/) — agent workflow and write discipline
115
+ - [shellbrain.ai/recall](https://shellbrain.ai/recall/) — retrieval pipeline
116
+ - [shellbrain.ai/memory/episodic](https://shellbrain.ai/memory/episodic/) — transcript evidence
117
+ - [shellbrain.ai/memory/semantic](https://shellbrain.ai/memory/semantic/) — facts, preferences, changes
118
+ - [shellbrain.ai/memory/procedural](https://shellbrain.ai/memory/procedural/) — problems, solutions, failed tactics
119
+ - [shellbrain.ai/memory/associative](https://shellbrain.ai/memory/associative/) — explicit links and semantic neighbors
@@ -0,0 +1,105 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/cucupac/shellbrain/main/docs/assets/shellbrain_logo_badge.png" alt="ShellBrain logo" height="88">
3
+ </p>
4
+
5
+ <h3 align="center">ShellBrain</h3>
6
+
7
+ <p align="center">Long-term Memory for AI Agents.</p>
8
+
9
+ Agents forget across sessions. They rediscover the same problems, repeat the same mistakes, and relearn what you already taught them. **ShellBrain makes their work compound.**
10
+
11
+ ### Recall in one command.
12
+ Episodic, empirical, conceptual. Three categories, one retrieval surface.
13
+
14
+ ---
15
+
16
+ ## Architecture
17
+
18
+ **Episodic knowledge** is the _evidence_ layer.
19
+ - What actually happened in the session: your prompts, the agent's steps, tool calls, and outputs.
20
+
21
+ **Empirical knowledge** is the concrete _extracted_ layer.
22
+ - An ontology of problems, solutions, failed tactics, facts, preferences, changes.
23
+ - This is **case-based reasoning** in a semantic graph.
24
+
25
+ **Conceptual konwledge** is the _abstractive_ layer.
26
+ - A **higher-level concept graph** with claims, relations, and implementations that link back to the concrete layer.
27
+ - **Progressive disclosure.** agents get oriented first, then ask for depth only where tasks require it.
28
+
29
+ The episodic layer is truth. Empirical memory extracts. Concept memory abstracts. **Each layer is grounded in the one beneath it.**
30
+
31
+ ---
32
+
33
+ ## How agents use ShellBrain
34
+
35
+ **Working agents call `recall`.** That is the normal interface they have to think about. One command, **one _carefully curated_ compact brief**, with sources cited.
36
+
37
+ ```bash
38
+ shellbrain recall --json '{"query":"what context matters for this migration lock timeout?","current_problem":{"goal":"fix the migration hang","surface":"db admin","obstacle":"lock timeout","hypothesis":"none yet"}}'
39
+ ```
40
+
41
+ Lower-level commands exist for inner agents.
42
+ - `read`, `events`, `concept show`, `memory add`, `memory update`, `concept add`, `concept update`
43
+
44
+ When a user explicitly says to store or teach Shellbrain something, working agents can call `teach`. It stores the statement as evidence and immediately runs Shellbrain's teach agent.
45
+
46
+ **Working agents focus on only their work.**
47
+
48
+ ---
49
+
50
+ ## Principled and Disciplined
51
+
52
+ Memory that is grounded in evidence, small in scope, and asked for rather than pushed is memory that compounds. Everything else is noise for working agents.
53
+
54
+ **A memory layer that cannot justify itself should not persist.**
55
+
56
+ ---
57
+
58
+ ## Install
59
+
60
+ ```bash
61
+ curl -L shellbrain.ai/install | bash
62
+ ```
63
+
64
+ **Works for Codex, Claude Code, and Cursor.** The installer runs `shellbrain init` for you. Repos register themselves on first use.
65
+
66
+ Requirements.
67
+ - macOS or Linux, Python 3.11+, Docker for the managed local Postgres+pgvector runtime.
68
+
69
+ ### Upgrade for latest capabilities
70
+
71
+ ```bash
72
+ shellbrain upgrade
73
+ ```
74
+
75
+ The install script also works as an upgrade path: `curl -L shellbrain.ai/upgrade | bash`. Manual alternative: `pipx upgrade shellbrain && shellbrain init`.
76
+
77
+ ---
78
+
79
+ ## How to Use ShellBrain
80
+
81
+ Use Shellbrain in your agent of choice. Then, just work normally.
82
+
83
+ **Claude Code:** *Use `/shellbrain` to remember Shellbrain recall at the right task boundaries.*
84
+
85
+ **Codex:** *Use $shellbrain to remember Shellbrain recall at the right task boundaries.*
86
+
87
+ **Cursor:** *Use `/shellbrain` to remember Shellbrain recall at the right task boundaries.*
88
+
89
+ ---
90
+
91
+ ## Repair
92
+
93
+ `shellbrain admin doctor` to inspect. `shellbrain init` to repair if doctor flags it. Do not rerun init every session — it is not a no-op.
94
+
95
+ ---
96
+
97
+ ## Docs
98
+
99
+ - [shellbrain.ai/humans](https://shellbrain.ai/humans/) — install, upgrade, getting started
100
+ - [shellbrain.ai/agents](https://shellbrain.ai/agents/) — agent workflow and write discipline
101
+ - [shellbrain.ai/recall](https://shellbrain.ai/recall/) — retrieval pipeline
102
+ - [shellbrain.ai/memory/episodic](https://shellbrain.ai/memory/episodic/) — transcript evidence
103
+ - [shellbrain.ai/memory/semantic](https://shellbrain.ai/memory/semantic/) — facts, preferences, changes
104
+ - [shellbrain.ai/memory/procedural](https://shellbrain.ai/memory/procedural/) — problems, solutions, failed tactics
105
+ - [shellbrain.ai/memory/associative](https://shellbrain.ai/memory/associative/) — explicit links and semantic neighbors
@@ -1,6 +1,6 @@
1
1
  """Allow `python -m app` to invoke the public CLI."""
2
2
 
3
- from app.periphery.cli.main import main
3
+ from app.entrypoints.cli.main import main
4
4
 
5
5
 
6
6
  if __name__ == "__main__":
@@ -1,4 +1,4 @@
1
- """Shared bootstrap exceptions for Shellbrain init flows."""
1
+ """Shared bootstrap exceptions for Shellbrain admin flows."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -3,6 +3,15 @@
3
3
  from dataclasses import dataclass
4
4
  from enum import Enum
5
5
 
6
+ from app.core.entities.ids import (
7
+ AssociationEdgeId,
8
+ Confidence,
9
+ EpisodeId,
10
+ MemoryId,
11
+ RepoId,
12
+ Salience,
13
+ )
14
+
6
15
 
7
16
  class AssociationRelationType(str, Enum):
8
17
  """This enum defines ratified formal association relation types."""
@@ -32,14 +41,14 @@ class AssociationState(str, Enum):
32
41
  class AssociationEdge:
33
42
  """This dataclass models a formal association edge between two memories."""
34
43
 
35
- id: str
36
- repo_id: str
37
- from_memory_id: str
38
- to_memory_id: str
44
+ id: AssociationEdgeId
45
+ repo_id: RepoId
46
+ from_memory_id: MemoryId
47
+ to_memory_id: MemoryId
39
48
  relation_type: AssociationRelationType
40
49
  source_mode: AssociationSourceMode = AssociationSourceMode.AGENT
41
50
  state: AssociationState = AssociationState.TENTATIVE
42
- strength: float = 0.0
51
+ strength: Confidence = Confidence(0.0)
43
52
 
44
53
 
45
54
  @dataclass(kw_only=True)
@@ -47,13 +56,13 @@ class AssociationObservation:
47
56
  """This dataclass models an immutable reinforcement observation for associations."""
48
57
 
49
58
  id: str
50
- repo_id: str
51
- from_memory_id: str
52
- to_memory_id: str
59
+ repo_id: RepoId
60
+ from_memory_id: MemoryId
61
+ to_memory_id: MemoryId
53
62
  relation_type: AssociationRelationType
54
63
  source: str
55
- valence: float
56
- salience: float = 0.5
57
- edge_id: str | None = None
58
- problem_id: str | None = None
59
- episode_id: str | None = None
64
+ valence: Confidence
65
+ salience: Salience = Salience(0.5)
66
+ edge_id: AssociationEdgeId | None = None
67
+ problem_id: MemoryId | None = None
68
+ episode_id: EpisodeId | None = None
@@ -0,0 +1,45 @@
1
+ """Core backup entities and policy errors."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+
7
+
8
+ BackupId = str
9
+
10
+
11
+ @dataclass(frozen=True)
12
+ class BackupTarget:
13
+ """Requested restore target database."""
14
+
15
+ database_name: str
16
+
17
+
18
+ @dataclass(frozen=True)
19
+ class BackupManifest:
20
+ """Portable metadata stored next to one logical backup artifact."""
21
+
22
+ backup_id: BackupId
23
+ instance_id: str
24
+ instance_mode: str
25
+ source: dict[str, str]
26
+ schema_revision: str
27
+ created_at: str
28
+ artifact_filename: str
29
+ artifact_sha256: str
30
+ artifact_size_bytes: int
31
+ compression: str
32
+
33
+
34
+ @dataclass(frozen=True)
35
+ class BackupVerificationResult:
36
+ """Stable result for a verified backup artifact."""
37
+
38
+ backup_id: BackupId
39
+ artifact_sha256: str
40
+ artifact_size_bytes: int
41
+ verified: bool
42
+
43
+
44
+ class BackupPolicyError(RuntimeError):
45
+ """Raised when a backup or restore request violates core safety policy."""
@@ -38,6 +38,34 @@ class Episode:
38
38
  created_at: datetime | None = None
39
39
 
40
40
 
41
+ @dataclass(frozen=True, kw_only=True)
42
+ class EpisodeBuildSnapshot:
43
+ """This dataclass exposes persisted episode state needed for build planning."""
44
+
45
+ episode_id: str
46
+ status: EpisodeStatus
47
+ latest_event_seq: int
48
+ latest_event_at: datetime
49
+ latest_successful_build_watermark: int | None = None
50
+
51
+ def __post_init__(self) -> None:
52
+ """Reject invalid persisted build-planning state at the core boundary."""
53
+
54
+ if not isinstance(self.episode_id, str) or not self.episode_id.strip():
55
+ raise ValueError("episode_id must be a non-empty string")
56
+ if not isinstance(self.status, EpisodeStatus):
57
+ raise ValueError("status must be an EpisodeStatus")
58
+ if self.latest_event_seq < 1:
59
+ raise ValueError("latest_event_seq must be positive")
60
+ if not isinstance(self.latest_event_at, datetime):
61
+ raise ValueError("latest_event_at must be a datetime")
62
+ if (
63
+ self.latest_successful_build_watermark is not None
64
+ and self.latest_successful_build_watermark < 0
65
+ ):
66
+ raise ValueError("latest_successful_build_watermark must be non-negative")
67
+
68
+
41
69
  @dataclass(kw_only=True)
42
70
  class EpisodeEvent:
43
71
  """This dataclass models a single immutable event inside an episode."""
@@ -2,14 +2,22 @@
2
2
 
3
3
  from dataclasses import dataclass
4
4
 
5
+ from app.core.entities.ids import (
6
+ AssociationEdgeId,
7
+ EvidenceId,
8
+ EvidenceRefText,
9
+ MemoryId,
10
+ RepoId,
11
+ )
12
+
5
13
 
6
14
  @dataclass(kw_only=True)
7
15
  class EvidenceRef:
8
16
  """This dataclass models a canonical evidence reference entry."""
9
17
 
10
- id: str
11
- repo_id: str
12
- ref: str
18
+ id: EvidenceId
19
+ repo_id: RepoId
20
+ ref: EvidenceRefText
13
21
  episode_event_id: str | None = None
14
22
 
15
23
 
@@ -17,13 +25,13 @@ class EvidenceRef:
17
25
  class MemoryEvidenceLink:
18
26
  """This dataclass models a many-to-many link between shellbrain and evidence."""
19
27
 
20
- memory_id: str
21
- evidence_id: str
28
+ memory_id: MemoryId
29
+ evidence_id: EvidenceId
22
30
 
23
31
 
24
32
  @dataclass(kw_only=True)
25
33
  class AssociationEdgeEvidenceLink:
26
34
  """This dataclass models a many-to-many link between association edges and evidence."""
27
35
 
28
- edge_id: str
29
- evidence_id: str
36
+ edge_id: AssociationEdgeId
37
+ evidence_id: EvidenceId
@@ -0,0 +1,69 @@
1
+ """Core caller-identity concepts used across runtime, episodes, and telemetry."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from enum import Enum
7
+
8
+
9
+ class IdentityTrustLevel(str, Enum):
10
+ """Supported caller-identity trust levels."""
11
+
12
+ TRUSTED = "trusted"
13
+ UNTRUSTED = "untrusted"
14
+ UNSUPPORTED = "unsupported"
15
+
16
+
17
+ SUPPORTED_HOST_APPS = frozenset({"codex", "claude_code", "cursor"})
18
+
19
+
20
+ def build_canonical_caller_id(
21
+ *, host_app: str, host_session_key: str, agent_key: str | None = None
22
+ ) -> str:
23
+ """Build the canonical caller identifier from one host session and optional agent key."""
24
+
25
+ canonical = f"{host_app}:{host_session_key}"
26
+ if agent_key:
27
+ canonical = f"{canonical}:agent:{agent_key}"
28
+ return canonical
29
+
30
+
31
+ @dataclass(frozen=True, kw_only=True)
32
+ class CallerIdentity:
33
+ """Canonical caller identity used to scope episodes, session state, and guidance."""
34
+
35
+ host_app: str
36
+ host_session_key: str
37
+ agent_key: str | None = None
38
+ canonical_id: str | None = None
39
+ trust_level: IdentityTrustLevel = IdentityTrustLevel.UNTRUSTED
40
+
41
+ def __post_init__(self) -> None:
42
+ """Validate caller identity and fill the canonical id when omitted."""
43
+
44
+ host_app = self.host_app.strip()
45
+ host_session_key = self.host_session_key.strip()
46
+ if not host_app:
47
+ raise ValueError("host_app must be non-empty")
48
+ if not host_session_key:
49
+ raise ValueError("host_session_key must be non-empty")
50
+ if host_app not in SUPPORTED_HOST_APPS:
51
+ raise ValueError(
52
+ f"host_app must be one of: {', '.join(sorted(SUPPORTED_HOST_APPS))}"
53
+ )
54
+ object.__setattr__(self, "host_app", host_app)
55
+ object.__setattr__(self, "host_session_key", host_session_key)
56
+ if not isinstance(self.trust_level, IdentityTrustLevel):
57
+ object.__setattr__(
58
+ self, "trust_level", IdentityTrustLevel(str(self.trust_level))
59
+ )
60
+ canonical_id = build_canonical_caller_id(
61
+ host_app=host_app,
62
+ host_session_key=host_session_key,
63
+ agent_key=self.agent_key,
64
+ )
65
+ if self.canonical_id is not None and self.canonical_id != canonical_id:
66
+ raise ValueError(
67
+ "canonical_id must match host_app, host_session_key, and agent_key"
68
+ )
69
+ object.__setattr__(self, "canonical_id", canonical_id)
@@ -0,0 +1,18 @@
1
+ """Semantic identifiers and value aliases used across core contracts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import NewType
6
+
7
+
8
+ MemoryId = NewType("MemoryId", str)
9
+ RepoId = NewType("RepoId", str)
10
+ EpisodeId = NewType("EpisodeId", str)
11
+ EvidenceRefText = NewType("EvidenceRefText", str)
12
+ EvidenceId = NewType("EvidenceId", str)
13
+ InvocationId = NewType("InvocationId", str)
14
+ AssociationEdgeId = NewType("AssociationEdgeId", str)
15
+
16
+ Confidence = NewType("Confidence", float)
17
+ Salience = NewType("Salience", float)
18
+ UtilityVote = NewType("UtilityVote", float)
@@ -0,0 +1,66 @@
1
+ """Core settings for bounded inner-agent execution."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Literal
6
+
7
+ from pydantic import BaseModel, ConfigDict, Field
8
+
9
+
10
+ class _StrictModel(BaseModel):
11
+ model_config = ConfigDict(extra="forbid")
12
+
13
+
14
+ InnerAgentName = Literal["build_context", "build_knowledge", "teach"]
15
+ InnerAgentProviderName = str
16
+ InnerAgentReasoningLevel = Literal["none", "minimal", "low", "medium", "high", "xhigh"]
17
+ TokenCaptureQuality = Literal["exact", "estimated"]
18
+ InnerAgentRunStatus = Literal[
19
+ "ok",
20
+ "no_context",
21
+ "provider_unavailable",
22
+ "timeout",
23
+ "invalid_output",
24
+ "error",
25
+ ]
26
+
27
+
28
+ class BuildContextSettings(_StrictModel):
29
+ """Typed model/runtime settings for the build_context recall agent."""
30
+
31
+ provider: InnerAgentProviderName = Field(min_length=1)
32
+ model: str = Field(min_length=1)
33
+ reasoning: InnerAgentReasoningLevel
34
+ timeout_seconds: int = Field(ge=1, le=600)
35
+ max_private_reads: int = Field(default=0, ge=0, le=10)
36
+ max_candidate_tokens: int = Field(ge=1, le=200_000)
37
+ max_brief_tokens: int | None = Field(default=None, ge=1, le=100_000)
38
+
39
+
40
+ class BuildKnowledgeSettings(_StrictModel):
41
+ """Typed model/runtime settings for the build_knowledge maintenance agent."""
42
+
43
+ provider: InnerAgentProviderName = Field(min_length=1)
44
+ model: str = Field(min_length=1)
45
+ reasoning: InnerAgentReasoningLevel
46
+ timeout_seconds: int = Field(ge=1, le=1200)
47
+ max_shellbrain_reads: int = Field(default=8, ge=1, le=50)
48
+ max_code_files: int = Field(default=24, ge=0, le=200)
49
+ max_write_commands: int = Field(default=20, ge=1, le=200)
50
+ idle_stable_seconds: int = Field(default=900, ge=60, le=86_400)
51
+ running_run_stale_seconds: int = Field(default=3600, ge=60, le=86_400)
52
+
53
+
54
+ class TeachKnowledgeSettings(_StrictModel):
55
+ """Typed model/runtime settings for explicit teaching consolidation."""
56
+
57
+ provider: InnerAgentProviderName = Field(min_length=1)
58
+ model: str = Field(min_length=1)
59
+ reasoning: InnerAgentReasoningLevel
60
+ timeout_seconds: int = Field(ge=1, le=1200)
61
+ max_shellbrain_reads: int = Field(default=6, ge=1, le=50)
62
+ max_code_files: int = Field(default=5, ge=0, le=200)
63
+ max_write_commands: int = Field(default=12, ge=1, le=200)
64
+
65
+
66
+ InnerAgentSettings = BuildContextSettings
@@ -0,0 +1,100 @@
1
+ """Entities for knowledge-builder lifecycle tracking."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass, field
6
+ from datetime import datetime
7
+ from enum import Enum
8
+
9
+
10
+ class KnowledgeBuildTrigger(str, Enum):
11
+ """Episode lifecycle events that can trigger build_knowledge."""
12
+
13
+ SESSION_REPLACED = "session_replaced"
14
+ IDLE_STABLE = "idle_stable"
15
+ WATERMARK_STABLE = "watermark_stable"
16
+ EXPLICIT_TEACH = "explicit_teach"
17
+
18
+
19
+ class KnowledgeBuildRunStatus(str, Enum):
20
+ """Durable statuses for one build_knowledge run."""
21
+
22
+ RUNNING = "running"
23
+ OK = "ok"
24
+ SKIPPED = "skipped"
25
+ PROVIDER_UNAVAILABLE = "provider_unavailable"
26
+ TIMEOUT = "timeout"
27
+ INVALID_OUTPUT = "invalid_output"
28
+ ERROR = "error"
29
+
30
+
31
+ @dataclass(frozen=True, kw_only=True)
32
+ class KnowledgeBuildRun:
33
+ """One durable build_knowledge run record."""
34
+
35
+ id: str
36
+ repo_id: str
37
+ episode_id: str
38
+ trigger: KnowledgeBuildTrigger
39
+ status: KnowledgeBuildRunStatus
40
+ event_watermark: int
41
+ previous_event_watermark: int | None
42
+ provider: str
43
+ model: str
44
+ reasoning: str
45
+ write_count: int = 0
46
+ skipped_item_count: int = 0
47
+ input_tokens: int | None = None
48
+ output_tokens: int | None = None
49
+ reasoning_output_tokens: int | None = None
50
+ cached_input_tokens_total: int | None = None
51
+ cache_read_input_tokens: int | None = None
52
+ cache_creation_input_tokens: int | None = None
53
+ capture_quality: str | None = None
54
+ run_summary: str | None = None
55
+ error_code: str | None = None
56
+ error_message: str | None = None
57
+ read_trace: dict[str, object] = field(default_factory=dict)
58
+ code_trace: dict[str, object] = field(default_factory=dict)
59
+ started_at: datetime | None = None
60
+ finished_at: datetime | None = None
61
+ created_at: datetime | None = None
62
+
63
+ def __post_init__(self) -> None:
64
+ """Keep invalid run records from crossing the core boundary."""
65
+
66
+ for field_name in ("id", "repo_id", "episode_id", "provider", "model"):
67
+ value = getattr(self, field_name)
68
+ if not isinstance(value, str) or not value.strip():
69
+ raise ValueError(f"{field_name} must be a non-empty string")
70
+ if self.event_watermark < 0:
71
+ raise ValueError("event_watermark must be non-negative")
72
+ if (
73
+ self.previous_event_watermark is not None
74
+ and self.previous_event_watermark < 0
75
+ ):
76
+ raise ValueError("previous_event_watermark must be non-negative")
77
+ if self.write_count < 0:
78
+ raise ValueError("write_count must be non-negative")
79
+ if self.skipped_item_count < 0:
80
+ raise ValueError("skipped_item_count must be non-negative")
81
+ for field_name in (
82
+ "input_tokens",
83
+ "output_tokens",
84
+ "reasoning_output_tokens",
85
+ "cached_input_tokens_total",
86
+ "cache_read_input_tokens",
87
+ "cache_creation_input_tokens",
88
+ ):
89
+ value = getattr(self, field_name)
90
+ if value is not None and value < 0:
91
+ raise ValueError(f"{field_name} must be non-negative")
92
+ if self.capture_quality is not None and self.capture_quality not in {
93
+ "exact",
94
+ "estimated",
95
+ }:
96
+ raise ValueError("capture_quality must be exact or estimated")
97
+ if not isinstance(self.read_trace, dict):
98
+ raise ValueError("read_trace must be a dict")
99
+ if not isinstance(self.code_trace, dict):
100
+ raise ValueError("code_trace must be a dict")