[CLD-1983]: feat(operations): add WithForceExecute option and latest cache reuse#925
[CLD-1983]: feat(operations): add WithForceExecute option and latest cache reuse#925graham-chainlink wants to merge 1 commit intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 03fc12e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
fd83eaa to
6fbfc43
Compare
| } | ||
|
|
||
| for _, report := range prevReports { | ||
| for i := len(prevReports) - 1; i >= 0; i-- { |
There was a problem hiding this comment.
now that there can be multiple reports of the same ID, we want to return the most recent ones instead of the oldest one
There was a problem hiding this comment.
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
WithAlwaysExecuteoption to forceExecuteOperationto 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.
6fbfc43 to
21976b1
Compare
There was a problem hiding this comment.
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.
21976b1 to
cd67514
Compare
There was a problem hiding this comment.
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.
cd67514 to
f4392ee
Compare
There was a problem hiding this comment.
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.
f4392ee to
b7045a8
Compare
There was a problem hiding this comment.
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.
b7045a8 to
c778609
Compare
There was a problem hiding this comment.
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.
c778609 to
88992dc
Compare
| - Before: `ExecuteOperationN(..., opts ...ExecuteOption[IN, DEP])` | ||
| - After: `ExecuteOperationN(..., opts ...ExecuteOperationNOption[IN, DEP])` |
There was a problem hiding this comment.
This is a breaking change, but i checked company wide usage for ExecuteOperationN and didn see any.
| type ExecuteOption[IN, DEP any] func(*ExecuteConfig[IN, DEP]) | ||
|
|
||
| // ExecuteOperationNConfig holds options for ExecuteOperationN. | ||
| type ExecuteOperationNConfig[IN, DEP any] struct { |
There was a problem hiding this comment.
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
88992dc to
7cb74d5
Compare
7cb74d5 to
9dcde2c
Compare
There was a problem hiding this comment.
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.
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.
9dcde2c to
03fc12e
Compare
|




What changed
WithForceExecuteexecute option to force operation execution and bypass previous successful report short-circuiting.Why
Context: https://chainlink-core.slack.com/archives/C043E82DUM8/p1775799230707799
JIRA: https://smartcontract-it.atlassian.net/browse/CLD-1983