ENG-8507: rebind MutableProxy when it is linked to an old _self_state reference#6048
Merged
adhami3310 merged 2 commits intomainfrom Dec 18, 2025
Merged
ENG-8507: rebind MutableProxy when it is linked to an old _self_state reference#6048adhami3310 merged 2 commits intomainfrom
adhami3310 merged 2 commits intomainfrom
Conversation
… reference Avoids an issue where MutableProxy references are saved in the state, then when accessing them again, they reference the wrong StateProxy. So even though the code enters `async with self`, the StateProxy that is marked mutable is NOT the StateProxy associated with the value. With this change, anytime a MutableProxy is accessed through a StateProxy, its state reference is reset to the current StateProxy before returning it.
CodSpeed Performance ReportMerging #6048 will not alter performanceComparing Summary
|
Contributor
Greptile OverviewGreptile SummaryFixed a bug where Key changes:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant StateProxy1
participant MutableProxy
participant StateProxy2
User->>StateProxy1: async with state_proxy
StateProxy1->>StateProxy1: Enter mutable context
User->>StateProxy1: state_proxy.data["a"] = state_proxy.data["b"]
StateProxy1->>MutableProxy: Access data["a"]
Note over MutableProxy: MutableProxy now references<br/>state_proxy.data["b"]
StateProxy1->>StateProxy1: Exit mutable context
User->>StateProxy2: Create new StateProxy(state)
Note over StateProxy2: New proxy for same state
User->>StateProxy2: Access data["a"]
StateProxy2->>MutableProxy: __getitem__("a")
MutableProxy->>MutableProxy: _wrap_recursive(value)
Note over MutableProxy: Check: value._self_state != self._self_state
MutableProxy->>MutableProxy: Rebind: value._self_state = self._self_state
MutableProxy-->>StateProxy2: Return rebound proxy
User->>StateProxy1: async with state_proxy
StateProxy1->>StateProxy1: Enter mutable context
User->>StateProxy1: state_proxy.data["a"].append(3)
StateProxy1->>MutableProxy: append(3)
MutableProxy->>StateProxy1: Mark dirty on correct StateProxy
Note over MutableProxy: Mutation tracked correctly<br/>because _self_state is up to date
|
adhami3310
approved these changes
Dec 18, 2025
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.
Avoids an issue where MutableProxy references are saved in the state, then when accessing them again, they reference the wrong StateProxy. So even though the code enters
async with self, the StateProxy that is marked mutable is NOT the StateProxy associated with the value.With this change, anytime a MutableProxy is accessed through a StateProxy, its state reference is reset to the current StateProxy before returning it.