Skip to content

feat(workflows): preserve execution principals - #6891

Open
TheodoreSpeaks wants to merge 8 commits into
stagingfrom
feat/workspace-principal
Open

feat(workflows): preserve execution principals#6891
TheodoreSpeaks wants to merge 8 commits into
stagingfrom
feat/workspace-principal

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • Carry a versioned execution principal through synchronous, asynchronous, nested, and paused workflow execution
  • Preserve verified external trigger identity, including Slack team and user IDs
  • Scope Credential Group access to the current external actor by default
  • Fail fast on malformed persisted identity instead of substituting billing or workflow owners

Type of Change

  • New feature

Testing

  • 350 tests across workflow execution, snapshots, delegation, Slack, and Credential Groups
  • Sim and auth TypeScript checks
  • bun run lint
  • bun run check:audits
  • Block registry stability check

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

Not applicable; this branch has no new UI.

@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 23, 2026 8:18pm

Request Review

@cursor

cursor Bot commented Aug 20, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Changes authentication, internal delegation JWTs, pause/resume snapshots, and managed OAuth access. Incorrect principal restore or enrollment matching could leak credentials or mis-attribute actor identity.

Overview
Carries a versioned execution principal (session, API key, delegated, or system) through hybrid auth, execute routes, background jobs, pause snapshots, and nested/custom-block runs. Billing/owner IDs no longer stand in for the original caller.

Identity persistence. Snapshots and queued jobs serialize principals with versioning. Legacy jobs/pauses restore only unambiguous identity (session vs actorless system); malformed data fails closed. Internal executor JWTs can be actorless or carry an external subject; they reject laundering those into a Sim user sub.

External triggers and Credential Groups. Slack webhooks attach a verified external_user (tenant + user). Managed OAuth token use now requires the current principal’s enrollment, so provider blocks default to that actor’s credential. Listing credentials is no longer auto-filtered to the caller; using another enrollment needs an explicit grant. System/delegated principals cannot create uploads.

Reviewed by Cursor Bugbot for commit dc027f2. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR introduces versioned execution principals and preserves them across synchronous, queued, nested, webhook, and paused workflow execution.

  • Adds principal serialization and bounded legacy decoding for pause snapshots.
  • Propagates verified external identities through execution boundaries.
  • Uses the active external actor when authorizing Credential Group access.
  • Rejects malformed or unsupported persisted identities rather than substituting workflow or billing owners.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/executor/execution/snapshot.ts Adds a versioned snapshot codec, strict principal parsing, and bounded compatibility for pre-principal snapshots; the previously reported legacy-resume failure is addressed.
apps/sim/executor/execution/snapshot-serializer.ts Requires and serializes the execution principal when producing durable pause snapshots.
apps/sim/executor/execution/executor.ts Carries the supplied principal into resumed executor context without replacing it with billing or workflow ownership.
apps/sim/lib/workflows/executor/execution-core.ts Propagates snapshot principals through the common execution boundary and nested delegation context.
packages/auth/src/principal.ts Defines the versioned principal serialization, parsing, subject resolution, and attribution contracts used by workflow execution.
apps/sim/executor/handlers/credential-group/credential-group-handler.ts Applies the propagated execution principal to Credential Group delegation and actor-scoped authorization.

Sequence Diagram

sequenceDiagram
  participant Trigger as Authenticated trigger
  participant Core as Execution core
  participant Exec as Workflow executor
  participant Store as Pause snapshot store
  participant Resume as Resume pipeline

  Trigger->>Core: Input + verified principal
  Core->>Exec: Execution metadata + principal
  Exec->>Store: Versioned snapshot with serialized principal
  Store->>Resume: Persisted snapshot
  Resume->>Resume: Parse version and principal
  Resume->>Core: Restored snapshot metadata
  Core->>Exec: Original principal preserved
Loading

Reviews (6): Last reviewed commit: "fix(workflows): resume legacy queued job..." | Re-trigger Greptile

Comment thread apps/sim/executor/execution/snapshot.ts Outdated
Comment thread apps/sim/app/api/mcp/serve/[serverId]/route.ts
@TheodoreSpeaks
TheodoreSpeaks force-pushed the feat/workspace-principal branch from 8532691 to 43e2364 Compare August 20, 2026 18:05
Comment thread apps/sim/lib/uploads/upload-session/service.ts
Comment thread apps/sim/lib/auth/hybrid.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/executor/execution/snapshot.ts Outdated
@TheodoreSpeaks
TheodoreSpeaks force-pushed the feat/workspace-principal branch from 41ea290 to 3f85676 Compare August 21, 2026 01:49
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/credentials/application/resolve-managed-oauth-token.ts
@TheodoreSpeaks
TheodoreSpeaks force-pushed the feat/workspace-principal branch from aebf473 to 4489fc2 Compare August 21, 2026 04:43
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/background/workflow-execution.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 33caa1f. Configure here.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit dc027f2. Configure here.

}
}
return { kind: 'system', serviceId: 'internal', workspaceId, workflowId }
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Legacy pause drops API-key actor

Medium Severity

parseLegacyPrincipal only restores a human actor from sessionUserId, so pre-principal paused runs that recorded the caller via enforceCredentialAccess and userId (personal API key / MCP bridge) become actorless internal principals on resume. The legacy workflow-job decoder already treats that same flag as an unambiguous user actor, so resumed HITL runs lose enrollment-scoped Credential Group access that the original execution had.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit dc027f2. Configure here.

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