Skip to content

fix(manifest): bootstrap never writes unreadable targets; plain dependency and target errors - #3873

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-3870-3871-manifest-errors
Nov 18, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-3870-3871-manifest-errors

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

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, wrote targets: [intellij], and the next apm install -g failed with Unknown target 'intellij'. After: the bootstrap gets its targets: list from the declaration owner (models/manifest_targets.py::bootstrap_target_names, which wraps rewrite_target_names). A target with no targets: 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 without targets: makes the next bare apm install -g deploy to every detected runtime, which is wider than the user asked for. _create_minimal_apm_yml now always verifies the rendered manifest (verify_rewritten_manifest), so neither init nor any bootstrap can write a targets: value the reader rejects. The helper lives in install/mcp/command.py, which keeps commands/install.py within its line budget.

#3871: dependency manifest errors showed a staging path and .., and target errors mixed in CLI formatting.

  • Dependency errors: before, 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_error now rewrites paths under the staged candidate as package-relative paths and joins sentences with a single period.
  • Target errors: the TargetResolutionError renderers (core/errors.py) and the empty-targets message (core/apm_yml.py) no longer embed [x]. Click prints Error: Unknown target 'bogus' instead of Error: [x] Unknown target 'bogus'. Logger call sites that passed symbol="" to avoid a doubled prefix now pass symbol="error", and the removeprefix("[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 define bootstrap_target_names; the MCP bootstrap must spell its targets through it; and _create_minimal_apm_yml must call verify_rewritten_manifest unconditionally (an indented token pins the call to that nesting level).
  • registry_delegation.output_diagnostics: no status-symbol literal in target error messages, and no removeprefix("[x] ") anywhere under src/.

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

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

Testing

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

Validation evidence: see the follow-up comment with exact-head commands and results.

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.

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.

🟢 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

Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
- 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]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Fixes #3870 and #3871: the global MCP bootstrap no longer writes a manifest that the next apm install -g rejects, and dependency manifest errors now name the package, end with one period, and say retry once.

panel-mode=lean; personas=python-architect,test-coverage-expert,cli-logging-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

This PR fixes two problems with the same cause: APM wrote a manifest it would reject on the next run (#3870), and a dependency error showed APM's internal staging path and asked the user to retry twice (#3871). For #3870, target names in the global bootstrap now come from the declaration owner (bootstrap_target_names calls rewrite_target_names in models/manifest_targets.py). The command refuses before writing anything, and _create_minimal_apm_yml always checks the manifest it rendered. Leaving targets: out was rejected, because the next bare install -g would then install to every detected runtime. For #3871, the target error messages no longer carry their own [x]: Click prints Error: Unknown target, CommandLogger adds exactly one [x], and the prefix-stripping workarounds are gone.

Round 1 ran on a09c055. All six test-coverage and cli-logging findings, and one of the three architecture findings, are folded at 9682d3c with real-binary lifecycle tests or guard mutation cases. The two remaining architecture items are deferred (below).

Aligned with: portable by manifest (APM no longer writes a manifest it cannot read back); multi-harness (--target intellij / --runtime no longer leaves an unreadable user manifest, and the next install does not fan out to every detected runtime); pragmatic as npm (dependency errors use package-relative paths, say retry once, and name the flag the user typed).

Panel summary

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

  1. [Python Architect] Make one module the only source of persisted target names: route package bootstrap (apm install -g <pkg> --target X) and init --target through models/manifest_targets instead of core/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.
  2. [Python Architect] Move the bootstrap-manifest logic now in commands._helpers into a core owner, so install/mcp/command.py stops 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 --target still convert --target through manifest_targets_from_target_option (intellij becomes copilot), a second authority. At src/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/lstrip stripping is caught, and 2 mutation cases were added.
  • [recommended] install/mcp/command.py imports from commands._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 wraps TargetResolutionError for dependency manifests; the lifecycle test covers the anchor, duplicate-key and unknown-target cases.
  • [recommended] The --runtime path and the refusal's recovery path were untested, and the message said --target when 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 --target when 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]>
- 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]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-3870-3871-manifest-errors branch from 77c059a to 527aea4 Compare November 18, 2026 13:34
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Merge worker: ready to merge (maintainer merges)

Folded in this run

  • (panel) guard pins install.py call into the bootstrap owner; replace()/lstrip() prefix stripping caught (+2 mutation cases) -- resolved in 9682d3c.
  • (panel) logger-rendered target error (compile -g) lifecycle: one [x] -- resolved in 9682d3c.
  • (panel) dependency targets: [bogus] named against the dependency; lifecycle over anchor/duplicate-key/unknown-target -- resolved in 9682d3c.
  • (panel) --runtime flag label and refusal recovery path lifecycle tests -- resolved in 9682d3c.
  • (panel) dependency errors carry one retry -- resolved in 9682d3c.
  • (panel) symbol-free doc headings for target errors -- resolved in 9682d3c.
  • (panel) CI: replacement dependency errors name the replacement instead of the staging path -- resolved in 527aea4.

Copilot signals reviewed

  • Copilot review at 527aea4: approval recommended, no issues.

Deferred (out-of-scope follow-ups)

Regression-trap evidence (mutation-break gate)

  • tests/integration/test_global_mcp_bootstrap_targets_lifecycle.py::test_bootstrap_refuses_a_target_with_no_targets_spelling -- removed owner-routed bootstrap targets (pre-fix: targets = supported_runtimes); the test failed as expected.
  • tests/integration/test_target_error_rendering_lifecycle.py::test_target_error_has_one_status_prefix -- removed plain renderers (pre-fix: '[x] ' embedded in core/errors.py); the test failed as expected.
  • tests/integration/test_manifest_anchor_rejection_lifecycle.py::test_dependency_manifest_error_names_the_dependency_before_any_write -- removed _package_relative_detail and single-period/retry join in apm_resolver; the test failed as expected.

Lint contract

At 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).

CI

Observed 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.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 4c6513e into main Nov 18, 2026
34 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-3870-3871-manifest-errors branch November 18, 2026 14:08
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