-
Notifications
You must be signed in to change notification settings - Fork 0
write primitives
parent_design: ../../memoryvault.md
part_slug: write-primitives
title: "Write primitives — memory save + memory evolve"
status: pending
visibility: published
author: Alex Herrero
contributors: []
created: 2026-05-15
updated: 2026-05-15
last_major_revision: 2026-05-15
dependencies: []
estimated_scope: M
prd:
project:
Parent design: MemoryVault — see Detailed Design §1 for the full architectural context.
This part ships the two foundational write primitives that every other part of MemoryVault depends on:
/memory save <kind> <slug> [--group <group>] [--always-load] — writes an entry at MemoryVault/<group>/<kind>/<slug>.md with YAML frontmatter (kind, status: active, created, updated, tags, optional supersedes). Body is free-form markdown. On save: file write is synchronous (<50ms target); embedding + vec-index update are async (don't block the agent or the user). The --always-load flag writes to MemoryVault/personal-private/_always-load/ and sets always_load: true frontmatter — entries flagged this way get injected at SessionStart per the recall-loop part.
/memory evolve <old-path> <new-content> <reason> — atomic archive-and-replace. Five steps: (1) Read the old entry; (2) write new entry with supersedes: <old-path> frontmatter pointing back; (3) atomically move old entry to MemoryVault/personal-private/_archive/<original-path>.YYYYMMDD.md via filesystem rename (single-syscall atomicity on macOS APFS); (4) update old entry's frontmatter status: superseded + superseded_by: <new-path> cross-link; (5) trigger vec-index update for both files. Recall filters skip status: superseded by default.
Tri-modal confidence routing (HIGH → auto-save / MEDIUM → interactive review / LOW → _inbox/) applies only when the reflection sidecar invokes these primitives — direct user invocation always writes immediately to the requested location.
The skill home is crickets/skills/memory/SKILL.md with full YAML frontmatter (name: memory, kind: skill, supported_hosts: [claude-code, antigravity], version: 0.1.0, install_scope: project) and tool allowlist [Read, Write, Edit, Glob, Grep] — no Bash. This part ships the skill scaffold + the save and evolve sub-command bodies only; recall/reflection/idea-ledger sub-commands stub for future parts. (Standalone Gemini CLI host removed from supported_hosts in v0.9.0 per ROADMAP item #15 / ADR 0006.)
None — foundational. All other parts depend on this one. The only pre-existing dependencies are:
-
sqlite-vec Python package (
pip install sqlite-vec) — installed lazily on first save invocation; if missing, save still succeeds (file write is unconditional) but index update is deferred until the dep lands. -
Local
sentence-transformers— the only embedding mode as of v0.9.2 (see ADR 0001's 2026-05-20 amendment). Call is async (queued); first invocation downloads BGE-large (~1.3GB) lazily; subsequent calls are on-device + offline-capable. The save side is unconditional — file write never blocks on embedding state. Embedding implementation lives in the recall-loop part.
-
Smoke install green —
bash crickets/scripts/smoke-install-bash.sh(+.ps1) verifies thememoryskill installs at the 2 host destinations (.claude/skills/,.agent/skills/); negative-existence assertions verify.agents/skills/is NOT created (gemini-cli removed in v0.9.0). -
validate-manifests.pyclean — skill manifest parses with no errors; skill count increments. -
/memory saveend-to-end — invoke against a scratch vault; file lands at the expected path with correct frontmatter (kind,status: active,created,updated,tags,group); content matches the input. -
--always-loadflag — files written with the flag land in_always-load/subdir withalways_load: truefrontmatter. -
/memory evolveend-to-end — invoke against an existing entry; verify old entry is archived to_archive/<original-path>.YYYYMMDD.mdwithstatus: superseded+superseded_bycross-link; new entry hassupersedescross-link; both files exist on disk after the operation. -
PII guardrails apply —
crickets/scripts/check-no-pii.shclean on toolkit-committed content (skill source + templates); pre-push hook runs clean. - All 3 OS CI workflows green on the commit that lands this part.
- This is the foundational part — every later part assumes these primitives exist + behave as specified above. If the spec needs amendment mid-execution, append to the parent design's Document History before re-running
/design translateon this part. - The skill body should document both sub-commands per the established pattern from
crickets/skills/design/SKILL.md(which is the first toolkit skill with multi-sub-command bodies — use it as the reference shape). - The vec-index file at
MemoryVault/_meta/vec-index.dbdoesn't need to exist when save is first invoked; create on first call if absent. - The
_archive/subdir doesn't need to exist for the first save; create lazily on first evolve.