Skip to content

fix: honor APM_HOME for global user state - #2967

Closed
Ching Wei Kang (WilliamK112) wants to merge 1 commit into
microsoft:mainfrom
WilliamK112:codex/apm-home-2884
Closed

Ching Wei Kang (WilliamK112) wants to merge 1 commit into
microsoft:mainfrom
WilliamK112:codex/apm-home-2884

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary

  • make APM_HOME the single canonical root for APM-owned user metadata: the user manifest, lockfile, modules, configuration, lifecycle trust/logs, command lock, registry workspace manifest, and legacy approval migration
  • keep target deployment independent, using target-specific overrides such as CLAUDE_CONFIG_DIR, CODEX_HOME, and HERMES_HOME, or the operating-system home
  • document the exact path and precedence contract across the environment-variable reference, affected CLI references, and the shipped APM guide

Architecture and tests

  • add an end-to-end global install isolation test with distinct HOME, APM_HOME, and CLAUDE_CONFIG_DIR
  • add focused coverage for configuration, scope helpers, lifecycle locking, command diagnostics, and lifecycle path parity
  • register a static architecture owner/guard so future APM metadata consumers cannot read APM_HOME independently or recreate the split
  • complete the existing mutation-matrix entry for the recently added onboarding-metadata-only guard while extending that same frozen matrix for the new APM_HOME guard

Validation

  • 22461 passed, 42 skipped, 21 xfailed — full unit suite (tests/unit tests/test_console.py, 2 workers)
  • 445 passed — architecture runner, entrypoint, and full owner-guard mutation matrix
  • 541 passed — affected command, compile, and APM_HOME contract suite
  • 469 passed — lifecycle, trust, registry, and executable-security paths
  • 281 passed — red-team suite
  • 431 passed, 38 skipped — Windows compatibility contract
  • 206 passed, 2 skipped — spec conformance suite; orphan and Mode-B gates passed
  • 170 passed — final focused integration regression run
  • Ruff lint/format, pylint duplicate-code guard, auth boundary lint, architecture boundary lint, CLI docs contract, rendered CLI registry check, schema ID check, and full Astro docs build all passed
  • generated docs link check validated 1,035 relative links

Closes #2884

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.

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

A critical shared-target locking issue and a moderate architecture-guard gap remain, alongside documentation inconsistencies.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR makes APM_HOME the canonical root for APM-owned global metadata while keeping target deployment paths independent.

Changes:

  • Routes manifests, configuration, lockfiles, lifecycle state, registry data, and approvals through APM_HOME.
  • Adds isolation tests, architecture guards, and mutation coverage.
  • Updates CLI help, documentation, shipped guides, and changelog references.
File summaries
File Summary
tests/unit/test_outdated_command.py Updates global path expectations.
tests/unit/test_config.py Tests APM_HOME configuration isolation.
tests/unit/scripts/test_architecture_runner.py Registers the architecture guard.
tests/unit/install/test_workspace_locking.py Tests APM_HOME lifecycle locking.
tests/unit/core/test_scope.py Tests metadata and target-root separation.
tests/unit/compilation/test_compile_global_flag.py Updates global target diagnostics.
tests/integration/test_compile_global.py Adds global install isolation coverage.
tests/integration/test_architecture_owner_rule_mutations.py Extends guard mutation coverage.
tests/integration/test_architecture_apm_home.py Tests canonical resolver enforcement.
src/apm_cli/security/executables.py Moves legacy approvals under APM_HOME.
src/apm_cli/install/phases/integrate.py Reports the effective configuration path.
src/apm_cli/install/manifest_helpers.py Updates user-scope install diagnostics.
src/apm_cli/install/locking.py Places lifecycle locks under APM_HOME.
src/apm_cli/deps/registry/config_loader.py Resolves manifests through the canonical root.
src/apm_cli/deps/registry/auth.py Updates registry remediation paths.
src/apm_cli/core/script_trust.py Moves trust state under APM_HOME.
src/apm_cli/core/script_executors.py Moves lifecycle logs under APM_HOME.
src/apm_cli/core/scope.py Defines canonical metadata-root resolution.
src/apm_cli/core/lifecycle_scripts.py Resolves lifecycle manifests canonically.
src/apm_cli/config.py Resolves user configuration from APM_HOME.
src/apm_cli/commands/view.py Updates global command help.
src/apm_cli/commands/update.py Updates global paths and diagnostics.
src/apm_cli/commands/uninstall/cli.py Updates global uninstall paths and output.
src/apm_cli/commands/outdated.py Updates global lockfile diagnostics.
src/apm_cli/commands/mcp.py Updates global MCP help.
src/apm_cli/commands/lock.py Updates global lock handling and help.
src/apm_cli/commands/lifecycle.py Reports the resolved lifecycle log path.
src/apm_cli/commands/install.py Documents metadata and deployment separation.
src/apm_cli/commands/discover.py Updates global manifest help.
src/apm_cli/commands/deps/why.py Updates global lockfile help.
src/apm_cli/commands/deps/cli.py Updates global dependency paths and help.
src/apm_cli/commands/config.py Reports the resolved configuration path.
src/apm_cli/commands/compile/cli.py Updates global compilation diagnostics.
src/apm_cli/commands/approve.py Uses the resolved user configuration path.
scripts/architecture_linter/checks/registry_owner_guards.py Adds the APM_HOME ownership guard.
packages/apm-guide/.apm/skills/apm-usage/governance.md Updates user configuration guidance.
packages/apm-guide/.apm/skills/apm-usage/commands.md Adds the metadata-root contract.
docs/src/content/docs/reference/environment-variables.md Documents APM_HOME paths and precedence.
docs/src/content/docs/reference/cli/view.md Documents global module paths.
docs/src/content/docs/reference/cli/update.md Documents global metadata paths.
docs/src/content/docs/reference/cli/uninstall.md Documents global uninstall paths.
docs/src/content/docs/reference/cli/self-update.md Updates configuration path wording.
docs/src/content/docs/reference/cli/publish.md Updates registry configuration paths.
docs/src/content/docs/reference/cli/outdated.md Updates global dependency paths.
docs/src/content/docs/reference/cli/mcp.md Documents global MCP manifest paths.
docs/src/content/docs/reference/cli/lock.md Documents global lock paths.
docs/src/content/docs/reference/cli/lifecycle.md Documents lifecycle state paths.
docs/src/content/docs/reference/cli/install.md Documents global install isolation.
docs/src/content/docs/reference/cli/experimental.md Updates experimental configuration paths.
docs/src/content/docs/reference/cli/deps.md Documents global dependency paths.
docs/src/content/docs/reference/cli/deny.md Updates user configuration paths.
docs/src/content/docs/reference/cli/config.md Documents configuration location and precedence.
docs/src/content/docs/reference/cli/compile.md Documents global compilation inputs.
docs/src/content/docs/reference/cli/approve.md Documents user approval storage.
CHANGELOG.md Records the APM_HOME behavior change.
.apm/architecture/owners/core-runtime.json Registers the canonical core-runtime owner.
Review details

Suppressed comments (12)

docs/src/content/docs/reference/cli/compile.md:148

  • The producer compile guide still says apm compile --global reads ~/.apm/apm_modules/ at docs/src/content/docs/producer/compile.md:288. With APM_HOME set, that guide directs users to the wrong input tree even though this reference now documents the override; update the guide to use $APM_HOME/apm_modules/ and its default.
| `-g, --global` | Compile user-scope root context files from `$APM_HOME/apm_modules` (default `~/.apm/apm_modules`). Writes targets declared by `target:` or `targets:` in `$APM_HOME/apm.yml`, or every supported user-scope target when neither field is declared. `APM_HOME` selects the input metadata only; compiled files use each target's home variable or the operating-system home. Not valid with project-output flags such as `--target`, `--all`, `--watch`, `--root`, or `--output`. Exits non-zero if the user-scope modules directory does not exist. |

docs/src/content/docs/reference/cli/mcp.md:31

  • The public MCP walkthrough still says the direct global command creates or updates ~/.apm/apm.yml at docs/src/content/docs/consumer/install-mcp-servers.md:243. That contradicts the $APM_HOME contract documented in this CLI reference, so users following the walkthrough can edit the wrong manifest; update the walkthrough to show $APM_HOME/apm.yml with the default noted.
updates `$APM_HOME/apm.yml` (default `~/.apm/apm.yml`) and writes only to
global-capable runtime configurations. `apm mcp install` is a forwarder that
calls the same code path -- use whichever spelling you prefer.

docs/src/content/docs/reference/cli/publish.md:26

  • The public registries guide still documents credentials, token precedence, and workspace registry paths under fixed ~/.apm locations (for example lines 116-156). That contradicts this CLI reference and causes an APM_HOME user to configure registry auth in a file APM does not read; update the guide's registry path and precedence examples to use $APM_HOME with the default.
The project's `apm.yml` must declare a `registries:` block with at least one registry URL. Publish credentials resolve via `APM_REGISTRY_TOKEN_{NAME}` or `apm config set registry.<name>.token`. Credentials are sent only when `registry.<name>.url` in `$APM_HOME/config.json` (default `~/.apm/config.json`) matches the publish destination.

docs/src/content/docs/reference/environment-variables.md:105

  • The new path contract lists the metadata files but omits the command lock introduced by this change ($APM_HOME/.apm-lifecycle.lock). Users therefore cannot identify all APM-owned state, and the documented exact-path contract is incomplete; add the lock path to this table.
| Lifecycle logs | `$APM_HOME/logs/` |

packages/apm-guide/.apm/skills/apm-usage/commands.md:9

  • This new shipped-guide contract is not reflected by the registry-auth guidance: packages/apm-guide/.apm/skills/apm-usage/authentication.md:266-295 still tells users to configure and verify credentials in ~/.apm/config.json without the $APM_HOME override. When APM_HOME is set, that advice points at a file APM no longer reads, so update the registry-auth page (and its precedence examples) to use $APM_HOME/config.json with the default noted here.
`APM_HOME` is the root for APM-owned user metadata: `apm.yml`,
`apm.lock.yaml`, `apm_modules/`, `config.json`, lifecycle trust, and lifecycle
logs. It defaults to `~/.apm`; every `~/.apm` path below describes that
default. Global package, dependency, lock, compile, lifecycle, and config
commands honor the override. Target deployments do not: target-specific home

packages/apm-guide/.apm/skills/apm-usage/commands.md:9

  • The new guide-wide contract says global compile commands honor APM_HOME, but this file still instructs users later to update ~/.apm/apm.yml (for example at lines 197 and 205). With an override, following that instruction edits a manifest that compilation will not read; change those operational references to $APM_HOME/apm.yml and reserve ~/.apm for the documented default.
`APM_HOME` is the root for APM-owned user metadata: `apm.yml`,
`apm.lock.yaml`, `apm_modules/`, `config.json`, lifecycle trust, and lifecycle
logs. It defaults to `~/.apm`; every `~/.apm` path below describes that
default. Global package, dependency, lock, compile, lifecycle, and config
commands honor the override. Target deployments do not: target-specific home

packages/apm-guide/.apm/skills/apm-usage/governance.md:23

  • Although this intro now names $APM_HOME/config.json, the same shipped skill still uses ~/.apm/config.json for registry precedence and user trust at lines 97, 110, 220, and 302. Those instructions are incorrect when APM_HOME is set; update the remaining references or link them to the canonical path contract.
`$APM_HOME/config.json` (default `~/.apm/config.json`) is user-scoped state, not org policy. Keep durable config
additive and narrow: `apm config` may persist non-secret defaults such as
install targets, transport preferences, and self-update installer preferences
(`self-update.channel`, `self-update.install-dir`). Do not use self-update
config for credentials, registry tokens, mirror URLs, commands, or installer

scripts/architecture_linter/checks/registry_owner_guards.py:661

  • This guard only rejects the literal "APM_HOME" outside core/scope.py; a future APM metadata consumer can still recreate the split by constructing the default Path.home() / ".apm" (or by using an aliased environment lookup), and this scan will pass. Since the PR claims this owner guard prevents future metadata consumers from bypassing the canonical root, extend it with a scope-aware check for hard-coded user-metadata roots while exempting intentional target/runtime paths.
        for node in index.nodes:
            if isinstance(node, ast.Constant) and node.value == "APM_HOME":
                findings.append(
                    violation(
                        rule_id,

src/apm_cli/commands/lock.py:30

  • This module now advertises $APM_HOME for --global, but the user-facing examples and SBOM --global help below still say ~/.apm/ (for example, lines 155 and 278). That contradicts the new path contract when APM_HOME is set; update those descriptions to $APM_HOME and mention the default only as a fallback.
    src/apm_cli/commands/update.py:36
  • The flag documentation correctly says global updates use $APM_HOME, but the command's user-facing example at line 474 still says ~/.apm/. With APM_HOME set, apm update -g does not operate on that path, so the help text contradicts the implementation and the new environment-variable contract.
    src/apm_cli/config.py:17
  • These constants now honor APM_HOME, but this module still documents ~/.apm/config.json in multiple public docstrings (get_config, remove_config, and the protocol/temp-dir helpers). With APM_HOME set those statements are false and can direct users to the wrong file; update them to $APM_HOME/config.json while retaining the default-path note.
    src/apm_cli/install/phases/integrate.py:534
  • This message now reports the configured config file, but the enclosing user-facing docstring still says approvals are persisted to ~/.apm/config.json. That is false when APM_HOME is set and makes the new diagnostic path contract inconsistent; describe it as $APM_HOME/config.json with ~/.apm only as the default.
  • Files reviewed: 56/56 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

def lifecycle_lock() -> FileLock:
"""Return the process-reentrant OS-user lifecycle lock."""
lock_path = Path.home() / ".apm" / _LIFECYCLE_LOCK_NAME
lock_path = get_apm_home() / _LIFECYCLE_LOCK_NAME
Comment thread CHANGELOG.md

### Fixed

- `APM_HOME` now consistently controls global manifests, lockfiles, modules, configuration, lifecycle trust, logs, and command locking while leaving target deployment destinations under their target-specific overrides or the operating-system home. (closes #2884)
Comment on lines +94 to +96
`APM_HOME` is the single root for APM-owned user metadata. When it is unset or
empty, the root is `~/.apm`. When set, global commands and lifecycle processing
use the same overridden root:
Comment on lines +87 to 92
# 3. user workspace ($APM_HOME/apm.yml, default ~/.apm/apm.yml)
from ...core.scope import InstallScope, get_manifest_path

workspace_yml = get_manifest_path(InstallScope.USER)
if workspace_yml.exists():
merged.update(_load_yaml_registries(workspace_yml))
Comment on lines +1269 to +1271
from ..core.scope import get_apm_home

return get_apm_home() / "approvals.yml"
@WilliamK112

Copy link
Copy Markdown
Contributor Author

After opening this PR, I saw the human-maintainer governance reset on #2884. Because this PR was opened after the earlier scope acceptance was withdrawn, I am closing it to respect the updated contribution rule.

The automated review also identified a real shared-target locking gap: separate APM_HOME values can still write the same runtime target, so this branch should not be merged as-is.

I will not continue substantive implementation unless a responsible human maintainer records the bounded scope, acceptance criteria, and review contact on the issue. The branch and validation work remain available if that approval is provided later.

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

[BUG] Document and align APM_HOME behavior for global user state

2 participants