Skip to content

fix: user-scope lifecycle scripts load once; user-scope policy negative cells - #4345

Merged
Daniel Meppiel (danielmeppiel) merged 8 commits into
mainfrom
danielmeppiel-curly-carnival
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 8 commits into
mainfrom
danielmeppiel-curly-carnival

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

User-scope policy negative cells. User scope is not governed by an org policy reachable from a git checkout at HOME. Each user-scope command now has its own cell:

  • install -g, update -g and install -g --frozen: HOME is a git checkout whose remote names an org whose policy denies the package. The command succeeds, sends no policy request (fixture request log), writes no policy cache, leaves the checkout untouched and prints nothing about policy.
  • Positive control in every cell: a project-scope apm install from the same HOME checkout is blocked by that policy (exit 1, "Install blocked by org policy", a policy request observed), so the user-scope negatives cannot pass vacuously.
  • apm policy status -g reports the user-scope source as none. The control is the same checkout at project scope, which resolves the org policy.

It splits the earlier combined user-scope test into separate cells and updates the #4087 ledger row to the new node ids.

User-scope consistency: at user scope the command manifest is $APM_HOME/apm.yml, which the user tier of lifecycle discovery already loads. Lifecycle discovery (core/lifecycle_scripts.py) now loads it once, as user-tier scripts, rather than also as a project tier. The concurrency scenarios park a user-scope lock holder in a one-shot user-manifest pre-install script, which runs under the lifecycle lock; project scope keeps the git-shim park.

Issue and approved scope

Issue: Fixes #4365

Issue: Refs #4087

Human scope-approval comments: #4365 (comment) (#4365), #4087 (comment) (#4087)

Does this PR complete the issue, or what remains? Completes #4365. #4087 is already fixed by #4158; this adds the negative cells the steward asked for.

Type of change

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

Testing

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

Installed CLI (APM_BINARY_PATH set to the binary under test), all green on this branch:

Cell Node id
install -g tests/integration/test_user_scope_manifest_lifecycle.py::test_user_scope_command_is_not_governed_by_home_remote_policy[install]
update -g tests/integration/test_user_scope_manifest_lifecycle.py::test_user_scope_command_is_not_governed_by_home_remote_policy[update]
install -g --frozen tests/integration/test_user_scope_manifest_lifecycle.py::test_user_scope_command_is_not_governed_by_home_remote_policy[install-frozen]
policy status -g tests/integration/test_user_scope_manifest_lifecycle.py::test_user_scope_policy_status_reports_no_source
user lifecycle scripts load once (installed CLI) tests/integration/test_user_scope_manifest_lifecycle.py::test_user_scope_lifecycle_scripts_run_once
user lifecycle scripts load once (owner) tests/unit/core/test_lifecycle_scripts.py::TestDiscoverScripts::test_user_scope_manifest_is_loaded_once, ::test_user_scope_runner_skips_no_project_scripts
user-scope lock serialization tests/lifecycle/scenarios/test_concurrency.py (all 9 rows, including user-install-vs-*, with the engine and binary drivers)

Spec coverage, so no waiver: OpenAPM v0.1 req-pl-001 and req-pl-011 discover policy from a project's remote git context, req-pl-012 attempts no discovery without a project remote, and Section 2 defines user scope as independent of any project root.

tests/quality/test_lifecycle_bug_ledger.py passes; the CI-mirror lint chain (ruff check/format, pylint R0801, auth signals, architecture boundaries, complexity and assertion ratchets) is clean.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

install -g, update -g and install -g --frozen each get their own cell: with
HOME a git checkout whose remote names an org policy that denies the
package, the command succeeds, sends no policy request, writes no policy
cache, leaves the checkout untouched and prints nothing about policy.
apm policy status -g reports the user-scope source as none, with a
project-scope control.

Spec: OpenAPM v0.1 req-pl-001 and req-pl-011 discover policy from a
project's remote git context, req-pl-012 attempts no discovery without a
project remote, and Section 2 defines user scope as independent of any
project root.

Refs #4087

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

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 lifecycle test can pass without applying the published revision, so it must assert the deployed skill contains v2 content to prove the intended upgrade path was exercised.

1 open issue
What changed in this PR

This test-only follow-up to #4158 expands regression coverage for #4087: user-scope commands must ignore organization policy reachable through a git checkout at HOME.

Changes:

  • Splits policy checks into separate cases for install -g, update -g, and install -g --frozen.
  • Separates policy status -g coverage, retaining a project-scope control that discovers the policy.
  • Updates the lifecycle bug ledger to reference the new tests.
File Description
tests/​integration/​test_user_scope_manifest_lifecycle.py Adds distinct user-scope policy cases and seeds a newer revision for update coverage.
tests/​fixtures/​lifecycle_bug_ledger.json Updates #4087 regression-test references.

Review effort: Balanced

At user scope the command manifest is $APM_HOME/apm.yml, which the user
tier already loads; lifecycle discovery no longer loads it again as a
project tier. The concurrency scenarios park a user-scope holder in a
one-shot user-manifest pre-install script, which runs under the lifecycle
lock, and keep the git-shim park for project scope.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
This was referenced Nov 20, 2026
…arnival

# Conflicts:
#	CHANGELOG.md
#	tests/lifecycle/scenarios/test_concurrency.py
… cell

Each user-scope negative cell now runs a project-scope install from the
same HOME checkout, which the published policy blocks, so the negatives
cannot pass vacuously. An installed-CLI cell asserts the user manifest's
pre-install script runs once with no project script reported as skipped.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title test: user-scope policy negative cells fix: user-scope lifecycle scripts load once; user-scope policy negative cells Nov 20, 2026
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 023cb17 into main Nov 21, 2026
43 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-curly-carnival branch November 21, 2026 05:24
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.

lifecycle: user-scope manifest is discovered as both user and project tier

2 participants