Skip to content

GemSkillLinker: links minted under a sandboxed session point into ephemeral sandbox cache paths #89

Description

@JPDuchesne

Found during the plans#17 read-path live check.

Symptom

ai-flow/.agents/skills/gem-rspock--rspock pointed at
/private/var/folders/.../T/cursor-sandbox-cache/<hash>/bundle/ruby/3.3.0/gems/rspock-3.0.0/skills/rspock
— a Cursor sandbox cache path. The link survives on disk after the session; the target is purgeable temp state, so the skill silently dangles later. (dev's checkout had no .agents/skills at all — the linker had only ever run there from environments that didn't produce links.)

Mechanism

GemSkillLinker#bundled_gem_paths runs shadowenv exec -- bundle list --paths and links whatever paths bundler reports. Under a sandboxed agent session, bundler's env (BUNDLE_PATH / GEM_HOME pointed into the sandbox cache) resolves gems to ephemeral locations, and the linker writes machine-persistent symlinks to them. Same failure family as the runner-shell env leak fixed at ai-flow's agent spawn (ai-flow#38/#39/#40): a harness's toolchain env leaking into a child process that should see the project's own environment.

Fix directions

  • Scrub the harness env for the bundle list --paths call (Bundler.original_env + unset of sandbox/bundler overrides), so paths resolve from the project's canonical bundler config — the same posture as ai-flow's worktree_env.
  • Belt-and-suspenders: refuse to link any resolved path under Dir.tmpdir (warn and skip) — a persistent link to ephemeral state is never right, whatever produced it.

Repair done meanwhile

Re-ran dev install-deps in ai-flow and dev from a normal shell: both now link to durable ~/.gem/ruby/<version>/gems/rspock-3.0.0/skills/rspock targets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions