Skip to content

fix(notify): preserve only relevant pending wakes - #91

Merged
trvon merged 4 commits into
fix/workflow-limit-authorityfrom
fix/notification-relevance
Sep 5, 2026
Merged

fix(notify): preserve only relevant pending wakes#91
trvon merged 4 commits into
fix/workflow-limit-authorityfrom
fix/notification-relevance

Conversation

@trvon

@trvon trvon commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • bind pending wakes to controller creation and fire identity
  • invalidate canceled, paused, completed, monitor-waiting, and superseded work
  • preserve compatible workflow revision refresh and legitimate final-fire delivery
  • retain busy wakes without overwriting newer same-key notifications

Validation

  • full branch suite: 926 tests passed

Stack

4 of 6. Base: fix/workflow-limit-authority.

Copilot AI lite review requested due to automatic review settings September 5, 2026 01:42

Copilot AI 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.

🟡 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.

Comment thread src/runtime/notification-runtime.ts Outdated
@trvon
trvon force-pushed the fix/notification-relevance branch from 30e4e32 to 73d4f57 Compare September 5, 2026 02:19
@trvon
trvon force-pushed the fix/notification-relevance branch from 73d4f57 to cc85bf4 Compare September 5, 2026 02:51
@trvon
trvon merged commit 88bc67b into master Sep 5, 2026
5 checks passed
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