Files
boxmaker/docs/plans/M5a/06-memoryd-edits.md
T
kyleandClaude Opus 5.5 de1032157b Plan M5a: local memory in 15 tasks
memoryd (files, the check, edits, journal, index, recall, serving),
the memory tools and built-in grants in brokerd, the memory block in
loopd, bxctl reindex and memory, and the device checks with memoryd.

Each task was built as a reference and gated. Each was replayed on its
own at its end state (854 to 936 tests) and mutation-checked. Each
skeleton compiles and fails its tests. Every todo comment was read
beside its signature.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 15:32:54 -07:00

54 lines
2.5 KiB
Markdown

# M5a task 06: notes and the memory edits
**Branch:** `m5a` (run `git switch m5a`; `git status --short` must be empty, otherwise stop)
**Commit subject:** `memoryd: notes.md, and the five memory actions with routing by trust`
## Goal
What a `memory` call does (M5a spec, section 5):
- `note` appends to `notes.md`, in any session, labelled by the session: its class, and
`untrusted` when the session has read untrusted content.
- `add`, `replace`, `remove` and `consolidate` edit `memory.md` or `user.md` (**identity**), and
only a session that has not read untrusted content may use them. In one that has, `add` becomes
a note (`SAVED_AS_NOTE`) and the other three are refused.
- Entries are named by their full text. An edit made against an old view of the file fails
safely; an entry named twice, a duplicate, or a file over its limit is refused, and nothing
changes.
- `remove` and `consolidate` never lose anything: what they take out goes to `notes.md` as
`dropped` or `moved`.
## Files
- Copy (skeletons): `crates/memoryd/src/notes.rs`, `crates/memoryd/src/edit.rs`
- Copy (tests): `crates/memoryd/tests/notes.rs`, `crates/memoryd/tests/edit.rs`
- Modify: `crates/memoryd/src/lib.rs` (`pub mod edit;` after `pub mod config;`, `pub mod notes;`
after `pub mod files;`), `docs/implementer-log.md`
## The skeletons
`notes.rs`: `Kind`, `Note`, `class_name`, `file_of` are written; fill `minute`, `Note::header`,
`Note::render`, `parse_header`, `parse`. `edit.rs`: `Context`, `Change`, `Outcome`, the sentences
(`over_limit`, `untrusted_refusal`, `SAVED_AS_NOTE`, `stale`), and the helpers `checked`, `note`,
`position` are written; fill `apply`, `edited`, `noted`, `consolidate`. `edited` still needs
an arm for a note, which `apply` never passes it: its comment says what that arm returns.
## Steps
- [ ] **1. Copy** the four files; edit `lib.rs`.
- [ ] **2. See it fail.** `cargo test -p memoryd --test notes --test edit`: `notes` 3 failed,
`edit` 8 failed.
- [ ] **3. Fill** `notes.rs` first, then `edit.rs` (`noted`, `consolidate`, `edited`, `apply`).
`cargo fmt --all`.
- [ ] **4. See it pass.** The same command: 3 and 8 passed.
- [ ] **5. Run the gate.** `make gate`: `gate: ok`, 11 more tests than before (about 896).
- [ ] **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.