Skip to content

Gated MOD-API harvest (#415, Project 2 Phase 1+2) - #475

Merged
micheldumontier merged 10 commits into
mainfrom
project2/mod-api-harvest
Nov 24, 2026
Merged

micheldumontier merged 10 commits into
mainfrom
project2/mod-api-harvest

Conversation

@micheldumontier

Copy link
Copy Markdown
Contributor

Project 2 — gated MOD-API harvest (Phase 1+2)

Harvest ontologies from one curated remote MOD-API catalogue, admit survivors through a cheap pre-enqueue gate, and enqueue each through the existing ingestion pipeline with catalogue provenance recorded. Builds on the Project-1 federation client (#472). Off by default; dry-run by default — nothing harvests until HARVEST_ENABLED=true + a configured peer, and a live enqueue needs an explicit dry_run=false.

The gate — not the harvest — is the deliverable: the admission gate is deliberately more lenient than the pipeline's post-ingest quality gate (it admits absent/unmappable licenses), because decide_publish_status remains the real safety boundary and holds anything non-compliant/untitled as needs_review. Harvested content is enqueued with no declared_license and no owner attribution, so nothing is laundered past that gate.

What's here

  • Provenance: nullable source_catalogue column on versions (migration c7e3a91d5f20, additive) threaded IngestionRequest → run_ingestion → ingest_ontology.
  • discovery/ package: Candidate + DiscoverySource interface; admission gate (bad_iri / no_title / duplicate / license_noncompliant, reusing find_ontology_by_canonical_iri + the license gate); peer-politeness rate limiter + run budget; paginating ModApiHarvestSource (reuses the SSRF-guarded federation client via a new thin fetch_mod_json; resolves each artefact's distribution download URL, falls back to ingest-by-IRI); gated run_harvest runner + HarvestReport.
  • Trigger: harvest_peer Celery task (opt-in, not scheduled) + POST /api/v1/admin/harvest (admin-only, dry-run default, limit 1–200).

Safety / review (whole-branch review verdict: SHIP, zero blocking)

  • All outbound traffic — harvest fetch and the resulting ingest (url=/iri=) — goes through the SSRF-guarded transport. No bypass for a hostile peer.
  • Pagination termination is limit-derived (bounded request volume even against an adversarial peer); politeness floor between requests.
  • Off-by-default + dry-run verified across all three entry layers; harvest_peer is not in beat_schedule.

Tests

217 passing across the touched surface (discovery 37, ingestion 142, integration 20, federation client 18). Subagent-driven: fresh implementer + reviewer per task, plus an Opus whole-branch review.

Documented limitations (non-blocking, for a later freshness/robustness increment)

  • Short-page stop counts parsed rows, so a peer with a malformed member per page under-harvests (never loops).
  • No /search/metadata fallback and no hydra:next paging (a peer that caps page_size below the request stops after page 1) — fails cleanly.
  • Candidate.landing_url/source_catalogue_id/label are carried for future report enrichment, not yet surfaced.

Plan: docs/superpowers/plans/2026-11-24-mod-api-harvest-increment.md. Deferred to later phases: GitHub OWL-scan source, freshness/re-harvest loop, full admin surface.

🤖 Generated with Claude Code

micheldumontier and others added 10 commits November 24, 2026 19:04
…t 2)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ions

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ingest gate

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…resolve

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e enqueue

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…efault)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…hin time_limit

Final-review N1: discover() does all fetches before enqueue; at the 1s politeness
floor a 500-candidate run exceeds harvest_peer's 900s time_limit and is killed
before ingesting anything. 200 stays well under; default run (50) is ~1 min.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@micheldumontier
micheldumontier merged commit 0afc15a into main Nov 24, 2026
5 checks passed
@micheldumontier
micheldumontier deleted the project2/mod-api-harvest branch November 24, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant