Skip to content

Sonny triggers: a sent one-shot keeps its row until its turn ends well - #442

Merged
lydakis merged 4 commits into
mainfrom
claude/project-thread-u2fp8q
Oct 30, 2026
Merged

lydakis merged 4 commits into
mainfrom
claude/project-thread-u2fp8q

Conversation

@lydakis

@lydakis lydakis commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

🤖 Generated with Claude Code

Fixes #422. George approved the approach in the coach thread.

Why

Two kinds of trigger fire once: a one-off (--at/--in), and a --runs trigger on its last run. Until now, such a trigger deleted its state row the moment its message went out. Suppose its turn then failed, for example because the machine was offline or a login had expired. Nothing pointed at that turn anymore, so /background, the footer's ✗ N failed and the agents' triggers tool all missed it. Reminders that leads set for themselves, like "check back at 15:00", are exactly this case.

What

  • settle / ends keep the row (retire with keep = true) whatever the fire did, not only when it did not deliver or its answer was not passed on.

  • trigger::forget_done(places, store_id, ended) removes a row once it qualifies. It is called by whoever just asked the daemon how fired turns ended: Sonny's 10-second background count (count_behind) and the triggers tool's answer. A row qualifies when all of these hold:

    • the trigger has ended (no job);
    • it was made on this daemon's store;
    • its last fire sent a turn;
    • that turn completed;
    • no answer failed to pass on.

    A row whose turn failed stays, with last.turn_error, until it is removed. Checks and removal both run under the trigger lock. A trigger made again under the same name has a job, so its row is never touched.

  • This follows the usual pattern for finished work: systemd keeps a failed unit until reset-failed, and Kubernetes keeps a finished Job until its TTL.

  • docs/SONNY.md and the /background row in FEATURES.md are updated.

Caveats

  • Cleanup is lazy, so a row goes only when something reads it: a Sonny window whose scope covers the trigger, or an agent calling triggers. A completed one-shot can sit as an ended row while nothing reads. These are small JSON files, one per one-shot.
  • While its turn runs, an ended one-shot shows in /background with "ended" and counts in ↻. That is true, since its turn is running.

Tests

cargo test -p sonny passes (537) and clippy is clean.

  • a_fire_ends_only_the_trigger_it_ran_for now covers a sent one-shot through four steps:
    1. its row stays after the send;
    2. it stays when its turn failed;
    3. it stays for another store's turn under the same handle;
    4. it goes once the turn completed.
  • The --runs test now expects the row to stay after the last run.

A one-off, or a `--runs` trigger's last run, deleted its state row as soon
as its message went out, so a turn that failed afterwards (offline, a login
expired) left nothing for /background, the footer's count or the triggers
tool to show. Its row now stays, and whoever asks the daemon how its turn
ended removes it once that turn completed with any answer passed on; a
failed one stays until removed, as systemd keeps a failed unit until
reset-failed. Fixes #422.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEbQZnXUy1kATtYcQ6
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-30T05:54:20.684211Z f124aa2 New commits
🔒 Security Review ✅ Completed 2026-10-30T05:55:48.273855Z f124aa2 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.

@lydakis lydakis self-assigned this Oct 30, 2026

@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: f89b4a768b

ℹ️ 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/main.rs Resolved

@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: 52468d22a7

ℹ️ 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/main.rs Resolved
@lydakis
lydakis merged commit b64f02d into main Oct 30, 2026
4 checks passed
lydakis pushed a commit that referenced this pull request Oct 31, 2026
Since #442 a sent one-shot's row stays, ended, until its turn is known
to have completed; only Sonny's window and the served tool forget it.
The real-launchd and real-systemd tests still expected an empty list
after the one-off ended itself, so both failed there (neither runs in
CI). They now expect the one ended row.

Closes #511.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g
lydakis added a commit that referenced this pull request Oct 31, 2026
…ne/day-two condition (#520)

* A cut output's file stays its outcome's until the store records it

A parallel batch records results in call order, so a later call's outcome
can wait in the batch's buffer, its output file already written, behind an
earlier call still running. Once written, the file names left the cleanup
guard for a plain vector in the outcome: stopping the turn then dropped the
outcome and left the file with no artifact row to find it by, so neither
prune nor delete removed it.

`Outcome.files` is now `Files`, which removes its files when dropped
unless the store recorded them, as a temporary file goes unless kept.
`tool_finish` and the background `process_finish` mark them recorded once
their savepoint commits. Copies share the files through an Arc, so the
held answer a group's rollback snapshot clones doesn't remove them twice;
no files allocates nothing. The keeper's own guard folds into it.

New runtime test: a batch with a slow call beside a large-output one,
stopped after the second wrote its file, leaves no file; it fails on main.

Flaky tests sync on events instead of tight wall-clock bounds:
- #502: the two sandboxed commands each wait for the other's mark, so
  they pass only by running at once, with no 1.1 s bound.
- #484: the lapse test waits for the answered call to start and gives the
  gate two seconds instead of 100 ms.

Closes #484. Closes #502.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g

* Record #505's matched perf screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g

* Memory: a refused cleanup takes back only its own changes

The loss guard reverted the cleanup's whole commit, and with it any fact
another agent saved or removed while the cleanup was open: git kept it in
the refused commit, but memory lost it and nothing told the agent.

`cleanup start` now records which agent runs the cleanup (AGENT_BOT_ID, or
none for the person). A save or removal by anyone else while it is open is
noted in `.cleanup-others` as the fact now stands. When the guard refuses
the cleanup, those facts are put back over the revert, each as its agent
last left it, their folders reindexed and committed, and the refusal says
how many were kept. Snapshot isolation in effect: the guard takes back the
cleanup's writes, never another writer's.

Closes #471.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g

* Memory: note others' changes under the folder lock, store-qualified owner, say when kept facts overfill the index

Review fixes on the refused-cleanup put-back:
- A save or rm hands the cleanup journal the fact as it wrote it while
  the folder is still locked, instead of rereading the file after the
  lock is gone, where the cleanup could have changed it in between.
- The cleanup's owner is AGENT_STORE#AGENT_BOT_ID: bot ids are each
  store's own, and stores under one HOME share its memory.
- When the put-back leaves a folder's index past its limit (the
  cleanup's removals made room for saves the revert brings back
  beside), the refusal says so; nothing saved is dropped to fit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g

* Memory: a cleanup's finish holds every folder's lock through its revert and put-back

A save between put_back reading the journal and replaying it was
overwritten with the older noted text, and a save during the revert
itself could be clobbered. The finish now takes every folder's lock,
in sorted order, from its commit to its end; saves and removals wait
and land after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g

* Triggers: each HOME has labels of its own

launchd keeps one domain per user and systemd one user manager, whatever
HOME is, so a test's or an eval's HOME added its triggers beside the
user's own, under the same labels: a same-named trigger replaced or
removed another HOME's, and one left loaded after its HOME was deleted
fired into nothing.

A trigger's label is now me.lydakis.agent.trigger.TAG.NAME, TAG being
eight hex digits of a hash of HOME (FNV-1a 64, folded to 32 bits, trailing
slash left out). Sonny's start moves each trigger made before labels had
the tag to its tagged label, once, rolling back one that will not load.
A fire whose HOME is gone removes its definition and unloads its own job,
by the label launchd (XPC_SERVICE_NAME) or systemd (its cgroup) runs it
under.

Closes #453.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g

* Triggers: the relabel moves only triggers made from this HOME

systemd's unit folder can be shared by several HOMEs (one absolute
XDG_CONFIG_HOME); a trigger whose definition runs with another HOME is
that HOME's to move, at its own Sonny's start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g

* Trigger tests: an ended one-off keeps its row until its turn is done

Since #442 a sent one-shot's row stays, ended, until its turn is known
to have completed; only Sonny's window and the served tool forget it.
The real-launchd and real-systemd tests still expected an empty list
after the one-off ended itself, so both failed there (neither runs in
CI). They now expect the one ended row.

Closes #511.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g

* Memory eval: a learned condition, day one hears the fact, day two applies it

The day-six review asked whether a fresh lead on day two applies what day
one learned. The memory condition seeds facts by hand; learned installs
the skill, saves nothing, and on day one has a new agent in the project
hear the fact from the person in passing, with nothing to change. Day
two's fresh agent, in the same HOME, gets the task: only what the first
agent chose to save can carry it. Rows record day one's status and the
facts it saved; the summary counts day_one_saved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g

* Memory eval: find day two's turn from its accepted event; record the 10-31 run

Day one and day two share a daemon, so day two is not turn 1; the script
waited on /1 and got turn_not_found. Take the turn from the run's
accepted event, record day one's rounds and tokens, and assert both in
the synthetic test (which failed before this change).

docs/MEMORY_EVAL.md gets the 2026-10-31 run on openai/gpt-6.1-sol:
learned 6/6, memory 9/9, none 3/9.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFBzSEQmnVuCCNV83g

---------

Co-authored-by: Claude <[email protected]>
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.

Sonny triggers: a finished one-shot's sent turn that later fails goes unseen

2 participants