Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

refuse release archives the old typescript updater could install (#3275)

ktbdc0ae559420
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 7994a8bf58..e6d0224cb6 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -509,6 +509,31 @@ jobs:
sys.exit("hash continuity failed:\n" + "\n".join(failures))
print(f"hash continuity verified for all archives")
PY
+ # Prime Agent 0.9.8 (the TypeScript release) updates itself with its
+ # bundled installer, which installs any archive that carries install.sh,
+ # theme/prime.json, export-html/template.html and photon_rs_bg.wasm.
+ # The Rust archive lacks all four, and that is the only thing stopping a
+ # TS client from installing a Rust release into the TS layout (which
+ # breaks it). TS needs all four, so refusing a root-level install.sh
+ # keeps every Rust archive uninstallable by the TS updater.
+ - name: Refuse archives the TypeScript updater would install
+ run: |
+ set -euo pipefail
+ python3 - <<'PY'
+ import pathlib, sys, tarfile
+ incoming = pathlib.Path("incoming")
+ failures = []
+ for entry_dir in sorted(p for p in incoming.iterdir() if p.is_dir()):
+ for archive in sorted(entry_dir.glob("prime-agent-*.tar.gz")):
+ with tarfile.open(archive) as tar:
+ names = {pathlib.PurePosixPath(m.name).parts for m in tar.getmembers()}
+ if ("install.sh",) in names:
+ failures.append(f"{archive.name}: contains a root-level install.sh")
+ if failures:
+ sys.exit("a TypeScript Prime Agent updater could install these archives:\n"
+ + "\n".join(failures))
+ print("no archive carries the TypeScript installer layout")
+ PY
- name: Verify Linux decoder integrity against installed tar ELF
run: |
set -euo pipefail
diff --git a/crates/pa-cli/tests/release_workflow.rs b/crates/pa-cli/tests/release_workflow.rs
index 80d545cb39..6c2bc5a910 100644
--- a/crates/pa-cli/tests/release_workflow.rs
+++ b/crates/pa-cli/tests/release_workflow.rs
@@ -51,6 +51,9 @@ use sha2::{Digest, Sha256};
/// The fixture version the assembled artifacts carry.
const VERSION: &str = "0.9.9";
+/// The promote step that refuses archives a TS 0.9.8 updater would install.
+const TS_GUARD_STEP: &str = "Refuse archives the TypeScript updater would install";
+
/// The current build matrix (release.yml `build`): the four standalone
/// targets. The single-artifact case stands in for a trimmed matrix; the
/// four-target case is today's full release.
@@ -196,22 +199,25 @@ fn sha256_file(path: &Path) -> String {
}
/// One real (extractable) tar.gz archive: the staged `prime-agent` payload
-/// with deterministic member metadata, the `assemble_artifacts.py` shape.
-fn write_fixture_tarball(out_path: &Path) {
+/// with deterministic member metadata, the `assemble_artifacts.py` shape,
+/// plus any `extra_members`.
+fn write_fixture_tarball(out_path: &Path, extra_members: &[&str]) {
let file = fs::File::create(out_path).expect("create the fixture archive");
let encoder = flate2::write::GzEncoder::new(file, flate2::Compression::default());
let mut archive = tar::Builder::new(encoder);
let payload = VERSION.as_bytes().to_vec();
- let mut header = tar::Header::new_gnu();
- header.set_size(payload.len() as u64);
- header.set_mode(0o755);
- header.set_uid(0);
- header.set_gid(0);
- header.set_mtime(0);
- header.set_cksum();
- archive
- .append_data(&mut header, "prime-agent", payload.as_slice())
- .expect("stage the fixture payload");
+ for name in std::iter::once("prime-agent").chain(extra_members.iter().copied()) {
+ let mut header = tar::Header::new_gnu();
+ header.set_size(payload.len() as u64);
+ header.set_mode(0o755);
+ header.set_uid(0);
+ header.set_gid(0);
+ header.set_mtime(0);
+ header.set_cksum();
+ archive
+ .append_data(&mut header, name, payload.as_slice())
+ .expect("stage the fixture payload");
+ }
archive
.into_inner()
.expect("finish the tar stream")
@@ -223,9 +229,13 @@ fn write_fixture_tarball(out_path: &Path) {
/// per-target manifest (`assemble_artifacts.py`'s schema). Returns the manifest
/// row the merged manifest must carry back.
fn write_artifact(dir: &Path, target: &str) -> serde_json::Value {
+ write_artifact_with(dir, target, &[])
+}
+
+fn write_artifact_with(dir: &Path, target: &str, extra_members: &[&str]) -> serde_json::Value {
fs::create_dir_all(dir).expect("create the artifact directory");
let archive_name = format!("prime-agent-{VERSION}-{target}.tar.gz");
- write_fixture_tarball(&dir.join(&archive_name));
+ write_fixture_tarball(&dir.join(&archive_name), extra_members);
let sha256 = sha256_file(&dir.join(&archive_name));
fs::write(
dir.join("SHA256SUMS"),
@@ -287,6 +297,7 @@ fn run_promote_gates(cwd: &Path, steps: &[Step]) -> (String, serde_json::Value)
steps,
"Verify hash continuity (artifacts match build-job manifests)",
)];
+ let ts_guard = &steps[step_position(steps, TS_GUARD_STEP)];
let merge = &steps[step_position(steps, "Merge per-target manifests + SHA256SUMS")];
let normalize_stdout = assert_success(&run_step(cwd, normalize), "normalize download layout");
@@ -295,6 +306,7 @@ fn run_promote_gates(cwd: &Path, steps: &[Step]) -> (String, serde_json::Value)
verify_stdout.contains("hash continuity verified for all archives"),
"hash continuity must report verifying the archives"
);
+ assert_success(&run_step(cwd, ts_guard), TS_GUARD_STEP);
assert_success(&run_step(cwd, merge), "merge per-target manifests");
let merged: serde_json::Value = serde_json::from_str(
@@ -367,6 +379,56 @@ fn promote_download_layout_contract() {
download < normalize && normalize < verify && verify < merge,
"the layout must be normalized between the download and the per-artifact gates"
);
+ let ts_guard = step_position(&steps, TS_GUARD_STEP);
+ assert!(
+ normalize < ts_guard && ts_guard < merge,
+ "the TS-updater gate must check every archive before anything is merged or published"
+ );
+}
+
+/// A TS 0.9.8 updater installs any archive that carries install.sh (plus
+/// three other files the Rust archive lacks) into the TS layout. The promote
+/// gate must refuse an archive with a root-level install.sh, and only that
+/// root-level file: the same name deeper in the tree is not what TS reads.
+#[test]
+fn an_archive_with_a_root_install_sh_fails_the_ts_updater_gate() {
+ let Some(_python3) = python3_binary((3, 0)) else {
+ return;
+ };
+ let steps = promote_steps();
+ let ts_guard = &steps[step_position(&steps, TS_GUARD_STEP)];
+
+ let cwd = tempfile::tempdir().expect("scratch dir");
+ let incoming = cwd.path().join("incoming");
+ write_artifact(
+ &incoming.join(format!("artifacts-{}", TARGETS[0])),
+ TARGETS[0],
+ );
+ write_artifact_with(
+ &incoming.join(format!("artifacts-{}", TARGETS[1])),
+ TARGETS[1],
+ &["skills/install.sh"],
+ );
+ let output = assert_success(&run_step(cwd.path(), ts_guard), TS_GUARD_STEP);
+ assert!(output.contains("no archive carries the TypeScript installer layout"));
+
+ write_artifact_with(
+ &incoming.join(format!("artifacts-{}", TARGETS[2])),
+ TARGETS[2],
+ &["install.sh"],
+ );
+ let output = assert_failure(&run_step(cwd.path(), ts_guard), TS_GUARD_STEP);
+ assert!(
+ output.contains(&format!(
+ "prime-agent-{VERSION}-{}.tar.gz: contains a root-level install.sh",
+ TARGETS[2]
+ )),
+ "the gate must name the offending archive\n{output}"
+ );
+ assert!(
+ !output.contains(TARGETS[1]),
+ "a nested install.sh must not trip the gate\n{output}"
+ );
}
/// A one-target release (the TS test's beta-only/stable-only case): the
diff --git a/scripts/release/verify_release.py b/scripts/release/verify_release.py
index 84f2cb20da..4b69091b60 100644
--- a/scripts/release/verify_release.py
+++ b/scripts/release/verify_release.py
@@ -36,6 +36,8 @@ from bundle_catalog import validate_bundled_catalog_dir
from assemble_artifacts import TARGET_ALIASES, RUNTIME_EXCLUDED_NAMES, RUNTIME_EXCLUDED_SUFFIXES
# Must mirror STAGED_ENTRIES in assemble_artifacts.py and §5 of the design doc.
+# Never add a root-level install.sh: it is what lets a TypeScript 0.9.8
+# updater install the archive (release.yml's promote job refuses it).
# Continuous builds additionally stage the package.json version manifest.
EXPECTED_TOP_LEVEL = {
"prime-agent",