Skip to content

[CLD-1983]: feat(operations): add WithForceExecute option and latest cache reuse#925

Open
graham-chainlink wants to merge 1 commit intomainfrom
ggoh/NOJIRA/operations-always-execute-cache
Open

[CLD-1983]: feat(operations): add WithForceExecute option and latest cache reuse#925
graham-chainlink wants to merge 1 commit intomainfrom
ggoh/NOJIRA/operations-always-execute-cache

Conversation

@graham-chainlink
Copy link
Copy Markdown
Collaborator

@graham-chainlink graham-chainlink commented Apr 13, 2026

What changed

  • Added WithForceExecute execute option to force operation execution and bypass previous successful report short-circuiting.
  • Updated cached report lookup to prefer the most recent matching successful report.

Why

  • We have use case from our users where in the same changeset , they want to execute the same operations but it can return different data due to it being update in between calls. With the operations report caching, they will never be able to fetch the latest data, introducing an option to bypass the cache will support this use case.

Context: https://chainlink-core.slack.com/archives/C043E82DUM8/p1775799230707799

JIRA: https://smartcontract-it.atlassian.net/browse/CLD-1983

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 13, 2026

🦋 Changeset detected

Latest commit: 03fc12e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
chainlink-deployments-framework Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@graham-chainlink graham-chainlink force-pushed the ggoh/NOJIRA/operations-always-execute-cache branch 2 times, most recently from fd83eaa to 6fbfc43 Compare April 13, 2026 14:12
Comment thread operations/execute.go
}

for _, report := range prevReports {
for i := len(prevReports) - 1; i >= 0; i-- {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

now that there can be multiple reports of the same ID, we want to return the most recent ones instead of the oldest one

@graham-chainlink graham-chainlink changed the title feat(operations): add always-execute option and latest cache reuse [CLD-1983]: feat(operations): add always-execute option and latest cache reuse Apr 16, 2026
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

Adds an execution option to bypass cached successful reports and adjusts cached report selection to prefer the newest successful match, updating tests and docs accordingly.

Changes:

  • Add WithAlwaysExecute option to force ExecuteOperation to run and skip successful-report reuse.
  • Update cached successful report lookup to prefer the most recent matching successful report.
  • Add/adjust tests and docs to reflect the new behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
operations/execute.go Adds WithAlwaysExecute/config flag and changes cached report lookup to scan from newest to oldest.
operations/execute_test.go Extends previous-run test for forced re-execution and adds a regression test for “most recent successful report” reuse.
operations/doc.go Updates package docs to mention default reuse and show WithAlwaysExecute usage.
.changeset/gentle-moles-rule.md Adds release note entry for the new option.

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

Comment thread operations/execute.go Outdated
Comment thread operations/execute.go
Comment thread operations/doc.go Outdated
Comment thread operations/execute_test.go Outdated
Comment thread .changeset/gentle-moles-rule.md Outdated
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

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


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

Comment thread operations/execute.go Outdated
Comment thread operations/execute_test.go Outdated
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


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

Comment thread operations/execute.go Outdated
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


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

Comment thread operations/execute.go Outdated
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

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


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

Comment thread operations/execute_test.go Outdated
Comment thread operations/execute_test.go Outdated
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

operations/execute.go:196

  • ExecuteOperationN now applies ExecuteOption functions before checking for reusable execution-series reports. Previously, if enough cached reports existed, options were not invoked. If any custom ExecuteOption has side effects, this is an observable behavior change on cache hits; consider documenting this or restructuring so only the needed option(s) are evaluated before the cache short-circuit.
	executeConfig := &ExecuteConfig[IN, DEP]{
		retryConfig: newDisabledRetryConfig[IN, DEP](),
	}
	for _, opt := range opts {
		opt(executeConfig)
	}

	if executeConfig.alwaysExecute {
		return []Report[IN, OUT]{}, ErrAlwaysExecuteNotSupportedForExecuteOperationN
	}

	results, ok := loadSuccessfulExecutionSeriesReports[IN, OUT](b, operation.def, input, seriesID)
	resultsLen := uint(len(results))
	if ok {
		// if there are more reports than n, we return only the first n reports
		if resultsLen >= n {
			b.Logger.Infow("Operations already executed in an execution series. Returning previous results", "id", operation.def.ID,
				"version", operation.def.Version, "description", operation.def.Description, "executionSeriesID", seriesID)

			return results[:n], nil
		}
	}

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

Comment thread operations/execute.go
@graham-chainlink graham-chainlink marked this pull request as ready for review April 16, 2026 08:07
@graham-chainlink graham-chainlink requested a review from a team as a code owner April 16, 2026 08:07
@graham-chainlink graham-chainlink force-pushed the ggoh/NOJIRA/operations-always-execute-cache branch from c778609 to 88992dc Compare April 17, 2026 03:54
Comment on lines +11 to +12
- Before: `ExecuteOperationN(..., opts ...ExecuteOption[IN, DEP])`
- After: `ExecuteOperationN(..., opts ...ExecuteOperationNOption[IN, DEP])`
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is a breaking change, but i checked company wide usage for ExecuteOperationN and didn see any.

Comment thread operations/execute.go
type ExecuteOption[IN, DEP any] func(*ExecuteConfig[IN, DEP])

// ExecuteOperationNConfig holds options for ExecuteOperationN.
type ExecuteOperationNConfig[IN, DEP any] struct {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I have to introduce new functional option type for ExecuteOperationN as i dont want ExecuteOperationN to support always run option as it has its own quirks. Previously it was sharing the same option type as ExecuteOperation

Copilot AI review requested due to automatic review settings April 17, 2026 03:57
@graham-chainlink graham-chainlink force-pushed the ggoh/NOJIRA/operations-always-execute-cache branch from 88992dc to 7cb74d5 Compare April 17, 2026 03:57
@graham-chainlink graham-chainlink force-pushed the ggoh/NOJIRA/operations-always-execute-cache branch from 7cb74d5 to 9dcde2c Compare April 17, 2026 03:59
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

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


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

@graham-chainlink graham-chainlink changed the title [CLD-1983]: feat(operations): add always-execute option and latest cache reuse [CLD-1983]: feat(operations): add WithAlwaysExecute option and latest cache reuse Apr 17, 2026
@graham-chainlink graham-chainlink changed the title [CLD-1983]: feat(operations): add WithAlwaysExecute option and latest cache reuse [CLD-1983]: feat(operations): add WithForceExecute option and latest cache reuse Apr 20, 2026
Introduce WithForceExecute for operations to bypass previous successful report reuse when explicitly requested. Also ensure cached report lookup prefers the most recent successful match and add regression coverage plus docs updates.
@graham-chainlink graham-chainlink force-pushed the ggoh/NOJIRA/operations-always-execute-cache branch from 9dcde2c to 03fc12e Compare April 20, 2026 07:00
@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