shellbrain 0.1.29__tar.gz → 0.1.31__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.
- shellbrain-0.1.31/PKG-INFO +119 -0
- shellbrain-0.1.31/README.md +105 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/__main__.py +1 -1
- shellbrain-0.1.29/app/periphery/admin/init_errors.py → shellbrain-0.1.31/app/core/entities/admin_errors.py +1 -1
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/entities/associations.py +22 -13
- shellbrain-0.1.31/app/core/entities/backups.py +45 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/entities/episodes.py +28 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/entities/evidence.py +15 -7
- shellbrain-0.1.31/app/core/entities/identity.py +69 -0
- shellbrain-0.1.31/app/core/entities/ids.py +18 -0
- shellbrain-0.1.31/app/core/entities/inner_agents.py +70 -0
- shellbrain-0.1.31/app/core/entities/knowledge_builder.py +100 -0
- shellbrain-0.1.31/app/core/entities/machine_config.py +83 -0
- shellbrain-0.1.31/app/core/entities/memories.py +146 -0
- shellbrain-0.1.31/app/core/entities/runtime_context.py +35 -0
- shellbrain-0.1.31/app/core/entities/scenarios.py +67 -0
- shellbrain-0.1.31/app/core/entities/settings.py +156 -0
- {shellbrain-0.1.29/app/core/contracts → shellbrain-0.1.31/app/core}/errors.py +18 -3
- shellbrain-0.1.31/app/core/policies/concepts/__init__.py +1 -0
- shellbrain-0.1.31/app/core/policies/concepts/relation_rules.py +68 -0
- shellbrain-0.1.31/app/core/policies/concepts/search_text.py +124 -0
- shellbrain-0.1.31/app/core/policies/episodes/__init__.py +1 -0
- shellbrain-0.1.31/app/core/policies/episodes/event_content.py +18 -0
- shellbrain-0.1.31/app/core/policies/episodes/knowledge_building.py +71 -0
- shellbrain-0.1.31/app/core/policies/memories/__init__.py +1 -0
- shellbrain-0.1.31/app/core/policies/memories/add_plan.py +107 -0
- shellbrain-0.1.29/app/periphery/validation/semantic_validation.py → shellbrain-0.1.31/app/core/policies/memories/link_rules.py +54 -11
- shellbrain-0.1.31/app/core/policies/memories/update_plan.py +116 -0
- shellbrain-0.1.31/app/core/policies/retrieval/__init__.py +0 -0
- {shellbrain-0.1.29/app/core/policies/read_policy → shellbrain-0.1.31/app/core/policies/retrieval}/bm25.py +33 -13
- shellbrain-0.1.29/app/core/policies/read_policy/context_pack_builder.py → shellbrain-0.1.31/app/core/policies/retrieval/context_pack.py +30 -9
- shellbrain-0.1.31/app/core/policies/retrieval/expansion.py +133 -0
- shellbrain-0.1.31/app/core/policies/retrieval/fusion_rrf.py +45 -0
- {shellbrain-0.1.29/app/core/policies/read_policy → shellbrain-0.1.31/app/core/policies/retrieval}/lexical_query.py +3 -1
- shellbrain-0.1.31/app/core/policies/retrieval/scoring.py +105 -0
- shellbrain-0.1.31/app/core/ports/__init__.py +1 -0
- shellbrain-0.1.31/app/core/ports/db/__init__.py +1 -0
- shellbrain-0.1.31/app/core/ports/db/concept_repositories.py +97 -0
- shellbrain-0.1.31/app/core/ports/db/episode_repositories.py +119 -0
- shellbrain-0.1.31/app/core/ports/db/guidance.py +21 -0
- shellbrain-0.1.31/app/core/ports/db/knowledge_builder.py +59 -0
- shellbrain-0.1.31/app/core/ports/db/memory_repositories.py +94 -0
- shellbrain-0.1.31/app/core/ports/db/problem_runs.py +26 -0
- shellbrain-0.1.31/app/core/ports/db/retrieval_repositories.py +115 -0
- {shellbrain-0.1.29/app/core/interfaces → shellbrain-0.1.31/app/core/ports/db}/unit_of_work.py +18 -8
- shellbrain-0.1.31/app/core/ports/embeddings/__init__.py +1 -0
- {shellbrain-0.1.29/app/core/interfaces → shellbrain-0.1.31/app/core/ports/embeddings}/retrieval.py +5 -0
- shellbrain-0.1.31/app/core/ports/host_apps/__init__.py +2 -0
- shellbrain-0.1.31/app/core/ports/host_apps/inner_agents.py +157 -0
- shellbrain-0.1.31/app/core/ports/local_state/__init__.py +1 -0
- shellbrain-0.1.31/app/core/ports/reporting/__init__.py +1 -0
- shellbrain-0.1.31/app/core/ports/reporting/metrics.py +32 -0
- shellbrain-0.1.31/app/core/ports/system/__init__.py +1 -0
- shellbrain-0.1.31/app/core/use_cases/admin/__init__.py +1 -0
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/core/use_cases}/admin/analytics_diagnostics.py +6 -2
- shellbrain-0.1.31/app/core/use_cases/admin/backfill_model_usage/__init__.py +19 -0
- shellbrain-0.1.31/app/core/use_cases/admin/backfill_model_usage/backfill_model_usage.py +81 -0
- shellbrain-0.1.31/app/core/use_cases/admin/backfill_model_usage/request.py +24 -0
- shellbrain-0.1.31/app/core/use_cases/admin/backfill_model_usage/result.py +31 -0
- shellbrain-0.1.31/app/core/use_cases/admin/create_backup.py +18 -0
- shellbrain-0.1.29/app/periphery/admin/doctor.py → shellbrain-0.1.31/app/core/use_cases/admin/diagnose_runtime.py +116 -85
- shellbrain-0.1.29/app/periphery/admin/analytics.py → shellbrain-0.1.31/app/core/use_cases/admin/generate_analytics_report.py +159 -65
- shellbrain-0.1.31/app/core/use_cases/admin/initialize_runtime.py +330 -0
- shellbrain-0.1.31/app/core/use_cases/admin/restore_backup.py +32 -0
- shellbrain-0.1.31/app/core/use_cases/admin/verify_backup.py +21 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/use_cases/build_guidance.py +7 -4
- shellbrain-0.1.31/app/core/use_cases/concepts/__init__.py +0 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/add/__init__.py +24 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/add/execute.py +72 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/add/request.py +84 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/add/result.py +21 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/containment_checks.py +26 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/embeddings.py +40 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/reference_checks.py +111 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/show/__init__.py +14 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/show/execute.py +30 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/show/request.py +34 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/show/result.py +20 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/update/__init__.py +38 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/update/execute.py +407 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/update/request.py +304 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/update/result.py +21 -0
- shellbrain-0.1.31/app/core/use_cases/concepts/views.py +207 -0
- shellbrain-0.1.31/app/core/use_cases/episodes/__init__.py +1 -0
- shellbrain-0.1.31/app/core/use_cases/episodes/events/__init__.py +5 -0
- shellbrain-0.1.31/app/core/use_cases/episodes/events/request.py +41 -0
- shellbrain-0.1.31/app/core/use_cases/episodes/sync_discovered_host_session.py +53 -0
- shellbrain-0.1.31/app/core/use_cases/episodes/sync_episode/__init__.py +15 -0
- shellbrain-0.1.31/app/core/use_cases/episodes/sync_episode/request.py +74 -0
- shellbrain-0.1.31/app/core/use_cases/episodes/sync_episode/result.py +35 -0
- shellbrain-0.1.31/app/core/use_cases/episodes/sync_episode/sync_episode.py +142 -0
- shellbrain-0.1.31/app/core/use_cases/knowledge_builder/__init__.py +1 -0
- shellbrain-0.1.31/app/core/use_cases/knowledge_builder/build_knowledge/__init__.py +17 -0
- shellbrain-0.1.31/app/core/use_cases/knowledge_builder/build_knowledge/execute.py +282 -0
- shellbrain-0.1.31/app/core/use_cases/knowledge_builder/build_knowledge/request.py +30 -0
- shellbrain-0.1.31/app/core/use_cases/knowledge_builder/build_knowledge/result.py +61 -0
- shellbrain-0.1.31/app/core/use_cases/knowledge_builder/teach_knowledge/__init__.py +19 -0
- shellbrain-0.1.31/app/core/use_cases/knowledge_builder/teach_knowledge/execute.py +337 -0
- shellbrain-0.1.31/app/core/use_cases/knowledge_builder/teach_knowledge/request.py +47 -0
- shellbrain-0.1.31/app/core/use_cases/knowledge_builder/teach_knowledge/result.py +69 -0
- shellbrain-0.1.31/app/core/use_cases/memories/__init__.py +0 -0
- shellbrain-0.1.31/app/core/use_cases/memories/add/__init__.py +14 -0
- shellbrain-0.1.31/app/core/use_cases/memories/add/execute.py +45 -0
- shellbrain-0.1.31/app/core/use_cases/memories/add/request.py +133 -0
- shellbrain-0.1.31/app/core/use_cases/memories/add/result.py +34 -0
- shellbrain-0.1.31/app/core/use_cases/memories/effect_plan.py +122 -0
- shellbrain-0.1.29/app/periphery/validation/integrity_validation.py → shellbrain-0.1.31/app/core/use_cases/memories/reference_checks.py +93 -67
- shellbrain-0.1.31/app/core/use_cases/memories/update/__init__.py +26 -0
- shellbrain-0.1.31/app/core/use_cases/memories/update/execute.py +90 -0
- shellbrain-0.1.31/app/core/use_cases/memories/update/request.py +135 -0
- shellbrain-0.1.31/app/core/use_cases/memories/update/result.py +61 -0
- shellbrain-0.1.31/app/core/use_cases/metrics/__init__.py +1 -0
- shellbrain-0.1.29/app/periphery/admin/agent_behavior_analysis.py → shellbrain-0.1.31/app/core/use_cases/metrics/analyze_agent_behavior.py +133 -155
- shellbrain-0.1.29/app/periphery/metrics/service.py → shellbrain-0.1.31/app/core/use_cases/metrics/build_snapshot.py +111 -48
- shellbrain-0.1.31/app/core/use_cases/metrics/generate_dashboard.py +82 -0
- shellbrain-0.1.31/app/core/use_cases/plan_execution.py +167 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/__init__.py +0 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/build_context/__init__.py +13 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/build_context/execute.py +683 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/concept_seed_retrieval.py +136 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/context_pack_pipeline.py +125 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/deterministic_graph_recall.py +1394 -0
- {shellbrain-0.1.29/app/core/policies/read_policy → shellbrain-0.1.31/app/core/use_cases/retrieval}/expansion.py +51 -19
- shellbrain-0.1.31/app/core/use_cases/retrieval/read/__init__.py +29 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/read/execute.py +74 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/read/request.py +114 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/read/result.py +20 -0
- {shellbrain-0.1.29/app/core/use_cases → shellbrain-0.1.31/app/core/use_cases/retrieval}/read_concepts.py +231 -38
- shellbrain-0.1.31/app/core/use_cases/retrieval/recall/__init__.py +22 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/recall/execute.py +38 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/recall/request.py +58 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/recall/result.py +29 -0
- shellbrain-0.1.31/app/core/use_cases/retrieval/seed_retrieval.py +122 -0
- shellbrain-0.1.31/app/core/use_cases/scenarios/__init__.py +1 -0
- shellbrain-0.1.31/app/core/use_cases/scenarios/record/__init__.py +15 -0
- shellbrain-0.1.31/app/core/use_cases/scenarios/record/execute.py +248 -0
- shellbrain-0.1.31/app/core/use_cases/scenarios/record/request.py +46 -0
- shellbrain-0.1.31/app/core/use_cases/scenarios/record/result.py +29 -0
- shellbrain-0.1.31/app/entrypoints/__init__.py +1 -0
- shellbrain-0.1.31/app/entrypoints/cli/__init__.py +1 -0
- shellbrain-0.1.31/app/entrypoints/cli/error_responses.py +10 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/__init__.py +0 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/cli_operation.py +86 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/dependencies.py +93 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/human/__init__.py +0 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/human/admin.py +143 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/human/admin_dependencies.py +34 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/human/init.py +43 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/human/metrics.py +38 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/human/upgrade.py +11 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/__init__.py +0 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/concepts/__init__.py +0 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/concepts/add.py +98 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/concepts/show.py +85 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/concepts/update.py +98 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/episodes/__init__.py +0 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/episodes/events.py +295 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/episodes/selection.py +106 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/episodes/serialization.py +25 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/memories/__init__.py +0 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/memories/add.py +155 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/memories/update.py +151 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/memories/utility_vote_evidence.py +98 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/retrieval/__init__.py +0 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/retrieval/execution.py +43 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/retrieval/read.py +95 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/scenarios/__init__.py +1 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/internal_agent/scenarios/record.py +96 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/result_envelopes.py +105 -0
- shellbrain-0.1.29/app/core/use_cases/manage_session_state.py → shellbrain-0.1.31/app/entrypoints/cli/handlers/session_state.py +24 -13
- shellbrain-0.1.31/app/entrypoints/cli/handlers/working_agent/__init__.py +0 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/working_agent/recall.py +101 -0
- shellbrain-0.1.31/app/entrypoints/cli/handlers/working_agent/teach.py +143 -0
- shellbrain-0.1.31/app/entrypoints/cli/main.py +19 -0
- shellbrain-0.1.31/app/entrypoints/cli/operation_command.py +43 -0
- shellbrain-0.1.31/app/entrypoints/cli/parser/__init__.py +5 -0
- shellbrain-0.1.31/app/entrypoints/cli/parser/builder.py +797 -0
- shellbrain-0.1.31/app/entrypoints/cli/presenters/__init__.py +1 -0
- shellbrain-0.1.31/app/entrypoints/cli/presenters/init.py +50 -0
- shellbrain-0.1.31/app/entrypoints/cli/presenters/metrics.py +26 -0
- shellbrain-0.1.31/app/entrypoints/cli/request_parsing/__init__.py +1 -0
- shellbrain-0.1.31/app/entrypoints/cli/request_parsing/concepts.py +68 -0
- shellbrain-0.1.31/app/entrypoints/cli/request_parsing/episodes.py +36 -0
- shellbrain-0.1.31/app/entrypoints/cli/request_parsing/hydration.py +121 -0
- shellbrain-0.1.31/app/entrypoints/cli/request_parsing/memories.py +81 -0
- shellbrain-0.1.31/app/entrypoints/cli/request_parsing/payload_validation.py +440 -0
- shellbrain-0.1.31/app/entrypoints/cli/request_parsing/prepared.py +30 -0
- shellbrain-0.1.31/app/entrypoints/cli/request_parsing/retrieval.py +84 -0
- shellbrain-0.1.31/app/entrypoints/cli/request_parsing/scenarios.py +38 -0
- shellbrain-0.1.31/app/entrypoints/cli/request_parsing/teach.py +32 -0
- shellbrain-0.1.31/app/entrypoints/cli/runner.py +431 -0
- shellbrain-0.1.31/app/entrypoints/cli/runtime.py +33 -0
- shellbrain-0.1.31/app/entrypoints/host_hooks/__init__.py +1 -0
- shellbrain-0.1.31/app/entrypoints/host_hooks/claude_session_start.py +11 -0
- shellbrain-0.1.31/app/entrypoints/host_hooks/cursor_statusline.py +9 -0
- shellbrain-0.1.31/app/entrypoints/jobs/__init__.py +1 -0
- shellbrain-0.1.31/app/entrypoints/jobs/episode_sync.py +24 -0
- shellbrain-0.1.31/app/infrastructure/db/__init__.py +1 -0
- shellbrain-0.1.31/app/infrastructure/db/admin/__init__.py +1 -0
- shellbrain-0.1.31/app/infrastructure/db/admin/app_role_safety.py +32 -0
- shellbrain-0.1.31/app/infrastructure/db/admin/backups/__init__.py +1 -0
- {shellbrain-0.1.29/app/periphery/admin → shellbrain-0.1.31/app/infrastructure/db/admin/backups}/destructive_guard.py +5 -1
- shellbrain-0.1.29/app/periphery/admin/backup.py → shellbrain-0.1.31/app/infrastructure/db/admin/backups/logical_backup.py +45 -41
- shellbrain-0.1.31/app/infrastructure/db/admin/backups/manifest_store.py +39 -0
- {shellbrain-0.1.29/app/periphery/admin → shellbrain-0.1.31/app/infrastructure/db/admin/backups}/restore.py +4 -1
- shellbrain-0.1.31/app/infrastructure/db/admin/connection.py +59 -0
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/db}/admin/instance_guard.py +12 -4
- shellbrain-0.1.31/app/infrastructure/db/admin/migrations.py +96 -0
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/db}/admin/privileges.py +5 -3
- shellbrain-0.1.31/app/infrastructure/db/admin/provisioning/__init__.py +1 -0
- shellbrain-0.1.31/app/infrastructure/db/admin/provisioning/docker_prerequisites.py +37 -0
- shellbrain-0.1.29/app/periphery/admin/external_runtime.py → shellbrain-0.1.31/app/infrastructure/db/admin/provisioning/external_postgres.py +35 -16
- shellbrain-0.1.31/app/infrastructure/db/admin/provisioning/init_effects.py +20 -0
- shellbrain-0.1.29/app/periphery/admin/managed_runtime.py → shellbrain-0.1.31/app/infrastructure/db/admin/provisioning/managed_local.py +61 -25
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/db}/admin/storage_setup.py +22 -8
- shellbrain-0.1.31/app/infrastructure/db/runtime/__init__.py +1 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/models/associations.py +61 -11
- shellbrain-0.1.31/app/infrastructure/db/runtime/models/concepts.py +543 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/models/episodes.py +53 -10
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/models/evidence.py +4 -2
- shellbrain-0.1.31/app/infrastructure/db/runtime/models/experiences.py +88 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/models/instance_metadata.py +1 -1
- shellbrain-0.1.31/app/infrastructure/db/runtime/models/knowledge_builder.py +127 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/models/memories.py +46 -5
- shellbrain-0.1.31/app/infrastructure/db/runtime/models/problem_runs.py +106 -0
- shellbrain-0.1.31/app/infrastructure/db/runtime/models/registry.py +33 -0
- shellbrain-0.1.31/app/infrastructure/db/runtime/models/telemetry.py +500 -0
- shellbrain-0.1.31/app/infrastructure/db/runtime/models/utility.py +48 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/models/views.py +257 -15
- shellbrain-0.1.31/app/infrastructure/db/runtime/queries/__init__.py +1 -0
- shellbrain-0.1.31/app/infrastructure/db/runtime/queries/agent_behavior.py +163 -0
- shellbrain-0.1.29/app/periphery/admin/analytics_queries.py → shellbrain-0.1.31/app/infrastructure/db/runtime/queries/analytics.py +12 -4
- shellbrain-0.1.29/app/periphery/metrics/queries.py → shellbrain-0.1.31/app/infrastructure/db/runtime/queries/metrics.py +10 -6
- shellbrain-0.1.31/app/infrastructure/db/runtime/queries/metrics_adapter.py +54 -0
- shellbrain-0.1.31/app/infrastructure/db/runtime/queries/model_usage_backfill.py +43 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/repos/relational/associations_repo.py +13 -4
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/repos/relational/concepts_repo.py +139 -170
- shellbrain-0.1.31/app/infrastructure/db/runtime/repos/relational/episodes_repo.py +481 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/repos/relational/evidence_repo.py +31 -6
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/repos/relational/experiences_repo.py +2 -2
- shellbrain-0.1.31/app/infrastructure/db/runtime/repos/relational/knowledge_builder_repo.py +205 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/repos/relational/memories_repo.py +24 -12
- shellbrain-0.1.31/app/infrastructure/db/runtime/repos/relational/problem_runs_repo.py +96 -0
- shellbrain-0.1.31/app/infrastructure/db/runtime/repos/relational/read_policy_repo.py +225 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/repos/relational/telemetry_repo.py +112 -29
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/repos/relational/utility_repo.py +2 -2
- shellbrain-0.1.31/app/infrastructure/db/runtime/repos/semantic/concept_retrieval_repo.py +290 -0
- shellbrain-0.1.31/app/infrastructure/db/runtime/repos/semantic/keyword_retrieval_repo.py +151 -0
- shellbrain-0.1.31/app/infrastructure/db/runtime/repos/semantic/semantic_retrieval_repo.py +307 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/uow.py +35 -14
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure}/embeddings/local_provider.py +5 -2
- shellbrain-0.1.31/app/infrastructure/embeddings/prewarm.py +98 -0
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure}/embeddings/query_vector_search.py +10 -3
- shellbrain-0.1.31/app/infrastructure/host_apps/__init__.py +1 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/__init__.py +15 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/claude.py +110 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/codex.py +87 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/cursor.py +77 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/cursor_statusline_config.py +148 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/inspection.py +25 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/managed_markdown.py +150 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/managed_tree.py +105 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/packaged_assets.py +17 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/paths.py +30 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/service.py +60 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/assets/types.py +25 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/identity/__init__.py +1 -0
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/host_apps}/identity/claude_hook_install.py +45 -15
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/host_apps}/identity/claude_runtime.py +5 -1
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/host_apps}/identity/codex_runtime.py +4 -2
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/host_apps}/identity/compatibility.py +1 -2
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/host_apps}/identity/cursor_statusline.py +39 -12
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/host_apps}/identity/resolver.py +60 -13
- shellbrain-0.1.31/app/infrastructure/host_apps/inner_agents/__init__.py +2 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/inner_agents/codex_cli.py +561 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/inner_agents/output_parser.py +136 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/inner_agents/prompt.py +1162 -0
- shellbrain-0.1.31/app/infrastructure/host_apps/transcripts/__init__.py +1 -0
- {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.31/app/infrastructure/host_apps/transcripts}/claude_code.py +50 -29
- {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.31/app/infrastructure/host_apps/transcripts}/codex.py +62 -28
- {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.31/app/infrastructure/host_apps/transcripts}/cursor.py +108 -37
- {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.31/app/infrastructure/host_apps/transcripts}/model_usage.py +57 -19
- {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.31/app/infrastructure/host_apps/transcripts}/normalization.py +5 -3
- {shellbrain-0.1.29/app/periphery/telemetry → shellbrain-0.1.31/app/infrastructure/host_apps/transcripts}/session_selection.py +20 -21
- {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.31/app/infrastructure/host_apps/transcripts}/source_discovery.py +20 -11
- {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.31/app/infrastructure/host_apps/transcripts}/tool_filter.py +26 -8
- shellbrain-0.1.31/app/infrastructure/local_state/__init__.py +1 -0
- shellbrain-0.1.31/app/infrastructure/local_state/init_lock.py +114 -0
- shellbrain-0.1.29/app/periphery/admin/machine_state.py → shellbrain-0.1.31/app/infrastructure/local_state/machine_config_store.py +27 -86
- shellbrain-0.1.31/app/infrastructure/local_state/operation_registration.py +44 -0
- shellbrain-0.1.29/app/periphery/admin/repo_state.py → shellbrain-0.1.31/app/infrastructure/local_state/repo_registration_store.py +15 -5
- shellbrain-0.1.31/app/infrastructure/local_state/session_state_file_store.py +201 -0
- shellbrain-0.1.31/app/infrastructure/process/__init__.py +0 -0
- shellbrain-0.1.31/app/infrastructure/process/episode_sync/__init__.py +1 -0
- shellbrain-0.1.31/app/infrastructure/process/episode_sync/autostart.py +17 -0
- {shellbrain-0.1.29/app/periphery/episodes → shellbrain-0.1.31/app/infrastructure/process/episode_sync}/launcher.py +7 -5
- shellbrain-0.1.29/app/periphery/episodes/poller_lock.py → shellbrain-0.1.31/app/infrastructure/process/episode_sync/lock_file.py +73 -19
- shellbrain-0.1.31/app/infrastructure/process/episode_sync/poller.py +409 -0
- shellbrain-0.1.31/app/infrastructure/process/episode_sync/status_store.py +35 -0
- shellbrain-0.1.31/app/infrastructure/reporting/__init__.py +1 -0
- shellbrain-0.1.31/app/infrastructure/reporting/metrics/__init__.py +1 -0
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/reporting}/metrics/artifacts.py +7 -3
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/reporting}/metrics/pager.py +31 -7
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/reporting}/metrics/render_html.py +44 -18
- shellbrain-0.1.31/app/infrastructure/system/__init__.py +1 -0
- shellbrain-0.1.31/app/infrastructure/system/clock.py +16 -0
- shellbrain-0.1.31/app/infrastructure/system/id_generator.py +16 -0
- shellbrain-0.1.29/app/periphery/admin/upgrade.py → shellbrain-0.1.31/app/infrastructure/system/package_upgrade.py +8 -2
- shellbrain-0.1.31/app/infrastructure/telemetry/__init__.py +0 -0
- shellbrain-0.1.31/app/infrastructure/telemetry/inner_agent_records.py +78 -0
- shellbrain-0.1.31/app/infrastructure/telemetry/operation_invocations.py +125 -0
- shellbrain-0.1.31/app/infrastructure/telemetry/operation_polling.py +19 -0
- shellbrain-0.1.31/app/infrastructure/telemetry/read_records.py +179 -0
- shellbrain-0.1.31/app/infrastructure/telemetry/recall_records.py +94 -0
- shellbrain-0.1.31/app/infrastructure/telemetry/recorder.py +68 -0
- shellbrain-0.1.29/app/core/entities/telemetry.py → shellbrain-0.1.31/app/infrastructure/telemetry/records.py +59 -15
- shellbrain-0.1.31/app/infrastructure/telemetry/sink.py +210 -0
- shellbrain-0.1.31/app/infrastructure/telemetry/storage_protocols.py +63 -0
- shellbrain-0.1.29/app/periphery/telemetry/sync_summary.py → shellbrain-0.1.31/app/infrastructure/telemetry/sync_records.py +7 -3
- shellbrain-0.1.31/app/infrastructure/telemetry/write_records.py +234 -0
- shellbrain-0.1.31/app/settings/__init__.py +1 -0
- {shellbrain-0.1.29/app/config → shellbrain-0.1.31/app/settings}/defaults/thresholds.yaml +1 -1
- shellbrain-0.1.31/app/settings/internal-agents/defaults.yaml +34 -0
- shellbrain-0.1.31/app/startup/__init__.py +0 -0
- shellbrain-0.1.31/app/startup/admin.py +104 -0
- {shellbrain-0.1.29/app/boot → shellbrain-0.1.31/app/startup}/admin_db.py +9 -5
- shellbrain-0.1.31/app/startup/admin_dependencies.py +36 -0
- shellbrain-0.1.31/app/startup/admin_diagnose.py +72 -0
- shellbrain-0.1.31/app/startup/analytics.py +60 -0
- shellbrain-0.1.31/app/startup/backup.py +52 -0
- shellbrain-0.1.31/app/startup/cli.py +153 -0
- shellbrain-0.1.31/app/startup/cli_runtime.py +37 -0
- {shellbrain-0.1.29/app/boot → shellbrain-0.1.31/app/startup}/config.py +3 -3
- {shellbrain-0.1.29/app/boot → shellbrain-0.1.31/app/startup}/create_policy.py +21 -13
- shellbrain-0.1.31/app/startup/db.py +71 -0
- {shellbrain-0.1.29/app/boot → shellbrain-0.1.31/app/startup}/embeddings.py +7 -5
- shellbrain-0.1.31/app/startup/episode_poller.py +24 -0
- shellbrain-0.1.31/app/startup/episode_sync_launcher.py +21 -0
- shellbrain-0.1.31/app/startup/host_hooks.py +24 -0
- shellbrain-0.1.31/app/startup/internal_agent_config.py +55 -0
- shellbrain-0.1.31/app/startup/internal_agents.py +100 -0
- shellbrain-0.1.31/app/startup/knowledge_builder.py +44 -0
- shellbrain-0.1.31/app/startup/metrics.py +64 -0
- shellbrain-0.1.31/app/startup/migrations.py +57 -0
- shellbrain-0.1.31/app/startup/model_usage_backfill.py +41 -0
- shellbrain-0.1.31/app/startup/operation_dependencies.py +118 -0
- {shellbrain-0.1.29/app/boot → shellbrain-0.1.31/app/startup}/read_policy.py +62 -60
- shellbrain-0.1.31/app/startup/repo_context.py +77 -0
- shellbrain-0.1.31/app/startup/repos.py +19 -0
- shellbrain-0.1.31/app/startup/retrieval.py +3 -0
- shellbrain-0.1.31/app/startup/runtime_admin.py +335 -0
- shellbrain-0.1.29/app/config/loader.py → shellbrain-0.1.31/app/startup/settings.py +16 -4
- shellbrain-0.1.31/app/startup/thresholds.py +30 -0
- {shellbrain-0.1.29/app/boot → shellbrain-0.1.31/app/startup}/update_policy.py +20 -7
- {shellbrain-0.1.29/app/boot → shellbrain-0.1.31/app/startup}/use_cases.py +2 -2
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/env.py +1 -1
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260312_0003_drop_create_confidence.py +1 -1
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260318_0006_usage_telemetry_schema.py +1 -1
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260414_0010_model_usage_telemetry.py +1 -1
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260414_0011_usage_problem_tokens_multi_solution_metrics.py +1 -1
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260415_0012_read_pack_cost_and_read_roi.py +1 -1
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260422_0015_problem_runs.py +1 -1
- shellbrain-0.1.31/migrations/versions/20260508_0016_recall_telemetry.py +96 -0
- shellbrain-0.1.31/migrations/versions/20260511_0017_inner_agent_invocations.py +87 -0
- shellbrain-0.1.31/migrations/versions/20260513_0018_knowledge_build_runs.py +66 -0
- shellbrain-0.1.31/migrations/versions/20260515_0019_scenario_records.py +132 -0
- shellbrain-0.1.31/migrations/versions/20260516_0020_knowledge_build_observability.py +166 -0
- shellbrain-0.1.31/migrations/versions/20260519_0021_knowledge_build_watermark_stable.py +42 -0
- shellbrain-0.1.31/migrations/versions/20260519_0022_update_evidence_links.py +71 -0
- shellbrain-0.1.31/migrations/versions/20260519_0023_explicit_teach_trigger.py +48 -0
- shellbrain-0.1.31/migrations/versions/20260519_0024_read_retrieval_latency_indexes.py +34 -0
- shellbrain-0.1.31/migrations/versions/20260519_0025_repair_recall_source_input_section_constraint.py +54 -0
- shellbrain-0.1.31/migrations/versions/20260519_0026_repair_knowledge_build_trigger_constraint.py +52 -0
- shellbrain-0.1.31/migrations/versions/20260519_0027_concept_embeddings.py +42 -0
- shellbrain-0.1.31/onboarding_assets/claude/CLAUDE.md +50 -0
- shellbrain-0.1.31/onboarding_assets/claude/skills/shellbrain/SKILL.md +175 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/onboarding_assets/claude/skills/shellbrain-usage-review/SKILL.md +2 -1
- shellbrain-0.1.31/onboarding_assets/codex/AGENTS.md +50 -0
- shellbrain-0.1.31/onboarding_assets/codex/clean-architecture/SKILL.md +290 -0
- shellbrain-0.1.31/onboarding_assets/codex/clean-code/SKILL.md +243 -0
- shellbrain-0.1.31/onboarding_assets/codex/shellbrain/SKILL.md +180 -0
- shellbrain-0.1.31/onboarding_assets/codex/shellbrain/agents/openai.yaml +6 -0
- shellbrain-0.1.31/onboarding_assets/codex/shellbrain/references/request-shapes.md +108 -0
- shellbrain-0.1.31/onboarding_assets/codex/shellbrain/references/session-workflow.md +189 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/onboarding_assets/codex/shellbrain-usage-review/SKILL.md +2 -1
- shellbrain-0.1.31/onboarding_assets/cursor/skills/shellbrain/SKILL.md +175 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/onboarding_assets/cursor/skills/shellbrain-usage-review/SKILL.md +2 -1
- {shellbrain-0.1.29 → shellbrain-0.1.31}/pyproject.toml +15 -11
- shellbrain-0.1.31/shellbrain.egg-info/PKG-INFO +119 -0
- shellbrain-0.1.31/shellbrain.egg-info/SOURCES.txt +443 -0
- shellbrain-0.1.31/shellbrain.egg-info/entry_points.txt +2 -0
- shellbrain-0.1.31/shellbrain.egg-info/top_level.txt +3 -0
- shellbrain-0.1.29/PKG-INFO +0 -116
- shellbrain-0.1.29/README.md +0 -102
- shellbrain-0.1.29/app/boot/__init__.py +0 -1
- shellbrain-0.1.29/app/boot/db.py +0 -45
- shellbrain-0.1.29/app/boot/migrations.py +0 -115
- shellbrain-0.1.29/app/boot/repos.py +0 -15
- shellbrain-0.1.29/app/boot/retrieval.py +0 -3
- shellbrain-0.1.29/app/boot/thresholds.py +0 -19
- shellbrain-0.1.29/app/config/__init__.py +0 -1
- shellbrain-0.1.29/app/core/contracts/__init__.py +0 -1
- shellbrain-0.1.29/app/core/contracts/concepts.py +0 -212
- shellbrain-0.1.29/app/core/contracts/requests.py +0 -252
- shellbrain-0.1.29/app/core/contracts/responses.py +0 -15
- shellbrain-0.1.29/app/core/entities/identity.py +0 -48
- shellbrain-0.1.29/app/core/entities/memory.py +0 -54
- shellbrain-0.1.29/app/core/entities/runtime_context.py +0 -19
- shellbrain-0.1.29/app/core/interfaces/__init__.py +0 -1
- shellbrain-0.1.29/app/core/interfaces/config.py +0 -28
- shellbrain-0.1.29/app/core/interfaces/repos.py +0 -371
- shellbrain-0.1.29/app/core/policies/_shared/__init__.py +0 -1
- shellbrain-0.1.29/app/core/policies/_shared/executor.py +0 -132
- shellbrain-0.1.29/app/core/policies/_shared/side_effects.py +0 -9
- shellbrain-0.1.29/app/core/policies/create_policy/__init__.py +0 -1
- shellbrain-0.1.29/app/core/policies/create_policy/pipeline.py +0 -96
- shellbrain-0.1.29/app/core/policies/read_policy/__init__.py +0 -1
- shellbrain-0.1.29/app/core/policies/read_policy/fusion_rrf.py +0 -34
- shellbrain-0.1.29/app/core/policies/read_policy/pipeline.py +0 -86
- shellbrain-0.1.29/app/core/policies/read_policy/scoring.py +0 -61
- shellbrain-0.1.29/app/core/policies/read_policy/seed_retrieval.py +0 -54
- shellbrain-0.1.29/app/core/policies/update_policy/__init__.py +0 -1
- shellbrain-0.1.29/app/core/policies/update_policy/pipeline.py +0 -80
- shellbrain-0.1.29/app/core/use_cases/create_memory.py +0 -26
- shellbrain-0.1.29/app/core/use_cases/manage_concepts.py +0 -460
- shellbrain-0.1.29/app/core/use_cases/read_memory.py +0 -28
- shellbrain-0.1.29/app/core/use_cases/record_episode_sync_telemetry.py +0 -19
- shellbrain-0.1.29/app/core/use_cases/record_model_usage_telemetry.py +0 -20
- shellbrain-0.1.29/app/core/use_cases/record_operation_telemetry.py +0 -32
- shellbrain-0.1.29/app/core/use_cases/sync_episode.py +0 -158
- shellbrain-0.1.29/app/core/use_cases/update_memory.py +0 -40
- shellbrain-0.1.29/app/onboarding_assets/claude/CLAUDE.md +0 -43
- shellbrain-0.1.29/app/onboarding_assets/claude/skills/shellbrain-session-start/SKILL.md +0 -151
- shellbrain-0.1.29/app/onboarding_assets/codex/AGENTS.md +0 -43
- shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start/SKILL.md +0 -158
- shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start/agents/openai.yaml +0 -6
- shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start/references/request-shapes.md +0 -197
- shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start/references/session-workflow.md +0 -249
- shellbrain-0.1.29/app/onboarding_assets/cursor/skills/shellbrain-session-start/SKILL.md +0 -93
- shellbrain-0.1.29/app/periphery/admin/__init__.py +0 -1
- shellbrain-0.1.29/app/periphery/admin/init.py +0 -662
- shellbrain-0.1.29/app/periphery/admin/model_usage_backfill.py +0 -123
- shellbrain-0.1.29/app/periphery/cli/__init__.py +0 -1
- shellbrain-0.1.29/app/periphery/cli/handlers.py +0 -905
- shellbrain-0.1.29/app/periphery/cli/hydration.py +0 -142
- shellbrain-0.1.29/app/periphery/cli/main.py +0 -1049
- shellbrain-0.1.29/app/periphery/cli/schema_validation.py +0 -218
- shellbrain-0.1.29/app/periphery/db/__init__.py +0 -1
- shellbrain-0.1.29/app/periphery/db/models/concepts.py +0 -247
- shellbrain-0.1.29/app/periphery/db/models/experiences.py +0 -33
- shellbrain-0.1.29/app/periphery/db/models/problem_runs.py +0 -60
- shellbrain-0.1.29/app/periphery/db/models/registry.py +0 -20
- shellbrain-0.1.29/app/periphery/db/models/telemetry.py +0 -230
- shellbrain-0.1.29/app/periphery/db/models/utility.py +0 -19
- shellbrain-0.1.29/app/periphery/db/repos/relational/episodes_repo.py +0 -242
- shellbrain-0.1.29/app/periphery/db/repos/relational/read_policy_repo.py +0 -219
- shellbrain-0.1.29/app/periphery/db/repos/semantic/keyword_retrieval_repo.py +0 -63
- shellbrain-0.1.29/app/periphery/db/repos/semantic/semantic_retrieval_repo.py +0 -111
- shellbrain-0.1.29/app/periphery/episodes/__init__.py +0 -1
- shellbrain-0.1.29/app/periphery/episodes/poller.py +0 -338
- shellbrain-0.1.29/app/periphery/identity/__init__.py +0 -1
- shellbrain-0.1.29/app/periphery/metrics/__init__.py +0 -1
- shellbrain-0.1.29/app/periphery/onboarding/__init__.py +0 -2
- shellbrain-0.1.29/app/periphery/onboarding/host_assets.py +0 -572
- shellbrain-0.1.29/app/periphery/session_state/__init__.py +0 -1
- shellbrain-0.1.29/app/periphery/session_state/file_store.py +0 -100
- shellbrain-0.1.29/app/periphery/telemetry/operation_summary.py +0 -392
- shellbrain-0.1.29/app/periphery/validation/__init__.py +0 -1
- shellbrain-0.1.29/shellbrain.egg-info/PKG-INFO +0 -116
- shellbrain-0.1.29/shellbrain.egg-info/SOURCES.txt +0 -223
- shellbrain-0.1.29/shellbrain.egg-info/entry_points.txt +0 -2
- shellbrain-0.1.29/shellbrain.egg-info/top_level.txt +0 -1
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/__init__.py +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/__init__.py +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/entities/__init__.py +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/entities/concepts.py +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/entities/facts.py +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/entities/guidance.py +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/entities/session_state.py +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/entities/utility.py +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/policies/__init__.py +0 -0
- /shellbrain-0.1.29/app/core/interfaces/embeddings.py → /shellbrain-0.1.31/app/core/ports/embeddings/provider.py +0 -0
- {shellbrain-0.1.29/app/core/interfaces → shellbrain-0.1.31/app/core/ports/local_state}/session_state_store.py +0 -0
- {shellbrain-0.1.29/app/core/interfaces → shellbrain-0.1.31/app/core/ports/system}/clock.py +0 -0
- {shellbrain-0.1.29/app/core/interfaces → shellbrain-0.1.31/app/core/ports/system}/idgen.py +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/app/core/use_cases/__init__.py +0 -0
- /shellbrain-0.1.29/app/periphery/cli/presenter_json.py → /shellbrain-0.1.31/app/entrypoints/cli/presenters/json.py +0 -0
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure}/__init__.py +0 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/engine.py +0 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/models/__init__.py +0 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/models/metadata.py +0 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/repos/__init__.py +0 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/repos/relational/__init__.py +0 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/repos/semantic/__init__.py +0 -0
- {shellbrain-0.1.29/app/periphery/db → shellbrain-0.1.31/app/infrastructure/db/runtime}/session.py +0 -0
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure}/embeddings/__init__.py +0 -0
- /shellbrain-0.1.29/app/boot/home.py → /shellbrain-0.1.31/app/infrastructure/local_state/paths.py +0 -0
- {shellbrain-0.1.29/app/periphery → shellbrain-0.1.31/app/infrastructure/reporting}/metrics/browser.py +0 -0
- {shellbrain-0.1.29/app/config → shellbrain-0.1.31/app/settings}/defaults/create_policy.yaml +0 -0
- {shellbrain-0.1.29/app/config → shellbrain-0.1.31/app/settings}/defaults/read_policy.yaml +0 -0
- {shellbrain-0.1.29/app/config → shellbrain-0.1.31/app/settings}/defaults/runtime.yaml +0 -0
- {shellbrain-0.1.29/app/config → shellbrain-0.1.31/app/settings}/defaults/update_policy.yaml +0 -0
- /shellbrain-0.1.29/app/boot/_dsn_resolution.py → /shellbrain-0.1.31/app/startup/dsn_resolution.py +0 -0
- /shellbrain-0.1.29/app/periphery/telemetry/__init__.py → /shellbrain-0.1.31/app/startup/runtime_context.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/__init__.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260226_0001_initial_schema.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260312_0002_add_hard_invariants.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260313_0004_episode_sync_hardening.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260313_0005_evidence_episode_event_refs.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260319_0007_identity_session_guidance.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260320_0008_instance_metadata_and_backup_safety.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260410_0009_frontier_memory_family.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260421_0013_concept_context_graph.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/20260422_0014_concept_read_telemetry.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/migrations/versions/__init__.py +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/onboarding_assets/__init__.py +0 -0
- {shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start → shellbrain-0.1.31/onboarding_assets/codex/shellbrain}/assets/shellbrain-large.svg +0 -0
- {shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-usage-review → shellbrain-0.1.31/onboarding_assets/codex/shellbrain}/assets/shellbrain-small.svg +0 -0
- {shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-usage-review → shellbrain-0.1.31/onboarding_assets/codex/shellbrain}/assets/shellbrain_logo.png +0 -0
- {shellbrain-0.1.29/app → shellbrain-0.1.31}/onboarding_assets/codex/shellbrain-usage-review/agents/openai.yaml +0 -0
- {shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start → shellbrain-0.1.31/onboarding_assets/codex/shellbrain-usage-review}/assets/shellbrain-small.svg +0 -0
- {shellbrain-0.1.29/app/onboarding_assets/codex/shellbrain-session-start → shellbrain-0.1.31/onboarding_assets/codex/shellbrain-usage-review}/assets/shellbrain_logo.png +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/setup.cfg +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/shellbrain.egg-info/dependency_links.txt +0 -0
- {shellbrain-0.1.29 → shellbrain-0.1.31}/shellbrain.egg-info/requires.txt +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shellbrain
|
|
3
|
+
Version: 0.1.31
|
|
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
|
|
@@ -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:
|
|
36
|
-
repo_id:
|
|
37
|
-
from_memory_id:
|
|
38
|
-
to_memory_id:
|
|
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:
|
|
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:
|
|
51
|
-
from_memory_id:
|
|
52
|
-
to_memory_id:
|
|
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:
|
|
56
|
-
salience:
|
|
57
|
-
edge_id:
|
|
58
|
-
problem_id:
|
|
59
|
-
episode_id:
|
|
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:
|
|
11
|
-
repo_id:
|
|
12
|
-
ref:
|
|
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:
|
|
21
|
-
evidence_id:
|
|
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:
|
|
29
|
-
evidence_id:
|
|
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,70 @@
|
|
|
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
|
+
BuildContextStrategy = Literal[
|
|
18
|
+
"deterministic_synthesis", "deterministic_only", "autonomous"
|
|
19
|
+
]
|
|
20
|
+
TokenCaptureQuality = Literal["exact", "estimated"]
|
|
21
|
+
InnerAgentRunStatus = Literal[
|
|
22
|
+
"ok",
|
|
23
|
+
"no_context",
|
|
24
|
+
"provider_unavailable",
|
|
25
|
+
"timeout",
|
|
26
|
+
"invalid_output",
|
|
27
|
+
"error",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class BuildContextSettings(_StrictModel):
|
|
32
|
+
"""Typed model/runtime settings for the build_context recall agent."""
|
|
33
|
+
|
|
34
|
+
strategy: BuildContextStrategy = "deterministic_synthesis"
|
|
35
|
+
provider: InnerAgentProviderName = Field(min_length=1)
|
|
36
|
+
model: str = Field(min_length=1)
|
|
37
|
+
reasoning: InnerAgentReasoningLevel
|
|
38
|
+
timeout_seconds: int = Field(ge=1, le=600)
|
|
39
|
+
max_private_reads: int = Field(default=0, ge=0, le=10)
|
|
40
|
+
max_candidate_tokens: int = Field(ge=1, le=200_000)
|
|
41
|
+
max_brief_tokens: int | None = Field(default=None, ge=1, le=100_000)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class BuildKnowledgeSettings(_StrictModel):
|
|
45
|
+
"""Typed model/runtime settings for the build_knowledge maintenance agent."""
|
|
46
|
+
|
|
47
|
+
provider: InnerAgentProviderName = Field(min_length=1)
|
|
48
|
+
model: str = Field(min_length=1)
|
|
49
|
+
reasoning: InnerAgentReasoningLevel
|
|
50
|
+
timeout_seconds: int = Field(ge=1, le=1200)
|
|
51
|
+
max_shellbrain_reads: int = Field(default=8, ge=1, le=50)
|
|
52
|
+
max_code_files: int = Field(default=24, ge=0, le=200)
|
|
53
|
+
max_write_commands: int = Field(default=20, ge=1, le=200)
|
|
54
|
+
idle_stable_seconds: int = Field(default=900, ge=60, le=86_400)
|
|
55
|
+
running_run_stale_seconds: int = Field(default=3600, ge=60, le=86_400)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class TeachKnowledgeSettings(_StrictModel):
|
|
59
|
+
"""Typed model/runtime settings for explicit teaching consolidation."""
|
|
60
|
+
|
|
61
|
+
provider: InnerAgentProviderName = Field(min_length=1)
|
|
62
|
+
model: str = Field(min_length=1)
|
|
63
|
+
reasoning: InnerAgentReasoningLevel
|
|
64
|
+
timeout_seconds: int = Field(ge=1, le=1200)
|
|
65
|
+
max_shellbrain_reads: int = Field(default=6, ge=1, le=50)
|
|
66
|
+
max_code_files: int = Field(default=5, ge=0, le=200)
|
|
67
|
+
max_write_commands: int = Field(default=12, ge=1, le=200)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
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")
|