Skip to content

fix(install): deploy an approved package that declares both hooks and LSP servers - #4680

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
ql-w1-4658-hooks-lsp-approve
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
ql-w1-4658-hooks-lsp-approve

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Description

apm install now deploys an approved package that declares both hooks and LSP servers. Before this fix it failed before writing anything:

[x] Failed to install APM dependencies: Failed to resolve APM dependencies: 'types.SimpleNamespace' object has no attribute 'install_path'

Root cause: _graph_declares_trusted_lsp in src/apm_cli/install/lsp/integration.py asked check_executable_approval about each LSP-declaring package, passing a stand-in that carried only dependency_ref. Once a hook pin exists (after apm approve), pinned-hook admission (hooks_package_admissible in security/trust.py) reads the package's hook files from package_info.install_path. That attribute was missing, so the install crashed.

The fix adds the package's install path (already computed for the manifest read) to the stand-in. The approval owner is unchanged and makes the same decisions.

Regression trap: tests/lifecycle/security/test_gate_removal.py::test_approved_package_with_hook_and_lsp_installs_both, on the real CLI driver in the hermetic lifecycle world.

  1. Author one local package with a hook and an lsp_dependencies entry.
  2. apm install <path>: the unapproved hook and LSP server park.
  3. apm approve <path>, then apm install. It must exit 0 with no traceback or AttributeError, deploy .github/hooks/<pkg>-session.json and the LSP server in .github/lsp.json, and record the hook in the package's lock row.
  4. A repeat apm install must leave the hook, lsp.json and the lockfile byte-identical.

Bug-ledger row: tests/fixtures/lifecycle_bug_ledger/bugs/4658.json.

Issue and approved scope

Issue: Fixes #4658

Human scope-approval comment: the apm-scope:v1 approve record on #4658 (review contact Daniel Meppiel (@danielmeppiel)).

Does this PR complete the issue, or what remains? It completes it.

  • A lifecycle test installs and approves one local package with a hook and an LSP server, then asserts exit 0 with both deployed. It fails before the fix and passes after.
  • A changelog fragment changelog.d/4680.fixed.md is added.
  • Approval semantics and other executable kinds are untouched.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

All local runs go through the host guard, on a worktree with its own venv:

  • Failing before (main 11f8f58, APM_E2E_TESTS=1): pytest tests/lifecycle/security/test_gate_removal.py::test_approved_package_with_hook_and_lsp_installs_both gives 1 failed: apm install exit 1, "'types.SimpleNamespace' object has no attribute 'install_path'".
  • Passing after: the same node gives 1 passed.
  • Neighbours: pytest tests/unit/install/test_lsp_integration.py tests/unit/install/test_frozen_service_boundary.py tests/unit/install/phases/test_integrate_held_headers.py tests/unit/commands/test_uninstall_atomic_selection.py tests/unit/commands/test_update_command.py: 142 passed.
  • pytest tests/quality/test_lifecycle_bug_ledger.py: 2 passed.
  • Lint contract: uvx ruff@0.15.12 check and format --check, pylint R0801, lint-auth-signals.sh, check_complexity_ratchet.py --base-ref origin/main, the assertion-quality ratchet, and python -m tests.quality.taxonomy --changed: all pass. python -m tests.lifecycle.generator --check and python -m tests.lifecycle.witnesses are up to date.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md (as the fragment changelog.d/4680.fixed.md):
    user-visible effect first, 25 words or fewer, ending with (#PR);
    breaking changes only under upgrade notes; no Highlights; see
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

…eclaring package

After `apm approve` pinned a package that declares both a hook and an
LSP server, the next `apm install` failed with "'types.SimpleNamespace'
object has no attribute 'install_path'". The trusted-LSP graph check
(install/lsp/integration.py) asked check_executable_approval about the
package with a stand-in carrying only its dependency_ref; pinned-hook
admission (security/trust.py hooks_package_admissible) reads the
package's hook files from install_path. The stand-in now carries the
install path, so the approved hook and LSP server deploy. Approval
decisions are unchanged.

Regression: tests/lifecycle/security/test_gate_removal.py::
test_approved_package_with_hook_and_lsp_installs_both (fails before:
exit 1 with the AttributeError; after: exit 0, hook and LSP deployed,
lock row records the hook, repeat install is a byte no-op). Ledger row
4658.

Fixes #4658

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 21, 2026 19:27
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

The new changelog bullet is rejected by check-unreleased because it requires a per-PR fragment and shortening to meet the 25-word limit.

1 open issue
What changed in this PR

Fixes #4658 by supplying the package install path to the existing approval check, preventing installation crashes for approved packages that declare both hooks and LSP servers.

Changes:

  • Passes install_path alongside the dependency identity without changing approval decisions.
  • Adds lifecycle coverage for approval, deployment, lockfile tracking, and repeat-install stability.
  • Records the regression in the bug ledger and documents the fix in the changelog.
File Description
tests/​lifecycle/​security/​test_gate_removal.py Adds a real-CLI regression test for combined hook and LSP deployment.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​4658.json Links the reported failure to its regression test.
src/​apm_cli/​install/​lsp/​integration.py Supplies the install path required by pinned-hook admission.
CHANGELOG.md Adds a user-facing entry describing the installation fix.

Review effort: Balanced

Comment thread CHANGELOG.md Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit d4aa297 into main Nov 21, 2026
92 of 94 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the ql-w1-4658-hooks-lsp-approve branch November 21, 2026 20:50
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 21, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

[BUG] apm install crashes after approving a package that declares both hooks and LSP servers

2 participants