Skip to content

fix(targets): one owner for harness user roots; honor COPILOT_HOME (#3745) - #3782

Merged
Daniel Meppiel (danielmeppiel) merged 12 commits into
mainfrom
danielmeppiel-t3-p3-harness-user-root
Nov 17, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 12 commits into
mainfrom
danielmeppiel-t3-p3-harness-user-root

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Description

COPILOT_HOME was honored in only 3 places, each with its own rules, and the other
harness home variables (CODEX_HOME, CLAUDE_CONFIG_DIR, HERMES_HOME) had split
resolvers that treated relative values differently. The docs already promised that
COPILOT_HOME drives Copilot user-scope writes.

This PR adds one owner for harness user roots in integration/targets.py:

  • USER_ROOT_VARIABLES holds a UserRootVariable(env_var, default_dir, tool_label, evidence_url, verbatim)
    for claude, codex, hermes and copilot (new). configured_user_root(target) and
    resolve_user_root(target) are the only readers; USER_ROOT_ENV_VARS stays as a derived view.
  • Unset or blank selects the default. An absolute value (inside or outside HOME) selects
    that profile. A relative value fails for every variable with an error naming the
    variable (decision E1). Codex keeps its verbatim (untrimmed) value semantics.
  • Routed call sites: TargetProfile.for_scope (Copilot instructions, agents, hooks and
    --legacy-skill-paths skills now land under $COPILOT_HOME), user-scope auto-detection,
    scoped_profile_or_none/selected_user_profiles (a relative value skips only that
    target in scans), Copilot/Claude/Codex/Hermes MCP adapters, Hermes MCP cleanup,
    Copilot plugin settings, the canvas refusal (user_root_is_default), and the
    Copilot (lsp-config.json) and Claude (plugin dir) LSP user paths. resolve_hermes_root
    is folded into the owner.
  • Coupled fixes found by the L5 lifecycle test: Copilot hook ledger locators use the
    scope-resolved profile (they hardcoded the static .github profile, so hooks under an
    outside-HOME root could not be recorded); audit --ci labels a recorded file under an
    absolute user root from that root instead of crashing; is_other_profile_path ignores
    Copilot's project-scope .github profile.
  • copilot-app (~/.copilot/data.db) and copilot-cowork are unchanged; global canvas
    installs are still refused when COPILOT_HOME is non-default, now decided by the owner.

Static guard: new owner record harness-user-root-resolution (core-runtime shard) with
guard registry-delegation-harness-user-root-resolution. It fails if any src/ module
other than targets.py names COPILOT_HOME, CODEX_HOME, CLAUDE_CONFIG_DIR or
HERMES_HOME as 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-paths they go to $COPILOT_HOME/skills/.

Evidence (official docs):

Upgrade note (CHANGELOG): users who already set COPILOT_HOME see Copilot user
primitives move there on the next apm install -g; files under the old ~/.copilot
stay as another profile's files. A relative CLAUDE_CONFIG_DIR or HERMES_HOME now fails
instead of resolving against the current directory.

Docs: reference/environment-variables.md (new "Harness home variables" section, all four
rows), targets-matrix.md, cli/uninstall.md, cli/audit.md, install-mcp-servers.md,
install-lsp-servers.md, and packages/apm-guide/.apm/skills/apm-usage/commands.md.

Coordination: P5 (#3727 OpenCode LSP) rebases on this; lsp_integrator.py changes are
limited to _LSPTargetSpec (user_relative_path is 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 already
written under ~/.copilot. Not fixed here: #3773 (drift replay after
--legacy-skill-paths with home-relative roots), owned by a separate PR. With
COPILOT_HOME outside HOME the legacy-layout audit --ci is green, so the L5 legacy
assertion is not marked xfail.

Type of change

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

Testing

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

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, no
    network): COPILOT_HOME outside HOME, install -g --target copilot with and without
    --legacy-skill-paths places agents, instructions, hooks, MCP and LSP under it (skills under
    it only with the legacy flag, otherwise ~/.agents/skills); audit --ci green;
    uninstall -g and an MCP/LSP-free reinstall clean it; unsetting leaves the old profile; a
    relative value fails with no writes.
  • RT3 oracle scenarios copied from the red-team branch (2304a64c54):
    test_harness_user_root_lifecycle.py, test_copilot_home_adjacent_lifecycle.py,
    _harness_output_kit.py.

Fails before the fix (run against main 2769573 with the new tests copied in and a shim
binary running the base source):

  • TestHarnessUserRootOwner: 23 failed, 6 passed (the 6 cover already-correct Codex/Hermes
    absolute paths, the canvas refusal and other-profile scans).
  • test_copilot_home_profile_lifecycle.py: 4 failed (agents, instructions, hooks and LSP not
    under COPILOT_HOME; relative COPILOT_HOME accepted with exit 0).

Validation commands (all run locally on this head):

Command Result
uvx [email protected] check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py passed
uvx [email protected] format --check (same paths) passed
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.py passed (10.00/10)
bash scripts/lint-auth-signals.sh passed
bash scripts/lint-architecture-boundaries.sh passed
YAML I/O, 2100-line file length, str(relative_to) guards (from ci.yml) passed
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" 61 passed
pytest -p no:xdist over the 32 unit files that touch these variables, LSP, or user-scope profiles, plus hook integrator and file scanner unit tests 1940 passed, 1 skipped
APM_BINARY_PATH=.venv/bin/apm pytest -p no:xdist tests/integration/test_copilot_home_profile_lifecycle.py 4 passed
APM_BINARY_PATH=.venv/bin/apm pytest -p no:xdist tests/integration/test_harness_user_root_lifecycle.py tests/integration/test_copilot_home_adjacent_lifecycle.py 10 passed
APM_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.py 105 passed, 6 skipped

Not run: full unit and integration suites (shared host; CI runs them).

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

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.

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]>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 16:10
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.36.1 milestone Nov 17, 2026

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

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

Comment thread src/apm_cli/adapters/client/hermes.py Resolved
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Single-owner centralization of four harness user-root variables with relative-path rejection and COPILOT_HOME support strengthens APM's multi-harness defensibility.

panel-mode=lean; personas=python-architect,devx-ux-expert,test-coverage-expert,apm-ceo

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

All three panelists converge on a clean ship signal. The python-architect confirms the frozen-dataclass single-owner pattern (USER_ROOT_VARIABLES, configured_user_root, resolve_user_root) is idiomatic APM architecture: four independent environment lookups collapse into one registry, every reader routes through it, and the new registry-delegation-harness-user-root-resolution guard keeps it that way as new harnesses arrive. The test-coverage-expert verified the new tests pass on HEAD across unit, lifecycle and integration tiers, with 23 of 29 owner unit cases and 4 of 4 L5 lifecycle cases failing on main, which confirms real regression coverage rather than tautological assertions.

The sole finding comes from the devx-ux-expert: install.md documents Claude Code profiles in detail (line 221) but has no COPILOT_HOME counterpart, and the uninstall.md heading excludes Copilot even though its body now covers it. That is a real discoverability gap for Copilot CLI users reading the canonical install reference. Widening to "Harness profiles" covering all four variables is the scalable frame and avoids per-harness sections as the roster grows.

Strategically, harness user-root resolution becomes a single-owner concern with validated absolute paths, so any future harness goes through the same contract. The CHANGELOG upgrade note (Copilot user primitives move on the next install -g; old ~/.copilot files stay) is honest and actionable.

Aligned with: multi-harness, multi-host (one owner for COPILOT_HOME, CODEX_HOME, CLAUDE_CONFIG_DIR and HERMES_HOME); secure by default (relative values rejected for all four with a named-variable error, enforced by an architecture guard); pragmatic as npm (COPILOT_HOME follows the override convention users already know).

Panel summary

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

  1. [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]>
…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]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Drive-to-merge pass: ready to merge

Head 9875f44f78 (merged with main bfda71b). The PR is mergeable; it is waiting on CODEOWNERS review from Sergio Sisternes (@sergio-sisternes-epam).

Folded in this run

  • (panel) install.md now has a Copilot CLI profiles note, and the uninstall section is renamed "Harness profiles". Resolved in 00aab82.
  • (copilot) Hermes integration test patches now set HERMES_HOME instead of patching the removed resolve_hermes_root. Resolved in 84fad9b.
  • (copilot) LSP refuses a configured COPILOT_HOME/CLAUDE_CONFIG_DIR outside HOME when the root itself is a symlink. Resolved in 84fad9b.
  • (CI) Lifecycle Smoke on Linux has no harness binaries, which showed that user-scope LSP target detection ignored the owner-selected user root. Detection now counts a harness whose user root exists. The frozen rule inventory now lists the new guard, and tests/integration/test_architecture_harness_user_root.py was added. Resolved in a2f5c65.

Copilot signals reviewed

  • src/apm_cli/adapters/client/hermes.py:70 -- LEGIT: stale resolve_hermes_root patches in integration tests (resolved in 84fad9b).
  • src/apm_cli/integration/lsp_integrator.py:436 -- LEGIT (narrowed): a symlinked outside-HOME root is now refused, matching the existing refusal of a symlinked ~/.copilot or ~/.claude. Parent components above the root are not checked, because system paths such as /tmp are often symlinks (resolved in 84fad9b).

Regression-trap evidence (mutation-break gate)

  • tests/unit/integration/test_lsp_integrator.py::TestInstallUserScope::test_rejects_symlinked_configured_root_outside_home -- deleted the symlink refusal in _target_config_path; the test FAILED as expected; guard restored.
  • tests/unit/integration/test_lsp_integrator.py::TestResolveLspTargets::test_user_scope_detects_the_configured_user_root -- deleted the user_root_exists candidates; both cases FAILED; guard restored.
  • tests/unit/integration/test_targets.py::TestHarnessUserRootOwner and tests/integration/test_copilot_home_profile_lifecycle.py -- run against main source: 23/29 and 4/4 FAILED.

Lint contract

At 9875f44f78, ruff check and ruff format --check (ruff 0.15.12) report nothing, pylint R0801 scores 10.00, and lint-auth-signals and lint-architecture-boundaries exit 0.

CI

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

Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 17, 2026
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]>
Daniel Meppiel (danielmeppiel) added a commit to gideruette/apm that referenced this pull request Nov 17, 2026
… 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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 17, 2026
…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]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Lane L: main merged for landing

  • Pre-merge head: 9875f44f78cf0b9740df63d10affc87ab2b2e300
  • Merged origin/main 82f8047b70b35920f8db9e02940c7e2770c566f2 (clean merge; GitHub reported DIRTY only on CHANGELOG.md, which this repo merges with merge=union).
  • New head: 702672a4b807672140f479ebbcdcd47871fcb816
  • CHANGELOG: moved 1 bullet(s) in '### Fixed' after entry Integrate copilot runtime #2 of 2, 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-t3-p3-harness-user-root (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 28e7450 into main Nov 17, 2026
26 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-t3-p3-harness-user-root branch November 17, 2026 20:54
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
…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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
#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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
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]>
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.

[FEATURE] Honor COPILOT_HOME for global Copilot skill deployment

2 participants