Repository navigation
Description
Why
APM's policy system (apm-policy.yml) enforces governance over dependencies, MCP servers, compilation targets, and manifest fields. But enterprise teams need to enforce rules beyond what APM natively checks — readiness thresholds, quality evaluation, license compliance, custom org validators.
Today there is no extension point. The check list is hardcoded in run_policy_checks(). Adding a custom_checks section lets governance teams plug in any tool via subprocess commands, keeping APM tool-agnostic (like npm never hardcodes ESLint).
What
A new custom_checks field in apm-policy.yml that defines arbitrary subprocess commands. Each runs during apm audit --ci --policy, returns pass/fail via exit code, and integrates into the existing JSON/SARIF audit output.
Policy YAML format
name: contoso-org-policy
version: "1.0.0"
enforcement: block
custom_checks:
- name: agentrc-readiness
description: "Repo must meet AI readiness level 3"
command: "agentrc readiness --json --fail-level 3"
timeout: 60
on_failure: warn
- name: license-check
description: "All dependencies must have OSS licenses"
command: "./scripts/check-licenses.sh"
timeout: 30
on_failure: blockExecution model
During apm audit --ci --policy org:
- Baseline checks run (lockfile, integrity, Unicode) — unchanged
- Policy checks run (allowlist, denylist, required) — unchanged
- Custom checks run — NEW: for each entry, run command as subprocess with timeout. Exit 0 = pass, non-zero = fail. Results appear alongside built-in checks in JSON/SARIF.
Result format
Uses existing CheckResult model — no new output format:
{
"name": "custom:agentrc-readiness",
"passed": false,
"message": "Repo must meet AI readiness level 3",
"details": ["exit code 1: achieved level 2, required 3"]
}How
~150 lines across 4 files:
schema.py—CustomCheckdataclass + field onApmPolicyparser.py— parsecustom_checksfrom YAMLpolicy_checks.py—_run_custom_checks()with subprocess + CheckResult- Tests
Design principles
- APM stays tool-agnostic — any command works (agentrc, scripts, scanners)
- No library coupling — subprocess execution across language boundaries
- Inherits enforcement —
on_failuredefaults to top-levelenforcement - Safe — timeout prevents hangs; missing commands handled gracefully
Use cases
| Check | Command | Value |
|---|---|---|
| AI readiness | agentrc readiness --json --fail-level 3 |
Gate on maturity |
| License compliance | ./scripts/check-licenses.sh |
Legal requirements |
| Secret scanning | gitleaks detect --no-banner -q |
Security hygiene |
| Doc coverage | test -f README.md |
Documentation standards |
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
chore: consolidate CHANGELOG entries to 1 line per PR
chore: consolidate CHANGELOG entries to 1 line per PR (#555)
github-actions commentedon Apr 26, 2026
Triage decision
needs-designProposed labels
Milestone
nullSuggested next action
Draft a design doc specifying: subprocess execution environment (PATH, env vars, working directory, timeout), token-isolation guarantees, allowed command formats (no shell expansion), CI/CD output format, and integration with the existing
policy_engine/ci_checkspipeline.Suggested issue comment
Per-lens notes (collapsed)
DevX UX Expert -- User-Need Reviewer
The user task is clear: enforce org-specific rules in the APM policy gate without modifying APM itself. The
pass_if.exit_codeandon_fail: block/warnAPI mirrors APM's existing policy model -- ergonomically consistent. Key gap in the proposal: what does the user see when a custom check fails? The error message must name the check, the exit code, and a configurablemessagefield (not raw subprocess stderr). If the proposal does not include amessagefield in the schema, add one.Supply Chain Security Expert -- Risk-Surface Reviewer
HIGH concern:
custom_checkswithcommand+argsis post-install code execution. Specific risks: (1) APM's auth token env vars must not be inherited by subprocesses -- a maliciousapm-policy.ymlinstalled from a package could exfiltrate them. (2) Shell expansion inargsvalues (backticks,$(), pipes) must be blocked -- usesubprocess.run(list, shell=False)exclusively. (3)apm-policy.ymlis itself installed from packages -- custom checks in a policy file from an untrusted source are a supply-chain attack vector. (4) Arbitrarycommandvalues could invoke destructive system tools. The design must address all four.theme/governanceandarea/audit-policyare required.OSS Growth Hacker -- Contributor-Tone Reviewer
Not activated -- author is the maintainer filing a governance extensibility feature; no tone-tuning needed.
Python Architect -- Architecture Reviewer
New components required: (1) schema extension in the policy model for
custom_checks, (2) a subprocess executor inci_checks.pyor a newcustom_check_runner.py, (3) integration withDiagnosticCollectorfor output capture, (4) timeout handling viasubprocess.run(timeout=...). Cross-cutting impact: policy model changes affect compilation, CI gate, and theapm auditcommand. The subprocess execution environment design is the critical safety boundary.status/needs-designis correct -- the security design must be written before any code.Doc Writer -- Documentation Reviewer
New policy schema requires docs:
policy-reference.mdneeds acustom_checkssection with the schema, security guidance, and examples.area/docs-sitesecondary label is warranted. The security guidance (do not use shell expansion, token isolation) must appear in the reference docs, not only in code comments.APM CEO -- Triage Arbiter
Powerful enterprise extensibility feature with a legitimate security concern that must be resolved in design, not in code review. The Supply Chain Security Expert's five-point concern is valid and non-negotiable: token isolation and shell-expansion prohibition are safety invariants. Setting
status/needs-designwith no milestone is correct. The design doc must explicitly address the policy-file trust boundary (custom checks in an installed policy file = post-install code execution).{ "decision": "needs-design", "decision_detail": "Requires design doc covering: subprocess env isolation (token vars must not leak), allowed command formats (no shell expansion), timeout/resource limits, CI output format via DiagnosticCollector, and policy-file trust boundary for custom checks installed from packages.", "theme": "theme/governance", "areas": ["area/audit-policy", "area/enterprise", "area/docs-site"], "type": "type/feature", "status": "status/needs-design", "priority": null, "preserved_labels": [], "milestone": null, "next_action": "Draft a design doc specifying subprocess execution environment isolation, allowed command formats, timeout handling, CI output format, and the policy-file trust boundary for installed custom checks.", "comment_markdown": "Extending APM's policy system with custom subprocess validators is a compelling enterprise feature -- it lets teams enforce readiness thresholds, license checks, and org-specific rules without forking APM.\n\nThe direction is accepted. Before code lands, a design doc must settle:\n\n1. **Subprocess execution environment**: What PATH, working directory, and environment variables are visible to the command? Critically, APM's auth token env vars must NOT be inherited by custom check subprocesses.\n2. **Allowed command formats**: Shell expansion (`$()`, backticks, pipes) must be prohibited. Only a command + argument list is safe.\n3. **Timeout and resource limits**: Unbounded subprocess execution blocks the install pipeline. A configurable timeout (default: 30s) and output size cap are required.\n4. **CI/CD output format**: When a custom check fails, the diagnostic output must integrate with APM's `DiagnosticCollector` -- not raw subprocess stderr.\n5. **Policy file trust boundary**: `apm-policy.yml` is itself a file that APM installs from packages. Custom checks in a policy file from an untrusted package are a post-install code execution vector. The design must address this trust boundary explicitly.\n\nOnce those five questions have written answers linked here, the implementation path is clear." }chore: consolidate CHANGELOG entries to 1 line per PR (#555)
danielmeppiel commentedon Sep 14, 2026
The maintainer decision is not to add arbitrary subprocess execution through fetched apm-policy.yml policy. That would make APM responsible for another executable authority, including environment/credential handling, portability, process cleanup and result interpretation. Explicit CI steps can compose these validators alongside APM audit without introducing that policy execution surface.
I'm closing this proposal as not planned rather than leaving it as an implied future commitment. This supersedes the direction suggested in the earlier automated triage advice; it is not a rejection of the underlying license/readiness checks. A materially narrower unmet declarative policy need can be discussed separately.