Repository navigation
feat(policy): apply manifest.content_types.allow to resolved packages - #4838
Conversation
The install policy check reads manifest.content_types.allow from the effective org policy and compares it with the primitive kinds each resolved package ships (instruction, prompt, agent, skill, hook, context; singular and plural spellings agree). Under enforcement: block the install stops after download and before any deploy write, naming each package, the kinds outside the allow list and the policy source; under warn it reports them. Adopts the QL policy-promise cells (control and allow-list rows) from danielmeppiel-ql-w3b-train7-promises and pins the refusal: exit 1, nothing deployed, apm.yml and apm.lock.yaml unchanged. apm-spec-waiver: org policy check on an existing policy field; no new manifest, lockfile or registry surface. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Critical policy-enforcement gaps can permit forbidden content to deploy because checks run before final acquisition, scan incorrect locations, omit colliding dependencies, and miss nested agents.
6 open issues
Run the policy check after all package acquisition and before deployment · New Check normalized materializations instead of reconstructing source paths · New Key package checks by unique dependency identity · New Use the registered classifier to detect nested agent files · New Preserve unrestricted allow values during policy merging · New Normalize content-type aliases before policy inheritance · New
What changed in this PR
Adds manifest.content_types.allow checking to APM’s dependency installation pipeline, intended to restrict which primitive kinds resolved packages may ship.
Changes:
- Adds package-content classification and allow-list evaluation.
- Invokes policy enforcement after the download phase, with blocking errors or source-attributed warnings.
- Adds unit and real-CLI tests for allow lists and state preservation on refusal.
| File | Description |
|---|---|
tests/unit/policy/test_policy_checks.py |
Tests classification, aliases, unrestricted policies, and empty allow lists. |
tests/lifecycle/scenarios/test_policy_promises.py |
Tests instruction deployment and policy refusal without manifest or lockfile changes. |
src/apm_cli/policy/policy_checks.py |
Adds content-kind detection and per-package policy results. |
src/apm_cli/install/phases/policy_gate.py |
Collects package roots and applies block-or-warn enforcement. |
src/apm_cli/install/phases/download.py |
Calls the content-type gate after pre-download processing. |
Review effort: Balanced
… audit --ci Review fold: - package_content_kinds classifies by the primitive source directories APM deploys from (.apm/<dir>/ and the plugin root directories); a directory with no content_types name is its own kind, so an allow list that does not name it refuses it. command, extension and workflow are nameable. - package_content_roots is the one package-root resolver; run_policy_checks applies check_content_types to the locked packages, so audit --ci reports a lock that ships a disallowed kind. - Rows: a plugin-root agents/ package is refused; audit --ci fails after a --no-policy install. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Critical enforcement gaps can let forbidden content bypass blocking policies because checks precede final acquisition, dependency-name collisions overwrite package roots, and manifest-declared custom plugin components go undetected.
8 open issues
Include manifest-declared plugin components in policy checks · New Key content roots by unique dependency identity · New Key package checks by unique dependency identity Check normalized materializations instead of reconstructing source paths Run the policy check after all package acquisition and before deployment Preserve unrecognized content kinds in the allow list · New Normalize content-type aliases before policy inheritance Preserve unrestricted allow values during policy merging
1 resolved since last review
Review effort: Balanced
…pes in its own module Review fold: - policy/content_types_check.py holds the content_types check (policy_checks.py line budget); run_policy_checks calls it only when the policy sets content_types. - Install judges a local dependency's source, which integrate re-copies and deploys, together with any apm_modules copy; audit judges the copy and falls back to the source. A package with no content on disk fails as unverifiable. - Row: a local dependency that gained a hook is refused on a targeted install of another package although its copy predates the change. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Critical content-type checks do not reliably inspect every final package image before deployment, allowing prohibited content to bypass enforcement.
14 open issues
Check normalized package images, including symlinks and inline hooks · New Resolve transitive dependencies from their recorded package anchors · New Key package roots by unique dependency identity · New Key content roots by unique dependency identity Include manifest-declared plugin components in policy checks Key package checks by unique dependency identity Check normalized materializations instead of reconstructing source paths Run the policy check after all package acquisition and before deployment Include all resolved local dependencies in policy checks · New Preserve unrestricted allow values during policy inheritance · New Normalize content-type aliases before policy inheritance · New Preserve unrecognized content kinds in the allow list Normalize content-type aliases before policy inheritance Preserve unrestricted allow values during policy merging
Review effort: Balanced
…endencies A locked local dependency is not redeployed by a targeted install of another package; an unlocked one (#4198) is, so that install is refused. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Critical gaps let content-type checks inspect stale or incorrect package images, overwrite distinct dependency records, and miss forbidden content that is later deployed.
14 open issues
Key package roots by unique dependency identity Resolve transitive dependencies from their recorded package anchors Check normalized package images, including symlinks and inline hooks Key content roots by unique dependency identity Include manifest-declared plugin components in policy checks Key package checks by unique dependency identity Check normalized materializations instead of reconstructing source paths Run the policy check after all package acquisition and before deployment Normalize content-type aliases before policy inheritance Preserve unrestricted allow values during policy inheritance Include all resolved local dependencies in policy checks Preserve unrecognized content kinds in the allow list Normalize content-type aliases before policy inheritance Preserve unrestricted allow values during policy merging
Review effort: Balanced
Review fold for #4838: - Install checks the normalized package image of every acquired package in the integrate batch preflight (after all acquisition, before any deploy), so sequential, retried and refreshed acquisitions, relative local anchors and plugin normalization are all covered by construction. - Packages are keyed by dependency identity (get_unique_key), never display name. - An allow entry with no kind alias is kept as its own kind, so an allow list can admit an unnamed source directory. - Plugin manifest components declared at custom paths count as their kind. - Inheritance intersects content_types by kind (aliases agree) and keeps an absent allow unrestricted, distinct from an explicit empty list. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The policy gate dereferences missing package metadata for cached dependencies with no active targets, causing installs to crash whenever an active policy defines content_types, even if empty or warn-only.
1 open issue
14 resolved since last review
Key package roots by unique dependency identity Resolve transitive dependencies from their recorded package anchors Check normalized package images, including symlinks and inline hooks Key content roots by unique dependency identity Include manifest-declared plugin components in policy checks Key package checks by unique dependency identity Check normalized materializations instead of reconstructing source paths Run the policy check after all package acquisition and before deployment Normalize content-type aliases before policy inheritance Preserve unrestricted allow values during policy inheritance Include all resolved local dependencies in policy checks Preserve unrecognized content kinds in the allow list Normalize content-type aliases before policy inheritance Preserve unrestricted allow values during policy merging
Review effort: Balanced
…oys nothing A package acquired with no targets materializes without package_info and deploys nothing; the gate judges only materializations that deploy. The gate reads the enforcement flag defensively, as other phase helpers do. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because unpublished findings identify a critical bundle-install policy bypass and inconsistent content-type enforcement for empty targets and normalized plugins.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
Hook kind under block and warn; an unnamed .apm/<dir> is its own kind; a plugin-manifest component at a custom path counts; extends: narrows by kind; audit --ci fails a locked package with no content on disk. Co-authored-by: Copilot App <[email protected]>
…rate test_policy_promises keeps this train's sections and takes main's G2 content_types section (#4838). The U-BIN-OPS text takes train 5's prune-free premises and keeps the Q&L baseline sentence for the org-policy level. test_mcp_write_receipts keeps W4's #4784 row and main's #4801 follow-ups. The workflow selections list both new quality modules. Co-authored-by: Copilot App <[email protected]>


Description
The install policy check now applies
manifest.content_types.allowfrom the effective org policy to the primitive kinds each resolved package ships.policy/policy_checks.py:check_content_types(check namecontent-types). It classifies a package's shipped files intoinstruction,prompt,agent,skill,hookandcontext, accepting singular and plural spellings. Each package with a kind outside the allow list becomes one policy subject, and the reason namesmanifest.content_typesand the allowed kinds. An absentcontent_types(or noallow) means unrestricted, and an explicit emptyallowadmits nothing (the inheritance intersection's meaning).install/phases/policy_gate.py:enforce_content_types, called at the end of the download phase. By then every resolved package is on disk and nothing is deployed. Underenforcement: blockit raisesPolicyViolationError(a commit refusal), so the install exits 1, deploys nothing and leavesapm.ymlandapm.lock.yamlunchanged. Underwarnit reports through the sharedemit_check_violationspath, which names the policy source.--dry-runand--no-policyare unaffected.Issue and approved scope
Issue: none; scope set by the maintainers.
Human scope-approval comment: approved by the maintainers.
Does this PR complete the issue, or what remains? Completes the install path.
Type of change
Testing
pytest tests/lifecycle/scenarios/test_policy_promises.py(real binary; QL cells fromdanielmeppiel-ql-w3b-train7-promisesa1805f4, G2)pytest tests/unit/policy/test_policy_checks.py -k ContentTypesuvx [email protected] check/format --check, pylint R0801,scripts/lint-auth-signals.sh,scripts/lint-architecture-boundaries.sh, complexity ratchet,tests.quality.taxonomy --changedChangelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Changelog entry is coordinated at release.
Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.
apm-spec-waiver: org policy check on an existing policy field; no new manifest, lockfile or registry surface.