brainlayer 1.6.0__tar.gz → 1.6.1__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 (285) hide show
  1. {brainlayer-1.6.0 → brainlayer-1.6.1}/.gitignore +5 -0
  2. {brainlayer-1.6.0 → brainlayer-1.6.1}/PKG-INFO +2 -2
  3. {brainlayer-1.6.0 → brainlayer-1.6.1}/README.md +1 -1
  4. {brainlayer-1.6.0 → brainlayer-1.6.1}/pyproject.toml +2 -2
  5. {brainlayer-1.6.0 → brainlayer-1.6.1}/server.json +2 -2
  6. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/__init__.py +1 -1
  7. brainlayer-1.6.1/src/brainlayer/_build.py +1 -0
  8. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/agent_census.py +6 -4
  9. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/agent_provenance.py +27 -2
  10. brainlayer-1.6.1/src/brainlayer/agy_attribution.py +188 -0
  11. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/cli/__init__.py +9 -2
  12. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/enrichment_quality_benchmark.py +0 -21
  13. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/health_facts.py +56 -5
  14. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/health_verdict.py +60 -3
  15. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/kg_repo.py +2 -3
  16. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/enrichment_prompts.py +4 -1
  17. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/sanitize.py +4 -1
  18. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/semantic_style.py +4 -1
  19. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/style_embed.py +4 -1
  20. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/watcher.py +88 -1
  21. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/watcher_bridge.py +20 -1
  22. brainlayer-1.6.0/src/brainlayer/_build.py +0 -1
  23. {brainlayer-1.6.0 → brainlayer-1.6.1}/LICENSE +0 -0
  24. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/brainlayer-version-check.sh +0 -0
  25. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/hotlane_brainbar_daemon.py +0 -0
  26. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/backup-daily.sh +0 -0
  27. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/brainlayer-env-run.sh +0 -0
  28. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/brainlayer.env.example +0 -0
  29. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.backup-daily.plist +0 -0
  30. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.daemon.plist +0 -0
  31. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.decay.plist +0 -0
  32. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.drain.plist +0 -0
  33. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.health-check.plist +0 -0
  34. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.hotlane-brainbar.plist +0 -0
  35. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.index.plist +0 -0
  36. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.jsonl-backup.plist +0 -0
  37. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.log-cap.plist +0 -0
  38. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.maintenance-nightly.plist +0 -0
  39. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.maintenance-weekly.plist +0 -0
  40. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.maintenance.plist +0 -0
  41. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.observability.plist +0 -0
  42. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.p0-counter.plist +0 -0
  43. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.repair-fts.plist +0 -0
  44. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.t3-ingest.plist +0 -0
  45. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.throughput-watchdog.plist +0 -0
  46. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.tier0-watchdog.plist +0 -0
  47. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.wal-checkpoint.plist +0 -0
  48. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.watch.plist +0 -0
  49. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/com.etanhey.brainlayer-fleet-watchdog.plist +0 -0
  50. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/fleet-watchdog.sh +0 -0
  51. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/install.sh +0 -0
  52. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/jsonl-backup.sh +0 -0
  53. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/launchd/throughput-watchdog.py +0 -0
  54. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/release-verify-signatures.sh +0 -0
  55. {brainlayer-1.6.0 → brainlayer-1.6.1}/scripts/tier0-watchdog.sh +0 -0
  56. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/__main__.py +0 -0
  57. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/_helpers.py +0 -0
  58. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/agent_profiles.py +0 -0
  59. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/alarm.py +0 -0
  60. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/archive_collapse.py +0 -0
  61. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/archive_lifecycle.py +0 -0
  62. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/backup_daily.py +0 -0
  63. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/backup_retention_invariant.py +0 -0
  64. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/badge_state.py +0 -0
  65. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/bitemporal.py +0 -0
  66. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/brainbar_activation.py +0 -0
  67. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/brainbar_auto_activation.py +0 -0
  68. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/brainbar_hybrid_helper.py +0 -0
  69. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/brainbar_identity.py +0 -0
  70. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/cachedelete_purge.swift +0 -0
  71. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/calibrate.py +0 -0
  72. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/chunk_origin.py +0 -0
  73. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/chunk_origin_backfill.py +0 -0
  74. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/chunk_origin_wipe.py +0 -0
  75. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/chunk_write.py +0 -0
  76. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/classify.py +0 -0
  77. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/claude_paths.py +0 -0
  78. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/cli/wizard.py +0 -0
  79. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/cli_jobs.py +0 -0
  80. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/cli_new.py +0 -0
  81. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/cloud_backfill.py +0 -0
  82. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/clustering.py +0 -0
  83. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/codex_zst.py +0 -0
  84. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/component_jobs.py +0 -0
  85. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/config.py +0 -0
  86. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/consolidation_plan.py +0 -0
  87. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/content_class.py +0 -0
  88. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/content_hash_repair.py +0 -0
  89. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/correction_judge.py +0 -0
  90. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/data/agents_registry.yaml +0 -0
  91. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/data/sandbox_seeds/skill-eval-baseline.json +0 -0
  92. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/db_shrink.py +0 -0
  93. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/decay.py +0 -0
  94. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/decay_backfill.py +0 -0
  95. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/decay_job.py +0 -0
  96. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/dedupe.py +0 -0
  97. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/dedupe_merge.py +0 -0
  98. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/deploy_drift.py +0 -0
  99. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/disk_space.py +0 -0
  100. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/doctor.py +0 -0
  101. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/drain.py +0 -0
  102. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/drain_liveness.py +0 -0
  103. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/drive_credentials.py +0 -0
  104. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/embeddings.py +0 -0
  105. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/engine.py +0 -0
  106. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/enrichment_replay.py +0 -0
  107. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/__init__.py +0 -0
  108. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/abcde_enrich_runner.py +0 -0
  109. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/abcde_variants.py +0 -0
  110. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/abcde_variants.yaml +0 -0
  111. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/benchmark.py +0 -0
  112. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/enrichment_gold.py +0 -0
  113. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/enrichment_graders.py +0 -0
  114. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/enrichment_judge.py +0 -0
  115. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/enrichment_llm_judge.py +0 -0
  116. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/experiment_store.py +0 -0
  117. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/fixtures/README.md +0 -0
  118. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/labeling/enrichment-labeler.html +0 -0
  119. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/__init__.py +0 -0
  120. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/__main__.py +0 -0
  121. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/baseline_store.py +0 -0
  122. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/cli.py +0 -0
  123. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/models.py +0 -0
  124. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/phoenix_client.py +0 -0
  125. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/regression_gate.py +0 -0
  126. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/triggers.py +0 -0
  127. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/eval/pilot_artifact_report.py +0 -0
  128. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/fallback_replay.py +0 -0
  129. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/git_learning.py +0 -0
  130. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/health_check.py +0 -0
  131. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/hook_python.py +0 -0
  132. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/hooks/__init__.py +0 -0
  133. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/hooks/indexer.py +0 -0
  134. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/hotlane_budget.py +0 -0
  135. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/import_sweep.py +0 -0
  136. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/index_admission.py +0 -0
  137. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/index_budget.py +0 -0
  138. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/index_completeness.py +0 -0
  139. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/index_new.py +0 -0
  140. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/index_watchdog.py +0 -0
  141. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/ingest/__init__.py +0 -0
  142. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/ingest/codex.py +0 -0
  143. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/ingest/codex_manifest.py +0 -0
  144. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/ingest/t3.py +0 -0
  145. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/ingest_denylist.py +0 -0
  146. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/ingest_guard.py +0 -0
  147. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/isolation_proof.py +0 -0
  148. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/job_alerts.py +0 -0
  149. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/job_lifecycle_health.py +0 -0
  150. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/jobs.py +0 -0
  151. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/jsonl_backup.py +0 -0
  152. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/kg/__init__.py +0 -0
  153. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/kg_cleanup.py +0 -0
  154. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/kg_judge.py +0 -0
  155. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/kg_promotion.py +0 -0
  156. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/kg_review_session.py +0 -0
  157. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/kg_session_finish.py +0 -0
  158. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/kg_session_harvest.py +0 -0
  159. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/launchd_consolidation.py +0 -0
  160. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/launchd_install.py +0 -0
  161. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/launchd_primitive.py +0 -0
  162. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/launchd_revert.py +0 -0
  163. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/launcher_policy_reconcile.py +0 -0
  164. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/lexical_defense.py +0 -0
  165. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/lexical_defense_dictionary.json +0 -0
  166. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/linkedin_import.py +0 -0
  167. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/log_cap.py +0 -0
  168. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/maintenance.py +0 -0
  169. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/maintenance_calendar.py +0 -0
  170. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/maintenance_control.py +0 -0
  171. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/maintenance_upload_recovery.py +0 -0
  172. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp/__init__.py +0 -0
  173. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp/_format.py +0 -0
  174. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp/_shared.py +0 -0
  175. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp/enrich_handler.py +0 -0
  176. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp/entity_handler.py +0 -0
  177. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp/palette.py +0 -0
  178. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp/search_handler.py +0 -0
  179. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp/store_handler.py +0 -0
  180. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp/tags_handler.py +0 -0
  181. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp_socket_config.py +0 -0
  182. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/mcp_stdio_bridge.py +0 -0
  183. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/memory_types.py +0 -0
  184. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/migrate.py +0 -0
  185. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/migration_custody.py +0 -0
  186. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/migration_journal.py +0 -0
  187. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/migration_runtime.py +0 -0
  188. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/notification_policy.py +0 -0
  189. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/observability_backup.py +0 -0
  190. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/observability_indexes.py +0 -0
  191. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/observability_surface.py +0 -0
  192. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/observability_transport.py +0 -0
  193. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/p0_longitudinal_count.py +0 -0
  194. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/parent_death.py +0 -0
  195. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/paths.py +0 -0
  196. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pause.py +0 -0
  197. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/phonetic.py +0 -0
  198. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/__init__.py +0 -0
  199. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/agent_enrichment.py +0 -0
  200. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/analyze_communication.py +0 -0
  201. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/batch_extraction.py +0 -0
  202. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/brain_graph.py +0 -0
  203. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/chat_tags.py +0 -0
  204. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/chunk.py +0 -0
  205. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/classify.py +0 -0
  206. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/cloud_scrub.py +0 -0
  207. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/cluster_sampling.py +0 -0
  208. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/code_intelligence.py +0 -0
  209. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/correction_detection.py +0 -0
  210. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/correction_mining.py +0 -0
  211. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/digest.py +0 -0
  212. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/enrichment_results.py +0 -0
  213. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/enrichment_tiers.py +0 -0
  214. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/entity_extraction.py +0 -0
  215. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/entity_resolution.py +0 -0
  216. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/extract.py +0 -0
  217. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/extract_claude_desktop.py +0 -0
  218. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/extract_corrections.py +0 -0
  219. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/extract_markdown.py +0 -0
  220. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/extract_whatsapp.py +0 -0
  221. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/frustration_mining.py +0 -0
  222. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/git_overlay.py +0 -0
  223. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/kg_extraction.py +0 -0
  224. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/kg_extraction_groq.py +0 -0
  225. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/longitudinal_analyzer.py +0 -0
  226. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/obsidian_export.py +0 -0
  227. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/operation_grouping.py +0 -0
  228. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/plan_linking.py +0 -0
  229. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/rate_limiter.py +0 -0
  230. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/relation_backfill.py +0 -0
  231. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/relation_verification.py +0 -0
  232. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/secret_scrub.py +0 -0
  233. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/sentiment.py +0 -0
  234. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/session_history.py +0 -0
  235. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/style_index.py +0 -0
  236. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/tag_entity_promotion.py +0 -0
  237. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/temporal_chains.py +0 -0
  238. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/time_batcher.py +0 -0
  239. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/unified_timeline.py +0 -0
  240. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/pipeline/write_queue.py +0 -0
  241. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/policy_reconcile.py +0 -0
  242. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/provenance.py +0 -0
  243. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/provenance_autosupersede.py +0 -0
  244. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/provenance_integration.py +0 -0
  245. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/queue_io.py +0 -0
  246. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/queue_merge.py +0 -0
  247. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/readonly_snapshot.py +0 -0
  248. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/reembed_backfill.py +0 -0
  249. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/retired_services.py +0 -0
  250. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/runtime_store.py +0 -0
  251. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/sandbox_db.py +0 -0
  252. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/schema_ddl_ledger.py +0 -0
  253. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/scoping.py +0 -0
  254. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/scrub_at_rest.py +0 -0
  255. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/search_fanout.py +0 -0
  256. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/search_profile.py +0 -0
  257. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/search_repo.py +0 -0
  258. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/search_response.py +0 -0
  259. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/service_supervisor.py +0 -0
  260. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/session_repo.py +0 -0
  261. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/setup.py +0 -0
  262. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/socket_hygiene.py +0 -0
  263. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/source_class_migration.py +0 -0
  264. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/spotlight.py +0 -0
  265. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/storage.py +0 -0
  266. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/store.py +0 -0
  267. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/supervisor_adapters.py +0 -0
  268. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/supervisor_child.py +0 -0
  269. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/supervisor_diagnostics.py +0 -0
  270. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/supervisor_guard.py +0 -0
  271. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/supervisor_jobs.py +0 -0
  272. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/system_prompt_guard.py +0 -0
  273. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/t3_linkage_alarm.py +0 -0
  274. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/t3_provenance.py +0 -0
  275. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/t3_sources.py +0 -0
  276. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/tag_normalization.py +0 -0
  277. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/taxonomy.json +0 -0
  278. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/telemetry.py +0 -0
  279. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/timestamp_iso.py +0 -0
  280. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/types.py +0 -0
  281. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/vector_store.py +0 -0
  282. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/wal_checkpoint.py +0 -0
  283. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/writer_policy.py +0 -0
  284. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/writer_telemetry.py +0 -0
  285. {brainlayer-1.6.0 → brainlayer-1.6.1}/src/brainlayer/zstd_stream.py +0 -0
@@ -52,6 +52,11 @@ data/
52
52
  .tmp-*
53
53
  grill*/
54
54
  docs.local/
55
+ # Per-PR bot-review scratch and agent briefs belong in docs.local/, never the repo root
56
+ /BUGBOT_*.md
57
+ /bugbot-review-notes.md
58
+ /SLICE-*-BRIEF.md
59
+ /progress.txt
55
60
 
56
61
  # Internal planning docs (contain cross-repo references)
57
62
  docs/plan/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: brainlayer
3
- Version: 1.6.0
3
+ Version: 1.6.1
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
@@ -375,7 +375,7 @@ brainlayer search "query" # Semantic + keyword search
375
375
  brainlayer stats # Database statistics
376
376
  brainlayer brain-export # Brain graph JSON for visualization
377
377
  brainlayer export-obsidian # Export to Obsidian vault
378
- brainlayer dashboard # Interactive TUI
378
+ brainlayer dashboard # Interactive TUI (source checkout only)
379
379
  ```
380
380
 
381
381
  ## Testing
@@ -300,7 +300,7 @@ brainlayer search "query" # Semantic + keyword search
300
300
  brainlayer stats # Database statistics
301
301
  brainlayer brain-export # Brain graph JSON for visualization
302
302
  brainlayer export-obsidian # Export to Obsidian vault
303
- brainlayer dashboard # Interactive TUI
303
+ brainlayer dashboard # Interactive TUI (source checkout only)
304
304
  ```
305
305
 
306
306
  ## Testing
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "brainlayer"
3
- version = "1.6.0"
3
+ version = "1.6.1"
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"
@@ -111,7 +111,7 @@ target-version = "py311"
111
111
 
112
112
  [tool.ruff.lint]
113
113
  select = ["E", "F", "I", "W"]
114
- ignore = ["E402", "E501", "E741", "F821", "F841"]
114
+ ignore = ["E402", "E501", "E741", "F841"]
115
115
  per-file-ignores = {"src/brainlayer/cli/__init__.py" = ["F401"]}
116
116
 
117
117
  [tool.pytest.ini_options]
@@ -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.0",
6
+ "version": "1.6.1",
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.0",
17
+ "version": "1.6.1",
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.0"
5
+ __version__ = "1.6.1"
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 = "0a33f0dda7828df58af5f5641bd2dbf0486ce0ac"
@@ -54,12 +54,14 @@ KNOWN_AGENTS: tuple[KnownAgent, ...] = (
54
54
  KnownAgent(
55
55
  "cursor-agent", ("cursor-agent",), ("cursor-agent",), ((".cursor/projects", "*/agent-transcripts/*.jsonl"),)
56
56
  ),
57
- # Gemini CLI saves chats as tmp/<project-hash>/chats/session-*.json, not under sessions/.
57
+ # Antigravity (agy), the current Gemini agent: the `agy` CLI, or T3's agy ACP server. It exports each
58
+ # conversation to brain/<conversation>/.system_generated/logs/transcript_full.jsonl. Gemini CLI is
59
+ # legacy and deprecated and is not listed.
58
60
  KnownAgent(
59
61
  "gemini",
60
- ("gemini",),
61
- ("gemini", "@google/gemini-cli/"),
62
- ((".gemini/tmp", "*/chats/session-*.json"), (".gemini/sessions", "*.jsonl")),
62
+ ("agy", "agy_acp_server.par"),
63
+ (),
64
+ ((".gemini/antigravity-cli/brain", "*/.system_generated/logs/transcript_full.jsonl"),),
63
65
  ),
64
66
  KnownAgent("opencode", ("opencode",), ("opencode", "opencode-ai/"), ((".local/share/opencode/storage", "*.json"),)),
65
67
  )
@@ -14,8 +14,9 @@ from dataclasses import dataclass
14
14
  from pathlib import Path
15
15
  from typing import Literal, cast
16
16
 
17
+ from .agy_attribution import agy_conversation, read_conversation_agent
17
18
  from .content_class import normalize_content_class
18
- from .ingest_denylist import is_denylisted, memory_reader_attribution
19
+ from .ingest_denylist import MEMORY_READER_ATTRIBUTIONS, is_denylisted, memory_reader_attribution
19
20
  from .t3_provenance import T3_APP_SESSION, CompactCodexHeader, is_t3_app_initiated_codex_session
20
21
 
21
22
  SearchPolicy = Literal["KEEP", "ISOLATE", "OUT"]
@@ -107,6 +108,12 @@ def _under_cursor_agent_transcripts(path: Path) -> bool:
107
108
  return "agent-transcripts" in parts[cursor_index + 1 :]
108
109
 
109
110
 
111
+ def _under_agy_brain(path: Path) -> bool:
112
+ """Under `.gemini/antigravity-cli/brain/<conversation>/`, where Antigravity (agy), the current Gemini
113
+ agent, exports transcripts."""
114
+ return agy_conversation(path) is not None
115
+
116
+
110
117
  def _project_segment(path: Path) -> str | None:
111
118
  parts = path.parts
112
119
  for index, part in enumerate(parts[:-1]):
@@ -180,8 +187,13 @@ def classify_provenance(
180
187
  t3_projection_version: int | None = None,
181
188
  t3_session_identity_cache: dict | None = None,
182
189
  t3_session_header: tuple[dict, int] | CompactCodexHeader | None = None,
190
+ agy_agent: str | None = None,
183
191
  ) -> ProvenanceDecision:
184
- """Classify a source path into an auditable provenance search policy."""
192
+ """Classify a source path into an auditable provenance search policy.
193
+
194
+ `agy_agent` is the agent an AgyAttributionGate resolved for an agy conversation; without it the
195
+ summary row is read here, and an unreadable or absent row leaves the source class unresolved.
196
+ """
185
197
  del content_class
186
198
  path = _abspath(source_file)
187
199
 
@@ -213,6 +225,18 @@ def classify_provenance(
213
225
  if _under_cursor_agent_transcripts(path):
214
226
  return ProvenanceDecision("cursor-gather", "KEEP", "Cursor coding-agent transcript root", "cli-agent")
215
227
 
228
+ if _under_agy_brain(path):
229
+ agent = agy_agent
230
+ if agent is None:
231
+ read_ok, agent = read_conversation_agent(path)
232
+ if not read_ok or agent is None:
233
+ return ProvenanceDecision("gemini-session", "KEEP", "agy attribution unresolved", None)
234
+ if agent in MEMORY_READER_ATTRIBUTIONS:
235
+ return ProvenanceDecision("recon-agent", "OUT", f"agy memory-reader agent {agent}", "brain-worker")
236
+ if agent:
237
+ return ProvenanceDecision("gemini-subagent", "KEEP", f"agy agent {agent}", "subagent")
238
+ return ProvenanceDecision("gemini-session", "KEEP", "Antigravity (agy) conversation", "cli-agent")
239
+
216
240
  if _under_provider_sessions(path, ".gemini"):
217
241
  return ProvenanceDecision("gemini-session", "KEEP", "Gemini session root stays searchable", "cli-agent")
218
242
 
@@ -247,6 +271,7 @@ def derive_source_class(
247
271
  "codex-session": "cli-agent",
248
272
  "cursor-gather": "cli-agent",
249
273
  "gemini-session": "cli-agent",
274
+ "gemini-subagent": "subagent",
250
275
  "direct-session": "cli-agent",
251
276
  }
252
277
  if provenance_class in provenance_map:
@@ -0,0 +1,188 @@
1
+ """Which agent an Antigravity (agy) conversation ran as, decided before any of it is indexed.
2
+
3
+ agy, the current Gemini agent, records `agy --agent <name>` per conversation in its own
4
+ `~/.gemini/antigravity-cli/conversation_summaries.db` (`agent_name`). That row is the only
5
+ attribution read; task text never is. The gate fails closed so a memory reader is never indexed
6
+ as an interactive session:
7
+
8
+ * a row exists: index under that agent ("" = no agent); a memory reader is classed brain-worker
9
+ downstream and never indexed;
10
+ * the DB was read and the row is absent: hold until `AGY_ATTRIBUTION_WAIT_S` after the FIRST time
11
+ the conversation was seen unresolved (persisted, so restarts and appends do not extend it), then
12
+ index with no agent;
13
+ * the DB could not be read: hold, retry on the next flush, and alarm `agy_attribution_unreadable`.
14
+
15
+ One race remains: a conversation indexed after its deadline whose row later names a memory reader.
16
+ Its later turns are not indexed, and the conversation is recorded under `late_memory_readers` in the
17
+ state file; chunks already written are not deleted.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ import json
23
+ import logging
24
+ import os
25
+ import sqlite3
26
+ import tempfile
27
+ import time
28
+ from pathlib import Path
29
+ from typing import Any
30
+
31
+ from .alarm import BrainLayerAlarm, raise_alarm
32
+ from .ingest_denylist import MEMORY_READER_ATTRIBUTIONS
33
+
34
+ logger = logging.getLogger(__name__)
35
+
36
+ AGY_ATTRIBUTION_WAIT_S = 600.0
37
+ # State entries older than this are dropped. fallback_indexed only saves re-deciding a conversation;
38
+ # a re-decision is idempotent (content-hash chunk ids), it only holds new turns for one more deadline.
39
+ STATE_MAX_AGE_S = 30 * 24 * 3600.0
40
+ STATE_FILE_NAME = "agy-attribution.json"
41
+ _cache: dict[str, tuple[tuple[int, ...], dict[str, str]]] = {}
42
+
43
+
44
+ def _now() -> float:
45
+ return time.time()
46
+
47
+
48
+ def agy_conversation(source_file: str | Path) -> tuple[Path, str] | None:
49
+ """(summaries DB, conversation id) for a file under `.gemini/antigravity-cli/brain/<conversation>/`."""
50
+ parts = Path(os.path.abspath(os.path.expanduser(str(source_file)))).parts
51
+ for index, part in enumerate(parts[:-3]):
52
+ if part == ".gemini" and parts[index + 1 : index + 3] == ("antigravity-cli", "brain"):
53
+ return Path(*parts[: index + 2], "conversation_summaries.db"), parts[index + 3]
54
+ return None
55
+
56
+
57
+ def read_conversation_agent(source_file: str | Path) -> tuple[bool, str | None]:
58
+ """(read ok, agent name or None when the row is absent). A failed read is never cached."""
59
+ located = agy_conversation(source_file)
60
+ if located is None:
61
+ return True, None
62
+ store, conversation = located
63
+ signature: list[int] = []
64
+ for candidate in (store, store.with_name(store.name + "-wal")):
65
+ try:
66
+ stat = candidate.stat()
67
+ signature += [stat.st_mtime_ns, stat.st_size]
68
+ except OSError:
69
+ signature += [0, 0]
70
+ cached = _cache.get(str(store))
71
+ if cached is not None and cached[0] == tuple(signature):
72
+ return True, cached[1].get(conversation)
73
+ try:
74
+ conn = sqlite3.connect(f"file:{store}?mode=ro", uri=True, timeout=1.0)
75
+ try:
76
+ agents = {
77
+ str(row_id): str(agent or "")
78
+ for row_id, agent in conn.execute("SELECT conversation_id, agent_name FROM conversation_summaries")
79
+ }
80
+ finally:
81
+ conn.close()
82
+ except (sqlite3.Error, OSError) as error:
83
+ logger.warning("agy attribution unreadable: %s: %s", store, error)
84
+ return False, None
85
+ _cache[str(store)] = (tuple(signature), agents)
86
+ return True, agents.get(conversation)
87
+
88
+
89
+ class AgyAttributionGate:
90
+ """Decides, per agy conversation, whether its turns may be indexed now and as which agent."""
91
+
92
+ def __init__(self, state_path: str | Path):
93
+ self.state_path = Path(state_path)
94
+ self._alarmed: set[str] = set()
95
+ self.state: dict[str, dict[str, Any]] = {"first_seen": {}, "fallback_indexed": {}, "late_memory_readers": {}}
96
+ try:
97
+ loaded = json.loads(self.state_path.read_text(encoding="utf-8"))
98
+ except (OSError, ValueError):
99
+ loaded = {}
100
+ for key in self.state:
101
+ if isinstance(loaded, dict) and isinstance(loaded.get(key), dict):
102
+ self.state[key] = dict(loaded[key])
103
+
104
+ def _prune(self) -> None:
105
+ """Drop entries whose transcript is gone, and first_seen/fallback_indexed entries past STATE_MAX_AGE_S."""
106
+ cutoff = _now() - STATE_MAX_AGE_S
107
+ for section, ages in (("first_seen", True), ("fallback_indexed", True), ("late_memory_readers", False)):
108
+ kept = {}
109
+ for conversation, entry in self.state[section].items():
110
+ if not isinstance(entry, dict):
111
+ continue
112
+ path, at = entry.get("path"), entry.get("at")
113
+ if not isinstance(path, str) or not os.path.exists(path):
114
+ continue
115
+ if ages and (not isinstance(at, (int, float)) or at < cutoff):
116
+ continue
117
+ kept[conversation] = entry
118
+ self.state[section] = kept
119
+
120
+ def save(self) -> None:
121
+ """Prune, then replace the state file atomically (unique temp file, fsync, rename)."""
122
+ self._prune()
123
+ self.state_path.parent.mkdir(parents=True, exist_ok=True)
124
+ fd, temp = tempfile.mkstemp(dir=self.state_path.parent, prefix=f".{self.state_path.name}.")
125
+ try:
126
+ with os.fdopen(fd, "w", encoding="utf-8") as handle:
127
+ json.dump(self.state, handle, indent=2, sort_keys=True)
128
+ handle.flush()
129
+ os.fsync(handle.fileno())
130
+ os.replace(temp, self.state_path)
131
+ except BaseException:
132
+ Path(temp).unlink(missing_ok=True)
133
+ raise
134
+
135
+ def _entry(self, source_file: str | Path, **extra: Any) -> dict[str, Any]:
136
+ return {"at": _now(), "path": os.path.abspath(os.path.expanduser(str(source_file))), **extra}
137
+
138
+ def resolve(self, source_file: str | Path) -> tuple[bool, str | None]:
139
+ """(index now, agent): agent is the row's agent_name, "" after the deadline, None while held."""
140
+ located = agy_conversation(source_file)
141
+ if located is None:
142
+ return True, None
143
+ store, conversation = located
144
+ read_ok, agent = read_conversation_agent(source_file)
145
+ if not read_ok or agent is None:
146
+ # The deadline counts from the first unresolved sighting, readable or not.
147
+ first_seen = self.state["first_seen"].get(conversation)
148
+ if not isinstance(first_seen, dict):
149
+ self.state["first_seen"][conversation] = first_seen = self._entry(source_file)
150
+ self.save()
151
+ if not read_ok:
152
+ if str(store) not in self._alarmed:
153
+ self._alarmed.add(str(store))
154
+ try:
155
+ raise_alarm(
156
+ "agy_attribution_unreadable",
157
+ "agy conversations are held: their agent attribution could not be read",
158
+ {"store": str(store), "conversation": conversation},
159
+ severity="warning",
160
+ )
161
+ except BrainLayerAlarm:
162
+ pass
163
+ return False, None
164
+ self._alarmed.discard(str(store))
165
+ if agent is not None:
166
+ changed = self.state["first_seen"].pop(conversation, None) is not None
167
+ if (
168
+ agent in MEMORY_READER_ATTRIBUTIONS
169
+ and conversation in self.state["fallback_indexed"]
170
+ and conversation not in self.state["late_memory_readers"]
171
+ ):
172
+ logger.warning(
173
+ "agy conversation %s was indexed after its attribution deadline and is now named "
174
+ "memory reader %r; no further turns are indexed, existing chunks are kept",
175
+ conversation,
176
+ agent,
177
+ )
178
+ self.state["late_memory_readers"][conversation] = self._entry(source_file, agent=agent)
179
+ changed = True
180
+ if changed:
181
+ self.save()
182
+ return True, agent
183
+ if _now() - float(first_seen["at"]) < AGY_ATTRIBUTION_WAIT_S:
184
+ return False, None
185
+ if conversation not in self.state["fallback_indexed"]:
186
+ self.state["fallback_indexed"][conversation] = self._entry(source_file)
187
+ self.save()
188
+ return True, ""
@@ -1220,10 +1220,17 @@ def dashboard() -> None:
1220
1220
  app.run()
1221
1221
 
1222
1222
  except ImportError as e:
1223
- rprint(f"[red]Dashboard dependencies missing: {e}[/]")
1224
- rprint("[yellow]Install with: pip install -e .[dev][/]")
1223
+ # The wheel and sdist exclude src/brainlayer/dashboard on purpose
1224
+ # (tests/test_engine_package_boundary.py), so an installed BrainLayer never has it.
1225
+ rprint(f"[red]Dashboard unavailable: {e}[/]")
1226
+ rprint(
1227
+ "[yellow]The dashboard ships only in a source checkout: in a BrainLayer clone, "
1228
+ "run `pip install -e .`, then `brainlayer dashboard`.[/]"
1229
+ )
1230
+ raise typer.Exit(1) from e
1225
1231
  except Exception as e:
1226
1232
  rprint(f"[red]Dashboard error: {e}[/]")
1233
+ raise typer.Exit(1) from e
1227
1234
 
1228
1235
 
1229
1236
  @app.command()
@@ -536,12 +536,6 @@ Now output exactly one JSON object matching the required keys. Do not copy JSON
536
536
  """
537
537
 
538
538
 
539
- def _apply_chat_template(tokenizer: Any, prompt: str) -> str:
540
- apply_template = getattr(tokenizer, "apply_chat_template", None)
541
- if apply_template is None:
542
- return prompt
543
-
544
-
545
539
  def _normalize_enrichment_for_benchmark(enrichment: Mapping[str, Any]) -> dict[str, Any]:
546
540
  result = dict(enrichment)
547
541
  if isinstance(result.get("importance"), float) and math.isfinite(result["importance"]):
@@ -557,21 +551,6 @@ def _normalize_enrichment_for_benchmark(enrichment: Mapping[str, Any]) -> dict[s
557
551
  if "version_scope" not in result:
558
552
  result["version_scope"] = None
559
553
  return result
560
- try:
561
- rendered = apply_template(
562
- [
563
- {
564
- "role": "system",
565
- "content": "You are a strict JSON enrichment function. You output only valid JSON.",
566
- },
567
- {"role": "user", "content": prompt},
568
- ],
569
- tokenize=False,
570
- add_generation_prompt=True,
571
- )
572
- return rendered if isinstance(rendered, str) else prompt
573
- except Exception:
574
- return prompt
575
554
 
576
555
 
577
556
  def _connect_readonly(db_path: str | Path) -> sqlite3.Connection:
@@ -9,6 +9,7 @@ The policy that turns these facts into the dot lives in ``health_verdict``.
9
9
  from __future__ import annotations
10
10
 
11
11
  import json
12
+ import math
12
13
  import os
13
14
  import sqlite3
14
15
  import sys
@@ -168,15 +169,60 @@ def drive_auth_fact(
168
169
  return max(known, key=lambda event: event[0])[1] if known else "ok"
169
170
 
170
171
 
171
- def watcher_fact(path: Path) -> datetime | None:
172
+ WATCHER_STALL_REASONS = ("coverage_drop", "offset_lag", "file_ingestion_failure")
173
+ WATCHER_DB_PROBE_GRACE_S = 300.0
174
+
175
+
176
+ def _is_number(value: Any) -> bool:
177
+ return isinstance(value, (int, float)) and not isinstance(value, bool) and math.isfinite(value)
178
+
179
+
180
+ def watcher_stall_codes(payload: Mapping[str, Any]) -> Any:
181
+ """Stall signals the watcher published, or UNOBSERVED when any field behind them is absent or
182
+ malformed (an absent signal is not evidence that nothing is stalled).
183
+
184
+ Codes: its debounced alerts, a DB probe failing for ``WATCHER_DB_PROBE_GRACE_S`` (one failed
185
+ probe is a momentary lock), and missing roots. The probe duration must be a finite number >= 0,
186
+ and 0 while the probe is not failing; ``poll_count`` (the snapshot's identity) must be an int >= 0.
187
+ """
188
+ reasons, probe, probe_for, roots, polls = (
189
+ payload.get(k)
190
+ for k in ("alert_reasons", "db_probe_failed", "db_probe_failed_for_s", "roots_missing", "poll_count")
191
+ )
192
+ if not (
193
+ isinstance(reasons, list)
194
+ and all(isinstance(r, str) for r in reasons)
195
+ and isinstance(probe, bool)
196
+ and _is_number(probe_for)
197
+ and probe_for >= 0
198
+ and (probe or probe_for == 0)
199
+ and isinstance(roots, list)
200
+ and all(isinstance(r, str) for r in roots)
201
+ and isinstance(polls, int)
202
+ and not isinstance(polls, bool)
203
+ and polls >= 0
204
+ ):
205
+ return UNOBSERVED
206
+ codes = [r for r in WATCHER_STALL_REASONS if r in reasons]
207
+ if probe and probe_for >= WATCHER_DB_PROBE_GRACE_S:
208
+ codes.append("db_probe_failed")
209
+ return tuple(codes + [f"root_missing:{r}" for r in roots])
210
+
211
+
212
+ def watcher_health_fact(path: Path) -> tuple[datetime | None, Any, Any]:
213
+ """(heartbeat, stall codes, poll_count) from one read of watcher-health.json; missing = (None, (), None).
214
+
215
+ poll_count is None unless the stall codes are observed (they validate it).
216
+ """
172
217
  try:
173
218
  payload = json.loads(path.expanduser().read_text(encoding="utf-8"))
174
219
  except FileNotFoundError:
175
- return None
220
+ return None, (), None
176
221
  updated = _aware(payload.get("updated_at")) if isinstance(payload, dict) else None
177
222
  if updated is None:
178
223
  raise ValueError("watcher-health.json has no updated_at")
179
- return updated
224
+ codes = watcher_stall_codes(payload)
225
+ return updated, codes, None if codes is UNOBSERVED else payload["poll_count"]
180
226
 
181
227
 
182
228
  def first_pending_store(pending_path: Path) -> datetime | None:
@@ -517,7 +563,7 @@ def collect_facts(
517
563
  "backup": backup_job,
518
564
  "transcripts": lambda: transcript_facts(read_receipts(config.jsonl_backup_log_path)),
519
565
  "drive_token": lambda: read_drive_token(config.drive_token_path or resolve_paths()[0]),
520
- "watcher": lambda: watcher_fact(config.watcher_health_path),
566
+ "watcher": lambda: watcher_health_fact(config.watcher_health_path),
521
567
  "pause": lambda: pause_sentinel_state(config.pause_sentinel_path, now),
522
568
  "drain": lambda: json.loads(config.drain_health_path.expanduser().read_text(encoding="utf-8")),
523
569
  "replay": lambda: first_pending_store(config.pending_stores_path),
@@ -609,6 +655,9 @@ def collect_facts(
609
655
  boot = got["boot"]
610
656
  boot_session = boot.stdout.strip() if getattr(boot, "returncode", None) == 0 else None
611
657
  awake_clock = awake_sample if boot_session else None
658
+ heartbeat, stall_codes, poll_count = (
659
+ got["watcher"] if got["watcher"] is not UNOBSERVED else (UNOBSERVED, UNOBSERVED, None)
660
+ )
612
661
  facts = Facts(
613
662
  now=now,
614
663
  awake_clock_s=awake_clock,
@@ -616,7 +665,9 @@ def collect_facts(
616
665
  **backup_kwargs,
617
666
  transcripts_verified_at=transcripts[0] if transcripts is not UNOBSERVED else UNOBSERVED,
618
667
  drive_auth=drive_auth,
619
- watcher_updated_at=got["watcher"],
668
+ watcher_updated_at=heartbeat,
669
+ watcher_stall_codes=stall_codes,
670
+ watcher_poll_count=poll_count,
620
671
  ingest_paused=paused(config.watch_label),
621
672
  unindexed_agents=tuple(result.unindexed_agents) if result.unindexed_agents is not None else UNOBSERVED,
622
673
  census_incomplete=tuple(result.agent_census_incomplete),
@@ -70,6 +70,7 @@ class Thresholds:
70
70
  embedding_red_s: float = 6 * HOURS
71
71
  canary_red_failures: int = 3
72
72
  unknown_amber_ticks: int = 3
73
+ ingest_alert_red_ticks: int = 6
73
74
  recovery_good_ticks: int = 2
74
75
  sleep_gap_s: float = 15 * 60
75
76
  wake_grace_s: float = 2 * HOURS
@@ -113,6 +114,11 @@ class Facts:
113
114
  drive_auth: Any = UNOBSERVED # "ok" | "refresh_failed" | "consent_needed"
114
115
  integrity: Any = UNOBSERVED # "ok" | "corrupt" (confirmed results only)
115
116
  watcher_updated_at: Any = UNOBSERVED
117
+ # Stall codes from the same watcher-health.json read; collect_facts passes UNOBSERVED for an
118
+ # incomplete or malformed payload. () is the default so callers that predate the codes keep
119
+ # heartbeat-only behaviour.
120
+ watcher_stall_codes: Any = ()
121
+ watcher_poll_count: int | None = None # with updated_at, the identity of the snapshot read
116
122
  ingest_paused: bool = False
117
123
  unindexed_agents: Any = UNOBSERVED # ("<agent>: <root>", ...) found by the known-agent census this check
118
124
  census_incomplete: tuple[str, ...] = () # agents the census could not measure this check
@@ -371,6 +377,51 @@ def _drive_auth(drive: Any, prior: Mapping[str, Any]) -> _Raw:
371
377
  return _Raw(AMBER, "token refresh failed; retrying", keep={"lost": False})
372
378
 
373
379
 
380
+ @dataclass
381
+ class _Stall:
382
+ read: bool # a valid stall reading arrived with an observed heartbeat this check
383
+ state: str | None
384
+ note: str
385
+ keep: dict[str, Any]
386
+
387
+
388
+ def _ingest_stall(facts: Facts, before: Mapping[str, Any], watcher: datetime | None, t: Thresholds) -> _Stall:
389
+ """The watcher's stall codes as a severity, counted once per new snapshot.
390
+
391
+ Each new snapshot carrying a code is one more alert check. A snapshot is new when its
392
+ updated_at or poll_count changed (changed, not increased: a backwards clock correction still
393
+ counts); a re-read frozen file is not a new check and keeps the count. Codes UNOBSERVED (an incomplete or malformed payload,
394
+ or no read) are never a no-stall reading: the count holds and a blind streak runs, which
395
+ turns amber after ``unknown_amber_ticks`` like any unknown.
396
+ """
397
+ ticks = int(before.get("alert_ticks") or 0)
398
+ seen = before.get("alert_seen")
399
+ blind = int(before.get("stall_blind_ticks") or 0)
400
+ codes = facts.watcher_stall_codes
401
+ read = watcher is not None and isinstance(codes, tuple)
402
+ if read:
403
+ blind = 0
404
+ if facts.stores_paused:
405
+ codes = tuple(c for c in codes if c != "coverage_drop") # the paused drain writes nothing
406
+ snapshot = [watcher.astimezone(UTC).isoformat(), facts.watcher_poll_count]
407
+ if seen != snapshot:
408
+ ticks, seen = (ticks + 1 if codes else 0), snapshot
409
+ elif not isinstance(codes, tuple):
410
+ blind += 1
411
+ keep: dict[str, Any] = {}
412
+ if ticks:
413
+ keep.update(alert_ticks=ticks, alert_seen=seen)
414
+ if blind:
415
+ keep["stall_blind_ticks"] = blind
416
+ if ticks:
417
+ what = ", ".join(codes) if read and codes else "a stall"
418
+ state = RED if ticks >= t.ingest_alert_red_ticks else AMBER
419
+ return _Stall(read, state, f"watcher reports {what} ({ticks} checks in a row)", keep)
420
+ if blind >= t.unknown_amber_ticks:
421
+ return _Stall(read, AMBER, f"watcher stall signals unreadable ({blind} checks in a row)", keep)
422
+ return _Stall(read, None, "", keep)
423
+
424
+
374
425
  def _raw_checks(
375
426
  facts: Facts,
376
427
  prior: Mapping[str, Mapping[str, Any]],
@@ -429,8 +480,9 @@ def _raw_checks(
429
480
  watcher = _aware(facts.watcher_updated_at)
430
481
  persisted = _parse(p("ingest").get("clock"))
431
482
  clock = max((x for x in (watcher, persisted) if x is not None), default=None)
483
+ stall = _ingest_stall(facts, p("ingest"), watcher, t)
432
484
  if clock is None:
433
- raw["ingest"] = _Raw(UNKNOWN, "watcher heartbeat not observed", threshold_s=t.ingest_red_s, evidence=False)
485
+ r = _Raw(UNKNOWN, "watcher heartbeat not observed", threshold_s=t.ingest_red_s, evidence=False)
434
486
  else:
435
487
  r = _graced_age(
436
488
  clock,
@@ -443,12 +495,17 @@ def _raw_checks(
443
495
  True,
444
496
  t.wake_grace_s,
445
497
  )
446
- r.evidence = r.evidence and watcher is not None # an observed heartbeat, fresh by its real age
498
+ r.evidence = r.evidence and watcher is not None and stall.read # observed heartbeat AND stall reading
447
499
  if watcher is None:
448
500
  r.note = f"watcher heartbeat not observed; {r.note}"
501
+ if stall.state is not None:
502
+ if _RANK[stall.state] > _RANK[r.state]:
503
+ r.state, r.amber_s = stall.state, None
504
+ r.note = "; ".join(x for x in (r.note, stall.note) if x)
449
505
  if facts.ingest_paused and r.state == RED:
450
506
  r.state, r.note = AMBER, r.note + " (watcher paused by maintenance)"
451
- raw["ingest"] = r
507
+ r.keep.update(stall.keep)
508
+ raw["ingest"] = r
452
509
  # Known-agent census: only a measured census replaces the last one; an unmeasured tick holds it.
453
510
  prior_census = p("ingest").get("census")
454
511
  prior_census = list(prior_census) if isinstance(prior_census, list) else None
@@ -1297,11 +1297,9 @@ class KGMixin:
1297
1297
  cursor = self._read_cursor()
1298
1298
 
1299
1299
  rel_filter = ""
1300
- params: list = [entity_id, max_depth]
1301
1300
  if relation_types:
1302
1301
  placeholders = ", ".join("?" for _ in relation_types)
1303
1302
  rel_filter = f"AND r.relation_type IN ({placeholders})"
1304
- params = [entity_id] + relation_types + [max_depth]
1305
1303
 
1306
1304
  if relation_types:
1307
1305
  query = f"""
@@ -1323,7 +1321,8 @@ class KGMixin:
1323
1321
  WHERE r.depth > 0
1324
1322
  ORDER BY r.depth, e.name
1325
1323
  """
1326
- params_list = [entity_id, entity_id] + relation_types + [max_depth]
1324
+ # Placeholder order: seed id, path seed, depth bound (WHERE re.depth < ?), then rel_filter.
1325
+ params_list = [entity_id, entity_id, max_depth] + relation_types
1327
1326
  else:
1328
1327
  query = """
1329
1328
  WITH RECURSIVE reachable(entity_id, depth, path) AS (
@@ -6,10 +6,13 @@ This module contains no model transport or producer entry point.
6
6
  import logging
7
7
  import os
8
8
  import threading
9
- from typing import Any, Dict, List, Optional
9
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional
10
10
 
11
11
  from ..tag_normalization import enrichment_tag_mode
12
12
 
13
+ if TYPE_CHECKING:
14
+ from .sanitize import Sanitizer, SanitizeResult
15
+
13
16
  logger = logging.getLogger(__name__)
14
17
 
15
18