Skip to content

feat(policy): apply manifest.content_types.allow to resolved packages - #4838

Merged
Daniel Meppiel (danielmeppiel) merged 7 commits into
mainfrom
e4628-sec-ql-7
Nov 23, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 7 commits into
mainfrom
e4628-sec-ql-7

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

The install policy check now applies manifest.content_types.allow from the effective org policy to the primitive kinds each resolved package ships.

  • policy/policy_checks.py: check_content_types (check name content-types). It classifies a package's shipped files into instruction, prompt, agent, skill, hook and context, accepting singular and plural spellings. Each package with a kind outside the allow list becomes one policy subject, and the reason names manifest.content_types and the allowed kinds. An absent content_types (or no allow) means unrestricted, and an explicit empty allow admits 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. Under enforcement: block it raises PolicyViolationError (a commit refusal), so the install exits 1, deploys nothing and leaves apm.yml and apm.lock.yaml unchanged. Under warn it reports through the shared emit_check_violations path, which names the policy source. --dry-run and --no-policy are 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

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
Command Result
pytest tests/lifecycle/scenarios/test_policy_promises.py (real binary; QL cells from danielmeppiel-ql-w3b-train7-promises a1805f4, G2) 2 passed. On main the allow-list row fails: the instruction deploys and the install exits 0.
pytest tests/unit/policy/test_policy_checks.py -k ContentTypes 5 passed
uvx [email protected] check / format --check, pylint R0801, scripts/lint-auth-signals.sh, scripts/lint-architecture-boundaries.sh, complexity ratchet, tests.quality.taxonomy --changed clean

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Changelog entry is coordinated at release.

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.

apm-spec-waiver: org policy check on an existing policy field; no new manifest, lockfile or registry surface.

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]>

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

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
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

Comment thread src/apm_cli/install/phases/download.py Resolved
Comment thread src/apm_cli/policy/policy_checks.py Resolved
Comment thread src/apm_cli/policy/policy_checks.py Resolved
Comment thread src/apm_cli/policy/policy_checks.py Resolved
… 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]>

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

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
1 resolved since last review

Review effort: Balanced

Comment thread src/apm_cli/policy/policy_checks.py Resolved
Comment thread src/apm_cli/policy/policy_checks.py Resolved
Comment thread src/apm_cli/policy/policy_checks.py Resolved
…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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

…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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

…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]>

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 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

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 501a47b into main Nov 23, 2026
72 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the e4628-sec-ql-7 branch November 23, 2026 00:41
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
…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]>
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.

2 participants