Repository navigation
fix(targets): one owner for harness user roots; honor COPILOT_HOME (#3745) - #3782
Conversation
Promote the harness user-root variables into one registered owner in integration/targets.py (USER_ROOT_VARIABLES, configured_user_root, resolve_user_root) and add COPILOT_HOME. Route every reader through it: for_scope, user-scope detection, the Copilot, Claude, Codex and Hermes MCP adapters, Copilot plugin settings, the canvas refusal, Hermes MCP cleanup and the Copilot/Claude LSP user paths. Copilot hook ledger locators use the scope-resolved profile, and audit labels recorded files under an absolute user root from that root. Relative values are now rejected for every variable (decision E1). A new architecture guard (registry-delegation-harness-user-root-resolution) bans naming these variables outside the owner table. Fixes #3745 apm-spec-waiver: harness user-root resolution is native-harness path behavior; no OpenAPM requirement pins it Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
LSP installation and cleanup can follow external-root symlinks and modify unintended configuration, while outdated Hermes resolver mocks cause three integration tests to fail before exercising the adapter.
2 open issues
What changed in this PR
This PR addresses #3745 by centralizing harness user-root resolution and making Copilot CLI user-scope deployment honor COPILOT_HOME, while preserving project paths and desktop app behavior.
Changes:
- Unifies home-variable handling for Copilot, Claude, Codex, and Hermes, including rejection of relative paths.
- Routes configuration, deployment tracking, cleanup, and audit through the selected roots.
- Adds lifecycle tests, architecture guards, and documentation for profile behavior.
| File | Description |
|---|---|
| tests/unit/integration/test_targets.py | Tests shared root resolution and consumer consistency. |
| tests/integration/test_harness_user_root_lifecycle.py | Covers relocated roots and relative-path rejection. |
| tests/integration/test_copilot_home_profile_lifecycle.py | Exercises Copilot install, audit, and cleanup. |
| tests/integration/test_copilot_home_adjacent_lifecycle.py | Checks desktop app and compile behavior remain unchanged. |
| tests/integration/test_architecture_owner_rule_mutations.py | Adds mutation coverage for owner delegation. |
| tests/integration/_harness_output_kit.py | Provides isolated lifecycle test helpers. |
| tests/conftest.py | Clears inherited harness home variables. |
| src/apm_cli/security/file_scanner.py | Labels recorded files under external roots. |
| src/apm_cli/integration/targets.py | Defines the canonical harness root resolver. |
| src/apm_cli/integration/mcp_integrator.py | Routes Hermes cleanup through the resolver. |
| src/apm_cli/integration/lsp_integrator.py | Uses selected roots for user LSP paths and cleanup. |
| src/apm_cli/integration/hook_integrator.py | Records hooks with scope-resolved profiles. |
| src/apm_cli/integration/canvas_integrator.py | Delegates default-root checks to the owner. |
| src/apm_cli/copilot_plugins/settings.py | Resolves plugin settings through the owner. |
| src/apm_cli/adapters/client/hermes.py | Delegates Hermes MCP root resolution. |
| src/apm_cli/adapters/client/copilot.py | Delegates Copilot MCP root resolution. |
| src/apm_cli/adapters/client/codex.py | Delegates Codex MCP root resolution. |
| src/apm_cli/adapters/client/claude.py | Delegates Claude configured-root selection. |
| scripts/architecture_linter/checks/registry_owner_guards.py | Enforces centralized home-variable handling. |
| scripts/architecture_linter/checks/mutation_hook_contract.py | Updates MCP guards to require owner delegation. |
| packages/apm-guide/.apm/skills/apm-usage/commands.md | Documents profile rules and configuration destinations. |
| docs/src/content/docs/reference/targets-matrix.md | Clarifies Copilot user deployment locations. |
| docs/src/content/docs/reference/environment-variables.md | Documents the shared harness home contract. |
| docs/src/content/docs/reference/cli/uninstall.md | Describes Copilot profile-aware removal. |
| docs/src/content/docs/reference/cli/audit.md | Adds Copilot external roots to audit guidance. |
| docs/src/content/docs/consumer/install-mcp-servers.md | Clarifies Copilot MCP path requirements. |
| docs/src/content/docs/consumer/install-lsp-servers.md | Documents configurable user LSP roots. |
| CHANGELOG.md | Records the fix and upgrade behavior. |
| .apm/architecture/owners/core-runtime.json | Registers the harness user-root owner and guard. |
Review effort: Balanced
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | Clean single-owner centralization of harness user-root variables; frozen dataclass, dual guardrails, and delegation pattern are idiomatic APM architecture. |
| DevX UX Expert | 0 | 1 | 0 | Error message and env-vars docs are clear and actionable; one discoverability gap where Copilot profile behavior hides behind Claude-only headings in install.md and uninstall.md. |
| Test Coverage Expert | 0 | 0 | 0 | All critical surfaces (user-root resolution, relative rejection, install/audit/uninstall lifecycle, LSP/MCP routing, detection, canvas) have regression traps at the e2e lifecycle tier. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 1 follow-ups
- [DevX UX Expert] Widen install.md and uninstall.md profile docs from Claude-only to all harness roots, or add a parallel Copilot CLI profiles section. -- Copilot CLI users reading the canonical install reference will not discover COPILOT_HOME profile behavior; a "Harness profiles" heading covering all four variables is the scalable fix.
Recommendation
Merge after CODEOWNERS review from Sergio Sisternes (@sergio-sisternes-epam). The single recommended follow-up (widening install/uninstall profile docs to cover all harness roots, not just Claude) is real but small; it can fold into this PR or land as a fast-follow docs change. Architecture, security contract and test coverage are where they need to be for 0.36.1.
Full per-persona findings
Python Architect
No findings.
DevX UX Expert
- [recommended] install.md documents Claude Code profiles but not Copilot CLI profiles, hiding this PR's primary behavior from the canonical CLI reference page. at
docs/src/content/docs/reference/cli/install.md:221
install.md line 221 has a detailed "Claude Code profiles" note and links to uninstall.md#claude-code-and-codex-profiles; there is no COPILOT_HOME counterpart, and the uninstall heading excludes Copilot although its body now covers it.
Suggested: Widen to "Harness profiles" covering all four variables (preferred), renaming the uninstall section and anchor; or add a parallel "Copilot CLI profiles" note linking to Harness home variables.
Test Coverage Expert
No findings.
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.
… Harness profiles Folds the panel's devx-ux finding on #3782. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…st patches Folds Copilot review on #3782: an outside-HOME COPILOT_HOME or CLAUDE_CONFIG_DIR that is itself a symlink is refused for LSP writes and cleanup, matching the in-HOME behavior. Integration tests that patched the removed resolve_hermes_root now set HERMES_HOME. Co-authored-by: Copilot App <[email protected]>
…root CI Lifecycle Smoke (no harness binaries) showed uninstall -g could not choose an LSP target when only COPILOT_HOME existed. At user scope LSP candidates now count a harness whose user root exists, through the user-root owner. Registers the new rule in the frozen rule inventory and adds the per-owner architecture regression test. Co-authored-by: Copilot App <[email protected]>
…l-t3-p3-harness-user-root
Co-authored-by: Copilot App <[email protected]>
Drive-to-merge pass: ready to mergeHead Folded in this run
Copilot signals reviewed
Regression-trap evidence (mutation-break gate)
Lint contractAt CIGreen at the exact head: 23 pass, 3 skipping (CodeQL, advisory eligibility, deploy), 0 failing. One CI fix iteration was needed (the Linux lifecycle smoke and the frozen rule inventory, above). The canonical-owner gate verified all 9 touched owners against exact-head functional tests. Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors. |
Panel folds for #3793: - uninstall rebuilds survivors in the layout the survivors recorded; the removed packages' paths only feed cleanup, which now recognises both layouts (with_every_skill_layout), so a mixed lockfile never migrates a survivor between layouts - the owner derives the per-client prefix from skills_rel_root - export-patch diff targets follow the recorded layout like the replay; export_patch.py joins the guard's rebuild modules - tests: env-rooted user scope lifecycle over every USER_ROOT_ENV_VARS target with converged skills (codex runs today, copilot with #3782), catalog-wide unit round-trip, mixed-layout uninstall cases, and the RT4 subset test checks .agents/skills before xfailing on #3760 only apm-spec-waiver: skill layout recovery for audit and uninstall rebuilds; no spec requirement changes Co-authored-by: Copilot App <[email protected]>
… built-ins Rework of microsoft#3730 for 0.36.1 (microsoft#3727), on top of the harness user-root owner (microsoft#3782). - F1: declared LSP servers with no LSP-capable selected target now fail before any target write. install/lsp/integration.py owns the refusal (require_lsp_capable_target). The install pipeline runs preflight_lsp_targets at the start of the integrate phase (after downloads, before skills, lockfile or .gitignore writes); service integration and apm update prepare LSP and call PreparedLspIntegration.require_capable_target before any MCP write. Local bundles and run_lsp_integration route through the same owner. New guard install-deployment-lsp-capability-gate on the lsp-lifecycle owner record, with a mutation case. - G1: when APM creates the `lsp` key of opencode.json it prints an [i] line: an `lsp` object turns on OpenCode's built-in language servers (https://opencode.ai/docs/lsp/). Docs say the same. - OpenCode user path routes through the harness user-root owner (resolve_user_root falls back to the profile's documented user_root_dir, ~/.config/opencode; OpenCode documents no replacing config-dir variable), and user-scope LSP detection uses the owner like copilot and claude. - L7 lifecycle scenario from RT3; its uninstall case is the pre-existing microsoft#3768 and is marked xfail(strict=True). apm-spec-waiver: OpenAPM v0.1 defines no LSP runtime config; adapter output and install gating only Co-authored-by: Gilderic Deruette <[email protected]> Co-authored-by: Copilot App <[email protected]>
…3773) (#3793) * fix(skills): rebuild recorded skills in the layout the install used (#3773) `apm install --legacy-skill-paths` deploys skills to per-client roots (.github/skills, ~/.copilot/skills), but nothing downstream knew that: the `apm audit --ci` drift replay and the uninstall cleanup and survivor rebuild resolved targets without the flag, so a clean legacy install was reported as drift and uninstalling an unrelated package re-deployed survivors into .agents/skills unrecorded. integration/skill_layout.py now owns the effective skill layout: install passes its flag through resolve_skill_layout, and every flagless rebuild recovers the layout from the lockfile's recorded deployed paths (resolve_reintegration_targets; resolve_audit_targets routes through it). No lockfile schema change. Guarded by install-deployment-skill-layout. apm-spec-waiver: skill layout recovery for audit and uninstall rebuilds; no spec requirement changes Co-authored-by: Copilot App <[email protected]> * docs(changelog): record the legacy skill layout fix (#3793) Co-authored-by: Copilot App <[email protected]> * fix(skills): rebuild uninstall survivors in their own recorded layout Panel folds for #3793: - uninstall rebuilds survivors in the layout the survivors recorded; the removed packages' paths only feed cleanup, which now recognises both layouts (with_every_skill_layout), so a mixed lockfile never migrates a survivor between layouts - the owner derives the per-client prefix from skills_rel_root - export-patch diff targets follow the recorded layout like the replay; export_patch.py joins the guard's rebuild modules - tests: env-rooted user scope lifecycle over every USER_ROOT_ENV_VARS target with converged skills (codex runs today, copilot with #3782), catalog-wide unit round-trip, mixed-layout uninstall cases, and the RT4 subset test checks .agents/skills before xfailing on #3760 only apm-spec-waiver: skill layout recovery for audit and uninstall rebuilds; no spec requirement changes Co-authored-by: Copilot App <[email protected]> * fix(skills): recognise the legacy layout when a user root equals HOME A harness user root equal to HOME (for example CODEX_HOME=$HOME) scopes to root_dir ".", so the per-client prefix was "./skills/" while the lockfile records "skills/...". Normalize the prefix before matching. apm-spec-waiver: skill layout recovery for audit and uninstall rebuilds; no spec requirement changes Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Avoids landing-order conflicts with other queued PRs. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Lane L: main merged for landing
This comment was generated by an AI agent (Lane L landing desk) on behalf of Daniel Meppiel (@danielmeppiel). |
…ny write (#3727) (#3730) * fix(targets): one owner for harness user roots; honor COPILOT_HOME Promote the harness user-root variables into one registered owner in integration/targets.py (USER_ROOT_VARIABLES, configured_user_root, resolve_user_root) and add COPILOT_HOME. Route every reader through it: for_scope, user-scope detection, the Copilot, Claude, Codex and Hermes MCP adapters, Copilot plugin settings, the canvas refusal, Hermes MCP cleanup and the Copilot/Claude LSP user paths. Copilot hook ledger locators use the scope-resolved profile, and audit labels recorded files under an absolute user root from that root. Relative values are now rejected for every variable (decision E1). A new architecture guard (registry-delegation-harness-user-root-resolution) bans naming these variables outside the owner table. Fixes #3745 apm-spec-waiver: harness user-root resolution is native-harness path behavior; no OpenAPM requirement pins it Co-authored-by: Copilot App <[email protected]> * docs(changelog): reference #3782 Co-authored-by: Copilot App <[email protected]> * docs(cli): document Copilot CLI profiles; rename uninstall section to Harness profiles Folds the panel's devx-ux finding on #3782. Co-authored-by: Copilot App <[email protected]> * chore: restore uv.lock (accidentally rewritten locally) Co-authored-by: Copilot App <[email protected]> * fix(lsp): refuse a symlinked user root outside HOME; update Hermes test patches Folds Copilot review on #3782: an outside-HOME COPILOT_HOME or CLAUDE_CONFIG_DIR that is itself a symlink is refused for LSP writes and cleanup, matching the in-HOME behavior. Integration tests that patched the removed resolve_hermes_root now set HERMES_HOME. Co-authored-by: Copilot App <[email protected]> * fix(lsp): detect user-scope LSP targets from the owner-selected user root CI Lifecycle Smoke (no harness binaries) showed uninstall -g could not choose an LSP target when only COPILOT_HOME existed. At user scope LSP candidates now count a harness whose user root exists, through the user-root owner. Registers the new rule in the frozen rule inventory and adds the per-owner architecture regression test. Co-authored-by: Copilot App <[email protected]> * docs(changelog): keep Unreleased sections ordered after merging main Co-authored-by: Copilot App <[email protected]> * fix(lsp): write dependencies.lsp to opencode.json for the opencode target (closes #3727) `apm install --target opencode` failed after deploying skills when a package declared dependencies.lsp, because only claude and copilot had an LSP target adapter. Add an opencode adapter that merges servers into the `lsp` key of opencode.json (project) or ~/.config/opencode/opencode.json (user): command and args become one command array, extensionToLanguage keys become `extensions`, initializationOptions becomes `initialization`, fields OpenCode lacks are dropped, and socket-transport servers are skipped with a warning. Other keys such as `mcp` are preserved; `$schema` is added only when APM creates the file. Target ownership in the lockfile is recorded from the servers each target can actually write, so a skipped server is never claimed and later cleanup cannot delete a same-name user entry. The config path gate is now pinned to the spec's exact path in both scopes, which admits the root-level opencode.json without widening harness prefixes; the LSP target-contract architecture rule follows the single resolve_deploy_path call. Error hints list every LSP-capable target. Fixes #3727 apm-spec-waiver: OpenAPM v0.1 defines no LSP runtime config; adapter output only Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(lsp): gate the LSP capability gap before any write; note OpenCode built-ins Rework of #3730 for 0.36.1 (#3727), on top of the harness user-root owner (#3782). - F1: declared LSP servers with no LSP-capable selected target now fail before any target write. install/lsp/integration.py owns the refusal (require_lsp_capable_target). The install pipeline runs preflight_lsp_targets at the start of the integrate phase (after downloads, before skills, lockfile or .gitignore writes); service integration and apm update prepare LSP and call PreparedLspIntegration.require_capable_target before any MCP write. Local bundles and run_lsp_integration route through the same owner. New guard install-deployment-lsp-capability-gate on the lsp-lifecycle owner record, with a mutation case. - G1: when APM creates the `lsp` key of opencode.json it prints an [i] line: an `lsp` object turns on OpenCode's built-in language servers (https://opencode.ai/docs/lsp/). Docs say the same. - OpenCode user path routes through the harness user-root owner (resolve_user_root falls back to the profile's documented user_root_dir, ~/.config/opencode; OpenCode documents no replacing config-dir variable), and user-scope LSP detection uses the owner like copilot and claude. - L7 lifecycle scenario from RT3; its uninstall case is the pre-existing #3768 and is marked xfail(strict=True). apm-spec-waiver: OpenAPM v0.1 defines no LSP runtime config; adapter output and install gating only Co-authored-by: Gilderic Deruette <[email protected]> Co-authored-by: Copilot App <[email protected]> * fix(lsp): one LSP target resolution for the preflight and the service phase Review fold for #3730. The pipeline LSP gate resolved targets without --runtime and --exclude, so `apm install --target cursor,opencode --exclude opencode` passed the gate, deployed skills, then failed in the service phase. The request now carries an LspPreflight (runtime, exclude; apm install sets it only for full installs), and preflight_lsp_targets and prepare_lsp_integration both resolve through _resolve_lsp_target_runtimes with lsp_target_config(apm_package). The capability-gate guard now also requires that single resolution. template._effective_allow becomes the public effective_allow_map, which the preflight reuses. L7 adds regression traps for --exclude, -g, apm update and --only apm. apm-spec-waiver: OpenAPM v0.1 defines no LSP runtime config; install gating only Co-authored-by: Gilderic Deruette <[email protected]> Co-authored-by: Copilot App <[email protected]> * fix(lsp): write user-scope LSP configs owner-only Copilot review fold for #3730: ~/.config/opencode/opencode.json (and the other user-scope LSP configs) can carry literal `env` values, but the LSP writer created them with the umask mode (0644). User-scope writes now keep the file 0600, like user-scope MCP configs; project configs keep their existing or umask mode. apm-spec-waiver: OpenAPM v0.1 defines no LSP runtime config; file mode only Co-authored-by: Gilderic Deruette <[email protected]> Co-authored-by: Copilot App <[email protected]> * chore(changelog): place #3782 entry away from the section head Avoids landing-order conflicts with other queued PRs. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
#3782 rejects relative harness user-root values (decision E1). On Windows a POSIX literal such as "/custom/hermes" has no drive and is relative, so TestHermesConfigPath::test_hermes_home_override failed on the release Windows unit run. Build the values from a temp directory instead, fix the two other POSIX literals set for CLAUDE_CONFIG_DIR and COPILOT_HOME, and mark the three tests windows_compat so the PR-time Windows gate runs them. Refs #3745 Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>
Re-verified the sweep's recorded findings on environment-variables, targets-matrix, install-packages, registries, registry-http-api and governance-guide against current main (after #3785, #3774, #3782, #3743, #3797 merged) and fixed what is still drifted. Refs #3800 Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>

Description
COPILOT_HOMEwas honored in only 3 places, each with its own rules, and the otherharness home variables (
CODEX_HOME,CLAUDE_CONFIG_DIR,HERMES_HOME) had splitresolvers that treated relative values differently. The docs already promised that
COPILOT_HOMEdrives Copilot user-scope writes.This PR adds one owner for harness user roots in
integration/targets.py:USER_ROOT_VARIABLESholds aUserRootVariable(env_var, default_dir, tool_label, evidence_url, verbatim)for claude, codex, hermes and copilot (new).
configured_user_root(target)andresolve_user_root(target)are the only readers;USER_ROOT_ENV_VARSstays as a derived view.that profile. A relative value fails for every variable with an error naming the
variable (decision E1). Codex keeps its verbatim (untrimmed) value semantics.
TargetProfile.for_scope(Copilot instructions, agents, hooks and--legacy-skill-pathsskills now land under$COPILOT_HOME), user-scope auto-detection,scoped_profile_or_none/selected_user_profiles(a relative value skips only thattarget in scans), Copilot/Claude/Codex/Hermes MCP adapters, Hermes MCP cleanup,
Copilot plugin settings, the canvas refusal (
user_root_is_default), and theCopilot (
lsp-config.json) and Claude (plugin dir) LSP user paths.resolve_hermes_rootis folded into the owner.
scope-resolved profile (they hardcoded the static
.githubprofile, so hooks under anoutside-HOME root could not be recorded);
audit --cilabels a recorded file under anabsolute user root from that root instead of crashing;
is_other_profile_pathignoresCopilot's project-scope
.githubprofile.~/.copilot/data.db) and copilot-cowork are unchanged; global canvasinstalls are still refused when
COPILOT_HOMEis non-default, now decided by the owner.Static guard: new owner record
harness-user-root-resolution(core-runtime shard) withguard
registry-delegation-harness-user-root-resolution. It fails if anysrc/moduleother than
targets.pynamesCOPILOT_HOME,CODEX_HOME,CLAUDE_CONFIG_DIRorHERMES_HOMEas a string constant, if the owner reads the environment more than once,if the owner table misses a variable, or if a routed consumer stops calling the owner.
The existing Copilot/Claude MCP path guards now require the owner call instead of the
variable literal. Mutation cases added/updated in
test_architecture_owner_rule_mutations.py.Default layout (confirmed intent): default user-scope Copilot skills keep going to the
shared
~/.agents/skills/; with--legacy-skill-pathsthey go to$COPILOT_HOME/skills/.Evidence (official docs):
COPILOT_HOMEreplaces the entire~/.copilotpath, which holdsagents/,skills/,instructions/,hooks/,mcp-config.jsonandlsp-config.json:https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-config-dir-reference
("
COPILOT_HOMEreplaces the entire~/.copilotpath.")~/.agents/skills/discovery is independent ofCOPILOT_HOME: the skill-locations tablelists
~/.copilot/skills/and, separately,~/.agents/skills/("Agent skills shared acrossall projects"):
https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference#skill-locations
https://code.claude.com/docs/en/env-vars (
CLAUDE_CONFIG_DIR, absolute path),https://developers.openai.com/codex/config-advanced (
CODEX_HOME, default~/.codex),https://hermes-agent.nousresearch.com/docs/reference/environment-variables (
HERMES_HOME).Upgrade note (CHANGELOG): users who already set
COPILOT_HOMEsee Copilot userprimitives move there on the next
apm install -g; files under the old~/.copilotstay as another profile's files. A relative
CLAUDE_CONFIG_DIRorHERMES_HOMEnow failsinstead of resolving against the current directory.
Docs:
reference/environment-variables.md(new "Harness home variables" section, all fourrows),
targets-matrix.md,cli/uninstall.md,cli/audit.md,install-mcp-servers.md,install-lsp-servers.md, andpackages/apm-guide/.apm/skills/apm-usage/commands.md.Coordination: P5 (#3727 OpenCode LSP) rebases on this;
lsp_integrator.pychanges arelimited to
_LSPTargetSpec(user_relative_pathis now relative to the harness user root,plus
user_cleanup_empty_relative_dirs) and_target_config_path.Issue and approved scope
Issue: Fixes #3745
Human scope-approval comment: #3745 (comment)
Does this PR complete the issue, or what remains? It completes it. Out of scope per the
record: Copilot desktop app and cowork paths,
GEMINI_CLI_HOME, migrating files alreadywritten under
~/.copilot. Not fixed here: #3773 (drift replay after--legacy-skill-pathswith home-relative roots), owned by a separate PR. WithCOPILOT_HOMEoutside HOME the legacy-layoutaudit --ciis green, so the L5 legacyassertion is not marked xfail.
Type of change
Testing
New tests:
tests/unit/integration/test_targets.py::TestHarnessUserRootOwner(29 cases): unset, blank,absolute under HOME, absolute outside HOME and relative (rejected) for each variable, and
every routed call site (for_scope, MCP adapter, plugin settings, LSP) resolves the same
physical root; detection, canvas refusal and LSP labels follow the owner.
tests/integration/test_copilot_home_profile_lifecycle.py(L5, real binary, temp HOME, nonetwork):
COPILOT_HOMEoutside HOME,install -g --target copilotwith and without--legacy-skill-pathsplaces agents, instructions, hooks, MCP and LSP under it (skills underit only with the legacy flag, otherwise
~/.agents/skills);audit --cigreen;uninstall -gand an MCP/LSP-free reinstall clean it; unsetting leaves the old profile; arelative value fails with no writes.
test_harness_user_root_lifecycle.py,test_copilot_home_adjacent_lifecycle.py,_harness_output_kit.py.Fails before the fix (run against
main2769573 with the new tests copied in and a shimbinary running the base source):
TestHarnessUserRootOwner: 23 failed, 6 passed (the 6 cover already-correct Codex/Hermesabsolute paths, the canvas refusal and other-profile scans).
test_copilot_home_profile_lifecycle.py: 4 failed (agents, instructions, hooks and LSP notunder
COPILOT_HOME; relativeCOPILOT_HOMEaccepted with exit 0).Validation commands (all run locally on this head):
uvx [email protected] check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.pyuvx [email protected] format --check(same paths)python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.pybash scripts/lint-auth-signals.shbash scripts/lint-architecture-boundaries.shstr(relative_to)guards (from ci.yml)pytest -p no:xdist tests/integration/test_architecture_owner_rule_mutations.py -k "harness or copilot-cli-mcp or claude-mcp or sorted or coverage or nothing_before or registry"pytest -p no:xdistover the 32 unit files that touch these variables, LSP, or user-scope profiles, plus hook integrator and file scanner unit testsAPM_BINARY_PATH=.venv/bin/apm pytest -p no:xdist tests/integration/test_copilot_home_profile_lifecycle.pyAPM_BINARY_PATH=.venv/bin/apm pytest -p no:xdist tests/integration/test_harness_user_root_lifecycle.py tests/integration/test_copilot_home_adjacent_lifecycle.pyAPM_BINARY_PATH=.venv/bin/apm pytest -p no:xdist tests/integration/test_claude_config_profile_lifecycle.py test_global_audit_deploy_root.py test_canvas_integration.py test_hermes_target.py test_compile_global.py test_profile_uninstall_runtime_scope_lifecycle.py test_copilot_native_plugin_binary_lifecycle.pyNot run: full unit and integration suites (shared host; CI runs them).
Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.
Harness home directories are native-harness path behavior; no OpenAPM requirement pins
them. The commit carries an
apm-spec-waiver:line for the Mode B gate.