Repository navigation
Triggers: one stable scheduler job per HOME, so the Mac stops announcing background items - #529
Conversation
A Mac lists each LaunchAgent as a background item and notifies the person whenever one is added or changed. Every trigger was its own LaunchAgent (or systemd unit), and leads rewrite their next-look trigger on every look, so the alerts kept coming. Now the system keeps one job per HOME, me.lydakis.agent.scheduler.TAG, written once and left alone while Sonny stays where it is. It runs `sonny scheduler`, a cron for triggers: it reads definitions from ~/.agent/triggers/jobs/NAME.json and fires on calendar times (catching up once after sleep), watched paths and queued asks, one fire per trigger at a time. The backup sync and start_at_boot run from it too, so their own jobs go. Sonny's start moves older per-trigger, backup and boot jobs over once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins. |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3ed6fe42b
ℹ️ 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".
- Backup syncs only once setup ran its first sync: a clone put in ~/agent-home by hand would otherwise push this machine's home over it. - Moving the old jobs is an upgrade::once migration (scheduler-job, retires at 0.10.0), with the backup's and boot's old jobs in it. - Sonny's start rewrites the job when it runs another Sonny, even while the old scheduler answers its doorbell (installs that keep each version in its own folder). - next_after searches eight years and a day, so 29 February crons fire. - A trigger new to the scheduler fires once for a write to its watched path after its definition was written, so a write before the first read is not lost; every followed trigger is kept in the checkpoint. - The scheduler's locks and checkpoint live in ~/.agent/triggers/.scheduler, which Sonny's start-up cleanup leaves, so a checkpoint write under way is never taken from it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS
|
The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51b76eea38
ℹ️ 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".
From the performance review of #529: - Fires the scheduler runs are indexed by trigger (no scan of running processes per trigger per wake); the trigger loop no longer clones and sorts names, and ended fires are a set. - At most four fires per core (eight at least) run at once: a burst of due triggers waits for room, woken by a fire's end. - A start that fails keeps its trigger due and retries after a wait that doubles from a second up to five minutes, instead of losing that run. - Watched paths are looked at every two seconds however often it wakes. New test: 10,000 due triggers with every third start failing once all fire exactly once, never more than the cap at a time. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS
|
The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins. |
next_after took one moment for each local time, so in the repeated hour an every-minute trigger skipped to 02:00. A local time now names every moment it can (epochs_of tries both DST readings): an entry with a set hour comes at the first, as cron runs a set-time job once; one with any hour comes at both, as time goes. The test runs itself in America/New_York as a child, so its TZ is no other test's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS
|
The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a894f70534
ℹ️ 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".
|
@codex security review This PR's automatic security review failed on the usage limit; it is one of the riskier rows in #531 (a login job that runs trigger fires outside the sandbox from Generated by Claude Code |
… time - A calendar time that came is checkpointed when its fire starts (or at once when a running fire skips it), so a scheduler that restarts while the time waits for room or after a failed start still finds it due. - ensure() is serialized within the process: Sonny's start reaches it from the trigger, backup and start-at-login threads, whose writes of the job shared one temporary file. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e123505df7
ℹ️ 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".
… before an earlier minute's second Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60079ee58b
ℹ️ 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".
… a wait, not every pass Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c0e59ad99
ℹ️ 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".
… for a new time zone; places in the fleet in turn Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS
…p clone is not set up A scheduler the system started after its HOME was deleted made HOME again opening its doorbell, so never saw it gone and ran on idle; it now checks before making anything. And backup counted as set up once ~/agent-home had a remote, though a clone made by hand has had no restore or first sync and the scheduler never syncs it; setup now needs that first sync too. (Codex code review on review-only #607, for #529.) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
…sitory (#603) Fixes #597. Adds `agent sandbox [--writable PATH]... -- COMMAND` (network always off, client protections, hold released before exit). Sonny runs the tree's status, the seed's listings and the task worktree's checkout through it. The worktree is made with a plain --no-checkout add, then checked out confined. Removal keeps git's submodule guard, and a kept agent/NAME branch is never deleted. Also fixes #607's findings for #529: a scheduler started after its HOME is gone, and a backup clone made by hand counted as set up. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
Why
macOS lists every LaunchAgent as a background item. It sends a notification each time one is added or changed. Every trigger was its own LaunchAgent (or systemd unit), and every lead resets its
NAME.nexttrigger withreplaceon each look.every()computes the calendar from now, so each replace wrote a new plist and the Mac announced it again. The #512 relabel and the separate backup and boot jobs added a few more.What
This follows the cron pattern: the system gets one job per HOME,
me.lydakis.agent.scheduler.TAG. It is written once and never rewritten while Sonny stays at the same path, so add, replace, rm and fires never touch it.RunAtLoad,KeepAliveon a failed exit andAbandonProcessGroup.default.target,Restart=on-failure,KillMode=process.sonny scheduler.sonny scheduler(newsonny/src/scheduler.rs)~/.agent/triggers/jobs/NAME.json. Each holds the program, environment, calendar entries and an optional watched path..scheduler/looked.~/.agent/triggers/.scheduler/NAME.lock.max(4 × cores, 8)fires at once. Freed places go to the trigger that has waited longest..ring) and fire ends wake it early.sonny bootat start whenstart_at_bootis on, andsonny home syncevery ten minutes once backup setup has run its first sync. So the oldme.lydakis.agent.backupandme.lydakis.agent.bootjobs go away.trigger.rs)upgrade::oncestep named "scheduler-job", which retires at 0.10.0.Checks
cargo test -p sonny: 742 pass. Tests include:cargo clippy -D warningsandcargo fmt --checkare clean.AGENT_TEST_RUNTIME=1 python -m unittest tests.test_trigger: 26 pass, 1 skipped (the opt-in real-system test). These tests run the realsonny scheduleragainst a real daemon under a scratch HOME.Not verified yet
bootstrap/kickstartof the scheduler job on a real Mac.Both need a run on George's own Mac, with his OK.