Merge current master while preserving Photon sleep and recovery ownership

This commit is contained in:
Codex committed 2026-11-16 15:41:44 -06:00
commit a34fb0bb0e
93 files changed
+3473 -403

No files matched your search

+2 -1
View File
@@ -60,6 +60,7 @@ else
fi
release_info "==> Installing paperclipai@${version} into a clean prefix..."
verify_npm_installable "paperclipai@${version}" "$version" || release_fail "paperclipai@${version} did not install cleanly"
wait_for_npm_installable "paperclipai@${version}" "$version" "${NPM_INSTALL_VERIFY_TIMEOUT_SECONDS:-1200}" "${NPM_INSTALL_VERIFY_DELAY_SECONDS:-30}" \
|| release_fail "paperclipai@${version} did not install cleanly"
push_release_tag_at "$PUBLISH_REMOTE" "$tag_name" "$source_sha"
+30 -1
View File
@@ -572,12 +572,18 @@ wait_for_npm_package_versions() {
verify_npm_installable() {
local package_spec="$1"
local expected_version="$2"
local install_timeout_seconds="${3:-}"
local install_dir
local installed_version
local install=(npm install --prefix "" "$package_spec" --no-audit --no-fund)
install_dir="$(mktemp -d "${TMPDIR:-/tmp}/paperclip-release-install.XXXXXX")"
install[3]="$install_dir"
if [ -n "$install_timeout_seconds" ] && command -v timeout >/dev/null 2>&1; then
install=(timeout --kill-after=10 "$install_timeout_seconds" "${install[@]}")
fi
if ! npm install --prefix "$install_dir" "$package_spec" --no-audit --no-fund; then
if ! "${install[@]}"; then
rm -rf "$install_dir"
return 1
fi
@@ -588,6 +594,29 @@ verify_npm_installable() {
[ "$installed_version" = "$expected_version" ]
}
wait_for_npm_installable() {
local package_spec="$1"
local expected_version="$2"
local deadline_seconds="${3:-1200}"
local delay_seconds="${4:-30}"
local deadline=$(( $(date +%s) + deadline_seconds ))
local attempt=1
local remaining
while :; do
remaining=$(( deadline - $(date +%s) ))
[ "$remaining" -gt 0 ] || return 1
if verify_npm_installable "$package_spec" "$expected_version" "$remaining"; then
return 0
fi
remaining=$(( deadline - $(date +%s) ))
[ "$remaining" -gt 0 ] || return 1
release_warn "${package_spec} did not install yet (attempt ${attempt}, ${remaining}s left); a large tarball can lag its metadata. Retrying in $(( delay_seconds < remaining ? delay_seconds : remaining ))s."
sleep $(( delay_seconds < remaining ? delay_seconds : remaining ))
attempt=$((attempt + 1))
done
}
wait_for_release_registry_state() {
local attempts="${1:-12}"
local delay_seconds="${2:-5}"
+56 -5
View File
@@ -1,5 +1,5 @@
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { execFileSync, spawnSync } from "node:child_process";
import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -395,15 +395,22 @@ test("the workflow budget fails closed after the last registry check", () => {
assert.equal(result.calls.match(/^sleep /gm)?.length, budget.verifyAttempts - 1);
});
test("every publish job budgets for build time and four delayed packages", () => {
test("every publish job budgets for build time, four delayed packages and the install deadline", () => {
const { verifyAttempts, verifyDelaySeconds } = workflowVerifyBudget();
const pollingSeconds = (verifyAttempts - 1) * verifyDelaySeconds;
const requiredSeconds = 30 * 60 + 4 * pollingSeconds;
const releaseScript = readFileSync(new URL("./release.sh", import.meta.url), "utf8");
const installDeadlineSeconds = Number(releaseScript.match(/NPM_INSTALL_VERIFY_TIMEOUT_SECONDS:-(\d+)/)?.[1]);
assert.ok(installDeadlineSeconds > 0);
for (const job of ["publish_canary", "publish_nightly", "publish_beta", "publish_stable"]) {
for (const [job, requiredSeconds] of [
["publish_canary", 30 * 60 + 4 * pollingSeconds],
["publish_nightly", 30 * 60 + 4 * pollingSeconds + installDeadlineSeconds],
["publish_beta", 30 * 60 + 4 * pollingSeconds + installDeadlineSeconds],
["publish_stable", 30 * 60 + 4 * pollingSeconds + installDeadlineSeconds],
]) {
const body = releaseWorkflow.split(`\n ${job}:\n`)[1]?.split(/\n [a-z_]+:\n/)[0] ?? "";
const timeoutMinutes = Number(body.match(/^ timeout-minutes: (\d+)$/m)?.[1]);
assert.ok(timeoutMinutes * 60 > requiredSeconds, `${job} must leave time beyond build and polling`);
assert.ok(timeoutMinutes * 60 > requiredSeconds, `${job} must leave time beyond build, polling and the install deadline`);
}
});
@@ -497,3 +504,47 @@ test("a canary version is accepted only for the master commit whose position num
const side = fixture.git(fixture.repo, "rev-parse", "HEAD").trim();
assert.throws(() => confirm("2026.1116.0-canary.2600", side), /is not on origin\/master/);
});
function installRetryFixture({ failures = 0, hangSeconds = 0 }) {
const dir = mkdtempSync(join(tmpdir(), "paperclip-install-retry-"));
const bin = join(dir, "bin");
mkdirSync(bin);
const counter = join(dir, "attempts");
writeFileSync(counter, "0");
writeExecutable(join(bin, "npm"), `#!/usr/bin/env bash
n=$(( $(cat "${counter}") + 1 )); echo "$n" > "${counter}"
if [ "${hangSeconds}" -gt 0 ]; then sleep "${hangSeconds}"; fi
if [ "$n" -le "${failures}" ]; then echo "npm error code E404" >&2; exit 1; fi
prefix="$3"; mkdir -p "$prefix/node_modules/paperclipai"
printf '{"version":"1.2.3"}' > "$prefix/node_modules/paperclipai/package.json"
`);
const run = (deadline, delay = 0) => {
const started = Date.now();
const result = spawnSync("bash", ["-c", `source "${repoRoot}/scripts/release-lib.sh"; wait_for_npm_installable paperclipai@canary 1.2.3 ${deadline} ${delay}`],
{ encoding: "utf8", env: { ...process.env, PATH: `${bin}:${process.env.PATH}` } });
return { status: result.status, seconds: (Date.now() - started) / 1000, attempts: Number(readFileSync(counter, "utf8")), stderr: result.stderr };
};
return { run };
}
test("a release install is retried while its tarball lags the metadata", () => {
const recovered = installRetryFixture({ failures: 3 }).run(60);
assert.equal(recovered.status, 0);
assert.equal(recovered.attempts, 4);
assert.match(recovered.stderr, /attempt 3, \d+s left/);
assert.equal(installRetryFixture({}).run(60).attempts, 1);
});
const hasTimeoutCommand = spawnSync("bash", ["-c", "command -v timeout"], { encoding: "utf8" }).status === 0;
test("install retries stop at the deadline", () => {
const exhausted = installRetryFixture({ failures: 1000 }).run(3, 1);
assert.notEqual(exhausted.status, 0);
assert.ok(exhausted.seconds < 8, `took ${exhausted.seconds}s`);
});
test("an install that hangs is stopped at the deadline", { skip: !hasTimeoutCommand && "needs the timeout command (GNU coreutils)" }, () => {
const hung = installRetryFixture({ hangSeconds: 120 }).run(3, 1);
assert.notEqual(hung.status, 0);
assert.ok(hung.seconds < 20, `a hung install outlived the deadline: ${hung.seconds}s`);
});
+1 -1
View File
@@ -485,7 +485,7 @@ else
fi
release_info " Installing paperclipai@$DIST_TAG into a clean prefix..."
if ! verify_npm_installable "paperclipai@$DIST_TAG" "$TARGET_PUBLISH_VERSION"; then
if ! wait_for_npm_installable "paperclipai@$DIST_TAG" "$TARGET_PUBLISH_VERSION" "${NPM_INSTALL_VERIFY_TIMEOUT_SECONDS:-1200}" "${NPM_INSTALL_VERIFY_DELAY_SECONDS:-30}"; then
release_fail "paperclipai@$DIST_TAG did not install cleanly at expected version ${TARGET_PUBLISH_VERSION}"
fi
release_info " ✓ Clean-prefix install resolved ${TARGET_PUBLISH_VERSION}"