fix(launcher): repoint shared-bundle symlinks to absolute in per-member agent copies (uid isolation)#141
Open
vikasiwp wants to merge 1 commit into
Open
Conversation
…er agent copies syncAgentDir copies an agent dir into the member home with `cp -a` (symlinks kept as relative links). An agent whose tools are relative symlinks to a shared bundle (`iwp -> ../../tools/iwp`, `tools -> ../../tools/tools`, `eng-repo`, …) then broke at the new location — `<stateRoot>/<member>/agents/<agent>/../../tools` resolves under the member home where nothing exists — so every `./iwp` / `bash tools/…` / `./eng-repo` would dangle the moment AOS_UID_ISOLATION is enabled. After the full copy, resolveExternalSymlinks() repoints each symlink that escapes the agent dir to an ABSOLUTE target resolved against the original source (in-tree links left relative). Pure helper externalSymlinkAbsoluteTarget() decides per link. Real-fs sanity confirms: the copied relative link dangles pre-fix and resolves post-fix. Test: npm run test:symlink-isolation (7/7). Regressions green (governance 57/57, enrich 14/14). tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HiUDC14XfeTQJZHf2wswma
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.
Under
AOS_UID_ISOLATION,Launcher.syncAgentDircopies an agent's dir into the member home (<stateRoot>/<member>/agents/<agent>/) withcp -a, which preserves symlinks as relative links. Agents whose tools are relative symlinks into a shared bundle — e.g.iwp -> ../../tools/iwp,tools -> ../../tools/tools,eng-repo -> ../../tools/eng-repo— then dangle at the new location, because../../toolsnow resolves under the member home where nothing exists. Result: every./iwp,bash tools/…,./eng-repofails the moment uid isolation is turned on. (Isolation is off by default, so this is latent today — but it bricks any bundle-backed agent when enabled.)Fix
After the first-time full copy,
resolveExternalSymlinks(src, work)walks the working copy and repoints every symlink whose target escapes the agent dir to an absolute path resolved against the original source — so the shared bundle stays shared (no per-member duplication) and the links survive the move. In-tree relative links (targets inside the agent dir) are left as-is. A pure, exported helperexternalSymlinkAbsoluteTarget(agentSrcDir, symlinkRelPath, linkTarget)makes the per-link decision (absolute link → skip; in-tree → skip; escaping → the absolute target).Note: this fixes path resolution only — the member uid must still have read access to the shared bundle for the tools to execute (a separate concern of the isolation setup).
Tests
scripts/test-symlink-isolation.cjs(npm run test:symlink-isolation) — 7/7 covering the bundle links, absolute links, in-tree links, and the agent-dir-itself edge.cp -ainto a deeper path) confirms the copied link dangles pre-fix and resolves post-fix.governance-conformance57/57,test:enrich14/14.tscclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01HiUDC14XfeTQJZHf2wswma