Skip to content

Interruptions keep what they owe: lookout news a wait never returned, a refused memory cleanup cut short - #777

Merged
lydakis merged 9 commits into
mainfrom
claude/project-thread-dw4ngo
Nov 7, 2026
Merged

lydakis merged 9 commits into
mainfrom
claude/project-thread-dw4ngo

Conversation

@lydakis

@lydakis lydakis commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

These fixes came out of the 11-07 state machine audit. Its interruption scenarios were used as a test plan: four of six already had tests, and one of the two missing ones was broken.

1. Lookout: a turn a lead's wait read is news again if the wait never returned it (K05)

What was wrong. The lookout dropped a task's turn from the lead's news the moment the lead's wait tool started on its handle (sonny/src/lookout/mod.rs, tool_started → Updates::read). If the wait handed nothing over, the lead never heard how the turn ended:

  • The wait failed. One bad handle, an unowned process, or a turn waiting on itself fails the whole wait (park in src/server/turn.rs).
  • The wait was cancelled, or the person stopped the lead mid-wait.

What changes. What a wait reads is held by its call in Updates::waits:

  • A tool_completed without failed, cancelled, outcome_unknown or denied drops the held news.
  • A tool_completed with any of those flags, or the lead's turn_finished while a wait is still open, puts it back.
  • Tasks gone in the meantime are not put back.
  • Held news keeps the lookout's saved floor (untold), so a lookout restart replays it.

Test: a_wait_that_failed_or_was_cancelled_hands_its_turns_back_as_news.

2. Memory: a refused cleanup cut short is carried on (C10)

What was wrong. The loss guard reverts a cleanup, then puts back what other agents saved or removed while it was open (put_back). A finish killed between those two steps left .cleanup behind. The next finish found memory already back at the start, read no loss, and closed it as a clean cleanup. That silently dropped the other agents' facts and moved .said as if the cleanup had landed. The new test reproduces this on main: the rerun returns success with removed: [], and agent 8's fact is gone.

What changes.

  • The refusal (head, lost, before, limit) is written to .cleanup before memory goes back.
  • The next finish carries the refusal on: back to the start while others' writes are still listed (or the refused commit is still the newest), then put_back, then the marker.
  • Going back now reads the start's tree with git read-tree -u --reset START instead of git revert HEAD, so each step can run again. The two are equivalent here, since nothing commits between cleanup start and finish.

Test: a_refusal_cut_short_is_carried_on_and_keeps_what_others_saved. It fails on main and passes here. The other 23 memory tests are unchanged and pass.

3. Daemon test: a parked task reaped after its turn resumed (A04)

There is no behavior change. The new test a_parked_task_reaped_after_its_turn_resumed_leaves_the_new_task_in_place pins the guard in Service::complete: a predecessor's late Paced/Parked exit leaves the new task owning the bot and its slot, and sets no wake-up. Removing the a.task == task check makes the test fail.

Checks

  • cargo test -p sonny --bin sonny: 1110 passed
  • cargo test -p agent-client --lib: 110 passed
  • cargo test --bin agent a_parked_task_reaped: pass
  • cargo clippy --workspace --all-targets -D warnings: clean

Docs: docs/LOOKOUT.md, docs/SONNY.md, and two sonny/FEATURES.md entries.

🤖 Generated with Claude Code

…turned it (K05)

The lookout dropped a task's turn from the lead's news the moment the
lead's wait tool started on its handle. A wait that then failed (one bad
handle, an unowned process or a turn waiting on itself fails it whole)
or was cancelled, or whose turn the person stopped, returned nothing, and
the lead never heard how that turn ended.

What a wait reads is now held by its call: dropped once the call
completes, put back as news when it completes failed, cancelled, denied
or with an unknown outcome, or when the lead's turn ends with it still
open. Held news keeps the lookout's saved floor, so a lookout restart
replays it. Tasks gone meanwhile are not put back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGH2pLHh19AigAztgFd
@lydakis lydakis self-assigned this Nov 7, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T04:55:45.518975Z 200a928 New commits
🔒 Security Review ✅ Completed 2026-11-07T04:11:42.314040Z 848b117 PR opened
ℹ️ 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: 848b11756e

ℹ️ 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/lookout/updates.rs Resolved
A cleanup the loss guard refuses reverts its commit, then puts back
what other agents saved or removed while it was open. A finish killed
between the two left the marker behind; the next finish found memory
already back at the cleanup's start, read no loss, and closed it as a
clean cleanup, dropping the other agents' facts for good and moving the
person's-words cursor as if the cleanup had landed.

The refusal is now written to the marker before memory goes back, and
the next finish carries it on: memory back to the start while what
others wrote is still listed (or the refused commit is still the
newest), then the put-back, then the marker. Going back reads the
start's tree with read-tree rather than reverting one commit, so each
step can run again.

Daemon test: a parked task reaped after its turn resumed as a new task
leaves the new task owning the bot and its slot, and sets no wake-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGH2pLHh19AigAztgFd
@lydakis lydakis changed the title Lookout: a turn a lead's wait read is news again if the wait never returned it (K05) Interruptions keep what they owe: lookout news a wait never returned, a refused memory cleanup cut short Nov 7, 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: b80510e6e8

ℹ️ 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/lookout/updates.rs Resolved
Another turn of the lead's ending while a wait runs (a steer it took, a
queued turn stopped) drained every held wait, so a wait that then
returned left its turns as news told twice. Each held wait now keeps the
lead turn it runs in, and only that turn's end puts it back.

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

A turn the lookout did not see start waits in unheard until who asked is
read. When a wait held it and who asked was read meanwhile, asked_by
found nothing to update and the asker was never read again, so a failed
wait put the turn back in unheard for good. asked_by now settles a held
entry where the wait keeps it (and a held forward's asker), and a failed
wait tells it as asked_by would have.

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

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

ℹ️ 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/lookout/updates.rs Resolved
Comment thread client/src/memory.rs Resolved
… a refused cleanup goes back once

A reply read with who asked, while a wait of the lead's holds the turn,
now stays with the held turn, so a failed or cancelled wait tells it with
its reply, and an automation's run no longer waits again for a reply
already read. A refused memory cleanup now records in .cleanup that memory
went back to its start, so a finish cut short after it put back other
agents' saves never resets again over a list begun later.

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

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

ℹ️ 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/lookout/updates.rs Resolved
Comment thread sonny/src/lookout/updates.rs Resolved
asked_by now names a turn's end held in a wait's news (a task with no
subscription rules), so a failed wait tells it as put would: an
automation's run that said nothing stays no news, and the person's own
turn stays theirs. A trigger's answer passed on while a wait holds its
turn's forward drops the held forward too, so a failed wait does not
announce it again.

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

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

ℹ️ 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 client/src/memory.rs Resolved
… owners' saves are put back

A cleanup start that finds a refusal cut short now closes it, as finish
would, and answers loss_guard, where it handed the cleanup on to carry on
and finish then left that run's new removals in place. Once a cleanup is
refused, its own agents' saves are listed and put back like the others'.
The cleanup skill says to stop for the night on that answer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGH2pLHh19AigAztgFd
@lydakis
lydakis merged commit 9d4aa91 into main Nov 7, 2026
5 checks passed
@lydakis
lydakis deleted the claude/project-thread-dw4ngo branch November 7, 2026 07:01
lydakis pushed a commit that referenced this pull request Nov 7, 2026
Conflicts in lookout/updates.rs (the goal hold beside #777's wait reads:
the goal parts go, the wait reads stay) and asks.rs (#776's reading of
an ask, with said_by_person now in reactions).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGGYoqceB21grsa5Q3v
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