Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

feat(fork): 桌面与根安装脚本去 OSS/速度探测,插件来源元数据指向 Adelie

lmliheng1ac076f7f77f
diff --git a/FORK-PROGRESS.md b/FORK-PROGRESS.md
index b41ec3d8..8a199c54 100644
--- a/FORK-PROGRESS.md
+++ b/FORK-PROGRESS.md
@@ -273,13 +273,22 @@ README 插件表那三条已闭,macOS 那条重跑即绿(确系跑机抖动
- 验证:`pnpm typecheck` 八个包全过;`pnpm lint` 0 警告;`pnpm format:check` 干净;
core 1346 · web 2886 · cli 505 · server 2552 · docs 62 全绿。
-**这条还没做完的部分(下一轮接着做)**:
+**这条的收尾(2026-10-05,第二轮,已做完)**:
-| 没做的 | 为什么这轮没做 | 做完的判据 |
+| 项 | 做了什么 | 验证 |
+| --- | --- | --- |
+| `packages/desktop` 的更新源 | 删掉「速度探测 + OSS 镜像 feed」整套:`src/update-source.ts`(364 行)与 `test/update-source.test.ts`(612 行)删除;`update-support.ts` 只留 `updateSupport` / `feedUrlOverride`;`updater.ts` 单源化(自建镜像只剩 `PENGUIN_UPDATE_FEED_URL` 覆盖,去 OSS / 探针 / 回退 feed);`RELEASES_URL`、`menu.ts` 的 `REPO_URL` 与 GitHub feed 的 owner/repo 全指向 Adelie | `npx tsc --noEmit -p packages/desktop/tsconfig.json` 退出 0;`vitest run --root packages/desktop` 22 文件 / 279 测试全绿(原 308,少的正是删掉的探针用例);`PENGUIN_UPDATE_SOURCE` / 探针符号全仓 grep 为空 |
+| 根目录 `install.sh` / `install.ps1` | `REPO` → Adelie,删 `OSS_ORIGIN` / `OSS_RELEASE_ROOT`;删速度探测整套(`SPEED_PROBE_*` 常量、`load_release_download_manifest` / `probe_*` / `select_speed_probe_source` / `speed_probe_release_sources` 及 PS 侧同名函数);`PENGUIN_DOWNLOAD_SOURCE` 收成 `auto\|github`(写 `oss` 直接报错);不再读 `PENGUIN_DOWNLOAD_SPEED_PROBE`;在线路径只剩 GitHub(stamped 用自身 tag,unstamped 走 latest),`PENGUIN_DOWNLOAD_BASE_URL` 及其 fallback 仍可自建镜像。`scripts/test-installer.{sh,ps1}` 同步重写:删掉共享常量守卫、探针用例与 `packages/landing` 转发器用例(那个目录 2.5 已删,CI 的 `installer-windows` 正是红在这里) | `sh scripts/test-installer.sh` 通过;`pnpm typecheck` 八包过、`pnpm lint` 0 警告、`pnpm format:check` 干净;重建 server 后 `dist/install.{sh,ps1}` 副本与根一致 |
+| `server/src/plugin/builtin-index.json` 的四行 `repository` | 四行全改成 `https://github.com/lmliheng/Adelie`;同口径把 14 个 `plugins/*/package.json` 的 `repository.url` 也改成 Adelie(`scripts/check-plugin-versions.mjs` 显式排除三级路径的 `package.json`,不受影响) | core 1346 · server 2552 · cli 505 · web 2886 · desktop 279 全绿 |
+
+**顺带补的一处(原 ③ 漏掉)**:`packages/web/src/components/account/update-modal.tsx` 的
+`RELEASES_URL` 还是上游 PenguinHarness 的 Releases —— 更新弹窗「打开发布页」会把用户带到上游项目,
+与 ③ 的目标相悖,改成 Adelie 的 Releases(web 2886 测试全绿,无用例钉这个常量)。
+
+**仍未做完的部分**:
+
+| 没做的 | 为什么没做 | 做完的判据 |
| --- | --- | --- |
-| `packages/desktop`(`updater.ts` / `update-source.ts` / `menu.ts`) | 它的自动更新是「速度探测 + OSS 镜像 feed」整套子系统(`update-source.ts` 364 行 + 612 行测试),拆它要单独一轮;Adelie 目前也**没有**桌面产物发布 | 桌面 feed 指向 `lmliheng/Adelie` 且没有 OSS 臂;`vitest --root packages/desktop` 全绿 |
-| 根目录 `install.sh` / `install.ps1` | 里面的 `REPO` 与 `OSS_ORIGIN` 还是上游的;`scripts/test-installer.{sh,ps1}` 用断言把这两个常量与 OSS 探针行为钉住了,改它得连那套测试一起重写 | 两个安装脚本指向 Adelie 且不再提 OSS;`sh scripts/test-installer.sh` 与 CI 的 `installer-windows` 通过 |
-| `server/src/plugin/builtin-index.json` 那四行 `repository` | 那是插件的来源元数据,不是更新链路 | 随桌面 / 发布那一轮统一口径 |
| Adelie Release 没有资产 | 所以现在 `penguin update` 会答「已是最新」(v0.2.0 = 当前版本),不会去装任何东西 —— 这是对的行为;真要能升级,得按上游同名的资产形状(install.sh + payload + 校验和)发一版;用户「不想给别人用」的那套包在 3003 | 发一版带资产的 Release 后,`penguin update --check` 报得出新版本 |
### ② 插件与 Agent 的升级是怎么做的(答用户问)
@@ -317,6 +326,9 @@ Agent 上对插件内容的本地改动 —— 现在的产品行为是「提示
| 首次登录 | 2026-10-05 用户自己设了管理员密码(值不进仓库),首次登录链接**已作废**;现在用 用户名 `admin` + 那个密码登录。忘了密码:停服务后 `penguin server reset-admin-password`,再启动会打印新的认领链接(步骤见 `/root/adelie-data/首次登录链接.txt`,0600) |
| 旧地址 | 上游设计规格页已从 3004 让到 **3003**(`adelie-design.service`,同步改了单元与端口表);旧 Adelie Web 仍在 4000(`adelie-web.service`) |
+> **2026-10-05(用户要求)**:`adelie-app.service`(3004)已 `systemctl stop`,端口已释放;
+> 单元仍 `enabled`,**重启机器会自己回来**,要不要 `disable` 等用户发话。3003 / 4000 未动。
+
要跑真任务还得在这个新实例里配模型 key(数据根独立,读不到旧实例的 `.project_config.toml`)。
**重启的代价**:服务端自己改了什么(字符串、core 的 dist)要等一次重启才生效,而**重启会换发首次
@@ -364,3 +376,4 @@ Agent 上对插件内容的本地改动 —— 现在的产品行为是「提示
| 2026-10-05 | 发布 | 旧 `main` 留档成 `legacy/main`,仓库**默认分支切到 `fork/penguin-base`**;仓库 About(描述 + 话题)改成「基于 PenguinHarness」的说法 | `git push origin legacy/main` = `7fb74262`;`PATCH /repos/lmliheng/Adelie` `default_branch` → 200;`GET /repos` 复核 `default_branch=fork/penguin-base`、description/topics 已换;真浏览器看仓库首页:分支选择器是 `fork/penguin-base`、About 新描述、Releases 侧栏 v0.2.0 Latest、正文就是写明 fork 的 README,无 4xx | 见本行提交 |
| 2026-10-05 | 主线 | 默认分支定名 **`main`**(新基座并进 `main`、旧 Adelie 存 `legacy/main`、删 `fork/penguin-base`);v0.2.0 安装包本机现打后放 **3003**;删 `docker.yml` 的 `push:main`;修 desktop 夹具 | `GET /repos` 报 `default_branch: main`;三个包 `.sha256` 自检 + linux 包在隔离 HOME 里真离线装(`penguin version --json` = `0.2.0`/release);桌面测试 308 全绿;CI run `37258858438`:`test(rest)` 一族由红转绿、Docker 未触发 | 见本行提交 |
| 2026-10-05 | 主线 | README 插件表断言放宽(用户选的 b)+ 删掉模型里的「官方推荐」+ 更新链路指向 Adelie(CLI / server / Web) | 见「主线三件事」一节 | 见本行提交 |
+| 2026-10-05 | 主线收尾 | 「主线三件事」的收尾:桌面更新源去 OSS/探针、根安装脚本去 OSS/探针并指向 Adelie、插件元数据 `repository` 指向 Adelie;顺带修 web 更新弹窗的上游 Releases 链接;`scripts/test-installer.{sh,ps1}` 同步重写 | `sh scripts/test-installer.sh` 通过;`pnpm typecheck` 八包过、`pnpm lint` 0 警告、`pnpm format:check` 干净;core 1346 · server 2552 · cli 505 · web 2886 · desktop 279 全绿 | 见本行提交 |
diff --git a/FORK.md b/FORK.md
index 2af7dbcd..b5762f41 100644
--- a/FORK.md
+++ b/FORK.md
@@ -45,13 +45,15 @@ git merge upstream/develop # 在 main 上
进度与每条待办记在 `FORK-PROGRESS.md`(本文件讲「为什么这样改」,它讲「改到哪了」)。
-### 已经改掉的两件事(Apache-2.0 §4 要求的改动声明,2026-10-05)
+### 已经改掉的(Apache-2.0 §4 要求的改动声明,2026-10-05 起)
- **更新链路只连 Adelie 自己的 Releases**。`penguin update`、Web 的「有新版本」提示与它的发布页
- 链接都指向 `lmliheng/Adelie`。上游那套 Alibaba Cloud OSS 镜像**没有跟着搬过来**(镜像是项目
- 自己的账号与账单),所以 CLI 的下载源只剩 GitHub,`PENGUIN_DOWNLOAD_SOURCE=oss` 会被明确拒绝
- 而不是默默回落到 auto。`packages/desktop` 与根目录 `install.sh` / `install.ps1` 里**还留着**
- 上游的仓库与镜像地址,两处的收尾判据记在 `FORK-PROGRESS.md`「主线三件事」一节的待办表里。
+ 链接、桌面端的自动更新 feed、根目录两个安装脚本,以及插件库的来源元数据
+ (`server/src/plugin/builtin-index.json` 与 `plugins/*/package.json`)都指向 `lmliheng/Adelie`。
+ 上游那套 Alibaba Cloud OSS 镜像**没有跟着搬过来**(镜像是项目自己的账号与账单),所以下载源
+ 只剩 GitHub,`PENGUIN_DOWNLOAD_SOURCE=oss`(CLI 与两个安装脚本)会被明确拒绝而不是默默回落到
+ auto。桌面端的「速度探测 + 镜像 feed」子系统与安装脚本里的 `SPEED_PROBE_*` 整套也一并删掉了;
+ 自建镜像改用自己的 base URL / feed(`PENGUIN_DOWNLOAD_BASE_URL`、`PENGUIN_UPDATE_FEED_URL`)。
- **模型库里没有「官方推荐」了**。上游把 TokenDance 分组标为 `recommended` 并在模型库页面挂
「官方推荐 / Recommended」标签;Adelie 删掉了这个标记(推荐哪家网关是上游的商业选择,不是我们
的)。分组的默认顺序没有变。
diff --git a/install.ps1 b/install.ps1
index 2724184d..e4931069 100644
--- a/install.ps1
+++ b/install.ps1
@@ -1,15 +1,13 @@
# Adelie one-line installer for Windows.
#
-# irm https://penguin.ooo/install.ps1 | iex
+# irm https://github.com/lmliheng/Adelie/releases/latest/download/install.ps1 | iex
#
# Options:
# $env:PENGUIN_VERSION = "vX.Y.Z" choose a version (same as -Version vX.Y.Z); a published Release
# installer defaults to its own version, an unstamped source copy to latest
# $env:PENGUIN_INSTALL_DIR = "<dir>" install dir; default $env:USERPROFILE\.penguin
# $env:PENGUIN_ARCHIVE = "<file>" install a local Release zip without network access (same as -ArchivePath)
-# $env:PENGUIN_DOWNLOAD_SOURCE = "auto|oss|github" choose the online source; default auto
-# (speed-probed, with the same-version other source as fallback)
-# $env:PENGUIN_DOWNLOAD_SPEED_PROBE = "0" disable same-version OSS/GitHub probe timing in auto mode
+# $env:PENGUIN_DOWNLOAD_SOURCE = "auto|github" choose the online source; default auto (GitHub Releases)
# $env:PENGUIN_DOWNLOAD_BASE_URL = "https://..." exact online asset directory selected by the stable forwarder
# $env:PENGUIN_DOWNLOAD_FALLBACK_BASE_URL = "https://..." fallback for PENGUIN_DOWNLOAD_BASE_URL
# -NoModifyPath do not add <install>\bin to the user Path; for a second installation
@@ -41,34 +39,10 @@ param(
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue" # Invoke-WebRequest progress rendering slows downloads massively on PS 5.1
-$Repo = "https://github.com/Prism-Shadow/penguin-harness"
-$OssOrigin = "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com"
-$OssReleaseRoot = "$OssOrigin/releases"
+$Repo = "https://github.com/lmliheng/Adelie"
$GitHubReleaseRoot = "$Repo/releases/download"
$GitHubLatestBase = "$Repo/releases/latest/download"
$Asset = "penguin-win32-x64.zip"
-# Auto-mode source selection, one rule shared by install.ps1 and install.sh:
-#
-# 1. Measure GitHub on the release's large probe file. At or above
-# $SpeedProbeGitHubMinBytesPerSecond it wins outright and OSS is never touched.
-# 2. Only below that is OSS measured, and it takes over only when it is more than
-# $SpeedProbeOssSwitchRatio of GitHub — a mirror that is merely a little quicker does not
-# justify its bandwidth bill, and a slow GitHub download still resumes.
-#
-# GitHub is the free source, so every tie and every unmeasurable comparison stays there. The two
-# constants are duplicated because these three implementations cannot import from each other — an
-# installer is a standalone file fetched over the network. Change them in all three at once, which
-# scripts/test-installer.sh pins.
-#
-# The total budget covers the whole probe: manifest, the small reachability pair, and up to two
-# large probes. It is deliberately the sum of their caps, so the second large probe always gets its
-# full window rather than being squeezed into declaring a healthy mirror unreachable.
-$SpeedProbeManifestTimeoutSeconds = 5
-$SpeedProbeSmallTimeoutSeconds = 5
-$SpeedProbeLargeTimeoutSeconds = 8
-$SpeedProbeTotalTimeoutSeconds = 26
-$SpeedProbeGitHubMinBytesPerSecond = 262144
-$SpeedProbeOssSwitchRatio = 1.5
$PayloadName = "payload.zip"
# The release workflow replaces this token with the immutable tag before publishing both the
# standalone installer and the copy sealed inside the Windows bundle.
@@ -116,47 +90,8 @@ function Test-ReleaseTag([string]$Value) {
return $Value -match '^v[0-9A-Za-z][0-9A-Za-z._-]*$'
}
-function Try-DownloadFile([string]$Uri, [string]$OutFile, [int]$TimeoutSec) {
- try {
- Invoke-WebRequest -Uri $Uri -OutFile $OutFile -UseBasicParsing -TimeoutSec $TimeoutSec | Out-Null
- return $true
- } catch {
- Remove-Item -LiteralPath $OutFile -Force -ErrorAction SilentlyContinue
- return $false
- }
-}
-
-function Get-SpeedProbeTimeoutSec([DateTime]$Deadline, [int]$MaxSec) {
- $Remaining = [int][Math]::Ceiling(($Deadline - [DateTime]::UtcNow).TotalSeconds)
- if ($Remaining -le 0) { return 0 }
- return [Math]::Min($MaxSec, $Remaining)
-}
-
-function Get-OssLatestTag([string]$ManifestPath) {
- Remove-Item -LiteralPath $ManifestPath -Force -ErrorAction SilentlyContinue
- try {
- Invoke-WebRequest -Uri "$OssOrigin/latest.json" -OutFile $ManifestPath -UseBasicParsing -TimeoutSec 8 | Out-Null
- } catch {
- Remove-Item -LiteralPath $ManifestPath -Force -ErrorAction SilentlyContinue
- return ""
- }
- try {
- $Manifest = [IO.File]::ReadAllText($ManifestPath, [Text.UTF8Encoding]::new($false)) | ConvertFrom-Json
- $CandidateTag = [string]$Manifest.tag
- $CandidateBase = ([string]$Manifest.releaseBaseUrl).TrimEnd('/')
- if ([int]$Manifest.schemaVersion -eq 1 -and
- (Test-ReleaseTag $CandidateTag) -and
- $CandidateBase -eq "$OssReleaseRoot/$CandidateTag") {
- return $CandidateTag
- }
- } catch {
- }
- return ""
-}
-
function Get-DownloadSourceLabel([string]$BaseUrl) {
try { $HostName = ([Uri]$BaseUrl).Host } catch { return "configured mirror" }
- if ($HostName -like "*.aliyuncs.com") { return "OSS mirror" }
if ($HostName -eq "github.com") { return "GitHub" }
return "configured mirror"
}
@@ -179,157 +114,6 @@ function Get-ReleasePair(
}
}
-function Test-SafeReleaseAssetName([string]$Value) {
- return $Value -match '^[A-Za-z0-9._+-]+$' -and -not $Value.Contains('..')
-}
-
-function Read-ReleaseDownloadManifest([string]$Tag, [string]$ManifestPath, [DateTime]$Deadline) {
- Remove-Item -LiteralPath $ManifestPath -Force -ErrorAction SilentlyContinue
- $TimeoutSec = Get-SpeedProbeTimeoutSec $Deadline $SpeedProbeManifestTimeoutSeconds
- if ($TimeoutSec -le 0 -or -not (Try-DownloadFile "$OssReleaseRoot/$Tag/release-download-manifest.tsv" $ManifestPath $TimeoutSec)) {
- $TimeoutSec = Get-SpeedProbeTimeoutSec $Deadline $SpeedProbeManifestTimeoutSeconds
- if ($TimeoutSec -le 0 -or -not (Try-DownloadFile "$GitHubReleaseRoot/$Tag/release-download-manifest.tsv" $ManifestPath $TimeoutSec)) {
- return $null
- }
- }
-
- $Lines = [IO.File]::ReadAllLines($ManifestPath, [Text.UTF8Encoding]::new($false))
- if ($Lines.Count -lt 4) { return $null }
- if ($Lines[0] -ne "penguin-release-download-manifest`t1`t$Tag") { return $null }
-
- $SmallProbe = $null
- $LargeProbe = $null
- $AssetSize = 0L
- foreach ($Line in $Lines | Select-Object -Skip 1) {
- if (-not $Line) { return $null }
- $Fields = $Line -split "`t"
- if ($Fields[0] -eq "probe") {
- if ($Fields.Count -ne 5) { return $null }
- $Probe = [PSCustomObject]@{
- Name = [string]$Fields[2]
- Size = 0L
- Sha256 = [string]$Fields[4]
- }
- if (-not (Test-SafeReleaseAssetName $Probe.Name)) { return $null }
- $ProbeSize = 0L
- if (-not [Int64]::TryParse([string]$Fields[3], [ref]$ProbeSize) -or $ProbeSize -le 0) { return $null }
- $Probe.Size = $ProbeSize
- if ($Probe.Sha256 -notmatch '^[0-9a-f]{64}$') { return $null }
- if ($Fields[1] -eq "small") { $SmallProbe = $Probe }
- if ($Fields[1] -eq "large") { $LargeProbe = $Probe }
- } elseif ($Fields[0] -eq "asset" -and $Fields.Count -eq 4 -and $Fields[1] -eq $Asset) {
- # Not part of the decision — an integrity check that this manifest belongs to a release which
- # actually carries this target's bundle, so a mismatched manifest cannot steer the probe.
- if (-not [Int64]::TryParse([string]$Fields[2], [ref]$AssetSize) -or $AssetSize -le 0) { return $null }
- }
- }
-
- if (-not $SmallProbe -or -not $LargeProbe -or $AssetSize -le 0) { return $null }
- [PSCustomObject]@{
- SmallProbe = $SmallProbe
- LargeProbe = $LargeProbe
- AssetSize = $AssetSize
- }
-}
-
-function Invoke-ProbeDownload(
- [string]$BaseUrl,
- [object]$Probe,
- [string]$Tmp,
- [string]$Label,
- [DateTime]$Deadline,
- [int]$MaxTimeoutSec = $SpeedProbeSmallTimeoutSeconds
-) {
- $ProbePath = Join-Path $Tmp "probe-$Label-$($Probe.Name)"
- Remove-Item -LiteralPath $ProbePath -Force -ErrorAction SilentlyContinue
- $TimeoutSec = Get-SpeedProbeTimeoutSec $Deadline $MaxTimeoutSec
- if ($TimeoutSec -le 0) {
- return [PSCustomObject]@{ Ok = $false; Seconds = 0.0 }
- }
- $Succeeded = $false
- $Elapsed = Measure-Command {
- $Succeeded = Try-DownloadFile "$BaseUrl/$($Probe.Name)" $ProbePath $TimeoutSec
- }
- if (-not $Succeeded) {
- return [PSCustomObject]@{ Ok = $false; Seconds = 0.0 }
- }
- try {
- $Item = Get-Item -LiteralPath $ProbePath -ErrorAction Stop
- if ($Item.Length -ne $Probe.Size) {
- return [PSCustomObject]@{ Ok = $false; Seconds = 0.0 }
- }
- $ActualHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $ProbePath).Hash.ToLowerInvariant()
- if ($ActualHash -ne $Probe.Sha256) {
- return [PSCustomObject]@{ Ok = $false; Seconds = 0.0 }
- }
- } catch {
- return [PSCustomObject]@{ Ok = $false; Seconds = 0.0 }
- }
- $Seconds = [Math]::Max($Elapsed.TotalSeconds, 0.001)
- [PSCustomObject]@{ Ok = $true; Seconds = $Seconds }
-}
-
-# Throughput a completed probe measured, in bytes per second; 0 when it did not complete, which
-# sorts it below any real measurement in the comparison below.
-function Get-ProbeBytesPerSecond([object]$Probe, [Int64]$ProbeSize) {
- if (-not $Probe.Ok) { return 0.0 }
- return [double]$ProbeSize / [Math]::Max([double]$Probe.Seconds, 0.001)
-}
-
-# The shared rule, in one place: GitHub clears the minimum and wins outright, otherwise the mirror
-# has to beat it by the switch ratio to take over.
-function Select-SpeedProbeSource([double]$GitHubBytesPerSecond, [double]$OssBytesPerSecond) {
- if ($GitHubBytesPerSecond -ge $SpeedProbeGitHubMinBytesPerSecond) { return "github" }
- if ($OssBytesPerSecond -gt ($GitHubBytesPerSecond * $SpeedProbeOssSwitchRatio)) { return "oss" }
- return "github"
-}
-
-function Select-SpeedProbeDownloadSources([string]$Tag, [string]$Tmp) {
- $Deadline = [DateTime]::UtcNow.AddSeconds($SpeedProbeTotalTimeoutSeconds)
- $Manifest = Read-ReleaseDownloadManifest $Tag (Join-Path $Tmp "release-download-manifest.tsv") $Deadline
- if (-not $Manifest) { return $null }
-
- Write-Host "Testing OSS mirror and GitHub download sources ..."
- $OssBase = "$OssReleaseRoot/$Tag"
- $GitHubBase = "$GitHubReleaseRoot/$Tag"
- $OssSmall = Invoke-ProbeDownload $OssBase $Manifest.SmallProbe $Tmp "oss-small" $Deadline
- $GitHubSmall = Invoke-ProbeDownload $GitHubBase $Manifest.SmallProbe $Tmp "github-small" $Deadline
-
- if ($GitHubSmall.Ok -and -not $OssSmall.Ok) {
- Write-Host "Selected GitHub (OSS mirror probe unavailable)."
- return [PSCustomObject]@{ BaseUrl = $GitHubBase; FallbackBaseUrl = $OssBase }
- }
- if ($OssSmall.Ok -and -not $GitHubSmall.Ok) {
- Write-Host "Selected OSS mirror (GitHub probe unavailable)."
- return [PSCustomObject]@{ BaseUrl = $OssBase; FallbackBaseUrl = $GitHubBase }
- }
- if (-not $OssSmall.Ok -and -not $GitHubSmall.Ok) { return $null }
-
- $GitHubLarge = Invoke-ProbeDownload $GitHubBase $Manifest.LargeProbe $Tmp "github-large" $Deadline $SpeedProbeLargeTimeoutSeconds
- $GitHubBytesPerSecond = Get-ProbeBytesPerSecond $GitHubLarge $Manifest.LargeProbe.Size
-
- # OSS is measured only once GitHub has failed the minimum: above it GitHub has already won, and
- # the mirror's bandwidth is not spent on a probe that could not change the answer. Probing runs
- # one source at a time on purpose — two concurrent transfers share the link and would each read
- # as half as fast, which an absolute threshold cannot tolerate.
- $OssBytesPerSecond = 0.0
- if ($GitHubBytesPerSecond -lt $SpeedProbeGitHubMinBytesPerSecond) {
- $OssLarge = Invoke-ProbeDownload $OssBase $Manifest.LargeProbe $Tmp "oss-large" $Deadline $SpeedProbeLargeTimeoutSeconds
- $OssBytesPerSecond = Get-ProbeBytesPerSecond $OssLarge $Manifest.LargeProbe.Size
- }
-
- if ((Select-SpeedProbeSource $GitHubBytesPerSecond $OssBytesPerSecond) -eq "github") {
- if ($GitHubBytesPerSecond -ge $SpeedProbeGitHubMinBytesPerSecond) {
- Write-Host "Selected GitHub (meets minimum download speed)."
- } else {
- Write-Host "Selected GitHub (the OSS mirror was not enough faster to be worth switching)."
- }
- return [PSCustomObject]@{ BaseUrl = $GitHubBase; FallbackBaseUrl = $OssBase }
- }
- Write-Host "Selected OSS mirror (clearly faster than GitHub here)."
- return [PSCustomObject]@{ BaseUrl = $OssBase; FallbackBaseUrl = $GitHubBase }
-}
-
function Restore-PreviousInstall(
[string]$InstallDir,
[string]$OldDir,
@@ -376,11 +160,6 @@ $SourceMode = if ($env:PENGUIN_DOWNLOAD_SOURCE) {
} else {
"auto"
}
-$DownloadSpeedProbe = if ($env:PENGUIN_DOWNLOAD_SPEED_PROBE) {
- $env:PENGUIN_DOWNLOAD_SPEED_PROBE
-} else {
- "1"
-}
# An extracted installer bundle keeps install.cmd, this script, payload.zip and its checksum
# together. `$PSScriptRoot` is empty for the documented `irm ... | iex` path, so online installs
# do not accidentally pick up an unrelated archive from the caller's current directory.
@@ -394,11 +173,8 @@ if ($ArchivePath -and $Version) {
if ($Version -and -not (Test-ReleaseTag $Version)) {
Fail "invalid release version: $Version"
}
-if ($SourceMode -notin @("auto", "oss", "github")) {
- Fail "PENGUIN_DOWNLOAD_SOURCE must be auto, oss, or github"
-}
-if ($DownloadSpeedProbe -notin @("0", "1")) {
- Fail "PENGUIN_DOWNLOAD_SPEED_PROBE must be 0 or 1"
+if ($SourceMode -notin @("auto", "github")) {
+ Fail "PENGUIN_DOWNLOAD_SOURCE must be auto or github"
}
$ResolvedReleaseVersion = if ($Version) {
$Version
@@ -429,10 +205,9 @@ try {
# .NET builds where the enum is immutable already default to TLS 1.2+.
}
-# --- Download. Explicit forwarder/configured URLs win. Otherwise a stamped Release installer
-# uses its own immutable version: auto prefers OSS and falls back only to the same GitHub
-# tag. An unstamped source-tree installer resolves latest.json first so it also locks one
-# version before downloading assets. ---
+# --- Download. An explicit forwarder/configured URL wins. Otherwise a stamped Release installer
+# uses its own immutable version; an unstamped source-tree installer falls back to the
+# release GitHub currently marks latest. ---
$Tmp = Join-Path ([IO.Path]::GetTempPath()) "penguin-install-$PID"
if (Test-Path $Tmp) { Remove-Item -Recurse -Force $Tmp }
New-Item -ItemType Directory -Path $Tmp | Out-Null
@@ -456,36 +231,10 @@ try {
$FallbackBaseUrl = $DownloadFallbackBaseUrl
if ($DownloadBaseUrl) {
$BaseUrl = $DownloadBaseUrl
- } elseif ($SourceMode -eq "github") {
- $BaseUrl = if ($ResolvedReleaseVersion) {
- "$GitHubReleaseRoot/$ResolvedReleaseVersion"
- } else {
- $GitHubLatestBase
- }
+ } elseif ($ResolvedReleaseVersion) {
+ $BaseUrl = "$GitHubReleaseRoot/$ResolvedReleaseVersion"
} else {
- $SelectedTag = $ResolvedReleaseVersion
- if (-not $SelectedTag) {
- $SelectedTag = Get-OssLatestTag (Join-Path $Tmp "latest.json")
- }
- if ($SelectedTag) {
- $BaseUrl = "$OssReleaseRoot/$SelectedTag"
- if ($SourceMode -eq "auto" -and -not $FallbackBaseUrl) {
- $FallbackBaseUrl = "$GitHubReleaseRoot/$SelectedTag"
- }
- if ($SourceMode -eq "auto" -and $DownloadSpeedProbe -eq "1" -and -not $DownloadBaseUrl) {
- $SpeedProbeSources = Select-SpeedProbeDownloadSources $SelectedTag $Tmp
- if ($SpeedProbeSources) {
- $BaseUrl = $SpeedProbeSources.BaseUrl
- $FallbackBaseUrl = $SpeedProbeSources.FallbackBaseUrl
- } else {
- Write-Host "Download source test was inconclusive; using OSS with same-version GitHub fallback."
- }
- }
- } elseif ($SourceMode -eq "oss") {
- Fail "the OSS mirror is unavailable or its release metadata is invalid."
- } else {
- $BaseUrl = $GitHubLatestBase
- }
+ $BaseUrl = $GitHubLatestBase
}
# Online: download the canonical bundle; the published checksum is mandatory.
diff --git a/install.sh b/install.sh
index 3cdea08a..5a77c92a 100644
--- a/install.sh
+++ b/install.sh
@@ -1,16 +1,14 @@
#!/bin/sh
# Adelie one-line installer.
#
-# curl -fsSL https://github.com/Prism-Shadow/penguin-harness/releases/latest/download/install.sh | sh
+# curl -fsSL https://github.com/lmliheng/Adelie/releases/latest/download/install.sh | sh
#
# Options:
# PENGUIN_VERSION=vX.Y.Z choose a version (same as --version vX.Y.Z); a published Release
# installer defaults to its own version, an unstamped source copy to latest
# PENGUIN_INSTALL_DIR=<dir> install dir; default ~/.penguin
# PENGUIN_ARCHIVE=<file> install a local Release archive without network access (same as --archive <file>)
-# PENGUIN_DOWNLOAD_SOURCE=auto|oss|github choose the online source; default auto (speed-probed,
-# with the same-version other source as fallback)
-# PENGUIN_DOWNLOAD_SPEED_PROBE=0 disable same-version OSS/GitHub probe timing in auto mode
+# PENGUIN_DOWNLOAD_SOURCE=auto|github choose the online source; default auto (GitHub Releases)
# PENGUIN_DOWNLOAD_BASE_URL=<url> exact online asset directory selected by the stable forwarder
# PENGUIN_DOWNLOAD_FALLBACK_BASE_URL=<url> fallback for PENGUIN_DOWNLOAD_BASE_URL
# --universal install the universal package (no bundled Node runtime; needs system Node >= 24)
@@ -31,9 +29,7 @@
# Docs: https://penguin.ooo/docs/quickstart-cli
set -eu
-REPO="https://github.com/Prism-Shadow/penguin-harness"
-OSS_ORIGIN="https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com"
-OSS_RELEASE_ROOT="$OSS_ORIGIN/releases"
+REPO="https://github.com/lmliheng/Adelie"
GITHUB_RELEASE_ROOT="$REPO/releases/download"
GITHUB_LATEST_BASE="$REPO/releases/latest/download"
VERSION="${PENGUIN_VERSION:-}"
@@ -45,30 +41,6 @@ ARCHIVE="${PENGUIN_ARCHIVE:-}"
SOURCE_MODE="${PENGUIN_DOWNLOAD_SOURCE:-auto}"
DOWNLOAD_BASE_URL="${PENGUIN_DOWNLOAD_BASE_URL:-}"
DOWNLOAD_FALLBACK_BASE_URL="${PENGUIN_DOWNLOAD_FALLBACK_BASE_URL:-}"
-DOWNLOAD_SPEED_PROBE="${PENGUIN_DOWNLOAD_SPEED_PROBE:-1}"
-# Auto-mode source selection, one rule shared by install.sh and install.ps1:
-#
-# 1. Measure GitHub on the release's large probe file. At or above
-# SPEED_PROBE_GITHUB_MIN_BYTES_PER_SECOND it wins outright and OSS is never touched.
-# 2. Only below that is OSS measured, and it takes over only when it is more than
-# SPEED_PROBE_OSS_SWITCH_RATIO_PERCENT of GitHub — a mirror that is merely a little quicker
-# does not justify its bandwidth bill, and a slow GitHub download still resumes.
-#
-# GitHub is the free source, so every tie and every unmeasurable comparison stays there. The two
-# constants are duplicated because these three implementations cannot import from each other — an
-# installer is a standalone file fetched over the network. Change them in all three at once, which
-# scripts/test-installer.sh pins.
-#
-# The total budget covers the whole probe: manifest, the small reachability pair, and up to two
-# large probes. It is deliberately the sum of their caps, so the second large probe always gets its
-# full window rather than being squeezed into declaring a healthy mirror unreachable.
-SPEED_PROBE_MANIFEST_TIMEOUT_SECONDS=5
-SPEED_PROBE_SMALL_TIMEOUT_SECONDS=5
-SPEED_PROBE_LARGE_TIMEOUT_SECONDS=8
-SPEED_PROBE_TOTAL_TIMEOUT_SECONDS=26
-SPEED_PROBE_GITHUB_MIN_BYTES_PER_SECOND=262144
-SPEED_PROBE_OSS_SWITCH_RATIO_PERCENT=150
-SPEED_PROBE_STARTED_AT=0
PAYLOAD_NAME="payload.tar.gz"
# The release workflow replaces this token with the immutable tag before publishing both the
# standalone installer and the copies sealed inside the Linux, macOS and universal bundles.
@@ -103,7 +75,6 @@ validate_release_tag() {
download_source_label() {
case "$1" in
- https://*.aliyuncs.com/*) printf '%s\n' "OSS mirror" ;;
https://github.com/*) printf '%s\n' "GitHub" ;;
*) printf '%s\n' "configured mirror" ;;
esac
@@ -160,12 +131,8 @@ if [ -n "$VERSION" ]; then
validate_release_tag "$VERSION"
fi
case "$SOURCE_MODE" in
- auto | oss | github) ;;
- *) fail "PENGUIN_DOWNLOAD_SOURCE must be auto, oss, or github" ;;
-esac
-case "$DOWNLOAD_SPEED_PROBE" in
- 0 | 1) ;;
- *) fail "PENGUIN_DOWNLOAD_SPEED_PROBE must be 0 or 1" ;;
+ auto | github) ;;
+ *) fail "PENGUIN_DOWNLOAD_SOURCE must be auto or github" ;;
esac
RESOLVED_RELEASE_VERSION="$VERSION"
if [ -z "$RESOLVED_RELEASE_VERSION" ] && is_release_tag "$EMBEDDED_RELEASE_VERSION"; then
@@ -296,234 +263,6 @@ sha256_file() {
fi
}
-is_positive_integer() {
- case "$1" in
- '' | *[!0-9]*) return 1 ;;
- 0) return 1 ;;
- *) return 0 ;;
- esac
-}
-
-speed_probe_now_seconds() {
- date +%s 2>/dev/null || printf '%s\n' 0
-}
-
-speed_probe_remaining_seconds() {
- brs_now="$(speed_probe_now_seconds)"
- case "$brs_now:$SPEED_PROBE_STARTED_AT" in
- *[!0-9:]* | :* | *:) printf '%s\n' "$SPEED_PROBE_TOTAL_TIMEOUT_SECONDS"; return 0 ;;
- esac
- brs_elapsed=$((brs_now - SPEED_PROBE_STARTED_AT))
- brs_remaining=$((SPEED_PROBE_TOTAL_TIMEOUT_SECONDS - brs_elapsed))
- if [ "$brs_remaining" -gt 0 ]; then
- printf '%s\n' "$brs_remaining"
- else
- printf '%s\n' 0
- fi
-}
-
-speed_probe_curl_timeout() {
- bct_cap="$1"
- bct_remaining="$(speed_probe_remaining_seconds)"
- [ "$bct_remaining" -gt 0 ] || return 1
- if [ "$bct_remaining" -lt "$bct_cap" ]; then
- printf '%s\n' "$bct_remaining"
- else
- printf '%s\n' "$bct_cap"
- fi
-}
-
-load_release_download_manifest() {
- lrdm_tag="$1"
- lrdm_manifest="$TMP/release-download-manifest.tsv"
- rm -f "$lrdm_manifest"
- if lrdm_timeout="$(speed_probe_curl_timeout "$SPEED_PROBE_MANIFEST_TIMEOUT_SECONDS")" \
- && curl -fsSL --connect-timeout "$lrdm_timeout" --max-time "$lrdm_timeout" "$OSS_RELEASE_ROOT/$lrdm_tag/release-download-manifest.tsv" -o "$lrdm_manifest" 2>/dev/null; then
- :
- elif lrdm_timeout="$(speed_probe_curl_timeout "$SPEED_PROBE_MANIFEST_TIMEOUT_SECONDS")" \
- && curl -fsSL --connect-timeout "$lrdm_timeout" --max-time "$lrdm_timeout" "$GITHUB_RELEASE_ROOT/$lrdm_tag/release-download-manifest.tsv" -o "$lrdm_manifest" 2>/dev/null; then
- :
- else
- return 1
- fi
-
- lrdm_expected_header="$(printf 'penguin-release-download-manifest\t1\t%s' "$lrdm_tag")"
- [ "$(sed -n '1p' "$lrdm_manifest")" = "$lrdm_expected_header" ] || return 1
-
- SPEED_PROBE_SMALL_PROBE="$(awk -F '\t' '$1 == "probe" && $2 == "small" { print $3; exit }' "$lrdm_manifest")"
- SPEED_PROBE_SMALL_SIZE="$(awk -F '\t' '$1 == "probe" && $2 == "small" { print $4; exit }' "$lrdm_manifest")"
- SPEED_PROBE_SMALL_HASH="$(awk -F '\t' '$1 == "probe" && $2 == "small" { print $5; exit }' "$lrdm_manifest")"
- SPEED_PROBE_LARGE_PROBE="$(awk -F '\t' '$1 == "probe" && $2 == "large" { print $3; exit }' "$lrdm_manifest")"
- SPEED_PROBE_LARGE_SIZE="$(awk -F '\t' '$1 == "probe" && $2 == "large" { print $4; exit }' "$lrdm_manifest")"
- SPEED_PROBE_LARGE_HASH="$(awk -F '\t' '$1 == "probe" && $2 == "large" { print $5; exit }' "$lrdm_manifest")"
- # Not part of the decision — an integrity check that this manifest belongs to a release which
- # actually carries this target's bundle, so a mismatched manifest cannot steer the probe.
- SPEED_PROBE_ASSET_SIZE="$(awk -F '\t' -v asset="$ASSET" '$1 == "asset" && $2 == asset { print $3; exit }' "$lrdm_manifest")"
-
- for lrdm_file in "$SPEED_PROBE_SMALL_PROBE" "$SPEED_PROBE_LARGE_PROBE"; do
- case "$lrdm_file" in
- *[!A-Za-z0-9._+-]* | *..* | '') return 1 ;;
- esac
- done
- is_positive_integer "$SPEED_PROBE_SMALL_SIZE" || return 1
- is_positive_integer "$SPEED_PROBE_LARGE_SIZE" || return 1
- is_positive_integer "$SPEED_PROBE_ASSET_SIZE" || return 1
- case "$SPEED_PROBE_SMALL_HASH:$SPEED_PROBE_LARGE_HASH" in
- *[!0-9a-f:]* | *::* | :* | *:) return 1 ;;
- esac
- [ "${#SPEED_PROBE_SMALL_HASH}" -eq 64 ] || return 1
- [ "${#SPEED_PROBE_LARGE_HASH}" -eq 64 ] || return 1
- return 0
-}
-
-probe_download_source() {
- pds_label="$1"
- pds_base="$2"
- pds_file="$3"
- pds_size="$4"
- pds_hash="$5"
- pds_metrics="$6"
- pds_timeout_cap="${7:-$SPEED_PROBE_SMALL_TIMEOUT_SECONDS}"
- pds_body="$TMP/probe-$pds_label-$pds_file"
- pds_write="$pds_metrics.tmp"
- rm -f "$pds_body" "$pds_metrics" "$pds_write"
- pds_timeout="$(speed_probe_curl_timeout "$pds_timeout_cap")" || {
- printf '%s\n' "fail" > "$pds_metrics"
- return 0
- }
- if curl -fsSL --connect-timeout "$pds_timeout" --max-time "$pds_timeout" -H "Accept-Encoding: identity" \
- -w '%{time_starttransfer} %{time_total} %{speed_download}' \
- "$pds_base/$pds_file" -o "$pds_body" > "$pds_write" 2>/dev/null; then
- pds_actual_size="$(wc -c < "$pds_body" | tr -d ' ')"
- pds_actual_hash="$(sha256_file "$pds_body" | tr 'A-F' 'a-f')"
- if [ "$pds_actual_size" = "$pds_size" ] && [ "$pds_actual_hash" = "$pds_hash" ]; then
- read pds_start pds_total pds_speed < "$pds_write" || :
- case "$pds_start:$pds_total" in
- *[!0-9.:]* | :* | *:) printf '%s\n' "fail" > "$pds_metrics" ;;
- *) printf '%s %s %s %s\n' "ok" "$pds_start" "$pds_total" "${pds_speed:-0}" > "$pds_metrics" ;;
- esac
- else
- printf '%s\n' "fail" > "$pds_metrics"
- fi
- else
- printf '%s\n' "fail" > "$pds_metrics"
- fi
-}
-
-run_probe_pair() {
- rpp_file="$1"
- rpp_size="$2"
- rpp_hash="$3"
- OSS_PROBE_METRICS="$TMP/probe-oss-$rpp_file.metrics"
- GITHUB_PROBE_METRICS="$TMP/probe-github-$rpp_file.metrics"
- probe_download_source oss "$OSS_SPEED_PROBE_BASE_URL" "$rpp_file" "$rpp_size" "$rpp_hash" "$OSS_PROBE_METRICS" &
- rpp_oss_pid=$!
- probe_download_source github "$GITHUB_SPEED_PROBE_BASE_URL" "$rpp_file" "$rpp_size" "$rpp_hash" "$GITHUB_PROBE_METRICS" &
- rpp_github_pid=$!
- wait "$rpp_oss_pid" 2>/dev/null || :
- wait "$rpp_github_pid" 2>/dev/null || :
-}
-
-probe_status() {
- ps_file="$1"
- if [ -f "$ps_file" ]; then
- awk 'NR == 1 { print $1 }' "$ps_file"
- else
- printf '%s\n' "fail"
- fi
-}
-
-# Throughput a completed probe measured, in whole bytes per second; 0 when it did not complete,
-# which sorts it below any real measurement in the comparison below.
-probe_bytes_per_second() {
- pbs_metrics="$1"
- if [ ! -f "$pbs_metrics" ]; then
- printf '%s\n' 0
- return 0
- fi
- awk 'NR == 1 && $1 == "ok" && $4 + 0 > 0 { printf "%d\n", $4 + 0; measured = 1 }
- END { if (!measured) print 0 }' "$pbs_metrics"
-}
-
-# The shared rule, in one place: GitHub clears the minimum and wins outright, otherwise the mirror
-# has to beat it by the switch ratio to take over. A POSIX shell has no floating point, so the ratio
-# is applied to the GitHub side as an integer percent — scaling the mirror's side instead could
-# overflow a 32-bit shell on a fast link, while this one is bounded by the minimum itself.
-select_speed_probe_source() {
- ssp_github_speed="$1"
- ssp_oss_speed="$2"
- if [ "$ssp_github_speed" -ge "$SPEED_PROBE_GITHUB_MIN_BYTES_PER_SECOND" ]; then
- printf '%s\n' "github"
- elif [ "$ssp_oss_speed" -gt "$((ssp_github_speed * SPEED_PROBE_OSS_SWITCH_RATIO_PERCENT / 100))" ]; then
- printf '%s\n' "oss"
- else
- printf '%s\n' "github"
- fi
-}
-
-speed_probe_release_sources() {
- brs_tag="$1"
- SPEED_PROBE_BASE_URL=""
- SPEED_PROBE_FALLBACK_BASE_URL=""
- OSS_SPEED_PROBE_BASE_URL="$OSS_RELEASE_ROOT/$brs_tag"
- GITHUB_SPEED_PROBE_BASE_URL="$GITHUB_RELEASE_ROOT/$brs_tag"
- SPEED_PROBE_STARTED_AT="$(speed_probe_now_seconds)"
-
- load_release_download_manifest "$brs_tag" || return 1
- echo "Testing OSS mirror and GitHub download sources ..."
-
- run_probe_pair "$SPEED_PROBE_SMALL_PROBE" "$SPEED_PROBE_SMALL_SIZE" "$SPEED_PROBE_SMALL_HASH"
- brs_oss_small="$(probe_status "$OSS_PROBE_METRICS")"
- brs_github_small="$(probe_status "$GITHUB_PROBE_METRICS")"
-
- if [ "$brs_oss_small" != "ok" ] && [ "$brs_github_small" = "ok" ]; then
- SPEED_PROBE_BASE_URL="$GITHUB_SPEED_PROBE_BASE_URL"
- SPEED_PROBE_FALLBACK_BASE_URL="$OSS_SPEED_PROBE_BASE_URL"
- echo "Selected GitHub (OSS mirror probe unavailable)."
- return 0
- fi
- if [ "$brs_oss_small" = "ok" ] && [ "$brs_github_small" != "ok" ]; then
- SPEED_PROBE_BASE_URL="$OSS_SPEED_PROBE_BASE_URL"
- SPEED_PROBE_FALLBACK_BASE_URL="$GITHUB_SPEED_PROBE_BASE_URL"
- echo "Selected OSS mirror (GitHub probe unavailable)."
- return 0
- fi
- if [ "$brs_oss_small" != "ok" ] && [ "$brs_github_small" != "ok" ]; then
- return 1
- fi
-
- GITHUB_PROBE_METRICS="$TMP/probe-github-$SPEED_PROBE_LARGE_PROBE.metrics"
- probe_download_source github "$GITHUB_SPEED_PROBE_BASE_URL" "$SPEED_PROBE_LARGE_PROBE" "$SPEED_PROBE_LARGE_SIZE" "$SPEED_PROBE_LARGE_HASH" "$GITHUB_PROBE_METRICS" "$SPEED_PROBE_LARGE_TIMEOUT_SECONDS"
- brs_github_speed="$(probe_bytes_per_second "$GITHUB_PROBE_METRICS")"
-
- # OSS is measured only once GitHub has failed the minimum: above it GitHub has already won, and
- # the mirror's bandwidth is not spent on a probe that could not change the answer. Probing runs
- # one source at a time on purpose — two concurrent transfers share the link and would each read
- # as half as fast, which an absolute threshold cannot tolerate.
- brs_oss_speed=0
- if [ "$brs_github_speed" -lt "$SPEED_PROBE_GITHUB_MIN_BYTES_PER_SECOND" ]; then
- OSS_PROBE_METRICS="$TMP/probe-oss-$SPEED_PROBE_LARGE_PROBE.metrics"
- probe_download_source oss "$OSS_SPEED_PROBE_BASE_URL" "$SPEED_PROBE_LARGE_PROBE" "$SPEED_PROBE_LARGE_SIZE" "$SPEED_PROBE_LARGE_HASH" "$OSS_PROBE_METRICS" "$SPEED_PROBE_LARGE_TIMEOUT_SECONDS"
- brs_oss_speed="$(probe_bytes_per_second "$OSS_PROBE_METRICS")"
- fi
-
- brs_choice="$(select_speed_probe_source "$brs_github_speed" "$brs_oss_speed")"
- if [ "$brs_choice" = "github" ]; then
- SPEED_PROBE_BASE_URL="$GITHUB_SPEED_PROBE_BASE_URL"
- SPEED_PROBE_FALLBACK_BASE_URL="$OSS_SPEED_PROBE_BASE_URL"
- if [ "$brs_github_speed" -ge "$SPEED_PROBE_GITHUB_MIN_BYTES_PER_SECOND" ]; then
- echo "Selected GitHub (meets minimum download speed)."
- else
- echo "Selected GitHub (the OSS mirror was not enough faster to be worth switching)."
- fi
- else
- SPEED_PROBE_BASE_URL="$OSS_SPEED_PROBE_BASE_URL"
- SPEED_PROBE_FALLBACK_BASE_URL="$GITHUB_SPEED_PROBE_BASE_URL"
- echo "Selected OSS mirror (clearly faster than GitHub here)."
- fi
- return 0
-}
-
# Downloads the bundle and its checksum as a pair. Transport failures may try a same-version
# fallback; checksum failures are handled afterwards and always abort rather than being hidden
# by a different source.
@@ -539,23 +278,6 @@ download_release_pair() {
return 0
}
-# Resolves the OSS mirror's latest immutable tag. The advertised base URL must exactly match
-# the expected bucket path so metadata cannot redirect downloads to an arbitrary host.
-get_oss_latest_tag() {
- gol_manifest="$1"
- rm -f "$gol_manifest"
- curl -fsSL --connect-timeout 3 --max-time 8 "$OSS_ORIGIN/latest.json" -o "$gol_manifest" 2>/dev/null \
- || return 1
- gol_schema_version="$(sed -n 's/.*"schemaVersion":[[:space:]]*\([0-9][0-9]*\).*/\1/p' "$gol_manifest" | head -n 1)"
- gol_candidate_tag="$(sed -n 's/.*"tag":[[:space:]]*"\([^"]*\)".*/\1/p' "$gol_manifest" | head -n 1)"
- gol_candidate_base="$(sed -n 's/.*"releaseBaseUrl":[[:space:]]*"\([^"]*\)".*/\1/p' "$gol_manifest" | head -n 1)"
- [ "$gol_schema_version" = "1" ] \
- && is_release_tag "$gol_candidate_tag" \
- && [ "$gol_candidate_base" = "$OSS_RELEASE_ROOT/$gol_candidate_tag" ] \
- || return 1
- printf '%s\n' "$gol_candidate_tag"
-}
-
# --- Resolve the program payload. Three entries converge on PAYLOAD_PATH:
# (a) bundled offline: this script sits next to payload.tar.gz in an extracted bundle;
# (b) --archive <file>: a local installer bundle, or a payload/legacy program archive;
@@ -602,42 +324,16 @@ elif [ -n "$ARCHIVE" ]; then
LOCAL_ARCHIVE=1
echo "Using local archive $ARCHIVE_PATH ..."
else
- # (c) Online: explicit forwarder/configured URLs win. Otherwise a stamped Release installer
- # uses its own immutable version: auto prefers OSS and falls back only to the same GitHub
- # tag. An unstamped source-tree installer resolves latest.json first so it also locks one
- # version before downloading assets.
+ # (c) Online: an explicit forwarder/configured URL wins. Otherwise a stamped Release installer
+ # uses its own immutable version; an unstamped source-tree installer falls back to the
+ # release GitHub currently marks latest.
FALLBACK_BASE_URL="$DOWNLOAD_FALLBACK_BASE_URL"
if [ -n "$DOWNLOAD_BASE_URL" ]; then
BASE_URL="$DOWNLOAD_BASE_URL"
- elif [ "$SOURCE_MODE" = "github" ]; then
- if [ -n "$RESOLVED_RELEASE_VERSION" ]; then
- BASE_URL="$GITHUB_RELEASE_ROOT/$RESOLVED_RELEASE_VERSION"
- else
- BASE_URL="$GITHUB_LATEST_BASE"
- fi
+ elif [ -n "$RESOLVED_RELEASE_VERSION" ]; then
+ BASE_URL="$GITHUB_RELEASE_ROOT/$RESOLVED_RELEASE_VERSION"
else
- SELECTED_TAG="$RESOLVED_RELEASE_VERSION"
- if [ -z "$SELECTED_TAG" ]; then
- SELECTED_TAG="$(get_oss_latest_tag "$TMP/latest.json" || :)"
- fi
- if [ -n "$SELECTED_TAG" ]; then
- BASE_URL="$OSS_RELEASE_ROOT/$SELECTED_TAG"
- if [ "$SOURCE_MODE" = "auto" ] && [ -z "$FALLBACK_BASE_URL" ]; then
- FALLBACK_BASE_URL="$GITHUB_RELEASE_ROOT/$SELECTED_TAG"
- fi
- if [ "$SOURCE_MODE" = "auto" ] && [ "$DOWNLOAD_SPEED_PROBE" = "1" ] && [ -z "$DOWNLOAD_BASE_URL" ]; then
- if speed_probe_release_sources "$SELECTED_TAG"; then
- BASE_URL="$SPEED_PROBE_BASE_URL"
- FALLBACK_BASE_URL="$SPEED_PROBE_FALLBACK_BASE_URL"
- else
- echo "Download source test was inconclusive; using OSS with same-version GitHub fallback."
- fi
- fi
- elif [ "$SOURCE_MODE" = "oss" ]; then
- fail "the OSS mirror is unavailable or its release metadata is invalid."
- else
- BASE_URL="$GITHUB_LATEST_BASE"
- fi
+ BASE_URL="$GITHUB_LATEST_BASE"
fi
ARCHIVE_PATH="$TMP/$ASSET"
ARCHIVE_NAME="$ASSET"
diff --git a/packages/desktop/src/menu.ts b/packages/desktop/src/menu.ts
index c62e0091..31fde785 100644
--- a/packages/desktop/src/menu.ts
+++ b/packages/desktop/src/menu.ts
@@ -14,7 +14,9 @@ import { checkForUpdatesManually, updatesAvailableInThisForm } from "./updater.j
export const INSTALL_CLI_MENU_LABEL = "Install 'penguin' Command…";
const CHECK_FOR_UPDATES_MENU_LABEL = "Check for Updates…";
-const REPO_URL = "https://github.com/Prism-Shadow/penguin-harness";
+// Adelie's own repository: this item used to open upstream PenguinHarness's, which is a
+// different product (2026-10-05).
+const REPO_URL = "https://github.com/lmliheng/Adelie";
export function installAppMenu(opts: {
includeCliInstall: boolean;
diff --git a/packages/desktop/src/update-source.ts b/packages/desktop/src/update-source.ts
deleted file mode 100644
index 14c8a29c..00000000
--- a/packages/desktop/src/update-source.ts
+++ /dev/null
@@ -1,364 +0,0 @@
-/**
- * Update-source selection for the desktop auto-updater.
- *
- * This module owns the same source-neutral speed-probe contract the release installers
- * and download page use: fix the target tag first, read that tag's
- * release-download-manifest.tsv, prove both sources can serve the shared probe file, and
- * then compare the large probe using the current installer rule. GitHub is the free
- * source: it wins outright at or above the minimum speed, and the OSS mirror takes over
- * only when GitHub misses that minimum and OSS is clearly faster.
- *
- * The desktop default feed is still the GitHub Releases feed electron-builder publishes.
- * An inconclusive test never blocks updates; the caller keeps that default.
- */
-import { createHash } from "node:crypto";
-
-export const OSS_ORIGIN = "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com";
-export const OSS_RELEASE_ROOT = `${OSS_ORIGIN}/releases`;
-export const GITHUB_RELEASE_ROOT =
- "https://github.com/Prism-Shadow/penguin-harness/releases/download";
-export const OSS_LATEST_JSON_URL = `${OSS_ORIGIN}/latest.json`;
-
-/** Same contract as the release installers (install.sh / install.ps1). */
-export const SPEED_PROBE_MANIFEST_TIMEOUT_SECONDS = 5;
-export const SPEED_PROBE_SMALL_TIMEOUT_SECONDS = 5;
-export const SPEED_PROBE_LARGE_TIMEOUT_SECONDS = 8;
-export const SPEED_PROBE_TOTAL_TIMEOUT_SECONDS = 26;
-export const SPEED_PROBE_GITHUB_MIN_BYTES_PER_SECOND = 262144;
-export const SPEED_PROBE_OSS_SWITCH_RATIO = 1.5;
-
-/** Minimal structural slice of fetch so callers can inject Electron's net.fetch or a fake. */
-export interface ProbeFetchInit {
- headers: Record<string, string>;
- signal: AbortSignal;
-}
-
-export interface ProbeResponse {
- ok: boolean;
- status: number;
- headers: { get(name: string): string | null };
- arrayBuffer(): Promise<ArrayBuffer>;
-}
-
-export type FetchFn = (url: string, init: ProbeFetchInit) => Promise<ProbeResponse>;
-
-export interface ReleaseProbe {
- name: string;
- size: number;
- sha256: string;
-}
-
-export interface ReleaseDownloadManifest {
- smallProbe: ReleaseProbe;
- largeProbe: ReleaseProbe;
- /** Integrity check that the manifest belongs to a release carrying this update asset. */
- assetSize: number;
-}
-
-/** The update asset electron-updater replaces on this platform (dmg is manual-only). */
-export function desktopUpdateAssetName(platform: NodeJS.Platform, arch: string): string | null {
- if (platform === "darwin") {
- return arch === "arm64" || arch === "x64" ? `penguin-desktop-darwin-${arch}.zip` : null;
- }
- if (platform === "win32") {
- return arch === "x64" ? "penguin-desktop-win32-x64.exe" : null;
- }
- if (platform === "linux") {
- return arch === "x64" ? "penguin-desktop-linux-x86_64.AppImage" : null;
- }
- return null;
-}
-
-/** Generic-provider feed base for the OSS mirror's immutable tag directory. */
-export function ossFeedUrl(tag: string): string {
- return `${OSS_RELEASE_ROOT}/${tag}/`;
-}
-
-/** Generic-provider feed base for the same tag on GitHub Releases. */
-export function githubFeedUrl(tag: string): string {
- return `${GITHUB_RELEASE_ROOT}/${tag}/`;
-}
-
-export type FeedLabel = "OSS mirror" | "GitHub" | "configured mirror";
-
-export function feedLabel(url: string): FeedLabel {
- try {
- const host = new URL(url).host;
- if (host.endsWith(".aliyuncs.com")) return "OSS mirror";
- if (host === "github.com") return "GitHub";
- } catch {
- // fall through: an unparseable feed keeps the neutral label
- }
- return "configured mirror";
-}
-
-/**
- * Resolves the OSS mirror's latest immutable tag, validated exactly like the installers
- * and the download page validate latest.json: schema 1, a safe v-tag, and a
- * releaseBaseUrl that names the expected bucket path (metadata cannot redirect the feed
- * to an arbitrary host).
- */
-export async function resolveOssLatestTag(fetchFn: FetchFn): Promise<string | null> {
- let response: ProbeResponse;
- try {
- response = await fetchFn(OSS_LATEST_JSON_URL, {
- headers: {},
- signal: AbortSignal.timeout(8_000),
- });
- } catch {
- return null;
- }
- if (!response.ok) return null;
- try {
- const body: unknown = JSON.parse(new TextDecoder().decode(await response.arrayBuffer()));
- if (typeof body !== "object" || body === null) return null;
- const { schemaVersion, tag, releaseBaseUrl } = body as {
- schemaVersion?: unknown;
- tag?: unknown;
- releaseBaseUrl?: unknown;
- };
- if (schemaVersion !== 1 || typeof tag !== "string") return null;
- if (!/^v[0-9A-Za-z][0-9A-Za-z._-]*$/.test(tag)) return null;
- if (releaseBaseUrl !== `${OSS_RELEASE_ROOT}/${tag}`) return null;
- return tag;
- } catch {
- return null;
- }
-}
-
-/**
- * Fetches and strictly validates the release-download-manifest.tsv for the fixed tag
- * (OSS first, then GitHub, each capped by the shared budget). Only the probe rows and the
- * current platform's desktop_asset size are needed — the updater still trusts Electron's
- * latest*.yml feeds for the update itself.
- */
-export async function loadReleaseDownloadManifest(opts: {
- fetchFn: FetchFn;
- tag: string;
- assetName: string;
- deadlineMs: number;
-}): Promise<ReleaseDownloadManifest | null> {
- const { fetchFn, tag, assetName, deadlineMs } = opts;
- const timeoutMs = remainingTimeout(deadlineMs, SPEED_PROBE_MANIFEST_TIMEOUT_SECONDS);
- if (timeoutMs <= 0) return null;
-
- let text: string | null = null;
- for (const base of [`${OSS_RELEASE_ROOT}/${tag}`, `${GITHUB_RELEASE_ROOT}/${tag}`]) {
- try {
- const response = await fetchFn(`${base}/release-download-manifest.tsv`, {
- headers: {},
- signal: AbortSignal.timeout(timeoutMs),
- });
- if (response.ok) text = new TextDecoder().decode(await response.arrayBuffer());
- } catch {
- // try the other source
- }
- if (text !== null) break;
- }
- if (text === null) return null;
-
- const lines = text.split(/\r?\n/);
- if (lines.at(-1) === "") lines.pop();
- if (lines.length < 4) return null;
- if (lines[0] !== `penguin-release-download-manifest\t1\t${tag}`) return null;
-
- let smallProbe: ReleaseProbe | null = null;
- let largeProbe: ReleaseProbe | null = null;
- let assetSize: number | null = null;
- for (const line of lines.slice(1)) {
- const parts = line.split("\t");
- if (parts[0] === "probe" && parts.length === 5) {
- const probe = parseProbeRow(parts[1]!, parts[2]!, parts[3]!, parts[4]!);
- if (probe === null) return null;
- if (parts[1] === "small") smallProbe = probe;
- if (parts[1] === "large") largeProbe = probe;
- } else if (parts[0] === "desktop_asset" && parts.length === 4 && parts[1] === assetName) {
- const size = parsePositiveSize(parts[2]!);
- if (size === null) return null;
- assetSize = size;
- }
- }
- if (smallProbe === null || largeProbe === null || assetSize === null) return null;
- return { smallProbe, largeProbe, assetSize };
-}
-
-function parseProbeRow(
- label: string,
- name: string,
- size: string,
- hash: string,
-): ReleaseProbe | null {
- if (label !== "small" && label !== "large") return null;
- if (!/^[A-Za-z0-9._+-]+$/.test(name) || name.includes("..")) return null;
- const parsedSize = parsePositiveSize(size);
- if (parsedSize === null) return null;
- if (!/^[0-9a-f]{64}$/.test(hash)) return null;
- return { name, size: parsedSize, sha256: hash };
-}
-
-function parsePositiveSize(raw: string): number | null {
- if (!/^[1-9][0-9]*$/.test(raw)) return null;
- const value = Number(raw);
- return Number.isSafeInteger(value) ? value : null;
-}
-
-export interface ProbeResult {
- ok: boolean;
- /** Whole-body throughput in bytes/second; only computed when wantSpeed is set. */
- speedBps?: number;
-}
-
-function probeSpeed(result: ProbeResult): number {
- return result.ok && result.speedBps !== undefined ? result.speedBps : 0;
-}
-
-export function selectMeasuredSource(githubBps: number, ossBps: number): "github" | "oss" {
- if (githubBps >= SPEED_PROBE_GITHUB_MIN_BYTES_PER_SECOND) return "github";
- return ossBps > githubBps * SPEED_PROBE_OSS_SWITCH_RATIO ? "oss" : "github";
-}
-
-/**
- * Downloads one probe within the shared budget. Success requires a 2xx status, no
- * non-identity content encoding, an exact byte count and a matching sha256 — the same
- * success criteria the installers use.
- */
-export async function probeSource(opts: {
- fetchFn: FetchFn;
- base: string;
- probe: ReleaseProbe;
- deadlineMs: number;
- maxTimeoutSeconds: number;
- wantSpeed: boolean;
-}): Promise<ProbeResult> {
- const timeoutMs = remainingTimeout(opts.deadlineMs, opts.maxTimeoutSeconds);
- if (timeoutMs <= 0) return { ok: false };
- const startedAt = Date.now();
- try {
- const response = await opts.fetchFn(`${opts.base}/${opts.probe.name}`, {
- headers: { "accept-encoding": "identity" },
- signal: AbortSignal.timeout(timeoutMs),
- });
- if (!response.ok) return { ok: false };
- const encoding = response.headers.get("content-encoding");
- if (encoding !== null && encoding.toLowerCase() !== "identity") return { ok: false };
- const body = new Uint8Array(await response.arrayBuffer());
- if (body.byteLength !== opts.probe.size) return { ok: false };
- if (createHash("sha256").update(body).digest("hex") !== opts.probe.sha256) {
- return { ok: false };
- }
- if (!opts.wantSpeed) return { ok: true };
- const seconds = Math.max((Date.now() - startedAt) / 1000, 0.001);
- return { ok: true, speedBps: Math.floor(body.byteLength / seconds) };
- } catch {
- return { ok: false };
- }
-}
-
-function remainingTimeout(deadlineMs: number, maxSeconds: number): number {
- const remaining = deadlineMs - Date.now();
- if (remaining <= 0) return 0;
- return Math.min(maxSeconds * 1000, remaining);
-}
-
-export type FeedDecision =
- /** Keep electron-updater's default GitHub Releases feed (no setFeedURL). */
- | { kind: "keep-github"; reason: string }
- /** Pin generic feeds: primary now, same-tag fallback on a failed check. */
- | { kind: "pinned"; primaryUrl: string; fallbackUrl: string };
-
-export interface SelectAutoUpdateFeedOptions {
- fetchFn: FetchFn;
- platform: NodeJS.Platform;
- arch: string;
- log: (line: string) => void;
- /** Total probe budget as a duration in ms; tests can stretch or exhaust it. */
- budgetMs?: number;
-}
-
-/**
- * The auto-mode selection tree. It mirrors the installers' current rule while keeping
- * the desktop's default GitHub feed on inconclusive input.
- */
-export async function selectAutoUpdateFeed(
- opts: SelectAutoUpdateFeedOptions,
-): Promise<FeedDecision> {
- const { fetchFn, platform, arch, log } = opts;
- const deadlineMs = Date.now() + (opts.budgetMs ?? SPEED_PROBE_TOTAL_TIMEOUT_SECONDS * 1000);
-
- const inconclusive = (): FeedDecision => {
- log("Download source test was inconclusive; keeping GitHub update feed.");
- return { kind: "keep-github", reason: "inconclusive" };
- };
-
- const assetName = desktopUpdateAssetName(platform, arch);
- if (assetName === null) return inconclusive();
-
- const tag = await resolveOssLatestTag(fetchFn);
- if (tag === null) return inconclusive();
-
- const manifest = await loadReleaseDownloadManifest({ fetchFn, tag, assetName, deadlineMs });
- if (manifest === null) return inconclusive();
-
- log("Testing OSS mirror and GitHub download sources ...");
- const ossBase = `${OSS_RELEASE_ROOT}/${tag}`;
- const githubBase = `${GITHUB_RELEASE_ROOT}/${tag}`;
-
- const [ossSmall, githubSmall] = await Promise.all([
- probeSource({
- fetchFn,
- base: ossBase,
- probe: manifest.smallProbe,
- deadlineMs,
- maxTimeoutSeconds: SPEED_PROBE_SMALL_TIMEOUT_SECONDS,
- wantSpeed: false,
- }),
- probeSource({
- fetchFn,
- base: githubBase,
- probe: manifest.smallProbe,
- deadlineMs,
- maxTimeoutSeconds: SPEED_PROBE_SMALL_TIMEOUT_SECONDS,
- wantSpeed: false,
- }),
- ]);
-
- if (!ossSmall.ok && githubSmall.ok) {
- log("Selected GitHub (OSS mirror probe unavailable).");
- return { kind: "pinned", primaryUrl: githubFeedUrl(tag), fallbackUrl: ossFeedUrl(tag) };
- }
- if (ossSmall.ok && !githubSmall.ok) {
- log("Selected OSS mirror (GitHub probe unavailable).");
- return { kind: "pinned", primaryUrl: ossFeedUrl(tag), fallbackUrl: githubFeedUrl(tag) };
- }
- if (!ossSmall.ok && !githubSmall.ok) return inconclusive();
-
- const githubLarge = await probeSource({
- fetchFn,
- base: githubBase,
- probe: manifest.largeProbe,
- deadlineMs,
- maxTimeoutSeconds: SPEED_PROBE_LARGE_TIMEOUT_SECONDS,
- wantSpeed: true,
- });
- const githubSpeed = probeSpeed(githubLarge);
- if (githubSpeed >= SPEED_PROBE_GITHUB_MIN_BYTES_PER_SECOND) {
- log("Selected GitHub (meets minimum download speed).");
- return { kind: "pinned", primaryUrl: githubFeedUrl(tag), fallbackUrl: ossFeedUrl(tag) };
- }
-
- const ossLarge = await probeSource({
- fetchFn,
- base: ossBase,
- probe: manifest.largeProbe,
- deadlineMs,
- maxTimeoutSeconds: SPEED_PROBE_LARGE_TIMEOUT_SECONDS,
- wantSpeed: true,
- });
- const ossSpeed = probeSpeed(ossLarge);
- if (selectMeasuredSource(githubSpeed, ossSpeed) === "oss") {
- log("Selected OSS mirror (clearly faster than GitHub here).");
- return { kind: "pinned", primaryUrl: ossFeedUrl(tag), fallbackUrl: githubFeedUrl(tag) };
- }
- log("Selected GitHub (the OSS mirror was not enough faster to be worth switching).");
- return { kind: "pinned", primaryUrl: githubFeedUrl(tag), fallbackUrl: ossFeedUrl(tag) };
-}
diff --git a/packages/desktop/src/update-support.ts b/packages/desktop/src/update-support.ts
index d90e33fc..4367493d 100644
--- a/packages/desktop/src/update-support.ts
+++ b/packages/desktop/src/update-support.ts
@@ -49,45 +49,8 @@ export function feedUrlOverride(env: NodeJS.ProcessEnv): string | null {
}
}
-export type UpdateSource = "auto" | "oss" | "github";
-
-/**
- * Desktop update source switches. The names are deliberately separate from the installer's
- * PENGUIN_DOWNLOAD_* variables so a CLI-install setting never leaks into the app's
- * background updater.
- */
-export interface UpdateSourceConfig {
- source: UpdateSource;
- probe: boolean;
- /** PENGUIN_UPDATE_SOURCE was set but not one of auto | oss | github. */
- invalidSource: boolean;
- /** PENGUIN_UPDATE_SPEED_PROBE was set but not 0 or 1. */
- invalidProbe: boolean;
-}
-
-export function updateSourceConfig(env: NodeJS.ProcessEnv): UpdateSourceConfig {
- const rawSource = env.PENGUIN_UPDATE_SOURCE?.trim() ?? "";
- let source: UpdateSource = "auto";
- let invalidSource = false;
- if (rawSource !== "") {
- if (rawSource === "auto" || rawSource === "oss" || rawSource === "github") {
- source = rawSource;
- } else {
- invalidSource = true;
- }
- }
-
- const rawProbe = env.PENGUIN_UPDATE_SPEED_PROBE?.trim() ?? "";
- let probe = true;
- let invalidProbe = false;
- if (rawProbe !== "") {
- if (rawProbe === "0") {
- probe = false;
- } else if (rawProbe === "1") {
- probe = true;
- } else {
- invalidProbe = true;
- }
- }
- return { source, probe, invalidSource, invalidProbe };
-}
+// Adelie fork note (2026-10-05): PENGUIN_UPDATE_SOURCE and PENGUIN_UPDATE_SPEED_PROBE lived
+// here. They chose between two feeds — upstream's GitHub Releases and an Alibaba Cloud OSS
+// mirror of the same assets — and Adelie has exactly one feed, its own GitHub Releases, so
+// both knobs are gone rather than left accepting values that no longer mean anything. A
+// deployment that runs a mirror of its own points PENGUIN_UPDATE_FEED_URL at it.
diff --git a/packages/desktop/src/updater.ts b/packages/desktop/src/updater.ts
index a13813fd..ac6c92dd 100644
--- a/packages/desktop/src/updater.ts
+++ b/packages/desktop/src/updater.ts
@@ -17,12 +17,18 @@
* check or download is manual too, but its outcomes render in the modal that asked, not
* in dialogs: the native restart prompt follows only a download the native dialog started.
*
+ * Adelie fork note (2026-10-05): this build publishes to one feed — its own GitHub Releases
+ * (`lmliheng/Adelie`). Upstream's second feed, an Alibaba Cloud OSS mirror of the same
+ * assets, is gone here, and with it the speed probe that chose between the two sources: a
+ * mirror belongs to the project that runs it, and this one has none. What remains is
+ * `PENGUIN_UPDATE_FEED_URL` for a deployment that runs a mirror of its own.
+ *
* Release builds use Developer ID signing on macOS and Authenticode signing on Windows;
* unsigned dry-run artifacts can still find updates, but platform trust and release
* gates only apply to signed release builds. Linux AppImage continues without
* code-signing for now.
*/
-import { app, dialog, net, shell } from "electron";
+import { app, dialog, shell } from "electron";
import type { BrowserWindow } from "electron";
import electronUpdater from "electron-updater";
import type {
@@ -31,14 +37,7 @@ import type {
} from "@prismshadow/penguin-server/api";
import { resolveProfile } from "./app-identity.js";
import { logLine } from "./desktop-log.js";
-import { feedUrlOverride, updateSourceConfig, updateSupport } from "./update-support.js";
-import {
- feedLabel,
- ossFeedUrl,
- resolveOssLatestTag,
- selectAutoUpdateFeed,
-} from "./update-source.js";
-import type { FetchFn } from "./update-source.js";
+import { feedUrlOverride, updateSupport } from "./update-support.js";
import { initialUpdateStatus, nextUpdateStatus } from "./updater-status.js";
import type { UpdaterEvent } from "./updater-status.js";
@@ -49,11 +48,14 @@ const FIRST_CHECK_DELAY_MS = 20_000;
/** Subsequent automatic checks. */
const CHECK_INTERVAL_MS = 6 * 60 * 60 * 1000;
-const RELEASES_URL = "https://github.com/Prism-Shadow/penguin-harness/releases";
+// Adelie's own releases, not upstream's (2026-10-05): the two projects reuse version
+// numbers, so a feed left pointing at PenguinHarness would offer — and install — a
+// PenguinHarness build over this app.
+const RELEASES_URL = "https://github.com/lmliheng/Adelie/releases";
const GITHUB_FEED = {
provider: "github" as const,
- owner: "Prism-Shadow",
- repo: "penguin-harness",
+ owner: "lmliheng",
+ repo: "Adelie",
};
function log(line: string): void {
@@ -69,102 +71,19 @@ let downloadInFlight = false;
/** The running download was started from the native dialog: its outcomes get native dialogs too. */
let nativeDownload = false;
-type FeedState =
- { phase: "pending" } | { phase: "unavailable" } | { phase: "ready"; fallbackUrl: string | null };
-let feedState: FeedState = { phase: "pending" };
-type FeedRefreshMode = "static" | "github" | "oss" | "auto-probe";
-let feedRefreshMode: FeedRefreshMode = "github";
-let feedRefreshInFlight: Promise<void> | null = null;
-/** The generic URL electron-updater currently points at (null = default GitHub feed). */
-let activeGenericUrl: string | null = null;
-/** The other pinned feed: retrying switches to it, and the pair swaps roles. */
-let otherGenericUrl: string | null = null;
-
-/** fetch for update-source.ts: Electron's proxy-aware network stack, same as updater downloads. */
-const fetchForUpdateSource: FetchFn = (url, init) =>
- net.fetch(url, { headers: init.headers, signal: init.signal });
-
-function setGenericFeed(url: string, fallbackUrl: string | null): void {
- activeGenericUrl = url;
- otherGenericUrl = fallbackUrl;
- feedState = { phase: "ready", fallbackUrl };
- autoUpdater.setFeedURL({ provider: "generic", url });
-}
-
-function setGitHubFeed(): void {
- activeGenericUrl = null;
- otherGenericUrl = null;
- feedState = { phase: "ready", fallbackUrl: null };
- autoUpdater.setFeedURL(GITHUB_FEED);
-}
-
-function switchToFallbackFeed(reason: string): boolean {
- if (downloadedVersion !== null || feedState.phase !== "ready" || feedState.fallbackUrl === null) {
- return false;
- }
- const previous = activeGenericUrl;
- const next = feedState.fallbackUrl;
- activeGenericUrl = next;
- otherGenericUrl = previous;
- feedState = { phase: "ready", fallbackUrl: null };
- autoUpdater.setFeedURL({ provider: "generic", url: next });
- log(`${feedLabel(previous ?? next)} update ${reason}; retrying ${feedLabel(next)}`);
- return true;
-}
-
-function refreshUpdateFeed(): Promise<void> {
- if (feedRefreshInFlight !== null) return feedRefreshInFlight;
- feedRefreshInFlight = refreshUpdateFeedOnce().finally(() => {
- feedRefreshInFlight = null;
- });
- return feedRefreshInFlight;
-}
-
-async function refreshUpdateFeedOnce(): Promise<void> {
- if (feedRefreshMode === "static") return;
- if (feedRefreshMode === "github") {
- setGitHubFeed();
- return;
- }
+/**
+ * The feed this build updates from: Adelie's own GitHub Releases, or the generic feed an
+ * explicit PENGUIN_UPDATE_FEED_URL names (a deployment's own mirror). One source, fixed at
+ * init — there is no selection step to wait on, and no second feed to retry against.
+ */
+let overrideFeedUrl: string | null = null;
- feedState = { phase: "pending" };
- if (feedRefreshMode === "oss") {
- try {
- const tag = await resolveOssLatestTag(fetchForUpdateSource);
- if (tag === null) {
- feedState = { phase: "unavailable" };
- log(
- "PENGUIN_UPDATE_SOURCE=oss but the OSS mirror latest.json is unavailable or invalid; updates are disabled for this check.",
- );
- return;
- }
- setGenericFeed(ossFeedUrl(tag), null);
- log(`selected OSS update feed (${tag})`);
- } catch {
- feedState = { phase: "unavailable" };
- log("OSS update source selection failed; updates are disabled for this check.");
- }
+function applyFeed(): void {
+ if (overrideFeedUrl === null) {
+ autoUpdater.setFeedURL(GITHUB_FEED);
return;
}
-
- try {
- const decision = await selectAutoUpdateFeed({
- fetchFn: fetchForUpdateSource,
- platform: process.platform,
- arch: process.arch,
- log,
- });
- if (decision.kind === "pinned") {
- setGenericFeed(decision.primaryUrl, decision.fallbackUrl);
- log(`selected ${feedLabel(decision.primaryUrl)} update feed`);
- } else {
- setGitHubFeed();
- log("selected GitHub update feed");
- }
- } catch (err) {
- setGitHubFeed();
- log(`update source selection failed: ${(err as Error).message}; keeping GitHub update feed.`);
- }
+ autoUpdater.setFeedURL({ provider: "generic", url: overrideFeedUrl });
}
function scheduleChecks(): void {
@@ -263,10 +182,6 @@ export function handleUpdaterCommand(action: DesktopUpdaterCommandMessage["actio
reannounceStatus();
return;
}
- if (feedState.phase === "pending") {
- reannounceStatus();
- return;
- }
void check();
return;
}
@@ -308,8 +223,7 @@ export function initUpdater(getWindow: () => BrowserWindow | null): void {
}
// Explicit download, explicit install: the user decides both when to fetch and when to
- // restart. Owning the download call here (rather than autoDownload) is also what lets a
- // failed package download retry the same tag on the fallback feed.
+ // restart, and each step's failure is reported where that step was asked for.
autoUpdater.autoDownload = false;
autoUpdater.autoInstallOnAppQuit = false;
autoUpdater.logger = null;
@@ -359,56 +273,13 @@ export function initUpdater(getWindow: () => BrowserWindow | null): void {
if (downloadInFlight) {
return;
}
- if (switchToFallbackFeed("feed unavailable")) {
- void autoUpdater.checkForUpdates().catch((retryErr: Error) => {
- log(`check failed: ${retryErr.message}`);
- });
- return;
- }
reportUpdaterError(err, "check");
});
- const override = feedUrlOverride(process.env);
- if (override) {
- feedRefreshMode = "static";
- setGenericFeed(override, null);
- log(`feed override: ${override}`);
- scheduleChecks();
- return;
- }
-
- const config = updateSourceConfig(process.env);
- if (config.invalidSource) {
- log("PENGUIN_UPDATE_SOURCE has an unsupported value; treated as auto.");
- }
- if (config.invalidProbe) {
- log("PENGUIN_UPDATE_SPEED_PROBE has an unsupported value; treated as 1.");
- }
-
- if (config.source === "github") {
- feedRefreshMode = "github";
- setGitHubFeed();
- log("selected GitHub update feed");
- scheduleChecks();
- return;
- }
-
- if (config.source === "oss") {
- feedRefreshMode = "oss";
- void refreshUpdateFeed().finally(scheduleChecks);
- return;
- }
-
- if (!config.probe) {
- feedRefreshMode = "github";
- setGitHubFeed();
- log("selected GitHub update feed");
- scheduleChecks();
- return;
- }
-
- feedRefreshMode = "auto-probe";
- void refreshUpdateFeed().finally(scheduleChecks);
+ overrideFeedUrl = feedUrlOverride(process.env);
+ applyFeed();
+ if (overrideFeedUrl !== null) log(`feed override: ${overrideFeedUrl}`);
+ scheduleChecks();
}
async function check(): Promise<void> {
@@ -424,20 +295,6 @@ async function check(): Promise<void> {
) {
return;
}
- await refreshUpdateFeed();
- if (feedState.phase !== "ready") {
- const message =
- feedState.phase === "pending"
- ? "Update source selection is still in progress."
- : "The configured update source is unavailable.";
- log(
- `check skipped (${feedState.phase === "pending" ? "update source selection pending" : "update source unavailable"})`,
- );
- emitStatus({ kind: "error", message });
- return;
- }
- // Each fresh cycle gets its one-shot switch back (the retry path bypasses check()).
- feedState = { phase: "ready", fallbackUrl: otherGenericUrl };
try {
await autoUpdater.checkForUpdates();
} catch (err) {
@@ -465,40 +322,22 @@ async function startDownload(origin: "native" | "web"): Promise<void> {
}
nativeDownload = origin === "native";
emitStatus({ kind: "download-started", version: status.version });
- await downloadUpdateWithFallback();
+ await downloadUpdate();
}
/**
- * One download of the offered release, retried once on the other pinned feed when the
- * package fetch fails there: the retry re-checks on the fallback feed (whose `checking`
- * and same-version `available` the status fold suppresses under the running download)
- * and downloads again if it offers the release.
+ * One download of the offered release. There is no second feed to retry it on, so a failed
+ * package fetch is reported like any other download failure — where the download was asked
+ * for (the page's modal, or the native dialog a menu-driven check ended in).
*/
-async function downloadUpdateWithFallback(): Promise<void> {
+async function downloadUpdate(): Promise<void> {
if (downloadedVersion !== null || downloadInFlight) return;
downloadInFlight = true;
try {
await autoUpdater.downloadUpdate();
} catch (err) {
- const error = err as Error;
if (downloadedVersion !== null) return;
- if (switchToFallbackFeed("download failed")) {
- try {
- const retryResult = await autoUpdater.checkForUpdates();
- if (retryResult !== null && retryResult.isUpdateAvailable) {
- await autoUpdater.downloadUpdate();
- return;
- }
- const message = "The fallback update source did not offer a downloadable update.";
- log(message);
- emitStatus({ kind: "error", message });
- nativeDownload = false;
- } catch (retryErr) {
- reportUpdaterError(retryErr as Error, "download");
- }
- return;
- }
- reportUpdaterError(error, "download");
+ reportUpdaterError(err as Error, "download");
} finally {
downloadInFlight = false;
}
@@ -526,15 +365,6 @@ export async function checkForUpdatesManually(): Promise<void> {
await promptRestart(downloadedVersion, null);
return;
}
- if (feedState.phase === "pending") {
- await dialog.showMessageBox({
- type: "info",
- message: "Updates are unavailable.",
- detail: "Update source selection is still in progress; try again in a moment.",
- buttons: ["OK"],
- });
- return;
- }
if (status.state === "downloading") {
// check() would decline anyway; a manual action still answers (the silence rule).
await dialog.showMessageBox({
@@ -551,15 +381,6 @@ export async function checkForUpdatesManually(): Promise<void> {
}
manualCheckInFlight = true;
await check();
- if (manualCheckInFlight && feedState.phase === "unavailable") {
- manualCheckInFlight = false;
- await dialog.showMessageBox({
- type: "error",
- message: "Could not check for updates.",
- detail: "The configured update source is unavailable. See the updater log for details.",
- buttons: ["OK"],
- });
- }
}
/**
diff --git a/packages/desktop/test/update-source.test.ts b/packages/desktop/test/update-source.test.ts
deleted file mode 100644
index fa4254cc..00000000
--- a/packages/desktop/test/update-source.test.ts
+++ /dev/null
@@ -1,612 +0,0 @@
-/**
- * Tests for the desktop update-source selection (no Electron runtime). A fake fetch stands
- * in for the release endpoints so the whole probe contract — latest.json validation,
- * manifest parsing, probe verification, the 256 KiB/s minimum-speed gate, the 1.5x OSS
- * switch threshold and the inconclusive fallbacks — runs against controlled responses,
- * mirroring the decision vectors the release installers test.
- */
-import { createHash } from "node:crypto";
-import { describe, expect, it, vi } from "vitest";
-import {
- GITHUB_RELEASE_ROOT,
- OSS_LATEST_JSON_URL,
- OSS_RELEASE_ROOT,
- desktopUpdateAssetName,
- feedLabel,
- githubFeedUrl,
- loadReleaseDownloadManifest,
- ossFeedUrl,
- probeSource,
- resolveOssLatestTag,
- selectAutoUpdateFeed,
- selectMeasuredSource,
- type FetchFn,
- type ProbeResponse,
-} from "../src/update-source.js";
-
-const TAG = "v0.2.2";
-const OSS_BASE = `${OSS_RELEASE_ROOT}/${TAG}`;
-const GH_BASE = `${GITHUB_RELEASE_ROOT}/${TAG}`;
-const WIN_ASSET = "penguin-desktop-win32-x64.exe";
-const MAC_ASSET = "penguin-desktop-darwin-arm64.zip";
-
-function probeBody(size: number): Uint8Array {
- return new Uint8Array(size).fill(0x2a);
-}
-
-function sha256Hex(bytes: Uint8Array): string {
- return createHash("sha256").update(bytes).digest("hex");
-}
-
-const SMALL = {
- name: "probe-64k.bin",
- size: 64 * 1024,
- sha256: sha256Hex(probeBody(64 * 1024)),
-};
-const LARGE = {
- name: "probe-1m.bin",
- size: 1024 * 1024,
- sha256: sha256Hex(probeBody(1024 * 1024)),
-};
-const LARGE_BYTES = probeBody(1024 * 1024);
-
-function manifestText(assetName: string, assetSize: number): string {
- return [
- `penguin-release-download-manifest\t1\t${TAG}`,
- `probe\tsmall\t${SMALL.name}\t${SMALL.size}\t${SMALL.sha256}`,
- `probe\tlarge\t${LARGE.name}\t${LARGE.size}\t${LARGE.sha256}`,
- `desktop_asset\t${assetName}\t${assetSize}\t${"0".repeat(64)}`,
- "",
- ].join("\n");
-}
-
-interface FakeRoute {
- status?: number;
- body?: Uint8Array | string;
- /** Advances the mocked clock without slowing the test process. */
- advanceMs?: number;
- networkError?: boolean;
- encoding?: string | null;
-}
-
-interface FakeCall {
- url: string;
- acceptEncoding: string | undefined;
-}
-
-interface FakeClock {
- now: number;
-}
-
-function fakeResponse(status: number, body: Uint8Array, encoding: string | null): ProbeResponse {
- return {
- ok: status >= 200 && status < 300,
- status,
- headers: { get: (name) => (name === "content-encoding" ? encoding : null) },
- arrayBuffer: async () => body.slice().buffer,
- };
-}
-
-function fakeFetch(
- routes: Record<string, FakeRoute>,
- calls: FakeCall[] = [],
- clock?: FakeClock,
-): FetchFn {
- return async (url, init) => {
- calls.push({ url, acceptEncoding: init.headers["accept-encoding"] });
- const route = routes[url];
- if (route === undefined) return fakeResponse(404, new Uint8Array(0), null);
- if (route.advanceMs !== undefined && route.advanceMs > 0 && clock) clock.now += route.advanceMs;
- if (route.networkError) throw new Error("simulated network failure");
- const body =
- typeof route.body === "string"
- ? new TextEncoder().encode(route.body)
- : (route.body ?? new Uint8Array(0));
- return fakeResponse(route.status ?? 200, body, route.encoding ?? null);
- };
-}
-
-/** latest.json + both manifests + both small probes + GitHub large probe all healthy. */
-function happyRoutes(
- opts: {
- assetName?: string;
- assetSize?: number;
- githubLargeMs?: number;
- ossLargeMs?: number;
- largeFail?: boolean;
- } = {},
-): Record<string, FakeRoute> {
- const assetName = opts.assetName ?? WIN_ASSET;
- return {
- [OSS_LATEST_JSON_URL]: {
- body: JSON.stringify({
- schemaVersion: 1,
- tag: TAG,
- releaseBaseUrl: `${OSS_RELEASE_ROOT}/${TAG}`,
- }),
- },
- [`${OSS_BASE}/release-download-manifest.tsv`]: {
- body: manifestText(assetName, opts.assetSize ?? 120 * 1024 * 1024),
- },
- [`${OSS_BASE}/${SMALL.name}`]: { body: probeBody(SMALL.size) },
- [`${GH_BASE}/${SMALL.name}`]: { body: probeBody(SMALL.size) },
- [`${OSS_BASE}/${LARGE.name}`]: {
- body: LARGE_BYTES,
- advanceMs: opts.ossLargeMs ?? 1000,
- },
- [`${GH_BASE}/${LARGE.name}`]: opts.largeFail
- ? { status: 500 }
- : { body: LARGE_BYTES, advanceMs: opts.githubLargeMs ?? 1000 },
- };
-}
-
-function runSelection(
- routes: Record<string, FakeRoute>,
- calls: FakeCall[] = [],
- platform: NodeJS.Platform = "win32",
- arch = "x64",
- budgetMs = 60_000,
-): { decision: ReturnType<typeof selectAutoUpdateFeed>; logs: string[] } {
- const logs: string[] = [];
- const clock = { now: 1_000_000 };
- const now = vi.spyOn(Date, "now").mockImplementation(() => clock.now);
- const decision = selectAutoUpdateFeed({
- fetchFn: fakeFetch(routes, calls, clock),
- platform,
- arch,
- log: (line) => logs.push(line),
- budgetMs,
- }).finally(() => {
- now.mockRestore();
- });
- return {
- decision,
- logs,
- };
-}
-
-describe("desktopUpdateAssetName", () => {
- it("maps the update asset per platform and arch (zip for macOS, never the dmg)", () => {
- expect(desktopUpdateAssetName("darwin", "arm64")).toBe("penguin-desktop-darwin-arm64.zip");
- expect(desktopUpdateAssetName("darwin", "x64")).toBe("penguin-desktop-darwin-x64.zip");
- expect(desktopUpdateAssetName("win32", "x64")).toBe(WIN_ASSET);
- expect(desktopUpdateAssetName("linux", "x64")).toBe("penguin-desktop-linux-x86_64.AppImage");
- });
-
- it("yields nothing for forms the updater never downloads", () => {
- expect(desktopUpdateAssetName("win32", "arm64")).toBeNull();
- expect(desktopUpdateAssetName("linux", "arm64")).toBeNull();
- expect(desktopUpdateAssetName("darwin", "ia32")).toBeNull();
- });
-});
-
-describe("feedLabel", () => {
- it("names the known sources and stays neutral for anything else", () => {
- expect(feedLabel("https://x.oss-cn-beijing.aliyuncs.com/releases/v1/")).toBe("OSS mirror");
- expect(feedLabel("https://github.com/Prism-Shadow/penguin-harness/releases/download/v1/")).toBe(
- "GitHub",
- );
- expect(feedLabel("https://mirror.example.com/updates/")).toBe("configured mirror");
- expect(feedLabel("not a url")).toBe("configured mirror");
- });
-});
-
-describe("resolveOssLatestTag", () => {
- it("returns the tag of a valid latest.json", async () => {
- const fetchFn = fakeFetch({
- [OSS_LATEST_JSON_URL]: {
- body: JSON.stringify({
- schemaVersion: 1,
- tag: TAG,
- releaseBaseUrl: `${OSS_RELEASE_ROOT}/${TAG}`,
- }),
- },
- });
- await expect(resolveOssLatestTag(fetchFn)).resolves.toBe(TAG);
- });
-
- it("rejects non-200, network failures and invalid JSON", async () => {
- await expect(
- resolveOssLatestTag(fakeFetch({ [OSS_LATEST_JSON_URL]: { status: 503 } })),
- ).resolves.toBeNull();
- await expect(
- resolveOssLatestTag(fakeFetch({ [OSS_LATEST_JSON_URL]: { networkError: true } })),
- ).resolves.toBeNull();
- await expect(
- resolveOssLatestTag(fakeFetch({ [OSS_LATEST_JSON_URL]: { body: "{not json" } })),
- ).resolves.toBeNull();
- });
-
- it("rejects wrong schema, unsafe tags and mismatched base URLs", async () => {
- await expect(
- resolveOssLatestTag(
- fakeFetch({
- [OSS_LATEST_JSON_URL]: {
- body: JSON.stringify({ schemaVersion: 2, tag: TAG, releaseBaseUrl: `${OSS_BASE}` }),
- },
- }),
- ),
- ).resolves.toBeNull();
- await expect(
- resolveOssLatestTag(
- fakeFetch({
- [OSS_LATEST_JSON_URL]: {
- body: JSON.stringify({
- schemaVersion: 1,
- tag: "../v0.2.2",
- releaseBaseUrl: `${OSS_BASE}`,
- }),
- },
- }),
- ),
- ).resolves.toBeNull();
- await expect(
- resolveOssLatestTag(
- fakeFetch({
- [OSS_LATEST_JSON_URL]: {
- body: JSON.stringify({
- schemaVersion: 1,
- tag: TAG,
- releaseBaseUrl: "https://evil.example/releases/v0.2.2",
- }),
- },
- }),
- ),
- ).resolves.toBeNull();
- });
-});
-
-describe("loadReleaseDownloadManifest", () => {
- const deadlineMs = Date.now() + 60_000;
-
- it("parses a valid manifest and falls back to GitHub when the OSS copy is missing", async () => {
- const parsed = await loadReleaseDownloadManifest({
- fetchFn: fakeFetch({
- [`${GH_BASE}/release-download-manifest.tsv`]: {
- body: manifestText(WIN_ASSET, 120 * 1024 * 1024),
- },
- }),
- tag: TAG,
- assetName: WIN_ASSET,
- deadlineMs,
- });
- expect(parsed).toEqual({ smallProbe: SMALL, largeProbe: LARGE, assetSize: 120 * 1024 * 1024 });
- });
-
- it("rejects a missing manifest, a wrong header and an exhausted budget", async () => {
- await expect(
- loadReleaseDownloadManifest({
- fetchFn: fakeFetch({}),
- tag: TAG,
- assetName: WIN_ASSET,
- deadlineMs,
- }),
- ).resolves.toBeNull();
- await expect(
- loadReleaseDownloadManifest({
- fetchFn: fakeFetch({
- [`${OSS_BASE}/release-download-manifest.tsv`]: {
- body: manifestText(WIN_ASSET, 120 * 1024 * 1024).replace(TAG, "v9.9.9"),
- },
- }),
- tag: TAG,
- assetName: WIN_ASSET,
- deadlineMs,
- }),
- ).resolves.toBeNull();
- await expect(
- loadReleaseDownloadManifest({
- fetchFn: fakeFetch({
- [`${OSS_BASE}/release-download-manifest.tsv`]: {
- body: manifestText(WIN_ASSET, 120 * 1024 * 1024),
- },
- }),
- tag: TAG,
- assetName: WIN_ASSET,
- deadlineMs: Date.now() - 1,
- }),
- ).resolves.toBeNull();
- });
-
- it("rejects manifests missing probes or the platform asset row", async () => {
- const withoutLarge = manifestText(WIN_ASSET, 120 * 1024 * 1024)
- .split("\n")
- .filter((line) => !line.startsWith("probe\tlarge"))
- .join("\n");
- await expect(
- loadReleaseDownloadManifest({
- fetchFn: fakeFetch({
- [`${OSS_BASE}/release-download-manifest.tsv`]: { body: withoutLarge },
- }),
- tag: TAG,
- assetName: WIN_ASSET,
- deadlineMs,
- }),
- ).resolves.toBeNull();
- await expect(
- loadReleaseDownloadManifest({
- fetchFn: fakeFetch({
- [`${OSS_BASE}/release-download-manifest.tsv`]: {
- body: manifestText(MAC_ASSET, 120 * 1024 * 1024),
- },
- }),
- tag: TAG,
- assetName: WIN_ASSET,
- deadlineMs,
- }),
- ).resolves.toBeNull();
- });
-});
-
-describe("probeSource", () => {
- const deadlineMs = Date.now() + 60_000;
-
- it("accepts an exact verified probe and reports throughput", async () => {
- const result = await probeSource({
- fetchFn: fakeFetch({ [`${OSS_BASE}/${LARGE.name}`]: { body: LARGE_BYTES } }),
- base: OSS_BASE,
- probe: LARGE,
- deadlineMs,
- maxTimeoutSeconds: 5,
- wantSpeed: true,
- });
- expect(result.ok).toBe(true);
- expect(result.speedBps).toBeGreaterThan(0);
- });
-
- it("rejects wrong sizes, wrong hashes, non-2xx, compression and network failures", async () => {
- const routes = (route: FakeRoute) => ({
- [`${OSS_BASE}/${SMALL.name}`]: route,
- });
- expect(
- (
- await probeSource({
- fetchFn: fakeFetch(routes({ body: new Uint8Array(100) })),
- base: OSS_BASE,
- probe: SMALL,
- deadlineMs,
- maxTimeoutSeconds: 2,
- wantSpeed: false,
- })
- ).ok,
- ).toBe(false);
- expect(
- (
- await probeSource({
- fetchFn: fakeFetch(routes({ body: probeBody(SMALL.size).fill(0x01) })),
- base: OSS_BASE,
- probe: SMALL,
- deadlineMs,
- maxTimeoutSeconds: 2,
- wantSpeed: false,
- })
- ).ok,
- ).toBe(false);
- expect(
- (
- await probeSource({
- fetchFn: fakeFetch(routes({ status: 500 })),
- base: OSS_BASE,
- probe: SMALL,
- deadlineMs,
- maxTimeoutSeconds: 2,
- wantSpeed: false,
- })
- ).ok,
- ).toBe(false);
- expect(
- (
- await probeSource({
- fetchFn: fakeFetch(routes({ body: probeBody(SMALL.size), encoding: "gzip" })),
- base: OSS_BASE,
- probe: SMALL,
- deadlineMs,
- maxTimeoutSeconds: 2,
- wantSpeed: false,
- })
- ).ok,
- ).toBe(false);
- expect(
- (
- await probeSource({
- fetchFn: fakeFetch(routes({ networkError: true })),
- base: OSS_BASE,
- probe: SMALL,
- deadlineMs,
- maxTimeoutSeconds: 2,
- wantSpeed: false,
- })
- ).ok,
- ).toBe(false);
- });
-
- it("requests identity encoding and refuses to start past the budget", async () => {
- const calls: FakeCall[] = [];
- await probeSource({
- fetchFn: fakeFetch({ [`${OSS_BASE}/${SMALL.name}`]: { body: probeBody(SMALL.size) } }, calls),
- base: OSS_BASE,
- probe: SMALL,
- deadlineMs,
- maxTimeoutSeconds: 2,
- wantSpeed: false,
- });
- expect(calls[0]?.acceptEncoding).toBe("identity");
- expect(
- (
- await probeSource({
- fetchFn: fakeFetch({}),
- base: OSS_BASE,
- probe: SMALL,
- deadlineMs: Date.now() - 1,
- maxTimeoutSeconds: 2,
- wantSpeed: false,
- })
- ).ok,
- ).toBe(false);
- });
-});
-
-describe("selectMeasuredSource", () => {
- it("keeps GitHub above the minimum speed and on ties below it", () => {
- expect(selectMeasuredSource(262144, 10_000_000)).toBe("github");
- expect(selectMeasuredSource(200_000, 299_999)).toBe("github");
- });
-
- it("switches to OSS only when GitHub missed the minimum and OSS is more than 1.5x faster", () => {
- expect(selectMeasuredSource(200_000, 300_001)).toBe("oss");
- });
-});
-
-describe("selectAutoUpdateFeed", () => {
- it("keeps GitHub when the GitHub large probe meets the 256 KiB/s gate", async () => {
- const { decision, logs } = await runSelection(happyRoutes());
- expect(await decision).toEqual({
- kind: "pinned",
- primaryUrl: githubFeedUrl(TAG),
- fallbackUrl: ossFeedUrl(TAG),
- });
- expect(logs).toContain("Selected GitHub (meets minimum download speed).");
- });
-
- it("promotes the OSS mirror when GitHub misses the minimum and OSS is clearly faster", async () => {
- const { decision, logs } = await runSelection(
- happyRoutes({ githubLargeMs: 5_000, ossLargeMs: 1_000 }),
- );
- expect(await decision).toEqual({
- kind: "pinned",
- primaryUrl: ossFeedUrl(TAG),
- fallbackUrl: githubFeedUrl(TAG),
- });
- expect(logs).toContain("Selected OSS mirror (clearly faster than GitHub here).");
- });
-
- it("keeps GitHub when both sources miss the minimum and OSS is not enough faster", async () => {
- const { decision, logs } = await runSelection(
- happyRoutes({ githubLargeMs: 5_000, ossLargeMs: 4_500 }),
- );
- expect(await decision).toEqual({
- kind: "pinned",
- primaryUrl: githubFeedUrl(TAG),
- fallbackUrl: ossFeedUrl(TAG),
- });
- expect(logs).toContain(
- "Selected GitHub (the OSS mirror was not enough faster to be worth switching).",
- );
- });
-
- it("uses the OSS mirror when the GitHub large probe fails and OSS can be measured", async () => {
- const { decision, logs } = await runSelection(
- happyRoutes({ largeFail: true, ossLargeMs: 1_000 }),
- );
- expect(await decision).toEqual({
- kind: "pinned",
- primaryUrl: ossFeedUrl(TAG),
- fallbackUrl: githubFeedUrl(TAG),
- });
- expect(logs).toContain("Selected OSS mirror (clearly faster than GitHub here).");
- });
-
- it("keeps GitHub when only the OSS small probe fails, without measuring throughput", async () => {
- const routes = happyRoutes();
- delete routes[`${OSS_BASE}/${SMALL.name}`];
- const calls: FakeCall[] = [];
- const { decision, logs } = await runSelection(routes, calls);
- expect(await decision).toEqual({
- kind: "pinned",
- primaryUrl: githubFeedUrl(TAG),
- fallbackUrl: ossFeedUrl(TAG),
- });
- expect(logs).toContain("Selected GitHub (OSS mirror probe unavailable).");
- expect(calls.some((c) => c.url.endsWith(LARGE.name))).toBe(false);
- });
-
- it("selects the OSS mirror when only the GitHub small probe fails", async () => {
- const routes = happyRoutes();
- delete routes[`${GH_BASE}/${SMALL.name}`];
- const calls: FakeCall[] = [];
- const { decision, logs } = await runSelection(routes, calls);
- expect(await decision).toEqual({
- kind: "pinned",
- primaryUrl: ossFeedUrl(TAG),
- fallbackUrl: githubFeedUrl(TAG),
- });
- expect(logs).toContain("Selected OSS mirror (GitHub probe unavailable).");
- expect(calls.some((c) => c.url.endsWith(LARGE.name))).toBe(false);
- });
-
- it("keeps GitHub when both small probes fail", async () => {
- const routes = happyRoutes();
- delete routes[`${OSS_BASE}/${SMALL.name}`];
- delete routes[`${GH_BASE}/${SMALL.name}`];
- const calls: FakeCall[] = [];
- const { decision, logs } = await runSelection(routes, calls);
- expect(await decision).toEqual({ kind: "keep-github", reason: "inconclusive" });
- expect(logs).toContain("Download source test was inconclusive; keeping GitHub update feed.");
- expect(calls.some((c) => c.url.endsWith(LARGE.name))).toBe(false);
- });
-
- it("keeps GitHub without any probes when latest.json is invalid or the manifest is unusable", async () => {
- const noLatest = await runSelection({ [OSS_LATEST_JSON_URL]: { status: 503 } });
- expect(await noLatest.decision).toEqual({ kind: "keep-github", reason: "inconclusive" });
-
- const routes = happyRoutes();
- delete routes[`${OSS_BASE}/release-download-manifest.tsv`];
- const noManifest = await runSelection(routes);
- expect(await noManifest.decision).toEqual({ kind: "keep-github", reason: "inconclusive" });
-
- const badHeader = happyRoutes();
- badHeader[`${OSS_BASE}/release-download-manifest.tsv`] = {
- body: manifestText(WIN_ASSET, 120 * 1024 * 1024).replace(TAG, "v9.9.9"),
- };
- const mismatched = await runSelection(badHeader);
- expect(await mismatched.decision).toEqual({ kind: "keep-github", reason: "inconclusive" });
- });
-
- it("selects the OSS mirror when the GitHub small probe is corrupted (wrong bytes or compressed)", async () => {
- const wrongBytes = happyRoutes();
- wrongBytes[`${GH_BASE}/${SMALL.name}`] = { body: new Uint8Array(100) };
- const corrupted = await runSelection(wrongBytes);
- expect(await corrupted.decision).toEqual({
- kind: "pinned",
- primaryUrl: ossFeedUrl(TAG),
- fallbackUrl: githubFeedUrl(TAG),
- });
-
- const compressed = happyRoutes();
- compressed[`${GH_BASE}/${SMALL.name}`] = {
- body: probeBody(SMALL.size),
- encoding: "gzip",
- };
- const gzipped = await runSelection(compressed);
- expect(await gzipped.decision).toEqual({
- kind: "pinned",
- primaryUrl: ossFeedUrl(TAG),
- fallbackUrl: githubFeedUrl(TAG),
- });
- });
-
- it("keeps GitHub when the probe budget is already exhausted", async () => {
- const routes = happyRoutes();
- const calls: FakeCall[] = [];
- const { decision, logs } = await runSelection(routes, calls, "win32", "x64", 0);
- expect(await decision).toEqual({ kind: "keep-github", reason: "inconclusive" });
- expect(logs).toContain("Download source test was inconclusive; keeping GitHub update feed.");
- });
-
- it("keeps GitHub for forms without a desktop update asset, without any network access", async () => {
- const calls: FakeCall[] = [];
- const { decision } = await runSelection(happyRoutes(), calls, "win32", "arm64");
- expect(await decision).toEqual({ kind: "keep-github", reason: "inconclusive" });
- expect(calls).toEqual([]);
- });
-
- it("uses the platform-specific desktop asset row (macOS zip)", async () => {
- const routes = happyRoutes({ assetName: MAC_ASSET });
- const { decision } = await runSelection(routes, [], "darwin", "arm64");
- expect(await decision).toEqual({
- kind: "pinned",
- primaryUrl: githubFeedUrl(TAG),
- fallbackUrl: ossFeedUrl(TAG),
- });
- });
-});
diff --git a/packages/desktop/test/update-support.test.ts b/packages/desktop/test/update-support.test.ts
index 721d3733..ab313760 100644
--- a/packages/desktop/test/update-support.test.ts
+++ b/packages/desktop/test/update-support.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
-import { feedUrlOverride, updateSourceConfig, updateSupport } from "../src/update-support.js";
+import { feedUrlOverride, updateSupport } from "../src/update-support.js";
describe("updateSupport", () => {
it("supports packaged macOS and Windows builds", () => {
@@ -65,42 +65,5 @@ describe("feedUrlOverride", () => {
});
});
-describe("updateSourceConfig", () => {
- it("defaults to auto with the speed probe on", () => {
- expect(updateSourceConfig({})).toEqual({
- source: "auto",
- probe: true,
- invalidSource: false,
- invalidProbe: false,
- });
- });
-
- it("accepts every source and the probe switch, trimming whitespace", () => {
- expect(updateSourceConfig({ PENGUIN_UPDATE_SOURCE: " oss " })).toMatchObject({
- source: "oss",
- invalidSource: false,
- });
- expect(updateSourceConfig({ PENGUIN_UPDATE_SOURCE: "github" })).toMatchObject({
- source: "github",
- invalidSource: false,
- });
- expect(updateSourceConfig({ PENGUIN_UPDATE_SOURCE: "auto" })).toMatchObject({
- source: "auto",
- invalidSource: false,
- });
- expect(updateSourceConfig({ PENGUIN_UPDATE_SPEED_PROBE: "1" })).toMatchObject({
- probe: true,
- invalidProbe: false,
- });
- expect(updateSourceConfig({ PENGUIN_UPDATE_SPEED_PROBE: " 0 " })).toMatchObject({
- probe: false,
- invalidProbe: false,
- });
- });
-
- it("treats unsupported values as defaults and flags them", () => {
- expect(
- updateSourceConfig({ PENGUIN_UPDATE_SOURCE: "mirror", PENGUIN_UPDATE_SPEED_PROBE: "2" }),
- ).toEqual({ source: "auto", probe: true, invalidSource: true, invalidProbe: true });
- });
-});
+// The source/probe switches (PENGUIN_UPDATE_SOURCE, PENGUIN_UPDATE_SPEED_PROBE) are gone with
+// the second feed; PENGUIN_UPDATE_FEED_URL above is what remains for a deployment's own mirror.
diff --git a/packages/server/src/plugin/builtin-index.json b/packages/server/src/plugin/builtin-index.json
index 39218d77..484b8aaa 100644
--- a/packages/server/src/plugin/builtin-index.json
+++ b/packages/server/src/plugin/builtin-index.json
@@ -5,7 +5,7 @@
"description": "Bubblewrap sandbox backend for Adelie: filesystem confinement plus network isolation and path masking.",
"authors": ["Prism Shadow"],
"license": "Apache-2.0",
- "repository": "https://github.com/Prism-Shadow/penguin-harness",
+ "repository": "https://github.com/lmliheng/Adelie",
"keywords": ["linux", "bubblewrap", "network-isolation", "path-masking"],
"categories": ["sandbox"]
},
@@ -15,7 +15,7 @@
"description": "macOS Seatbelt sandbox backend for Adelie: filesystem confinement plus network isolation and path masking.",
"authors": ["Prism Shadow"],
"license": "Apache-2.0",
- "repository": "https://github.com/Prism-Shadow/penguin-harness",
+ "repository": "https://github.com/lmliheng/Adelie",
"keywords": ["macos", "seatbelt", "network-isolation", "path-masking"],
"categories": ["sandbox"]
},
@@ -25,7 +25,7 @@
"description": "WSL sandbox backend for Adelie on Windows: commands run in a dedicated WSL2 distro under bubblewrap, with Windows interop switched off.",
"authors": ["Prism Shadow"],
"license": "Apache-2.0",
- "repository": "https://github.com/Prism-Shadow/penguin-harness",
+ "repository": "https://github.com/lmliheng/Adelie",
"keywords": ["windows", "wsl", "bubblewrap", "network-isolation", "path-masking"],
"categories": ["sandbox"]
},
@@ -35,7 +35,7 @@
"description": "DeepSeek Harness sandbox adaptor for Adelie: the DSH local backend chain behind the harness's own sandbox interface.",
"authors": ["Prism Shadow"],
"license": "Apache-2.0",
- "repository": "https://github.com/Prism-Shadow/penguin-harness",
+ "repository": "https://github.com/lmliheng/Adelie",
"keywords": ["linux", "macos", "windows", "dsh", "filesystem-only"],
"categories": ["sandbox"]
}
diff --git a/packages/web/src/components/account/update-modal.tsx b/packages/web/src/components/account/update-modal.tsx
index 60d232a9..91bb9d90 100644
--- a/packages/web/src/components/account/update-modal.tsx
+++ b/packages/web/src/components/account/update-modal.tsx
@@ -28,7 +28,7 @@ import {
useUpdateFlowOwner,
} from "../../lib/use-update-flow";
-const RELEASES_URL = "https://github.com/Prism-Shadow/penguin-harness/releases";
+const RELEASES_URL = "https://github.com/lmliheng/Adelie/releases";
export function UpdateModal() {
useUpdateFlowOwner();
diff --git a/plugins/agent-company/package.json b/plugins/agent-company/package.json
index c128effc..847005f4 100644
--- a/plugins/agent-company/package.json
+++ b/plugins/agent-company/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/agent-company"
},
"files": [
diff --git a/plugins/agent-development/package.json b/plugins/agent-development/package.json
index 84f59c74..f6964ea1 100644
--- a/plugins/agent-development/package.json
+++ b/plugins/agent-development/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/agent-development"
},
"files": [
diff --git a/plugins/agent-tuning/package.json b/plugins/agent-tuning/package.json
index eab4a203..2f3ef2c5 100644
--- a/plugins/agent-tuning/package.json
+++ b/plugins/agent-tuning/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/agent-tuning"
},
"files": [
diff --git a/plugins/browser-automation/package.json b/plugins/browser-automation/package.json
index 3db5b2b8..62b4377d 100644
--- a/plugins/browser-automation/package.json
+++ b/plugins/browser-automation/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/browser-automation"
},
"files": [
diff --git a/plugins/continual-learning/package.json b/plugins/continual-learning/package.json
index 3809e8ee..801f6f91 100644
--- a/plugins/continual-learning/package.json
+++ b/plugins/continual-learning/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/continual-learning"
},
"files": [
diff --git a/plugins/data-analysis/package.json b/plugins/data-analysis/package.json
index 378c61c7..cacb5ea8 100644
--- a/plugins/data-analysis/package.json
+++ b/plugins/data-analysis/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/data-analysis"
},
"files": [
diff --git a/plugins/goal/package.json b/plugins/goal/package.json
index ae6d7741..840a7321 100644
--- a/plugins/goal/package.json
+++ b/plugins/goal/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/goal"
},
"files": [
diff --git a/plugins/humanizer/package.json b/plugins/humanizer/package.json
index a190b948..77b20d5c 100644
--- a/plugins/humanizer/package.json
+++ b/plugins/humanizer/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/humanizer"
},
"files": [
diff --git a/plugins/model-development/package.json b/plugins/model-development/package.json
index 094ad511..85cacfc8 100644
--- a/plugins/model-development/package.json
+++ b/plugins/model-development/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/model-development"
},
"files": [
diff --git a/plugins/skill-porting/package.json b/plugins/skill-porting/package.json
index d929175b..6c6798a7 100644
--- a/plugins/skill-porting/package.json
+++ b/plugins/skill-porting/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/skill-porting"
},
"files": [
diff --git a/plugins/software-development/package.json b/plugins/software-development/package.json
index a52c981a..9af454b4 100644
--- a/plugins/software-development/package.json
+++ b/plugins/software-development/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/software-development"
},
"files": [
diff --git a/plugins/use-bento-slides/package.json b/plugins/use-bento-slides/package.json
index e5185f6b..4cfee018 100644
--- a/plugins/use-bento-slides/package.json
+++ b/plugins/use-bento-slides/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/use-bento-slides"
},
"files": [
diff --git a/plugins/use-claude-code/package.json b/plugins/use-claude-code/package.json
index cb7f5ca5..dca883db 100644
--- a/plugins/use-claude-code/package.json
+++ b/plugins/use-claude-code/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/use-claude-code"
},
"files": [
diff --git a/plugins/use-firecrawl/package.json b/plugins/use-firecrawl/package.json
index 15531fa4..615f59a6 100644
--- a/plugins/use-firecrawl/package.json
+++ b/plugins/use-firecrawl/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
+ "url": "git+https://github.com/lmliheng/Adelie.git",
"directory": "plugins/use-firecrawl"
},
"files": [
diff --git a/scripts/test-installer.ps1 b/scripts/test-installer.ps1
index a700373d..8959c2ad 100644
--- a/scripts/test-installer.ps1
+++ b/scripts/test-installer.ps1
@@ -14,7 +14,6 @@ $OriginalOs = $env:OS
$OriginalDownloadBaseUrl = $env:PENGUIN_DOWNLOAD_BASE_URL
$OriginalDownloadFallbackBaseUrl = $env:PENGUIN_DOWNLOAD_FALLBACK_BASE_URL
$OriginalDownloadSource = $env:PENGUIN_DOWNLOAD_SOURCE
-$OriginalDownloadSpeedProbe = $env:PENGUIN_DOWNLOAD_SPEED_PROBE
$OriginalArchive = $env:PENGUIN_ARCHIVE
$OriginalInstallDir = $env:PENGUIN_INSTALL_DIR
$OriginalVersion = $env:PENGUIN_VERSION
@@ -25,10 +24,6 @@ $Fixture = @{
BadInnerBundle = $null
LegacyArchive = $null
Installer = $Installer
- Probe64 = $null
- Probe64Hash = $null
- Probe1M = $null
- Probe1MHash = $null
}
$global:PenguinInstallerFixture = $Fixture
@@ -72,63 +67,10 @@ function global:Invoke-WebRequest {
$f.Requests.Add($Uri)
if ($f.Mode -eq "404") { throw "fixture 404: $Uri" }
if ($f.Mode -eq "network") { throw "fixture network failure: $Uri" }
- if ($f.Mode -eq "primary-network" -and $Uri -like "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/*") {
+ if ($f.Mode -eq "primary-network" -and $Uri -like "https://primary.example.test/*") {
throw "fixture primary network failure"
}
- if ($f.Mode -eq "forced-oss-payload" -and
- $Uri -like "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/*/penguin-*") {
- throw "fixture forced OSS payload failure"
- }
- if ($f.Mode -eq "forwarder-auto-github" -and $Uri -like "*/latest.json") {
- throw "fixture OSS metadata failure"
- }
- if ($f.Mode -eq "speed-probe-missing-manifest" -and $Uri -like "*/release-download-manifest.tsv") {
- throw "fixture missing release download manifest"
- }
- # 1 MiB in 6.0s is ~175 KB/s, under the 256 KB/s minimum; the mirror answering the same probe in
- # 5.0s is ~210 KB/s — faster than GitHub, but only 1.2x, short of the 1.5x switch ratio.
- if ($f.Mode -in @("speed-probe-oss-clearly-faster", "speed-probe-oss-not-worth-switching") -and
- $Uri -like "https://github.com/*/probe-1m.bin") {
- Start-Sleep -Milliseconds 6000
- }
- if ($f.Mode -eq "speed-probe-oss-not-worth-switching" -and $Uri -like "*aliyuncs.com/*/probe-1m.bin") {
- Start-Sleep -Milliseconds 5000
- }
switch -Wildcard ($Uri) {
- "*/latest.json" {
- if ($f.Mode -eq "forwarder-invalid-metadata") {
- '{"schemaVersion":1,"tag":"../invalid","releaseBaseUrl":"https://example.invalid"}' |
- Set-Content -LiteralPath $OutFile -Encoding ascii
- } else {
- @{
- schemaVersion = 1
- tag = "v0.0.0-test"
- releaseBaseUrl = "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test"
- } | ConvertTo-Json | Set-Content -LiteralPath $OutFile -Encoding ascii
- }
- }
- "*/release-download-manifest.tsv" {
- if ($f.Mode -like "speed-probe-*") {
- $AssetSize = 104857600
- @(
- "penguin-release-download-manifest`t1`tv0.0.0-test"
- "probe`tsmall`tprobe-64k.bin`t65536`t$($f.Probe64Hash)"
- "probe`tlarge`tprobe-1m.bin`t1048576`t$($f.Probe1MHash)"
- "asset`tpenguin-win32-x64.zip`t$AssetSize`t$((Get-FileHash -Algorithm SHA256 -LiteralPath $f.GoodBundle).Hash.ToLowerInvariant())"
- ) | Set-Content -LiteralPath $OutFile -Encoding ascii
- } else {
- throw "unexpected manifest request: $Uri"
- }
- }
- "*/probe-64k.bin" {
- Copy-Item -LiteralPath $f.Probe64 -Destination $OutFile
- }
- "*/probe-1m.bin" {
- Copy-Item -LiteralPath $f.Probe1M -Destination $OutFile
- }
- "*/install.ps1" {
- Copy-Item -LiteralPath $f.Installer -Destination $OutFile
- }
"*/penguin-win32-x64.zip.sha256" {
switch ($f.Mode) {
"outer-sha-mismatch" {
@@ -156,8 +98,7 @@ function Invoke-OnlineCase(
[string]$Version,
[bool]$ShouldSucceed,
[int]$ExpectedRequests,
- [string]$InstallerPath = "",
- [string]$SpeedProbe = "0"
+ [string]$InstallerPath = ""
) {
$Fixture.Mode = $Mode
$Fixture.Requests.Clear()
@@ -165,11 +106,6 @@ function Invoke-OnlineCase(
$Arguments = @{ InstallDir = $InstallDir }
if ($Version) { $Arguments.Version = $Version }
if (-not $InstallerPath) { $InstallerPath = $Installer }
- if ($SpeedProbe -eq "__unset") {
- Remove-Item Env:\PENGUIN_DOWNLOAD_SPEED_PROBE -ErrorAction SilentlyContinue
- } else {
- $env:PENGUIN_DOWNLOAD_SPEED_PROBE = $SpeedProbe
- }
$Succeeded = $true
$Output = @()
try { $Output = @(& $InstallerPath @Arguments *>&1) } catch { $Succeeded = $false; $Output += $_ }
@@ -179,51 +115,12 @@ function Invoke-OnlineCase(
[PSCustomObject]@{ InstallDir = $InstallDir; Requests = @($Fixture.Requests); Output = @($Output) }
}
-function Invoke-ForwarderCase(
- [string]$Name,
- [string]$Mode,
- [string]$Source,
- [int]$ExpectedRequests,
- [string]$Version = "",
- [bool]$ShouldSucceed = $true,
- [string]$SpeedProbe = "0"
-) {
- $Fixture.Mode = $Mode
- $Fixture.Requests.Clear()
- $InstallDir = Join-Path $WorkDir "$Name-install"
- if ($Version) {
- Remove-Item Env:\PENGUIN_ARCHIVE -ErrorAction SilentlyContinue
- $env:PENGUIN_VERSION = $Version
- } else {
- $env:PENGUIN_ARCHIVE = $Fixture.GoodBundle
- Remove-Item Env:\PENGUIN_VERSION -ErrorAction SilentlyContinue
- }
- $env:PENGUIN_INSTALL_DIR = $InstallDir
- $env:PENGUIN_DOWNLOAD_SOURCE = $Source
- if ($SpeedProbe -eq "__unset") {
- Remove-Item Env:\PENGUIN_DOWNLOAD_SPEED_PROBE -ErrorAction SilentlyContinue
- } else {
- $env:PENGUIN_DOWNLOAD_SPEED_PROBE = $SpeedProbe
- }
- Remove-Item Env:\PENGUIN_DOWNLOAD_BASE_URL, Env:\PENGUIN_DOWNLOAD_FALLBACK_BASE_URL -ErrorAction SilentlyContinue
- $Forwarder = Join-Path $RepoRoot "packages\landing\public\install.ps1"
- $Output = @()
- $Succeeded = $true
- try { $Output = @(& $Forwarder *>&1) } catch { $Succeeded = $false }
- Assert-True ($Succeeded -eq $ShouldSucceed) "$Name returned an unexpected result"
- Assert-True ($Fixture.Requests.Count -eq $ExpectedRequests) `
- "$Name made $($Fixture.Requests.Count) requests, expected $ExpectedRequests"
- Assert-True (-not (($Output | Out-String) -match 'aliyuncs\.com')) `
- "$Name exposed the OSS URL in normal output"
- [PSCustomObject]@{ InstallDir = $InstallDir; Requests = @($Fixture.Requests); Output = @($Output) }
-}
-
try {
New-Item -ItemType Directory -Path $WorkDir -Force | Out-Null
# Keep the fixture tests away from the runner's user registry Path.
$env:OS = "PenguinInstallerFixtureTest"
Remove-Item Env:\PENGUIN_DOWNLOAD_BASE_URL, Env:\PENGUIN_DOWNLOAD_FALLBACK_BASE_URL, `
- Env:\PENGUIN_DOWNLOAD_SOURCE, Env:\PENGUIN_DOWNLOAD_SPEED_PROBE, Env:\PENGUIN_ARCHIVE, Env:\PENGUIN_INSTALL_DIR, `
+ Env:\PENGUIN_DOWNLOAD_SOURCE, Env:\PENGUIN_ARCHIVE, Env:\PENGUIN_INSTALL_DIR, `
Env:\PENGUIN_VERSION -ErrorAction SilentlyContinue
# --- Offline program archive: good install, then a failing upgrade must roll back. ---
@@ -276,12 +173,6 @@ try {
Set-Content -LiteralPath "$($Fixture.BadInnerBundle).sha256" -Encoding ascii
$Fixture.LegacyArchive = $GoodArchive
- $Fixture.Probe64 = Join-Path $WorkDir "probe-64k.bin"
- $Fixture.Probe1M = Join-Path $WorkDir "probe-1m.bin"
- [IO.File]::WriteAllBytes($Fixture.Probe64, [byte[]]::new(65536))
- [IO.File]::WriteAllBytes($Fixture.Probe1M, [byte[]]::new(1048576))
- $Fixture.Probe64Hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $Fixture.Probe64).Hash.ToLowerInvariant()
- $Fixture.Probe1MHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $Fixture.Probe1M).Hash.ToLowerInvariant()
# Model the release workflow's installer stamping without changing the source installer.
$StampedInstaller = Join-Path $WorkDir "install-v0.0.0-test.ps1"
@@ -309,137 +200,74 @@ try {
Assert-True ($Version -eq "fixture-old") "sibling install did not produce a working command"
# --- Online cases. ---
- $canonical = Invoke-OnlineCase "canonical" "canonical" "" $true 3
- Assert-True ($canonical.Requests[0] -like "*/latest.json") `
- "unstamped installer did not resolve the OSS latest metadata"
- Assert-True ($canonical.Requests[1] -like "*/releases/v0.0.0-test/penguin-win32-x64.zip") `
- "unstamped installer did not lock the resolved OSS release"
+ # Unstamped source-tree installer: no embedded tag, so it follows GitHub's "latest" release.
+ $canonical = Invoke-OnlineCase "canonical" "canonical" "" $true 2
+ Assert-True ($canonical.Requests[0] -eq "https://github.com/lmliheng/Adelie/releases/latest/download/penguin-win32-x64.zip") `
+ "unstamped installer did not use the latest GitHub release"
+ Assert-True (-not (($canonical.Requests | Out-String) -match 'aliyuncs')) `
+ "installer still reaches the retired OSS mirror"
$Version = & (Join-Path $canonical.InstallDir "bin\penguin.cmd") --version
Assert-True ($Version -eq "fixture-old") "canonical bundle was not installed"
+ # A stamped release installer uses its own immutable tag and never resolves "latest".
$stamped = Invoke-OnlineCase "stamped" "canonical" "" $true 2 $StampedInstaller
- Assert-True ($stamped.Requests[0] -eq "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test/penguin-win32-x64.zip") `
- "stamped installer did not select its own immutable OSS release"
- Assert-True (-not (($stamped.Requests | Out-String) -match 'latest\.json')) `
- "stamped installer unexpectedly resolved latest metadata"
-
- $stampedFallback = Invoke-OnlineCase "stamped-fallback" "primary-network" "" $true 3 $StampedInstaller
- Assert-True ($stampedFallback.Requests[0] -like "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test/*") `
- "stamped installer did not try its own OSS release first"
- Assert-True ($stampedFallback.Requests[1] -like "https://github.com/*/releases/download/v0.0.0-test/penguin-win32-x64.zip") `
- "stamped installer did not fall back to the same GitHub version"
-
- $speedProbeGitHubFast = Invoke-OnlineCase "speed-probe-github-fast" "speed-probe-github-fast" "" $true 6 $StampedInstaller "1"
- Assert-True (($speedProbeGitHubFast.Requests | Out-String) -match 'release-download-manifest\.tsv') `
- "speed probe did not request the release download manifest"
- Assert-True (($speedProbeGitHubFast.Requests | Out-String) -match 'probe-64k\.bin') `
- "speed probe did not request the small probe"
- Assert-True ($speedProbeGitHubFast.Requests[-2] -like "https://github.com/*/releases/download/v0.0.0-test/penguin-win32-x64.zip") `
- "speed probe did not select GitHub when it met the minimum speed"
- Assert-True (-not (($speedProbeGitHubFast.Requests | Out-String) -match 'aliyuncs\.com/[^\r\n]*probe-1m\.bin')) `
- "speed probe spent the paid mirror's bandwidth even though GitHub already met the minimum"
-
- $speedProbeDefaultOn = Invoke-OnlineCase "speed-probe-default-on" "speed-probe-github-fast" "" $true 6 $StampedInstaller "__unset"
- Assert-True ($speedProbeDefaultOn.Requests[-2] -like "https://github.com/*/releases/download/v0.0.0-test/penguin-win32-x64.zip") `
- "speed probe was not enabled by default"
-
- # Below the minimum the mirror is measured too, which is the seventh request of these two cases.
- $speedProbeOssFaster = Invoke-OnlineCase "speed-probe-oss-clearly-faster" "speed-probe-oss-clearly-faster" "" $true 7 $StampedInstaller "1"
- Assert-True (($speedProbeOssFaster.Requests | Out-String) -match 'aliyuncs\.com/[^\r\n]*probe-1m\.bin') `
- "speed probe did not measure the OSS mirror once GitHub was below the minimum speed"
- Assert-True ($speedProbeOssFaster.Requests[-2] -like "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/*/penguin-win32-x64.zip") `
- "speed probe did not switch to OSS when it was clearly faster than a slow GitHub"
-
- $speedProbeOssMarginal = Invoke-OnlineCase "speed-probe-oss-not-worth-switching" "speed-probe-oss-not-worth-switching" "" $true 7 $StampedInstaller "1"
- Assert-True ($speedProbeOssMarginal.Requests[-2] -like "https://github.com/*/releases/download/v0.0.0-test/penguin-win32-x64.zip") `
- "speed probe left GitHub even though OSS was not faster by the switch ratio"
-
- $speedProbeMissing = Invoke-OnlineCase "speed-probe-missing-manifest" "speed-probe-missing-manifest" "" $true 4 $StampedInstaller "1"
- Assert-True (($speedProbeMissing.Output | Out-String) -match 'Download source test was inconclusive') `
- "missing speed probe manifest did not fall back to the compatible source policy"
+ Assert-True ($stamped.Requests[0] -eq "https://github.com/lmliheng/Adelie/releases/download/v0.0.0-test/penguin-win32-x64.zip") `
+ "stamped installer did not select its own immutable release"
+ Assert-True (-not (($stamped.Requests | Out-String) -match '/latest/')) `
+ "stamped installer unexpectedly resolved the latest release"
+ # GitHub is an accepted explicit source mode and behaves like auto.
$env:PENGUIN_DOWNLOAD_SOURCE = "github"
$stampedGitHub = Invoke-OnlineCase "stamped-github" "canonical" "" $true 2 $StampedInstaller
Assert-True ($stampedGitHub.Requests[0] -like "https://github.com/*/releases/download/v0.0.0-test/penguin-win32-x64.zip") `
"stamped installer did not honor forced GitHub mode"
Remove-Item Env:\PENGUIN_DOWNLOAD_SOURCE
- $env:PENGUIN_DOWNLOAD_BASE_URL = "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test"
+ # The retired OSS mode is rejected before any request leaves the process.
+ $env:PENGUIN_DOWNLOAD_SOURCE = "oss"
+ $ossRejected = Invoke-OnlineCase "source-mode-oss" "canonical" "" $false 0
+ Assert-True (($ossRejected.Output | Out-String) -match 'PENGUIN_DOWNLOAD_SOURCE must be auto or github') `
+ "retired PENGUIN_DOWNLOAD_SOURCE=oss was not rejected"
+ Remove-Item Env:\PENGUIN_DOWNLOAD_SOURCE
+
+ # An explicit base URL overrides source selection entirely.
+ $env:PENGUIN_DOWNLOAD_BASE_URL = "https://mirror.example.test/releases/v0.0.0-test"
$override = Invoke-OnlineCase "download-base-override" "canonical" "" $true 2
- Assert-True ($override.Requests[0] -eq "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test/penguin-win32-x64.zip") `
+ Assert-True ($override.Requests[0] -eq "https://mirror.example.test/releases/v0.0.0-test/penguin-win32-x64.zip") `
"download base override did not request the configured asset directory"
- Assert-True (($override.Output | Out-String) -match 'OSS mirror') `
- "download base override did not identify the OSS mirror"
- Assert-True (-not (($override.Output | Out-String) -match 'aliyuncs\.com')) `
- "download base override exposed the OSS URL in normal output"
+ Assert-True (($override.Output | Out-String) -match 'configured mirror') `
+ "download base override did not label the configured mirror"
+ Remove-Item Env:\PENGUIN_DOWNLOAD_BASE_URL
- $env:PENGUIN_DOWNLOAD_FALLBACK_BASE_URL = "https://github.com/Prism-Shadow/penguin-harness/releases/download/v0.0.0-test"
+ # A transport failure on the primary base URL falls back to the configured fallback.
+ $env:PENGUIN_DOWNLOAD_BASE_URL = "https://primary.example.test/releases/v0.0.0-test"
+ $env:PENGUIN_DOWNLOAD_FALLBACK_BASE_URL = "https://fallback.example.test/releases/v0.0.0-test"
$fallback = Invoke-OnlineCase "download-fallback" "primary-network" "" $true 3
- Assert-True ($fallback.Requests[0] -like "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/*") `
+ Assert-True ($fallback.Requests[0] -eq "https://primary.example.test/releases/v0.0.0-test/penguin-win32-x64.zip") `
"download fallback did not try the primary source first"
- Assert-True ($fallback.Requests[1] -like "https://github.com/*/penguin-win32-x64.zip") `
- "download fallback did not use the same-version GitHub source"
- Assert-True (-not (($fallback.Output | Out-String) -match 'aliyuncs\.com')) `
- "download fallback exposed the OSS URL in normal output"
+ Assert-True ($fallback.Requests[1] -eq "https://fallback.example.test/releases/v0.0.0-test/penguin-win32-x64.zip") `
+ "download fallback did not use the configured fallback"
Remove-Item Env:\PENGUIN_DOWNLOAD_FALLBACK_BASE_URL
Remove-Item Env:\PENGUIN_DOWNLOAD_BASE_URL
+ # A fallback without a base URL is ignored: the stamped installer keeps its own tag.
$env:PENGUIN_DOWNLOAD_FALLBACK_BASE_URL = "https://example.invalid/releases/v0.0.0-test"
- $fallbackWithoutBase = Invoke-OnlineCase "fallback-without-base" "primary-network" "" $true 3 $StampedInstaller
+ $fallbackWithoutBase = Invoke-OnlineCase "fallback-without-base" "canonical" "" $true 2 $StampedInstaller
Assert-True (-not (($fallbackWithoutBase.Requests | Out-String) -match 'example\.invalid')) `
- "fallback without base should not override auto/source fallback"
+ "fallback without base should not override the source-mode download"
Assert-True (($fallbackWithoutBase.Requests | Out-String) -match 'github\.com/.*/releases/download/v0\.0\.0-test/penguin-win32-x64\.zip') `
- "fallback without base did not keep the internal same-version GitHub fallback"
+ "fallback without base did not keep the release's own tag"
Remove-Item Env:\PENGUIN_DOWNLOAD_FALLBACK_BASE_URL
- $forwarderOss = Invoke-ForwarderCase "forwarder-oss" "forwarder-oss" "auto" 2
- Assert-True ($forwarderOss.Requests[0] -like "*/latest.json") `
- "OSS forwarder did not request release metadata first"
- Assert-True ($forwarderOss.Requests[1] -like "*/releases/v0.0.0-test/install.ps1") `
- "OSS forwarder did not request the versioned installer"
-
- $forwarderGitHub = Invoke-ForwarderCase "forwarder-auto-github" "forwarder-auto-github" "auto" 2
- Assert-True ($forwarderGitHub.Requests[1] -like "https://github.com/*/releases/latest/download/install.ps1") `
- "forwarder did not fall back to the GitHub installer"
-
- $invalidMetadata = Invoke-ForwarderCase "forwarder-invalid-metadata" "forwarder-invalid-metadata" "auto" 2
- Assert-True ($invalidMetadata.Requests[1] -like "https://github.com/*/releases/latest/download/install.ps1") `
- "invalid OSS metadata did not fall back to the GitHub installer"
-
- $forcedGitHub = Invoke-ForwarderCase "forwarder-github" "canonical" "github" 1
- Assert-True ($forcedGitHub.Requests[0] -like "https://github.com/*/releases/latest/download/install.ps1") `
- "forced GitHub mode did not request the GitHub installer"
-
- $forcedOss = Invoke-ForwarderCase "forwarder-forced-oss-no-fallback" `
- "forced-oss-payload" "oss" 2 "v0.0.0-test" $false
- Assert-True (-not (($forcedOss.Requests | Out-String) -match 'github\.com')) `
- "forced OSS mode unexpectedly fell back to GitHub"
+ Remove-Item Env:\PENGUIN_ARCHIVE, Env:\PENGUIN_INSTALL_DIR, Env:\PENGUIN_DOWNLOAD_SOURCE, Env:\PENGUIN_VERSION -ErrorAction SilentlyContinue
- $pinnedForwarder = Invoke-ForwarderCase "forwarder-pinned" "canonical" "auto" 3 "v0.0.0-test"
- Assert-True ($pinnedForwarder.Requests[0] -like "*/releases/v0.0.0-test/install.ps1") `
- "pinned forwarder did not request the versioned installer"
- Assert-True ($pinnedForwarder.Requests[1] -like "*/releases/v0.0.0-test/penguin-win32-x64.zip") `
- "pinned installer did not keep the selected release version"
-
- $speedProbeForwarder = Invoke-ForwarderCase "forwarder-speed-probe-handoff" "speed-probe-github-fast" "auto" 7 "v0.0.0-test" $true "1"
- Assert-True ($speedProbeForwarder.Requests[0] -like "*/releases/v0.0.0-test/install.ps1") `
- "speed probe handoff forwarder did not fetch the versioned installer"
- Assert-True ($speedProbeForwarder.Requests[-2] -like "https://github.com/*/releases/download/v0.0.0-test/penguin-win32-x64.zip") `
- "forwarder locked the payload source instead of letting the installer run speed probes"
-
- $speedProbeDefaultForwarder = Invoke-ForwarderCase "forwarder-speed-probe-default-handoff" "speed-probe-github-fast" "auto" 7 "v0.0.0-test" $true "__unset"
- Assert-True ($speedProbeDefaultForwarder.Requests[-2] -like "https://github.com/*/releases/download/v0.0.0-test/penguin-win32-x64.zip") `
- "forwarder handoff did not leave speed probing enabled by default"
-
- Remove-Item Env:\PENGUIN_ARCHIVE, Env:\PENGUIN_INSTALL_DIR, Env:\PENGUIN_DOWNLOAD_SOURCE, Env:\PENGUIN_DOWNLOAD_SPEED_PROBE, Env:\PENGUIN_VERSION -ErrorAction SilentlyContinue
-
- Invoke-OnlineCase "outer-mismatch" "outer-sha-mismatch" "" $false 3 | Out-Null
- Invoke-OnlineCase "inner-mismatch" "inner-sha-mismatch" "" $false 3 | Out-Null
- Invoke-OnlineCase "latest-404" "404" "" $false 2 | Out-Null
- Invoke-OnlineCase "pinned-network" "network" "v0.1.4" $false 2 | Out-Null
+ Invoke-OnlineCase "outer-mismatch" "outer-sha-mismatch" "" $false 2 | Out-Null
+ Invoke-OnlineCase "inner-mismatch" "inner-sha-mismatch" "" $false 2 | Out-Null
+ Invoke-OnlineCase "latest-404" "404" "" $false 1 | Out-Null
+ Invoke-OnlineCase "pinned-network" "network" "v0.1.4" $false 1 | Out-Null
$pinned = Invoke-OnlineCase "pinned-legacy" "legacy" "v0.1.4" $true 2
- Assert-True ($pinned.Requests[0] -like "*/releases/v0.1.4/penguin-win32-x64.zip") `
- "pinned legacy did not prefer the pinned OSS asset"
+ Assert-True ($pinned.Requests[0] -eq "https://github.com/lmliheng/Adelie/releases/download/v0.1.4/penguin-win32-x64.zip") `
+ "pinned legacy did not prefer the pinned release asset"
Write-Host "Windows installer bundle, offline, rollback and online tests passed."
} finally {
@@ -460,11 +288,6 @@ try {
} else {
$env:PENGUIN_DOWNLOAD_SOURCE = $OriginalDownloadSource
}
- if ($null -eq $OriginalDownloadSpeedProbe) {
- Remove-Item Env:\PENGUIN_DOWNLOAD_SPEED_PROBE -ErrorAction SilentlyContinue
- } else {
- $env:PENGUIN_DOWNLOAD_SPEED_PROBE = $OriginalDownloadSpeedProbe
- }
if ($null -eq $OriginalArchive) {
Remove-Item Env:\PENGUIN_ARCHIVE -ErrorAction SilentlyContinue
} else {
diff --git a/scripts/test-installer.sh b/scripts/test-installer.sh
index 4125548a..0904be94 100755
--- a/scripts/test-installer.sh
+++ b/scripts/test-installer.sh
@@ -17,24 +17,6 @@ fail_test() {
exit 1
}
-# The auto-mode rule lives in two implementations that cannot import from each other (a POSIX shell
-# has no floats, PowerShell does). Nothing but this check keeps their constants in step, so a
-# threshold edited in one place fails here instead of shipping two different rules.
-check_shared_constant() {
- csc_label="$1"
- csc_expected="$2"
- shift 2
- for csc_file in "$@"; do
- grep -qF "$csc_expected" "$ROOT_DIR/$csc_file" \
- || fail_test "$csc_file does not carry $csc_label as \"$csc_expected\""
- done
-}
-
-check_shared_constant "the GitHub minimum" "262144" install.sh install.ps1
-# The same 1.5, written as an integer percent in install.sh because a POSIX shell has no floats.
-check_shared_constant "the OSS switch ratio" "SPEED_PROBE_OSS_SWITCH_RATIO_PERCENT=150" install.sh
-check_shared_constant "the OSS switch ratio" '$SpeedProbeOssSwitchRatio = 1.5' install.ps1
-
# --- The launchers the release packages ship verbatim (scripts/launchers/). They are the only
# spelling of the payload layout, so moving where web/ or node/ sits fails here rather than
# shipping a package whose `penguin` cannot find its own web assets. ---
@@ -421,25 +403,14 @@ BAD_BUNDLE="$WORK_DIR/bad-bundle.tar.gz"
tar -czf "$BAD_BUNDLE" -C "$BAD_DIR" .
write_sha256 "$BAD_BUNDLE"
-PROBE64="$WORK_DIR/probe-64k.bin"
-PROBE1M="$WORK_DIR/probe-1m.bin"
-dd if=/dev/zero of="$PROBE64" bs=65536 count=1 2>/dev/null
-dd if=/dev/zero of="$PROBE1M" bs=1048576 count=1 2>/dev/null
-PROBE64_HASH="$(sha256sum "$PROBE64" | awk '{ print $1 }')"
-PROBE1M_HASH="$(sha256sum "$PROBE1M" | awk '{ print $1 }')"
-HOST_ASSET_HASH="$(sha256sum "$ARTIFACT_DIR/$HOST_ASSET" | awk '{ print $1 }')"
-SPEED_PROBE_ASSET_SIZE=104857600
-
cat > "$STUB_BIN/curl" <<'EOF'
#!/bin/sh
set -eu
output=""
url=""
-writeout=""
while [ $# -gt 0 ]; do
case "$1" in
-o) output="$2"; shift 2 ;;
- -w | --write-out) writeout="$2"; shift 2 ;;
-H | --header | --connect-timeout | --max-time | --speed-limit | --speed-time) shift 2 ;;
-*) shift ;;
*) url="$1"; shift ;;
@@ -447,65 +418,26 @@ while [ $# -gt 0 ]; do
done
printf '%s\n' "$url" >> "$REQUEST_LOG"
base="${url##*/}"
+# A fixture host that never answers, used to drive the transport-failure fallback.
case "$MODE:$url" in
- primary-network:https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/*) exit 7 ;;
- forced-oss-payload:https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/*/penguin-*) exit 7 ;;
+ primary-network:https://primary.example.test/*) exit 7 ;;
esac
case "$MODE:$base" in
- forwarder-auto-github:latest.json) exit 7 ;;
- forwarder-invalid-metadata:latest.json)
- printf '%s\n' '{"schemaVersion":1,"tag":"../invalid","releaseBaseUrl":"https://example.invalid"}' > "$output"
- ;;
- canonical:latest.json | outer-sha-mismatch:latest.json | inner-sha-mismatch:latest.json | forwarder-oss:latest.json | forced-oss-payload:latest.json)
- printf '%s\n' '{"schemaVersion":1,"tag":"v0.0.0-test","releaseBaseUrl":"https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test"}' > "$output"
- ;;
- speed-probe-missing-manifest:release-download-manifest.tsv) exit 22 ;;
- speed-probe-*:release-download-manifest.tsv)
- {
- printf 'penguin-release-download-manifest\t1\tv0.0.0-test\n'
- printf 'probe\tsmall\tprobe-64k.bin\t65536\t%s\n' "$PROBE64_HASH"
- printf 'probe\tlarge\tprobe-1m.bin\t1048576\t%s\n' "$PROBE1M_HASH"
- printf 'asset\t%s\t%s\t%s\n' "$HOST_ASSET" "$SPEED_PROBE_ASSET_SIZE" "$HOST_ASSET_HASH"
- } > "$output"
- ;;
- speed-probe-*:probe-64k.bin) cp "$PROBE64" "$output" ;;
- speed-probe-*:probe-1m.bin) cp "$PROBE1M" "$output" ;;
- forwarder-oss:install.sh | forced-oss-payload:install.sh | forwarder-auto-github:install.sh | forwarder-invalid-metadata:install.sh | canonical:install.sh | speed-probe-*:install.sh) cp "$ROOT_DIR/install.sh" "$output" ;;
- 404:penguin-*) exit 22 ;;
- network:penguin-*) exit 7 ;;
outer-sha-mismatch:penguin-*.sha256) printf '%064d %s\n' 0 "${base%.sha256}" > "$output" ;;
outer-sha-mismatch:penguin-*) cp "$ARTIFACT_DIR/$base" "$output" ;;
inner-sha-mismatch:penguin-*.sha256) cp "$BAD_BUNDLE.sha256" "$output" ;;
inner-sha-mismatch:penguin-*) cp "$BAD_BUNDLE" "$output" ;;
- speed-probe-*:penguin-*.sha256) cp "$ARTIFACT_DIR/$base" "$output" ;;
- speed-probe-*:penguin-*) cp "$ARTIFACT_DIR/$base" "$output" ;;
- primary-network:penguin-*.sha256) cp "$ARTIFACT_DIR/$base" "$output" ;;
- primary-network:penguin-*) cp "$ARTIFACT_DIR/$base" "$output" ;;
- forced-oss-payload:penguin-*.sha256) cp "$ARTIFACT_DIR/$base" "$output" ;;
- forced-oss-payload:penguin-*) cp "$ARTIFACT_DIR/$base" "$output" ;;
+ network:penguin-*) exit 7 ;;
+ 404:penguin-*) exit 22 ;;
legacy:penguin-*.sha256) cp "$LEGACY_ARCHIVE.sha256" "$output" ;;
legacy:penguin-*) cp "$LEGACY_ARCHIVE" "$output" ;;
- canonical:penguin-*.sha256) cp "$ARTIFACT_DIR/$base" "$output" ;;
- canonical:penguin-*) cp "$ARTIFACT_DIR/$base" "$output" ;;
+ *:penguin-*.sha256) cp "$ARTIFACT_DIR/$base" "$output" ;;
+ *:penguin-*) cp "$ARTIFACT_DIR/$base" "$output" ;;
*) echo "unexpected fixture request: $url" >&2; exit 2 ;;
esac
-if [ -n "$writeout" ]; then
- case "$MODE:$url" in
- speed-probe-github-fast:https://github.com/*/probe-1m.bin) printf '%s' '0.020 0.120 8738133' ;;
- speed-probe-github-fast:*aliyuncs.com*/probe-1m.bin) printf '%s' '0.100 2.100 499321' ;;
- # GitHub under the 262144 minimum, mirror well past 1.5x it: worth paying for.
- speed-probe-oss-clearly-faster:https://github.com/*/probe-1m.bin) printf '%s' '0.020 10.240 102400' ;;
- speed-probe-oss-clearly-faster:*aliyuncs.com*/probe-1m.bin) printf '%s' '0.020 3.413 307200' ;;
- # GitHub equally slow, mirror only 1.4x faster: not worth paying for, GitHub keeps it.
- speed-probe-oss-not-worth-switching:https://github.com/*/probe-1m.bin) printf '%s' '0.020 10.240 102400' ;;
- speed-probe-oss-not-worth-switching:*aliyuncs.com*/probe-1m.bin) printf '%s' '0.020 7.314 143360' ;;
- speed-probe-github-fast:*) printf '%s' '0.020 0.060 1092266' ;;
- *) printf '%s' '0.010 0.020 3276800' ;;
- esac
-fi
EOF
chmod +x "$STUB_BIN/curl"
-export ARTIFACT_DIR BAD_BUNDLE LEGACY_ARCHIVE ROOT_DIR PROBE64 PROBE1M PROBE64_HASH PROBE1M_HASH HOST_ASSET HOST_ASSET_HASH SPEED_PROBE_ASSET_SIZE
+export ARTIFACT_DIR BAD_BUNDLE LEGACY_ARCHIVE
run_online_case() {
name="$1"
@@ -517,28 +449,17 @@ run_online_case() {
download_fallback_base_url="${7:-}"
installer_path="${8:-$ROOT_DIR/install.sh}"
source_mode="${9:-auto}"
- speed_probe="${10:-0}"
CASE_LOG="$WORK_DIR/$name.log"
CASE_OUTPUT="$WORK_DIR/$name.output"
CASE_INSTALL="$WORK_DIR/$name-install"
: > "$CASE_LOG"
set +e
- if [ "$speed_probe" = "__unset" ]; then
- unset PENGUIN_DOWNLOAD_SPEED_PROBE
- REQUEST_LOG="$CASE_LOG" MODE="$mode" PATH="$STUB_BIN:$PATH" \
- HOME="$WORK_DIR/$name-home" PENGUIN_INSTALL_DIR="$CASE_INSTALL" \
- PENGUIN_VERSION="$version" PENGUIN_DOWNLOAD_BASE_URL="$download_base_url" \
- PENGUIN_DOWNLOAD_FALLBACK_BASE_URL="$download_fallback_base_url" \
- PENGUIN_DOWNLOAD_SOURCE="$source_mode" \
- sh "$installer_path" >"$CASE_OUTPUT" 2>&1
- else
- REQUEST_LOG="$CASE_LOG" MODE="$mode" PATH="$STUB_BIN:$PATH" \
- HOME="$WORK_DIR/$name-home" PENGUIN_INSTALL_DIR="$CASE_INSTALL" \
- PENGUIN_VERSION="$version" PENGUIN_DOWNLOAD_BASE_URL="$download_base_url" \
- PENGUIN_DOWNLOAD_FALLBACK_BASE_URL="$download_fallback_base_url" \
- PENGUIN_DOWNLOAD_SOURCE="$source_mode" PENGUIN_DOWNLOAD_SPEED_PROBE="$speed_probe" \
- sh "$installer_path" >"$CASE_OUTPUT" 2>&1
- fi
+ REQUEST_LOG="$CASE_LOG" MODE="$mode" PATH="$STUB_BIN:$PATH" \
+ HOME="$WORK_DIR/$name-home" PENGUIN_INSTALL_DIR="$CASE_INSTALL" \
+ PENGUIN_VERSION="$version" PENGUIN_DOWNLOAD_BASE_URL="$download_base_url" \
+ PENGUIN_DOWNLOAD_FALLBACK_BASE_URL="$download_fallback_base_url" \
+ PENGUIN_DOWNLOAD_SOURCE="$source_mode" \
+ sh "$installer_path" >"$CASE_OUTPUT" 2>&1
status=$?
set -e
if [ "$expected" = "success" ]; then
@@ -550,82 +471,84 @@ run_online_case() {
|| fail_test "$name made an unexpected number of requests"
}
-run_online_case canonical canonical "" success 3
+# Unstamped source-tree installer: no embedded tag, so it follows GitHub's "latest" release.
+run_online_case canonical canonical "" success 2
[ "$("$WORK_DIR/canonical-install/bin/penguin" --version)" = "fixture-old" ] \
|| fail_test "canonical online install did not produce a working command"
-grep -q "/latest.json\$" "$WORK_DIR/canonical.log" \
- || fail_test "unstamped installer did not resolve the OSS latest metadata"
-grep -q "/releases/v0.0.0-test/$HOST_ASSET\$" "$WORK_DIR/canonical.log" \
- || fail_test "unstamped installer did not lock the resolved OSS release"
+[ "$(sed -n '1p' "$WORK_DIR/canonical.log")" = \
+ "https://github.com/lmliheng/Adelie/releases/latest/download/$HOST_ASSET" ] \
+ || fail_test "unstamped installer did not use the latest GitHub release"
+! grep -qi "aliyuncs" "$WORK_DIR/canonical.log" \
+ || fail_test "installer still reaches the retired OSS mirror"
+# A stamped release installer uses its own immutable tag and never resolves "latest".
run_online_case stamped canonical "" success 2 "" "" "$STAMPED_INSTALLER"
[ "$(sed -n '1p' "$WORK_DIR/stamped.log")" = \
- "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test/$HOST_ASSET" ] \
- || fail_test "stamped installer did not select its own immutable OSS release"
-! grep -q "/latest.json\$" "$WORK_DIR/stamped.log" \
- || fail_test "stamped installer unexpectedly resolved latest metadata"
-
-run_online_case stamped-fallback primary-network "" success 3 "" "" "$STAMPED_INSTALLER"
-[ "$(sed -n '1p' "$WORK_DIR/stamped-fallback.log")" = \
- "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test/$HOST_ASSET" ] \
- || fail_test "stamped installer did not try its own OSS release first"
-grep -q "github.com/.*/releases/download/v0.0.0-test/$HOST_ASSET\$" "$WORK_DIR/stamped-fallback.log" \
- || fail_test "stamped installer did not fall back to the same GitHub version"
-
-run_online_case speed-probe-github-fast speed-probe-github-fast "" success 6 "" "" "$STAMPED_INSTALLER" auto 1
-[ "$(grep -c "/$HOST_ASSET\$" "$WORK_DIR/speed-probe-github-fast.log" | tr -d ' ')" -eq 1 ] \
- || fail_test "speed probe selected more than one primary bundle download"
-grep -q "github.com/.*/releases/download/v0.0.0-test/$HOST_ASSET\$" "$WORK_DIR/speed-probe-github-fast.log" \
- || fail_test "speed probe did not select GitHub when it met the minimum speed"
-run_online_case speed-probe-default-on speed-probe-github-fast "" success 6 "" "" "$STAMPED_INSTALLER" auto __unset
-grep -q "github.com/.*/releases/download/v0.0.0-test/$HOST_ASSET\$" "$WORK_DIR/speed-probe-default-on.log" \
- || fail_test "speed probe was not enabled by default"
-# Below the minimum the mirror is measured too, which is the seventh request of these two cases.
-run_online_case speed-probe-oss-clearly-faster speed-probe-oss-clearly-faster "" success 7 "" "" "$STAMPED_INSTALLER" auto 1
-grep -q "aliyuncs.com/.*/probe-1m.bin\$" "$WORK_DIR/speed-probe-oss-clearly-faster.log" \
- || fail_test "speed probe did not measure the OSS mirror once GitHub was below the minimum speed"
-grep -q "penguin-harness-releases.oss-cn-beijing.aliyuncs.com/.*/$HOST_ASSET\$" "$WORK_DIR/speed-probe-oss-clearly-faster.log" \
- || fail_test "speed probe did not switch to OSS when it was clearly faster than a slow GitHub"
-
-run_online_case speed-probe-oss-not-worth-switching speed-probe-oss-not-worth-switching "" success 7 "" "" "$STAMPED_INSTALLER" auto 1
-grep -q "github.com/.*/releases/download/v0.0.0-test/$HOST_ASSET\$" "$WORK_DIR/speed-probe-oss-not-worth-switching.log" \
- || fail_test "speed probe left GitHub even though OSS was not faster by the switch ratio"
-
-run_online_case speed-probe-missing-manifest speed-probe-missing-manifest "" success 4 "" "" "$STAMPED_INSTALLER" auto 1
-grep -q "Download source test was inconclusive" "$WORK_DIR/speed-probe-missing-manifest.output" \
- || fail_test "missing speed probe manifest did not fall back to the compatible source policy"
+ "https://github.com/lmliheng/Adelie/releases/download/v0.0.0-test/$HOST_ASSET" ] \
+ || fail_test "stamped installer did not select its own immutable release"
+! grep -q "/latest/" "$WORK_DIR/stamped.log" \
+ || fail_test "stamped installer unexpectedly resolved the latest release"
+# GitHub is an accepted explicit source mode and behaves like auto.
run_online_case stamped-github canonical "" success 2 "" "" "$STAMPED_INSTALLER" github
grep -q "github.com/.*/releases/download/v0.0.0-test/$HOST_ASSET\$" "$WORK_DIR/stamped-github.log" \
- || fail_test "stamped installer did not honor forced GitHub mode"
+ || fail_test "stamped installer did not honor explicit GitHub mode"
+
+# The retired OSS mode is rejected before any request leaves the process.
+run_online_case source-mode-oss canonical "" failure 0 "" "" "$ROOT_DIR/install.sh" oss
+grep -q "PENGUIN_DOWNLOAD_SOURCE must be auto or github" "$WORK_DIR/source-mode-oss.output" \
+ || fail_test "retired PENGUIN_DOWNLOAD_SOURCE=oss was not rejected"
+
+# The speed probe is gone: its switch must not exist in either installer...
+! grep -q "PENGUIN_DOWNLOAD_SPEED_PROBE" "$ROOT_DIR/install.sh" \
+ || fail_test "install.sh still reads PENGUIN_DOWNLOAD_SPEED_PROBE"
+! grep -q "PENGUIN_DOWNLOAD_SPEED_PROBE" "$ROOT_DIR/install.ps1" \
+ || fail_test "install.ps1 still reads PENGUIN_DOWNLOAD_SPEED_PROBE"
+# ...and setting it must not change the download flow.
+SPEED_PROBE_LOG="$WORK_DIR/speed-probe-ignored.log"
+: > "$SPEED_PROBE_LOG"
+REQUEST_LOG="$SPEED_PROBE_LOG" MODE=canonical PATH="$STUB_BIN:$PATH" \
+ HOME="$WORK_DIR/speed-probe-ignored-home" PENGUIN_INSTALL_DIR="$WORK_DIR/speed-probe-ignored-install" \
+ PENGUIN_DOWNLOAD_SPEED_PROBE=1 PENGUIN_DOWNLOAD_SOURCE=auto \
+ sh "$ROOT_DIR/install.sh" >"$WORK_DIR/speed-probe-ignored.output" 2>&1 \
+ || fail_test "install failed while PENGUIN_DOWNLOAD_SPEED_PROBE was set"
+[ "$(wc -l < "$SPEED_PROBE_LOG" | tr -d ' ')" -eq 2 ] \
+ || fail_test "PENGUIN_DOWNLOAD_SPEED_PROBE still changes the download flow"
+
+# An explicit base URL overrides source selection entirely.
run_online_case download-base-override canonical "" success 2 \
- "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test" ""
-grep -q "OSS mirror" "$WORK_DIR/download-base-override.output" \
- || fail_test "download base override did not identify the OSS mirror"
-! grep -q "aliyuncs.com" "$WORK_DIR/download-base-override.output" \
- || fail_test "download base override exposed the OSS URL in normal output"
+ "https://mirror.example.test/releases/v0.0.0-test"
+[ "$(sed -n '1p' "$WORK_DIR/download-base-override.log")" = \
+ "https://mirror.example.test/releases/v0.0.0-test/$HOST_ASSET" ] \
+ || fail_test "download base override did not take precedence"
+grep -q "configured mirror" "$WORK_DIR/download-base-override.output" \
+ || fail_test "download base override did not label the configured mirror"
+
+# A transport failure on the primary base URL falls back to the configured fallback.
run_online_case download-fallback primary-network "" success 3 \
- "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test" \
- "https://github.com/Prism-Shadow/penguin-harness/releases/download/v0.0.0-test"
+ "https://primary.example.test/releases/v0.0.0-test" \
+ "https://fallback.example.test/releases/v0.0.0-test"
[ "$(sed -n '1p' "$WORK_DIR/download-fallback.log")" = \
- "https://penguin-harness-releases.oss-cn-beijing.aliyuncs.com/releases/v0.0.0-test/$HOST_ASSET" ] \
+ "https://primary.example.test/releases/v0.0.0-test/$HOST_ASSET" ] \
|| fail_test "download fallback did not try the primary source first"
-grep -q "github.com/.*/releases/download/v0.0.0-test/$HOST_ASSET\$" "$WORK_DIR/download-fallback.log" \
- || fail_test "download fallback did not use the same-version GitHub source"
-! grep -q "aliyuncs.com" "$WORK_DIR/download-fallback.output" \
- || fail_test "download fallback exposed the OSS URL in normal output"
-run_online_case fallback-without-base primary-network "" success 3 "" \
+grep -q "fallback.example.test/releases/v0.0.0-test/$HOST_ASSET\$" "$WORK_DIR/download-fallback.log" \
+ || fail_test "download fallback did not use the configured fallback"
+
+# A fallback without a base URL is ignored: the stamped installer keeps its own tag.
+run_online_case fallback-without-base canonical "" success 2 "" \
"https://example.invalid/releases/v0.0.0-test" "$STAMPED_INSTALLER"
! grep -q "example.invalid" "$WORK_DIR/fallback-without-base.log" \
- || fail_test "fallback without base should not override auto/source fallback"
-grep -q "github.com/.*/releases/download/v0.0.0-test/$HOST_ASSET\$" "$WORK_DIR/fallback-without-base.log" \
- || fail_test "fallback without base did not keep the internal same-version GitHub fallback"
-run_online_case outer-mismatch outer-sha-mismatch "" failure 3
-run_online_case inner-mismatch inner-sha-mismatch "" failure 3
-run_online_case latest-404 404 "" failure 2
-run_online_case pinned-network network v0.1.4 failure 2
+ || fail_test "fallback without base should not override the source-mode download"
+grep -q "releases/download/v0.0.0-test/$HOST_ASSET\$" "$WORK_DIR/fallback-without-base.log" \
+ || fail_test "fallback without base did not keep the release's own tag"
+
+run_online_case outer-mismatch outer-sha-mismatch "" failure 2
+run_online_case inner-mismatch inner-sha-mismatch "" failure 2
+run_online_case latest-404 404 "" failure 1
+run_online_case pinned-network network v0.1.4 failure 1
run_online_case pinned-legacy legacy v0.1.4 success 2
-grep -q "/releases/v0.1.4/$HOST_ASSET\$" "$WORK_DIR/pinned-legacy.log" \
- || fail_test "pinned legacy did not prefer the pinned OSS asset"
+[ "$(sed -n '1p' "$WORK_DIR/pinned-legacy.log")" = \
+ "https://github.com/lmliheng/Adelie/releases/download/v0.1.4/$HOST_ASSET" ] \
+ || fail_test "pinned legacy did not prefer the pinned release asset"
echo "Installer bundle, offline, rollback and online tests passed."