Skip to content

feat(memory): temporal validity + review-gated supersession for lessons - #72

Merged
mustafa-bharmal-shipveho merged 1 commit into
mainfrom
phase-2/temporal-supersession
Sep 24, 2026
Merged

mustafa-bharmal-shipveho merged 1 commit into
mainfrom
phase-2/temporal-supersession

Conversation

@mustafa-bharmal-shipveho

Copy link
Copy Markdown
Owner

Phase 2 — temporal validity + review-gated contradiction supersession

Builds on #71 (uses its contradiction-labeled dataset for stale-metric validation). Steps 1–8 and 10 of the approved plan; step 9 (bench-harness stamping) lands after #71 merges.

What

Lessons now carry temporal validity and contradictions become review-gated supersessions — never auto-applied:

  1. Schema: status enum + superseded; valid_from/valid_until/superseded_by/supersedes as a brainstack extension block.
  2. recall/frontmatter.py: TemporalMeta + temporal_meta() — single normalization point (aliases, date coercion, garbage → None, never raises).
  3. Writers: write_lesson stamps valid_from (+status: current when reviewed); projection emits status/valid_from from source_ts_epoch.
  4. render_lessons.update_lesson: flock, last-match, in-place flip of status/superseded_by/valid_until; extract_lesson_lines skips superseded.
  5. graduate.py: graduating a supersession candidate persists the pair (new row + updated old row), --supersedes default for supersession candidates.
  6. agent/memory/contradictions.py (new): pure, deterministic, no-LLM detector — slot-conflict → predicate-value → condition-overlap (Jaccard/token-J windows, exact-dup excluded).
  7. Staging: contradictions land in the review queue as kind: supersession candidates; auto_dream stages post-consolidation; rejected candidates restage only on new evidence; 1.5× candidate priority.
  8. Ranking: apply_temporal_policy mirrors apply_review_policy — ranking.superseded_policy (demote default / exclude / ignore) + superseded_penalty 0.5, threaded through CLI, MCP server, and daemon; valid_from tie-break; Qdrant filter for exclude.
  9. Trace: supersession chains walked forward/backward cycle-safe, surfaced in provenance output.

Invariant preserved everywhere: supersession only ever stages a candidate for human review; nothing auto-rewrites a durable lesson.

Test plan

  • Full hermetic suite: 2429 passed, 2 skipped (baseline 2347 → +82 new tests), run supervised in the worktree and re-verified independently: 2429 passed, 2 skipped, 230 deselected
  • ruff clean on all changed files
  • Red-then-green TDD per plan step (see commit history)

@mustafa-bharmal-shipveho
mustafa-bharmal-shipveho merged commit b8cfbc9 into main Sep 24, 2026
3 checks passed
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