8.6 KiB
Agent brief: MiniMax M3.1 Flash on NotesCraft
You are a coding agent building part of NotesCraft: a native, Obsidian-compatible notes app in Rust only (egui/eframe, no JavaScript, no webview). Read this whole brief, then the TASK at the end. Follow it exactly. When the brief and the task disagree, the task wins; when the task and the repo rules (AGENTS.md) disagree, stop and report.
Skills and rules (load them)
This repo ships project skills in .claude/skills/ and path rules in .claude/rules/ (loaded automatically in the Claude Code harness; with Pi read the files yourself). Start with notescraft-agent-workflow, then notescraft-rust-safety for Rust, notescraft-verify-loop before you finish, notescraft-egui-screen for UI, notescraft-engine-command for engine and vault, notescraft-sync-protocol for sync. They hold the code patterns to copy; this brief holds the hard limits.
Before you write code
- Read
AGENTS.md(workspace rules) and every file the task lists under READ FIRST. - Read neighbouring code in the crate you edit and copy its style: naming, comment density, error handling, test layout. Do not invent a new pattern when one exists.
- Plan the work as small steps of at most about 150 lines of new code each. Write one file per tool call, build after each step.
Hard rules (the build and review reject violations)
- Never
unwrap(),expect(),panic!,todo!,unreachable!,unimplemented!in non-test code. Nounsafe. - Never index or slice with an input-derived value (
v[i],s[a..b]), even when guarded. Useget(),split_at_checked, iterators,checked_*,saturating_*. - Bound every loop over input (each iteration consumes input or has a cap) and every allocation sized by input. A loop that does not advance can eat all memory: run tests as
timeout 120 cargo test .... - Invalid input returns
Err. Never silently clamp, truncate or "fix" it. - Every user-visible string goes through the i18n tables (
crates/i18n/locales/en.toml, thencargo xtask i18nmust be clean). No hardcoded UI text. - Every write to disk goes through
craft-atomic(or the vault'swrite_privatefor.notescraft/). Never write.obsidian/. - Files stay at or below about 400 lines; split by concern. A source directory holds at most 12 loose
.rsfiles (mod.rs,lib.rsnot counted): put new modules in a sub-folder withmod.rswhen the directory is full. Check withcargo xtask tree. - Layering is enforced (
cargo xtask layers): a crate depends only on lower layers; nothing below L6 uses egui. - A new third-party dependency needs owner approval. Approved:
notify,pulldown-cmark,toml,wasmi,thiserror,serde,serde_json,sha2,axum,tokio,ureq(rustls),rusqlite. Anything else: stop and ask in your final report. - Every public item has rustdoc; every module has a
//!comment. OnethiserrorenumErrorandpub type Result<T>per crate. - Clippy pedantic is on with
-D warnings. Known traps:too_many_lines(100),many_single_char_names(userow/col, noti/j, when more than 4 short names),assert!(x.is_empty())(useassert_eq!(x, [])),explicit_iter_loop, collapsibleif letchains (use&&let-chains), by-value params that are not consumed,format!appended to aString(usewrite!),ascasts between integer/float types (usetry_fromorf64::from). - Smallest design that works. No speculative abstractions, no extra features, no files beyond what the task names plus tests.
Working rules for the shared tree
- You share the working tree with other agents. Edit ONLY the files and folders the task lists under OWNS. Never touch root
Cargo.toml,Cargo.lock(cargo may update it for approved dependencies already registered; do not hand-edit),xtask/,SPEC.md,ROADMAP.md,docs/, or another agent's files. - Do not run
git add,git commit,git checkout,git stash,git resetor any command that changes git state. Do not delete files you did not create. - Use your own target dir: the launcher already sets
CARGO_TARGET_DIR. Never touchtarget/debug. - Never print, copy or log secrets or tokens.
Tests and verification (all mandatory)
- Test first: write the failing test, then the code. Unit tests in
src, integration tests intests/. Tests may useunwrap/expect. - Byte offsets in tests: compute with
str::find, never by hand (éis 2 bytes). - Every module must be declared in its
lib.rs/mod.rs, and its tests must run: after writing tests, confirmcargo test -p <crate>lists them. - Run, in this order, and fix every failure at the root cause (never weaken a test, never add an
allowto pass):timeout 300 cargo test -p <crate>cargo clippy -p <crate> --all-targets -- -D warnings- format ONLY your own files:
rustfmt --edition 2024 <file>...(nevercargo fmt -por--allwhen other agents share the crate: it rewrites their unfinished files) - the extra commands the task names
- Do not claim success unless these passed in your last run. Paste the final test summary line.
Output hygiene (you have a response cap)
- Keep each response small: one file per tool call, at most about 250 lines. A huge single response gets cut off and you will stall.
- Keep thinking short. When stuck for more than three attempts on one error, stop and report the exact error instead of looping.
- If a command prints a lot, filter it (
| tail -40,| grep -E "error|warning" -A5).
Final report (max 15 lines)
What is implemented; public API signatures; test counts and the last cargo test summary line; every file you created or changed; anything skipped, any dependency you needed but lacked, any rule you could not satisfy.
Lessons from the 2026-10-20 runs (checked against what the agents delivered)
en.toml: add a new[ui.x]table at the END of the[ui.*]tables, never between keys of another table (one insertion split[ui.settings-view-calendar]and broke two tests). After editing runpython3 -c "import tomllib;tomllib.load(open('crates/i18n/locales/en.toml','rb'))".- If lib tests print raw keys like
ui.foo.barinstead of text, the i18n crate was built from an olderen.toml:touch crates/i18n/src/i18n.rsand rerun. Do not "fix" the test. - Never write a call to an API you did not read: open the function in the repo first. Invented egui or engine method names were the most common compile error (
egui::Vertex,semibold_with,on_hover_texton aButton). - Keep each file under 400 lines and each source dir under 13 loose
.rs(cargo xtask tree); put tests of a big file in<file>/tests.rs. - Another session may leave files that do not compile. If
cargo checkfails only in files outside OWNS, say so in the report and verify your part with the narrowest test filter; never edit those files. - Do not run long commands without a
timeout; stdin is closed, so never start anything interactive. - Your final message IS the report. If you run out of room, write the report first and the extras later. A last message like "Now the integration test:" counts as unfinished work.
- The launcher's
doneline only means the process ended. Quota errors (429, 2067) end a run silently: the owner checks the tail of the.jsonl.
TASK:
Lessons from the 2026-10-21 runs (8 of 9 briefs delivered, all gated by cargo xtask ci)
- Small, pure, one-crate briefs work: tags rename/merge, paste URL,
notescraft://URI, periodic notes,export.pandoc,properties.rename_all, outliner moves and the dice wasm plugin all landed with tests. Keep each brief to one new folder plus 1-2 registration lines. - The one failure was
reason: length(outliner, first try): the agent explored for 32k tokens. The retry added aHOW TO STARTblock ("do not explore; open only X and Y; write the first file in your second tool call") and succeeded. Put that block in every brief. - Name the OWNS files and the exact signature of the first function; the agents that had a signature wrote it first and refined.
- Stagger launches by 45 s (3 at once, no "database is locked" seen); give each agent its own
CARGO_TARGET_DIR(the script does). - The lead always re-runs the full gate on a copy of the tree (
cargo xtask ci; budget two runs of ~9 min because the first compile exceeds a 580 s command cap). Agents' own "all gates green" claims matched the gate every time so far, but gaps (no UI wiring, wasm built outside CI) are only found by reading the report. - Built artefacts stay out of git:
dice.wasmis gitignored and its tests are#[ignore]d. - Briefs that need a fixture the repo does not have (a Kanban board saved by the real plugin) must stop at step 0; do not launch them until the owner supplies it.