Section 17 of 25
Recipes
Contents
Every recipe starts with a test that fails on the old code, on an assertion and not on compilation. In Rust, write the signature first with todo!(), so the test compiles and fails for the right reason.
17.1. A new read (Query)
core/<s>/model.rs: the result type, if it does not exist.core/<s>/store.rs: the read function. Test it on a temporary database.core/<s>/service.rs:pub async fn <verb>(…)that calls store and logic.core/<s>/mod.rs:pub usethe new function or type.app/<s>/dto.rs: the DTO andFrom<model>.app/<s>/commands.rs: a command of at most 10 lines; register it.- Front-end: the data-access layer calls the command.
17.2. A new change without background state (Command)
As 17.1, and the decision (is it allowed, what changes) is written in logic.rs as a pure function with a test. service.rs only calls it and performs the write.
17.3. A new slice
- Name: the feature as a singular noun in
snake_case. core/src/<s>/mod.rsplus only the files it needs;pub mod <s>;incore/src/lib.rs.app/src/<s>/mod.rs,commands.rs,dto.rs; register its commands.- If the slice has background state: recipe 17.4.
17.4. A new flow with state (actor)
- Check the three conditions from 9.1. If one fails: recipe 17.2.
msg.rs,state.rs,snapshot.rs: the types.update.rs: tests first (message in, expected effects and state out), then the implementation.effect.rs:executefor every effect; results return asMsg.run.rsandhandle.rs: the loop and the door.AppStategets exactly one field: the registry or theHandle.app/<s>/events.rs: subscribe to theSnapshotandemit("<s>:snapshot").
17.5. A new driver (the outside world)
drivers/src/<name>.rsor a folder. A driver knows no slices and no database.- A trait only when there are at least two implementations.
- A process: process group, kill escalation, proof of death; secrets kept out of arguments and logs. All of it through the contracts of
platform(12.2), never through a system call in the driver. - A slice uses the driver from
service.rsor fromeffect.rs.
17.6. A new event for the window
- A change in
corepublishes aSnapshotor anEventon a channel. app/<s>/events.rssubscribes and emits<s>:<event>.- Front-end: the data-access layer listens and updates its store.
17.7. A new platform
Section 12.7.
17.8. Where does this go? (decision tree)
Does it call Tauri, the window, MCP or a remote hub? → app (commands, events, doors)
Does it depend on the operating system? → drivers/src/platform/ (section 12)
Does it talk to a process, the network, a keychain? → drivers (through platform contracts)
Is it a database read/write or the schema? → store (connection) / core/<s>/store.rs (queries)
Is it a pure decision or a calculation? → core/<s>/logic.rs (or update.rs in an actor)
Is it a domain type? → core/<s>/model.rs
Is it a sequence of steps with I/O? → core/<s>/service.rs
Is it state that lives in the background and the window watches? → core/<s>/actor/
Can the user switch it off while the rest keeps working? → a plugin slice (section 23)
Does it have no domain at all (time, paths, ids, files)? → kit
The first question is about the entry alone: the command, the emit, the listener of an MCP server or of a remote hub. What such an entry does (pairing, encryption, the messages a bridge carries, the rules of a remote session) is domain, and lives in a core slice that the entry calls.