11# cargo-rail
22
3- ** Graph-aware workspace orchestration for Rust monorepos.**
4-
5- Split crates to standalone repos, sync bidirectionally, run smart CI, enforce policies, orchestrate releases—all from one tool.
3+ ** Hyper-efficient Rust monorepo orchestration.**
64
75---
86
97## Status
108
11- This crate is under active development. I've deliberately not published anything yet. If you stumble upon it and are interested in it; feel free. I'd love any reviews early on. However, be aware, it's not ready for any kind of high-stakes, production work. It has many things that need to be fixed. It has many unhinged comments/TODO items.
12-
13- I estimate this will be v1 ready in the next 3-5 days. (Today: 11/14/2025)
9+ ** NOT READY FOR PUBLIC USE.** Active development. Internal testing only.
1410
1511---
1612
17- ## Quick Start
18-
19- ``` bash
20- # Initialize
21- cargo rail init
22-
23- # Graph-aware CI
24- cargo rail graph affected --since origin/main
25- cargo rail graph test --since origin/main
13+ ## What It Does
2614
27- # Split/sync
28- cargo rail split my-crate --apply
29- cargo rail sync my-crate --apply
15+ ### 1. Workspace Dependency Unification
3016
31- # Enforce policies
32- cargo rail lint deps --fix --apply
33- cargo rail lint versions --json
17+ ** Replaces cargo-hakari and workspace-hack crates.**
3418
35- # Release orchestration
36- cargo rail release plan my-crate
37- cargo rail release apply my-crate --dry-run
38- ```
39-
40- ---
41-
42- ## Four Pillars
43-
44- ### 1. Graph Orchestration ✅
45-
46- Test only what changed. Stop wasting CI time.
19+ - Native Cargo ` [workspace.dependencies] ` unification
20+ - No fake crates, no guppy, no runtime overhead
21+ - CI-enforceable via ` cargo rail unify check `
22+ - Invisible after initial application
4723
4824``` bash
49- cargo rail graph affected --since origin/main --format json
50- cargo rail graph test --since origin/main
51- cargo rail graph check --workspace
52- cargo rail graph clippy --since origin/main
25+ cargo rail unify analyze # Dry-run analysis
26+ cargo rail unify apply --backup # Apply unification
27+ cargo rail unify check # CI verification (exit 0 = unified)
5328```
5429
55- ### 2. Split/Sync ✅
30+ ### 2. Split & Sync
5631
57- Split crates to standalone repos with full history . Sync bidirectionally.
32+ ** Split crates from monorepo to standalone repos. Sync bidirectionally.**
5833
5934``` bash
35+ # Split: Monorepo → Standalone Repo (with full git history)
6036cargo rail split my-crate --apply
61- cargo rail sync my-crate --apply
62- cargo rail sync my-crate --apply --from-remote # PR branch for external contributions
63- ```
64-
65- ### 3. Policy & Linting ✅
66-
67- Enforce consistency. Prevent dependency drift.
6837
69- ``` bash
70- cargo rail lint deps --fix --apply # Workspace inheritance
71- cargo rail lint versions --strict # Duplicate versions
72- cargo rail lint manifest # Edition, MSRV, patch/replace
73- ```
74-
75- ### 4. Release Orchestration ✅
76-
77- Plan releases with conventional commits. Coordinate mono + split repos.
38+ # Sync: Monorepo → Split Repo (direct push to main)
39+ cargo rail sync my-crate --to-remote --apply
7840
79- ``` bash
80- cargo rail release plan --all
81- cargo rail release apply my-crate --dry-run
41+ # Sync: Split Repo → Monorepo (creates PR branch, never commits to main)
42+ cargo rail sync my-crate --from-remote --apply
8243```
8344
84- ---
85-
86- ## Commands
87-
88- ### Graph
45+ ** Modes:**
46+ - ** Single crate** → Single repo
47+ - ** Multiple crates** → Single repo
48+ - ** Multiple crates** → Separate monorepo
8949
90- ``` bash
91- cargo rail graph affected # Show affected crates
92- cargo rail graph test # Smart test targeting
93- cargo rail graph check # Smart cargo check
94- cargo rail graph clippy # Smart clippy
95- ```
96-
97- ** Flags:** ` --since <ref> ` , ` --workspace ` , ` --dry-run ` , ` --format json|names `
98-
99- ### Split/Sync
100-
101- ``` bash
102- cargo rail init # Initialize rail.toml
103- cargo rail split < name> # Split with history
104- cargo rail sync < name> # Bidirectional sync
105- cargo rail sync --all # Sync all splits
106- ```
50+ ### 3. Centralized Configuration Management
10751
108- ** Flags: ** ` --apply ` (default: dry-run), ` --json ` , ` --from-remote `
52+ ** Enforce uniform policies across all workspace crates. **
10953
110- ### Lint
54+ - Edition, MSRV, resolver version
55+ - Dependency version consistency
56+ - Workspace inheritance validation
11157
112- ``` bash
113- cargo rail lint deps # Workspace inheritance
114- cargo rail lint versions # Duplicate versions
115- cargo rail lint manifest # Quality checks
58+ ``` toml
59+ # rail.toml
60+ [policy ]
61+ edition = " 2024"
62+ msrv = " 1.76.0"
63+ resolver = " 2"
64+ forbid_multiple_versions = [" tokio" , " serde" ]
11665```
11766
118- ** Flags:** ` --fix --apply ` , ` --json ` , ` --strict `
119-
120- ### Release
121-
122- ``` bash
123- cargo rail release plan # Analyze commits
124- cargo rail release apply # Bump, tag, sync
125- ```
67+ ---
12668
127- ** Flags: ** ` --all ` , ` --json ` , ` --dry-run `
69+ ## Architecture
12870
129- ### Inspect
130-
131- ``` bash
132- cargo rail status # Show all splits
133- cargo rail doctor # Health checks
134- cargo rail mappings < name> # Commit mappings
135- ```
71+ - ** Git + Cargo + Petgraph** - Core foundation
72+ - ** Zero libgit2/gitoxide** - System git binary only
73+ - ** Zero guppy** - Direct cargo_metadata usage
74+ - ** Workspace-aware graph** - Dependency + reverse-dependency tracking
13675
13776---
13877
@@ -144,60 +83,38 @@ cargo rail mappings <name> # Commit mappings
14483[workspace ]
14584root = " ."
14685
147- # Split config
86+ # Split configuration
14887[[splits ]]
14988name = " my-crate"
150- remote =
" [email protected] :you /my-crate.git" 89+ remote =
" [email protected] :user /my-crate.git" 15190branch = " main"
152- mode = " single" # or "combined"
91+ mode = " single"
15392paths = [{ crate = " crates/my-crate" }]
15493
94+ # Unification configuration (optional)
95+ [unify ]
96+ strategy = " all"
97+ normal_only = false
98+ exclude = [" some-special-dep" ]
99+
155100# Policy enforcement
156101[policy ]
157102edition = " 2024"
158103msrv = " 1.76.0"
159104resolver = " 2"
160- forbid_multiple_versions = [" tokio" , " serde" ]
161- forbid_patch_replace = true
162-
163- # Release tracking
164- [[releases ]]
165- name = " my-crate"
166- crate = " crates/my-crate"
167- split = " my-crate" # optional link to [[splits]]
168- last_version = " 0.3.1"
169- last_sha = " abc123"
170- last_date = " 2025-01-15T00:00:00Z"
105+ forbid_multiple_versions = [" tokio" ]
171106```
172107
173108---
174109
175- ## Architecture
176-
177- - ** WorkspaceGraph** - cargo_metadata + petgraph
178- - ** AffectedAnalysis** - File changes → crate impact
179- - ** SystemGit** - Zero-dependency git via system binary
180- - ** Plan** - Auditable dry-run with SHA IDs
181- - ** MappingStore** - Git-notes commit mapping (rebase-safe)
182-
183- ** Dependencies:** cargo_metadata, petgraph, toml_edit, clap, serde. No libgit2/gitoxide by design; no guppy by design.
184-
185- ---
186-
187110## Security
188111
189- ** Split → Mono:** Creates PR branch ` rail/sync/{name}/{timestamp} ` . Never commits to main directly .
112+ ** Split → Mono:** Creates PR branch ` rail/sync/{name}/{timestamp} ` . Never commits to main.
190113
191- ** Mono → Split:** Direct push with SSH auth . Use deploy keys + branch protection.
114+ ** Mono → Split:** Direct push. Use SSH keys + branch protection.
192115
193116---
194117
195- ## Use Cases
196-
197- ** Open-source subset:** Work in monorepo, auto-sync to public repos.
198-
199- ** CI optimization:** Test 5 affected crates instead of 50. 10x faster.
200-
201- ** Policy enforcement:** Uniform edition, MSRV, dependency versions across 50+ crates.
118+ ## License
202119
203- ** Release coordination: ** Version bump + tag + changelog across mono + split repos.
120+ MIT OR Apache-2.0
0 commit comments