-
Notifications
You must be signed in to change notification settings - Fork 2
Fact lifecycle decay: two-stage expiry with explicit ratification (#14) #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
codenamev
merged 5 commits into
codenamev:main
from
minerva-sky:feat/fact-lifecycle-decay
Sep 1, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6c50d79
Add two-stage fact expiry lifecycle (active→expiring→expired) per #14
minerva-sky 6a7047f
Decouple decay clock from passive recall; surface expiring facts (#14)
minerva-sky ca668ba
Add MCP ratification surface: list_expiring_facts + ratify_fact (#14)
minerva-sky 9ffb856
Add CLI ratify command (#14)
minerva-sky 33ad0c7
Surface expiring facts on the dashboard (#14)
minerva-sky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # Migration v21: two-stage fact expiry lifecycle (#14). | ||
| # | ||
| # - reaffirmed_at: set ONLY by explicit ratification (CLI/MCP ratify | ||
| # surface) — never by passive recall. Passive recall touches | ||
| # last_recalled_at (v17), which self-defeats as a staleness signal: | ||
| # frequently-recalled-but-wrong facts never age out. Ratification is the | ||
| # distinct, intentional "still true" signal that returns an expiring | ||
| # fact to active and resets both clocks. | ||
| # - expiring_since: set when the sweeper moves an active fact to | ||
| # "expiring" (stale past threshold). Starts the ratification window; | ||
| # after ratify_window_days without ratification the fact becomes | ||
| # "expired" (excluded from default recall, never deleted, restorable). | ||
| Sequel.migration do | ||
| up do | ||
| alter_table(:facts) do | ||
| add_column :reaffirmed_at, String # ISO 8601, explicit ratification only | ||
| add_column :expiring_since, String # ISO 8601, entered expiring stage | ||
| end | ||
|
|
||
| run "CREATE INDEX IF NOT EXISTS idx_facts_expiring_since ON facts(expiring_since)" | ||
| end | ||
|
|
||
| down do | ||
| alter_table(:facts) do | ||
| drop_column :reaffirmed_at | ||
| drop_column :expiring_since | ||
| end | ||
| end | ||
| end | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "optparse" | ||
|
|
||
| module ClaudeMemory | ||
| module Commands | ||
| # Reaffirm a fact as still true, resetting its decay clock. | ||
| # Restores expiring/expired facts to active (#14). | ||
| class RatifyCommand < BaseCommand | ||
| # @param args [Array<String>] command line arguments (fact_id_or_docid, --scope) | ||
| # @return [Integer] exit code (0 for success, 1 for failure) | ||
| def call(args) | ||
| opts = parse_options(args, {scope: "project"}) do |o| | ||
| OptionParser.new do |parser| | ||
| parser.banner = "Usage: claude-memory ratify <fact_id_or_docid> [options]" | ||
| parser.on("--scope SCOPE", %w[project global], "Database scope (default: project)") { |v| o[:scope] = v } | ||
| end | ||
| end | ||
| return 1 if opts.nil? | ||
|
|
||
| identifier = args.first | ||
| return failure("Usage: claude-memory ratify <fact_id_or_docid> [options]") if identifier.nil? || identifier.empty? | ||
|
|
||
| manager = ClaudeMemory::Store::StoreManager.new | ||
| store = manager.store_for_scope(opts[:scope]) | ||
|
|
||
| fact_id = resolve_fact_id(store, identifier) | ||
| unless fact_id | ||
| stderr.puts "Fact '#{identifier}' not found in #{opts[:scope]} database." | ||
| manager.close | ||
| return 1 | ||
| end | ||
|
|
||
| result = store.ratify_fact(fact_id) | ||
| manager.close | ||
|
|
||
| if result.nil? | ||
| stderr.puts "Fact ##{fact_id} not found." | ||
| return 1 | ||
| end | ||
|
|
||
| unless result[:ratified] | ||
| stderr.puts "Fact ##{fact_id} is #{result[:status]} — only active, expiring, or expired facts can be ratified." | ||
| return 1 | ||
| end | ||
|
|
||
| stdout.puts "Ratified fact ##{fact_id} in #{opts[:scope]} database (was #{result[:previous_status]}) — decay clock reset." | ||
| 0 | ||
| end | ||
|
|
||
| private | ||
|
|
||
| # Accept either a numeric fact id or an 8-char docid hex string. | ||
| # @param store [Store::SQLiteStore] database to look up the fact in | ||
| # @param identifier [String] numeric fact id or hex docid | ||
| # @return [Integer, nil] resolved fact id, or nil if not found | ||
| def resolve_fact_id(store, identifier) | ||
| return identifier.to_i if identifier.match?(/\A\d+\z/) | ||
|
|
||
| row = store.find_fact_by_docid(identifier) | ||
| row ? row[:id] : nil | ||
| end | ||
| end | ||
| end | ||
| end |
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these be datetimes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deliberate, following the schema-wide convention: every timestamp in this DB is an ISO-8601 UTC string —
created_at(001),vec_indexed_at(012),last_recalled_at(017),promoted_at(020). SQLite has no native datetime type, and all the existing query logic compares these lexicographically (ISO-8601 UTC sorts chronologically), e.g. the sweeper'sexpiring_since < cutoff. Typing just these two asDateTimewould make them the only columns Sequel round-trips as Time objects and break symmetry with every comparison in the codebase.If you'd rather move the whole schema to typed timestamps, I'd do that as its own migration + issue rather than smuggling two odd columns in here. Happy to file it — say the word.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File it for investigation for performance. Not required if working well as-is