brainlayer 1.5.99__tar.gz → 1.6.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {brainlayer-1.5.99 → brainlayer-1.6.1}/.gitignore +5 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/PKG-INFO +2 -2
- {brainlayer-1.5.99 → brainlayer-1.6.1}/README.md +1 -1
- {brainlayer-1.5.99 → brainlayer-1.6.1}/pyproject.toml +2 -2
- {brainlayer-1.5.99 → brainlayer-1.6.1}/server.json +2 -2
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/__init__.py +1 -1
- brainlayer-1.6.1/src/brainlayer/_build.py +1 -0
- brainlayer-1.6.1/src/brainlayer/agent_census.py +258 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/agent_provenance.py +27 -2
- brainlayer-1.6.1/src/brainlayer/agy_attribution.py +188 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/cli/__init__.py +9 -2
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/enrichment_quality_benchmark.py +0 -21
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/health_check.py +26 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/health_facts.py +80 -6
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/health_verdict.py +129 -5
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/jsonl_backup.py +75 -3
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/kg_repo.py +2 -3
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/enrichment_prompts.py +4 -1
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/sanitize.py +4 -1
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/semantic_style.py +4 -1
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/style_embed.py +4 -1
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/watcher.py +88 -1
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/watcher_bridge.py +20 -1
- brainlayer-1.5.99/src/brainlayer/_build.py +0 -1
- {brainlayer-1.5.99 → brainlayer-1.6.1}/LICENSE +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/brainlayer-version-check.sh +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/hotlane_brainbar_daemon.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/backup-daily.sh +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/brainlayer-env-run.sh +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/brainlayer.env.example +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.backup-daily.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.daemon.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.decay.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.drain.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.health-check.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.hotlane-brainbar.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.index.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.jsonl-backup.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.log-cap.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.maintenance-nightly.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.maintenance-weekly.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.maintenance.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.observability.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.p0-counter.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.repair-fts.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.t3-ingest.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.throughput-watchdog.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.tier0-watchdog.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.wal-checkpoint.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.brainlayer.watch.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/com.etanhey.brainlayer-fleet-watchdog.plist +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/fleet-watchdog.sh +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/install.sh +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/jsonl-backup.sh +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/launchd/throughput-watchdog.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/release-verify-signatures.sh +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/scripts/tier0-watchdog.sh +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/__main__.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/_helpers.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/agent_profiles.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/alarm.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/archive_collapse.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/archive_lifecycle.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/backup_daily.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/backup_retention_invariant.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/badge_state.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/bitemporal.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/brainbar_activation.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/brainbar_auto_activation.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/brainbar_hybrid_helper.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/brainbar_identity.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/cachedelete_purge.swift +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/calibrate.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/chunk_origin.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/chunk_origin_backfill.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/chunk_origin_wipe.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/chunk_write.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/classify.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/claude_paths.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/cli/wizard.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/cli_jobs.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/cli_new.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/cloud_backfill.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/clustering.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/codex_zst.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/component_jobs.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/config.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/consolidation_plan.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/content_class.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/content_hash_repair.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/correction_judge.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/data/agents_registry.yaml +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/data/sandbox_seeds/skill-eval-baseline.json +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/db_shrink.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/decay.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/decay_backfill.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/decay_job.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/dedupe.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/dedupe_merge.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/deploy_drift.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/disk_space.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/doctor.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/drain.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/drain_liveness.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/drive_credentials.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/embeddings.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/engine.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/enrichment_replay.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/__init__.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/abcde_enrich_runner.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/abcde_variants.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/abcde_variants.yaml +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/benchmark.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/enrichment_gold.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/enrichment_graders.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/enrichment_judge.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/enrichment_llm_judge.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/experiment_store.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/fixtures/README.md +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/labeling/enrichment-labeler.html +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/__init__.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/__main__.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/baseline_store.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/cli.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/models.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/phoenix_client.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/regression_gate.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/phoenix_gate/triggers.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/eval/pilot_artifact_report.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/fallback_replay.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/git_learning.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/hook_python.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/hooks/__init__.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/hooks/indexer.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/hotlane_budget.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/import_sweep.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/index_admission.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/index_budget.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/index_completeness.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/index_new.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/index_watchdog.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/ingest/__init__.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/ingest/codex.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/ingest/codex_manifest.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/ingest/t3.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/ingest_denylist.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/ingest_guard.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/isolation_proof.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/job_alerts.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/job_lifecycle_health.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/jobs.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/kg/__init__.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/kg_cleanup.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/kg_judge.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/kg_promotion.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/kg_review_session.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/kg_session_finish.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/kg_session_harvest.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/launchd_consolidation.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/launchd_install.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/launchd_primitive.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/launchd_revert.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/launcher_policy_reconcile.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/lexical_defense.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/lexical_defense_dictionary.json +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/linkedin_import.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/log_cap.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/maintenance.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/maintenance_calendar.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/maintenance_control.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/maintenance_upload_recovery.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp/__init__.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp/_format.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp/_shared.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp/enrich_handler.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp/entity_handler.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp/palette.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp/search_handler.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp/store_handler.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp/tags_handler.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp_socket_config.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/mcp_stdio_bridge.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/memory_types.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/migrate.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/migration_custody.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/migration_journal.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/migration_runtime.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/notification_policy.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/observability_backup.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/observability_indexes.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/observability_surface.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/observability_transport.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/p0_longitudinal_count.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/parent_death.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/paths.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pause.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/phonetic.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/__init__.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/agent_enrichment.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/analyze_communication.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/batch_extraction.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/brain_graph.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/chat_tags.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/chunk.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/classify.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/cloud_scrub.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/cluster_sampling.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/code_intelligence.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/correction_detection.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/correction_mining.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/digest.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/enrichment_results.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/enrichment_tiers.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/entity_extraction.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/entity_resolution.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/extract.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/extract_claude_desktop.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/extract_corrections.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/extract_markdown.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/extract_whatsapp.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/frustration_mining.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/git_overlay.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/kg_extraction.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/kg_extraction_groq.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/longitudinal_analyzer.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/obsidian_export.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/operation_grouping.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/plan_linking.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/rate_limiter.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/relation_backfill.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/relation_verification.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/secret_scrub.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/sentiment.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/session_history.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/style_index.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/tag_entity_promotion.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/temporal_chains.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/time_batcher.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/unified_timeline.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/pipeline/write_queue.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/policy_reconcile.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/provenance.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/provenance_autosupersede.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/provenance_integration.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/queue_io.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/queue_merge.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/readonly_snapshot.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/reembed_backfill.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/retired_services.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/runtime_store.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/sandbox_db.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/schema_ddl_ledger.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/scoping.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/scrub_at_rest.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/search_fanout.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/search_profile.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/search_repo.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/search_response.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/service_supervisor.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/session_repo.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/setup.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/socket_hygiene.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/source_class_migration.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/spotlight.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/storage.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/store.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/supervisor_adapters.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/supervisor_child.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/supervisor_diagnostics.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/supervisor_guard.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/supervisor_jobs.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/system_prompt_guard.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/t3_linkage_alarm.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/t3_provenance.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/t3_sources.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/tag_normalization.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/taxonomy.json +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/telemetry.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/timestamp_iso.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/types.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/vector_store.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/wal_checkpoint.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/writer_policy.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/writer_telemetry.py +0 -0
- {brainlayer-1.5.99 → brainlayer-1.6.1}/src/brainlayer/zstd_stream.py +0 -0
|
@@ -52,6 +52,11 @@ data/
|
|
|
52
52
|
.tmp-*
|
|
53
53
|
grill*/
|
|
54
54
|
docs.local/
|
|
55
|
+
# Per-PR bot-review scratch and agent briefs belong in docs.local/, never the repo root
|
|
56
|
+
/BUGBOT_*.md
|
|
57
|
+
/bugbot-review-notes.md
|
|
58
|
+
/SLICE-*-BRIEF.md
|
|
59
|
+
/progress.txt
|
|
55
60
|
|
|
56
61
|
# Internal planning docs (contain cross-repo references)
|
|
57
62
|
docs/plan/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: brainlayer
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.1
|
|
4
4
|
Summary: Persistent local memory for AI agents — 16 BrainBar MCP tools, semantic search, knowledge graph, SQLite
|
|
5
5
|
Project-URL: Homepage, https://brainlayer.etanheyman.com
|
|
6
6
|
Project-URL: Repository, https://github.com/EtanHey/brainlayer
|
|
@@ -375,7 +375,7 @@ brainlayer search "query" # Semantic + keyword search
|
|
|
375
375
|
brainlayer stats # Database statistics
|
|
376
376
|
brainlayer brain-export # Brain graph JSON for visualization
|
|
377
377
|
brainlayer export-obsidian # Export to Obsidian vault
|
|
378
|
-
brainlayer dashboard # Interactive TUI
|
|
378
|
+
brainlayer dashboard # Interactive TUI (source checkout only)
|
|
379
379
|
```
|
|
380
380
|
|
|
381
381
|
## Testing
|
|
@@ -300,7 +300,7 @@ brainlayer search "query" # Semantic + keyword search
|
|
|
300
300
|
brainlayer stats # Database statistics
|
|
301
301
|
brainlayer brain-export # Brain graph JSON for visualization
|
|
302
302
|
brainlayer export-obsidian # Export to Obsidian vault
|
|
303
|
-
brainlayer dashboard # Interactive TUI
|
|
303
|
+
brainlayer dashboard # Interactive TUI (source checkout only)
|
|
304
304
|
```
|
|
305
305
|
|
|
306
306
|
## Testing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "brainlayer"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.6.1"
|
|
4
4
|
description = "Persistent local memory for AI agents — 16 BrainBar MCP tools, semantic search, knowledge graph, SQLite"
|
|
5
5
|
license = {text = "Apache-2.0"}
|
|
6
6
|
readme = "README.md"
|
|
@@ -111,7 +111,7 @@ target-version = "py311"
|
|
|
111
111
|
|
|
112
112
|
[tool.ruff.lint]
|
|
113
113
|
select = ["E", "F", "I", "W"]
|
|
114
|
-
ignore = ["E402", "E501", "E741", "
|
|
114
|
+
ignore = ["E402", "E501", "E741", "F841"]
|
|
115
115
|
per-file-ignores = {"src/brainlayer/cli/__init__.py" = ["F401"]}
|
|
116
116
|
|
|
117
117
|
[tool.pytest.ini_options]
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "io.github.etanhey/brainlayer",
|
|
4
4
|
"title": "BrainLayer",
|
|
5
5
|
"description": "Persistent local memory for AI agents \u2014 semantic search, knowledge graph, and 16 BrainBar MCP tools with ToolAnnotations over SQLite.",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.6.1",
|
|
7
7
|
"websiteUrl": "https://brainlayer.etanheyman.com",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/EtanHey/brainlayer",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"registryType": "pypi",
|
|
15
15
|
"registryBaseUrl": "https://pypi.org",
|
|
16
16
|
"identifier": "brainlayer",
|
|
17
|
-
"version": "1.
|
|
17
|
+
"version": "1.6.1",
|
|
18
18
|
"runtimeHint": "pipx",
|
|
19
19
|
"transport": {
|
|
20
20
|
"type": "stdio"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
__version__ = "1.
|
|
5
|
+
__version__ = "1.6.1"
|
|
6
6
|
# Git sha the distributed package was built from; stamped by the release build, None in a source tree.
|
|
7
7
|
# scripts/sprint_gate.py reads it in "keg" mode to prove the served package is the code under test.
|
|
8
8
|
# No runtime `str | None` annotation: launchd/install.sh imports this under /usr/bin/python3 (3.9).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
BUILD_SHA = "0a33f0dda7828df58af5f5641bd2dbf0486ce0ac"
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"""Known-agent census: a local agent from a fixed list is running and writes where BrainLayer does not watch.
|
|
2
|
+
|
|
3
|
+
The ingest guarantee (formal/ingest-coverage) holds only for wired roots, and new sources are wired on
|
|
4
|
+
purpose, never auto-detected. This is the honest add-on: it names a running agent from the list below
|
|
5
|
+
that wrote one of its transcripts, during its current run, outside every watched root. It cannot see an
|
|
6
|
+
agent that is not on the list.
|
|
7
|
+
|
|
8
|
+
Result, per agent: ``found`` lists ``"<agent>: <root>"`` for each agent measured positive this check;
|
|
9
|
+
``incomplete`` names each agent that could not be measured (a running instance without a start time, or a
|
|
10
|
+
scan cut short by a cap or a read error, with nothing found). Every other listed agent is a measured
|
|
11
|
+
negative, including one that is not running. The verdict merges per agent, so an incomplete agent keeps
|
|
12
|
+
whatever was last measured for it.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
import re
|
|
19
|
+
import time
|
|
20
|
+
from collections.abc import Callable, Iterable, Sequence
|
|
21
|
+
from dataclasses import dataclass
|
|
22
|
+
from fnmatch import fnmatch
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
MAX_ENTRIES = 5000
|
|
26
|
+
MAX_DEPTH = 6
|
|
27
|
+
START_SLACK_S = 1.0 # ps reports elapsed time in whole seconds
|
|
28
|
+
_INTERPRETER = re.compile(r"^(node|nodejs|bun|deno|python[0-9.]*)$")
|
|
29
|
+
|
|
30
|
+
ProcessStarts = Callable[[Sequence[int]], "dict[int, float] | None"]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True)
|
|
34
|
+
class Census:
|
|
35
|
+
found: list[str] # "<agent>: <root>", measured positive this check
|
|
36
|
+
incomplete: list[str] # agent names that could not be measured this check
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def complete(self) -> bool:
|
|
40
|
+
return not self.incomplete
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass(frozen=True)
|
|
44
|
+
class KnownAgent:
|
|
45
|
+
name: str
|
|
46
|
+
executables: tuple[str, ...] # argv[0] basename of the agent's own binary
|
|
47
|
+
entry_scripts: tuple[str, ...] # script an interpreter runs: a basename, or a path fragment containing "/"
|
|
48
|
+
transcripts: tuple[tuple[str, str], ...] # (home-relative root, fnmatch pattern for the path under it)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
KNOWN_AGENTS: tuple[KnownAgent, ...] = (
|
|
52
|
+
KnownAgent("claude", ("claude",), ("claude", "@anthropic-ai/claude-code/"), ((".claude/projects", "*.jsonl"),)),
|
|
53
|
+
KnownAgent("codex", ("codex",), ("codex", "@openai/codex/"), ((".codex/sessions", "*rollout-*.jsonl"),)),
|
|
54
|
+
KnownAgent(
|
|
55
|
+
"cursor-agent", ("cursor-agent",), ("cursor-agent",), ((".cursor/projects", "*/agent-transcripts/*.jsonl"),)
|
|
56
|
+
),
|
|
57
|
+
# Antigravity (agy), the current Gemini agent: the `agy` CLI, or T3's agy ACP server. It exports each
|
|
58
|
+
# conversation to brain/<conversation>/.system_generated/logs/transcript_full.jsonl. Gemini CLI is
|
|
59
|
+
# legacy and deprecated and is not listed.
|
|
60
|
+
KnownAgent(
|
|
61
|
+
"gemini",
|
|
62
|
+
("agy", "agy_acp_server.par"),
|
|
63
|
+
(),
|
|
64
|
+
((".gemini/antigravity-cli/brain", "*/.system_generated/logs/transcript_full.jsonl"),),
|
|
65
|
+
),
|
|
66
|
+
KnownAgent("opencode", ("opencode",), ("opencode", "opencode-ai/"), ((".local/share/opencode/storage", "*.json"),)),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# Options that take the next token as their value (it is never the script).
|
|
71
|
+
_VALUE_OPTIONS = {
|
|
72
|
+
"python": {"-W", "-X", "-Q", "--check-hash-based-pycs"},
|
|
73
|
+
"node": {"-r", "--require", "--import", "--loader", "--experimental-loader", "-C", "--conditions"},
|
|
74
|
+
"bun": {"-r", "--preload", "--cwd", "--config", "-c"},
|
|
75
|
+
"deno": {"-c", "--config", "-L", "--log-level", "--import-map"},
|
|
76
|
+
}
|
|
77
|
+
# Options whose value is inline code or a module: the process runs no script at all.
|
|
78
|
+
_CODE_OPTIONS = {
|
|
79
|
+
"python": ("-c", "-m"),
|
|
80
|
+
"node": ("-e", "--eval", "-p", "--print"),
|
|
81
|
+
"bun": ("-e", "--eval", "-p", "--print"),
|
|
82
|
+
"deno": (),
|
|
83
|
+
}
|
|
84
|
+
_SUBCOMMANDS = {"bun": {"run"}, "deno": {"run"}} # a subcommand that is followed by a script
|
|
85
|
+
_NO_SCRIPT = {"bun": {"x", "exec", "eval", "repl", "install", "add", "test"}, "deno": {"eval", "repl", "test", "task"}}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _family(exe: str) -> str:
|
|
89
|
+
return "python" if exe.startswith("python") else "node" if exe in ("node", "nodejs") else exe
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _entry_script(tokens: Sequence[str]) -> str | None:
|
|
93
|
+
"""The script an interpreter runs, reading its options; None for ``-c``/``-e``/``-m``/``eval`` and the like."""
|
|
94
|
+
family = _family(os.path.basename(tokens[0]))
|
|
95
|
+
rest, i = list(tokens[1:]), 0
|
|
96
|
+
while i < len(rest):
|
|
97
|
+
token = rest[i]
|
|
98
|
+
if token == "--":
|
|
99
|
+
return rest[i + 1] if i + 1 < len(rest) else None
|
|
100
|
+
if any(
|
|
101
|
+
token == code
|
|
102
|
+
or (code.startswith("--") and token.startswith(code + "="))
|
|
103
|
+
or (not code.startswith("--") and token.startswith(code))
|
|
104
|
+
for code in _CODE_OPTIONS.get(family, ())
|
|
105
|
+
):
|
|
106
|
+
return None # inline code, e.g. ``python3 -c gemini`` or ``node -egemini``: not a script
|
|
107
|
+
if family == "python" and token.startswith("-") and not token.startswith("--") and len(token) > 1:
|
|
108
|
+
# A cluster such as -uc: -c or -m anywhere ends the options with code; -W/-X take a value.
|
|
109
|
+
for j, char in enumerate(token[1:], 1):
|
|
110
|
+
if char in "cm":
|
|
111
|
+
return None
|
|
112
|
+
if char in "WXQ":
|
|
113
|
+
i += 1 if j < len(token) - 1 else 2
|
|
114
|
+
break
|
|
115
|
+
else:
|
|
116
|
+
i += 1
|
|
117
|
+
continue
|
|
118
|
+
if token.startswith("-"):
|
|
119
|
+
i += 2 if token in _VALUE_OPTIONS.get(family, ()) else 1
|
|
120
|
+
continue
|
|
121
|
+
if token in _NO_SCRIPT.get(family, ()):
|
|
122
|
+
return None
|
|
123
|
+
if token in _SUBCOMMANDS.get(family, ()):
|
|
124
|
+
i += 1
|
|
125
|
+
continue
|
|
126
|
+
return token
|
|
127
|
+
return None
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _is_agent(tokens: Sequence[str], agent: KnownAgent) -> bool:
|
|
131
|
+
exe = os.path.basename(tokens[0])
|
|
132
|
+
if exe in agent.executables:
|
|
133
|
+
return True
|
|
134
|
+
if not _INTERPRETER.match(exe):
|
|
135
|
+
return False
|
|
136
|
+
script = _entry_script(tokens)
|
|
137
|
+
if script is None:
|
|
138
|
+
return False
|
|
139
|
+
return any(
|
|
140
|
+
(fragment in script) if "/" in fragment else os.path.basename(script) == fragment
|
|
141
|
+
for fragment in agent.entry_scripts
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def running_agents(ps_output: str, agents: Sequence[KnownAgent] = KNOWN_AGENTS) -> dict[str, list[int]]:
|
|
146
|
+
"""PIDs per agent from a ``ps axo pid=,command=`` snapshot, matched on the executable or entry script only."""
|
|
147
|
+
found: dict[str, list[int]] = {}
|
|
148
|
+
for line in ps_output.splitlines():
|
|
149
|
+
parts = line.split()
|
|
150
|
+
if len(parts) < 2 or not parts[0].isdigit():
|
|
151
|
+
continue
|
|
152
|
+
for agent in agents:
|
|
153
|
+
if _is_agent(parts[1:], agent):
|
|
154
|
+
found.setdefault(agent.name, []).append(int(parts[0]))
|
|
155
|
+
return found
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def parse_etime(value: str) -> int | None:
|
|
159
|
+
"""``ps`` elapsed time ``[[dd-]hh:]mm:ss`` in seconds."""
|
|
160
|
+
days, _, clock = value.strip().rpartition("-")
|
|
161
|
+
fields = clock.split(":")
|
|
162
|
+
if not 2 <= len(fields) <= 3 or not all(f.isdigit() for f in fields) or (days and not days.isdigit()):
|
|
163
|
+
return None
|
|
164
|
+
seconds = 0
|
|
165
|
+
for field in fields:
|
|
166
|
+
seconds = seconds * 60 + int(field)
|
|
167
|
+
return seconds + int(days or 0) * 86400
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _watched(path: Path, watch_roots: Iterable[Path]) -> bool:
|
|
171
|
+
return any(path == root or root in path.parents for root in watch_roots)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def _scan(root: Path, pattern: str, since: float) -> tuple[bool, bool]:
|
|
175
|
+
"""(found, complete): a file under ``root`` matching ``pattern`` modified at or after ``since``."""
|
|
176
|
+
stack, looked, complete = [(root, 0)], 0, True
|
|
177
|
+
while stack:
|
|
178
|
+
directory, depth = stack.pop()
|
|
179
|
+
try:
|
|
180
|
+
with os.scandir(directory) as entries:
|
|
181
|
+
for entry in entries:
|
|
182
|
+
looked += 1
|
|
183
|
+
if looked > MAX_ENTRIES:
|
|
184
|
+
return False, False
|
|
185
|
+
if entry.is_dir(follow_symlinks=False):
|
|
186
|
+
if depth + 1 >= MAX_DEPTH:
|
|
187
|
+
complete = False
|
|
188
|
+
else:
|
|
189
|
+
stack.append((Path(entry.path), depth + 1))
|
|
190
|
+
elif entry.is_file(follow_symlinks=False):
|
|
191
|
+
relative = Path(entry.path).relative_to(root).as_posix()
|
|
192
|
+
if fnmatch(relative, pattern) and entry.stat().st_mtime >= since:
|
|
193
|
+
return True, True
|
|
194
|
+
except OSError:
|
|
195
|
+
complete = False
|
|
196
|
+
return False, complete
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def unindexed_agents(
|
|
200
|
+
ps_output: str,
|
|
201
|
+
*,
|
|
202
|
+
home: Path,
|
|
203
|
+
watch_roots: Iterable[Path],
|
|
204
|
+
process_starts: ProcessStarts | None = None,
|
|
205
|
+
agents: Sequence[KnownAgent] = KNOWN_AGENTS,
|
|
206
|
+
) -> Census:
|
|
207
|
+
"""Per agent: wrote a transcript during its current run under a root nobody watches, did not, or unknown."""
|
|
208
|
+
running = running_agents(ps_output, agents)
|
|
209
|
+
if not running:
|
|
210
|
+
return Census([], [])
|
|
211
|
+
watched = [Path(root).expanduser() for root in watch_roots]
|
|
212
|
+
pids = sorted(pid for found in running.values() for pid in found)
|
|
213
|
+
starts = process_starts(pids) if process_starts is not None else None
|
|
214
|
+
found, incomplete = [], []
|
|
215
|
+
for agent in agents:
|
|
216
|
+
if agent.name not in running:
|
|
217
|
+
continue
|
|
218
|
+
known = [starts[pid] for pid in running[agent.name] if starts and pid in starts]
|
|
219
|
+
unwatched = [
|
|
220
|
+
(home / rel, pattern)
|
|
221
|
+
for rel, pattern in agent.transcripts
|
|
222
|
+
if (home / rel).is_dir() and not _watched(home / rel, watched)
|
|
223
|
+
]
|
|
224
|
+
if not unwatched:
|
|
225
|
+
continue
|
|
226
|
+
if not known:
|
|
227
|
+
incomplete.append(agent.name) # running, but no start time to tie a write to this run
|
|
228
|
+
continue
|
|
229
|
+
since = min(known) - START_SLACK_S # any write newer than a live instance's start
|
|
230
|
+
complete = True
|
|
231
|
+
for root, pattern in unwatched:
|
|
232
|
+
hit, scanned = _scan(root, pattern, since)
|
|
233
|
+
if hit:
|
|
234
|
+
found.append(f"{agent.name}: {root}")
|
|
235
|
+
break
|
|
236
|
+
complete = complete and scanned
|
|
237
|
+
else:
|
|
238
|
+
if not complete:
|
|
239
|
+
incomplete.append(agent.name)
|
|
240
|
+
return Census(found, incomplete)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def ps_process_starts(run: Callable[[list[str]], object], now: Callable[[], float] = time.time) -> ProcessStarts:
|
|
244
|
+
"""Start times (epoch seconds) from ``ps -o pid=,etime= -p <pids>``; None when ps cannot answer."""
|
|
245
|
+
|
|
246
|
+
def starts(pids: Sequence[int]) -> dict[int, float] | None:
|
|
247
|
+
result = run(["ps", "-o", "pid=,etime=", "-p", ",".join(str(pid) for pid in pids)])
|
|
248
|
+
if getattr(result, "returncode", 1) not in (0, 1): # 1: some PIDs already gone
|
|
249
|
+
return None
|
|
250
|
+
at, out = now(), {}
|
|
251
|
+
for line in str(getattr(result, "stdout", "") or "").splitlines():
|
|
252
|
+
parts = line.split()
|
|
253
|
+
elapsed = parse_etime(parts[1]) if len(parts) == 2 and parts[0].isdigit() else None
|
|
254
|
+
if elapsed is not None:
|
|
255
|
+
out[int(parts[0])] = at - elapsed
|
|
256
|
+
return out
|
|
257
|
+
|
|
258
|
+
return starts
|
|
@@ -14,8 +14,9 @@ from dataclasses import dataclass
|
|
|
14
14
|
from pathlib import Path
|
|
15
15
|
from typing import Literal, cast
|
|
16
16
|
|
|
17
|
+
from .agy_attribution import agy_conversation, read_conversation_agent
|
|
17
18
|
from .content_class import normalize_content_class
|
|
18
|
-
from .ingest_denylist import is_denylisted, memory_reader_attribution
|
|
19
|
+
from .ingest_denylist import MEMORY_READER_ATTRIBUTIONS, is_denylisted, memory_reader_attribution
|
|
19
20
|
from .t3_provenance import T3_APP_SESSION, CompactCodexHeader, is_t3_app_initiated_codex_session
|
|
20
21
|
|
|
21
22
|
SearchPolicy = Literal["KEEP", "ISOLATE", "OUT"]
|
|
@@ -107,6 +108,12 @@ def _under_cursor_agent_transcripts(path: Path) -> bool:
|
|
|
107
108
|
return "agent-transcripts" in parts[cursor_index + 1 :]
|
|
108
109
|
|
|
109
110
|
|
|
111
|
+
def _under_agy_brain(path: Path) -> bool:
|
|
112
|
+
"""Under `.gemini/antigravity-cli/brain/<conversation>/`, where Antigravity (agy), the current Gemini
|
|
113
|
+
agent, exports transcripts."""
|
|
114
|
+
return agy_conversation(path) is not None
|
|
115
|
+
|
|
116
|
+
|
|
110
117
|
def _project_segment(path: Path) -> str | None:
|
|
111
118
|
parts = path.parts
|
|
112
119
|
for index, part in enumerate(parts[:-1]):
|
|
@@ -180,8 +187,13 @@ def classify_provenance(
|
|
|
180
187
|
t3_projection_version: int | None = None,
|
|
181
188
|
t3_session_identity_cache: dict | None = None,
|
|
182
189
|
t3_session_header: tuple[dict, int] | CompactCodexHeader | None = None,
|
|
190
|
+
agy_agent: str | None = None,
|
|
183
191
|
) -> ProvenanceDecision:
|
|
184
|
-
"""Classify a source path into an auditable provenance search policy.
|
|
192
|
+
"""Classify a source path into an auditable provenance search policy.
|
|
193
|
+
|
|
194
|
+
`agy_agent` is the agent an AgyAttributionGate resolved for an agy conversation; without it the
|
|
195
|
+
summary row is read here, and an unreadable or absent row leaves the source class unresolved.
|
|
196
|
+
"""
|
|
185
197
|
del content_class
|
|
186
198
|
path = _abspath(source_file)
|
|
187
199
|
|
|
@@ -213,6 +225,18 @@ def classify_provenance(
|
|
|
213
225
|
if _under_cursor_agent_transcripts(path):
|
|
214
226
|
return ProvenanceDecision("cursor-gather", "KEEP", "Cursor coding-agent transcript root", "cli-agent")
|
|
215
227
|
|
|
228
|
+
if _under_agy_brain(path):
|
|
229
|
+
agent = agy_agent
|
|
230
|
+
if agent is None:
|
|
231
|
+
read_ok, agent = read_conversation_agent(path)
|
|
232
|
+
if not read_ok or agent is None:
|
|
233
|
+
return ProvenanceDecision("gemini-session", "KEEP", "agy attribution unresolved", None)
|
|
234
|
+
if agent in MEMORY_READER_ATTRIBUTIONS:
|
|
235
|
+
return ProvenanceDecision("recon-agent", "OUT", f"agy memory-reader agent {agent}", "brain-worker")
|
|
236
|
+
if agent:
|
|
237
|
+
return ProvenanceDecision("gemini-subagent", "KEEP", f"agy agent {agent}", "subagent")
|
|
238
|
+
return ProvenanceDecision("gemini-session", "KEEP", "Antigravity (agy) conversation", "cli-agent")
|
|
239
|
+
|
|
216
240
|
if _under_provider_sessions(path, ".gemini"):
|
|
217
241
|
return ProvenanceDecision("gemini-session", "KEEP", "Gemini session root stays searchable", "cli-agent")
|
|
218
242
|
|
|
@@ -247,6 +271,7 @@ def derive_source_class(
|
|
|
247
271
|
"codex-session": "cli-agent",
|
|
248
272
|
"cursor-gather": "cli-agent",
|
|
249
273
|
"gemini-session": "cli-agent",
|
|
274
|
+
"gemini-subagent": "subagent",
|
|
250
275
|
"direct-session": "cli-agent",
|
|
251
276
|
}
|
|
252
277
|
if provenance_class in provenance_map:
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""Which agent an Antigravity (agy) conversation ran as, decided before any of it is indexed.
|
|
2
|
+
|
|
3
|
+
agy, the current Gemini agent, records `agy --agent <name>` per conversation in its own
|
|
4
|
+
`~/.gemini/antigravity-cli/conversation_summaries.db` (`agent_name`). That row is the only
|
|
5
|
+
attribution read; task text never is. The gate fails closed so a memory reader is never indexed
|
|
6
|
+
as an interactive session:
|
|
7
|
+
|
|
8
|
+
* a row exists: index under that agent ("" = no agent); a memory reader is classed brain-worker
|
|
9
|
+
downstream and never indexed;
|
|
10
|
+
* the DB was read and the row is absent: hold until `AGY_ATTRIBUTION_WAIT_S` after the FIRST time
|
|
11
|
+
the conversation was seen unresolved (persisted, so restarts and appends do not extend it), then
|
|
12
|
+
index with no agent;
|
|
13
|
+
* the DB could not be read: hold, retry on the next flush, and alarm `agy_attribution_unreadable`.
|
|
14
|
+
|
|
15
|
+
One race remains: a conversation indexed after its deadline whose row later names a memory reader.
|
|
16
|
+
Its later turns are not indexed, and the conversation is recorded under `late_memory_readers` in the
|
|
17
|
+
state file; chunks already written are not deleted.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import json
|
|
23
|
+
import logging
|
|
24
|
+
import os
|
|
25
|
+
import sqlite3
|
|
26
|
+
import tempfile
|
|
27
|
+
import time
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
from typing import Any
|
|
30
|
+
|
|
31
|
+
from .alarm import BrainLayerAlarm, raise_alarm
|
|
32
|
+
from .ingest_denylist import MEMORY_READER_ATTRIBUTIONS
|
|
33
|
+
|
|
34
|
+
logger = logging.getLogger(__name__)
|
|
35
|
+
|
|
36
|
+
AGY_ATTRIBUTION_WAIT_S = 600.0
|
|
37
|
+
# State entries older than this are dropped. fallback_indexed only saves re-deciding a conversation;
|
|
38
|
+
# a re-decision is idempotent (content-hash chunk ids), it only holds new turns for one more deadline.
|
|
39
|
+
STATE_MAX_AGE_S = 30 * 24 * 3600.0
|
|
40
|
+
STATE_FILE_NAME = "agy-attribution.json"
|
|
41
|
+
_cache: dict[str, tuple[tuple[int, ...], dict[str, str]]] = {}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _now() -> float:
|
|
45
|
+
return time.time()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def agy_conversation(source_file: str | Path) -> tuple[Path, str] | None:
|
|
49
|
+
"""(summaries DB, conversation id) for a file under `.gemini/antigravity-cli/brain/<conversation>/`."""
|
|
50
|
+
parts = Path(os.path.abspath(os.path.expanduser(str(source_file)))).parts
|
|
51
|
+
for index, part in enumerate(parts[:-3]):
|
|
52
|
+
if part == ".gemini" and parts[index + 1 : index + 3] == ("antigravity-cli", "brain"):
|
|
53
|
+
return Path(*parts[: index + 2], "conversation_summaries.db"), parts[index + 3]
|
|
54
|
+
return None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def read_conversation_agent(source_file: str | Path) -> tuple[bool, str | None]:
|
|
58
|
+
"""(read ok, agent name or None when the row is absent). A failed read is never cached."""
|
|
59
|
+
located = agy_conversation(source_file)
|
|
60
|
+
if located is None:
|
|
61
|
+
return True, None
|
|
62
|
+
store, conversation = located
|
|
63
|
+
signature: list[int] = []
|
|
64
|
+
for candidate in (store, store.with_name(store.name + "-wal")):
|
|
65
|
+
try:
|
|
66
|
+
stat = candidate.stat()
|
|
67
|
+
signature += [stat.st_mtime_ns, stat.st_size]
|
|
68
|
+
except OSError:
|
|
69
|
+
signature += [0, 0]
|
|
70
|
+
cached = _cache.get(str(store))
|
|
71
|
+
if cached is not None and cached[0] == tuple(signature):
|
|
72
|
+
return True, cached[1].get(conversation)
|
|
73
|
+
try:
|
|
74
|
+
conn = sqlite3.connect(f"file:{store}?mode=ro", uri=True, timeout=1.0)
|
|
75
|
+
try:
|
|
76
|
+
agents = {
|
|
77
|
+
str(row_id): str(agent or "")
|
|
78
|
+
for row_id, agent in conn.execute("SELECT conversation_id, agent_name FROM conversation_summaries")
|
|
79
|
+
}
|
|
80
|
+
finally:
|
|
81
|
+
conn.close()
|
|
82
|
+
except (sqlite3.Error, OSError) as error:
|
|
83
|
+
logger.warning("agy attribution unreadable: %s: %s", store, error)
|
|
84
|
+
return False, None
|
|
85
|
+
_cache[str(store)] = (tuple(signature), agents)
|
|
86
|
+
return True, agents.get(conversation)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class AgyAttributionGate:
|
|
90
|
+
"""Decides, per agy conversation, whether its turns may be indexed now and as which agent."""
|
|
91
|
+
|
|
92
|
+
def __init__(self, state_path: str | Path):
|
|
93
|
+
self.state_path = Path(state_path)
|
|
94
|
+
self._alarmed: set[str] = set()
|
|
95
|
+
self.state: dict[str, dict[str, Any]] = {"first_seen": {}, "fallback_indexed": {}, "late_memory_readers": {}}
|
|
96
|
+
try:
|
|
97
|
+
loaded = json.loads(self.state_path.read_text(encoding="utf-8"))
|
|
98
|
+
except (OSError, ValueError):
|
|
99
|
+
loaded = {}
|
|
100
|
+
for key in self.state:
|
|
101
|
+
if isinstance(loaded, dict) and isinstance(loaded.get(key), dict):
|
|
102
|
+
self.state[key] = dict(loaded[key])
|
|
103
|
+
|
|
104
|
+
def _prune(self) -> None:
|
|
105
|
+
"""Drop entries whose transcript is gone, and first_seen/fallback_indexed entries past STATE_MAX_AGE_S."""
|
|
106
|
+
cutoff = _now() - STATE_MAX_AGE_S
|
|
107
|
+
for section, ages in (("first_seen", True), ("fallback_indexed", True), ("late_memory_readers", False)):
|
|
108
|
+
kept = {}
|
|
109
|
+
for conversation, entry in self.state[section].items():
|
|
110
|
+
if not isinstance(entry, dict):
|
|
111
|
+
continue
|
|
112
|
+
path, at = entry.get("path"), entry.get("at")
|
|
113
|
+
if not isinstance(path, str) or not os.path.exists(path):
|
|
114
|
+
continue
|
|
115
|
+
if ages and (not isinstance(at, (int, float)) or at < cutoff):
|
|
116
|
+
continue
|
|
117
|
+
kept[conversation] = entry
|
|
118
|
+
self.state[section] = kept
|
|
119
|
+
|
|
120
|
+
def save(self) -> None:
|
|
121
|
+
"""Prune, then replace the state file atomically (unique temp file, fsync, rename)."""
|
|
122
|
+
self._prune()
|
|
123
|
+
self.state_path.parent.mkdir(parents=True, exist_ok=True)
|
|
124
|
+
fd, temp = tempfile.mkstemp(dir=self.state_path.parent, prefix=f".{self.state_path.name}.")
|
|
125
|
+
try:
|
|
126
|
+
with os.fdopen(fd, "w", encoding="utf-8") as handle:
|
|
127
|
+
json.dump(self.state, handle, indent=2, sort_keys=True)
|
|
128
|
+
handle.flush()
|
|
129
|
+
os.fsync(handle.fileno())
|
|
130
|
+
os.replace(temp, self.state_path)
|
|
131
|
+
except BaseException:
|
|
132
|
+
Path(temp).unlink(missing_ok=True)
|
|
133
|
+
raise
|
|
134
|
+
|
|
135
|
+
def _entry(self, source_file: str | Path, **extra: Any) -> dict[str, Any]:
|
|
136
|
+
return {"at": _now(), "path": os.path.abspath(os.path.expanduser(str(source_file))), **extra}
|
|
137
|
+
|
|
138
|
+
def resolve(self, source_file: str | Path) -> tuple[bool, str | None]:
|
|
139
|
+
"""(index now, agent): agent is the row's agent_name, "" after the deadline, None while held."""
|
|
140
|
+
located = agy_conversation(source_file)
|
|
141
|
+
if located is None:
|
|
142
|
+
return True, None
|
|
143
|
+
store, conversation = located
|
|
144
|
+
read_ok, agent = read_conversation_agent(source_file)
|
|
145
|
+
if not read_ok or agent is None:
|
|
146
|
+
# The deadline counts from the first unresolved sighting, readable or not.
|
|
147
|
+
first_seen = self.state["first_seen"].get(conversation)
|
|
148
|
+
if not isinstance(first_seen, dict):
|
|
149
|
+
self.state["first_seen"][conversation] = first_seen = self._entry(source_file)
|
|
150
|
+
self.save()
|
|
151
|
+
if not read_ok:
|
|
152
|
+
if str(store) not in self._alarmed:
|
|
153
|
+
self._alarmed.add(str(store))
|
|
154
|
+
try:
|
|
155
|
+
raise_alarm(
|
|
156
|
+
"agy_attribution_unreadable",
|
|
157
|
+
"agy conversations are held: their agent attribution could not be read",
|
|
158
|
+
{"store": str(store), "conversation": conversation},
|
|
159
|
+
severity="warning",
|
|
160
|
+
)
|
|
161
|
+
except BrainLayerAlarm:
|
|
162
|
+
pass
|
|
163
|
+
return False, None
|
|
164
|
+
self._alarmed.discard(str(store))
|
|
165
|
+
if agent is not None:
|
|
166
|
+
changed = self.state["first_seen"].pop(conversation, None) is not None
|
|
167
|
+
if (
|
|
168
|
+
agent in MEMORY_READER_ATTRIBUTIONS
|
|
169
|
+
and conversation in self.state["fallback_indexed"]
|
|
170
|
+
and conversation not in self.state["late_memory_readers"]
|
|
171
|
+
):
|
|
172
|
+
logger.warning(
|
|
173
|
+
"agy conversation %s was indexed after its attribution deadline and is now named "
|
|
174
|
+
"memory reader %r; no further turns are indexed, existing chunks are kept",
|
|
175
|
+
conversation,
|
|
176
|
+
agent,
|
|
177
|
+
)
|
|
178
|
+
self.state["late_memory_readers"][conversation] = self._entry(source_file, agent=agent)
|
|
179
|
+
changed = True
|
|
180
|
+
if changed:
|
|
181
|
+
self.save()
|
|
182
|
+
return True, agent
|
|
183
|
+
if _now() - float(first_seen["at"]) < AGY_ATTRIBUTION_WAIT_S:
|
|
184
|
+
return False, None
|
|
185
|
+
if conversation not in self.state["fallback_indexed"]:
|
|
186
|
+
self.state["fallback_indexed"][conversation] = self._entry(source_file)
|
|
187
|
+
self.save()
|
|
188
|
+
return True, ""
|
|
@@ -1220,10 +1220,17 @@ def dashboard() -> None:
|
|
|
1220
1220
|
app.run()
|
|
1221
1221
|
|
|
1222
1222
|
except ImportError as e:
|
|
1223
|
-
|
|
1224
|
-
|
|
1223
|
+
# The wheel and sdist exclude src/brainlayer/dashboard on purpose
|
|
1224
|
+
# (tests/test_engine_package_boundary.py), so an installed BrainLayer never has it.
|
|
1225
|
+
rprint(f"[red]Dashboard unavailable: {e}[/]")
|
|
1226
|
+
rprint(
|
|
1227
|
+
"[yellow]The dashboard ships only in a source checkout: in a BrainLayer clone, "
|
|
1228
|
+
"run `pip install -e .`, then `brainlayer dashboard`.[/]"
|
|
1229
|
+
)
|
|
1230
|
+
raise typer.Exit(1) from e
|
|
1225
1231
|
except Exception as e:
|
|
1226
1232
|
rprint(f"[red]Dashboard error: {e}[/]")
|
|
1233
|
+
raise typer.Exit(1) from e
|
|
1227
1234
|
|
|
1228
1235
|
|
|
1229
1236
|
@app.command()
|
|
@@ -536,12 +536,6 @@ Now output exactly one JSON object matching the required keys. Do not copy JSON
|
|
|
536
536
|
"""
|
|
537
537
|
|
|
538
538
|
|
|
539
|
-
def _apply_chat_template(tokenizer: Any, prompt: str) -> str:
|
|
540
|
-
apply_template = getattr(tokenizer, "apply_chat_template", None)
|
|
541
|
-
if apply_template is None:
|
|
542
|
-
return prompt
|
|
543
|
-
|
|
544
|
-
|
|
545
539
|
def _normalize_enrichment_for_benchmark(enrichment: Mapping[str, Any]) -> dict[str, Any]:
|
|
546
540
|
result = dict(enrichment)
|
|
547
541
|
if isinstance(result.get("importance"), float) and math.isfinite(result["importance"]):
|
|
@@ -557,21 +551,6 @@ def _normalize_enrichment_for_benchmark(enrichment: Mapping[str, Any]) -> dict[s
|
|
|
557
551
|
if "version_scope" not in result:
|
|
558
552
|
result["version_scope"] = None
|
|
559
553
|
return result
|
|
560
|
-
try:
|
|
561
|
-
rendered = apply_template(
|
|
562
|
-
[
|
|
563
|
-
{
|
|
564
|
-
"role": "system",
|
|
565
|
-
"content": "You are a strict JSON enrichment function. You output only valid JSON.",
|
|
566
|
-
},
|
|
567
|
-
{"role": "user", "content": prompt},
|
|
568
|
-
],
|
|
569
|
-
tokenize=False,
|
|
570
|
-
add_generation_prompt=True,
|
|
571
|
-
)
|
|
572
|
-
return rendered if isinstance(rendered, str) else prompt
|
|
573
|
-
except Exception:
|
|
574
|
-
return prompt
|
|
575
554
|
|
|
576
555
|
|
|
577
556
|
def _connect_readonly(db_path: str | Path) -> sqlite3.Connection:
|