diff --git a/scripts/launchd/com.brainlayer.enrichment.plist b/scripts/launchd/com.brainlayer.enrichment.plist index 36f93650..f8ac4d34 100644 --- a/scripts/launchd/com.brainlayer.enrichment.plist +++ b/scripts/launchd/com.brainlayer.enrichment.plist @@ -6,23 +6,20 @@ com.brainlayer.enrichment + Runs a supervised shell loop so the one-shot enrich command stays continuous. --> ProgramArguments - __BRAINLAYER_BIN__ - enrich - --mode - realtime - --limit - 50 + /bin/zsh + -lc + cd "__BRAINLAYER_DIR__" || exit 1; while true; do "__BRAINLAYER_BIN__" enrich --mode realtime --limit 200000 --since-hours 87600; sleep 5; done WorkingDirectory __BRAINLAYER_DIR__ - StartInterval - 600 + KeepAlive + StandardOutPath __HOME__/Library/Logs/brainlayer-enrichment.log @@ -40,9 +37,9 @@ BRAINLAYER_STALL_TIMEOUT 300 BRAINLAYER_ENRICH_RATE - 50 + 15 BRAINLAYER_ENRICH_CONCURRENCY - 10 + 18 BRAINLAYER_GEMINI_SERVICE_TIER flex GOOGLE_API_KEY diff --git a/tests/test_enrichment_controller.py b/tests/test_enrichment_controller.py index f659dc4a..c6e850b9 100644 --- a/tests/test_enrichment_controller.py +++ b/tests/test_enrichment_controller.py @@ -8,6 +8,7 @@ """ import json +import plistlib import sqlite3 import sys import threading @@ -1160,36 +1161,42 @@ def test_enrichment_plist_uses_realtime_mode(): assert "realtime" in content -def test_enrichment_plist_has_start_interval(): +def _load_enrichment_plist(): from pathlib import Path plist_path = Path(__file__).parent.parent / "scripts" / "launchd" / "com.brainlayer.enrichment.plist" - content = plist_path.read_text() - assert "StartInterval" in content - assert "600" in content + return plistlib.loads(plist_path.read_bytes()) -def test_enrichment_plist_invokes_cli_enrich_entrypoint(): - from pathlib import Path +def test_enrichment_plist_uses_continuous_keepalive_shape(): + plist = _load_enrichment_plist() - plist_path = Path(__file__).parent.parent / "scripts" / "launchd" / "com.brainlayer.enrichment.plist" - content = plist_path.read_text() - assert "__BRAINLAYER_BIN__" in content - assert "enrich" in content - assert "realtime" in content - assert "50" in content + assert plist["KeepAlive"] is True + assert "StartInterval" not in plist -def test_enrichment_plist_uses_low_priority_library_logs_and_flex_tier(): - from pathlib import Path - - plist_path = Path(__file__).parent.parent / "scripts" / "launchd" / "com.brainlayer.enrichment.plist" - content = plist_path.read_text() - assert "Nice" in content - assert "10" in content - assert "__HOME__/Library/Logs/brainlayer-enrichment.log" in content - assert "BRAINLAYER_GEMINI_SERVICE_TIER" in content - assert "flex" in content +def test_enrichment_plist_invokes_cli_enrich_entrypoint(): + plist = _load_enrichment_plist() + + args = plist["ProgramArguments"] + assert args[:2] == ["/bin/zsh", "-lc"] + command = args[2] + assert "__BRAINLAYER_BIN__" in command + assert "while true" in command + assert "enrich --mode realtime" in command + assert "--limit 200000" in command + assert "--since-hours 87600" in command + + +def test_enrichment_plist_matches_validated_flex_realtime_profile(): + plist = _load_enrichment_plist() + env = plist["EnvironmentVariables"] + + assert plist["Nice"] == 10 + assert plist["StandardOutPath"] == "__HOME__/Library/Logs/brainlayer-enrichment.log" + assert env["BRAINLAYER_ENRICH_RATE"] == "15" + assert env["BRAINLAYER_ENRICH_CONCURRENCY"] == "18" + assert env["BRAINLAYER_GEMINI_SERVICE_TIER"] == "flex" def test_launchd_installer_supports_enrichment_load_and_unload():