Skip to content

fix(cli): derive consistency-checker surface from apm --help and fit root summaries - #3643

Merged
Daniel Meppiel (danielmeppiel) merged 8 commits into
mainfrom
danielmeppiel-issue-3523-cli-consistency-checker
Nov 12, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 8 commits into
mainfrom
danielmeppiel-issue-3523-cli-consistency-checker

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

TL;DR

The cli-consistency-checker agentic workflow inspected a hand-written list of ~25 commands and read docs/cli-reference.md, a file that no longer exists. It now walks apm --help recursively (70+ command sections today, including marketplace's split headings) and cross-checks docs/src/content/docs/reference/cli/. Ten top-level commands also get a Click short_help, so apm --help prints every summary in full instead of ....

Fixes #3523

Note

Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate.

Description

The workflow prompt (Step 2 and Step 3.4) and its compiled lock are updated. Ten command decorators get short_help. Two new regression guards keep the checker and the root help from drifting again.

Issue and approved scope

Issue: Fixes #3523

Human scope-approval comment: #3523 (comment) (apm-scope:v1, approved by Daniel Meppiel (@danielmeppiel), review contact Daniel Meppiel (@danielmeppiel)).

Does this PR complete the issue? Yes. All three Done-when items are covered: the checker derives commands from apm --help recursively, it references only docs paths that exist on main, the lock is regenerated with gh aw compile, and no top-level summary in apm --help ends in an ellipsis. A unit test enforces the last item. Out-of-scope items are untouched: command names, flags and behavior, long help bodies, and the checker's schedule, model and safe-outputs.

Problem (WHY)

  • Step 2 ran --help only for init/install/uninstall/update/compile/run, deps, mcp, config and runtime setup. It skipped approve, audit, auth, cache, deny, doctor, experimental, find, lifecycle, list, lock, marketplace, outdated, pack, plugin, policy, preview, prune, publish, search, self-update, targets, unpack, view and newer subcommands such as deps why, mcp list, config unset and runtime list|remove|status.
  • Step 3.4 ran cat docs/cli-reference.md, but that file was removed. The CLI reference is now one page per command under docs/src/content/docs/reference/cli/.
  • [!] At 80 columns, apm --help truncated 10 summaries (approve, audit, deny, doctor, export-patch, find, install, lock, prune, uninstall), for example approve Approve executable primitives (hooks, MCP, LSP, bin,....

Why these matter: a hand-maintained list goes stale every time a command ships, so the checker silently stops covering new surface. The root help is the first thing a new user reads, and truncated summaries hide what each verb does.

Approach (WHAT)

# Fix
1 Replace the hand list with a recursive bash walker (apm_help_walk) that parses every *commands: heading of each --help output.
2 Point Step 3.4 at docs/src/content/docs/reference/cli/ (one page per top-level command, with subcommands on the parent page) and read pages one command at a time, not 312 KB in one cat.
3 Add Click short_help to the 10 truncated commands. Their --help bodies are unchanged, and the lazy-stub summaries in cli.py match.
4 Recompile cli-consistency-checker.lock.yml with gh-aw v0.89.15 (the version pinned in the lock header).

Implementation (HOW)

  • .github/workflows/cli-consistency-checker.md: Step 2 now uses apm_subcommands (awk over /^([A-Za-z]+ )*[Cc]ommands:$/, so MarketplaceGroup's Consumer commands: / Authoring commands: are included) and apm_help_walk. Output goes to /tmp/gh-aw/agent/ per the compiler's artifact-root warning. In Step 3.4, docs/cli-reference.md is replaced by the reference/cli/ directory. The schedule, model, permissions and safe-outputs are untouched.
  • .github/workflows/cli-consistency-checker.lock.yml: recompiled. Only body_hash in the metadata header changed, because the prompt is runtime-imported.
  • src/apm_cli/commands/{approve,audit,doctor,export_patch,find,install,lock,prune}.py, uninstall/cli.py: each gets a short_help= of 60 characters or fewer, the width left beside the 12-char experimental/export-patch names at 80 columns.
  • src/apm_cli/cli.py: _LAZY_COMMANDS stub summaries match the new short_help, so test_lazy_stub_short_help_matches_resolved_command still holds.
  • tests/unit/test_cli_consistency.py: test_root_help_command_summaries_are_not_truncated renders apm --help at terminal_width=80 and requires each visible top-level row to equal the command's untruncated summary on one line.
  • tests/unit/test_cli_consistency_checker_workflow.py (new): checks that every docs/... path in the workflow exists and that no per-command --help list is hardcoded. It also runs the workflow's own awk program against every Click group's rendered help and requires exactly the group's visible subcommands.

Diagrams

Legend: how the checker now derives its command surface. The awk parser that drives the recursion is the same program the unit test executes against the Click tree.

flowchart LR
    A["apm_help_walk PATH"] --> B["apm PATH --help"]
    B --> C["/tmp/gh-aw/agent/apm-help-all.txt"]
    B --> D["apm_subcommands: awk over *commands: headings"]
    D -->|"each subcommand"| A
    C --> E["Step 3.4: compare with docs/src/content/docs/reference/cli/CMD.md"]
    T["test_checker_walker_finds_every_visible_subcommand"] -.->|"runs same awk program"| D
Loading

Trade-offs

  • short_help over rewriting the first help line. I chose short_help because it changes only the root listing and leaves every --help body byte-identical, which keeps the out-of-scope "rewriting long help bodies" untouched. I rejected first-line rewrites because they would also change apm <cmd> --help and its docs quotes. The cost is that 10 commands now keep a second, short string.
  • Bash walker over Click introspection in the workflow. The record requires deriving from apm --help, and the walker tests the shipped CLI as users see it. The cost is one apm --help process per command (~70+). That is well within the 20-minute timeout.
  • The awk test is skipped where awk is absent (some Windows runners). It runs on the Linux PR CI.
  • install.py is now exactly 2100 lines. The CI guard fails only above 2100 (NR > max).

Benefits

  1. Checker coverage grows from a fixed ~25 entries to every visible command and subcommand (70 sections today) and follows new commands automatically.
  2. The docs cross-check targets the 35 real pages under reference/cli/ instead of a missing file.
  3. apm --help truncates 0 summaries at 80 columns, down from 10.
  4. Four regression guards fail if the list is hand-written again, a dead docs path returns, the parser stops matching a group, or a summary truncates (each mutation-verified below).

Validation

Lint mirror (CI Lint job, run on the merge with origin/main at 1a370716e1):

$ uvx [email protected] check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py
All checks passed!
$ uvx [email protected] format --check ...
2162 files already formatted
$ python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ ...
Your code has been rated at 10.00/10
$ bash scripts/lint-auth-signals.sh
[+] auth-signal lint clean

Targeted tests (no xdist):

$ pytest -p no:xdist -q tests/unit/test_cli_consistency.py tests/unit/test_cli_consistency_checker_workflow.py tests/unit/test_cli_lazy_dispatch.py tests/unit/test_cli_docs_contract.py
33 passed in 10.64s
Mutation-break evidence
# revert approve short_help + narrow awk to /^Commands:$/ + restore `cat docs/cli-reference.md`
FAILED tests/unit/test_cli_consistency.py::test_root_help_command_summaries_are_not_truncated
FAILED tests/unit/test_cli_consistency_checker_workflow.py::test_checker_references_only_existing_docs_paths
FAILED tests/unit/test_cli_consistency_checker_workflow.py::test_checker_walker_finds_every_visible_subcommand
3 failed, 1 passed
# append a hardcoded "apm deps list --help" block
FAILED tests/unit/test_cli_consistency_checker_workflow.py::test_checker_does_not_hardcode_subcommand_help_list
# restored
4 passed

Compiler: gh aw compile cli-consistency-checker (v0.89.15) reproduced the pre-change lock byte-for-byte before editing. After the edit it reports 1 succeeded, 0 warnings. Running the walker end-to-end against the source CLI printed 70 ===== apm ... --help sections.

Scenario Evidence

# Scenario (user promise) Principle(s) Test(s) proving it Type
1 apm --help shows every command's summary in full at 80 columns DevX tests/unit/test_cli_consistency.py::test_root_help_command_summaries_are_not_truncated (regression-trap for #3523) unit
2 The nightly CLI checker inspects every command and subcommand, including new ones OSS / community-driven, DevX tests/unit/test_cli_consistency_checker_workflow.py::test_checker_walker_finds_every_visible_subcommand
::test_checker_does_not_hardcode_subcommand_help_list
unit
3 The checker compares the CLI against docs that exist OSS / community-driven tests/unit/test_cli_consistency_checker_workflow.py::test_checker_references_only_existing_docs_paths unit

Type of change

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

Testing

  • Tested locally
  • All existing tests pass (targeted CLI suites; CI is the authority for the full suite)
  • Added tests for new functionality (if applicable)

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

How to test

  • Run COLUMNS=80 apm --help -> no row in Commands: ends with ....
  • Run apm install --help -> the body still starts with the full original sentence.
  • Paste the Step 2 walker from the workflow into a shell with apm on PATH -> grep -c '^===== ' /tmp/gh-aw/agent/apm-help-all.txt prints about 70, including apm marketplace add --help.
  • Run gh aw compile cli-consistency-checker with v0.89.15 -> no diff to the lock.

Co-authored-by: Copilot [email protected]

…root summaries

The cli-consistency-checker workflow now walks apm --help recursively
instead of a stale hand list, and cross-checks the current CLI reference
under docs/src/content/docs/reference/cli/. Ten top-level commands get a
Click short_help so apm --help prints them without truncation; their
--help bodies are unchanged. Lock recompiled with gh-aw v0.89.15.

Fixes #3523

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 16:40
Co-authored-by: Copilot App <[email protected]>

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

The nested-group test can contact the live release API and write update-cache state because the update checker is not mocked, making the test non-hermetic.

1 open issue
What changed in this PR

Addresses #3523 by deriving the CLI consistency checker’s coverage from live help output and keeping top-level command summaries readable at 80 columns.

Changes:

  • Replaces the fixed command list with recursive help discovery and points documentation checks at the current CLI reference directory.
  • Adds concise summaries for ten commands and synchronizes lazy-command summaries without changing command behavior or long help.
  • Adds regression checks for summary formatting, command discovery, and documentation paths.
File Description
tests/​unit/​test_cli_consistency.py Checks that root summaries fit without truncation or wrapping.
tests/​unit/​test_cli_consistency_checker_workflow.py Adds workflow discovery and documentation-path guards.
src/​apm_cli/​commands/​uninstall/​cli.py Adds a concise uninstall summary.
src/​apm_cli/​commands/​prune.py Adds a concise prune summary.
src/​apm_cli/​commands/​lock.py Adds a concise lock summary.
src/​apm_cli/​commands/​install.py Adds a concise install summary.
src/​apm_cli/​commands/​find.py Adds a concise find summary.
src/​apm_cli/​commands/​export_patch.py Adds a concise export-patch summary.
src/​apm_cli/​commands/​doctor.py Adds a concise doctor summary.
src/​apm_cli/​commands/​audit.py Adds a concise audit summary.
src/​apm_cli/​commands/​approve.py Adds concise approve and deny summaries.
src/​apm_cli/​cli.py Synchronizes lazy-command summaries.
CHANGELOG.md Records the help and checker fixes.
.github/​workflows/​cli-consistency-checker.md Introduces recursive discovery and current documentation paths.
.github/​workflows/​cli-consistency-checker.lock.yml Updates the compiled workflow’s body hash.

Review effort: Balanced

Step 3.4 now says subcommands at any depth live on their top-level
command's reference page, and tells the agent to invoke a docs-mentioned
command or flag directly before flagging it, since hidden aliases such
as apm info never appear in --help. Addresses doc-writer panel
follow-ups on PR #3643. Lock recompiled with gh-aw v0.89.15.

Co-authored-by: Copilot App <[email protected]>
Nested --help invocations run the root callback, which calls the update
checker and may hit the release API and write cache state. Patch it so
the walker parity test stays hermetic. Addresses Copilot inline on
tests/unit/test_cli_consistency_checker_workflow.py:64.

Co-authored-by: Copilot App <[email protected]>
Hidden options never appear in --help, so passing the option together
with --help is the reliable existence probe (Click rejects unknown
options before handling --help). Addresses doc-writer delta follow-up
on PR #3643. Lock recompiled with gh-aw v0.89.15.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_now

Delta pass confirms convergence: all lean-pass and inline findings are folded, CI is green, and no follow-ups remain.

panel-mode=lean -> delta; personas=devx-ux-expert,test-coverage-expert,doc-writer(adhoc: gh-aw workflow prompt + CHANGELOG),apm-ceo

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

The lean pass at b4320a1 found nothing on the CLI surface or tests. The new root summaries are accurate and consistent, and every Done-when item maps to a test that fails on revert. The doc-writer raised two clarity items in checker Step 3.4: documented hidden aliases such as apm info would be flagged as high-severity drift, and depth-3 subcommands should map to the top-level command's page. Both were folded in 2cbc8c7. Copilot flagged, correctly, that the walker test reached the live update checker through nested --help; 067014d patches it out. The delta pass then surfaced one refinement: hidden options need a --option value --help probe. That was verified against the CLI (--branch main --help exits 0, --bogus exits 2) and folded in 7d41aec. The lock was recompiled with gh-aw v0.89.15 each time.

Aligned with: Pragmatic as npm -- root help summaries now fit 80-column terminals without truncation. OSS / community-driven -- the checker derives its surface from apm --help, so new commands are covered without editing the workflow.

Panel summary

Persona B R N Takeaway
DevX UX Expert 0 0 0 New root summaries are accurate and stylistically consistent, and lose no essential meaning.
Test Coverage Expert 0 0 0 Each Done-when item has a regression trap; the walker test is hermetic after the fold; all tests pass.
Doc Writer 0 3 0 Three Step 3.4 clarity gaps (hidden aliases, depth-3 page mapping, hidden-option probe); all folded.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Folded in this run

  • 2cbc8c7 -- [Doc Writer] Step 3.4: subcommands at any depth map to the top-level page; invoke docs-mentioned commands directly before flagging.
  • 067014d -- [Copilot, LEGIT] Patch apm_cli.cli._check_and_notify_updates in the walker parity test so nested --help stays offline.
  • 7d41aec -- [Doc Writer, delta] Probe hidden options with --option value --help.

Copilot signals reviewed

  • 4553459125 (tests/unit/test_cli_consistency_checker_workflow.py) -- LEGIT: nested --help runs the root callback, which calls the update checker (confirmed). Folded and thread resolved.

Evidence

  • Lint: ruff check/format (uv.lock pin 0.15.12), pylint R0801 10.00/10, lint-auth-signals and lint-architecture-boundaries clean on the merged head.
  • CI at 7d41aec: 32 success, 2 neutral, 1 skipped, 0 failing; gate, Lint, license/cla pass.
  • Canonical owner: commands/install.py ("Install command scope selection") touched only by a short_help string. Exact-head functional evidence: 4 install-scope tests in tests/unit/test_install_command.py passed at 7d41aec.
PR head stance iters folds deferrals copilot rounds CI mergeable state notes
#3643 7d41aec ship_now 2 3 0 2 green MERGEABLE BLOCKED pending required review

Recommendation

Every finding from the lean pass, the Copilot inline review and the delta pass is folded and verified. CI is green at 7d41aec, and nothing is deferred.


Full per-persona findings

DevX UX Expert

No findings.

Test Coverage Expert

  • [recommended] Affirmation: the mock target and scope are correct, and the test is still a valid regression trap after the fold. at tests/unit/test_cli_consistency_checker_workflow.py:71

Doc Writer

  • [recommended] Hidden aliases documented in reference/cli/ (for example apm info) would be flagged as high-severity drift. Folded in 2cbc8c7.
  • [recommended] Depth-3 subcommands (marketplace package add) have no intermediate page; map them to the top-level page. Folded in 2cbc8c7.
  • [recommended] Hidden options need a --option value --help probe (--branch on marketplace add). Folded in 7d41aec.

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-merge-worker. This comment is AI-generated and may contain errors.

Avoids landing-order conflicts with other queued PRs.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Lane L: main merged for landing

  • Pre-merge head: 7d41aec638741c939c4391816baf5d15537ca8bb
  • Merged origin/main c2c2e0d72c8e8c88f143099c73f40720b6529a4e (clean merge; GitHub reported DIRTY only on CHANGELOG.md, which this repo merges with merge=union).
  • New head: 09431c2c8b240aa3ce6f6a20f6fed7dec7c1d811
  • CHANGELOG: moved 1 bullet(s) in '### Fixed' after entry Add auto-bootstrap in apm install when no apm.yml exists #14 of 18, so queued PRs no longer collide at the section head while landing serially.
  • Lint: ruff check + ruff format --check silent at the new head; CI green at the new head.
  • Owner-touch report regenerated at the new head; every recorded functional test was re-run at that exact head and passed (one process at a time, no xdist).
  • Push: git push https://github.com/microsoft/apm.git HEAD:refs/heads/danielmeppiel-issue-3523-cli-consistency-checker (plain push, no force).

This comment was generated by an AI agent (Lane L landing desk) on behalf of Daniel Meppiel (@danielmeppiel).

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit da076f4 into main Nov 12, 2026
35 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-issue-3523-cli-consistency-checker branch November 12, 2026 18:38
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
#3608 added a longer view summary and #3643 added a check that root summaries are not truncated at 80 columns; together they fail tests/unit/test_cli_consistency.py on main and on every PR merge ref. Shorten the summary so the CI merge ref for this PR is green.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
This reverts commit bed006f. Lane F owns the main hotfix for the #3608 x #3643 root-help truncation; this PR stays out of that change.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
* fix(cli): shorten apm view summary so root help is not truncated

#3608 gave `apm view` a short_help that wraps at 80 columns, which
fails the root-help no-truncation check added in #3643.

apm-spec-waiver: help-text-only change, no spec surface

Co-authored-by: Copilot App <[email protected]>

* docs(changelog): note apm view root-help summary fix (#3651)

apm-spec-waiver: help-text-only change, no spec surface

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 12, 2026
…3614)

* fix: honor APM_HOME for global user state

Centralize APM-owned user metadata under APM_HOME while keeping target deployment paths independent. Document and test the contract across package, config, lifecycle, and architecture boundaries.

* fix: complete APM_HOME contract for receipts, marketplaces and docs (#2884)

Finish the APM_HOME single-root contract on top of the cherry-picked
change from @WilliamK112 (closed PR #2967):

- Deployment receipts move under get_apm_home(); the deploy-root
  .apm-local identity stays with the deployment root, like target files.
- The architecture guard also pins the deployment ledger consumer.
- Tests: subprocess isolation (two APM_HOME values, every global
  command family) and parity (unset/empty == ~/.apm); conftest drops a
  developer APM_HOME so the suite stays hermetic.
- Docs: env-var contract lists marketplace registrations, receipts,
  lock, precedence, migration and the out-of-contract paths; apm-guide
  and CHANGELOG updated (entry moved to Unreleased).

Co-authored-by: Ching-Wei Kang <[email protected]>
Co-authored-by: Copilot App <[email protected]>

* test: run APM_HOME isolation through the apm binary fixture (#2884)

Co-authored-by: Copilot App <[email protected]>

* docs(changelog): reference #3614 for APM_HOME entry

Co-authored-by: Copilot App <[email protected]>

* fix(scope): anchor a relative APM_HOME to the start directory

apm lock -g and apm update -g chdir into the APM home, so a relative APM_HOME such as 'metadata' resolved to metadata/metadata on later lookups and split the manifest from its lockfile, modules and config. get_apm_home() now expands a leading ~ and anchors a relative value once against the working directory captured at import. Addresses Copilot inline on src/apm_cli/core/scope.py:54 (#2884).

Co-authored-by: Copilot App <[email protected]>

* fix(locking): serialize state changes across APM_HOME values

Moving the lifecycle lock under APM_HOME let processes with different homes mutate the same project or harness directories at once, so a failed install's rollback could overwrite another operation's manifest. acquire_lifecycle_lock() now takes the OS-user deployment-root lock in ~/.apm-local/ (named by the deployment owner) before the APM_HOME metadata lock and releases both together; unset APM_HOME keeps the ~/.apm layout. Adds a cross-home contention regression and updates home write-set snapshots and the pre-compile lock probe. Addresses Copilot inline on src/apm_cli/install/locking.py:44 (#2884).

Co-authored-by: Copilot App <[email protected]>

* docs(apm-home): document relative values and cross-home locking

The APM_HOME path contract now states that ~ is expanded, a relative value resolves against the start directory, and ~/.apm-local/.apm-lifecycle.lock serializes commands across APM_HOME values. Mirrors the change in apm-guide and the CHANGELOG entry (#2884).

Co-authored-by: Copilot App <[email protected]>

* docs(changelog): drop stray #2938 entry from the 0.31.0 block

The cherry-pick from closed PR #2967 added a second Fixed heading with an unrelated GitLab entry inside the released 0.31.0 section. Released sections are not rewritten and the entry is outside #2884's scope. Addresses doc-writer panel finding on PR #3614.

Co-authored-by: Copilot App <[email protected]>

* docs(apm-home): link the path contract and fix stale ~/.apm wording

install.md still named ~/.apm/ as the canonical metadata root, and install/update/deps/lock each restated the APM_HOME contract. They now link the env-var reference instead; the env-var page no longer claims APM_HOME is read once. approve/deny --help, config_loader docstrings and lock -g help name the APM user home. Addresses doc-writer, devx-ux and auth panel findings on PR #3614.

Co-authored-by: Copilot App <[email protected]>

* fix(locking): harden the cross-home lock and relative APM_HOME

Adds a symlink-rejection regression for the ~/.apm-local deployment-root lock, loads LOCAL_STATE_DIR lazily so importing locking no longer pulls the deployment ledger, names the shared lock in the busy error, fails closed when a relative APM_HOME cannot be anchored, and documents the receipts containment base. Addresses test-coverage, python-architect, performance, devx-ux and supply-chain panel findings on PR #3614.

Co-authored-by: Copilot App <[email protected]>

* chore(spec): record Mode B waiver for the APM_HOME user-state root

The user-scope metadata location (APM_HOME) and lifecycle lock placement are CLI configuration, not OpenAPM manifest, lockfile or resolution behaviour, so no req anchor applies (#2884).

apm-spec-waiver: APM_HOME relocates CLI user-state paths only; no OpenAPM manifest, lockfile or resolution behaviour changes

Co-authored-by: Copilot App <[email protected]>

* docs(apm-home): document the fail-closed relative APM_HOME case

get_apm_home() now errors when a relative APM_HOME cannot be anchored because the start directory is gone; the env-var contract and apm-guide state it. Addresses doc-writer delta panel finding on PR #3614.

Co-authored-by: Copilot App <[email protected]>

* fix(view): fit the root help summary in 80 columns

#3608 added a longer view summary and #3643 added a check that root summaries are not truncated at 80 columns; together they fail tests/unit/test_cli_consistency.py on main and on every PR merge ref. Shorten the summary so the CI merge ref for this PR is green.

Co-authored-by: Copilot App <[email protected]>

* Revert "fix(view): fit the root help summary in 80 columns"

This reverts commit bed006f. Lane F owns the main hotfix for the #3608 x #3643 root-help truncation; this PR stays out of that change.

Co-authored-by: Copilot App <[email protected]>

---------

Co-authored-by: Ching-Wei Kang <[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 13, 2026
…led by apm install -g (#3610)

* fix: honor APM_HOME for global user state

Centralize APM-owned user metadata under APM_HOME while keeping target deployment paths independent. Document and test the contract across package, config, lifecycle, and architecture boundaries.

* feat(marketplace): declare marketplaces in the user manifest, reconciled by apm install -g

Add a 'marketplaces:' list (name + an existing 'apm marketplace add'
source form, optional ref) to the user manifest at the effective APM
user root. 'apm install -g' reconciles it before resolving
dependencies: registers missing entries, updates changed ones and
removes only manifest-origin entries. The registry records each
entry's origin; manual registrations are never overwritten or
removed, and name conflicts are reported. Project and package
manifests that declare 'marketplaces:' fail with an error naming the
user manifest.

The source-to-registration step is extracted from 'marketplace add'
into marketplace.registration so both paths share one parser/probe.

Refs #3006

Co-authored-by: Copilot App <[email protected]>

* docs(changelog): reference #3610

Co-authored-by: Copilot App <[email protected]>

* fix: complete APM_HOME contract for receipts, marketplaces and docs (#2884)

Finish the APM_HOME single-root contract on top of the cherry-picked
change from @WilliamK112 (closed PR #2967):

- Deployment receipts move under get_apm_home(); the deploy-root
  .apm-local identity stays with the deployment root, like target files.
- The architecture guard also pins the deployment ledger consumer.
- Tests: subprocess isolation (two APM_HOME values, every global
  command family) and parity (unset/empty == ~/.apm); conftest drops a
  developer APM_HOME so the suite stays hermetic.
- Docs: env-var contract lists marketplace registrations, receipts,
  lock, precedence, migration and the out-of-contract paths; apm-guide
  and CHANGELOG updated (entry moved to Unreleased).

Co-authored-by: Ching-Wei Kang <[email protected]>
Co-authored-by: Copilot App <[email protected]>

* test: run APM_HOME isolation through the apm binary fixture (#2884)

Co-authored-by: Copilot App <[email protected]>

* docs(changelog): reference #3614 for APM_HOME entry

Co-authored-by: Copilot App <[email protected]>

* test(marketplace): user-manifest marketplaces follow APM_HOME (#2884)

Co-authored-by: Copilot App <[email protected]>

* fix(scope): anchor a relative APM_HOME to the start directory

apm lock -g and apm update -g chdir into the APM home, so a relative APM_HOME such as 'metadata' resolved to metadata/metadata on later lookups and split the manifest from its lockfile, modules and config. get_apm_home() now expands a leading ~ and anchors a relative value once against the working directory captured at import. Addresses Copilot inline on src/apm_cli/core/scope.py:54 (#2884).

Co-authored-by: Copilot App <[email protected]>

* fix(locking): serialize state changes across APM_HOME values

Moving the lifecycle lock under APM_HOME let processes with different homes mutate the same project or harness directories at once, so a failed install's rollback could overwrite another operation's manifest. acquire_lifecycle_lock() now takes the OS-user deployment-root lock in ~/.apm-local/ (named by the deployment owner) before the APM_HOME metadata lock and releases both together; unset APM_HOME keeps the ~/.apm layout. Adds a cross-home contention regression and updates home write-set snapshots and the pre-compile lock probe. Addresses Copilot inline on src/apm_cli/install/locking.py:44 (#2884).

Co-authored-by: Copilot App <[email protected]>

* docs(apm-home): document relative values and cross-home locking

The APM_HOME path contract now states that ~ is expanded, a relative value resolves against the start directory, and ~/.apm-local/.apm-lifecycle.lock serializes commands across APM_HOME values. Mirrors the change in apm-guide and the CHANGELOG entry (#2884).

Co-authored-by: Copilot App <[email protected]>

* docs(changelog): drop stray #2938 entry from the 0.31.0 block

The cherry-pick from closed PR #2967 added a second Fixed heading with an unrelated GitLab entry inside the released 0.31.0 section. Released sections are not rewritten and the entry is outside #2884's scope. Addresses doc-writer panel finding on PR #3614.

Co-authored-by: Copilot App <[email protected]>

* docs(apm-home): link the path contract and fix stale ~/.apm wording

install.md still named ~/.apm/ as the canonical metadata root, and install/update/deps/lock each restated the APM_HOME contract. They now link the env-var reference instead; the env-var page no longer claims APM_HOME is read once. approve/deny --help, config_loader docstrings and lock -g help name the APM user home. Addresses doc-writer, devx-ux and auth panel findings on PR #3614.

Co-authored-by: Copilot App <[email protected]>

* fix(locking): harden the cross-home lock and relative APM_HOME

Adds a symlink-rejection regression for the ~/.apm-local deployment-root lock, loads LOCAL_STATE_DIR lazily so importing locking no longer pulls the deployment ledger, names the shared lock in the busy error, fails closed when a relative APM_HOME cannot be anchored, and documents the receipts containment base. Addresses test-coverage, python-architect, performance, devx-ux and supply-chain panel findings on PR #3614.

Co-authored-by: Copilot App <[email protected]>

* chore(spec): record Mode B waiver for the APM_HOME user-state root

The user-scope metadata location (APM_HOME) and lifecycle lock placement are CLI configuration, not OpenAPM manifest, lockfile or resolution behaviour, so no req anchor applies (#2884).

apm-spec-waiver: APM_HOME relocates CLI user-state paths only; no OpenAPM manifest, lockfile or resolution behaviour changes

Co-authored-by: Copilot App <[email protected]>

* docs(apm-home): document the fail-closed relative APM_HOME case

get_apm_home() now errors when a relative APM_HOME cannot be anchored because the start directory is gone; the env-var contract and apm-guide state it. Addresses doc-writer delta panel finding on PR #3614.

Co-authored-by: Copilot App <[email protected]>

* fix(view): fit the root help summary in 80 columns

#3608 added a longer view summary and #3643 added a check that root summaries are not truncated at 80 columns; together they fail tests/unit/test_cli_consistency.py on main and on every PR merge ref. Shorten the summary so the CI merge ref for this PR is green.

Co-authored-by: Copilot App <[email protected]>

* Revert "fix(view): fit the root help summary in 80 columns"

This reverts commit bed006f. Lane F owns the main hotfix for the #3608 x #3643 root-help truncation; this PR stays out of that change.

Co-authored-by: Copilot App <[email protected]>

* fix(marketplace): reconcile never destroys entries it cannot replace

A malformed user manifest root (empty, list, scalar or invalid YAML)
read as "no marketplaces" and removed every manifest-owned
registration before package parsing rejected the file. A failed fetch
for a renamed or moved entry still removed the stale one. Dry runs and
no-op runs created marketplaces.json and config.json.

Reject a non-mapping root before the registry is read, skip removals
while any declared entry failed, and read the registry without
creating files (read_registered_marketplaces).

Addresses Copilot inline on src/apm_cli/marketplace/reconcile.py:116,
:117 and :140.

Co-authored-by: Copilot App <[email protected]>

* refactor(marketplace): add parses SOURCE through the shared owner

`apm marketplace add` still split #ref fragments, resolved ref
precedence and classified direct URLs itself, a second authority for
the grammar the user-manifest reconcile parses with
parse_registration_source. Normalize the CLI-only --branch alias at
the command boundary and route add through the shared parser.

Extend the marketplace-source-admission owner to registration.py and
its guard: add and reconcile must call parse_registration_source, and
the command may not re-split fragments or classify direct URLs.
Behavioural, architecture and mutation tests cover the boundary, plus
regressions for the three reconcile safety fixes.

Addresses Copilot inline on src/apm_cli/marketplace/registration.py:89.

Co-authored-by: Copilot App <[email protected]>

* fix(install): keep commands/install.py within the 2100-line guard

main already sits at the 2100-line cap, so the reconcile hook pushed
install.py to 2105 and failed the Lint file-length guardrail. Make the
hook a single call (the user-scope check moves into
reconcile_user_marketplaces_or_exit) and collapse a single-name import.

Co-authored-by: Copilot App <[email protected]>

* docs(marketplace): follow APM_HOME and state reconcile limits

The user manifest path now reads $APM_HOME/apm.yml (default
~/.apm/apm.yml) everywhere this PR documents it, the source column
notes that entries have no --host equivalent, failure and hand-over
wording matches the code, apm install's reference notes the reconcile
step, the CHANGELOG leads with the benefit, the apm-guide row is
shorter and the "Declare instead of add" callout opens the add
section.

Addresses panel follow-ups from doc-writer, devx-ux-expert and
oss-growth-hacker.

Co-authored-by: Copilot App <[email protected]>

* refactor(marketplace): one registry write per reconcile, clearer output

Fetch every new or changed entry first, then apply all registrations
and removals in one locked transaction (apply_manifest_marketplaces)
instead of a lock-read-write cycle per entry. Removals use the [-]
symbol, the kept line pluralizes, a single failure is named directly,
and the manual-conflict warning shows the current source. The source
admission guard now also forbids reconcile.py from re-parsing SOURCE.
The integration module declares its component marker and covers
`apm install -g --dry-run` creating no registry files.

Addresses panel follow-ups from performance-expert, cli-logging-expert,
devx-ux-expert, test-coverage-expert, supply-chain-security-expert and
python-architect.

Co-authored-by: Copilot App <[email protected]>

* fix(marketplace): reject relative local sources in the user manifest

A relative local source such as ./catalog resolved against the
directory where `apm install -g` ran, so the same user manifest
registered different paths (or failed) depending on the cwd. Reject
it with an actionable error; absolute and ~/ paths are unchanged. The
shared not-found hint now says "use the path to the apm.yml file" so it
reads right for both `marketplace add` and a manifest `source:`.

Addresses delta panel follow-ups from doc-writer and cli-logging-expert.

Co-authored-by: Copilot App <[email protected]>

---------

Co-authored-by: Ching-Wei Kang <[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

Development

Successfully merging this pull request may close these issues.

cli-consistency-checker: inspect the full command surface and current CLI docs path

2 participants