Repository navigation
fix(policy): accept plural targets key in compilation-target check - #3739
Closed
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
Closed
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
Conversation
6 of 12 tasks
Collaborator
|
Thank you Mohammed Alkindi (@MohammedAlkindi) for picking up #3732 and for the clear tests. While tracing the issue we found the same root cause behind a few sibling bugs (CSV values, the Your five plural-key tests are ported into #3774 as audit-level tests, and the commits carry a |
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 17, 2026
) * fix(policy): judge compilation-target on the canonical target set apm audit read only the singular `target:` key, so a manifest using plural `targets:` passed compilation-target policy whatever it listed (#3732). Audit and every install seam now hand the check the EffectiveTargetDecision.canonical_targets projection, and the policy parser canonicalizes compilation.target.allow/enforce through the same owner: - plural `targets:` is judged in audit, matching the install gate; - CSV `target: "claude,copilot"` is split instead of failing as one token; - aliases compare as the profile they deploy (vscode/agents -> copilot, agy -> antigravity, intellij -> copilot) on both sides; - `target: all` is judged as its install expansion; `targets: [all]` stays omitted; `all` in an allow list means unrestricted; - inherited alias allow lists no longer intersect to "allow nothing". normalize_policy_targets is folded into EffectiveTargetDecision and a new registry-delegation-policy-target-projection guard keeps every compilation-target seam on that projection. Fixes #3732. Supersedes #3739 and reuses its plural-key tests. apm-spec-waiver: compilation-target policy evaluation is APM policy behavior; OpenAPM v0.1 does not specify it Co-authored-by: Mohammed Alkindi <[email protected]> Co-authored-by: Copilot App <[email protected]> * docs(changelog): compilation-target policy fix (#3774) Co-authored-by: Mohammed Alkindi <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(arch): register policy-target-projection rule and pin local bundle Add registry_delegation.policy_target_projection to the frozen rule inventory so test_registered_rule_inventory_matches_frozen_semantic_contract matches the registered rules (Build & Test Shard 2 was red). Add the local-bundle install seam to the policy-target projection mutation test, and scope each case's assertion to a violation in the mutated file so an unrelated violation elsewhere cannot satisfy it. Mutation-break: dropping run_policy_preflight from the guard's seams fails the new case. Addresses panel follow-ups 1 and 3 on #3774. Co-authored-by: Copilot App <[email protected]> * docs(governance): state that target enforce takes precedence over allow The install guarantees said the selection matches both compilation.target.allow and compilation.target.enforce, but the check evaluates enforce first and skips allow when enforce is set, as the policy reference already documents. Addresses Copilot inline review on governance-guide.md:311 and panel follow-up 2 on #3774. Co-authored-by: Copilot App <[email protected]> * chore(changelog): place #3774 entry away from the section head Avoids landing-order conflicts with other queued PRs. Co-authored-by: Copilot App <[email protected]> * Merge main (82f8047) into #3774; slot CHANGELOG bullet Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Mohammed Alkindi <[email protected]> Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 18, 2026
…er (#3791) * fix(policy): judge compilation-target on the canonical target set apm audit read only the singular `target:` key, so a manifest using plural `targets:` passed compilation-target policy whatever it listed (#3732). Audit and every install seam now hand the check the EffectiveTargetDecision.canonical_targets projection, and the policy parser canonicalizes compilation.target.allow/enforce through the same owner: - plural `targets:` is judged in audit, matching the install gate; - CSV `target: "claude,copilot"` is split instead of failing as one token; - aliases compare as the profile they deploy (vscode/agents -> copilot, agy -> antigravity, intellij -> copilot) on both sides; - `target: all` is judged as its install expansion; `targets: [all]` stays omitted; `all` in an allow list means unrestricted; - inherited alias allow lists no longer intersect to "allow nothing". normalize_policy_targets is folded into EffectiveTargetDecision and a new registry-delegation-policy-target-projection guard keeps every compilation-target seam on that projection. Fixes #3732. Supersedes #3739 and reuses its plural-key tests. apm-spec-waiver: compilation-target policy evaluation is APM policy behavior; OpenAPM v0.1 does not specify it Co-authored-by: Mohammed Alkindi <[email protected]> Co-authored-by: Copilot App <[email protected]> * docs(changelog): compilation-target policy fix (#3774) Co-authored-by: Mohammed Alkindi <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(arch): register policy-target-projection rule and pin local bundle Add registry_delegation.policy_target_projection to the frozen rule inventory so test_registered_rule_inventory_matches_frozen_semantic_contract matches the registered rules (Build & Test Shard 2 was red). Add the local-bundle install seam to the policy-target projection mutation test, and scope each case's assertion to a violation in the mutated file so an unrelated violation elsewhere cannot satisfy it. Mutation-break: dropping run_policy_preflight from the guard's seams fails the new case. Addresses panel follow-ups 1 and 3 on #3774. Co-authored-by: Copilot App <[email protected]> * docs(governance): state that target enforce takes precedence over allow The install guarantees said the selection matches both compilation.target.allow and compilation.target.enforce, but the check evaluates enforce first and skips allow when enforce is set, as the policy reference already documents. Addresses Copilot inline review on governance-guide.md:311 and panel follow-up 2 on #3774. Co-authored-by: Copilot App <[email protected]> * refactor(targets): route every manifest target reader through one owner Package-level `target:` / `targets:` is now read only through ManifestTargetDeclaration (models/manifest_targets.py), exposed as APMPackage.target_declaration, package_target_declaration(), read_manifest_target_declaration() and manifest_target_restriction(). Compile, the install targets phase, MCP/LSP integration, lockfile reconciliation, the build orchestrator, the audit target hint, the package-target filter and init re-init no longer re-read or re-parse the raw keys. - `apm install` rejects `target: intellij` / `copilot-app` before writing anything (it used to deploy files and a lockfile, then exit 2). - singular `target: all` no longer prints "treating the field as omitted" while install expands it; `apm init` re-init writes its expansion instead of narrowing it to `targets: [all]`. - docs: `compilation.target` is documented as ignored by `apm compile`. The registry-delegation-target-vocabulary rule is widened to deny-by-default over src/apm_cli with concept-named exemptions, and a new manifest-target-declaration owner record registers its guard. Refs #3732 apm-spec-waiver: routes existing manifest target readers through one owner; OpenAPM-observable acceptance is unchanged Co-authored-by: Copilot App <[email protected]> * docs(changelog): manifest target declaration owner (#3791) Co-authored-by: Copilot App <[email protected]> * fix(architecture): scope target exemptions to the marked statement The deny-by-default target guard let an exemption marker cover a whole block (marker above an if/for/try exempted its body) and the line after a trailing marker, so a raw package.targets read placed inside an exempted block went unflagged. A marker now covers only the innermost statement holding the read (its header for compound statements) or sits alone on the line directly above it. The guard also flags .pop/.setdefault on the target keys. Existing init and compilation.target exemptions are marked per statement. Mutation cases cover a read leaking out of an exempt block, a trailing-marker leak, and the subscript, key-test and pop shapes. Addresses panel follow-up 2 (test-coverage-expert, python-architect) on #3791. apm-spec-waiver: architecture guard and exemption markers only; no OpenAPM-observable behavior change Co-authored-by: Copilot App <[email protected]> * fix(targets): route compile -g and disk readers through the declaration owner apm compile -g still re-read ~/.apm/apm.yml with its own parser and, for target: all, printed the "treating the field as omitted" warning that install no longer prints. read_manifest_target_declaration is now the one disk reader (strict: refuses symlinks, empty and non-mapping documents; lenient: returns None), and compile -g, audit's read_manifest_target and install's declared_target_profiles go through it. read_declared_target_names is removed; restriction() gains allow_empty_singular for strict readers. The pre-write rejection moves into reject_undeployable_manifest_targets (keeps install/pipeline.py under its LOC budget) and also runs before the CLI renames a legacy apm.lock, so a rejected install writes nothing. Re-init expands singular target: all with the install spellings, so vscode keeps its .vscode/mcp.json destination instead of becoming copilot (.github/mcp.json). Tests: e2e for compile -g without the warning, -g pre-write rejection, legacy lockfile untouched on rejection, and the MCP destination after re-init; unit tests for the strict/lenient reader; drift tests patch the owner's parser. Addresses panel follow-ups 1 and 3 and Copilot inline comments on src/apm_cli/install/pipeline.py:443 and src/apm_cli/models/manifest_targets.py:155. apm-spec-waiver: routes existing manifest target readers through one owner; OpenAPM-observable acceptance is unchanged Co-authored-by: Copilot App <[email protected]> * fix(targets): close delta-panel gaps in exemption scope and strict reads A marker on a block's first body line still exempted raw reads in the enclosing if/for/with header, because comment lines between a header and its body counted as header lines. Those lines now belong to the body, and match blocks end their header at the first case. compile -g silently compiled every harness for singular target: all,<x>, which install -g rejects; restriction(strict=True) (renamed from allow_empty_singular) now raises the same "all cannot be combined" error. A direct run_install_pipeline test pins the pipeline's own pre-write gate, which the CLI's earlier call otherwise hides. Addresses delta panel findings (python-architect, test-coverage-expert) on #3791. apm-spec-waiver: routes existing manifest target readers through one owner; OpenAPM-observable acceptance is unchanged Co-authored-by: Copilot App <[email protected]> * chore(changelog): place #3774 entry away from the section head Avoids landing-order conflicts with other queued PRs. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Mohammed Alkindi <[email protected]> Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The compilation target policy check read only the singular target key from apm.yml. Manifests declaring targets using the plural targets key were reported as having no target configured, skipping policy enforcement. The check now reads targets when present, falling back to target.
Issue and approved scope
Issue: Fixes #3732
Human scope-approval comment: #3732
Does this PR complete the issue, or what remains? Completes the issue.
Type of change
Testing
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.