You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cli: the migration command assumes Unix without a cfg gate #1121
The migration command and its storage additions use Unix-only APIs without a cfg gate:
crates/nostream-cli/src/commands/migrate.rs:16 — std::os::unix::fs::{MetadataExt, OpenOptionsExt, PermissionsExt}, used for the manifest's 0600 mode, the target owner/euid check and the store directory's mode.
crates/nostream-storage/src/backend.rs:4 — std::os::unix::fs::DirBuilderExt, used for the store directory's 0700 create.
the tests that plant symlinks and chmod directories.
rewrite/main is careful about this: the only pre-existing std::os::unix in a non-test file (nostream-config/src/load.rs:73) sits behind #[cfg(unix)]. This branch adds the first ungated one, so cargo build -p nostream-cli on a non-Unix target now fails where it previously would not.
Why it is not fixed in the migration branch
Gating it is not a cfg on an import: the command needs to exist on every target to be refused, so the work is #[cfg(unix)] on commands::migrate, a #[cfg(unix)] arm plus a non-Unix stub in main.rs's dispatch, and cfg gates on the tests. None of that can be verified here — there is no Windows toolchain on this host and no windows or macos entry in .github/workflows, so the change would ship unproven, which is the class this job refuses.
Acceptance
cargo build -p nostream-cli --no-default-features succeeds on a non-Unix target (a windows-latest job in checks.yml is the cheapest proof), migrate pg-to-lmdb answers an explicit "unsupported on this platform" rather than failing to compile, and the Unix-only tests are gated alongside the code they test.
I have gone through this issue and analyzed the codebase. I would like to work on this! Please assign it to me.
Proposed Approach:
Module & Import Gating:
Gate the Unix-specific migration logic in crates/nostream-cli/src/commands/migrate.rs and crates/nostream-storage/src/backend.rs behind #[cfg(unix)].
Add a #[cfg(not(unix))] stub implementation for the migrate pg-to-lmdb command that gracefully prints an explicit error: "unsupported on this platform" with exit code 1 instead of failing compilation.
Dispatch & Tests:
Update main.rs dispatch with matching #[cfg(unix)] / #[cfg(not(unix))] branches.
Gate the Unix-only test cases (symlinks and directory permission tests) with #[cfg(unix)].
Verification:
Verify that cargo build -p nostream-cli --no-default-features builds cleanly and non-Unix targets compile without error.
Apologies for jumping ahead with the fix before being officially assigned. While reading through the issue and analyzing the acceptance criteria, I went through the codebase to verify the seams and implemented the solution:
Gated Unix-specific migration imports and logic in crates/nostream-cli/src/commands/migrate.rs behind #[cfg(unix)].
Added a #[cfg(not(unix))] stub for run() that prints "migrate pg-to-lmdb is unsupported on this platform" with exit code 1.
Gated file mode permissions in nostream-storage::backend behind #[cfg(unix)] with create_dir_all fallback on non-Unix.
Gated symlink and chmod tests in crates/nostream-cli/tests/migrate_cli.rs behind #[cfg(unix)].
Added a windows-latest check job in .github/workflows/checks.yml running cargo check -p nostream-cli --no-default-features.
Thanks @tirthraj01 — the work is genuinely unclaimed: rewrite/main still imports std::os::unix ungated at crates/nostream-cli/src/commands/migrate.rs:16 and crates/nostream-storage/src/backend.rs:5, and there is no non-Unix stub and no Windows runner. #1125 merged as 522e816, so nothing is blocked behind it now.
Your shape is right: #[cfg] on the Unix imports, a #[cfg(not(unix))]run() that prints the explicit message and exits 1, a create_dir_all fallback in backend.rs, the Unix-only tests gated, and a Windows job. Three things before it can land:
Rebase onto rewrite/main. Your branch is based on 6885fcf, an intermediate commit of the migration branch. That branch was rebased before merge, so 6885fcf is not an ancestor of 522e816, and applying your patch there conflicts in crates/nostream-cli/src/commands/migrate.rs and .github/workflows/checks.yml (backend.rs and tests/migrate_cli.rs apply).
Restore the trailing newline in crates/nostream-cli/src/commands/migrate.rs — the diff drops it, so cargo fmt --all --check fails, and CI runs it.
Match the changeset convention: .changeset/cli-migrate-cfg-gate.md carries "nostream-cli": patch / "nostream-storage": patch, but this repo's changesets are empty-frontmatter prose (---, ---, then the description), deliberately, because nothing here publishes to npm.
One question on the acceptance: it asks for cargo build -p nostream-cli --no-default-features on a non-Unix target, and your job runs cargo check. Both prove the gating; build is what the issue says, so prefer it unless it is slow on Windows.
Open the PR against rewrite/main once it rebases and we will review it there.
Thanks @tirthraj01 — your branch is in #1148, opening against rewrite/main and closing this issue. You are the author of your commit, and the Windows job with its SHA-pinned actions is yours.
Three corrections went on top, all measurable:
Three call sites were still ungated, so the Windows job would have failed on its first run: create_target calls DirBuilder::mode and the now-gated refuse_unsafe_target, and the tests a_target_under_a_swappable_directory_is_refused and a_missing_target_is_created_and_then_judged read MetadataExt::uid and Permissions::from_mode. Gating run is not enough on its own — Rust still type-checks a function that nothing on that platform can call.
A trailing-whitespace line in backend.rs (the blank line before Self::open_with) makes cargo fmt --all --check fail, and CI runs it.
The concurrency.group quote flip in checks.yml was unrelated to the job, so it was dropped to keep the diff on the change.
A practical hint for the next one: cargo check --target x86_64-pc-windows-gnu catches exactly this on a Linux box once a mingw C compiler is present (apt install gcc-mingw-w64-x86-64), which is faster than waiting on a runner.
Landed in two PRs, and the Windows build now passes rather than merely compiling the parts I could gate:
fix(cli): gate the unix-only migration APIs behind cfg(unix) #1148 — the cfg gates, the Windows job, the changeset. Merged at 6e3af92, but its job still failed: run was gated while every helper it called still compiled, which -D warnings turns into eleven dead-code errors.
refactor(cli): make the whole migrate module Unix-only #1153 — commands::migrate is #[cfg(unix)] outright, with migrate_unsupported.rs at the same path carrying MigrateOptions and a refusing run. Merged at 0f202f1. Windows CLI Check is green there, so cargo build -p nostream-cli --no-default-features and the refusal test both run on windows-latest.
Two things turned up on the way that were not in the original scope:
nostream-config imported std::ffi::OsStr where only its Unix trim used it, so the Windows build failed there before it reached the CLI.
A SHA pin on a uses: makes this repository's pull_request run fail at startup with no jobs created. Measured on probe branches; the job pins by tag like the rest of the file.
cargo fmt --all also follows the crate root's cfg, so each platform formats only its own half of the pair. The Windows job now runs cargo fmt --all --check as well, which closes that.
Thanks @tirthraj01 — the gate shape was right from the start; the miss was mine, checking call sites reachable from run instead of everything the compiler still type-checks.
Activity
tirthraj01 commentedon Nov 13, 2026
Hi @cameri @chappie-daemon,
I have gone through this issue and analyzed the codebase. I would like to work on this! Please assign it to me.
Proposed Approach:
crates/nostream-cli/src/commands/migrate.rsandcrates/nostream-storage/src/backend.rsbehind#[cfg(unix)].#[cfg(not(unix))]stub implementation for themigrate pg-to-lmdbcommand that gracefully prints an explicit error:"unsupported on this platform"with exit code 1 instead of failing compilation.main.rsdispatch with matching#[cfg(unix)]/#[cfg(not(unix))]branches.#[cfg(unix)].cargo build -p nostream-cli --no-default-featuresbuilds cleanly and non-Unix targets compile without error.Looking forward to your approval to get started!
tirthraj01 commentedon Nov 13, 2026
Hi @cameri @chappie-daemon,
Apologies for jumping ahead with the fix before being officially assigned. While reading through the issue and analyzing the acceptance criteria, I went through the codebase to verify the seams and implemented the solution:
crates/nostream-cli/src/commands/migrate.rsbehind#[cfg(unix)].#[cfg(not(unix))]stub forrun()that prints"migrate pg-to-lmdb is unsupported on this platform"with exit code 1.nostream-storage::backendbehind#[cfg(unix)]withcreate_dir_allfallback on non-Unix.crates/nostream-cli/tests/migrate_cli.rsbehind#[cfg(unix)].windows-latestcheck job in.github/workflows/checks.ymlrunningcargo check -p nostream-cli --no-default-features.Here is the branch comparing against
factory/029-pg-to-lmdb:factory/029-pg-to-lmdb...tirthraj01:nostream:fix/1121-cli-migrate-cfg-gate
Happy to open a PR or wait until PR #1125 lands, whichever you prefer!
cameri commentedon Nov 14, 2026
@tirthraj01 Assigned to you.
chappie-daemon commentedon Nov 14, 2026
Thanks @tirthraj01 — the work is genuinely unclaimed:
rewrite/mainstill importsstd::os::unixungated atcrates/nostream-cli/src/commands/migrate.rs:16andcrates/nostream-storage/src/backend.rs:5, and there is no non-Unix stub and no Windows runner. #1125 merged as522e816, so nothing is blocked behind it now.Your shape is right:
#[cfg]on the Unix imports, a#[cfg(not(unix))]run()that prints the explicit message and exits 1, acreate_dir_allfallback inbackend.rs, the Unix-only tests gated, and a Windows job. Three things before it can land:rewrite/main. Your branch is based on6885fcf, an intermediate commit of the migration branch. That branch was rebased before merge, so6885fcfis not an ancestor of522e816, and applying your patch there conflicts incrates/nostream-cli/src/commands/migrate.rsand.github/workflows/checks.yml(backend.rsandtests/migrate_cli.rsapply).crates/nostream-cli/src/commands/migrate.rs— the diff drops it, socargo fmt --all --checkfails, and CI runs it..changeset/cli-migrate-cfg-gate.mdcarries"nostream-cli": patch/"nostream-storage": patch, but this repo's changesets are empty-frontmatter prose (---,---, then the description), deliberately, because nothing here publishes to npm.One question on the acceptance: it asks for
cargo build -p nostream-cli --no-default-featureson a non-Unix target, and your job runscargo check. Both prove the gating;buildis what the issue says, so prefer it unless it is slow on Windows.Open the PR against
rewrite/mainonce it rebases and we will review it there.fix(cli): gate unix-only migration apis behind cfg(unix) (cameri#1121)
tirthraj01 commentedon Nov 14, 2026
Hi @chappie-daemon @cameri,
I've rebased the branch onto the latest
rewrite/main(clean 1-commit diff, verified and able to merge automatically) and addressed all items:rewrite/main.crates/nostream-cli/src/commands/migrate.rs.---/---)..github/workflows/checks.ymlto runcargo build -p nostream-cli --no-default-features.Here is the rebased compare link:
rewrite/main...tirthraj01:nostream:fix/1121-cli-migrate-cfg-gate
Because repository interaction limits are active, could you please open the PR from this branch? Thank you!
chappie-daemon commentedon Nov 16, 2026
Thanks @tirthraj01 — your branch is in #1148, opening against
rewrite/mainand closing this issue. You are the author of your commit, and the Windows job with its SHA-pinned actions is yours.Three corrections went on top, all measurable:
create_targetcallsDirBuilder::modeand the now-gatedrefuse_unsafe_target, and the testsa_target_under_a_swappable_directory_is_refusedanda_missing_target_is_created_and_then_judgedreadMetadataExt::uidandPermissions::from_mode. Gatingrunis not enough on its own — Rust still type-checks a function that nothing on that platform can call.backend.rs(the blank line beforeSelf::open_with) makescargo fmt --all --checkfail, and CI runs it.concurrency.groupquote flip inchecks.ymlwas unrelated to the job, so it was dropped to keep the diff on the change.A practical hint for the next one:
cargo check --target x86_64-pc-windows-gnucatches exactly this on a Linux box once a mingw C compiler is present (apt install gcc-mingw-w64-x86-64), which is faster than waiting on a runner.fix(cli): gate the unix-only migration APIs behind cfg(unix) (#1148)
refactor(cli): make the whole migrate module Unix-only (#1153)
chappie-daemon commentedon Nov 16, 2026
Landed in two PRs, and the Windows build now passes rather than merely compiling the parts I could gate:
cfggates, the Windows job, the changeset. Merged at6e3af92, but its job still failed:runwas gated while every helper it called still compiled, which-D warningsturns into eleven dead-code errors.commands::migrateis#[cfg(unix)]outright, withmigrate_unsupported.rsat the same path carryingMigrateOptionsand a refusingrun. Merged at0f202f1.Windows CLI Checkis green there, socargo build -p nostream-cli --no-default-featuresand the refusal test both run onwindows-latest.Two things turned up on the way that were not in the original scope:
nostream-configimportedstd::ffi::OsStrwhere only its Unix trim used it, so the Windows build failed there before it reached the CLI.uses:makes this repository'spull_requestrun fail at startup with no jobs created. Measured on probe branches; the job pins by tag like the rest of the file.cargo fmt --allalso follows the crate root'scfg, so each platform formats only its own half of the pair. The Windows job now runscargo fmt --all --checkas well, which closes that.Thanks @tirthraj01 — the gate shape was right from the start; the miss was mine, checking call sites reachable from
runinstead of everything the compiler still type-checks.