Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(ok): gate Windows terminal release assertions on the checked-out tree (#4002)
serafin-garcia165d07f5a0d8
diff --git a/.github/scripts/release-cascade-shape.test.mjs b/.github/scripts/release-cascade-shape.test.mjsindex 334d1f897..307b0eb95 100644--- a/.github/scripts/release-cascade-shape.test.mjs+++ b/.github/scripts/release-cascade-shape.test.mjs@@ -236,9 +236,24 @@ describe('the optional Windows signing lane proves what it reports', () => {});describe('the publishing Windows lane attests its signed native payload', () => {+ // This workflow runs main's YAML against `client_payload[ref]`, which may be+ // an older tag whose tree legitimately excludes node-pty from its Windows+ // package (a soaked beta or bug-lane synthetic commit cut before the+ // terminal shipped). The terminal-specific assertions are therefore gated on+ // the checked-out tree's own packaging intent via the `winterm` detect step;+ // the app-signature attestation stays unconditional. These tests pin BOTH+ // halves: the gate may say exactly one thing, and nothing else in the+ // attestation region may grow a condition.+ const GATE_CONDITION = "success() && steps.winterm.outputs.ships == 'true'";+test('checks both outer architectures before staging release assets', () => {- const attest = desktopRelease.indexOf(- '- name: Attest signed Windows packages and preserved Microsoft signatures',+ const detect = desktopRelease.indexOf(+ '- name: Detect whether this ref packages the Windows terminal',+ );+ const attest = desktopRelease.indexOf('- name: Attest signed Windows packages', detect);+ const conpty = desktopRelease.indexOf(+ '- name: Attest preserved Microsoft signatures on the packaged ConPTY pairs',+ attest,);const asar = desktopRelease.indexOf('- name: Assert the packaged asar carries its dependencies',@@ -249,40 +264,91 @@ describe('the publishing Windows lane attests its signed native payload', () =>attest,);- expect(attest).toBeGreaterThan(0);- expect(attest).toBeLessThan(asar);+ expect(detect).toBeGreaterThan(0);+ expect(detect).toBeLessThan(attest);+ expect(attest).toBeLessThan(conpty);+ expect(conpty).toBeLessThan(asar);expect(asar).toBeLessThan(upload);const attestationSteps = desktopRelease.slice(attest, asar);expect(attestationSteps).toContain('Get-AuthenticodeSignature');expect(attestationSteps).toContain("-notmatch 'Microsoft'");expect(attestationSteps.match(/OK_WIN_PACKAGE_REQUIRED: "1"/gu) ?? []).toHaveLength(2);- expect(attestationSteps).not.toMatch(/^\s+if:/mu);expect(attestationSteps).not.toContain('continue-on-error:');+ // Every condition in the attestation region is exactly the tree gate —+ // nothing may weaken these steps with any other predicate.+ const conditions = stepLevelIfConditions(attestationSteps);+ expect(conditions).toHaveLength(3);+ for (const condition of conditions) {+ expect(condition).toBe(GATE_CONDITION);+ }for (const dir of ['dist-desktop/win-unpacked', 'dist-desktop/win-arm64-unpacked']) {expect(attestationSteps).toContain(`Path = '${dir}'`);expect(attestationSteps).toContain(`OK_WIN_PACKAGE_DIR: ${dir}`);}});+ test('the tree gate probes the pre-terminal exclusion and fails closed', () => {+ const detectStep = workflowStep(+ desktopRelease,+ 'desktop-release.yml',+ 'Detect whether this ref packages the Windows terminal',+ );+ // The probe is the checked-out tree's own electron-builder config — never+ // the packaged output, which would let a broken packaging run skip its+ // own guard.+ expect(detectStep).toContain('packages/desktop/electron-builder.yml');+ expect(detectStep).toContain('grep -qF -- \'- "!**/node_modules/node-pty/**"\'');+ // Polarity: the grep HIT (the closed set of pre-terminal trees) is the+ // skip; every other shape — including future config refactors — stays+ // armed.+ expect(detectStep.indexOf('ships=false')).toBeGreaterThan(-1);+ expect(detectStep.indexOf('ships=false')).toBeLessThan(detectStep.indexOf('ships=true'));+ // The app-signature attestation itself carries no condition at all.+ const appAttestation = workflowStep(+ desktopRelease,+ 'desktop-release.yml',+ 'Attest signed Windows packages',+ );+ expect(stepLevelIfConditions(appAttestation)).toHaveLength(0);+ });+test('keeps the shared signature-preservation core in both Windows lanes', () => {- for (const [workflowName, workflow] of [- ['desktop-release.yml', desktopRelease],- ['desktop-build-win-linux.yml', desktopBuildWinLinux],+ // desktop-release splits the attestation (the app-signature half runs on+ // every ref; the ConPTY half is tree-gated); desktop-build-win-linux runs+ // its workflow file from the dispatched ref itself, so no tree skew is+ // possible there and it keeps the combined unconditional step.+ const releaseAppStep = workflowStep(+ desktopRelease,+ 'desktop-release.yml',+ 'Attest signed Windows packages',+ );+ expect(releaseAppStep).toContain('$signature = Get-AuthenticodeSignature $appExecutable');++ const conptyTokens = [+ '$signature = Get-AuthenticodeSignature $path',+ "-notmatch 'Microsoft'",+ "foreach ($name in @('conpty.dll', 'OpenConsole.exe'))",+ 'node-pty[\\\\/]prebuilds[\\\\/]win32-(x64|arm64)[\\\\/]conpty$',+ ];+ const releaseConptyStep = workflowStep(+ desktopRelease,+ 'desktop-release.yml',+ 'Attest preserved Microsoft signatures on the packaged ConPTY pairs',+ );+ for (const token of conptyTokens) {+ expect(releaseConptyStep).toContain(token);+ }++ const qaAttestationStep = workflowStep(+ desktopBuildWinLinux,+ 'desktop-build-win-linux.yml',+ 'Attest signed Windows packages and preserved Microsoft signatures',+ );+ for (const token of [+ '$signature = Get-AuthenticodeSignature $appExecutable',+ ...conptyTokens,]) {- const attestationStep = workflowStep(- workflow,- workflowName,- 'Attest signed Windows packages and preserved Microsoft signatures',- );- for (const token of [- '$signature = Get-AuthenticodeSignature $appExecutable',- '$signature = Get-AuthenticodeSignature $path',- "-notmatch 'Microsoft'",- "foreach ($name in @('conpty.dll', 'OpenConsole.exe'))",- 'node-pty[\\\\/]prebuilds[\\\\/]win32-(x64|arm64)[\\\\/]conpty$',- ]) {- expect(attestationStep).toContain(token);- }+ expect(qaAttestationStep).toContain(token);}});});diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.ymlindex a608690ad..a7eb5ac4a 100644--- a/.github/workflows/desktop-release.yml+++ b/.github/workflows/desktop-release.yml@@ -1012,7 +1012,33 @@ jobs:bash -c "$PKG_CMD"fi- - name: Attest signed Windows packages and preserved Microsoft signatures+ # This workflow always executes main's YAML (repository_dispatch), while+ # the checkout above follows `client_payload[ref]` — typically a tag+ # whose tree predates whatever main's assertions were written against. A+ # soaked beta or a bug-lane synthetic commit cut before the Windows+ # terminal shipped legitimately excludes node-pty from its Windows+ # package, and holding it to the ConPTY assertions below permanently+ # blocks its release (re-firing the dispatch repairs nothing — the tag+ # cannot move, per the soak model). Gate on the checked-out tree's own+ # packaging intent, read from its electron-builder config — NOT from the+ # packaged output, which would let a genuinely broken packaging run skip+ # its own guard. The pre-terminal shape is a closed set: every such tree+ # carries the literal win-files exclusion probed here. Anything else —+ # including future refactors of the config — keeps the assertions armed,+ # so this fails closed.+ - name: Detect whether this ref packages the Windows terminal+ id: winterm+ shell: bash+ run: |+ set -euo pipefail+ if grep -qF -- '- "!**/node_modules/node-pty/**"' packages/desktop/electron-builder.yml; then+ echo "ships=false" >> "$GITHUB_OUTPUT"+ echo "::notice::This ref excludes node-pty from its Windows package (pre-terminal tree) — the ConPTY signature + terminal native-package assertions are skipped; the app-signature attestation still runs."+ else+ echo "ships=true" >> "$GITHUB_OUTPUT"+ fi++ - name: Attest signed Windows packagesshell: pwshworking-directory: packages/desktoprun: |@@ -1034,11 +1060,21 @@ jobs:if ($signature.Status -ne 'Valid') {throw "Our signing pass did not leave a valid signature on ${appExecutable}: $($signature.Status)"}+ }+ "### Windows signing attestation: PASSED`n`nBoth outer architectures carry a validly signed app." |+ Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY- $pairDirectories = @(Get-ChildItem $package.Path -Recurse -Directory -Filter 'conpty' |+ - name: Attest preserved Microsoft signatures on the packaged ConPTY pairs+ if: success() && steps.winterm.outputs.ships == 'true'+ shell: pwsh+ working-directory: packages/desktop+ run: |+ $ErrorActionPreference = 'Stop'+ foreach ($packagePath in @('dist-desktop/win-unpacked', 'dist-desktop/win-arm64-unpacked')) {+ $pairDirectories = @(Get-ChildItem $packagePath -Recurse -Directory -Filter 'conpty' |Where-Object { $_.FullName -match 'node-pty[\\/]prebuilds[\\/]win32-(x64|arm64)[\\/]conpty$' })if ($pairDirectories.Count -ne 2) {- throw "Expected both ConPTY architecture directories in the $($package.Arch) release package; found $($pairDirectories.Count)."+ throw "Expected both ConPTY architecture directories in the release package at ${packagePath}; found $($pairDirectories.Count)."}foreach ($directory in $pairDirectories) {foreach ($name in @('conpty.dll', 'OpenConsole.exe')) {@@ -1056,10 +1092,11 @@ jobs:}}}- "### Windows release signature rider: PASSED`n`nBoth outer architectures carry a signed app, and Microsoft signatures remain valid on every packaged ConPTY pair." |+ "### Windows release signature rider: PASSED`n`nMicrosoft signatures remain valid on every packaged ConPTY pair." |Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY- name: Assert Windows x64 terminal native package compatibility+ if: success() && steps.winterm.outputs.ships == 'true'working-directory: packages/desktopenv:OK_WIN_PACKAGE_DIR: dist-desktop/win-unpacked@@ -1067,6 +1104,7 @@ jobs:run: pnpm exec vitest run tests/unit/windows-package-native-guards.test.ts- name: Assert Windows arm64 terminal native package compatibility+ if: success() && steps.winterm.outputs.ships == 'true'working-directory: packages/desktopenv:OK_WIN_PACKAGE_DIR: dist-desktop/win-arm64-unpacked