brainlayer 1.5.91__tar.gz → 1.5.93__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. {brainlayer-1.5.91 → brainlayer-1.5.93}/PKG-INFO +1 -1
  2. {brainlayer-1.5.91 → brainlayer-1.5.93}/pyproject.toml +1 -1
  3. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/hotlane_brainbar_daemon.py +380 -23
  4. {brainlayer-1.5.91 → brainlayer-1.5.93}/server.json +2 -2
  5. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/__init__.py +1 -1
  6. brainlayer-1.5.93/src/brainlayer/_build.py +1 -0
  7. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/agent_provenance.py +3 -1
  8. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/backup_daily.py +143 -83
  9. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/cli/__init__.py +68 -8
  10. brainlayer-1.5.93/src/brainlayer/codex_zst.py +271 -0
  11. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/drain.py +6 -7
  12. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/drain_liveness.py +1 -1
  13. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/drive_credentials.py +17 -19
  14. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/health_facts.py +46 -0
  15. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/health_verdict.py +7 -0
  16. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/hotlane_budget.py +3 -0
  17. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/ingest/codex.py +11 -5
  18. brainlayer-1.5.93/src/brainlayer/ingest/codex_manifest.py +421 -0
  19. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/launchd_consolidation.py +8 -3
  20. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/maintenance_calendar.py +80 -11
  21. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/maintenance_control.py +3 -3
  22. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp_stdio_bridge.py +16 -0
  23. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/migration_runtime.py +50 -23
  24. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/queue_io.py +18 -0
  25. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/queue_merge.py +39 -8
  26. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/service_supervisor.py +3 -1
  27. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/supervisor_guard.py +64 -2
  28. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/t3_linkage_alarm.py +111 -0
  29. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/t3_provenance.py +86 -45
  30. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/wal_checkpoint.py +1 -1
  31. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/watcher.py +837 -88
  32. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/watcher_bridge.py +78 -13
  33. brainlayer-1.5.93/src/brainlayer/zstd_stream.py +91 -0
  34. brainlayer-1.5.91/src/brainlayer/_build.py +0 -1
  35. {brainlayer-1.5.91 → brainlayer-1.5.93}/.gitignore +0 -0
  36. {brainlayer-1.5.91 → brainlayer-1.5.93}/LICENSE +0 -0
  37. {brainlayer-1.5.91 → brainlayer-1.5.93}/README.md +0 -0
  38. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/backup-daily.sh +0 -0
  39. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/brainlayer-env-run.sh +0 -0
  40. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/brainlayer.env.example +0 -0
  41. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.backup-daily.plist +0 -0
  42. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.daemon.plist +0 -0
  43. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.decay.plist +0 -0
  44. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.drain.plist +0 -0
  45. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.health-check.plist +0 -0
  46. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.hotlane-brainbar.plist +0 -0
  47. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.index.plist +0 -0
  48. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.jsonl-backup.plist +0 -0
  49. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.log-cap.plist +0 -0
  50. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.maintenance-nightly.plist +0 -0
  51. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.maintenance-weekly.plist +0 -0
  52. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.maintenance.plist +0 -0
  53. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.observability.plist +0 -0
  54. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.p0-counter.plist +0 -0
  55. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.repair-fts.plist +0 -0
  56. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.t3-ingest.plist +0 -0
  57. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.throughput-watchdog.plist +0 -0
  58. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.tier0-watchdog.plist +0 -0
  59. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.wal-checkpoint.plist +0 -0
  60. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.brainlayer.watch.plist +0 -0
  61. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/com.etanhey.brainlayer-fleet-watchdog.plist +0 -0
  62. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/fleet-watchdog.sh +0 -0
  63. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/install.sh +0 -0
  64. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/jsonl-backup.sh +0 -0
  65. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/launchd/throughput-watchdog.py +0 -0
  66. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/release-verify-signatures.sh +0 -0
  67. {brainlayer-1.5.91 → brainlayer-1.5.93}/scripts/tier0-watchdog.sh +0 -0
  68. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/__main__.py +0 -0
  69. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/_helpers.py +0 -0
  70. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/agent_profiles.py +0 -0
  71. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/alarm.py +0 -0
  72. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/archive_collapse.py +0 -0
  73. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/archive_lifecycle.py +0 -0
  74. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/backup_retention_invariant.py +0 -0
  75. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/badge_state.py +0 -0
  76. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/bitemporal.py +0 -0
  77. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/brainbar_activation.py +0 -0
  78. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/brainbar_auto_activation.py +0 -0
  79. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/brainbar_hybrid_helper.py +0 -0
  80. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/brainbar_identity.py +0 -0
  81. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/cachedelete_purge.swift +0 -0
  82. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/calibrate.py +0 -0
  83. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/chunk_origin.py +0 -0
  84. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/chunk_origin_backfill.py +0 -0
  85. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/chunk_origin_wipe.py +0 -0
  86. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/chunk_write.py +0 -0
  87. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/classify.py +0 -0
  88. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/claude_paths.py +0 -0
  89. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/cli/wizard.py +0 -0
  90. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/cli_jobs.py +0 -0
  91. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/cli_new.py +0 -0
  92. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/cloud_backfill.py +0 -0
  93. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/clustering.py +0 -0
  94. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/component_jobs.py +0 -0
  95. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/config.py +0 -0
  96. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/consolidation_plan.py +0 -0
  97. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/content_class.py +0 -0
  98. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/content_hash_repair.py +0 -0
  99. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/correction_judge.py +0 -0
  100. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/data/agents_registry.yaml +0 -0
  101. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/data/sandbox_seeds/skill-eval-baseline.json +0 -0
  102. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/db_shrink.py +0 -0
  103. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/decay.py +0 -0
  104. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/decay_backfill.py +0 -0
  105. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/decay_job.py +0 -0
  106. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/dedupe.py +0 -0
  107. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/dedupe_merge.py +0 -0
  108. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/deploy_drift.py +0 -0
  109. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/disk_space.py +0 -0
  110. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/doctor.py +0 -0
  111. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/embeddings.py +0 -0
  112. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/engine.py +0 -0
  113. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/enrichment_replay.py +0 -0
  114. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/__init__.py +0 -0
  115. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/abcde_enrich_runner.py +0 -0
  116. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/abcde_variants.py +0 -0
  117. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/abcde_variants.yaml +0 -0
  118. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/benchmark.py +0 -0
  119. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/enrichment_gold.py +0 -0
  120. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/enrichment_graders.py +0 -0
  121. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/enrichment_judge.py +0 -0
  122. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/enrichment_llm_judge.py +0 -0
  123. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/enrichment_quality_benchmark.py +0 -0
  124. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/experiment_store.py +0 -0
  125. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/fixtures/README.md +0 -0
  126. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/labeling/enrichment-labeler.html +0 -0
  127. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/phoenix_gate/__init__.py +0 -0
  128. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/phoenix_gate/__main__.py +0 -0
  129. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/phoenix_gate/baseline_store.py +0 -0
  130. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/phoenix_gate/cli.py +0 -0
  131. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/phoenix_gate/models.py +0 -0
  132. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/phoenix_gate/phoenix_client.py +0 -0
  133. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/phoenix_gate/regression_gate.py +0 -0
  134. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/phoenix_gate/triggers.py +0 -0
  135. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/eval/pilot_artifact_report.py +0 -0
  136. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/fallback_replay.py +0 -0
  137. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/git_learning.py +0 -0
  138. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/health_check.py +0 -0
  139. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/hook_python.py +0 -0
  140. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/hooks/__init__.py +0 -0
  141. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/hooks/indexer.py +0 -0
  142. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/import_sweep.py +0 -0
  143. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/index_admission.py +0 -0
  144. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/index_budget.py +0 -0
  145. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/index_completeness.py +0 -0
  146. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/index_new.py +0 -0
  147. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/index_watchdog.py +0 -0
  148. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/ingest/__init__.py +0 -0
  149. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/ingest/t3.py +0 -0
  150. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/ingest_denylist.py +0 -0
  151. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/ingest_guard.py +0 -0
  152. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/isolation_proof.py +0 -0
  153. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/job_alerts.py +0 -0
  154. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/job_lifecycle_health.py +0 -0
  155. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/jobs.py +0 -0
  156. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/jsonl_backup.py +0 -0
  157. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/kg/__init__.py +0 -0
  158. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/kg_cleanup.py +0 -0
  159. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/kg_judge.py +0 -0
  160. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/kg_promotion.py +0 -0
  161. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/kg_repo.py +0 -0
  162. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/kg_review_session.py +0 -0
  163. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/kg_session_finish.py +0 -0
  164. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/kg_session_harvest.py +0 -0
  165. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/launchd_install.py +0 -0
  166. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/launchd_primitive.py +0 -0
  167. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/launchd_revert.py +0 -0
  168. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/launcher_policy_reconcile.py +0 -0
  169. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/lexical_defense.py +0 -0
  170. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/lexical_defense_dictionary.json +0 -0
  171. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/linkedin_import.py +0 -0
  172. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/log_cap.py +0 -0
  173. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/maintenance.py +0 -0
  174. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp/__init__.py +0 -0
  175. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp/_format.py +0 -0
  176. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp/_shared.py +0 -0
  177. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp/enrich_handler.py +0 -0
  178. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp/entity_handler.py +0 -0
  179. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp/palette.py +0 -0
  180. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp/search_handler.py +0 -0
  181. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp/store_handler.py +0 -0
  182. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp/tags_handler.py +0 -0
  183. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/mcp_socket_config.py +0 -0
  184. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/memory_types.py +0 -0
  185. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/migrate.py +0 -0
  186. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/migration_custody.py +0 -0
  187. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/migration_journal.py +0 -0
  188. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/notification_policy.py +0 -0
  189. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/observability_backup.py +0 -0
  190. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/observability_surface.py +0 -0
  191. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/observability_transport.py +0 -0
  192. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/p0_longitudinal_count.py +0 -0
  193. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/parent_death.py +0 -0
  194. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/paths.py +0 -0
  195. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pause.py +0 -0
  196. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/phonetic.py +0 -0
  197. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/__init__.py +0 -0
  198. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/agent_enrichment.py +0 -0
  199. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/analyze_communication.py +0 -0
  200. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/batch_extraction.py +0 -0
  201. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/brain_graph.py +0 -0
  202. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/chat_tags.py +0 -0
  203. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/chunk.py +0 -0
  204. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/classify.py +0 -0
  205. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/cloud_scrub.py +0 -0
  206. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/cluster_sampling.py +0 -0
  207. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/code_intelligence.py +0 -0
  208. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/correction_detection.py +0 -0
  209. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/correction_mining.py +0 -0
  210. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/digest.py +0 -0
  211. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/enrichment_prompts.py +0 -0
  212. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/enrichment_results.py +0 -0
  213. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/enrichment_tiers.py +0 -0
  214. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/entity_extraction.py +0 -0
  215. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/entity_resolution.py +0 -0
  216. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/extract.py +0 -0
  217. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/extract_claude_desktop.py +0 -0
  218. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/extract_corrections.py +0 -0
  219. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/extract_markdown.py +0 -0
  220. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/extract_whatsapp.py +0 -0
  221. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/frustration_mining.py +0 -0
  222. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/git_overlay.py +0 -0
  223. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/kg_extraction.py +0 -0
  224. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/kg_extraction_groq.py +0 -0
  225. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/longitudinal_analyzer.py +0 -0
  226. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/obsidian_export.py +0 -0
  227. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/operation_grouping.py +0 -0
  228. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/plan_linking.py +0 -0
  229. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/rate_limiter.py +0 -0
  230. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/relation_backfill.py +0 -0
  231. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/relation_verification.py +0 -0
  232. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/sanitize.py +0 -0
  233. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/secret_scrub.py +0 -0
  234. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/semantic_style.py +0 -0
  235. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/sentiment.py +0 -0
  236. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/session_history.py +0 -0
  237. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/style_embed.py +0 -0
  238. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/style_index.py +0 -0
  239. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/tag_entity_promotion.py +0 -0
  240. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/temporal_chains.py +0 -0
  241. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/time_batcher.py +0 -0
  242. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/unified_timeline.py +0 -0
  243. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/pipeline/write_queue.py +0 -0
  244. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/policy_reconcile.py +0 -0
  245. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/provenance.py +0 -0
  246. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/provenance_autosupersede.py +0 -0
  247. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/provenance_integration.py +0 -0
  248. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/readonly_snapshot.py +0 -0
  249. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/reembed_backfill.py +0 -0
  250. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/retired_services.py +0 -0
  251. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/runtime_store.py +0 -0
  252. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/sandbox_db.py +0 -0
  253. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/schema_ddl_ledger.py +0 -0
  254. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/scoping.py +0 -0
  255. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/scrub_at_rest.py +0 -0
  256. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/search_fanout.py +0 -0
  257. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/search_profile.py +0 -0
  258. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/search_repo.py +0 -0
  259. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/search_response.py +0 -0
  260. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/session_repo.py +0 -0
  261. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/setup.py +0 -0
  262. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/socket_hygiene.py +0 -0
  263. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/source_class_migration.py +0 -0
  264. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/spotlight.py +0 -0
  265. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/storage.py +0 -0
  266. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/store.py +0 -0
  267. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/supervisor_adapters.py +0 -0
  268. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/supervisor_child.py +0 -0
  269. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/supervisor_diagnostics.py +0 -0
  270. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/supervisor_jobs.py +0 -0
  271. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/system_prompt_guard.py +0 -0
  272. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/t3_sources.py +0 -0
  273. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/tag_normalization.py +0 -0
  274. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/taxonomy.json +0 -0
  275. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/telemetry.py +0 -0
  276. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/timestamp_iso.py +0 -0
  277. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/types.py +0 -0
  278. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/vector_store.py +0 -0
  279. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/writer_policy.py +0 -0
  280. {brainlayer-1.5.91 → brainlayer-1.5.93}/src/brainlayer/writer_telemetry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: brainlayer
3
- Version: 1.5.91
3
+ Version: 1.5.93
4
4
  Summary: Persistent local memory for AI agents — 16 BrainBar MCP tools, semantic search, knowledge graph, SQLite
5
5
  Project-URL: Homepage, https://brainlayer.etanheyman.com
6
6
  Project-URL: Repository, https://github.com/EtanHey/brainlayer
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "brainlayer"
3
- version = "1.5.91"
3
+ version = "1.5.93"
4
4
  description = "Persistent local memory for AI agents — 16 BrainBar MCP tools, semantic search, knowledge graph, SQLite"
5
5
  license = {text = "Apache-2.0"}
6
6
  readme = "README.md"
@@ -10,11 +10,14 @@ Python enrichment arguments are accepted for compatibility but cannot invoke a m
10
10
  from __future__ import annotations
11
11
 
12
12
  import argparse
13
+ import errno
14
+ import hashlib
13
15
  import inspect
14
16
  import json
15
17
  import logging
16
18
  import math
17
19
  import os
20
+ import re
18
21
  import signal
19
22
  import subprocess
20
23
  import sys
@@ -48,6 +51,24 @@ VECTOR_WRITE_YIELD_SECONDS = 0.005
48
51
  # inside the cycle (each try waits up to the hotlane busy timeout at BEGIN IMMEDIATE), then
49
52
  # whatever is still unwritten is carried to the next cycle instead of being discarded.
50
53
  HOTLANE_WRITE_ATTEMPTS = 3
54
+ MAX_CHUNK_FAILURE_ATTEMPTS = 3
55
+ DEFAULT_QUARANTINE_TTL_SECONDS = 3600.0
56
+ MAX_CHUNK_FAILURE_ENTRIES = 4096
57
+ # This many consecutive distinct chunks failing with one error class in one loop is the
58
+ # environment failing, not the chunks. Above the 2-row poison batch the backlog lane sees.
59
+ SYSTEMIC_FAILURE_STREAK = 4
60
+ MAX_SYSTEMIC_BACKOFF_SECONDS = 60.0
61
+ # Known-good operations the failure streak runs to tell a failing environment from that
62
+ # many genuine poison rows (see _FailureStreak).
63
+ HOTLANE_CANARY_TEXT = "BrainLayer hotlane canary: a short, ordinary sentence the encoder must embed."
64
+ HOTLANE_CANARY_CHUNK_ID = "__brainlayer_hotlane_write_canary__"
65
+ HOTLANE_CANARY_COMPONENT = 0.03125
66
+ _DECLARED_VECTOR_DIMENSION = re.compile(r"\bembedding\s+float\s*\[\s*(\d+)\s*\]", re.IGNORECASE)
67
+ # 2**16 times any base of 1 ms or more already exceeds the 60 s cap; never exponentiate past it.
68
+ SYSTEMIC_BACKOFF_MAX_EXPONENT = 16
69
+ _ENVIRONMENTAL_ERRNOS = frozenset({errno.ENOSPC, errno.EIO, errno.EROFS, errno.EDQUOT})
70
+ _ENVIRONMENTAL_SQLITE_ERRORS = (apsw.FullError, apsw.IOError, apsw.ReadOnlyError)
71
+ _ENVIRONMENTAL_SQLITE_PRIMARY_CODES = frozenset({8, 10, 13}) # READONLY, IOERR, FULL
51
72
  HOTLANE_WRITE_RETRY_BACKOFF_SECONDS = 0.25
52
73
  MAX_CARRIED_VECTORS = 64
53
74
  # Hooks the hotlane writer never runs in its Connection() constructor. `connection_optimize`
@@ -167,6 +188,248 @@ class EmbedCandidate(NamedTuple):
167
188
  content: str
168
189
 
169
190
 
191
+ def _systemic_backoff_seconds(base: float, failures: int) -> float:
192
+ """Geometric backoff for the ``failures``-th consecutive systemic cycle, capped.
193
+
194
+ The exponent is clamped BEFORE the power: ``base * 2 ** 1024`` is a float overflow,
195
+ which would escape ``run()``'s cycle handler and stop the daemon at the 1,025th
196
+ consecutive systemic cycle (~17 h of a full disk at the 60 s cap).
197
+ """
198
+ exponent = min(max(failures - 1, 0), SYSTEMIC_BACKOFF_MAX_EXPONENT)
199
+ return min(base * 2**exponent, MAX_SYSTEMIC_BACKOFF_SECONDS)
200
+
201
+
202
+ def _quarantine_ttl_seconds() -> float:
203
+ raw = os.environ.get("BRAINLAYER_HOTLANE_QUARANTINE_TTL_S")
204
+ if raw is None:
205
+ return DEFAULT_QUARANTINE_TTL_SECONDS
206
+ try:
207
+ value = float(raw)
208
+ except ValueError:
209
+ value = math.nan
210
+ if not math.isfinite(value) or value <= 0:
211
+ LOGGER.warning(
212
+ "ignoring invalid BRAINLAYER_HOTLANE_QUARANTINE_TTL_S=%r; using %.0fs",
213
+ raw,
214
+ DEFAULT_QUARANTINE_TTL_SECONDS,
215
+ )
216
+ return DEFAULT_QUARANTINE_TTL_SECONDS
217
+ return value
218
+
219
+
220
+ def _is_environmental_error(exc: BaseException | None) -> bool:
221
+ """True when the failure belongs to the machine (disk, I/O, read-only), not to one chunk."""
222
+ seen: set[int] = set()
223
+ while exc is not None and id(exc) not in seen:
224
+ seen.add(id(exc))
225
+ if isinstance(exc, _ENVIRONMENTAL_SQLITE_ERRORS):
226
+ return True
227
+ if isinstance(exc, OSError) and exc.errno in _ENVIRONMENTAL_ERRNOS:
228
+ return True
229
+ code = getattr(exc, "sqlite_errorcode", None)
230
+ if isinstance(code, int) and code & 0xFF in _ENVIRONMENTAL_SQLITE_PRIMARY_CODES:
231
+ return True
232
+ exc = exc.__cause__ if exc.__cause__ is not None else (None if exc.__suppress_context__ else exc.__context__)
233
+ return False
234
+
235
+
236
+ class HotlaneSystemicFailure(RuntimeError):
237
+ """A cycle-level failure: the environment, not individual chunks, is failing."""
238
+
239
+ def __init__(self, stage: str, error_type: str, chunk_ids: list[str]) -> None:
240
+ super().__init__(
241
+ f"hotlane systemic {stage} failure error_type={error_type} chunks={len(chunk_ids)}; "
242
+ "not counted toward per-chunk quarantine"
243
+ )
244
+ self.stage = stage
245
+ self.error_type = error_type
246
+ self.chunk_ids = chunk_ids
247
+
248
+
249
+ class ChunkFailureAttempts:
250
+ """Process-local quarantine; source rows stay intact and restart permits a new try.
251
+
252
+ Key by content digest as well as id so an edited chunk can recover. Only failures
253
+ attributable to an individual chunk count; writer connection errors do not. An entry
254
+ expires ``ttl_s`` after its last failure, so a quarantined chunk is retried (loudly)
255
+ without a restart, and the table never holds more than ``max_entries`` keys.
256
+ """
257
+
258
+ def __init__(
259
+ self,
260
+ *,
261
+ clock: Callable[[], float] = time.monotonic,
262
+ ttl_s: float | None = None,
263
+ max_entries: int = MAX_CHUNK_FAILURE_ENTRIES,
264
+ ) -> None:
265
+ # key -> (attempts, monotonic time of the last failure); oldest failure first.
266
+ self.attempts: OrderedDict[tuple[str, str], tuple[int, float]] = OrderedDict()
267
+ self.quarantined_total = 0
268
+ self.clock = clock
269
+ self.ttl_s = _quarantine_ttl_seconds() if ttl_s is None else ttl_s
270
+ self.max_entries = max(1, max_entries)
271
+ self._full_logged = False
272
+
273
+ def _key(self, candidate: EmbedCandidate) -> tuple[str, str]:
274
+ return candidate.chunk_id, hashlib.sha256(candidate.content.encode()).hexdigest()
275
+
276
+ def _expire(self, key: tuple[str, str], entry: tuple[int, float], now: float) -> bool:
277
+ if now - entry[1] < self.ttl_s:
278
+ return False
279
+ del self.attempts[key]
280
+ if entry[0] >= MAX_CHUNK_FAILURE_ATTEMPTS:
281
+ LOGGER.warning(
282
+ "hotlane chunk re-admitted after quarantine ttl chunk_id=%s attempts=%d ttl_s=%.0f",
283
+ key[0],
284
+ entry[0],
285
+ self.ttl_s,
286
+ )
287
+ return True
288
+
289
+ def count(self, candidate: EmbedCandidate) -> int:
290
+ key = self._key(candidate)
291
+ entry = self.attempts.get(key)
292
+ if entry is None or self._expire(key, entry, self.clock()):
293
+ return 0
294
+ return entry[0]
295
+
296
+ def quarantined(self, candidate: EmbedCandidate) -> bool:
297
+ return self.count(candidate) >= MAX_CHUNK_FAILURE_ATTEMPTS
298
+
299
+ def _has_room(self, now: float) -> bool:
300
+ """Free space by TTL expiry only; never evict a live entry.
301
+
302
+ Evicting a live quarantine re-admits it before its TTL. Evicting a below-cap
303
+ counter is worse under churn: cycling ``max_entries + 1`` distinct failures
304
+ evicts each key just before it fails again, pinning every counter at 1 so
305
+ nothing is ever quarantined. Refusing the incoming key (count 0, the least
306
+ evidence) instead lets the tracked keys reach quarantine; it is admitted once
307
+ an entry succeeds or expires. Bounded either way: TTL frees every entry.
308
+ """
309
+ for key, entry in list(self.attempts.items()):
310
+ if not self._expire(key, entry, now):
311
+ break # Ordered by last failure: the rest are younger.
312
+ if len(self.attempts) < self.max_entries:
313
+ self._full_logged = False
314
+ return True
315
+ if not self._full_logged:
316
+ self._full_logged = True
317
+ live = sum(1 for attempts, _ in self.attempts.values() if attempts >= MAX_CHUNK_FAILURE_ATTEMPTS)
318
+ LOGGER.warning(
319
+ "hotlane chunk failure table full; not tracking new failures until an entry succeeds or "
320
+ "expires max_entries=%d live_quarantines=%d ttl_s=%.0f",
321
+ self.max_entries,
322
+ live,
323
+ self.ttl_s,
324
+ )
325
+ return False
326
+
327
+ def failed(self, candidate: EmbedCandidate, exc: Exception) -> None:
328
+ if isinstance(exc, (apsw.BusyError, apsw.LockedError)) or self.quarantined(candidate):
329
+ return
330
+ key = self._key(candidate)
331
+ now = self.clock()
332
+ attempts = self.count(candidate) + 1
333
+ if key in self.attempts:
334
+ del self.attempts[key] # Re-inserted below as the youngest entry; never grows the table.
335
+ elif not self._has_room(now):
336
+ LOGGER.error(
337
+ "hotlane chunk failure untracked (table full) chunk_id=%s error_type=%s",
338
+ candidate.chunk_id,
339
+ type(exc).__name__,
340
+ )
341
+ return
342
+ self.attempts[key] = (attempts, now)
343
+ if attempts == MAX_CHUNK_FAILURE_ATTEMPTS:
344
+ self.quarantined_total += 1
345
+ LOGGER.error(
346
+ "hotlane chunk %s chunk_id=%s error_type=%s attempts=%d quarantined_total=%d",
347
+ "quarantined" if attempts >= MAX_CHUNK_FAILURE_ATTEMPTS else "retrying",
348
+ candidate.chunk_id,
349
+ type(exc).__name__,
350
+ attempts,
351
+ self.quarantined_total,
352
+ )
353
+
354
+ def succeeded(self, candidate: EmbedCandidate) -> None:
355
+ self.attempts.pop(self._key(candidate), None)
356
+
357
+
358
+ CHUNK_FAILURE_ATTEMPTS = ChunkFailureAttempts()
359
+
360
+
361
+ class _FailureStreak:
362
+ """Hold one loop's per-chunk failures until they prove to be about the chunk.
363
+
364
+ An environmental error (disk/I/O/read-only) raises ``HotlaneSystemicFailure`` at
365
+ once and counts nothing. ``SYSTEMIC_FAILURE_STREAK`` consecutive distinct chunks
366
+ failing with one error class is ambiguous -- the environment, or that many genuine
367
+ poison rows -- so it runs ``canary``, a known-good operation on the same path (a
368
+ fixed sentence through the same encoder; a correctly shaped vector written for a
369
+ sentinel id and rolled back). Canary passes: the environment works, so the rows are
370
+ at fault; they are charged per chunk and the loop goes on, letting later healthy
371
+ rows land and real poison reach quarantine. Canary fails, or there is none: the
372
+ streak is systemic and counts nothing. Anything else is charged to its chunk when
373
+ the streak breaks or the loop ends.
374
+ """
375
+
376
+ def __init__(self, stage: str, canary: Callable[[], None] | None = None) -> None:
377
+ self.stage = stage
378
+ self.canary = canary
379
+ self.error_type: type[BaseException] | None = None
380
+ self.members: list[tuple[EmbedCandidate, Exception]] = []
381
+
382
+ def _environment_works(self, exc: Exception) -> bool:
383
+ if self.canary is None:
384
+ return False
385
+ try:
386
+ self.canary()
387
+ except Exception as canary_exc:
388
+ LOGGER.error(
389
+ "hotlane %s canary failed after %d chunks failed error_type=%s canary_error_type=%s canary_error=%s",
390
+ self.stage,
391
+ len(self.members),
392
+ type(exc).__name__,
393
+ type(canary_exc).__name__,
394
+ canary_exc,
395
+ )
396
+ return False
397
+ LOGGER.warning(
398
+ "hotlane %s canary passed after %d chunks failed error_type=%s; charging them per chunk",
399
+ self.stage,
400
+ len(self.members),
401
+ type(exc).__name__,
402
+ )
403
+ return True
404
+
405
+ def _systemic(self, error_type: str, chunk_ids: list[str]) -> HotlaneSystemicFailure:
406
+ self.members = []
407
+ self.error_type = None
408
+ failure = HotlaneSystemicFailure(self.stage, error_type, chunk_ids)
409
+ LOGGER.error("%s; backing off", failure)
410
+ return failure
411
+
412
+ def failed(self, candidate: EmbedCandidate, exc: Exception) -> None:
413
+ if _is_environmental_error(exc):
414
+ ids = [member.chunk_id for member, _ in self.members] + [candidate.chunk_id]
415
+ raise self._systemic(type(exc).__name__, ids) from exc
416
+ if type(exc) is not self.error_type:
417
+ self.flush()
418
+ self.error_type = type(exc)
419
+ if all(member.chunk_id != candidate.chunk_id for member, _ in self.members):
420
+ self.members.append((candidate, exc))
421
+ if len(self.members) >= SYSTEMIC_FAILURE_STREAK:
422
+ if self._environment_works(exc):
423
+ self.flush()
424
+ return
425
+ raise self._systemic(type(exc).__name__, [member.chunk_id for member, _ in self.members]) from exc
426
+
427
+ def flush(self) -> None:
428
+ members, self.members, self.error_type = self.members, [], None
429
+ for candidate, exc in members:
430
+ CHUNK_FAILURE_ATTEMPTS.failed(candidate, exc)
431
+
432
+
170
433
  def _sysctl(name: str) -> str:
171
434
  return subprocess.check_output(["/usr/sbin/sysctl", "-n", name], text=True, timeout=5).strip()
172
435
 
@@ -340,7 +603,10 @@ def _candidates_from_scanned_rows(
340
603
  first_candidate_rowid = int(rowid)
341
604
  if str(chunk_id) in exclude_ids:
342
605
  continue
343
- candidates.append(EmbedCandidate(str(chunk_id), str(content)))
606
+ candidate = EmbedCandidate(str(chunk_id), str(content))
607
+ if CHUNK_FAILURE_ATTEMPTS.quarantined(candidate):
608
+ continue
609
+ candidates.append(candidate)
344
610
  if len(candidates) >= limit:
345
611
  return candidates, first_candidate_rowid, last_inspected_rowid, index == len(rows) - 1
346
612
  return candidates, first_candidate_rowid, last_inspected_rowid, True
@@ -379,7 +645,7 @@ class HotCandidateScanner:
379
645
  )
380
646
  active = {str(chunk_id): EmbedCandidate(str(chunk_id), str(content)) for chunk_id, content in rows}
381
647
  for chunk_id in list(self._retries):
382
- if chunk_id not in active:
648
+ if chunk_id not in active or CHUNK_FAILURE_ATTEMPTS.quarantined(active[chunk_id]):
383
649
  del self._retries[chunk_id]
384
650
  else:
385
651
  self._retries[chunk_id] = active[chunk_id]
@@ -530,7 +796,10 @@ def _candidate_chunk_rows(store: VectorStore, *, limit: int) -> list[EmbedCandid
530
796
  and superseded_by is None
531
797
  and aggregated_into is None
532
798
  ):
533
- candidates.append(EmbedCandidate(str(chunk_id), str(content)))
799
+ candidate = EmbedCandidate(str(chunk_id), str(content))
800
+ if CHUNK_FAILURE_ATTEMPTS.quarantined(candidate):
801
+ continue
802
+ candidates.append(candidate)
534
803
  if len(candidates) >= limit:
535
804
  break
536
805
  return candidates
@@ -605,9 +874,12 @@ def _pending_chunk_rows(
605
874
  for row in content_rows
606
875
  if row[1] and row[2] is None and row[3] is None and row[4] is None
607
876
  }
608
- candidates.extend(
609
- EmbedCandidate(chunk_id, content_by_id[chunk_id]) for chunk_id in candidate_ids if chunk_id in content_by_id
610
- )
877
+ for chunk_id in candidate_ids:
878
+ if chunk_id not in content_by_id:
879
+ continue
880
+ candidate = EmbedCandidate(chunk_id, content_by_id[chunk_id])
881
+ if not CHUNK_FAILURE_ATTEMPTS.quarantined(candidate):
882
+ candidates.append(candidate)
611
883
 
612
884
  after_created_at = id_rows[-1][1]
613
885
  after_rowid = int(id_rows[-1][2])
@@ -655,11 +927,16 @@ def _embed_candidates(
655
927
  LOGGER.warning("Failed to embed hotlane batch: %s", exc)
656
928
 
657
929
  embedded: list[EmbeddedVector] = []
930
+ streak = _FailureStreak("encode", canary=lambda: _encode_canary(embed_fn))
658
931
  for candidate in candidates:
659
932
  try:
660
933
  embedded.append(EmbeddedVector(candidate.chunk_id, candidate.content, embed_fn(candidate.content)))
661
934
  except Exception as exc:
662
935
  LOGGER.warning("Failed to embed chunk %s: %s", candidate.chunk_id, exc)
936
+ streak.failed(candidate, exc)
937
+ else:
938
+ streak.flush()
939
+ streak.flush()
663
940
  return embedded
664
941
 
665
942
 
@@ -734,6 +1011,34 @@ def _upsert_chunk_vector_raw(
734
1011
  )
735
1012
 
736
1013
 
1014
+ def _declared_vector_dimension(cursor) -> int:
1015
+ row = cursor.execute("SELECT sql FROM sqlite_master WHERE name = 'chunk_vectors'").fetchone()
1016
+ match = _DECLARED_VECTOR_DIMENSION.search(row[0] if row and row[0] else "")
1017
+ if match is None:
1018
+ raise RuntimeError("chunk_vectors declares no FLOAT[n] embedding; write canary inconclusive")
1019
+ return int(match.group(1))
1020
+
1021
+
1022
+ def _write_canary(cursor, upsert_chunk_vector: Callable[..., object]) -> None:
1023
+ """A known-good write on the hotlane's own path, always rolled back.
1024
+
1025
+ Writes a vector of the table's declared dimension for a sentinel id that no chunk
1026
+ uses, inside its own transaction, then rolls it back: nothing persists.
1027
+ """
1028
+ dimension = _declared_vector_dimension(cursor)
1029
+ cursor.execute("BEGIN IMMEDIATE")
1030
+ try:
1031
+ upsert_chunk_vector(cursor, HOTLANE_CANARY_CHUNK_ID, [HOTLANE_CANARY_COMPONENT] * dimension)
1032
+ finally:
1033
+ if cursor.connection.in_transaction:
1034
+ cursor.execute("ROLLBACK")
1035
+
1036
+
1037
+ def _encode_canary(embed_fn: Callable[[str], list[float]]) -> None:
1038
+ if not len(embed_fn(HOTLANE_CANARY_TEXT)):
1039
+ raise RuntimeError("encoder returned an empty embedding for the canary text")
1040
+
1041
+
737
1042
  class _WriteProgress:
738
1043
  def __init__(self) -> None:
739
1044
  self.written = 0
@@ -807,6 +1112,7 @@ def _write_embedded_vectors_once(
807
1112
  )
808
1113
 
809
1114
  count = 0
1115
+ streak = _FailureStreak("write", canary=lambda: _write_canary(cursor, upsert_chunk_vector))
810
1116
  try:
811
1117
  for vector_index, (chunk_id, content, embedding) in enumerate(vectors):
812
1118
  metrics = IngestMetrics("hotlane", "vector")
@@ -854,6 +1160,8 @@ def _write_embedded_vectors_once(
854
1160
  metadata = metadata if isinstance(metadata, dict) else {}
855
1161
  metrics.committed([{"queued_at": metadata.get("ingest_queued_at"), "metadata": metadata}])
856
1162
  metrics.finish("commit")
1163
+ streak.flush()
1164
+ CHUNK_FAILURE_ATTEMPTS.succeeded(EmbedCandidate(chunk_id, content))
857
1165
  count += rows_touched
858
1166
  progress.written = count
859
1167
  progress.processed = vector_index + 1
@@ -866,6 +1174,7 @@ def _write_embedded_vectors_once(
866
1174
  metrics.finish("error")
867
1175
  telemetry_span.finish("rollback", error=f"{type(exc).__name__}: {exc}")
868
1176
  if isinstance(exc, (apsw.BusyError, apsw.LockedError)):
1177
+ streak.flush()
869
1178
  raise
870
1179
  progress.processed = vector_index + 1
871
1180
  LOGGER.error(
@@ -874,8 +1183,10 @@ def _write_embedded_vectors_once(
874
1183
  type(exc).__name__,
875
1184
  exc,
876
1185
  )
1186
+ streak.failed(EmbedCandidate(chunk_id, content), exc)
877
1187
  if vector_index < len(vectors) - 1:
878
1188
  _sleep(VECTOR_WRITE_YIELD_SECONDS)
1189
+ streak.flush()
879
1190
  finally:
880
1191
  if conn is not None:
881
1192
  conn.close()
@@ -947,8 +1258,19 @@ def _run_split_cycle(
947
1258
  carryover = VECTOR_CARRYOVER if carryover is None else carryover
948
1259
  metrics = IngestMetrics("hotlane", "hotlane")
949
1260
  embedded = 0
1261
+
1262
+ def finish(outcome: str = "completed", exc: BaseException | None = None) -> None:
1263
+ metrics.fields["quarantined_total"] = CHUNK_FAILURE_ATTEMPTS.quarantined_total
1264
+ if isinstance(exc, HotlaneSystemicFailure):
1265
+ metrics.fields["systemic_failure"] = f"{exc.stage}:{exc.error_type}"
1266
+ metrics.finish(outcome)
1267
+
950
1268
  # Peek, not take: a scan or encode failure later in this cycle must not lose them.
951
- carried = carryover.peek()
1269
+ carried = [
1270
+ vector
1271
+ for vector in carryover.peek()
1272
+ if not CHUNK_FAILURE_ATTEMPTS.quarantined(EmbedCandidate(vector.chunk_id, vector.content))
1273
+ ]
952
1274
  carried_by_id = {vector.chunk_id: vector for vector in carried}
953
1275
  hot_rows: list[EmbedCandidate] = []
954
1276
  pending_rows: list[EmbedCandidate] = []
@@ -959,6 +1281,13 @@ def _run_split_cycle(
959
1281
  else None
960
1282
  )
961
1283
 
1284
+ def restore_pending_scan() -> None:
1285
+ if pending_scan_checkpoint is not None and pending_scan_state is not None:
1286
+ # Committed rows are filtered by the next scan; unresolved rows retry immediately.
1287
+ pending_scan_state.active, pending_scan_state.after_created_at, pending_scan_state.after_rowid = (
1288
+ pending_scan_checkpoint
1289
+ )
1290
+
962
1291
  if recent_limit > 0 or backlog_batch > 0:
963
1292
  if not db_path.exists():
964
1293
  bootstrap_store = _open_store(vector_store_cls, db_path, readonly=False)
@@ -972,6 +1301,9 @@ def _run_split_cycle(
972
1301
  finally:
973
1302
  read_store.close()
974
1303
 
1304
+ hot_rows = [candidate for candidate in hot_rows if not CHUNK_FAILURE_ATTEMPTS.quarantined(candidate)]
1305
+ pending_rows = [candidate for candidate in pending_rows if not CHUNK_FAILURE_ATTEMPTS.quarantined(candidate)]
1306
+ pending_candidates = pending_rows
975
1307
  seen_hot_ids = {candidate.chunk_id for candidate in hot_rows}
976
1308
  pending_rows = [candidate for candidate in pending_rows if candidate.chunk_id not in seen_hot_ids]
977
1309
 
@@ -982,33 +1314,47 @@ def _run_split_cycle(
982
1314
 
983
1315
  hot_rows = [candidate for candidate in hot_rows if needs_embedding(candidate)]
984
1316
  pending_rows = [candidate for candidate in pending_rows if needs_embedding(candidate)]
985
- vectors = metrics.run("encode", _embed_candidates, hot_rows, embed_fn=embed_fn, embed_batch_fn=embed_batch_fn)
986
- backlog_vectors = metrics.run(
987
- "encode", _embed_candidates, pending_rows, embed_fn=embed_fn, embed_batch_fn=embed_batch_fn
988
- )
1317
+ try:
1318
+ vectors = metrics.run("encode", _embed_candidates, hot_rows, embed_fn=embed_fn, embed_batch_fn=embed_batch_fn)
1319
+ backlog_vectors = metrics.run(
1320
+ "encode", _embed_candidates, pending_rows, embed_fn=embed_fn, embed_batch_fn=embed_batch_fn
1321
+ )
1322
+ except Exception as exc:
1323
+ restore_pending_scan()
1324
+ finish("error", exc)
1325
+ raise
989
1326
  vectors.extend(backlog_vectors)
990
1327
  fresh_ids = {vector.chunk_id for vector in vectors}
991
1328
  vectors = [vector for vector in carried if vector.chunk_id not in fresh_ids] + vectors
1329
+ encoded_content = {vector.chunk_id: vector.content for vector in vectors}
1330
+ if any(
1331
+ encoded_content.get(candidate.chunk_id) != candidate.content
1332
+ and not CHUNK_FAILURE_ATTEMPTS.quarantined(candidate)
1333
+ for candidate in pending_candidates
1334
+ ):
1335
+ # Individual encode failures are logged and omitted, including hot/backlog overlaps.
1336
+ restore_pending_scan()
992
1337
  if vectors:
993
1338
  try:
994
1339
  embedded += metrics.run("write", write_vectors_fn, db_path, vectors)
995
1340
  carryover.clear()
1341
+ if any(
1342
+ 0 < CHUNK_FAILURE_ATTEMPTS.count(candidate) < MAX_CHUNK_FAILURE_ATTEMPTS
1343
+ for candidate in pending_candidates
1344
+ ):
1345
+ restore_pending_scan()
996
1346
  except Exception as exc:
997
1347
  deferred = exc if isinstance(exc, HotlaneVectorWriteDeferred) else None
998
1348
  is_lock_error = deferred is not None or isinstance(exc, (apsw.BusyError, apsw.LockedError))
999
- if is_lock_error and pending_scan_checkpoint is not None and pending_scan_state is not None:
1000
- # Earlier one-row commits stay indexed; retry only rows still missing vectors.
1001
- pending_scan_state.active, pending_scan_state.after_created_at, pending_scan_state.after_rowid = (
1002
- pending_scan_checkpoint
1003
- )
1004
- elif not is_lock_error:
1349
+ restore_pending_scan()
1350
+ if not is_lock_error:
1005
1351
  LOGGER.error(
1006
- "hotlane vector write failed; pending scan cursor remains advanced past chunk_ids=%s error_type=%s",
1352
+ "hotlane vector write failed; retrying chunk_ids=%s error_type=%s",
1007
1353
  [candidate.chunk_id for candidate in pending_rows],
1008
1354
  type(exc).__name__,
1009
1355
  )
1010
1356
  if not is_lock_error:
1011
- metrics.finish("error")
1357
+ finish("error", exc)
1012
1358
  raise
1013
1359
  # S17: a busy writer slot never costs the embedded batch. A writer that does not
1014
1360
  # report progress gets all of its vectors carried; its writes are idempotent
@@ -1027,12 +1373,12 @@ def _run_split_cycle(
1027
1373
  carryover.dropped_total,
1028
1374
  exc,
1029
1375
  )
1030
- metrics.finish("deferred")
1376
+ finish("deferred")
1031
1377
  _warn_retired_enrichment(enrich_limit, enrich_since_hours, enrich_fn)
1032
1378
  return CycleResult(embedded=embedded, deferred=len(unwritten), backlog_encoded=len(backlog_vectors))
1033
1379
 
1034
1380
  _warn_retired_enrichment(enrich_limit, enrich_since_hours, enrich_fn)
1035
- metrics.finish()
1381
+ finish()
1036
1382
  return CycleResult(embedded=embedded, backlog_encoded=len(backlog_vectors))
1037
1383
 
1038
1384
 
@@ -1154,6 +1500,7 @@ def run(
1154
1500
  backlog_batch = min(max(backlog_batch, 0), MAX_BACKLOG_BATCH)
1155
1501
  LOGGER.info("hotlane adapter started db=%s", db_path)
1156
1502
  idle_sleep = interval
1503
+ systemic_failures = 0
1157
1504
  while not STOP:
1158
1505
  if max_cycles is not None and cycles >= max_cycles:
1159
1506
  break
@@ -1236,18 +1583,28 @@ def run(
1236
1583
  cpu_sampler.observe(state, result.backlog_encoded, cycle_start=cycle_start)
1237
1584
  if result.embedded:
1238
1585
  LOGGER.info("embedded=%d", result.embedded)
1239
- except Exception:
1586
+ except Exception as exc:
1240
1587
  LOGGER.exception("hotlane adapter cycle failed")
1241
1588
  if cpu_sampler is not None:
1242
1589
  cpu_sampler.observe("error")
1243
1590
  cycles += 1
1591
+ error_sleep = min(interval * 2, 5.0)
1592
+ if isinstance(exc, HotlaneSystemicFailure):
1593
+ # The environment is failing for every chunk: back off geometrically so a
1594
+ # full disk is not re-encoded every few seconds. Never counted per chunk.
1595
+ systemic_failures += 1
1596
+ error_sleep = _systemic_backoff_seconds(error_sleep, systemic_failures)
1597
+ LOGGER.warning("hotlane systemic failure streak=%d; backing off %.1fs", systemic_failures, error_sleep)
1598
+ else:
1599
+ systemic_failures = 0
1244
1600
  # A raised cycle is a RETRY, not an idle cycle (PR #735 review, macroscope):
1245
1601
  # it already slept its own backoff here, and letting it fall through to the
1246
1602
  # geometric idle path would compound repeated transient failures into a much
1247
1603
  # longer retry gap. Reset the idle cadence so recovery stays prompt.
1248
1604
  idle_sleep = interval
1249
- sleep_fn(min(interval * 2, 5.0))
1605
+ sleep_fn(error_sleep)
1250
1606
  continue
1607
+ systemic_failures = 0
1251
1608
  cycles += 1
1252
1609
  # Work resets the cadence so latency stays at `interval`; an idle cycle backs off
1253
1610
  # geometrically up to MAX_IDLE_INTERVAL_SECONDS instead of probing every second.
@@ -3,7 +3,7 @@
3
3
  "name": "io.github.etanhey/brainlayer",
4
4
  "title": "BrainLayer",
5
5
  "description": "Persistent local memory for AI agents \u2014 semantic search, knowledge graph, and 16 BrainBar MCP tools with ToolAnnotations over SQLite.",
6
- "version": "1.5.91",
6
+ "version": "1.5.93",
7
7
  "websiteUrl": "https://brainlayer.etanheyman.com",
8
8
  "repository": {
9
9
  "url": "https://github.com/EtanHey/brainlayer",
@@ -14,7 +14,7 @@
14
14
  "registryType": "pypi",
15
15
  "registryBaseUrl": "https://pypi.org",
16
16
  "identifier": "brainlayer",
17
- "version": "1.5.91",
17
+ "version": "1.5.93",
18
18
  "runtimeHint": "pipx",
19
19
  "transport": {
20
20
  "type": "stdio"
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- __version__ = "1.5.91"
5
+ __version__ = "1.5.93"
6
6
  # Git sha the distributed package was built from; stamped by the release build, None in a source tree.
7
7
  # scripts/sprint_gate.py reads it in "keg" mode to prove the served package is the code under test.
8
8
  # No runtime `str | None` annotation: launchd/install.sh imports this under /usr/bin/python3 (3.9).
@@ -0,0 +1 @@
1
+ BUILD_SHA = "635d86244e9b02909d032fb727ac3841ae1b5887"
@@ -16,7 +16,7 @@ from typing import Literal, cast
16
16
 
17
17
  from .content_class import normalize_content_class
18
18
  from .ingest_denylist import is_denylisted, memory_reader_attribution
19
- from .t3_provenance import T3_APP_SESSION, is_t3_app_initiated_codex_session
19
+ from .t3_provenance import T3_APP_SESSION, CompactCodexHeader, is_t3_app_initiated_codex_session
20
20
 
21
21
  SearchPolicy = Literal["KEEP", "ISOLATE", "OUT"]
22
22
  EffectiveVisibility = Literal["default", "operational", "cold"]
@@ -179,6 +179,7 @@ def classify_provenance(
179
179
  t3_linked_session_ids: set[str] | None = None,
180
180
  t3_projection_version: int | None = None,
181
181
  t3_session_identity_cache: dict | None = None,
182
+ t3_session_header: tuple[dict, int] | CompactCodexHeader | None = None,
182
183
  ) -> ProvenanceDecision:
183
184
  """Classify a source path into an auditable provenance search policy."""
184
185
  del content_class
@@ -195,6 +196,7 @@ def classify_provenance(
195
196
  linked_session_ids=t3_linked_session_ids,
196
197
  projection_version=t3_projection_version,
197
198
  session_identity_cache=t3_session_identity_cache,
199
+ session_header=t3_session_header,
198
200
  )
199
201
  )
200
202
  if is_t3_app_session: