From a34860eefe2e9b7f79fab6d2b85b1d09aa9ce797 Mon Sep 17 00:00:00 2001 From: ruv Date: Tue, 10 Nov 2026 23:04:49 -0500 Subject: [PATCH] fix(release): bump cuda-rust-wasm to 0.2.1 so the 2.0.2 release can pass its byte gate; 10-minute crates.io wait PR #216 bumped cuda-wasm (npm) to 2.0.1 but left the cuda-rust-wasm crate at 0.2.0, which is already on crates.io. The crate archive packs the same directory, including package.json, README.md and CHANGELOG.md, so the new candidate no longer matches the published 0.2.0 bytes and publish-candidates.py would stop the protected release with "Published version exists with different bytes: cuda-rust-wasm". Verified by packaging locally and diffing against static.crates.io: package.json and CHANGELOG.md differ; the three ruv-swarm crates match. - cuda-rust-wasm 0.2.0 -> 0.2.1 (Cargo.toml, Cargo.lock). No Rust code change. - cuda-wasm README: drop the "staged / publication is a separate step" wording (0.2.0 is already published) and install 0.2.1. - cuda-wasm keywords: add cuda2rust, code-generation, nodejs (6 -> 9). - publish-npm-candidates.py: the public consumer installs the cuda2rust that this release publishes (=0.2.1) instead of =0.2.0. - publish-candidates.py: replace the 24 x 5 s crates.io visibility loop with the same 600 s, 5/10/20/30/60 s backoff the npm path uses; a timeout reports "not publicly downloadable" instead of failing silently. Three new tests. Checked: scripts/tests 68/68; cargo build --locked (cuda2rust 0.2.1); cuda-wasm npm test 18/18; cli-integration against the built binary. Co-Authored-By: claude-flow --- cuda-wasm/CHANGELOG.md | 2 ++ cuda-wasm/Cargo.lock | 2 +- cuda-wasm/Cargo.toml | 2 +- cuda-wasm/README.md | 6 ++-- cuda-wasm/package.json | 5 ++- scripts/publish-candidates.py | 32 ++++++++++++----- scripts/publish-npm-candidates.py | 2 +- scripts/tests/test_publish_candidates.py | 44 ++++++++++++++++++++++++ 8 files changed, 80 insertions(+), 15 deletions(-) diff --git a/cuda-wasm/CHANGELOG.md b/cuda-wasm/CHANGELOG.md index f007ee80..c6ff9c12 100644 --- a/cuda-wasm/CHANGELOG.md +++ b/cuda-wasm/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Package metadata - Set `homepage` to https://ruv.io. No code or dependency change. +- Add truthful search keywords (`cuda2rust`, `code-generation`, `nodejs`). +- The `cuda-rust-wasm` crate moves to 0.2.1 because its archive contains this directory's `package.json`, README and changelog; crates.io 0.2.0 holds the old bytes. No Rust code change. ## [2.0.0] - Unreleased diff --git a/cuda-wasm/Cargo.lock b/cuda-wasm/Cargo.lock index f7d9c719..5ad71592 100644 --- a/cuda-wasm/Cargo.lock +++ b/cuda-wasm/Cargo.lock @@ -648,7 +648,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] name = "cuda-rust-wasm" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anyhow", "approx", diff --git a/cuda-wasm/Cargo.toml b/cuda-wasm/Cargo.toml index d79105ec..43ac584b 100644 --- a/cuda-wasm/Cargo.toml +++ b/cuda-wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cuda-rust-wasm" -version = "0.2.0" +version = "0.2.1" edition = "2021" authors = ["CUDA-Rust Team"] description = "CUDA to Rust transpiler with WebGPU/WASM support" diff --git a/cuda-wasm/README.md b/cuda-wasm/README.md index 7d7713d1..ea8b6078 100644 --- a/cuda-wasm/README.md +++ b/cuda-wasm/README.md @@ -2,7 +2,7 @@ `cuda-rust-wasm` is an experimental Rust toolkit for reading a subset of CUDA C++, generating Rust or WGSL text, and experimenting with CPU reference kernels. CUDA is an NVIDIA trademark; this project is independent of NVIDIA. -The Rust library and `cuda2rust` command have a staged 0.2.0 release. The `cuda-wasm` npm package has a staged 2.0.1 release with a smaller, working contract: a Node.js wrapper around that command, returning Rust or WGSL **source text**. These versions are prepared in this checkout; registry publication is a separate step. +The Rust library and `cuda2rust` command are published on crates.io as `cuda-rust-wasm` 0.2.1. The `cuda-wasm` npm package (2.0.1) has a smaller, working contract: a Node.js wrapper around that command, returning Rust or WGSL **source text**. ![CUDA source passes through the Node wrapper to a trusted cuda2rust executable, which returns Rust or WGSL source for separate validation.](docs/assets/source-flow.svg) @@ -10,11 +10,11 @@ The Rust library and `cuda2rust` command have a staged 0.2.0 release. The `cuda- Node.js 22.12 or newer and a trusted `cuda2rust` 0.2.0-or-newer executable are required. npm installation has no install hooks, downloads no executables, and builds no native modules. The package has no npm runtime dependencies. -After the staged versions are published: +Install both: ```bash npm install cuda-wasm@2 -cargo install cuda-rust-wasm --version 0.2.0 --locked +cargo install cuda-rust-wasm --version 0.2.1 --locked ``` For this checkout, build the real command and point the wrapper at it: diff --git a/cuda-wasm/package.json b/cuda-wasm/package.json index 8f45029f..d8eaa6c5 100644 --- a/cuda-wasm/package.json +++ b/cuda-wasm/package.json @@ -36,7 +36,10 @@ "rust", "wgsl", "cli", - "source-generation" + "source-generation", + "cuda2rust", + "code-generation", + "nodejs" ], "author": { "name": "CUDA-WASM Team", diff --git a/scripts/publish-candidates.py b/scripts/publish-candidates.py index a05f6455..29282dc0 100644 --- a/scripts/publish-candidates.py +++ b/scripts/publish-candidates.py @@ -20,6 +20,9 @@ ROOT = Path(__file__).resolve().parents[1] API = 'https://crates.io/api/v1' USER_AGENT = 'ruv-fann-release (https://github.com/ruvnet/ruv-FANN)' +# static.crates.io can take several minutes to serve a newly uploaded crate. +VISIBILITY_TIMEOUT = 600 +VISIBILITY_DELAYS = (5, 10, 20, 30, 60) def sha(data): @@ -111,6 +114,21 @@ def downloaded(name, version): raise +def wait_public(name, version, timeout=VISIBILITY_TIMEOUT, sleep=time.sleep, clock=time.monotonic): + """Return the public crate bytes, or None if static.crates.io still lacks them past the deadline.""" + deadline = clock() + timeout + attempt = 0 + while True: + public = downloaded(name, version) + if public is not None: + return public + remaining = deadline - clock() + if remaining <= 0: + return None + sleep(min(VISIBILITY_DELAYS[min(attempt, len(VISIBILITY_DELAYS) - 1)], remaining)) + attempt += 1 + + def publish(archive, data, digest, token): existing = downloaded(data['name'], data['vers']) if existing is not None: @@ -132,14 +150,12 @@ def publish(archive, data, digest, token): raise RuntimeError(f'Crates upload HTTP {error.code}: {detail}') from None if result.get('errors'): raise RuntimeError(str(result['errors']).replace(token, '[REDACTED]')) - for _ in range(24): - public = downloaded(data['name'], data['vers']) - if public is not None: - if sha(public) != digest: - raise ValueError('Public bytes differ from verified candidate') - return 'published-and-byte-verified' - time.sleep(5) - raise RuntimeError('Published, but public download is not yet available') + public = wait_public(data['name'], data['vers']) + if public is None: + raise RuntimeError(f"Published, but {data['name']} {data['vers']} was not publicly downloadable within {VISIBILITY_TIMEOUT}s; rerun the failed job to verify the bytes") + if sha(public) != digest: + raise ValueError('Public bytes differ from verified candidate') + return 'published-and-byte-verified' def main(): diff --git a/scripts/publish-npm-candidates.py b/scripts/publish-npm-candidates.py index d0a3a6d9..cb73df0b 100644 --- a/scripts/publish-npm-candidates.py +++ b/scripts/publish-npm-candidates.py @@ -155,7 +155,7 @@ def main(): stream.seek(0);json.dump({'sourceSha':head(),'packages':published},stream,indent=2);stream.truncate();stream.flush() return # Install the Cargo compiler and dense example from public crates.io too. - run(['cargo','install','cuda-rust-wasm','--version','=0.2.0','--locked','--bin','cuda2rust','--root',str(base/'public-compiler')],base) + run(['cargo','install','cuda-rust-wasm','--version','=0.2.1','--locked','--bin','cuda2rust','--root',str(base/'public-compiler')],base) consumer(base/'npm-public-consumer',[r['name']+'@'+r['version'] for r in record['packages']],record['packages'],base/'public-compiler/bin/cuda2rust') rust = base/'rust-public-consumer';(rust/'src').mkdir(parents=True) (rust/'Cargo.toml').write_text('[package]\nname="release-consumer"\nversion="0.0.0"\nedition="2021"\n[dependencies]\nruv-fann={version="=0.2.2",default-features=false,features=["std","serde"]}\nruv-fann-candle="=0.1.0"\n') diff --git a/scripts/tests/test_publish_candidates.py b/scripts/tests/test_publish_candidates.py index 304fc220..c652b507 100644 --- a/scripts/tests/test_publish_candidates.py +++ b/scripts/tests/test_publish_candidates.py @@ -85,4 +85,48 @@ def test_changed_archive_is_rejected_before_upload(self): upload.assert_not_called() + def test_public_download_waits_past_two_minutes_with_backoff(self): + clock = Clock() + calls = [] + def fake(name, version): + calls.append((name, version)) + return b'crate' if clock.now >= 300 else None + with patch.object(publisher, 'downloaded', side_effect=fake): + self.assertEqual(publisher.wait_public('fixture', '1.0.0', sleep=clock.sleep, clock=clock.time), b'crate') + self.assertEqual(clock.sleeps[:5], [5, 10, 20, 30, 60]) + self.assertTrue(all(delay <= 60 for delay in clock.sleeps)) + self.assertEqual(calls[0], ('fixture', '1.0.0')) + + def test_public_download_gives_up_at_the_deadline(self): + clock = Clock() + with patch.object(publisher, 'downloaded', return_value=None): + self.assertIsNone(publisher.wait_public('fixture', '1.0.0', sleep=clock.sleep, clock=clock.time)) + self.assertEqual(clock.now, publisher.VISIBILITY_TIMEOUT) + + def test_upload_timeout_reports_visibility_not_byte_mismatch(self): + with tempfile.TemporaryDirectory() as directory: + archive = self.archive(directory, '[package]\nname="fixture"\nversion="1.0.0"') + response = io.BytesIO(b'{}') + response.__enter__ = lambda *a: response + response.__exit__ = lambda *a: False + with patch.object(publisher, 'downloaded', return_value=None), \ + patch.object(publisher.urllib.request, 'urlopen', return_value=response), \ + patch.object(publisher, 'wait_public', return_value=None): + with self.assertRaisesRegex(RuntimeError, 'not publicly downloadable'): + publisher.publish(archive, publisher.metadata(archive), publisher.sha(archive.read_bytes()), 'test-only') + + +class Clock: + def __init__(self): + self.now = 0 + self.sleeps = [] + + def time(self): + return self.now + + def sleep(self, seconds): + self.sleeps.append(seconds) + self.now += seconds + + if __name__ == '__main__': unittest.main()