Skip to content

Adds activity call stack support#119

Merged
sfmskywalker merged 14 commits intomainfrom
feat/activity-call-stack
Mar 2, 2026
Merged

Adds activity call stack support#119
sfmskywalker merged 14 commits intomainfrom
feat/activity-call-stack

Conversation

@sfmskywalker
Copy link
Copy Markdown
Member

Adds support for tracking the activity call stack during workflow execution. This allows for better debugging and understanding of workflow execution flow.

  • Adds new fields to ActivityExecutionRecord and ActivityExecutionSummaryRecord for tracking scheduling activity information and call stack depth.
  • Introduces a GetExecutionChainAsync method to retrieve the chain of activity executions, enabling traversal of the call stack.
  • Includes a database migration to add the new fields to the ActivityExecutionRecords table.
  • Fixes an infinite loop issue that could occur during activity execution chain traversal.

…ecution record stores

Implemented a method to retrieve the execution chain of activity records with optional cross-workflow traversal and pagination capabilities. Expanded filtering and mapping functionality to support new attributes.
Introduced properties for metadata, fault aggregation, scheduling, and call stack depth to enhance activity execution tracking and analysis.
Refactored constructors across multiple activity providers to return the full result object from `CreateActivity` method, ensuring consistent object handling.
Added a new FluentMigrator migration to include extra fields in the `ActivityExecutionRecords` table, enabling enhanced metadata, scheduling, and call stack depth tracking.
Added cycle detection using a `HashSet` to prevent infinite loops when traversing activity execution chains in multiple storage implementations. Updated unit tests to validate correct handling of circular references and chain traversal.
Copilot AI review requested due to automatic review settings February 4, 2026 20:15
Centralized the `GetExecutionChainAsync` method into an extension class to streamline and unify its implementation across stores. Removed redundant implementations from individual stores and updated interfaces to utilize the new extension method. This reduces code duplication and simplifies future maintenance.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for tracking the activity call stack during workflow execution to enable better debugging and understanding of workflow execution flow.

Changes:

  • Introduces new database fields (SchedulingActivityExecutionId, SchedulingActivityId, SchedulingWorkflowInstanceId, CallStackDepth, SerializedMetadata, AggregateFaultCount) to track activity scheduling relationships and call stack depth
  • Implements GetExecutionChainAsync method in both MongoDB and Dapper persistence stores to retrieve the execution chain with infinite loop protection using a visited set
  • Updates activity providers to handle the new return type from CreateActivity, which now returns a result object containing the activity and additional metadata

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/modules/persistence/Elsa.Persistence.Dapper.Migrations/Runtime/V3_7.cs Adds database migration to create new columns for activity execution tracking
src/modules/persistence/Elsa.Persistence.Dapper/Modules/Runtime/Records/ActivityExecutionRecord.cs Adds new properties for scheduling context, metadata, fault count, and call stack depth
src/modules/persistence/Elsa.Persistence.Dapper/Modules/Runtime/Records/ActivityExecutionSummaryRecord.cs Adds metadata and aggregate fault count to summary record
src/modules/persistence/Elsa.Persistence.Dapper/Modules/Runtime/Stores/DapperActivityExecutionRecordStore.cs Implements GetExecutionChainAsync, updates filter criteria, and adds mapping for new fields
src/modules/persistence/Elsa.Persistence.MongoDb/Modules/Runtime/ActivityExecutionLogStore.cs Implements GetExecutionChainAsync with pagination and cross-workflow chain traversal support
src/modules/servicebus/Elsa.ServiceBus.MassTransit/Services/MassTransitActivityTypeProvider.cs Updates activity constructors to handle new CreateActivity return type
src/modules/http/Elsa.Http.Webhooks/ActivityProviders/WebhookEventActivityProvider.cs Updates activity constructor to handle new CreateActivity return type
src/modules/cms/Elsa.OrchardCore/ActivityProviders/OrchardContentItemsEventActivityProvider.cs Updates activity constructor to handle new CreateActivity return type
src/modules/agents/Elsa.Agents.Activities/ActivityProviders/AgentActivityProvider.cs Updates activity constructor to handle new CreateActivity return type
Comments suppressed due to low confidence (1)

src/modules/persistence/Elsa.Persistence.MongoDb/Modules/Runtime/ActivityExecutionLogStore.cs:102

  • The logic for stopping at workflow boundaries appears to be incorrect. The current condition stops traversal whenever SchedulingWorkflowInstanceId is not null, even if it's the same workflow instance. This would incorrectly stop the traversal within the same workflow when one activity schedules another. The condition should compare SchedulingWorkflowInstanceId with WorkflowInstanceId to detect actual cross-workflow boundaries. Consider changing the condition to: if (!includeCrossWorkflowChain && record.SchedulingWorkflowInstanceId != null && record.SchedulingWorkflowInstanceId != record.WorkflowInstanceId)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sfmskywalker
Copy link
Copy Markdown
Member Author

@copilot open a new pull request to apply changes based on the comments in this thread. Make sure you understand & agree with the feedback before making changes.

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 5, 2026

@sfmskywalker I've opened a new pull request, #120, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits February 5, 2026 11:40
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Add missing AggregateFaultCount column to V3_7 migration
@lukhipolito-nexxbiz
Copy link
Copy Markdown
Contributor

Build step is failing

@gitguardian
Copy link
Copy Markdown

gitguardian bot commented Mar 2, 2026

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
13223926 Triggered Generic Password b13f55a src/modules/scheduling/Elsa.Scheduling.Quartz.EFCore.PostgreSql/ShellFeatures/QuartzPostgreSqlFeature.cs View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@sfmskywalker sfmskywalker merged commit 7b7cd22 into main Mar 2, 2026
5 of 8 checks passed
@sfmskywalker sfmskywalker deleted the feat/activity-call-stack branch March 2, 2026 19:06
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.

4 participants