Skip to content

spec: H3 amendment, the context diff (#119) - #157

Merged
gosha70 merged 2 commits into
mainfrom
spec/119-h3-context-diff
Nov 24, 2026
Merged

gosha70 merged 2 commits into
mainfrom
spec/119-h3-context-diff

Conversation

@gosha70

@gosha70 gosha70 commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

The design for H3, the context diff (issue #119's FR-004, SC-2), as a spec amendment before any code (D5), approved by the owner on 2026-11-24. Spec only: one section appended to specs/memkernel-0-15-harness-foundations/spec.md. It leaves #119 open: the H3 build follows, then US4 (the README harness section) and the template note in their own PR.

What H3 is

eval/context-diff/diff.py --store … --run <run_id> [--json …], a maintained eval tool like the repeated-mistake count: it reads a run's receipts (H1) from the recall log and reports, per memory the run received, its status against the store now. No server, tool, store or retrieval change.

The owner's decisions

  • C1 (refined): each memory is judged by the last receipt in the run that has its hash; unknown only when no receipt has it.
  • C2: a receipt hashed with a different scheme is rehashed, and its hash is not compared, so a scheme change (Context rescue S4: supersede suggestions at retain, and canonical hashing (#59) #153) is never "changed content". The current scheme is the installed memkernel's CONTENT_HASH_SCHEME (sha256-raw, the only one so far).
  • C3: statuses combine, with the rules stated: missing, unknown and unchanged stand alone; changed and rehashed exclude each other; every other pair combines.
  • C4: diff.py joins CI's mypy --strict beside the count.

Stated for the review (C5–C9)

  • Input, output and exit codes (0 report, 1 no record carries the run id, 2 usage or store error); every scope read.
  • The statuses: missing, superseded/withdrawn, changed, rehashed, flagged (judged against the receipt's own state), source changed, unchanged, unknown.
  • What source changed can and cannot say: only that the source file hashes differently (through memkernel's own compute_content_hash, as revalidation does); not that the memory is wrong, not other files it cites, not a change made and undone; a source outside the project root or unreadable gets no check, reported as such.
  • Cut-down receipts: judged by an earlier full receipt (C1); a note counts the records whose ref_ids were cut short.
  • No memory content in the report.
  • The tests, starting with SC-2 (a superseded decision and a changed code file diff as superseded and source changed).

Review so far

The owner asked that the review's points be in the text before approval: the C3 rules, flagged against the receipt's state, source changed's limits, the source of the current scheme, the cut-short note. DeepSeek (plan review, two rounds): PASS; its gaps (how flagged is read, receipts without a hash, scope lookups, exit codes, older stores' scheme, one hashing function, an empty run versus a wrong id) are closed in the text.

The owner's fixes (c90a092 → head)

  • Code chunks are judged by the file record they belong to, found from the chunk id (<owner>-chunk-<n>), so also after a superseded snapshot's chunk records were deleted: superseded, withdrawn, missing (only when the owner is gone) and flagged come from the owner; source changed compares the file with the owner's content_hash. A chunk is in the tests.
  • unknown combines with superseded and withdrawn (read from the store, not a receipt); missing still stands alone.
  • A gone file counts as source changed even without a source_hash.
  • DeepSeek: PASS; its three precisions (where superseded is read from, splitting the chunk id and an owner that cannot be found, which scheme applies to a chunk's source check) are in the text.

eval/context-diff/diff.py over a run's receipts (FR-004, SC-2). Approved by the
owner: C1 (the last receipt in the run with the memory's hash; unknown only when
none has it), C2 (a different hashing scheme is "rehashed", never "changed"), C3
(statuses combine, with stated rules), C4 (strict type check in CI). Also
stated: flagged judged against the receipt's state, what "source changed" can
and cannot say, where the current hashing scheme comes from, a note when ref_ids
were cut short, exit codes.
A code chunk is judged by the file record it belongs to (found from the chunk
id, so also after its chunk record was deleted): superseded, withdrawn, missing
and flagged come from the owner, and source changed compares the file with the
owner's content_hash. unknown combines with superseded and withdrawn (read from
the store, not a receipt); missing still stands alone. A gone file counts as
source changed even without a source_hash. Tests: a chunk of a superseded
snapshot, unknown with superseded, a gone file with and without a source_hash.
@gosha70
gosha70 merged commit 87e216e into main Nov 24, 2026
9 checks passed
@gosha70
gosha70 deleted the spec/119-h3-context-diff branch November 24, 2026 13:36
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.

1 participant