Skip to content

Eagerly bootstrap pi-ac-safety hook environments before registration #97

Description

@MatiasComercio

Bug Description

Hook dependency installation can run inside the short PreToolUse execution window, which makes setup flaky. The correct package fix is to eagerly bootstrap hook environments before registering the hooks.

Environment

  • OS: Darwin 24.5.0
  • Shell: zsh
  • Git: 2.39.5
  • agentic-config: 0.3.2

Steps to Reproduce

  1. Activate pi-ac-safety hooks that declare UV script dependencies (e.g. pyyaml).
  2. Trigger a tool call that runs PreToolUse.
  3. Observe dependency bootstrap competing with the ~5s PreToolUse timeout path.

Expected Behavior

Hook environments are bootstrapped during pi-ac-safety activation (before tool hooks are enabled), so PreToolUse only runs already-prepared hooks. Bootstrap failures surface actionable stderr details.

Actual Behavior

Dependency installation can occur on the PreToolUse path, risking timeouts/failures without clear setup diagnostics.

Proposed Fix

  1. During pi-ac-safety activation, run each hook once with a 60-second setup timeout:
    uv run --no-project --script <hook.py>
    using a harmless empty payload.
  2. Wait for bootstrap completion before enabling tool hooks.
  3. Pin the dependency:
    dependencies = ["pyyaml==6.0.3"]
  4. Update pi-compat/extensions/hook-compat/runtime.js to include error.details.stderr when bootstrap fails.

This keeps dependency installation out of the 5-second PreToolUse execution path and gives an actionable error if setup genuinely fails.


Reported via /skill:ac-tools-ac-issue command

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions