Repository navigation
[0.38] feat(claude): converge Claude instructions on AGENTS.md - #4005
Conversation
3a7734c to
f616011
Compare
a833161 to
b397d04
Compare
b397d04 to
b2fa03b
Compare
b2fa03b to
4af4d40
Compare
Always-on and single-directory instructions reach Claude Code through the compiled AGENTS.md; every CLAUDE.md APM writes imports @AGENTS.md so both load on every Claude Code version. File-type globs stay in .claude/rules/. Hand-authored root CLAUDE.md without the import (or hand-authored AGENTS.md) keeps the legacy .claude/rules/ layout and warns; user scope is unchanged. Refs #3939 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
4af4d40 to
e46b72c
Compare
A frozen replay of a pre-#3939 lock deleted the always-on .claude/rules/ file Claude now loads from AGENTS.md, then refused because the lock recorded a file missing from disk. --frozen never rewrites the lock, so stale-file cleanup now keeps such files with their lock claim and names them; a normal install migrates them. Re-pin the upgrade and receipt lifecycle cells to the AGENTS.md routing. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Both bundle formats admit unverified live-cache instructions, bypassing source-lock provenance and allowing post-install edits to alter packaged guidance without changing the source lock.
5 open issues
What changed in this PR
This PR brings Claude project instructions onto APM's shared AGENTS.md compilation path, addressing #3939 while retaining native rules for file-type globs and preserving user-authored context files.
Changes:
- Routes always-on and directory instructions into root or nested
AGENTS.md, with importingCLAUDE.mdfiles and explicit compile guidance. - Adds migration handling, frozen-install retention, and bundle rendering for routed instructions.
- Updates architecture guards, regression coverage, conformance records, and migration documentation.
| File | Description |
|---|---|
| tests/unit/scripts/test_architecture_runner.py | Registers the routing guard in the expected inventory. |
| tests/unit/integration/test_instruction_integrator.py | Tests routed instructions and native-rule fallback. |
| tests/unit/install/phases/test_finalize_compile_hint.py | Expects Claude compile guidance. |
| tests/unit/core/test_target_detection_logic.py | Includes Claude in AGENTS compilation. |
| tests/unit/core/test_remediation_w3_deps_compilation_catalog.py | Records executed Claude remediation proofs. |
| tests/unit/compilation/test_token_overhead_opt_in.py | Exercises attribution on importing context files. |
| tests/unit/compilation/test_stale_claude_md_cleanup_1729.py | Updates deduplication and cleanup expectations. |
| tests/unit/compilation/test_project_root_context_protection.py | Updates nested context protection assertions. |
| tests/unit/compilation/test_global_instructions_1072.py | Checks global guidance through imported AGENTS content. |
| tests/unit/compilation/test_compile_target_flag.py | Checks Claude's paired context outputs. |
| tests/unit/compilation/test_compile_no_dedup_flag.py | Tests AGENTS instruction deduplication overrides. |
| tests/unit/compilation/test_compile_cli_surface.py | Updates Claude target classification. |
| tests/unit/compilation/test_compile_clean_last_primitive_2130.py | Keeps cleanup coverage on a path-scoped rule. |
| tests/unit/compilation/test_claude_dependency_roots.py | Uses the new formatter while preserving dependency checks. |
| tests/unit/compilation/test_agents_compiler_coverage.py | Updates instruction and constitution assertions. |
| tests/spec_conformance/test_manifest_reqs.py | Adds Claude post-install compile coverage. |
| tests/spec_conformance/test_lockfile_reqs.py | Preserves dependency-import checks with the new formatter. |
| tests/quality/promise-catalog.json | Adds the Claude routing promise. |
| tests/quality/complexity_baseline.json | Removes the simplified compiler's complexity allowance. |
| tests/lifecycle/scenarios/test_history_upgrade.py | Checks retirement of legacy Claude rules. |
| tests/lifecycle/journeys/goldens/J03/02.txt | Adds frozen-install compile guidance. |
| tests/lifecycle/journeys/goldens/J02/03.txt | Updates the deployed-file scan count. |
| tests/lifecycle/journeys/goldens/J02/02.txt | Updates frozen-install output. |
| tests/lifecycle/journeys/goldens/J01/06.txt | Adds reinstall compile guidance. |
| tests/lifecycle/journeys/goldens/J01/04.txt | Updates deployment counts and compile guidance. |
| tests/integration/test_user_authored_name_collision_lifecycle.py | Keeps collision coverage on a native rule. |
| tests/integration/test_unquoted_lockfile_version_lifecycle.py | Uses a path-scoped deployment fixture. |
| tests/integration/test_unicode_space_paths_lifecycle.py | Preserves native-rule path coverage. |
| tests/integration/test_target_manifest_upgrade_lifecycle.py | Accounts for routed-rule retirement during upgrades. |
| tests/integration/test_required_lifecycle_state_machine.py | Parameterizes scope for deployment-sensitive scenarios. |
| tests/integration/test_remediation_advice_lifecycle.py | Adds blocker and single-file remediation scenarios. |
| tests/integration/test_prune_deployment_ledger_e2e.py | Preserves per-package native-rule ledger coverage. |
| tests/integration/test_project_self_audit_lifecycle.py | Keeps audit assertions on deployed rules. |
| tests/integration/test_lock_e2e.py | Parameterizes instruction scope for lock coverage. |
| tests/integration/test_local_single_file_matrix.py | Uses a file-type glob for Claude deployment checks. |
| tests/integration/test_local_install.py | Updates native-rule fixtures across install scenarios. |
| tests/integration/test_legacy_lock_upgrade_lifecycle.py | Checks frozen retention and normal migration. |
| tests/integration/test_global_claude_dedup_lifecycle.py | Checks project AGENTS content separately from user rules. |
| tests/integration/test_frozen_dropped_target_lifecycle.py | Keeps dropped-target coverage on native rules. |
| tests/integration/test_frozen_deployed_hash_lifecycle.py | Moves integrity checks to a path-scoped rule. |
| tests/integration/test_file_primitive_receipt_lifecycle.py | Preserves instruction deployment receipt coverage. |
| tests/integration/test_drift_check.py | Tests routing replay against live project blockers. |
| tests/integration/test_config_surface_lifecycle_contract.py | Updates deployment-sensitive configuration fixtures. |
| tests/integration/test_compile_nested_context_protection_lifecycle.py | Checks nested imports and user-file protection. |
| tests/integration/test_compile_clean_nested_worktree.py | Checks imported content and worktree exclusion. |
| tests/integration/test_compile_claude_single_h1.py | Checks headings across paired context files. |
| tests/integration/test_cleanup_deployment_evidence_lifecycle.py | Retains dropped-target cleanup evidence coverage. |
| tests/integration/test_claude_dependency_import_lifecycle.py | Separates AGENTS imports from dependency imports. |
| tests/integration/test_claude_agents_md_pack_lifecycle.py | Adds bundle preservation and target-selection scenarios. |
| tests/integration/test_claude_agents_md_lifecycle.py | Adds routing, compile-hint, and opt-in lifecycle tests. |
| tests/integration/test_case_only_rename_lifecycle.py | Keeps rename coverage on a deployed rule. |
| tests/integration/test_architecture_owner_rule_mutations.py | Adds routing and blocker bypass mutations. |
| src/apm_cli/integration/instruction_integrator.py | Filters routed sources and exposes legacy rule rendering. |
| src/apm_cli/integration/cleanup.py | Adds rendered evidence for retiring legacy rules. |
| src/apm_cli/install/service.py | Defines frozen stale-file retention. |
| src/apm_cli/install/phases/finalize.py | Emits compile hints for Claude routed instructions. |
| src/apm_cli/install/phases/cleanup.py | Retains stale locked files during frozen installs. |
| src/apm_cli/core/target_detection.py | Makes Claude an AGENTS consumer. |
| src/apm_cli/core/remediation.py | Adds Claude migration remediation entries. |
| src/apm_cli/core/command_logger.py | Reports frozen stale-file retention. |
| src/apm_cli/compilation/claude_formatter.py | Generates importing CLAUDE files instead of instruction copies. |
| src/apm_cli/compilation/claude_agents_md.py | Centralizes routing, blockers, placement, and deduplication. |
| src/apm_cli/compilation/agents_compiler.py | Connects AGENTS outputs to Claude imports. |
| src/apm_cli/commands/compile/cli.py | Updates deduplication override help. |
| src/apm_cli/bundle/plugin_exporter.py | Adds routed instructions to plugin bundles. |
| src/apm_cli/bundle/packer.py | Adds rendered rules and bundle lockfile claims. |
| src/apm_cli/bundle/claude_routed_rules.py | Selects and writes routed rules for packing. |
| scripts/architecture_linter/checks/registry_module_ownership.py | Tightens the unowned-module ceiling. |
| scripts/architecture_linter/checks/install_deployment_analyzers.py | Registers the Claude routing analyzer. |
| scripts/architecture_linter/checks/install_claude_agents_md_routing.py | Guards routing ownership and consumer calls. |
| packages/apm-guide/.apm/skills/apm-usage/workflow.md | Lists the paired Claude context artifacts. |
| packages/apm-guide/.apm/skills/apm-usage/commands.md | Documents routing, compilation, and migration behavior. |
| docs/src/content/docs/reference/targets-matrix.md | Updates Claude outputs and compile requirements. |
| docs/src/content/docs/reference/cli/compile.md | Documents imported context and deduplication behavior. |
| docs/src/content/docs/producer/write-primitives.md | Explains Claude instruction destinations. |
| docs/src/content/docs/consumer/update-and-refresh.mdx | Adds the Claude migration procedure and caveats. |
| docs/src/content/docs/consumer/choose-harnesses.mdx | Updates the Claude output example. |
| CONFORMANCE.md | Updates compile-guidance coverage counts. |
| CONFORMANCE.json | Records the new conformance test. |
| CHANGELOG.md | Adds the Claude upgrade note. |
| .apm/architecture/unowned-modules.json | Removes the newly owned Claude formatter. |
| .apm/architecture/owners/install-deployment.json | Registers the Claude instruction-routing owner. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical issues allow missing dependency caches to bypass locked-instruction verification and invalid managed-section layouts to leave routed guidance undelivered.
8 open issues
Validate managed-section markers before routing instructions Pack projection includes instructions outside the admitted source plan Redirected compile checks source placements in the output root · New Failed AGENTS.md writes can leave dangling Claude shims · New Scope changes evade compiled-guidance coverage checks · New Cache compiled coverage per path during installation Missing dependency checkout bypasses locked-source verification Link rewriting causes unchanged instructions to appear stale
Review effort: Balanced
|
PGM: refreshing merge ref after main-red fix #4777 (no head change). |
c02224d
into
main
…SOURCE instruction #4005 routes Claude '**' instructions to AGENTS.md through compile, so the M-SOURCE instruction uses a file-type glob (as test_file_routing does on main) and keeps a per-file rule on every deployed target the other-file oracle checks. The user-scope native-plugin row reports ~/.claude and the install output when Claude settings are missing. Co-authored-by: Copilot App <[email protected]>
…ew (#4787) - pack renders routed rules only from sources the canonical deployment source plan admits (item 1); - compile records each routed instruction's scope and body fingerprint per AGENTS.md (with the file digest); install compares it through one CompiledCoverage per root, so link rewriting stays quiet and applyTo or body edits remind (items 2, 4, 7); - managed_section mode validates its markers through the managed-section owner before the route opens (item 3); - compile --root checks directory placements under the source root (item 5); - AGENTS.md outputs are recorded only once written, and no CLAUDE.md shim is written after a failed AGENTS.md batch (item 6). Co-authored-by: Copilot App <[email protected]>
…4005) A '**' instruction under targets: [claude] never becomes a .claude rule; install asks for apm compile, which writes it to AGENTS.md beside a CLAUDE.md importing @AGENTS.md (P-OWN-claude-agents-md-instruction-routing). Co-authored-by: Copilot App <[email protected]>
…low #4005 Co-authored-by: Copilot App <[email protected]>
…t instruction #4805 makes compile record which routed instructions each Claude AGENTS.md carries under APM home (.apm/compiled-agents-md, core/agents_md_compile_record.py), so nothing new lands in the repository. I5 now admits that one prefix for a non-read-only compile only. A dry-run compile, and every other command, stays forbidden from writing it. Fixes test_claude_routes_an_always_on_instruction_to_agents_md. On main d8b37cb (#4805), the kit packages' '**' instruction no longer reaches .claude/rules for Claude in the M-SOURCE context pass. That is the #4005 contract (always-on guidance routes to AGENTS.md through compile), so the spine's rule-evidence oracle was stale for an always-on instruction. The kit instruction is now path-scoped ('**/*.py'), like M-SOURCE's own packages, so .claude/rules/<pkg>.md stays a deterministic, strictly checked destination; test_file_routing covers the '**' route. Fixes test_source_spine_covers_every_form_and_op. Co-authored-by: Copilot App <[email protected]>
…4005 review (microsoft#4787) Co-authored-by: Copilot App <[email protected]>
test(lifecycle): J08/J09 follow #4005 (Claude instructions converge on AGENTS.md)
…onverge on AGENTS.md) microsoft#4005 stopped deploying .claude/rules/<name>.md, so prune and a dropped claude target no longer clean it: J08 step 3 cleans 3 paths and prints the compile hint, J09 step 3 cleans 1. Nightly dispatch 45068563849 (main 76be7b6) failed both journeys on all three OSes at step 3. Co-authored-by: Copilot App <[email protected]> (cherry picked from commit f32346b)


Description
feat(claude): converge Claude instructions on AGENTS.md
TL;DR. The Claude target now gets always-on (
applyTo: "**"or none) and single-directory (src/test/**) instructions through the same root and nestedAGENTS.mdthat Copilot and Codex get; file-type globs stay in.claude/rules/withpaths:. EveryCLAUDE.mdAPM writes imports@AGENTS.md, so both load on every Claude Code version. Existing users are never broken: a hand-authoredCLAUDE.mdwithout the import keeps the old.claude/rules/layout and gets a one-line fix hint, and APM never overwrites user files.Issue and approved scope
Issue: Fixes #3939
Human scope-approval comment: #3939 (comment) (
apm-scope:v1, review contact Daniel Meppiel (@danielmeppiel);scripts/governance/eligibility.cjs→record-present).Completes the issue: lifecycle tests for root + nested
AGENTS.mdand the@AGENTS.mdimport, unchanged file-type rules, upgrade note, compile/target docs, apm-usage skill, one CHANGELOG line. Out of scope (per record) and untouched: new primitives/frontmatter, other targets' output,CLAUDE.local.md.Problem (WHY)
AGENTS.mdnatively since v2.1.277, but the official memory docs say "By default, Claude readsAGENTS.mdonly when you have noCLAUDE.mdin your working directory or above it", and recommend "putting an@AGENTS.mdimport in aCLAUDE.mdnext to it" otherwise..claude/rules/, so always-on and directory guidance behaved differently on Claude than on every other harness (Let authors target native context files (root or nested CLAUDE.md/AGENTS.md), not just .claude/rules #1807).AGENTS.mdloads natively only while no rootCLAUDE.mdcounts, so once APM writes a rootCLAUDE.md, nestedAGENTS.mdneeds its own importingCLAUDE.md.CLAUDE.mdonly — the import is the only path that works everywhere.Approach (WHAT)
applyTo**/**/*.claude/rules/<n>.md(unconditional)AGENTS.mdsrc/test/**,docs/**/*.claude/rules/<n>.md(paths:)<dir>/AGENTS.md— pinned, never hoisted (stays in.claude/rules/if the dir is missing or the project issingle-file)**/*.py,src/**/*.py.claude/rules/<n>.md(paths:)CLAUDE.md@AGENTS.md+ dependency@imports(constitution only as fallback)CLAUDE.md@AGENTS.mdnext to each generated nestedAGENTS.mdSafety rails (the migration contract):
CLAUDE.mdthat does not import@AGENTS.md, or a hand-authored rootAGENTS.mdAPM may not write into (nomanaged_section), keeps every instruction in.claude/rules/(old behavior) and warns once with the fix (add '@AGENTS.md' to CLAUDE.md).CLAUDE.mdthat already imports@AGENTS.mdis left alone silently. APM never overwrites hand-authored files (existing protection owner unchanged).-g,~/.claude) is unchanged — Claude does not read~/AGENTS.md.<dir>/AGENTS.md, even where the shared optimizer would hoist it to the root;--single-agentsleaves directory instructions out of the root file with a warning..apm/ones included) that no compiledAGENTS.mdcarries yet, it printsRun 'apm compile' to update AGENTS.md / CLAUDE.md.; a no-op reinstall after compile stays quiet, and an edited routed instruction asks again.apm pack --format apmkeeps shipping them: APM-format bundles carry deployed files and their consumers do not compile, so the pack renders each routed Claude instruction as.claude/rules/<n>.mdthrough the install projection (InstructionIntegrator.render_agents_md_routed_rules) and records it in the bundle lockfile viaDeploymentLedgerCodec; bytes equal a legacy-layout install's (tests/integration/test_claude_agents_md_pack_lifecycle.py, fails on4b2eeed2). Bundle consumers converging on AGENTS.md is Bundle installs keep the legacy .claude/rules layout instead of converging on AGENTS.md #4034.instructions/<n>.md(bytes equal the legacy layout's; before this, a dependency whose only content was a routed instruction madeapm packrefuse with a stale-install error). Claude is active only when the producer's install resolves it (targets:inapm.yml, else harness detection), never from the folder-detected pack target, so atargets: [copilot]producer with a stray.claude/ships no Claude rules. A recorded Claude deployment in the lockfile wins (coversinstall --target claudeon a.claude/+.cursor/project withouttargets:); with no record and ambiguous folders, pack prints[!] Skipped N Claude rule(s)...with the fix instead of dropping them silently (test_claude_agents_md_pack_lifecycle.py; both new cases fail on3221f0e8)..claude/rules/<n>.mdfromAGENTS.md(no double context; an edited rule that install kept stays authoritative). Multi-target compiles keep the sharedAGENTS.mdcomplete, as before.Implementation (HOW)
compilation/claude_agents_md.py(new)routes_to_agents_md(applyTo, project_root)(classifier + directory exists / not single-file),directory_scope,pin_directory_placements,without_directory_instructions,claude_agents_md_blocker(hand-authored root files, with the matching fix text),@AGENTS.mdimport detection, Claude-only rule dedup.integration/instruction_integrator.py_claude_rule_sourcesfilters.claude/rules/sources at project scope and records routed sources (agents_md_routed); routing and blocker read the live project root (drift replay passes a scratch root viadeployment_frame).compilation/agents_compiler.pyAGENTS.mdpaths;_compile_claude_mdnow emits@AGENTS.mdshims, keeps the protection/--cleanpaths, warns when a protectedCLAUDE.mdlacks the import. Net −50 lines (file stays under the 2100 guard).compilation/claude_formatter.pyformat_agents_md_importsreplaces the instruction-carryingformat_distributed.core/target_detection.py,install/phases/finalize.py,commands/compile/cli.pyshould_compile_agents_md("claude"); post-install compile hint fires for Claude dependency instructions and whenever install routed any instruction (local included);--force-instructionshelp text..apm/architecture/owners/install-deployment.json,scripts/architecture_linter/checks/install_claude_agents_md_routing.pyinstall-deployment-claude-agents-md-routing): owner functions defined once; install filter must be exactlyroutes_to_agents_md(applyTo, live_root)(catches... or True); compile must call the pin / single-file / shim helpers. Two mutation cases.Diagrams
Where one instruction lands for a Claude project after
apm install && apm compile:flowchart LR I["instruction applyTo"] --> R{"routes_to_agents_md"} R -->|"file-type glob"| RULES[".claude/rules/name.md (paths:)"] R -->|"** or one literal dir"| B{"claude_agents_md_blocker"} B -->|"hand-authored CLAUDE.md without import"| RULES B -->|"clear"| A["root or nested AGENTS.md"] A --> C["CLAUDE.md beside it: @AGENTS.md"]Decision for Daniel: multi-target placement trade-off
[claude, copilot]/[claude, codex]projects the sharedAGENTS.mdkeeps the optimizer's placement, so a directory (or file-type) instruction can be hoisted into the rootAGENTS.mdthat the rootCLAUDE.mdimports and load in every Claude session; withcompilation.strategy: single-filea directory instruction is also kept in.claude/rules/, so it appears twice.AGENTS.mdoutput, which the approved record excludes; this PR pins only Claude-only compiles and documents the multi-target behavior (compile docs, targets matrix, migration note).<dir>/AGENTS.mdeven in multi-target compiles, changing Copilot/Codex placement; (3) keep directory (and file-type) rules in.claude/rules/and out of the imported scope when the project is multi-target.Trade-offs
AGENTS.mdkeeps the optimizer's placement (other targets' output unchanged), so Claude reads it exactly as Codex does.src/**/*.py) stay path-scoped rules so their scope is never widened to a whole folder.apm compile; the post-install hint and the upgrade note cover it. Rejected: auto-compiling during install (compile stays explicit).CLAUDE.mdis written wheneverAGENTS.mdis, even on 2.1.277+ where it is redundant — required for older versions and for nested files (see Problem).claude+ others) keeps the sharedAGENTS.mdcomplete, so file-type instructions also appear always-on for Claude there; avoiding that would change other targets' output (out of scope)..claude/rules/layout (no loss; follow-up candidate).Benefits
AGENTS.mdon Claude, Copilot, Codex: one artifact to review and commit.CLAUDE.mdsee no behavior change until they add one import line.Validation
Lint chain (CI mirror)
Tests
Note
Pre-existing flake (not this PR): Build & Test Shard 1 job
136029540890failedtests/unit/scripts/test_architecture_skill_layout_guard.py::test_audit_targets_must_recover_the_recorded_layoutwithcannot inventory repository: ... apm_modules/_local/autopilot-pr-triage-scheduler/... No such file— a repo-rootapm_modulesfile vanishing mid-run. It passes locally and on rerun; none of this PR's new or changed tests touch the repository root (all usetmp_path), and the production changes only readapm.yml/CLAUDE.md/AGENTS.md.Updated tests (intended behavior change)
Each test below asserted the pre-#3939 layout for an
applyTo: "**"/ directory instruction on Claude. None was weakened: either the fixture became path-scoped so the original.claude/rules/assertion still runs, or the assertion now checks the newAGENTS.md/@AGENTS.mdpaths.Per-test decision
test_project_self_audit_lifecycle,test_required_lifecycle_state_machine(lock-provenance, mixed-primitives),test_lock_e2econtraction,test_local_install(#714 root primitives, four-hyphen, multi-target preflight),test_config_surface_lifecycle_contract(saved / unset target),test_case_only_rename_lifecycle,test_unicode_space_paths_lifecycle,test_unquoted_lockfile_version_lifecycle,test_local_single_file_matrix(Claude),test_drift_checkb7/d1/d2**/*.md,src/**/*.py, …) so the test keeps observing a.claude/rules/deployment; assertions unchanged.test_user_authored_name_collision_lifecycle--forcecollision now seeded on the path-scopedpy.md(the global instruction no longer targets.claude/rules/global.md); user files still byte-checked at every step.test_compile_nested_context_protection_lifecycledocs/AGENTS.mdstill protected; nodocs/CLAUDE.mdwrite is attempted while it is hand-authored; after hand-back,docs/CLAUDE.mdis protected and the compile warns to add@AGENTS.md; newsrc/CLAUDE.mdimport check.test_claude_dependency_import_lifecycleCLAUDE.mdimports@AGENTS.md; dependency-import resolution checks unchanged for the remaining imports.test_global_claude_dedup_lifecycle::test_project_and_global_native_rules_do_not_cross_scopeAGENTS.md(imported byCLAUDE.md); user scope keeps native rules; cross-scope byte checks unchanged.test_prune_deployment_ledger_e2e.claude/rules/ledger row; prune/ledger assertions unchanged.test_compile_claude_single_h1,test_compile_clean_nested_worktreeAGENTS.md;CLAUDE.mdasserted to import@AGENTS.md(single H1 kept).test_target_manifest_upgrade_lifecycle.claude/rules/files (computed withroutes_to_agents_md) leave on first install; nothing changes after.test_drift_check::test_d4_claude_agents_md_routing_replays_clean[False/True]CLAUDE.md(fails if the blocker reads the scratch root).Note
Pre-existing gap surfaced (not changed here): local
.apm/content that deploys no file (hooks-only, and now Claude projects whose own instructions are all always-on) writes noapm.lock.yaml, soapm audit --ciskips drift replay for merged root hooks.test_drift_check::b7keeps its intent with a path-scoped rule; the gap is flagged for a follow-up.Scenario evidence
AGENTS.md,@AGENTS.mdimports, file-type rule not duplicatedtests/unit/compilation/test_claude_agents_md.py::TestCompileShims::test_root_and_nested_agents_md_with_claude_importstest_claude_agents_md.py::TestInstallRoutingCLAUDE.mdblocks routing, warns once, never overwrittenTestInstallRouting::test_blocked_project_keeps_every_rule_and_warns_once,TestCompileShims::test_hand_authored_claude_md_without_import_warnsTestInstallRouting::test_replay_reads_blocker_from_live_project,tests/integration/test_drift_check.py::test_d4_*TestCompileShims::test_widely_matching_directory_glob_is_pinned_not_hoisted,test_single_file_compile_keeps_directory_rules_out_of_root,TestInstallRouting::test_directory_rule_stays_when_directory_is_missing,test_single_file_project_keeps_directory_ruletests/unit/install/phases/test_finalize_user_compile.py::test_hint_fired_for_local_claude_instructions_routed_to_agents_mdtargets: [claude]with**,src/**(hoist-prone tree),**/*.py→ hint, root +src/AGENTS.md,@AGENTS.mdshims,py.mdunchanged; hand-authoredCLAUDE.mdopt-intests/integration/test_claude_agents_md_lifecycle.py--force-instructionsputs every instruction inAGENTS.mdtests/unit/compilation/test_compile_no_dedup_flag.py.claude/rules/style.mdretired, edited rule kept with warningManual upgrade check: project installed with
origin/main, thenapm install+apm compileon this branch →style.md(applyTo: "**") retired,AGENTS.md+CLAUDE.md(@AGENTS.md) written,python.md(**/*.py) unchanged; an editedstyle.mdis kept (Kept user-edited file .claude/rules/style.md) and compile leaves that instruction out ofAGENTS.md.How to test
.claude/,apm.ymlwithtargets: [claude], three.apm/instructions(**,src/test/**,**/*.py), files undersrc/test/andsrc/app/.apm install→ only.claude/rules/python.md.apm compile→AGENTS.md,src/test/AGENTS.md, and aCLAUDE.mdbeside each containing@AGENTS.md.CLAUDE.mdwith# notes, rerunapm install→ one warning, all three rules back in.claude/rules/,CLAUDE.mduntouched.Frozen replay of a pre-#3939 lock (fixed in 70b0a74)
apm install --frozenon a project whose lock still records an always-on.claude/rules/<n>.mddeleted it (it now routes to AGENTS.md) and then refused: the lock recorded a file missing from disk.--frozennever rewrites the lock, so stale-file cleanup now keeps such files with their lock claim (FrozenDisposition.retain_stale_files) and printsLeft N file(s) recorded in apm.lock.yaml that this APM version no longer deploys, because --frozen does not change apm.lock.yaml: ... Run 'apm install' to re-render them for this version.A normal install migrates them.test_legacy_lock_upgrade_lifecycle.py::test_c4_frozen_install_of_untouched_pre036_project_writes_nothing(fails before: exit 1 after deleting the rule).Landing order
Type of change
Testing
origin/main)Changelog
## [Unreleased](upgrade notes, bottom of section).Spec conformance (OpenAPM v0.1)
req-tg-007delegates target classification to the companion targets matrix, which now listsclaudeas requiring post-install compilation.Docs re-home after #3996 (done)
Rebased onto v0.37.0 (
2e01e131); the docs commit now targets #3996's layout:producer/compile.md(Claude routing note,clauderow)producer/write-primitives.md(one paragraph),consumer/choose-harnesses.mdx(Claude tab listsAGENTS.md+CLAUDE.md, since the sample package'sdesign-standardsisapplyTo: "**"),reference/cli/compile.md(unchanged paragraph)troubleshooting/migration.md(upgrade note)consumer/update-and-refresh.mdx, section "Claude: instructions move to AGENTS.md (0.38)";reference/targets-matrix.mdlinks to itconsumer/install-packages.mdqualifierTests added on main by the 0.37 stack that encode the old routing were moved to a path-scoped instruction, with the same assertions:
test_compile_clean_last_primitive_2130.py::test_claude_native_rules_compile_reports_onceandtest_frozen_deployed_hash_lifecycle.py(.claude/rules/global.md->.claude/rules/py.md).Co-authored-by: Copilot [email protected]