From beb7c4616278d563e67b5ab6f937e221335ffa6f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 15:17:58 +0200 Subject: [PATCH 1/4] Interop guard: accept cultnet-rs's vendored schema copies The consolidation guard rejected every *.schema.json outside contracts/cultnet/, including the R-AB byte copies vendored into packages/cultnet-rs/contracts/cultnet/. The interop workflow has been red at that step on main ever since, so no later cross-runtime step ran. The guard now accepts that one path; drift of those copies is judged by the Rust equality test in tests/schema_discovery_contracts.rs. The retired-namespace check is unchanged. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/cultnet-interop.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cultnet-interop.yml b/.github/workflows/cultnet-interop.yml index 5f8936bf..680d474e 100644 --- a/.github/workflows/cultnet-interop.yml +++ b/.github/workflows/cultnet-interop.yml @@ -69,7 +69,9 @@ jobs: shell: pwsh run: | $ErrorActionPreference = "Stop" - $stray = git ls-files '*.schema.json' | Where-Object { $_ -notmatch '^contracts/cultnet/' } + # packages/cultnet-rs/contracts/cultnet/ holds R-AB's vendored byte copies (the crate must build + # when copied alone). Their drift guard is packages/cultnet-rs/tests/schema_discovery_contracts.rs:74-99. + $stray = git ls-files '*.schema.json' | Where-Object { $_ -notmatch '^(packages/cultnet-rs/)?contracts/cultnet/' } # -I skips binary files: unity/org.gamecult.cultlib/Runtime/Plugins/GameCult.Networking.dll # still embeds the retired namespace until it is rebuilt (REC-032 D4, deferred). $oldNamespace = git grep -I -lE 'GameCult/cultnet-ts/(integration/)?contracts' -- ':!.voidbot' From 52abce91910b049d92db35a2ac163799be5d747c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 15:32:28 +0200 Subject: [PATCH 2/4] Interop workflow: every command in a step counts The Windows runner's default pwsh does not stop when a native command fails, so a multi-command step reported only its last command: a failing cultnet-py suite went green inside "Verify Python RUDP reliability". The job now defaults to Git Bash, which the runner starts with -e -o pipefail. The pwsh consolidation guard checks git ls-files' exit code instead of treating a failed listing as clean. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/cultnet-interop.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cultnet-interop.yml b/.github/workflows/cultnet-interop.yml index 680d474e..9072e0cb 100644 --- a/.github/workflows/cultnet-interop.yml +++ b/.github/workflows/cultnet-interop.yml @@ -12,6 +12,13 @@ jobs: name: C# / TypeScript / Rust / Python / Kotlin runs-on: windows-latest timeout-minutes: 60 + # Windows runners default to pwsh, which does not stop when a native command fails: a + # multi-command step reported only its last command, and a failing cultnet-py suite + # went green that way. Git Bash runs as `bash -e -o pipefail`, so every command counts. + # Steps that name `shell: pwsh` check $LASTEXITCODE themselves. + defaults: + run: + shell: bash env: DOTNET: dotnet @@ -71,7 +78,9 @@ jobs: $ErrorActionPreference = "Stop" # packages/cultnet-rs/contracts/cultnet/ holds R-AB's vendored byte copies (the crate must build # when copied alone). Their drift guard is packages/cultnet-rs/tests/schema_discovery_contracts.rs:74-99. - $stray = git ls-files '*.schema.json' | Where-Object { $_ -notmatch '^(packages/cultnet-rs/)?contracts/cultnet/' } + $tracked = git ls-files '*.schema.json' + if ($LASTEXITCODE -ne 0) { throw "git ls-files failed" } + $stray = $tracked | Where-Object { $_ -notmatch '^(packages/cultnet-rs/)?contracts/cultnet/' } # -I skips binary files: unity/org.gamecult.cultlib/Runtime/Plugins/GameCult.Networking.dll # still embeds the retired namespace until it is rebuilt (REC-032 D4, deferred). $oldNamespace = git grep -I -lE 'GameCult/cultnet-ts/(integration/)?contracts' -- ':!.voidbot' From b62bfc7c8ceffdcd60d6150c18814e92a4a75d0e Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 15:32:32 +0200 Subject: [PATCH 3/4] cultnet-py: the explicit-bind test stays on loopback The test sent from an explicit 127.0.0.1 bind to a non-loopback address, which Windows refuses outright (WinError 10051), so it only held on Linux. It now binds 127.0.0.2 for a 127.0.0.1 endpoint, whose derived bind is 127.0.0.1, and checks the source address the listener sees. That still fails if the explicit host is ignored, on every platform, with no dependence on a non-loopback route. Co-Authored-By: Claude Opus 5.5 --- packages/cultnet-py/tests/test_cultnet.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/cultnet-py/tests/test_cultnet.py b/packages/cultnet-py/tests/test_cultnet.py index 0d707730..4f3984b7 100644 --- a/packages/cultnet-py/tests/test_cultnet.py +++ b/packages/cultnet-py/tests/test_cultnet.py @@ -2446,24 +2446,31 @@ class CultNetRudpClientBindTests(unittest.TestCase): finally: listener.close() + # The endpoint alone would bind 127.0.0.1; the explicit host must win, and the + # source address shows which one was bound. It stays on loopback, because a + # loopback-bound socket cannot send off the host on Windows. def test_a_schema_transport_binds_an_explicit_bind_host(self) -> None: - address = _non_loopback_ipv4_address() - if address is None: - self.skipTest("no non-loopback IPv4 address on this host") + probe = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + try: + probe.bind(("127.0.0.2", 0)) + except OSError: + self.skipTest("127.0.0.2 is not a local address on this host") + finally: + probe.close() listener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - listener.bind(("0.0.0.0", 0)) + listener.bind(("127.0.0.1", 0)) listener.settimeout(2.0) try: with self.assertRaises(TimeoutError): create_rudp_schema_transport( - host=address, + host="127.0.0.1", port=listener.getsockname()[1], connection_id=0x43554C54, timeout_seconds=0.2, - bind_host="127.0.0.1", + bind_host="127.0.0.2", ) _, source = listener.recvfrom(65535) - self.assertEqual(source[0], "127.0.0.1") + self.assertEqual(source[0], "127.0.0.2") finally: listener.close() From 59d8555719cee84940907362ae8d1f00a2a921ec Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 15:32:37 +0200 Subject: [PATCH 4/4] cultnet-rs: the vendored-schema guard lists the directory The equality test compared only the 22 names in a hand-kept list, so a schema copied into packages/cultnet-rs/contracts/cultnet/ without joining the list escaped it. Every *.schema.json under the vendored tree is now found by listing it and compared against its canonical copy. The presence test is gone: include_str! already fails the build for an embedded schema that is not vendored. Co-Authored-By: Claude Opus 5.5 --- .../tests/schema_discovery_contracts.rs | 97 ++++++++----------- 1 file changed, 39 insertions(+), 58 deletions(-) diff --git a/packages/cultnet-rs/tests/schema_discovery_contracts.rs b/packages/cultnet-rs/tests/schema_discovery_contracts.rs index 7c62b80f..833f40c3 100644 --- a/packages/cultnet-rs/tests/schema_discovery_contracts.rs +++ b/packages/cultnet-rs/tests/schema_discovery_contracts.rs @@ -18,85 +18,66 @@ //! Vendoring is a second copy of files this repo already treats as canonical //! (`contracts/cultnet/*.schema.json`, the shared source multiple runtimes compile against per //! `docs/cultnet-selection-cut.md` section 1). A second copy can drift silently, so this test is -//! the thing that makes that impossible without a loud, immediate failure: every vendored file is -//! compared byte-for-byte against its repo-root original. It skips (not fails) when the canonical +//! the thing that makes that impossible without a loud, immediate failure: every `*.schema.json` +//! under the vendored `contracts/cultnet/` is compared byte-for-byte against its repo-root +//! original. The files are found by listing the directory, not from a list kept by hand, so a newly +//! vendored copy cannot escape the check. It skips (not fails) when the canonical //! `contracts/` tree is not present beside the package - i.e. exactly the isolated-copy situation //! R-AB exists to survive - so this check does not reintroduce the same escape it is guarding -//! against. +//! against. A schema embedded by `schema_discovery.rs` but not vendored fails to compile. use std::fs; -use std::path::Path; +use std::path::{Path, PathBuf}; -/// Every schema this crate's `schema_discovery::builtin_schema_registry` embeds via -/// `include_str!("../contracts/cultnet/…")` - kept in sync with `schema_discovery.rs` by hand; -/// a schema added there and not here is still caught, because the crate would then fail to -/// compile against a file this list never copied to `contracts/cultnet/`. -const VENDORED_SCHEMAS: &[&str] = &[ - "cultnet.hello.schema.json", - "cultnet.document-mutation-contract.schema.json", - "cultnet.transport-profile.schema.json", - "cultnet.login.schema.json", - "cultnet.register.schema.json", - "cultnet.verify.schema.json", - "cultnet.login-success.schema.json", - "cultnet.error.schema.json", - "cultnet.sample-change-name.schema.json", - "cultnet.sample-chat.schema.json", - "cultnet.document-put.schema.json", - "cultnet.document-delete.schema.json", - "cultnet.raw-document-record.schema.json", - "cultnet.document-put-raw.schema.json", - "cultnet.snapshot-request.schema.json", - "cultnet.snapshot-response.schema.json", - "cultnet.snapshot-response-raw.schema.json", - "cultnet.schema-catalog-request.schema.json", - "cultnet.schema-catalog-response.schema.json", - "cultnet.shard-catalog-request.schema.json", - "cultnet.shard-catalog-response.schema.json", - "ghostlight.agent-state.schema.json", -]; - -#[test] -fn vendored_contract_schemas_are_present_and_match_every_include_str_call() { - let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); - let vendored_root = manifest_dir.join("contracts/cultnet"); - for name in VENDORED_SCHEMAS { - let path = vendored_root.join(name); - assert!( - path.is_file(), - "{name} is embedded by schema_discovery.rs but missing from the vendored \ - contracts/cultnet/ copy at {path:?}" - ); +/// Every `*.schema.json` under `root`, as paths relative to it, sorted. +fn schema_files(root: &Path) -> Vec { + fn walk(root: &Path, dir: &Path, found: &mut Vec) { + for entry in fs::read_dir(dir).unwrap_or_else(|error| panic!("listing {dir:?}: {error}")) { + let path = entry.expect("directory entry").path(); + if path.is_dir() { + walk(root, &path, found); + } else if path.to_string_lossy().ends_with(".schema.json") { + found.push(path.strip_prefix(root).expect("path under root").to_path_buf()); + } + } } + let mut found = Vec::new(); + walk(root, root, &mut found); + found.sort(); + found +} + +fn vendored_root() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")).join("contracts/cultnet") } #[test] fn vendored_contract_schemas_match_the_canonical_repo_root_source() { - let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); - let vendored_root = manifest_dir.join("contracts/cultnet"); // packages/cultnet-rs -> packages -> repo root -> contracts/cultnet - let canonical_root = manifest_dir.join("../../contracts/cultnet"); + let canonical_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../contracts/cultnet"); if !canonical_root.is_dir() { // R-AB: exactly the isolated-copy case this crate's own vendored files exist to survive // (cargo-mutants, or any tool that copies only this package's directory). Nothing to // compare against, and that is expected, not a failure. eprintln!( - "skipping: {canonical_root:?} not present beside the package (isolated build, \ - the case R-AB's vendored copies are for)" + "skipping: {canonical_root:?} not present beside the package (isolated build, the case R-AB's vendored copies are for)" ); return; } - for name in VENDORED_SCHEMAS { - let canonical = fs::read_to_string(canonical_root.join(name)) - .unwrap_or_else(|error| panic!("reading canonical contracts/cultnet/{name}: {error}")); - let vendored = fs::read_to_string(vendored_root.join(name)) - .unwrap_or_else(|error| panic!("reading vendored contracts/cultnet/{name}: {error}")); + let vendored = schema_files(&vendored_root()); + assert!(!vendored.is_empty(), "no vendored schemas found under {:?}", vendored_root()); + for name in vendored { + let shown = name.display(); + let canonical = fs::read_to_string(canonical_root.join(&name)).unwrap_or_else(|error| { + panic!("packages/cultnet-rs/contracts/cultnet/{shown} has no canonical contracts/cultnet/{shown}: {error}") + }); + let copy = fs::read_to_string(vendored_root().join(&name)) + .unwrap_or_else(|error| panic!("reading vendored contracts/cultnet/{shown}: {error}")); assert_eq!( - canonical, vendored, - "packages/cultnet-rs/contracts/cultnet/{name} has drifted from the canonical \ - contracts/cultnet/{name} - re-copy it" + canonical, copy, + "packages/cultnet-rs/contracts/cultnet/{shown} has drifted from the canonical contracts/cultnet/{shown} - re-copy it" ); } } @@ -107,7 +88,7 @@ fn builtin_schema_registry_loads_every_vendored_schema() { let listed = registry.list(&cultnet_rs::CultNetSchemaCatalogOptions::default()); assert_eq!( listed.len(), - VENDORED_SCHEMAS.len(), + schema_files(&vendored_root()).len(), "one registration per vendored schema file" ); }