fix(enrichment): restore validated flex launchd profile#271
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 56 minutes.Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e54bc7ab52
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <key>KeepAlive</key> | ||
| <true/> |
There was a problem hiding this comment.
Avoid KeepAlive for one-shot enrich command
Switching this LaunchAgent to KeepAlive causes a restart loop because brainlayer enrich --mode realtime is a one-pass command (it returns after enrich_realtime(...) finishes, including the common no-candidates path). In that steady-state case the process exits quickly, launchd repeatedly respawns it, and macOS can classify it as “respawning too fast” and stop relaunching, which means realtime enrichment can silently stall until manual intervention while also churning logs/CPU. A timed trigger (or an internal sleep loop in the process) is needed for this command shape.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Addressed the review findings in
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 40c0388. Configure here.
| <string>50</string> | ||
| <string>15</string> | ||
| <key>BRAINLAYER_ENRICH_CONCURRENCY</key> | ||
| <string>10</string> |
There was a problem hiding this comment.
Missing BRAINLAYER_ENRICH_BACKEND=gemini environment variable in plist
High Severity
The PR description explicitly identifies BRAINLAYER_ENRICH_BACKEND being unset as one of the four configuration drift issues to fix ("unset instead of explicit gemini"), but the plist EnvironmentVariables dict never adds BRAINLAYER_ENRICH_BACKEND=gemini. Without it, _detect_default_backend() in enrichment.py will auto-detect mlx on Apple Silicon instead of gemini, meaning the service runs against the wrong backend entirely. The regression test test_enrichment_plist_matches_validated_flex_realtime_profile also omits any assertion for this variable, so the drift will go undetected.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 40c0388. Configure here.


Summary
scripts/launchd/com.brainlayer.enrichment.plistStartIntervalticks to continuousKeepAlive, make the Gemini backend explicit, and restoreRATE=15/CONCURRENCY=18Why
The May 2 audit showed the live enrichment service had drifted away from the last validated fast configuration:
BRAINLAYER_ENRICH_RATE=50instead of15BRAINLAYER_ENRICH_CONCURRENCY=10instead of18BRAINLAYER_ENRICH_BACKENDunset instead of explicitgeminiStartIntervallaunch shape instead of the continuous detached realtime path validated on April 12Audit reference:
/Users/etanheyman/Gits/orchestrator/docs.local/handoffs/2026-05-02-enrichment-perf-audit.mdVerification
uv run --extra dev pytest -q tests/test_enrichment_controller.py -k 'enrichment_plist or launchagent'bash scripts/run_tests.sh@orcClaude
Note
Medium Risk
Changes the enrichment LaunchAgent from periodic runs to a continuously running KeepAlive loop and significantly alters enrich parameters (limit/window) plus rate/concurrency tuning, which could affect resource usage, API costs, and runtime stability.
Overview
Restores the enrichment
LaunchAgentto a continuousKeepAlive-driven loop (via/bin/zsh -lc ... while true ...) instead of aStartIntervaltick, so realtime enrichment stays running.Updates the realtime command to use a much larger
--limitand long--since-hourswindow, and resets the validated flex tuning in the plist env (BRAINLAYER_ENRICH_RATE=15,BRAINLAYER_ENRICH_CONCURRENCY=18,BRAINLAYER_GEMINI_SERVICE_TIER=flex).Tightens tests to parse the plist with
plistliband assert the new KeepAlive shape, program arguments, and env values to prevent future drift.Reviewed by Cursor Bugbot for commit 40c0388. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Restore validated flex launchd profile for enrichment with continuous loop and updated concurrency
StartInterval 600withKeepAlive truein com.brainlayer.enrichment.plist, switching from periodic scheduling to a persistent process managed by launchd.ProgramArgumentsto invoke/bin/zsh -lcwith awhile trueloop runningenrich --mode realtime --limit 200000 --since-hours 87600with a 5-second sleep between runs.BRAINLAYER_ENRICH_RATEfrom50to15andBRAINLAYER_ENRICH_CONCURRENCYfrom10to18in environment variables.plistliband replace theStartIntervalassertion withKeepAlive-based and zsh-loop assertions.Macroscope summarized 40c0388.