From 56c643ee1718e6612f7a206c838ab99f2f1d0c0d Mon Sep 17 00:00:00 2001 From: chappie-daemon Date: Sun, 15 Nov 2026 23:07:40 -0500 Subject: [PATCH 1/4] refactor(cli): make the whole migrate module Unix-only Gating `run` left every helper it called compiled but unreachable on Windows, and `-D warnings` makes each one a dead-code error: eleven of them, from `PostgresBackend` in the imports down to `open_existing_target`. The issue's own shape is the fix: `commands::migrate` is `#[cfg(unix)]`, and the other platform gets `migrate_unsupported.rs` at the same path, carrying the same `MigrateOptions` and a `run` that refuses. `main.rs` stays free of a `cfg` arm because both modules answer the same names. Verified by compiling the non-Unix arm on Linux: a scratch copy with the module cfgs swapped passes `cargo clippy -p nostream-cli --no-default-features --lib --bins -- -D warnings`, which is the check the Windows runner was failing. --- crates/nostream-cli/src/commands/migrate.rs | 10 ----- .../src/commands/migrate_unsupported.rs | 41 +++++++++++++++++++ crates/nostream-cli/src/commands/mod.rs | 6 +++ 3 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 crates/nostream-cli/src/commands/migrate_unsupported.rs diff --git a/crates/nostream-cli/src/commands/migrate.rs b/crates/nostream-cli/src/commands/migrate.rs index 2fd5d685..30d8e3bd 100644 --- a/crates/nostream-cli/src/commands/migrate.rs +++ b/crates/nostream-cli/src/commands/migrate.rs @@ -112,16 +112,6 @@ pub fn run(options: MigrateOptions, out: &mut dyn Write) -> Result Result { - writeln!(out, "migrate pg-to-lmdb is unsupported on this platform") - .map_err(|e| CliError::Migrate(e.to_string()))?; - Ok(CommandOutput { - lines: Vec::new(), - exit_code: 1, - }) -} - /// The copy over an injected source, target and writer, which is how the whole run is tested /// without a process and without a database. /// diff --git a/crates/nostream-cli/src/commands/migrate_unsupported.rs b/crates/nostream-cli/src/commands/migrate_unsupported.rs new file mode 100644 index 00000000..742f9115 --- /dev/null +++ b/crates/nostream-cli/src/commands/migrate_unsupported.rs @@ -0,0 +1,41 @@ +//! `migrate pg-to-lmdb` where the copy cannot run. +//! +//! The copy reads and writes Unix file modes, refuses a target by its owner's uid and reads the +//! caller's from `/proc/self/status`, so the whole command lives in `migrate.rs` behind +//! `cfg(unix)`. The command still has to exist everywhere — a `main.rs` that cannot name it would +//! need its own `cfg` arm — so this module supplies the same `MigrateOptions` and a `run` that +//! refuses with the reason, which is what an operator on another platform needs to read. + +use std::io::Write; +use std::path::PathBuf; + +use crate::config::CommandOutput; +use crate::error::CliError; + +/// The options one run carries. Kept in step with `migrate::MigrateOptions`, which is the arm +/// that uses them. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct MigrateOptions { + /// The store root: the environment is `/lmdb`, the manifest `/migration-manifest.json`. + pub target: PathBuf, + /// Rows per batch, which is also the page size verify reads with. + pub batch_size: usize, + /// Verify the target against its manifest and copy nothing. + pub verify: bool, +} + +/// `migrate pg-to-lmdb`: refused, naming the platform as the reason and answering exit code 1. +/// +/// `migrate_cli_unsupported.rs` pins the line and the code, and the `windows-latest` job in +/// `checks.yml` runs it there. +pub fn run( + _options: MigrateOptions, + out: &mut dyn Write, +) -> Result { + writeln!(out, "migrate pg-to-lmdb is unsupported on this platform") + .map_err(|e| CliError::Migrate(e.to_string()))?; + Ok(CommandOutput { + lines: Vec::new(), + exit_code: 1, + }) +} diff --git a/crates/nostream-cli/src/commands/mod.rs b/crates/nostream-cli/src/commands/mod.rs index 645c0dc8..b463b262 100644 --- a/crates/nostream-cli/src/commands/mod.rs +++ b/crates/nostream-cli/src/commands/mod.rs @@ -7,6 +7,12 @@ pub mod export; pub mod import; pub mod info; pub mod invite; +/// The copy needs Unix file modes, so the whole command is Unix-only and the other platform +/// gets a refusal with the same option type, which is what keeps `main.rs` free of a `cfg` arm. +#[cfg(unix)] +pub mod migrate; +#[cfg(not(unix))] +#[path = "migrate_unsupported.rs"] pub mod migrate; pub mod seed; pub mod setup; From 3f64e85bde3bef157512b1ac4117a742da8d9be0 Mon Sep 17 00:00:00 2001 From: chappie-daemon Date: Sun, 15 Nov 2026 23:10:17 -0500 Subject: [PATCH 2/4] chore(cli): add the changeset for the platform split --- .changeset/cli-migrate-module-cfg.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changeset/cli-migrate-module-cfg.md diff --git a/.changeset/cli-migrate-module-cfg.md b/.changeset/cli-migrate-module-cfg.md new file mode 100644 index 00000000..74b6c721 --- /dev/null +++ b/.changeset/cli-migrate-module-cfg.md @@ -0,0 +1,4 @@ +--- +--- + +The migration module is gated by platform, so the CLI builds where the copy cannot run (#1121) From 4714a00ef1f4c1d1cc5ae8df46352a78800292d0 Mon Sep 17 00:00:00 2001 From: chappie-daemon Date: Sun, 15 Nov 2026 23:12:33 -0500 Subject: [PATCH 3/4] style(cli): format the module cargo fmt cannot reach MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `migrate_unsupported.rs` is behind `#[cfg(not(unix))]`, so on Linux `cargo fmt --all` never visits it — and CI's `cargo fmt --all --check` runs on Linux, which is why the crate root's own listing decides what is formatted. Formatted by name instead. --- crates/nostream-cli/src/commands/migrate_unsupported.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/nostream-cli/src/commands/migrate_unsupported.rs b/crates/nostream-cli/src/commands/migrate_unsupported.rs index 742f9115..6f22619c 100644 --- a/crates/nostream-cli/src/commands/migrate_unsupported.rs +++ b/crates/nostream-cli/src/commands/migrate_unsupported.rs @@ -28,10 +28,7 @@ pub struct MigrateOptions { /// /// `migrate_cli_unsupported.rs` pins the line and the code, and the `windows-latest` job in /// `checks.yml` runs it there. -pub fn run( - _options: MigrateOptions, - out: &mut dyn Write, -) -> Result { +pub fn run(_options: MigrateOptions, out: &mut dyn Write) -> Result { writeln!(out, "migrate pg-to-lmdb is unsupported on this platform") .map_err(|e| CliError::Migrate(e.to_string()))?; Ok(CommandOutput { From 32d278a2689375ccbf799e93a288634a5e85d509 Mon Sep 17 00:00:00 2001 From: chappie-daemon Date: Sun, 15 Nov 2026 23:12:42 -0500 Subject: [PATCH 4/4] ci: check formatting on Windows too, where the other half lives `cargo fmt --all` formats the modules the crate root reaches, and the root's `cfg` picks one of the two `migrate` files per platform. Linux therefore never formats `migrate_unsupported.rs` and Windows never formats `migrate.rs`; a check on each platform covers both. This caught a wrapped signature in the unreachable file on the run before. --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d59da805..54598ac7 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -296,6 +296,8 @@ jobs: persist-credentials: false - name: Install Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1.17.0 + - name: Format, which covers the file Linux cannot reach + run: cargo fmt --all --check - name: CLI builds on Windows run: cargo build -p nostream-cli --no-default-features - name: CLI refuses the migration on Windows