fix(notify): preserve only relevant pending wakes - #91
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The current staleness/retention logic can treat superseded wakes as current and can overwrite a newer same-key notification when re-queuing during a busy transition.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR tightens the notification runtime’s handling of pending loop wakes by binding queued notifications to controller identity/fire identity, invalidating stale work, and refreshing workflow wake messages when only the workflow definition revision changes.
Changes:
- Add controller identity (
controllerCreatedAt) and fire identity (fireCount) fields to loop-fire notifications and validate them at delivery time. - Refresh queued workflow notifications to reflect updated definition revisions (without invalidating the current execution wake) and drop wakes for canceled/paused/completed/superseded work.
- Expand test coverage for workflow revision refresh + session/busy-boundary delivery behavior.
File summaries
| File | Description |
|---|---|
| test/workflow-task-integration.test.ts | Adds a workflow integration test ensuring revising future work preserves the current pending wake and refreshes message revision. |
| test/notification-runtime.test.ts | Adds notification runtime tests for invalidation on delete/pause/complete, legitimate final-fire delivery, and busy retention semantics. |
| test/notification-coordinator.test.ts | Updates notification test helper to include the newly-required prompt field. |
| src/runtime/notification-runtime.ts | Implements controller/fire identity checks, workflow notification refresh, and “busy during delivery” retention behavior. |
| src/notification-reducer.ts | Extends the notification model (adds prompt, controller/fire identity fields, and tightens trigger typing). |
| src/index.ts | Populates controllerCreatedAt and fireCount in emitted loop-fire notifications. |
Review details
Suppressed comments (1)
src/runtime/notification-runtime.ts:426
- When the runtime becomes busy during delivery, this block re-queues the dequeued notification unconditionally. If a newer same-key notification was queued after the flush dequeued this one (common for recurring loops), this re-queue will overwrite the newer wake in notificationsByKey. Guard the re-queue so it only happens when there isn’t already a newer notification for the same key.
if (notificationState.agentRunning) {
debug?.(`loop:fire #${notification.loopId} — runtime became busy before delivery, retaining wake`);
applyNotificationEvent({
type: "NOTIFICATION_QUEUED",
at: Date.now(),
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
trvon
force-pushed
the
fix/notification-relevance
branch
from
September 5, 2026 02:19
30e4e32 to
73d4f57
Compare
trvon
force-pushed
the
fix/notification-relevance
branch
from
September 5, 2026 02:51
73d4f57 to
cc85bf4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
Stack
4 of 6. Base:
fix/workflow-limit-authority.