# M5a task 07: the journal, undo and review **Branch:** `m5a` (run `git switch m5a`; `git status --short` must be empty, otherwise stop) **Commit subject:** `memoryd: the edit journal, undo of the latest edit, and review` ## Goal M5a spec, section 5, "Seeing writes", "Undo" and "Review": - Every applied write is one JSON line in `memory/edits/YYYY-MM.jsonl`, with an id numbered from 1 each day (`2026-09-24-0001`), the entries before and after, and where it went. `log` lists the last N. - `undo` reverts an edit only if it is the latest edit of its identity file **and** the file still holds exactly what it left; the undo is journalled too. Notes are append-only and never undone. - With review on, identity writes wait in `memory/pending.jsonl` until the owner accepts one (applied then, against the file as it is) or rejects it (journalled). ## Files - Copy (skeletons): `crates/memoryd/src/journal.rs`, `crates/memoryd/src/review.rs` - Copy (test): `crates/memoryd/tests/journal.rs` - Modify: `crates/memoryd/src/lib.rs` (`pub mod journal;` after `pub mod files;`, `pub mod review;` after `pub mod notes;`), `docs/implementer-log.md` ## The skeletons `journal.rs`: `Record` and `file_of` are written; fill `records`, `append`, `record`, `log`, `undo`. `append` is `pub(crate)` because `review::reject` journals through it. `review.rs`: `Line` is written; fill `lines`, `add`, `waiting`, `submit`, `list`, `accept`, `reject`. ## Steps - [ ] **1. Copy** the three files; edit `lib.rs`. - [ ] **2. See it fail.** `cargo test -p memoryd --test journal`: 4 failed. - [ ] **3. Fill** `journal.rs`, then `review.rs`. `cargo fmt --all`. - [ ] **4. See it pass.** The same command: 4 passed. - [ ] **5. Run the gate.** `make gate`: `gate: ok`, 4 more tests than before (about 900). - [ ] **6. Log and commit.** `git add -A crates/memoryd docs/implementer-log.md Cargo.lock && git commit` ## Done when - `make gate` prints `gate: ok`. ## Stop and report if - A test fails after the functions follow their comments exactly. Do not edit a test.