Skip to content

copilot: apply the CopilotCliCommand policy to Linux packages and the macOS shim - #342101

Merged
Karthik Nadig (karthiknadig) merged 9 commits into
mainfrom
kanadig/copilot-cli-policy-unix
Oct 19, 2026
Merged

Karthik Nadig (karthiknadig) merged 9 commits into
mainfrom
kanadig/copilot-cli-policy-unix

Conversation

@karthiknadig

@karthiknadig Karthik Nadig (karthiknadig) commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

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 CopilotCliCommand policy now governs the copilot command at install time on Linux and in the shim on every platform, matching Windows setup:

CopilotCliCommand = false Windows Linux DEB/RPM macOS
Don't expose copilot on PATH, and remove what VS Code added Setup (existing) /usr/bin/copilot not created; a link to either edition's shim is removed on install, upgrade, reconfigure, and removal VS Code doesn't create a link (unchanged)
Don't install Copilot CLI Setup + shim (existing) Shim (from #342014) Shim reads the policy (configuration-profile domains of all qualities)
Integrated terminals Copilot extension (existing) Same Same
  • copilot --vscode-shim policy: exits 0 (allowed) or 10 (disabled) using the shim's platform reader, so package scripts don't parse policy.json in shell. Any other exit (missing shim, older shim → 2) is treated as unknown.
  • copilot-link.sh: install queries 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). remove queries the remaining edition's shim and hands the link over only when that edition is usable, wants the command, and the policy allows it.
  • DEB opt-out: new <package>/add-copilot-command debconf question (boolean, default true, medium priority so normal installs don't prompt), asked only by code and code-insiders. Admins can preseed it (echo "code code/add-copilot-command boolean false" | sudo debconf-set-selections); dpkg-reconfigure code asks it and re-applies the policy. RPM has no equivalent; the policy is the only control there.
  • macOS shim: CFPreferencesCopyAppValue for com.microsoft.VSCode, …VSCodeInsiders, …VSCodeExploration, com.visualstudio.code.oss; only CFBoolean false disables, any quality wins (same rule as Windows). New target-specific dependency core-foundation-sys 0.8.7.
  • Policy description and policyData.jsonc now mention the Linux packages; REQUIREMENTS.md documents the ordering (policy → debconf answer → install), the policy command, 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

Environment Command Result
Windows x64, Rust stable cargo test --locked --manifest-path copilot_shim/Cargo.toml Passed (69 lib + integration)
Windows, Rust stable cargo clippy --manifest-path copilot_shim/Cargo.toml --target {aarch64-apple-darwin,x86_64-unknown-linux-gnu} --all-targets --locked -- -D warnings; Windows --lib --test app Passed
rust:1.88 container (CI toolchain) cargo fmt --check, cargo test --locked, cargo clippy --all-targets --locked -- -D warnings Passed (72 lib tests; native policy test ignored as designed)
rust:1.88 container cargo clippy --target {aarch64,x86_64}-apple-darwin --all-targets --locked -- -D warnings Passed (macOS tests not executed)
Linux release shim copilot --vscode-shim policy with no/disabled/malformed policy and an extra option 0 / 10 / 0 / 2
node:24-bookworm-slim npm run test-copilot-shim-helper (new) Passed: 6 tests under dash and bash; all 6 fail against the helper from #342014
node:24-bookworm-slim, then Windows after 8d36014 npm run test-copilot-shim-rendering Passed. It now has 2 tests, which check the real helper source and templates; the 4 that only exercised the harness validator were removed in review
debian:stable-slim, real dpkg/debconf Minimal code/code-insiders DEBs rendered from the real templates and shim: pre-staged policy, upgrade, dpkg-reconfigure, preseeded opt-out, two-edition hand-over, foreign command, purge Passed: 20 scenarios; under a pseudo-TTY a default-priority install doesn't prompt, dpkg-reconfigure asks and applies the answer, and dpkg-reconfigure code-exploration doesn't ask
fedora:latest RPM %post/%postun rendered from the spec template, run as rpm does Passed: 9 scenarios
Repository npm run export-policy-data Only the CopilotCliCommand description changed
Repository npm run eslint -- <changed TS>, npm run precommit -- <changed files> Passed

Product build validation

Unpublished product builds of this branch (VSCODE_PUBLISH=false, VSCODE_RELEASE=false):

Build Contents Result
485321 Insiders: Linux x64 (DEB, RPM, snap) and macOS arm64, with tests and artifact sanity tests Passed: unit, integration, smoke, browser/remote, Copilot shim tests on Linux, and artifact sanity tests on Linux and macOS
485326 Stable: Linux x64, tests skipped (same commit as 485321) Linux stage passed. The build failed only at the Stable-only APIScan stage's production-readiness checkpoint, which doesn't touch Linux packaging
485379 Insiders: macOS x64 CLI only, to run the shim's Rust tests on macOS (the arm64 CLI job doesn't run them) Test 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 afterwards

Real packages from these builds, installed with the system package manager in clean containers:

Environment Scenario Result
ubuntu:24.04, apt Insiders DEB: disabled policy staged before install creates no link and the shipped shim's --vscode-shim policy exits 10; dpkg-reconfigure after lifting it creates the link, copilot --vscode-shim policy exits 0, copilot without Copilot CLI or a terminal prints the not-found message and exits 127; reinstall with a disabled policy removes the link; preseeded false gives it up and true restores it; disabled policy keeps a foreign /usr/bin/copilot; remove deletes the link; purge drops the question 13 checks passed
fedora:latest, dnf Insiders RPM: the same for install, reinstall, and remove 7 checks passed
ubuntu:24.04 and fedora:latest Stable and Insiders packages from the same commit: install Insiders, install Stable (takeover), reinstall Insiders (takeover), remove the owner (hand-over to Stable), remove the non-owner, remove the last edition; no vscode_copilot_link warnings, and copilot works whenever an edition is installed 7 steps passed with apt and with dnf

Validation limits

  • Don's full package-lifecycle matrix (npm run test-copilot-shim) wasn't run. The real-package checks above cover its main ownership cases and the new policy cases.
  • No real macOS configuration profile or cfprefsd propagation test; TPI microsoft/vscode-internalbacklog#10123 covers it.

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]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 16:07
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Base: 73c10ef7 Current: 9502b8fa

No screenshot changes.

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.

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

@vs-code-engineering

vs-code-engineering Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Raymond Zhao (@rzhao271)

Matched files:

  • resources/linux/debian/postinst.template
  • resources/linux/debian/postrm.template
  • resources/linux/debian/templates.template
  • resources/linux/rpm/code.spec.template

Comment thread test/sanity/src/copilotShim.test.ts Outdated
const formatLabel = runtime.format.toUpperCase();
const brandedIdentities = ['code', 'code-insiders'] as const;

describe(`Copilot shim ${formatLabel} package lifecycle`, () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. these new tests do not appear to be tagged with capabilities, so they will run on all platforms?
  2. what is the impact on sanity tests run time of adding this much tests?

@karthiknadig Karthik Nadig (karthiknadig) Oct 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't speak agent, sorry...

);
});

test('Embedded Copilot helper must remain exact when comments contain placeholders', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these tests for tests?

@karthiknadig Karthik Nadig (karthiknadig) Oct 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@DonJayamanne
Don Jayamanne (DonJayamanne) dismissed Dmitriy Vasyura (dmitrivMS)’s stale review October 19, 2026 18:55

he's not in, dismissing his blocker
His comments have been address by Karthik

@karthiknadig
Karthik Nadig (karthiknadig) merged commit 07f69c5 into main Oct 19, 2026
50 checks passed
@karthiknadig
Karthik Nadig (karthiknadig) deleted the kanadig/copilot-cli-policy-unix branch October 19, 2026 18:57
@vs-code-engineering vs-code-engineering Bot added this to the 1.144.0 milestone Oct 19, 2026
Don Jayamanne (DonJayamanne) added a commit that referenced this pull request Oct 19, 2026
#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]>
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.

5 participants