# District Source Network V3.4 Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Seed and manage verified district-specific publisher pages for all 64 Bangladesh districts using the existing scrape/local-news pipeline.

**Architecture:** Add a pure publisher-pattern registry and source generator, then wire it to the existing `scrape_sources` persistence and a new Admin page. Add health metadata without changing the core article ingestion contract.

**Tech Stack:** PHP 8+, MySQL/MariaDB, existing cURL scraper/admin framework.

**Spec:** `docs/superpowers/specs/2026-09-14-district-source-network-design.md`

## Global Constraints
- Existing V3.3 scraping/classification behavior must remain backward compatible.
- Do not scrape Google Search result HTML.
- District-specific pages are strict district sources by default.
- Duplicate seeding must be idempotent.
- Production MySQL/network checks are not assumed available in local verification.

---

### Task 1: Publisher registry and 64-district URL generator
**Files:** Create `includes/district_sources.php`; Test `tests/test_district_source_registry.php`.
- [ ] Write failing tests for publisher count, 64-district coverage, Sunamganj URLs and deterministic IDs.
- [ ] Run tests and confirm RED.
- [ ] Implement registry/generator.
- [ ] Run tests and confirm GREEN.

### Task 2: Persist registry metadata and seed sources
**Files:** Modify `includes/functions.php`; Create `database/migration_district_source_network.sql`; Test `tests/test_district_source_contracts.php`.
- [ ] Write failing contract tests for new metadata and seed functions.
- [ ] Run RED.
- [ ] Add additive DB fields and idempotent seed helpers.
- [ ] Run GREEN.

### Task 3: Admin District Source Network
**Files:** Create `admin/district_sources.php`; Modify `admin/partials/header.php`; Test `tests/test_district_source_admin.php`.
- [ ] Write failing admin-contract tests.
- [ ] Run RED.
- [ ] Implement publisher/district seeding, health checking, enable/disable UI.
- [ ] Run GREEN.

### Task 4: Documentation and full verification
**Files:** Create `DISTRICT_SOURCE_NETWORK_V34.md`.
- [ ] Run all PHP tests.
- [ ] Lint all PHP files.
- [ ] Verify 64 districts and source generation count.
- [ ] ZIP and run integrity test.
