Skip to content

CRE Gate and Limit Handling Improvements - #23458

Open
tarcisiozf wants to merge 6 commits into
developfrom
DEVSVCS-5859/fix-early-returns
Open

CRE Gate and Limit Handling Improvements#23458
tarcisiozf wants to merge 6 commits into
developfrom
DEVSVCS-5859/fix-early-returns

Conversation

@tarcisiozf

@tarcisiozf tarcisiozf commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces improvements to how configuration setting (CRE) gates and limits are handled across several components, focusing on more robust error handling, consistent gate evaluation, and improved observability. The changes standardize the use of helper functions for gate checks, ensure soft-fail behavior (falling back to defaults) when reading certain limits fails, and add new metrics for monitoring such fallbacks. Additionally, there is a refactor to how trigger event aging is managed in the workflow engine.

CRE Gate and Limit Handling Improvements:

  • Standardized gate evaluation across the codebase by replacing direct calls to Limit and custom error handling with the shared crelimits.GateOpen and crelimits.GateAllows helpers, ensuring consistent behavior and error logging for CRE gates.
  • Improved error handling for limit reads in the workflow engine: when reading the execution time limit fails, the system now logs the error, increments a new metric, and falls back to the default value instead of dropping the execution.

Metrics and Observability:

  • Added a new metric (limitReadFallbackTotal) and corresponding label (limitKey) to monitor cases where a limit read fails and the system falls back to its static default, increasing visibility into configuration issues.

Workflow Engine Refactor and Behavior:

  • Refactored trigger event queue age limiting: replaced the time limiter with a bound limiter on event age, and changed the handling so that a limit read failure no longer drops the event but allows execution to proceed, logging the error.
  • Added robust handling for executions that are dropped before they can start, ensuring that appropriate events are emitted for better traceability in the UI and metrics.

Internal Refactoring:

  • Updated EngineLimiters to track and expose the effective default settings used for limits, supporting the new fallback logic and making configuration more transparent.

These changes collectively make the system more resilient to configuration read errors, provide better diagnostics, and improve the consistency of gate and limit enforcement.

@github-actions

Copy link
Copy Markdown
Contributor

✅ No conflicts with other open PRs targeting develop

@github-actions

Copy link
Copy Markdown
Contributor

I see you updated files related to core. Please run make gocs in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

Copilot AI 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.

Pull request overview

Risk Rating: MEDIUM — changes touch core workflow-engine execution control-flow (early returns, limiter fallbacks, metering lifecycle), which can affect reliability/observability across all runs.

This PR adjusts the workflows v2 engine to fail soft when dynamic limit reads error (use static defaults instead of dropping runs/events), and to surface previously-silent early drops by emitting Started/Finished events plus a new fallback metric.

Changes:

  • Convert several limiter read error paths (trigger queue age, execution timeout, log event cap sizing, execution response size, etc.) from “drop/return” to “fallback to static default + metric”.
  • Add platform_engine_limit_read_fallback_total metric (labeled by limit key) and wire it into the engine paths that now fail-soft.
  • Improve observability for early execution abandonment (e.g., metering reserve failure) by emitting Started/Finished even when returning before the “normal” emit points; add regression tests for these drop paths.

Areas needing scrupulous human review:

  • Engine.startExecution early-return behavior (new emitDroppedExecution helper + metering End() guarded-defer): verify event emission, store state transitions, and metering report lifecycle are correct for every return path (including sharding denials, reserve failures, trigger-index conversion failures, and timeout paths).
  • Limiter fallback defaults: confirm each fallback uses the intended settings key + default value for the specific limiter being read, and that the new fallback metric won’t introduce excessive label cardinality.

Reviewed changes

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

Show a summary per file
File Description
core/services/workflows/v2/engine.go Implements fail-soft limiter reads, adds early-drop Started/Finished emission, and ensures metering reports are ended on early returns.
core/services/workflows/v2/engine_drop_paths_test.go Adds regression tests for limiter read fallbacks and early-drop observability/metering cleanup paths.
core/services/workflows/v2/config.go Tracks effective limiter defaults used to construct EngineLimiters to support correct fallback values.
core/services/workflows/monitoring/trigger_drop_reason.go Documents legacy drop reasons retained for dashboard compatibility (now expected to fall to 0).
core/services/workflows/monitoring/monitoring.go Registers and emits the new limit-read-fallback metric counter.
core/platform/monitoring.go Adds limitKey observability label constant for the new metric.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread core/services/workflows/v2/engine_drop_paths_test.go
Comment thread core/services/workflows/monitoring/monitoring.go
@trunk-io

trunk-io Bot commented Aug 19, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

Failed Test Failure Summary Logs
TestTokenTransfer_Solana2EVM The test failed during the deployment or initialization of Solana programs or contracts, likely due to an issue with setting up the Solana environm... Logs ↗︎
TestTokenTransfer_Solana2EVM/Send_token_to_contract The test for sending tokens to a contract failed during execution. Logs ↗︎
TestTokenTransfer_EVM2Solana The test failed during the setup or execution of the Solana container and program deployment, likely due to an issue with initializing or interacti... Logs ↗︎
FuzzParse/seed#0 A goroutine attempted to log after the test had already completed, causing a panic due to improper logging after test finish. Logs ↗︎

View Full Report ↗︎Docs

@tarcisiozf
tarcisiozf force-pushed the DEVSVCS-5859/fix-early-returns branch 2 times, most recently from e41d103 to 4b4895b Compare August 19, 2026 17:10
Comment thread core/services/workflows/v2/engine.go
@tarcisiozf
tarcisiozf force-pushed the DEVSVCS-5859/fix-early-returns branch from 4b4895b to 368c962 Compare August 20, 2026 17:34
@tarcisiozf
tarcisiozf requested a lite review from Copilot August 20, 2026 17:34
@tarcisiozf tarcisiozf changed the title fail-soft / early-returns CRE Gate and Limit Handling Improvements Aug 20, 2026
@tarcisiozf
tarcisiozf marked this pull request as ready for review August 20, 2026 17:36
@tarcisiozf
tarcisiozf requested review from a team as code owners August 20, 2026 17:36

Copilot AI 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.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

}
// A settings read failure is not an expiry: run the execution rather than
// dropping a customer's trigger event over a transient config read.
e.logger().Errorw("Failed to check trigger event queue age limit; proceeding with execution", "err", ageErr)

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.

Should this block still end in a continue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, the idea of these changes is exactly the opposite: do not drop a user event unless it's a true abort case, failing to read the settings in this case can be transient and we are tolerating it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What I'm going to now is to add a counter here so we can track how many hits we get.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

applied here: 1c6988e

@cl-sonarqube-production

Copy link
Copy Markdown

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.

3 participants