diff --git a/.github/workflows/weasel-release62-recovery.yml b/.github/workflows/weasel-release62-recovery.yml new file mode 100644 index 0000000000000..26f671dd5e9ce --- /dev/null +++ b/.github/workflows/weasel-release62-recovery.yml @@ -0,0 +1,587 @@ +name: Recover only the pinned .62 Windows package and publish original platform bytes +run-name: Pinned .62 Windows recovery; original application source 01102e1d064e371033bbd9782bc8f2ac20c7b3ad +on: + workflow_dispatch: + inputs: + publish: + description: Explicitly approved one-time .62 recovery and publication + type: boolean + required: true + default: false + source_sha: + description: Must remain the original .62 application commit + type: string + required: true + default: 01102e1d064e371033bbd9782bc8f2ac20c7b3ad + origin_run_id: + description: Must remain the failed .62 origin run + type: string + required: true + default: "39537119530" +concurrency: + group: weasel-desktop-nightly + cancel-in-progress: false +permissions: + actions: read + contents: read +jobs: + recover: + if: github.repository == 'morrowbyte/t3code' && inputs.publish + runs-on: ${{ vars.WEASEL_LINUX_RUNNER || 'blacksmith-8vcpu-ubuntu-2404' }} + timeout-minutes: 15 + outputs: + source_sha: ${{ steps.recover.outputs.source_sha }} + version: ${{ steps.recover.outputs.version }} + android_version_code: ${{ steps.recover.outputs.android_version_code }} + tag: ${{ steps.recover.outputs.tag }} + observatory_route_sha256: ${{ steps.recover.outputs.observatory_route_sha256 }} + desktop_run_id: ${{ steps.recover.outputs.desktop_run_id }} + desktop_run_attempt: ${{ steps.recover.outputs.desktop_run_attempt }} + desktop_context_sha: ${{ steps.recover.outputs.desktop_context_sha }} + desktop_workflow_sha: ${{ steps.recover.outputs.desktop_workflow_sha }} + desktop_workflow_ref: ${{ steps.recover.outputs.desktop_workflow_ref }} + recovery_artifact_attempt: ${{ steps.recover.outputs.recovery_artifact_attempt }} + recovery_workflow_sha256: ${{ steps.recover.outputs.recovery_workflow_sha256 }} + windows_packaging_sha256: ${{ steps.recover.outputs.windows_packaging_sha256 }} + windows_recovery_receipt_sha256: ${{ steps.recover.outputs.windows_recovery_receipt_sha256 }} + android_source_sha: ${{ steps.recover.outputs.android_source_sha }} + android_lock_sha256: ${{ steps.recover.outputs.android_lock_sha256 }} + recovered_apk_sha256: ${{ steps.recover.outputs.recovered_apk_sha256 }} + recovered_apk_receipt_sha256: ${{ steps.recover.outputs.recovered_apk_receipt_sha256 }} + steps: + - name: Checkout immutable .62 application source + uses: actions/checkout@v4 + with: + ref: 01102e1d064e371033bbd9782bc8f2ac20c7b3ad + fetch-depth: 0 + - name: Load the reviewed .62 recovery helper from the immutable workflow commit + env: + CONTROL_SHA: ${{ github.sha }} + run: | + set -euo pipefail + git fetch --no-tags origin "$CONTROL_SHA" + git show "$CONTROL_SHA:scripts/weasel/release62-recovery.py" > "$RUNNER_TEMP/release62-recovery.py" + - id: recover + name: Verify .62 origin, tooling CI, exact artifact bytes and proof chain + env: + SOURCE_SHA: ${{ inputs.source_sha }} + ORIGIN_RUN_ID: ${{ inputs.origin_run_id }} + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + python3 "$RUNNER_TEMP/release62-recovery.py" recover + - name: Retain verified original weasel-release-recovered-platforms + uses: actions/upload-artifact@v4 + with: + name: weasel-release-recovered-platforms + path: ${{ runner.temp }}/recovered-platforms/* + if-no-files-found: error + compression-level: 0 + retention-days: 7 + - name: Retain verified original weasel-release-cli-linux + uses: actions/upload-artifact@v4 + with: + name: weasel-release-cli-linux + path: ${{ runner.temp }}/recovered-cli-linux/* + if-no-files-found: error + compression-level: 0 + retention-days: 7 + - name: Retain verified original weasel-js-bundle + uses: actions/upload-artifact@v4 + with: + name: weasel-js-bundle + path: ${{ runner.temp }}/recovered-js-bundle + if-no-files-found: error + compression-level: 0 + retention-days: 7 + - name: Retain verified original weasel-observatory-preflight-01102e1d064e371033bbd9782bc8f2ac20c7b3ad-1 + uses: actions/upload-artifact@v4 + with: + name: weasel-observatory-preflight-01102e1d064e371033bbd9782bc8f2ac20c7b3ad-1 + path: ${{ runner.temp }}/observatory-route-generation/* + if-no-files-found: error + compression-level: 0 + retention-days: 7 + - name: Retain verified original weasel-observatory-build-01102e1d064e371033bbd9782bc8f2ac20c7b3ad-1 + uses: actions/upload-artifact@v4 + with: + name: weasel-observatory-build-01102e1d064e371033bbd9782bc8f2ac20c7b3ad-1 + path: ${{ runner.temp }}/observatory-release-build/* + if-no-files-found: error + compression-level: 0 + retention-days: 7 + build_windows: + if: ${{ !cancelled() && inputs.publish && needs.recover.result == 'success' }} + needs: + - recover + runs-on: ${{ vars.WEASEL_WINDOWS_RUNNER || 'blacksmith-8vcpu-windows-2025' }} + timeout-minutes: 50 + steps: + - name: Checkout source + uses: actions/checkout@v4 + with: + ref: ${{ needs.recover.outputs.source_sha }} + fetch-depth: 0 + - name: Apply only the hash-pinned .62 validator fix + shell: bash + env: + SOURCE_SHA: ${{ needs.recover.outputs.source_sha }} + PACKAGING_SHA256: ${{ needs.recover.outputs.windows_packaging_sha256 }} + CONTROL_SHA: ${{ github.sha }} + run: | + set -euo pipefail + test "$SOURCE_SHA" = 01102e1d064e371033bbd9782bc8f2ac20c7b3ad + test "$(git rev-parse HEAD)" = "$SOURCE_SHA" + test -z "$(git status --porcelain --untracked-files=all)" + test "$PACKAGING_SHA256" = 537a26500a69adb09690a68af0e98cf8e822e0bbc428308fb229eb05d462829d + git fetch --no-tags origin "$CONTROL_SHA" + git show "$CONTROL_SHA:scripts/build-desktop-artifact.ts" > scripts/build-desktop-artifact.ts + printf '%s %s\n' "$PACKAGING_SHA256" scripts/build-desktop-artifact.ts | sha256sum --check --strict + test "$(git diff --name-only)" = scripts/build-desktop-artifact.ts + test "$(git rev-parse HEAD)" = "$SOURCE_SHA" + - name: Setup Vite+ + uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb + with: + node-version-file: package.json + cache: false + run-install: false + - name: Install Windows build dependencies + run: vp install --frozen-lockfile --filter=@t3tools/desktop... --filter=t3... --filter=@t3tools/scripts... + - name: Install Spectre-mitigated MSVC runtime libraries + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + $installPath = & $vswhere -products * -latest -property installationPath + $setupExe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe" + $proc = Start-Process -FilePath $setupExe ` + -ArgumentList "modify", "--installPath", "`"$installPath`"", "--add", ` + "Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre", "--quiet", "--norestart" ` + -Wait -PassThru -NoNewWindow + if ($null -eq $proc -or $proc.ExitCode -ne 0) { + $code = if ($null -ne $proc) { $proc.ExitCode } else { 1 } + Write-Error "Visual Studio Installer failed with exit code $code" + exit $code + } + - name: Setup Rust + uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 + with: + targets: x86_64-pc-windows-msvc + - name: Download shared assets + uses: actions/download-artifact@v4 + with: + name: weasel-js-bundle + path: apps + - name: Align package versions + run: node scripts/update-release-package-versions.ts "${{ needs.recover.outputs.version }}" + - name: Download same-build Linux CLI runtime for WSL + uses: actions/download-artifact@v4 + with: + name: weasel-release-cli-linux + path: wsl-runtime + - name: Build Windows CLI executable + env: + VP_NODE_VERSION: 26.8.2 + shell: bash + run: node apps/server/scripts/cli.ts build-exe --verbose + - name: Build Windows x64 installer and updater metadata + env: + T3CODE_DESKTOP_REUSE_PUBLISHED_WSL_RUNTIME: ${{ false }} + T3CODE_DESKTOP_UPDATE_REPOSITORY: ${{ vars.WEASEL_RELEASE_REPOSITORY || 'EvilWeasel/t3code' }} + T3CODE_DESKTOP_APP_ID: com.evilweasel.t3code + T3CODE_DESKTOP_PRODUCT_NAME: T3 Code (Weasel Nightly) + T3CODE_DESKTOP_PROFILE: weasel + shell: bash + run: > + set -euo pipefail + + node scripts/build-desktop-artifact.ts --platform win --target nsis --arch x64 --build-version "${{ + needs.recover.outputs.version }}" --skip-build --keep-stage --wsl-runtime + "$GITHUB_WORKSPACE"/wsl-runtime/t3-*-linux-x64.tar.gz --output-dir release-windows + + test -s release-windows/nightly.yml + + tmp_roots=("$RUNNER_TEMP") + + [[ -n "${TEMP:-}" ]] && tmp_roots+=("$TEMP") + + [[ -n "${TMP:-}" ]] && tmp_roots+=("$TMP") + + update_config="$(find "${tmp_roots[@]}" -path '*/resources/app-update.yml' -print -quit 2>/dev/null + || true)" + + test -n "$update_config" + + IFS=/ read -r expected_owner expected_repo <<<"${T3CODE_DESKTOP_UPDATE_REPOSITORY}" + + grep -Fq "owner: $expected_owner" "$update_config" + + grep -Fq "repo: $expected_repo" "$update_config" + - name: Package and smoke-test Windows CLI archive + shell: bash + run: > + set -euo pipefail + + monitor_dir="$RUNNER_TEMP/cli-resource-monitor/win32-x64" + + mkdir -p "$monitor_dir" + + cp native/resource-monitor/target/x86_64-pc-windows-msvc/release/t3-resource-monitor.exe + "$monitor_dir/" + + node scripts/build-cli-archive.ts --platform win --arch x64 --version "${{ + needs.recover.outputs.version }}" --resource-monitor-dir "$RUNNER_TEMP/cli-resource-monitor" + --output-dir release-cli + + node scripts/smoke-cli-archive.ts --archive release-cli/* --expect-version "${{ + needs.recover.outputs.version }}" + - name: Upload Windows release assets + uses: actions/upload-artifact@v4 + with: + name: weasel-release-windows + path: release-windows/* + if-no-files-found: error + retention-days: 1 + - name: Upload Windows CLI archive + uses: actions/upload-artifact@v4 + with: + name: weasel-release-cli-windows + path: release-cli/* + if-no-files-found: error + retention-days: 1 + publish: + if: + ${{ !cancelled() && inputs.publish && needs.recover.result == 'success' && needs.build_windows.result == + 'success' }} + needs: + - recover + - build_windows + runs-on: ${{ vars.WEASEL_LINUX_RUNNER || 'blacksmith-8vcpu-ubuntu-2404' }} + timeout-minutes: 15 + permissions: + contents: write + steps: + - name: Checkout promoted source for receipt metadata + uses: actions/checkout@v4 + with: + ref: ${{ needs.recover.outputs.source_sha }} + fetch-depth: 1 + - name: Load the reviewed .62 recovery helper from the immutable workflow commit + env: + CONTROL_SHA: ${{ github.sha }} + run: | + set -euo pipefail + git fetch --no-tags origin "$CONTROL_SHA" + git show "$CONTROL_SHA:scripts/weasel/release62-recovery.py" > "$RUNNER_TEMP/release62-recovery.py" + - name: Download dedicated release assets + uses: actions/download-artifact@v4 + with: + pattern: weasel-release-* + merge-multiple: true + path: release-assets + - name: Download Observatory preflight proof for publication + if: needs.recover.outputs.observatory_route_sha256 != '' + uses: actions/download-artifact@v4 + with: + name: weasel-observatory-preflight-${{ needs.recover.outputs.source_sha }}-${{ + needs.recover.outputs.recovery_artifact_attempt || github.run_attempt }} + path: ${{ runner.temp }}/observatory-publish-preflight + - name: Download Observatory build proof for publication + if: needs.recover.outputs.observatory_route_sha256 != '' + uses: actions/download-artifact@v4 + with: + name: weasel-observatory-build-${{ needs.recover.outputs.source_sha }}-${{ + needs.recover.outputs.recovery_artifact_attempt || github.run_attempt }} + path: ${{ runner.temp }}/observatory-publish-build + - name: Require matching Observatory route proofs before publication + env: + SOURCE_SHA: ${{ needs.recover.outputs.source_sha }} + PREFLIGHT_ROUTE_SHA: ${{ needs.recover.outputs.observatory_route_sha256 }} + DESKTOP_RUN_ID: ${{ needs.recover.outputs.desktop_run_id }} + DESKTOP_RUN_ATTEMPT: ${{ needs.recover.outputs.desktop_run_attempt }} + DESKTOP_CONTEXT_SHA: ${{ needs.recover.outputs.desktop_context_sha }} + DESKTOP_WORKFLOW_SHA: ${{ needs.recover.outputs.desktop_workflow_sha }} + DESKTOP_WORKFLOW_REF: ${{ needs.recover.outputs.desktop_workflow_ref }} + run: > + set -euo pipefail + + if [[ ! -f apps/web/src/routes/observatory.tsx ]]; then + test -z "$PREFLIGHT_ROUTE_SHA" + exit 0 + fi + + python3 - <<'PYROUTE' + + import hashlib, json, os, pathlib, subprocess + + digest = lambda p: hashlib.sha256(p.read_bytes()).hexdigest() + + expected = 'fa1b95cb16c59c5a6bf92647b1bb3f3ab872c4cb06ef7a0e5e723775fb5c3dcc' + + source = os.environ['SOURCE_SHA'] + + assert subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() == source + + assert os.environ['PREFLIGHT_ROUTE_SHA'] == expected + + root = pathlib.Path(os.environ['RUNNER_TEMP']) + + preflight = root / 'observatory-publish-preflight' + + build = root / 'observatory-publish-build' + + pre = json.loads((preflight / 'receipt.json').read_bytes()) + + built = json.loads((build / 'receipt.json').read_bytes()) + + for receipt in [pre, built]: + assert receipt['source'] == source + assert receipt['run'] == os.environ['DESKTOP_RUN_ID'] and receipt['attempt'] == os.environ['DESKTOP_RUN_ATTEMPT'] + assert receipt['lockSha256'] == digest(pathlib.Path('pnpm-lock.yaml')) + assert receipt['trustedContextSha'] == os.environ['DESKTOP_CONTEXT_SHA'] + assert receipt['trustedWorkflowSha'] == os.environ['DESKTOP_WORKFLOW_SHA'] + assert receipt['trustedWorkflowRef'] == os.environ['DESKTOP_WORKFLOW_REF'] + assert pre['effectiveSourceSha'] == source and pre['status'] == 'generated-unreviewed' + + assert pre['afterSha256'] == built['generatedRouteSha256'] == expected + + assert digest(preflight / 'routeTree.gen.ts') == digest(build / 'routeTree.gen.ts') == expected + + assert built['preflightReceiptSha256'] == digest(preflight / 'receipt.json') + + assert pre['generatorVersion'] == '1.167.12' and pre['config'] == {'autoCodeSplitting': True} + + assert (preflight / 'routeTree.diff').is_file() + + PYROUTE + - name: Setup checksum consumer runtime + uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb + with: + node-version-file: package.json + cache: false + run-install: false + - name: Verify Android bytes from this build before publication + env: + SOURCE_SHA: ${{ needs.recover.outputs.android_source_sha || needs.recover.outputs.source_sha }} + DESKTOP_SOURCE_SHA: ${{ needs.recover.outputs.source_sha }} + ANDROID_LOCK_SHA256: ${{ needs.recover.outputs.android_lock_sha256 }} + ANDROID_VERSION: ${{ needs.recover.outputs.version }} + ANDROID_VERSION_CODE: ${{ needs.recover.outputs.android_version_code }} + APK_SHA256: ${{ needs.recover.outputs.recovered_apk_sha256 }} + APK_RECEIPT_SHA256: ${{ needs.recover.outputs.recovered_apk_receipt_sha256 }} + APK_BUILD_ATTEMPT: "1" + APK_BUILD_RUN: "39537119530" + APK_CONTEXT_SHA: 01102e1d064e371033bbd9782bc8f2ac20c7b3ad + APK_WORKFLOW_SHA: 01102e1d064e371033bbd9782bc8f2ac20c7b3ad + APK_WORKFLOW_REF: morrowbyte/t3code/.github/workflows/weasel-release.yml@refs/heads/main + run: > + set -euo pipefail + + python3 - <<'PYPUBLISHAPK' + + import hashlib, json, os, re + + from pathlib import Path + + digest = lambda p: hashlib.sha256(p.read_bytes()).hexdigest() + + assets = Path('release-assets') + + version = os.environ['ANDROID_VERSION'] + + name = f'Morrowbyte-{version}-android-arm64.apk' + + assert sorted(p.name for p in assets.iterdir() if p.suffix in {'.apk', '.aab', '.ipa'}) == [name] + + expected_sha = os.environ['APK_SHA256'] + + assert re.fullmatch('[0-9a-f]{64}', expected_sha) + + receipt_path = assets / (name + '.json') + + assert digest(assets / name) == expected_sha + + assert digest(receipt_path) == os.environ['APK_RECEIPT_SHA256'] + + assert (assets / (name + '.sha256')).read_text() == f'{expected_sha} {name}\n' + + receipt = json.loads(receipt_path.read_text()) + + expected = { + 'schemaVersion': 1, 'source': os.environ['SOURCE_SHA'], 'version': version, + 'desktopSource': os.environ['DESKTOP_SOURCE_SHA'], + 'lockSha256': os.environ['ANDROID_LOCK_SHA256'] or digest(Path('pnpm-lock.yaml')), + 'versionCode': int(os.environ['ANDROID_VERSION_CODE']), + 'run': os.environ['APK_BUILD_RUN'], 'attempt': os.environ['APK_BUILD_ATTEMPT'], + 'trustedContextSha': os.environ['APK_CONTEXT_SHA'], 'trustedWorkflowSha': os.environ['APK_WORKFLOW_SHA'], + 'trustedWorkflowRef': os.environ['APK_WORKFLOW_REF'], + 'apk': name, 'apkSha256': expected_sha, 'package': 'com.morrowbyte.t3code', 'name': 'Morrowbyte', + 'certificateSha256': '34a33c2541544bc4a96e359a33e9f71aaa449ee9a0cd725c2469b65b057aa2b2', + 'abis': ['arm64-v8a'], 'signatureVerified': True, 'zip16KB': True, 'elf16KB': True, + 'deviceAcceptance': 'not-run', + } + + assert all(receipt.get(key) == value for key, value in expected.items()) + + PYPUBLISHAPK + - name: Verify every retained .62 payload byte and recovery ownership + env: + RECOVERY_RECEIPT_SHA256: ${{ needs.recover.outputs.windows_recovery_receipt_sha256 }} + PACKAGING_SHA256: ${{ needs.recover.outputs.windows_packaging_sha256 }} + run: | + set -euo pipefail + python3 "$RUNNER_TEMP/release62-recovery.py" verify + - name: Verify isolated release payload + env: + DESKTOP_ONLY: ${{ false }} + run: > + set -euo pipefail + + if [[ "$DESKTOP_ONLY" == true ]]; then + test -z "$(find release-assets -maxdepth 1 -type f \( -name '*.apk' -o -name '*.aab' -o -name '*.ipa' \) -print -quit)" + fi + + test -s release-assets/nightly-linux.yml + + test -s release-assets/nightly.yml + + test -s release-assets/weasel-linux-x64.tar.gz + + test -s "release-assets/T3-Code-${{ needs.recover.outputs.version }}-x86_64.AppImage" + + test -s release-assets/install-linux.sh + + test -s "release-assets/T3-Code-${{ needs.recover.outputs.version + }}-x86_64-linux-nix-closure.nar.zst" + + test -s "release-assets/T3-Code-${{ needs.recover.outputs.version + }}-x86_64-linux-nix-closure.json" + + bash scripts/weasel/verify-nixos-closure.sh "${{ needs.recover.outputs.version }}" release-assets + + test -n "$(find release-assets -maxdepth 1 -name 't3-*-linux-x64.tar.gz' -print -quit)" + + test -n "$(find release-assets -maxdepth 1 -name 't3-*-win32-x64.zip' -print -quit)" + + bash scripts/weasel/verify-published-release.sh --write-checksums "${{ + needs.recover.outputs.version }}" release-assets + - name: Create fork-only prerelease + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ vars.WEASEL_RELEASE_REPOSITORY || 'EvilWeasel/t3code' }} + OBSERVATORY_ROUTE_SHA: ${{ needs.recover.outputs.observatory_route_sha256 }} + DESKTOP_RUN_ID: ${{ needs.recover.outputs.desktop_run_id }} + DESKTOP_RUN_ATTEMPT: ${{ needs.recover.outputs.desktop_run_attempt }} + DESKTOP_CONTEXT_SHA: ${{ needs.recover.outputs.desktop_context_sha }} + DESKTOP_WORKFLOW_SHA: ${{ needs.recover.outputs.desktop_workflow_sha }} + DESKTOP_WORKFLOW_REF: ${{ needs.recover.outputs.desktop_workflow_ref }} + RECOVERY_WORKFLOW_SHA256: ${{ needs.recover.outputs.recovery_workflow_sha256 }} + ANDROID_SOURCE_SHA: ${{ needs.recover.outputs.android_source_sha || needs.recover.outputs.source_sha }} + ANDROID_LOCK_SHA256: ${{ needs.recover.outputs.android_lock_sha256 }} + DESKTOP_ONLY: ${{ false }} + WINDOWS_RECOVERY_RUN_ID: ${{ '39537119530' }} + WINDOWS_PACKAGING_SHA256: ${{ needs.recover.outputs.windows_packaging_sha256 }} + run: > + set -euo pipefail + + tag="${{ needs.recover.outputs.tag }}" + + source_sha="${{ needs.recover.outputs.source_sha }}" + + version="${{ needs.recover.outputs.version }}" + + assert_draft_release() { + local release_state is_draft target_commitish + release_state="$(gh release view "$tag" --json isDraft,targetCommitish)" + is_draft="$(jq -r .isDraft <<<"$release_state")" + target_commitish="$(jq -r .targetCommitish <<<"$release_state")" + if [[ "$is_draft" != "true" ]]; then + echo "Release tag $tag is already published and immutable; refusing to overwrite its assets." >&2 + return 1 + fi + if [[ "$target_commitish" != "$source_sha" ]]; then + echo "Release tag $tag already points to $target_commitish, refusing to replace it." >&2 + return 1 + fi + } + + if gh release view "$tag" >/dev/null 2>&1; then + release_state="$(gh release view "$tag" --json isDraft,targetCommitish)" + if [[ "$(jq -r .isDraft <<<"$release_state")" == "false" ]]; then + bash scripts/weasel/verify-published-release.sh \ + "$tag" "$source_sha" "$version" release-assets + exit 0 + fi + assert_draft_release + else + if [[ "$DESKTOP_ONLY" == true ]]; then + platform_notes="Desktop-only hotfix for Windows x64, Linux x64 and NixOS x64. No Android or macOS assets were built for this release." + else + platform_notes="Android source $ANDROID_SOURCE_SHA." + fi + if [[ -n "$WINDOWS_RECOVERY_RUN_ID" ]]; then + platform_notes+=" Retained Linux, NixOS, Android and shared runtime bytes from run $WINDOWS_RECOVERY_RUN_ID. Windows packaging uses validation-only script $WINDOWS_PACKAGING_SHA256 from control source $GITHUB_SHA; application source and version remain unchanged." + fi + gh release create "$tag" \ + --target "$source_sha" \ + --title "Weasel Nightly ${{ needs.recover.outputs.version }}" \ + --prerelease \ + --draft \ + --notes "Fork channel desktop source $source_sha. $platform_notes Linux AppImage installs include a user-local installer. NixOS installs use the dedicated package and updater launcher when available at https://github.com/$GH_REPO/tree/main/packaging/nixos. Linux auto-updates stay disabled for Nix store installs. This build has no configured T3 Connect relay backend." + fi + + # Asset replacement is permitted only while the release is still a + + # draft. Recheck immediately before each clobber in case a maintainer + + # published it while the job was preparing the payload. + + assert_draft_release + + gh release upload "$tag" release-assets/* --clobber + + + lock_sha="$(sha256sum pnpm-lock.yaml | cut -d ' ' -f 1)" + + assets_json="$(bash scripts/weasel/read-draft-release-assets.sh "$tag" "$source_sha")" + + jq -e 'length > 0 and all(.[]; (.digest | type == "string") and (.digest | startswith("sha256:")))' + <<<"$assets_json" + + expected_assets="$(find release-assets -maxdepth 1 -type f ! -name 'RELEASE-RECEIPT.txt' -printf + '%f\n' | jq -Rsc 'split("\n") | map(select(length > 0)) | sort')" + + jq -e --argjson expected "$expected_assets" '([.[].name] | sort) == $expected' <<<"$assets_json" + + { + printf 'fork_release=%s\nsource_sha=%s\npnpm_lock_sha256=%s\n' "$tag" "$source_sha" "$lock_sha" + if [[ -f apps/web/src/routes/observatory.tsx ]]; then + test "$OBSERVATORY_ROUTE_SHA" = fa1b95cb16c59c5a6bf92647b1bb3f3ab872c4cb06ef7a0e5e723775fb5c3dcc + printf 'generated_route_sha256=%s\ngenerated_route_source_sha=%s\ngenerated_route_run_id=%s\ngenerated_route_run_attempt=%s\n' \ + "$OBSERVATORY_ROUTE_SHA" "$source_sha" "$DESKTOP_RUN_ID" "$DESKTOP_RUN_ATTEMPT" + fi + printf 'desktop_origin_run_id=%s\ndesktop_origin_run_attempt=%s\ndesktop_origin_context_sha=%s\ndesktop_origin_workflow_sha=%s\ndesktop_origin_workflow_ref=%s\n' \ + "$DESKTOP_RUN_ID" "$DESKTOP_RUN_ATTEMPT" "$DESKTOP_CONTEXT_SHA" "$DESKTOP_WORKFLOW_SHA" "$DESKTOP_WORKFLOW_REF" + printf 'publication_run_id=%s\npublication_run_attempt=%s\npublication_context_sha=%s\npublication_workflow_sha=%s\npublication_workflow_ref=%s\npublication_workflow_sha256=%s\n' \ + "$GITHUB_RUN_ID" "$GITHUB_RUN_ATTEMPT" "$GITHUB_SHA" "$GITHUB_WORKFLOW_SHA" "$GITHUB_WORKFLOW_REF" \ + "${RECOVERY_WORKFLOW_SHA256:-$(sha256sum .github/workflows/weasel-release.yml | cut -d ' ' -f 1)}" + if [[ -n "$WINDOWS_RECOVERY_RUN_ID" ]]; then + printf 'retained_platform_origin_run_id=%s\nretained_platform_origin_run_attempt=1\nwindows_build_run_id=%s\nwindows_build_run_attempt=%s\nwindows_application_source_sha=%s\nwindows_packaging_control_sha=%s\nwindows_packaging_script_sha256=%s\n' \ + "$WINDOWS_RECOVERY_RUN_ID" "$GITHUB_RUN_ID" "$GITHUB_RUN_ATTEMPT" "$source_sha" "$GITHUB_SHA" "$WINDOWS_PACKAGING_SHA256" + fi + if [[ "$DESKTOP_ONLY" == true ]]; then + printf 'release_platforms=windows-x64,linux-x64,nixos-x64\nandroid_status=not-built-desktop-only\n' + else + printf 'android_source_sha=%s\nandroid_pnpm_lock_sha256=%s\n' \ + "$ANDROID_SOURCE_SHA" "${ANDROID_LOCK_SHA256:-$lock_sha}" + fi + printf 'github_asset_digests=%s\n' "$(jq -c '[.[] | {name, digest}]' <<<"$assets_json")" + printf 'artifact_sha256:\n' + cat release-assets/SHA256SUMS + } > release-assets/RELEASE-RECEIPT.txt + + assert_draft_release + + gh release upload "$tag" release-assets/RELEASE-RECEIPT.txt --clobber + + gh release edit "$tag" --draft=false diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts index 29b12c9205c06..a7ca6aa600fde 100644 --- a/scripts/build-desktop-artifact.test.ts +++ b/scripts/build-desktop-artifact.test.ts @@ -162,6 +162,8 @@ const WINDOWS_PAYLOAD_FIXTURE_VERSION = "1.2.3"; const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(function* (input: { readonly copyUnpackedNatives: boolean; + readonly cuaFileCount?: number; + readonly cuaPackage?: string; readonly serverEntrySource?: string; readonly wslRuntime?: "valid" | "loose-server-tree" | "missing-pty" | "bad-digest"; readonly targetArch?: "x64" | "arm64"; @@ -180,6 +182,18 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu yield* fs.writeFileString(serverEntryPath, input.serverEntrySource ?? "console.log('server');\n"); yield* fs.writeFileString(nativePath, "MZ native-binary"); + for (let index = 0; index < (input.cuaFileCount ?? 0); index += 1) { + const file = path.join( + sourceDir, + "node_modules", + input.cuaPackage ?? "@trycua/cua-driver", + "dist", + `fixture-${index}.js`, + ); + yield* fs.makeDirectory(path.dirname(file), { recursive: true }); + yield* fs.writeFileString(file, "export {};\n"); + } + const generatedAsarPath = path.join(tempDir, WINDOWS_SERVER_ASAR_RESOURCE); yield* packWindowsServerAsar({ sourceDir, asarPath: generatedAsarPath, arch: "x64" }); @@ -1665,6 +1679,125 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => { ), ); + it.effect("allows only bounded ASAR-declared CUA packages beyond the Windows base budget", () => + Effect.scoped( + Effect.gen(function* () { + const fixture = yield* makeWindowsPayloadFixture({ + copyUnpackedNatives: true, + cuaFileCount: 107, + }); + const result = yield* validateWindowsPackagedPayload({ + stageDistDir: fixture.stageDistDir, + appExecutableName: fixture.appExecutableName, + targetArch: "x64", + appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION, + }); + assert.isAbove(result.fileCount, WINDOWS_PACKAGED_PAYLOAD_FILE_LIMIT); + assert.lengthOf( + result.unpackedFiles.filter((file) => + file.startsWith("node_modules/@trycua/cua-driver/"), + ), + 107, + ); + }), + ).pipe(Effect.provideService(HostProcess.Platform, "linux")), + ); + + it.effect("keeps loose files outside the CUA allowance", () => + Effect.scoped( + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const fixture = yield* makeWindowsPayloadFixture({ + copyUnpackedNatives: true, + cuaFileCount: 107, + }); + for (let index = 0; index < WINDOWS_PACKAGED_PAYLOAD_FILE_LIMIT; index += 1) + yield* fs.writeFileString( + path.join(fixture.packagedAppDir, `loose-${index}.txt`), + "unexpected", + ); + const error = yield* validateWindowsPackagedPayload({ + stageDistDir: fixture.stageDistDir, + appExecutableName: fixture.appExecutableName, + targetArch: "x64", + appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION, + }).pipe(Effect.flip); + assert.instanceOf(error, WindowsPackagedPayloadValidationError); + assert.equal(error.reason, "file-limit-exceeded"); + }), + ), + ); + + it.effect("rejects a missing declared CUA resolver file", () => + Effect.scoped( + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const fixture = yield* makeWindowsPayloadFixture({ + copyUnpackedNatives: true, + cuaFileCount: 107, + }); + yield* fs.remove( + path.join( + fixture.packagedAppDir, + "resources", + "server.asar.unpacked", + "node_modules/@trycua/cua-driver/dist/fixture-0.js", + ), + ); + const error = yield* validateWindowsPackagedPayload({ + stageDistDir: fixture.stageDistDir, + appExecutableName: fixture.appExecutableName, + targetArch: "x64", + appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION, + }).pipe(Effect.flip); + assert.instanceOf(error, WindowsPackagedPayloadValidationError); + assert.equal(error.reason, "unpacked-native-missing"); + }), + ), + ); + + it.effect("rejects an oversized CUA SDK despite its declared ASAR paths", () => + Effect.scoped( + Effect.gen(function* () { + const fixture = yield* makeWindowsPayloadFixture({ + copyUnpackedNatives: true, + cuaFileCount: 129, + }); + const error = yield* validateWindowsPackagedPayload({ + stageDistDir: fixture.stageDistDir, + appExecutableName: fixture.appExecutableName, + targetArch: "x64", + appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION, + }).pipe(Effect.flip); + assert.instanceOf(error, WindowsPackagedPayloadValidationError); + assert.equal(error.reason, "cua-file-limit-exceeded"); + assert.equal(error.fileLimit, 128); + }), + ), + ); + + it.effect("does not grant other trycua packages the Windows SDK allowance", () => + Effect.scoped( + Effect.gen(function* () { + const fixture = yield* makeWindowsPayloadFixture({ + copyUnpackedNatives: true, + cuaFileCount: 107, + cuaPackage: "@trycua/unreviewed", + }); + const error = yield* validateWindowsPackagedPayload({ + stageDistDir: fixture.stageDistDir, + appExecutableName: fixture.appExecutableName, + targetArch: "x64", + appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION, + }).pipe(Effect.flip); + assert.instanceOf(error, WindowsPackagedPayloadValidationError); + assert.equal(error.reason, "file-limit-exceeded"); + }), + ), + ); + it.effect("rejects a Windows payload that regresses above the file-count budget", () => Effect.scoped( Effect.gen(function* () { diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts index eb685882bd9ae..11c27bdc3c1af 100644 --- a/scripts/build-desktop-artifact.ts +++ b/scripts/build-desktop-artifact.ts @@ -752,6 +752,7 @@ const WindowsPackagedPayloadValidationReason = Schema.Literals([ "wsl-runtime-missing", "wsl-runtime-invalid", "file-limit-exceeded", + "cua-file-limit-exceeded", ]); export class WindowsPackagedPayloadValidationError extends Schema.TaggedError()( @@ -766,6 +767,9 @@ export class WindowsPackagedPayloadValidationError extends Schema.TaggedError fileLimit) { + const cuaPackageRoots = [ + "node_modules/@trycua/cua-driver/", + `node_modules/@trycua/cua-driver-win32-${input.targetArch}-msvc/`, + "node_modules/@ubjs/core/", + "node_modules/@ubjs/node/", + `node_modules/@ubjs/node-win32-${input.targetArch}-msvc/`, + ]; + const cuaFileCount = unpackedFiles.filter((file) => + cuaPackageRoots.some((root) => file.startsWith(root)), + ).length; + if (cuaFileCount > WINDOWS_CUA_UNPACKED_FILE_LIMIT) { + return yield* new WindowsPackagedPayloadValidationError({ + reason: "cua-file-limit-exceeded", + packagedAppDir, + fileCount: cuaFileCount, + fileLimit: WINDOWS_CUA_UNPACKED_FILE_LIMIT, + }); + } + // Only ASAR-declared files already checked above earn the SDK allowance. + // Loose files and unrelated packages still consume the original budget. + const totalFileLimit = fileLimit + cuaFileCount; + if (fileCount > totalFileLimit) { return yield* new WindowsPackagedPayloadValidationError({ reason: "file-limit-exceeded", packagedAppDir, fileCount, - fileLimit, + fileLimit: totalFileLimit, }); } diff --git a/scripts/weasel/release62-recovery.py b/scripts/weasel/release62-recovery.py new file mode 100644 index 0000000000000..1d5d36353f2a7 --- /dev/null +++ b/scripts/weasel/release62-recovery.py @@ -0,0 +1,217 @@ +#!/usr/bin/env python3 +"""One-cut recovery for the failed .62 Windows package; no generic recovery mode.""" +import datetime +import hashlib +import json +import os +from pathlib import Path, PurePosixPath +import shutil +import stat +import subprocess +import sys +import zipfile + +SOURCE = "01102e1d064e371033bbd9782bc8f2ac20c7b3ad" +ORIGIN_RUN = "39537119530" +VERSION = "0.1.2-nightly.20261021.62" +REPO = "morrowbyte/t3code" +WORKFLOW = ".github/workflows/weasel-release62-recovery.yml" +ORIGIN_WORKFLOW = ".github/workflows/weasel-release.yml" +ORIGIN_WORKFLOW_SHA256 = "36a9673b2d37b36b9131ba8a4dfc893777fac6b22c1993e48b0581f4326d4f5d" +LOCK_SHA256 = "e58efebfbcc2e7601e0459343b97fc033b67e665b416596119ac7647d7a4abb1" +ROUTE_SHA256 = "fa1b95cb16c59c5a6bf92647b1bb3f3ab872c4cb06ef7a0e5e723775fb5c3dcc" +PACKAGING_SHA256 = "537a26500a69adb09690a68af0e98cf8e822e0bbc428308fb229eb05d462829d" +PACKAGING_TEST_SHA256 = "46974cac0c2414b170f78be368ff8c8eee1bf0921fb14169b0b12db3836acc1a" +ALLOWED_TOOLING = {WORKFLOW, "scripts/weasel/release62-recovery.py", "scripts/weasel/release62-recovery.test.py", "scripts/weasel/test.sh", "scripts/build-desktop-artifact.ts", "scripts/build-desktop-artifact.test.ts"} +ARTIFACTS = {'12318601381': {'name': 'weasel-observatory-build-01102e1d064e371033bbd9782bc8f2ac20c7b3ad-1', 'digest': 'sha256:e546bfe35c42a17c1e84f74814b3f1cf0f42703b3e1e9b366557787430f0bf74', 'size_in_bytes': 4107, 'expires_at': '2026-10-28T03:14:27Z'}, '12318462143': {'name': 'weasel-release-linux', 'digest': 'sha256:697e18acee18f30b0783eea1b728a118db31467873774389a7acba90fde42ea6', 'size_in_bytes': 360661420, 'expires_at': '2026-10-22T03:17:12Z'}, '12318277967': {'name': 'weasel-release-nixos', 'digest': 'sha256:0f752852751859f718dad30f4f14e1fd337ceec469b81b4ddf4a378b32af27b0', 'size_in_bytes': 370920901, 'expires_at': '2026-10-22T03:18:38Z'}, '12318262084': {'name': 'weasel-js-bundle', 'digest': 'sha256:fe8c4b43cd9c995e2e863be8f9490184c611f30c0014cc20bddf1943b5280849', 'size_in_bytes': 56356251, 'expires_at': '2026-10-22T03:14:28Z'}, '12318137293': {'name': 'weasel-observatory-preflight-01102e1d064e371033bbd9782bc8f2ac20c7b3ad-1', 'digest': 'sha256:a1327d8e43803c89559f2b157057c7a0898cdd1444fcd0255a76ed29c04db5fb', 'size_in_bytes': 4452, 'expires_at': '2026-10-28T03:13:09Z'}, '12318098003': {'name': 'weasel-release-cli-linux', 'digest': 'sha256:26dbfc4337e35854f106c77f99bd4920b927939f4c6c276048aae0304439e86f', 'size_in_bytes': 112049857, 'expires_at': '2026-10-22T03:17:19Z'}, '12317657922': {'name': 'weasel-android-build-evidence-01102e1d064e371033bbd9782bc8f2ac20c7b3ad-1', 'digest': 'sha256:8e38c15c2354a2803bd8ac72c3195f70fc414198a841326298828a64cf2fb512', 'size_in_bytes': 19120, 'expires_at': '2026-10-28T03:20:39Z'}, '12317643042': {'name': 'weasel-release-android', 'digest': 'sha256:c479ce6ab8f8c7050ae9e95c269ff2e52eb2c13f7bca7926d9206e7a06623fd0', 'size_in_bytes': 56293459, 'expires_at': '2026-10-28T03:20:36Z'}} +JOBS = {"preflight": "success", "build_bundle": "success", "build_linux": "success", "build_nixos": "success", "build_windows": "failure", "Build Morrowbyte Android APK": "success", "publish": "skipped", "publish_android": "skipped", "publish_windows": "skipped"} + + +VERIFIED_STEPS = { + "preflight": ["Check source before release", "Verify reviewed Observatory preflight route"], + "Build Morrowbyte Android APK": ["Build signed standalone arm64 APK once", "Verify APK signature, embedded bundle, identity and 16KB native alignment"], + "build_bundle": ["Bind independently built Observatory route"], + "build_linux": ["Package and smoke-test Linux CLI archive"], + "build_nixos": ["Build immutable NixOS closure on Blacksmith"], +} + + +def require(condition, message): + if not condition: + raise RuntimeError(message) + + +def digest(path): + with Path(path).open("rb") as stream: + return hashlib.file_digest(stream, "sha256").hexdigest() + + +def git(*args): + return subprocess.check_output(["git", *args], text=True).strip() + + +def api(suffix): + return json.loads(subprocess.check_output(["gh", "api", f"repos/{REPO}/" + suffix])) + + +def validate_origin(run, jobs, metadata, now): + require(run["id"] == int(ORIGIN_RUN) and run["run_number"] == 62 and run["run_attempt"] == 1, "Wrong origin run/version/attempt") + require(run["repository"]["full_name"] == run["head_repository"]["full_name"] == REPO, "Foreign origin") + require(run["head_sha"] == SOURCE and run["head_branch"] == "main" and run["event"] == "workflow_dispatch" and run["path"] == ORIGIN_WORKFLOW, "Wrong origin source/workflow") + require(run["status"] == "completed" and run["conclusion"] == "failure", "Origin is not the terminal failed run") + require(jobs["total_count"] == len(jobs["jobs"]) == len(JOBS), "Incomplete origin jobs") + require({j["name"]: j["conclusion"] for j in jobs["jobs"]} == JOBS, "Unexpected origin job conclusions") + require(all(j["head_sha"] == SOURCE and j["status"] == "completed" for j in jobs["jobs"]), "Wrong job source/state") + for job_name, step_names in VERIFIED_STEPS.items(): + job = next(j for j in jobs["jobs"] if j["name"] == job_name) + for step_name in step_names: + matches = [step for step in job["steps"] if step["name"] == step_name] + require(len(matches) == 1 and matches[0]["conclusion"] == "success", "Original verification step did not pass: " + step_name) + windows = next(j for j in jobs["jobs"] if j["name"] == "build_windows") + require([s["name"] for s in windows["steps"] if s["conclusion"] == "failure"] == ["Build Windows x64 installer and updater metadata"], "Unexpected failed Windows step") + artifacts = metadata["artifacts"] + require(metadata["total_count"] == len(artifacts) == len(ARTIFACTS), "Incomplete artifact inventory") + require({str(a["id"]) for a in artifacts} == set(ARTIFACTS), "Changed origin artifact IDs") + for artifact in artifacts: + pin = ARTIFACTS[str(artifact["id"])] + require(all(artifact[key] == value for key, value in pin.items()), "Changed artifact name/digest/size/expiry") + require(not artifact["expired"] and datetime.datetime.fromisoformat(artifact["expires_at"].replace("Z", "+00:00")) > now, "Origin artifact expired") + owner = artifact["workflow_run"] + require(owner["id"] == int(ORIGIN_RUN) and owner["head_sha"] == SOURCE, "Wrong artifact workflow owner") + require(owner["repository_id"] == owner["head_repository_id"] == run["repository"]["id"], "Foreign artifact repository") + return artifacts + + +def validate_tooling_changes(changed, packaging_hash, test_hash): + require(set(changed) == ALLOWED_TOOLING, "Application/lock/auth source changed outside reviewed recovery tooling") + require(packaging_hash == PACKAGING_SHA256 and test_hash == PACKAGING_TEST_SHA256, "Wrong validator/test bytes") + + +def extract_verified(archive_path, artifact, target, bundle=False): + require(Path(archive_path).stat().st_size == artifact["size_in_bytes"] and "sha256:" + digest(archive_path) == artifact["digest"], "Origin ZIP bytes do not match pinned digest/length") + target.mkdir(exist_ok=True) + with zipfile.ZipFile(archive_path) as archive: + require(sum(m.file_size for m in archive.infolist()) <= 4 * 1024**3, "Oversized artifact expansion") + for member in archive.infolist(): + relative = PurePosixPath(member.filename) + require(bool(relative.parts) and not relative.is_absolute() and ".." not in relative.parts and "\\" not in member.filename and ":" not in member.filename, "Unsafe ZIP path") + require(not stat.S_ISLNK(member.external_attr >> 16), "ZIP symlink") + if bundle: + require(relative.parts[:2] in {("server", "dist"), ("desktop", "dist-electron")}, "Unexpected bundle path") + else: + require(member.filename == relative.name and not member.is_dir(), "Non-flat payload") + destination = target / relative + if member.filename == "builder-debug.yml": + require(artifact["name"] == "weasel-release-linux", "Unexpected debug metadata") + destination = target / "weasel-release-linux-builder-debug.yml" + if member.is_dir(): + destination.mkdir(parents=True, exist_ok=True) + continue + destination.parent.mkdir(parents=True, exist_ok=True) + with archive.open(member) as incoming, destination.open("xb") as outgoing: + shutil.copyfileobj(incoming, outgoing) + + +def validate_proofs(root): + pre = json.loads((root / "observatory-route-generation/receipt.json").read_bytes()) + built = json.loads((root / "observatory-release-build/receipt.json").read_bytes()) + ref = REPO + "/" + ORIGIN_WORKFLOW + "@refs/heads/main" + for proof in [pre, built]: + require(proof["source"] == proof["trustedContextSha"] == proof["trustedWorkflowSha"] == SOURCE, "Wrong route proof source") + require(proof["run"] == ORIGIN_RUN and proof["attempt"] == "1" and proof["trustedWorkflowRef"] == ref and proof["lockSha256"] == LOCK_SHA256, "Wrong route proof owner/lock") + require(pre["status"] == "generated-unreviewed" and pre["effectiveSourceSha"] == SOURCE, "Wrong route generation state") + require(pre["generatorVersion"] == "1.167.12" and pre["config"] == {"autoCodeSplitting": True}, "Wrong route generator") + require(pre["checkScriptSha256"] == digest("scripts/weasel/check.sh") and pre["beforeSha256"] == digest("apps/web/src/routeTree.gen.ts"), "Wrong route input/check source") + require(pre["afterSha256"] == built["generatedRouteSha256"] == ROUTE_SHA256, "Wrong generated route") + for directory in ["observatory-route-generation", "observatory-release-build"]: + require(digest(root / directory / "routeTree.gen.ts") == ROUTE_SHA256, "Wrong generated route bytes") + require(built["preflightReceiptSha256"] == digest(root / "observatory-route-generation/receipt.json") and (root / "observatory-route-generation/routeTree.diff").is_file(), "Broken route proof chain") + assets = root / "recovered-platforms" + name = f"Morrowbyte-{VERSION}-android-arm64.apk" + receipt_path = assets / (name + ".json") + receipt = json.loads(receipt_path.read_bytes()) + apk_hash = digest(assets / name) + expected = {"schemaVersion": 1, "source": SOURCE, "desktopSource": SOURCE, "version": VERSION, "versionCode": 62, "run": ORIGIN_RUN, "attempt": "1", "trustedContextSha": SOURCE, "trustedWorkflowSha": SOURCE, "trustedWorkflowRef": ref, "lockSha256": LOCK_SHA256, "apk": name, "apkSha256": apk_hash, "package": "com.morrowbyte.t3code", "name": "Morrowbyte", "certificateSha256": "34a33c2541544bc4a96e359a33e9f71aaa449ee9a0cd725c2469b65b057aa2b2", "abis": ["arm64-v8a"], "signatureVerified": True, "zip16KB": True, "elf16KB": True, "deviceAcceptance": "not-run"} + require(all(receipt.get(k) == v for k, v in expected.items()), "Wrong APK provenance/signature/identity proof") + require((assets / (name + ".sha256")).read_text() == f"{apk_hash} {name}\n", "Wrong APK checksum sidecar") + return apk_hash, digest(receipt_path) + + +def recover(): + require(os.environ["GITHUB_REPOSITORY"] == REPO and os.environ["SOURCE_SHA"] == SOURCE and os.environ["ORIGIN_RUN_ID"] == ORIGIN_RUN, "Wrong recovery request") + require(os.environ["GITHUB_REF"] == "refs/heads/main" and os.environ["GITHUB_WORKFLOW_REF"] == REPO + "/" + WORKFLOW + "@refs/heads/main", "Wrong recovery workflow/ref") + control = os.environ["GITHUB_SHA"] + require(control == os.environ["GITHUB_WORKFLOW_SHA"] and os.environ["GITHUB_RUN_ATTEMPT"] == "1", "Wrong tooling pin or repeated recovery attempt") + require(git("rev-parse", "HEAD") == SOURCE and not git("status", "--porcelain", "--untracked-files=all"), "Application checkout must be exact and clean") + subprocess.run(["git", "fetch", "--no-tags", "origin", "main"], check=True) + require(git("rev-parse", "FETCH_HEAD") == control, "Recovery tooling is no longer current main") + subprocess.run(["git", "merge-base", "--is-ancestor", SOURCE, control], check=True) + changed = set(git("diff", "--name-only", SOURCE, control).splitlines()) + validate_tooling_changes(changed, + hashlib.sha256(subprocess.check_output(["git", "show", control + ":scripts/build-desktop-artifact.ts"])).hexdigest(), + hashlib.sha256(subprocess.check_output(["git", "show", control + ":scripts/build-desktop-artifact.test.ts"])).hexdigest()) + require(digest("pnpm-lock.yaml") == LOCK_SHA256 and digest(ORIGIN_WORKFLOW) == ORIGIN_WORKFLOW_SHA256, "Wrong original app lock/workflow") + ci = api(f"actions/workflows/weasel-ci.yml/runs?head_sha={control}&event=push&branch=main&per_page=100") + candidates = ci["workflow_runs"] + require(candidates and ci["total_count"] == len(candidates), "Missing/incomplete tooling main CI") + latest = max(candidates, key=lambda r: r["id"]) + require(latest["status"] == "completed" and latest["conclusion"] == "success" and latest["head_sha"] == control and latest["head_branch"] == "main" and latest["event"] == "push" and latest["path"] == ".github/workflows/weasel-ci.yml" and latest["head_repository"]["full_name"] == REPO, "Tooling main CI not qualified") + ci_jobs = api(f"actions/runs/{latest['id']}/attempts/{latest['run_attempt']}/jobs?per_page=100") + require(ci_jobs["total_count"] == len(ci_jobs["jobs"]), "Incomplete tooling CI jobs") + for name in ["check", "windows_installer_guard"]: + matches = [j for j in ci_jobs["jobs"] if j["name"] == name] + require(len(matches) == 1 and matches[0]["status"] == "completed" and matches[0]["conclusion"] == "success", "Required tooling CI job not successful") + runs = api("actions/workflows/weasel-release62-recovery.yml/runs?event=workflow_dispatch&per_page=100") + require(runs["total_count"] == len(runs["workflow_runs"]) == 1 and str(runs["workflow_runs"][0]["id"]) == os.environ["GITHUB_RUN_ID"], "Recovery is one-shot; no duplicate dispatch or retry") + for page in range(1, 11): + releases = api(f"releases?per_page=100&page={page}") + require(not any(item["tag_name"] == "v" + VERSION for item in releases), "Release already exists; reconcile without a new Windows build") + if len(releases) < 100: + break + require(page < 10, "Incomplete release observation") + tag_refs = git("ls-remote", "origin", "refs/tags/v" + VERSION, "refs/tags/v" + VERSION + "^{}") + if tag_refs: + resolved = {line.split()[1]: line.split()[0] for line in tag_refs.splitlines()} + require(resolved.get("refs/tags/v" + VERSION + "^{}", resolved.get("refs/tags/v" + VERSION)) == SOURCE, "Existing release tag has a different source") + run = api(f"actions/runs/{ORIGIN_RUN}") + jobs = api(f"actions/runs/{ORIGIN_RUN}/attempts/1/jobs?per_page=100") + metadata = api(f"actions/runs/{ORIGIN_RUN}/artifacts?per_page=100") + artifacts = validate_origin(run, jobs, metadata, datetime.datetime.now(datetime.timezone.utc)) + root = Path(os.environ["RUNNER_TEMP"]) + destinations = {"weasel-release-linux": "recovered-platforms", "weasel-release-nixos": "recovered-platforms", "weasel-release-android": "recovered-platforms", "weasel-release-cli-linux": "recovered-cli-linux", "weasel-js-bundle": "recovered-js-bundle", f"weasel-observatory-preflight-{SOURCE}-1": "observatory-route-generation", f"weasel-observatory-build-{SOURCE}-1": "observatory-release-build"} + for artifact in artifacts: + name = artifact["name"] + if name not in destinations: + continue + archive = root / (str(artifact["id"]) + ".zip") + with archive.open("xb") as output: + subprocess.run(["gh", "api", f"repos/{REPO}/actions/artifacts/{artifact['id']}/zip"], stdout=output, check=True) + extract_verified(archive, artifact, root / destinations[name], bundle=name == "weasel-js-bundle") + archive.unlink() + apk_hash, apk_receipt_hash = validate_proofs(root) + workflow_hash = hashlib.sha256(subprocess.check_output(["git", "show", control + ":" + WORKFLOW])).hexdigest() + files = [{"name": f.name, "sha256": digest(f)} for d in ["recovered-platforms", "recovered-cli-linux"] for f in sorted((root / d).iterdir())] + receipt = {"schemaVersion": 1, "source": SOURCE, "version": VERSION, "originRun": ORIGIN_RUN, "originAttempt": "1", "originWorkflowSha": SOURCE, "originWorkflowRef": REPO + "/" + ORIGIN_WORKFLOW + "@refs/heads/main", "originWorkflowSha256": ORIGIN_WORKFLOW_SHA256, "controlSource": control, "controlWorkflowSha256": workflow_hash, "windowsPackagingScriptSha256": PACKAGING_SHA256, "publicationRun": os.environ["GITHUB_RUN_ID"], "publicationAttempt": "1", "changedPaths": sorted(changed), "originArtifacts": artifacts, "files": files} + receipt_path = root / "recovered-platforms/WINDOWS-RECOVERY.json" + receipt_path.write_text(json.dumps(receipt, indent=2) + "\n") + outputs = {"source_sha": SOURCE, "version": VERSION, "android_version_code": "62", "tag": "v" + VERSION, "observatory_route_sha256": ROUTE_SHA256, "desktop_run_id": ORIGIN_RUN, "desktop_run_attempt": "1", "desktop_context_sha": SOURCE, "desktop_workflow_sha": SOURCE, "desktop_workflow_ref": REPO + "/" + ORIGIN_WORKFLOW + "@refs/heads/main", "recovery_artifact_attempt": "1", "recovery_workflow_sha256": workflow_hash, "windows_packaging_sha256": PACKAGING_SHA256, "windows_recovery_receipt_sha256": digest(receipt_path), "android_source_sha": SOURCE, "android_lock_sha256": LOCK_SHA256, "recovered_apk_sha256": apk_hash, "recovered_apk_receipt_sha256": apk_receipt_hash} + with open(os.environ["GITHUB_OUTPUT"], "a") as output: + for key, value in outputs.items(): + output.write(f"{key}={value}\n") + + +def verify_retained(): + assets = Path("release-assets") + receipt_path = assets / "WINDOWS-RECOVERY.json" + require(digest(receipt_path) == os.environ["RECOVERY_RECEIPT_SHA256"], "Changed recovery receipt") + receipt = json.loads(receipt_path.read_bytes()) + require(receipt["source"] == SOURCE and receipt["version"] == VERSION and receipt["originRun"] == ORIGIN_RUN and receipt["originAttempt"] == "1", "Wrong retained source/version/run") + require(receipt["controlSource"] == os.environ["GITHUB_SHA"] and receipt["publicationRun"] == os.environ["GITHUB_RUN_ID"] and receipt["publicationAttempt"] == os.environ["GITHUB_RUN_ATTEMPT"] == "1", "Wrong recovery ownership") + require(receipt["windowsPackagingScriptSha256"] == PACKAGING_SHA256, "Wrong Windows validator") + for item in receipt["files"]: + require(Path(item["name"]).name == item["name"] and digest(assets / item["name"]) == item["sha256"], "Retained platform bytes changed") + + +if __name__ == "__main__": + require(len(sys.argv) == 2 and sys.argv[1] in {"recover", "verify"}, "Expected recover or verify") + recover() if sys.argv[1] == "recover" else verify_retained() diff --git a/scripts/weasel/release62-recovery.test.py b/scripts/weasel/release62-recovery.test.py new file mode 100644 index 0000000000000..07ce687463835 --- /dev/null +++ b/scripts/weasel/release62-recovery.test.py @@ -0,0 +1,225 @@ +#!/usr/bin/env python3 +"""Bounded offline fixtures; never dispatch, download, compile or publish.""" +import contextlib +import datetime +import importlib.util +import json +import os +from pathlib import Path +import stat +import subprocess +import sys +import tempfile +import unittest +from unittest.mock import patch +import zipfile + +sys.dont_write_bytecode = True + +spec = importlib.util.spec_from_file_location("release62_recovery", Path(__file__).with_name("release62-recovery.py")) +r = importlib.util.module_from_spec(spec) +spec.loader.exec_module(r) +ROOT = Path(__file__).resolve().parents[2] + + +def origin_fixture(): + run = {"id": int(r.ORIGIN_RUN), "run_number": 62, "run_attempt": 1, "repository": {"full_name": r.REPO, "id": 1175532637}, "head_repository": {"full_name": r.REPO}, "head_sha": r.SOURCE, "head_branch": "main", "event": "workflow_dispatch", "path": r.ORIGIN_WORKFLOW, "status": "completed", "conclusion": "failure"} + jobs = {"total_count": len(r.JOBS), "jobs": [{"name": name, "conclusion": conclusion, "status": "completed", "head_sha": r.SOURCE, "steps": [{"name": "Build Windows x64 installer and updater metadata", "conclusion": "failure"}] if name == "build_windows" else []} for name, conclusion in r.JOBS.items()]} + for job in jobs["jobs"]: + if job["name"] in r.VERIFIED_STEPS: + job["steps"] = [{"name": name, "conclusion": "success"} for name in r.VERIFIED_STEPS[job["name"]]] + artifacts = [{"id": int(key), **value, "expired": False, "workflow_run": {"id": int(r.ORIGIN_RUN), "head_sha": r.SOURCE, "repository_id": 1175532637, "head_repository_id": 1175532637}} for key, value in r.ARTIFACTS.items()] + return run, jobs, {"total_count": len(artifacts), "artifacts": artifacts} + + +def proof_fixture(root): + ref = r.REPO + "/" + r.ORIGIN_WORKFLOW + "@refs/heads/main" + common = {"source": r.SOURCE, "trustedContextSha": r.SOURCE, "trustedWorkflowSha": r.SOURCE, "run": r.ORIGIN_RUN, "attempt": "1", "trustedWorkflowRef": ref, "lockSha256": r.LOCK_SHA256} + pre = {**common, "status": "generated-unreviewed", "effectiveSourceSha": r.SOURCE, "generatorVersion": "1.167.12", "config": {"autoCodeSplitting": True}, "checkScriptSha256": r.digest(ROOT / "scripts/weasel/check.sh"), "beforeSha256": r.digest(ROOT / "apps/web/src/routeTree.gen.ts"), "afterSha256": r.ROUTE_SHA256} + for directory in ["observatory-route-generation", "observatory-release-build", "recovered-platforms"]: + (root / directory).mkdir() + (root / "observatory-route-generation/receipt.json").write_text(json.dumps(pre)) + (root / "observatory-route-generation/routeTree.diff").write_text("fixture diff") + for directory in ["observatory-route-generation", "observatory-release-build"]: + (root / directory / "routeTree.gen.ts").write_bytes((ROOT / "apps/web/src/routeTree.gen.ts").read_bytes()) + built = {**common, "generatedRouteSha256": r.ROUTE_SHA256, "preflightReceiptSha256": r.digest(root / "observatory-route-generation/receipt.json")} + (root / "observatory-release-build/receipt.json").write_text(json.dumps(built)) + name = f"Morrowbyte-{r.VERSION}-android-arm64.apk" + apk = root / "recovered-platforms" / name + apk.write_bytes(b"receipt-contract fixture; no native APK/signature acceptance") + sha = r.digest(apk) + receipt = {"schemaVersion": 1, **common, "desktopSource": r.SOURCE, "version": r.VERSION, "versionCode": 62, "apk": name, "apkSha256": sha, "package": "com.morrowbyte.t3code", "name": "Morrowbyte", "certificateSha256": "34a33c2541544bc4a96e359a33e9f71aaa449ee9a0cd725c2469b65b057aa2b2", "abis": ["arm64-v8a"], "signatureVerified": True, "zip16KB": True, "elf16KB": True, "deviceAcceptance": "not-run"} + (root / "recovered-platforms" / (name + ".json")).write_text(json.dumps(receipt)) + (root / "recovered-platforms" / (name + ".sha256")).write_text(f"{sha} {name}\n") + return receipt, apk + + +class RecoveryFixtures(unittest.TestCase): + def test_exact_failed_origin_and_all_eight_artifacts_qualify(self): + self.assertEqual(len(r.validate_origin(*origin_fixture(), datetime.datetime(2026, 10, 21, tzinfo=datetime.timezone.utc))), 8) + + def test_wrong_origin_attempt_source_version_and_job_outcomes_fail(self): + for key, value in [("id", 39182028263), ("run_attempt", 2), ("run_number", 63), ("head_sha", "f" * 40), ("path", r.WORKFLOW), ("conclusion", "success")]: + run, jobs, artifacts = origin_fixture() + run[key] = value + with self.subTest(key=key), self.assertRaises(RuntimeError): + r.validate_origin(run, jobs, artifacts, datetime.datetime(2026, 10, 21, tzinfo=datetime.timezone.utc)) + run, jobs, artifacts = origin_fixture() + jobs["jobs"][0]["conclusion"] = "failure" + with self.assertRaises(RuntimeError): + r.validate_origin(run, jobs, artifacts, datetime.datetime(2026, 10, 21, tzinfo=datetime.timezone.utc)) + + def test_artifact_digest_size_owner_expiry_and_complete_inventory_fail_closed(self): + for key, value in [("id", 1), ("digest", "sha256:" + "0" * 64), ("size_in_bytes", 1), ("expired", True), ("expires_at", "2026-10-20T00:00:00Z")]: + run, jobs, artifacts = origin_fixture() + artifacts["artifacts"][0][key] = value + with self.subTest(key=key), self.assertRaises(RuntimeError): + r.validate_origin(run, jobs, artifacts, datetime.datetime(2026, 10, 21, tzinfo=datetime.timezone.utc)) + run, jobs, artifacts = origin_fixture() + artifacts["artifacts"][0]["workflow_run"]["head_repository_id"] = 1 + with self.assertRaises(RuntimeError): + r.validate_origin(run, jobs, artifacts, datetime.datetime(2026, 10, 21, tzinfo=datetime.timezone.utc)) + run, jobs, artifacts = origin_fixture() + artifacts["artifacts"].pop() + with self.assertRaises(RuntimeError): + r.validate_origin(run, jobs, artifacts, datetime.datetime(2026, 10, 21, tzinfo=datetime.timezone.utc)) + + def test_skipped_original_apk_signature_step_cannot_qualify(self): + run, jobs, artifacts = origin_fixture() + android = next(job for job in jobs["jobs"] if job["name"] == "Build Morrowbyte Android APK") + android["steps"][-1]["conclusion"] = "skipped" + with self.assertRaisesRegex(RuntimeError, "verification step did not pass"): + r.validate_origin(run, jobs, artifacts, datetime.datetime(2026, 10, 21, tzinfo=datetime.timezone.utc)) + + def test_pinned_artifacts_expire_before_recovery_can_build_windows(self): + with self.assertRaisesRegex(RuntimeError, "expired"): + r.validate_origin(*origin_fixture(), datetime.datetime(2026, 10, 29, tzinfo=datetime.timezone.utc)) + + def test_route_and_apk_receipt_contract_chain_qualifies_offline(self): + with tempfile.TemporaryDirectory() as temp: + root = Path(temp) + receipt, apk = proof_fixture(root) + self.assertEqual(r.validate_proofs(root)[0], r.digest(apk)) + + def test_wrong_apk_source_cert_abi_version_and_false_signature_proofs_fail(self): + for key, value in [("source", "f" * 40), ("versionCode", 63), ("certificateSha256", "0" * 64), ("abis", ["x86_64"]), ("signatureVerified", False), ("zip16KB", False), ("attempt", "2")]: + with self.subTest(key=key), tempfile.TemporaryDirectory() as temp: + root = Path(temp) + receipt, apk = proof_fixture(root) + receipt[key] = value + apk.with_name(apk.name + ".json").write_text(json.dumps(receipt)) + with self.assertRaisesRegex(RuntimeError, "APK provenance"): + r.validate_proofs(root) + + def test_changed_apk_or_route_proof_bytes_fail_before_publish(self): + with tempfile.TemporaryDirectory() as temp: + root = Path(temp) + receipt, apk = proof_fixture(root) + apk.write_bytes(b"changed") + with self.assertRaises(RuntimeError): + r.validate_proofs(root) + with tempfile.TemporaryDirectory() as temp: + root = Path(temp) + proof_fixture(root) + (root / "observatory-release-build/routeTree.gen.ts").write_text("changed") + with self.assertRaisesRegex(RuntimeError, "route bytes"): + r.validate_proofs(root) + + def test_tooling_allowlist_never_allows_app_lock_or_auth_changes(self): + r.validate_tooling_changes(r.ALLOWED_TOOLING, r.PACKAGING_SHA256, r.PACKAGING_TEST_SHA256) + for extra in ["apps/server/src/voice/CodexLiveSessionService.ts", "pnpm-lock.yaml", "apps/server/src/auth/RpcAuthorization.ts"]: + with self.subTest(extra=extra), self.assertRaises(RuntimeError): + r.validate_tooling_changes(r.ALLOWED_TOOLING | {extra}, r.PACKAGING_SHA256, r.PACKAGING_TEST_SHA256) + with self.assertRaises(RuntimeError): + r.validate_tooling_changes(r.ALLOWED_TOOLING, "0" * 64, r.PACKAGING_TEST_SHA256) + + def test_exact_zip_bytes_are_reused_without_overwrite(self): + with tempfile.TemporaryDirectory() as temp: + root = Path(temp) + archive = root / "fixture.zip" + with zipfile.ZipFile(archive, "w") as output: + output.writestr("fixture.apk", b"fixture, not an Android package") + artifact = {"name": "weasel-release-android", "size_in_bytes": archive.stat().st_size, "digest": "sha256:" + r.digest(archive)} + r.extract_verified(archive, artifact, root / "out") + self.assertEqual((root / "out/fixture.apk").read_bytes(), b"fixture, not an Android package") + with self.assertRaises(FileExistsError): + r.extract_verified(archive, artifact, root / "out") + artifact["digest"] = "sha256:" + "0" * 64 + with self.assertRaisesRegex(RuntimeError, "digest/length"): + r.extract_verified(archive, artifact, root / "other") + + def test_zip_traversal_symlink_and_unexpected_bundle_paths_are_rejected(self): + for name, symlink, bundle in [("../escape", False, False), ("C:/escape", False, False), ("folder/file", False, False), ("link", True, False), ("server/source/unreviewed.js", False, True)]: + with self.subTest(name=name), tempfile.TemporaryDirectory() as temp: + root = Path(temp) + archive = root / "fixture.zip" + with zipfile.ZipFile(archive, "w") as output: + info = zipfile.ZipInfo(name) + if symlink: + info.create_system = 3 + info.external_attr = (stat.S_IFLNK | 0o777) << 16 + output.writestr(info, "fixture") + artifact = {"name": "fixture", "size_in_bytes": archive.stat().st_size, "digest": "sha256:" + r.digest(archive)} + with self.assertRaises(RuntimeError): + r.extract_verified(archive, artifact, root / "out", bundle=bundle) + + def test_wrong_recovery_request_stops_before_any_network_or_git(self): + for key, value in [("SOURCE_SHA", "f" * 40), ("ORIGIN_RUN_ID", "39182028263"), ("GITHUB_REPOSITORY", "foreign/repo")]: + env = {"SOURCE_SHA": r.SOURCE, "ORIGIN_RUN_ID": r.ORIGIN_RUN, "GITHUB_REPOSITORY": r.REPO, key: value} + with self.subTest(key=key), patch.dict(os.environ, env, clear=True), patch.object(r, "api") as network, patch.object(r, "git") as git: + with self.assertRaises(RuntimeError): + r.recover() + network.assert_not_called() + git.assert_not_called() + + def test_retained_files_and_control_identity_are_checked_before_publish(self): + with tempfile.TemporaryDirectory() as temp, contextlib.chdir(temp): + assets = Path("release-assets") + assets.mkdir() + (assets / "retained.AppImage").write_bytes(b"fixture-original") + receipt = {"source": r.SOURCE, "version": r.VERSION, "originRun": r.ORIGIN_RUN, "originAttempt": "1", "controlSource": "c" * 40, "publicationRun": "700", "publicationAttempt": "1", "windowsPackagingScriptSha256": r.PACKAGING_SHA256, "files": [{"name": "retained.AppImage", "sha256": r.digest(assets / "retained.AppImage")}]} + path = assets / "WINDOWS-RECOVERY.json" + path.write_text(json.dumps(receipt)) + env = {"RECOVERY_RECEIPT_SHA256": r.digest(path), "GITHUB_SHA": "c" * 40, "GITHUB_RUN_ID": "700", "GITHUB_RUN_ATTEMPT": "1"} + with patch.dict(os.environ, env, clear=True): + r.verify_retained() + (assets / "retained.AppImage").write_bytes(b"changed") + with self.assertRaisesRegex(RuntimeError, "bytes changed"): + r.verify_retained() + with patch.dict(os.environ, {**env, "GITHUB_SHA": "d" * 40}, clear=True): + with self.assertRaisesRegex(RuntimeError, "ownership"): + r.verify_retained() + + def test_workflow_has_only_recover_windows_publish_and_no_product_jobs_without_go(self): + command = "const {createRequire}=require('node:module'); const {resolve}=require('node:path');const y=createRequire(resolve('packages/shared/package.json'))('yaml'); console.log(JSON.stringify(y.parse(require('node:fs').readFileSync('.github/workflows/weasel-release62-recovery.yml','utf8'))));" + workflow = json.loads(subprocess.check_output(["node", "-e", command], cwd=ROOT)) + self.assertEqual(set(workflow["jobs"]), {"recover", "build_windows", "publish"}) + self.assertEqual(workflow["concurrency"], {"group": "weasel-desktop-nightly", "cancel-in-progress": False}) + self.assertFalse(workflow["on"]["workflow_dispatch"]["inputs"]["publish"]["default"]) + for name, job in workflow["jobs"].items(): + self.assertIn("inputs.publish", job["if"]) + self.assertEqual(job["timeout-minutes"], {"recover": 15, "build_windows": 50, "publish": 15}[name]) + evaluate = "const fs=require('node:fs');const a=JSON.parse(fs.readFileSync(0,'utf8'));let e=a.expression.trim().replace(/^\\$\\{\\{/,'').replace(/\\}\\}$/,'');console.log(JSON.stringify(Boolean(Function('inputs','needs','github','cancelled','return ('+e+')')(a.inputs,a.needs,{repository:'morrowbyte/t3code'},()=>false))));" + def condition(job, publish, recover="success", windows="success"): + payload = {"expression": workflow["jobs"][job]["if"], "inputs": {"publish": publish}, "needs": {"recover": {"result": recover}, "build_windows": {"result": windows}}} + return json.loads(subprocess.check_output(["node", "-e", evaluate], input=json.dumps(payload), text=True)) + for job in workflow["jobs"]: + self.assertFalse(condition(job, False)) + self.assertTrue(condition(job, True)) + self.assertFalse(condition("build_windows", True, recover="failure")) + self.assertFalse(condition("publish", True, windows="failure")) + self.assertFalse(condition("publish", True, recover="failure")) + windows = workflow["jobs"]["build_windows"] + self.assertEqual(windows["needs"], ["recover"]) + overlay = next(step for step in windows["steps"] if step["name"] == "Apply only the hash-pinned .62 validator fix") + self.assertIn(r.PACKAGING_SHA256, overlay["run"]) + self.assertIn('test "$(git diff --name-only)" = scripts/build-desktop-artifact.ts', overlay["run"]) + self.assertEqual(workflow["jobs"]["publish"]["needs"], ["recover", "build_windows"]) + publish = workflow["jobs"]["publish"] + self.assertIn("needs.build_windows.result == 'success'", publish["if"]) + self.assertTrue(any("Verify APK" in s.get("name", "") or s.get("name") == "Verify Android bytes from this build before publication" for s in publish["steps"])) + self.assertTrue(any(s.get("name") == "Verify every retained .62 payload byte and recovery ownership" for s in publish["steps"])) + + +if __name__ == "__main__": + unittest.main() diff --git a/scripts/weasel/test.sh b/scripts/weasel/test.sh index 85229d754f26f..4b74c60a5e57a 100644 --- a/scripts/weasel/test.sh +++ b/scripts/weasel/test.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -euo pipefail +python3 scripts/weasel/release62-recovery.test.py bash -n scripts/weasel/*.sh bash scripts/weasel/sync-upstream-nightly.test.sh