Skip to content

fix(workflows): recheck current trigger grants before event dispatch - #302

Open
drewstone wants to merge 3 commits into
mainfrom
fix/workflow-dispatch-current-grants
Open

drewstone wants to merge 3 commits into
mainfrom
fix/workflow-dispatch-current-grants

Conversation

@drewstone

@drewstone drewstone commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Why

Event dispatch previously matched installed workflow status, connection and trigger without rechecking the current trigger grant or subscription status. Revoked, deleted or narrowed grants could remain effective.

Implementation

Reuse the existing workflow primitive. Require active workflow and subscription; resolve the current trigger grant for each candidate; verify its status, allowed trigger, manifest, owner, grantee, connection and connector. Grant lookup errors fail closed before consumer invocation. Existing APIs and callback behavior are preserved.

Verification

Complete repository verification passed for head 1ab5db508ef1d9e1160ffa5fd156fe7b636431a3: frozen installation, typecheck, full Vitest suite and packed-release checks.

Run: https://github.com/tangle-network/agent-integrations/actions/runs/34722173137

Behavioral tests cover successful dispatch, later revocation, deleted/narrowed/mismatched grants, inactive subscriptions, unrelated events, grant-store errors and consumer failures. Earlier isolated harness evidence was 7/23 passing before the fix and 23/23 after; the repository CI above supersedes the earlier local-only verification limitation.

Integration and boundaries

Companions: #303 adds messaging adapters/verifiers; tangle-network/agent-dev-container#7334 binds queued messaging work and reply effects to their current source connection; tangle-network/agent-app#579 removes single-use broker-token sharing.

Ingress authentication remains the caller's responsibility. A dispatch-time grant snapshot is not a transaction-wide revocation lease; deferred effects must recheck authority. This PR does not provision accounts, buy numbers, send live messages, publish packages or deploy services. Non-draft implementation PR; not a deployment claim.

@drewstone
drewstone marked this pull request as ready for review September 12, 2026 22:14

@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: 1ab5db508e

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

Comment thread src/workflow.ts
|| workflow.subscription.trigger !== event.trigger
) continue

const grant = await this.grants.get(workflow.triggerGrantId)

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 Batch grant lookups before dispatch

When a connection and trigger have multiple active workflows backed by a persistent grant store, this await performs one database/network round trip at a time, so webhook dispatch latency grows linearly with the number of matching workflows and can exceed ingress timeouts. Collect the candidate grant IDs first and use listByIds when available (with a parallel get fallback, as resolveBundleGrants already does) while retaining the fail-closed behavior before invoking the handler.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-12T22:16:20.887660Z 1ab5db5 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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