# M5a task 04: entries and the check **Branch:** `m5a` (run `git switch m5a`; `git status --short` must be empty, otherwise stop) **Commit subject:** `memoryd: entries, and the check on every memory write` ## Goal Two small modules (M5a spec, section 3 and section 5, "The check"): - `entries`: `memory.md` and `user.md` are entries separated by a line holding only `ยง`. Parse, render, and measure a file in characters. - `check`: every entry the agent writes, and every identity entry going into the prompt, is refused if it holds a control character (other than newline and tab), an invisible or direction-changing character, chat-template markup, or one of six instruction phrases. The table of invisible characters is written in the skeleton, from Unicode 16's `Default_Ignorable_Code_Point` property, plus six more. ## Files - Copy (skeleton): `crates/memoryd/src/entries.rs` - Copy (complete, nothing to fill): `crates/memoryd/src/check.rs` - Copy (tests): `crates/memoryd/tests/entries.rs`, `crates/memoryd/tests/check.rs` - Modify: `crates/memoryd/src/lib.rs`, `docs/implementer-log.md` ## The edits, exactly **`crates/memoryd/src/lib.rs`:** add `pub mod check;` before `pub mod config;`, and `pub mod entries;` after it. The file then lists `check`, `config`, `entries`, `socket`. ## The skeleton, and the given `check.rs` `entries.rs`: fill `parse`, `push`, `render`, `size`. `check.rs` is **given complete**, and its tests pass as soon as it is copied. Do not change it, and do not open its test or work through the test cases in your reasoning. Some of those cases are chat-template tags, built from pieces so that no file holds one. Your own model uses the same tags to mark its reasoning and its tool calls. If you spell one out, even in your thinking, it ends your reasoning or your turn. That is what stopped this task twice before. If you ever need to refer to them, call them "the markup strings". ## Steps - [ ] **1. Copy** the four files; edit `lib.rs`. - [ ] **2. See it fail.** `cargo test -p memoryd --test entries --test check`: `entries` 3 failed; `check` 6 passed (it is given complete). - [ ] **3. Fill** the four functions of `entries.rs`. `cargo fmt --all`. - [ ] **4. See it pass.** The same command: 3 and 6 passed. - [ ] **5. Run the gate.** `make gate`: `gate: ok`, 9 more tests than before (about 877). - [ ] **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.