brainlayer 1.6.3__tar.gz → 1.6.5__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 (286) hide show
  1. {brainlayer-1.6.3 → brainlayer-1.6.5}/PKG-INFO +1 -1
  2. {brainlayer-1.6.3 → brainlayer-1.6.5}/pyproject.toml +1 -1
  3. {brainlayer-1.6.3 → brainlayer-1.6.5}/server.json +2 -2
  4. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/__init__.py +1 -1
  5. brainlayer-1.6.5/src/brainlayer/_build.py +1 -0
  6. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/brainbar_auto_activation.py +18 -4
  7. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/brainbar_identity.py +1 -1
  8. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/health_facts.py +1 -0
  9. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/ingest/t3.py +177 -18
  10. brainlayer-1.6.5/src/brainlayer/ingest/t3_bookmark.py +84 -0
  11. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/job_alerts.py +13 -6
  12. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/jsonl_backup.py +20 -11
  13. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/watcher.py +244 -11
  14. brainlayer-1.6.3/src/brainlayer/_build.py +0 -1
  15. {brainlayer-1.6.3 → brainlayer-1.6.5}/.gitignore +0 -0
  16. {brainlayer-1.6.3 → brainlayer-1.6.5}/LICENSE +0 -0
  17. {brainlayer-1.6.3 → brainlayer-1.6.5}/README.md +0 -0
  18. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/brainlayer-version-check.sh +0 -0
  19. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/hotlane_brainbar_daemon.py +0 -0
  20. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/backup-daily.sh +0 -0
  21. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/brainlayer-env-run.sh +0 -0
  22. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/brainlayer.env.example +0 -0
  23. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.backup-daily.plist +0 -0
  24. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.daemon.plist +0 -0
  25. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.decay.plist +0 -0
  26. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.drain.plist +0 -0
  27. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.health-check.plist +0 -0
  28. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.hotlane-brainbar.plist +0 -0
  29. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.index.plist +0 -0
  30. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.jsonl-backup.plist +0 -0
  31. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.log-cap.plist +0 -0
  32. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.maintenance-nightly.plist +0 -0
  33. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.maintenance-weekly.plist +0 -0
  34. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.maintenance.plist +0 -0
  35. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.observability.plist +0 -0
  36. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.p0-counter.plist +0 -0
  37. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.repair-fts.plist +0 -0
  38. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.t3-ingest.plist +0 -0
  39. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.throughput-watchdog.plist +0 -0
  40. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.tier0-watchdog.plist +0 -0
  41. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.wal-checkpoint.plist +0 -0
  42. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.brainlayer.watch.plist +0 -0
  43. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/com.etanhey.brainlayer-fleet-watchdog.plist +0 -0
  44. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/fleet-watchdog.sh +0 -0
  45. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/install.sh +0 -0
  46. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/jsonl-backup.sh +0 -0
  47. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/launchd/throughput-watchdog.py +0 -0
  48. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/release-verify-signatures.sh +0 -0
  49. {brainlayer-1.6.3 → brainlayer-1.6.5}/scripts/tier0-watchdog.sh +0 -0
  50. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/__main__.py +0 -0
  51. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/_helpers.py +0 -0
  52. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/agent_census.py +0 -0
  53. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/agent_profiles.py +0 -0
  54. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/agent_provenance.py +0 -0
  55. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/agy_attribution.py +0 -0
  56. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/alarm.py +0 -0
  57. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/archive_collapse.py +0 -0
  58. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/archive_lifecycle.py +0 -0
  59. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/backup_daily.py +0 -0
  60. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/backup_retention_invariant.py +0 -0
  61. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/badge_state.py +0 -0
  62. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/bitemporal.py +0 -0
  63. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/brainbar_activation.py +0 -0
  64. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/brainbar_hybrid_helper.py +0 -0
  65. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/cachedelete_purge.swift +0 -0
  66. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/calibrate.py +0 -0
  67. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/chunk_origin.py +0 -0
  68. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/chunk_origin_backfill.py +0 -0
  69. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/chunk_origin_wipe.py +0 -0
  70. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/chunk_write.py +0 -0
  71. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/classify.py +0 -0
  72. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/claude_paths.py +0 -0
  73. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/cli/__init__.py +0 -0
  74. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/cli/wizard.py +0 -0
  75. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/cli_jobs.py +0 -0
  76. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/cli_new.py +0 -0
  77. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/cloud_backfill.py +0 -0
  78. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/clustering.py +0 -0
  79. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/codex_zst.py +0 -0
  80. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/component_jobs.py +0 -0
  81. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/config.py +0 -0
  82. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/consolidation_plan.py +0 -0
  83. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/content_class.py +0 -0
  84. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/content_hash_repair.py +0 -0
  85. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/correction_judge.py +0 -0
  86. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/data/agents_registry.yaml +0 -0
  87. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/data/sandbox_seeds/skill-eval-baseline.json +0 -0
  88. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/db_shrink.py +0 -0
  89. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/decay.py +0 -0
  90. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/decay_backfill.py +0 -0
  91. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/decay_job.py +0 -0
  92. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/dedupe.py +0 -0
  93. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/dedupe_merge.py +0 -0
  94. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/deploy_drift.py +0 -0
  95. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/disk_space.py +0 -0
  96. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/doctor.py +0 -0
  97. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/drain.py +0 -0
  98. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/drain_liveness.py +0 -0
  99. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/drive_credentials.py +0 -0
  100. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/embeddings.py +0 -0
  101. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/engine.py +0 -0
  102. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/enrichment_replay.py +0 -0
  103. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/__init__.py +0 -0
  104. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/abcde_enrich_runner.py +0 -0
  105. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/abcde_variants.py +0 -0
  106. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/abcde_variants.yaml +0 -0
  107. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/benchmark.py +0 -0
  108. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/enrichment_gold.py +0 -0
  109. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/enrichment_graders.py +0 -0
  110. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/enrichment_judge.py +0 -0
  111. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/enrichment_llm_judge.py +0 -0
  112. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/enrichment_quality_benchmark.py +0 -0
  113. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/experiment_store.py +0 -0
  114. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/fixtures/README.md +0 -0
  115. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/labeling/enrichment-labeler.html +0 -0
  116. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/phoenix_gate/__init__.py +0 -0
  117. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/phoenix_gate/__main__.py +0 -0
  118. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/phoenix_gate/baseline_store.py +0 -0
  119. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/phoenix_gate/cli.py +0 -0
  120. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/phoenix_gate/models.py +0 -0
  121. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/phoenix_gate/phoenix_client.py +0 -0
  122. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/phoenix_gate/regression_gate.py +0 -0
  123. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/phoenix_gate/triggers.py +0 -0
  124. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/eval/pilot_artifact_report.py +0 -0
  125. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/fallback_replay.py +0 -0
  126. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/git_learning.py +0 -0
  127. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/health_check.py +0 -0
  128. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/health_verdict.py +0 -0
  129. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/hook_python.py +0 -0
  130. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/hooks/__init__.py +0 -0
  131. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/hooks/indexer.py +0 -0
  132. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/hotlane_budget.py +0 -0
  133. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/import_sweep.py +0 -0
  134. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/index_admission.py +0 -0
  135. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/index_budget.py +0 -0
  136. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/index_completeness.py +0 -0
  137. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/index_new.py +0 -0
  138. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/index_watchdog.py +0 -0
  139. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/ingest/__init__.py +0 -0
  140. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/ingest/codex.py +0 -0
  141. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/ingest/codex_manifest.py +0 -0
  142. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/ingest_denylist.py +0 -0
  143. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/ingest_guard.py +0 -0
  144. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/isolation_proof.py +0 -0
  145. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/job_lifecycle_health.py +0 -0
  146. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/jobs.py +0 -0
  147. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/kg/__init__.py +0 -0
  148. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/kg_cleanup.py +0 -0
  149. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/kg_judge.py +0 -0
  150. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/kg_promotion.py +0 -0
  151. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/kg_repo.py +0 -0
  152. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/kg_review_session.py +0 -0
  153. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/kg_session_finish.py +0 -0
  154. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/kg_session_harvest.py +0 -0
  155. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/launchd_consolidation.py +0 -0
  156. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/launchd_install.py +0 -0
  157. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/launchd_primitive.py +0 -0
  158. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/launchd_revert.py +0 -0
  159. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/launcher_policy_reconcile.py +0 -0
  160. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/lexical_defense.py +0 -0
  161. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/lexical_defense_dictionary.json +0 -0
  162. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/linkedin_import.py +0 -0
  163. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/log_cap.py +0 -0
  164. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/maintenance.py +0 -0
  165. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/maintenance_calendar.py +0 -0
  166. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/maintenance_control.py +0 -0
  167. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/maintenance_upload_recovery.py +0 -0
  168. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp/__init__.py +0 -0
  169. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp/_format.py +0 -0
  170. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp/_shared.py +0 -0
  171. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp/enrich_handler.py +0 -0
  172. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp/entity_handler.py +0 -0
  173. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp/palette.py +0 -0
  174. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp/search_handler.py +0 -0
  175. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp/store_handler.py +0 -0
  176. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp/tags_handler.py +0 -0
  177. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp_socket_config.py +0 -0
  178. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/mcp_stdio_bridge.py +0 -0
  179. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/memory_types.py +0 -0
  180. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/migrate.py +0 -0
  181. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/migration_custody.py +0 -0
  182. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/migration_journal.py +0 -0
  183. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/migration_runtime.py +0 -0
  184. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/notification_policy.py +0 -0
  185. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/observability_backup.py +0 -0
  186. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/observability_indexes.py +0 -0
  187. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/observability_surface.py +0 -0
  188. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/observability_transport.py +0 -0
  189. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/p0_longitudinal_count.py +0 -0
  190. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/parent_death.py +0 -0
  191. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/paths.py +0 -0
  192. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pause.py +0 -0
  193. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/phonetic.py +0 -0
  194. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/__init__.py +0 -0
  195. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/agent_enrichment.py +0 -0
  196. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/analyze_communication.py +0 -0
  197. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/batch_extraction.py +0 -0
  198. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/brain_graph.py +0 -0
  199. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/chat_tags.py +0 -0
  200. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/chunk.py +0 -0
  201. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/classify.py +0 -0
  202. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/cloud_scrub.py +0 -0
  203. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/cluster_sampling.py +0 -0
  204. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/code_intelligence.py +0 -0
  205. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/correction_detection.py +0 -0
  206. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/correction_mining.py +0 -0
  207. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/digest.py +0 -0
  208. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/enrichment_prompts.py +0 -0
  209. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/enrichment_results.py +0 -0
  210. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/enrichment_tiers.py +0 -0
  211. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/entity_extraction.py +0 -0
  212. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/entity_resolution.py +0 -0
  213. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/extract.py +0 -0
  214. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/extract_claude_desktop.py +0 -0
  215. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/extract_corrections.py +0 -0
  216. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/extract_markdown.py +0 -0
  217. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/extract_whatsapp.py +0 -0
  218. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/frustration_mining.py +0 -0
  219. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/git_overlay.py +0 -0
  220. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/kg_extraction.py +0 -0
  221. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/kg_extraction_groq.py +0 -0
  222. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/longitudinal_analyzer.py +0 -0
  223. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/obsidian_export.py +0 -0
  224. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/operation_grouping.py +0 -0
  225. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/plan_linking.py +0 -0
  226. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/rate_limiter.py +0 -0
  227. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/relation_backfill.py +0 -0
  228. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/relation_verification.py +0 -0
  229. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/sanitize.py +0 -0
  230. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/secret_scrub.py +0 -0
  231. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/semantic_style.py +0 -0
  232. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/sentiment.py +0 -0
  233. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/session_history.py +0 -0
  234. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/style_embed.py +0 -0
  235. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/style_index.py +0 -0
  236. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/tag_entity_promotion.py +0 -0
  237. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/temporal_chains.py +0 -0
  238. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/time_batcher.py +0 -0
  239. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/unified_timeline.py +0 -0
  240. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/pipeline/write_queue.py +0 -0
  241. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/policy_reconcile.py +0 -0
  242. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/provenance.py +0 -0
  243. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/provenance_autosupersede.py +0 -0
  244. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/provenance_integration.py +0 -0
  245. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/queue_io.py +0 -0
  246. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/queue_merge.py +0 -0
  247. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/readonly_snapshot.py +0 -0
  248. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/reembed_backfill.py +0 -0
  249. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/retired_services.py +0 -0
  250. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/runtime_store.py +0 -0
  251. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/sandbox_db.py +0 -0
  252. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/schema_ddl_ledger.py +0 -0
  253. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/scoping.py +0 -0
  254. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/scrub_at_rest.py +0 -0
  255. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/search_fanout.py +0 -0
  256. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/search_profile.py +0 -0
  257. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/search_repo.py +0 -0
  258. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/search_response.py +0 -0
  259. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/service_supervisor.py +0 -0
  260. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/session_repo.py +0 -0
  261. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/setup.py +0 -0
  262. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/socket_hygiene.py +0 -0
  263. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/source_class_migration.py +0 -0
  264. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/spotlight.py +0 -0
  265. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/storage.py +0 -0
  266. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/store.py +0 -0
  267. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/supervisor_adapters.py +0 -0
  268. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/supervisor_child.py +0 -0
  269. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/supervisor_diagnostics.py +0 -0
  270. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/supervisor_guard.py +0 -0
  271. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/supervisor_jobs.py +0 -0
  272. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/system_prompt_guard.py +0 -0
  273. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/t3_linkage_alarm.py +0 -0
  274. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/t3_provenance.py +0 -0
  275. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/t3_sources.py +0 -0
  276. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/tag_normalization.py +0 -0
  277. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/taxonomy.json +0 -0
  278. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/telemetry.py +0 -0
  279. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/timestamp_iso.py +0 -0
  280. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/types.py +0 -0
  281. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/vector_store.py +0 -0
  282. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/wal_checkpoint.py +0 -0
  283. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/watcher_bridge.py +0 -0
  284. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/writer_policy.py +0 -0
  285. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/writer_telemetry.py +0 -0
  286. {brainlayer-1.6.3 → brainlayer-1.6.5}/src/brainlayer/zstd_stream.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: brainlayer
3
- Version: 1.6.3
3
+ Version: 1.6.5
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.6.3"
3
+ version = "1.6.5"
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"
@@ -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.6.3",
6
+ "version": "1.6.5",
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.6.3",
17
+ "version": "1.6.5",
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.6.3"
5
+ __version__ = "1.6.5"
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 = "eafb720108c47d535f80ed14bc2db253a1eab72b"
@@ -20,6 +20,15 @@ class ProcessScanUnavailable(Exception):
20
20
  """Detection is unknown; only the safe exception class name may escape."""
21
21
 
22
22
 
23
+ def inspect_processes(function, *args):
24
+ try:
25
+ return function(*args)
26
+ except (subprocess.TimeoutExpired, TimeoutError) as exc:
27
+ error = ProcessScanUnavailable(type(exc).__name__)
28
+ error.inspection_timeout = True
29
+ raise error from None
30
+
31
+
23
32
  def process_table():
24
33
  result = subprocess.run(
25
34
  ["/bin/ps", "-axo", "pid=,ppid=,comm=,args="], capture_output=True, text=True, check=True, timeout=5
@@ -68,10 +77,12 @@ class AutoActivator:
68
77
  except BlockingIOError:
69
78
  return
70
79
  failures = self.state.with_suffix(".scan.json")
80
+ prior = json.loads(failures.read_text()) if failures.exists() else {}
71
81
  try:
72
82
  self._tick()
73
83
  except ProcessScanUnavailable as exc:
74
- prior = json.loads(failures.read_text()) if failures.exists() else {}
84
+ if not getattr(exc, "inspection_timeout", False):
85
+ prior = json.loads(failures.read_text()) if failures.exists() else {}
75
86
  count = min(prior.get("failures", 0) + 1, 12)
76
87
  _atomic_write_json(failures, {"failures": count})
77
88
  if count >= 12:
@@ -105,11 +116,14 @@ class AutoActivator:
105
116
  (
106
117
  "BrainBar activation process scan failed for >=12 ticks:",
107
118
  "BrainBar activation monitor refused: Command '['/bin/ps',",
119
+ "BrainBar activation monitor refused: Command '['/usr/sbin/lsof',",
120
+ "BrainBar activation monitor refused: Command '['/bin/launchctl',",
121
+ "BrainBar activation monitor refused: running-bundle inspection deadline exceeded",
108
122
  "BrainBar activation monitor refused: unreadable process table",
109
123
  )
110
124
  ):
111
125
  report("brainbar-activation", None)
112
- absent = bool(processes) and all(loaded(label).returncode == 113 for label, _ in JOBS)
126
+ absent = bool(processes) and all(inspect_processes(loaded, label).returncode == 113 for label, _ in JOBS)
113
127
  if not absent:
114
128
  if prior:
115
129
  path.unlink()
@@ -153,8 +167,8 @@ class AutoActivator:
153
167
  prior = json.loads(self.state.read_text()) if self.state.exists() else {}
154
168
  if prior.get("identity") == identity and prior.get("stage") == "ready":
155
169
  return
156
- states = [loaded(label).returncode for label, _ in JOBS]
157
- if all(code == 0 for code in states) and running_bundle_matches(app):
170
+ states = [inspect_processes(loaded, label).returncode for label, _ in JOBS]
171
+ if all(code == 0 for code in states) and inspect_processes(running_bundle_matches, app):
158
172
  _atomic_write_json(self.state, {"identity": identity, "stage": "ready"})
159
173
  report("brainbar-activation", None)
160
174
  return
@@ -59,7 +59,7 @@ def running_bundle_matches(app: Path, *, timeout=10) -> bool:
59
59
  program = re.search(r"(?m)^\s*program\s*=\s*(.*?)\s*$", state.stdout)
60
60
  if state.returncode or not pid or not program or program[1].strip('"') != str(executable):
61
61
  return False
62
- result = run(["/usr/sbin/lsof", "-a", "-p", pid[1], "-d", "txt", "-F", "Din"], remaining())
62
+ result = run(["/usr/sbin/lsof", "-b", "-w", "-a", "-p", pid[1], "-d", "txt", "-F", "Din"], remaining())
63
63
  if result.returncode:
64
64
  return False
65
65
  device = inode = None
@@ -204,6 +204,7 @@ def watcher_stall_codes(payload: Mapping[str, Any]) -> Any:
204
204
  ):
205
205
  return UNOBSERVED
206
206
  codes = [r for r in WATCHER_STALL_REASONS if r in reasons]
207
+ codes += sorted({r for r in reasons if r.startswith("growth_not_indexed:")})
207
208
  if probe and probe_for >= WATCHER_DB_PROBE_GRACE_S:
208
209
  codes.append("db_probe_failed")
209
210
  return tuple(codes + [f"root_missing:{r}" for r in roots])
@@ -21,6 +21,7 @@ from typing import Any
21
21
  from ..alarm import BrainLayerAlarm, raise_alarm
22
22
  from ..t3_sources import DEFAULT_T3_STATE_DB as DEFAULT_T3_STATE_DB
23
23
  from ..t3_sources import resolve_t3_sources
24
+ from . import t3_bookmark
24
25
 
25
26
  logger = logging.getLogger(__name__)
26
27
 
@@ -87,6 +88,11 @@ class T3Thread:
87
88
 
88
89
  @dataclass
89
90
  class T3IngestionResult:
91
+ mode: str = "full"
92
+ events_read: int = 0
93
+ bookmark_from: int | None = None
94
+ bookmark_to: int | None = None
95
+ bookmark_held: str | None = None
90
96
  threads_seen: int = 0
91
97
  threads_ingested: int = 0
92
98
  messages_seen: int = 0
@@ -125,21 +131,40 @@ class T3Reader:
125
131
  ):
126
132
  self.state_db_path, self.projection_version = resolve_t3_sources(state_db_path, projection_version)[0]
127
133
  self.health_path = Path(health_path).expanduser() if health_path is not None else None
128
- self._last_counts: dict[str, int] = {}
134
+ self._last_counts: dict[str, Any] = {}
129
135
  self._failures: list[dict[str, Any]] = []
130
136
 
131
137
  def read_threads(self, *, report_success: bool = True) -> list[T3Thread]:
132
138
  """Read a complete short snapshot of the T3 projections.
133
139
 
134
- Each query runs in SQLite autocommit mode and is fully materialized
135
- before the next query, so the adapter does not hold an application
136
- transaction open while indexing.
140
+ Bookmark reads use one short transaction so the event ceiling and
141
+ projections agree. All rows are materialized and the connection closes
142
+ before indexing; direct reads retain the legacy autocommit behavior.
137
143
  """
138
144
  conn: sqlite3.Connection | None = None
139
145
  try:
146
+ source_identity = t3_bookmark.identity(self.state_db_path)
140
147
  conn = self._connect()
141
148
  self._validate_schema(conn, self.projection_version)
142
- threads = self._read_v2_snapshot(conn) if self.projection_version == 2 else self._read_snapshot(conn)
149
+ selection = None
150
+ if self.projection_version == 2 and hasattr(self, "_previous_bookmark"):
151
+ tables = {r[0] for r in conn.execute("SELECT name FROM sqlite_master WHERE type='table'")}
152
+ if {"orchestration_events", "orchestration_v2_projection_metadata"} <= tables:
153
+ conn.execute("BEGIN")
154
+ self._bookmark_info, mids, tids, self._next_bookmark = t3_bookmark.window(
155
+ conn, self._previous_bookmark, source_identity
156
+ )
157
+ if self._bookmark_info["mode"] == "incremental":
158
+ selection = (mids, tids)
159
+ if getattr(self, "_include_message_identities", False):
160
+ # Legacy precedence needs all V2 owners, not just touched threads.
161
+ # Read IDs only, in the same snapshot as the event window.
162
+ self._message_identities = set(
163
+ conn.execute("SELECT thread_id, message_id FROM orchestration_v2_projection_messages")
164
+ )
165
+ threads = (
166
+ self._read_v2_snapshot(conn, selection) if self.projection_version == 2 else self._read_snapshot(conn)
167
+ )
143
168
  except BrainLayerAlarm:
144
169
  raise
145
170
  except T3PayloadError as error:
@@ -175,6 +200,9 @@ class T3Reader:
175
200
  {"state_db_path": str(self.state_db_path), "error_type": type(error).__name__},
176
201
  error,
177
202
  )
203
+ except RuntimeError as error:
204
+ self._last_counts["bookmark_held"] = "event_window_failure"
205
+ self._fail("t3_reader_failed", "T3 event window could not be read", {}, error)
178
206
  else:
179
207
  self._last_counts = {
180
208
  "threads_seen": len(threads),
@@ -275,27 +303,47 @@ class T3Reader:
275
303
  return threads
276
304
 
277
305
  @staticmethod
278
- def _read_v2_snapshot(conn: sqlite3.Connection) -> list[T3Thread]:
306
+ def _read_v2_snapshot(conn: sqlite3.Connection, selection=None) -> list[T3Thread]:
279
307
  """Read only the explicitly selected V2 projection; never fall back to legacy rows."""
308
+ # JSON parameters avoid SQLite's bound-variable limit for large replay windows.
309
+ params = () if selection is None else tuple(json.dumps(sorted(ids)) for ids in selection[:2])
310
+ selected = (
311
+ ""
312
+ if selection is None
313
+ else """
314
+ AND (message_id IN (SELECT value FROM json_each(?))
315
+ OR thread_id IN (SELECT value FROM json_each(?)))
316
+ """
317
+ )
318
+ message_rows = conn.execute(
319
+ "SELECT message_id, thread_id, role, created_at, payload_json "
320
+ "FROM orchestration_v2_projection_messages WHERE streaming = 0 "
321
+ + selected
322
+ + " ORDER BY thread_id, created_at, message_id",
323
+ params,
324
+ ).fetchall()
325
+ thread_filter = ""
326
+ thread_params = ()
327
+ if selection is not None:
328
+ touched = selection[1] | {row[1] for row in message_rows}
329
+ thread_filter = "WHERE t.thread_id IN (SELECT value FROM json_each(?))"
330
+ thread_params = (json.dumps(sorted(touched)),)
280
331
  thread_rows = conn.execute(
281
332
  """
282
333
  SELECT t.thread_id, t.project_id, p.title, t.title, t.created_at,
283
334
  t.default_provider, t.active_provider_thread_id
284
335
  FROM orchestration_v2_projection_threads AS t
285
336
  LEFT JOIN projection_projects AS p ON p.project_id = t.project_id
286
- ORDER BY t.created_at, t.thread_id
287
- """
288
- ).fetchall()
289
- message_rows = conn.execute(
290
- """
291
- SELECT message_id, thread_id, role, created_at, payload_json
292
- FROM orchestration_v2_projection_messages
293
- WHERE streaming = 0
294
- ORDER BY thread_id, created_at, message_id
295
337
  """
338
+ + thread_filter
339
+ + " ORDER BY t.created_at, t.thread_id",
340
+ thread_params,
296
341
  ).fetchall()
342
+ provider_ids = json.dumps([row[6] for row in thread_rows if row[6]])
297
343
  provider_rows = conn.execute(
298
344
  "SELECT provider_thread_id, provider, payload_json FROM orchestration_v2_projection_provider_threads"
345
+ " WHERE provider_thread_id IN (SELECT value FROM json_each(?))",
346
+ (provider_ids,),
299
347
  ).fetchall()
300
348
  providers = {}
301
349
  for provider_thread_id, provider, raw in provider_rows:
@@ -337,6 +385,9 @@ class T3Reader:
337
385
  return threads
338
386
 
339
387
  def _fail(self, code: str, message: str, context: dict[str, Any], error: BaseException) -> None:
388
+ self._last_counts.update(getattr(self, "_bookmark_info", {}))
389
+ if not self._last_counts.get("bookmark_held"):
390
+ self._last_counts["bookmark_held"] = "reader_failure"
340
391
  failure = {
341
392
  "code": code,
342
393
  "message": message,
@@ -394,6 +445,9 @@ def _provider_session_id(resume_cursor_json: str | None) -> str | None:
394
445
  class _IndexBudget:
395
446
  remaining: int = DEFAULT_T3_MAX_CHANGED_CHUNKS
396
447
  deferred: int = 0
448
+ oldest_first: bool = False
449
+ pending_ids: set[str] | None = None
450
+ deferred_ids: set[str] = field(default_factory=set)
397
451
 
398
452
 
399
453
  def _changed_chunks(chunks, store):
@@ -430,13 +484,16 @@ def _index_chunks(
430
484
  if skipped_empty:
431
485
  logger.info("T3 index admission skipped_empty_chunks=%s source_file=%s", skipped_empty, source_file)
432
486
  eligible = admitted
487
+ if budget.pending_ids is not None:
488
+ eligible = [chunk for chunk in eligible if chunk.metadata["chunk_id"] in budget.pending_ids]
433
489
  # Fail fast on an already-busy writer, then release it before model loading.
434
490
  with open_writer_store(db_path) as store:
435
491
  changed = _changed_chunks(eligible, store)
436
- changed.sort(key=_newest_chunk_key, reverse=True)
492
+ changed.sort(key=_newest_chunk_key, reverse=not budget.oldest_first)
437
493
  selected = changed[: budget.remaining]
438
494
  budget.remaining -= len(selected)
439
495
  budget.deferred += len(changed) - len(selected)
496
+ budget.deferred_ids.update(chunk.metadata["chunk_id"] for chunk in changed[len(selected) :])
440
497
  if not selected:
441
498
  return 0
442
499
  computed = embed_chunks(selected)
@@ -553,8 +610,14 @@ def ingest_t3(
553
610
  health_path: Path | str | None = DEFAULT_T3_HEALTH_PATH,
554
611
  dry_run: bool = False,
555
612
  projection_version: int | None = None,
613
+ bookmark_path: Path | str | None = None,
556
614
  ) -> T3IngestionResult:
557
- """Ingest all T3 threads, deliberately retaining mirrored content."""
615
+ """Replay changed T3 messages, deliberately retaining mirrored content.
616
+
617
+ State defaults beside health; ``health_path=None`` disables implicit state.
618
+ Dry runs persist state only with an explicit ``bookmark_path`` and never
619
+ open a BrainLayer destination. Dry-run state cannot skip a real backfill.
620
+ """
558
621
  destination = Path(db_path).expanduser() if db_path is not None else None
559
622
  try:
560
623
  sources = resolve_t3_sources(state_db_path, projection_version, tolerate_legacy_failure=True)
@@ -565,10 +628,24 @@ def ingest_t3(
565
628
  failed_reader._write_health(alerting=True, alert_reasons=["source_selection_failure"])
566
629
  raise
567
630
  reader = T3Reader(sources[0][0], health_path=health_path, projection_version=sources[0][1])
631
+ # Dry-run state is explicitly opt-in and never shares production replay state.
632
+ state_path = (
633
+ Path(bookmark_path).expanduser()
634
+ if bookmark_path is not None
635
+ else (Path(health_path).expanduser().with_name("t3-bookmark.json") if health_path is not None else None)
636
+ )
637
+ state = t3_bookmark.load(state_path) if state_path is not None and (not dry_run or bookmark_path) else {}
638
+ # A different destination needs a full backfill, including dry-run → real indexing.
639
+ target = "dry-run" if dry_run else str(destination.resolve()) if destination else "default"
640
+ if state.get("target") != target:
641
+ state = {}
642
+ next_state = {"target": target, "sources": {}}
568
643
  reader._source_paths = [str(path) for path, _ in sources]
644
+ reader._include_message_identities = any(version == 1 for _, version in sources)
569
645
  threads = []
570
646
  seen_messages = set()
571
647
  source_alerts = []
648
+ resume_pending = True
572
649
  # Read every selected source before indexing. Newer projections win shared IDs.
573
650
  for path, version in sources:
574
651
  source_reader = (
@@ -577,7 +654,35 @@ def ingest_t3(
577
654
  else T3Reader(path, health_path=health_path, projection_version=version)
578
655
  )
579
656
  try:
657
+ key = str(path.resolve())
658
+ previous = state.get("sources", {}).get(key, {})
659
+ if version == 2:
660
+ source_reader._previous_bookmark = previous
661
+ else:
662
+ try:
663
+ stat = path.stat()
664
+ fingerprint = {**t3_bookmark.identity(path), "size": stat.st_size, "mtime_ns": stat.st_mtime_ns}
665
+ # WAL changes must invalidate the legacy skip too.
666
+ wal = Path(str(path) + "-wal")
667
+ fingerprint["wal"] = [wal.stat().st_size, wal.stat().st_mtime_ns] if wal.exists() else None
668
+ except OSError as error:
669
+ source_reader._fail(
670
+ "t3_reader_failed",
671
+ "T3 legacy source fingerprint could not be read",
672
+ {"state_db_path": str(path), "error_type": type(error).__name__},
673
+ error,
674
+ )
675
+ next_state["sources"][key] = fingerprint
676
+ if previous == fingerprint:
677
+ continue
678
+ if "pending_chunks" in state:
679
+ next_state["sources"].pop(key, None)
680
+ if previous:
681
+ next_state["sources"][key] = previous
580
682
  source_threads = source_reader.read_threads(report_success=False)
683
+ if hasattr(source_reader, "_next_bookmark"):
684
+ next_state["sources"][key] = source_reader._next_bookmark
685
+ resume_pending &= source_reader._next_bookmark.pop("resume_pending")
581
686
  except BrainLayerAlarm:
582
687
  if state_db_path is not None or path == reader.state_db_path or reader.projection_version != 2:
583
688
  raise
@@ -592,7 +697,9 @@ def ingest_t3(
592
697
  seen_messages.add(identity)
593
698
  messages.append(message)
594
699
  threads.append((path, replace(thread, messages=tuple(messages))))
700
+ seen_messages.update(getattr(source_reader, "_message_identities", ()))
595
701
  result = T3IngestionResult(
702
+ **getattr(reader, "_bookmark_info", {}),
596
703
  threads_seen=len({thread.thread_id for _, thread in threads}),
597
704
  threads_ingested=len({thread.thread_id for _, thread in threads}),
598
705
  messages_seen=sum(len(thread.messages) for _, thread in threads),
@@ -618,7 +725,9 @@ def ingest_t3(
618
725
  from ..paths import DEFAULT_DB_PATH
619
726
 
620
727
  destination = DEFAULT_DB_PATH
621
- budget = _IndexBudget(remaining=DEFAULT_T3_MAX_CHANGED_CHUNKS)
728
+ budget = _IndexBudget(remaining=DEFAULT_T3_MAX_CHANGED_CHUNKS, oldest_first=hasattr(reader, "_next_bookmark"))
729
+ if "pending_chunks" in state and resume_pending:
730
+ budget.pending_ids = set(state["pending_chunks"])
622
731
  try:
623
732
  for path, batch in batches.items():
624
733
  result.chunks_indexed += _index_chunks(
@@ -629,6 +738,8 @@ def ingest_t3(
629
738
  # Preserve failure/cancellation semantics and any committed rows for stable-ID replay.
630
739
  # A successful projection read must not remain the final health result of a failed import.
631
740
  reader._last_counts["chunks_planned"] = result.chunks_planned
741
+ reader._last_counts.update(getattr(reader, "_bookmark_info", {}))
742
+ reader._last_counts["bookmark_held"] = "indexing_failure"
632
743
  reader._failures.append(
633
744
  {
634
745
  "code": "t3_indexing_failure",
@@ -643,10 +754,58 @@ def ingest_t3(
643
754
  reason = "writer_busy" if isinstance(exc, WriterInUseError) else "indexing_failure"
644
755
  reader._write_health(alerting=True, alert_reasons=source_alerts + [reason])
645
756
  raise
757
+ result.bookmark_held = (
758
+ "chunks_deferred"
759
+ if result.chunks_deferred
760
+ else (
761
+ "source_failure"
762
+ if source_alerts
763
+ else (
764
+ "event_log_unavailable"
765
+ if reader.projection_version == 2 and not hasattr(reader, "_next_bookmark")
766
+ else None
767
+ )
768
+ )
769
+ )
770
+ if result.chunks_deferred and state_path is not None and hasattr(reader, "_next_bookmark"):
771
+ held = {
772
+ "target": target,
773
+ "sources": dict(state.get("sources", {})),
774
+ "pending_chunks": sorted(budget.deferred_ids),
775
+ }
776
+ for path, version in sources:
777
+ key = str(path.resolve())
778
+ candidate = next_state["sources"].get(key)
779
+ if version == 2 and candidate:
780
+ held["sources"][key] = {
781
+ **candidate,
782
+ # Only an incremental window can replay from the old sequence.
783
+ # Full safety scans must keep reloading all pending threads.
784
+ "last_sequence": (
785
+ reader._bookmark_info["bookmark_from"]
786
+ if reader._bookmark_info["mode"] == "incremental"
787
+ else None
788
+ ),
789
+ "pending_to": candidate["last_sequence"],
790
+ }
791
+ t3_bookmark.save(state_path, held)
792
+ if state_path is not None and (not dry_run or bookmark_path) and result.bookmark_held is None:
793
+ try:
794
+ t3_bookmark.save(state_path, next_state)
795
+ except OSError as error:
796
+ reader._last_counts["bookmark_held"] = "state_write_failure"
797
+ reader._fail("t3_bookmark_failed", "T3 replay state could not be saved", {}, error)
798
+ elif state_path is None or (dry_run and bookmark_path is None):
799
+ result.bookmark_held = "state_disabled"
646
800
  if reader.health_path is not None:
647
801
  reader._last_counts.update(
648
802
  {
649
803
  "threads_seen": result.threads_seen,
804
+ "mode": result.mode,
805
+ "events_read": result.events_read,
806
+ "bookmark_from": result.bookmark_from,
807
+ "bookmark_to": result.bookmark_to,
808
+ "bookmark_held": result.bookmark_held,
650
809
  "messages_seen": result.messages_seen,
651
810
  "threads_ingested": result.threads_ingested,
652
811
  "messages_ingested": result.messages_ingested,
@@ -0,0 +1,84 @@
1
+ """Atomic replay state and bounded, read-only T3 event selection."""
2
+
3
+ import json
4
+ import os
5
+ import tempfile
6
+ from pathlib import Path
7
+
8
+
9
+ def load(path):
10
+ try:
11
+ value = json.loads(path.read_text())
12
+ return value if isinstance(value, dict) else {}
13
+ except (OSError, ValueError):
14
+ return {}
15
+
16
+
17
+ def save(path, state):
18
+ path.parent.mkdir(parents=True, exist_ok=True)
19
+ fd, temporary = tempfile.mkstemp(prefix=path.name, dir=path.parent)
20
+ try:
21
+ with os.fdopen(fd, "w") as output:
22
+ json.dump(state, output, sort_keys=True)
23
+ output.flush()
24
+ os.fsync(output.fileno())
25
+ os.replace(temporary, path)
26
+ finally:
27
+ Path(temporary).unlink(missing_ok=True)
28
+
29
+
30
+ def identity(path):
31
+ stat = path.stat()
32
+ return {"path": str(path.resolve()), "dev": stat.st_dev, "inode": stat.st_ino}
33
+
34
+
35
+ def window(conn, previous, source_identity):
36
+ # First data read in the transaction: later commits belong to the next run.
37
+ head = conn.execute("SELECT coalesce(max(sequence), 0) FROM orchestration_events").fetchone()[0]
38
+ metadata = dict(conn.execute("SELECT projection_name, last_sequence FROM orchestration_v2_projection_metadata"))
39
+ ceiling = min(head, metadata.get("thread-projections", head))
40
+ same_source = previous.get("identity") == source_identity
41
+ pending = previous.get("pending_to") if same_source else None
42
+ resume_pending = type(pending) is int and pending <= ceiling
43
+ if resume_pending:
44
+ ceiling = pending
45
+ stamp = conn.execute(
46
+ "SELECT occurred_at FROM orchestration_events WHERE sequence <= ? ORDER BY sequence DESC LIMIT 1",
47
+ (ceiling,),
48
+ ).fetchone()
49
+ occurred_at = stamp[0] if stamp else previous.get("occurred_at")
50
+ start = previous.get("last_sequence")
51
+ valid = (
52
+ same_source
53
+ and type(start) is int
54
+ and "event-log-pruned-through" in metadata
55
+ and metadata.get("event-log-pruned-through", 0) <= start <= ceiling <= head
56
+ )
57
+ info = {
58
+ "mode": "incremental" if valid else "full",
59
+ "events_read": 0,
60
+ "bookmark_from": start,
61
+ "bookmark_to": ceiling,
62
+ "bookmark_held": None,
63
+ }
64
+ messages, threads = set(), set()
65
+ if valid:
66
+ rows = conn.execute(
67
+ "SELECT stream_id FROM orchestration_events WHERE sequence > ? AND sequence <= ?",
68
+ (start, ceiling),
69
+ )
70
+ for (stream_id,) in rows:
71
+ info["events_read"] += 1
72
+ if isinstance(stream_id, str):
73
+ threads.add(stream_id)
74
+ return (
75
+ info,
76
+ messages,
77
+ threads,
78
+ {
79
+ "identity": source_identity,
80
+ "last_sequence": ceiling,
81
+ "occurred_at": occurred_at,
82
+ "resume_pending": resume_pending,
83
+ },
84
+ )
@@ -1,4 +1,4 @@
1
- """Durable, deduplicated backup/maintenance failure notices."""
1
+ """Durable, deduplicated backup/maintenance alert records for BrainBar."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -27,7 +27,10 @@ def _times_path(path: Path) -> Path:
27
27
  return path.with_name(f"{path.stem}.times.json")
28
28
 
29
29
 
30
- def _notify(message: str) -> None:
30
+ def _notify(message: str, *, key: str | None = None) -> None:
31
+ """Only activation failures may notify without a running BrainBar."""
32
+ if key != "brainbar-activation":
33
+ return
31
34
  if os.environ.get("BRAINLAYER_TEST_PATH_PROVENANCE") == "pytest":
32
35
  return
33
36
  subprocess.run(
@@ -108,9 +111,10 @@ def report(
108
111
  ) -> bool:
109
112
  """Set or clear one episode. Return true only when the visible state changes.
110
113
 
111
- Only a new failure posts a notification, and only when no other active key already
112
- carries the identical message (one incident fanned out across keys posts once).
113
- Recovery updates the alert file and the health log but never notifies.
114
+ Only a new failure invokes the optional notification hook, and only when no
115
+ other active key carries the identical message. Only brainbar-activation uses
116
+ the production OS hook; BrainBar delivers every other job notification from
117
+ the alert records. Recovery only updates the alert file and health log.
114
118
  """
115
119
  destination = path or alert_path()
116
120
  with _locked(destination):
@@ -137,7 +141,10 @@ def report(
137
141
  if not post:
138
142
  return True
139
143
  try:
140
- notify(message)
144
+ if notify is _notify:
145
+ _notify(message, key=key)
146
+ else:
147
+ notify(message)
141
148
  except (OSError, subprocess.SubprocessError) as exc:
142
149
  LOG.warning("macOS notification failed for %s: %s", key, type(exc).__name__)
143
150
  return True
@@ -453,20 +453,25 @@ def reconcile_drive_receipts(
453
453
  for path in sorted(_local_archive_paths(staging_dir)):
454
454
  if path.name in receipts:
455
455
  continue
456
- matches = drive_objects.get(path.name, [])
457
- if len(matches) != 1:
456
+ candidates = drive_objects.get(path.name, [])
457
+ if not candidates:
458
458
  continue
459
- remote = matches[0]
460
459
  size = path.stat().st_size
461
- try:
462
- remote_size = int(remote.get("size"))
463
- except (TypeError, ValueError):
464
- continue
465
- if remote.get("trashed") is not False or remote_size != size or not remote.get("id"):
466
- continue
460
+ sized = []
461
+ for remote in candidates:
462
+ try:
463
+ remote_size = int(remote.get("size"))
464
+ except (TypeError, ValueError):
465
+ continue
466
+ if remote.get("trashed") is False and remote_size == size and remote.get("id"):
467
+ sized.append(remote)
468
+ if not sized:
469
+ continue # Hash a multi-GB archive only when some live copy has its exact size.
467
470
  md5 = _md5_file(path)
468
- if not remote.get("md5Checksum") or remote["md5Checksum"] != md5:
471
+ matches = [remote for remote in sized if remote.get("md5Checksum") == md5]
472
+ if len(matches) != 1:
469
473
  continue
474
+ remote = matches[0]
470
475
  receipts[path.name] = {
471
476
  "name": path.name,
472
477
  "size": size,
@@ -486,7 +491,11 @@ def _local_archive_paths(staging_dir: Path) -> list[Path]:
486
491
  parent = staging_dir if staging_dir.name == "jsonl-backups" else staging_dir.parent
487
492
  if parent.name == "jsonl-backups":
488
493
  roots.add(parent)
489
- roots.update(p for p in parent.iterdir() if p.name.startswith("release-") and p.is_dir() and not p.is_symlink())
494
+ roots.update(
495
+ p
496
+ for p in parent.iterdir()
497
+ if p.name.startswith(("release-", "recovery-")) and p.is_dir() and not p.is_symlink()
498
+ )
490
499
  return [p for root in roots for p in root.glob("claude-jsonl-*.tar.gz") if p.is_file() and not p.is_symlink()]
491
500
 
492
501