feat: Knowledge freshness cron — detect stale entries from code changes (#200) #227

Merged
Rockachopa merged 2 commits from feat/200-knowledge-freshness-cron into main 2026-04-21 15:21:29 +00:00
Owner

Summary

Automatically detects when knowledge entries become stale due to code changes.

Acceptance Criteria

  • Freshness checker: scripts/freshness.py
  • Cron job ready: run daily, check all entries with file references
  • Report: N stale entries detected with reasons
  • Auto-re-extract flag (placeholder for harvester integration)

Implementation

Detection Method

  1. Track source file hash alongside knowledge entry
  2. Compare current file hashes vs stored
  3. Mismatch → flag entry as potentially stale
  4. Report stale entries and optionally re-extract

Features

  • Git change detection (modified, added, deleted files)
  • Hash-based staleness detection
  • YAML and JSON knowledge file support
  • Human-readable and JSON output formats
  • Summary statistics with stale-by-reason breakdown

Usage

# Human-readable report
python3 scripts/freshness.py --knowledge-dir knowledge/

# JSON output for dashboards
python3 scripts/freshness.py --knowledge-dir knowledge/ --json

# Custom repo path and time window
python3 scripts/freshness.py --knowledge-dir knowledge/ --repo /path/to/repo --days 7

Cron Job

Designed to run daily:

0 2 * * * cd /path/to/compounding-intelligence && python3 scripts/freshness.py --knowledge-dir knowledge/ --json >> /var/log/freshness.log

Tests

8 tests covering:

  • File hash computation
  • Knowledge entry loading (JSON and YAML)
  • Freshness checking with various scenarios
  • Staleness detection (hash mismatch, missing source)

Closes #200

## Summary Automatically detects when knowledge entries become stale due to code changes. ## Acceptance Criteria - [x] Freshness checker: `scripts/freshness.py` - [x] Cron job ready: run daily, check all entries with file references - [x] Report: N stale entries detected with reasons - [x] Auto-re-extract flag (placeholder for harvester integration) ## Implementation ### Detection Method 1. Track source file hash alongside knowledge entry 2. Compare current file hashes vs stored 3. Mismatch → flag entry as potentially stale 4. Report stale entries and optionally re-extract ### Features - Git change detection (modified, added, deleted files) - Hash-based staleness detection - YAML and JSON knowledge file support - Human-readable and JSON output formats - Summary statistics with stale-by-reason breakdown ### Usage ```bash # Human-readable report python3 scripts/freshness.py --knowledge-dir knowledge/ # JSON output for dashboards python3 scripts/freshness.py --knowledge-dir knowledge/ --json # Custom repo path and time window python3 scripts/freshness.py --knowledge-dir knowledge/ --repo /path/to/repo --days 7 ``` ### Cron Job Designed to run daily: ```bash 0 2 * * * cd /path/to/compounding-intelligence && python3 scripts/freshness.py --knowledge-dir knowledge/ --json >> /var/log/freshness.log ``` ## Tests 8 tests covering: - File hash computation - Knowledge entry loading (JSON and YAML) - Freshness checking with various scenarios - Staleness detection (hash mismatch, missing source) Closes #200
Rockachopa added 2 commits 2026-04-21 11:59:02 +00:00
feat: Add test_freshness.py (#200)
Some checks failed
Test / pytest (pull_request) Failing after 26s
baa2c84c3f
Rockachopa merged commit 277f9e3a2b into main 2026-04-21 15:21:29 +00:00
Sign in to join this conversation.