Skip to content

feat: revalidate decisions that cite files; flag them, don't hide them (#123) - #127

Merged
gosha70 merged 4 commits into
mainfrom
feat/123-decision-revalidation
Nov 15, 2026
Merged

gosha70 merged 4 commits into
mainfrom
feat/123-decision-revalidation

Conversation

@gosha70

@gosha70 gosha70 commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Refs #123. The build of the approved spec (#126, specs/memkernel-0-10-decision-revalidation/).

Commits

  • db4a251 spec review amendment (from the review of spec: revalidate decisions that cite files (#123) #126, which merged before it): FR-003 covers recall(order="newest") through a checkpoints_newest_first(include_flagged_decisions=False) keyword that only recall sets, so the lifecycle's checkpoint selection is unchanged; FR-004 has both result builders fill the new fields; SC-3c checks both sides; plan and tasks cite the replay as SC-3b.
  • 0e68953 the build.
  • 2c29939 amendment A1 (review of feat: revalidate decisions that cite files; flag them, don't hide them (#123) #127): the hook blocks' context lines (session start, compaction recovery, on_post_compact) label a flagged memory with its reason, e.g. [decision, needs review: changed].
  • f2fd55b second review of feat: revalidate decisions that cite files; flag them, don't hide them (#123) #127: a hashless decision's present file clears only a missing flag (any other flag is kept, counted unknown); the session-start list shows every memory still flagged, including one whose file could not be read this pass; SC-4 tested on a record with no source_hash key (raw metadata checked); README, consolidate and POST /revalidate no longer say code only.

Changes

  • Hash at retain (core/services.py, _new_metadata): a new decision records source_hash when its source is a readable file under the project root. A dedup hit returns the existing record unchanged (it never reaches _new_metadata). Memory.source_hash loads empty from older records.
  • Revalidation: live decisions with a source are flagged changed (hash differs) or missing; hashless decisions only missing, and a present file clears only that flag; a restored file clears the flag; outside the project root or unreadable is unknown. flagged items gain a type key (additive).
  • Recall: flagged decisions are returned on the relevance path and, through the new keyword, on order="newest"; every ArtifactRef carries needs_review and review_reason, filled by both builders. Flagged code stays hidden; checkpoints_newest_first()'s default is unchanged.
  • Session start and compaction: the ### Needs review lines name each item's type ([decision], [code]), with a hint for both; context lines mark a flagged memory ([decision, needs review: changed]).
  • Docs: README (revalidation section, recall row), the recall tool's docstring, CHANGELOG under [Unreleased].

Tests

  • tests/unit/test_decision_revalidation.py (17): SC-1 the Preserve and retrieve implementation alternatives for reuse-first coding #57 file probe (flagged and still returned; code hidden); SC-2 clearing, a record with no source_hash key (SC-4; flagged only when missing, never hashed later), an empty hash, a kept changed flag on a hashless decision, source outside the root or missing at retain, no source; SC-3 cross-source dedup, same-source dedup, a hashless dedup hit; SC-3c the newest path and the lifecycle's selection; D1 the startup list; A1 the startup and compaction blocks' marked context lines (they fail on 0e68953), and an unflagged decision's plain label; a durable flag still listed when its file is unreadable.
  • tests/unit/test_revalidation.py: three exact comparisons now expect the type key and the [code] prefix.

Checks

  • ruff, format and mypy strict clean; fast suite 1099 passed, coverage 94.6%.
  • SC-3b: the Preserve and retrieve implementation alternatives for reuse-first coding #57 replay's rankings are identical to results-k5.json; its file probe now flags the decision on rewrite and delete.
  • Origin gate: aligned, high (after A1). DeepSeek on A1 and on the second-review fixes: PASS, notes only. DeepSeek on the build: PASS; one point applied (helper renamed _exempt_from_review_hiding), three answered (the hash is the retain-time baseline by spec; the newest path ignoring include_needs_review is the spec's choice; a directory source counts as missing, as for code).

…sion-revalidation)

From the review of #126, not merged with it: FR-003 covers recall's order="newest" path through a checkpoints_newest_first() keyword (include_flagged_decisions, default off) that only recall sets, so the lifecycle's checkpoint selection is unchanged; FR-004 has both result builders fill the new fields; SC-3c checks both sides; plan and tasks cite the replay as SC-3b. Refs #123.
#123)

A new decision records source_hash for a readable source under the project root (a dedup hit keeps the existing record's source and hash). revalidate() flags decisions changed or missing (hashless ones only missing) and adds a type key to flagged items. recall returns flagged decisions on the relevance and newest paths, with additive needs_review and review_reason on every result; flagged code stays hidden; the lifecycle's checkpoint choice is unchanged. The session-start list names each item's type with a type-aware hint. README, tool docstring, CHANGELOG. Refs #123.
…mendment A1)

The session-start, compaction-recovery and on_post_compact context lines label a flagged memory with its reason, e.g. [decision, needs review: changed], so a flagged decision shown there is marked as recall marks it. Tests for the startup and compaction blocks; spec amendment A1. Review of PR #127.
A hashless decision's present file clears only a missing flag; any other flag is kept and counted unknown. The session-start review list shows every memory still flagged, not only those found in this pass. SC-4 is tested on a record with no source_hash key (raw metadata checked). README, consolidate and POST /revalidate no longer say code only. Spec FR-002 and FR-005. Refs #123.
@gosha70
gosha70 merged commit baff4dd into main Nov 15, 2026
11 checks passed
@gosha70
gosha70 deleted the feat/123-decision-revalidation branch November 15, 2026 03: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