Repository navigation
copilot: apply the CopilotCliCommand policy to Linux packages and the macOS shim - #342101
Conversation
Honor Linux installation policy and preserve the official installer PATH. Manage Stable and Insiders command ownership through guarded package lifecycle hooks. Add native runtime regressions and a focused package lifecycle harness while leaving deferred packaging formats and non-Linux behavior unchanged. Co-authored-by: Copilot <[email protected]>
Preserve the upstream macOS Copilot installation flow alongside Linux native policy enforcement and DEB/RPM command exposure. Co-authored-by: Copilot <[email protected]>
Use a scenario-local profile for root launcher validation and ignore disabled shell comments when checking unresolved package placeholders. Preserve strict helper validation and add focused regressions. Co-authored-by: Copilot <[email protected]>
…summary' into kanadig/copilot-cli-policy-unix
… macOS shim The Linux DEB/RPM scripts now ask the shim for the CopilotCliCommand policy before managing /usr/bin/copilot, matching Windows setup: a disabled policy removes a link to either edition's shim instead of creating one, and an unreadable policy leaves the entry unchanged. DEB packages add a preseedable <package>/add-copilot-command debconf question (medium priority, default true) that lets an edition opt out; hand-over on removal respects the other edition's answer and the policy. The shim gains `--vscode-shim policy`, which exits 0 when the policy allows the command and 10 when it turns it off, and reads the policy on macOS from the configuration-profile domains of every quality (ported from #341916). Co-authored-by: Don Jayamanne <[email protected]> Co-authored-by: Copilot <[email protected]>
|
Base:
|
There was a problem hiding this comment.
🔵 Needs a closer look
Native macOS policy behavior and the complete source-built DEB/RPM lifecycle matrix still require runtime validation and human review.
0 open findings
What changed in this PR
Extends CopilotCliCommand enforcement to Linux package installation and the macOS native shim, aligning command exposure and installation controls with Windows.
Changes:
- Adds policy-aware Linux link management and a DEB opt-out.
- Adds native policy readers and a policy-query command while preserving Linux installer PATH.
- Adds regression tests, isolated package-lifecycle tooling, and documentation.
| File | Description |
|---|---|
| test/sanity/src/generateCopilotShimFixtures.ts | Generates package fixtures and provenance. |
| test/sanity/src/copilotShimRuntime.ts | Stores lifecycle runner configuration. |
| test/sanity/src/copilotShimRenderingIndex.ts | Runs rendering tests. |
| test/sanity/src/copilotShimRendering.ts | Validates embedded helpers and lifecycle calls. |
| test/sanity/src/copilotShimRendering.test.ts | Tests template rendering safeguards. |
| test/sanity/src/copilotShimIndex.ts | Launches the isolated lifecycle suite. |
| test/sanity/src/copilotShimHelperIndex.ts | Runs helper tests. |
| test/sanity/src/copilotShimHelper.test.ts | Tests policy, opt-out, and handover behavior. |
| test/sanity/src/copilotShimFixtures.ts | Defines and validates fixture manifests. |
| test/sanity/src/copilotShim.test.ts | Covers package ownership and lifecycle scenarios. |
| test/sanity/scripts/run-copilot-shim-container.sh | Launches disposable test containers. |
| test/sanity/scripts/provision-copilot-shim-runner.sh | Provisions isolated runner markers. |
| test/sanity/README.md | Documents testing and fixture workflows. |
| test/sanity/package.json | Adds focused test and generation commands. |
| test/sanity/fixtures/copilot-shim-fixtures.schema.json | Defines the fixture manifest schema. |
| test/sanity/fixtures/copilot-shim-fixture-plan.example.json | Provides an example fixture plan. |
| src/vs/workbench/contrib/chat/browser/chat.shared.contribution.ts | Updates the policy description. |
| src/vs/platform/agentHost/common/agentHostPolicySupport.ts | Updates the enforcement comment only. |
| resources/linux/rpm/code.spec.template | Adds installation and removal hooks. |
| resources/linux/debian/templates.template | Adds the command opt-out question. |
| resources/linux/debian/postrm.template | Applies policy-aware link removal. |
| resources/linux/debian/postinst.template | Applies debconf choice and link installation. |
| resources/linux/copilot-link.sh | Manages the shared command with policy checks. |
| copilot_shim/tests/pty.rs | Tests inherited Linux PATH and fallback launch. |
| copilot_shim/tests/native_policy.rs | Adds isolated native Linux policy coverage. |
| copilot_shim/src/runtime.rs | Delegates to platform policy readers. |
| copilot_shim/src/policy.rs | Implements Linux and macOS policy readers. |
| copilot_shim/src/lib.rs | Registers the policy module. |
| copilot_shim/src/invocation.rs | Parses the policy-query command. |
| copilot_shim/src/install.rs | Preserves Linux installer PATH. |
| copilot_shim/src/candidate.rs | Restricts production PATH filtering to non-Linux Unix. |
| copilot_shim/src/app.rs | Reports policy status and adds regressions. |
| copilot_shim/SHIM_POST_INSTALL.md | Explains platform-specific installer behavior. |
| copilot_shim/REQUIREMENTS.md | Documents policy and package lifecycle contracts. |
| copilot_shim/Cargo.toml | Updates shim version and platform dependencies. |
| copilot_shim/Cargo.lock | Records updated dependency resolution. |
| build/lib/policies/policyData.jsonc | Updates exported policy documentation. |
| build/gulpfile.vscode.linux.ts | Embeds the helper into package scripts. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Raymond Zhao (@rzhao271)Matched files:
|
| const formatLabel = runtime.format.toUpperCase(); | ||
| const brandedIdentities = ['code', 'code-insiders'] as const; | ||
|
|
||
| describe(`Copilot shim ${formatLabel} package lifecycle`, () => { |
There was a problem hiding this comment.
- these new tests do not appear to be tagged with capabilities, so they will run on all platforms?
- what is the impact on sanity tests run time of adding this much tests?
There was a problem hiding this comment.
Edited: a script bug posted the wrong text here, sorry about that.
They don't run in the sanity tests at all, so there's no run time impact. The sanity runner (src/index.ts) only loads main.js. These tests have their own npm scripts (test-copilot-shim, test-copilot-shim-rendering, and test-copilot-shim-helper) that no pipeline runs. test-copilot-shim installs and removes real DEB/RPM packages as root, so it only runs in a disposable Linux container.
There was a problem hiding this comment.
Don't speak agent, sorry...
| ); | ||
| }); | ||
|
|
||
| test('Embedded Copilot helper must remain exact when comments contain placeholders', () => { |
There was a problem hiding this comment.
Are these tests for tests?
There was a problem hiding this comment.
Edited: a script bug posted the wrong text here, sorry about that.
Mostly, yes. Four of them tested the test harness's own checks rather than product code, so I removed them in 8d36014. The two that are left check the real resources/linux/copilot-link.sh and that the DEB/RPM templates include it correctly.
There was a problem hiding this comment.
Huh? :-)
Keep the checks of the real link helper source and the DEB/RPM templates; the removed cases tested the package-lifecycle harness's own validator rather than product code. Co-authored-by: Copilot <[email protected]>
…olicy-unix # Conflicts: # copilot_shim/REQUIREMENTS.md
…olicy-unix # Conflicts: # copilot_shim/REQUIREMENTS.md
main's #342224 and this branch both changed the shim and bumped it from 0.1.0 to 0.1.1. Windows setup keeps a published shim whose file version matches, so the merged shim needs its own version to replace main's 0.1.1. Co-authored-by: Copilot <[email protected]>
he's not in, dismissing his blocker
His comments have been address by Karthik
#342660) copilot: apply the CopilotCliCommand policy to Linux packages and the macOS shim (#342101) * linux: expose the Copilot shim in DEB/RPM packages Honor Linux installation policy and preserve the official installer PATH. Manage Stable and Insiders command ownership through guarded package lifecycle hooks. Add native runtime regressions and a focused package lifecycle harness while leaving deferred packaging formats and non-Linux behavior unchanged. * test: fix Copilot package launcher and rendering checks Use a scenario-local profile for root launcher validation and ignore disabled shell comments when checking unresolved package placeholders. Preserve strict helper validation and add focused regressions. * copilot: apply the CopilotCliCommand policy to Linux packages and the macOS shim The Linux DEB/RPM scripts now ask the shim for the CopilotCliCommand policy before managing /usr/bin/copilot, matching Windows setup: a disabled policy removes a link to either edition's shim instead of creating one, and an unreadable policy leaves the entry unchanged. DEB packages add a preseedable <package>/add-copilot-command debconf question (medium priority, default true) that lets an edition opt out; hand-over on removal respects the other edition's answer and the policy. The shim gains `--vscode-shim policy`, which exits 0 when the policy allows the command and 10 when it turns it off, and reads the policy on macOS from the configuration-profile domains of every quality (ported from #341916). * test: drop rendering tests that only exercised the harness validator Keep the checks of the real link helper source and the DEB/RPM templates; the removed cases tested the package-lifecycle harness's own validator rather than product code. * copilot: bump the shim to 0.1.2 main's #342224 and this branch both changed the shim and bumped it from 0.1.0 to 0.1.1. Windows setup keeps a published shim whose file version matches, so the merged shim needs its own version to replace main's 0.1.1. --------- Co-authored-by: Karthik Nadig <[email protected]> Co-authored-by: Copilot <[email protected]>
Addresses microsoft/vscode-internalbacklog#10108. Builds on Don Jayamanne (@DonJayamanne)'s #342014 (merged in here with its commits) and ports the macOS reader from his #341916.
Summary
The
CopilotCliCommandpolicy now governs thecopilotcommand at install time on Linux and in the shim on every platform, matching Windows setup:CopilotCliCommand= falsecopiloton PATH, and remove what VS Code added/usr/bin/copilotnot created; a link to either edition's shim is removed on install, upgrade, reconfigure, and removalcopilot --vscode-shim policy: exits0(allowed) or10(disabled) using the shim's platform reader, so package scripts don't parsepolicy.jsonin shell. Any other exit (missing shim, older shim →2) is treated as unknown.copilot-link.sh:installqueries the edition's shim. Disabled → withdraw a link to either edition's shim (foreign entries are preserved). Unknown → warn and leave the entry unchanged (never create a link).removequeries the remaining edition's shim and hands the link over only when that edition is usable, wants the command, and the policy allows it.<package>/add-copilot-commanddebconf question (boolean, defaulttrue, medium priority so normal installs don't prompt), asked only bycodeandcode-insiders. Admins can preseed it (echo "code code/add-copilot-command boolean false" | sudo debconf-set-selections);dpkg-reconfigure codeasks it and re-applies the policy. RPM has no equivalent; the policy is the only control there.CFPreferencesCopyAppValueforcom.microsoft.VSCode,…VSCodeInsiders,…VSCodeExploration,com.visualstudio.code.oss; onlyCFBoolean falsedisables, any quality wins (same rule as Windows). New target-specific dependencycore-foundation-sys 0.8.7.policyData.jsoncnow mention the Linux packages; REQUIREMENTS.md documents the ordering (policy → debconf answer → install), thepolicycommand, and how to re-apply a changed policy before the next upgrade (dpkg-reconfigure/ RPM reinstall).Policy changes made after installation apply on the next upgrade or reconfiguration. Until then a leftover link still can't install Copilot CLI, because the shim enforces the policy at runtime.
Validation
cargo test --locked --manifest-path copilot_shim/Cargo.tomlcargo clippy --manifest-path copilot_shim/Cargo.toml --target {aarch64-apple-darwin,x86_64-unknown-linux-gnu} --all-targets --locked -- -D warnings; Windows--lib --test apprust:1.88container (CI toolchain)cargo fmt --check,cargo test --locked,cargo clippy --all-targets --locked -- -D warningsrust:1.88containercargo clippy --target {aarch64,x86_64}-apple-darwin --all-targets --locked -- -D warningscopilot --vscode-shim policywith no/disabled/malformed policy and an extra option0/10/0/2node:24-bookworm-slimnpm run test-copilot-shim-helper(new)dashandbash; all 6 fail against the helper from #342014node:24-bookworm-slim, then Windows after 8d36014npm run test-copilot-shim-renderingdebian:stable-slim, realdpkg/debconfcode/code-insidersDEBs rendered from the real templates and shim: pre-staged policy, upgrade,dpkg-reconfigure, preseeded opt-out, two-edition hand-over, foreign command, purgedpkg-reconfigureasks and applies the answer, anddpkg-reconfigure code-explorationdoesn't askfedora:latest%post/%postunrendered from the spec template, run as rpm doesnpm run export-policy-dataCopilotCliCommanddescription changednpm run eslint -- <changed TS>,npm run precommit -- <changed files>Product build validation
Unpublished product builds of this branch (
VSCODE_PUBLISH=false,VSCODE_RELEASE=false):APIScanstage's production-readiness checkpoint, which doesn't touch Linux packagingTest Copilot shim,Lint Copilot shim(clippy), and formatting passed on macOS, including the macOS policy reader's tests. The rest of the build was canceled afterwardsReal packages from these builds, installed with the system package manager in clean containers:
ubuntu:24.04,apt--vscode-shim policyexits10;dpkg-reconfigureafter lifting it creates the link,copilot --vscode-shim policyexits0,copilotwithout Copilot CLI or a terminal prints the not-found message and exits127; reinstall with a disabled policy removes the link; preseededfalsegives it up andtruerestores it; disabled policy keeps a foreign/usr/bin/copilot; remove deletes the link; purge drops the questionfedora:latest,dnfubuntu:24.04andfedora:latestvscode_copilot_linkwarnings, andcopilotworks whenever an edition is installedaptand withdnfValidation limits
npm run test-copilot-shim) wasn't run. The real-package checks above cover its main ownership cases and the new policy cases.cfprefsdpropagation test; TPI microsoft/vscode-internalbacklog#10123 covers it.