Revert "[9.4](backport #7794) refactor: clone ParsedPolicy in process… - #7805
Merged
Conversation
…processPolicy to prevent shared-state races (elastic#7802)" This reverts commit d8b6a04.
ebeahan
requested review from
macdewee and
swiatekm
and removed request for
a team
September 11, 2026 13:19
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical concurrency issues in exporter cloning and monitor lock scope remain unresolved.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Reverts the ParsedPolicy fan-out cloning refactor and restores shared policy dispatch.
Changes:
- Removes
ParsedPolicy.Clone()and its isolation test. - Moves policy-data and secret-key copying into
processPolicy. - Restores shared dispatch and broad monitor locking.
- Reverts deep cloning of nested policy and OTel maps.
File summaries
| File | Summary | Review findings |
|---|---|---|
internal/pkg/policy/parsed_policy.go |
Removes ParsedPolicy.Clone. |
None. |
internal/pkg/policy/parsed_policy_test.go |
Removes clone isolation coverage. | None. |
internal/pkg/policy/monitor.go |
Restores shared dispatch and broad mutex scope. | Critical (3 votes): The mutex remains held during rate limiting and channel sends, blocking subscriptions, unsubscriptions, and policy updates (lines 277 and 314). |
internal/pkg/model/ext.go |
Reverts nested OTel map cloning. | Critical (3 votes): Only outer maps are cloned; inner exporter configs remain shared and can race during mutation (lines 99 and 144). |
internal/pkg/api/handleCheckin.go |
Adds local policy-data and secret-key copies. | Nit (2 votes): The updated comment is ungrammatical and unclear (line 1166). |
internal/pkg/api/handleCheckin_test.go |
Tests concurrent processing with the shared policy. | None. |
Review details
Suppressed comments (2)
internal/pkg/model/ext.go:144
maps.Clone(v)only copies each output's top-level map, so nested maps remain shared with the cached policy.ProcessOutputSecretcan follow a path secret into an existing nested map and mutate it, allowing concurrent check-ins to race and leak one agent's substituted secret into another response. This needs a recursive clone for output values before processing.
r[k] = maps.Clone(v)
internal/pkg/policy/monitor.go:314
- Sending the cached
ParsedPolicywithout cloning reintroduces shared mutable state across fan-out subscribers.processPolicyruns concurrently for these deliveries, and the revertedClonePolicyDataonly shallow-copies nested maps, so secret/output/OTel preparation can mutate another agent's policy and race. Keep the clone at this dispatch boundary or otherwise guarantee a complete deep copy before delivery.
case s.ch <- &policy.pp:
- Files reviewed: 6/6 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
samuelvl
approved these changes
Sep 11, 2026
ebeahan
enabled auto-merge (squash)
September 11, 2026 13:52
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.
…Policy to prevent shared-state races (#7802)"
This reverts commit d8b6a04.