diff --git a/.github/release-signing.yml b/.github/release-signing.yml index 003d17668..dc1b0c626 100644 --- a/.github/release-signing.yml +++ b/.github/release-signing.yml @@ -31,4 +31,7 @@ fingerprint_files: - scripts/verify-windows-authenticode.ps1 - scripts/test-windows-installer-startup.ps1 - scripts/test-windows-startup-recovery.ps1 + - scripts/test-windows-legacy-update.ps1 + - scripts/legacy-windows-update.gotest + - .github/workflows/verify-windows-auto-update.yml - cmd/release-signing-contract/main.go diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml index 8c4f67e89..d4015bc2f 100644 --- a/.github/workflows/release-desktop.yml +++ b/.github/workflows/release-desktop.yml @@ -819,12 +819,74 @@ jobs: overwrite: true if-no-files-found: error retention-days: 30 + windows-legacy-upgrade: + name: verify v0.0.7 automatic handoff (${{ matrix.arch }}) + needs: [resolve, windows-sign] + if: ${{ always() && !cancelled() && needs.resolve.result == 'success' && needs.windows-sign.result == 'success' }} + permissions: + contents: read + actions: read + strategy: + fail-fast: false + matrix: + include: + - runner: windows-latest + arch: amd64 + - runner: windows-11-arm + arch: arm64 + runs-on: ${{ matrix.runner }} + timeout-minutes: 25 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + ref: ${{ github.workflow_sha }} + path: release-control + persist-credentials: false + - name: Select legacy upgrade qualification + id: policy + shell: pwsh + run: | + $mode = node ./release-control/scripts/windows-distribution.mjs mode "${{ needs.resolve.outputs.version }}" + if ($LASTEXITCODE -ne 0) { throw 'Invalid Windows distribution policy' } + "required=$($mode -eq 'installer-only')" >> $env:GITHUB_OUTPUT + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 + if: steps.policy.outputs.required == 'True' + with: + name: ${{ needs.resolve.outputs.artifact_prefix }}-windows-${{ matrix.arch }} + path: ${{ runner.temp }}/windows-bundle + - name: Upgrade published installed and portable clients with their own helper + if: steps.policy.outputs.required == 'True' + shell: pwsh + run: | + $installer = @(Get-ChildItem -LiteralPath "$env:RUNNER_TEMP/windows-bundle/files" -Filter '*-Setup.exe' -File) + if ($installer.Count -ne 1) { throw 'Expected one exact candidate installer' } + ./release-control/scripts/test-windows-legacy-update.ps1 -InstallerPath $installer[0].FullName -Architecture "${{ matrix.arch }}" -ExpectedVersion "${{ needs.resolve.outputs.version }}" -EvidenceDirectory "$env:RUNNER_TEMP/deepzora-legacy-update" + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 + if: always() && steps.policy.outputs.required == 'True' + with: + name: windows-legacy-update-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.arch }} + path: | + ${{ runner.temp }}/deepzora-legacy-update/**/*.json + ${{ runner.temp }}/deepzora-legacy-update/**/*.log + !${{ runner.temp }}/deepzora-legacy-update/*/installed/** + !${{ runner.temp }}/deepzora-legacy-update/**/cache/** + if-no-files-found: ignore + retention-days: 90 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 + if: steps.policy.outputs.required == 'True' + with: + name: ${{ needs.resolve.outputs.artifact_prefix }}-legacy-upgrade-${{ matrix.arch }} + path: ${{ runner.temp }}/deepzora-legacy-update/legacy-update.json + overwrite: true + if-no-files-found: error + retention-days: 90 windows-runtime-acceptance: name: verify Windows installer (${{ matrix.arch }}, ${{ needs.resolve.outputs.windows_signing }}) needs: - resolve - windows-sign - if: ${{ always() && !cancelled() && needs.resolve.result == 'success' && needs.windows-sign.result == 'success' }} + - windows-legacy-upgrade + if: ${{ always() && !cancelled() && needs.resolve.result == 'success' && needs.windows-sign.result == 'success' && needs.windows-legacy-upgrade.result == 'success' }} permissions: contents: read actions: read @@ -892,6 +954,11 @@ jobs: !${{ runner.temp }}/deepzora-portable-acceptance/**/cache/** if-no-files-found: ignore retention-days: 90 + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 + if: steps.distribution.outputs.mode == 'installer-only' + with: + name: ${{ needs.resolve.outputs.artifact_prefix }}-legacy-upgrade-${{ matrix.arch }} + path: ${{ runner.temp }}/legacy-upgrade-receipt - name: Record Windows acceptance receipt shell: pwsh run: | @@ -904,6 +971,9 @@ jobs: $archiveHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $portable[0].FullName).Hash.ToLowerInvariant() if ("${{ steps.distribution.outputs.mode }}" -eq 'installer-only') { $receipt.schema = 3 + $upgrade = Get-Content -LiteralPath "$env:RUNNER_TEMP/legacy-upgrade-receipt/legacy-update.json" -Raw | ConvertFrom-Json + if ($upgrade.targetSHA256 -ne $receipt.sha256 -or $upgrade.targetVersion -ne $receipt.version -or $upgrade.installed -ne 'passed' -or $upgrade.portable -ne 'passed') { throw 'Legacy upgrade did not qualify this installer' } + $receipt.legacyUpgrade = $upgrade $receipt.compatibilityStatus = 'passed' $receipt.compatibilitySha256 = $archiveHash } else { diff --git a/.github/workflows/release-promote.yml b/.github/workflows/release-promote.yml index 986d41dca..4abc2fcfa 100644 --- a/.github/workflows/release-promote.yml +++ b/.github/workflows/release-promote.yml @@ -381,6 +381,16 @@ jobs: R2_BUCKET: ${{ secrets.R2_BUCKET }} CLOUDFLARE_PAGES_DEPLOY_HOOK: ${{ secrets.CLOUDFLARE_PAGES_DEPLOY_HOOK }} + legacy-windows-client: + name: verify original client against public update channel + needs: [preflight, mirror] + if: ${{ needs.mirror.result == 'success' }} + permissions: + contents: read + uses: ./.github/workflows/verify-windows-auto-update.yml + with: + version: ${{ needs.preflight.outputs.version }} + metrics: name: record publication timing needs: [preflight, authorize, activate, cli, npm, desktop, postflight] diff --git a/.github/workflows/verify-windows-auto-update.yml b/.github/workflows/verify-windows-auto-update.yml new file mode 100644 index 000000000..89ae4fedb --- /dev/null +++ b/.github/workflows/verify-windows-auto-update.yml @@ -0,0 +1,144 @@ +name: Verify published Windows automatic updates + +on: + pull_request: + paths: + - 'scripts/test-windows-legacy-update.ps1' + - 'scripts/test-windows-startup-recovery.ps1' + - '.github/workflows/verify-windows-auto-update.yml' + workflow_call: + inputs: + version: + required: true + type: string + workflow_dispatch: + inputs: + version: + required: true + type: string + +permissions: + contents: read + +jobs: + handoff-smoke: + name: self-test published v0.0.7 handoff (${{ matrix.arch }}) + if: github.repository == 'SivanCola/deepzora' && github.event_name == 'pull_request' + strategy: + fail-fast: false + matrix: + include: + - runner: windows-latest + arch: amd64 + - runner: windows-11-arm + arch: arm64 + runs-on: ${{ matrix.runner }} + timeout-minutes: 20 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + ref: ${{ github.sha }} + persist-credentials: false + - name: Exercise the handoff harness using an immutable signed repair target + shell: pwsh + run: | + $cpu = if ('${{ matrix.arch }}' -eq 'amd64') { 'x64' } else { 'arm64' } + $expected = if ($cpu -eq 'x64') { 'b19176ec83b500975235e554ce4935207dbefb3c987ba58dcf735a4120c7ad25' } else { '6c253aee4082c157334511593350b0be84b33a5e111e8356fdfd651fd42b18b6' } + $installer = Join-Path $env:RUNNER_TEMP 'repair-target.exe' + Invoke-WebRequest "https://github.com/SivanCola/deepzora/releases/download/desktop-v0.0.7/Deepzora-0.0.7-Windows-$cpu-Setup.exe" -OutFile $installer -TimeoutSec 180 + if ((Get-FileHash -Algorithm SHA256 -LiteralPath $installer).Hash.ToLowerInvariant() -ne $expected) { throw 'Repair target differs from the sealed v0.0.7 installer' } + # No candidate is available on a PR. Repairing with the original signed + # version exercises the exact same native driver without publishing, + # credentials, model calls or claiming v0.0.8 upgrade qualification. + ./scripts/test-windows-legacy-update.ps1 -InstallerPath $installer -ExpectedVersion v0.0.7 -Architecture '${{ matrix.arch }}' -EvidenceDirectory "$env:RUNNER_TEMP/legacy-handoff-smoke" + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 + if: always() + with: + name: legacy-handoff-smoke-${{ matrix.arch }}-${{ github.run_attempt }} + path: | + ${{ runner.temp }}/legacy-handoff-smoke/**/*.json + ${{ runner.temp }}/legacy-handoff-smoke/**/*.log + !${{ runner.temp }}/legacy-handoff-smoke/*/installed/** + !${{ runner.temp }}/legacy-handoff-smoke/**/cache/** + if-no-files-found: ignore + retention-days: 7 + policy: + if: github.repository == 'SivanCola/deepzora' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_protected + runs-on: ubuntu-latest + outputs: + required: ${{ steps.policy.outputs.required }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + ref: ${{ github.workflow_sha }} + persist-credentials: false + - id: policy + env: + VERSION: ${{ inputs.version }} + run: | + node --input-type=module <<'JS' + import { appendFileSync } from 'node:fs'; + import { windowsInstallerOnly } from './scripts/windows-distribution.mjs'; + import { shouldAdvance } from './scripts/publish-github-update-pointer.mjs'; + const response = await fetch('https://downloads.deepzora.app/desktop/latest.json', {redirect:'error',signal:AbortSignal.timeout(30000)}); + if (!response.ok) throw new Error('Published App update pointer is unavailable'); + const latest = await response.json(); + const required = windowsInstallerOnly(process.env.VERSION) && shouldAdvance(process.env.VERSION, latest.version); + appendFileSync(process.env.GITHUB_OUTPUT, `required=${required}\n`); + if (!required) console.log('Historical recovery does not move the public update channel backwards.'); + JS + verify: + needs: policy + if: needs.policy.outputs.required == 'true' + strategy: + fail-fast: false + matrix: + include: + - runner: windows-latest + arch: amd64 + - runner: windows-11-arm + arch: arm64 + runs-on: ${{ matrix.runner }} + timeout-minutes: 25 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + ref: ${{ github.workflow_sha }} + path: release-control + persist-credentials: false + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + ref: b0208b176ba43c129d228b41b770579eb050bb1f + path: legacy-client + persist-credentials: false + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e + with: + go-version-file: legacy-client/desktop/go.mod + architecture: ${{ matrix.arch == 'amd64' && 'x64' || 'arm64' }} + cache: false + - name: Run the original client's public update path + shell: pwsh + env: + PUBLISHED_UPDATE_VERSION: ${{ inputs.version }} + PUBLISHED_UPDATE_EVIDENCE: ${{ runner.temp }}/published-update + run: | + if ((git -C legacy-client rev-parse HEAD) -ne 'b0208b176ba43c129d228b41b770579eb050bb1f') { throw 'Old client source drifted' } + Copy-Item release-control/scripts/legacy-windows-update.gotest legacy-client/desktop/published_update_acceptance_test.go + Push-Location legacy-client/desktop + go test . -run '^TestPublishedWindowsAutoUpdate$' -count=1 -v -timeout=15m + if ($LASTEXITCODE -ne 0) { throw 'The real old client public update path failed' } + Pop-Location + $file = Join-Path $env:PUBLISHED_UPDATE_EVIDENCE 'verified-installer.exe' + $signature = Get-AuthenticodeSignature -LiteralPath $file + if ($signature.Status -ne 'Valid' -or -not $signature.TimeStamperCertificate) { throw 'Old client did not download a trusted timestamped installer' } + $report = Get-Content (Join-Path $env:PUBLISHED_UPDATE_EVIDENCE 'published-update.json') -Raw | ConvertFrom-Json + if ($report.architecture -ne '${{ matrix.arch }}') { throw 'Native updater acceptance architecture mismatch' } + $report | Add-Member -NotePropertyName authenticode -NotePropertyValue 'passed' + $report | ConvertTo-Json | Set-Content (Join-Path $env:PUBLISHED_UPDATE_EVIDENCE 'published-update.json') -Encoding utf8 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 + if: always() + with: + name: published-windows-update-${{ inputs.version }}-${{ matrix.arch }}-${{ github.run_attempt }} + path: ${{ runner.temp }}/published-update/*.json + if-no-files-found: error + retention-days: 90 diff --git a/cmd/release-signing-contract/certum_ui_test.go b/cmd/release-signing-contract/certum_ui_test.go index 4619ec42d..a4098738d 100644 --- a/cmd/release-signing-contract/certum_ui_test.go +++ b/cmd/release-signing-contract/certum_ui_test.go @@ -21,9 +21,17 @@ func TestPowerShellCertumWindowReadiness(t *testing.T) { } found = true t.Run(name, func(t *testing.T) { - command := exec.Command(binary, "-NoLogo", "-NoProfile", "-NonInteractive", "-File", script) - if output, err := command.CombinedOutput(); err != nil { - t.Fatalf("Certum UI regression: %v\n%s", err, output) + scripts := []string{script} + if runtime.GOOS == "windows" { + for _, name := range []string{"test-windows-installer-startup.test.ps1", "test-windows-upgrade-startup.test.ps1"} { + scripts = append(scripts, filepath.Join(filepath.Dir(script), name)) + } + } + for _, file := range scripts { + command := exec.Command(binary, "-NoLogo", "-NoProfile", "-NonInteractive", "-File", file) + if output, err := command.CombinedOutput(); err != nil { + t.Fatalf("Windows signing/acceptance regression %s: %v\n%s", file, err, output) + } } }) } diff --git a/desktop/bot_team_test.go b/desktop/bot_team_test.go index 183053979..43702a220 100644 --- a/desktop/bot_team_test.go +++ b/desktop/bot_team_test.go @@ -31,6 +31,12 @@ func TestBotMemberRoutingUsesSharedMemberWithoutBroadcast(t *testing.T) { if err != nil || member.Outcome != "applied" { t.Fatalf("member creation %s %v", member.Outcome, err) } + // This test measures channel routing, not cold member-runtime creation. + // Prepare the shared seat before starting the adapters' bounded ready wait; + // otherwise slow Windows storage turns setup into an opaque bot timeout. + if _, err := a.prepareBotMember(t.Context(), member.TargetID); err != nil { + t.Fatalf("prepare shared member runtime: %v", err) + } inputs := []BotConnectionInput{} for _, id := range []string{"wechat", "feishu"} { input := BotConnectionInput{Config: botchannels.Config{ID: id, Name: id, Provider: "weixin", Mode: "member", MemberID: member.TargetID, ChatID: "peer", SenderID: "peer"}, Secret: id + "-secret", Connect: true} diff --git a/desktop/current_catalog_rebuild_test.go b/desktop/current_catalog_rebuild_test.go index c4fd7594e..6f080957a 100644 --- a/desktop/current_catalog_rebuild_test.go +++ b/desktop/current_catalog_rebuild_test.go @@ -136,9 +136,9 @@ func TestCurrentCatalogRepairFailureCanRetryWithoutChangingSource(t *testing.T) if err := os.Remove(dir); err != nil { t.Fatal(err) } - if err := os.Rename(dir+".saved", dir); err != nil { - t.Fatal(err) - } + // Let repair recreate this disposable cache. Readers may already recreate + // the directory after the blocker is removed; renaming the saved directory + // back would race those legitimate reads. The source must remain untouched. if err := app.RebuildSessionCatalog(); err != nil { t.Fatal(err) } diff --git a/docs/RELEASE_CANDIDATES.md b/docs/RELEASE_CANDIDATES.md index 225622d10..481d2c455 100644 --- a/docs/RELEASE_CANDIDATES.md +++ b/docs/RELEASE_CANDIDATES.md @@ -26,6 +26,15 @@ Starting with v0.0.8, Windows ships installers only. Each final x64 and ARM64 installer undergoes native startup, second-launch, normal-exit, uninstall and user-data retention acceptance. Schema 3 receipts bind its SHA-256 and the hash of an exact text-only migration ZIP, independently checked again when sealing. +They also require native upgrades from the exact published v0.0.7 installer and +portable packages, using that release's signed update helper. Both old clients +must exit normally, the helper must activate and restart the new candidate, +and the target must pass startup, repeat launch, normal exit and retained-data +checks. After publication and R2 promotion, the immutable v0.0.7 source runs its +original manifest, installer routing, download, Minisign verification and cache +code against the real public channel on x64 and ARM64. This last check is part +of the publication workflow; recovery of a superseded version does not downgrade +the public pointer to rerun an older target. v0.0.7 and older updaters validate all eleven downloads, including the two `*-Portable.zip` names, before updating any platform. Their Windows update route diff --git a/docs/RELEASE_CANDIDATES.zh-CN.md b/docs/RELEASE_CANDIDATES.zh-CN.md index 06bbac740..1ed30bd22 100644 --- a/docs/RELEASE_CANDIDATES.zh-CN.md +++ b/docs/RELEASE_CANDIDATES.zh-CN.md @@ -22,6 +22,12 @@ Desktop 文件、执行最终安装包的原生验收并封存记录。`Publish 从 v0.0.8 起,Windows 只提供安装包。最终 x64、ARM64 安装包在原生 runner 上验收 启动、重复启动、正常退出、卸载及用户数据保留。schema 3 回执绑定安装包与纯文本 迁移 ZIP 的 SHA-256;封存时再次独立检查迁移 ZIP 的精确内容。 +回执还要求从已发布的 v0.0.7 安装包和便携包分别执行原生升级:运行真实旧客户端, +使用它自带的已签名更新助手,正常退出、激活并重启当前候选,验证新版本启动、 +重复启动、正常退出和数据保留。公开发布及 R2 推进后,固定检出的 v0.0.7 源码 +还会在原生 x64、ARM64 上,用原有清单校验、安装包选择、下载、Minisign 校验和 +缓存代码访问真实公开更新通道。该验收属于发布工作流;恢复已被新版替代的历史 +版本时不会倒退公开更新指针来测试旧目标。 v0.0.7 及更早更新器会在任意平台更新前严格校验全部 11 个下载条目,包括两个 `*-Portable.zip` 名称;Windows 更新路线实际已经指向 `*-Setup.exe`,现有便携 diff --git a/docs/desktop-contract/INVENTORY.md b/docs/desktop-contract/INVENTORY.md index 5d683fb68..0ead9732c 100644 --- a/docs/desktop-contract/INVENTORY.md +++ b/docs/desktop-contract/INVENTORY.md @@ -15,8 +15,8 @@ Every entry carries one class: `keep-business` is implemented in Go and exposed | persistence | 16 | 0 | 0 | 16 | | shell-file | 1 | 24 | 0 | 25 | | artifact | 11 | 0 | 0 | 11 | -| ci-job | 20 | 0 | 0 | 20 | -| **all** | | | | **658** | +| ci-job | 21 | 0 | 0 | 21 | +| **all** | | | | **659** | ## Desktop commands (Go `App` methods bound to the UI) @@ -723,5 +723,6 @@ Every entry carries one class: `keep-business` is implemented in Go and exposed | `release-desktop.yml/resolve` | | .github/workflows/release-desktop.yml | keep-business (保留业务实现) | version/channel resolution unchanged | | `release-desktop.yml/signing-contract` | | .github/workflows/release-desktop.yml | keep-business (保留业务实现) | payload list covers the Electron executables and native modules | | `release-desktop.yml/windows-build` | | .github/workflows/release-desktop.yml | keep-business (保留业务实现) | builds and smoke-tests unsigned x64 and ARM64 packages on native Windows runners before signing | +| `release-desktop.yml/windows-legacy-upgrade` | | .github/workflows/release-desktop.yml | keep-business (保留业务实现) | qualifies published v0.0.7 installed and portable clients upgrading through their original signed helper | | `release-desktop.yml/windows-runtime-acceptance` | | .github/workflows/release-desktop.yml | keep-business (保留业务实现) | installs and starts the exact signed x64 and ARM64 installers on native runners | | `release-desktop.yml/windows-sign` | | .github/workflows/release-desktop.yml | keep-business (保留业务实现) | Certum signs native-tested x64 and ARM64 payloads and rebuilt installers on x64 | diff --git a/docs/desktop-contract/inventory.json b/docs/desktop-contract/inventory.json index 09976c23d..b64619f85 100644 --- a/docs/desktop-contract/inventory.json +++ b/docs/desktop-contract/inventory.json @@ -5134,6 +5134,13 @@ "class": "keep-business", "owner": "builds and smoke-tests unsigned x64 and ARM64 packages on native Windows runners before signing" }, + { + "kind": "ci-job", + "name": "release-desktop.yml/windows-legacy-upgrade", + "location": ".github/workflows/release-desktop.yml", + "class": "keep-business", + "owner": "qualifies published v0.0.7 installed and portable clients upgrading through their original signed helper" + }, { "kind": "ci-job", "name": "release-desktop.yml/windows-runtime-acceptance", diff --git a/internal/persistentshell/pty_unix.go b/internal/persistentshell/pty_unix.go index c7dcdf344..96e74112e 100644 --- a/internal/persistentshell/pty_unix.go +++ b/internal/persistentshell/pty_unix.go @@ -3,12 +3,14 @@ package persistentshell import ( + "fmt" "os" "os/exec" "sync" "syscall" "github.com/creack/pty" + "golang.org/x/sys/unix" "deepzora/internal/proc" ) @@ -30,6 +32,25 @@ func startPTY(argv []string, dir string, env []string) (ptyConn, error) { if err != nil { return nil, err } + // PTY setup obtains Fd(), which can leave the master in blocking mode. + // Register a fresh nonblocking descriptor with Go's poller so Close can + // interrupt Read even when another process still holds the slave open. + fd, err := unix.FcntlInt(file.Fd(), unix.F_DUPFD_CLOEXEC, 0) + if err == nil { + err = unix.SetNonblock(fd, true) + if err != nil { + _ = unix.Close(fd) + } + } + if err != nil { + _ = syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL) + _ = file.Close() + _ = cmd.Wait() + return nil, fmt.Errorf("persistent shell PTY polling: %w", err) + } + pollable := os.NewFile(uintptr(fd), file.Name()) + _ = file.Close() + file = pollable // Reap the shell without blocking: its exit surfaces to callers as a read // error on the master side, so the wait status itself carries no decision. go func() { _ = cmd.Wait() }() diff --git a/internal/persistentshell/pty_unix_test.go b/internal/persistentshell/pty_unix_test.go new file mode 100644 index 000000000..e1ba4baa7 --- /dev/null +++ b/internal/persistentshell/pty_unix_test.go @@ -0,0 +1,54 @@ +//go:build !windows + +package persistentshell + +import ( + "errors" + "os" + "testing" + "time" +) + +func TestUnixPTYReadDeadlineAndClose(t *testing.T) { + conn, err := startPTY([]string{"/bin/sh", "-c", "sleep 60"}, t.TempDir(), os.Environ()) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = conn.Close() }) + file := conn.(*unixPTY).file + if err := file.SetReadDeadline(time.Now().Add(50 * time.Millisecond)); err != nil { + t.Fatalf("PTY reads must support cancellation: %v", err) + } + read := func() <-chan error { + done := make(chan error, 1) + go func() { + var buf [1]byte + _, err := conn.Read(buf[:]) + done <- err + }() + return done + } + await := func(done <-chan error) error { + t.Helper() + select { + case err := <-done: + return err + case <-time.After(2 * time.Second): + t.Fatal("PTY reader remained blocked") + return nil + } + } + if err := await(read()); !errors.Is(err, os.ErrDeadlineExceeded) { + t.Fatalf("idle read did not honor its deadline: %v", err) + } + if err := file.SetReadDeadline(time.Time{}); err != nil { + t.Fatal(err) + } + done := read() + if err := conn.Close(); err != nil { + t.Fatal(err) + } + if err := await(done); err == nil { + t.Fatal("closed PTY read reported success") + } +} diff --git a/release-notes/releases.json b/release-notes/releases.json index b06886857..deabb2eae 100644 --- a/release-notes/releases.json +++ b/release-notes/releases.json @@ -1,6 +1,191 @@ { "schemaVersion": 1, "releases": [ + { + "version": "0.0.8", + "releaseId": "0.0.8", + "baseVersion": "0.0.8", + "previousRelease": "0.0.7", + "date": "2026-11-13", + "channel": "stable", + "status": "reviewed", + "targetingVersion": 1, + "builds": { + "cli": "v0.0.8", + "desktop": "v0.0.8", + "npm": "0.0.8" + }, + "title": { + "en": "Local Web workspace, community plugins and installer-only Windows releases", + "zh": "本机 Web 工作台、社区插件与 Windows 安装包发行" + }, + "summary": { + "en": "Deepzora 0.0.8 restores the real local Web workspace with an embedded UI in the CLI, adds community plugin discovery with commit-pinned install previews, and distributes Windows applications through signed x64 and ARM64 installers. Legacy updater metadata is preserved, with native upgrade qualification from the published 0.0.7 installed and portable clients.", + "zh": "Deepzora 0.0.8 恢复连接真实后端的本机 Web 工作台,CLI 内置完整页面;新增社区插件发现和锁定提交的安装预览。Windows 改为仅提供已签名的 x64、ARM64 安装包,保留旧更新清单兼容,并从已发布的 0.0.7 安装版、便携版进行原生升级验收。" + }, + "surfaces": [ + "desktop", + "cli" + ], + "guides": [], + "highlights": [ + { + "kind": "new", + "targets": [ + "cli" + ], + "title": { + "en": "Run the workspace in a local browser", + "zh": "在本机浏览器中运行完整工作台" + }, + "body": { + "en": "Run deepzora web from a project directory. The official CLI embeds the UI, starts a local service on a free loopback port and prints an authenticated access URL. Conversations, streaming, approvals, history and diffs use the same Go application service as Desktop. --dir, --port and --no-open control startup; Node and Electron are not required to run the official CLI package.", + "zh": "在项目目录运行 deepzora web 即可启动本机工作台。官方 CLI 内置页面,在回环地址的空闲端口启动服务并提供带认证的访问链接。对话、流式输出、工具审批、历史记录和差异查看复用桌面端同一套 Go 应用服务;支持 --dir、--port、--no-open,运行官方 CLI 包无需另装 Node 或 Electron。" + }, + "refs": [ + 181 + ] + }, + { + "kind": "new", + "targets": [ + "desktop", + "cli" + ], + "title": { + "en": "Discover plugins and confirm the exact commit to install", + "zh": "发现插件并确认将安装的准确提交" + }, + "body": { + "en": "Settings → Plugins → Discover and deepzora plugin search show community catalog entries, with an optional channel for unreviewed GitHub plugins. Install and update previews bind the package, source, permissions and exact Git commit to a plan ID. Moved tags, withdrawn releases and conflicting local sources cannot silently replace that reviewed plan.", + "zh": "通过“设置 → 插件 → 发现”或 deepzora plugin search 查找社区目录中的插件,也可选择查看未经审核的 GitHub 插件。安装和更新预览以计划 ID 绑定包、来源、权限及准确 Git 提交;标签移动、版本撤回或本地同名来源冲突不会静默替换已确认的计划。" + }, + "refs": [ + 182 + ] + } + ], + "changes": { + "new": [], + "improved": [ + { + "targets": ["desktop"], + "title": { "en": "Filter Magpie models by upstream provider", "zh": "按上游供应商筛选 Magpie 模型" }, + "body": { + "en": "The model picker groups Magpie routes under upstream providers such as Ollama Cloud. Identical routes exposed through two Magpie connections remain separate options, retain their connection and send the original routing reference. Existing connection filters and favorites remain available.", + "zh": "模型选择器按 Ollama Cloud 等上游供应商组织 Magpie 路由。两条 Magpie 连接提供相同路由时,仍保留独立选项、原连接及原始路由引用;现有连接筛选与收藏保持可用。" + }, + "refs": [183] + }, + { + "targets": [ + "desktop" + ], + "title": { + "en": "Windows installers replace the portable application download", + "zh": "Windows 统一使用安装包" + }, + "body": { + "en": "Windows x64 and ARM64 applications ship as timestamped Certum Authenticode-signed installers. The website and new release download navigation show installers only. The two legacy Portable.zip names remain as small Minisign-signed archives containing only a migration notice and installer link, so strict older updaters can validate the unchanged eleven-entry matrix. They contain no application.", + "zh": "Windows x64、ARM64 应用统一通过带时间戳的 Certum Authenticode 签名安装包发行,官网和新版下载导航只展示安装包。两个旧 Portable.zip 名称保留为很小的 Minisign 签名归档,仅含迁移说明与安装包链接,不含程序;旧更新器仍能校验原有 11 项清单。" + }, + "refs": [ + 180 + ] + }, + { + "targets": [ + "desktop" + ], + "title": { + "en": "Qualify upgrades with the published old client and update helper", + "zh": "使用真实旧客户端和更新助手验收升级" + }, + "body": { + "en": "Before sealing, the published 0.0.7 installed and portable applications run on native x64 and ARM64 Windows, then their own signed update helper stages, verifies, activates and restarts the exact new installer. Acceptance checks repeated launch, normal exit and retained data. After publication and mirror promotion, the original 0.0.7 updater code checks the live manifest, downloads and verifies the installer and writes its update cache.", + "zh": "封存前,在原生 Windows x64、ARM64 上运行已发布的 0.0.7 安装版和便携版,由它们自带的已签名更新助手验证、暂存、激活并重启本次准确安装包,再验证重复启动、正常退出与数据保留。发布和镜像推进后,还使用原始 0.0.7 更新器代码验证公开清单、安装包下载、签名校验和更新缓存。" + } + }, + { + "targets": [ + "desktop" + ], + "title": { + "en": "Unattended signing waits for the real login form", + "zh": "无人值守签名等待真实登录表单" + }, + "body": { + "en": "SimplySign automation identifies the native credential controls before sending account information, and restricts popup handling to acknowledgement dialogs. A transient splash window can no longer be selected as the login form. Signer, trust, timestamp and session cleanup checks remain required.", + "zh": "SimplySign 自动化在发送账户信息前识别原生输入控件,并只对确认弹窗执行恢复操作,避免把短暂出现的启动画面误当成登录表单;发布者、证书信任、时间戳及会话清理检查保持必需。" + }, + "refs": [ + 179 + ] + } + ], + "fixed": [ + { + "targets": ["desktop", "cli"], + "title": { "en": "Interrupt idle Unix terminal readers during session cleanup", "zh": "会话清理时中断 Unix 终端的空闲读取" }, + "body": { + "en": "Linux and macOS persistent shells register their PTY master for cancellable I/O, so closing a session can interrupt an idle reader even if another process keeps a terminal writer open. Command output, Unicode transport and persistent working-directory state remain covered by regression checks.", + "zh": "Linux、macOS 持久化终端将 PTY 主端注册为可取消的 I/O,即使其他进程仍持有终端写入端,关闭会话也能中断空闲读取。命令输出、Unicode 传输及工作目录保持均继续通过回归检查。" + } + } + ] + }, + "upgrade": [ + { + "level": "info", + "targets": [ + "desktop" + ], + "title": { + "en": "Existing Windows installations keep their automatic update route", + "zh": "现有 Windows 安装保持自动更新路径" + }, + "body": { + "en": "Use the application's normal update action. Existing installed and portable layouts both select Setup.exe; do not install the small compatibility ZIP as an application. Historical 0.0.7 and earlier release files and immutable mirror indexes remain unchanged.", + "zh": "使用应用内正常更新入口即可。现有安装版与便携布局均选择 Setup.exe 更新;不要把纯文本兼容 ZIP 当成应用安装。0.0.7 及更早的历史发布文件和不可变镜像索引保持不变。" + } + }, + { + "level": "info", + "targets": [ + "cli" + ], + "title": { + "en": "Open the complete URL printed by deepzora web", + "zh": "使用 deepzora web 输出的完整访问链接" + }, + "body": { + "en": "The Web workspace is local-only. A fresh controlling tab replaces the previous connection; closing or refreshing a tab does not cancel accepted work. Native windows, tray, the built-in Electron browser, bots and heartbeat jobs are not started by Web. Update the CLI with deepzora upgrade.", + "zh": "Web 工作台仅支持本机访问。新的控制标签页会替换原连接,关闭或刷新标签页不会取消已接受的任务。Web 不启动原生窗口、托盘、Electron 内置浏览器、机器人或心跳任务;通过 deepzora upgrade 更新 CLI。" + } + } + ], + "risks": [ + { + "targets": [ + "desktop" + ], + "title": { + "en": "Keep shutdown diagnostics if a Windows exit stalls", + "zh": "Windows 退出卡住时请保留诊断日志" + }, + "body": { + "en": "Earlier Windows reports included shutdown stopping in cancelling_background. Native upgrade acceptance covers clean hosted systems and does not establish a fix for every production environment. If it recurs, preserve the named shutdown step and service.log/service.log.1 when reporting it.", + "zh": "此前的 Windows 报告包含退出停在 cancelling_background 的情况。原生升级验收覆盖干净的托管系统,并不代表已经修复所有生产环境中的退出问题;如再次出现,请保留报错中的退出步骤名及 service.log、service.log.1 以供定位。" + } + } + ], + "contributors": [], + "links": { + "github": "https://github.com/SivanCola/deepzora/releases/tag/v0.0.8", + "compare": "https://github.com/SivanCola/deepzora/compare/v0.0.7...v0.0.8", + "download": "https://deepzora.app/#download" + } + }, { "version": "0.0.7", "releaseId": "0.0.7", diff --git a/scripts/ci-paths.mjs b/scripts/ci-paths.mjs index bed73897c..44f958e1c 100644 --- a/scripts/ci-paths.mjs +++ b/scripts/ci-paths.mjs @@ -18,7 +18,7 @@ const WEB_SURFACE = /^(?:scripts\/(?:build-web-ui\.mjs|test-web-workspace\.py)|d const FRONTEND = /^desktop\/frontend\//; const DESKTOP_MANIFEST = /^(?:desktop\/(?:package\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml|\.npmrc)|desktop\/frontend\/(?:package\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml|\.npmrc|\.node-version|vite\.config\.[cm]?[jt]s|tsconfig[^/]*\.json))$/; const ELECTRON = /^(?:desktop\/electron\/|desktop\/(?:package\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml)$)/; -const PACKAGING = /^(?:desktop\/(?:packaging\/|build\/|internal\/upgradefixture\/|cmd\/windows-upgrade-fixture\/)|scripts\/(?:desktop-build|package-windows-desktop|install-nsis|check-windows-uninstaller|finalize-windows-signed-candidate|test-windows-(?:installer-startup|startup-recovery|upgrade-startup)|windows-(?:upgrade-ui-evidence|acceptance-environment))\b)/; +const PACKAGING = /^(?:desktop\/(?:packaging\/|build\/|internal\/upgradefixture\/|cmd\/windows-upgrade-fixture\/)|scripts\/(?:desktop-build|package-windows-desktop|install-nsis|check-windows-uninstaller|finalize-windows-signed-candidate|test-windows-(?:installer-startup|startup-recovery|upgrade-startup|legacy-update)|windows-(?:upgrade-ui-evidence|acceptance-environment))\b)/; const RELEASE_CONTROL = /^(?:\.github\/workflows\/release[^/]*\.yml|scripts\/(?:release|resolve-release-candidate|validate-release-candidate|build-release-cli-candidate|publish-homebrew-cask|desktop-release-artifacts|finalize-windows-signed-candidate|verify-release-artifact-archive|verify-release-tag-identity|verify-stable-release-artifacts)[^/]*|npm\/publish(?:-candidate)?(?:\.test)?\.mjs)$/; const DESKTOP_GO = /^(?:desktop\/(?:[^/]+\.go|go\.(?:mod|sum)|cmd\/|internal\/)|internal\/|cmd\/|go\.(?:mod|sum)$)/; const SDK = /^internal\/extension\//; diff --git a/scripts/legacy-windows-update.gotest b/scripts/legacy-windows-update.gotest new file mode 100644 index 000000000..f1c0ebc3f --- /dev/null +++ b/scripts/legacy-windows-update.gotest @@ -0,0 +1,102 @@ +package main + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "os" + "path/filepath" + "runtime" + "strings" + "testing" + "time" + + "deepzora/desktop/internal/update" +) + +// Copied into the immutable v0.0.7 source checkout, not the current application. +// Exercise its real network, matrix validator, platform routing, embedded public +// key and update cache against the public release. No replacement transport, +// verifier, manifest, or application code is injected. +func TestPublishedWindowsAutoUpdate(t *testing.T) { + if runtime.GOOS != "windows" || os.Getenv("GITHUB_ACTIONS") != "true" { + t.Fatal("published updater acceptance requires a disposable hosted Windows runner") + } + target := "v" + os.Getenv("PUBLISHED_UPDATE_VERSION") + if !stableDesktopVersionRE.MatchString(target) { + t.Fatal("invalid target version") + } + t.Setenv("DEEPZORA_HOME", t.TempDir()) + previousVersion, previousChannel := version, channel + version, channel = "v0.0.7", "stable" + t.Cleanup(func() { version, channel = previousVersion, previousChannel }) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) + defer cancel() + client, err := httpClient() + if err != nil { + t.Fatal(err) + } + ipv4, err := httpClientIPv4() + if err != nil { + t.Fatal(err) + } + manifest, err := fetchManifest(ctx, client, ipv4, "stable") + if err != nil { + t.Fatal(err) + } + profile := installProfile{Mode: installModePortable, CanSelfUpdate: true, ArtifactKind: artifactKindTarball} + info := evaluateWithProfileForChannel("v0.0.7", "stable", manifest, profile) + if manifest.Version != target || !info.Available || info.Err != "" || !info.CanSelfUpdate { + t.Fatalf("old client did not offer %s: %+v", target, info) + } + asset, kind, ok := selectUpdateAsset(manifest, profile) + if !ok || !strings.HasSuffix(asset.URL, "-Setup.exe") { + t.Fatalf("old client did not choose an installer: %+v", asset) + } + data, signature, err := downloadVerifiedAsset(ctx, client, ipv4, "stable", manifest.Version, asset, nil, nil, update.Verify) + if err != nil { + t.Fatal(err) + } + if len(signature) == 0 { + t.Fatal("empty public integrity signature") + } + cached, err := saveCachedUpdateForChannel("stable", manifest.Version, asset, data, kind, signature) + if err != nil { + t.Fatal(err) + } + bytes, err := os.ReadFile(cached.Path) + if err != nil { + t.Fatal(err) + } + digest := sha256.Sum256(bytes) + if hex.EncodeToString(digest[:]) != asset.SHA256 { + t.Fatal("old updater cache changed installer bytes") + } + output := os.Getenv("PUBLISHED_UPDATE_EVIDENCE") + if output == "" { + t.Fatal("missing evidence directory") + } + if err := os.MkdirAll(output, 0700); err != nil { + t.Fatal(err) + } + // Keep the verified installer outside t.TempDir for a native Authenticode + // check in the following step. It is never uploaded as evidence. + installerPath := filepath.Join(output, "verified-installer.exe") + if err := os.WriteFile(installerPath, bytes, 0600); err != nil { + t.Fatal(err) + } + report := map[string]any{ + "schema": 1, "clientVersion": "v0.0.7", "clientSourceSHA": "b0208b176ba43c129d228b41b770579eb050bb1f", + "targetVersion": target, "architecture": runtime.GOARCH, "installerSHA256": asset.SHA256, + "manifestValidation": "passed", "updateAvailable": "passed", "installerRoute": "passed", + "downloadAndMinisign": "passed", "cache": "passed", "url": asset.URL, + } + raw, err := json.MarshalIndent(report, "", " ") + if err != nil { + t.Fatal(err) + } + if err := os.WriteFile(filepath.Join(output, "published-update.json"), raw, 0600); err != nil { + t.Fatal(err) + } +} diff --git a/scripts/release-candidate.mjs b/scripts/release-candidate.mjs index d8cdf8fdb..b6d19bfe7 100644 --- a/scripts/release-candidate.mjs +++ b/scripts/release-candidate.mjs @@ -158,11 +158,17 @@ function requireAcceptanceReceipt(payloadRoot, files, metadata, item) { || receipt.compatibilityStatus !== "passed" || !/^[0-9a-f]{64}$/.test(receipt.compatibilitySha256 ?? "")) { throw new Error(`installer-only Windows acceptance requires a verified compatibility notice: ${item.kind}`); } + const upgrade = receipt.legacyUpgrade; + if (upgrade?.sourceVersion !== "v0.0.7" || upgrade.targetVersion !== receipt.version + || upgrade.targetSHA256 !== receipt.sha256 || upgrade.installed !== "passed" || upgrade.portable !== "passed" + || upgrade.architecture !== platform.slice("windows-".length)) { + throw new Error(`legacy Windows automatic handoff did not qualify this installer: ${item.kind}`); + } const compatibility = identity.files.find(file => file.sha256 === receipt.compatibilitySha256 && file.name.endsWith("-Portable.zip")); if (!compatibility) throw new Error(`candidate compatibility acceptance does not name a sealed archive: ${item.kind}`); verifyWindowsCompatibilityArchive(readFileSync(path.join(payloadRoot, "desktop", platform, "files", compatibility.name)), metadata.version, platform.slice("windows-".length)); - return { ...item, evidenceSha256: evidence.sha256, artifactSha256: receipt.sha256, compatibilityArtifactSha256: receipt.compatibilitySha256 }; + return { ...item, evidenceSha256: evidence.sha256, artifactSha256: receipt.sha256, compatibilityArtifactSha256: receipt.compatibilitySha256, legacyUpgradeFrom: upgrade.sourceVersion }; } if (receipt.schema === 3) throw new Error("installer-only acceptance is invalid for this release"); if (windows && windowsSigningMode(metadata.version, "stable") === "certum" && receipt.schema !== 2) { @@ -293,6 +299,9 @@ export function verifyCandidate(payloadRoot, record, now = new Date(), purpose = if (validated.artifactSha256 !== item.artifactSha256) { throw new Error(`candidate acceptance artifact mismatch: ${item.kind}`); } + if (validated.legacyUpgradeFrom !== item.legacyUpgradeFrom) { + throw new Error(`candidate legacy upgrade source mismatch: ${item.kind}`); + } if (validated.compatibilityArtifactSha256 !== item.compatibilityArtifactSha256) { throw new Error(`candidate compatibility acceptance artifact mismatch: ${item.kind}`); } diff --git a/scripts/release-candidate.test.mjs b/scripts/release-candidate.test.mjs index 4e353675e..1e6076b93 100644 --- a/scripts/release-candidate.test.mjs +++ b/scripts/release-candidate.test.mjs @@ -67,7 +67,8 @@ function fixture(t, version = "1.2.3") { version: `v${version}`, sha256: createHash("sha256").update(windows ? `${platform}:installer` : platform).digest("hex"), ...(signed ? (windowsInstallerOnly(version) - ? { compatibilityStatus: 'passed', compatibilitySha256: createHash('sha256').update(compatibility(version, platform)).digest('hex') } + ? { compatibilityStatus: 'passed', compatibilitySha256: createHash('sha256').update(compatibility(version, platform)).digest('hex'), + legacyUpgrade: { sourceVersion: 'v0.0.7', targetVersion: `v${version}`, targetSHA256: createHash('sha256').update(`${platform}:installer`).digest('hex'), architecture: platform.slice('windows-'.length), installed: 'passed', portable: 'passed' } } : { portableStatus: 'passed', portableSha256: createHash('sha256').update(`${platform}:portable`).digest('hex') }) : {}), })); } @@ -201,11 +202,29 @@ for (const mutation of ['missing', 'failed', 'foreign', 'installer-as-archive', }); } +for (const mutation of ['missing', 'wrong-target', 'installed-failed', 'portable-failed']) { + test(`installer-only receipt rejects ${mutation} old updater qualification`, t => { + const root = fixture(t); + const file = path.join(root, 'evidence/windows-amd64.json'); + const value = JSON.parse(readFileSync(file, 'utf8')); + if (mutation === 'missing') delete value.legacyUpgrade; + if (mutation === 'wrong-target') value.legacyUpgrade.targetSHA256 = 'f'.repeat(64); + if (mutation === 'installed-failed') value.legacyUpgrade.installed = 'failed'; + if (mutation === 'portable-failed') value.legacyUpgrade.portable = 'failed'; + writeFileSync(file, JSON.stringify(value)); + assert.throws(() => sealCandidate(root, metadata), /automatic handoff/); + }); +} + test('sealed Windows acceptance binds installer and exact text-only compatibility hashes', t => { const root = fixture(t); const record = sealCandidate(root, metadata); const item = record.acceptance.find(item => item.kind === 'windows-amd64'); assert.equal(item.artifactSha256, createHash('sha256').update('windows-amd64:installer').digest('hex')); + assert.equal(item.legacyUpgradeFrom, 'v0.0.7'); + item.legacyUpgradeFrom = 'v0.0.6'; + assert.throws(() => verifyCandidate(root, record, new Date('2026-01-02T00:00:00Z')), /legacy upgrade source mismatch/); + item.legacyUpgradeFrom = 'v0.0.7'; assert.equal(item.compatibilityArtifactSha256, createHash('sha256').update(compatibility(metadata.version, 'windows-amd64')).digest('hex')); item.compatibilityArtifactSha256 = 'f'.repeat(64); assert.throws(() => verifyCandidate(root, record, new Date('2026-01-02T00:00:00Z')), /compatibility acceptance artifact mismatch/); diff --git a/scripts/release-workflows.test.sh b/scripts/release-workflows.test.sh index 2925475b4..e924cbed8 100755 --- a/scripts/release-workflows.test.sh +++ b/scripts/release-workflows.test.sh @@ -39,7 +39,10 @@ fi for arch in x64 arm64; do grep -Fq "\"suffix\": \"Windows-$arch-Setup.exe\"" internal/releaseassets/desktop.json done -[ "$(grep -Fc -e "-Filter '*-Setup.exe' -File" .github/workflows/release-desktop.yml)" = 2 ] +[ "$(grep -Fc -e "-Filter '*-Setup.exe' -File" .github/workflows/release-desktop.yml)" = 3 ] +grep -Fq 'test-windows-legacy-update.ps1 -InstallerPath $installer[0].FullName' .github/workflows/release-desktop.yml +grep -Fq '$receipt.legacyUpgrade = $upgrade' .github/workflows/release-desktop.yml +grep -Fq 'needs: [preflight, mirror]' .github/workflows/release-promote.yml # Historical releases require portable startup; installer-only releases verify # the exact compatibility notice. Both bind the final archive in their receipt. [ "$(grep -Fc -e "-Filter '*-Portable.zip' -File" .github/workflows/release-desktop.yml)" = 2 ] diff --git a/scripts/test-web-workspace.py b/scripts/test-web-workspace.py index afd7ed80e..bf8745487 100644 --- a/scripts/test-web-workspace.py +++ b/scripts/test-web-workspace.py @@ -40,6 +40,7 @@ def main(): home = root / "home" home.mkdir() requests = [] + stream_release = threading.Event() class Provider(BaseHTTPRequestHandler): def log_message(self, *_args): @@ -78,7 +79,10 @@ def emit(delta, finish=None): emit({"content": "WEB_WRITE_DONE"}, "stop") else: emit({"content": "WEB_STREAM_"}) - time.sleep(1.5) + # Keep the real turn active until the browser has observed the + # first chunk and reloaded; runner speed must not decide this. + if not stream_release.wait(timeout=90): + raise TimeoutError("Browser did not release the active stream") emit({"content": "DONE"}, "stop") self.wfile.write(b"data: [DONE]\n\n") self.wfile.flush() @@ -157,16 +161,21 @@ def watch_socket(socket): print("PASS packaged UI, real service, authentication, token removal", flush=True) composer.fill("WEB_STREAM test the shared engine") + # The input is editable during cold workspace initialization, but + # submission intentionally waits for the runtime/controller gate. + expect(page.locator(".composer__btn--send")).to_be_enabled(timeout=60000) composer.press("Enter") page.get_by_text("WEB_STREAM_", exact=True).wait_for(timeout=60000) # Reload during the provider stream: browser lifetime cannot own execution. page.reload() page.wait_for_load_state("networkidle") + stream_release.set() page.get_by_text("WEB_STREAM_DONE", exact=True).wait_for(timeout=60000) page.wait_for_timeout(1500) print("PASS streaming and reload recovery during an active turn", flush=True) composer = page.locator('#composer-input') composer.fill("WEB_WRITE edit web-proof.txt using write_file") + expect(page.locator(".composer__btn--send")).to_be_enabled(timeout=60000) composer.press("Enter") page.screenshot(path=str(evidence / "write-pending.png"), full_page=True) # An explicit ask rule requires the same real approval flow as Desktop. @@ -209,6 +218,7 @@ def watch_socket(socket): print("PASS session recovery after a full service restart without replay", flush=True) browser.close() finally: + stream_release.set() if process.poll() is None: process.terminate() try: diff --git a/scripts/test-windows-installer-startup.ps1 b/scripts/test-windows-installer-startup.ps1 index a18795bfa..611b3672c 100644 --- a/scripts/test-windows-installer-startup.ps1 +++ b/scripts/test-windows-installer-startup.ps1 @@ -1,4 +1,4 @@ -[CmdletBinding()] +[CmdletBinding()] param( [Parameter(Mandatory=$true)][string]$InstallerPath, [Parameter(Mandatory=$true)][string]$ExpectedVersion, diff --git a/scripts/test-windows-installer-startup.test.ps1 b/scripts/test-windows-installer-startup.test.ps1 index 6a5553b44..39952aa0f 100644 --- a/scripts/test-windows-installer-startup.test.ps1 +++ b/scripts/test-windows-installer-startup.test.ps1 @@ -1,7 +1,13 @@ -# Exercise the real acceptance orchestration with disposable files and mocked +# Exercise the real acceptance orchestration with disposable files and mocked # process/registry boundaries. This never installs or uninstalls an application. $ErrorActionPreference = 'Stop' if ($env:OS -ne 'Windows_NT') { throw 'Run these tests on Windows.' } +foreach ($name in @('test-windows-legacy-update.ps1', 'test-windows-startup-recovery.ps1')) { + $tokens = $null + $parseErrors = $null + $null = [Management.Automation.Language.Parser]::ParseFile((Join-Path $PSScriptRoot $name), [ref]$tokens, [ref]$parseErrors) + if ($parseErrors.Count -ne 0) { throw ($parseErrors | Out-String) } +} . (Join-Path $PSScriptRoot 'test-windows-installer-startup.ps1') -InstallerPath unused -ExpectedVersion v1.2.3 $script:testRoot = [IO.Path]::GetFullPath((Join-Path $env:TEMP ('deepzora-installer-tests-' + [guid]::NewGuid().ToString('N')))) diff --git a/scripts/test-windows-legacy-update.ps1 b/scripts/test-windows-legacy-update.ps1 new file mode 100644 index 000000000..a01adb40a --- /dev/null +++ b/scripts/test-windows-legacy-update.ps1 @@ -0,0 +1,138 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory=$true)][string]$InstallerPath, + [Parameter(Mandatory=$true)][string]$ExpectedVersion, + [Parameter(Mandatory=$true)][ValidateSet('amd64','arm64')][string]$Architecture, + [Parameter(Mandatory=$true)][string]$EvidenceDirectory +) +$ErrorActionPreference = 'Stop' +. (Join-Path $PSScriptRoot 'test-windows-installer-startup.ps1') -InstallerPath $InstallerPath -ExpectedVersion $ExpectedVersion -EvidenceDirectory $EvidenceDirectory +Assert-InstallerTestAccount +$installer = (Resolve-Path -LiteralPath $InstallerPath).Path +if ((Get-AuthenticodeSignature -LiteralPath $installer).Status -ne 'Valid') { throw 'Candidate installer signature is not trusted' } +$targetHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $installer).Hash.ToLowerInvariant() +$evidence = [IO.Path]::GetFullPath($EvidenceDirectory) +if (Test-Path -LiteralPath $evidence) { throw 'Legacy update evidence directory must be new' } +New-Item -ItemType Directory -Path $evidence | Out-Null +# Exact v0.0.7 bytes from the sealed and published release. Never follow Latest +# for the old client, or silently test an unsigned/rebuilt approximation of it. +$published = @{ + amd64 = @{ + installed = 'b19176ec83b500975235e554ce4935207dbefb3c987ba58dcf735a4120c7ad25' + portable = 'b828fcc61282966270a43bc9451a395745e309ffcf503291b0d8e145770195a3' + } + arm64 = @{ + installed = '6c253aee4082c157334511593350b0be84b33a5e111e8356fdfd651fd42b18b6' + portable = 'dc9fa13c7c721a3a3c95c61d5dc83802cca0dcb1fc15fc1d1328f9356e393567' + } +} +$cpu = if ($Architecture -eq 'amd64') { 'x64' } else { 'arm64' } +$summary = @{ sourceVersion = 'v0.0.7'; targetVersion = $ExpectedVersion; targetSHA256 = $targetHash; architecture = $Architecture } +foreach ($mode in @('installed','portable')) { + $root = Join-Path $evidence $mode + $install = Join-Path $root 'installed' + $homePath = Join-Path $root 'home' + New-Item -ItemType Directory -Path $homePath -Force | Out-Null + $snapshot = Enter-WindowsAcceptanceEnvironment -DataHome $homePath + try { + $suffix = if ($mode -eq 'installed') { 'Setup.exe' } else { 'Portable.zip' } + $name = "Deepzora-0.0.7-Windows-$cpu-$suffix" + $oldPackage = Join-Path $root $name + $downloaded = $false + foreach ($url in @("https://downloads.deepzora.app/desktop/desktop-v0.0.7/$name", "https://github.com/SivanCola/deepzora/releases/download/desktop-v0.0.7/$name")) { + try { + Invoke-WebRequest $url -OutFile $oldPackage -TimeoutSec 180 -UserAgent "Deepzora-Updater/v0.0.7 (windows/$Architecture; acceptance)" + $downloaded = $true + break + } catch { Write-Host 'Old package origin unavailable; trying the official fallback.' } + } + if (-not $downloaded) { throw 'Published old package is unavailable from both official origins' } + if ((Get-FileHash -Algorithm SHA256 -LiteralPath $oldPackage).Hash.ToLowerInvariant() -ne $published[$Architecture][$mode]) { + throw 'Published v0.0.7 package does not match its sealed digest' + } + if ($mode -eq 'installed') { + Install-Deepzora -Installer $oldPackage -InstallRoot $install + $null = Assert-InstalledIdentity -InstallRoot $install -ExpectedVersion 'v0.0.7' + } else { + Expand-Archive -LiteralPath $oldPackage -DestinationPath $install + } + [IO.File]::WriteAllText((Join-Path $homePath 'config.toml'), "[desktop]`nlanguage = `"en`"`ncheck_updates = false`ntelemetry = false`nmetrics = false`n") + $marker = Join-Path $homePath 'legacy-update-retention.txt' + [IO.File]::WriteAllText($marker, [guid]::NewGuid().ToString('N')) + $markerHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $marker).Hash + & (Join-Path $PSScriptRoot 'test-windows-startup-recovery.ps1') -InstallRoot $install -ExpectedVersion 'v0.0.7' ` + -DataHome $homePath -EvidenceDirectory (Join-Path $root 'before') -KeepRunning | Out-Host + if (-not $?) { throw 'Published old client did not reach ready' } + $before = Get-Content -LiteralPath (Join-Path $root 'before/result.json') -Raw | ConvertFrom-Json + $oldShell = Get-Process -Id $before.shellPID + $oldService = Get-Process -Id $before.servicePID + $null = $oldShell.Handle + $null = $oldService.Handle + $oldHelper = Join-Path $root 'v0.0.7-update-helper.exe' + Copy-Item -LiteralPath (Join-Path $install 'versions/v0.0.7/deepzora-update-helper.exe') -Destination $oldHelper + if ((Get-AuthenticodeSignature -LiteralPath $oldHelper).Status -ne 'Valid') { throw 'Published old update helper is not trusted' } + $helperHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $oldHelper).Hash.ToLowerInvariant() + # Frozen v0.0.7 instance identity on the disposable runner's ordinary, + # case-insensitive, newly created data directory. The old helper itself + # revalidates this identity and the new endpoint before reporting success. + $sha = [Security.Cryptography.SHA256]::Create() + try { $digest = $sha.ComputeHash([Text.Encoding]::UTF8.GetBytes($homePath.ToLowerInvariant())) } finally { $sha.Dispose() } + $env:DEEPZORA_UPDATE_INSTANCE_ID = 'com.deepzora.desktop.' + ([BitConverter]::ToString($digest).Replace('-','').ToLowerInvariant().Substring(0,16)) + $arguments = @('--parent-pid', $oldService.Id, '--installer', ('"' + $installer + '"'), '--installer-sha256', $targetHash, + '--to-version', $ExpectedVersion, '--install-layout', 'versioned-v1', '--install-dir', ('"' + $install + '"'), + '--relaunch', ('"' + (Join-Path $install 'Deepzora.exe') + '"')) + $helper = Start-Process -FilePath $oldHelper -ArgumentList $arguments -PassThru ` + -RedirectStandardOutput (Join-Path $root 'helper.stdout.log') -RedirectStandardError (Join-Path $root 'helper.stderr.log') + $null = $helper.Handle + Start-Process -FilePath $oldShell.Path -ArgumentList '--deepzora-lifecycle-request=quit' | Out-Null + if (-not $oldShell.WaitForExit(15000) -or -not $oldService.WaitForExit(1000)) { throw 'Old client did not exit normally for automatic update' } + if (-not $helper.WaitForExit(240000)) { throw 'Published old helper did not finish the automatic update' } + if ($helper.ExitCode -ne 0) { throw "Published old helper failed automatic update: $($helper.ExitCode)" } + # The old helper verifies the ready shell but does not join the stable + # launcher it started. Await that exact child's exit before testing another + # launch; otherwise the immutable old launcher's teardown can overlap our + # next process snapshot. Keep the helper handle alive so its PID cannot be + # reused, and never skip a still-present child that cannot be inspected. + $launchDeadline = [DateTime]::UtcNow.AddSeconds(40) + while ($true) { + $children = @(Get-CimInstance Win32_Process -Filter "ParentProcessId = $($helper.Id) AND Name = 'Deepzora.exe'") + if ($children.Count -eq 0) { break } + $remaining = [int]($launchDeadline - [DateTime]::UtcNow).TotalMilliseconds + if ($remaining -le 0) { throw 'Old helper relauncher did not finish; child evidence remains unverified' } + foreach ($child in $children) { + $relaunchProcess = $null + try { + $relaunchProcess = Get-Process -Id $child.ProcessId -ErrorAction Stop + $null = $relaunchProcess.Handle + } catch { + if ($null -ne $relaunchProcess) { $relaunchProcess.Dispose() } + continue + } + try { + if (-not $relaunchProcess.WaitForExit($remaining)) { throw 'Old helper relauncher remained alive' } + if ($relaunchProcess.ExitCode -ne 0) { throw "Old helper relauncher failed: $($relaunchProcess.ExitCode)" } + } finally { $relaunchProcess.Dispose() } + } + Start-Sleep -Milliseconds 100 + } + & (Join-Path $PSScriptRoot 'test-windows-startup-recovery.ps1') -InstallRoot $install -ExpectedVersion $ExpectedVersion ` + -DataHome $homePath -EvidenceDirectory (Join-Path $root 'after') -ArtifactPath $installer | Out-Host + if (-not $?) { throw 'Updated client failed startup, repeat launch or normal exit' } + if ((Get-FileHash -Algorithm SHA256 -LiteralPath $marker).Hash -ne $markerHash) { throw 'Automatic update modified old user data' } + if ((Get-FileHash -Algorithm SHA256 -LiteralPath $installer).Hash.ToLowerInvariant() -ne $targetHash) { throw 'Candidate bytes changed during upgrade' } + if ($mode -eq 'installed') { + $null = Assert-InstalledIdentity -InstallRoot $install -ExpectedVersion $ExpectedVersion + $uninstaller = Join-Path $install 'uninstall.exe' + $process = Start-Process -FilePath $uninstaller -ArgumentList '/S' -PassThru -Wait + if ($process.ExitCode -ne 0) { throw 'Upgraded installation failed to uninstall' } + Assert-UninstalledState -InstallRoot $install -DataSnapshot @{ $marker = $markerHash } + } + $summary[$mode] = 'passed' + $summary[$mode + 'SourceSHA256'] = $published[$Architecture][$mode] + $summary[$mode + 'HelperSHA256'] = $helperHash + } finally { + Restore-WindowsAcceptanceEnvironment -Snapshot $snapshot + } +} +$summary | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $evidence 'legacy-update.json') -Encoding utf8 +Write-Host 'Published v0.0.7 installed and portable clients upgraded using their own signed helper; target startup and retained data passed.' diff --git a/scripts/test-windows-startup-recovery.ps1 b/scripts/test-windows-startup-recovery.ps1 index daeaa1dbe..c3a3791c6 100644 --- a/scripts/test-windows-startup-recovery.ps1 +++ b/scripts/test-windows-startup-recovery.ps1 @@ -7,6 +7,7 @@ param( [string]$DataHome = '', [string]$ExpectedVisibleText = '', [switch]$PrepareHistoricalSession, + [switch]$KeepRunning, [string]$EvidenceDirectory = (Join-Path $env:TEMP ('deepzora-recovery-' + [guid]::NewGuid().ToString('N'))) ) $ErrorActionPreference = 'Stop' @@ -105,10 +106,12 @@ try { if ($ExpectedVisibleText) { Assert-VisibleContentAndCapture $first.Shell $ExpectedVisibleText (Join-Path $EvidenceDirectory 'upgraded-history.png') } - Start-Process $shellPath -ArgumentList '--deepzora-lifecycle-request=quit' | Out-Null - if (-not $first.Shell.WaitForExit(15000) -or -not $first.Service.WaitForExit(1000)) { throw 'Normal exit left a shell or service alive' } - $shellLog = Get-Content (Join-Path $dataHome 'desktop-shell\logs\shell.log') -Raw - if ($shellLog -match 'exit deadline exceeded|killing it|termination failed') { throw 'Forced cleanup is not a normal-exit pass' } + if (-not $KeepRunning) { + Start-Process $shellPath -ArgumentList '--deepzora-lifecycle-request=quit' | Out-Null + if (-not $first.Shell.WaitForExit(15000) -or -not $first.Service.WaitForExit(1000)) { throw 'Normal exit left a shell or service alive' } + $shellLog = Get-Content (Join-Path $dataHome 'desktop-shell\logs\shell.log') -Raw + if ($shellLog -match 'exit deadline exceeded|killing it|termination failed') { throw 'Forced cleanup is not a normal-exit pass' } + } $artifactHash = if ($ArtifactPath) { (Get-FileHash -Algorithm SHA256 $ArtifactPath).Hash } elseif ($PortableZip) { (Get-FileHash -Algorithm SHA256 $PortableZip).Hash } else { '' } $report = @{ artifact=$artifactHash @@ -117,7 +120,7 @@ try { architecture=$env:PROCESSOR_ARCHITECTURE shellPID=$first.Shell.Id servicePID=$first.Service.Id - startup='passed'; secondLaunch='passed'; normalExit='passed'; visibleHistory=if ($ExpectedVisibleText) { 'passed' } else { 'not requested' } + startup='passed'; secondLaunch='passed'; normalExit=if ($KeepRunning) { 'not exercised' } else { 'passed' }; visibleHistory=if ($ExpectedVisibleText) { 'passed' } else { 'not requested' } signing='not checked'; installer=if ($PSCmdlet.ParameterSetName -eq 'Installed') { 'passed' } else { 'not exercised' }; recoveryConsent='not exercised' } $report | ConvertTo-Json | Set-Content (Join-Path $EvidenceDirectory 'result.json') diff --git a/scripts/test-windows-upgrade-startup.ps1 b/scripts/test-windows-upgrade-startup.ps1 index 4aaaac57f..1f8be869a 100644 --- a/scripts/test-windows-upgrade-startup.ps1 +++ b/scripts/test-windows-upgrade-startup.ps1 @@ -1,4 +1,4 @@ -[CmdletBinding()] +[CmdletBinding()] param( [string]$ApplicationPath, [string]$FixtureBuilderPath, diff --git a/scripts/test-windows-upgrade-startup.test.ps1 b/scripts/test-windows-upgrade-startup.test.ps1 index f05814b3b..a02458bbd 100644 --- a/scripts/test-windows-upgrade-startup.test.ps1 +++ b/scripts/test-windows-upgrade-startup.test.ps1 @@ -1,4 +1,4 @@ -$ErrorActionPreference = 'Stop' +$ErrorActionPreference = 'Stop' . (Join-Path $PSScriptRoot 'test-windows-upgrade-startup.ps1') . (Join-Path $PSScriptRoot 'windows-upgrade-ui-evidence.ps1') diff --git a/scripts/validate-release-control-plane.sh b/scripts/validate-release-control-plane.sh index 67fe9cda3..a75a6ef05 100755 --- a/scripts/validate-release-control-plane.sh +++ b/scripts/validate-release-control-plane.sh @@ -9,11 +9,13 @@ required=( .github/workflows/release-promote.yml .github/workflows/release-mirror.yml .github/workflows/release-desktop.yml + .github/workflows/verify-windows-auto-update.yml .github/release-signing.yml npm/publish-candidate.mjs scripts/build-release-cli-candidate.mjs scripts/desktop-release-artifacts.mjs scripts/desktop-downloads.mjs + scripts/windows-distribution.mjs internal/releaseassets/desktop.json scripts/finalize-windows-signed-candidate.sh scripts/install-nsis.ps1 @@ -34,6 +36,8 @@ required=( scripts/resolve-release-candidate.mjs scripts/sign-certum.ps1 scripts/test-windows-installer-startup.ps1 + scripts/test-windows-legacy-update.ps1 + scripts/legacy-windows-update.gotest scripts/test-windows-startup-recovery.ps1 scripts/test-windows-upgrade-startup.ps1 scripts/verify-windows-authenticode.ps1 diff --git a/scripts/windows-upgrade-ui-evidence.ps1 b/scripts/windows-upgrade-ui-evidence.ps1 index b871e3c6e..2005d1618 100644 --- a/scripts/windows-upgrade-ui-evidence.ps1 +++ b/scripts/windows-upgrade-ui-evidence.ps1 @@ -1,4 +1,4 @@ -# The selector is deliberately scoped to the rendered transcript. Sidebar topic +# The selector is deliberately scoped to the rendered transcript. Sidebar topic # titles and offscreen accessibility nodes are not evidence of restored history. function Get-UpgradeUIDescendants($element) { return $element.FindAll([Windows.Automation.TreeScope]::Descendants, [Windows.Automation.Condition]::TrueCondition) diff --git a/tools/desktopinventory/sources.go b/tools/desktopinventory/sources.go index 84b4c9225..653139892 100644 --- a/tools/desktopinventory/sources.go +++ b/tools/desktopinventory/sources.go @@ -36,6 +36,7 @@ var ciJobs = map[string]struct { "release-desktop.yml/windows-build": {classKeepBusiness, "builds and smoke-tests unsigned x64 and ARM64 packages on native Windows runners before signing"}, "release-desktop.yml/windows-sign": {classKeepBusiness, "Certum signs native-tested x64 and ARM64 payloads and rebuilt installers on x64"}, "release-desktop.yml/windows-runtime-acceptance": {classKeepBusiness, "installs and starts the exact signed x64 and ARM64 installers on native runners"}, + "release-desktop.yml/windows-legacy-upgrade": {classKeepBusiness, "qualifies published v0.0.7 installed and portable clients upgrading through their original signed helper"}, "release-desktop.yml/mac-universal-intel": {classKeepBusiness, "validates the exact universal DMG from the build matrix on an Intel runner"}, "release-desktop.yml/publish": {classKeepBusiness, "manifest, minisign and mirror unchanged"}, "release-desktop.yml/attest-signing-contract": {classKeepBusiness, "attests the extended payload list"},