brainlayer 1.6.5__tar.gz → 1.6.7__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.5 → brainlayer-1.6.7}/PKG-INFO +1 -1
  2. {brainlayer-1.6.5 → brainlayer-1.6.7}/pyproject.toml +1 -1
  3. {brainlayer-1.6.5 → brainlayer-1.6.7}/server.json +2 -2
  4. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/__init__.py +1 -1
  5. brainlayer-1.6.7/src/brainlayer/_build.py +1 -0
  6. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/agent_provenance.py +4 -1
  7. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/health_facts.py +26 -0
  8. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/health_verdict.py +35 -2
  9. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/ingest/t3.py +124 -63
  10. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/ingest/t3_bookmark.py +33 -2
  11. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/t3_provenance.py +57 -1
  12. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/watcher.py +640 -53
  13. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/watcher_bridge.py +42 -5
  14. brainlayer-1.6.5/src/brainlayer/_build.py +0 -1
  15. {brainlayer-1.6.5 → brainlayer-1.6.7}/.gitignore +0 -0
  16. {brainlayer-1.6.5 → brainlayer-1.6.7}/LICENSE +0 -0
  17. {brainlayer-1.6.5 → brainlayer-1.6.7}/README.md +0 -0
  18. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/brainlayer-version-check.sh +0 -0
  19. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/hotlane_brainbar_daemon.py +0 -0
  20. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/backup-daily.sh +0 -0
  21. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/brainlayer-env-run.sh +0 -0
  22. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/brainlayer.env.example +0 -0
  23. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.backup-daily.plist +0 -0
  24. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.daemon.plist +0 -0
  25. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.decay.plist +0 -0
  26. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.drain.plist +0 -0
  27. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.health-check.plist +0 -0
  28. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.hotlane-brainbar.plist +0 -0
  29. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.index.plist +0 -0
  30. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.jsonl-backup.plist +0 -0
  31. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.log-cap.plist +0 -0
  32. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.maintenance-nightly.plist +0 -0
  33. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.maintenance-weekly.plist +0 -0
  34. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.maintenance.plist +0 -0
  35. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.observability.plist +0 -0
  36. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.p0-counter.plist +0 -0
  37. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.repair-fts.plist +0 -0
  38. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.t3-ingest.plist +0 -0
  39. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.throughput-watchdog.plist +0 -0
  40. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.tier0-watchdog.plist +0 -0
  41. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.wal-checkpoint.plist +0 -0
  42. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.brainlayer.watch.plist +0 -0
  43. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/com.etanhey.brainlayer-fleet-watchdog.plist +0 -0
  44. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/fleet-watchdog.sh +0 -0
  45. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/install.sh +0 -0
  46. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/jsonl-backup.sh +0 -0
  47. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/launchd/throughput-watchdog.py +0 -0
  48. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/release-verify-signatures.sh +0 -0
  49. {brainlayer-1.6.5 → brainlayer-1.6.7}/scripts/tier0-watchdog.sh +0 -0
  50. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/__main__.py +0 -0
  51. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/_helpers.py +0 -0
  52. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/agent_census.py +0 -0
  53. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/agent_profiles.py +0 -0
  54. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/agy_attribution.py +0 -0
  55. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/alarm.py +0 -0
  56. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/archive_collapse.py +0 -0
  57. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/archive_lifecycle.py +0 -0
  58. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/backup_daily.py +0 -0
  59. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/backup_retention_invariant.py +0 -0
  60. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/badge_state.py +0 -0
  61. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/bitemporal.py +0 -0
  62. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/brainbar_activation.py +0 -0
  63. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/brainbar_auto_activation.py +0 -0
  64. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/brainbar_hybrid_helper.py +0 -0
  65. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/brainbar_identity.py +0 -0
  66. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/cachedelete_purge.swift +0 -0
  67. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/calibrate.py +0 -0
  68. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/chunk_origin.py +0 -0
  69. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/chunk_origin_backfill.py +0 -0
  70. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/chunk_origin_wipe.py +0 -0
  71. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/chunk_write.py +0 -0
  72. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/classify.py +0 -0
  73. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/claude_paths.py +0 -0
  74. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/cli/__init__.py +0 -0
  75. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/cli/wizard.py +0 -0
  76. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/cli_jobs.py +0 -0
  77. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/cli_new.py +0 -0
  78. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/cloud_backfill.py +0 -0
  79. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/clustering.py +0 -0
  80. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/codex_zst.py +0 -0
  81. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/component_jobs.py +0 -0
  82. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/config.py +0 -0
  83. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/consolidation_plan.py +0 -0
  84. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/content_class.py +0 -0
  85. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/content_hash_repair.py +0 -0
  86. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/correction_judge.py +0 -0
  87. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/data/agents_registry.yaml +0 -0
  88. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/data/sandbox_seeds/skill-eval-baseline.json +0 -0
  89. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/db_shrink.py +0 -0
  90. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/decay.py +0 -0
  91. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/decay_backfill.py +0 -0
  92. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/decay_job.py +0 -0
  93. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/dedupe.py +0 -0
  94. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/dedupe_merge.py +0 -0
  95. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/deploy_drift.py +0 -0
  96. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/disk_space.py +0 -0
  97. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/doctor.py +0 -0
  98. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/drain.py +0 -0
  99. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/drain_liveness.py +0 -0
  100. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/drive_credentials.py +0 -0
  101. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/embeddings.py +0 -0
  102. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/engine.py +0 -0
  103. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/enrichment_replay.py +0 -0
  104. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/__init__.py +0 -0
  105. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/abcde_enrich_runner.py +0 -0
  106. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/abcde_variants.py +0 -0
  107. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/abcde_variants.yaml +0 -0
  108. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/benchmark.py +0 -0
  109. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/enrichment_gold.py +0 -0
  110. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/enrichment_graders.py +0 -0
  111. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/enrichment_judge.py +0 -0
  112. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/enrichment_llm_judge.py +0 -0
  113. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/enrichment_quality_benchmark.py +0 -0
  114. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/experiment_store.py +0 -0
  115. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/fixtures/README.md +0 -0
  116. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/labeling/enrichment-labeler.html +0 -0
  117. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/phoenix_gate/__init__.py +0 -0
  118. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/phoenix_gate/__main__.py +0 -0
  119. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/phoenix_gate/baseline_store.py +0 -0
  120. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/phoenix_gate/cli.py +0 -0
  121. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/phoenix_gate/models.py +0 -0
  122. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/phoenix_gate/phoenix_client.py +0 -0
  123. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/phoenix_gate/regression_gate.py +0 -0
  124. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/phoenix_gate/triggers.py +0 -0
  125. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/eval/pilot_artifact_report.py +0 -0
  126. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/fallback_replay.py +0 -0
  127. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/git_learning.py +0 -0
  128. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/health_check.py +0 -0
  129. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/hook_python.py +0 -0
  130. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/hooks/__init__.py +0 -0
  131. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/hooks/indexer.py +0 -0
  132. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/hotlane_budget.py +0 -0
  133. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/import_sweep.py +0 -0
  134. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/index_admission.py +0 -0
  135. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/index_budget.py +0 -0
  136. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/index_completeness.py +0 -0
  137. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/index_new.py +0 -0
  138. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/index_watchdog.py +0 -0
  139. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/ingest/__init__.py +0 -0
  140. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/ingest/codex.py +0 -0
  141. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/ingest/codex_manifest.py +0 -0
  142. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/ingest_denylist.py +0 -0
  143. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/ingest_guard.py +0 -0
  144. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/isolation_proof.py +0 -0
  145. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/job_alerts.py +0 -0
  146. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/job_lifecycle_health.py +0 -0
  147. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/jobs.py +0 -0
  148. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/jsonl_backup.py +0 -0
  149. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/kg/__init__.py +0 -0
  150. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/kg_cleanup.py +0 -0
  151. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/kg_judge.py +0 -0
  152. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/kg_promotion.py +0 -0
  153. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/kg_repo.py +0 -0
  154. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/kg_review_session.py +0 -0
  155. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/kg_session_finish.py +0 -0
  156. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/kg_session_harvest.py +0 -0
  157. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/launchd_consolidation.py +0 -0
  158. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/launchd_install.py +0 -0
  159. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/launchd_primitive.py +0 -0
  160. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/launchd_revert.py +0 -0
  161. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/launcher_policy_reconcile.py +0 -0
  162. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/lexical_defense.py +0 -0
  163. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/lexical_defense_dictionary.json +0 -0
  164. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/linkedin_import.py +0 -0
  165. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/log_cap.py +0 -0
  166. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/maintenance.py +0 -0
  167. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/maintenance_calendar.py +0 -0
  168. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/maintenance_control.py +0 -0
  169. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/maintenance_upload_recovery.py +0 -0
  170. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp/__init__.py +0 -0
  171. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp/_format.py +0 -0
  172. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp/_shared.py +0 -0
  173. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp/enrich_handler.py +0 -0
  174. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp/entity_handler.py +0 -0
  175. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp/palette.py +0 -0
  176. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp/search_handler.py +0 -0
  177. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp/store_handler.py +0 -0
  178. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp/tags_handler.py +0 -0
  179. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp_socket_config.py +0 -0
  180. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/mcp_stdio_bridge.py +0 -0
  181. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/memory_types.py +0 -0
  182. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/migrate.py +0 -0
  183. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/migration_custody.py +0 -0
  184. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/migration_journal.py +0 -0
  185. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/migration_runtime.py +0 -0
  186. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/notification_policy.py +0 -0
  187. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/observability_backup.py +0 -0
  188. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/observability_indexes.py +0 -0
  189. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/observability_surface.py +0 -0
  190. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/observability_transport.py +0 -0
  191. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/p0_longitudinal_count.py +0 -0
  192. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/parent_death.py +0 -0
  193. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/paths.py +0 -0
  194. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pause.py +0 -0
  195. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/phonetic.py +0 -0
  196. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/__init__.py +0 -0
  197. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/agent_enrichment.py +0 -0
  198. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/analyze_communication.py +0 -0
  199. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/batch_extraction.py +0 -0
  200. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/brain_graph.py +0 -0
  201. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/chat_tags.py +0 -0
  202. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/chunk.py +0 -0
  203. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/classify.py +0 -0
  204. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/cloud_scrub.py +0 -0
  205. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/cluster_sampling.py +0 -0
  206. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/code_intelligence.py +0 -0
  207. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/correction_detection.py +0 -0
  208. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/correction_mining.py +0 -0
  209. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/digest.py +0 -0
  210. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/enrichment_prompts.py +0 -0
  211. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/enrichment_results.py +0 -0
  212. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/enrichment_tiers.py +0 -0
  213. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/entity_extraction.py +0 -0
  214. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/entity_resolution.py +0 -0
  215. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/extract.py +0 -0
  216. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/extract_claude_desktop.py +0 -0
  217. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/extract_corrections.py +0 -0
  218. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/extract_markdown.py +0 -0
  219. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/extract_whatsapp.py +0 -0
  220. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/frustration_mining.py +0 -0
  221. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/git_overlay.py +0 -0
  222. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/kg_extraction.py +0 -0
  223. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/kg_extraction_groq.py +0 -0
  224. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/longitudinal_analyzer.py +0 -0
  225. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/obsidian_export.py +0 -0
  226. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/operation_grouping.py +0 -0
  227. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/plan_linking.py +0 -0
  228. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/rate_limiter.py +0 -0
  229. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/relation_backfill.py +0 -0
  230. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/relation_verification.py +0 -0
  231. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/sanitize.py +0 -0
  232. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/secret_scrub.py +0 -0
  233. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/semantic_style.py +0 -0
  234. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/sentiment.py +0 -0
  235. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/session_history.py +0 -0
  236. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/style_embed.py +0 -0
  237. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/style_index.py +0 -0
  238. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/tag_entity_promotion.py +0 -0
  239. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/temporal_chains.py +0 -0
  240. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/time_batcher.py +0 -0
  241. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/unified_timeline.py +0 -0
  242. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/pipeline/write_queue.py +0 -0
  243. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/policy_reconcile.py +0 -0
  244. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/provenance.py +0 -0
  245. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/provenance_autosupersede.py +0 -0
  246. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/provenance_integration.py +0 -0
  247. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/queue_io.py +0 -0
  248. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/queue_merge.py +0 -0
  249. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/readonly_snapshot.py +0 -0
  250. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/reembed_backfill.py +0 -0
  251. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/retired_services.py +0 -0
  252. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/runtime_store.py +0 -0
  253. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/sandbox_db.py +0 -0
  254. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/schema_ddl_ledger.py +0 -0
  255. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/scoping.py +0 -0
  256. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/scrub_at_rest.py +0 -0
  257. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/search_fanout.py +0 -0
  258. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/search_profile.py +0 -0
  259. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/search_repo.py +0 -0
  260. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/search_response.py +0 -0
  261. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/service_supervisor.py +0 -0
  262. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/session_repo.py +0 -0
  263. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/setup.py +0 -0
  264. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/socket_hygiene.py +0 -0
  265. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/source_class_migration.py +0 -0
  266. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/spotlight.py +0 -0
  267. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/storage.py +0 -0
  268. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/store.py +0 -0
  269. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/supervisor_adapters.py +0 -0
  270. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/supervisor_child.py +0 -0
  271. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/supervisor_diagnostics.py +0 -0
  272. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/supervisor_guard.py +0 -0
  273. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/supervisor_jobs.py +0 -0
  274. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/system_prompt_guard.py +0 -0
  275. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/t3_linkage_alarm.py +0 -0
  276. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/t3_sources.py +0 -0
  277. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/tag_normalization.py +0 -0
  278. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/taxonomy.json +0 -0
  279. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/telemetry.py +0 -0
  280. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/timestamp_iso.py +0 -0
  281. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/types.py +0 -0
  282. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/vector_store.py +0 -0
  283. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/wal_checkpoint.py +0 -0
  284. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/writer_policy.py +0 -0
  285. {brainlayer-1.6.5 → brainlayer-1.6.7}/src/brainlayer/writer_telemetry.py +0 -0
  286. {brainlayer-1.6.5 → brainlayer-1.6.7}/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.5
3
+ Version: 1.6.7
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.5"
3
+ version = "1.6.7"
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.5",
6
+ "version": "1.6.7",
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.5",
17
+ "version": "1.6.7",
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.5"
5
+ __version__ = "1.6.7"
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 = "983d28262294c217eb1c4ca0e2c8cb17b728d313"
@@ -17,7 +17,7 @@ from typing import Literal, cast
17
17
  from .agy_attribution import agy_conversation, read_conversation_agent
18
18
  from .content_class import normalize_content_class
19
19
  from .ingest_denylist import MEMORY_READER_ATTRIBUTIONS, is_denylisted, memory_reader_attribution
20
- from .t3_provenance import T3_APP_SESSION, CompactCodexHeader, is_t3_app_initiated_codex_session
20
+ from .t3_provenance import T3_APP_SESSION, T3_UNLINKED, CompactCodexHeader, is_t3_app_initiated_codex_session
21
21
 
22
22
  SearchPolicy = Literal["KEEP", "ISOLATE", "OUT"]
23
23
  EffectiveVisibility = Literal["default", "operational", "cold"]
@@ -33,6 +33,7 @@ ProvenanceClass = Literal[
33
33
  "recon-agent",
34
34
  "t3-app-session",
35
35
  "t3-thread",
36
+ "t3-unlinked",
36
37
  "unknown",
37
38
  "workflow-agent",
38
39
  ]
@@ -47,6 +48,7 @@ PROVENANCE_CLASSES = frozenset(
47
48
  "recon-agent",
48
49
  T3_APP_SESSION,
49
50
  "t3-thread",
51
+ T3_UNLINKED,
50
52
  "unknown",
51
53
  "workflow-agent",
52
54
  }
@@ -265,6 +267,7 @@ def derive_source_class(
265
267
  provenance_map: dict[str, SourceClass] = {
266
268
  T3_APP_SESSION: "cli-agent",
267
269
  "t3-thread": "cli-agent",
270
+ T3_UNLINKED: "cli-agent",
268
271
  "recon-agent": "brain-worker",
269
272
  "fleet-subagent": "fleet-coordination",
270
273
  "product-subagent": "subagent",
@@ -170,6 +170,7 @@ def drive_auth_fact(
170
170
 
171
171
 
172
172
  WATCHER_STALL_REASONS = ("coverage_drop", "offset_lag", "file_ingestion_failure")
173
+ WATCHER_CATCHING_UP = "catching_up" # watcher-health.json catch_up.state; amber, never a stall
173
174
  WATCHER_DB_PROBE_GRACE_S = 300.0
174
175
 
175
176
 
@@ -203,13 +204,38 @@ def watcher_stall_codes(payload: Mapping[str, Any]) -> Any:
203
204
  and polls >= 0
204
205
  ):
205
206
  return UNOBSERVED
207
+ # catch_up is newer than the fields above: absent (an older watcher) adds nothing, while a
208
+ # present but malformed block is unreadable like any other stall field.
209
+ # An explicit null is not an older watcher's omission: it is unreadable too. A catching_up
210
+ # block is progress only with a measured lag and ETA (the watcher always writes both).
211
+ present = "catch_up" in payload
212
+ catch_up = payload.get("catch_up")
213
+ if present and not (isinstance(catch_up, dict) and isinstance(catch_up.get("state"), str)):
214
+ return UNOBSERVED
215
+ if present and catch_up["state"] == WATCHER_CATCHING_UP:
216
+ behind, eta = catch_up.get("bytes_behind"), catch_up.get("eta_s")
217
+ if not (_is_number(behind) and behind >= 0 and _is_number(eta) and eta >= 0):
218
+ return UNOBSERVED
206
219
  codes = [r for r in WATCHER_STALL_REASONS if r in reasons]
207
220
  codes += sorted({r for r in reasons if r.startswith("growth_not_indexed:")})
208
221
  if probe and probe_for >= WATCHER_DB_PROBE_GRACE_S:
209
222
  codes.append("db_probe_failed")
223
+ if catch_up is not None and catch_up["state"] == WATCHER_CATCHING_UP:
224
+ codes.append(catching_up_code(catch_up.get("bytes_behind"), catch_up.get("eta_s")))
210
225
  return tuple(codes + [f"root_missing:{r}" for r in roots])
211
226
 
212
227
 
228
+ def catching_up_code(bytes_behind: Any, eta_s: Any) -> str:
229
+ """``catching_up:<bytes behind>:<eta seconds>``, ``?`` for a value the watcher did not measure.
230
+
231
+ The watcher publishes catching_up only for a lag over its threshold for alert_after_s that is
232
+ still shrinking (progress), so the verdict holds it at amber and never counts it toward red.
233
+ """
234
+ behind = str(int(bytes_behind)) if _is_number(bytes_behind) and bytes_behind >= 0 else "?"
235
+ eta = str(round(eta_s)) if _is_number(eta_s) and eta_s >= 0 else "?"
236
+ return f"{WATCHER_CATCHING_UP}:{behind}:{eta}"
237
+
238
+
213
239
  def watcher_health_fact(path: Path) -> tuple[datetime | None, Any, Any]:
214
240
  """(heartbeat, stall codes, poll_count) from one read of watcher-health.json; missing = (None, (), None).
215
241
 
@@ -235,6 +235,9 @@ class _Raw:
235
235
  evidence: bool = True # False: nothing new was observed, so this tick cannot show recovery
236
236
  graced: bool = False # the state is milder than the real age only because the monitor was not running
237
237
  typed: dict[str, Any] = field(default_factory=dict) # display-only fields; never read by the policy
238
+ # The amber is measured progress (the watcher's catching_up: a lag at a new low over its
239
+ # window, with an ETA under its ceiling). Only such an amber may step a red check down.
240
+ progress: bool = False
238
241
 
239
242
 
240
243
  def _age_state(age: float, amber: float, red: float) -> str:
@@ -383,6 +386,21 @@ class _Stall:
383
386
  state: str | None
384
387
  note: str
385
388
  keep: dict[str, Any]
389
+ progress: bool = False # the amber is the watcher's measured catch-up (see _Raw.progress)
390
+
391
+
392
+ CATCHING_UP_PREFIX = "catching_up:" # health_facts.catching_up_code: catching_up:<bytes>:<eta s>
393
+
394
+
395
+ def _catching_up_note(code: str) -> str:
396
+ """'watcher catching up: 107.0 MB behind, about 12 min left' from a catching_up code."""
397
+ _, behind, eta = (code.split(":") + ["?", "?"])[:3]
398
+ parts = []
399
+ if behind.isdigit():
400
+ parts.append(f"{int(behind) / 1_000_000:.1f} MB behind")
401
+ if eta.isdigit():
402
+ parts.append(f"about {max(1, round(int(eta) / 60))} min left")
403
+ return "watcher catching up" + (": " + ", ".join(parts) if parts else "")
386
404
 
387
405
 
388
406
  def _ingest_stall(facts: Facts, before: Mapping[str, Any], watcher: datetime | None, t: Thresholds) -> _Stall:
@@ -399,13 +417,20 @@ def _ingest_stall(facts: Facts, before: Mapping[str, Any], watcher: datetime | N
399
417
  blind = int(before.get("stall_blind_ticks") or 0)
400
418
  codes = facts.watcher_stall_codes
401
419
  read = watcher is not None and isinstance(codes, tuple)
420
+ # catching_up is the watcher's measured progress (a lag at a new low over its window, ETA
421
+ # under its ceiling). A snapshot carrying only it HOLDS the count: it neither adds nor resets
422
+ # (#1827 round 1: a reset let a lag that flickered to catching_up stay amber forever). It
423
+ # reads amber, and may step a red check down (progress); the next stall snapshot continues
424
+ # the held count, so a stall after a catch-up is red again at once if it was red before.
425
+ catching_up = [c for c in codes if c.startswith(CATCHING_UP_PREFIX)] if read else []
402
426
  if read:
427
+ codes = tuple(c for c in codes if not c.startswith(CATCHING_UP_PREFIX))
403
428
  blind = 0
404
429
  if facts.stores_paused:
405
430
  codes = tuple(c for c in codes if c != "coverage_drop") # the paused drain writes nothing
406
431
  snapshot = [watcher.astimezone(UTC).isoformat(), facts.watcher_poll_count]
407
432
  if seen != snapshot:
408
- ticks, seen = (ticks + 1 if codes else 0), snapshot
433
+ ticks, seen = (ticks + 1 if codes else ticks if catching_up else 0), snapshot
409
434
  elif not isinstance(codes, tuple):
410
435
  blind += 1
411
436
  keep: dict[str, Any] = {}
@@ -413,6 +438,9 @@ def _ingest_stall(facts: Facts, before: Mapping[str, Any], watcher: datetime | N
413
438
  keep.update(alert_ticks=ticks, alert_seen=seen)
414
439
  if blind:
415
440
  keep["stall_blind_ticks"] = blind
441
+ if catching_up and not codes:
442
+ held = f" ({ticks} stall checks held)" if ticks else ""
443
+ return _Stall(read, AMBER, _catching_up_note(catching_up[0]) + held, keep, progress=True)
416
444
  if ticks:
417
445
  what = ", ".join(codes) if read and codes else "a stall"
418
446
  state = RED if ticks >= t.ingest_alert_red_ticks else AMBER
@@ -502,6 +530,9 @@ def _raw_checks(
502
530
  if _RANK[stall.state] > _RANK[r.state]:
503
531
  r.state, r.amber_s = stall.state, None
504
532
  r.note = "; ".join(x for x in (r.note, stall.note) if x)
533
+ # Measured progress only when the catch-up amber IS the state (a stale heartbeat's
534
+ # own red or amber is not progress).
535
+ r.progress = stall.progress and r.state == AMBER and stall.state == AMBER
505
536
  if facts.ingest_paused and r.state == RED:
506
537
  r.state, r.note = AMBER, r.note + " (watcher paused by maintenance)"
507
538
  r.keep.update(stall.keep)
@@ -683,7 +714,9 @@ def evaluate(facts: Facts, prior: Mapping[str, Any] | None = None, thresholds: T
683
714
  # Nothing new was observed (or the age only looks fresh because the monitor was
684
715
  # not running): a known amber or red holds, and this is not a good tick.
685
716
  state, note = prior_state, f"{note}; {prior_state} holds until positive evidence".lstrip("; ")
686
- elif name in _HYSTERESIS and prior_state == RED and state == AMBER:
717
+ elif name in _HYSTERESIS and prior_state == RED and state == AMBER and not r.progress:
718
+ # A measured catch-up (r.progress) steps red down to amber: positive evidence that
719
+ # ingest is moving, with an ETA (lead decision on Etan's 18 Nov words, #1827 r1).
687
720
  state, note = RED, f"{note}; red holds until consecutive observed good checks"
688
721
  elif name in _HYSTERESIS and state == GREEN and prior_state in (AMBER, RED):
689
722
  good_ticks += 1
@@ -13,9 +13,11 @@ import hashlib
13
13
  import json
14
14
  import logging
15
15
  import sqlite3
16
+ from contextlib import ExitStack, contextmanager
16
17
  from dataclasses import dataclass, field, replace
17
18
  from datetime import datetime, timezone
18
19
  from pathlib import Path
20
+ from time import perf_counter
19
21
  from typing import Any
20
22
 
21
23
  from ..alarm import BrainLayerAlarm, raise_alarm
@@ -31,6 +33,26 @@ T3_SOURCE = "t3"
31
33
  T3_PROVENANCE_CLASS = "t3-thread"
32
34
  DEFAULT_T3_HEALTH_PATH = Path("~/.local/share/brainlayer/t3-health.json").expanduser()
33
35
 
36
+ _PHASES = ("read_ms", "chunk_ms", "change_check_ms", "embed_ms", "write_ms")
37
+
38
+
39
+ @contextmanager
40
+ def _timed_phase(timings, phase):
41
+ started = perf_counter()
42
+ try:
43
+ yield
44
+ finally:
45
+ timings[phase] = timings.get(phase, 0.0) + (perf_counter() - started) * 1000
46
+
47
+
48
+ def _legacy_fingerprint(path):
49
+ stat = path.stat()
50
+ fingerprint = {**t3_bookmark.identity(path), "size": stat.st_size, "mtime_ns": stat.st_mtime_ns}
51
+ wal = Path(str(path) + "-wal")
52
+ fingerprint["wal"] = [wal.stat().st_size, wal.stat().st_mtime_ns] if wal.exists() else None
53
+ return fingerprint
54
+
55
+
34
56
  _REQUIRED_COLUMNS: dict[str, frozenset[str]] = {
35
57
  "projection_threads": frozenset({"thread_id", "project_id", "title", "created_at"}),
36
58
  "projection_thread_messages": frozenset({"message_id", "thread_id", "role", "text", "created_at"}),
@@ -88,6 +110,11 @@ class T3Thread:
88
110
 
89
111
  @dataclass
90
112
  class T3IngestionResult:
113
+ read_ms: float = 0.0
114
+ chunk_ms: float = 0.0
115
+ change_check_ms: float = 0.0
116
+ embed_ms: float = 0.0
117
+ write_ms: float = 0.0
91
118
  mode: str = "full"
92
119
  events_read: int = 0
93
120
  bookmark_from: int | None = None
@@ -133,6 +160,7 @@ class T3Reader:
133
160
  self.health_path = Path(health_path).expanduser() if health_path is not None else None
134
161
  self._last_counts: dict[str, Any] = {}
135
162
  self._failures: list[dict[str, Any]] = []
163
+ self._timings = dict.fromkeys(_PHASES, 0.0)
136
164
 
137
165
  def read_threads(self, *, report_success: bool = True) -> list[T3Thread]:
138
166
  """Read a complete short snapshot of the T3 projections.
@@ -154,7 +182,7 @@ class T3Reader:
154
182
  self._bookmark_info, mids, tids, self._next_bookmark = t3_bookmark.window(
155
183
  conn, self._previous_bookmark, source_identity
156
184
  )
157
- if self._bookmark_info["mode"] == "incremental":
185
+ if self._bookmark_info["mode"] in ("incremental", "bounded"):
158
186
  selection = (mids, tids)
159
187
  if getattr(self, "_include_message_identities", False):
160
188
  # Legacy precedence needs all V2 owners, not just touched threads.
@@ -306,15 +334,14 @@ class T3Reader:
306
334
  def _read_v2_snapshot(conn: sqlite3.Connection, selection=None) -> list[T3Thread]:
307
335
  """Read only the explicitly selected V2 projection; never fall back to legacy rows."""
308
336
  # 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
- )
337
+ params = []
338
+ clauses = []
339
+ if selection is not None:
340
+ for column, ids in zip(("message_id", "thread_id"), selection):
341
+ if ids:
342
+ clauses.append(f"{column} IN (SELECT value FROM json_each(?))")
343
+ params.append(json.dumps(sorted(ids)))
344
+ selected = "" if selection is None else " AND (" + (" OR ".join(clauses) or "0") + ")"
318
345
  message_rows = conn.execute(
319
346
  "SELECT message_id, thread_id, role, created_at, payload_json "
320
347
  "FROM orchestration_v2_projection_messages WHERE streaming = 0 "
@@ -417,6 +444,7 @@ class T3Reader:
417
444
  "alerting": alerting,
418
445
  "alert_reasons": alert_reasons,
419
446
  "failures": list(self._failures),
447
+ **self._timings,
420
448
  **self._last_counts,
421
449
  }
422
450
  try:
@@ -448,6 +476,7 @@ class _IndexBudget:
448
476
  oldest_first: bool = False
449
477
  pending_ids: set[str] | None = None
450
478
  deferred_ids: set[str] = field(default_factory=set)
479
+ timings: dict[str, float] = field(default_factory=dict)
451
480
 
452
481
 
453
482
  def _changed_chunks(chunks, store):
@@ -472,46 +501,51 @@ def _index_chunks(
472
501
  from ..system_prompt_guard import looks_like_system_prompt
473
502
 
474
503
  budget = budget if budget is not None else _IndexBudget()
475
- eligible = [
476
- _scrubbed_chunk(chunk)
477
- for chunk in chunks
478
- if not chunk.metadata.get("is_system_prompt") and not looks_like_system_prompt(chunk.content)
479
- ]
480
- # Match index admission before budgeting, change detection, and precomputing
481
- # vectors. Empty inputs are handled skips, not pending writes to replay.
482
- admitted = [chunk for chunk in eligible if chunk.content.strip()]
483
- skipped_empty = len(eligible) - len(admitted)
484
- if skipped_empty:
485
- logger.info("T3 index admission skipped_empty_chunks=%s source_file=%s", skipped_empty, source_file)
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]
489
- # Fail fast on an already-busy writer, then release it before model loading.
490
- with open_writer_store(db_path) as store:
491
- changed = _changed_chunks(eligible, store)
492
- changed.sort(key=_newest_chunk_key, reverse=not budget.oldest_first)
493
- selected = changed[: budget.remaining]
494
- budget.remaining -= len(selected)
495
- budget.deferred += len(changed) - len(selected)
496
- budget.deferred_ids.update(chunk.metadata["chunk_id"] for chunk in changed[len(selected) :])
504
+ with _timed_phase(budget.timings, "change_check_ms"):
505
+ eligible = [
506
+ _scrubbed_chunk(chunk)
507
+ for chunk in chunks
508
+ if not chunk.metadata.get("is_system_prompt") and not looks_like_system_prompt(chunk.content)
509
+ ]
510
+ # Match index admission before budgeting, change detection, and precomputing
511
+ # vectors. Empty inputs are handled skips, not pending writes to replay.
512
+ admitted = [chunk for chunk in eligible if chunk.content.strip()]
513
+ skipped_empty = len(eligible) - len(admitted)
514
+ if skipped_empty:
515
+ logger.info("T3 index admission skipped_empty_chunks=%s source_file=%s", skipped_empty, source_file)
516
+ eligible = admitted
517
+ if budget.pending_ids is not None:
518
+ eligible = [chunk for chunk in eligible if chunk.metadata["chunk_id"] in budget.pending_ids]
519
+ # Fail fast on an already-busy writer, then release it before model loading.
520
+ with open_writer_store(db_path) as store:
521
+ changed = _changed_chunks(eligible, store)
522
+ changed.sort(key=_newest_chunk_key, reverse=not budget.oldest_first)
523
+ selected = changed[: budget.remaining]
524
+ budget.remaining -= len(selected)
525
+ budget.deferred += len(changed) - len(selected)
526
+ budget.deferred_ids.update(chunk.metadata["chunk_id"] for chunk in changed[len(selected) :])
497
527
  if not selected:
498
528
  return 0
499
- computed = embed_chunks(selected)
500
- with open_writer_store(db_path) as store:
529
+ with _timed_phase(budget.timings, "embed_ms"):
530
+ computed = embed_chunks(selected)
531
+ with ExitStack() as writers:
501
532
  # Another writer may have indexed these IDs while we embedded.
502
- changed = _changed_chunks(selected, store)
533
+ with _timed_phase(budget.timings, "change_check_ms"):
534
+ store = writers.enter_context(open_writer_store(db_path))
535
+ changed = _changed_chunks(selected, store)
503
536
  if not changed:
504
537
  return 0
505
538
  admitted = {(chunk.metadata["chunk_id"], chunk.content) for chunk in changed}
506
539
  computed = [ec for ec in computed if (ec.chunk.metadata["chunk_id"], ec.chunk.content) in admitted]
507
- indexed = index_chunks_to_sqlite(
508
- changed,
509
- source_file=source_file,
510
- project=project,
511
- db_path=db_path,
512
- store=store,
513
- precomputed_embeddings=computed,
514
- )
540
+ with _timed_phase(budget.timings, "write_ms"):
541
+ indexed = index_chunks_to_sqlite(
542
+ changed,
543
+ source_file=source_file,
544
+ project=project,
545
+ db_path=db_path,
546
+ store=store,
547
+ precomputed_embeddings=computed,
548
+ )
515
549
  if indexed != len(changed):
516
550
  raise RuntimeError(
517
551
  f"T3 indexing incomplete: indexed {indexed} of {len(changed)} eligible chunks; retain rows for replay"
@@ -619,6 +653,7 @@ def ingest_t3(
619
653
  open a BrainLayer destination. Dry-run state cannot skip a real backfill.
620
654
  """
621
655
  destination = Path(db_path).expanduser() if db_path is not None else None
656
+ read_started = perf_counter()
622
657
  try:
623
658
  sources = resolve_t3_sources(state_db_path, projection_version, tolerate_legacy_failure=True)
624
659
  except BrainLayerAlarm as exc:
@@ -641,7 +676,19 @@ def ingest_t3(
641
676
  state = {}
642
677
  next_state = {"target": target, "sources": {}}
643
678
  reader._source_paths = [str(path) for path, _ in sources]
644
- reader._include_message_identities = any(version == 1 for _, version in sources)
679
+ # Decide legacy reads before the V2 snapshot, so unchanged legacy sources
680
+ # need neither payloads nor the complete V2 ownership set.
681
+ fingerprints = {}
682
+ for path, version in sources:
683
+ if version == 1:
684
+ try:
685
+ fingerprints[path] = _legacy_fingerprint(path)
686
+ except OSError as error:
687
+ fingerprints[path] = error
688
+ reader._include_message_identities = any(
689
+ not isinstance(fingerprint, OSError) and fingerprint != state.get("sources", {}).get(str(path.resolve()), {})
690
+ for path, fingerprint in fingerprints.items()
691
+ )
645
692
  threads = []
646
693
  seen_messages = set()
647
694
  source_alerts = []
@@ -653,6 +700,7 @@ def ingest_t3(
653
700
  if path == reader.state_db_path
654
701
  else T3Reader(path, health_path=health_path, projection_version=version)
655
702
  )
703
+ source_reader._timings = reader._timings
656
704
  try:
657
705
  key = str(path.resolve())
658
706
  previous = state.get("sources", {}).get(key, {})
@@ -660,11 +708,9 @@ def ingest_t3(
660
708
  source_reader._previous_bookmark = previous
661
709
  else:
662
710
  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
711
+ fingerprint = fingerprints[path]
712
+ if isinstance(fingerprint, OSError):
713
+ raise fingerprint
668
714
  except OSError as error:
669
715
  source_reader._fail(
670
716
  "t3_reader_failed",
@@ -679,7 +725,8 @@ def ingest_t3(
679
725
  next_state["sources"].pop(key, None)
680
726
  if previous:
681
727
  next_state["sources"][key] = previous
682
- source_threads = source_reader.read_threads(report_success=False)
728
+ with _timed_phase(reader._timings, "read_ms"):
729
+ source_threads = source_reader.read_threads(report_success=False)
683
730
  if hasattr(source_reader, "_next_bookmark"):
684
731
  next_state["sources"][key] = source_reader._next_bookmark
685
732
  resume_pending &= source_reader._next_bookmark.pop("resume_pending")
@@ -698,6 +745,7 @@ def ingest_t3(
698
745
  messages.append(message)
699
746
  threads.append((path, replace(thread, messages=tuple(messages))))
700
747
  seen_messages.update(getattr(source_reader, "_message_identities", ()))
748
+ reader._timings["read_ms"] = (perf_counter() - read_started) * 1000
701
749
  result = T3IngestionResult(
702
750
  **getattr(reader, "_bookmark_info", {}),
703
751
  threads_seen=len({thread.thread_id for _, thread in threads}),
@@ -707,25 +755,30 @@ def ingest_t3(
707
755
  )
708
756
  chunks = []
709
757
  batches = {}
710
- for path, thread in threads:
711
- for message in thread.messages:
712
- if message.role not in {"user", "assistant"}:
713
- result.messages_skipped["unsupported_role"] = result.messages_skipped.get("unsupported_role", 0) + 1
714
- continue
715
- message_chunks = _message_chunks(thread, message)
716
- if not message_chunks:
717
- result.messages_skipped["empty_text"] = result.messages_skipped.get("empty_text", 0) + 1
718
- continue
719
- result.messages_ingested += 1
720
- chunks.extend(message_chunks)
721
- batches.setdefault(path, []).extend(message_chunks)
758
+ with _timed_phase(reader._timings, "chunk_ms"):
759
+ for path, thread in threads:
760
+ for message in thread.messages:
761
+ if message.role not in {"user", "assistant"}:
762
+ result.messages_skipped["unsupported_role"] = result.messages_skipped.get("unsupported_role", 0) + 1
763
+ continue
764
+ message_chunks = _message_chunks(thread, message)
765
+ if not message_chunks:
766
+ result.messages_skipped["empty_text"] = result.messages_skipped.get("empty_text", 0) + 1
767
+ continue
768
+ result.messages_ingested += 1
769
+ chunks.extend(message_chunks)
770
+ batches.setdefault(path, []).extend(message_chunks)
722
771
  result.chunks_planned = len(chunks)
723
772
  if chunks and not dry_run:
724
773
  if destination is None:
725
774
  from ..paths import DEFAULT_DB_PATH
726
775
 
727
776
  destination = DEFAULT_DB_PATH
728
- budget = _IndexBudget(remaining=DEFAULT_T3_MAX_CHANGED_CHUNKS, oldest_first=hasattr(reader, "_next_bookmark"))
777
+ budget = _IndexBudget(
778
+ remaining=DEFAULT_T3_MAX_CHANGED_CHUNKS,
779
+ oldest_first=hasattr(reader, "_next_bookmark"),
780
+ timings=reader._timings,
781
+ )
729
782
  if "pending_chunks" in state and resume_pending:
730
783
  budget.pending_ids = set(state["pending_chunks"])
731
784
  try:
@@ -786,6 +839,12 @@ def ingest_t3(
786
839
  if reader._bookmark_info["mode"] == "incremental"
787
840
  else None
788
841
  ),
842
+ # The held sequence and timestamp must describe the same start.
843
+ "occurred_at": (
844
+ state.get("sources", {}).get(key, {}).get("occurred_at")
845
+ if reader._bookmark_info["mode"] == "incremental"
846
+ else None
847
+ ),
789
848
  "pending_to": candidate["last_sequence"],
790
849
  }
791
850
  t3_bookmark.save(state_path, held)
@@ -797,6 +856,8 @@ def ingest_t3(
797
856
  reader._fail("t3_bookmark_failed", "T3 replay state could not be saved", {}, error)
798
857
  elif state_path is None or (dry_run and bookmark_path is None):
799
858
  result.bookmark_held = "state_disabled"
859
+ for phase, elapsed in reader._timings.items():
860
+ setattr(result, phase, elapsed)
800
861
  if reader.health_path is not None:
801
862
  reader._last_counts.update(
802
863
  {
@@ -3,6 +3,7 @@
3
3
  import json
4
4
  import os
5
5
  import tempfile
6
+ from datetime import datetime, timedelta, timezone
6
7
  from pathlib import Path
7
8
 
8
9
 
@@ -54,15 +55,45 @@ def window(conn, previous, source_identity):
54
55
  and "event-log-pruned-through" in metadata
55
56
  and metadata.get("event-log-pruned-through", 0) <= start <= ceiling <= head
56
57
  )
58
+ cutoff = None
59
+ if (
60
+ same_source
61
+ and type(start) is int
62
+ and start <= ceiling <= head
63
+ and "event-log-pruned-through" in metadata
64
+ and metadata.get("event-log-pruned-through", 0) > start
65
+ # Any saved pending replay (resumable or not, e.g. pending_to past a restored
66
+ # head) may predate start-time preservation: reload it from the full read.
67
+ and pending is None
68
+ and isinstance(previous.get("occurred_at"), str)
69
+ and any(
70
+ row[1] == "updated_at" for row in conn.execute("PRAGMA table_info(orchestration_v2_projection_messages)")
71
+ )
72
+ ):
73
+ try:
74
+ stamp_time = datetime.fromisoformat(previous["occurred_at"].replace("Z", "+00:00"))
75
+ if stamp_time.tzinfo is not None:
76
+ cutoff = (stamp_time.astimezone(timezone.utc) - timedelta(minutes=10)).isoformat()
77
+ except (ValueError, OverflowError):
78
+ pass # An unusable timestamp requires the full safety read.
57
79
  info = {
58
- "mode": "incremental" if valid else "full",
80
+ "mode": "incremental" if valid else "bounded" if cutoff is not None else "full",
59
81
  "events_read": 0,
60
82
  "bookmark_from": start,
61
83
  "bookmark_to": ceiling,
62
84
  "bookmark_held": None,
63
85
  }
64
86
  messages, threads = set(), set()
65
- if valid:
87
+ if cutoff is not None:
88
+ messages.update(
89
+ row[0]
90
+ for row in conn.execute(
91
+ "SELECT message_id FROM orchestration_v2_projection_messages "
92
+ "WHERE julianday(updated_at) > julianday(?)",
93
+ (cutoff,),
94
+ )
95
+ )
96
+ elif valid:
66
97
  rows = conn.execute(
67
98
  "SELECT stream_id FROM orchestration_events WHERE sequence > ? AND sequence <= ?",
68
99
  (start, ceiling),