Skip to content

linux: expose the Copilot shim in DEB/RPM packages - #342014

Closed
Don Jayamanne (DonJayamanne) wants to merge 3 commits into
mainfrom
don/agents/unix-document-review-summary
Closed

Don Jayamanne (DonJayamanne) wants to merge 3 commits into
mainfrom
don/agents/unix-document-review-summary

Conversation

@DonJayamanne

Copy link
Copy Markdown
Contributor

Summary

  • Expose the bundled native Copilot shim through /usr/bin/copilot in Linux DEB/RPM Stable and Insiders packages, including external terminals.
  • Port the Linux-only CopilotCliCommand policy reader from fix: enforce Copilot CLI shim policy on macOS and Linux #341916. An eligible installed CLI still launches; disabled policy blocks installation of a missing CLI.
  • Preserve the Linux installer child's original PATH, avoiding removal of system utilities when a shim is exposed through /usr/bin. Retain shim-aware discovery and installation-directory fallback.
  • Manage the shared link through guarded lifecycle hooks: the last installed/upgraded edition takes ownership; uninstalling its owner falls back to the other usable shim. Preserve unrelated commands and warn without failing editor installation when link handling fails.
  • Add runtime regressions, a focused package-lifecycle test harness, and related documentation; bump the shim to 0.1.1.

Windows/macOS behaviour, existing code launchers, and independent Copilot CLI installations/data are intended to remain unchanged. Snap exposure, archive layout/exposure, downstream recipes, and special handling for image-based Fedora systems are deferred. Shared Linux runtime changes still reach binaries bundled in those existing formats.

Validation

The following checks were run during implementation; successful checks were reused while their relevant inputs remained unchanged.

Environment Command Result
Linux x64, Rust 1.88.0, isolated container; working directory copilot_shim cargo test --locked Passed: 75 tests. The native-policy test is deliberately ignored in the ordinary run and was executed separately below.
Same Linux environment cargo fmt --check Passed.
Same Linux environment cargo clippy --all-targets --locked -- -D warnings Passed.
Same Linux environment, with an exclusively provisioned temporary policy fixture VSCODE_COPILOT_SHIM_NATIVE_POLICY_TEST=1 VSCODE_COPILOT_SHIM_NATIVE_POLICY_TEST_ROOT=/etc/vscode cargo test --locked --test native_policy -- --ignored --exact native_binary_dispatches_provisioned_policy Passed: 1 native dispatch test; fixture cleaned up.
Windows x64, Rust 1.98.1 cargo test --manifest-path copilot_shim\Cargo.toml --locked Passed: 75 tests.
Windows, after related test refinements cargo test --manifest-path copilot_shim\Cargo.toml --locked --lib app::tests Passed: 11 tests.
Windows, affected Rust targets cargo clippy --manifest-path copilot_shim\Cargo.toml --lib --test app --test native_policy --test pty --locked -- -D warnings Passed.
Windows npm --prefix test\sanity run compile Passed, including the final pre-commit compile.
Windows npm --prefix test\sanity run test-copilot-shim-rendering Passed: 2 checks.
Windows; working directory build\azure-pipelines\oss npx --yes [email protected] tsx cargo-section4.test.ts Passed: 52 lockfile-harvesting checks; this is not complete licence approval.
Repository root git diff --cached --check Passed.

Targeted TypeScript lint also passed:

npm run eslint -- build\gulpfile.vscode.linux.ts test\sanity\src\copilotShimFixtures.ts test\sanity\src\copilotShimHarness.ts test\sanity\src\copilotShimIndex.ts test\sanity\src\copilotShimRuntime.ts test\sanity\src\copilotShimRendering.ts test\sanity\src\copilotShimRenderingIndex.ts test\sanity\src\copilotShimRendering.test.ts test\sanity\src\copilotShim.test.ts test\sanity\src\generateCopilotShimFixtures.ts

An additional isolated smoke using an actual /usr/bin/copilot shim and merged /bin alias verified unchanged installer/downloader/CLI PATH, available system utilities, one installation, and two successful fallback launches.

Validation limitations:

  • Actual DEB/RPM package transactions and the new package-lifecycle matrix have not been executed successfully end to end.
  • Official product installer builds, native macOS execution, other architectures, and release-artifact/GLIBC checks have not been performed for this change.
  • Full Windows all-target Clippy under Rust 1.98 reports an existing chunks_exact lint in unchanged ConPTY tests; affected Windows targets and all Linux targets under Rust 1.88 pass.

Draft follow-ups

The read-only review and subsequent rubber-duck review identified these test-tooling issues. They are intentionally left unfixed in this draft:

  • P2: Complete-package smoke invokes the nested editor launcher rather than verifying the public /usr/bin/code / /usr/bin/code-insiders command.
  • P3: Custom-runner isolation checks miss descendant bind mounts. The supplied Docker wrapper does not create those mounts.
  • P3: DEB fixtures removed during a scenario are no longer tracked for final purge, leaving residual dpkg/debconf state.
  • P3: Optional minimal OSS fixture generation incorrectly requires a Copilot shim even when the input is valid without one.

Installer validation

Build this branch with the existing Azure product pipeline using VSCODE_BUILD_TYPE=Product, the required Linux architecture, VSCODE_BUILD_LINUX_SNAP=false, VSCODE_PUBLISH=false, and VSCODE_RELEASE=false. Keep tests enabled; artifact-backed sanity testing can be enabled with VSCODE_RUN_ARTIFACT_SANITY_TESTS=true.

Use separate Stable and Insiders builds from the same implementation commit to test fresh installation, cross-edition takeover, owner/non-owner removal, fallback, and preservation of unrelated commands. Retain older/newer package revisions for genuine upgrade tests. The existing artifact sanity tests do not replace the full new ownership matrix.

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]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 10:53

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

Placeholder validation and root launcher invocation prevent the new package-lifecycle matrix from completing.

2 open findings
What changed in this PR

Exposes the bundled Copilot shim through Linux DEB/RPM packages, with guarded shared-command ownership and Linux installation-policy enforcement.

Changes:

  • Adds lifecycle-managed /usr/bin/copilot links for Stable and Insiders.
  • Preserves Linux installer PATH and adds native policy enforcement.
  • Adds runtime regressions, 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 checks.
test/​sanity/​src/​copilotShimRendering.ts Validates embedded helpers and hooks.
test/​sanity/​src/​copilotShimRendering.test.ts Tests template rendering contracts.
test/​sanity/​src/​copilotShimIndex.ts Configures the focused lifecycle runner.
test/​sanity/​src/​copilotShimHarness.ts Implements package transactions and assertions.
test/​sanity/​src/​copilotShimFixtures.ts Loads and validates fixture manifests.
test/​sanity/​src/​copilotShim.test.ts Covers 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 runner markers and directories.
test/​sanity/​README.md Documents fixture generation and validation.
test/​sanity/​package.json Adds focused test commands.
test/​sanity/​fixtures/​copilot-shim-fixtures.schema.json Defines fixture manifest structure.
test/​sanity/​fixtures/​copilot-shim-fixture-plan.example.json Provides an example fixture plan.
resources/​linux/​rpm/​code.spec.template Adds RPM lifecycle hooks.
resources/​linux/​debian/​postrm.template Handles shared-link removal and fallback.
resources/​linux/​debian/​postinst.template Selects the shared link during configuration.
resources/​linux/​copilot-link.sh Implements guarded shared-link management.
copilot_shim/​tests/​pty.rs Tests inherited PATH and fallback launches.
copilot_shim/​tests/​native_policy.rs Tests native Linux policy dispatch.
copilot_shim/​src/​runtime.rs Delegates policy checks to the reader.
copilot_shim/​src/​policy.rs Implements Linux policy parsing.
copilot_shim/​src/​lib.rs Registers the policy module.
copilot_shim/​src/​install.rs Preserves Linux installer PATH.
copilot_shim/​src/​candidate.rs Limits production PATH filtering to non-Linux Unix.
copilot_shim/​src/​app.rs Extends policy and installer regressions.
copilot_shim/​SHIM_POST_INSTALL.md Explains platform-specific installation behavior.
copilot_shim/​REQUIREMENTS.md Defines Linux exposure and policy contracts.
copilot_shim/​Cargo.toml Bumps shim version and adds JSON support.
copilot_shim/​Cargo.lock Locks updated version and dependencies.
build/​gulpfile.vscode.linux.ts Embeds the helper into package templates.

🧠 Review effort: Balanced


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

Comment thread test/sanity/src/copilotShimHarness.ts Resolved
Comment thread test/sanity/src/copilotShimRendering.ts Resolved
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]>
@karthiknadig

Copy link
Copy Markdown
Member

Superseded by #342101, which includes every commit from this PR (c25b427 is an ancestor of its head). #342101 also adds the CopilotCliCommand policy at package install time, the add-copilot-command debconf opt-out, and the macOS policy reader, and it's validated with real DEB/RPM packages from unpublished product builds. Closing in favor of it; the branch is left in place.

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.

4 participants