fix(py-isolation-sso): correct misleading 'deep copy' comment in create_snapshot#2171
Merged
imran-siddique merged 1 commit intoMay 12, 2026
Conversation
…te_snapshot
`SessionVFS.create_snapshot` was documented as "simple deep copy", but
the body is a one-level copy:
- `dict(self._files)` — top-level copy; relies on `str` values being
immutable to be effectively-independent
- `{k: set(v) for k, v in self._permissions.items()}` — top-level
copy with explicit set-rebuild per path
Neither is a `copy.deepcopy`. The implementation is *sufficient* today
because the value types are either immutable (`str`) or explicitly
rebuilt (the inner `set`), but the docstring sets the wrong mental
model for readers and would mislead anyone extending the value shape.
Replace the docstring with one that names what the operation actually
does and flags the future-fragility: if either value shape grows a
mutable nested type, the snapshot stops being effectively-independent
and would need `copy.deepcopy`.
Pure comment change — no behaviour delta.
🤖 AI Agent: breaking-change-detector — View detailsNo breaking changes detected. |
🤖 AI Agent: docs-sync-checker — Docs SyncDocs Sync
|
🤖 AI Agent: test-generator — `sso.py`
|
🤖 AI Agent: code-reviewer — View detailsTL;DR: 0 blockers, 0 warnings. No issues found. Clean change. |
🤖 AI Agent: security-scanner — View detailsNo security issues found. |
|
🟡 Contributor Check: MEDIUM
Automated check by AGT Contributor Check. |
PR Review Summary
Verdict: ✅ Ready for human review |
MohammadHaroonAbuomar
pushed a commit
to MohammadHaroonAbuomar/agt-acs
that referenced
this pull request
Jun 1, 2026
…te_snapshot (microsoft#2171) `SessionVFS.create_snapshot` was documented as "simple deep copy", but the body is a one-level copy: - `dict(self._files)` — top-level copy; relies on `str` values being immutable to be effectively-independent - `{k: set(v) for k, v in self._permissions.items()}` — top-level copy with explicit set-rebuild per path Neither is a `copy.deepcopy`. The implementation is *sufficient* today because the value types are either immutable (`str`) or explicitly rebuilt (the inner `set`), but the docstring sets the wrong mental model for readers and would mislead anyone extending the value shape. Replace the docstring with one that names what the operation actually does and flags the future-fragility: if either value shape grows a mutable nested type, the snapshot stops being effectively-independent and would need `copy.deepcopy`. Pure comment change — no behaviour delta.
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
session/sso.py'sSessionVFS.create_snapshotwas documented as "simple deep copy", but the body is a one-level copy:Neither line is a
copy.deepcopy. The implementation is sufficient today because the value types are either immutable (strfile contents) or explicitly rebuilt (the innersetper path), but the docstring sets the wrong mental model and would mislead anyone extending the value shape.Change
Replace the docstring with one that names what the operation actually does, and flags the future-fragility: if either value shape grows a mutable nested type (e.g.
dict[str, list[...]]for files, or sets-of-mutable values for permissions), the snapshot would stop being effectively-independent and a realcopy.deepcopywould be required.Tests
Pure comment change — no behaviour delta, no new tests. Existing
SessionVFSsnapshot/restore tests continue to pass.Test plan
SessionVFS.create_snapshot/restore_snapshotSurfaced during independent audit conducted by @finnoybu (Ken Tannenbaum, AEGIS Initiative); [LOW, Python Isolation].