# Implementation Plan: Ingest Representative Data Subset for Pilot Experiment

## Goal Description
Connect a small, bounded, and representative subset of available data sources to support the MVP pilot experiment (*Enterprise Software Licensing & Cost Optimization — Europe*) without ingesting or processing the entire raw archive. 

The ingestion pipeline must remain strictly domain-agnostic and configuration-driven, ensuring evidence integrity, provenance tracking (source URI, ingestion timestamp, signal date), and traceability for downstream qualification into Lead Cards.

---

## User Review Required

> [!IMPORTANT]
> **Data Archive Location & Volume Limits:**
> - Ingestion will be restricted to a hard cap (e.g., 50–100 raw signal records across 20–30 target candidate organizations) to prevent archive overflow and maintain high signal-to-noise ratio for the manual validation phase (target: 10 Lead Cards).
> - Raw data ingestion connectors will operate via configurable source adapters (e.g., job postings, financial/annual reports, technology stack signals, press releases/news) rather than hardcoded logic.

> [!NOTE]
> **No External Outreach:** Per project constraints, this phase only ingests and structures incoming signal data. No external communication or enrichment calls to third-party live outreach APIs will occur.

---

## Key Principles & Architectural Boundary

1. **Domain-Agnostic Core Ingestion Engine:**
   - The ingestion runner processes data sources according to a declarative source configuration schema (`source_type`, `schema_version`, `extraction_rules`, `provenance_keys`).
   - Domain-specific filters (e.g., European geos, enterprise size indicators, software vendor mentions like SAP, Oracle, Microsoft, VMware) remain externalized in campaign configuration files (`pilot-campaign-definition-v1.md`).
2. **Provenance & Evidence First:**
   - Every ingested signal record retains:
     - `signal_id`: Unique deterministic or UUID identifier.
     - `source_uri` / `source_origin`: File path, feed URI, or document identifier.
     - `published_at` / `observed_at`: Signal timestamp.
     - `ingested_at`: UTC timestamp of extraction.
     - `raw_content_snippet`: Exact textual quote/snippet supporting potential evidence.
     - `metadata`: Source-specific metadata fields.
3. **Bounded Sampling Strategy:**
   - Ingestion enforces strict limits (`max_records_per_source`, `date_window_cutoff`, `sample_ratio` or explicit subset manifest) to guarantee only a lightweight representative sample is imported.

---

## Proposed Implementation Steps

### 1. Define Ingestion Schema & Sample Manifest
- Define the standard domain-agnostic `RawSignal` and `DataSourceConfig` data contracts (JSON Schema / Pydantic models).
- Create a sample configuration manifest selecting a balanced, representative mix of signals:
  - Enterprise job vacancy signals (e.g., IT procurement, SAM/software asset management, ERP migration).
  - Regulatory / corporate disclosure snippets (e.g., European annual reports referencing IT transformation or licensing cost pressures).
  - Technology changes / contract renewal notices.

### 2. Implement Lightweight Ingestion Connector & Extractor
- Implement an ingestion runner that reads local source files or manifests using bounded iterators (with configurable `limit` and `offset`).
- Ensure deduplication and validation against the `RawSignal` schema.
- Store extracted subset in the local project artifact repository under `data/artifacts/LEAD-GEN/LEAD-001.2/` or designated staging directory in structured JSONL format.

### 3. Build Provenance & Evidence Verification Step
- Verify that every ingested item has non-empty evidence text, valid timestamps, and origin attribution.
- Generate an ingestion report summarizing:
  - Total records evaluated vs. ingested.
  - Distribution across source types.
  - Compliance with the pilot campaign scope filters (Europe, enterprise scale, licensing context).

---

## Verification Plan

### Automated Verification
- **Schema Validation:** Validate ingested JSONL records against the universal `RawSignal` schema.
- **Volume & Boundary Check:** Ensure the total ingested records count does not exceed the predefined cap ($N \le 100$).
- **Provenance Completeness:** Check that 100% of records contain valid `source_uri`, `observed_at`, and raw excerpt/evidence fields.

### Manual Verification
- Review a sample of 10–15 ingested signals to confirm they provide sufficient raw evidence for the next stage (lead discovery and generating the first 10 Lead Cards).
- Confirm no full archives were unzipped or imported into the primary working dataset.