brainlayer 1.5.98__tar.gz → 1.5.99__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 (283) hide show
  1. {brainlayer-1.5.98 → brainlayer-1.5.99}/PKG-INFO +1 -1
  2. {brainlayer-1.5.98 → brainlayer-1.5.99}/pyproject.toml +1 -1
  3. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/hotlane_brainbar_daemon.py +122 -39
  4. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.observability.plist +2 -2
  5. {brainlayer-1.5.98 → brainlayer-1.5.99}/server.json +2 -2
  6. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/__init__.py +1 -1
  7. brainlayer-1.5.99/src/brainlayer/_build.py +1 -0
  8. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/backup_retention_invariant.py +36 -2
  9. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/health_facts.py +7 -0
  10. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/hotlane_budget.py +11 -1
  11. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/jsonl_backup.py +180 -17
  12. brainlayer-1.5.98/src/brainlayer/_build.py +0 -1
  13. {brainlayer-1.5.98 → brainlayer-1.5.99}/.gitignore +0 -0
  14. {brainlayer-1.5.98 → brainlayer-1.5.99}/LICENSE +0 -0
  15. {brainlayer-1.5.98 → brainlayer-1.5.99}/README.md +0 -0
  16. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/brainlayer-version-check.sh +0 -0
  17. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/backup-daily.sh +0 -0
  18. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/brainlayer-env-run.sh +0 -0
  19. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/brainlayer.env.example +0 -0
  20. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.backup-daily.plist +0 -0
  21. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.daemon.plist +0 -0
  22. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.decay.plist +0 -0
  23. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.drain.plist +0 -0
  24. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.health-check.plist +0 -0
  25. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.hotlane-brainbar.plist +0 -0
  26. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.index.plist +0 -0
  27. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.jsonl-backup.plist +0 -0
  28. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.log-cap.plist +0 -0
  29. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.maintenance-nightly.plist +0 -0
  30. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.maintenance-weekly.plist +0 -0
  31. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.maintenance.plist +0 -0
  32. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.p0-counter.plist +0 -0
  33. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.repair-fts.plist +0 -0
  34. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.t3-ingest.plist +0 -0
  35. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.throughput-watchdog.plist +0 -0
  36. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.tier0-watchdog.plist +0 -0
  37. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.wal-checkpoint.plist +0 -0
  38. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.brainlayer.watch.plist +0 -0
  39. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/com.etanhey.brainlayer-fleet-watchdog.plist +0 -0
  40. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/fleet-watchdog.sh +0 -0
  41. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/install.sh +0 -0
  42. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/jsonl-backup.sh +0 -0
  43. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/launchd/throughput-watchdog.py +0 -0
  44. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/release-verify-signatures.sh +0 -0
  45. {brainlayer-1.5.98 → brainlayer-1.5.99}/scripts/tier0-watchdog.sh +0 -0
  46. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/__main__.py +0 -0
  47. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/_helpers.py +0 -0
  48. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/agent_profiles.py +0 -0
  49. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/agent_provenance.py +0 -0
  50. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/alarm.py +0 -0
  51. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/archive_collapse.py +0 -0
  52. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/archive_lifecycle.py +0 -0
  53. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/backup_daily.py +0 -0
  54. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/badge_state.py +0 -0
  55. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/bitemporal.py +0 -0
  56. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/brainbar_activation.py +0 -0
  57. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/brainbar_auto_activation.py +0 -0
  58. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/brainbar_hybrid_helper.py +0 -0
  59. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/brainbar_identity.py +0 -0
  60. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/cachedelete_purge.swift +0 -0
  61. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/calibrate.py +0 -0
  62. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/chunk_origin.py +0 -0
  63. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/chunk_origin_backfill.py +0 -0
  64. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/chunk_origin_wipe.py +0 -0
  65. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/chunk_write.py +0 -0
  66. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/classify.py +0 -0
  67. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/claude_paths.py +0 -0
  68. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/cli/__init__.py +0 -0
  69. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/cli/wizard.py +0 -0
  70. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/cli_jobs.py +0 -0
  71. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/cli_new.py +0 -0
  72. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/cloud_backfill.py +0 -0
  73. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/clustering.py +0 -0
  74. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/codex_zst.py +0 -0
  75. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/component_jobs.py +0 -0
  76. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/config.py +0 -0
  77. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/consolidation_plan.py +0 -0
  78. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/content_class.py +0 -0
  79. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/content_hash_repair.py +0 -0
  80. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/correction_judge.py +0 -0
  81. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/data/agents_registry.yaml +0 -0
  82. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/data/sandbox_seeds/skill-eval-baseline.json +0 -0
  83. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/db_shrink.py +0 -0
  84. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/decay.py +0 -0
  85. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/decay_backfill.py +0 -0
  86. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/decay_job.py +0 -0
  87. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/dedupe.py +0 -0
  88. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/dedupe_merge.py +0 -0
  89. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/deploy_drift.py +0 -0
  90. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/disk_space.py +0 -0
  91. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/doctor.py +0 -0
  92. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/drain.py +0 -0
  93. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/drain_liveness.py +0 -0
  94. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/drive_credentials.py +0 -0
  95. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/embeddings.py +0 -0
  96. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/engine.py +0 -0
  97. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/enrichment_replay.py +0 -0
  98. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/__init__.py +0 -0
  99. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/abcde_enrich_runner.py +0 -0
  100. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/abcde_variants.py +0 -0
  101. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/abcde_variants.yaml +0 -0
  102. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/benchmark.py +0 -0
  103. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/enrichment_gold.py +0 -0
  104. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/enrichment_graders.py +0 -0
  105. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/enrichment_judge.py +0 -0
  106. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/enrichment_llm_judge.py +0 -0
  107. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/enrichment_quality_benchmark.py +0 -0
  108. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/experiment_store.py +0 -0
  109. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/fixtures/README.md +0 -0
  110. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/labeling/enrichment-labeler.html +0 -0
  111. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/phoenix_gate/__init__.py +0 -0
  112. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/phoenix_gate/__main__.py +0 -0
  113. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/phoenix_gate/baseline_store.py +0 -0
  114. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/phoenix_gate/cli.py +0 -0
  115. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/phoenix_gate/models.py +0 -0
  116. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/phoenix_gate/phoenix_client.py +0 -0
  117. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/phoenix_gate/regression_gate.py +0 -0
  118. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/phoenix_gate/triggers.py +0 -0
  119. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/eval/pilot_artifact_report.py +0 -0
  120. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/fallback_replay.py +0 -0
  121. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/git_learning.py +0 -0
  122. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/health_check.py +0 -0
  123. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/health_verdict.py +0 -0
  124. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/hook_python.py +0 -0
  125. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/hooks/__init__.py +0 -0
  126. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/hooks/indexer.py +0 -0
  127. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/import_sweep.py +0 -0
  128. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/index_admission.py +0 -0
  129. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/index_budget.py +0 -0
  130. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/index_completeness.py +0 -0
  131. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/index_new.py +0 -0
  132. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/index_watchdog.py +0 -0
  133. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/ingest/__init__.py +0 -0
  134. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/ingest/codex.py +0 -0
  135. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/ingest/codex_manifest.py +0 -0
  136. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/ingest/t3.py +0 -0
  137. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/ingest_denylist.py +0 -0
  138. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/ingest_guard.py +0 -0
  139. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/isolation_proof.py +0 -0
  140. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/job_alerts.py +0 -0
  141. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/job_lifecycle_health.py +0 -0
  142. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/jobs.py +0 -0
  143. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/kg/__init__.py +0 -0
  144. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/kg_cleanup.py +0 -0
  145. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/kg_judge.py +0 -0
  146. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/kg_promotion.py +0 -0
  147. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/kg_repo.py +0 -0
  148. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/kg_review_session.py +0 -0
  149. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/kg_session_finish.py +0 -0
  150. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/kg_session_harvest.py +0 -0
  151. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/launchd_consolidation.py +0 -0
  152. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/launchd_install.py +0 -0
  153. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/launchd_primitive.py +0 -0
  154. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/launchd_revert.py +0 -0
  155. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/launcher_policy_reconcile.py +0 -0
  156. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/lexical_defense.py +0 -0
  157. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/lexical_defense_dictionary.json +0 -0
  158. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/linkedin_import.py +0 -0
  159. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/log_cap.py +0 -0
  160. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/maintenance.py +0 -0
  161. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/maintenance_calendar.py +0 -0
  162. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/maintenance_control.py +0 -0
  163. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/maintenance_upload_recovery.py +0 -0
  164. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp/__init__.py +0 -0
  165. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp/_format.py +0 -0
  166. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp/_shared.py +0 -0
  167. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp/enrich_handler.py +0 -0
  168. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp/entity_handler.py +0 -0
  169. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp/palette.py +0 -0
  170. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp/search_handler.py +0 -0
  171. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp/store_handler.py +0 -0
  172. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp/tags_handler.py +0 -0
  173. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp_socket_config.py +0 -0
  174. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/mcp_stdio_bridge.py +0 -0
  175. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/memory_types.py +0 -0
  176. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/migrate.py +0 -0
  177. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/migration_custody.py +0 -0
  178. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/migration_journal.py +0 -0
  179. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/migration_runtime.py +0 -0
  180. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/notification_policy.py +0 -0
  181. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/observability_backup.py +0 -0
  182. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/observability_indexes.py +0 -0
  183. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/observability_surface.py +0 -0
  184. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/observability_transport.py +0 -0
  185. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/p0_longitudinal_count.py +0 -0
  186. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/parent_death.py +0 -0
  187. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/paths.py +0 -0
  188. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pause.py +0 -0
  189. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/phonetic.py +0 -0
  190. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/__init__.py +0 -0
  191. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/agent_enrichment.py +0 -0
  192. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/analyze_communication.py +0 -0
  193. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/batch_extraction.py +0 -0
  194. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/brain_graph.py +0 -0
  195. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/chat_tags.py +0 -0
  196. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/chunk.py +0 -0
  197. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/classify.py +0 -0
  198. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/cloud_scrub.py +0 -0
  199. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/cluster_sampling.py +0 -0
  200. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/code_intelligence.py +0 -0
  201. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/correction_detection.py +0 -0
  202. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/correction_mining.py +0 -0
  203. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/digest.py +0 -0
  204. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/enrichment_prompts.py +0 -0
  205. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/enrichment_results.py +0 -0
  206. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/enrichment_tiers.py +0 -0
  207. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/entity_extraction.py +0 -0
  208. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/entity_resolution.py +0 -0
  209. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/extract.py +0 -0
  210. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/extract_claude_desktop.py +0 -0
  211. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/extract_corrections.py +0 -0
  212. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/extract_markdown.py +0 -0
  213. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/extract_whatsapp.py +0 -0
  214. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/frustration_mining.py +0 -0
  215. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/git_overlay.py +0 -0
  216. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/kg_extraction.py +0 -0
  217. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/kg_extraction_groq.py +0 -0
  218. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/longitudinal_analyzer.py +0 -0
  219. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/obsidian_export.py +0 -0
  220. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/operation_grouping.py +0 -0
  221. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/plan_linking.py +0 -0
  222. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/rate_limiter.py +0 -0
  223. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/relation_backfill.py +0 -0
  224. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/relation_verification.py +0 -0
  225. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/sanitize.py +0 -0
  226. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/secret_scrub.py +0 -0
  227. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/semantic_style.py +0 -0
  228. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/sentiment.py +0 -0
  229. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/session_history.py +0 -0
  230. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/style_embed.py +0 -0
  231. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/style_index.py +0 -0
  232. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/tag_entity_promotion.py +0 -0
  233. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/temporal_chains.py +0 -0
  234. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/time_batcher.py +0 -0
  235. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/unified_timeline.py +0 -0
  236. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/pipeline/write_queue.py +0 -0
  237. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/policy_reconcile.py +0 -0
  238. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/provenance.py +0 -0
  239. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/provenance_autosupersede.py +0 -0
  240. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/provenance_integration.py +0 -0
  241. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/queue_io.py +0 -0
  242. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/queue_merge.py +0 -0
  243. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/readonly_snapshot.py +0 -0
  244. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/reembed_backfill.py +0 -0
  245. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/retired_services.py +0 -0
  246. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/runtime_store.py +0 -0
  247. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/sandbox_db.py +0 -0
  248. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/schema_ddl_ledger.py +0 -0
  249. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/scoping.py +0 -0
  250. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/scrub_at_rest.py +0 -0
  251. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/search_fanout.py +0 -0
  252. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/search_profile.py +0 -0
  253. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/search_repo.py +0 -0
  254. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/search_response.py +0 -0
  255. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/service_supervisor.py +0 -0
  256. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/session_repo.py +0 -0
  257. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/setup.py +0 -0
  258. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/socket_hygiene.py +0 -0
  259. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/source_class_migration.py +0 -0
  260. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/spotlight.py +0 -0
  261. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/storage.py +0 -0
  262. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/store.py +0 -0
  263. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/supervisor_adapters.py +0 -0
  264. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/supervisor_child.py +0 -0
  265. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/supervisor_diagnostics.py +0 -0
  266. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/supervisor_guard.py +0 -0
  267. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/supervisor_jobs.py +0 -0
  268. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/system_prompt_guard.py +0 -0
  269. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/t3_linkage_alarm.py +0 -0
  270. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/t3_provenance.py +0 -0
  271. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/t3_sources.py +0 -0
  272. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/tag_normalization.py +0 -0
  273. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/taxonomy.json +0 -0
  274. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/telemetry.py +0 -0
  275. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/timestamp_iso.py +0 -0
  276. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/types.py +0 -0
  277. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/vector_store.py +0 -0
  278. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/wal_checkpoint.py +0 -0
  279. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/watcher.py +0 -0
  280. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/watcher_bridge.py +0 -0
  281. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/writer_policy.py +0 -0
  282. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/writer_telemetry.py +0 -0
  283. {brainlayer-1.5.98 → brainlayer-1.5.99}/src/brainlayer/zstd_stream.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: brainlayer
3
- Version: 1.5.98
3
+ Version: 1.5.99
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.98"
3
+ version = "1.5.99"
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"
@@ -441,7 +441,7 @@ def _performance_cores() -> int:
441
441
 
442
442
 
443
443
  def _backlog_max_load() -> float:
444
- value = float(os.environ.get("BRAINLAYER_HOTLANE_BACKLOG_MAX_LOAD", "") or _performance_cores())
444
+ value = float(os.environ.get("BRAINLAYER_HOTLANE_BACKLOG_MAX_LOAD", "") or 2 * _performance_cores())
445
445
  if not math.isfinite(value) or value < 0:
446
446
  raise ValueError("BRAINLAYER_HOTLANE_BACKLOG_MAX_LOAD must be finite and nonnegative")
447
447
  return value
@@ -483,6 +483,32 @@ def _backlog_yield_reason(db_path: Path, max_load: float) -> str:
483
483
  return "high load" if load > max_load else ""
484
484
 
485
485
 
486
+ def _positive_seconds(name: str, default: float) -> float:
487
+ value = float(os.environ.get(name, str(default)))
488
+ if not math.isfinite(value) or value <= 0:
489
+ raise ValueError(f"{name} must be finite and positive")
490
+ return value
491
+
492
+
493
+ def _backlog_pending_count(db_path: Path) -> int | None:
494
+ try:
495
+ store = VectorStore(db_path, readonly=True)
496
+ conn = store.conn
497
+ try:
498
+ return conn.execute("""
499
+ SELECT count(*) FROM chunks c
500
+ LEFT JOIN chunk_vectors_rowids r ON r.id=c.id
501
+ WHERE r.id IS NULL AND c.archived_at IS NULL
502
+ AND c.superseded_by IS NULL AND c.aggregated_into IS NULL
503
+ AND coalesce(c.archived,0)=0 AND coalesce(c.status,'active')='active'
504
+ """).fetchone()[0]
505
+ finally:
506
+ store.close()
507
+ except Exception:
508
+ LOGGER.exception("cannot measure backlog progress; retaining normal forced batches")
509
+ return None
510
+
511
+
486
512
  class PendingCandidateScanState:
487
513
  def __init__(self) -> None:
488
514
  self.active = False
@@ -1484,10 +1510,21 @@ def run(
1484
1510
  queue_dir_was_explicit = queue_dir is not None
1485
1511
  queue_dir = queue_dir or _default_queue_dir()
1486
1512
  last_backlog = time_fn() - backlog_interval
1513
+ backlog_yield_since = None
1514
+ floor_setting = (
1515
+ "BRAINLAYER_HOTLANE_BACKLOG_FLOOR_SECONDS"
1516
+ if "BRAINLAYER_HOTLANE_BACKLOG_FLOOR_SECONDS" in os.environ
1517
+ else "BRAINLAYER_HOTLANE_BACKLOG_MAX_WAIT_SECONDS"
1518
+ )
1519
+ backlog_floor_seconds = min(300.0, _positive_seconds(floor_setting, 300))
1520
+ backlog_stall_seconds = _positive_seconds("BRAINLAYER_HOTLANE_BACKLOG_STALL_SECONDS", 900)
1521
+ backlog_budget_seconds = _positive_seconds("BRAINLAYER_HOTLANE_BACKLOG_BUDGET_SECONDS", 120)
1487
1522
  last_backlog_duty = last_backlog + backlog_interval
1488
- max_backlog_wait = float(os.environ.get("BRAINLAYER_HOTLANE_BACKLOG_MAX_WAIT_SECONDS", "300"))
1489
- if not math.isfinite(max_backlog_wait) or max_backlog_wait <= 0:
1490
- raise ValueError("BRAINLAYER_HOTLANE_BACKLOG_MAX_WAIT_SECONDS must be finite and positive")
1523
+ count_interval = _positive_seconds("BRAINLAYER_HOTLANE_BACKLOG_COUNT_INTERVAL_SECONDS", 900)
1524
+ next_count_at = 0.0
1525
+ progress_count = None
1526
+ progress_since = None
1527
+ adaptive_drain = False
1491
1528
  _warn_retired_enrichment(enrich_limit, enrich_since_hours, None)
1492
1529
  if enrich_limit > 0:
1493
1530
  LOGGER.warning("Ignoring retired hotlane enrichment interval=%s", enrich_interval)
@@ -1508,14 +1545,29 @@ def run(
1508
1545
  try:
1509
1546
  now = time_fn()
1510
1547
  queue_has_backlog = queue_depth_fn(queue_dir) > 0
1511
- queue_has_high_priority_backlog = queue_has_backlog and high_priority_queue_depth_fn(queue_dir) > 0
1548
+ priority_queue_depth = high_priority_queue_depth_fn(queue_dir) if queue_has_backlog else 0
1549
+ queue_has_high_priority_backlog = priority_queue_depth > 0
1512
1550
  cycle_backlog_batch = backlog_batch if backlog_batch > 0 and now - last_backlog >= backlog_interval else 0
1513
1551
  cycle_recent_limit = recent_limit
1514
1552
  reason = _backlog_yield_reason(db_path, backlog_max_load) if backlog_batch else ""
1515
- if reason == "high load" and now - last_backlog_duty >= max_backlog_wait:
1516
- # Reserve the existing backlog lane; never lift store-queue backpressure.
1517
- reason = ""
1518
- cycle_backlog_batch = backlog_batch
1553
+ forced_turn = False
1554
+ if reason == "high load":
1555
+ if backlog_yield_since is None:
1556
+ backlog_yield_since = now
1557
+ if min(backlog_yield_since + backlog_floor_seconds, last_backlog_duty + 300) <= now:
1558
+ # Reserve the existing backlog lane; never lift store-queue backpressure.
1559
+ forced_turn = True
1560
+ reason = ""
1561
+ cycle_backlog_batch = backlog_batch
1562
+ backlog_yield_since = now
1563
+ else:
1564
+ backlog_yield_since = None
1565
+ if cpu_sampler is not None:
1566
+ cpu_sampler.set_backlog_floor(
1567
+ max(0, min(backlog_yield_since + backlog_floor_seconds, last_backlog_duty + 300) - now)
1568
+ if reason == "high load" and backlog_yield_since is not None
1569
+ else None
1570
+ )
1519
1571
  if reason != backlog_yield_reason:
1520
1572
  LOGGER.info("backlog embedding %s", f"yielding: {reason}" if reason else "resumed")
1521
1573
  backlog_yield_reason = reason
@@ -1527,7 +1579,7 @@ def run(
1527
1579
  queue_backpressure_active = True
1528
1580
  if cycle_backlog_batch <= 0:
1529
1581
  if cpu_sampler is not None:
1530
- cpu_sampler.observe("store queue")
1582
+ cpu_sampler.observe(reason or "store queue")
1531
1583
  cycles += 1
1532
1584
  # Backpressure is not idleness: hold the configured cadence so the
1533
1585
  # reserved backlog slice resumes on time.
@@ -1547,42 +1599,73 @@ def run(
1547
1599
  if cycle_backlog_batch > 0:
1548
1600
  last_backlog = now
1549
1601
  last_backlog_duty = now
1550
- cycle_start = cpu_sampler.begin_cycle() if cpu_sampler is not None else None
1551
- if cycle_fn is run_cycle:
1552
- result = _run_split_cycle(
1553
- db_path=db_path,
1554
- vector_store_cls=vector_store_cls,
1555
- embed_fn=embed_fn,
1556
- recent_limit=cycle_recent_limit,
1557
- backlog_batch=cycle_backlog_batch,
1558
- embed_batch_fn=embed_batch_fn,
1559
- enrich_limit=0,
1560
- enrich_since_hours=enrich_since_hours,
1561
- candidate_rows_fn=hot_candidate_scanner,
1562
- )
1563
- else:
1564
- store = vector_store_cls(db_path)
1565
- try:
1566
- result = cycle_fn(
1567
- store=store,
1602
+ if forced_turn and now >= next_count_at:
1603
+ next_count_at = now + count_interval
1604
+ count = _backlog_pending_count(db_path)
1605
+ if count is not None:
1606
+ if progress_count is None or count < progress_count:
1607
+ progress_since = now
1608
+ progress_count = count
1609
+ if count == 0:
1610
+ adaptive_drain = False
1611
+ elif progress_since is not None and now - progress_since >= backlog_stall_seconds:
1612
+ adaptive_drain = True
1613
+ burst_deadline = now + backlog_budget_seconds
1614
+ batch_duration = 0.0
1615
+ first_batch = True
1616
+ while first_batch or (forced_turn and adaptive_drain):
1617
+ if not first_batch:
1618
+ if STOP or (db_path.parent / "hotlane.pause").exists():
1619
+ break
1620
+ if time_fn() + batch_duration > burst_deadline or result.backlog_encoded == 0:
1621
+ break
1622
+ queue_has_backlog = queue_depth_fn(queue_dir) > 0
1623
+ current_priority_depth = high_priority_queue_depth_fn(queue_dir) if queue_has_backlog else 0
1624
+ if current_priority_depth > priority_queue_depth:
1625
+ LOGGER.info("durable store queue grew during burst; yielding extra backlog batches")
1626
+ break
1627
+ priority_queue_depth = current_priority_depth
1628
+ cycle_recent_limit = 0
1629
+ first_batch = False
1630
+ batch_started = time_fn() if forced_turn and adaptive_drain else now
1631
+ cycle_start = cpu_sampler.begin_cycle() if cpu_sampler is not None else None
1632
+ if cycle_fn is run_cycle:
1633
+ result = _run_split_cycle(
1634
+ db_path=db_path,
1635
+ vector_store_cls=vector_store_cls,
1568
1636
  embed_fn=embed_fn,
1569
1637
  recent_limit=cycle_recent_limit,
1570
1638
  backlog_batch=cycle_backlog_batch,
1571
1639
  embed_batch_fn=embed_batch_fn,
1572
1640
  enrich_limit=0,
1573
1641
  enrich_since_hours=enrich_since_hours,
1642
+ candidate_rows_fn=hot_candidate_scanner,
1574
1643
  )
1575
- finally:
1576
- store.close()
1577
- # A queued backlog means the system has work even when THIS cycle embedded
1578
- # nothing (the hot slice is deliberately suppressed to yield to the drain),
1579
- # so it must not be treated as idle -- backing off there would slow recovery.
1580
- did_work = bool(result.embedded) or queue_has_backlog
1581
- if cpu_sampler is not None:
1582
- state = reason or ("running" if result.backlog_encoded else "waiting")
1583
- cpu_sampler.observe(state, result.backlog_encoded, cycle_start=cycle_start)
1584
- if result.embedded:
1585
- LOGGER.info("embedded=%d", result.embedded)
1644
+ else:
1645
+ store = vector_store_cls(db_path)
1646
+ try:
1647
+ result = cycle_fn(
1648
+ store=store,
1649
+ embed_fn=embed_fn,
1650
+ recent_limit=cycle_recent_limit,
1651
+ backlog_batch=cycle_backlog_batch,
1652
+ embed_batch_fn=embed_batch_fn,
1653
+ enrich_limit=0,
1654
+ enrich_since_hours=enrich_since_hours,
1655
+ )
1656
+ finally:
1657
+ store.close()
1658
+ # A queued backlog means the system has work even when THIS cycle embedded
1659
+ # nothing (the hot slice is deliberately suppressed to yield to the drain),
1660
+ # so it must not be treated as idle -- backing off there would slow recovery.
1661
+ did_work = bool(result.embedded) or queue_has_backlog
1662
+ if cpu_sampler is not None:
1663
+ state = reason or ("running" if result.backlog_encoded else "waiting")
1664
+ cpu_sampler.observe(state, result.backlog_encoded, cycle_start=cycle_start)
1665
+ if result.embedded:
1666
+ LOGGER.info("embedded=%d", result.embedded)
1667
+ if forced_turn and adaptive_drain:
1668
+ batch_duration = max(0.001, time_fn() - batch_started)
1586
1669
  except Exception as exc:
1587
1670
  LOGGER.exception("hotlane adapter cycle failed")
1588
1671
  if cpu_sampler is not None:
@@ -41,11 +41,11 @@
41
41
  <key>Nice</key>
42
42
  <integer>10</integer>
43
43
  <key>ProcessType</key>
44
- <string>Background</string>
44
+ <string>Standard</string>
45
45
  <key>ExitTimeOut</key>
46
46
  <integer>45</integer>
47
47
  <key>LowPriorityIO</key>
48
- <true/>
48
+ <false/>
49
49
  <key>SoftResourceLimits</key>
50
50
  <dict>
51
51
  <key>NumberOfFiles</key>
@@ -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.98",
6
+ "version": "1.5.99",
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.98",
17
+ "version": "1.5.99",
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.98"
5
+ __version__ = "1.5.99"
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 = "0d1675e5fd0dd7bfa81d591b047cc4372a94c990"
@@ -474,8 +474,42 @@ def inspect_jsonl_retention_invariant(source: str, *, backup_daily_source: str)
474
474
  delete_calls = [*prune_calls, *archive_unlinks]
475
475
  if not prune_calls:
476
476
  errors.append("the Drive retention deletion call disappeared instead of retaining its safety contract")
477
- if not archive_unlinks:
478
- errors.append("the local staging deletion call disappeared instead of retaining its safety contract")
477
+ if not _calls(run_backup, "prune_local_archives"):
478
+ errors.append("local receipt-backed retention sweep is missing")
479
+ sweep = _function(tree, "prune_local_archives")
480
+ loops = [n for n in ast.walk(sweep) if isinstance(n, ast.For)] if sweep else []
481
+ loop = next((n for n in loops if ast.unparse(n.target) == "path"), None)
482
+ required_guards = {
483
+ "path == newest",
484
+ "age < days * 86400",
485
+ 'receipt.get("verified") is not True',
486
+ 'now - receipt["verified_at"] < days * 86400',
487
+ 'surviving_archives.get(receipt.get("archive_id")) != receipt["archive_md5"]',
488
+ '_md5_file(path) != receipt["archive_md5"]',
489
+ 'receipt.get("sha256") != _sha256_file(path)',
490
+ 'receipt.get("name") != path.name',
491
+ 'receipt.get("size") != path.stat().st_size',
492
+ }
493
+ guards = set()
494
+ if loop:
495
+ for statement in loop.body:
496
+ if isinstance(statement, ast.Expr) and _calls(statement, "unlink"):
497
+ break
498
+ if (
499
+ isinstance(statement, ast.If)
500
+ and len(statement.body) == 1
501
+ and isinstance(statement.body[0], ast.Continue)
502
+ ):
503
+ guards.update(ast.dump(n) for n in ast.walk(statement.test))
504
+ if (
505
+ not {ast.dump(ast.parse(expr, mode="eval").body) for expr in required_guards} <= guards
506
+ or not sweep
507
+ or not _calls(sweep, "_load_state")
508
+ or not _calls(sweep, "unlink")
509
+ ):
510
+ errors.append(
511
+ "local unlink must follow durable receipt, identity, both ages, md5, live Drive and newest rejection gates"
512
+ )
479
513
  if verified_gate is None or any(call not in safe_calls for call in delete_calls):
480
514
  errors.append("backup deletion calls must remain inside verified-upload control flow")
481
515
  deletion_statement_indexes = (
@@ -330,6 +330,13 @@ def embedding_activity(cpu: Any, budget: Any, db: Path, now: datetime) -> tuple[
330
330
  if paused
331
331
  else "Embedding progressing but incoming work is keeping the queue full"
332
332
  )
333
+ if paused:
334
+ due = _aware(cpu.get("backlog_next_forced_batch_at"))
335
+ label += (
336
+ f"; next forced batch {due.astimezone().strftime('%H:%M:%S')} (local time)"
337
+ if due is not None
338
+ else "; next forced batch time unavailable"
339
+ )
333
340
  return recent or (
334
341
  now - timedelta(seconds=600) if progressing else None
335
342
  ), f"{label}: {{count}} queued, last batch {clock}"
@@ -6,7 +6,7 @@ import sys
6
6
  import threading
7
7
  import time
8
8
  from collections import deque
9
- from datetime import datetime, timezone
9
+ from datetime import datetime, timedelta, timezone
10
10
 
11
11
 
12
12
  class HotlaneCpuSampler:
@@ -17,6 +17,7 @@ class HotlaneCpuSampler:
17
17
  self.samples = deque()
18
18
  self.backlog_cycles = deque()
19
19
  self.last_publish = float("-inf")
20
+ self.next_forced_batch_at = None
20
21
  self.state = None
21
22
  self.last_batch_at = None
22
23
  self.lock = threading.Lock()
@@ -37,6 +38,14 @@ class HotlaneCpuSampler:
37
38
  while not self.stop.wait(10):
38
39
  self.observe()
39
40
 
41
+ def set_backlog_floor(self, seconds):
42
+ with self.lock:
43
+ self.next_forced_batch_at = (
44
+ (datetime.now(timezone.utc) + timedelta(seconds=max(0, seconds))).isoformat()
45
+ if seconds is not None
46
+ else None
47
+ )
48
+
40
49
  def begin_cycle(self):
41
50
  return self.clock(), self.cpu_clock()
42
51
 
@@ -80,6 +89,7 @@ class HotlaneCpuSampler:
80
89
  backlog_wall_seconds=sum(cycle[1] for cycle in self.backlog_cycles),
81
90
  backlog_cpu_seconds=sum(cycle[2] for cycle in self.backlog_cycles),
82
91
  backlog_state=state,
92
+ backlog_next_forced_batch_at=self.next_forced_batch_at,
83
93
  backlog_last_batch_at=self.last_batch_at,
84
94
  )
85
95
  try:
@@ -77,9 +77,7 @@ ICLOUD_MIN_BYTES_PER_SECOND = 20 * 1024 * 1024
77
77
  ICLOUD_DIR_ENV = "BRAINLAYER_JSONL_BACKUP_ICLOUD_DIR"
78
78
  ICLOUD_TIMEOUT_ENV = "BRAINLAYER_JSONL_BACKUP_ICLOUD_TIMEOUT_SECONDS"
79
79
  BRAINLAYER_JSONL_BACKUP_RETENTION_ENV = "BRAINLAYER_JSONL_BACKUP_RETENTION"
80
- # Retention is a destructive operation even when the source-side coverage check passes. Keep
81
- # it off until archive-level history coverage is proven; the explicit environment override is
82
- # the only opt-in for a deliberately bounded run.
80
+ # Remote pruning remains opt-in; local receipt-backed retention has its own default.
83
81
  RETENTION_ENABLED = False
84
82
  JSONL_RETENTION = backup_daily.DriveRetentionPolicy(
85
83
  keep_latest=30,
@@ -214,8 +212,16 @@ def _atomic_write_json(path: Path, payload: dict[str, Any]) -> None:
214
212
  path.parent.mkdir(parents=True, exist_ok=True)
215
213
  temp_path = path.with_name(f".{path.name}.{os.getpid()}.tmp")
216
214
  try:
217
- temp_path.write_text(json.dumps(payload, indent=2, sort_keys=True) + "\n", encoding="utf-8")
215
+ with temp_path.open("w", encoding="utf-8") as handle:
216
+ handle.write(json.dumps(payload, indent=2, sort_keys=True) + "\n")
217
+ handle.flush()
218
+ os.fsync(handle.fileno())
218
219
  os.replace(temp_path, path)
220
+ directory_fd = os.open(path.parent, os.O_RDONLY)
221
+ try:
222
+ os.fsync(directory_fd)
223
+ finally:
224
+ os.close(directory_fd)
219
225
  finally:
220
226
  temp_path.unlink(missing_ok=True)
221
227
 
@@ -397,6 +403,112 @@ def _retention_enabled() -> bool:
397
403
  }
398
404
 
399
405
 
406
+ def _local_retention_enabled() -> bool:
407
+ return os.environ.get("BRAINLAYER_JSONL_BACKUP_LOCAL_RETENTION", "1").strip().lower() in {"1", "true"}
408
+
409
+
410
+ def _md5_file(path: Path) -> str:
411
+ with path.open("rb") as handle:
412
+ return hashlib.file_digest(handle, "md5").hexdigest()
413
+
414
+
415
+ def _drive_archive_receipt(path: Path, uploaded: dict[str, Any], *, now: float) -> dict[str, Any]:
416
+ md5 = _md5_file(path)
417
+ return {
418
+ "name": path.name,
419
+ "size": path.stat().st_size,
420
+ "sha256": _sha256_file(path),
421
+ "archive_md5": md5,
422
+ "verified": uploaded.get("md5Checksum") == md5,
423
+ "verified_at": now,
424
+ "archive_id": uploaded.get("id"),
425
+ }
426
+
427
+
428
+ def _local_archive_paths(staging_dir: Path) -> list[Path]:
429
+ roots = {staging_dir}
430
+ parent = staging_dir if staging_dir.name == "jsonl-backups" else staging_dir.parent
431
+ if parent.name == "jsonl-backups":
432
+ roots.add(parent)
433
+ roots.update(p for p in parent.iterdir() if p.name.startswith("release-") and p.is_dir() and not p.is_symlink())
434
+ return [p for root in roots for p in root.glob("claude-jsonl-*.tar.gz") if p.is_file() and not p.is_symlink()]
435
+
436
+
437
+ def _retention_warning(log_path: Path, error: str) -> None:
438
+ print(f"JSONL local retention disabled for this run: {error}", file=sys.stderr, flush=True)
439
+ try:
440
+ _append_json_log(log_path, {"event": "local_retention_error", "error": error})
441
+ except Exception:
442
+ pass # Logging failure must not stop the backup either.
443
+
444
+
445
+ def prune_local_archives(
446
+ staging_dir: Path, *, state_path: Path, log_path: Path, now: float, surviving_archives: dict[str, str | None]
447
+ ) -> list[str]:
448
+ """Caller holds the staging lock; only durable exact-archive receipts authorize unlink."""
449
+ if not _local_retention_enabled():
450
+ return []
451
+ days = int(os.environ.get("BRAINLAYER_JSONL_BACKUP_LOCAL_RETENTION_DAYS", "14"))
452
+ if days < 14:
453
+ raise ValueError("local JSONL retention must be at least 14 days")
454
+ receipts = _load_state(state_path).get("drive_archives", {})
455
+ archives = _local_archive_paths(staging_dir)
456
+ if not archives:
457
+ return []
458
+ newest = max(archives, key=lambda p: (p.stat().st_mtime, p.as_posix()))
459
+ deleted = []
460
+ for path in archives:
461
+ age = now - path.stat().st_mtime
462
+ receipt = receipts.get(path.name, {}) if isinstance(receipts, dict) else {}
463
+ if path == newest or age < days * 86400:
464
+ continue
465
+ if not isinstance(receipt, dict) or receipt.get("verified") is not True:
466
+ continue
467
+ if (
468
+ not isinstance(receipt.get("verified_at"), (int, float))
469
+ or not math.isfinite(receipt["verified_at"])
470
+ or now - receipt["verified_at"] < days * 86400
471
+ ):
472
+ continue
473
+ if (
474
+ not receipt.get("archive_md5")
475
+ or surviving_archives.get(receipt.get("archive_id")) != receipt["archive_md5"]
476
+ or _md5_file(path) != receipt["archive_md5"]
477
+ ):
478
+ continue
479
+ if (
480
+ receipt.get("name") != path.name
481
+ or receipt.get("size") != path.stat().st_size
482
+ or not receipt.get("archive_id")
483
+ or receipt.get("sha256") != _sha256_file(path)
484
+ ):
485
+ continue
486
+ # A durable intent makes every unlink auditable even if the process dies immediately after it.
487
+ _append_json_log(
488
+ log_path,
489
+ {
490
+ "event": "local_retention_delete",
491
+ "name": path.name,
492
+ "age_days": age / 86400,
493
+ "verified_receipt_id": receipt["archive_id"],
494
+ },
495
+ )
496
+ with log_path.open("a") as handle:
497
+ os.fsync(handle.fileno())
498
+ path.unlink()
499
+ deleted.append(path.name)
500
+ _append_json_log(
501
+ log_path,
502
+ {
503
+ "event": "local_retention_deleted",
504
+ "name": path.name,
505
+ "age_days": age / 86400,
506
+ "verified_receipt_id": receipt["archive_id"],
507
+ },
508
+ )
509
+ return deleted
510
+
511
+
400
512
  def _prune_drive_backups_to_trash(
401
513
  service: Any,
402
514
  *,
@@ -1474,7 +1586,12 @@ def _update_state_for_uploaded(
1474
1586
  elif isinstance(existing_icloud_directory, str) and existing_icloud_directory:
1475
1587
  entry["icloud_required"] = True
1476
1588
  files[candidate.path.as_posix()] = entry
1477
- updated = {"files": files, "updated_at": dt.datetime.now(dt.UTC).isoformat()}
1589
+ updated = {
1590
+ "files": files,
1591
+ "drive_archives": dict(state.get("drive_archives") or {}),
1592
+ "local_retention_revoke_pending": state.get("local_retention_revoke_pending", False),
1593
+ "updated_at": dt.datetime.now(dt.UTC).isoformat(),
1594
+ }
1478
1595
 
1479
1596
  archives = dict(state.get("icloud_archives") or {})
1480
1597
  if icloud_archive_name is not None and icloud_receipt is not None:
@@ -1614,12 +1731,37 @@ def run_backup(
1614
1731
  # archive-backed coverage there is nothing to verify, so a run that would be a
1615
1732
  # clean no-op does not touch Drive. Once entries DO claim coverage the listing is
1616
1733
  # unavoidable -- survival cannot be proven without asking.
1617
- if any(isinstance(e, dict) and e.get("archive_id") for e in (state.get("files") or {}).values()):
1618
- credentials = backup_daily.get_drive_credentials()
1619
- service = backup_daily.build_drive_service()
1620
- surviving_archives = _list_surviving_archives(service, folder_parts)
1734
+ if state.get("drive_archives") or any(
1735
+ isinstance(e, dict) and e.get("archive_id") for e in (state.get("files") or {}).values()
1736
+ ):
1737
+ try:
1738
+ credentials = backup_daily.get_drive_credentials()
1739
+ service = backup_daily.build_drive_service()
1740
+ surviving_archives = _list_surviving_archives(service, folder_parts)
1741
+ except Exception as exc:
1742
+ surviving_archives = {}
1743
+ retention_receipt["local_retention_error"] = f"Drive inventory unavailable: {exc}"
1744
+ _retention_warning(log_path, retention_receipt["local_retention_error"])
1621
1745
  else:
1622
1746
  surviving_archives = {}
1747
+ retention_receipt["local_retention_deleted"] = []
1748
+ if state.get("local_retention_revoke_pending"):
1749
+ retention_receipt["local_retention_error"] = (
1750
+ "Receipt loss after interrupted Drive pruning; local retention receipts need reconciliation"
1751
+ )
1752
+ _retention_warning(log_path, retention_receipt["local_retention_error"])
1753
+ if upload and "local_retention_error" not in retention_receipt:
1754
+ try:
1755
+ retention_receipt["local_retention_deleted"] = prune_local_archives(
1756
+ Path(staging_dir).expanduser(),
1757
+ state_path=state_path,
1758
+ log_path=log_path,
1759
+ now=now,
1760
+ surviving_archives=(surviving_archives or {}),
1761
+ )
1762
+ except Exception as exc:
1763
+ retention_receipt["local_retention_error"] = str(exc)
1764
+ _retention_warning(log_path, str(exc))
1623
1765
  changed, active, covered, vanished = _select_backup_candidates(
1624
1766
  candidates,
1625
1767
  state=selection_state,
@@ -1788,6 +1930,9 @@ def run_backup(
1788
1930
  "md5Checksum": uploaded.get("md5Checksum"),
1789
1931
  }
1790
1932
  )
1933
+ state.setdefault("drive_archives", {})[archive_path.name] = _drive_archive_receipt(
1934
+ archive_path, uploaded, now=time.time()
1935
+ )
1791
1936
  # The same incident was two individually reasonable deletions composed together:
1792
1937
  # successful upload removed local staging, then Drive retention removed the remote
1793
1938
  # bundle. Persist the exact Drive object and archived-source digests before either
@@ -1811,6 +1956,12 @@ def run_backup(
1811
1956
  try:
1812
1957
  # Do not move this ahead of the provenance write or loosen `_state_matches` to
1813
1958
  # mtime/size. That exact shape left 22 successful nights with no surviving bundle.
1959
+ retained_state = _load_state(state_path)
1960
+ authorized = retained_state.get("drive_archives", {})
1961
+ if retention_enabled:
1962
+ retained_state["drive_archives"] = {}
1963
+ retained_state["local_retention_revoke_pending"] = True
1964
+ _atomic_write_json(state_path, retained_state)
1814
1965
  deleted = (
1815
1966
  _prune_drive_backups_to_trash(
1816
1967
  service,
@@ -1820,6 +1971,12 @@ def run_backup(
1820
1971
  if retention_enabled
1821
1972
  else []
1822
1973
  )
1974
+ if retention_enabled:
1975
+ retained_state["drive_archives"] = {
1976
+ name: receipt for name, receipt in authorized.items() if name not in deleted
1977
+ }
1978
+ retained_state["local_retention_revoke_pending"] = False
1979
+ _atomic_write_json(state_path, retained_state)
1823
1980
  result["retention_deleted"] = deleted
1824
1981
  if _forever_enabled():
1825
1982
  forever_files = _upload_forever_files(
@@ -1832,15 +1989,20 @@ def run_backup(
1832
1989
  )
1833
1990
  result["forever_files"] = forever_files
1834
1991
  result["forever_uploaded_file_count"] = len(forever_files)
1835
- finally:
1836
- # Local staging may disappear only inside verified-upload control flow. Together
1837
- # with the retention call above, this unlink is why survivor identity is a deletion
1838
- # invariant rather than an optional integrity check (2026-09-09 / PR #815).
1992
+ except Exception:
1839
1993
  if retention_enabled:
1840
- archive_path.unlink(missing_ok=True)
1841
- result["local_archive_removed"] = True
1842
- else:
1843
- result["local_archive_removed"] = False
1994
+ _retention_warning(log_path, "Drive prune interrupted; receipt reconciliation required")
1995
+ from .job_alerts import report
1996
+
1997
+ report(
1998
+ "jsonl-retention",
1999
+ "Drive prune interrupted; receipt reconciliation required",
2000
+ path=state_path.parent / "job-alerts.json",
2001
+ notify=lambda _: None,
2002
+ )
2003
+ raise
2004
+ finally:
2005
+ result["local_archive_removed"] = False
1844
2006
  elif not result["verified"]:
1845
2007
  result["status"] = "failed"
1846
2008
  result["message"] = f"local bundle verification failed: {result.get('verification_error', 'unknown error')}"
@@ -1915,6 +2077,7 @@ def main() -> int:
1915
2077
  signal.setitimer(signal.ITIMER_REAL, 0)
1916
2078
  signal.signal(signal.SIGALRM, previous_alarm_handler)
1917
2079
  print(json.dumps(result, sort_keys=True), flush=True)
2080
+ report("jsonl-retention", result.get("local_retention_error"))
1918
2081
  code = 0 if result.get("verified", True) else 1
1919
2082
  report("jsonl-backup", None if code == 0 else "Transcript backup failed verification; check the backup log")
1920
2083
  return code
@@ -1 +0,0 @@
1
- BUILD_SHA = "60ae893b615a1cc792a8adc32de5d3f3441b935e"
File without changes
File without changes
File without changes