Skip to content

fix(wake): probe an undeliverable recipient once per drain pass (#2812) - #2813

Merged
jerryfane merged 4 commits into
mainfrom
fix/wake-drain-probe-memo
Dec 4, 2026
Merged

jerryfane merged 4 commits into
mainfrom
fix/wake-drain-probe-memo

Conversation

@jerryfane

Copy link
Copy Markdown
Collaborator

Closes #2812.

Problem: live seats got message wakes 5–7 minutes late (jarvis 607168: 607144–607148). Every drain pass probed the recipient (config load + Herdr pane list, ~0.5–1 s) once per pending group. The live outbox has 135 groups belonging to seats that cannot take a wake (they collect mail by turn hook, or are offline), so each pass spent 1–2 minutes before live wakes went out. Full evidence is in #2812.

Fix (internal/cli/reply_wake_outbox.go):

  • Each pass remembers every recipient whose probe returned an undeliverable reason and reuses that status for its other groups.
  • The health pass (classifyWakeOutboxObligations) is seeded with the same statuses. It already memoized per recipient, but only within itself.
  • Deliverable recipients are still probed per group, because their idle/working state decides the batching hold. Deferral recording, notices and rule checks are unchanged.

Tests

  • New: TestReplyWakeDrainProbesAnUndeliverableRecipientOncePerPass. It covers one undeliverable seat with 3 groups and one live seat.
    • Old code: the seat was probed 4 times in one pass (red, run locally with the fix stashed).
    • New code: it is probed 1 time, the live wake is delivered, and the 3 deferred rows stay pending.
  • go test -run 'Wake|Message|OwnerGram|Directive|AwaitedFact|Uncertain|Mute|Requester|Deferral|Notice' ./internal/cli/ passes. go vet ./internal/cli/ is clean.

Attribution gap: implemented in-session by the gitmoot seat; no implement job exists.

Deploy: daemon only (standard recipe). Live check after deploy: drain passes should claim within seconds of a row coming due. The gap between a live seat's created_at (plus any working-recipient hold) and attempted_at in wake_outbox should be seconds.

The drain probed recipient readiness (org config load + Herdr pane list)
once per pending group. Seats that collect mail by turn hook, or are
offline, own one group per awaited fact or directive; on the live outbox
135 such groups made each pass take one to two minutes, so live seats'
wakes waited behind them. Remember undeliverable statuses for the pass
and seed the health pass with them; deliverable recipients are still
probed per group because their state decides the batching hold.
@jerryfane

Copy link
Copy Markdown
Collaborator Author

Reviewer: e2b-full-review-2230
Runtime: omp
Job: local-review-review-router-18edf547a0b7e1a9-1

Decision: changes_requested
Summary: Reviewed exact head a0352fe against its parent. Build, vet, and focused tests passed. The new regression test failed on the parent as intended: four probes instead of one. Deferral recording and notice deduplication are unchanged for stable readiness. When a seat becomes ready between groups, however, the head delays a wake the parent delivered in the same pass and persists an unnecessary sender notice. The next pass delivered the wake; no delivery was dropped in the probe. No prior findings for #2813 were recorded in the supplied snapshot.
Severity: P1

Findings

  • A stale readiness result delays delivery and publishes a false offline notice (P1)
    • detail: The memo treats every nonempty reason as valid for the rest of the pass, including unresolved pane bindings and snapshot failures. In TestReview2813WakeRecoversBetweenGroups, the worker bound an idle OMP pane before the second group. The parent delivered that group's message immediately and sent no notice. The head recorded the earlier offline reason, left the message pending, and sent a one-time notice saying the worker was offline. The notice remained after the next pass delivered the wake. Keep later eligible groups fresh for transient readiness results; memoize only negatives known to remain valid for the pass.
    • evidence_locator: local://7.log; internal/cli/reply_wake_outbox.go:326-338,375-377; internal/cli/message_delivery.go:52-74
    • file: internal/cli/reply_wake_outbox.go:283-294
  • The closing health pass copies a map the drain no longer uses (P3)
    • detail: The classifier is the drain's final call, and the standalone health caller passes nil. Hand the map to the classifier directly and allocate only when no map was supplied; the copy protects no caller.
    • file: internal/cli/reply_wake_outbox.go:438-441
  • The memo regression test accepts an aborted health pass (P3)
    • detail: Logging any drain error lets the test pass if health resolution fails after delivery but before it probes the pending rows. Assert the expected health result of three outstanding rows and reject unrelated errors.
    • file: internal/cli/reply_wake_probe_memo_test.go:42-44

Tests Run

  • CGO_ENABLED=0 go build -buildvcs=false ./cmd/gitmoot -> linked, then exited 1 because the read-only checkout denied the default output path
  • CGO_ENABLED=0 go build -buildvcs=false -o "$d/gitmoot" ./cmd/gitmoot -> passed with output in a temporary directory
  • CGO_ENABLED=0 go vet -buildvcs=false ./internal/cli -> passed
  • CGO_ENABLED=0 go test -buildvcs=false -timeout 5m -count=1 ./internal/cli -run 'Test.*(ReplyWake|WakeOutbox|FactWakeDrain|DirectiveWakeDrain|MessageDaemon|MessageDeferralNotice|ReviewResultWake)' -> passed, including the new memo regression test
  • CGO_ENABLED=0 go test -buildvcs=false -timeout 5m -count=1 ./internal/cli -run '^TestMessageNotificationTimingFollowsRecipientState$' -> passed
  • CGO_ENABLED=0 go test -overlay "$d/overlay.json" -buildvcs=false -timeout 5m -count=1 ./internal/cli -run '^TestReplyWakeDrainProbesAnUndeliverableRecipientOncePerPass$' -> expected failure with parent production code: four probes, want one
  • CGO_ENABLED=0 go test -overlay "$d/head.json" -buildvcs=false -timeout 5m -count=1 -v ./internal/cli -run '^TestReview2813WakeRecoversBetweenGroups$' -> failed on head: first-pass deferral and stale sender notice; second-pass delivery
  • CGO_ENABLED=0 go test -overlay "$d/base.json" -buildvcs=false -timeout 5m -count=1 -v ./internal/cli -run '^TestReview2813WakeRecoversBetweenGroups$' -> passed with parent production code: first-pass delivery and no notice

Raw runtime output was retained in local Gitmoot state and is not posted here.

…2812)

Review round 1 of #2813: an offline or unresolved binding can clear
between groups of one pass, so caching it delayed a wake and could send a
false offline notice. Only unregistered, unseated, remote and runtime-kind
reasons are remembered; the health pass receives the drain's map without a
copy, and the regression test asserts the exact health result.
@jerryfane

Copy link
Copy Markdown
Collaborator Author

Reviewer: e2b-full-review-2230
Runtime: omp
Job: local-review-review-router-18edf674810a85dc-1

Decision: changes_requested
Summary: Reviewed #2813 at e64b038. All three prior findings are answered. Build, vet, and focused repository tests passed. A separate probe reproduced a stale deferral notice when a recipient’s runtime changed to OMP between groups.
Severity: P1

Findings

  • Live runtime detection is cached as if it were fixed configuration (P1)
    • detail: Both memoized capability reasons come from the current Herdr session snapshot, not the role’s configuration. In two executed cases, the first group saw either no detected runtime or Claude, and the seat became OMP before the next group. The later message stayed pending, no prompt was sent, and the sender received a notice citing the obsolete reason. The next pass delivered the message but left the notice in place. Re-probe live runtime negatives unless the cache can establish that the same runtime session still owns the seat.
    • evidence_locator: proc://bg_2; internal/cli/message_delivery.go:58-75; internal/cli/reply_wake_outbox.go:285-296; internal/cockpit/herdr_org.go:198-219
    • file: internal/cli/message_delivery.go:85-90
    • in_delta: false
  • User-facing reason text doubles as cache policy (P3)
    • detail: The allowlist makes memoization depend on the exact diagnostic a readiness branch returns. A branch cannot reuse a diagnostic with different freshness semantics, and adding context to a diagnostic can silently disable caching. Have the branch that observes the condition return an explicit cache classification alongside the display text.
    • evidence_locator: internal/cli/message_delivery.go:41-90; internal/cli/reply_wake_outbox.go:285-296
    • file: internal/cli/message_delivery.go:85-90
    • in_delta: true
  • Offline and unresolved-binding results are no longer memoized (P1)
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f1
    • evidence_locator: local://11.log:103-107; internal/cli/message_delivery.go:54-60,85-90
    • file: internal/cli/reply_wake_outbox.go:285-296
    • rationale: TestReplyWakeDrainReprobesATransientlyOfflineRecipient passed: only the group seen offline stayed pending, and both later groups delivered in the same pass. Unreadable-snapshot reasons also bypass the memo. The separate runtime-capability case is reported above.
    • state: answered
  • The closing health pass reuses the drain map without copying it (P3)
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f2
    • evidence_locator: internal/cli/reply_wake_outbox.go:379-394,441-444; local://11.log:100-102
    • file: internal/cli/reply_wake_outbox.go:441-444
    • rationale: The classifier assigns the supplied map directly and allocates only when passed nil. TestReplyWakeDrainProbesAnUndeliverableRecipientOncePerPass passed.
    • state: answered
  • The memo regression test rejects an aborted health pass (P3)
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f3
    • evidence_locator: internal/cli/reply_wake_probe_memo_test.go:67-69; local://11.log:100-102
    • file: internal/cli/reply_wake_probe_memo_test.go:67-69
    • rationale: The test now requires the outstanding-obligations error with pending=3 and rejects nil or unrelated errors. It passed at this head.
    • state: answered

Tests Run

  • CGO_ENABLED=0 go build -buildvcs=false -o /dev/null ./cmd/gitmoot -> passed
  • CGO_ENABLED=0 go vet -buildvcs=false ./internal/cli ./cmd/gitmoot -> passed
  • CGO_ENABLED=0 go test -buildvcs=false -count=1 -v -timeout 5m ./internal/cli -run 'Test.*(ReplyWake|WakeOutbox|DeferredNotice|DeferredMessage|MessageRecipient|AwaitedFact.*Wake|ReviewResult.*Wake)' -> passed; local://11.log
  • CGO_ENABLED=0 go test -buildvcs=false -count=1 -v -timeout 3m ./internal/cli -run '^(TestMessageDaemon|TestMessageDeferralNotice|TestDirectiveWakeDrain|TestRuntimeDeferralKeeps)' -> passed; local://10.log
  • CGO_ENABLED=0 go test -buildvcs=false -overlay "$probe/overlay.json" -count=1 -v -timeout 2m ./internal/cli -run '^TestReview2813RuntimeDetectionRecoversBetweenGroups$' -> failed in both cases: next-pass delivery, with a stale notice persisted; proc://bg_2
    Diagnostics: workflow advance failed: review objection held: the objection is bound to head e64b038 and the observed pull request head is a0352fe; waiting for the repo poll to update the observed head before deciding whether the objection is current

Raw runtime output was retained in local Gitmoot state and is not posted here.

…g it (#2812)

Review round 2 of #2813: a runtime-kind result can change between groups
of one pass, and recording it for later groups wrote a stale reason that a
sender notice could cite. Probe results now carry an explicit
skipRestOfPass classification instead of an allowlist of reason text. A
recipient's later groups reuse the first result but record nothing; after
the group loop one fresh probe per recipient decides whether their
deferral reason is recorded, so a stale result costs at most one pass of
delay. Two probes per undeliverable recipient per pass, however many
groups it owns.
@jerryfane

Copy link
Copy Markdown
Collaborator Author

Reviewer: e2b-full-review-2230
Runtime: omp
Job: local-review-review-router-18edf7012735c440-1

Decision: changes_requested
Summary: Reviewed #2813 at 0219a7b. Build, vet, and 41 focused tests passed. An independent regression probe reproduced a false one-time sender notice after the drain confirmed the recipient was ready.
Severity: P1

Findings

  • A successful recheck still lets a historical reason reach the sender (P1)
    • detail: The ready branch leaves skipped rows pending without overriding their projected LastError. The notice pass falls back to that old value. The probe first stored Claude's next-turn reason before the 15-minute notice threshold. On the next pass, the first lookup found no seat and the recheck found idle OMP, yet the sender received a one-time notice naming Claude's old reason. The prior head wrote the no-seat reason for that batch, which suppresses notices. Explicitly suppress notices for the row IDs confirmed ready; leaving delivery to the next pass is fine.
    • evidence_locator: TestReview2813RecheckDoesNotPublishHistoricalReason, review2813_overlay_test.go:49; internal/cli/reply_wake_outbox.go:389-392,417-419; internal/cli/message_delivery.go:126-133,183-191
    • file: internal/cli/reply_wake_outbox.go:389-392
    • in_delta: true
  • Queued rechecks use whichever readiness callback was resolved last (P3)
    • detail: An unrelated later batch can replace the callback used to confirm earlier recipients. Production returns equivalent same-home callbacks today, but the drain depends on that unstated invariant. Keep the callback with the queued recipient or make readiness explicitly pass-scoped.
    • evidence_locator: internal/cli/reply_wake_outbox.go:293-305,336-339,379-385; internal/cli/daemon_worker.go:161-178
    • file: internal/cli/reply_wake_outbox.go:305
    • in_delta: true
  • Closing health discards the fresh positive probe and probes again (P3)
    • detail: The regression probe observed three readiness calls for the recovering recipient. The group loop has already ended, so keeping the fresh positive status cannot skip any more groups. Pass that result to health just as the code already does for a fresh negative.
    • evidence_locator: TestReview2813RecheckDoesNotPublishHistoricalReason, review2813_overlay_test.go:49; internal/cli/reply_wake_outbox.go:384-394,513-525
    • file: internal/cli/reply_wake_outbox.go:391
    • in_delta: true
  • P1
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f4
    • evidence_locator: local://7.log:150-155
    • file: internal/cli/reply_wake_outbox.go:336-339,384-402
    • rationale: TestReplyWakeDrainDoesNotRecordAReasonThatWentStaleMidPass passed. A cached runtime negative no longer writes a reason for later groups: the fresh probe decides that write. The separate historical-reason fallback is reported above.
    • state: answered
  • P3
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f5
    • evidence_locator: internal/cli/reply_wake_outbox.go:293-304; local://7.log:147-149,156-160
    • file: internal/cli/message_delivery.go:32-84
    • rationale: Readiness branches now set skipRestOfPass directly; the drain no longer matches diagnostic text. The steady-skip and transient-offline tests passed.
    • state: answered
  • P1
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f1
    • evidence_locator: local://7.log:156-160
    • file: internal/cli/message_delivery.go:59-68
    • rationale: TestReplyWakeDrainReprobesATransientlyOfflineRecipient passed: only the group seen offline stayed pending, and later groups delivered in the same pass. Snapshot failures also leave the skip flag unset.
    • state: answered
  • P3
  • P3

Tests Run

  • CGO_ENABLED=0 go build -buildvcs=false ./cmd/gitmoot ./internal/cli — passed
  • CGO_ENABLED=0 go vet ./internal/cli ./cmd/gitmoot — passed
  • CGO_ENABLED=0 go test -count=1 -timeout 8m -v ./internal/cli -run '^Test(ReplyWake(Drain|Outbox)|WakeOutbox(Health|Coalesces|TickHealth)|FactWakeDrain|DirectiveWake(Outbox|Drain)|OptionalWakeRuleDeletedMidDrain|Message(Daemon|Deferral|Delivery|Recipient))' — 41 top-level tests passed
  • CGO_ENABLED=0 go test -overlay /proc/3899824/fd/10 -count=1 -v ./internal/cli -run '^TestReview2813RecheckDoesNotPublishHistoricalReason$' — failed as reproduced: message 11 received the historical reason after OMP recovery; overlay held in memory
    Diagnostics: workflow advance failed: review objection held: the objection is bound to head 0219a7b and the observed pull request head is e64b038; waiting for the repo poll to update the observed head before deciding whether the objection is current

Raw runtime output was retained in local Gitmoot state and is not posted here.

Review round 3 of #2813: rows the closing probe finds deliverable record
an empty reason for the pass, so the notice cannot fall back to a reason
an earlier pass stored. Each skipped recipient is confirmed with the
readiness callback of the batch that observed it, and the fresh result,
positive or negative, seeds the health pass.
@jerryfane

Copy link
Copy Markdown
Collaborator Author

Reviewer: e2b-full-review-2230
Runtime: omp
Job: local-review-review-router-18edf7d7cbdc39df-1

Decision: approved
Summary: Reviewed #2813 at 114d2db. Confirmed-ready rows no longer send notices citing historical deferral reasons. Build, vet, and focused wake-outbox and notice tests passed. Two nonblocking design findings.
Severity: P3

Findings

  • P1
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f6
    • evidence_locator: local://9.log:121-122; internal/cli/message_delivery.go:126-133,183-185
    • file: internal/cli/reply_wake_outbox.go:394-401
    • rationale: The closing probe writes a present-but-empty reason for each confirmed-ready row, so the notice pass does not fall back to LastError. TestReplyWakeDrainConfirmedReadyRowsEarnNoNoticeFromAnOldReason passed.
    • state: answered
  • P3
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f7
    • evidence_locator: internal/cli/reply_wake_outbox.go:296-307,382-391
    • file: internal/cli/reply_wake_outbox.go:304-307
    • rationale: The drain retains the callback that first memoized each recipient and uses that recipient's callback for confirmation. Later batch resolutions cannot overwrite it.
    • state: answered
  • P3
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f8
    • evidence_locator: internal/cli/reply_wake_outbox.go:392-394,427,489-492,521-530
    • file: internal/cli/reply_wake_outbox.go:392-394
    • rationale: Both positive and negative recheck results enter the map before the branches diverge. Closing health probes only when the recipient key is absent.
    • state: answered
  • P1
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f1
    • evidence_locator: local://9.log:123-127; internal/cli/reply_wake_outbox.go:296-307
    • file: internal/cli/message_delivery.go:59-68
    • rationale: Offline, unresolved-binding, and snapshot-error results do not set the skip flag. The transient-offline test passed: only the first group remained pending.
    • state: answered
  • P3
  • P3
  • P1
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f4
    • evidence_locator: local://9.log:115-120; internal/cli/reply_wake_outbox.go:388-411
    • file: internal/cli/reply_wake_outbox.go:339-342
    • rationale: Cached batches queue their IDs without recording a reason; the fresh probe controls any later write. The runtime-transition test passed: only the first group recorded a reason, and the next pass delivered all three groups.
    • state: answered
  • P3
    • continues_uid: fix(wake): probe an undeliverable recipient once per drain pass (#2812) #2813-f5
    • evidence_locator: internal/cli/message_delivery.go:32-84; local://9.log:112-114,123-127
    • file: internal/cli/reply_wake_outbox.go:304-307
    • rationale: The drain uses the explicit skipRestOfPass flag rather than matching display text. Both steady-skip and transient-offline tests passed.
    • state: answered
  • Recheck rows and their callback live in separate maps (P3)
    • detail: The closing loop trusts that every recipient in recheck has a non-nil callback in recheckReady. Current insertion order guarantees that, but the maps do not express it. Store the callback and queued IDs in one per-recipient recheck entry; keep the status map for health.
    • evidence_locator: internal/cli/reply_wake_outbox.go:304-307,339-342,382-388
    • file: internal/cli/reply_wake_outbox.go:175-180
    • in_delta: true
  • The no-notice regression can pass without confirming readiness (P3)
    • detail: The test hard-codes the batch size and only checks that the target notice is absent. If the drain exits before the notice pass, the fixture discards its diagnostic and the assertion passes. Queue replyWakeMaxCoalescedItems+1 messages and verify that the closing probe ran and a first-batch notice was written before asserting that the final message earned none.
    • evidence_locator: internal/cli/reply_wake_probe_memo_test.go:149-180; internal/cli/message_deferral_notice_test.go:48-51; internal/cli/reply_wake_drain_loop.go:82-93
    • file: internal/cli/reply_wake_probe_memo_test.go:149-180
    • in_delta: true

Tests Run

  • CGO_ENABLED=0 GOCACHE="$TMPDIR/go-build" go build -buildvcs=false -o /dev/null ./cmd/gitmoot -> passed
  • CGO_ENABLED=0 GOCACHE="$TMPDIR/go-build" go vet -buildvcs=false ./internal/cli -> passed
  • CGO_ENABLED=0 GOCACHE="$TMPDIR/go-build" go test -buildvcs=false -count=1 -v ./internal/cli -run 'Test.*(ReplyWake|WakeOutbox|MessageDeferralNotice)' -> passed; internal/cli 7.930s (local://9.log)
    Diagnostics: workflow advance failed: review approval held: approval is bound to head 114d2db but the observed pull request head is e64b038; holding until the observed head catches up, because an approval at a genuinely superseded head must not clear changes_requested

Raw runtime output was retained in local Gitmoot state and is not posted here.

@jerryfane
jerryfane added this pull request to the merge queue Dec 4, 2026
Merged via the queue into main with commit 2152ffe Dec 4, 2026
23 checks passed
@jerryfane
jerryfane deleted the fix/wake-drain-probe-memo branch December 4, 2026 06:47
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.

Wake drain re-probes undeliverable seats per group; live seats' wakes wait minutes

1 participant