Skip to main content

Implementation Plan: Item Source Validation

Feature ID: item-source-validation Spec: ./spec.md Status: Done (Retrospective) Last updated: 2026-05-01


1. Architecture

2. Tech Choices

ConcernChoiceRationale
Reachability checkNative fetch with timeout + redirectsLightweight; no extra dep
Content extractionExisting extractor facadeReuses configured extractor plugin
AI evaluationAI provider facade with structured outPrinciple II
Manual re-checkCached result for ~60 sAvoids hammering external resources
SchedulingTrigger.dev task with own cadencePrinciple IV

3. Data Model

  • Item YAML in the data repo gains an optional source_validation blob with the documented shape.
  • work_schedules adds a sourceValidationCadence column (additive nullable).

4. API Surface

MethodEndpointDescription
POST/api/works/:id/check-item-healthRe-check a single item

5. Plugin / Web / CLI

  • Plugins: AI provider + content extractor only.
  • Web: Items UI surfaces status indicators and the action menu (Re-check source, Apply suggestion).
  • CLI: not exposed.

6. Background Jobs

  • work-source-validation Trigger.dev task running on the work's sourceValidationCadence (or the main cadence as a fallback).
  • Post-generation hook calls the same validator inline.

7. Security & Permissions

  • Read: viewer.
  • Write (manual re-check, apply suggestion): editor.
  • HTTP fetches use the platform's egress, not the user's network.

8. Observability

  • Activity log entries: source_validation_run with {reachableCount, brokenCount, unknownCount, accurateCount, ...}.

9. Risks & Mitigations

RiskMitigation
False-positive broken from transient errorsOnly 404/410broken; everything else → unknown
AI cost runaway on huge worksValidation skips items unchanged since last check
Manual re-check abuseCooldown cache window

10. Constitution Reconciliation

See spec.md §9.

11. References

  • Spec: ./spec.md
  • Implementation:
    • packages/agent/src/services/item-source-validation-scheduler.service.ts
    • packages/agent/src/generators/data-generator/source-validation/