Repository navigation
Conversation
…ing background items (#529) * Triggers: one stable scheduler job per HOME 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 * Feature log: #529 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS * Scheduler: review fixes - 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 * Scheduler: a bounded fleet of fires, and a failed start stays due 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 * Scheduler: the hour the clock repeats as daylight saving ends 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 * Scheduler: keep a calendar time once its fire starts; one ensure at a 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 * Scheduler: in the repeated hour, a later minute's first time can come before an earlier minute's second Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS * Scheduler: a fire left from before a restart is looked at again after a wait, not every pass Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEcjSFCKYRSW92srAS * Scheduler: no extra fire for an ask a fire is taking; a new scheduler 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 --------- Co-authored-by: Claude <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsFinding details are still loading. Check the individual review comments. ℹ️ 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 36c6f493db
ℹ️ 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".
| let read = std::fs::read_to_string(entry.path()) | ||
| .ok() | ||
| .and_then(|text| Job::read(&text)) | ||
| .and_then(|job| Some((trigger::trigger_of(&job.program)?.0.generation, job))); |
There was a problem hiding this comment.
Protect scheduler definitions from sandboxed writable roots
When a workspace-write bot's workspace or additional writable root contains ~/.agent (for example, Sonny opened in HOME), it can modify these definitions: client/src/lib.rs protects .git, .agents, and .codex, but not .agent, and src/sandbox.rs::root does not independently protect the trigger directory. The scheduler then executes the supplied job.program outside the sandbox. trigger_of only validates the arguments after the executable, so replacing an existing definition's program[0] with a bot-written executable preserves validation and yields persistent execution with the person's permissions. Protect the scheduler's definitions and control files by absolute path in the sandbox policy, including when they fall beneath a writable root.
Useful? React with 👍 / 👎.
A workspace-write bot whose folder contains ~/.agent (Sonny opened in HOME) could rewrite the scheduler's job definitions, which run outside the sandbox, or the settings that say how every bot is sandboxed. The CLI now starts the daemon with ~/.agent as a protected path, as Codex keeps ~/.codex: read-only in any root that holds it, writable only where a bot is given a folder in it by name (Sonny's zen folder). Bots in any other folder already could not write there, so nothing they do changes. Found by the Codex code review on the security-review-only PR #579 (#531). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
…, note topics (#587) * Read zen focus files only when plain, small and not a link Sandboxed agents may write ~/.agent/sonny/zen so `sonny zen` works from their shell, and Sonny reads every focus on its UI loop. A focus replaced by a FIFO, or a link to /dev/zero, would hold the window (and any other window that asks). focus_in now opens with O_NOFOLLOW | O_NONBLOCK, reads only a regular file, and at most 16 KiB. Found by the Codex code review on the security-review-only PR #578 (#531). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2 * Keep the agent's home read-only for bots whose folder holds it A workspace-write bot whose folder contains ~/.agent (Sonny opened in HOME) could rewrite the scheduler's job definitions, which run outside the sandbox, or the settings that say how every bot is sandboxed. The CLI now starts the daemon with ~/.agent as a protected path, as Codex keeps ~/.codex: read-only in any root that holds it, writable only where a bot is given a folder in it by name (Sonny's zen folder). Bots in any other folder already could not write there, so nothing they do changes. Found by the Codex code review on the security-review-only PR #579 (#531). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2 * Keep line breaks and stray commons names out of a note's topic A source's topic goes into the agent's note unquoted, after the source's name, and Event::parse let line breaks through, so an event could add lines of its own outside the quoted text. A topic now holds no control characters, and the commons reads only threads whose file names it could have made (valid_name), as its listing already did. Found by the Codex code review on the security-review-only PR #585 (#531). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2 --------- Co-authored-by: Claude <[email protected]>
Do not merge. This PR exists only so Codex runs the security review that #529 never got (tracked in #531). The base is the commit before #529 merged (
36c6f49^) and the head is the merge commit36c6f49, so the diff is exactly what #529 landed on main. Once findings are fixed on main or filed, this PR gets closed and bothsecurity-review/529*branches are deleted.What to look at: a LaunchAgent (KeepAlive, RunAtLoad) or systemd user service runs
sonny scheduleroutside every sandbox. It runs trigger fires from definitions in~/.agent/triggers/jobs, and a FIFO doorbell sits at~/.agent/triggers/.ring. Check that no sandboxed bot can write those definitions or the FIFO, since that would give it lasting execution as the person.