superlocalmemory 4.1.13 → 4.1.15
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.
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +103 -0
- package/README.md +3 -3
- package/package.json +1 -8
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/CLAUDE.md +3 -3
- package/plugin/agents/slm-governance-advisor.md +1 -1
- package/plugin/agents/slm-loop-runner.md +1 -1
- package/plugin/agents/slm-memory-advisor.md +1 -1
- package/plugin/agents/slm-optimize-advisor.md +1 -1
- package/plugin/requirements.txt +1 -1
- package/plugin/skills/slm-cache/SKILL.md +1 -1
- package/plugin/skills/slm-compress/SKILL.md +1 -1
- package/plugin/skills/slm-governance/SKILL.md +1 -1
- package/plugin/skills/slm-graph/SKILL.md +1 -1
- package/plugin/skills/slm-loop/SKILL.md +1 -1
- package/plugin/skills/slm-mesh/SKILL.md +1 -1
- package/plugin/skills/slm-profile/SKILL.md +1 -1
- package/plugin/skills/slm-recall/SKILL.md +1 -1
- package/plugin/skills/slm-remember/SKILL.md +1 -1
- package/plugin/skills/slm-scope/SKILL.md +1 -1
- package/plugin/skills/slm-session/SKILL.md +1 -1
- package/plugin/skills/slm-status/SKILL.md +1 -1
- package/plugin-src/agents/slm-memory-advisor.md +1 -1
- package/plugin-src/agents/slm-optimize-advisor.md +1 -1
- package/plugin-src/rules/AGENTS.md +1 -1
- package/plugin-src/skills/slm-cache/SKILL.md +1 -1
- package/plugin-src/skills/slm-compress/SKILL.md +1 -1
- package/plugin-src/skills/slm-governance/SKILL.md +1 -1
- package/plugin-src/skills/slm-graph/SKILL.md +1 -1
- package/plugin-src/skills/slm-loop/SKILL.md +1 -1
- package/plugin-src/skills/slm-mesh/SKILL.md +1 -1
- package/plugin-src/skills/slm-profile/SKILL.md +1 -1
- package/plugin-src/skills/slm-recall/SKILL.md +1 -1
- package/plugin-src/skills/slm-remember/SKILL.md +1 -1
- package/plugin-src/skills/slm-scope/SKILL.md +1 -1
- package/plugin-src/skills/slm-session/SKILL.md +1 -1
- package/plugin-src/skills/slm-status/SKILL.md +1 -1
- package/scripts/postinstall.js +71 -2
- package/pyproject.toml +0 -250
- package/src/superlocalmemory/__init__.py +0 -82
- package/src/superlocalmemory/access/__init__.py +0 -3
- package/src/superlocalmemory/access/rbac.py +0 -575
- package/src/superlocalmemory/attribution/__init__.py +0 -9
- package/src/superlocalmemory/attribution/signer.py +0 -173
- package/src/superlocalmemory/attribution/watermark.py +0 -189
- package/src/superlocalmemory/brain/__init__.py +0 -5
- package/src/superlocalmemory/brain/truth.py +0 -418
- package/src/superlocalmemory/cli/__init__.py +0 -5
- package/src/superlocalmemory/cli/__main__.py +0 -17
- package/src/superlocalmemory/cli/_lazy_init.py +0 -115
- package/src/superlocalmemory/cli/cache_cmd.py +0 -198
- package/src/superlocalmemory/cli/commands.py +0 -4710
- package/src/superlocalmemory/cli/compress_cmd.py +0 -151
- package/src/superlocalmemory/cli/context_commands.py +0 -193
- package/src/superlocalmemory/cli/daemon.py +0 -909
- package/src/superlocalmemory/cli/db_migrate.py +0 -150
- package/src/superlocalmemory/cli/diagnostics_cmd.py +0 -101
- package/src/superlocalmemory/cli/escape_hatch.py +0 -220
- package/src/superlocalmemory/cli/evidence_cmd.py +0 -103
- package/src/superlocalmemory/cli/gdpr_cmd.py +0 -792
- package/src/superlocalmemory/cli/gdpr_io.py +0 -109
- package/src/superlocalmemory/cli/help_cmd.py +0 -197
- package/src/superlocalmemory/cli/host_upgrades.py +0 -189
- package/src/superlocalmemory/cli/ingest_cmd.py +0 -327
- package/src/superlocalmemory/cli/json_output.py +0 -81
- package/src/superlocalmemory/cli/loop_cmd.py +0 -187
- package/src/superlocalmemory/cli/main.py +0 -1145
- package/src/superlocalmemory/cli/mesh_cmd.py +0 -38
- package/src/superlocalmemory/cli/migrate_cmd.py +0 -55
- package/src/superlocalmemory/cli/ops_cmd.py +0 -281
- package/src/superlocalmemory/cli/optimize_cmd.py +0 -179
- package/src/superlocalmemory/cli/optimize_constants.py +0 -31
- package/src/superlocalmemory/cli/pending_store.py +0 -296
- package/src/superlocalmemory/cli/proxy_cmd.py +0 -108
- package/src/superlocalmemory/cli/scale_engine_cmd.py +0 -56
- package/src/superlocalmemory/cli/service_installer.py +0 -373
- package/src/superlocalmemory/cli/setup_wizard.py +0 -1162
- package/src/superlocalmemory/cli/summary_cmd.py +0 -215
- package/src/superlocalmemory/cli/version_banner.py +0 -202
- package/src/superlocalmemory/cli/wizard_v3426_options.py +0 -129
- package/src/superlocalmemory/code_graph/__init__.py +0 -46
- package/src/superlocalmemory/code_graph/blast_radius.py +0 -177
- package/src/superlocalmemory/code_graph/bridge/__init__.py +0 -36
- package/src/superlocalmemory/code_graph/bridge/entity_resolver.py +0 -490
- package/src/superlocalmemory/code_graph/bridge/event_listeners.py +0 -206
- package/src/superlocalmemory/code_graph/bridge/fact_enricher.py +0 -159
- package/src/superlocalmemory/code_graph/bridge/hebbian_linker.py +0 -170
- package/src/superlocalmemory/code_graph/bridge/maintenance.py +0 -220
- package/src/superlocalmemory/code_graph/bridge/temporal_checker.py +0 -152
- package/src/superlocalmemory/code_graph/changes.py +0 -363
- package/src/superlocalmemory/code_graph/communities.py +0 -299
- package/src/superlocalmemory/code_graph/config.py +0 -154
- package/src/superlocalmemory/code_graph/database.py +0 -526
- package/src/superlocalmemory/code_graph/extractors/__init__.py +0 -95
- package/src/superlocalmemory/code_graph/extractors/python.py +0 -413
- package/src/superlocalmemory/code_graph/extractors/typescript.py +0 -556
- package/src/superlocalmemory/code_graph/flows.py +0 -350
- package/src/superlocalmemory/code_graph/git_hooks.py +0 -226
- package/src/superlocalmemory/code_graph/graph_engine.py +0 -295
- package/src/superlocalmemory/code_graph/graph_store.py +0 -335
- package/src/superlocalmemory/code_graph/incremental.py +0 -200
- package/src/superlocalmemory/code_graph/models.py +0 -130
- package/src/superlocalmemory/code_graph/parser.py +0 -687
- package/src/superlocalmemory/code_graph/resolver.py +0 -321
- package/src/superlocalmemory/code_graph/search.py +0 -460
- package/src/superlocalmemory/code_graph/service.py +0 -95
- package/src/superlocalmemory/code_graph/watcher.py +0 -207
- package/src/superlocalmemory/compliance/__init__.py +0 -0
- package/src/superlocalmemory/compliance/abac.py +0 -204
- package/src/superlocalmemory/compliance/audit.py +0 -385
- package/src/superlocalmemory/compliance/eu_ai_act.py +0 -101
- package/src/superlocalmemory/compliance/gdpr.py +0 -1479
- package/src/superlocalmemory/compliance/lifecycle.py +0 -158
- package/src/superlocalmemory/compliance/retention.py +0 -415
- package/src/superlocalmemory/compliance/scheduler.py +0 -217
- package/src/superlocalmemory/contracts/__init__.py +0 -1
- package/src/superlocalmemory/contracts/schemas/agent-experience-v1.schema.json +0 -92
- package/src/superlocalmemory/contracts/schemas/agent-integration-contract-v2.schema.json +0 -46
- package/src/superlocalmemory/contracts/schemas/cognitive-turn-receipt-v1.schema.json +0 -59
- package/src/superlocalmemory/contracts/v402.py +0 -62
- package/src/superlocalmemory/core/__init__.py +0 -0
- package/src/superlocalmemory/core/actor_context.py +0 -166
- package/src/superlocalmemory/core/admission.py +0 -769
- package/src/superlocalmemory/core/backend_orchestrator.py +0 -637
- package/src/superlocalmemory/core/block_hygiene.py +0 -147
- package/src/superlocalmemory/core/community_summary.py +0 -267
- package/src/superlocalmemory/core/component_healer.py +0 -144
- package/src/superlocalmemory/core/component_registry.py +0 -514
- package/src/superlocalmemory/core/config.py +0 -2204
- package/src/superlocalmemory/core/consolidation_engine.py +0 -983
- package/src/superlocalmemory/core/context_cache.py +0 -574
- package/src/superlocalmemory/core/derivation_lineage.py +0 -246
- package/src/superlocalmemory/core/embedding_worker.py +0 -208
- package/src/superlocalmemory/core/embeddings.py +0 -1052
- package/src/superlocalmemory/core/engine.py +0 -1395
- package/src/superlocalmemory/core/engine_capabilities.py +0 -24
- package/src/superlocalmemory/core/engine_ingestion.py +0 -983
- package/src/superlocalmemory/core/engine_lock.py +0 -75
- package/src/superlocalmemory/core/engine_wiring.py +0 -776
- package/src/superlocalmemory/core/entity_community.py +0 -178
- package/src/superlocalmemory/core/error_envelope.py +0 -60
- package/src/superlocalmemory/core/evidence_bundle.py +0 -528
- package/src/superlocalmemory/core/fact_consolidator.py +0 -812
- package/src/superlocalmemory/core/file_lock.py +0 -92
- package/src/superlocalmemory/core/graph_analyzer.py +0 -456
- package/src/superlocalmemory/core/graph_metrics.py +0 -597
- package/src/superlocalmemory/core/graph_pruner.py +0 -939
- package/src/superlocalmemory/core/health_monitor.py +0 -338
- package/src/superlocalmemory/core/hooks.py +0 -65
- package/src/superlocalmemory/core/ingest_gate.py +0 -133
- package/src/superlocalmemory/core/ingest_policy.py +0 -38
- package/src/superlocalmemory/core/ingestion_command.py +0 -1042
- package/src/superlocalmemory/core/injection.py +0 -434
- package/src/superlocalmemory/core/install_detector.py +0 -131
- package/src/superlocalmemory/core/key_expander.py +0 -138
- package/src/superlocalmemory/core/lifecycle_state.py +0 -153
- package/src/superlocalmemory/core/maintenance.py +0 -777
- package/src/superlocalmemory/core/maintenance_scheduler.py +0 -507
- package/src/superlocalmemory/core/materialization_control.py +0 -20
- package/src/superlocalmemory/core/mcp_embedder_proxy.py +0 -89
- package/src/superlocalmemory/core/memory_health.py +0 -266
- package/src/superlocalmemory/core/mode_capability.py +0 -111
- package/src/superlocalmemory/core/modes.py +0 -168
- package/src/superlocalmemory/core/mutations.py +0 -688
- package/src/superlocalmemory/core/ollama_embedder.py +0 -266
- package/src/superlocalmemory/core/ollama_validator.py +0 -315
- package/src/superlocalmemory/core/operation_policy.py +0 -92
- package/src/superlocalmemory/core/operation_policy_registry.py +0 -542
- package/src/superlocalmemory/core/operation_request.py +0 -127
- package/src/superlocalmemory/core/ops_remediation.py +0 -542
- package/src/superlocalmemory/core/pii.py +0 -105
- package/src/superlocalmemory/core/platform_utils.py +0 -138
- package/src/superlocalmemory/core/profiles.py +0 -234
- package/src/superlocalmemory/core/progressive_abstraction.py +0 -208
- package/src/superlocalmemory/core/projection_drain.py +0 -380
- package/src/superlocalmemory/core/queue_consumer.py +0 -168
- package/src/superlocalmemory/core/ram_lock.py +0 -160
- package/src/superlocalmemory/core/rate_limit.py +0 -151
- package/src/superlocalmemory/core/recall_gate.py +0 -95
- package/src/superlocalmemory/core/recall_pipeline.py +0 -1337
- package/src/superlocalmemory/core/recall_queue.py +0 -377
- package/src/superlocalmemory/core/recall_worker.py +0 -414
- package/src/superlocalmemory/core/registry.py +0 -121
- package/src/superlocalmemory/core/remember_admission.py +0 -161
- package/src/superlocalmemory/core/remember_runtime.py +0 -1190
- package/src/superlocalmemory/core/remote_mode.py +0 -214
- package/src/superlocalmemory/core/reranker_worker.py +0 -338
- package/src/superlocalmemory/core/safe_fs.py +0 -108
- package/src/superlocalmemory/core/scale_autopromote.py +0 -196
- package/src/superlocalmemory/core/scale_engine.py +0 -915
- package/src/superlocalmemory/core/score_contract.py +0 -82
- package/src/superlocalmemory/core/security_primitives.py +0 -672
- package/src/superlocalmemory/core/session_identity.py +0 -98
- package/src/superlocalmemory/core/shadow_router.py +0 -319
- package/src/superlocalmemory/core/slm_disabled.py +0 -85
- package/src/superlocalmemory/core/status_contract.py +0 -108
- package/src/superlocalmemory/core/store_pipeline.py +0 -1404
- package/src/superlocalmemory/core/summarizer.py +0 -200
- package/src/superlocalmemory/core/tier_manager.py +0 -461
- package/src/superlocalmemory/core/topic_signature.py +0 -156
- package/src/superlocalmemory/core/transactions/__init__.py +0 -78
- package/src/superlocalmemory/core/transactions/concrete_owners.py +0 -604
- package/src/superlocalmemory/core/transactions/erasure.py +0 -825
- package/src/superlocalmemory/core/transactions/manifest.py +0 -255
- package/src/superlocalmemory/core/transactions/manifest_key.py +0 -155
- package/src/superlocalmemory/core/transactions/obligations.py +0 -272
- package/src/superlocalmemory/core/transactions/owners.py +0 -114
- package/src/superlocalmemory/core/transactions/reconciler.py +0 -285
- package/src/superlocalmemory/core/transactions/service.py +0 -330
- package/src/superlocalmemory/core/worker_pool.py +0 -377
- package/src/superlocalmemory/core/working_memory.py +0 -288
- package/src/superlocalmemory/dynamics/__init__.py +0 -0
- package/src/superlocalmemory/dynamics/activation_guided_quantization.py +0 -374
- package/src/superlocalmemory/dynamics/eap_scheduler.py +0 -294
- package/src/superlocalmemory/dynamics/ebbinghaus_langevin_coupling.py +0 -171
- package/src/superlocalmemory/dynamics/fisher_langevin_coupling.py +0 -227
- package/src/superlocalmemory/encoding/__init__.py +0 -0
- package/src/superlocalmemory/encoding/auto_linker.py +0 -308
- package/src/superlocalmemory/encoding/cognitive_consolidator.py +0 -899
- package/src/superlocalmemory/encoding/consolidator.py +0 -472
- package/src/superlocalmemory/encoding/context_generator.py +0 -175
- package/src/superlocalmemory/encoding/emotional.py +0 -189
- package/src/superlocalmemory/encoding/entity_reflexion.py +0 -200
- package/src/superlocalmemory/encoding/entity_resolver.py +0 -687
- package/src/superlocalmemory/encoding/entropy_gate.py +0 -101
- package/src/superlocalmemory/encoding/fact_extractor.py +0 -877
- package/src/superlocalmemory/encoding/foresight.py +0 -93
- package/src/superlocalmemory/encoding/graph_builder.py +0 -346
- package/src/superlocalmemory/encoding/observation_builder.py +0 -177
- package/src/superlocalmemory/encoding/prospective_markers.py +0 -262
- package/src/superlocalmemory/encoding/scene_builder.py +0 -410
- package/src/superlocalmemory/encoding/signal_inference.py +0 -90
- package/src/superlocalmemory/encoding/temporal_parser.py +0 -432
- package/src/superlocalmemory/encoding/temporal_validator.py +0 -572
- package/src/superlocalmemory/encoding/type_router.py +0 -237
- package/src/superlocalmemory/evaluation/__init__.py +0 -13
- package/src/superlocalmemory/evaluation/calibration.py +0 -308
- package/src/superlocalmemory/evolution/__init__.py +0 -29
- package/src/superlocalmemory/evolution/blind_verifier.py +0 -122
- package/src/superlocalmemory/evolution/budget.py +0 -356
- package/src/superlocalmemory/evolution/evolution_store.py +0 -619
- package/src/superlocalmemory/evolution/llm_dispatch.py +0 -559
- package/src/superlocalmemory/evolution/model_selection.py +0 -175
- package/src/superlocalmemory/evolution/mutation_generator.py +0 -226
- package/src/superlocalmemory/evolution/skill_activator.py +0 -270
- package/src/superlocalmemory/evolution/skill_evolver.py +0 -928
- package/src/superlocalmemory/evolution/triggers.py +0 -376
- package/src/superlocalmemory/evolution/types.py +0 -114
- package/src/superlocalmemory/graph/__init__.py +0 -9
- package/src/superlocalmemory/graph/cozo_adjacency.py +0 -122
- package/src/superlocalmemory/graph/cozo_backend.py +0 -751
- package/src/superlocalmemory/hooks/__init__.py +0 -3
- package/src/superlocalmemory/hooks/_outcome_common.py +0 -523
- package/src/superlocalmemory/hooks/adapter_base.py +0 -347
- package/src/superlocalmemory/hooks/antigravity_adapter.py +0 -171
- package/src/superlocalmemory/hooks/auto_capture.py +0 -133
- package/src/superlocalmemory/hooks/auto_invoker.py +0 -521
- package/src/superlocalmemory/hooks/auto_parameterize.py +0 -147
- package/src/superlocalmemory/hooks/auto_recall.py +0 -191
- package/src/superlocalmemory/hooks/auto_recall_hook.py +0 -251
- package/src/superlocalmemory/hooks/before_web_hook.py +0 -131
- package/src/superlocalmemory/hooks/claude_code_hooks.py +0 -637
- package/src/superlocalmemory/hooks/codex_assets.py +0 -251
- package/src/superlocalmemory/hooks/codex_hooks.py +0 -186
- package/src/superlocalmemory/hooks/context_payload.py +0 -311
- package/src/superlocalmemory/hooks/copilot_adapter.py +0 -208
- package/src/superlocalmemory/hooks/cross_platform_connector.py +0 -90
- package/src/superlocalmemory/hooks/cursor_adapter.py +0 -173
- package/src/superlocalmemory/hooks/hook_daemon.py +0 -295
- package/src/superlocalmemory/hooks/hook_handlers.py +0 -822
- package/src/superlocalmemory/hooks/ide_connector.py +0 -246
- package/src/superlocalmemory/hooks/memory_protocol.py +0 -158
- package/src/superlocalmemory/hooks/portable_kit.py +0 -755
- package/src/superlocalmemory/hooks/post_tool_async_hook.py +0 -183
- package/src/superlocalmemory/hooks/post_tool_outcome_hook.py +0 -351
- package/src/superlocalmemory/hooks/prewarm_auth.py +0 -187
- package/src/superlocalmemory/hooks/rules_engine.py +0 -99
- package/src/superlocalmemory/hooks/session_registry.py +0 -330
- package/src/superlocalmemory/hooks/stop_outcome_hook.py +0 -138
- package/src/superlocalmemory/hooks/sync_loop.py +0 -114
- package/src/superlocalmemory/hooks/topic_shift_hook.py +0 -302
- package/src/superlocalmemory/hooks/user_prompt_hook.py +0 -131
- package/src/superlocalmemory/hooks/user_prompt_rehash_hook.py +0 -210
- package/src/superlocalmemory/infra/__init__.py +0 -3
- package/src/superlocalmemory/infra/auth_middleware.py +0 -145
- package/src/superlocalmemory/infra/backup.py +0 -974
- package/src/superlocalmemory/infra/backup_obligations.py +0 -423
- package/src/superlocalmemory/infra/cache_manager.py +0 -267
- package/src/superlocalmemory/infra/cloud_backup.py +0 -788
- package/src/superlocalmemory/infra/daemon_identity.py +0 -300
- package/src/superlocalmemory/infra/data_root.py +0 -238
- package/src/superlocalmemory/infra/event_bus.py +0 -637
- package/src/superlocalmemory/infra/local_diagnostics.py +0 -327
- package/src/superlocalmemory/infra/pid_manager.py +0 -193
- package/src/superlocalmemory/infra/process_identity.py +0 -180
- package/src/superlocalmemory/infra/process_reaper.py +0 -624
- package/src/superlocalmemory/infra/rate_limiter.py +0 -228
- package/src/superlocalmemory/infra/self_heal.py +0 -401
- package/src/superlocalmemory/infra/version_integrity.py +0 -229
- package/src/superlocalmemory/ingestion/__init__.py +0 -13
- package/src/superlocalmemory/ingestion/adapter_manager.py +0 -255
- package/src/superlocalmemory/ingestion/base_adapter.py +0 -171
- package/src/superlocalmemory/ingestion/calendar_adapter.py +0 -349
- package/src/superlocalmemory/ingestion/credentials.py +0 -125
- package/src/superlocalmemory/ingestion/gmail_adapter.py +0 -378
- package/src/superlocalmemory/ingestion/parsers.py +0 -100
- package/src/superlocalmemory/ingestion/transcript_adapter.py +0 -161
- package/src/superlocalmemory/integrations/__init__.py +0 -1
- package/src/superlocalmemory/integrations/bounded_loops_mcp.py +0 -431
- package/src/superlocalmemory/integrations/bounded_loops_v051.py +0 -236
- package/src/superlocalmemory/learning/__init__.py +0 -0
- package/src/superlocalmemory/learning/adaptive.py +0 -172
- package/src/superlocalmemory/learning/arm_catalog.py +0 -97
- package/src/superlocalmemory/learning/assertion_miner.py +0 -403
- package/src/superlocalmemory/learning/bandit.py +0 -654
- package/src/superlocalmemory/learning/bandit_cache.py +0 -131
- package/src/superlocalmemory/learning/behavioral.py +0 -542
- package/src/superlocalmemory/learning/bootstrap.py +0 -298
- package/src/superlocalmemory/learning/consolidation_cycle.py +0 -398
- package/src/superlocalmemory/learning/consolidation_quantization_worker.py +0 -115
- package/src/superlocalmemory/learning/consolidation_worker.py +0 -261
- package/src/superlocalmemory/learning/cross_project.py +0 -408
- package/src/superlocalmemory/learning/database.py +0 -698
- package/src/superlocalmemory/learning/dedup_hnsw.py +0 -413
- package/src/superlocalmemory/learning/engagement.py +0 -487
- package/src/superlocalmemory/learning/engagement_features.py +0 -279
- package/src/superlocalmemory/learning/ensemble.py +0 -309
- package/src/superlocalmemory/learning/entity_compiler.py +0 -356
- package/src/superlocalmemory/learning/fact_outcome_joins.py +0 -207
- package/src/superlocalmemory/learning/features.py +0 -138
- package/src/superlocalmemory/learning/feedback.py +0 -724
- package/src/superlocalmemory/learning/forgetting_scheduler.py +0 -375
- package/src/superlocalmemory/learning/hnsw_dedup.py +0 -69
- package/src/superlocalmemory/learning/labeler.py +0 -85
- package/src/superlocalmemory/learning/legacy_migration.py +0 -316
- package/src/superlocalmemory/learning/lightgbm_subprocess.py +0 -236
- package/src/superlocalmemory/learning/memory_merge.py +0 -175
- package/src/superlocalmemory/learning/model_cache.py +0 -267
- package/src/superlocalmemory/learning/model_rollback.py +0 -281
- package/src/superlocalmemory/learning/outcome_queue.py +0 -306
- package/src/superlocalmemory/learning/outcomes.py +0 -286
- package/src/superlocalmemory/learning/pattern_miner.py +0 -465
- package/src/superlocalmemory/learning/pattern_miner_constants.py +0 -90
- package/src/superlocalmemory/learning/pcos.py +0 -291
- package/src/superlocalmemory/learning/project_context.py +0 -366
- package/src/superlocalmemory/learning/propensity.py +0 -131
- package/src/superlocalmemory/learning/ranker.py +0 -300
- package/src/superlocalmemory/learning/ranker_common.py +0 -163
- package/src/superlocalmemory/learning/ranker_retrain_legacy.py +0 -210
- package/src/superlocalmemory/learning/ranker_retrain_online.py +0 -423
- package/src/superlocalmemory/learning/reward.py +0 -888
- package/src/superlocalmemory/learning/reward_archive.py +0 -223
- package/src/superlocalmemory/learning/reward_boost.py +0 -211
- package/src/superlocalmemory/learning/reward_from_outcomes.py +0 -365
- package/src/superlocalmemory/learning/reward_model.py +0 -144
- package/src/superlocalmemory/learning/reward_proxy.py +0 -578
- package/src/superlocalmemory/learning/shadow_test.py +0 -524
- package/src/superlocalmemory/learning/signal_kinds.py +0 -79
- package/src/superlocalmemory/learning/signal_worker.py +0 -268
- package/src/superlocalmemory/learning/signals.py +0 -646
- package/src/superlocalmemory/learning/skill_performance_miner.py +0 -422
- package/src/superlocalmemory/learning/source_quality.py +0 -828
- package/src/superlocalmemory/learning/trigram_index.py +0 -548
- package/src/superlocalmemory/learning/workflows.py +0 -309
- package/src/superlocalmemory/llm/__init__.py +0 -0
- package/src/superlocalmemory/llm/backbone.py +0 -364
- package/src/superlocalmemory/loops/__init__.py +0 -58
- package/src/superlocalmemory/loops/budget.py +0 -58
- package/src/superlocalmemory/loops/engine.py +0 -174
- package/src/superlocalmemory/loops/ledger.py +0 -298
- package/src/superlocalmemory/loops/models.py +0 -152
- package/src/superlocalmemory/loops/rules.py +0 -52
- package/src/superlocalmemory/math/__init__.py +0 -0
- package/src/superlocalmemory/math/ebbinghaus.py +0 -352
- package/src/superlocalmemory/math/fisher.py +0 -356
- package/src/superlocalmemory/math/fisher_quantized.py +0 -255
- package/src/superlocalmemory/math/hopfield.py +0 -282
- package/src/superlocalmemory/math/langevin.py +0 -411
- package/src/superlocalmemory/math/polar_quant.py +0 -414
- package/src/superlocalmemory/math/qjl.py +0 -115
- package/src/superlocalmemory/math/sheaf.py +0 -261
- package/src/superlocalmemory/math/turbo_quant.py +0 -318
- package/src/superlocalmemory/mcp/__init__.py +0 -0
- package/src/superlocalmemory/mcp/_daemon_proxy.py +0 -203
- package/src/superlocalmemory/mcp/_pool_adapter.py +0 -181
- package/src/superlocalmemory/mcp/_stdin_guard.py +0 -60
- package/src/superlocalmemory/mcp/agent_context.py +0 -115
- package/src/superlocalmemory/mcp/cli_fallback.py +0 -602
- package/src/superlocalmemory/mcp/http_transport.py +0 -85
- package/src/superlocalmemory/mcp/profiles.py +0 -154
- package/src/superlocalmemory/mcp/resources.py +0 -281
- package/src/superlocalmemory/mcp/server.py +0 -480
- package/src/superlocalmemory/mcp/session_binding.py +0 -98
- package/src/superlocalmemory/mcp/shared.py +0 -112
- package/src/superlocalmemory/mcp/tools.py +0 -18
- package/src/superlocalmemory/mcp/tools_active.py +0 -958
- package/src/superlocalmemory/mcp/tools_brain.py +0 -298
- package/src/superlocalmemory/mcp/tools_code_graph.py +0 -1717
- package/src/superlocalmemory/mcp/tools_context.py +0 -239
- package/src/superlocalmemory/mcp/tools_core.py +0 -1112
- package/src/superlocalmemory/mcp/tools_evolution.py +0 -343
- package/src/superlocalmemory/mcp/tools_learning.py +0 -393
- package/src/superlocalmemory/mcp/tools_loops.py +0 -345
- package/src/superlocalmemory/mcp/tools_mesh.py +0 -429
- package/src/superlocalmemory/mcp/tools_ops.py +0 -115
- package/src/superlocalmemory/mcp/tools_optimize.py +0 -322
- package/src/superlocalmemory/mcp/tools_summaries.py +0 -147
- package/src/superlocalmemory/mcp/tools_v28.py +0 -292
- package/src/superlocalmemory/mcp/tools_v3.py +0 -398
- package/src/superlocalmemory/mcp/tools_v33.py +0 -507
- package/src/superlocalmemory/mesh/__init__.py +0 -12
- package/src/superlocalmemory/mesh/broker.py +0 -812
- package/src/superlocalmemory/mesh/broker_security.py +0 -470
- package/src/superlocalmemory/mesh/discovery.py +0 -365
- package/src/superlocalmemory/mesh/lock_protocol.py +0 -313
- package/src/superlocalmemory/mesh/node_identity.py +0 -97
- package/src/superlocalmemory/mesh/outbox_remote.py +0 -429
- package/src/superlocalmemory/mesh/remote_sync.py +0 -829
- package/src/superlocalmemory/mesh/state_sync.py +0 -286
- package/src/superlocalmemory/migrations/__init__.py +0 -5
- package/src/superlocalmemory/migrations/v3_4_25_to_v3_4_26.py +0 -144
- package/src/superlocalmemory/optimize/NOTICE +0 -6
- package/src/superlocalmemory/optimize/__init__.py +0 -0
- package/src/superlocalmemory/optimize/adapters/__init__.py +0 -68
- package/src/superlocalmemory/optimize/adapters/_agent_registry.py +0 -120
- package/src/superlocalmemory/optimize/adapters/anthropic_adapter.py +0 -112
- package/src/superlocalmemory/optimize/adapters/openai_adapter.py +0 -122
- package/src/superlocalmemory/optimize/adapters/wrap.py +0 -228
- package/src/superlocalmemory/optimize/cache/__init__.py +0 -31
- package/src/superlocalmemory/optimize/cache/boundary_store.py +0 -488
- package/src/superlocalmemory/optimize/cache/centroid_store.py +0 -199
- package/src/superlocalmemory/optimize/cache/context_key.py +0 -67
- package/src/superlocalmemory/optimize/cache/exact.py +0 -88
- package/src/superlocalmemory/optimize/cache/invalidation.py +0 -36
- package/src/superlocalmemory/optimize/cache/key_builder.py +0 -111
- package/src/superlocalmemory/optimize/cache/manager.py +0 -737
- package/src/superlocalmemory/optimize/cache/semantic.py +0 -637
- package/src/superlocalmemory/optimize/cache/stampede.py +0 -50
- package/src/superlocalmemory/optimize/compress/__init__.py +0 -17
- package/src/superlocalmemory/optimize/compress/align.py +0 -159
- package/src/superlocalmemory/optimize/compress/ccr.py +0 -116
- package/src/superlocalmemory/optimize/compress/prose_llmlingua.py +0 -71
- package/src/superlocalmemory/optimize/compress/router.py +0 -667
- package/src/superlocalmemory/optimize/config/__init__.py +0 -56
- package/src/superlocalmemory/optimize/config/defaults.py +0 -43
- package/src/superlocalmemory/optimize/config/schema.py +0 -327
- package/src/superlocalmemory/optimize/config/store.py +0 -270
- package/src/superlocalmemory/optimize/metrics/__init__.py +0 -8
- package/src/superlocalmemory/optimize/metrics/counters.py +0 -155
- package/src/superlocalmemory/optimize/metrics/estimator.py +0 -87
- package/src/superlocalmemory/optimize/metrics/exporters.py +0 -77
- package/src/superlocalmemory/optimize/metrics/persistence.py +0 -115
- package/src/superlocalmemory/optimize/proxy/__init__.py +0 -28
- package/src/superlocalmemory/optimize/proxy/_helpers.py +0 -730
- package/src/superlocalmemory/optimize/proxy/anthropic_surface.py +0 -375
- package/src/superlocalmemory/optimize/proxy/capture.py +0 -550
- package/src/superlocalmemory/optimize/proxy/gemini_surface.py +0 -528
- package/src/superlocalmemory/optimize/proxy/lifecycle.py +0 -126
- package/src/superlocalmemory/optimize/proxy/openai_surface.py +0 -465
- package/src/superlocalmemory/optimize/proxy/server.py +0 -199
- package/src/superlocalmemory/optimize/proxy/vertex_surface.py +0 -246
- package/src/superlocalmemory/optimize/storage/__init__.py +0 -0
- package/src/superlocalmemory/optimize/storage/db.py +0 -1185
- package/src/superlocalmemory/optimize/storage/schema.py +0 -205
- package/src/superlocalmemory/parameterization/__init__.py +0 -47
- package/src/superlocalmemory/parameterization/cross_project.py +0 -12
- package/src/superlocalmemory/parameterization/pattern_extractor.py +0 -584
- package/src/superlocalmemory/parameterization/pii_filter.py +0 -106
- package/src/superlocalmemory/parameterization/prompt_injector.py +0 -219
- package/src/superlocalmemory/parameterization/prompt_lifecycle.py +0 -281
- package/src/superlocalmemory/parameterization/soft_prompt_generator.py +0 -542
- package/src/superlocalmemory/parameterization/workflow_miner.py +0 -17
- package/src/superlocalmemory/reliability/__init__.py +0 -45
- package/src/superlocalmemory/reliability/join_liveness.py +0 -301
- package/src/superlocalmemory/reliability/prior_distance.py +0 -243
- package/src/superlocalmemory/retrieval/__init__.py +0 -0
- package/src/superlocalmemory/retrieval/agentic.py +0 -367
- package/src/superlocalmemory/retrieval/ann_index.py +0 -235
- package/src/superlocalmemory/retrieval/bm25_channel.py +0 -451
- package/src/superlocalmemory/retrieval/bridge_discovery.py +0 -253
- package/src/superlocalmemory/retrieval/channel_registry.py +0 -154
- package/src/superlocalmemory/retrieval/channel_status.py +0 -117
- package/src/superlocalmemory/retrieval/engine.py +0 -1615
- package/src/superlocalmemory/retrieval/entity_channel.py +0 -994
- package/src/superlocalmemory/retrieval/forgetting_filter.py +0 -160
- package/src/superlocalmemory/retrieval/fusion.py +0 -81
- package/src/superlocalmemory/retrieval/graph_adjacency.py +0 -219
- package/src/superlocalmemory/retrieval/hopfield_channel.py +0 -465
- package/src/superlocalmemory/retrieval/profile_channel.py +0 -105
- package/src/superlocalmemory/retrieval/quantization_aware_search.py +0 -147
- package/src/superlocalmemory/retrieval/remote_reranker.py +0 -758
- package/src/superlocalmemory/retrieval/reranker.py +0 -674
- package/src/superlocalmemory/retrieval/scope_policy.py +0 -126
- package/src/superlocalmemory/retrieval/semantic_channel.py +0 -638
- package/src/superlocalmemory/retrieval/spreading.py +0 -288
- package/src/superlocalmemory/retrieval/spreading_activation.py +0 -616
- package/src/superlocalmemory/retrieval/strategy.py +0 -248
- package/src/superlocalmemory/retrieval/temporal_channel.py +0 -433
- package/src/superlocalmemory/retrieval/temporal_frame.py +0 -102
- package/src/superlocalmemory/retrieval/temporal_utils.py +0 -122
- package/src/superlocalmemory/retrieval/temporal_validity_filter.py +0 -499
- package/src/superlocalmemory/retrieval/time_window.py +0 -181
- package/src/superlocalmemory/retrieval/vector_store.py +0 -863
- package/src/superlocalmemory/server/__init__.py +0 -1
- package/src/superlocalmemory/server/api.py +0 -310
- package/src/superlocalmemory/server/asset_versions.py +0 -171
- package/src/superlocalmemory/server/bandit_loops.py +0 -158
- package/src/superlocalmemory/server/config_file.py +0 -90
- package/src/superlocalmemory/server/consolidation_runner.py +0 -140
- package/src/superlocalmemory/server/egress_policy.py +0 -258
- package/src/superlocalmemory/server/loopback.py +0 -85
- package/src/superlocalmemory/server/middleware/__init__.py +0 -11
- package/src/superlocalmemory/server/middleware/security_headers.py +0 -144
- package/src/superlocalmemory/server/origin.py +0 -55
- package/src/superlocalmemory/server/profile_runtime.py +0 -515
- package/src/superlocalmemory/server/rbac_enforce.py +0 -194
- package/src/superlocalmemory/server/recall_health.py +0 -343
- package/src/superlocalmemory/server/recall_serializer.py +0 -320
- package/src/superlocalmemory/server/route_mutations.py +0 -104
- package/src/superlocalmemory/server/routes/__init__.py +0 -4
- package/src/superlocalmemory/server/routes/abstraction.py +0 -314
- package/src/superlocalmemory/server/routes/adapters.py +0 -63
- package/src/superlocalmemory/server/routes/agents.py +0 -303
- package/src/superlocalmemory/server/routes/backup.py +0 -869
- package/src/superlocalmemory/server/routes/behavioral.py +0 -659
- package/src/superlocalmemory/server/routes/brain.py +0 -1892
- package/src/superlocalmemory/server/routes/chat.py +0 -393
- package/src/superlocalmemory/server/routes/compliance.py +0 -533
- package/src/superlocalmemory/server/routes/config_api.py +0 -703
- package/src/superlocalmemory/server/routes/data_io.py +0 -329
- package/src/superlocalmemory/server/routes/entity.py +0 -237
- package/src/superlocalmemory/server/routes/events.py +0 -214
- package/src/superlocalmemory/server/routes/evolution.py +0 -510
- package/src/superlocalmemory/server/routes/helpers.py +0 -499
- package/src/superlocalmemory/server/routes/ingest.py +0 -137
- package/src/superlocalmemory/server/routes/insights.py +0 -366
- package/src/superlocalmemory/server/routes/learning.py +0 -834
- package/src/superlocalmemory/server/routes/learning_telemetry.py +0 -154
- package/src/superlocalmemory/server/routes/lifecycle.py +0 -184
- package/src/superlocalmemory/server/routes/memories.py +0 -1661
- package/src/superlocalmemory/server/routes/mesh.py +0 -517
- package/src/superlocalmemory/server/routes/mesh_lock.py +0 -54
- package/src/superlocalmemory/server/routes/mesh_state.py +0 -63
- package/src/superlocalmemory/server/routes/optimize.py +0 -197
- package/src/superlocalmemory/server/routes/prewarm.py +0 -173
- package/src/superlocalmemory/server/routes/profiles.py +0 -292
- package/src/superlocalmemory/server/routes/ratelimit.py +0 -132
- package/src/superlocalmemory/server/routes/rbac.py +0 -366
- package/src/superlocalmemory/server/routes/stats.py +0 -385
- package/src/superlocalmemory/server/routes/tiers.py +0 -222
- package/src/superlocalmemory/server/routes/timeline.py +0 -258
- package/src/superlocalmemory/server/routes/token.py +0 -90
- package/src/superlocalmemory/server/routes/v3_api.py +0 -3023
- package/src/superlocalmemory/server/routes/ws.py +0 -171
- package/src/superlocalmemory/server/security_middleware.py +0 -89
- package/src/superlocalmemory/server/ui.py +0 -354
- package/src/superlocalmemory/server/unified_daemon.py +0 -6326
- package/src/superlocalmemory/server/write_identity.py +0 -195
- package/src/superlocalmemory/storage/__init__.py +0 -0
- package/src/superlocalmemory/storage/_migration_internals.py +0 -638
- package/src/superlocalmemory/storage/_schema_version.py +0 -174
- package/src/superlocalmemory/storage/access_log.py +0 -170
- package/src/superlocalmemory/storage/admission_codec.py +0 -129
- package/src/superlocalmemory/storage/admission_journal.py +0 -843
- package/src/superlocalmemory/storage/agent_experience.py +0 -546
- package/src/superlocalmemory/storage/backup.py +0 -531
- package/src/superlocalmemory/storage/correction_cases.py +0 -670
- package/src/superlocalmemory/storage/database.py +0 -3180
- package/src/superlocalmemory/storage/deferred_writes.py +0 -209
- package/src/superlocalmemory/storage/embedding_codec.py +0 -200
- package/src/superlocalmemory/storage/embedding_migrator.py +0 -672
- package/src/superlocalmemory/storage/erasure_fence.py +0 -45
- package/src/superlocalmemory/storage/execution_learning.py +0 -285
- package/src/superlocalmemory/storage/external_evidence.py +0 -359
- package/src/superlocalmemory/storage/generation_fence.py +0 -63
- package/src/superlocalmemory/storage/lineage_retention.py +0 -236
- package/src/superlocalmemory/storage/logical_edges.py +0 -86
- package/src/superlocalmemory/storage/memory_write.py +0 -115
- package/src/superlocalmemory/storage/migration_runner.py +0 -895
- package/src/superlocalmemory/storage/migration_v33.py +0 -140
- package/src/superlocalmemory/storage/migrations/M001_add_signal_features_columns.py +0 -67
- package/src/superlocalmemory/storage/migrations/M002_model_state_history.py +0 -107
- package/src/superlocalmemory/storage/migrations/M003_migration_log.py +0 -38
- package/src/superlocalmemory/storage/migrations/M004_cross_platform_sync_log.py +0 -46
- package/src/superlocalmemory/storage/migrations/M005_bandit_tables.py +0 -75
- package/src/superlocalmemory/storage/migrations/M006_action_outcomes_reward.py +0 -75
- package/src/superlocalmemory/storage/migrations/M007_pending_outcomes.py +0 -63
- package/src/superlocalmemory/storage/migrations/M009_model_lineage.py +0 -94
- package/src/superlocalmemory/storage/migrations/M010_evolution_config.py +0 -80
- package/src/superlocalmemory/storage/migrations/M011_archive_and_merge.py +0 -87
- package/src/superlocalmemory/storage/migrations/M012_shadow_observations.py +0 -72
- package/src/superlocalmemory/storage/migrations/M013_bi_temporal_columns.py +0 -55
- package/src/superlocalmemory/storage/migrations/M014_v345_scale_ready.py +0 -45
- package/src/superlocalmemory/storage/migrations/M015_add_pinned_column.py +0 -58
- package/src/superlocalmemory/storage/migrations/M016_add_scope_support.py +0 -120
- package/src/superlocalmemory/storage/migrations/M017_ccq_scope_column.py +0 -79
- package/src/superlocalmemory/storage/migrations/M018_ingestion_operations.py +0 -120
- package/src/superlocalmemory/storage/migrations/M019_derivation_lineage.py +0 -54
- package/src/superlocalmemory/storage/migrations/M020_model_state_integrity.py +0 -52
- package/src/superlocalmemory/storage/migrations/M021_ingestion_log_profile.py +0 -108
- package/src/superlocalmemory/storage/migrations/M022_entity_aliases_profile.py +0 -86
- package/src/superlocalmemory/storage/migrations/M023_mesh_profile_isolation.py +0 -194
- package/src/superlocalmemory/storage/migrations/M024_rbac_users_roles.py +0 -87
- package/src/superlocalmemory/storage/migrations/M025_perf_indexes.py +0 -90
- package/src/superlocalmemory/storage/migrations/M026_rbac_memberships_fk.py +0 -136
- package/src/superlocalmemory/storage/migrations/M027_transferable_patterns_profile.py +0 -163
- package/src/superlocalmemory/storage/migrations/M028_fact_entity_associations.py +0 -305
- package/src/superlocalmemory/storage/migrations/M029_behavioral_history_indexes.py +0 -137
- package/src/superlocalmemory/storage/migrations/M030_entity_explorer_indexes.py +0 -93
- package/src/superlocalmemory/storage/migrations/M031_dead_letter_operations.py +0 -80
- package/src/superlocalmemory/storage/migrations/M032_write_coordinator_admission.py +0 -188
- package/src/superlocalmemory/storage/migrations/M033_projection_transactions.py +0 -148
- package/src/superlocalmemory/storage/migrations/M034_obligation_integrity.py +0 -58
- package/src/superlocalmemory/storage/migrations/M035_erasure_receipts.py +0 -113
- package/src/superlocalmemory/storage/migrations/M036_vector_row_map.py +0 -107
- package/src/superlocalmemory/storage/migrations/M037_manifest_hmac_version.py +0 -162
- package/src/superlocalmemory/storage/migrations/M038_learning_feedback_channel.py +0 -77
- package/src/superlocalmemory/storage/migrations/M039_scene_fact_members.py +0 -137
- package/src/superlocalmemory/storage/migrations/M040_agent_experience_receipts.py +0 -254
- package/src/superlocalmemory/storage/migrations/M041_external_evidence_receipts.py +0 -189
- package/src/superlocalmemory/storage/migrations/M042_correction_case_ledger.py +0 -245
- package/src/superlocalmemory/storage/migrations/M043_quarantine_display_summaries.py +0 -512
- package/src/superlocalmemory/storage/migrations/M044_play_carries_its_own_evidence.py +0 -127
- package/src/superlocalmemory/storage/migrations/M045_fact_outcome_score.py +0 -158
- package/src/superlocalmemory/storage/migrations/M046_prospective_memory_has_its_own_name.py +0 -620
- package/src/superlocalmemory/storage/migrations/M047_fisher_vectors_are_stored_like_every_other_vector.py +0 -306
- package/src/superlocalmemory/storage/migrations/M048_upcoming_holds_only_what_is_upcoming.py +0 -229
- package/src/superlocalmemory/storage/migrations/M049_a_schema_version_marker_is_one_row.py +0 -201
- package/src/superlocalmemory/storage/migrations/M050_execution_learning_v2.py +0 -70
- package/src/superlocalmemory/storage/migrations/__init__.py +0 -103
- package/src/superlocalmemory/storage/migrations.py +0 -333
- package/src/superlocalmemory/storage/models.py +0 -500
- package/src/superlocalmemory/storage/projection_outbox.py +0 -346
- package/src/superlocalmemory/storage/quantized_store.py +0 -280
- package/src/superlocalmemory/storage/read_connection.py +0 -115
- package/src/superlocalmemory/storage/retention_policy.py +0 -860
- package/src/superlocalmemory/storage/schema.py +0 -1108
- package/src/superlocalmemory/storage/schema_code_graph.py +0 -282
- package/src/superlocalmemory/storage/schema_v32.py +0 -382
- package/src/superlocalmemory/storage/schema_v3410.py +0 -159
- package/src/superlocalmemory/storage/schema_v3411.py +0 -149
- package/src/superlocalmemory/storage/schema_v343.py +0 -315
- package/src/superlocalmemory/storage/schema_v345.py +0 -109
- package/src/superlocalmemory/storage/schema_v347.py +0 -140
- package/src/superlocalmemory/storage/sqlite_vectors.py +0 -169
- package/src/superlocalmemory/storage/v2_migrator.py +0 -466
- package/src/superlocalmemory/storage/write_coordinator.py +0 -949
- package/src/superlocalmemory/storage/write_lock.py +0 -88
- package/src/superlocalmemory/summaries/__init__.py +0 -37
- package/src/superlocalmemory/summaries/base.py +0 -267
- package/src/superlocalmemory/summaries/daily_reflection.py +0 -340
- package/src/superlocalmemory/summaries/non_answer.py +0 -223
- package/src/superlocalmemory/summaries/project_work_log.py +0 -440
- package/src/superlocalmemory/summaries/session_summary.py +0 -311
- package/src/superlocalmemory/trust/__init__.py +0 -0
- package/src/superlocalmemory/trust/gate.py +0 -171
- package/src/superlocalmemory/trust/provenance.py +0 -124
- package/src/superlocalmemory/trust/scorer.py +0 -413
- package/src/superlocalmemory/trust/signals.py +0 -153
- package/src/superlocalmemory/ui/assets/slm-icon-white.svg +0 -64
- package/src/superlocalmemory/ui/assets/slm-icon.svg +0 -36
- package/src/superlocalmemory/ui/css/brain.css +0 -409
- package/src/superlocalmemory/ui/css/design-system.css +0 -696
- package/src/superlocalmemory/ui/css/legacy-dashboard.css +0 -663
- package/src/superlocalmemory/ui/css/neural-glass.css +0 -1599
- package/src/superlocalmemory/ui/css/od-bridge.css +0 -158
- package/src/superlocalmemory/ui/favicon.svg +0 -36
- package/src/superlocalmemory/ui/index.html +0 -1638
- package/src/superlocalmemory/ui/js/agents.js +0 -192
- package/src/superlocalmemory/ui/js/auto-settings.js +0 -624
- package/src/superlocalmemory/ui/js/brain.js +0 -1400
- package/src/superlocalmemory/ui/js/clusters.js +0 -326
- package/src/superlocalmemory/ui/js/compliance.js +0 -307
- package/src/superlocalmemory/ui/js/core.js +0 -566
- package/src/superlocalmemory/ui/js/dashboard.js +0 -503
- package/src/superlocalmemory/ui/js/event-delegation.js +0 -113
- package/src/superlocalmemory/ui/js/events.js +0 -178
- package/src/superlocalmemory/ui/js/fact-detail.js +0 -142
- package/src/superlocalmemory/ui/js/feedback.js +0 -339
- package/src/superlocalmemory/ui/js/graph-event-bus.js +0 -83
- package/src/superlocalmemory/ui/js/graph-filters.js +0 -220
- package/src/superlocalmemory/ui/js/graph-ui.js +0 -214
- package/src/superlocalmemory/ui/js/ide-status.js +0 -115
- package/src/superlocalmemory/ui/js/init.js +0 -54
- package/src/superlocalmemory/ui/js/knowledge-graph.js +0 -945
- package/src/superlocalmemory/ui/js/lifecycle.js +0 -387
- package/src/superlocalmemory/ui/js/math-health.js +0 -114
- package/src/superlocalmemory/ui/js/memories.js +0 -394
- package/src/superlocalmemory/ui/js/memory-chat.js +0 -371
- package/src/superlocalmemory/ui/js/memory-timeline.js +0 -265
- package/src/superlocalmemory/ui/js/modal.js +0 -733
- package/src/superlocalmemory/ui/js/ng-entities.js +0 -298
- package/src/superlocalmemory/ui/js/ng-health.js +0 -208
- package/src/superlocalmemory/ui/js/ng-ingestion.js +0 -203
- package/src/superlocalmemory/ui/js/ng-mesh.js +0 -374
- package/src/superlocalmemory/ui/js/ng-shell.js +0 -524
- package/src/superlocalmemory/ui/js/ng-skills.js +0 -663
- package/src/superlocalmemory/ui/js/od-agents.js +0 -588
- package/src/superlocalmemory/ui/js/od-auth-gate.js +0 -257
- package/src/superlocalmemory/ui/js/od-backup.js +0 -878
- package/src/superlocalmemory/ui/js/od-boundedloops.js +0 -324
- package/src/superlocalmemory/ui/js/od-brain.js +0 -1095
- package/src/superlocalmemory/ui/js/od-compliance-ext.js +0 -301
- package/src/superlocalmemory/ui/js/od-components.js +0 -147
- package/src/superlocalmemory/ui/js/od-entities.js +0 -622
- package/src/superlocalmemory/ui/js/od-graph.js +0 -776
- package/src/superlocalmemory/ui/js/od-health.js +0 -579
- package/src/superlocalmemory/ui/js/od-mcp.js +0 -508
- package/src/superlocalmemory/ui/js/od-memories.js +0 -1499
- package/src/superlocalmemory/ui/js/od-mesh.js +0 -645
- package/src/superlocalmemory/ui/js/od-operations.js +0 -1268
- package/src/superlocalmemory/ui/js/od-ops-health.js +0 -417
- package/src/superlocalmemory/ui/js/od-optimize.js +0 -828
- package/src/superlocalmemory/ui/js/od-settings.js +0 -1275
- package/src/superlocalmemory/ui/js/od-shell.js +0 -819
- package/src/superlocalmemory/ui/js/od-skills.js +0 -600
- package/src/superlocalmemory/ui/js/od-team.js +0 -265
- package/src/superlocalmemory/ui/js/optimize.js +0 -191
- package/src/superlocalmemory/ui/js/profiles.js +0 -362
- package/src/superlocalmemory/ui/js/quick-actions.js +0 -334
- package/src/superlocalmemory/ui/js/recall-lab.js +0 -373
- package/src/superlocalmemory/ui/js/search.js +0 -86
- package/src/superlocalmemory/ui/js/settings.js +0 -556
- package/src/superlocalmemory/ui/js/timeline.js +0 -62
- package/src/superlocalmemory/ui/js/trust-dashboard.js +0 -225
- package/src/superlocalmemory/ui/vendor/bootstrap-icons/bootstrap-icons.css +0 -2018
- package/src/superlocalmemory/ui/vendor/bootstrap-icons/fonts/bootstrap-icons.woff +0 -0
- package/src/superlocalmemory/ui/vendor/bootstrap-icons/fonts/bootstrap-icons.woff2 +0 -0
- package/src/superlocalmemory/ui/vendor/bootstrap.bundle.min.js +0 -7
- package/src/superlocalmemory/ui/vendor/bootstrap.min.css +0 -6
- package/src/superlocalmemory/ui/vendor/d3.v7.min.js +0 -2
- package/src/superlocalmemory/ui/vendor/graphology-library.min.js +0 -2
- package/src/superlocalmemory/ui/vendor/graphology.umd.min.js +0 -2
- package/src/superlocalmemory/ui/vendor/inter-ui/inter-variable.min.css +0 -8
- package/src/superlocalmemory/ui/vendor/inter-ui/variable/InterVariable-Italic.woff2 +0 -0
- package/src/superlocalmemory/ui/vendor/inter-ui/variable/InterVariable.woff2 +0 -0
- package/src/superlocalmemory/ui/vendor/sigma.min.js +0 -1
- package/src/superlocalmemory/vector/__init__.py +0 -9
- package/src/superlocalmemory/vector/lancedb_backend.py +0 -366
|
@@ -1,983 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
|
|
2
|
-
# Licensed under AGPL-3.0-or-later - see LICENSE file
|
|
3
|
-
|
|
4
|
-
"""Production adapter between MemoryEngine and canonical ingestion.
|
|
5
|
-
|
|
6
|
-
This is the anti-corruption layer for the expand-migrate-contract rollout:
|
|
7
|
-
the command owns durability and state, while the existing engine remains the
|
|
8
|
-
implementation of queryable projection and complete derivation.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
from __future__ import annotations
|
|
12
|
-
|
|
13
|
-
import hashlib
|
|
14
|
-
import logging
|
|
15
|
-
import os
|
|
16
|
-
import uuid
|
|
17
|
-
from typing import TYPE_CHECKING, Protocol
|
|
18
|
-
|
|
19
|
-
from superlocalmemory.core.ingestion_command import (
|
|
20
|
-
IngestionCommand,
|
|
21
|
-
IngestionOperation,
|
|
22
|
-
IngestionOperationRepository,
|
|
23
|
-
IngestionRequest,
|
|
24
|
-
MaterializationResult,
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
if TYPE_CHECKING:
|
|
28
|
-
from superlocalmemory.core.engine import MemoryEngine
|
|
29
|
-
from superlocalmemory.storage.models import AtomicFact, MemoryRecord
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
logger = logging.getLogger(__name__)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_PREBUILT_FACT_KEY = "_slm_prebuilt_fact_v1"
|
|
36
|
-
_DERIVATION_VERSION = "v3.7-ingestion-1"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class _ImmediateAdmissionDatabase(Protocol):
|
|
40
|
-
"""The deliberately tiny persistence surface used by receipt admission.
|
|
41
|
-
|
|
42
|
-
The coordinator will bind this to its sole writer connection. Keeping the
|
|
43
|
-
seam this narrow prevents the immediate path from accidentally acquiring a
|
|
44
|
-
model, hook, graph, or secondary-store dependency while it owns SQLite's
|
|
45
|
-
write transaction.
|
|
46
|
-
"""
|
|
47
|
-
|
|
48
|
-
def store_memory(self, record: "MemoryRecord") -> str: ...
|
|
49
|
-
|
|
50
|
-
def store_fact(self, fact: "AtomicFact") -> str: ...
|
|
51
|
-
|
|
52
|
-
def execute(self, sql: str, params: tuple = ()) -> list: ...
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def _pii_redaction_enabled(engine: "MemoryEngine") -> bool:
|
|
56
|
-
"""C4: opt-in PII redaction on ingest.
|
|
57
|
-
|
|
58
|
-
On when the engine config sets ``pii_redaction`` truthy OR the
|
|
59
|
-
``SLM_PII_REDACTION`` env var is set (1/on/true/yes). Default OFF — personal
|
|
60
|
-
use is unchanged; team/company operators opt in.
|
|
61
|
-
"""
|
|
62
|
-
cfg = getattr(engine, "_config", None)
|
|
63
|
-
if cfg is not None and getattr(cfg, "pii_redaction", False):
|
|
64
|
-
return True
|
|
65
|
-
return os.environ.get("SLM_PII_REDACTION", "").strip().lower() in (
|
|
66
|
-
"1", "on", "true", "yes",
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def content_passes_admission(content: str) -> bool:
|
|
71
|
-
"""Return whether raw content is eligible to reach durable ingestion.
|
|
72
|
-
|
|
73
|
-
This is deliberately stateless: canonical admission must not populate the
|
|
74
|
-
live entropy gate's duplicate window before the materialization pipeline
|
|
75
|
-
evaluates the same content.
|
|
76
|
-
"""
|
|
77
|
-
if not content or not content.strip():
|
|
78
|
-
return False
|
|
79
|
-
|
|
80
|
-
from superlocalmemory.core.injection import is_low_quality
|
|
81
|
-
from superlocalmemory.encoding.entropy_gate import EntropyGate
|
|
82
|
-
|
|
83
|
-
return not is_low_quality(content) and EntropyGate().should_pass(content)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def _prebuilt_fact_payload(fact: AtomicFact) -> dict:
|
|
87
|
-
"""Serialize the stable public AtomicFact contract into M018 metadata."""
|
|
88
|
-
enum_fields = {"fact_type", "lifecycle", "signal_type"}
|
|
89
|
-
fields = (
|
|
90
|
-
"fact_id", "memory_id", "profile_id", "scope", "shared_with",
|
|
91
|
-
"content", "fact_type", "entities", "canonical_entities",
|
|
92
|
-
"observation_date", "referenced_date", "interval_start", "interval_end",
|
|
93
|
-
"confidence", "importance", "evidence_count", "access_count",
|
|
94
|
-
"source_turn_ids", "session_id", "embedding", "fisher_mean",
|
|
95
|
-
"fisher_variance", "lifecycle", "langevin_position",
|
|
96
|
-
"emotional_valence", "emotional_arousal", "signal_type", "pinned",
|
|
97
|
-
"created_at",
|
|
98
|
-
)
|
|
99
|
-
payload = {}
|
|
100
|
-
for name in fields:
|
|
101
|
-
value = getattr(fact, name)
|
|
102
|
-
payload[name] = value.value if name in enum_fields else value
|
|
103
|
-
return payload
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def _prebuilt_fact_from_payload(payload: dict):
|
|
107
|
-
from superlocalmemory.storage.models import (
|
|
108
|
-
AtomicFact,
|
|
109
|
-
FactType,
|
|
110
|
-
MemoryLifecycle,
|
|
111
|
-
SignalType,
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
values = dict(payload)
|
|
115
|
-
values["fact_type"] = FactType(values.get("fact_type", FactType.SEMANTIC.value))
|
|
116
|
-
values["lifecycle"] = MemoryLifecycle(
|
|
117
|
-
values.get("lifecycle", MemoryLifecycle.ACTIVE.value)
|
|
118
|
-
)
|
|
119
|
-
values["signal_type"] = SignalType(
|
|
120
|
-
values.get("signal_type", SignalType.FACTUAL.value)
|
|
121
|
-
)
|
|
122
|
-
return AtomicFact(**values)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
def build_immediate_admission_handler(
|
|
126
|
-
db: _ImmediateAdmissionDatabase,
|
|
127
|
-
*,
|
|
128
|
-
profile_id: str,
|
|
129
|
-
max_verbatim_chars: int = 24_000,
|
|
130
|
-
max_ingest_bytes: int = 1_048_576,
|
|
131
|
-
):
|
|
132
|
-
"""Build the deterministic queryable projection for one engine profile.
|
|
133
|
-
|
|
134
|
-
``IngestionCommand`` wraps this callback with operation creation and the
|
|
135
|
-
RAW -> QUERYABLE receipt transition in one transaction. This function is
|
|
136
|
-
intentionally restricted to constructing a raw ``MemoryRecord`` and one
|
|
137
|
-
embedding-free ``AtomicFact`` then persisting those two records. All
|
|
138
|
-
authorization hooks, embedding, extraction, FTS-adjacent enrichment,
|
|
139
|
-
graph, provenance, and external index work run only after this receipt has
|
|
140
|
-
committed through the durable materializer.
|
|
141
|
-
"""
|
|
142
|
-
def write_queryable(request: IngestionRequest, operation_id: str) -> list[str]:
|
|
143
|
-
if request.profile_id != profile_id:
|
|
144
|
-
raise ValueError("ingestion request profile does not match engine")
|
|
145
|
-
if not request.trusted_actor_id:
|
|
146
|
-
raise ValueError("trusted actor identity is required")
|
|
147
|
-
if not content_passes_admission(request.content):
|
|
148
|
-
return []
|
|
149
|
-
|
|
150
|
-
import re
|
|
151
|
-
from datetime import UTC, datetime
|
|
152
|
-
|
|
153
|
-
from superlocalmemory.core.ingest_gate import apply_ingest_gate
|
|
154
|
-
from superlocalmemory.core.ingest_policy import scrub_secrets_for_ingest
|
|
155
|
-
from superlocalmemory.storage.models import AtomicFact, FactType, MemoryRecord
|
|
156
|
-
|
|
157
|
-
# Secrets are ALWAYS scrubbed at this shared queryable-write chokepoint,
|
|
158
|
-
# which both the canonical HTTP /remember runtime and the canonical_store
|
|
159
|
-
# Python/CLI path funnel through. A credential must never persist verbatim
|
|
160
|
-
# in any durable representation (memory rows, fact rows), regardless of
|
|
161
|
-
# ingress surface. The scrub is idempotent: content already scrubbed by an
|
|
162
|
-
# upstream caller is returned unchanged.
|
|
163
|
-
scrub = scrub_secrets_for_ingest(request.content)
|
|
164
|
-
content = scrub.content
|
|
165
|
-
if scrub.redacted:
|
|
166
|
-
logger.info("secret scrub: redacted credential material on queryable write")
|
|
167
|
-
|
|
168
|
-
metadata = dict(request.metadata)
|
|
169
|
-
metadata["ingestion_operation_id"] = operation_id
|
|
170
|
-
if request.session_id:
|
|
171
|
-
metadata.setdefault("session_id", request.session_id)
|
|
172
|
-
gate = apply_ingest_gate(
|
|
173
|
-
content,
|
|
174
|
-
max_verbatim_chars=max_verbatim_chars,
|
|
175
|
-
max_ingest_bytes=max_ingest_bytes,
|
|
176
|
-
)
|
|
177
|
-
if gate.rejected:
|
|
178
|
-
return []
|
|
179
|
-
fact_content = gate.fact_content
|
|
180
|
-
now = datetime.now(UTC).isoformat()
|
|
181
|
-
observation_date = request.session_date or now[:10]
|
|
182
|
-
|
|
183
|
-
prebuilt_payload = metadata.get(_PREBUILT_FACT_KEY)
|
|
184
|
-
if isinstance(prebuilt_payload, dict):
|
|
185
|
-
fact = _prebuilt_fact_from_payload(prebuilt_payload)
|
|
186
|
-
fact.profile_id = request.profile_id
|
|
187
|
-
fact.scope = request.scope
|
|
188
|
-
fact.shared_with = list(request.shared_with) or None
|
|
189
|
-
fact.session_id = request.session_id or fact.session_id
|
|
190
|
-
if request.session_date:
|
|
191
|
-
fact.observation_date = request.session_date
|
|
192
|
-
else:
|
|
193
|
-
entities = sorted(
|
|
194
|
-
{match.group(1) for match in re.finditer(
|
|
195
|
-
r"\b([A-Z][a-z]+(?:\s[A-Z][a-z]+){0,3})\b", fact_content,
|
|
196
|
-
)}
|
|
197
|
-
| {match.group(1) for match in re.finditer(
|
|
198
|
-
r"\b([A-Z]{2,})\b", fact_content,
|
|
199
|
-
)}
|
|
200
|
-
)
|
|
201
|
-
fact = AtomicFact(
|
|
202
|
-
fact_id=uuid.uuid4().hex[:16],
|
|
203
|
-
profile_id=request.profile_id,
|
|
204
|
-
scope=request.scope,
|
|
205
|
-
shared_with=list(request.shared_with) or None,
|
|
206
|
-
content=fact_content,
|
|
207
|
-
fact_type=FactType.EPISODIC,
|
|
208
|
-
entities=entities,
|
|
209
|
-
observation_date=observation_date,
|
|
210
|
-
session_id=request.session_id,
|
|
211
|
-
confidence=0.7,
|
|
212
|
-
importance=0.5,
|
|
213
|
-
created_at=now,
|
|
214
|
-
)
|
|
215
|
-
|
|
216
|
-
# A receipt is queryable through FTS immediately, but model-derived
|
|
217
|
-
# values cannot participate in its write transaction. The materializer
|
|
218
|
-
# owns their later, retryable population.
|
|
219
|
-
fact.embedding = None
|
|
220
|
-
fact.fisher_mean = None
|
|
221
|
-
fact.fisher_variance = None
|
|
222
|
-
memory_id = fact.memory_id or uuid.uuid4().hex
|
|
223
|
-
existing = db.execute(
|
|
224
|
-
"SELECT profile_id FROM memories WHERE memory_id = ?",
|
|
225
|
-
(memory_id,),
|
|
226
|
-
)
|
|
227
|
-
if existing:
|
|
228
|
-
existing_profile = str(existing[0]["profile_id"])
|
|
229
|
-
if existing_profile != request.profile_id:
|
|
230
|
-
raise ValueError("prebuilt fact memory belongs to a different profile")
|
|
231
|
-
# Reuse the existing source row. DatabaseManager.store_memory uses
|
|
232
|
-
# INSERT OR REPLACE; calling it here would delete every child fact
|
|
233
|
-
# through the memory_id foreign-key cascade before recreating the
|
|
234
|
-
# parent.
|
|
235
|
-
fact.memory_id = memory_id
|
|
236
|
-
else:
|
|
237
|
-
record = MemoryRecord(
|
|
238
|
-
memory_id=memory_id,
|
|
239
|
-
profile_id=request.profile_id,
|
|
240
|
-
content=content,
|
|
241
|
-
session_id=request.session_id,
|
|
242
|
-
session_date=observation_date,
|
|
243
|
-
speaker=request.speaker,
|
|
244
|
-
role=request.role,
|
|
245
|
-
metadata=metadata,
|
|
246
|
-
scope=request.scope,
|
|
247
|
-
shared_with=list(request.shared_with) or None,
|
|
248
|
-
)
|
|
249
|
-
fact.memory_id = db.store_memory(record)
|
|
250
|
-
return [db.store_fact(fact)]
|
|
251
|
-
|
|
252
|
-
return write_queryable
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
def local_trusted_actor_id(actor_kind: str) -> str:
|
|
256
|
-
"""Derive a stable local actor from the private install capability."""
|
|
257
|
-
from superlocalmemory.core.security_primitives import ensure_install_token
|
|
258
|
-
from superlocalmemory.infra.daemon_identity import namespace_id_for, owner_id
|
|
259
|
-
from superlocalmemory.infra.data_root import canonical_data_root
|
|
260
|
-
|
|
261
|
-
token = ensure_install_token()
|
|
262
|
-
material = (
|
|
263
|
-
b"superlocalmemory-local-actor-v1\0"
|
|
264
|
-
+ token.encode("utf-8")
|
|
265
|
-
+ b"\0"
|
|
266
|
-
+ actor_kind.encode("utf-8")
|
|
267
|
-
)
|
|
268
|
-
fingerprint = hashlib.sha256(material).hexdigest()
|
|
269
|
-
return (
|
|
270
|
-
f"local-capability:{actor_kind}:{owner_id()}:"
|
|
271
|
-
f"{namespace_id_for(canonical_data_root())}:{fingerprint}"
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
def canonical_store(
|
|
276
|
-
engine: MemoryEngine,
|
|
277
|
-
content: str,
|
|
278
|
-
*,
|
|
279
|
-
source_type: str,
|
|
280
|
-
trusted_actor_id: str,
|
|
281
|
-
metadata: dict | None = None,
|
|
282
|
-
scope: str = "personal",
|
|
283
|
-
shared_with: list[str] | tuple[str, ...] | None = None,
|
|
284
|
-
session_id: str = "",
|
|
285
|
-
session_date: str | None = None,
|
|
286
|
-
speaker: str = "",
|
|
287
|
-
role: str = "user",
|
|
288
|
-
idempotency_key: str = "",
|
|
289
|
-
require_complete: bool = True,
|
|
290
|
-
return_receipt: bool = False,
|
|
291
|
-
) -> list[str] | IngestionOperation:
|
|
292
|
-
"""Submit canonical evidence, optionally waiting for enrichment completion.
|
|
293
|
-
|
|
294
|
-
``require_complete=False`` is the interactive/CQRS path: it commits a
|
|
295
|
-
profile-scoped memory and FTS-queryable fact through M018, then returns the
|
|
296
|
-
durable receipt without invoking any LLM, embedding, or graph work. The
|
|
297
|
-
daemon materializer owns that expensive, retryable enrichment. Explicit
|
|
298
|
-
complete callers retain the historical synchronous contract.
|
|
299
|
-
"""
|
|
300
|
-
import time
|
|
301
|
-
|
|
302
|
-
from superlocalmemory.core.ingestion_command import IngestionRequest, IngestionState
|
|
303
|
-
from superlocalmemory.infra.local_diagnostics import record_operation
|
|
304
|
-
|
|
305
|
-
started = time.monotonic()
|
|
306
|
-
|
|
307
|
-
# Preserve the long-standing Python/API contract for rejected content:
|
|
308
|
-
# low-information input is a no-op and never becomes an M018 operation.
|
|
309
|
-
if not content_passes_admission(content):
|
|
310
|
-
record_operation(
|
|
311
|
-
"remember",
|
|
312
|
-
client=trusted_actor_id,
|
|
313
|
-
duration_ms=(time.monotonic() - started) * 1000.0,
|
|
314
|
-
error=ValueError("content rejected by local admission policy"),
|
|
315
|
-
)
|
|
316
|
-
return []
|
|
317
|
-
# Secrets are ALWAYS scrubbed pre-admission (not opt-in): a credential must
|
|
318
|
-
# never persist verbatim in any durable or queryable representation
|
|
319
|
-
# (facts, receipts, journal, exports, backups, mesh).
|
|
320
|
-
from superlocalmemory.core.ingest_policy import scrub_secrets_for_ingest
|
|
321
|
-
|
|
322
|
-
_secret_scrub = scrub_secrets_for_ingest(content)
|
|
323
|
-
if _secret_scrub.redacted:
|
|
324
|
-
content = _secret_scrub.content
|
|
325
|
-
logger.info("secret scrub: redacted credential material on ingest")
|
|
326
|
-
# C4: opt-in PII redaction. When enabled (config.pii_redaction or
|
|
327
|
-
# SLM_PII_REDACTION), scrub personal identifiers BEFORE the content is
|
|
328
|
-
# extracted, embedded, or persisted — nothing sensitive ever reaches disk.
|
|
329
|
-
if _pii_redaction_enabled(engine):
|
|
330
|
-
from superlocalmemory.core.pii import redact_pii
|
|
331
|
-
|
|
332
|
-
scrubbed, n_pii = redact_pii(content)
|
|
333
|
-
if n_pii:
|
|
334
|
-
content = scrubbed
|
|
335
|
-
logger.info("PII redaction: scrubbed %d identifier(s) on ingest", n_pii)
|
|
336
|
-
try:
|
|
337
|
-
command = build_engine_ingestion_command(engine)
|
|
338
|
-
receipt = command.submit(IngestionRequest(
|
|
339
|
-
content=content,
|
|
340
|
-
profile_id=engine._profile_id,
|
|
341
|
-
source_type=source_type,
|
|
342
|
-
idempotency_key=idempotency_key or uuid.uuid4().hex,
|
|
343
|
-
metadata=dict(metadata or {}),
|
|
344
|
-
scope=scope,
|
|
345
|
-
shared_with=tuple(shared_with or ()),
|
|
346
|
-
trusted_actor_id=trusted_actor_id,
|
|
347
|
-
session_id=session_id,
|
|
348
|
-
session_date=session_date or "",
|
|
349
|
-
speaker=speaker,
|
|
350
|
-
role=role,
|
|
351
|
-
))
|
|
352
|
-
if not require_complete:
|
|
353
|
-
record_operation(
|
|
354
|
-
"remember",
|
|
355
|
-
client=trusted_actor_id,
|
|
356
|
-
duration_ms=(time.monotonic() - started) * 1000.0,
|
|
357
|
-
)
|
|
358
|
-
return receipt if return_receipt else list(receipt.fact_ids)
|
|
359
|
-
|
|
360
|
-
result = command.materialize(receipt.operation_id)
|
|
361
|
-
if result.state is not IngestionState.COMPLETE:
|
|
362
|
-
raise RuntimeError(result.last_error or "canonical materialization failed")
|
|
363
|
-
except Exception as exc:
|
|
364
|
-
record_operation(
|
|
365
|
-
"remember",
|
|
366
|
-
client=trusted_actor_id,
|
|
367
|
-
duration_ms=(time.monotonic() - started) * 1000.0,
|
|
368
|
-
error=exc,
|
|
369
|
-
)
|
|
370
|
-
raise
|
|
371
|
-
record_operation(
|
|
372
|
-
"remember",
|
|
373
|
-
client=trusted_actor_id,
|
|
374
|
-
duration_ms=(time.monotonic() - started) * 1000.0,
|
|
375
|
-
)
|
|
376
|
-
return result if return_receipt else list(result.fact_ids)
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
def canonical_store_fn(
|
|
380
|
-
engine: MemoryEngine,
|
|
381
|
-
*,
|
|
382
|
-
source_type: str,
|
|
383
|
-
trusted_actor_id: str,
|
|
384
|
-
):
|
|
385
|
-
"""Return an AutoCapture-compatible synchronous canonical store callable."""
|
|
386
|
-
def store(content: str, metadata: dict | None = None) -> list[str]:
|
|
387
|
-
values = dict(metadata or {})
|
|
388
|
-
return canonical_store(
|
|
389
|
-
engine,
|
|
390
|
-
content,
|
|
391
|
-
source_type=source_type,
|
|
392
|
-
trusted_actor_id=trusted_actor_id,
|
|
393
|
-
metadata=values,
|
|
394
|
-
session_id=str(values.get("session_id") or ""),
|
|
395
|
-
)
|
|
396
|
-
|
|
397
|
-
return store
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
def canonical_store_fact(
|
|
401
|
-
engine: MemoryEngine,
|
|
402
|
-
fact: AtomicFact,
|
|
403
|
-
*,
|
|
404
|
-
trusted_actor_id: str,
|
|
405
|
-
) -> str:
|
|
406
|
-
"""Durably ingest a caller-built fact without changing its public ID."""
|
|
407
|
-
from superlocalmemory.core.ingestion_command import IngestionRequest, IngestionState
|
|
408
|
-
from superlocalmemory.core.injection import is_low_quality
|
|
409
|
-
|
|
410
|
-
if is_low_quality(fact.content):
|
|
411
|
-
return fact.fact_id
|
|
412
|
-
command = build_engine_ingestion_command(engine)
|
|
413
|
-
receipt = command.submit(IngestionRequest(
|
|
414
|
-
content=fact.content,
|
|
415
|
-
profile_id=engine._profile_id,
|
|
416
|
-
source_type="python-api-prebuilt",
|
|
417
|
-
idempotency_key=f"prebuilt:{fact.fact_id}",
|
|
418
|
-
metadata={_PREBUILT_FACT_KEY: _prebuilt_fact_payload(fact)},
|
|
419
|
-
scope=fact.scope or "personal",
|
|
420
|
-
shared_with=tuple(fact.shared_with or ()),
|
|
421
|
-
trusted_actor_id=trusted_actor_id,
|
|
422
|
-
session_id=fact.session_id,
|
|
423
|
-
session_date=fact.observation_date or "",
|
|
424
|
-
))
|
|
425
|
-
result = command.materialize(receipt.operation_id)
|
|
426
|
-
if result.state is not IngestionState.COMPLETE:
|
|
427
|
-
raise RuntimeError(result.last_error or "prebuilt fact materialization failed")
|
|
428
|
-
if fact.fact_id not in result.fact_ids:
|
|
429
|
-
raise RuntimeError("prebuilt fact ID was not preserved by canonical ingestion")
|
|
430
|
-
stored = engine._db.get_fact(fact.fact_id)
|
|
431
|
-
if stored is not None:
|
|
432
|
-
fact.memory_id = stored.memory_id
|
|
433
|
-
return fact.fact_id
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
def build_engine_ingestion_command(engine: MemoryEngine) -> IngestionCommand:
|
|
437
|
-
"""Bind one initialized engine to the durable ingestion command."""
|
|
438
|
-
engine._require_full("canonical_ingestion")
|
|
439
|
-
engine._ensure_init()
|
|
440
|
-
repository = IngestionOperationRepository(engine._db)
|
|
441
|
-
store_config = getattr(engine._config, "store", None)
|
|
442
|
-
write_queryable = build_immediate_admission_handler(
|
|
443
|
-
engine._db,
|
|
444
|
-
profile_id=engine._profile_id,
|
|
445
|
-
max_verbatim_chars=getattr(store_config, "max_verbatim_chars", 24_000),
|
|
446
|
-
max_ingest_bytes=getattr(store_config, "max_ingest_bytes", 1_048_576),
|
|
447
|
-
)
|
|
448
|
-
|
|
449
|
-
def validate_admission(request: IngestionRequest) -> None:
|
|
450
|
-
"""Apply trust policy before the journal or canonical transaction.
|
|
451
|
-
|
|
452
|
-
V4 Phase 4 addition: evaluate the OperationPolicyRegistry AFTER the
|
|
453
|
-
trust hook and BEFORE the coordinator transaction. This evaluation is
|
|
454
|
-
CPU-only (dict lookup + frozenset operations, no I/O) and runs in the
|
|
455
|
-
validate_admission slot which is already outside the SQLite writer.
|
|
456
|
-
|
|
457
|
-
The default registry allows every REMEMBER from an OWNER via the
|
|
458
|
-
INTERNAL transport in local mode — zero new rejections on the current
|
|
459
|
-
happy path. A denial raises ValueError, which propagates through
|
|
460
|
-
IngestionCommand.submit() to the caller exactly as existing slot
|
|
461
|
-
violations do.
|
|
462
|
-
"""
|
|
463
|
-
engine._hooks.run_pre("store", {
|
|
464
|
-
"operation": "store",
|
|
465
|
-
"agent_id": request.trusted_actor_id,
|
|
466
|
-
"profile_id": request.profile_id,
|
|
467
|
-
"content_preview": request.content[:100],
|
|
468
|
-
})
|
|
469
|
-
|
|
470
|
-
# Phase 4: additive policy check — runs after the trust hook.
|
|
471
|
-
# Imports are lazy to avoid import-order coupling at module init.
|
|
472
|
-
from superlocalmemory.core.actor_context import ActorContext, ActorRole, Transport
|
|
473
|
-
from superlocalmemory.core.operation_policy_registry import _DEFAULT_REGISTRY
|
|
474
|
-
from superlocalmemory.core.operation_request import OperationKind
|
|
475
|
-
|
|
476
|
-
# A missing actor is rejected by the existing admission check with its
|
|
477
|
-
# canonical message; the policy layer is strictly additive and must not
|
|
478
|
-
# preempt that rejection, so it only evaluates when an actor is present.
|
|
479
|
-
if request.trusted_actor_id:
|
|
480
|
-
_actor = ActorContext(
|
|
481
|
-
# trusted_actor_id is already server-validated by the caller;
|
|
482
|
-
# it is NEVER taken from the request body here.
|
|
483
|
-
principal_id=request.trusted_actor_id,
|
|
484
|
-
roles=frozenset({ActorRole.OWNER}),
|
|
485
|
-
active_profile_id=request.profile_id,
|
|
486
|
-
transport=Transport.INTERNAL,
|
|
487
|
-
client_host="", # in-process: always local
|
|
488
|
-
)
|
|
489
|
-
_decision = _DEFAULT_REGISTRY.evaluate(
|
|
490
|
-
OperationKind.REMEMBER,
|
|
491
|
-
_actor,
|
|
492
|
-
"local", # internal Python-API path is always local/single-user
|
|
493
|
-
)
|
|
494
|
-
if not _decision.allowed:
|
|
495
|
-
raise ValueError(
|
|
496
|
-
f"operation policy denied REMEMBER: {_decision.reason}"
|
|
497
|
-
)
|
|
498
|
-
|
|
499
|
-
def resume_checkpoint(operation: IngestionOperation) -> MaterializationResult:
|
|
500
|
-
"""Repair only stages whose writes have an idempotent natural key."""
|
|
501
|
-
state = dict(operation.derivation_state)
|
|
502
|
-
if not state.get("pipeline", False):
|
|
503
|
-
return MaterializationResult(
|
|
504
|
-
operation.final_fact_ids, state, operation.last_error,
|
|
505
|
-
)
|
|
506
|
-
facts = engine._db.get_facts_by_ids(
|
|
507
|
-
list(operation.final_fact_ids), operation.profile_id,
|
|
508
|
-
)
|
|
509
|
-
if len(facts) != len(operation.final_fact_ids):
|
|
510
|
-
state["relational"] = False
|
|
511
|
-
return MaterializationResult(
|
|
512
|
-
operation.final_fact_ids,
|
|
513
|
-
state,
|
|
514
|
-
"checkpointed relational facts are missing",
|
|
515
|
-
)
|
|
516
|
-
if state.get("provenance") is False and engine._provenance is not None:
|
|
517
|
-
provenance_complete = True
|
|
518
|
-
for fact in facts:
|
|
519
|
-
existing = engine._db.execute(
|
|
520
|
-
"SELECT 1 FROM provenance WHERE fact_id=? AND profile_id=? "
|
|
521
|
-
"AND source_type=? AND source_id=? AND created_by=? LIMIT 1",
|
|
522
|
-
(
|
|
523
|
-
fact.fact_id,
|
|
524
|
-
operation.profile_id,
|
|
525
|
-
operation.source_type,
|
|
526
|
-
operation.operation_id,
|
|
527
|
-
operation.trusted_actor_id,
|
|
528
|
-
),
|
|
529
|
-
)
|
|
530
|
-
if existing:
|
|
531
|
-
continue
|
|
532
|
-
try:
|
|
533
|
-
engine._provenance.record(
|
|
534
|
-
fact_id=fact.fact_id,
|
|
535
|
-
profile_id=operation.profile_id,
|
|
536
|
-
source_type=operation.source_type,
|
|
537
|
-
source_id=operation.operation_id,
|
|
538
|
-
created_by=operation.trusted_actor_id,
|
|
539
|
-
)
|
|
540
|
-
except Exception:
|
|
541
|
-
provenance_complete = False
|
|
542
|
-
state["provenance"] = provenance_complete
|
|
543
|
-
if state.get("post_hooks") is False:
|
|
544
|
-
try:
|
|
545
|
-
engine._hooks.run_post("store", {
|
|
546
|
-
"operation": "store",
|
|
547
|
-
"agent_id": operation.trusted_actor_id,
|
|
548
|
-
"profile_id": operation.profile_id,
|
|
549
|
-
"content_preview": operation.raw_content[:100],
|
|
550
|
-
"ingestion_operation_id": operation.operation_id,
|
|
551
|
-
"fact_ids": list(operation.final_fact_ids),
|
|
552
|
-
"fact_count": len(operation.final_fact_ids),
|
|
553
|
-
})
|
|
554
|
-
except Exception as exc:
|
|
555
|
-
return MaterializationResult(
|
|
556
|
-
operation.final_fact_ids, state, str(exc),
|
|
557
|
-
)
|
|
558
|
-
state["post_hooks"] = True
|
|
559
|
-
incomplete = [name for name, complete in state.items() if not complete]
|
|
560
|
-
return MaterializationResult(
|
|
561
|
-
operation.final_fact_ids,
|
|
562
|
-
state,
|
|
563
|
-
"" if not incomplete else operation.last_error,
|
|
564
|
-
)
|
|
565
|
-
|
|
566
|
-
def resume_partial_relational(
|
|
567
|
-
operation: IngestionOperation,
|
|
568
|
-
memory_id: str,
|
|
569
|
-
) -> MaterializationResult:
|
|
570
|
-
"""Finish idempotent relational effects from facts committed before a crash.
|
|
571
|
-
|
|
572
|
-
Extraction and consolidation mutate evidence and access counters, so a
|
|
573
|
-
relational-start checkpoint is an at-most-once boundary for those
|
|
574
|
-
stages. The facts already committed to this operation's dedicated
|
|
575
|
-
memory can safely be promoted again: they use stable fact IDs, graph
|
|
576
|
-
edge logical keys, temporal event IDs, and fact/entity association
|
|
577
|
-
keys. Deliberately omit the other best-effort enrichers here; they
|
|
578
|
-
have no operation-scoped idempotency contract.
|
|
579
|
-
"""
|
|
580
|
-
from superlocalmemory.core.store_pipeline import run_store
|
|
581
|
-
|
|
582
|
-
# Consolidation may replace a submitted projection with an existing
|
|
583
|
-
# canonical fact from another memory. The operation checkpoint is the
|
|
584
|
-
# authoritative recovery set in that case; falling back to the source
|
|
585
|
-
# memory is only for a fault before the checkpoint captured final IDs.
|
|
586
|
-
if operation.final_fact_ids:
|
|
587
|
-
facts = engine._db.get_facts_by_ids(
|
|
588
|
-
list(operation.final_fact_ids), operation.profile_id,
|
|
589
|
-
)
|
|
590
|
-
if len(facts) != len(operation.final_fact_ids):
|
|
591
|
-
return MaterializationResult(
|
|
592
|
-
operation.final_fact_ids,
|
|
593
|
-
dict(operation.derivation_state),
|
|
594
|
-
"checkpointed relational facts are missing",
|
|
595
|
-
)
|
|
596
|
-
else:
|
|
597
|
-
facts = engine._db.get_facts_by_memory_id(
|
|
598
|
-
memory_id, operation.profile_id,
|
|
599
|
-
)
|
|
600
|
-
fact_ids = tuple(fact.fact_id for fact in facts)
|
|
601
|
-
if not fact_ids:
|
|
602
|
-
return MaterializationResult(
|
|
603
|
-
(),
|
|
604
|
-
dict(operation.derivation_state),
|
|
605
|
-
"no committed facts available for relational recovery",
|
|
606
|
-
)
|
|
607
|
-
|
|
608
|
-
class _CommittedFactsExtractor:
|
|
609
|
-
@staticmethod
|
|
610
|
-
def extract_facts(**_kwargs):
|
|
611
|
-
return []
|
|
612
|
-
|
|
613
|
-
pipeline_state: dict[str, bool] = {}
|
|
614
|
-
progress: dict[str, object] = {}
|
|
615
|
-
|
|
616
|
-
def checkpoint_materialization(
|
|
617
|
-
_phase: str,
|
|
618
|
-
checkpoint_fact_ids: tuple[str, ...],
|
|
619
|
-
state: dict[str, bool],
|
|
620
|
-
) -> None:
|
|
621
|
-
repository.checkpoint_enriching(
|
|
622
|
-
operation.operation_id,
|
|
623
|
-
final_fact_ids=checkpoint_fact_ids,
|
|
624
|
-
derivation_version=_DERIVATION_VERSION,
|
|
625
|
-
derivation_state=state,
|
|
626
|
-
lease_owner=operation.lease_owner,
|
|
627
|
-
lease_seconds=900.0,
|
|
628
|
-
)
|
|
629
|
-
|
|
630
|
-
recovered_ids = run_store(
|
|
631
|
-
operation.raw_content,
|
|
632
|
-
operation.profile_id,
|
|
633
|
-
session_id=operation.session_id,
|
|
634
|
-
session_date=operation.session_date or None,
|
|
635
|
-
speaker=operation.speaker,
|
|
636
|
-
role=operation.role,
|
|
637
|
-
metadata=dict(operation.metadata),
|
|
638
|
-
scope=operation.scope,
|
|
639
|
-
shared_with=list(operation.shared_with) or None,
|
|
640
|
-
config=engine._config,
|
|
641
|
-
db=engine._db,
|
|
642
|
-
embedder=engine._embedder,
|
|
643
|
-
fact_extractor=_CommittedFactsExtractor(),
|
|
644
|
-
entity_resolver=engine._entity_resolver,
|
|
645
|
-
temporal_parser=engine._temporal_parser,
|
|
646
|
-
type_router=None,
|
|
647
|
-
graph_builder=engine._graph_builder,
|
|
648
|
-
consolidator=None,
|
|
649
|
-
observation_builder=None,
|
|
650
|
-
scene_builder=None,
|
|
651
|
-
entropy_gate=engine._entropy_gate,
|
|
652
|
-
ann_index=None,
|
|
653
|
-
sheaf_checker=None,
|
|
654
|
-
retrieval_engine=None,
|
|
655
|
-
provenance=engine._provenance,
|
|
656
|
-
hooks=engine._hooks,
|
|
657
|
-
vector_store=None,
|
|
658
|
-
context_generator=None,
|
|
659
|
-
temporal_validator=engine._temporal_validator,
|
|
660
|
-
auto_linker=None,
|
|
661
|
-
consolidation_engine=None,
|
|
662
|
-
existing_memory_id=memory_id,
|
|
663
|
-
queryable_fact_ids=fact_ids,
|
|
664
|
-
trusted_actor_id=operation.trusted_actor_id,
|
|
665
|
-
pre_authorized=True,
|
|
666
|
-
ingestion_source_type=operation.source_type,
|
|
667
|
-
ingestion_operation_id=operation.operation_id,
|
|
668
|
-
derivation_report=pipeline_state,
|
|
669
|
-
precompleted_derivation_stages=frozenset({
|
|
670
|
-
"extraction", "consolidation",
|
|
671
|
-
}),
|
|
672
|
-
materialization_progress=progress,
|
|
673
|
-
materialization_checkpoint=checkpoint_materialization,
|
|
674
|
-
)
|
|
675
|
-
state = {
|
|
676
|
-
"pipeline_started": True,
|
|
677
|
-
"relational_started": True,
|
|
678
|
-
"pipeline": True,
|
|
679
|
-
"post_hooks": True,
|
|
680
|
-
"relational": True,
|
|
681
|
-
**pipeline_state,
|
|
682
|
-
}
|
|
683
|
-
return MaterializationResult(tuple(recovered_ids), state)
|
|
684
|
-
|
|
685
|
-
def materialize(operation: IngestionOperation) -> MaterializationResult:
|
|
686
|
-
# A checkpointed relational result is an at-most-once boundary. The
|
|
687
|
-
# extraction/consolidation pipeline mutates evidence/access counters,
|
|
688
|
-
# so replaying it is not a valid repair strategy. Idempotent external
|
|
689
|
-
# projections are resumed by IngestionCommand after every relational
|
|
690
|
-
# stage is complete; otherwise the durable failure remains inspectable.
|
|
691
|
-
if operation.final_fact_ids and operation.derivation_state.get("pipeline", False):
|
|
692
|
-
return resume_checkpoint(operation)
|
|
693
|
-
|
|
694
|
-
facts = engine._db.get_facts_by_ids(
|
|
695
|
-
list(operation.queryable_fact_ids),
|
|
696
|
-
operation.profile_id,
|
|
697
|
-
)
|
|
698
|
-
if len(facts) != len(operation.queryable_fact_ids):
|
|
699
|
-
raise ValueError("queryable fact profile mismatch or missing fact")
|
|
700
|
-
memory_ids = {fact.memory_id for fact in facts}
|
|
701
|
-
if len(memory_ids) != 1:
|
|
702
|
-
raise ValueError("queryable facts do not share one source memory")
|
|
703
|
-
memory_id = next(iter(memory_ids))
|
|
704
|
-
|
|
705
|
-
from superlocalmemory.core.store_pipeline import run_store
|
|
706
|
-
|
|
707
|
-
is_prebuilt = isinstance(operation.metadata.get(_PREBUILT_FACT_KEY), dict)
|
|
708
|
-
if (
|
|
709
|
-
operation.derivation_state.get("pipeline_started", False)
|
|
710
|
-
and not operation.derivation_state.get("pipeline", False)
|
|
711
|
-
and operation.derivation_state.get("relational_started", False)
|
|
712
|
-
):
|
|
713
|
-
return resume_partial_relational(operation, memory_id)
|
|
714
|
-
repository.checkpoint_enriching(
|
|
715
|
-
operation.operation_id,
|
|
716
|
-
final_fact_ids=(),
|
|
717
|
-
derivation_version=_DERIVATION_VERSION,
|
|
718
|
-
derivation_state={
|
|
719
|
-
"pipeline_started": True,
|
|
720
|
-
"pipeline": False,
|
|
721
|
-
},
|
|
722
|
-
lease_owner=operation.lease_owner,
|
|
723
|
-
lease_seconds=900.0,
|
|
724
|
-
)
|
|
725
|
-
|
|
726
|
-
class _QueryableProjectionExtractor:
|
|
727
|
-
@staticmethod
|
|
728
|
-
def extract_facts(**_kwargs):
|
|
729
|
-
return []
|
|
730
|
-
|
|
731
|
-
pipeline_state: dict[str, bool] = {}
|
|
732
|
-
progress: dict[str, object] = {}
|
|
733
|
-
|
|
734
|
-
def checkpoint_materialization(
|
|
735
|
-
_phase: str,
|
|
736
|
-
fact_ids: tuple[str, ...],
|
|
737
|
-
state: dict[str, bool],
|
|
738
|
-
) -> None:
|
|
739
|
-
repository.checkpoint_enriching(
|
|
740
|
-
operation.operation_id,
|
|
741
|
-
final_fact_ids=fact_ids,
|
|
742
|
-
derivation_version=_DERIVATION_VERSION,
|
|
743
|
-
derivation_state=state,
|
|
744
|
-
lease_owner=operation.lease_owner,
|
|
745
|
-
lease_seconds=900.0,
|
|
746
|
-
)
|
|
747
|
-
|
|
748
|
-
try:
|
|
749
|
-
fact_ids = run_store(
|
|
750
|
-
operation.raw_content,
|
|
751
|
-
operation.profile_id,
|
|
752
|
-
session_id=operation.session_id,
|
|
753
|
-
session_date=operation.session_date or None,
|
|
754
|
-
speaker=operation.speaker,
|
|
755
|
-
role=operation.role,
|
|
756
|
-
metadata=dict(operation.metadata),
|
|
757
|
-
scope=operation.scope,
|
|
758
|
-
shared_with=list(operation.shared_with) or None,
|
|
759
|
-
config=engine._config,
|
|
760
|
-
db=engine._db,
|
|
761
|
-
embedder=engine._embedder,
|
|
762
|
-
fact_extractor=(
|
|
763
|
-
_QueryableProjectionExtractor()
|
|
764
|
-
if is_prebuilt else engine._fact_extractor
|
|
765
|
-
),
|
|
766
|
-
entity_resolver=engine._entity_resolver,
|
|
767
|
-
temporal_parser=engine._temporal_parser,
|
|
768
|
-
type_router=None if is_prebuilt else engine._type_router,
|
|
769
|
-
graph_builder=engine._graph_builder,
|
|
770
|
-
consolidator=None if is_prebuilt else engine._consolidator,
|
|
771
|
-
observation_builder=engine._observation_builder,
|
|
772
|
-
scene_builder=engine._scene_builder,
|
|
773
|
-
entropy_gate=engine._entropy_gate,
|
|
774
|
-
# External indexes are projected only after the relational unit
|
|
775
|
-
# of work commits; sqlite-vec uses a separate connection.
|
|
776
|
-
ann_index=None,
|
|
777
|
-
sheaf_checker=engine._sheaf_checker,
|
|
778
|
-
retrieval_engine=None,
|
|
779
|
-
provenance=engine._provenance,
|
|
780
|
-
hooks=engine._hooks,
|
|
781
|
-
vector_store=None,
|
|
782
|
-
context_generator=engine._context_generator,
|
|
783
|
-
temporal_validator=engine._temporal_validator,
|
|
784
|
-
auto_linker=engine._auto_linker,
|
|
785
|
-
consolidation_engine=engine._consolidation_engine,
|
|
786
|
-
existing_memory_id=memory_id,
|
|
787
|
-
queryable_fact_ids=operation.queryable_fact_ids,
|
|
788
|
-
trusted_actor_id=operation.trusted_actor_id,
|
|
789
|
-
pre_authorized=True,
|
|
790
|
-
ingestion_source_type=operation.source_type,
|
|
791
|
-
ingestion_operation_id=operation.operation_id,
|
|
792
|
-
derivation_report=pipeline_state,
|
|
793
|
-
precompleted_derivation_stages=(
|
|
794
|
-
frozenset({"extraction", "consolidation"})
|
|
795
|
-
if is_prebuilt else frozenset()
|
|
796
|
-
),
|
|
797
|
-
materialization_progress=progress,
|
|
798
|
-
materialization_checkpoint=checkpoint_materialization,
|
|
799
|
-
)
|
|
800
|
-
except Exception as exc:
|
|
801
|
-
from superlocalmemory.core.materialization_control import (
|
|
802
|
-
MaterializationDeferred,
|
|
803
|
-
)
|
|
804
|
-
if isinstance(exc, MaterializationDeferred):
|
|
805
|
-
raise
|
|
806
|
-
# ``run_store`` checkpoints the completed relational pipeline
|
|
807
|
-
# immediately before post-hooks run. Prefer that durable ledger
|
|
808
|
-
# over rebuilding state from local variables: a one-time hook
|
|
809
|
-
# failure must not make committed extraction/consolidation look
|
|
810
|
-
# incomplete and trigger a destructive pipeline replay on retry.
|
|
811
|
-
checkpoint = repository.get(operation.operation_id)
|
|
812
|
-
partial_ids = tuple(checkpoint.final_fact_ids)
|
|
813
|
-
failed_state = dict(checkpoint.derivation_state)
|
|
814
|
-
if not partial_ids:
|
|
815
|
-
partial_ids = tuple(progress.get("fact_ids") or ())
|
|
816
|
-
if not partial_ids:
|
|
817
|
-
partial_ids = tuple(
|
|
818
|
-
fact.fact_id
|
|
819
|
-
for fact in engine._db.get_facts_by_memory_id(
|
|
820
|
-
memory_id, operation.profile_id
|
|
821
|
-
)
|
|
822
|
-
)
|
|
823
|
-
if not failed_state:
|
|
824
|
-
relational_complete = bool(
|
|
825
|
-
progress.get("relational_complete", False)
|
|
826
|
-
)
|
|
827
|
-
failed_state = {
|
|
828
|
-
**{
|
|
829
|
-
name: bool(pipeline_state.get(name, False))
|
|
830
|
-
for name in (
|
|
831
|
-
"extraction",
|
|
832
|
-
"canonicalization",
|
|
833
|
-
"consolidation",
|
|
834
|
-
"graph",
|
|
835
|
-
"temporal",
|
|
836
|
-
"provenance",
|
|
837
|
-
)
|
|
838
|
-
},
|
|
839
|
-
"pipeline_started": True,
|
|
840
|
-
"relational_started": bool(
|
|
841
|
-
progress.get("relational_started", False)
|
|
842
|
-
),
|
|
843
|
-
"pipeline": relational_complete,
|
|
844
|
-
"post_hooks": False,
|
|
845
|
-
}
|
|
846
|
-
# Reaching this exception handler means hooks did not complete.
|
|
847
|
-
# Keep this false even if a future hook implementation mutates the
|
|
848
|
-
# in-memory progress map before raising.
|
|
849
|
-
failed_state["post_hooks"] = False
|
|
850
|
-
return MaterializationResult(partial_ids, failed_state, str(exc))
|
|
851
|
-
if not fact_ids:
|
|
852
|
-
return MaterializationResult((), {"relational": False})
|
|
853
|
-
|
|
854
|
-
placeholders = ",".join("?" for _ in fact_ids)
|
|
855
|
-
relational_count = engine._db.execute(
|
|
856
|
-
f"SELECT COUNT(*) AS count FROM atomic_facts "
|
|
857
|
-
f"WHERE fact_id IN ({placeholders}) AND profile_id=?",
|
|
858
|
-
(*fact_ids, operation.profile_id),
|
|
859
|
-
)
|
|
860
|
-
fts_count = engine._db.execute(
|
|
861
|
-
f"SELECT COUNT(*) AS count FROM atomic_facts_fts "
|
|
862
|
-
f"WHERE fact_id IN ({placeholders})",
|
|
863
|
-
tuple(fact_ids),
|
|
864
|
-
)
|
|
865
|
-
provenance_count = engine._db.execute(
|
|
866
|
-
f"SELECT COUNT(DISTINCT fact_id) AS count FROM provenance "
|
|
867
|
-
f"WHERE fact_id IN ({placeholders}) AND profile_id=? "
|
|
868
|
-
"AND source_type=? AND source_id=? AND created_by=?",
|
|
869
|
-
(
|
|
870
|
-
*fact_ids,
|
|
871
|
-
operation.profile_id,
|
|
872
|
-
operation.source_type,
|
|
873
|
-
operation.operation_id,
|
|
874
|
-
operation.trusted_actor_id,
|
|
875
|
-
),
|
|
876
|
-
)
|
|
877
|
-
temporal_required = engine._temporal_validator is not None
|
|
878
|
-
temporal_complete = True
|
|
879
|
-
if temporal_required:
|
|
880
|
-
temporal_count = engine._db.execute(
|
|
881
|
-
f"SELECT COUNT(DISTINCT fact_id) AS count FROM fact_temporal_validity "
|
|
882
|
-
f"WHERE fact_id IN ({placeholders}) AND profile_id=?",
|
|
883
|
-
(*fact_ids, operation.profile_id),
|
|
884
|
-
)
|
|
885
|
-
temporal_complete = int(dict(temporal_count[0])["count"]) == len(fact_ids)
|
|
886
|
-
|
|
887
|
-
embeddings_complete = True
|
|
888
|
-
if engine._embedder is not None:
|
|
889
|
-
embedding_count = engine._db.execute(
|
|
890
|
-
f"SELECT COUNT(*) AS count FROM atomic_facts "
|
|
891
|
-
f"WHERE fact_id IN ({placeholders}) AND embedding IS NOT NULL",
|
|
892
|
-
tuple(fact_ids),
|
|
893
|
-
)
|
|
894
|
-
embeddings_complete = (
|
|
895
|
-
int(dict(embedding_count[0])["count"]) == len(fact_ids)
|
|
896
|
-
)
|
|
897
|
-
|
|
898
|
-
derivation_state = {
|
|
899
|
-
"pipeline_started": True,
|
|
900
|
-
"relational_started": True,
|
|
901
|
-
"pipeline": True,
|
|
902
|
-
"post_hooks": True,
|
|
903
|
-
"relational": int(dict(relational_count[0])["count"]) == len(fact_ids),
|
|
904
|
-
"fts": int(dict(fts_count[0])["count"]) == len(fact_ids),
|
|
905
|
-
"extraction": pipeline_state.get("extraction", False),
|
|
906
|
-
"canonicalization": pipeline_state.get("canonicalization", False),
|
|
907
|
-
"consolidation": pipeline_state.get("consolidation", False),
|
|
908
|
-
"graph": pipeline_state.get("graph", False),
|
|
909
|
-
"temporal": (
|
|
910
|
-
temporal_complete and pipeline_state.get("temporal", False)
|
|
911
|
-
),
|
|
912
|
-
"provenance": (
|
|
913
|
-
int(dict(provenance_count[0])["count"]) == len(fact_ids)
|
|
914
|
-
and pipeline_state.get("provenance", False)
|
|
915
|
-
),
|
|
916
|
-
"trust_policy": bool(operation.trusted_actor_id),
|
|
917
|
-
"embeddings": embeddings_complete,
|
|
918
|
-
}
|
|
919
|
-
return MaterializationResult(tuple(fact_ids), derivation_state)
|
|
920
|
-
|
|
921
|
-
def project(operation: IngestionOperation) -> dict[str, bool]:
|
|
922
|
-
facts = engine._db.get_facts_by_ids(
|
|
923
|
-
list(operation.final_fact_ids),
|
|
924
|
-
operation.profile_id,
|
|
925
|
-
)
|
|
926
|
-
if len(facts) != len(operation.final_fact_ids):
|
|
927
|
-
raise RuntimeError("external projection facts are missing")
|
|
928
|
-
|
|
929
|
-
ann_required = engine._ann_index is not None
|
|
930
|
-
vector_store = engine._vector_store
|
|
931
|
-
vector_required = bool(
|
|
932
|
-
vector_store is not None and getattr(vector_store, "available", False)
|
|
933
|
-
)
|
|
934
|
-
ann_complete = True
|
|
935
|
-
vector_complete = True
|
|
936
|
-
bm25_complete = True
|
|
937
|
-
bm25 = getattr(engine._retrieval_engine, "_bm25", None)
|
|
938
|
-
for fact in facts:
|
|
939
|
-
if not fact.embedding:
|
|
940
|
-
if ann_required:
|
|
941
|
-
ann_complete = False
|
|
942
|
-
if vector_required:
|
|
943
|
-
vector_complete = False
|
|
944
|
-
if fact.embedding and ann_required:
|
|
945
|
-
try:
|
|
946
|
-
engine._ann_index.add(fact.fact_id, fact.embedding)
|
|
947
|
-
except Exception:
|
|
948
|
-
ann_complete = False
|
|
949
|
-
if fact.embedding and vector_required:
|
|
950
|
-
if not vector_store.upsert(
|
|
951
|
-
fact_id=fact.fact_id,
|
|
952
|
-
profile_id=operation.profile_id,
|
|
953
|
-
embedding=fact.embedding,
|
|
954
|
-
):
|
|
955
|
-
vector_complete = False
|
|
956
|
-
if bm25 is not None:
|
|
957
|
-
try:
|
|
958
|
-
bm25.add(fact.fact_id, fact.content, operation.profile_id)
|
|
959
|
-
except Exception:
|
|
960
|
-
bm25_complete = False
|
|
961
|
-
return {
|
|
962
|
-
"ann": ann_complete,
|
|
963
|
-
"vector": vector_complete,
|
|
964
|
-
"bm25": bm25_complete,
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
return IngestionCommand(
|
|
968
|
-
repository,
|
|
969
|
-
write_queryable=write_queryable,
|
|
970
|
-
materialize=materialize,
|
|
971
|
-
validate_admission=validate_admission,
|
|
972
|
-
project=project,
|
|
973
|
-
derivation_version=_DERIVATION_VERSION,
|
|
974
|
-
)
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
__all__ = [
|
|
978
|
-
"build_immediate_admission_handler",
|
|
979
|
-
"build_engine_ingestion_command",
|
|
980
|
-
"canonical_store",
|
|
981
|
-
"canonical_store_fn",
|
|
982
|
-
"local_trusted_actor_id",
|
|
983
|
-
]
|