Repository navigation
fix(manifest): bootstrap never writes unreadable targets; plain dependency and target errors - #3873
Conversation
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the bootstrap-manifest and diagnostic improvements.
No open issues 🎉
What changed in this PR
This PR addresses #3870 and #3871, following #3867, by preventing unreadable bootstrap manifests and improving dependency and target diagnostics.
Changes:
- Routes global MCP bootstrap targets through the declaration owner and validates every rendered scaffold before writing.
- Uses package-relative paths in dependency errors, removes doubled periods, and leaves status prefixes to CLI renderers.
- Adds regression tests and architecture guards, with matching documentation updates.
| File | Description |
|---|---|
tests/unit/models/test_manifest_targets.py |
Tests readable bootstrap targets and rejection of unsupported spellings. |
tests/unit/install/phases/test_read_yaml_targets_list_form.py |
Expects plain unknown-target messages. |
tests/unit/deps/test_apm_resolver_edge_cases.py |
Checks package-relative paths and single-period diagnostics. |
tests/unit/core/test_error_renderer.py |
Verifies target messages contain no status prefixes. |
tests/unit/compilation/test_compile_target_flag.py |
Checks Click formats target errors once. |
tests/integration/test_target_error_rendering_lifecycle.py |
Adds installed-CLI target-error formatting coverage. |
tests/integration/test_manifest_anchor_rejection_lifecycle.py |
Checks actionable dependency errors without staging paths. |
tests/integration/test_global_mcp_bootstrap_targets_lifecycle.py |
Tests bootstrap refusal and readable-target persistence. |
tests/integration/test_architecture_owner_rule_mutations.py |
Extends mutation coverage for validation and output ownership. |
src/apm_cli/models/manifest_targets.py |
Adds owner-managed bootstrap spelling and structured rejection details. |
src/apm_cli/integration/mcp_integrator.py |
Restores renderer-owned error symbols. |
src/apm_cli/install/phases/targets.py |
Delegates target-error symbols to the logger. |
src/apm_cli/install/mcp/integration.py |
Uses logger formatting for target failures. |
src/apm_cli/install/mcp/command.py |
Builds bootstrap configuration and refuses unrepresentable targets. |
src/apm_cli/deps/apm_resolver.py |
Normalizes candidate paths and error punctuation. |
src/apm_cli/core/errors.py |
Makes target-error renderers return plain text. |
src/apm_cli/core/apm_yml.py |
Removes the embedded empty-targets error symbol. |
src/apm_cli/commands/install.py |
Delegates user-manifest bootstrap configuration. |
src/apm_cli/commands/init.py |
Removes optional-verification arguments and prefix stripping. |
src/apm_cli/commands/compile/cli.py |
Lets the logger format global target errors. |
src/apm_cli/commands/_helpers.py |
Makes scaffold verification unconditional. |
scripts/architecture_linter/checks/registry_owner_guards.py |
Guards bootstrap delegation, verification, and plain diagnostics. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Documents global MCP bootstrap restrictions and recovery. |
docs/src/content/docs/troubleshooting/common-errors.md |
Updates the unknown-target error example. |
docs/src/content/docs/reference/cli/install.md |
Explains bootstrap refusal and manual-manifest recovery. |
CHANGELOG.md |
Records both fixes under Unreleased. |
Review effort: Balanced
- Dependency manifests that declare an unknown target are reported against the dependency, not as a usage error in the consumer's command. - Dependency errors carry a single "retry" (the resolver hint), and every invalid dependency manifest shape has a lifecycle test. - The bootstrap refusal names the flag the user typed (--target or --runtime), and its recovery path is covered. - `apm compile -g` (logger path) is covered with one `[x]` prefix. - Guards also pin the install command's call into the bootstrap owner, and reject replace()/lstrip() status-prefix stripping. - common-errors and ide-tool-integration headings are symbol-free. apm-spec-waiver: error wording and bootstrap guard folds only; no OpenAPM normative behaviour changes Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 3 | 0 | The MCP bootstrap now goes through the owner and every write is verified. The guard gap is folded; package/init --target persistence and the layering are deferred. |
| Test Coverage Expert | 0 | 3 | 0 | Logger-rendered errors, dependency targets: [bogus], --runtime and the recovery path now all have lifecycle tests. |
| Cli Logging Expert | 0 | 3 | 0 | One status symbol everywhere. The double retry, the --runtime label and the [x] doc headings are folded. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 2 follow-ups
- [Python Architect] Make one module the only source of persisted target names: route package bootstrap (
apm install -g <pkg> --target X) andinit --targetthroughmodels/manifest_targetsinstead ofcore/target_detection.manifest_targets_from_target_option, after deciding whether intellij is recorded as itself or as copilot. -- Two sources of truth for writing target names is how [BUG] apm install -g --mcp --target intellij writes an unreadable targets: [intellij] user manifest #3870 happened, and the choice needs a product decision first. - [Python Architect] Move the bootstrap-manifest logic now in
commands._helpersinto a core owner, soinstall/mcp/command.pystops importing from the commands layer. -- This upward import predates the PR; a core owner can then be enforced by an architecture guard.
Recommendation
Merge at 9682d3c. Every in-scope finding is folded and has a test: real-binary lifecycle tests, guard mutation cases, and passing unit, lint and architecture runs. Before merging, open two issues: (1) decide how package/init --target should persist intellij, so there is one source of persisted target names, and (2) move the bootstrap-manifest logic out of commands._helpers. Put (1) first.
Full per-persona findings
Python Architect
- [recommended] The package bootstrap and
init --targetstill convert--targetthroughmanifest_targets_from_target_option(intellijbecomescopilot), a second authority. Atsrc/apm_cli/commands/install.py:1530. Deferred: outside [BUG] apm install -g --mcp --target intellij writes an unreadable targets: [intellij] user manifest #3870's scope, and it needs a product decision. - [recommended] The guard pinned only the callee, and the strip check caught only
removeprefix. Folded: the install command's call into the owner is pinned,replace/lstripstripping is caught, and 2 mutation cases were added. - [recommended]
install/mcp/command.pyimports fromcommands._helpers, an upward dependency. Deferred: a refactor of a pre-existing dependency.
Test Coverage Expert
- [recommended] The logger-rendered target errors were untested. Folded:
test_logger_rendered_target_error_has_one_status_prefix(apm compile -g, exactly one[x]). - [recommended] A dependency declaring
targets: [bogus]printed a usage error for the consumer's command instead of naming the dependency. Folded: the resolver now wrapsTargetResolutionErrorfor dependency manifests; the lifecycle test covers the anchor, duplicate-key and unknown-target cases. - [recommended] The
--runtimepath and the refusal's recovery path were untested, and the message said--targetwhen the user typed--runtime. Folded: the message now names the flag the user typed, with 2 lifecycle tests.
Cli Logging Expert
- [recommended] The dependency error said "retry" twice. Folded: the manifest owner's trailing "then retry" is dropped inside the dependency wrapper; the lifecycle test asserts one "retry".
- [recommended] The bootstrap refusal named
--targetwhen the user typed--runtime. Folded. - [recommended] Doc headings still showed
[x]. Folded: the common-errors and ide-tool-integration headings are now symbol-free.
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.
…dency and target errors wrote `targets: [intellij]`, which the next `apm install -g` rejected. The user-manifest bootstrap now spells its targets through the declaration owner (bootstrap_target_names -> rewrite_target_names) and refuses, before any write, a target with no `targets:` spelling. Every scaffold and bootstrap write now verifies the rendered manifest (verify_rewritten_manifest). ended with `..`; they now name the dependency and its in-package path with one period. Target-resolution messages no longer embed `[x]`: Click or CommandLogger adds exactly one status prefix, so `Error: [x] Unknown target` becomes `Error: Unknown target`, and callers no longer strip prefixes. Guards: registry_delegation.target_vocabulary (bootstrap and scaffold routing) and registry_delegation.output_diagnostics (no status symbol in target messages, no prefix stripping), with mutation cases. apm-spec-waiver: user-facing error wording and bootstrap target spelling only; no OpenAPM normative behaviour changes Fixes #3870 Fixes #3871 Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
- Dependency manifests that declare an unknown target are reported against the dependency, not as a usage error in the consumer's command. - Dependency errors carry a single "retry" (the resolver hint), and every invalid dependency manifest shape has a lifecycle test. - The bootstrap refusal names the flag the user typed (--target or --runtime), and its recovery path is covered. - `apm compile -g` (logger path) is covered with one `[x]` prefix. - Guards also pin the install command's call into the bootstrap owner, and reject replace()/lstrip() status-prefix stripping. - common-errors and ide-tool-integration headings are symbol-free. apm-spec-waiver: error wording and bootstrap guard folds only; no OpenAPM normative behaviour changes Co-authored-by: Copilot App <[email protected]>
A dependency resolved through a `replace:` rule used to be identifiable only through the leaked staging path. The error now says "Downloaded dependency '../local-base' (replacement for 'owner/repo') is invalid: ...", and the replacement lifecycle test asserts it. apm-spec-waiver: error wording for replaced dependencies only; no OpenAPM normative behaviour changes Co-authored-by: Copilot App <[email protected]>
77c059a to
527aea4
Compare
Merge worker: ready to merge (maintainer merges)Folded in this run
Copilot signals reviewed
Deferred (out-of-scope follow-ups)
Regression-trap evidence (mutation-break gate)
Lint contractAt 527aea4: uvx [email protected] check + format --check clean; pylint R0801 10.00/10; scripts/lint-auth-signals.sh clean; scripts/lint_architecture_boundaries.py --root . clean; commands/install.py 2096 LOC (budget 2100). CIObserved green at exact head 527aea4 (rebased on main 2ce7a38): gh pr checks 31 pass, 3 skipping, 0 pending/failed; MERGEABLE, mergeStateStatus BLOCKED (review required). Copilot review: approval recommended, no issues. Earlier rounds: replacement lifecycle relied on the leaked staging path (fixed), then a main conflict in install.md (resolved by rebase). (after 3 CI round(s)). Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors. |
…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
Two 0.37 defects found while landing #3867.
#3870: the user-manifest bootstrap wrote a manifest APM rejects. Before:
apm install -g --mcp NAME --target intellij, run with no~/.apm/apm.yml, wrotetargets: [intellij], and the nextapm install -gfailed withUnknown target 'intellij'. After: the bootstrap gets itstargets:list from the declaration owner (models/manifest_targets.py::bootstrap_target_names, which wrapsrewrite_target_names). A target with notargets:spelling is refused before anything is written, and the message names the token and the recovery. Representable targets (--target claude) are still recorded, and the next run reads them. Omitting the token instead was considered and rejected: a manifest withouttargets:makes the next bareapm install -gdeploy to every detected runtime, which is wider than the user asked for._create_minimal_apm_ymlnow always verifies the rendered manifest (verify_rewritten_manifest), so neither init nor any bootstrap can write atargets:value the reader rejects. The helper lives ininstall/mcp/command.py, which keepscommands/install.pywithin its line budget.#3871: dependency manifest errors showed a staging path and
.., and target errors mixed in CLI formatting.Downloaded dependency './pkgs/alpha' is invalid: /.../apm_modules/.apm-resolution-staging/<id>/replacements/<id>/apm.yml uses the YAML anchor ... then retry.. The downloaded candidate .... After,Downloaded dependency './pkgs/alpha' is invalid: apm.yml uses the YAML anchor '&v' on line 2. ... then retry. The downloaded candidate was not activated; ...._raise_downloaded_package_errornow rewrites paths under the staged candidate as package-relative paths and joins sentences with a single period.TargetResolutionErrorrenderers (core/errors.py) and the empty-targets message (core/apm_yml.py) no longer embed[x]. Click printsError: Unknown target 'bogus'instead ofError: [x] Unknown target 'bogus'. Logger call sites that passedsymbol=""to avoid a doubled prefix now passsymbol="error", and theremoveprefix("[x] ")workarounds added in fix(manifest): route init re-init target rewrites through the declaration owner; reject apm.yml YAML anchors #3867 are gone.Guards (extended rules, with mutation cases):
registry_delegation.target_vocabulary: the owner must definebootstrap_target_names; the MCP bootstrap must spell its targets through it; and_create_minimal_apm_ymlmust callverify_rewritten_manifestunconditionally (an indented token pins the call to that nesting level).registry_delegation.output_diagnostics: no status-symbol literal in target error messages, and noremoveprefix("[x] ")anywhere undersrc/.Issue and approved scope
Issue: Fixes #3870
Issue: Fixes #3871
Human scope-approval comment:
Does this PR complete the issue, or what remains? It completes both records' Done-when.
Type of change
Testing
Validation evidence: see the follow-up comment with exact-head commands and results.
Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated (new/changed<a id="req-XXX"></a>anchor + prose + Appendix C row).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.