perf([cos-on-demand-mark-app-review-started-dedupe]): dedupe per-app markAppReviewStarted in CoS on-demand loop#611
Merged
atomantic merged 3 commits intoJun 1, 2026
Conversation
…eview-started once per CoS evaluation cycle Multiple on-demand improvement requests targeting the same app each called markAppReviewStarted, rewriting the app's activity record once per request. Guard the call with a per-cycle Set so each app is marked at most once.
…N.md and log to changelog
…tTask on-demand loop too The event-driven 'Run Now' path runs a second, near-identical on-demand loop in dequeueNextTask that also marked the app review-started once per request. Apply the same per-cycle Set guard there, extend the source invariant to cover both loops, and generalize the changelog wording.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When several on-demand improvement requests for the same managed app are processed in a single CoS evaluation cycle,
evaluateTaskspreviously calledmarkAppReviewStarted(appId, …)once per request — each call rewriting the same app activity record (activeAgentId+lastReviewedAt).This guards the mark with a per-cycle
Setso each app's activity record is marked review-started at most once per evaluation cycle.recordExecutionand task generation still run per request — only the redundant activity-record write is deduped.The activity record's
activeAgentIdis a single field that was already last-wins under multiple requests, so first-wins dedup introduces no lifecycle change beyond removing the wasted writes.Test plan
server/services/cos.test.jsgains a source-level invariant pinning both thereviewStartedAppsset declaration and the!reviewStartedApps.has(targetApp.id)guard, matching the file's established source-assertion style.cd server && npm test -- cos.test.js— 116 tests pass.