Skip to content

feat: install enrichment launch agent#151

Merged
EtanHey merged 2 commits into
mainfrom
codex/p4-enrichment-launchagent
Mar 30, 2026
Merged

feat: install enrichment launch agent#151
EtanHey merged 2 commits into
mainfrom
codex/p4-enrichment-launchagent

Conversation

@EtanHey
Copy link
Copy Markdown
Owner

@EtanHey EtanHey commented Mar 30, 2026

Summary

  • switch the enrichment LaunchAgent template to a Python entrypoint that imports and runs brainlayer.enrichment_controller.enrich_realtime
  • render the agent into ~/Library/LaunchAgents, resolve GOOGLE_API_KEY from the environment or ~/.zshrc at install time, and add explicit load / unload convenience actions to the installer
  • lower launch priority to Nice=10, move logging to ~/Library/Logs/brainlayer-enrichment.log, and document the new launchd flow

Test plan

  • pytest tests/test_enrichment_controller.py -k 'enrichment_plist or launchd_installer' -v
  • pytest tests/test_enrichment_controller.py -v (57 passed / 5 pre-existing failures in the same file unrelated to this LaunchAgent work)
  • bash -n scripts/launchd/install.sh
  • bash scripts/launchd/install.sh enrichment
  • plutil -p ~/Library/LaunchAgents/com.brainlayer.enrichment.plist
  • bash scripts/launchd/install.sh unload enrichment
  • bash scripts/launchd/install.sh load enrichment
  • pytest -x (stops on pre-existing failure: tests/test_enrichment_controller.py::test_enrich_batch_uses_checkpoint_db_for_resume)

Notes

  • cr review --plain was attempted twice. The first run surfaced a docs consistency issue that was fixed; the second run hit a rate limit before completing.
  • The worktree still contains an unrelated user change in brain-bar/build-app.sh, which is intentionally excluded from this PR.

Note

Install macOS LaunchAgent for realtime Gemini enrichment

  • Adds com.brainlayer.enrichment.plist, a macOS LaunchAgent that runs enrich_realtime (limit=50, since_hours=24) via Python on a scheduled interval with Nice=10 and logs to ~/Library/Logs/brainlayer-enrichment.log.
  • Updates install.sh with resolve_google_api_key (reads from environment or ~/.zshrc), load_plist/unload_plist helpers, and new load, unload, and enrichment subcommands.
  • Installation fails fast if GOOGLE_API_KEY cannot be resolved; the key is baked into the rendered plist at install time.
  • Adds tests covering plist structure, installer subcommands, and API key resolution from .zshrc.

Macroscope summarized 40412a4.

Summary by CodeRabbit

  • New Features

    • Added Google Gemini realtime enrichment mode alongside existing backends.
    • Enrichment service now auto-runs on macOS at login/boot.
  • Documentation

    • Updated configuration guide with Gemini backend details and LaunchAgent installation instructions.
    • Added enrichment LaunchAgent implementation plan.
  • Changes

    • Enrichment logs now write to ~/Library/Logs directory.
    • New load/unload commands for enrichment service management.
    • GOOGLE_API_KEY environment variable now required for Gemini enrichment.
  • Tests

    • Added LaunchAgent and installer script validation tests.

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 Mar 30, 2026

@coderabbitai review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Mar 30, 2026

@codex review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Mar 30, 2026

@cursor @BugBot review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Mar 30, 2026

@greptileai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 2026

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 15 minutes and 4 seconds.

⌛ 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: e4191ee1-80ed-44c4-ac4b-7feda23ea642

📥 Commits

Reviewing files that changed from the base of the PR and between 68cd2e4 and 40412a4.

📒 Files selected for processing (1)
  • tests/test_enrichment_controller.py
📝 Walkthrough

Walkthrough

This PR implements a macOS launchd LaunchAgent to automatically run realtime Gemini enrichment at login. Changes include updating the plist template to execute Python directly, refactoring the installer script to resolve Google API keys from environment or shell configuration, and updating documentation with installation instructions and configuration details.

Changes

Cohort / File(s) Summary
LaunchAgent & Installer Implementation
scripts/launchd/com.brainlayer.enrichment.plist, scripts/launchd/install.sh
Updated plist to invoke Python one-liner (instead of CLI) that calls enrich_realtime() with PYTHONPATH and WorkingDirectory configuration; refactored installer with new resolve_google_api_key() function to source API key from environment or ~/.zshrc, updated log paths to ~/Library/Logs/, and added load/unload helper subcommands.
Configuration & Planning Documentation
docs/configuration.md, docs/plans/2026-03-30-enrichment-launchagent.md
Updated configuration docs to describe "Gemini realtime" enrichment mode, added GOOGLE_API_KEY environment variable documentation, renamed service to com.brainlayer.enrichment, and documented manual launchd control; added implementation plan specifying plist contract, installer behavior, and verification workflow.
Test Coverage
tests/test_enrichment_controller.py
Added five new test assertions validating LaunchAgent plist includes Python execution targeting enrich_realtime(), configures Nice=10 priority, writes logs to expected path, and verifying installer supports load/unload subcommands and reads GOOGLE_API_KEY from .zshrc.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰✨ At login time, enrichment hops to life,
Gemini keys resolved without strife,
Logs now cozy in ~/Library/Logs,
Python direct, no CLI cogs,
LaunchAgent ready—realtime magic springs! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: implementing a macOS launchd LaunchAgent for automatic enrichment execution.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/p4-enrichment-launchagent

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

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cursor
Copy link
Copy Markdown

cursor Bot commented Mar 30, 2026

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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 EtanHey merged commit 679236a into main Mar 30, 2026
2 of 5 checks passed
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