Skip to content

A trigger's fire brings up the lookout and the approver - #333

Closed
lydakis wants to merge 2 commits into
mainfrom
claude/project-thread-kxnbh9
Closed

lydakis wants to merge 2 commits into
mainfrom
claude/project-thread-kxnbh9

Conversation

@lydakis

@lydakis lydakis commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Step 1 of the autonomy plan. Before this PR, only an open Sonny window (and sonny acp) started the lookout and the auto approver. A trigger's fire that started the daemon, for example after the Mac restarted with no window open, started neither. Leads it woke never heard from their tasks, and auto calls had nobody to judge them.

What changes

  • Before it sends, a fire starts the lookout if none watches that daemon. "Watches" now means a process holds the lookout's lock: the check takes a shared, non-blocking flock and lets go at once. It no longer goes by the pid in the lock file, which after a restart may belong to another process. A lookout that starts during that instant tries its lock once more after 50 ms.
  • If the agent it wakes is in auto and no approver serves auto, the fire also starts the approver, judged on the agent's model unless [judge] names another.
  • Both get the login shell's environment, with ~/.agent/env on top, the same as the daemon a fire starts. That way a judge whose key only the person's profile exports can still run.
  • This uses the same start_lookout and serve_auto a window uses. They now take the store, the socket and a login flag instead of the window's options, and sonny acp's call sites are updated to match.
  • If either one can't start, that's logged on the fire's stderr and the message still goes.
  • A fire that finds both running starts neither, so a trigger that fires every minute adds no process.
  • docs/SONNY.md and docs/LOOKOUT.md describe this.

Sonny only; the daemon doesn't change.

Tests

  • Runtime test test_a_fire_that_starts_its_daemon_brings_up_the_lookout_and_the_approver: makes an auto lead, shuts down the daemon, and fires with a login profile that exports a key. It checks that a lookout watches, auto is served, and that both processes have the profile's key (Linux /proc). A second fire keeps the same lookout. The test fails without the login environment and passes with it.
  • Unit test a_lookout_runs_while_one_holds_its_lock_whatever_pid_it_names.
  • tests.test_trigger + tests.test_lookout: 32 ran, 1 skipped (launchd, macOS only). cargo test -p sonny, cargo clippy --workspace --all-targets -D warnings and cargo fmt --check are clean.

No visible change, so no screenshots.


🤖 Generated with Claude Code

@lydakis lydakis self-assigned this Oct 29, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T03:26:17.733754Z 892fbb8 New commits
🔒 Security Review ✅ Completed 2026-10-29T03:30:34.854553Z 892fbb8 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: baf946b80f

ℹ️ 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 thread sonny/src/trigger.rs Resolved
Comment thread sonny/src/trigger.rs Resolved
A fire that started the daemon after a restart, with no Sonny window open,
left the lead deaf to its tasks and `auto` calls with nobody to judge them.
Before it sends, a fire now starts the lookout when none watches that
daemon, and the approver when the agent it wakes is in `auto` and none
serves it, as a window does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHCyGRHdT5WYDPKVFY
…y its lock

The lookout and approver a fire starts now get the login shell's
environment under Agent's env file, as the daemon does, so a judge whose
key only the profile exports can run. Whether a lookout runs is now
whether one holds the lock, not whether the pid in its file lives, which
after a restart may be another process's. Also passes store and socket at
sonny acp's two call sites, which main added meanwhile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHCyGRHdT5WYDPKVFY
@lydakis
lydakis force-pushed the claude/project-thread-kxnbh9 branch from baf946b to 892fbb8 Compare October 29, 2026 03:25

lydakis commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

runtime failed on one daemon test: tests.test_wait test_a_fatal_storage_failure_still_answers_admissions_queued_before_it ("runtime exited before expected response"). It isn't this PR's:

  • This PR changes only Sonny. git diff origin/main -- src/ is empty, so the daemon code under test is main's.
  • The test passed 4 of 4 times locally on this head.
  • Every other module passed, including test_trigger, test_served and test_lookout, which do cover this PR.

No fix exists for it yet. I'm re-running the failed job once.


Generated by Claude Code

lydakis commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

I couldn't re-run it: the re-run call got 403 "Resource not accessible by integration". The PR stays watched. Someone with Actions access needs to re-run the failed runtime job.


Generated by Claude Code

lydakis commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

Closing this. George picked a different shape: the daemon will start, restart and stop companion commands listed in ~/.agent/config.toml, and Sonny registers its lookout and the approver there. That way they share the daemon's life cycle whoever starts it, and a fire no longer needs to start them. The lock-based lookout::running check carries over to that PR.


Generated by Claude Code

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.

2 participants