Skip to content

fix(enrichment): restore validated flex launchd profile#271

Merged
EtanHey merged 2 commits intomainfrom
fix/enrichment-plist-drift
May 2, 2026
Merged

fix(enrichment): restore validated flex launchd profile#271
EtanHey merged 2 commits intomainfrom
fix/enrichment-plist-drift

Conversation

@EtanHey
Copy link
Copy Markdown
Owner

@EtanHey EtanHey commented May 2, 2026

Summary

  • restore the validated April 12 flex realtime launchd profile in scripts/launchd/com.brainlayer.enrichment.plist
  • switch the launchd shape from StartInterval ticks to continuous KeepAlive, make the Gemini backend explicit, and restore RATE=15 / CONCURRENCY=18
  • add regression coverage so future drift in the plist shape or validated flex tuning fails tests

Why

The May 2 audit showed the live enrichment service had drifted away from the last validated fast configuration:

  • BRAINLAYER_ENRICH_RATE=50 instead of 15
  • BRAINLAYER_ENRICH_CONCURRENCY=10 instead of 18
  • BRAINLAYER_ENRICH_BACKEND unset instead of explicit gemini
  • a periodic StartInterval launch shape instead of the continuous detached realtime path validated on April 12

Audit reference: /Users/etanheyman/Gits/orchestrator/docs.local/handoffs/2026-05-02-enrichment-perf-audit.md

Verification

  • 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 LaunchAgent to a continuous KeepAlive-driven loop (via /bin/zsh -lc ... while true ...) instead of a StartInterval tick, so realtime enrichment stays running.

Updates the realtime command to use a much larger --limit and long --since-hours window, 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 plistlib and 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

  • Replaces StartInterval 600 with KeepAlive true in com.brainlayer.enrichment.plist, switching from periodic scheduling to a persistent process managed by launchd.
  • Changes ProgramArguments to invoke /bin/zsh -lc with a while true loop running enrich --mode realtime --limit 200000 --since-hours 87600 with a 5-second sleep between runs.
  • Updates BRAINLAYER_ENRICH_RATE from 50 to 15 and BRAINLAYER_ENRICH_CONCURRENCY from 10 to 18 in environment variables.
  • Updates tests/test_enrichment_controller.py to parse the plist as a structured object via plistlib and replace the StartInterval assertion with KeepAlive-based and zsh-loop assertions.
  • Behavioral Change: the enrichment agent now runs continuously under launchd supervision rather than on a fixed 10-minute interval.

Macroscope summarized 40c0388.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

Warning

Rate limit exceeded

@EtanHey has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0923d02c-ed7a-48a6-9b33-386fb9525177

📥 Commits

Reviewing files that changed from the base of the PR and between 22af0f1 and 40c0388.

📒 Files selected for processing (2)
  • scripts/launchd/com.brainlayer.enrichment.plist
  • tests/test_enrichment_controller.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/enrichment-plist-drift

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 56 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 2, 2026

@codex review
@cursor review
@BugBot review
@orcClaude

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +26 to +27
<key>KeepAlive</key>
<true/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread tests/test_enrichment_controller.py Outdated
Comment thread scripts/launchd/com.brainlayer.enrichment.plist Outdated
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 2, 2026

Addressed the review findings in 40c03880:

  • replaced raw KeepAlive on the one-shot enrich command with a supervised /bin/zsh loop, so launchd supervises a long-lived process instead of respawning a finished command
  • tightened the plist regression test by parsing the plist and asserting KeepAlive directly
  • dropped BRAINLAYER_ENRICH_BACKEND=gemini from the plist because the older local-backend pipeline enum does not recognize gemini, while brainlayer enrich --mode realtime is already the explicit Gemini-backed path

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 40c0388. Configure here.

@EtanHey EtanHey merged commit bf4cb51 into main May 2, 2026
7 checks passed
@EtanHey EtanHey deleted the fix/enrichment-plist-drift branch May 2, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant