Skip to content

feat(workflows): preserve execution principals - #6891

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

feat(workflows): preserve execution principals#6891
TheodoreSpeaks wants to merge 12 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 26, 2026 6:19pm

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 carries verified identity through synchronous, queued, nested, webhook, and paused workflow execution.

  • Adds a bounded legacy decoder for pre-principal pause snapshots and queued jobs.
  • Persists principals in newly versioned snapshots and validates malformed or unsupported persisted identity.
  • Uses the current principal to scope credential-group and managed-credential access.
  • Preserves external trigger identities, including Slack actor information.

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported legacy snapshot incompatibility is addressed by the bounded unversioned decoder, and no blocking failure remains.

Important Files Changed

Filename Overview
packages/auth/src/principal.ts Defines the versioned principal model, serialization, parsing, and subject-resolution helpers used across execution boundaries.
apps/sim/executor/execution/snapshot.ts Versions newly persisted snapshots and restores pre-principal snapshots through a bounded compatibility decoder.
apps/sim/executor/execution/snapshot-serializer.ts Requires the active execution principal to be included when serializing resumable workflow state.
apps/sim/background/workflow-execution.ts Parses queued principals and reconstructs bounded authority for legacy workflow jobs.
apps/sim/background/webhook-execution.ts Validates persisted webhook principals and reconstructs the canonical webhook identity for legacy jobs.
apps/sim/lib/credentials/application/resolve-managed-oauth-token.ts Applies the propagated execution principal when resolving managed credentials.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Authenticated request or verified trigger] --> P[Versioned execution principal]
  P --> E[Workflow execution]
  E --> Q[Queued or nested execution]
  E --> S[Pause snapshot]
  Q --> R[Principal validation and restoration]
  S --> R
  R --> C[Credential and operation authorization]
Loading

Reviews (8): Last reviewed commit: "fix(workflows): restore legacy paused ap..." | 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.

Comment thread apps/sim/executor/execution/snapshot.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

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