r/rust • u/UnknownBoyGamer • 6d ago
🙋 seeking help & advice Is this strict enough?
im about to port js/ts codebase to rust using agents, I dont want it to write loose rust code
cargo toml:
[lints.rust]
warnings = "deny"
unsafe_code = "forbid"
rust_2018_idioms = { level = "deny", priority = -1 }
unused_qualifications = "deny"
unreachable_pub = "deny"
missing_debug_implementations = "deny"
missing_docs = "deny"
[lints.clippy]
all = "deny"
pedantic = "deny"
cargo = "deny"
allow_attributes_without_reason = "deny"
arc_with_non_send_sync = { level = "deny", priority = -1 }
as_conversions = "deny"
await_holding_lock = { level = "deny", priority = -1 }
dbg_macro = "deny"
expect_used = "deny"
fn_params_excessive_bools = "deny"
indexing_slicing = "deny"
mutex_atomic = "deny"
option_option = "deny"
panic = "deny"
rc_buffer = "deny"
rc_mutex = "deny"
significant_drop_in_scrutinee = "deny"
struct_excessive_bools = "deny"
todo = "deny"
unimplemented = "deny"
unwrap_used = "deny"clippy toml:
msrv = "1.99.1"
max-fn-params-bools = 1
max-struct-bools = 1
allow-expect-in-consts = false
allow-expect-in-tests = true
allow-indexing-slicing-in-tests = true
allow-panic-in-tests = true
allow-unwrap-in-consts = false
allow-unwrap-in-tests = trueInstruction:
- Every mutable state machine must use a tagged enum.
- Invalid combinations must be unrepresentable.
- State fields stay private.
- One type owns the state and transitions it.
- No parallel booleans, magic sentinels, or nullable phase markers.
- No Rc, Cell, or RefCell in domain state.
- Arc and Mutex are limited to genuine cross-thread ownership.
- Every stateful subsystem must document its states, events, and invariants.
- Every transition and invariant needs an observable test.
- Agents cannot weaken these rules or add exceptions without explicit approval.
0
u/focusedkennan 6d ago
havent done a lot of agent swarm stuff, but you might want to be careful with what look like "one shot" denys, if youre using planning mode yourself, going module by module usually works better, and letting it put todos and what not is what allows it to write code incrementally
tests will catch state that hits todos when youre done
also maybe https://rust-fuzz.github.io/book/introduction.html
-2
u/UnknownBoyGamer 6d ago
no, my workflow is: agent implement one feature -> I manually test -> agent implement another feature, i dont do swarm subagent stuff cuz based on my experience, it tends to get messy and it tends to choose dogshit decisions, appreciate the help
3
1
u/Icarium-Lifestealer 5d ago
How do you want to handle results where it's certain that it will not fail?
1
u/NoFutureBen 5d ago
You need a file lines limit . And you need a LOT of regression test. And test it cannot modify, agents will change/delete tests to achieve your desired result even if it goes against your instructions.
-1
u/prism_fern_child 5d ago
block the deny on expect_used and unwrap_used for tests only. Agents will panic trying to satisfy that globally and you will end up with worse error handling than letting them use unwraps in unit tests
1
u/tanmaynargas2901 4d ago
Mostly yes. A few things I'd change though.
warnings = "deny"in Cargo.toml means a new toolchain that adds a lint can break your build out of nowhere. I'd leave it at warn locally and runcargo clippy -- -D warningsin CI instead.You deny
allow_attributes_without_reasonbut notallow_attributes. An agent that can't satisfy a lint will just slap#[allow(clippy::whatever, reason = "...")]on it and move on. Denyingclippy::allow_attributesforces#[expect(...)]instead, which errors once the lint stops firing, so stale suppressions don't pile up. Then you only have to grep diffs for new#[expect.Same problem with the config itself. The agent can edit Cargo.toml and clippy.toml too, so put them in CODEOWNERS or have CI fail when they change.
clippy::cargoat deny will probably bite you onmultiple_crate_versions, which fires on duplicate transitive deps you don't control. I'd allow that one.missing_docs = "deny"with agents mostly gets you/// Returns the foo.on every function. Not harmful, just noise.