Repository navigation
Run every wrap into a macOS session inside that session - #83
Merged
Merged
Conversation
A second `agentmon wrap --session` into a session ran its agent outside the session, with no policy (SECENG-312). The daemon sent the extension only the first root PID. wrap-init waited for any snapshot of the session, so it returned at once when the extension already held one. The tracker now keeps every root of a session, and the snapshot sends them as root_pids. wrap-init waits for a snapshot that names its own PID. For a session that is already registered, it also posts the policy-update notification, so that the extension fetches the session again. If that wait times out, the session stays, because another agent runs in it. The extension maps each root in root_pids to the session, and drops its "outside" answers when a new root arrives. scripts/test-macos-wrap-session-reuse.sh failed 2 of 4 on build 1676 and passes 4 of 4 on build 1677. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The problem
A second
agentmon wrap --session <id>into a session ran its agent outside that session. No policy applied, but the agent still showed as wrapped (SECENG-312).The daemon sent the extension only the session's first root PID. wrap-init waited for any snapshot of the session, so it returned at once when the extension already held one. That snapshot did not name the new wrap process.
The fix
SessionTrackerkeeps every PID registered with no parent as a root of the session, insessionRoots.root_pids.NoteSnapshotDeliveredrecords which roots each delivered snapshot named.AwaitRootDeliveredfor a snapshot that names its own PID.SessionPolicyCachemaps each root inroot_pidsto the session, on the first fetch and on each refetch. It drops its "outside" answers after a new root is mapped.Verification
scripts/test-macos-wrap-session-reuse.shstarts three wraps into one session. The first wrap is still running when the second starts. On build 1676, the second and third wraps ran outside the session (2 of 4 failed). On build 1677, 4 of 4 pass.scripts/test-macos-socket-signal-rules.shprints 13 ok, andscripts/test-macos-network-proxy.shpasses 6 of 6.TestAwaitRootDelivered,TestBuildPolicySnapshot_RootPIDs,TestPlatformWrapInit_ReusedSessionWaitsForItsOwnRootandTestPlatformWrapInit_ReusedSessionTimeoutKeepsSession.go test -tags nofuse ./...passes, andgolangci-lintreports 0 issues.Fixes SECENG-312.
🤖 Generated with Claude Code