AI SOURCE WATCH / 10 / MVP IMPLEMENTATION PLAN / 2026

План реализации Source Watch MVP.

Финальный документ mini-серии. Переводим architecture, policy, scheduler, adapters, snapshots, security и routing в последовательный coding plan, где реальный benchmark на server2 обязателен до ADR по changedetection.io vs urlwatch.

Главное правило: MVP должен быть полезен даже без changedetection.io. Сначала canonical control plane + один простой adapter + direct GitHub/RSS/Docling paths. После этого — реальный spike и ADR.

1. Repository layout

ai-source-watch/
├── pyproject.toml
├── README.md
├── config/
│   ├── source_watch.yaml
│   ├── policies.yaml
│   ├── permissions.yaml
│   └── adapters.yaml
├── migrations/
├── src/ai_source_watch/
│   ├── api/
│   │   ├── watches.py
│   │   ├── runs.py
│   │   ├── snapshots.py
│   │   ├── changes.py
│   │   ├── routing.py
│   │   └── health.py
│   ├── domain/
│   │   ├── watch_target.py
│   │   ├── source_snapshot.py
│   │   ├── diff.py
│   │   ├── change_event.py
│   │   ├── freshness.py
│   │   └── health.py
│   ├── scheduler/
│   │   ├── scheduler.py
│   │   ├── leases.py
│   │   ├── backoff.py
│   │   └── throttling.py
│   ├── adapters/
│   │   ├── base.py
│   │   ├── http.py
│   │   ├── changedetection.py
│   │   ├── urlwatch.py
│   │   ├── github.py
│   │   ├── rss.py
│   │   └── docling.py
│   ├── diffing/
│   ├── classifier/
│   │   ├── deterministic.py
│   │   └── qwen.py
│   ├── policy/
│   │   ├── change.py
│   │   ├── freshness.py
│   │   └── routing.py
│   ├── storage/
│   ├── security/
│   ├── integrations/
│   │   ├── dossier.py
│   │   ├── researcher.py
│   │   └── curator.py
│   ├── audit/
│   └── cli.py
└── tests/
    ├── unit/
    ├── golden/
    ├── integration/
    ├── failure/
    ├── security/
    └── benchmark/

2. Порядок реализации

PHASE 0
Domain + DB schema
      ↓
PHASE 1
Watch registry + scheduler
      ↓
PHASE 2
HTTP snapshots + diff
      ↓
PHASE 3
Change/freshness policy
      ↓
PHASE 4
GitHub + RSS + Docling adapters
      ↓
PHASE 5
Routing + security + audit
      ↓
PHASE 6
changedetection/urlwatch spike
      ↓
BENCHMARK ON SERVER2
      ↓
ADR REUSE / ADAPT / BUILD
      ↓
PRODUCTION MVP

3. Phase 0 — Domain + migrations

Canonical models

WatchTarget
WatchRevision
WatchRun
SourceSnapshot
Diff
ChangeEvent
SourceHealth
FreshnessState
RouteJob
ExternalEvent
AdapterMapping
RetentionHold
AuditEvent

Migrations

001_watch_targets
002_watch_runs
003_snapshots
004_diffs
005_change_events
006_health_freshness
007_route_jobs
008_external_events
009_adapter_mappings
010_retention
011_audit

DoD

[ ] canonical IDs ours
[ ] revisions mandatory
[ ] snapshots immutable
[ ] change→snapshot links enforced
[ ] route jobs durable
[ ] audit schema ready
[ ] export/import schema versioned

4. Phase 1 — Watch registry + scheduler

Implement

create/get/search/update
pause/resume/archive
next_due_at
priority
jitter
lease claim
retry/backoff
provider rate budget
manual check_now

Acceptance

500 overdue watches after restart
→ no stampede

worker crash
→ lease recovery

429
→ Retry-After respected

manual + scheduled same watch
→ idempotent execution policy

5. Phase 2 — HTTP / snapshot / diff baseline

Build first

simple HTTP adapter
ETag
If-Modified-Since
redirect handling
body limits
normalization
raw_hash
normalized_hash
text diff

Fast path

304
→ update last_checked
→ STOP

normalized_hash same
→ STOP

changed
→ create diff

Why first

Это даёт полноценный минимальный Source Watch без зависимости от стороннего watcher engine.

6. Phase 3 — Policy + Qwen selective

Deterministic classifier

NO_CHANGE
COSMETIC
METADATA_ONLY
VERSION_RELEASE
SOURCE_REMOVED
SOURCE_RESTORED
known structured patterns

Qwen 30B classifier

only ambiguous semantic diffs

output:
change_type
severity_hint
summary
affected topics
scope hint
confidence

Policy resolver

classifier
+ authority
+ watch priority
+ promoted knowledge intersection
+ safety relevance
→ final severity/routes

7. Phase 4 — Specialized adapters

GitHub

webhook endpoint
HMAC SHA-256 validation
delivery dedup
release mapping
advisory mapping
push path filtering
REST fallback

RSS/Atom

ETag
Last-Modified
GUID/content hash
new/updated item
native feed preferred
RSSHub optional

Docling

download document
binary hash
structured parse
block/section/table diff
page provenance

8. Phase 5 — Routing / security / audit

Routing

Dossier:
SOURCE_CHANGE TimelineEvent

Researcher:
ResearchRequest

Curator:
StaleCheckRequest
only when promoted scope intersects

Security

SSRF protection
redirect re-validation
DNS/IP checks
secret refs
credential redaction
content-as-data
webhook replay protection

Reliability

transactional ChangeEvent
+ outbox route jobs

routing retry
without duplicate external events

9. Phase 6 — Practical spike + benchmark

Do not choose from README

CANDIDATES:
changedetection.io
urlwatch

BASELINE:
our HTTP adapter

Shared targets

40 static HTML
20 dynamic pages
10 JSON
10 release/changelog pages
20 synthetic pages

Measure real values on server2

HIGH/CRITICAL recall
false meaningful alerts
dynamic success
selector/filter effort
API integration effort
restart recovery
state export
idle RAM
peak RAM
CPU
disk growth
Qwen latency impact

ADR

REUSE:
candidate can be used nearly as-is

ADAPT:
candidate useful behind adapter

BUILD:
our baseline is better fit

HYBRID:
urlwatch/simple HTTP default
+ changedetection/browser difficult targets
Нельзя заполнять benchmark цифрами без реального запуска на server2.

10. Rollout sequence

STEP 1
10 controlled HTTP targets

STEP 2
golden synthetic changes

STEP 3
Dossier routing shadow mode

STEP 4
Researcher requests shadow mode

STEP 5
GitHub direct events

STEP 6
RSS feeds

STEP 7
Docling document changes

STEP 8
Curator stale-check shadow mode

STEP 9
changedetection/urlwatch benchmark

STEP 10
ADR

STEP 11
production adapter

STEP 12
expand watch fleet gradually

Shadow mode

На первых этапах routes создаются как test/shadow artifacts и сравниваются с human labels до включения operational notifications.

11. Release test gates

LayerMust pass
Unitschedule, backoff, classifier, freshness
Goldenall HIGH/CRITICAL changes
Integrationsource→snapshot→change→route
SecuritySSRF, secrets, webhook forgery
Failureworker crash, DB failure, queue recovery
Retentionprotected evidence preserved
Benchmarkserver2 resource fit

Hard blockers

missed CRITICAL golden change = 0
successful SSRF = 0
secret leakage = 0
forged webhook accepted = 0
lost critical route = 0
duplicate routed event = 0
poisoned snapshot accepted = 0
silent classifier failure = 0
permanent-RAG mutation = 0

12. Definition of Source Watch MVP Done

[ ] canonical WatchTarget registry
[ ] scheduler/jitter/priority
[ ] retry/backoff
[ ] provider budgets
[ ] lease recovery
[ ] HTTP adapter
[ ] snapshots immutable
[ ] normalized hash
[ ] diff storage
[ ] deterministic classification
[ ] selective Qwen classification
[ ] freshness
[ ] source health
[ ] GitHub adapter
[ ] RSS adapter
[ ] Docling document diff
[ ] Dossier routing
[ ] Researcher routing
[ ] Curator stale-check routing
[ ] transactional outbox
[ ] SSRF protection
[ ] webhook HMAC/dedup
[ ] secret isolation
[ ] audit
[ ] retention/holds
[ ] reconciliation
[ ] server2 throttling
[ ] practical benchmark complete
[ ] ADR based on measured results
[ ] no direct permanent knowledge mutation

Post-MVP

automatic source discovery
semantic clustering of changes
LLM selector repair
distributed browser workers
predictive schedules
source reputation model
cross-source event correlation
Mini-серия Source Watch завершена. Следующий модуль по исходной очереди Additional — Investigator. Его нужно начинать отдельной mini-серией с reuse-first research и только после закрытия Source Watch MVP plan.