Skip to content

fix(manifest): extract the bootstrap manifest owner; refuse IDE targets in apm.yml - #3882

Merged
Daniel Meppiel (danielmeppiel) merged 5 commits into
mainfrom
danielmeppiel-3879-bootstrap-manifest-owner
Nov 18, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 5 commits into
mainfrom
danielmeppiel-3879-bootstrap-manifest-owner

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Description

#3879, bootstrap owner extraction (byte-identical behaviour).

  • The bootstrap manifest writer (bootstrap_config, write_minimal_manifest, auto_detect_description) now lives in models/manifest_bootstrap.py. It is the only writer and always parses the manifest back before writing.
  • Helpers that install/** borrowed from commands/ now live below that layer:
    • orphans: install/orphans.py;
    • gitignore: install/helpers/gitignore.py;
    • the themed console: utils/themed_console.py;
    • the CLI InstallContext: install/command_context.py.
  • commands/_helpers.py and commands/uninstall/engine.py keep the historical names as re-exports.
  • src/apm_cli/install/** no longer imports apm_cli.commands.

#3878, IDE targets refused in apm.yml (decision option a).

  • intellij is an IDE, not a target. Every path that writes apm.yml now refuses it before writing anything, with the same guidance on each path:
    • apm install <pkg> --target intellij with no apm.yml;
    • apm init --target intellij;
    • apm install -g --mcp NAME --target intellij with no user manifest.
  • The refusal is:
    'intellij' is an IDE, not a target, so apm.yml cannot record it. Use '--target copilot' for GitHub Copilot in JetBrains IDEs; once apm.yml exists, '--target intellij' writes JetBrains MCP config.
    
  • Every refusal exits 1, and the package bootstrap refuses in a preflight (install/manifest_helpers.preflight_bootstrap_targets) before --root, user-scope directories, config or the lock are touched.
  • Every path routes through the declaration owner (option_target_names / bootstrap_target_names in models/manifest_targets.py). core/target_detection.manifest_targets_from_target_option is deleted.
  • The JetBrains user-scope MCP adapter is unchanged. --target intellij still writes JetBrains MCP config when apm.yml already exists.

Guards

  • New rule registry_delegation.install_layering: an install/** import that resolves into apm_cli.commands fails, and so does a second bootstrap_config / write_minimal_manifest definition. It has a MutationCase and an _EXPECTED_RULE_ID_TEXT entry, and the owner record manifest-bootstrap-writer is in core-runtime.json.
  • _TARGET_REWRITE_CALLS now requires init, package bootstrap and MCP bootstrap to route through the owner, and the owner to refuse IDE targets.
  • _RETIRED_TARGET_OPTION_MAPPERS forbids reintroducing manifest_targets_from_target_option.
  • Four new mutation params cover these guards.

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

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

I reproduced the #3878 defect first: on main's src, the new real-binary test tests/integration/test_ide_target_refusal_lifecycle.py failed. The review folds then added cases that fail on each earlier head:

  • 623ae27: install, install-mixed, install-global and init-named;
  • 09329d6: 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.

Command Result
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) 10 passed
test_global_mcp_bootstrap_targets_lifecycle.py 5 passed
test_init_reinit_targets_lifecycle.py, test_init_bootstrap_chain_lifecycle.py 5 passed
test_intellij_mcp_config_lifecycle.py 10 passed
Owner unit tests: preflight, owner mapping, bootstrap golden bytes, init, orphans, dry-run plan, uninstall engine, pipeline gitignore, target selection 710 passed
test_architecture_owner_rule_mutations.py (full module) 766 passed
pytest tests/unit -n 8 Passed, except test_unix_install_ownership / test_install_safety (xdist flakes; 420 passed when run serially) and test_is_tool_available (local environment)
uvx [email protected] check and format --check (CI paths) clean
pylint R0801 10.00/10
bash scripts/lint-auth-signals.sh clean
python scripts/lint_architecture_boundaries.py --root . clean
CI at e2a78f3 31 pass, 3 skipping

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour. intellij was never a valid targets: token, so refusing to write it only stops the CLI from producing an invalid manifest.

…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]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 18, 2026
Copilot AI balanced review requested due to automatic review settings November 18, 2026 15:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread src/apm_cli/commands/init.py Resolved
Comment thread src/apm_cli/commands/install.py Resolved
Comment thread src/apm_cli/install/mcp/command.py Resolved
…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]>
@danielmeppiel

Daniel Meppiel (danielmeppiel) commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Fixes #3878 and #3879. apm.yml never records intellij: every path that writes the manifest refuses it before writing. The bootstrap manifest writer moves below the commands layer, so install/** no longer imports apm_cli.commands.

panel-mode=lean; personas=python-architect,test-coverage-expert,devx-ux-expert,apm-ceo

#3879. The bootstrap writer now lives in models/manifest_bootstrap.py. The orphan, gitignore, console and InstallContext helpers moved under install/ and utils/, and the commands layer re-exports the historical names. I compared the scaffold bytes against main and they are identical; a golden test now pins them. The new rule registry_delegation.install_layering fails when an install/** import resolves into apm_cli.commands or a second bootstrap writer appears.

#3878. The package bootstrap, apm init --target and the -g --mcp bootstrap all route through the declaration owner (option_target_names / bootstrap_target_names in models/manifest_targets.py). Each refuses intellij, exits 1, and names the fix. core/target_detection.manifest_targets_from_target_option is gone, and a guard stops it coming back. With an existing apm.yml, --target intellij still writes JetBrains MCP config.

Round 1 ran on 623ae27. Every in-scope finding is folded at 09329d6, and Copilot's review is folded at e2a78f3:

  • the apm install <pkg> refusal now runs as a preflight before --root is created;
  • the -g --mcp IDE refusal exits 1;
  • plain imports are caught by the layering guard.

At 133a489, apm init and apm plugin init refuse before the lifecycle lock is taken, so no lock, lock directory or project directory is created. One pre-existing item is deferred: the vscode mapping parity.

Aligned with:

  • Portable by manifest: APM never writes a target it cannot read back.
  • Multi-harness: JetBrains MCP deployment is unchanged.
  • Pragmatic as npm: one message on every path, with a copy-paste fix.

Panel summary

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

  1. [Python Architect] option_target_names maps vscode to copilot, while bootstrap_target_names keeps vscode, so the package bootstrap and the -g --mcp bootstrap 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_commands missed a plain import apm_cli.commands._helpers: the import fact has module=None and the dotted name sits in names. Folded: names with level == 0 are checked. The bypass check plain-import-of-commands fails 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 cases install, install-global and init-named fail on the previous head.
  • [recommended] option_target_names and bootstrap_target_names map vscode differently. 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_config would not be caught. Folded: both are retired writer names, with a bypass check retired-bootstrap-writer-redefined.
  • [nit] if TYPE_CHECKING: pass was dead code in commands/install.py. Folded: removed.

Test Coverage Expert

  • [recommended] apm install -g <pkg> --target intellij had no real-binary test and left ~/.apm writes behind. Folded: the install-global case, plus the ordering fix.
  • [recommended] --runtime intellij on a package bootstrap was unpinned. Folded: a lifecycle test pins it: exit 0, and apm.yml records no targets: (the runtime is never persisted).
  • [recommended] Mixed lists and --dry-run were checked only at the unit level. Folded: install-mixed (claude,intellij), init-mixed (all,intellij) and install-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 to main.

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]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit dc9972d into main Nov 18, 2026
34 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-3879-bootstrap-manifest-owner branch November 18, 2026 16:24
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 19, 2026
…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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 19, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants