Repository navigation
feat: recall log and repeated-mistake count (#120) - #124
Merged
Merged
Conversation
…call-log) A normal session start shows memories without calling recall, so logging only recall calls would report them as missed. The owner chose (2026-11-11) that each hook block that shows memories writes one record listing the ref_ids it injected. Corrects the draft's checked fact on the session-start path. Refs #120.
MEMKERNEL_RECALL_LOG (off by default) makes each MCP recall, and each hook block that shows memories, append one JSON line under MEMKERNEL_STATE_DIR/recall-log/<project_id>/, mode 0600, rotated by MEMKERNEL_RECALL_LOG_MAX_BYTES and _MAX_FILES. eval/repeat-mistakes/count.py applies #112's rule to the stores, the recall logs and Claude Code transcripts (temporary reader until #59 Phase 2) and reports each repeat as shown, missed, other store or unknown. recall's results, the MCP tools and the hook scripts are unchanged. README section and settings rows; CHANGELOG. Refs #120.
A lifecycle built without settings falls back to defaults, so its own state_dir, project_id and recall_log can differ from the store's (the FR-011 lesson). Hook records now use self._service.settings; a test pins that a lifecycle built without settings writes to the service's log. Review of PR #124.
1. A record larger than recall_log_max_bytes keeps its first ref_ids, then query text, up to the limit and is marked truncated. 2. on_post_compact(session_id="") logs only when given a session id (the owner's choice); Claude Code's hooks do not call it. 3. The count evaluates every logged filter (session_id_filter and include_needs_review too) and separates MCP recalls from hook blocks in a miss's evidence. 4. shown_without_repeat counts each session once. 5. The log is POSIX-locked like the store locks, with one warning per process on Windows (session_spool.locking(); the owner's choice). 6. mypy --strict passes on the eval modules. Spec amendment A2, README, CHANGELOG. Refs #120.
Second round: records keep query_sha256, the hash of the full query, and the count pairs by it; an oversized record gives up query text first, then trailing ref_ids (binary search, no longer quadratic); a record whose ref_ids were cut is marked ref_ids_truncated and makes a miss unknown; include_needs_review is not judged, since whether a memory was flagged at recall time is not known. Third round: recall_log_max_bytes is at least 4,096 bytes, so a full MCP record always fits; ambiguous tool records are kept as possible records of their candidate sessions and make a miss they may explain unknown; recall-log lines are type-checked, malformed ones skipped and counted. Spec A2, README, CHANGELOG. Refs #120.
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #120. The build of the approved spec (#122,
specs/memkernel-0-10-recall-log/).Commits
100d034spec amendment A1 (the owner's, 2026-11-11): a normal session start shows memories without callingrecall, so each hook block that shows memories logs theref_ids it injected. Corrects the draft's checked fact on the session-start path.b8df8fbthe build.a2db2f1hook records use the service's settings (the FR-011 lesson), with a test for a lifecycle built without settings.ea6a802review fixes, amendment A2:recall_log_max_byteskeeps its firstref_ids, then query text, up to the limit, markedtruncated;on_post_compact(session_id="")logs only when given a session id (the owner's choice; Claude Code's hooks do not call it);session_id_filterandinclude_needs_review, and a miss's evidence counts MCP recalls and hook blocks separately;shown_without_repeatcounts each session once;mypy --strictpasses on the eval modules (CI runsmypy src/only).607f3aasecond and third review rounds:query_sha256(hash of the full query), and the count pairs tool records with transcript calls by it, so a cut query still pairs;ref_ids, by binary search (10,000 ids: 5.6 s before, 0.006 s now);ref_ids_truncatedis written only when ids were dropped, and only that makes a miss unknown;include_needs_reviewis not judged in a miss's evidence: whether the memory was flagged at recall time is not known (listed in the report's limits);recall_log_max_bytesis at least 4,096 bytes (RECALL_LOG_MIN_BYTES), so a full MCP record (seven filters, a 2,000-character query, an id) always fits;malformed_log_records).Changes
config.py, README table):MEMKERNEL_RECALL_LOG(off),MEMKERNEL_RECALL_LOG_MAX_BYTES(5 MB),MEMKERNEL_RECALL_LOG_MAX_FILES(10).src/memkernel/recall_log.py: one JSON line per record underMEMKERNEL_STATE_DIR/recall-log/<project_id>/recall.jsonl(withquery_sha256), created mode 0600, locked on POSIX, rotated before an append would pass the size limit (at least 4,096 bytes); an oversized record is cut to fit and marked; a failed write is logged once per process and never fails the recall; nothing when off or for an in-memory store.recalltool (query and filters) and the session-start and compact-recovery blocks (session id, theref_ids shown);on_post_compactonly when given a session id.recall's results, the MCP tools and the hook scripts are unchanged. The spool's file lock is now public (session_spool.locked) and shared.eval/repeat-mistakes/count.py: applies Question: has a repeated mistake ever been counted on memkernel sessions, in the lifecycle evaluation or in real use? #112's rule (D5), pairs tool records with the transcript's own recall calls (D2), and reports each repeat as shown, missed, other store or unknown (D6), with evidence and limits;--jsontoo. Refuses a store path that does not exist.eval/repeat-mistakes/transcripts.py: a temporary Claude Code transcript reader, until Context rescue: fix the compaction hooks, then capture session knowledge before it is lost (0.5.1 → 0.6) #59 Phase 2.[Unreleased].Tests
tests/unit/test_recall_log.py(10): record fields, mode 0600, query cap, off and in-memory, rotation, one-file mode, a failed write logged once, session-start and compact-recovery records, resume logs nothing.tests/e2e/test_recall_log_tool.py: two MCP recalls leave twotoolrecords with the returnedref_ids and filters.tests/unit/test_repeat_mistakes_count.py(6): a fixture with two stores and seven sessions covering every outcome, a recall after the failure, a two-span memory line, an ambiguous pairing and a note that mentions an error (not counted); signature rule; a filter that excludes the memory.Checks
mypy src/andmypy --strictoneval/repeat-mistakes/clean; fast suite 1082 passed, coverage 94.6%.607f3aa's changes: two rounds, PASS; one valid warning fixed (only cut ids, not a cut query, make a miss unknown), the rest notes. DeepSeek onea6a802's fixes: PASS, three warnings answered. Earlier DeepSeek review: PASS; one typo fixed, three warnings answered (an oversized single record can pass the size limit by one line;ref_idmatching by text relies on UUIDs; the 5-second pairing is two-sided, as the spec says).