ワンクリックで
workspace
Workspace Organization guidance for Fortress Rollback. Use when Organizing workspace, splitting crates, module structure decisions.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Workspace Organization guidance for Fortress Rollback. Use when Organizing workspace, splitting crates, module structure decisions.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Crate Publishing guidance for Fortress Rollback. Use when Publishing to crates.io, version bumps, release checklist.
Changelog Practices guidance for Fortress Rollback. Use when Writing CHANGELOG entries, deciding what to document.
Design Decision Log Pattern guidance for Fortress Rollback. Use when Architectural decisions, design alternatives, superseding prior choices.
Repository-wide engineering policy and project context for Fortress Rollback. Use when implementing, diagnosing, reviewing, testing, documenting, or releasing changes in this repository.
GitHub Actions Best Practices guidance for Fortress Rollback. Use when Writing GitHub Actions workflows, CI debugging, actionlint, caching.
Adversarial Handoff Workflow guidance for Fortress Rollback. Use when High-risk reviews, post-incident hardening, escalation from code review.
| name | workspace |
| description | Workspace Organization guidance for Fortress Rollback. Use when Organizing workspace, splitting crates, module structure decisions. |
Is this used by external projects TODAY?
├── YES -> Has stable, well-defined API?
│ ├── YES -> Can be versioned independently?
│ │ ├── YES -> CREATE CRATE
│ │ └── NO -> Use module
│ └── NO -> Stabilize API first, use module
└── NO ->
Need different feature flags than parent?
├── YES -> Will splitting reduce feature combinations?
│ ├── YES -> CREATE CRATE
│ └── NO -> Use cfg attributes
└── NO ->
Compile times a verified problem?
├── YES -> Will splitting enable parallel compilation?
│ ├── YES -> Profile to confirm, then CREATE CRATE
│ └── NO -> Use modules
└── NO -> KEEP AS MODULE
| Anti-Pattern | Why Wrong |
|---|---|
| "It's getting big" | Size alone is not valid |
| "Might be reusable someday" | YAGNI -- split when needed |
| "Cleaner separation" | Use modules within a crate |
| "Faster compilation" | Often slower (more linking) |
# Flat -- simple, no submodules
src/
├── lib.rs
├── utils.rs
└── math.rs
# Directory -- module has submodules
src/
├── lib.rs
└── network/
├── mod.rs
├── tcp.rs
└── udp.rs
Do NOT use a directory for single-file modules (utils/mod.rs when utils.rs suffices).
pub struct PublicType; // Public API
pub(crate) struct InternalType; // Crate-internal
pub(super) fn helper(); // Parent module only
struct Private; // Module-private (default)
// Re-export for convenience -- flatten the API
pub use types::Config;
pub use error::{Error, Result};
// src/lib.rs -- ~100 lines, not 5000
#![warn(missing_docs)]
#![deny(unsafe_code)]
mod types;
mod protocol;
mod network;
mod error;
pub use types::{Config, Session, Input};
pub use protocol::Protocol;
pub use error::{Error, Result};
pub(crate) mod internal;
[workspace]
resolver = "2"
members = ["crates/*"]
[workspace.package]
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
[workspace.dependencies]
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
[workspace.lints.rust]
unsafe_code = "forbid"
[workspace.lints.clippy]
pedantic = { level = "warn", priority = -1 }
[package]
name = "my-project-core"
version.workspace = true
edition.workspace = true
license.workspace = true
[dependencies]
serde.workspace = true
[lints]
workspace = true
my-workspace/
├── Cargo.toml # Workspace root
├── Cargo.lock # Shared lock file
├── .cargo/config.toml
├── crates/
│ ├── core/ # Shared types, minimal deps
│ ├── protocol/ # Domain logic
│ └── transport/ # I/O layer
├── tests/
│ └── integration/ # Workspace-level integration tests
└── benches/
cargo build --workspace
cargo test --workspace
cargo test -p my-project-core
cargo clippy --workspace --all-targets
cargo doc --workspace
cargo publish -p crate_name
Fortress Rollback discovers every tracked manifest with Cargo and requires one
tracked Cargo.lock beside each owning workspace-root manifest. Workspace
members share their root lock; member-local and orphan locks are invalid.
python3 scripts/release/workspace_locks.py list
python3 scripts/release/workspace_locks.py sync
python3 scripts/release/workspace_locks.py check
Do not hand-edit locks, bypass --locked, or use cargo metadata --no-deps as
a freshness check. The canonical checker performs full locked dependency
resolution for every dynamically discovered root.
Each file in tests/ compiles as a separate crate. Use consolidated structure:
# SLOW: 4 separate compilation units
tests/
├── test_auth.rs
├── test_network.rs
└── test_protocol.rs
# FAST: Single crate with submodules
tests/
└── it/
├── main.rs # Entry point
├── auth.rs
├── network.rs
└── protocol.rs
// tests/it/main.rs
mod auth;
mod network;
mod protocol;
#[cfg(test)] mod tests): test internals, private functionstests/): test public API as a user would// Minimal public API -- hide implementation
pub struct Session {
state: SessionState, // private
config: Config, // private
}
// Newtype for type safety
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct FrameId(u32);
// Re-export dependency types exposed in API
pub use bytes::Bytes;
// Use #[non_exhaustive] for extensibility
#[non_exhaustive]
pub enum SessionEvent {
Connected { peer_id: PeerId },
Disconnected { peer_id: PeerId },
}
# BAD: 5 crates, 800 lines total
my-project-core/ # 200 lines
my-project-types/ # 150 lines
my-project-utils/ # 100 lines
# GOOD: 1 crate with modules
src/
├── lib.rs
├── types.rs
├── utils.rs
└── core.rs
// BAD: auth uses network, network uses auth
// FIX: Extract shared types into a common module
mod types; // Contains Credentials, Connection
mod auth; // uses types::Credentials
mod network; // uses types::Connection
Keep lib.rs as a coordinator (~100 lines) with mod declarations and pub use re-exports. Put implementation in separate modules.
| Factor | Effect |
|---|---|
| Many small crates | More object files, slower linking |
| Large public API | More codegen per dependent |
| Cross-crate calls | Less optimization without LTO |
| Incremental compilation | Works within crates, not across |
| Parallel compilation | Works across crates |
cargo build --workspace --all-features
cargo clippy --workspace --all-targets
cargo nextest run --workspace
cargo tree --workspace --duplicates # Inconsistent versions
cargo +nightly udeps --workspace # Unused deps