Repository navigation
fix(manifest): extract the bootstrap manifest owner; refuse IDE targets in apm.yml - #3882
Conversation
…ts in apm.yml #3879: move the bootstrap manifest writer (bootstrap_config, write_minimal_manifest, auto_detect_description) into models/manifest_bootstrap.py, and move the orphan, gitignore, console and InstallContext helpers below the commands layer, so src/apm_cli/install/** no longer imports apm_cli.commands. Behaviour is byte-identical; commands keep the historical names as re-exports. New guard registry_delegation.install_layering fails if an install import resolves into apm_cli.commands or a second bootstrap writer appears. #3878: `intellij` is an IDE, not a target. Every apm.yml-writing path (package bootstrap, `apm init --target`, `apm install -g --mcp` bootstrap) now refuses it before any write, via option_target_names / bootstrap_target_names in the declaration owner (models/manifest_targets.py). core/target_detection.manifest_targets_from_target_option is removed, and a guard forbids it returning. JetBrains MCP config still deploys with `--target intellij` when apm.yml already exists. Fixes #3878 Fixes #3879 apm-spec-waiver: internal owner extraction plus IDE-token refusal at bootstrap; no OpenAPM normative surface changes Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
IntelliJ refusals still create directories despite claiming no writes, the global MCP refusal exits 2 instead of 1, and plain or aliased imports bypass the dependency guard.
4 open issues
What changed in this PR
This PR addresses #3878 and #3879 by centralizing bootstrap manifest creation below the commands layer and rejecting IntelliJ as a persisted manifest target, while retaining existing-manifest JetBrains MCP support.
Changes:
- Extracts bootstrap writing and shared install helpers into lower-level modules, retaining compatibility re-exports.
- Routes init and bootstrap target selection through the manifest-target owner with IDE-specific refusal guidance.
- Adds architecture guards and regression coverage, updates mock locations, and documents the behavior.
| File | Description |
|---|---|
| tests/unit/test_prune_casing.py | Updates materialization-reader mock locations. |
| tests/unit/test_init_phase3w5.py | Tests IDE refusal and updates description mocks. |
| tests/unit/test_init_command_selection.py | Updates description-detection mock locations. |
| tests/unit/scripts/test_architecture_runner.py | Registers the layering rule in the expected inventory. |
| tests/unit/models/test_manifest_targets.py | Tests IDE refusal and guidance. |
| tests/unit/install/test_update_remediation_hints.py | Updates the gitignore helper mock. |
| tests/unit/install/test_local_edit_hint.py | Updates the gitignore helper mock. |
| tests/unit/install/test_gitignore_scope_guard.py | Updates the gitignore helper mock. |
| tests/unit/install/test_finalize_phase.py | Patches success output at its new lookup location. |
| tests/unit/core/test_target_resolution_v2.py | Tests the replacement target-mapping owner. |
| tests/unit/commands/test_helpers_version.py | Resets the relocated console cache. |
| tests/unit/commands/test_helpers_coverage.py | Updates console and gitignore mocks. |
| tests/integration/test_ide_target_refusal_lifecycle.py | Adds installed-CLI refusal and compatibility coverage. |
| tests/integration/test_global_mcp_bootstrap_targets_lifecycle.py | Checks revised global MCP refusal guidance. |
| tests/integration/test_architecture_owner_rule_mutations.py | Adds guard mutations and updates owner paths. |
| src/apm_cli/utils/themed_console.py | Houses the extracted themed console helpers. |
| src/apm_cli/models/manifest_targets.py | Owns CLI-to-manifest target mapping and IDE refusal. |
| src/apm_cli/models/manifest_bootstrap.py | Houses bootstrap defaults and the validated manifest writer. |
| src/apm_cli/install/summary.py | Imports console output below the commands layer. |
| src/apm_cli/install/presentation/dry_run.py | Imports the logger type from its owner. |
| src/apm_cli/install/pipeline.py | Calls the extracted gitignore helper. |
| src/apm_cli/install/phases/finalize.py | Uses the console owner directly. |
| src/apm_cli/install/phases/cleanup.py | Uses extracted orphan-selection helpers. |
| src/apm_cli/install/package_selection.py | Uses the extracted orphan-candidate collector. |
| src/apm_cli/install/orphans.py | Houses shared orphan-selection logic. |
| src/apm_cli/install/mcp/command.py | Uses the bootstrap owner and IDE-specific guidance. |
| src/apm_cli/install/manifest_helpers.py | Adds package-bootstrap target validation. |
| src/apm_cli/install/helpers/gitignore.py | Houses the extracted gitignore updater. |
| src/apm_cli/install/dry_run_plan.py | Imports the relocated command context type. |
| src/apm_cli/install/command_context.py | Houses the install command’s parameter bundle. |
| src/apm_cli/core/target_detection.py | Removes the former manifest-target mapper. |
| src/apm_cli/commands/uninstall/engine.py | Re-exports extracted orphan helpers. |
| src/apm_cli/commands/install.py | Uses the relocated context and bootstrap validation. |
| src/apm_cli/commands/init.py | Routes explicit targets through the declaration owner. |
| src/apm_cli/commands/_helpers.py | Re-exports helpers from their new owners. |
| scripts/architecture_linter/diagnostics.py | Maps the new layering diagnostic. |
| scripts/architecture_linter/checks/registry_owner_guards.py | Adds layering, bootstrap ownership, and target-routing guards. |
| scripts/architecture_linter/checks/install_request_and_source.py | Recognizes the renamed bootstrap writer. |
| scripts/architecture_linter/checks/install_frozen_and_audit.py | Checks reachability delegation at the new orphan owner. |
| packages/apm-guide/.apm/skills/apm-usage/commands.md | Documents IDE refusal in command guidance. |
| docs/src/content/docs/troubleshooting/common-errors.md | Explains IDE refusal and recovery steps. |
| docs/src/content/docs/reference/cli/install.md | Documents bootstrap target restrictions. |
| docs/src/content/docs/reference/cli/init.md | Documents IntelliJ refusal during init. |
| CHANGELOG.md | Records the IDE-target behavior change. |
| .apm/architecture/owners/install-deployment.json | Updates orphan-selection ownership. |
| .apm/architecture/owners/core-runtime.json | Registers the bootstrap manifest owner. |
Review effort: Balanced
…ard bypasses Panel folds for #3878/#3879: - apm install -g <pkg> --target intellij and apm init NAME --target intellij now refuse before user-scope prep, config creation or the project mkdir. - The install layering guard also catches `import apm_cli.commands.x` and a redefined _create_minimal_apm_yml / _get_bootstrap_config. - Lifecycle refusal test covers -g, mixed lists, --dry-run, named init and --runtime with full before/after tree snapshots; golden bytes pin the bootstrap writer. apm-spec-waiver: panel folds for owner extraction and IDE-token refusal; no OpenAPM normative surface changes Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 1 | 2 | 2 | Single owner and identical bytes. The guard bypass (import apm_cli.commands.x) and the refusal ordering are folded. |
| Test Coverage Expert | 0 | 4 | 1 | The real-binary refusal test now covers -g, mixed lists, --dry-run, named init and --runtime, with full before/after tree snapshots. |
| Devx Ux Expert | 0 | 2 | 1 | The guidance now gives --target copilot as a copy-paste fix and says what to do once apm.yml exists. Exit codes are unified to 1. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top follow-up
- [Python Architect]
option_target_namesmapsvscodetocopilot, whilebootstrap_target_nameskeepsvscode, so the package bootstrap and the-g --mcpbootstrap persist different tokens for--target vscode. -- This predates this PR and depends on the vscode deprecation work ([BUG] Deprecate vscode as an alias of copilot; copilot writes project MCP servers to workspace-root .mcp.json #3866): fold the parity into that PR, with one mapping delegating to the other.
Recommendation
Merge at 133a489. CI is green at that exact head. Both records' Done-when are met:
- refusal before any write on every apm.yml-writing path, pinned by a real-binary test that fails on the previous head (4 of 9 cases);
- install->commands imports removed, with a guard, a MutationCase and two bypass checks, each shown to fail without its guard hunk;
- docs and CHANGELOG updated.
Full per-persona findings
Python Architect
- [blocking]
_imports_commandsmissed a plainimport apm_cli.commands._helpers: the import fact hasmodule=Noneand the dotted name sits innames. Folded: names withlevel == 0are checked. The bypass checkplain-import-of-commandsfails without the fix. - [recommended] The refusal ran after
ensure_user_dirs()/ protocol config creation (install -g) and after the project mkdir (init NAME). Folded: both commands refuse first. The lifecycle casesinstall,install-globalandinit-namedfail on the previous head. - [recommended]
option_target_namesandbootstrap_target_namesmapvscodedifferently. Deferred: this predates the PR and belongs to the vscode deprecation work ([BUG] Deprecate vscode as an alias of copilot; copilot writes project MCP servers to workspace-root .mcp.json #3866). - [nit] A redefined
_create_minimal_apm_yml/_get_bootstrap_configwould not be caught. Folded: both are retired writer names, with a bypass checkretired-bootstrap-writer-redefined. - [nit]
if TYPE_CHECKING: passwas dead code incommands/install.py. Folded: removed.
Test Coverage Expert
- [recommended]
apm install -g <pkg> --target intellijhad no real-binary test and left~/.apmwrites behind. Folded: theinstall-globalcase, plus the ordering fix. - [recommended]
--runtime intellijon a package bootstrap was unpinned. Folded: a lifecycle test pins it: exit 0, and apm.yml records notargets:(the runtime is never persisted). - [recommended] Mixed lists and
--dry-runwere checked only at the unit level. Folded:install-mixed(claude,intellij),init-mixed(all,intellij) andinstall-dry-run. - [recommended] "Nothing was written" was checked against three paths. Folded: a full before/after tree comparison of the isolated home and project. The lifecycle lock and the network-guard bytecode are excluded as harness state.
- [nit] No test pinned the bootstrap writer bytes. Folded:
tests/unit/models/test_manifest_bootstrap.py, with golden bytes identical tomain.
Devx Ux Expert
- [recommended] Write the fix out as a copy-paste flag. Folded:
Use '--target copilot' .... - [recommended] Tell JetBrains MCP users what to do next. Folded:
once apm.yml exists, '--target intellij' writes JetBrains MCP config. - [nit] Exit codes differed (init 1, package bootstrap 2). Folded: all refusals exit 1.
- The proposed reframing to "an MCP-only target" was not taken: the [BUG] Two code paths decide what --target intellij records in apm.yml #3878 record requires the guidance that IDEs are not targets.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.
Copilot review folds for #3878: - apm install <pkg> --target intellij now refuses in a preflight (install/manifest_helpers.preflight_bootstrap_targets) before --root is created, user dirs are prepared, config is written or the lock is taken. --mcp installs and local bundles (which never edit apm.yml) are skipped. - apm install -g --mcp NAME --target intellij exits 1 like every other apm.yml writer; other bootstrap target refusals stay usage errors. apm-spec-waiver: review folds for IDE-token refusal ordering; no OpenAPM normative surface changes Co-authored-by: Copilot App <[email protected]>
apm init and apm plugin init now run the declaration owner's IDE refusal in a wrapper outside the lifecycle decorator, so a refused --target intellij creates no lock, lock directory, project directory or manifest. The lifecycle test compares every file and directory (locks included) for init, init NAME, plugin init and plugin init NAME. apm-spec-waiver: IDE-token refusal ordering for init; no OpenAPM normative surface changes Co-authored-by: Copilot App <[email protected]>
…3891) * test: realign daily release smoke tests with 0.37 contracts (#3885) - retained-lock-keys mutation targets install/orphans.py, where the expected-path selector moved in #3879/#3882 - locked-skill-subset rule requires skill_subset=sorted(self.skill_subset) as one fragment; _replay_pairing(self.skill_subset, ...) from #3769 satisfied the old split needles, so the mutation went undetected - install --dry-run bootstrap previews targets and writes no apm.yml (#3865) - pack docs pointer is the install-patterns page (#3865) - finalize imports _rich_success from the console owner (#3879) - audit JSON contract tests parse stdout; the target: deprecation warning goes to stderr and is emitted once per process Co-authored-by: Copilot App <[email protected]> * docs(changelog): reference #3891 Co-authored-by: Copilot App <[email protected]> * test: pin COLUMNS for wrap-sensitive smoke assertions Rich wraps CliRunner output at the terminal width, so on a narrow console the dry-run target preview and the pack docs URL split across lines and the assertions fail although the output is correct. Pass a wide COLUMNS per invoke, as other integration tests do. Addresses Copilot inline on test_pack_ux_e2e.py:362 and test_wave7_marketplace_install_coverage.py:1013. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>
…idance (#3903) * docs(changelog): enforce one-line entries in agent and contributor guidance Make the changelog rule concrete in its single source (.apm/instructions/changelog.instructions.md): one line, user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes in "Breaking changes and upgrade notes" with a one-line migration; never a second line for the same change; no entry for internal-only PRs; two good and two bad examples from the current changelog. cut-release now re-sanitizes the whole [Unreleased] block at release time (dedupe, condense, Highlights, upgrade notes, ref/credit check). The delivery and merge autopilot workers, pr-description-skill, CONTRIBUTING.md, the PR template and the development guide point at the rule. Generated .github/ and .agents/ copies and apm.lock.yaml hashes are re-synced with apm install. Clean the current [Unreleased] block into that shape: drop the long duplicates of #3765/#3818, #3769, #3788, #3865, #3867, #3873, #3875, #3882 and the spec lines, fold their user-relevant caveats into the short lines, and drop test-only #3877. Co-authored-by: Copilot App <[email protected]> * docs(changelog): scope delivery-worker CHANGELOG edits to one task; shorten sanitizer example Address review: only the task whose files_hint owns CHANGELOG.md edits it (wave gate forbids shared-file edits across task branches), and the worked example now fits rule 2 while keeping its caveat and four refs. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>

Description
#3879, bootstrap owner extraction (byte-identical behaviour).
bootstrap_config,write_minimal_manifest,auto_detect_description) now lives inmodels/manifest_bootstrap.py. It is the only writer and always parses the manifest back before writing.install/**borrowed fromcommands/now live below that layer:install/orphans.py;install/helpers/gitignore.py;utils/themed_console.py;InstallContext:install/command_context.py.commands/_helpers.pyandcommands/uninstall/engine.pykeep the historical names as re-exports.src/apm_cli/install/**no longer importsapm_cli.commands.#3878, IDE targets refused in apm.yml (decision option a).
intellijis an IDE, not a target. Every path that writesapm.ymlnow refuses it before writing anything, with the same guidance on each path:apm install <pkg> --target intellijwith noapm.yml;apm init --target intellij;apm install -g --mcp NAME --target intellijwith no user manifest.install/manifest_helpers.preflight_bootstrap_targets) before--root, user-scope directories, config or the lock are touched.option_target_names/bootstrap_target_namesinmodels/manifest_targets.py).core/target_detection.manifest_targets_from_target_optionis deleted.--target intellijstill writes JetBrains MCP config whenapm.ymlalready exists.Guards
registry_delegation.install_layering: aninstall/**import that resolves intoapm_cli.commandsfails, and so does a secondbootstrap_config/write_minimal_manifestdefinition. It has a MutationCase and an_EXPECTED_RULE_ID_TEXTentry, and the owner recordmanifest-bootstrap-writeris incore-runtime.json._TARGET_REWRITE_CALLSnow requires init, package bootstrap and MCP bootstrap to route through the owner, and the owner to refuse IDE targets._RETIRED_TARGET_OPTION_MAPPERSforbids reintroducingmanifest_targets_from_target_option.Wording. devx-ux reviewed the refusal. I folded two of its suggestions: the copy-paste flag
--target copilot, and the "once apm.yml exists" follow-up for JetBrains MCP users. Exit codes are now unified to 1 (the package bootstrap previously exited 2). I kept "an IDE, not a target" as the record requires; devx-ux had proposed "an MCP-only target".Issue and approved scope
Issue: Fixes #3878
Issue: Fixes #3879
Human scope-approval comment:
This PR completes both issues.
Type of change
Testing
I reproduced the #3878 defect first: on
main'ssrc, the new real-binary testtests/integration/test_ide_target_refusal_lifecycle.pyfailed. The review folds then added cases that fail on each earlier head:install,install-mixed,install-globalandinit-named;install-root, plus the global MCP exit-code assertion.Every guard bypass check fails without its guard hunk.
Evidence at the exact head e2a78f3. Lifecycle rows ran with
APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm; unit rows use.venv/bin/python -m pytest -p no:xdist.test_ide_target_refusal_lifecycle.py: install, mixed, dry-run,-g,--root, init, init mixed, named init,--runtime, existing manifest (full before/after tree snapshots)test_global_mcp_bootstrap_targets_lifecycle.pytest_init_reinit_targets_lifecycle.py,test_init_bootstrap_chain_lifecycle.pytest_intellij_mcp_config_lifecycle.pytest_architecture_owner_rule_mutations.py(full module)pytest tests/unit -n 8test_unix_install_ownership/test_install_safety(xdist flakes; 420 passed when run serially) andtest_is_tool_available(local environment)uvx [email protected] checkandformat --check(CI paths)bash scripts/lint-auth-signals.shpython scripts/lint_architecture_boundaries.py --root .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.
intellijwas never a validtargets:token, so refusing to write it only stops the CLI from producing an invalid manifest.