brainlayer 1.6.16__tar.gz → 1.6.17__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 (299) hide show
  1. {brainlayer-1.6.16 → brainlayer-1.6.17}/PKG-INFO +1 -1
  2. {brainlayer-1.6.16 → brainlayer-1.6.17}/pyproject.toml +1 -1
  3. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/brainbar-update.sh +4 -0
  4. {brainlayer-1.6.16 → brainlayer-1.6.17}/server.json +2 -2
  5. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/__init__.py +1 -1
  6. brainlayer-1.6.17/src/brainlayer/_build.py +1 -0
  7. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/backup_daily.py +234 -14
  8. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/backup_heavy_gate.py +78 -24
  9. brainlayer-1.6.16/src/brainlayer/_build.py +0 -1
  10. {brainlayer-1.6.16 → brainlayer-1.6.17}/.gitignore +0 -0
  11. {brainlayer-1.6.16 → brainlayer-1.6.17}/LICENSE +0 -0
  12. {brainlayer-1.6.16 → brainlayer-1.6.17}/README.md +0 -0
  13. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/brainlayer-version-check.sh +0 -0
  14. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/hotlane_brainbar_daemon.py +0 -0
  15. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/backup-daily.sh +0 -0
  16. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/brainlayer-env-run.sh +0 -0
  17. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/brainlayer.env.example +0 -0
  18. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.backup-daily.plist +0 -0
  19. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.daemon.plist +0 -0
  20. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.decay.plist +0 -0
  21. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.drain.plist +0 -0
  22. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.health-check.plist +0 -0
  23. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.hotlane-brainbar.plist +0 -0
  24. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.index.plist +0 -0
  25. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.jsonl-backup.plist +0 -0
  26. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.log-cap.plist +0 -0
  27. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.maintenance-nightly.plist +0 -0
  28. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.maintenance-weekly.plist +0 -0
  29. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.maintenance.plist +0 -0
  30. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.observability.plist +0 -0
  31. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.p0-counter.plist +0 -0
  32. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.repair-fts.plist +0 -0
  33. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.t3-audit.plist +0 -0
  34. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.t3-ingest.plist +0 -0
  35. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.throughput-watchdog.plist +0 -0
  36. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.tier0-watchdog.plist +0 -0
  37. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.wal-checkpoint.plist +0 -0
  38. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.brainlayer.watch.plist +0 -0
  39. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/com.etanhey.brainlayer-fleet-watchdog.plist +0 -0
  40. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/fleet-watchdog.sh +0 -0
  41. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/install.sh +0 -0
  42. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/jsonl-backup.sh +0 -0
  43. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/launchd/throughput-watchdog.py +0 -0
  44. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/release-verify-signatures.sh +0 -0
  45. {brainlayer-1.6.16 → brainlayer-1.6.17}/scripts/tier0-watchdog.sh +0 -0
  46. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/__main__.py +0 -0
  47. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/_helpers.py +0 -0
  48. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/agent_census.py +0 -0
  49. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/agent_profiles.py +0 -0
  50. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/agent_provenance.py +0 -0
  51. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/agy_attribution.py +0 -0
  52. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/alarm.py +0 -0
  53. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/archive_collapse.py +0 -0
  54. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/archive_lifecycle.py +0 -0
  55. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/backup_clone.py +0 -0
  56. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/backup_retention.py +0 -0
  57. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/backup_retention_invariant.py +0 -0
  58. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/backup_retention_observation.py +0 -0
  59. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/backup_sleep.py +0 -0
  60. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/badge_state.py +0 -0
  61. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/bitemporal.py +0 -0
  62. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/brainbar_activation.py +0 -0
  63. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/brainbar_auto_activation.py +0 -0
  64. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/brainbar_hybrid_helper.py +0 -0
  65. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/brainbar_identity.py +0 -0
  66. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/cachedelete_purge.swift +0 -0
  67. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/calibrate.py +0 -0
  68. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/chunk_origin.py +0 -0
  69. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/chunk_origin_backfill.py +0 -0
  70. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/chunk_origin_wipe.py +0 -0
  71. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/chunk_write.py +0 -0
  72. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/classify.py +0 -0
  73. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/claude_paths.py +0 -0
  74. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/cli/__init__.py +0 -0
  75. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/cli/wizard.py +0 -0
  76. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/cli_jobs.py +0 -0
  77. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/cli_new.py +0 -0
  78. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/cloud_backfill.py +0 -0
  79. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/clustering.py +0 -0
  80. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/codex_zst.py +0 -0
  81. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/component_jobs.py +0 -0
  82. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/config.py +0 -0
  83. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/consolidation_plan.py +0 -0
  84. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/content_class.py +0 -0
  85. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/content_hash_repair.py +0 -0
  86. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/correction_judge.py +0 -0
  87. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/data/agents_registry.yaml +0 -0
  88. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/data/sandbox_seeds/skill-eval-baseline.json +0 -0
  89. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/db_shrink.py +0 -0
  90. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/decay.py +0 -0
  91. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/decay_backfill.py +0 -0
  92. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/decay_job.py +0 -0
  93. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/dedupe.py +0 -0
  94. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/dedupe_merge.py +0 -0
  95. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/deploy_drift.py +0 -0
  96. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/disk_space.py +0 -0
  97. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/doctor.py +0 -0
  98. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/drain.py +0 -0
  99. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/drain_liveness.py +0 -0
  100. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/drive_credentials.py +0 -0
  101. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/embeddings.py +0 -0
  102. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/engine.py +0 -0
  103. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/enrichment_replay.py +0 -0
  104. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/__init__.py +0 -0
  105. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/abcde_enrich_runner.py +0 -0
  106. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/abcde_variants.py +0 -0
  107. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/abcde_variants.yaml +0 -0
  108. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/benchmark.py +0 -0
  109. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/enrichment_gold.py +0 -0
  110. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/enrichment_graders.py +0 -0
  111. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/enrichment_judge.py +0 -0
  112. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/enrichment_llm_judge.py +0 -0
  113. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/enrichment_quality_benchmark.py +0 -0
  114. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/experiment_store.py +0 -0
  115. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/fixtures/README.md +0 -0
  116. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/labeling/enrichment-labeler.html +0 -0
  117. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/phoenix_gate/__init__.py +0 -0
  118. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/phoenix_gate/__main__.py +0 -0
  119. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/phoenix_gate/baseline_store.py +0 -0
  120. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/phoenix_gate/cli.py +0 -0
  121. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/phoenix_gate/models.py +0 -0
  122. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/phoenix_gate/phoenix_client.py +0 -0
  123. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/phoenix_gate/regression_gate.py +0 -0
  124. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/phoenix_gate/triggers.py +0 -0
  125. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/eval/pilot_artifact_report.py +0 -0
  126. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/fallback_replay.py +0 -0
  127. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/git_learning.py +0 -0
  128. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/health_check.py +0 -0
  129. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/health_facts.py +0 -0
  130. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/health_verdict.py +0 -0
  131. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/hook_python.py +0 -0
  132. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/hooks/__init__.py +0 -0
  133. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/hooks/indexer.py +0 -0
  134. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/hotlane_budget.py +0 -0
  135. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/import_sweep.py +0 -0
  136. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/index_admission.py +0 -0
  137. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/index_budget.py +0 -0
  138. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/index_completeness.py +0 -0
  139. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/index_new.py +0 -0
  140. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/index_watchdog.py +0 -0
  141. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/ingest/__init__.py +0 -0
  142. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/ingest/codex.py +0 -0
  143. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/ingest/codex_manifest.py +0 -0
  144. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/ingest/t3.py +0 -0
  145. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/ingest/t3_audit.py +0 -0
  146. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/ingest/t3_bookmark.py +0 -0
  147. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/ingest/t3_ownership.py +0 -0
  148. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/ingest_denylist.py +0 -0
  149. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/ingest_guard.py +0 -0
  150. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/isolation_proof.py +0 -0
  151. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/job_alerts.py +0 -0
  152. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/job_lifecycle_health.py +0 -0
  153. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/jobs.py +0 -0
  154. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/jsonl_backup.py +0 -0
  155. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/kg/__init__.py +0 -0
  156. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/kg_cleanup.py +0 -0
  157. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/kg_judge.py +0 -0
  158. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/kg_promotion.py +0 -0
  159. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/kg_repo.py +0 -0
  160. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/kg_review_session.py +0 -0
  161. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/kg_session_finish.py +0 -0
  162. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/kg_session_harvest.py +0 -0
  163. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/launchd_consolidation.py +0 -0
  164. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/launchd_install.py +0 -0
  165. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/launchd_primitive.py +0 -0
  166. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/launchd_revert.py +0 -0
  167. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/launcher_policy_reconcile.py +0 -0
  168. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/lexical_defense.py +0 -0
  169. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/lexical_defense_dictionary.json +0 -0
  170. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/linkedin_import.py +0 -0
  171. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/log_cap.py +0 -0
  172. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/maintenance.py +0 -0
  173. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/maintenance_calendar.py +0 -0
  174. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/maintenance_control.py +0 -0
  175. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/maintenance_upload_recovery.py +0 -0
  176. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp/__init__.py +0 -0
  177. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp/_format.py +0 -0
  178. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp/_shared.py +0 -0
  179. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp/enrich_handler.py +0 -0
  180. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp/entity_handler.py +0 -0
  181. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp/palette.py +0 -0
  182. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp/search_handler.py +0 -0
  183. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp/store_handler.py +0 -0
  184. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp/tags_handler.py +0 -0
  185. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp_socket_config.py +0 -0
  186. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/mcp_stdio_bridge.py +0 -0
  187. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/memory_types.py +0 -0
  188. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/migrate.py +0 -0
  189. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/migration_custody.py +0 -0
  190. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/migration_journal.py +0 -0
  191. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/migration_runtime.py +0 -0
  192. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/notification_policy.py +0 -0
  193. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/observability_backup.py +0 -0
  194. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/observability_indexes.py +0 -0
  195. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/observability_surface.py +0 -0
  196. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/observability_transport.py +0 -0
  197. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/p0_longitudinal_count.py +0 -0
  198. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/parent_death.py +0 -0
  199. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/paths.py +0 -0
  200. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pause.py +0 -0
  201. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/phonetic.py +0 -0
  202. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/__init__.py +0 -0
  203. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/agent_enrichment.py +0 -0
  204. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/analyze_communication.py +0 -0
  205. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/batch_extraction.py +0 -0
  206. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/brain_graph.py +0 -0
  207. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/chat_tags.py +0 -0
  208. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/chunk.py +0 -0
  209. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/classify.py +0 -0
  210. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/cloud_scrub.py +0 -0
  211. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/cluster_sampling.py +0 -0
  212. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/code_intelligence.py +0 -0
  213. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/correction_detection.py +0 -0
  214. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/correction_mining.py +0 -0
  215. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/digest.py +0 -0
  216. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/enrichment_prompts.py +0 -0
  217. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/enrichment_results.py +0 -0
  218. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/enrichment_tiers.py +0 -0
  219. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/entity_extraction.py +0 -0
  220. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/entity_resolution.py +0 -0
  221. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/extract.py +0 -0
  222. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/extract_claude_desktop.py +0 -0
  223. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/extract_corrections.py +0 -0
  224. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/extract_markdown.py +0 -0
  225. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/extract_whatsapp.py +0 -0
  226. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/frustration_mining.py +0 -0
  227. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/git_overlay.py +0 -0
  228. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/kg_extraction.py +0 -0
  229. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/kg_extraction_groq.py +0 -0
  230. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/longitudinal_analyzer.py +0 -0
  231. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/obsidian_export.py +0 -0
  232. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/operation_grouping.py +0 -0
  233. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/plan_linking.py +0 -0
  234. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/rate_limiter.py +0 -0
  235. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/relation_backfill.py +0 -0
  236. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/relation_verification.py +0 -0
  237. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/sanitize.py +0 -0
  238. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/secret_scrub.py +0 -0
  239. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/semantic_style.py +0 -0
  240. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/sentiment.py +0 -0
  241. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/session_history.py +0 -0
  242. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/style_embed.py +0 -0
  243. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/style_index.py +0 -0
  244. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/tag_entity_promotion.py +0 -0
  245. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/temporal_chains.py +0 -0
  246. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/time_batcher.py +0 -0
  247. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/unified_timeline.py +0 -0
  248. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/pipeline/write_queue.py +0 -0
  249. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/policy_reconcile.py +0 -0
  250. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/provenance.py +0 -0
  251. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/provenance_autosupersede.py +0 -0
  252. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/provenance_integration.py +0 -0
  253. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/queue_io.py +0 -0
  254. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/queue_merge.py +0 -0
  255. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/queued_messages.py +0 -0
  256. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/readonly_snapshot.py +0 -0
  257. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/reembed_backfill.py +0 -0
  258. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/retired_services.py +0 -0
  259. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/runtime_store.py +0 -0
  260. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/sandbox_db.py +0 -0
  261. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/schema_ddl_ledger.py +0 -0
  262. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/scoping.py +0 -0
  263. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/script_copy_refresh.py +0 -0
  264. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/scrub_at_rest.py +0 -0
  265. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/search_fanout.py +0 -0
  266. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/search_profile.py +0 -0
  267. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/search_repo.py +0 -0
  268. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/search_response.py +0 -0
  269. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/service_supervisor.py +0 -0
  270. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/session_repo.py +0 -0
  271. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/setup.py +0 -0
  272. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/socket_hygiene.py +0 -0
  273. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/source_class_migration.py +0 -0
  274. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/source_visibility.py +0 -0
  275. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/spotlight.py +0 -0
  276. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/storage.py +0 -0
  277. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/store.py +0 -0
  278. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/supervisor_adapters.py +0 -0
  279. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/supervisor_child.py +0 -0
  280. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/supervisor_diagnostics.py +0 -0
  281. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/supervisor_guard.py +0 -0
  282. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/supervisor_jobs.py +0 -0
  283. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/system_prompt_guard.py +0 -0
  284. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/t3_linkage_alarm.py +0 -0
  285. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/t3_provenance.py +0 -0
  286. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/t3_sources.py +0 -0
  287. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/t3_thread_tables.py +0 -0
  288. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/tag_normalization.py +0 -0
  289. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/taxonomy.json +0 -0
  290. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/telemetry.py +0 -0
  291. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/timestamp_iso.py +0 -0
  292. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/types.py +0 -0
  293. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/vector_store.py +0 -0
  294. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/wal_checkpoint.py +0 -0
  295. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/watcher.py +0 -0
  296. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/watcher_bridge.py +0 -0
  297. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/writer_policy.py +0 -0
  298. {brainlayer-1.6.16 → brainlayer-1.6.17}/src/brainlayer/writer_telemetry.py +0 -0
  299. {brainlayer-1.6.16 → brainlayer-1.6.17}/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.16
3
+ Version: 1.6.17
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.16"
3
+ version = "1.6.17"
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"
@@ -320,6 +320,10 @@ state "$STEP"
320
320
  [ "$("$PLIST" -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")" = "$V" ]
321
321
  # activate --verify above performs the real MCP handshake, not a socket-presence test.
322
322
  state success
323
+ # LaunchServices can discover the moved bundle even under Backups.noindex.
324
+ # Keep the rollback bundle and remove only its registration after success.
325
+ LSREGISTER=${BRAINBAR_LSREGISTER:-/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister}
326
+ "$LSREGISTER" -u "$BACKUP" || echo "Could not unregister $BACKUP from LaunchServices" >&2
323
327
  # Prune only a backup explicitly recorded by a previous successful invocation.
324
328
  if [ -f "$ROOT/last-backup" ]; then
325
329
  previous_backup=$(cat "$ROOT/last-backup")
@@ -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.16",
6
+ "version": "1.6.17",
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.16",
17
+ "version": "1.6.17",
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.16"
5
+ __version__ = "1.6.17"
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 = "dfdf8bcfde92f4bc799ae3b2ed1b921ee3da88ec"
@@ -3581,7 +3581,22 @@ def _recent_verified_backup_for_reuse(
3581
3581
  return None
3582
3582
 
3583
3583
 
3584
- def _local_snapshot_intact(receipt: Mapping[str, Any]) -> bool:
3584
+ def _file_proof_identity(info: os.stat_result) -> tuple[int, ...]:
3585
+ return info.st_dev, info.st_ino, info.st_size, info.st_mtime_ns, info.st_ctime_ns
3586
+
3587
+
3588
+ @functools.lru_cache(maxsize=128)
3589
+ def _rotation_upload_identity(path: Path, identity: tuple[int, ...]) -> dict[str, Any]:
3590
+ """Memoize only unchanged bytes across this process's admission retries."""
3591
+ if _file_proof_identity(path.lstat()) != identity:
3592
+ raise OSError("Local snapshot changed before hash")
3593
+ artifact = _upload_identity(path)
3594
+ if _file_proof_identity(path.lstat()) != identity:
3595
+ raise OSError("Local snapshot changed during hash")
3596
+ return artifact
3597
+
3598
+
3599
+ def _local_snapshot_intact(receipt: Mapping[str, Any], *, cache_identity: bool = False) -> bool:
3585
3600
  """The durable #1387 proof is bound to these exact bytes, not a dated filename."""
3586
3601
  try:
3587
3602
  path = Path(receipt["snapshot"])
@@ -3594,7 +3609,12 @@ def _local_snapshot_intact(receipt: Mapping[str, Any]) -> bool:
3594
3609
  # Cheap disproof first: a missing record or a size change can never equal the hash (#1385).
3595
3610
  and isinstance(artifact, dict)
3596
3611
  and artifact.get("size") == path.stat().st_size
3597
- and artifact == _upload_identity(path)
3612
+ and artifact
3613
+ == (
3614
+ _rotation_upload_identity(path, _file_proof_identity(path.lstat()))
3615
+ if cache_identity
3616
+ else _upload_identity(path)
3617
+ )
3598
3618
  )
3599
3619
  except (OSError, KeyError, TypeError, ValueError):
3600
3620
  return False
@@ -3697,6 +3717,103 @@ def _local_retention_deferred(context: Mapping[str, Any], error: Exception) -> N
3697
3717
  context["retention_alert_error"] = _redact_upload_secrets(str(exc))
3698
3718
 
3699
3719
 
3720
+ def _early_rotation_local_candidate(receipt: Mapping[str, Any], context: Mapping[str, Any], staging: Path) -> bool:
3721
+ """Cheap necessary conditions; the sweep still proves the current bytes."""
3722
+ path = Path(receipt["snapshot"])
3723
+ artifact = receipt.get("local_artifact")
3724
+ return (
3725
+ all(receipt.get(k) == context.get(k) for k in ("db", "machine_id", "drive_folder", "backup_log_provenance"))
3726
+ and path.parent.resolve() == staging.resolve()
3727
+ and _parse_snapshot_date(path.name) is not None
3728
+ and path.name == f"{path.name[:10]}{_snapshot_suffix(path.name)}"
3729
+ and receipt.get("local_integrity") == "ok"
3730
+ and receipt.get("local_integrity_pragma") == "integrity_check"
3731
+ and not receipt.get("verification_error")
3732
+ and receipt.get("drive_md5_match") is not False
3733
+ and receipt.get("local_removed") is not True
3734
+ and receipt.get("upload_state") not in {"abandoned", "superseded"}
3735
+ and not (receipt.get("uploaded") is True and receipt.get("verified") is not True)
3736
+ and receipt.get("local_verified") is True
3737
+ and not path.is_symlink()
3738
+ and path.is_file()
3739
+ and path.stat().st_nlink == 1
3740
+ and isinstance(artifact, dict)
3741
+ and artifact.get("size") == path.stat().st_size
3742
+ )
3743
+
3744
+
3745
+ def _archive_rotation_reclaimable(staging: Path) -> int:
3746
+ """Receipt-only upper bound: no listing or payload hash when rotation cannot admit.
3747
+
3748
+ A fresh listing and current hashes remain mandatory before any deletion. This
3749
+ optimistic bound can overestimate reclaim (APFS sharing or missing live proof),
3750
+ so admission must always remeasure after the sweep.
3751
+ """
3752
+ from .backup_retention import local_keep_names
3753
+
3754
+ if not staging.is_dir() or staging.is_symlink():
3755
+ return 0
3756
+ log = _backup_log_path(None, db_path=get_db_path())
3757
+ if not log.exists():
3758
+ return 0
3759
+ protected, pin_reason = _weekly_pin_protection(staging)
3760
+ if pin_reason == "pin_unreadable":
3761
+ return 0
3762
+ try:
3763
+ machine = resolve_machine_id()
3764
+ except InvalidMachineIdError:
3765
+ return 0 # An unidentifiable machine cannot authorize reclaim; report the real disk shortfall.
3766
+ context = dict(
3767
+ db=str(get_db_path()),
3768
+ machine_id=machine,
3769
+ drive_folder="/".join(default_drive_folder_parts(machine)),
3770
+ backup_log_provenance=_backup_log_provenance(),
3771
+ )
3772
+ try:
3773
+ receipts = _read_backup_receipts(log, strict=True)
3774
+ except ValueError:
3775
+ return 0 # An unreadable retention journal cannot authorize reclaim.
3776
+ latest = {
3777
+ r["snapshot"]: r for r in receipts if r.get("event") != "local_sweep" and isinstance(r.get("snapshot"), str)
3778
+ }
3779
+ verified = {}
3780
+ cohort = set()
3781
+ for receipt in latest.values():
3782
+ path = Path(receipt["snapshot"])
3783
+ if _early_rotation_local_candidate(receipt, context, staging):
3784
+ cohort.add(path.name)
3785
+ drive = receipt.get("drive_file")
3786
+ if (
3787
+ receipt.get("db") == context["db"]
3788
+ and path.parent.resolve() == staging.resolve()
3789
+ and not path.is_symlink()
3790
+ and path.is_file()
3791
+ and receipt.get("uploaded") is True
3792
+ and receipt.get("verified") is True
3793
+ and _archive_drive_md5_matches(receipt)
3794
+ and isinstance(drive, dict)
3795
+ and isinstance(drive.get("id"), str)
3796
+ and drive.get("name") == path.name
3797
+ and str(drive.get("size")) == str(path.stat().st_size)
3798
+ ):
3799
+ verified[path.name] = path
3800
+ cohort.add(path.name)
3801
+ keep = local_keep_names(cohort, cohort, keep_latest=_local_retention_keep())
3802
+ reclaimable = 0
3803
+ for name, path in verified.items():
3804
+ day = _parse_snapshot_date(name)
3805
+ if (
3806
+ name not in keep
3807
+ and name not in protected
3808
+ and day is not None
3809
+ and day < local_backup_date()
3810
+ and name == f"{day.isoformat()}{_snapshot_suffix(name)}"
3811
+ and path.resolve() != Path(context["db"]).resolve()
3812
+ ):
3813
+ reclaimable += path.lstat().st_blocks * 512
3814
+ return reclaimable
3815
+
3816
+
3700
3817
  def _sweep_verified_local_archives(
3701
3818
  log_path: Path,
3702
3819
  staging_dir: Path,
@@ -3705,6 +3822,9 @@ def _sweep_verified_local_archives(
3705
3822
  remove_local: bool,
3706
3823
  live_files: list[Mapping[str, Any]] | None = None,
3707
3824
  folder_id: str | None = None,
3825
+ before_upload: bool = False,
3826
+ minimum_reclaim_bytes: int = 0,
3827
+ failed_proofs: set[tuple] | None = None,
3708
3828
  ) -> list[str]:
3709
3829
  """Local-only cleanup requires this same snapshot live in a fresh Drive listing."""
3710
3830
  if live_files is None or folder_id is None or not isinstance(context.get("machine_id"), str):
@@ -3752,11 +3872,21 @@ def _sweep_verified_local_archives(
3752
3872
  and r["drive_file"].get("name") == Path(r["snapshot"]).name
3753
3873
  and str(r["drive_file"].get("size")) == str(Path(r["snapshot"]).stat().st_size)
3754
3874
  }
3755
- keep = local_keep_names(verified_names, verified_names, keep_latest=_local_retention_keep())
3875
+ cohort = set(verified_names)
3876
+ if before_upload:
3877
+ # Only intact, integrity-checked local bytes can replace a retained slot.
3878
+ # They never authorize deletion of an archive without its own live Drive proof.
3879
+ for receipt in latest.values():
3880
+ path = Path(receipt["snapshot"])
3881
+ if _early_rotation_local_candidate(receipt, context, staging_dir) and _local_snapshot_intact(
3882
+ receipt, cache_identity=True
3883
+ ):
3884
+ cohort.add(path.name)
3885
+ keep = local_keep_names(cohort, cohort, keep_latest=_local_retention_keep())
3756
3886
  except (ValueError, OSError, subprocess.SubprocessError) as exc:
3757
3887
  _local_retention_deferred(context, exc)
3758
3888
  return []
3759
- removed = []
3889
+ planned: list[tuple[Path, str | None, os.stat_result | None]] = []
3760
3890
  for receipt in latest.values():
3761
3891
  path = Path(receipt["snapshot"])
3762
3892
  day = _parse_snapshot_date(path.name)
@@ -3794,27 +3924,49 @@ def _sweep_verified_local_archives(
3794
3924
  if path.name in keep
3795
3925
  else None
3796
3926
  )
3927
+ before_hash = None
3797
3928
  if reason is None:
3798
3929
  try:
3799
3930
  before_hash = path.stat(follow_symlinks=False)
3800
- if _md5_file(path) != drive["md5Checksum"]:
3931
+ proof_key = ("archive_rotation", str(path), *_file_proof_identity(before_hash))
3932
+ if failed_proofs is not None and proof_key in failed_proofs:
3933
+ reason = "proof_previously_failed"
3934
+ elif _md5_file(path) != drive["md5Checksum"]:
3801
3935
  reason = "md5_current_mismatch"
3802
3936
  else:
3803
3937
  after_hash = path.stat(follow_symlinks=False)
3804
3938
 
3805
- def identity(st):
3806
- return st.st_dev, st.st_ino, st.st_size, st.st_mtime_ns, st.st_ctime_ns
3807
-
3808
- if identity(before_hash) != identity(after_hash):
3939
+ if _file_proof_identity(before_hash) != _file_proof_identity(after_hash):
3809
3940
  reason = "local_identity_changed"
3810
- else:
3811
- path.unlink()
3941
+ if reason is not None and failed_proofs is not None:
3942
+ failed_proofs.add(proof_key)
3812
3943
  except OSError as exc:
3813
3944
  print(f"Cannot delete local archive {path}: {exc}", flush=True)
3814
3945
  reason = "delete_failed"
3815
- else:
3816
- if reason is None:
3946
+ planned.append((path, reason, before_hash))
3947
+ # The cheap admission estimate is optimistic. A missing live proof, changed
3948
+ # hash or narrower keep cohort must not cause a partial, futile rotation.
3949
+ reclaimable = sum(info.st_blocks * 512 for _, reason, info in planned if reason is None and info is not None)
3950
+ if reclaimable < minimum_reclaim_bytes:
3951
+ if failed_proofs is not None:
3952
+ failed_proofs.update(
3953
+ ("archive_rotation", str(path), *_file_proof_identity(info))
3954
+ for path, reason, info in planned
3955
+ if reason is None and info is not None
3956
+ )
3957
+ return []
3958
+ removed = []
3959
+ for path, reason, info in planned:
3960
+ if reason is None:
3961
+ try:
3962
+ if info is None or _file_proof_identity(path.lstat()) != _file_proof_identity(info):
3963
+ reason = "local_identity_changed"
3964
+ else:
3965
+ path.unlink()
3817
3966
  removed.append(path.name)
3967
+ except OSError as exc:
3968
+ print(f"Cannot delete local archive {path}: {exc}", flush=True)
3969
+ reason = "delete_failed"
3818
3970
  # Local housekeeping cannot grant/revoke Drive verification or refresh last-backup status.
3819
3971
  update = {
3820
3972
  "event": "local_sweep",
@@ -3828,6 +3980,70 @@ def _sweep_verified_local_archives(
3828
3980
  return removed
3829
3981
 
3830
3982
 
3983
+ def _rotate_verified_archives_before_upload(
3984
+ staging_dir: Path,
3985
+ *,
3986
+ minimum_reclaim_bytes: int = 0,
3987
+ deadline: float | None = None,
3988
+ failed_proofs: set[tuple] | None = None,
3989
+ ) -> list[str]:
3990
+ """Resolve only the current machine's existing Drive folder under staging custody."""
3991
+ from .backup_heavy_gate import BackupGateDeferred
3992
+
3993
+ def check_deadline():
3994
+ if deadline is not None and time.monotonic() >= deadline:
3995
+ raise BackupGateDeferred("backup deferred: admission deadline elapsed during Drive rotation")
3996
+
3997
+ if not staging_dir.is_dir() or staging_dir.is_symlink():
3998
+ return []
3999
+ fd = os.open(staging_dir / ".backup.lock", os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW, 0o600)
4000
+ context: dict[str, Any] = {"db": str(get_db_path())}
4001
+ try:
4002
+ try:
4003
+ fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
4004
+ except BlockingIOError:
4005
+ return []
4006
+ machine = resolve_machine_id()
4007
+ parts = default_drive_folder_parts(machine)
4008
+ context.update(machine_id=machine, drive_folder="/".join(parts), backup_log_provenance=_backup_log_provenance())
4009
+ log = _backup_log_path(None, db_path=get_db_path())
4010
+ if not log.exists():
4011
+ return []
4012
+ # Validate local policy and the journal before any network request.
4013
+ _local_retention_keep()
4014
+ _read_backup_receipts(log, strict=True)
4015
+ if _weekly_pin_protection(staging_dir)[1] == "pin_unreadable":
4016
+ raise ValueError("Cannot read weekly pin; retaining all local archives")
4017
+ check_deadline()
4018
+ service = build_drive_service()
4019
+ check_deadline()
4020
+ folders = _find_drive_folder_ids(service, parts)
4021
+ check_deadline()
4022
+ if len(folders) != 1:
4023
+ raise ValueError("Cannot establish one existing machine backup folder")
4024
+ live = _list_drive_backup_files(service, folders[0])
4025
+ check_deadline()
4026
+ _assert_backup_owners(live, folder_id=folders[0], machine_id=machine)
4027
+ return _sweep_verified_local_archives(
4028
+ log,
4029
+ staging_dir,
4030
+ context,
4031
+ remove_local=True,
4032
+ live_files=live,
4033
+ folder_id=folders[0],
4034
+ before_upload=True,
4035
+ minimum_reclaim_bytes=minimum_reclaim_bytes,
4036
+ failed_proofs=failed_proofs,
4037
+ )
4038
+ except (BackupStoppedError, BackupTimeoutError, BackupGateDeferred):
4039
+ raise
4040
+ except Exception as exc:
4041
+ _local_retention_deferred(context, exc)
4042
+ return []
4043
+ finally:
4044
+ os.close(fd)
4045
+
4046
+
3831
4047
  def _reclaim_superseded_local(log_path: Path, result: dict[str, Any], staging_dir: Path) -> None:
3832
4048
  """Close an abandoned upload's alert after new proof, retaining its local bytes."""
3833
4049
  if result.get("uploaded") is not True or result.get("verified") is not True:
@@ -3946,6 +4162,10 @@ def _serialized_backup_run(func: Callable[..., dict[str, Any]]) -> Callable[...,
3946
4162
  time.sleep(min(0.05, remaining))
3947
4163
  except BlockingIOError as exc:
3948
4164
  error = f"backup already running in {staging_dir}"
4165
+ if bound.arguments.get("phase", "all") == "upload":
4166
+ from .backup_heavy_gate import BackupGateDeferred
4167
+
4168
+ raise BackupGateDeferred(f"backup upload deferred: staging busy in {staging_dir}") from exc
3949
4169
  resolved_db_path = bound.arguments.get("db_path") or get_db_path()
3950
4170
  _append_json_log(
3951
4171
  _backup_log_path(bound.arguments.get("log_path"), db_path=resolved_db_path),
@@ -5221,7 +5441,7 @@ def main(argv: list[str] | None = None) -> int:
5221
5441
  except Exception:
5222
5442
  report(key, "Database backup failed; check the backup log")
5223
5443
  raise
5224
- if code != BACKUP_DEFERRED_EXIT_CODE or deadline is None: # a child's deadline deferral is not a failure
5444
+ if code != BACKUP_DEFERRED_EXIT_CODE: # A child's admission deferral is not a failure.
5225
5445
  report(key, None if code == 0 else "Database backup failed; check the backup log")
5226
5446
  return code
5227
5447
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import fcntl
5
6
  import math
6
7
  import os
7
8
  import re
@@ -70,7 +71,7 @@ def _pressure_reason(swap_limit: float, load_limit: float) -> str | None:
70
71
  return None
71
72
 
72
73
 
73
- def _disk_reason(host: str, failed_proofs: set[tuple] | None = None) -> str | None:
74
+ def _disk_reason(host: str, failed_proofs: set[tuple] | None = None, *, deadline: float | None = None) -> str | None:
74
75
  """Measure first; prove and reclaim dated raws only when that could admit, then measure again.
75
76
 
76
77
  `failed_proofs` is the gate's per-process memo of raw/archive identities whose proof failed,
@@ -104,28 +105,50 @@ def _disk_reason(host: str, failed_proofs: set[tuple] | None = None) -> str | No
104
105
  while not volume_path.exists():
105
106
  volume_path = volume_path.parent
106
107
 
107
- def measure() -> tuple[list[tuple[Path, int]], int, int]:
108
+ def measure() -> tuple[list[tuple[Path, int]], int, int, int, int]:
108
109
  reserves = backup._clone_growth_reserves(staging, 0)
109
- required = peak + sum(size for _, size in reserves) + math.ceil(floor_gib * 1024**3)
110
- free = backup.disk_space.measure_disk_space(volume_path, include_available=False).free_now_bytes
111
- return reserves, required, free
112
-
113
- reserves, required, free = measure()
114
- if free < required:
110
+ allocation = peak + sum(size for _, size in reserves)
111
+ required = allocation + math.ceil(floor_gib * 1024**3)
112
+ space = backup.disk_space.measure_disk_space(volume_path, include_available=sys.platform == "darwin")
113
+ free = space.free_now_bytes
114
+ available = space.available_bytes if sys.platform == "darwin" else free
115
+ raw_required = allocation if sys.platform == "darwin" else 0
116
+ return reserves, required, raw_required, free, available
117
+
118
+ reserves, required, raw_required, free, available = measure()
119
+ if available < required or free < raw_required:
115
120
  # Upper bound of what reclaiming the dated raws can return: each raw's COW reserve plus
116
121
  # its allocated blocks (a byte copy frees them; a clone shares them and frees less).
117
122
  reclaimable = sum(size + path.lstat().st_blocks * 512 for path, size in reserves if path.parent == staging)
118
- if free + reclaimable >= required and backup._reclaim_verified_raws_before_admission(
119
- staging, failed_proofs
123
+ if (
124
+ available + reclaimable >= required
125
+ and free + reclaimable >= raw_required
126
+ and backup._reclaim_verified_raws_before_admission(staging, failed_proofs)
127
+ ):
128
+ reserves, required, raw_required, free, available = measure()
129
+ if phase == "upload" and (available < required or free < raw_required):
130
+ reclaimable = backup._archive_rotation_reclaimable(staging)
131
+ if (
132
+ available + reclaimable >= required
133
+ and free + reclaimable >= raw_required
134
+ and backup._rotate_verified_archives_before_upload(
135
+ staging,
136
+ minimum_reclaim_bytes=max(required - available, raw_required - free),
137
+ deadline=deadline,
138
+ failed_proofs=failed_proofs,
139
+ )
120
140
  ):
121
- reserves, required, free = measure()
141
+ reserves, required, raw_required, free, available = measure()
142
+ except (BackupGateDeferred, backup.BackupTimeoutError):
143
+ raise
122
144
  except (OSError, RuntimeError, ValueError) as exc:
123
145
  return f"disk space measurement unavailable: {type(exc).__name__}"
124
- if free < required:
146
+ if available < required or free < raw_required:
125
147
  reserved = ", ".join(f"{path.relative_to(staging)}={size / 1024**3:.3f} GiB" for path, size in reserves)
126
148
  return (
127
- f"disk space needs {required / 1024**3:.3f} GiB, has {free / 1024**3:.3f} GiB "
128
- f"(peak plus {floor_gib:g} GiB host floor)" + (f"; retained COW reserves: {reserved}" if reserved else "")
149
+ f"disk space needs {required / 1024**3:.3f} GiB, has {available / 1024**3:.3f} GiB available; "
150
+ f"free-now {free / 1024**3:.3f} GiB (raw needs {raw_required / 1024**3:.3f} GiB); "
151
+ f"peak plus {floor_gib:g} GiB host floor" + (f"; retained COW reserves: {reserved}" if reserved else "")
129
152
  )
130
153
  return None
131
154
 
@@ -165,6 +188,26 @@ def _upload_peak_bytes(staging: Path, *, full: bool) -> int:
165
188
  return max(extra, default=0) + backup.MIN_RAW_FREE_BYTES + backup.COPY_CHUNK_BYTES
166
189
 
167
190
 
191
+ def _upload_staging_reason() -> str | None:
192
+ """Probe staging custody without launching a child that would fail and alert."""
193
+ from . import backup_daily as backup
194
+
195
+ staging = Path(os.environ.get("BRAINLAYER_BACKUP_STAGING_DIR", str(backup.DEFAULT_STAGING_DIR))).expanduser()
196
+ try:
197
+ if not staging.exists():
198
+ return None
199
+ fd = os.open(staging / ".backup.lock", os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW, 0o600)
200
+ try:
201
+ fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
202
+ finally:
203
+ os.close(fd)
204
+ except BlockingIOError:
205
+ return "staging busy"
206
+ except OSError as exc:
207
+ return f"staging lock unavailable: {type(exc).__name__}"
208
+ return None
209
+
210
+
168
211
  def expected_phase_seconds() -> float:
169
212
  phase = os.environ.get("BRAINLAYER_BACKUP_PHASE", "all")
170
213
  defaults = {"snapshot": 2400, "upload": 1800, "all": 4200}
@@ -272,12 +315,21 @@ def backup_heavy_gate(*, deadline: float | None = None, job_key: str = "backup-d
272
315
  host = _host()
273
316
  except (ValueError, OSError, subprocess.SubprocessError) as exc:
274
317
  raise BackupGateDeferred(f"backup heavy-work gate host detection failed: {type(exc).__name__}") from exc
275
- lock = Path(os.environ.get("BRAINLAYER_BACKUP_HEAVY_LOCK_PATH", str(Path.home() / f".{host}-heavy.lock")))
276
- log = Path(os.environ.get("BRAINLAYER_BACKUP_HEAVY_LOG_PATH", str(Path.home() / f".{host}-heavy.log")))
318
+ upload = os.environ.get("BRAINLAYER_BACKUP_PHASE", "all") == "upload"
319
+ lock = (
320
+ Path(os.environ.get("BRAINLAYER_BACKUP_UPLOAD_LOCK_PATH", str(Path.home() / ".brainlayer-backup-upload.lock")))
321
+ if upload
322
+ else Path(os.environ.get("BRAINLAYER_BACKUP_HEAVY_LOCK_PATH", str(Path.home() / f".{host}-heavy.lock")))
323
+ )
324
+ log = (
325
+ Path(os.environ.get("BRAINLAYER_BACKUP_UPLOAD_LOG_PATH", str(lock.with_suffix(".log"))))
326
+ if upload
327
+ else Path(os.environ.get("BRAINLAYER_BACKUP_HEAVY_LOG_PATH", str(Path.home() / f".{host}-heavy.log")))
328
+ )
277
329
  window = _number("WINDOW_SECONDS", 6 * 3600)
278
330
  retry = _number("RETRY_SECONDS", 600)
279
- swap_limit = _number("SWAP_GIB", 9)
280
- load_limit = _number("LOAD", 12)
331
+ swap_limit = _number("SWAP_GIB", 9) if not upload else 0
332
+ load_limit = _number("LOAD", 12) if not upload else 0
281
333
  started = time.monotonic()
282
334
  since = datetime.now().astimezone().isoformat(timespec="seconds")
283
335
  pressure_window_end = started + window
@@ -288,7 +340,7 @@ def backup_heavy_gate(*, deadline: float | None = None, job_key: str = "backup-d
288
340
  waited = False
289
341
  previous = {}
290
342
  failed_proofs: set[tuple] = set() # Raw/archive identities whose reclaim proof failed this gate run.
291
- reservation = _M1Reservation(lock, job_key) if host == "m1" else None
343
+ reservation = _M1Reservation(lock, job_key) if host == "m1" and not upload else None
292
344
 
293
345
  def stopped(signum, _frame):
294
346
  raise SystemExit(128 + signum)
@@ -308,8 +360,9 @@ def backup_heavy_gate(*, deadline: float | None = None, job_key: str = "backup-d
308
360
  reason = reservation.check() if reservation is not None else None
309
361
  reason = (
310
362
  reason
311
- or (None if past_window else _pressure_reason(swap_limit, load_limit))
312
- or _disk_reason(host, failed_proofs)
363
+ or (None if upload or past_window else _pressure_reason(swap_limit, load_limit))
364
+ or _disk_reason(host, failed_proofs, deadline=deadline)
365
+ or (_upload_staging_reason() if upload else None)
313
366
  )
314
367
  if reason is not None and reservation is not None:
315
368
  reservation.release()
@@ -319,7 +372,7 @@ def backup_heavy_gate(*, deadline: float | None = None, job_key: str = "backup-d
319
372
  try:
320
373
  lock.mkdir()
321
374
  except FileExistsError:
322
- reason = "heavy lock held by another lane (never cleared by backup)"
375
+ reason = f"{'upload' if upload else 'heavy'} lock held by another lane (never cleared by backup)"
323
376
  if reservation is not None:
324
377
  reason = reservation.check(publish=True) or reason
325
378
  else:
@@ -327,8 +380,9 @@ def backup_heavy_gate(*, deadline: float | None = None, job_key: str = "backup-d
327
380
  reason = reservation.check() if reservation is not None else None
328
381
  reason = (
329
382
  reason
330
- or (None if past_window else _pressure_reason(swap_limit, load_limit))
331
- or _disk_reason(host, failed_proofs)
383
+ or (None if upload or past_window else _pressure_reason(swap_limit, load_limit))
384
+ or _disk_reason(host, failed_proofs, deadline=deadline)
385
+ or (_upload_staging_reason() if upload else None)
332
386
  )
333
387
  if reason is None and time.monotonic() < expires:
334
388
  if reservation is not None:
@@ -1 +0,0 @@
1
- BUILD_SHA = "a55ab00c37f3e1c2d415ff427354f17024d495d0"
File without changes
File without changes
File without changes