Skip to content

[EPIC] Policy compile: turn one APM policy into each harness's managed settings, and check them before install #3618

Not planned
12 of 12 issues completed

Description

In one sentence: admins keep one vendor-neutral policy file; apm policy compile turns the rules that map exactly into each coding agent's own lockdown settings, and apm install refuses what those settings block instead of reporting false success.

Why

Persona. Amara is a platform admin at a strict enterprise. Her APM policy (apm-policy.yml) lists allowed plugin marketplaces (catalogs of trusted plugins) and MCP servers (tool servers an agent can call). She also hand-writes managed settings for each harness (the coding agent tool APM configures, such as Claude Code, GitHub Copilot or Codex): a file IT deploys to every laptop, which the harness must obey. Same rules, written twice, drifting apart.

Worse, APM never reads the deployed files. On a locked-down laptop, apm install can report success for a plugin the harness then drops.

Why now. Claude Code and GitHub Copilot both ship managed settings with shared keys such as strictKnownMarketplaces and deniedMcpServers, and admins hand-write these files today.

What

Two layers, one policy. APM checks at install time; the harness enforces at run time. APM writes the settings files; IT deploys them (device management, root-owned paths, GitHub server-managed settings).

flowchart TB
  P["apm-policy.yml (one policy)"] --> C["apm policy compile"]
  C --> F["managed settings files + UNMAPPED.md"]
  F --> IT["IT deploys the files"]
  subgraph L2["Layer 2: harness, run time"]
    MS["Managed settings on the laptop"] --> RT["Harness enforces: loads or drops"]
  end
  IT --> MS
  subgraph L1["Layer 1: APM, install time"]
    I["apm install"] --> D{"Allowed by APM policy AND by deployed managed settings?"}
    D -->|yes| W["Write files, exit 0"]
    D -->|no| X["Refuse, exit 1, nothing written"]
  end
  P --> D
  MS -->|"preflight reads the file"| D
  W --> RT
Loading

Illustrative, planned for 0.40:

# apm-policy.yml (existing keys only)
enforcement: block
marketplace:
  allow: [acme/agent-marketplace]
mcp:
  allow: [github, acme-jira]
  deny: [shell-exec]
$ apm policy compile --vendor claude,copilot -o dist/policy/
[+] dist/policy/claude/managed-settings.json   deniedMcpServers (1)
[i] dist/policy/copilot/managed-settings.json  no rule proven equal yet (file not written)
[!] not emitted (APM enforces these at install only), see dist/policy/UNMAPPED.md
$ apm install foo@random      # laptop with the deployed file
[x] foo@random: marketplace 'random' is not allowed by managed settings (claude). Nothing written.

When the layers disagree

Situation What happens
APM policy allows it; deployed managed settings block it Install preflight (a check before writing) refuses, exit 1, nothing written.
APM policy blocks it; managed settings allow it or are absent apm install refuses (enforcement: block). Items added another way still load; apm status flags them (#5745).
A rule has no exactly equal vendor key Listed in UNMAPPED.md, not written. Only APM enforces it, at install.
Compiled files are older than the policy apm policy compile --check fails.

Until 0.41 adds installs from the org marketplace, APM registers plugins through a local marketplace entry. A strictKnownMarketplaces list that omits it refuses those installs too, and preflight says so.

What it includes

  • apm policy compile, --check and UNMAPPED.md: Claude Code and Copilot first, then Codex and Gemini.
  • Install preflight that reads deployed managed settings files.
  • Policy check fixes already filed (see Child issues).

What it does not include

  • Deploying files to machines, new policy keys, vendor-only keys.
  • Planned for 0.41: forcing plugins on, managed-only hooks, "install = enable from the org marketplace", registering marketplaces, reading device-management or server-pushed settings.

How

One mapping table holds all vendor knowledge. Each row links an APM rule to a harness key, rates how their meanings compare (equal, narrower, wider, approximate) and cites the vendor doc. Only equal rows are written; UNMAPPED.md lists the rest. A row is equal only once a real-harness test shows an allowed item loading and a blocked one refused.

Each emitted key must be documented by two or more harnesses or a published standard. A new vendor adds rows, not code. Preflight reuses the apm status reader (#5745). The vendor is a command-line flag, so the policy file stays vendor-neutral.

Value

How it fits APM's principles

  • One manifest, one lockfile, one policy: one policy file feeds every harness.
  • Standards-first: only keys shared by harnesses or a standard.
  • Honest evidence: written only when proven equal; the rest is listed.
  • Unbound from harness binaries: preflight reads files only.
  • Promises before features: each promise is a failing test first.
  • Backward-compatible YAML: no key added or renamed.

Promises you can verify

  1. Every key apm policy compile writes traces to a rule proven equal; every other rule appears in UNMAPPED.md.
    How we verify it: a test traces each key to its row; a planted approximate row must not be written.
  2. The same policy always compiles to the same bytes.
    How we verify it: compile twice and compare.
  3. With enforcement: warn or off, compile writes nothing restrictive.
    How we verify it: a test compiles in both modes and inspects the files.
  4. When deployed managed settings block a plugin, apm install exits 1, writes nothing and never reports success.
    How we verify it: a test runs the real Claude Code under strict managed settings and checks exit code 1 and no file changes.
  5. In the real harness, compiled files behave as mapped: allowed items load, denied items are refused.
    How we verify it: real-harness tests for allowed, denied, warn and off cases.
  6. Your existing apm-policy.yml behaves exactly as before, and compile never writes a vendor-only key.
    How we verify it: a sweep compares every test policy before and after, and checks emitted keys against the shared list.

Child issues

For contributors and agents

Waves and sizing (CTO). W1 (Claude + Copilot; M), W2 (Codex + Gemini; S-M). Milestone 0.40. Persona: S3 Amara.

Problem (V). Admins hand-write managed settings per vendor. APM never reads them, so in strict orgs apm install can report success for plugins the harness drops (APM's route uses a derived local directory marketplace, V native_plugins/claude_marketplaces.py:296).

Story S3, full output.

$ apm policy compile --vendor claude,copilot -o dist/policy/
[+] dist/policy/claude/managed-settings.json   deniedMcpServers (1)
[i] dist/policy/copilot/managed-settings.json  nothing EQUAL yet (file not written)
[!] not emitted (APM enforces at install only), see dist/policy/UNMAPPED.md:
    mcp.allow -> allowedMcpServers: APPROX (Claude merges user allowlists; the proprietary
      allowManagedMcpServersOnly that would close it is out by the absorb rule)
    marketplace.allow: APPROX until a real-harness cell proves it (APM allows catalog origins;
      Claude/Copilot allow marketplace sources; APM's own installs register a local directory)
    copilot mcp.allow/deny: APPROX (trusted first-party servers exempt)
    dependencies.*, security.*, executables.*: no vendor key
$ apm install foo@random      # laptop with the deployed file
[x] foo@random: marketplace 'random' is not allowed by managed settings (claude). Nothing written.

IT deploys the files (MDM, root, GitHub server-managed). APM never claims to deploy them.

Scope in. Compile from existing keys only. marketplace.allow -> strictKnownMarketplaces starts APPROX (APM matches catalog-origin globs, not marketplace sources) and is promoted to EQUAL per row only when an F1 cell shows an allowed install loading and a disallowed one refused. mcp.deny -> deniedMcpServers (EQUAL on Claude); mcp.allow -> allowedMcpServers is APPROX (user lists can widen it; the closing key is Claude-proprietary). Copilot MCP rows are APPROX and listed. Emitted keys come only from the F0 common-keys set (absorb rule: >= 2 harnesses or a standard: enabledPlugins, extraKnownMarketplaces, strictKnownMarketplaces, mcpServers, allowedMcpServers, deniedMcpServers); vendor-proprietary keys are never emitted. enforcement: warn|off emits nothing restrictive. --check = artifact drift only. Preflight reads deployed managed files via the P1 reader.
Out (0.41). Force-enable, managed-only hooks, "install = enable from org marketplace", marketplace registration (extraKnownMarketplaces); MDM/server reads.

Architecture (CTO). One owner: policy/vendor_map.py rows (apm_key, target, client, vendor_key, transform, semantics EQUAL | NARROWER | WIDER | APPROX, min version, evidence_url). Emitter policy/vendor_compile.py (<= 250 LOC; JSON, TOML). Unmapped lists are derived. Only EQUAL rows emit. Guards: policy.vendor_keys_owner, policy.unmapped_derived, policy.common_keys_only (a row's vendor key must be in the F0 common-keys set). Each row needs a doc and an effective-behavior test.

YAML (additive, optional). Compile reads today's apm-policy.yml keys (V policy/schema.py; enforcement is off | warn | block); no new keys are required and none are renamed. Vendor selection is a CLI flag (--vendor), defaulting to the project's targets, so the policy file stays vendor-neutral.

Promises first.

Promise Oracle Where
P-LAW policy.compile_equal_only: every emitted key traces to an EQUAL row; the rest is listed row trace + seeded APPROX row E01 known cell
P-LAW policy.compile_deterministic I2 E01
P-LAW policy.warn_off_emit_nothing_restrictive FS-DELTA, both modes E01
P-LAW policy.effective_matches_mapping: allowed, denied, warn, off cases behave as mapped in the real harness F1 strict cells expected.json
P-LAW policy.preflight_never_reports_dropped_success O5 exit 1 + O9 empty E07 + F1
P-LAW schema.backward_compatible: every current fixture apm-policy.yml parses to the same effective policy and install outcome parse-and-compare over fixture policies tests/fixtures/ sweep
P-LAW policy.common_keys_only: no emitted key outside the cited common set emitted-key set vs registry E01
E07 "Compile org policy to vendor managed settings" O1, O2 new journey

Related: P-LAW policy.runtime_drop_is_reported (F1 strict cell: exit 1 + no writes) is green-owned by this epic. Mapping semantics spec: #5769 under #3620.

Children, done-when. Existing: #3703 (already a child), #5542, #4935, #5488, #4956, #5644; also listed: #1894, #3227; closed: #1925, #2753, #3224, #3226, #3319, #3369, #3509. New:

  1. Vendor mapping table (Claude, Copilot) with evidence and behavior tests #5758 "Vendor mapping table (Claude, Copilot) with evidence and behavior tests" -- done when each EQUAL row has a passing F1 cell and marketplace.allow has a promotion cell (red until proven).
  2. apm policy compile + --check + UNMAPPED.md #5759 "apm policy compile + --check + UNMAPPED.md" -- done when E07 passes.
  3. Install preflight against deployed managed files #5760 "Install preflight against deployed managed files" -- done when the F1 strict cell flips to refused, exit 1.
  4. Codex + Gemini rows (Codex: allowed_sources with restrict_to_allowed_sources=true) #5761 "Codex + Gemini rows (Codex: allowed_sources with restrict_to_allowed_sources=true)" -- done when W2 rows pass.
  5. Red-first: E07 + policy laws (incl. schema.backward_compatible, common_keys_only) #5762 "Red-first: E07 + policy laws (incl. schema.backward_compatible, common_keys_only)" -- done when rows land failing.

Deps. F0 PR-A, P1 reader, F1 strict cells, F2 child 1 (journey index admits E07).


Epic codes: F0 = #3616, F1 = #5197, F2 = #5509, P1 = #5745, P2 = #3618, P3 = #3297. Evidence markers: V = verified in code at 20bd83d, I = inferred, D = vendor docs.
This epic is a plan. It is not a scope approval: each child needs its own apm-scope:v1 record (CONTRIBUTING).

Sub-issues

Sub-issues

12 of 12 Issues completed
Loading 12 sub-issues

Activity

  1. added
    pillar/govern
    on Nov 12, 2026
  2. moved this from Todo to In Progress in APM Roadmapon Nov 23, 2026
  3. 11 remaining items

  4. changed the title [-][EPIC] Policy compile: one APM policy to each vendor's managed settings, plus install preflight[/-] [+][EPIC] Policy compile: turn one APM policy into each harness's managed settings, and check them before install[/+] on Dec 2, 2026
  5. danielmeppiel commented on Dec 2, 2026

    @danielmeppiel
    CollaboratorAuthor

    Closing as not planned. APM will not translate its policy into harness managed settings. The live policy work (choosing a policy source, enforcement coverage, user scope) continues in #5792.

  6. moved this from In Progress to Done in APM Roadmapon Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pillar/governtrackingtriage/recommended

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions