Task 04's session read the given test and the check.rs skeleton, both holding the tags the check refuses, and Ornith took them for its own template. It lost track of the file and made no change. The tags are now built with concat! and format! in check.rs and in the four given tests that held them, and the spec describes them in words. The rewritten tests pass against the reference, are rustfmt-clean, and still catch the case-folding mutation. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2.4 KiB
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.mdanduser.mdare 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'sDefault_Ignorable_Code_Pointproperty, plus six more.
Files
- Copy (skeletons):
crates/memoryd/src/entries.rs,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 skeletons
entries.rs: fill parse, push, render, size. check.rs: Refused and its sentences,
DEFAULT_IGNORABLE, ALSO_INVISIBLE, MARKUP and PHRASES are written; fill invisible and
check. Do not change the tables.
Markup in this code. MARKUP and the test build the chat-template tags from pieces
(concat!("<", "think"), format!("{LT}think>")), so that no file holds a tag literally. Keep it that
way: do not write a tag out whole in code, a comment, a command or your log. When you need to
name one, say "the opening think tag".
Steps
- 1. Copy the four files; edit
lib.rs. - 2. See it fail.
cargo test -p memoryd --test entries --test check:entries3 failed,check6 failed. - 3. Fill the six functions.
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 gateprintsgate: ok.
Stop and report if
- A test fails after the functions follow their comments exactly.