Skip to content

Resolve a Version-Manager Shim Before Registering It as the Hook Launcher #4355

Open

Description

@ptr727

Defect

The host-safety installer can register a POSIX version-manager shim as every hook's launcher. Examples are pyenv's ~/.pyenv/shims/python3, or an asdf or mise shim. A shim picks its interpreter when the hook runs, from the session's working directory (.python-version, PYENV_VERSION). So the interpreter at hook time can differ from the one the installer probed.

Failure

Here is a constructed case:

  1. A host has pyenv with 3.12 as its global version, and ~/.pyenv/shims comes first on PATH.
  2. The installer resolves python3 to the shim, probes it as 3.12, and registers it.
  3. A session then starts in a project whose .python-version pins 3.10.14.
  4. Every kit hook now runs under 3.10, or fails to start where that version is not installed.

The guards need 3.11+, so each one exits non-zero. A non-zero PreToolUse exit is a non-blocking error, so the write guard fails open. --report probes the launcher from its own working directory, so it stays green.

Origin

This predates the exec-form registration in #4040. A bare python3 resolved to the same shim at hook time. The exec-form change in PR #4350 pins the path the installer resolves, but a shim still resolves per directory.

Done when

The installer resolves a shim to a concrete interpreter before registering it, or refuses a shim. A test pins whichever behavior is chosen.

Activity

  1. added
    pre-existing
    on Nov 23, 2026
  2. ptr727 commented on Nov 23, 2026

    @ptr727
    OwnerAuthor

    Maintainer's answer, 2026-11-23 (recorded during backlog burndown round 5): approved. Have the installer detect a version-manager shim, refuse, and print the concrete interpreter path to pass instead, rather than resolving the shim or leaving it as is. This approves the design of an edit under host-setup/agent-safety/. Its pull request still merges only on the maintainer's own go-ahead, given after he reads the diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pre-existing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions