Skip to content

feat(events): warn at install when the hook interpreter is missing - #5714

Open
AdityaxDeore wants to merge 3 commits into
github:mainfrom
AdityaxDeore:feat/5619-hook-interpreter-check
Open

AdityaxDeore wants to merge 3 commits into
github:mainfrom
AdityaxDeore:feat/5619-hook-interpreter-check

Conversation

@AdityaxDeore

Copy link
Copy Markdown

What problem this solves

Related: #5619

Generated event hooks start the dispatcher with a fixed interpreter, and nothing checks that interpreter up front. If it is not on the agent's PATH, every hook fails, most agents fail open, and no message says why. This adds the check at install time, so the failure is named before it matters.

Root cause

_resolve_interpreter / _resolve_interpreter_for_target pick an interpreter string and _dispatcher_command writes it into the native hook config. No code ever asks whether that string resolves on the machine that will run the hook.

Implementation

  • hook_interpreter_available(interpreter, project_root) in src/specify_cli/events/__init__.py: resolves the interpreter the same way the hook command does. Bare names use PATH lookup (with the Windows Store stub probe, matching resolve_python_interpreter); project-relative paths resolve against the project root; absolute paths must exist.
  • install_integration_events prints a warning to stderr when the host interpreter cannot be resolved, naming the interpreter and the remedy (put a Python interpreter on PATH, or create a project .venv and rerun specify integration upgrade <key>). Install still succeeds: the hooks may run on another machine. Generated hook command text is unchanged.

Tests

Fail-before/pass-after: the new tests failed on main (missing helper, no warning) and pass with this change.

  • tests/specify_cli/events/test_events.py: 217 passed (209 existing + 8 new: PATH, venv-relative, and absolute resolution, plus install warn / no-warn cases).
  • tests/specify_cli/events/, tests/integrations/test_base.py, tests/test_agent_config_consistency.py: 460 passed.
  • uvx ruff@0.15.0 check on the changed files: clean. ruff format reports pre-existing drift in both files on unmodified main; untouched lines left as-is.
  • Manual smoke: specify init with the Claude integration succeeds with no spurious warning.

Limits

This implements the install-time check half of #5619 only, and the issue stays open:

  • No Windows py -3 fallback is emitted. Generated PowerShell changes need Windows PowerShell 5.1 evidence, which was not available on the Linux machine used here.
  • No workflow-dispatch pre-flight. The workflow step schema has no hook-dependency declaration, and the engine treats requires as advisory, not a gate; adding a hard gate needs maintainer agreement.

Disclosure

Implemented with Muse Spark (model: Muse Spark 1.3) in autonomous mode; code generation and tests. No line-by-line human review before commit.

Disclosure: AI coding assistance was used in preparing this change.

Generated event hooks start the dispatcher with a fixed interpreter and nothing checks it up front, so a missing interpreter fails silently inside the agent's hook runner. Add a shared availability check that resolves the hook interpreter the same way the hook command does (PATH lookup for bare names, project-relative resolution for venv paths, existence for absolute paths) and warn at install time, naming the interpreter and the remedy. Install still succeeds: the hooks may run on another machine.

The Windows py -3 fallback and the workflow pre-flight from the issue are deliberately left out: generated PowerShell changes need Windows PowerShell 5.1 evidence unavailable here, and the workflow engine treats requires as advisory rather than a gate.

Assisted-by: Muse Spark (model: Muse Spark 1.3, autonomous)
@AdityaxDeore
AdityaxDeore requested a review from mnriem as a code owner December 5, 2026 06:41
Copilot AI adaptive review requested due to automatic review settings December 5, 2026 06:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Hook interpreter checks can suppress necessary warnings, and new tests fail on Windows or when Python is absent from PATH.

4 open issues
What changed in this PR

Adds advisory install-time checks for missing event-hook interpreters in Specify CLI, addressing the installation-check portion of #5619 without changing generated hook commands.

Changes:

  • Checks PATH, project-relative, and absolute interpreter paths.
  • Warns on stderr with remediation while allowing installation to succeed.
  • Adds interpreter-resolution and warning tests.
File Description
tests/​specify_cli/​events/​test_events.py Adds resolution and install-warning coverage.
src/​specify_cli/​events/​__init__.py Adds interpreter availability checks and advisory installation warnings.

Review effort: Balanced (adaptive)

Comment thread tests/specify_cli/events/test_events.py Resolved
Comment thread tests/specify_cli/events/test_events.py Resolved
Comment on lines +1243 to +1244
interpreter = _resolve_interpreter(project_root)
if hook_interpreter_available(interpreter, project_root):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI-assisted reply on behalf of Aditya Chandrajit Deore — prepared by Muse (model: Muse Spark 1.3, autonomous).] Deferring this one. Measured on this branch: with a .venv interpreter present and no python3/python on PATH, the host check passes (.venv/bin/python resolves) while the Copilot bash hook embeds bare python3, so that hook would fail silently. The PowerShell variant embeds python, and OpenCode resolves its interpreter at plugin load with an import-specify_cli probe, so no single host check covers all three without also warning on variants that never run on this machine. Leaving the per-format scope for a maintainer decision; the host check here is unchanged for the formats it covers.

Comment thread src/specify_cli/events/__init__.py Resolved
An empty .venv directory suppressed the hook-interpreter fallback
warning even though resolve_python_interpreter ignores the directory
and still falls back to the running interpreter, so the warning
depended on a directory that changed nothing about the selected
interpreter. Drop the directory-existence condition.

Also make two install-warning tests deterministic: pin the PATH-only
resolution test to a POSIX platform (the Windows stub probe rejects
the fake PATH entry) and mock a successful PATH lookup in the
no-warning test (a uvx-only install otherwise warns). The per-format
interpreter-selection finding is left out as a scope call; see the
review-round summary on the PR.

Tests: new empty-.venv test failed before (no warning) and passes
after; tests/specify_cli/events/test_events.py 218 passed;
events + integrations base 430 passed; ruff check clean on the
changed files (pre-existing format drift left untouched).

Assisted-by: Muse Spark (model: Muse Spark 1.3, autonomous)
Copilot AI adaptive review requested due to automatic review settings December 5, 2026 08:46
@AdityaxDeore

Copy link
Copy Markdown
Author

Posted on behalf of Aditya Chandrajit Deore. This round was prepared by Muse (model: Muse Spark 1.3, autonomous) from the Copilot review below; the changes were tested as described, with no human review of this round yet.

Commit d29145a addresses three of the four findings: the PATH-only resolution test is pinned to a POSIX platform so the Windows stub probe no longer rejects the fake PATH entry; the no-warning test now mocks a successful PATH lookup instead of depending on the runner having a system Python; and an empty .venv directory no longer suppresses the fallback warning, since it does not change the selected interpreter.

Tests on d29145a: 218 passed in tests/specify_cli/events/test_events.py (one new test, failed before the fix and passes after), 430 passed across the events tests and the integrations base tests, ruff check clean on the changed files. CI on the new head is approval-gated, not claimed green. The full specify_cli suite did not finish in this run and is not claimed.

The per-format interpreter finding is deferred, with the measured gap in my reply on that thread, pending a maintainer decision on what the check should cover. No review re-requested.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Windows Store alias stubs suppress the ephemeral-interpreter warning despite unusable PATH interpreters; the availability check needs correction and regression coverage.

2 open issues
3 resolved since last review

Review effort: Balanced (adaptive)

Comment thread src/specify_cli/events/__init__.py Resolved
@mnriem mnriem added the triage-nice-to-have Verdict: evidence-backed fix or greenlit feature — land after review label Dec 5, 2026
shutil.which finds a Store alias stub, so the fallback warning stayed silent even though neither PATH interpreter runs and the resolver had already fallen back to an absolute interpreter. Check the bare names with hook_interpreter_available, which runs the stub probe on Windows.

Tests: new stub-only-PATH test failed before (no warning) and passes after; tests/specify_cli/events/ + integrations/test_base.py 431 passed; ruff check clean on the changed files (pre-existing format drift left untouched).

Assisted-by: Muse Spark (model: Muse Spark 1.3, autonomous)
Copilot AI adaptive review requested due to automatic review settings December 5, 2026 12:27
@AdityaxDeore

Copy link
Copy Markdown
Author

Posted on behalf of Aditya Chandrajit Deore. This round was prepared by Muse (model: Muse Spark 1.3, autonomous) from the Copilot review below; the changes were tested as described, with no human review of this round yet.

Commit dcb65a8 addresses the new Windows Store stub finding: the fallback warning now checks python3/python with hook_interpreter_available, which runs the stub probe on Windows, instead of shutil.which, which returns the stub. A regression test with a stub-only PATH failed before (no warning) and passes after.

Tests on dcb65a8: 219 passed in tests/specify_cli/events/test_events.py (one new test), 431 passed across the events tests and the integrations base tests, ruff check clean on the changed files. CI on the new head is approval-gated, not claimed green.

The per-format interpreter finding remains deferred, with the measured gap in the reply on that thread, pending a maintainer decision. No review re-requested.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed to evaluate the impact of an interpreter-resolution warning that can misrepresent an available machine-specific fallback as missing.

1 open issue
1 resolved since last review

Review effort: Balanced (adaptive)

This branch has not been deployed

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

Labels

triage-nice-to-have Verdict: evidence-backed fix or greenlit feature — land after review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants