Skip to content

fix(launcher): repoint shared-bundle symlinks to absolute in per-member agent copies (uid isolation)#141

Open
vikasiwp wants to merge 1 commit into
vikasprogrammer:mainfrom
vikasiwp:feat/symlink-isolation
Open

fix(launcher): repoint shared-bundle symlinks to absolute in per-member agent copies (uid isolation)#141
vikasiwp wants to merge 1 commit into
vikasprogrammer:mainfrom
vikasiwp:feat/symlink-isolation

Conversation

@vikasiwp

Copy link
Copy Markdown
Contributor

Under AOS_UID_ISOLATION, Launcher.syncAgentDir copies an agent's dir into the member home (<stateRoot>/<member>/agents/<agent>/) with cp -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 ../../tools now resolves under the member home where nothing exists. Result: every ./iwp, bash tools/…, ./eng-repo fails 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 helper externalSymlinkAbsoluteTarget(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

  • New 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.
  • Real-fs sanity (a cp -a into a deeper path) confirms the copied link dangles pre-fix and resolves post-fix.
  • Regressions green: governance-conformance 57/57, test:enrich 14/14. tsc clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HiUDC14XfeTQJZHf2wswma

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant