Skip to content

Freeze compiler-generated Copilot SDK npm installs - #71885

Closed
pelikhan with Copilot wants to merge 9 commits into
mainfrom
copilot/aw-top-10-09-make-generated-npm-and-pip-installs-d
Closed

pelikhan with Copilot wants to merge 9 commits into
mainfrom
copilot/aw-top-10-09-make-generated-npm-and-pip-installs-d

Conversation

Copilot AI commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Shared compiler templates multiply non-deterministic dependency installs across generated workflows. This change freezes the Node SDK dependency tree while preserving existing exact-version npm and pip defaults.

  • Locked SDK installs

    • Embed separate Node.js and TypeScript manifests and integrity-checked lockfiles.
    • Replace 160 SDK install commands across 102 workflow lockfiles with:
      cd "${GITHUB_WORKSPACE}/.gh-aw/copilot-sdk"
      npm ci --ignore-scripts --no-audit --no-fund
  • Runtime compatibility

    • Isolate installation from repository manifests and node_modules.
    • Preserve CommonJS and ESM SDK resolution through scoped module hooks.
  • Regression contracts

    • Assert version pins, lockfile integrity, SDK-version synchronization, workspace preservation, and module resolution.
  • Human review

    • SDK dependencies move into .gh-aw/copilot-sdk.
    • Update undici from 6.28.0 to 6.29.1 and override vulnerable transitive zod with 4.6.6.
  • Scope and remaining verification

    • Global CLI installs retain exact version pins; their transitive dependencies are not frozen here.
    • Scanning-alert reduction remains unverified because the API returned 403.

Copilot AI changed the title [WIP] Fix generated npm and pip installs to ensure determinism Freeze compiler-generated Copilot SDK npm installs Oct 25, 2026
Copilot AI requested a review from pelikhan October 25, 2026 13:13
@pelikhan
pelikhan marked this pull request as ready for review October 25, 2026 13:23
Copilot AI max review requested due to automatic review settings October 25, 2026 13:23

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

Resolver scoping, missing-package fallback, and older-Node CommonJS regressions must be fixed, and affected workflows regenerated.

2 open issues
What changed in this PR

Moves compiler-generated Copilot SDK npm installs into .gh-aw/copilot-sdk, using embedded manifests and lockfiles to make dependency installation reproducible.

Changes:

  • Generate npm ci --ignore-scripts --no-audit --no-fund installs for Node.js and TypeScript profiles.
  • Add runtime module-resolution hooks and regenerate workflow setup.
  • Update undici to 6.29.1 and override zod to 4.6.6.
  • Expand regression tests and document the installation layout.

Review blockers: Critical findings concern session-wide hook and executable-path inheritance affecting repository tooling, and resolver failures when packages are absent from the SDK profile. Moderate findings concern unrelated dependency redirection in the reviewed generated workflows and CommonJS loading workspace dependencies instead of frozen copies on runtimes without synchronous hooks.

File Description
pkg/​workflow/​data/​copilot-sdk/​typescript/​package.json Pins SDK dependencies, TypeScript tooling, and dependency overrides.
pkg/​workflow/​data/​copilot-sdk/​node/​package.json Pins Node.js SDK dependencies and the Zod override.
pkg/​workflow/​copilot_sdk_npm.go Embeds dependency profiles and generates installation and resolution scripts.
pkg/​workflow/​copilot_sdk_npm_test.go Tests version pins, lockfile integrity, workspace preservation, and resolution.
pkg/​workflow/​copilot_inline_driver_test.go Updates inline-driver installation expectations.
pkg/​workflow/​copilot_engine_installation.go Routes Node.js and TypeScript SDK setup through locked installs.
pkg/​workflow/​copilot_engine_execution.go Configures SDK module paths, executable paths, and resolver preloading.
pkg/​workflow/​copilot_engine_basic_test.go Updates compiler installation assertions.
docs/​src/​content/​docs/​reference/​engines/​copilot.md Documents SDK installation and module resolution.
.github/​workflows/​workflow-skill-extractor.lock.yml Regenerates locked SDK installation and runtime setup.
.github/​workflows/​weekly-editors-health-check.lock.yml Regenerates locked SDK installation and runtime setup.
.github/​workflows/​visual-regression-checker.lock.yml Regenerates locked SDK installation and runtime setup.
.github/​workflows/​smoke-copilot-sdk.lock.yml Updates the SDK smoke workflow’s installation and runtime setup.
.github/​workflows/​slide-deck-maintainer.lock.yml Regenerates locked SDK installation and runtime setup.
.github/​workflows/​pr-nitpick-reviewer.lock.yml Regenerates locked SDK installation and runtime setup.
.github/​workflows/​linter-miner.lock.yml Regenerates locked SDK installation and runtime setup.
.github/​workflows/​jsweep.lock.yml Regenerates locked SDK installation and runtime setup.
.github/​workflows/​firewall.lock.yml Regenerates locked SDK installation and runtime setup.
.github/​workflows/​dead-code-remover.lock.yml Regenerates locked SDK installation and runtime setup.
.github/​workflows/​daily-report-dispatcher.lock.yml Regenerates locked SDK installation and runtime setup.
.github/​workflows/​daily-pr-review-cursor.lock.yml Regenerates locked SDK installation and runtime setup.

Review effort: Max

@@ -121,7 +121,7 @@ func buildCopilotMCPConfigExport(workflowData *WorkflowData) string {

const nodePathSetupCommand = `GH_AW_NPM_GLOBAL_ROOT="$(npm root -g 2>/dev/null || true)"; if [ -n "$GH_AW_NPM_GLOBAL_ROOT" ]; then export NODE_PATH="${GH_AW_NPM_GLOBAL_ROOT}${NODE_PATH:+:${NODE_PATH}}"; fi`
const nodeRuntimeResolutionCommand = `GH_AW_NODE_EXEC="${GH_AW_NODE_BIN:-}"; if [ -z "$GH_AW_NODE_EXEC" ] || [ ! -x "$GH_AW_NODE_EXEC" ]; then GH_AW_NODE_EXEC="$(command -v node 2>/dev/null || true)"; fi; if [ -z "$GH_AW_NODE_EXEC" ]; then echo "node runtime missing on this runner — check runtimes.node in workflow YAML" >&2; exit 127; fi; ` + nodePathSetupCommand + `; "$GH_AW_NODE_EXEC"`
const nodePathSetupCommandForCopilotSDK = `GH_AW_WORKSPACE_NODE_MODULES="${GITHUB_WORKSPACE:-$PWD}/node_modules"; if [ -d "$GH_AW_WORKSPACE_NODE_MODULES" ]; then export NODE_PATH="${GH_AW_WORKSPACE_NODE_MODULES}${NODE_PATH:+:${NODE_PATH}}"; fi; ` + nodePathSetupCommand
const nodePathSetupCommandForCopilotSDK = nodePathSetupCommand + `; GH_AW_WORKSPACE_NODE_MODULES="${GITHUB_WORKSPACE:-$PWD}/node_modules"; if [ -d "$GH_AW_WORKSPACE_NODE_MODULES" ]; then export NODE_PATH="${GH_AW_WORKSPACE_NODE_MODULES}${NODE_PATH:+:${NODE_PATH}}"; fi; GH_AW_SDK_NODE_MODULES="${GITHUB_WORKSPACE:-$PWD}/.gh-aw/copilot-sdk/node_modules"; export NODE_PATH="${GH_AW_SDK_NODE_MODULES}${NODE_PATH:+:${NODE_PATH}}"; export PATH="${GH_AW_SDK_NODE_MODULES}/.bin:$PATH"; if [ -f "${GH_AW_SDK_NODE_MODULES}/../resolve.cjs" ]; then export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--import=\"${GH_AW_SDK_NODE_MODULES}/../resolve.cjs\""; fi`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 606a398. SDK hooks, NODE_PATH, and executable paths are now added only to SDK driver subprocesses; sidecars and CLI-only runs retain their normal environment, including with a retained SDK installation. Added helper and real driver/sidecar regression tests; all 571 affected JavaScript tests pass. Regenerated workflow locks.

Comment thread pkg/workflow/copilot_sdk_npm.go Outdated
Comment on lines +26 to +28
`const packages = ["@github/copilot-sdk", "undici", "ts-node", "typescript"];` +
`if (context.parentURL !== sdkParentURL && packages.some(pkg => specifier === pkg || specifier.startsWith(pkg + "/"))) {` +
`return { url: pathToFileURL(createRequire(sdkParentURL).resolve(specifier)).href, shortCircuit: true }; }` +

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 606a398. Resolver targets now come from the selected profile manifest, missing SDK lookups fall back to normal resolution, and older Node runtimes get a CommonJS fallback. Tests cover nested packages, missing subpaths, both profiles, and synchronous/asynchronous hooks on Node 22 and 24. Regenerated workflow locks.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/workflow/copilot_engine_execution.go:124): The import hook applies to the whole agent session, not just the driver. - Freeze compiler-generated Copilot SDK npm installs #71885 (comment)
  3. Review (pkg/workflow/copilot_sdk_npm.go:28): The resolver throws instead of falling back when the SDK copy is missing. - Freeze compiler-generated Copilot SDK npm installs #71885 (comment)

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 58338c0
Sous-chef work: c7e1db752e72b85483d77531d11e6e5e3e847ebe45c7fbd11ce67abccacb71e9 f7f828326317dacf105b2d2bfbe4a4046a3f0fae35e08d3dcebb34b01e4b91eb
Sous-chef state: 9428ec181c00f0981657617e0bf1a0d3a05bf6fe9bbac8d2869828c7bf56cdde

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · ~8 AIC · ⌖ ~8 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

Copilot AI commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes....

Merged main with make merge-main (f2eb12d) and pushed both fixes in 606a398. Replied to both review threads; all 348 workflow locks are in sync, focused Go tests and 571 affected JS tests pass. Final local gate is blocked by the pre-existing unchecked fmt.Fprintf return at pkg/workflow/copilot_engine_execution.go:330; CodeQL timed out. I could not mark threads resolved: available PR tools support read/reply, not thread resolution, and gh has no authentication. No CI was triggered. Remaining handoff: resolve the two answered threads, human review, and CI/security verification.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot maintain package.json and lock in actions/setup/js/copilot-sdk and copy it instead of printf

Copilot AI commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot maintain package.json and lock in actions/setup/js/copilot-sdk and copy it instead of printf

Moved both profile manifests and lockfiles into actions/setup/js/copilot-sdk, added setup-action copying, and regenerated the workflow locks. Committed as db538bd.

Comment thread actions/setup/js/copilot_harness.cjs Outdated
const nodeModules = path.join(sdkDir, "node_modules");
return {
...baseEnv,
NODE_OPTIONS: `${baseEnv.NODE_OPTIONS ? `${baseEnv.NODE_OPTIONS} ` : ""}--import=${JSON.stringify(resolver)}`,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f8af7d3: the harness now skips the workspace resolver preload by default and only adds the resolver and SDK paths when GH_AW_TRUSTED_SDK_RESOLVER=1. Added regression coverage for default-deny and explicit opt-in.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/copilot_harness.cjs:1502): Prompt injection risk: actions/setup/js/copilot_harness.cjs buildCopilotSDKDriverEnv loads a JavaScript preload from the checked-out workspace (GITHUB_WORKSPACE/.gh-aw/copilot-sdk/resolve.cjs) via NODE_OPTIONS=--import without validating it is the compiler-generated resolver. A repo under analysis can supply/replace this file to run attacker-controlled code inside the Copilot SDK driver process (which shapes agent/LLM prompts and tool calls), overriding the intended workflow behavior. - Freeze compiler-generated Copilot SDK npm installs #71885 (comment)

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: db538bd
Sous-chef work: 2a7e1db4ae32528ac62d00b6dd23203c64836b1fdbc17241bddbcc349277c15b
Sous-chef state: 020cd70808b5f0ecb2a6bf3ff3211912e5ea256ebb9e097e3c6056cbe470dcfa

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · ~8 AIC · ⌖ ~8 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

…make-generated-npm-and-pip-installs-d

Co-authored-by: gh-aw-bot <[email protected]>
cd "${GITHUB_WORKSPACE}/.gh-aw/copilot-sdk"
cp -- "${RUNNER_TEMP}/gh-aw/actions/copilot-sdk/node/package.json" package.json
cp -- "${RUNNER_TEMP}/gh-aw/actions/copilot-sdk/node/package-lock.json" package-lock.json
printf '%s\n' 'const { register, registerHooks, createRequire } = require("node:module");const { pathToFileURL } = require("node:url");const sdkParentURL = pathToFileURL(__filename).href;const packages = Object.keys(require("./package.json").dependencies);function resolve(specifier, context, nextResolve) {if (context.parentURL !== sdkParentURL && packages.some(pkg => specifier === pkg || specifier.startsWith(pkg + "/"))) {try { return { url: pathToFileURL(createRequire(sdkParentURL).resolve(specifier)).href, shortCircuit: true }; }catch (error) { if (error.code !== "MODULE_NOT_FOUND" && error.code !== "ERR_MODULE_NOT_FOUND") throw error; } }return nextResolve(specifier, context); }if (registerHooks) { registerHooks({ resolve }); } else {const Module = require("node:module"); const originalResolve = Module._resolveFilename;Module._resolveFilename = function(specifier, parent, ...args) {if (parent?.filename !== __filename && packages.some(pkg => specifier === pkg || specifier.startsWith(pkg + "/"))) {try { return createRequire(sdkParentURL).resolve(specifier); }catch (error) { if (error.code !== "MODULE_NOT_FOUND") throw error; } }return originalResolve.call(this, specifier, parent, ...args); };register("data:text/javascript," + encodeURIComponent('\''import { createRequire } from "node:module"; import { pathToFileURL } from "node:url";'\'' +"const packages = " + JSON.stringify(packages) + ";" +"const sdkParentURL = " + JSON.stringify(sdkParentURL) + "; export " + resolve.toString())); }' > resolve.cjs

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.

@copilot refactor helper in actions/setup/js file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Extracted the SDK driver environment builder into actions/setup/js/copilot_sdk_driver_env.cjs with colocated regression tests. Committed as 6bde786.

Copilot AI requested a review from pelikhan October 25, 2026 17:16
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot recompile to use the env helper instead of inline js in the .lock.yml

Copilot AI commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot recompile to use the env helper instead of inline js in the .lock.yml

make recompile completed successfully (348/348 workflows), but produced no lockfile diff. The inline code still present at actions-aw-linter-factory.lock.yml:659 writes resolve.cjs from pkg/workflow/copilot_sdk_npm.go; copilot_sdk_driver_env.cjs is a separate harness environment helper and does not replace that resolver. Did you intend to replace the inline resolver with a checked-in helper as well?

cd "${GITHUB_WORKSPACE}/.gh-aw/copilot-sdk"
cp -- "${RUNNER_TEMP}/gh-aw/actions/copilot-sdk/node/package.json" package.json
cp -- "${RUNNER_TEMP}/gh-aw/actions/copilot-sdk/node/package-lock.json" package-lock.json
printf '%s\n' 'const { register, registerHooks, createRequire } = require("node:module");const { pathToFileURL } = require("node:url");const sdkParentURL = pathToFileURL(__filename).href;const packages = Object.keys(require("./package.json").dependencies);function resolve(specifier, context, nextResolve) {if (context.parentURL !== sdkParentURL && packages.some(pkg => specifier === pkg || specifier.startsWith(pkg + "/"))) {try { return { url: pathToFileURL(createRequire(sdkParentURL).resolve(specifier)).href, shortCircuit: true }; }catch (error) { if (error.code !== "MODULE_NOT_FOUND" && error.code !== "ERR_MODULE_NOT_FOUND") throw error; } }return nextResolve(specifier, context); }if (registerHooks) { registerHooks({ resolve }); } else {const Module = require("node:module"); const originalResolve = Module._resolveFilename;Module._resolveFilename = function(specifier, parent, ...args) {if (parent?.filename !== __filename && packages.some(pkg => specifier === pkg || specifier.startsWith(pkg + "/"))) {try { return createRequire(sdkParentURL).resolve(specifier); }catch (error) { if (error.code !== "MODULE_NOT_FOUND") throw error; } }return originalResolve.call(this, specifier, parent, ...args); };register("data:text/javascript," + encodeURIComponent('\''import { createRequire } from "node:module"; import { pathToFileURL } from "node:url";'\'' +"const packages = " + JSON.stringify(packages) + ";" +"const sdkParentURL = " + JSON.stringify(sdkParentURL) + "; export " + resolve.toString())); }' > resolve.cjs

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.

@copilot store helper in file in actions/setup/js. Avoid inlining js

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved the resolver into actions/setup/js/copilot_sdk_resolver.cjs, copied it into the SDK directory from generated install steps, and regenerated 102 workflow locks. Commit: 05a3a78.

Copilot AI requested a review from pelikhan October 25, 2026 19:12
@pelikhan

Copy link
Copy Markdown
Collaborator

/smoke-copilot-sdk

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🔬 Smoke Copilot SDK has started processing this issue comment

@pelikhan pelikhan closed this Oct 25, 2026
@github-actions
github-actions Bot deleted the copilot/aw-top-10-09-make-generated-npm-and-pip-installs-d branch November 2, 2026 02:02
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.

[AW Top 10] 09 Make generated npm and pip installs deterministic

5 participants