Baseline CI checks
apm audit --ci runs a fixed set of baseline checks against the project on
disk. Baseline checks are always on — they need no apm-policy.yml. With
policy discovery active, the org policy contributes additional checks on
top (see apm policy and the
policy schema).
This page documents the baseline set defined in
src/apm_cli/policy/ci_checks.py. For the command surface, see
apm audit. For the CI wiring, see
Enforce in CI.
Exit-code contract
Section titled “Exit-code contract”| Outcome | Exit code |
|---|---|
| All baseline checks pass (and any policy + drift checks pass) | 0 |
| Any baseline, policy, or drift check fails | 1 |
--no-fail-fast runs every check before exiting; the default stops at the
first failure to skip expensive I/O.
At a glance
Section titled “At a glance”| ID | Severity | Source | Always on? |
|---|---|---|---|
manifest-parse | block | ci_checks.py | only when apm.yml cannot be parsed |
manifest-missing | block in --ci, advisory otherwise | ci_checks.py | only when apm.yml is absent |
lockfile-exists | block | ci_checks.py | yes |
ref-consistency | block | ci_checks.py | yes |
deployment-ledger-owners | block | ci_checks.py | yes |
deployed-files-present | block | ci_checks.py | yes |
exec-status-current | block | ci_checks.py | yes |
no-orphaned-packages | block | ci_checks.py | yes |
lockfile-targets-current | block | ci_checks.py | yes |
skill-subset-consistency | block | ci_checks.py | yes |
config-consistency | block | ci_checks.py | yes |
native-mcp-ownership | block | ci_checks.py | yes |
native-mcp-drift | block | ci_checks.py | only when a recorded self-defined native MCP entry was edited |
kept-mcp-entries | block | ci_checks.py | only when install kept an MCP entry it no longer deploys |
content-integrity | block | ci_checks.py | yes |
local-bundle-hooks | block | ci_checks.py | yes |
hook-approval-pins | block | ci_checks.py | yes |
includes-consent | advisory | ci_checks.py | yes (advisory; promotable by policy) |
drift | block | _check_drift in ci_checks.py, invoked from commands/audit.py | yes, unless --no-drift |
Policy checks (dependency-allowlist, dependency-denylist,
required-packages, required-packages-deployed,
required-package-version, transitive-depth, and others in
policy/policy_checks.py) only run when an apm-policy.yml is resolved
through discovery or --policy. They are out of scope for this page; see
the policy schema.
Baseline checks
Section titled “Baseline checks”manifest-parse
Section titled “manifest-parse”- What it verifies. That
apm.yml, if present, is valid YAML and a valid APM manifest. - Fails when. The file exists but cannot be parsed (
yaml.YAMLError,ValueError, orOSError). - Effect. Skips every other check and exits
1. This is the only check that runs before the lockfile gate. - Remediation. Fix the YAML syntax error reported in the message and re-run.
manifest-missing
Section titled “manifest-missing”- What it verifies. That the current directory holds the
apm.ymlto audit. APM does not search parent directories. - Fails when. In
--cimode,apm.ymlis absent: from a subdirectory or a wrong checkout path the gate would otherwise pass without auditing anything. Without--ciit is an advisory warning, shown only when.apm/,apm.lock.yamlorapm.locksuggests a deleted manifest. - Remediation. Run
apm audit --cifrom the project root that containsapm.yml, or restore the deleted manifest.
lockfile-exists
Section titled “lockfile-exists”- What it verifies. That
apm.lock.yamlis present whenever the project has APM, MCP or LSP dependencies (includingdevDependencies), or whenever an existing lockfile records local content under the synthesized self-entry. With none declared,apm installwrites no lockfile, and both this check andapm install --frozenaccept its absence. - Fails when.
apm.ymldeclares dependencies (production or dev) but no lockfile is on disk. - Effect. Subsequent checks are skipped (the lockfile is required input).
- Remediation. Run
apm installto generateapm.lock.yamland commit it.
ref-consistency
Section titled “ref-consistency”- What it verifies. That every dependency’s
referenceinapm.yml(bothdependencies.apmanddevDependencies.apm) matches theresolved_refrecorded in the lockfile. - Fails when. A manifest ref differs from the lockfile entry, or the manifest declares a dependency that is missing from the lockfile.
- Marketplace declarations. Object-form
name+marketplaceentries match one locked dependency through recorded marketplace/plugin provenance. Missing or ambiguous provenance fails; APM does not guess from package names or paths. Version selections require the locked selected version and tag to satisfy the requested range; literal refs and full commit pins must match their locked evidence. A package’s display version or a repeated selector alone is not proof. Audit reads this evidence without fetching today’s catalog or changing the manifest, lockfile, or deployment. An unavailable catalog does not invalidate an otherwise valid installed dependency. - Remediation. Run the command the check message names:
apm updatewhen the lockfile already holds a resolution that must be refreshed or re-keyed (the source-identity rewrite and commit-pin mismatch cases), or plainapm installfor a first resolution — so the lockfile re-resolves to the manifest, then commitapm.lock.yaml. - Runs before
deployment-ledger-owners. This external manifest-versus-lockfile identity check is evaluated ahead of the internal ledger-owner check on purpose. A source-identity tamper (a rewritten dependencyhost/repo_urlin the lockfile) trips both, but onlyref-consistencypoints at the safe fix — re-resolving from the trusted manifest viaapm update. The ledger-owner remedy (apm prune) reconciles ownership toward the current lockfile, so it must never be the surfaced cause when the manifest and lockfile disagree about a dependency’s identity.
deployment-ledger-owners
Section titled “deployment-ledger-owners”- What it verifies. That every canonical
deploymentsrow’sownersandactive_ownerresolve to a member of the valid owner universe: a current key inapm.lock.yaml’sdependencies, the workspace self-owner., orlocal-bundle. - Fails when. A row references a dependency key that has since been
removed from the lockfile (a stale, “ghost” owner), or
active_owneritself is invalid. This is a hard integrity failure, distinct from ordinary drift — unlike hand-edits or missing files, it fails in both bareapm auditandapm audit --ci. - Effect. Findings render in text, JSON, SARIF, and markdown output
alike, naming the locator and its invalid owner(s).
apm audit --striprefuses to modify content while any reference is invalid. - Remediation. Run
apm prune, then rerunapm audit. Prune repairs the stale ownership metadata; it does not delete files based on a ghost row alone. Seeapm pruneand Lockfile spec.
deployed-files-present
Section titled “deployed-files-present”- What it verifies. That every path in each lockfile entry’s
deployed_filesexists on disk under the project root. Gitignored paths are considered expected-absent and do not cause a failure. - Fails when. One or more non-gitignored deployed files are missing (e.g. a developer ran
apm installthen deleted integrated files, or skipped install entirely). - Remediation. Run
apm installto restore integrated files. Whenapm.ymldeclares targets, install also removes stale entries outside the declared, gated, and dynamic target set. Then commit the updated lockfile:git add apm.lock.yaml && git commit.
exec-status-current
Section titled “exec-status-current”- What it verifies. That each locked package’s recorded
exec_statusis still the executables gate’s decision under the currentapm.ymland org policy. It uses the same staleness test asapm updateandapm install --frozen. - Fails when.
apm denyor an org policy change gates a package the lockfile records with a different decision, for examplerecorded deployed, now denied. This includes Claudesettings.jsonhooks, where no recorded file goes missing. The decision depends on org policy, so the check is not evaluated under--no-policy(without--policy), and an org policy that cannot be resolved (for example no cache and an unreachable source) or an unreadable package reports it as not verified instead of failing. - Remediation. Run
apm install(without--frozen) and commitapm.lock.yaml.
no-orphaned-packages
Section titled “no-orphaned-packages”- What it verifies. That every dependency in the lockfile is still declared in
apm.yml(in eitherdependencies.apmordevDependencies.apm). The synthesized self-entry is excluded. - Fails when. The lockfile holds a package that the manifest no longer lists.
- Marketplace declarations. Only the uniquely associated locked coordinate counts as declared. Marketplace provenance does not exempt other entries from orphan detection.
- Remediation. Run
apm installto prune the orphan, then commitapm.lock.yaml.
lockfile-targets-current
Section titled “lockfile-targets-current”- What it verifies. That
apm.lock.yamlrecords no deployed file of a targetapm.ymlno longer declares intargets:. Projects that declare no targets (auto-detect) always pass. - Fails when.
apm.ymldropped a target but the lockfile still records that target’s files.apm install --frozenrefuses the same state, with no writes. - Remediation. Run
apm install(without--frozen) to retire the dropped target and updateapm.lock.yaml, then commit it.
skill-subset-consistency
Section titled “skill-subset-consistency”- What it verifies. That each locked dependency’s
skill_subset,target_subsetandsubset_pairingsequal the merge of everyskills:/targets:declaration inapm.ymland the installed dependency manifests, and that every recorded skill path exists in the resolved package tree. When CI audit has prepared a lock-pinned scratch replay, this check uses its dependency tree instead of checkout-localapm_modules/; no checkout install is required. - Fails when. The merged declarations differ from the recorded selection,
subset_pairingsis malformed or disagrees with the flat fields, a declaring manifest cannot be read, or a recorded subset path does not map to a deployable skill in the dependency tree being checked. - Remediation. Run
apm installto regenerate the lockfile against the current selection.
config-consistency
Section titled “config-consistency”- What it verifies. That MCP server configs derived from the root
dependencies.mcpanddevDependencies.mcp, plusdependencies.mcpfrom every current local or installed-remote package manifest bounded by the lockfile, match themcp_configsbaseline. Dependency-packagedevDependencies.mcpis author-only and is excluded from the consumer baseline. - Fails when. A server’s resolved config differs from the lockfile, a server exists on only one side, or a locked package manifest is unreadable. In
apm audit --ci, whenapm_modules/is absent but the lockfile is present, APM first self-hydrates a lock-pinned scratch install and derives the current MCP truth from that isolated modules tree; if the scratch replay itself fails,config-consistencyfails closed with the replay error. A missing manifest also fails unless the lockfile records a skill bundle, or records a remote Claude skill at a repository root or subdirectory. Before remote materialization the locked type is authoritative; once materialized, the on-disk shape and lock metadata must both identify a Claude skill. Present local paths use the same shape-and-lock check, while a missing local path still fails.mcp_config_provenanceidentifies the package in lock-only diagnostics but never exempts a removed declaration. - Consent. Audit re-evaluates admission from
apm.ymland org policy, never from the lockfile or the personal--userstore. A server the lockfile admitted thatapm.ymldoes not approve, for example after a one-off--trust-transitive-mcprun or a hand edit, fails withadmitted in apm.lock.yaml but not approved in apm.yml (<reason>); run 'apm approve <pkg>' and re-run 'apm install'. A denied server fails withadmitted in apm.lock.yaml but the executables gate now parks it (denied), pointing atapm policy explain <pkg>. A passing check names servers parked because their definition changed since approval (Review: apm approve --pending). - Intentional omissions. Install and update record dependency MCP omitted by
--only apm, by the default refusal of unapproved transitive MCP (including retiring one a previous run trusted with--trust-transitive-mcp), or by the executables gate while the declaring package is not approved, is denied, or no longer matches its pin. Audit excludes only the exact dependency and authored declaration covered by that evidence; expanding${CLAUDE_PLUGIN_ROOT}at a different materialization path does not change it. This applies to project and global installs, includingagent-skills. After direct MCP admission, obsolete omission evidence no longer affects that server: its admitted configuration participates in normal drift checks. Root declarations and previously admitted MCP configurations remain checked; a later skills-only install preserves their baseline. If removing a server fails, the previous baseline is kept and no omission is recorded. - Frozen skills-only replay.
apm install --only apm --frozenaccepts matchingonly-apmomission evidence and preserves the admitted MCP baseline and exact lockfile and native-configuration bytes. Missing, damaged or stale omission evidence still fails. Existing frozen source and consent checks still apply: a baseline that already admitted transitive MCP requires an approval inapm.ymlor the same explicit--trust-transitive-mcp.--only apmstill prevents native MCP integration; omission evidence never grants consent. - Remediation. Repeat the intended install selection or restore an unreadable package source. For skills-only use
apm install --only apm, orapm install --global --target agent-skills --only apmfor the global skills-only case. Older lockfiles, empty MCP fields, and missing, damaged or stale omission evidence do not establish intent: audit reports unknown selection rather than assuming success. Do not enable MCP or add--trust-transitive-mcpmerely to clear the finding; for a consent failure, approve the package. Audit itself does not reconcile or write configuration.
native-mcp-ownership
Section titled “native-mcp-ownership”- What it verifies. That no MCP runtime holds a same-name entry that differs from a self-defined declared server whose ownership the lockfile does not record.
apm install --frozenrefuses the same entry, so both commands reach one verdict. - Fails when. Such an entry exists. The detail names the server and the target. An entry equal to the declaration, including one switched off with
enabled = false, passes and stays the user’s. - Remediation. Make the entry match the declaration or remove it, then run
apm install. Audit does not change the native configuration.
native-mcp-drift
Section titled “native-mcp-drift”- What it verifies. That every native MCP entry the lockfile records APM writing for a self-defined server, with its recorded fingerprint, still matches that write (for example in
.mcp.jsonor~/.claude.json). It appears only when such an entry changed. Entries the lockfile does not record are covered bynative-mcp-ownership; registry servers are not compared. - Fails when. A recorded entry was edited by hand. The detail names the server, the config file and the runtime.
apm installpreserves the same entry and refuses to overwrite it. - Remediation. Undo your edit to the entry or remove it, then run
apm install(apm install -gfor a user-scope entry). Audit does not change the native configuration.
kept-mcp-entries
Section titled “kept-mcp-entries”- What it verifies. That no MCP entry is left over that an install without
apm.lock.yamlkept because it could not confirm the entry is the one APM wrote for a server it no longer deploys (the entry changed since, or this machine’s record of it is unusable), or kept for a runtime the manifest’stargets:no longer select while its server stays declared. It appears only when such an entry exists. - Fails when. A kept entry is still in the selected config and the lockfile does not manage its server (or, for an entry kept for a runtime no longer targeted, no install has targeted that runtime again), or this machine’s MCP write record cannot be used (without a lockfile, or once an install without a lockfile met it, also after the lockfile is rewritten). The detail names the server, the config file and the runtime, or the unusable record file.
- Remediation. Remove each entry you no longer use, or declare the server or target its runtime again, and remove an unusable record file, then run
apm install. Audit does not change the native configuration.
content-integrity
Section titled “content-integrity”- What it verifies. Two independent signals, including local
.apm/deployments recorded through the synthesized self-entry:- Critical hidden Unicode in recognized prompt documents and decoded native prompt fields. Discovery uses each resolved target’s filenames and primitive patterns, including untracked files and shared hook settings. Recorded paths use the same applicability rules: tracking a command or script does not turn it into prompt text. Hook definitions remain visible even when their command-only content is not applicable to Unicode prompt checks. Session transcripts, history, caches, command strings and referenced executables are not scanned. See Discovery and prompt coverage for the format boundaries.
- SHA-256 drift between the on-disk content and the hash recorded in
deployed_file_hashesat install time. Necessarily lockfile-scoped: an unrecorded file has no baseline to compare against. Local bundle instructions staged forapm compileare checked the same way againstlocal_staged_file_hashes; staged paths without a recorded hash (older lockfiles) are skipped.
- Fails when. An applicable prompt contains critical Unicode, recognized content is unreadable or unsupported (incomplete coverage), a recorded hash differs, or a legacy hash lacks canonical ownership metadata. Missing files are reported by
deployed-files-present; unrecorded files have no hash baseline. Existing path and symlink protections still apply. - Remediation. Review the reported format or access error for incomplete coverage. Use
apm audit --striponly for supported regular prompt documents; structured/shared settings and external-root findings require manual review. Runapm installto restore hash-drifted files; for drifted staged bundle files, reinstall the bundle withapm install <bundle> --force. Discovery does not grant ownership or permission to rewrite user configuration.
local-bundle-hooks
Section titled “local-bundle-hooks”Fails when a local bundle’s deployed hooks (or canvas extensions) are no longer
admitted by the current executables trust, and when a bundle hook entry in a
merged hook config was changed outside APM (for example a new matcher), or
its ownership record (apm-hooks.json beside the config) is unreadable or
missing: APM can no longer match the entry to its recorded content, so the check
names it instead of losing track of the bundle’s hooks. Restore the recorded entry first: apm uninstall refuses while an edited entry still runs the bundle’s script. Keep
your own changes in a separate hook entry.
hook-approval-pins
Section titled “hook-approval-pins”- What it verifies. That every hook file the lockfile records as deployed is still admitted by its pinned approval in
apm.yml(see pinned approvals). It runs aftercontent-integrityand uses the same check asapm install --frozen, so both reach one verdict. - Fails when. A pinned hook file’s content no longer matches its pin, or its pin was removed, while
exec_statusstill records the hooks as deployed. A deny is reported by the deny checks instead. It also fails when a file the lockfile does not record sits at one of a package’s own hook destinations (such as.github/hooks/<package>-<name>.json) while the executables gate withholds that package’s hooks (denied or not approved); the detail names the path. For targets that merge hooks into one config file (such as.claude/settings.json,.cursor/hooks.json,.codex/hooks.json), it fails on an entry that matches such a package’s own hook and that no ownership record attributes to another source; the detail names the file and the event.apm installkeeps such a file or entry and warns naming it, because no lock record proves APM wrote it. - Remediation. Re-approve the package with
apm approve <package>, or runapm installto retire the hook, then commitapm.ymlandapm.lock.yaml. For an unrecorded file at a withheld package’s hook path, delete it if you did not write it yourself, then runapm audit --ci; for a named merged-config entry, remove the entry if you did not add it yourself.
includes-consent
Section titled “includes-consent”- What it verifies. That projects deploying local content (the lockfile’s
local_deployed_filesis non-empty) declare anincludes:field inapm.ymlfor explicit governance. - Fails when. Never — this check is advisory and always passes. The message advises adding
includes: auto(or an explicit list) when local content is deployed without a declaration. - Promote to a block. Set
manifest.require_explicit_includesinapm-policy.ymlto make missingincludes:fail the policy layer. - Remediation. Add
includes: autotoapm.yml, or list the paths explicitly.
- What it verifies. That the working tree matches what an install from the current lockfile would produce. The check replays the install pipeline into a scratch tree and diffs the result against the project.
- Fails when. Any deployed file differs from the replay output (hand-edits, missing integrations, orphaned files). For shared hook configuration files, the comparison covers only APM-owned hook entries; user-owned hooks are preserved and do not create drift. The complete APM-owned sidecar is compared as JSON, ignoring object-key order and formatting but preserving all fields and list order; changed content, malformed JSON, duplicate keys, and non-JSON constants (
NaN,Infinity,-Infinity) still fail. Inapm audit --ci, a cold cache no longer yields a green skip: ifapm_modules/is absent, APM self-hydrates a lock-pinned scratch install first and then diffs against the checkout. If that scratch replay cannot be materialized, the drift check fails closed with the replay error. - Skips when. Only in bare
apm audit, where the replay remains cache-only and a missing cache yields an informational skip advising the user to runapm installfirst. - Skip with.
apm audit --ci --no-drift(reduces coverage; reserve for performance-constrained CI loops). - Remediation. Run
apm installto restore the deployed state, or revert the hand-edit. For a cache-miss skip, the sameapm installwarms the cache and enables the check on the next run.
Run order and fail-fast
Section titled “Run order and fail-fast”The aggregate runner in run_baseline_checks evaluates checks in this order: manifest-parse (only when apm.yml is unparseable), lockfile-exists, ref-consistency, deployment-ledger-owners, deployed-files-present, no-orphaned-packages, lockfile-targets-current, skill-subset-consistency, config-consistency, native-mcp-ownership, native-mcp-drift (only when reported), kept-mcp-entries (only when reported), content-integrity, local-bundle-hooks, hook-approval-pins, exec-status-current, includes-consent. Drift is invoked separately by the audit command after the baseline batch, but in --ci mode it shares the same cold-cache scratch materialization with skill-subset-consistency and config-consistency.
With fail-fast on (the default), the runner stops at the first failing check. apm audit --ci --no-fail-fast evaluates every check so the report lists every problem at once.
Related
Section titled “Related”apm audit— the command surface and modes.apm prune— reconcilesdeployment-ledger-ownersfindings.apm policy— inspect, validate, and resolve org policy.- Policy schema — the policy-gated checks layered on top of this baseline.
- Enforce in CI — wiring the gate into branch protection.
Copyright (c) Microsoft Corporation. General documentation: CC-BY-4.0. Software, code examples and OpenAPM: Apache-2.0. See scope and exclusions.