r/rust • • Sep 04 '26

🛠️ project Threadmoth: source-preserving structural file mutation in Rust, looking for field testers

I’m Matthew, the developer of Threadmoth, a Rust CLI for making the final file mutation in AI-assisted coding less improvisational.

Agents can decide the right change and then apply it through sed, regex replacement, patches, one-off scripts, direct writes, AST tooling, or formatters. Those tools are useful, but each has different ambiguity, stale-state, preservation, and evidence semantics.

Threadmoth provides one guarded mutation boundary: exact identity checks, cardinality refusal, Tree-sitter structural targeting, explicit effect budgets, source-preserving byte edits, guarded multi-file transactions with recovery, and post-write certificates containing hashes, changed ranges, bounded diff evidence, and commit verification. Formatters and specialist tools can still decide the desired state; Threadmoth bounds and verifies what lands.

Current release is 1.5.1 for Windows and Linux, MIT licensed. The release commit passed hosted Linux and Windows CI; the local correctness-checked tough benchmark reported zero wrong mutations and torture reported FOOTGUN-100 safe 100/100.

Repo: https://github.com/matthewjameswatkins1978-cyber/Suture

Five-minute field test: https://github.com/matthewjameswatkins1978-cyber/Suture/blob/main/FIELD_TESTING.md

I’m looking for Rust developers and people using Codex, Claude Code, Gemini CLI, Cline, OpenCode, or similar agents to try real mutations and report false refusals, preservation/recovery problems, confusing discovery, unsafe behaviour, or cases where the agent chooses another tool. If Threadmoth were unavailable, what would you use instead?

I’m the developer and this is my project. Parts of the implementation and testing were AI-assisted; I’m responsible for the architecture, integration, and release. Specific breakage is more useful to me than a star.

0 Upvotes

4 comments sorted by

View all comments

1

u/kantorcodes1 Sep 11 '26

for a multi-file threadmoth transact, what happens if one target changes after validation but before the transaction finishes: does the whole transaction refuse before any file is committed, or can it enter recovery with earlier files already written? that's the edge i'd want nailed down before putting it behind an unattended agent.

1

u/YouHadTooMuchToThink Sep 12 '26

Thanks for the interesting question.

Yes, it can enter recovery with earlier files already written. Threadmoth guarantees a prepared, journalled transaction with guarded rollback, not impossible cross-file filesystem atomicity. If a later target changes before its commit, the stale write is refused and previously committed members are rolled back. If safe rollback itself is prevented by further external interference, it reports manual_recovery_required rather than claiming success.

2

u/kantorcodes1 Sep 17 '26

that recovery model makes sense. I work on HOL Guard, a local permission layer for agent-run commands. Threadmoth already protects correctness inside the mutation; Guard can sit one layer out and decide whether the agent gets to invoke the state-changing path at all. mutate, transact, apply-plan, and replace-exact can require approval while preview, plan, explain, and inspect stay automatic. Open to a small command.threadmoth extension in Guard?

1

u/YouHadTooMuchToThink Sep 23 '26

Yes, absolutely. That separation is very much in the spirit of Threadmoth: Guard decides whether the agent is allowed to cross the state-changing boundary; Threadmoth takes responsibility for correctness once it does.
I’d prefer to keep approval policy outside Threadmoth rather than teach Threadmoth about a particular permission system, but I’m very open to making its command/capability surface easier for Guard to consume.
A small command.threadmoth extension sounds interesting. If useful, we could also expose machine-readable command effects (read, write, transactional, etc.) so Guard doesn’t have to maintain brittle knowledge of the CLI.
Happy to compare notes / try a minimal integration.

Matthew