Files
gbrain/test
0dff84b16a fix(remediation): gate sync/extract recs on real extraction lag, refresh at D7 recheck
Takeover of #2363. The sync.repo/extract.all recommendations gated on
health.stale_pages — a proxy (updated_at predates newest timeline entry)
that stopped meaning anything after migration v10 dropped the trigger
behind it. Gate them on the honest counter instead:
engine.countStalePagesForExtraction, the same staleness `gbrain extract
--stale` and doctor's links_extraction_lag use.

On top of the original PR, two repairs:

- runRemediation loads RecommendationContext once, but the D7 per-step
  recheck reused the frozen extractionLagPages — a completed sync/extract
  step could never clear the gate, so the pipeline re-fired every recheck
  until maxJobs. The recheck now refreshes the gate alongside getHealth
  via the shared countExtractionLag() helper (extracted into
  remediation/context.ts). Pinned by
  test/remediation-run-d7-refresh.serial.test.ts (serial: mock.module).
- autopilot builds its own RecommendationContext by hand; without wiring,
  it would silently never fire sync.repo/extract.all again. It now
  populates extractionLagPages from the same helper.

Co-authored-by: DarkNightForge <DarkNightForge@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 15:06:34 -07:00
..