pam ▸ docs/generated/ralph_loop_2026-03-16_latest_state_freshness.md
updated 2026-03-28

Ralph Loop 2026-03-16: Latest State Freshness

Change

Added explicit freshness metadata for PRD 003/004 handoff quality.

Files: - research/continuous_loop.py - research/status.py - research/discord_status.py - research/README.md - tests/test_research_status.py

Why

The previous status output could show a stale loop snapshot beside a freshly recomputed replay check without making the age gap obvious. That weakened candidate-review quality because handoff consumers had to infer whether latest_state.json was still trustworthy.

Result

research/latest_state.json now carries a freshness block with:

  1. state generation timestamp
  2. candidate-review generation timestamp
  3. latest scan timestamp
  4. warning thresholds for each timestamp

Status and Discord summaries now compute concrete ages and mark stale sections explicitly.

Current smoke output shows the real bottleneck clearly:

  1. state_age=55802s stale=True
  2. candidate_review_age=0s stale=False
  3. latest_scan_age=55803s stale=True
  4. notes include latest_state_differs_from_current_replay_rows, latest_state_is_stale, and latest_scan_is_stale

That means the stored loop handoff is old, while the candidate-review packet is being refreshed from current live rows.

Validation

Commands run:

pytest -q tests/test_research_status.py tests/test_candidate_review.py
python3 -m py_compile research/continuous_loop.py research/status.py research/discord_status.py
python3 research/status.py
python3 research/discord_status.py

Observed behavior:

  1. Focused tests passed: 7 passed
  2. Updated modules compiled cleanly.
  3. Human and Discord status now expose concrete freshness ages and stale warnings.

Next bottleneck

Freshness is now visible, but the stored loop snapshot is still materially behind the current replay rows. The next bounded change should either refresh latest_state.json more aggressively or make the replay/candidate-review handoff path less dependent on the last completed loop cycle.