Fastmod Audit and Backfill Step 4 Implementation Summary

Stage 1 - Historical candidate classification

  • Changes:

    • Added a read-only historical audit service that classifies current-content/current-rubric posts and exposes unrated candidates.

    • Added a private-store work lookup for pending and failed classification.

  • Verification:

    • php tests/run.php FastmodHistoricalAuditServiceTest SqliteFastScoreStoreTest

  • Notes:

    • This stage creates no score, work, task, or exchange rows.

Stage 2 - Cost estimation

  • Changes:

    • Added a model-scoped Fastmod cost estimator using completed private exchange usage.

    • Added a conservative token fallback when no matching usage history exists.

  • Verification:

    • php tests/run.php FastmodCostEstimatorTest

  • Notes:

    • Estimates are preflight guidance, not provider billing guarantees.

Stage 3 - Read-only operator audit

  • Changes:

    • Added ./v3 fast-score audit --include-existing with historical states, configured model, usage-based estimate, and an explicit no-write result.

    • Added explicit pricing overrides for non-default models.

  • Verification:

    • php tests/run.php FastmodAuditCommandTest

  • Notes:

    • The audit only opens existing private databases and uses in-memory empty stores when no score or exchange database exists.

Stage 4 - Bounded private backfill request

  • Changes:

    • Added a migration-backed private backfill batch and work-provenance snapshot.

    • Added a confirmed fast-score backfill request with post and estimated-cost bounds.

    • Isolated backfill work from ordinary new-post sweeps pending bounded worker processing.

  • Verification:

    • php tests/run.php FastmodBackfillRequestServiceTest

  • Notes:

    • A request persists authorization; Stage 5 adds bounded provider processing.

Stage 5 - Bounded worker processing

  • Changes:

    • Added worker claims that reserve a batch's estimated cost before every provider attempt, including retries, and stop when the reserved budget is spent.

    • Enqueued confirmed backfill batches through the existing Fastmod task type while preserving normal new-post sweep isolation.

    • Corrected exchange-usage parsing to use the recorded provider response.

  • Verification:

    • php tests/run.php FastScoreSweepServiceTest FastmodBackfillRequestServiceTest FastmodAuditCommandTest

  • Notes:

    • Provider bills can vary from a preflight estimate; the private batch retains its reserved estimate and exposes underlying exchanges for exact inspection.

Stage 6 - Operator documentation and retention

  • Changes:

    • Added private backfill-batch state and reserved-estimate output to fast-score status.

    • Extended the one-year prune path to remove expired backfill provenance and work without making it eligible for an ordinary sweep.

    • Documented pricing, audit/backfill commands, and a manual verification runbook.

  • Verification:

    • php tests/run.php SqliteFastScoreStoreTest FastmodAuditCommandTest

  • Notes:

    • No public UI, API, read-model, or automatic historical sweep was added.

Follow-up - Operator output clarity

  • Changes:

    • Replaced Fastmod count JSON with labeled operator-facing summaries and added next/monitor commands after backfill creation.

    • Made invalid option parsing return a safe guided error rather than a PHP stack trace.

    • Added batch progress, reserved-estimate/cap, deterministic-exclusion, and continuation explanations to worker output.

  • Verification:

    • php tests/run.php FastmodAuditCommandTest FastScoreSweepServiceTest