These rules govern Smith development. Changing one requires explicit owner approval.
1. Product Authority
docs/SPEC.md is the complete product contract.
The specification contains product requirements only.
Research is evidence, never authority.
Production Rust work starts only after the relevant product behavior is specified.
Prototypes may validate uncertain claims but MUST NOT become production dependencies.
2. Build Boundary
Cargo is the sole build interface.
cargo build
cargo test
cargo fmt
cargo clippy
cargo run -p xtask -- <command>
Forbidden production build surfaces:
Makefiles;
justfiles;
root scripts;
root package.json;
Python, Node, or shell as a second build system.
xtask MAY orchestrate installed tools but MUST contain no product logic. Any CI definition MUST delegate to Cargo or xtask.
Workspace version starts at 0.1.0 under Apache-2.0. Release builds use optimization level 3, thin LTO, one codegen unit, stripped symbols, and aborting panics.
Product code lives in crates. Product requirements live in docs/SPEC.md. Research and prototypes MUST NOT define runtime behavior.
4. Rust
Use latest stable Rust and edition 2024.
Product code MUST compile without warnings.
Workspace lints live in root Cargo.toml; target flags MUST NOT weaken them.
Library crates forbid unsafe code.
smith-cli MAY use unsafe only for unavoidable terminal operations behind a documented, tested safe abstraction.
Shipped libraries MUST NOT use unwrap, expect, panic, todo, or unimplemented for external failures.
Use rustfmt defaults from rustfmt.toml and the project policy in .clippy.toml.
5. Dependencies
Root [workspace.dependencies] is the single dependency registry.
Crates inherit shared dependencies from the workspace.
New or removed third-party dependencies require owner approval.
Version bumps are maintenance unless they change API compatibility, Rust requirements, architecture, or binary/compile budgets.
Heavy dependencies stay in the crate that owns their concern.
An incremental crate edit MUST rebuild only that crate and its reverse-dependency closure.
Cold-build time and crate count are regression-gated once a full-workspace baseline exists.
Product code MUST NOT depend on prototype crates.
6. Verification
Before integration, run the smallest complete applicable gate. At minimum:
cargo fmt --all --check
cargo test --workspace
Rust changes additionally require applicable clippy, architecture, documentation, and product-acceptance checks. A failing check MUST NOT be skipped, weakened, or deleted to obtain green output.
Release verification requires at least 80% workspace coverage, more than 80% mutation score, and Criterion scenarios session_encode_1000, session_decode_1000, widget_render_100, agent_loop_turn, config_resolve_3level, trace_filter_10000, and plugin_load_10. Benchmark regression above 5% warns; above 10% blocks release.
7. Protected Decisions
Agents MUST obtain explicit owner approval before modifying:
docs/SPEC.md;
docs/PROJECT-INVARIANTS.md;
root Cargo.toml dependency membership;
.cargo/config.toml;
rust-toolchain.toml;
CI definitions under .ci/.
Agents MAY freely modify specified implementation and test code within those boundaries.
Commit messages explain why, use imperative subjects, and contain no AI attribution.
9. Services
Source: https://vcs.bugabinga.net/smith.
CI: https://ci.bugabinga.net.
Luci discovers .ci/*.kdl from the public source repository.
CI configuration is orchestration only and MUST call Cargo or xtask.
Credentials, mutable automation state, and provider output MUST NOT enter the repository.
10. Generated State
Generated files, build outputs, scratch workspaces, credentials, captures, and local caches MUST remain ignored and untracked. Repository history MUST contain source, contracts, retained research, and deliberate fixtures only.
# Project InvariantsThese rules govern Smith development. Changing one requires explicit owner approval.
## 1. Product Authority- `docs/SPEC.md` is the complete product contract.
- The specification contains product requirements only.
- Research is evidence, never authority.
- Production Rust work starts only after the relevant product behavior is specified.
- Prototypes may validate uncertain claims but MUST NOT become production dependencies.
## 2. Build BoundaryCargo is the sole build interface.
```textcargo build
cargo test
cargo fmt
cargo clippy
cargo run -p xtask -- <command>
```
Forbidden production build surfaces:
- Makefiles;
- justfiles;
- root scripts;
- root `package.json`;
- Python, Node, or shell as a second build system.
`xtask` MAY orchestrate installed tools but MUST contain no product logic. Any CI definition MUST delegate to Cargo or xtask.
Workspace version starts at `0.1.0` under Apache-2.0. Release builds use optimization level 3, thin LTO, one codegen unit, stripped symbols, and aborting panics.
## 3. Repository Layout```textsmith/ shared contracts
smith-core/ agent runtime
smith-ai/ provider integrations
smith-tui/ terminal frontend
smith-harness/ orchestration and Lua plugins
smith-cli/ executable
xtask/ Cargo orchestration
docs/SPEC.md product contract
docs/research/ retained evidence
prototypes/ isolated disposable proofs
```
Product code lives in crates. Product requirements live in `docs/SPEC.md`. Research and prototypes MUST NOT define runtime behavior.
## 4. Rust- Use latest stable Rust and edition 2024.
- Product code MUST compile without warnings.
- Workspace lints live in root `Cargo.toml`; target flags MUST NOT weaken them.
- Library crates forbid unsafe code.
- `smith-cli` MAY use unsafe only for unavoidable terminal operations behind a documented, tested safe abstraction.
- Shipped libraries MUST NOT use `unwrap`, `expect`, `panic`, `todo`, or `unimplemented` for external failures.
- Use rustfmt defaults from `rustfmt.toml` and the project policy in `.clippy.toml`.
## 5. Dependencies- Root `[workspace.dependencies]` is the single dependency registry.
- Crates inherit shared dependencies from the workspace.
- New or removed third-party dependencies require owner approval.
- Version bumps are maintenance unless they change API compatibility, Rust requirements, architecture, or binary/compile budgets.
- Heavy dependencies stay in the crate that owns their concern.
- An incremental crate edit MUST rebuild only that crate and its reverse-dependency closure.
- Cold-build time and crate count are regression-gated once a full-workspace baseline exists.
- Product code MUST NOT depend on prototype crates.
## 6. VerificationBefore integration, run the smallest complete applicable gate. At minimum:
```textcargo fmt --all --check
cargo test --workspace
```
Rust changes additionally require applicable clippy, architecture, documentation, and product-acceptance checks. A failing check MUST NOT be skipped, weakened, or deleted to obtain green output.
Release verification requires at least 80% workspace coverage, more than 80% mutation score, and Criterion scenarios `session_encode_1000`, `session_decode_1000`, `widget_render_100`, `agent_loop_turn`, `config_resolve_3level`, `trace_filter_10000`, and `plugin_load_10`. Benchmark regression above 5% warns; above 10% blocks release.
## 7. Protected DecisionsAgents MUST obtain explicit owner approval before modifying:
- `docs/SPEC.md`;
- `docs/PROJECT-INVARIANTS.md`;
- root `Cargo.toml` dependency membership;
- `.cargo/config.toml`;
- `rust-toolchain.toml`;
- CI definitions under `.ci/`.
Agents MAY freely modify specified implementation and test code within those boundaries.
## 8. Version Control- Git is canonical.
- Canonical origin: `git@vcs.bugabinga.net:smith.git`.
- Canonical branch: `trunk`.
- Integrate by signed fast-forward.
- Never force-push without explicit owner approval.
- Never add merge commits.
- Delete topic branches after integration.
- Commit messages explain why, use imperative subjects, and contain no AI attribution.
## 9. Services- Source: `https://vcs.bugabinga.net/smith`.
- CI: `https://ci.bugabinga.net`.
- Luci discovers `.ci/*.kdl` from the public source repository.
- CI configuration is orchestration only and MUST call Cargo or xtask.
- Credentials, mutable automation state, and provider output MUST NOT enter the repository.
## 10. Generated StateGenerated files, build outputs, scratch workspaces, credentials, captures, and local caches MUST remain ignored and untracked. Repository history MUST contain source, contracts, retained research, and deliberate fixtures only.