Skip to content

docs: open spec for memory dynamics (decay, delta-writes, decision hi… - #182

Merged
navbytes merged 7 commits into
mainfrom
feat/memory-dynamics-spec
Jul 30, 2026
Merged

docs: open spec for memory dynamics (decay, delta-writes, decision hi…#182
navbytes merged 7 commits into
mainfrom
feat/memory-dynamics-spec

Conversation

@navbytes

Copy link
Copy Markdown
Owner

…story)

Kimi K3-inspired spec covering four additive features: half_life/reviewed relevance decay, if_exists write steering on nt_note, a ## Decisions convention with nt decide + nt history over the git layer, and a recall escalation hint. All opt-in, byte-identical for untouched stores; builds on valid-windows, distill, tiers, and the note undo journal rather than duplicating them.

Claude-Session: https://claude.ai/code/session_01Ku62tzyPQMMbwQwywahtX1

…story)

Kimi K3-inspired spec covering four additive features: half_life/reviewed
relevance decay, if_exists write steering on nt_note, a ## Decisions
convention with nt decide + nt history over the git layer, and a recall
escalation hint. All opt-in, byte-identical for untouched stores; builds
on valid-windows, distill, tiers, and the note undo journal rather than
duplicating them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ku62tzyPQMMbwQwywahtX1
@navbytes

Copy link
Copy Markdown
Owner Author

What this spec improves, in plain terms

Right now nt is a great filing cabinet: notes go in, they stay forever, and they all look equally trustworthy no matter how old they are. This spec adds four small behaviors that make it act less like a filing cabinet and more like a good memory.

1. Notes can age. A note can carry a shelf life (half_life: 90d). As it gets older without anyone re-confirming it, it slowly sinks in recall results — never hidden, just ranked lower and marked ~faded. A two-year-old gotcha about an old tool version stops outranking fresh, correct info. A quick nt touch says "still true" and resets the clock.

2. Agents stop creating duplicates. Today, when an AI learns something new about a topic, it tends to create a second note next to the first — and later searches surface both, including the wrong one. if_exists: "return" on nt_note lets the create call say "this note already exists — edit that one instead." One topic, one note, kept current.

3. Notes remember why they changed. Editing in place is good, but it erases the story. Each note gets a small ## Decisions list — one dated line per change ("switched X → Y because Z"). An agent reading the note sees not just the current answer but what was already tried and rejected, so it doesn't re-propose the old wrong idea. Full per-edit detail stays in git, readable on demand via nt history.

4. Search admits when it's unsure. When recall comes back with weak matches, the response says so and tells the agent exactly what to try next (full-text search including archived notes) instead of the agent trusting a bad answer or giving up.

Net effect: the store stays smaller and fresher, agents find the right note more often, trust it the right amount, and repeat past mistakes less. All of it is opt-in — a store that ignores these features behaves byte-identically to today.

(Design inspired by the two mechanisms behind Kimi K3's ~2.5× scaling-efficiency gain — delta-rule memory with learned decay, and attention residuals across depth — translated into plain-text policies. Full mapping in the spec.)

claude added 5 commits July 30, 2026 12:03
Grounded in an investigation of the Pi extension and Claude Code plugin:
tool exposure is dynamic in both (new MCP tools need zero bridge changes),
the only mandatory Pi code change is the two write-detection regexes, and
decay applied inside recall.RankProject reaches all three error-recall
paths automatically. Work breakdown per phase (files, functions, tests),
rollout matrix, sequencing (3 -> 1 -> 2 -> 4), risks, estimates.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ku62tzyPQMMbwQwywahtX1
nt_note/nt note gain if_exists=create|return|error — an exact slug/title
match (folder-scoped when one is given, retired notes never match) steers
the agent to edit the canonical note instead of minting a sibling; return
writes nothing and hands back the mtime token for the expect_mtime loop.
Low-confidence/empty recall now carries an escalate hint pointing at the
new include_archived deep sweep on search; retired hits are flagged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ku62tzyPQMMbwQwywahtX1
…phases 1-2

half_life:/reviewed: frontmatter with smooth down-ranking in recall (beside
expiredPenalty, Confidence stays pre-penalty), fade-rollup in the tiered
index (arithmetic invariant preserved), faded flags on every read surface,
a review-report faded section, and doctor warnings for malformed decay
values — all opt-in, byte-identical for untouched stores. nt touch/nt_touch
resets the decay clock; nt decide/nt_decide maintains the ## Decisions
version history (newest-first, hostile-input refused, supersede stamps
provenance on the replacement); nt history/nt_history reads the git layer
(--follow, honest no-git error). Pi extension write-regexes learn the new
verbs; Claude/Pi skills and prompts teach if_exists-first capture, decay,
and escalation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ku62tzyPQMMbwQwywahtX1
…ation

Eight confirmed findings, all fixed: nt_touch/nt_decide re-stat after save
so the returned mtime token survives the documented expect_mtime round-trip
(test now proves the chain); nt_archive superseded_by= stamps the same
provenance decision line as every other supersede door; nt_history converts
nt's Nd/Nw shorthand for git --since (raw '30d' silently filtered out ALL
commits) and an empty filtered result no longer claims the note was never
committed; nt note --json --if-exists return emits the JSON payload with
the mtime token; ranking samples one now per pass, not per candidate;
nt_get / nt show --json / search stubs expose faded/halfLife/reviewed/
decisions; the ## Decisions scanner is code-fence-aware; nt touch refuses
--expect-mtime with multiple handles.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ku62tzyPQMMbwQwywahtX1
….2.0

SPEC.md documents half_life/reviewed and the ## Decisions convention in §5,
the new commands in §7.3, and a memory-dynamics feature entry in §9; README
gains the memory-that-ages-honestly bullet; nt help lists touch/decide/
history (typo suggestions included); claude-integration.md gets a worked
end-to-end example (verified against the built binary); Claude Code plugin
bumped to 0.2.0 with refreshed descriptions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ku62tzyPQMMbwQwywahtX1
@navbytes
navbytes force-pushed the feat/memory-dynamics-spec branch from 4123bd1 to a19be5d Compare July 30, 2026 12:04
Three findings from running fresh Sonnet/Haiku sessions against a shared
store: (1) --old-string/old_string that matches the DESCRIPTION now gets a
targeted error naming the real field (--desc / description arg) instead of
a bare not-found, on both CLI and MCP; (2) nt edit accepts --source only to
explain that provenance is set at creation and edits keep it, replacing the
opaque flag error two agents hit; (3) an empty --project scope on nt index
warns that the store's vocabulary may differ (check nt tags) rather than
reading as 'those notes don't exist', and both skill copies teach
vocabulary-first scoping plus that nt history covers the memory store's
repo, not the project's.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ku62tzyPQMMbwQwywahtX1
@navbytes
navbytes merged commit f9e2769 into main Jul 30, 2026
9 checks passed
@navbytes
navbytes deleted the feat/memory-dynamics-spec branch July 30, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants