Skip to content

fix(perception): a review delivered twice moves her surprise number once - #4814

Merged
joelteply merged 1 commit into
canaryfrom
perception/surprise-counts-an-event-once
Oct 6, 2026
Merged

joelteply merged 1 commit into
canaryfrom
perception/surprise-counts-an-event-once

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Joel: replay "should be impossible". The daemon side is Cormac's; this makes the consumer safe regardless. Her surprise tally counted every Reviewed event it was handed, so a replayed gap counted her expectations twice, and since #4796 that number gates whether she trains.

  • RoomWork::Reviewed and BoardChange::Reviewed carry airc's review_id.
  • ActivityView.counted_reviews (bounded by UNPERCEIVED_CAP): a review already counted is skipped and probed mind.surprise.duplicate; a new review of the same card still counts.

67 green across perception, feed, salience, wire, trigger and job_create; hygiene green; no new warnings with tests built.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Joel, 2026-10-06, on attach replay: "it should be impossible". Replay is going
away in the daemon (Cormac), but the consumer must not depend on that: her
surprise tally counted every Reviewed event it was handed, so a replayed gap
or a re-sent event counted her expectation as confirmed or contradicted a
second time. That number now gates whether she trains (#4796), so a
duplicate delivery was corrupting a decision.

- RoomWork::Reviewed and BoardChange::Reviewed carry the review's own id
  (airc's review_id).
- ActivityView keeps the reviews it has counted (bounded by
  UNPERCEIVED_CAP); a review already counted is skipped and probed
  (mind.surprise.duplicate). A new review of the same card still counts.

Test: the same review twice leaves the tally unchanged; a new review of the
same card moves it.

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

Copy link
Copy Markdown
Contributor Author

APPROVED at 6ed72f0, pending its lib-test check. Keying on the review's own id is right (card_id + outcome would merge two real reviews), and the test pins both directions: a duplicate doesn't move her number, a new review of the same card does. One question, not blocking: counted_reviews is in-memory while the tally it guards may not be. If the surprise tally survives a core restart (persisted or reloaded) and the counted set doesn't, the first attach page after the restart (up to 10 events under the new airc rule) can recount reviews already in the tally. If the tally is also rebuilt fresh, it's consistent as is; worth one line in the doc saying which.

@joelteply

Copy link
Copy Markdown
Contributor Author

The tally does not survive a restart: MindState persists cursors, the continuation and the dial, never SurpriseTally, so the tally and the counted set are rebuilt together and the rule is consistent as it stands. A doc line saying so goes on the field in the follow-up (it would move this approved head for a comment). If the tally is ever persisted, counted_reviews must persist beside it in the same write.

@joelteply
joelteply enabled auto-merge (squash) October 6, 2026 10:47
@joelteply
joelteply merged commit 15253e5 into canary Oct 6, 2026
6 checks passed
@joelteply
joelteply deleted the perception/surprise-counts-an-event-once branch October 6, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant