Skip to content

engine: fire node-scoped actions from message triggers#261

Merged
willwashburn merged 2 commits into
mainfrom
trigger-node-scoped-actions
Jul 11, 2026
Merged

engine: fire node-scoped actions from message triggers#261
willwashburn merged 2 commits into
mainfrom
trigger-node-scoped-actions

Conversation

@willwashburn

@willwashburn willwashburn commented Jul 10, 2026

Copy link
Copy Markdown
Member

What this is

Message triggers can now fire node-scoped (fleet-provider) actions. A trigger bound to an action name resolves plain node-scoped action rows and dispatches them node-addressed, so defineNode's onMessage→action handlers run.

Why

A trigger binds to an action name with no node and fires through the workspace-global invokeAction, whose resolver (fetchAction) intentionally excludes plain node-scoped actions — or(isNull(handlerNodeId), isGlobal) — because the HTTP /v1/actions/:name/invoke path treats those as node-addressed. So a trigger bound to a fleet-provider action never resolved, threw action_not_found, and was silently swallowed by the trigger's best-effort catch. Under the node-provider model that broke defineNode's onMessage→action feature product-wide.

Change

fetchAction/invokeAction take an opt-in includeNodeScoped (default off — the HTTP invoke path is unchanged). The trigger firing path passes it, and the resolved node-scoped row dispatches through invokeAction's existing handlerNodeId branch. (workspaceId, name) is not unique across nodes, so resolution ranks agent-hosted > global-alias > node-scoped and breaks ties by id for determinism.

Known limitation: when several nodes define the same action name, the trigger dispatches to one deterministically. Placement-aware or fan-out selection across identical fleet nodes is a follow-up; the common defineNode case is one node per action name.

Test

triggerNodeScoped.test.ts registers a node-scoped action, binds a trigger to it, fires a matching message, and asserts the action is dispatched to the owning node. Verified to fail without the fix (trigger never fires).

Refs #250.

🤖 Generated with Claude Code

Review in cubic

A message trigger binds to an action name with no node and dispatches through
the workspace-global invokeAction, whose resolver excludes plain node-scoped
actions (`or(isNull(handlerNodeId), isGlobal)`). So a trigger bound to a
fleet-provider action never resolved and never fired — breaking defineNode's
onMessage->action feature under the node-provider model.

Give action resolution an opt-in to include node-scoped rows and pass it from
the trigger path. The resolved node-scoped row dispatches node-addressed through
invokeAction's existing handlerNodeId branch. (workspace, name) is not unique
across nodes, so resolution ranks agent-hosted > global > node-scoped and breaks
ties by id for determinism; the HTTP invoke path is unchanged (opt-in defaults
off).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@willwashburn, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c2f53d3-26fd-466c-b356-dea412a79792

📥 Commits

Reviewing files that changed from the base of the PR and between 1447018 and 46ae310.

📒 Files selected for processing (8)
  • .agentworkforce/trajectories/completed/2026-07/traj_xyv1cw196ghp/summary.md
  • .agentworkforce/trajectories/completed/2026-07/traj_xyv1cw196ghp/trajectory.json
  • README.md
  • openapi.yaml
  • packages/engine/CHANGELOG.md
  • packages/engine/src/__tests__/conformance/triggerNodeScoped.test.ts
  • packages/engine/src/engine/action.ts
  • packages/engine/src/engine/trigger.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch trigger-node-scoped-actions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request fixes an issue where message triggers failed to fire node-scoped (fleet-provider) actions by allowing triggers to resolve actions without a node constraint. It introduces a deterministic action resolution ranking (agent-hosted, workspace-global, then node-scoped) and adds a comprehensive conformance test. The feedback suggests replacing localeCompare with standard comparison operators to ensure locale-independent and faster sorting of action IDs.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +162 to +164
return rows.sort(
(a, b) => actionResolutionRank(a) - actionResolutionRank(b) || a.id.localeCompare(b.id),
)[0] ?? null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using localeCompare without a specified locale is non-deterministic because its behavior depends on the default locale of the system/runtime environment. Since action IDs are standard alphanumeric strings, using standard comparison operators (< and >) is fully deterministic, locale-independent, and significantly faster.

Suggested change
return rows.sort(
(a, b) => actionResolutionRank(a) - actionResolutionRank(b) || a.id.localeCompare(b.id),
)[0] ?? null;
return rows.sort(
(a, b) => actionResolutionRank(a) - actionResolutionRank(b) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0),
)[0] ?? null;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 46ae310. The ID tie-break now uses direct less-than/greater-than comparisons instead of localeCompare, preserving the resolution rank while making ordering locale-independent.

@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: 99264f0b9c

ℹ️ 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".

## [Unreleased]

### Fixed
- Message triggers fire node-scoped (fleet-provider) actions: a trigger bound to an action name now resolves plain node-scoped actions and dispatches them node-addressed, so `defineNode`'s onMessage→action handlers run. Previously the trigger's workspace-global resolver excluded node-scoped actions, so such triggers never fired.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update README.md and OpenAPI for trigger behavior

This changelog entry documents a public /v1/triggers behavior change: action_name can now resolve plain node-scoped actions and dispatch one node-addressed. The root AGENTS.md Docs Hygiene section says to “Update README.md and openapi.yaml together when API behavior changes,” but this patch only updates the changelog, so generated/API docs still omit the node-scoped resolution and deterministic single-node selection semantics that trigger users need to understand.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 46ae310. README and openapi.yaml now document that triggers can resolve plain node-scoped actions, the agent-hosted then workspace-global alias then node-scoped precedence, owning-node dispatch, and deterministic single-target selection without fan-out. Direct workspace-scoped invoke behavior remains unchanged.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Re-trigger cubic

@willwashburn willwashburn merged commit 9723f1e into main Jul 11, 2026
6 of 7 checks passed
@willwashburn willwashburn deleted the trigger-node-scoped-actions branch July 11, 2026 15:00
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.

1 participant