brainlayer 1.6.12__tar.gz → 1.6.13__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.
- {brainlayer-1.6.12 → brainlayer-1.6.13}/PKG-INFO +1 -1
- {brainlayer-1.6.12 → brainlayer-1.6.13}/pyproject.toml +1 -1
- brainlayer-1.6.13/scripts/brainbar-update.sh +333 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/server.json +2 -2
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/__init__.py +1 -1
- brainlayer-1.6.13/src/brainlayer/_build.py +1 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/backup_clone.py +9 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/backup_daily.py +71 -12
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/backup_heavy_gate.py +40 -9
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/brainbar_auto_activation.py +40 -1
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/maintenance_calendar.py +27 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/supervisor_guard.py +8 -1
- brainlayer-1.6.12/scripts/brainbar-update.sh +0 -174
- brainlayer-1.6.12/src/brainlayer/_build.py +0 -1
- {brainlayer-1.6.12 → brainlayer-1.6.13}/.gitignore +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/LICENSE +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/README.md +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/brainlayer-version-check.sh +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/hotlane_brainbar_daemon.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/backup-daily.sh +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/brainlayer-env-run.sh +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/brainlayer.env.example +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.backup-daily.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.daemon.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.decay.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.drain.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.health-check.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.hotlane-brainbar.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.index.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.jsonl-backup.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.log-cap.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.maintenance-nightly.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.maintenance-weekly.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.maintenance.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.observability.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.p0-counter.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.repair-fts.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.t3-audit.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.t3-ingest.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.throughput-watchdog.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.tier0-watchdog.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.wal-checkpoint.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.brainlayer.watch.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/com.etanhey.brainlayer-fleet-watchdog.plist +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/fleet-watchdog.sh +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/install.sh +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/jsonl-backup.sh +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/launchd/throughput-watchdog.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/release-verify-signatures.sh +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/scripts/tier0-watchdog.sh +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/__main__.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/_helpers.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/agent_census.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/agent_profiles.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/agent_provenance.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/agy_attribution.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/alarm.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/archive_collapse.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/archive_lifecycle.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/backup_retention.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/backup_retention_invariant.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/backup_retention_observation.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/backup_sleep.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/badge_state.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/bitemporal.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/brainbar_activation.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/brainbar_hybrid_helper.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/brainbar_identity.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/cachedelete_purge.swift +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/calibrate.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/chunk_origin.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/chunk_origin_backfill.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/chunk_origin_wipe.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/chunk_write.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/classify.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/claude_paths.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/cli/__init__.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/cli/wizard.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/cli_jobs.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/cli_new.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/cloud_backfill.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/clustering.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/codex_zst.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/component_jobs.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/config.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/consolidation_plan.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/content_class.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/content_hash_repair.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/correction_judge.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/data/agents_registry.yaml +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/data/sandbox_seeds/skill-eval-baseline.json +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/db_shrink.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/decay.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/decay_backfill.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/decay_job.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/dedupe.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/dedupe_merge.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/deploy_drift.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/disk_space.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/doctor.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/drain.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/drain_liveness.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/drive_credentials.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/embeddings.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/engine.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/enrichment_replay.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/__init__.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/abcde_enrich_runner.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/abcde_variants.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/abcde_variants.yaml +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/benchmark.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/enrichment_gold.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/enrichment_graders.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/enrichment_judge.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/enrichment_llm_judge.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/enrichment_quality_benchmark.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/experiment_store.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/fixtures/README.md +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/labeling/enrichment-labeler.html +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/phoenix_gate/__init__.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/phoenix_gate/__main__.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/phoenix_gate/baseline_store.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/phoenix_gate/cli.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/phoenix_gate/models.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/phoenix_gate/phoenix_client.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/phoenix_gate/regression_gate.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/phoenix_gate/triggers.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/eval/pilot_artifact_report.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/fallback_replay.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/git_learning.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/health_check.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/health_facts.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/health_verdict.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/hook_python.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/hooks/__init__.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/hooks/indexer.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/hotlane_budget.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/import_sweep.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/index_admission.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/index_budget.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/index_completeness.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/index_new.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/index_watchdog.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/ingest/__init__.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/ingest/codex.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/ingest/codex_manifest.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/ingest/t3.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/ingest/t3_audit.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/ingest/t3_bookmark.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/ingest/t3_ownership.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/ingest_denylist.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/ingest_guard.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/isolation_proof.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/job_alerts.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/job_lifecycle_health.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/jobs.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/jsonl_backup.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/kg/__init__.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/kg_cleanup.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/kg_judge.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/kg_promotion.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/kg_repo.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/kg_review_session.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/kg_session_finish.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/kg_session_harvest.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/launchd_consolidation.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/launchd_install.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/launchd_primitive.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/launchd_revert.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/launcher_policy_reconcile.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/lexical_defense.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/lexical_defense_dictionary.json +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/linkedin_import.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/log_cap.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/maintenance.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/maintenance_control.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/maintenance_upload_recovery.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp/__init__.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp/_format.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp/_shared.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp/enrich_handler.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp/entity_handler.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp/palette.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp/search_handler.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp/store_handler.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp/tags_handler.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp_socket_config.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/mcp_stdio_bridge.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/memory_types.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/migrate.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/migration_custody.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/migration_journal.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/migration_runtime.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/notification_policy.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/observability_backup.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/observability_indexes.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/observability_surface.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/observability_transport.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/p0_longitudinal_count.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/parent_death.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/paths.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pause.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/phonetic.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/__init__.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/agent_enrichment.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/analyze_communication.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/batch_extraction.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/brain_graph.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/chat_tags.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/chunk.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/classify.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/cloud_scrub.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/cluster_sampling.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/code_intelligence.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/correction_detection.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/correction_mining.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/digest.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/enrichment_prompts.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/enrichment_results.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/enrichment_tiers.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/entity_extraction.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/entity_resolution.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/extract.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/extract_claude_desktop.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/extract_corrections.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/extract_markdown.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/extract_whatsapp.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/frustration_mining.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/git_overlay.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/kg_extraction.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/kg_extraction_groq.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/longitudinal_analyzer.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/obsidian_export.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/operation_grouping.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/plan_linking.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/rate_limiter.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/relation_backfill.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/relation_verification.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/sanitize.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/secret_scrub.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/semantic_style.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/sentiment.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/session_history.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/style_embed.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/style_index.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/tag_entity_promotion.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/temporal_chains.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/time_batcher.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/unified_timeline.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/pipeline/write_queue.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/policy_reconcile.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/provenance.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/provenance_autosupersede.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/provenance_integration.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/queue_io.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/queue_merge.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/queued_messages.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/readonly_snapshot.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/reembed_backfill.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/retired_services.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/runtime_store.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/sandbox_db.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/schema_ddl_ledger.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/scoping.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/scrub_at_rest.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/search_fanout.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/search_profile.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/search_repo.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/search_response.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/service_supervisor.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/session_repo.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/setup.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/socket_hygiene.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/source_class_migration.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/source_visibility.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/spotlight.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/storage.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/store.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/supervisor_adapters.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/supervisor_child.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/supervisor_diagnostics.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/supervisor_jobs.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/system_prompt_guard.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/t3_linkage_alarm.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/t3_provenance.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/t3_sources.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/t3_thread_tables.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/tag_normalization.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/taxonomy.json +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/telemetry.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/timestamp_iso.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/types.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/vector_store.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/wal_checkpoint.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/watcher.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/watcher_bridge.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/writer_policy.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/writer_telemetry.py +0 -0
- {brainlayer-1.6.12 → brainlayer-1.6.13}/src/brainlayer/zstd_stream.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: brainlayer
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.13
|
|
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
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Shipped installer shared by the app helper and release workers. Never invoke sudo.
|
|
3
|
+
# brainbar-update-handoff: 1
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
umask 077
|
|
6
|
+
export PATH="${BRAINBAR_UPDATE_PATH:-/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin}"
|
|
7
|
+
export HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1
|
|
8
|
+
export SUDO_ASKPASS=/usr/bin/false NONINTERACTIVE=1
|
|
9
|
+
# flock is shared by the supervisor and installer for the entire attempt, including stale mkdir recovery.
|
|
10
|
+
# The file is permanent: unlinking it would let contenders lock different inodes.
|
|
11
|
+
if [ "${1:-}" != --custody-held ]; then
|
|
12
|
+
custody_root=${BRAINBAR_UPDATE_ROOT:-"$HOME/Library/Application Support/BrainBar"}
|
|
13
|
+
mkdir -p "$custody_root"
|
|
14
|
+
exec /usr/bin/ruby -rtempfile -e '
|
|
15
|
+
File.open(ARGV.shift, File::RDWR|File::CREAT, 0600) do |lock|
|
|
16
|
+
unless lock.flock(File::LOCK_EX|File::LOCK_NB)
|
|
17
|
+
# A shared lock proves no installer can write state while we publish deferral.
|
|
18
|
+
# An exclusive holder is another updater: leave its receipt entirely alone.
|
|
19
|
+
unless lock.flock(File::LOCK_SH|File::LOCK_NB)
|
|
20
|
+
warn "Another update owns custody"; exit 75
|
|
21
|
+
end
|
|
22
|
+
version, operation = ARGV[1], ARGV[2]
|
|
23
|
+
unless version && version.match?(/\A[0-9]+\.[0-9]+\.[0-9]+\z/) &&
|
|
24
|
+
operation && operation.match?(/\A[A-Za-z0-9-]+\z/)
|
|
25
|
+
exit 64
|
|
26
|
+
end
|
|
27
|
+
root = File.dirname(lock.path)
|
|
28
|
+
# Serialize shared-lock contenders too; each receipt belongs to one operation.
|
|
29
|
+
File.open(File.join(root, "update-wait.lock"), File::RDWR|File::CREAT, 0600) do |writer|
|
|
30
|
+
writer.flock(File::LOCK_EX)
|
|
31
|
+
path = File.join(root, "update-state")
|
|
32
|
+
previous = File.exist?(path) ? File.readlines(path, chomp: true) : nil
|
|
33
|
+
if previous && !%w[success failed cancelled].include?(previous[1]) &&
|
|
34
|
+
!(previous[0] == operation && previous[1] == "waiting")
|
|
35
|
+
warn "Another unsettled operation owns update-state"; exit 75
|
|
36
|
+
end
|
|
37
|
+
Tempfile.create("update-wait", root) do |state|
|
|
38
|
+
state.write("#{operation}\nwaiting\nWill update when BrainBar activation finishes\n")
|
|
39
|
+
state.close
|
|
40
|
+
File.rename(state.path, path)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
exit 0
|
|
44
|
+
end
|
|
45
|
+
lock.close_on_exec = false
|
|
46
|
+
system("/bin/bash", ARGV.shift, "--custody-held", *ARGV)
|
|
47
|
+
exit($?.exitstatus || 1)
|
|
48
|
+
end
|
|
49
|
+
' "$custody_root/update-custody.lock" "$0" "$@"
|
|
50
|
+
fi
|
|
51
|
+
shift
|
|
52
|
+
# After the formula upgrade, an older helper execs the new keg's copy with --handoff: same pid,
|
|
53
|
+
# same inherited custody flock, same lock directory and state file. It resumes at signatures.
|
|
54
|
+
HANDOFF=0
|
|
55
|
+
if [ "${1:-}" = --handoff ]; then HANDOFF=1; shift; fi
|
|
56
|
+
V=${1:?Usage: brainbar-update.sh VERSION OPERATION_ID}
|
|
57
|
+
OP=${2:?operation id required}
|
|
58
|
+
[[ "$V" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ && "$OP" =~ ^[A-Za-z0-9-]+$ ]] || exit 64
|
|
59
|
+
ROOT=${BRAINBAR_UPDATE_ROOT:-"$HOME/Library/Application Support/BrainBar"}
|
|
60
|
+
APP=${BRAINBAR_UPDATE_APP:-/Applications/BrainBar.app}
|
|
61
|
+
PLIST=${BRAINBAR_UPDATE_PLIST:-/usr/libexec/PlistBuddy}
|
|
62
|
+
AGENTS=${BRAINBAR_UPDATE_AGENTS:-"$HOME/Library/LaunchAgents"}
|
|
63
|
+
LABELS="com.brainlayer.brainbar com.brainlayer.brainbar-daemon"
|
|
64
|
+
mkdir -p "$ROOT/Backups.noindex"
|
|
65
|
+
LOCK="$ROOT/update.lock"
|
|
66
|
+
if [ "$HANDOFF" = 1 ]; then
|
|
67
|
+
# Custody is proven only by our own pid in the lock, written by the helper this exec replaced.
|
|
68
|
+
if [ "$(cat "$LOCK/pid" 2>/dev/null)" != "$$" ] || [ "$(cat "$LOCK/operation" 2>/dev/null)" != "$OP" ]; then
|
|
69
|
+
echo 'Handoff without live custody; refusing.' >&2
|
|
70
|
+
exit 75
|
|
71
|
+
fi
|
|
72
|
+
# A dead controller's unsettled attempt is retained for recovery, never silently retried.
|
|
73
|
+
elif ! mkdir "$LOCK" 2>/dev/null; then
|
|
74
|
+
REAPED=0
|
|
75
|
+
if mkdir "$ROOT/update-reaper.lock" 2>/dev/null; then
|
|
76
|
+
if [ -f "$LOCK/pid" ]; then
|
|
77
|
+
owner=$(cat "$LOCK/pid")
|
|
78
|
+
if [[ "$owner" =~ ^[0-9]+$ ]] && ! kill -0 "$owner" 2>/dev/null; then
|
|
79
|
+
# Reap only our known lock files. Durable unsettled state below still blocks retries.
|
|
80
|
+
rm -f "$LOCK/pid" "$LOCK/operation" "$LOCK/formula.json" "$LOCK/cask.json"
|
|
81
|
+
if ! rmdir "$LOCK"; then
|
|
82
|
+
rmdir "$ROOT/update-reaper.lock"
|
|
83
|
+
echo 'Unknown lock contents; inspect update.lock before recovery.' >&2
|
|
84
|
+
exit 75
|
|
85
|
+
fi
|
|
86
|
+
if mkdir "$LOCK" 2>/dev/null; then REAPED=1; fi
|
|
87
|
+
fi
|
|
88
|
+
fi
|
|
89
|
+
rmdir "$ROOT/update-reaper.lock"
|
|
90
|
+
fi
|
|
91
|
+
if [ "$REAPED" = 0 ]; then
|
|
92
|
+
echo 'Another update owns the lock; inspect update-state before recovery.' >&2
|
|
93
|
+
exit 75
|
|
94
|
+
fi
|
|
95
|
+
fi
|
|
96
|
+
printf '%s\n' "$$" > "$LOCK/pid"
|
|
97
|
+
printf '%s\n' "$OP" > "$LOCK/operation"
|
|
98
|
+
STEP=preflight
|
|
99
|
+
MUTATED=0
|
|
100
|
+
BACKUP=""
|
|
101
|
+
SAVED=""
|
|
102
|
+
STOPPED=0
|
|
103
|
+
UNKNOWN=0
|
|
104
|
+
FAILURE=""
|
|
105
|
+
state() { printf '%s\n%s\n%s\n' "$OP" "$1" "${2:-}" > "$ROOT/update-state.new"; mv "$ROOT/update-state.new" "$ROOT/update-state"; }
|
|
106
|
+
cleanup() { rm -f "$LOCK/pid" "$LOCK/operation" "$LOCK/formula.json" "$LOCK/cask.json"; rmdir "$LOCK"; }
|
|
107
|
+
# A BrainBar process is one whose executable (argv[0], as launchd starts it) is inside the bundle;
|
|
108
|
+
# a process that only names a bundle path in a later argument (tail, codesign, grep) is not.
|
|
109
|
+
app_pids() {
|
|
110
|
+
# The prefix travels in the environment: macOS awk rewrites its argv, so an argument would match awk itself.
|
|
111
|
+
ps -axo pid=,command= | BRAINBAR_EXE_PREFIX="$APP/Contents/MacOS/" awk '
|
|
112
|
+
{p = ENVIRON["BRAINBAR_EXE_PREFIX"]; c = $0; sub(/^ *[0-9]+ +/, "", c)} index(c, p) == 1 {print $1}'
|
|
113
|
+
}
|
|
114
|
+
# Every scan's exit status counts: an unknown process state never permits a bundle move.
|
|
115
|
+
scan() { pids=$(app_pids) || { UNKNOWN=1; echo 'Could not list processes; BrainBar state is unknown' >&2; return 1; }; }
|
|
116
|
+
# Stop BrainBar ourselves: Homebrew's AppleScript quit needs Automation access a launchd job never has.
|
|
117
|
+
stop_brainbar() {
|
|
118
|
+
local label rc deadline
|
|
119
|
+
STOPPED=1
|
|
120
|
+
for label in $LABELS; do
|
|
121
|
+
rc=0
|
|
122
|
+
launchctl print "gui/$(id -u)/$label" >/dev/null 2>&1 || rc=$?
|
|
123
|
+
if [ "$rc" = 0 ]; then
|
|
124
|
+
launchctl bootout "gui/$(id -u)/$label" || { echo "Could not unload $label" >&2; return 1; }
|
|
125
|
+
elif [ "$rc" != 113 ]; then
|
|
126
|
+
UNKNOWN=1; echo "Could not inspect $label (launchctl $rc)" >&2; return 1
|
|
127
|
+
fi
|
|
128
|
+
done
|
|
129
|
+
scan || return 1
|
|
130
|
+
[ -n "$pids" ] || return 0
|
|
131
|
+
kill -TERM $pids 2>/dev/null || true
|
|
132
|
+
deadline=$((SECONDS + ${BRAINBAR_UPDATE_STOP_TIMEOUT:-30}))
|
|
133
|
+
while [ "$SECONDS" -lt "$deadline" ]; do
|
|
134
|
+
sleep 0.2
|
|
135
|
+
scan || return 1
|
|
136
|
+
[ -n "$pids" ] || return 0
|
|
137
|
+
done
|
|
138
|
+
kill -KILL $pids 2>/dev/null || true
|
|
139
|
+
sleep 1
|
|
140
|
+
scan || return 1
|
|
141
|
+
[ -n "$pids" ] || return 0
|
|
142
|
+
echo 'BrainBar did not exit' >&2
|
|
143
|
+
return 1
|
|
144
|
+
}
|
|
145
|
+
# A failed plist restore cannot be fixed by re-activation; say exactly how to put them back.
|
|
146
|
+
restore_or_recover() {
|
|
147
|
+
restore_agents && return 0
|
|
148
|
+
state recovery-required "Restore plists: cp -p '$SAVED/com.brainlayer.brainbar.plist' '$SAVED/com.brainlayer.brainbar-daemon.plist' '$AGENTS/' then run: $CLI brainbar activate --verify --timeout 90"
|
|
149
|
+
exit 1
|
|
150
|
+
}
|
|
151
|
+
# The cask uninstall trashes both plists; put back the saved copy of any that postflight did not write.
|
|
152
|
+
restore_agents() {
|
|
153
|
+
local label
|
|
154
|
+
[ -n "$SAVED" ] || return 0
|
|
155
|
+
for label in $LABELS; do
|
|
156
|
+
[ -f "$AGENTS/$label.plist" ] || cp -p "$SAVED/$label.plist" "$AGENTS/$label.plist" || return 1
|
|
157
|
+
done
|
|
158
|
+
}
|
|
159
|
+
# Same gates and flag as brainlayer-update-brainbar.sh: verify signature and notarization, then
|
|
160
|
+
# carry the user's approval (0x40) onto the new quarantine value. Provenance is kept, never stripped.
|
|
161
|
+
identity() { codesign -dv --verbose=4 "$1" 2>&1 | sed -n 's/^TeamIdentifier=//p; s/^Identifier=//p' | tr '\n' ';'; }
|
|
162
|
+
approve() {
|
|
163
|
+
local assessment attributes old new before after flags
|
|
164
|
+
codesign --verify --deep --strict "$APP" || return 1
|
|
165
|
+
assessment=$(spctl -a -t exec -vv "$APP" 2>&1) || { echo "Gatekeeper refused: $assessment" >&2; return 1; }
|
|
166
|
+
grep -Fxq "$APP: accepted" <<<"$assessment" && grep -Fxq 'source=Notarized Developer ID' <<<"$assessment" || return 1
|
|
167
|
+
attributes=$(xattr "$APP") || return 1
|
|
168
|
+
grep -Fxq com.apple.quarantine <<<"$attributes" || return 0
|
|
169
|
+
old=$(xattr -p com.apple.quarantine "$BACKUP" 2>/dev/null) || old=""
|
|
170
|
+
new=$(xattr -p com.apple.quarantine "$APP" 2>/dev/null) || new=""
|
|
171
|
+
before=$(identity "$BACKUP") || before=""
|
|
172
|
+
after=$(identity "$APP") || after=""
|
|
173
|
+
if [[ ! "$old" =~ ^[[:xdigit:]]{1,8}\; || ! "$new" =~ ^[[:xdigit:]]{1,8}\; ]] || (( (16#${old%%;*} & 0x40) == 0 )) ||
|
|
174
|
+
[[ ! "$before" =~ ^[A-Za-z0-9.-]+\;[A-Z0-9]+\;$ ]] || [ "$before" != "$after" ]; then
|
|
175
|
+
echo 'Approval not carried; the first launch will ask the user.' >&2
|
|
176
|
+
return 0
|
|
177
|
+
fi
|
|
178
|
+
flags=${new%%;*}
|
|
179
|
+
printf -v flags '%0*x' "${#flags}" "$((16#$flags | 0x40))"
|
|
180
|
+
find "$APP" ! -type l -print0 | xargs -0 xattr -w com.apple.quarantine "$flags;${new#*;}" ||
|
|
181
|
+
echo 'Could not write the approval flag; the first launch will ask the user.' >&2
|
|
182
|
+
}
|
|
183
|
+
finish() {
|
|
184
|
+
rc=$?
|
|
185
|
+
trap - EXIT
|
|
186
|
+
if [ "$rc" -ne 0 ]; then
|
|
187
|
+
if [ "$UNKNOWN" = 1 ]; then
|
|
188
|
+
state recovery-required "BrainBar process state unknown; nothing more was moved. Check ps and launchctl, then run: $CLI brainbar activate --verify --timeout 90"
|
|
189
|
+
exit 1
|
|
190
|
+
fi
|
|
191
|
+
if [ -n "$BACKUP" ] && [ -d "$BACKUP" ]; then
|
|
192
|
+
# Same order as the update: stop whatever runs from the replacement before moving it.
|
|
193
|
+
stop_brainbar || { state recovery-required "BrainBar did not stop or its state is unknown. Restore $BACKUP to $APP"; exit 1; }
|
|
194
|
+
# Preserve the failed replacement rather than delete a bundle we did not create.
|
|
195
|
+
if [ -e "$APP" ]; then
|
|
196
|
+
failed="$ROOT/Backups.noindex/BrainBar.failed-$OP.app"
|
|
197
|
+
mv "$APP" "$failed" || { state recovery-required "Restore $BACKUP to $APP"; exit 1; }
|
|
198
|
+
fi
|
|
199
|
+
mv "$BACKUP" "$APP" || { state recovery-required "$BACKUP"; exit 1; }
|
|
200
|
+
restore_or_recover
|
|
201
|
+
if ! "$CLI" brainbar activate --verify --timeout 90; then
|
|
202
|
+
state recovery-required "Run: $CLI brainbar activate --verify --timeout 90"
|
|
203
|
+
exit 1
|
|
204
|
+
fi
|
|
205
|
+
# Restoration and its real activation check take priority over retention cleanup.
|
|
206
|
+
if [ -n "${failed:-}" ]; then
|
|
207
|
+
if [ -f "$ROOT/last-failed" ]; then
|
|
208
|
+
previous_failed=$(cat "$ROOT/last-failed")
|
|
209
|
+
case "$previous_failed" in "$ROOT/Backups.noindex/BrainBar.failed-"*.app)
|
|
210
|
+
ruby -rfileutils -e 'FileUtils.remove_entry_secure(ARGV[0]) if File.directory?(ARGV[0])' "$previous_failed" || echo "Could not prune $previous_failed" >&2 ;;
|
|
211
|
+
esac
|
|
212
|
+
fi
|
|
213
|
+
printf '%s\n' "$failed" > "$ROOT/last-failed"
|
|
214
|
+
fi
|
|
215
|
+
elif [ "$STOPPED" = 1 ]; then
|
|
216
|
+
# Stopped but never moved: bring the untouched app back.
|
|
217
|
+
restore_or_recover
|
|
218
|
+
if ! "$CLI" brainbar activate --verify --timeout 90; then
|
|
219
|
+
state recovery-required "Run: $CLI brainbar activate --verify --timeout 90"
|
|
220
|
+
exit 1
|
|
221
|
+
fi
|
|
222
|
+
fi
|
|
223
|
+
if [ "$MUTATED" = 0 ]; then
|
|
224
|
+
state failed "${FAILURE:-Update preflight failed. Check Homebrew and try again. See update.log.}"
|
|
225
|
+
else
|
|
226
|
+
state failed "Step $STEP failed. Run: /opt/homebrew/bin/brainlayer brainbar activate --verify --timeout 90"
|
|
227
|
+
fi
|
|
228
|
+
fi
|
|
229
|
+
cleanup
|
|
230
|
+
exit "$rc"
|
|
231
|
+
}
|
|
232
|
+
trap finish EXIT
|
|
233
|
+
trap 'if [ "$MUTATED" = 0 ]; then state cancelled; exit 0; fi' TERM INT
|
|
234
|
+
if [ "$HANDOFF" = 0 ]; then
|
|
235
|
+
if [ -f "$ROOT/update-state" ]; then
|
|
236
|
+
previous=$(sed -n '2p' "$ROOT/update-state")
|
|
237
|
+
case "$previous" in success|failed|cancelled|waiting) ;; *) echo 'Unsettled update requires recovery' >&2; cleanup; trap - EXIT; exit 75 ;; esac
|
|
238
|
+
fi
|
|
239
|
+
state preflight
|
|
240
|
+
fi
|
|
241
|
+
busy() {
|
|
242
|
+
# App keeps this snapshot fresh until the first mutation. A release worker may omit it.
|
|
243
|
+
if [ -n "${BRAINBAR_UPDATE_JOBS:-}" ]; then
|
|
244
|
+
ruby -rjson -e 's=JSON.parse(File.read(ARGV[0])); exit 1 unless Time.now.to_f-s.fetch("at") < 10 && s.fetch("busy").empty?' "$BRAINBAR_UPDATE_JOBS" || return 0
|
|
245
|
+
fi
|
|
246
|
+
pgrep -fl 'maintenance-calendar|maintenance_calendar|backup_daily|backup-daily' | grep -vE 'pytest|\.worktrees/|/t3/worktrees/' | grep -q .
|
|
247
|
+
}
|
|
248
|
+
preflight() {
|
|
249
|
+
if busy; then state waiting 'Will update when background jobs finish'; exit 0; fi
|
|
250
|
+
if [ -e "$ROOT/cancel-$OP" ]; then rm -f "$ROOT/cancel-$OP"; state cancelled; exit 0; fi
|
|
251
|
+
}
|
|
252
|
+
# Homebrew release/tap metadata fetch; no model call.
|
|
253
|
+
fetch() { brew update </dev/null; }
|
|
254
|
+
pin() {
|
|
255
|
+
brew info --json=v2 --formula etanhey/layers/brainlayer > "$LOCK/formula.json"
|
|
256
|
+
brew info --json=v2 --cask etanhey/layers/brainbar > "$LOCK/cask.json"
|
|
257
|
+
ruby -rjson -e 'f=JSON.parse(File.read(ARGV[0])).fetch("formulae").fetch(0); c=JSON.parse(File.read(ARGV[1])).fetch("casks").fetch(0); abort "Tap versions changed; check again" unless f.fetch("versions").fetch("stable")==ARGV[2] && c.fetch("version")==ARGV[2]' "$LOCK/formula.json" "$LOCK/cask.json" "$V"
|
|
258
|
+
rm -f "$LOCK/formula.json" "$LOCK/cask.json"
|
|
259
|
+
}
|
|
260
|
+
if [ "$HANDOFF" = 0 ]; then
|
|
261
|
+
preflight
|
|
262
|
+
fetch
|
|
263
|
+
pin
|
|
264
|
+
fi
|
|
265
|
+
PREFIX=$(brew --prefix)
|
|
266
|
+
CLI="$PREFIX/bin/brainlayer"
|
|
267
|
+
K="$PREFIX/Cellar/brainlayer/$V"
|
|
268
|
+
if [ "$HANDOFF" = 0 ]; then
|
|
269
|
+
[ -w "$(dirname "$APP")" ] || { FAILURE="Homebrew needs permission. Run: brew upgrade --formula etanhey/layers/brainlayer; brew reinstall --cask etanhey/layers/brainbar"; echo "$FAILURE" >&2; exit 1; }
|
|
270
|
+
pin
|
|
271
|
+
preflight
|
|
272
|
+
STEP=formula
|
|
273
|
+
state "$STEP"
|
|
274
|
+
MUTATED=1
|
|
275
|
+
brew upgrade --formula etanhey/layers/brainlayer </dev/null
|
|
276
|
+
else
|
|
277
|
+
STEP=formula
|
|
278
|
+
MUTATED=1
|
|
279
|
+
fi
|
|
280
|
+
INSTALL=$(find "$K" -path '*/brainlayer/launchd/install.sh' -print -quit)
|
|
281
|
+
[ -n "$INSTALL" ]
|
|
282
|
+
# The app copied its helper from the OLD keg; the rest of the update runs the new release's steps.
|
|
283
|
+
NEXT="$(dirname "$INSTALL")/brainbar-update.sh"
|
|
284
|
+
if [ "$HANDOFF" = 0 ] && [ -f "$NEXT" ] && ! cmp -s "$NEXT" "$0" && grep -qx '# brainbar-update-handoff: 1' "$NEXT"; then
|
|
285
|
+
exec /bin/bash "$NEXT" --custody-held --handoff "$V" "$OP"
|
|
286
|
+
fi
|
|
287
|
+
STEP=signatures
|
|
288
|
+
state "$STEP"
|
|
289
|
+
bash "$(dirname "$INSTALL")/release-verify-signatures.sh" "$K"
|
|
290
|
+
STEP=consolidate
|
|
291
|
+
state "$STEP"
|
|
292
|
+
bash "$INSTALL" consolidate
|
|
293
|
+
STEP=backup
|
|
294
|
+
state "$STEP"
|
|
295
|
+
OLD=$("$PLIST" -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")
|
|
296
|
+
[[ "$OLD" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
|
|
297
|
+
BACKUP="$ROOT/Backups.noindex/BrainBar.backup-$OLD-$OP.app"
|
|
298
|
+
SAVED="$ROOT/Backups.noindex/LaunchAgents-$OP"
|
|
299
|
+
mkdir -p "$SAVED"
|
|
300
|
+
for label in $LABELS; do cp -p "$AGENTS/$label.plist" "$SAVED/$label.plist"; done
|
|
301
|
+
STEP=stop
|
|
302
|
+
state "$STEP"
|
|
303
|
+
stop_brainbar
|
|
304
|
+
# Never move a running bundle: the move happens only after every BrainBar process has exited.
|
|
305
|
+
mv "$APP" "$BACKUP"
|
|
306
|
+
STEP=cask
|
|
307
|
+
state "$STEP"
|
|
308
|
+
brew reinstall --cask etanhey/layers/brainbar </dev/null
|
|
309
|
+
[ -d "$APP" ]
|
|
310
|
+
restore_agents
|
|
311
|
+
STEP=approval
|
|
312
|
+
state "$STEP"
|
|
313
|
+
approve
|
|
314
|
+
# One activation, after Homebrew has returned and both plists are in place.
|
|
315
|
+
STEP=activate
|
|
316
|
+
state "$STEP"
|
|
317
|
+
"$CLI" brainbar activate --verify --timeout 90
|
|
318
|
+
STEP=health
|
|
319
|
+
state "$STEP"
|
|
320
|
+
[ "$("$PLIST" -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")" = "$V" ]
|
|
321
|
+
# activate --verify above performs the real MCP handshake, not a socket-presence test.
|
|
322
|
+
state success
|
|
323
|
+
# Prune only a backup explicitly recorded by a previous successful invocation.
|
|
324
|
+
if [ -f "$ROOT/last-backup" ]; then
|
|
325
|
+
previous_backup=$(cat "$ROOT/last-backup")
|
|
326
|
+
case "$previous_backup" in "$ROOT/Backups.noindex/BrainBar.backup-"*.app)
|
|
327
|
+
if [ "$previous_backup" != "$BACKUP" ]; then
|
|
328
|
+
ruby -rfileutils -e 'FileUtils.remove_entry_secure(ARGV[0]) if File.directory?(ARGV[0])' "$previous_backup" || echo "Could not prune $previous_backup" >&2
|
|
329
|
+
fi ;;
|
|
330
|
+
esac
|
|
331
|
+
fi
|
|
332
|
+
printf '%s\n' "$BACKUP" > "$ROOT/last-backup"
|
|
333
|
+
rm -f "$SAVED"/*.plist && rmdir "$SAVED" || echo "Could not prune $SAVED" >&2
|
|
@@ -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.
|
|
6
|
+
"version": "1.6.13",
|
|
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.
|
|
17
|
+
"version": "1.6.13",
|
|
18
18
|
"runtimeHint": "pipx",
|
|
19
19
|
"transport": {
|
|
20
20
|
"type": "stdio"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
__version__ = "1.6.
|
|
5
|
+
__version__ = "1.6.13"
|
|
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 = "ca4e5022081a11daf2ae05fcd0fc924fe2a20fe1"
|
|
@@ -26,6 +26,10 @@ class CloneUnavailable(RuntimeError):
|
|
|
26
26
|
"""Stop this clone attempt; clean owned files before a capacity-checked fallback."""
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
class CloneIntegrityError(CloneUnavailable):
|
|
30
|
+
"""Private SQLite recovery found corruption; the caller owns its diagnostic alert."""
|
|
31
|
+
|
|
32
|
+
|
|
29
33
|
def divergence_allowance_bytes() -> int:
|
|
30
34
|
from .backup_heavy_gate import _number
|
|
31
35
|
|
|
@@ -175,6 +179,11 @@ def snapshot(source: Path, target: Path, *, validate=None, max_recovery_bytes: i
|
|
|
175
179
|
raise CloneUnavailable(f"private WAL recovery incomplete: {result}")
|
|
176
180
|
if recovered.execute("PRAGMA journal_mode=DELETE").fetchone()[0] != "delete":
|
|
177
181
|
raise CloneUnavailable("private clone did not become standalone")
|
|
182
|
+
except sqlite3.OperationalError:
|
|
183
|
+
# Busy/locked/interrupted recovery is unavailable, not evidence of corruption.
|
|
184
|
+
raise
|
|
185
|
+
except sqlite3.DatabaseError as exc:
|
|
186
|
+
raise CloneIntegrityError(f"private clone recovery failed: {type(exc).__name__}: {exc}") from exc
|
|
178
187
|
finally:
|
|
179
188
|
recovered.close()
|
|
180
189
|
if validate is not None:
|
|
@@ -976,6 +976,7 @@ def _sweep_stale_clones(output_dir: Path) -> list[str]:
|
|
|
976
976
|
|
|
977
977
|
|
|
978
978
|
def _sweep_clones_before_admission(output_dir: Path) -> None:
|
|
979
|
+
"""Reclaim stale clones under the staging lock before measuring (cheap: stat and unlink only)."""
|
|
979
980
|
if not output_dir.exists() or output_dir.is_symlink():
|
|
980
981
|
return
|
|
981
982
|
fd = os.open(output_dir / ".backup.lock", os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW, 0o600)
|
|
@@ -989,11 +990,39 @@ def _sweep_clones_before_admission(output_dir: Path) -> None:
|
|
|
989
990
|
os.close(fd)
|
|
990
991
|
|
|
991
992
|
|
|
993
|
+
def _reclaim_verified_raws_before_admission(output_dir: Path, failed_proofs: set[tuple] | None = None) -> list[str]:
|
|
994
|
+
"""Unlink archive-bound raws under the staging lock so their blocks and COW reserve stop deferring admission.
|
|
995
|
+
|
|
996
|
+
Runs the run's full binding/durability proof, never receipt metadata alone. The gate calls this
|
|
997
|
+
only when reclaiming could admit, and passes `failed_proofs` across its retries so a raw whose
|
|
998
|
+
proof failed is not re-proved until the raw or its archive changes.
|
|
999
|
+
"""
|
|
1000
|
+
if not output_dir.exists() or output_dir.is_symlink():
|
|
1001
|
+
return []
|
|
1002
|
+
fd = os.open(output_dir / ".backup.lock", os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW, 0o600)
|
|
1003
|
+
try:
|
|
1004
|
+
try:
|
|
1005
|
+
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
1006
|
+
except BlockingIOError:
|
|
1007
|
+
return []
|
|
1008
|
+
deleted, _ = _cleanup_raw_snapshots(output_dir, failed_proofs=failed_proofs)
|
|
1009
|
+
finally:
|
|
1010
|
+
os.close(fd)
|
|
1011
|
+
for name in deleted:
|
|
1012
|
+
print(f"Backup removed verified raw snapshot before admission: {output_dir / name}", flush=True)
|
|
1013
|
+
return deleted
|
|
1014
|
+
|
|
1015
|
+
|
|
992
1016
|
def _clone_growth_reserve_bytes(output_dir: Path, db_size: int) -> int:
|
|
993
1017
|
"""Existing blocks are in free_now; reserve the full possible COW divergence."""
|
|
1018
|
+
return sum(size for _, size in _clone_growth_reserves(output_dir, db_size))
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
def _clone_growth_reserves(output_dir: Path, db_size: int) -> list[tuple[Path, int]]:
|
|
1022
|
+
"""Keep the reservation inventory available for admission diagnostics."""
|
|
994
1023
|
paths = list(output_dir.glob(".brainlayer-clone-*/snapshot.db"))
|
|
995
1024
|
paths += [p for p in output_dir.glob("*.db") if _parse_uncompressed_snapshot_date(p.name)]
|
|
996
|
-
|
|
1025
|
+
reserves = []
|
|
997
1026
|
for path in paths:
|
|
998
1027
|
parent = path.parent.lstat()
|
|
999
1028
|
info = path.lstat()
|
|
@@ -1003,8 +1032,8 @@ def _clone_growth_reserve_bytes(output_dir: Path, db_size: int) -> int:
|
|
|
1003
1032
|
and stat.S_ISREG(info.st_mode)
|
|
1004
1033
|
and info.st_uid == os.getuid()
|
|
1005
1034
|
):
|
|
1006
|
-
|
|
1007
|
-
return
|
|
1035
|
+
reserves.append((path, max(db_size, info.st_size)))
|
|
1036
|
+
return reserves
|
|
1008
1037
|
|
|
1009
1038
|
|
|
1010
1039
|
def _owned_temp_inventory(output_dir: Path) -> list[tuple[str, int]]:
|
|
@@ -1477,11 +1506,31 @@ def _retained_raw_snapshot_names(output_dir: Path) -> list[str]:
|
|
|
1477
1506
|
return sorted(path.name for path in output_dir.glob("*.db") if _parse_uncompressed_snapshot_date(path.name))
|
|
1478
1507
|
|
|
1479
1508
|
|
|
1480
|
-
def
|
|
1509
|
+
def _raw_proof_key(output_dir: Path, raw: Path) -> tuple:
|
|
1510
|
+
"""The raw's and its archive's file identity; any change to either re-arms a failed proof."""
|
|
1511
|
+
|
|
1512
|
+
def identity(path: Path) -> tuple[int, ...]:
|
|
1513
|
+
info = os.lstat(path)
|
|
1514
|
+
return info.st_dev, info.st_ino, info.st_size, info.st_mtime_ns, info.st_ctime_ns
|
|
1515
|
+
|
|
1516
|
+
archive_name = _raw_archive_name(output_dir, raw)
|
|
1517
|
+
return raw.name, identity(raw), archive_name, identity(output_dir / archive_name)
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
def _cleanup_raw_snapshots(output_dir: Path, *, failed_proofs: set[tuple] | None = None) -> tuple[list[str], list[str]]:
|
|
1481
1521
|
deleted, retained_raw = [], []
|
|
1482
1522
|
for raw in sorted(output_dir.glob("*.db")):
|
|
1483
1523
|
if _parse_uncompressed_snapshot_date(raw.name) is None:
|
|
1484
1524
|
continue
|
|
1525
|
+
key = None
|
|
1526
|
+
if failed_proofs is not None:
|
|
1527
|
+
try:
|
|
1528
|
+
key = _raw_proof_key(output_dir, raw)
|
|
1529
|
+
except OSError:
|
|
1530
|
+
key = None # No archive or a vanished file: the proof itself fails at once.
|
|
1531
|
+
if key is not None and key in failed_proofs:
|
|
1532
|
+
retained_raw.append(raw.name)
|
|
1533
|
+
continue
|
|
1485
1534
|
try:
|
|
1486
1535
|
_remove_raw_with_verified_archive(output_dir, raw)
|
|
1487
1536
|
deleted.append(raw.name)
|
|
@@ -1489,6 +1538,8 @@ def _cleanup_raw_snapshots(output_dir: Path) -> tuple[list[str], list[str]]:
|
|
|
1489
1538
|
raise
|
|
1490
1539
|
except (OSError, EOFError, ValueError, RuntimeError, subprocess.CalledProcessError):
|
|
1491
1540
|
retained_raw.append(raw.name)
|
|
1541
|
+
if key is not None and failed_proofs is not None:
|
|
1542
|
+
failed_proofs.add(key)
|
|
1492
1543
|
return deleted, retained_raw
|
|
1493
1544
|
|
|
1494
1545
|
|
|
@@ -2194,6 +2245,18 @@ def create_sqlite_backup_artifact(
|
|
|
2194
2245
|
minimum_free=MIN_RAW_FREE_BYTES + backup_clone.host_reserve_bytes(),
|
|
2195
2246
|
)
|
|
2196
2247
|
|
|
2248
|
+
def report_clone_integrity(reason):
|
|
2249
|
+
from .job_alerts import report
|
|
2250
|
+
|
|
2251
|
+
try:
|
|
2252
|
+
report("backup-clone-integrity", reason, replace_reason=True)
|
|
2253
|
+
except TimeoutError:
|
|
2254
|
+
raise
|
|
2255
|
+
except OSError as exc:
|
|
2256
|
+
import logging
|
|
2257
|
+
|
|
2258
|
+
logging.getLogger(__name__).warning("Could not update backup-clone-integrity alert: %s", exc)
|
|
2259
|
+
|
|
2197
2260
|
def validate_clone(path):
|
|
2198
2261
|
started = time.monotonic()
|
|
2199
2262
|
try:
|
|
@@ -2201,16 +2264,10 @@ def create_sqlite_backup_artifact(
|
|
|
2201
2264
|
except sqlite3.Error as exc:
|
|
2202
2265
|
check = f"{type(exc).__name__}: {exc}"
|
|
2203
2266
|
if check != "ok":
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
report(
|
|
2207
|
-
"backup-clone-integrity", f"APFS clone integrity_check failed: {check}", replace_reason=True
|
|
2208
|
-
)
|
|
2267
|
+
report_clone_integrity(f"APFS clone integrity_check failed: {check}")
|
|
2209
2268
|
raise backup_clone.CloneUnavailable(f"clone integrity_check failed: {check}")
|
|
2210
2269
|
clone_validation.update(integrity=check, seconds=time.monotonic() - started)
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
report("backup-clone-integrity", None)
|
|
2270
|
+
report_clone_integrity(None)
|
|
2214
2271
|
|
|
2215
2272
|
try:
|
|
2216
2273
|
promoted = backup_clone.snapshot(
|
|
@@ -2222,6 +2279,8 @@ def create_sqlite_backup_artifact(
|
|
|
2222
2279
|
clone_guard(force=True)
|
|
2223
2280
|
except backup_clone.CloneUnavailable as exc:
|
|
2224
2281
|
_check_backup_interrupt()
|
|
2282
|
+
if isinstance(exc, backup_clone.CloneIntegrityError):
|
|
2283
|
+
report_clone_integrity(str(exc))
|
|
2225
2284
|
clone_fallback = str(exc)
|
|
2226
2285
|
print(f"Backup snapshot fallback: {clone_fallback}; using VACUUM INTO", flush=True)
|
|
2227
2286
|
if raw_snapshot.exists():
|
|
@@ -68,7 +68,12 @@ def _pressure_reason(swap_limit: float, load_limit: float) -> str | None:
|
|
|
68
68
|
return None
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
def _disk_reason(host: str) -> str | None:
|
|
71
|
+
def _disk_reason(host: str, failed_proofs: set[tuple] | None = None) -> str | None:
|
|
72
|
+
"""Measure first; prove and reclaim dated raws only when that could admit, then measure again.
|
|
73
|
+
|
|
74
|
+
`failed_proofs` is the gate's per-process memo of raw/archive identities whose proof failed,
|
|
75
|
+
so a retry never re-hashes an unchanged pair.
|
|
76
|
+
"""
|
|
72
77
|
from . import backup_daily as backup
|
|
73
78
|
|
|
74
79
|
floor_gib = float(os.environ.get("BRAINLAYER_BACKUP_HEAVY_HOST_FREE_GIB", 40 if host == "m4" else 0))
|
|
@@ -93,17 +98,32 @@ def _disk_reason(host: str) -> str | None:
|
|
|
93
98
|
clone_mode=clone_mode,
|
|
94
99
|
**(backup.backup_clone.budget(backup.get_db_path()) if clone_mode else {}),
|
|
95
100
|
)
|
|
96
|
-
required = peak + backup._clone_growth_reserve_bytes(staging, 0) + math.ceil(floor_gib * 1024**3)
|
|
97
101
|
volume_path = staging
|
|
98
102
|
while not volume_path.exists():
|
|
99
103
|
volume_path = volume_path.parent
|
|
100
|
-
|
|
104
|
+
|
|
105
|
+
def measure() -> tuple[list[tuple[Path, int]], int, int]:
|
|
106
|
+
reserves = backup._clone_growth_reserves(staging, 0)
|
|
107
|
+
required = peak + sum(size for _, size in reserves) + math.ceil(floor_gib * 1024**3)
|
|
108
|
+
free = backup.disk_space.measure_disk_space(volume_path, include_available=False).free_now_bytes
|
|
109
|
+
return reserves, required, free
|
|
110
|
+
|
|
111
|
+
reserves, required, free = measure()
|
|
112
|
+
if free < required:
|
|
113
|
+
# Upper bound of what reclaiming the dated raws can return: each raw's COW reserve plus
|
|
114
|
+
# its allocated blocks (a byte copy frees them; a clone shares them and frees less).
|
|
115
|
+
reclaimable = sum(size + path.lstat().st_blocks * 512 for path, size in reserves if path.parent == staging)
|
|
116
|
+
if free + reclaimable >= required and backup._reclaim_verified_raws_before_admission(
|
|
117
|
+
staging, failed_proofs
|
|
118
|
+
):
|
|
119
|
+
reserves, required, free = measure()
|
|
101
120
|
except (OSError, RuntimeError, ValueError) as exc:
|
|
102
121
|
return f"disk space measurement unavailable: {type(exc).__name__}"
|
|
103
122
|
if free < required:
|
|
123
|
+
reserved = ", ".join(f"{path.relative_to(staging)}={size / 1024**3:.3f} GiB" for path, size in reserves)
|
|
104
124
|
return (
|
|
105
125
|
f"disk space needs {required / 1024**3:.3f} GiB, has {free / 1024**3:.3f} GiB "
|
|
106
|
-
f"(peak plus {floor_gib:g} GiB host floor)"
|
|
126
|
+
f"(peak plus {floor_gib:g} GiB host floor)" + (f"; retained COW reserves: {reserved}" if reserved else "")
|
|
107
127
|
)
|
|
108
128
|
return None
|
|
109
129
|
|
|
@@ -111,7 +131,9 @@ def _disk_reason(host: str) -> str | None:
|
|
|
111
131
|
def _upload_peak_bytes(staging: Path, *, full: bool) -> int:
|
|
112
132
|
"""Count only NEW verification files; existing local archives already occupy free space.
|
|
113
133
|
|
|
114
|
-
|
|
134
|
+
This estimator only inspects receipt metadata; it never hashes payloads or mutates
|
|
135
|
+
the journal. The caller sweeps stale clones before measuring, and proves and reclaims
|
|
136
|
+
dated raws under the staging lock only when that could admit.
|
|
115
137
|
Budget all possible pending candidates because upload-only can drain them sequentially.
|
|
116
138
|
"""
|
|
117
139
|
from . import backup_daily as backup
|
|
@@ -181,7 +203,9 @@ def backup_heavy_gate(*, deadline: float | None = None, job_key: str = "backup-d
|
|
|
181
203
|
last_reason = "pressure admission window elapsed"
|
|
182
204
|
owned = False
|
|
183
205
|
admitted = False
|
|
206
|
+
waited = False
|
|
184
207
|
previous = {}
|
|
208
|
+
failed_proofs: set[tuple] = set() # Raw/archive identities whose reclaim proof failed this gate run.
|
|
185
209
|
|
|
186
210
|
def stopped(signum, _frame):
|
|
187
211
|
raise SystemExit(128 + signum)
|
|
@@ -197,8 +221,10 @@ def backup_heavy_gate(*, deadline: float | None = None, job_key: str = "backup-d
|
|
|
197
221
|
f"last cause: {last_reason}"
|
|
198
222
|
)
|
|
199
223
|
past_window = time.monotonic() >= pressure_window_end
|
|
200
|
-
|
|
201
|
-
reason =
|
|
224
|
+
# Pressure first: the disk check may prove and reclaim raws, which is heavy I/O.
|
|
225
|
+
reason = (None if past_window else _pressure_reason(swap_limit, load_limit)) or _disk_reason(
|
|
226
|
+
host, failed_proofs
|
|
227
|
+
)
|
|
202
228
|
if reason is None:
|
|
203
229
|
try:
|
|
204
230
|
lock.mkdir()
|
|
@@ -206,13 +232,17 @@ def backup_heavy_gate(*, deadline: float | None = None, job_key: str = "backup-d
|
|
|
206
232
|
reason = "heavy lock held by another lane (never cleared by backup)"
|
|
207
233
|
else:
|
|
208
234
|
owned = True
|
|
209
|
-
|
|
210
|
-
|
|
235
|
+
reason = (None if past_window else _pressure_reason(swap_limit, load_limit)) or _disk_reason(
|
|
236
|
+
host, failed_proofs
|
|
237
|
+
)
|
|
211
238
|
if reason is None and time.monotonic() < expires:
|
|
212
239
|
admitted = True
|
|
213
240
|
_log(log, "took")
|
|
214
241
|
if past_window:
|
|
215
242
|
_log(log, f"running past window after {window:g}s; ignoring swap/load: {last_reason}")
|
|
243
|
+
if waited:
|
|
244
|
+
# Clear only the wait alert this gate raised; an older one waits for the backup's end.
|
|
245
|
+
report(job_key, None)
|
|
216
246
|
yield
|
|
217
247
|
return
|
|
218
248
|
if reason is None:
|
|
@@ -224,6 +254,7 @@ def backup_heavy_gate(*, deadline: float | None = None, job_key: str = "backup-d
|
|
|
224
254
|
f"backup waiting behind the heavy-work gate since {since}: {reason}",
|
|
225
255
|
replace_reason=True,
|
|
226
256
|
)
|
|
257
|
+
waited = True
|
|
227
258
|
last_reason = reason
|
|
228
259
|
_log(log, f"deferred: {reason}; retry in {retry:g}s")
|
|
229
260
|
print(f"brainlayer backup deferred: {reason}", flush=True)
|