STATIYA_POLUCHATEL_1
EXEC-19 · SPIKES & ADR
PRE-START_PROJECT / EVIDENCE-BASED ARCHITECTURE

Равные crawler-spikes и протокол архитектурных ADR

После runtime discovery нужно не «выбрать любимую библиотеку», а провести одинаковые ограниченные испытания и зафиксировать решения. Этот пакет задаёт единые fixtures, метрики, hard-fail критерии и структуру ADR-01…ADR-05.

3candidate classes
12common metrics
6hard-fail criteria
5mandatory ADRs

01 / Candidate set

SPIKE-A · Crawlee for Python

Primary crawler candidate if compatible with verified runtime.

SPIKE-B · Scrapy

Alternative crawler candidate under identical fixtures and metrics.

SPIKE-C · Existing Work crawler/library

Mandatory comparison if EXEC-17 finds an already-present equivalent.

Кандидат C обязателен, если Work уже содержит рабочий crawler.

Нельзя игнорировать существующую инфраструктуру только потому, что в плане заранее рассматривались Crawlee и Scrapy.

02 / Equal-test contract

DimensionSame for every candidate
Fixture setSame controlled sitemap/archive/article/loop/robots/429 fixtures for every candidate.
Source sampleSame bounded public test source or recorded fixture snapshot.
Request budgetSame max URLs, concurrency ceiling and timeout budget.
Security policySame SSRF/scope/robots/rate-limit guard.
Resume testSame forced-kill point and recovery expectation.
Output contractSame request/candidate event schema.
MeasurementSame timing/resource/error counters.

03 / Bounded spike scope

IDCapability
S-19-01Read seed URLs from approved crawl_plan-like fixture.
S-19-02Normalize and de-duplicate requests.
S-19-03Enforce same-host/scope guard.
S-19-04Fetch HTTP pages with retries/timeouts.
S-19-05Parse links and enqueue bounded pagination.
S-19-06Emit idempotent candidate URL records.
S-19-07Persist enough queue/checkpoint state for forced-stop resume.
S-19-08Handle robots/rate policy through shared guard layer.
S-19-09Do not implement article classifier/render/deploy inside the spike.

04 / Common metrics

IDMetricExpectation
M-19-01Correct discovered URL countMust match fixture truth.
M-19-02Duplicate request countPrefer zero after normalization/queue dedup.
M-19-03Out-of-scope fetchesMust be zero.
M-19-04Forced-stop recoveryMust resume without restarting whole fixture.
M-19-05429/backoff behaviorMust respect configured/reported delay.
M-19-06Peak memoryMeasured under same fixture.
M-19-07Wall-clock timeSecondary metric; correctness beats speed.
M-19-08Implementation complexityLOC/config/adapter burden.
M-19-09Runtime fitWorks cleanly with verified Work Python/Node/process model.
M-19-10Observability fitStructured events/logging integration effort.
M-19-11Security fitCan enforce redirect/DNS/scope policy without hacks.
M-19-12Maintenance riskDependency maturity, project activity, lock-in/upgrade burden.
Scoring areaWeight
Correctness / determinism25%
Resume / persistence integration20%
Security / scope enforcement15%
Work runtime fit15%
Observability integration10%
Implementation complexity10%
Performance5%

05 / Hard-fail criteria

IDFailure condition
HF-19-01Cannot enforce same security/scope policy.
HF-19-02Cannot resume safely after forced stop without custom rewrite disproportionate to benefit.
HF-19-03Requires incompatible runtime stack or invasive production changes.
HF-19-04Cannot produce deterministic/idempotent request/candidate events.
HF-19-05Relies on browser automation for ordinary HTTP-first crawling.
HF-19-06Introduces privileged/root execution requirement.

06 / Evidence outputs per candidate

ArtifactPurpose
spike_<candidate>_runtime.jsonVersions, environment and exact commit.
spike_<candidate>_metrics.jsonAll common metrics.
spike_<candidate>_events.jsonlStructured sample event stream.
spike_<candidate>_resume.txt/jsonForced-stop and resume evidence.
spike_<candidate>_security.txt/jsonScope/robots/rate evidence.
spike_<candidate>_notes.md/htmlIntegration friction and caveats.

07 / ADR schema and required decisions

FieldMeaning
adr_idStable ADR ID.
titleDecision title.
statusPROPOSED / ACCEPTED / REJECTED / SUPERSEDED.
contextVerified runtime and product constraints.
options[]All serious candidates.
evidence_refs[]Spike/runtime/test evidence.
decisionChosen option.
whyEvidence-based rationale.
rejected_reasonsWhy alternatives lost.
consequencesTrade-offs and follow-up work.
security_impactSecurity implications.
rollbackHow to reverse decision.
review_triggerWhat future condition warrants reconsideration.
ADRAreaDecision scope
ADR-01Crawler coreCrawlee / Scrapy / existing Work equivalent.
ADR-02Persistent state + queueExisting DB/queue first; new dependency only if evidence requires it.
ADR-03Live event/log transportExisting stack / SSE / WebSocket / polling.
ADR-04RendererExisting template system or lightweight deterministic renderer.
ADR-05Deploy adapterVerified current Work deployment/rollback mechanism.

08 / Runtime-dependent decision checklists

State / queueRule
Existing firstIf Work already has a durable DB/queue, evaluate reuse before adding RQ/Celery/etc.
Checkpoint contractMust support monotonic state_version and atomic or equivalent safe transitions.
Worker leaseMust prevent two active mutators for same job.
RecoveryMust survive process/server restart.
Operational burdenPrefer fewer new services for MVP.
LoggingRule
Existing firstReuse current Work logging/event transport if adequate.
UI needMust support current status plus near-live structured events.
ReconnectClient reconnect must not change job state.
FallbackPolling acceptable if runtime lacks safe push transport.
No log-as-stateTransport choice cannot make logs canonical state.
RendererRule
DeterministicSame frozen model → same semantic output.
EscapingSafe by default.
Static outputCore dataset readable without JS.
Dependency fitPrefer existing Work templating; otherwise lightweight dependency.
DeployRule
Existing mechanismDo not invent second deploy path.
AtomicityNeed stage/publish/verify/rollback behavior.
PermissionsLeast privilege.
Catalog integrationMust know canonical service/index update mechanism.

09 / Definition of Done

IDCriterion
A-19-01All viable crawler candidates receive the same fixture/input budget.
A-19-02Every candidate produces comparable metric/evidence artifacts.
A-19-03Hard-fail criteria eliminate unsafe/incompatible candidates immediately.
A-19-04Crawler decision is written as ADR-01 with evidence refs.
A-19-05State/queue choice is written as ADR-02.
A-19-06Logging transport choice is written as ADR-03.
A-19-07Renderer choice is written as ADR-04.
A-19-08Deploy adapter choice is written as ADR-05.
A-19-09No ADR contains secret values.
A-19-10START_PROJECT is still not instantiated until all required ADRs are ACCEPTED.

10 / Luna Medium bounded blocks

BlockScopeOutput
LUNA-19-ACreate shared spike fixturesOne reusable fixture harness and truth set.
LUNA-19-BImplement candidate A adapterOnly bounded crawler spike contract.
LUNA-19-CImplement candidate B adapterSame contract and fixtures.
LUNA-19-DImplement existing-stack adapterOnly if EXEC-17 proves one exists.
LUNA-19-ERun forced-stop/security testsSame tests for each candidate.
LUNA-19-FCompile comparison matrixCommon metrics + hard-fail status.
LUNA-19-GWrite ADR-01Crawler core decision.
LUNA-19-HWrite ADR-02…05Runtime-dependent architecture decisions.

11 / Next exact action

ORDER:

EXEC-17 runtime discovery
→ EXEC-19 equal candidate spikes
→ ADR-01 crawler
→ ADR-02 state/queue
→ ADR-03 logging transport
→ ADR-04 renderer
→ ADR-05 deploy adapter
→ conflict review
→ EXEC-18 template instantiation
→ immutable START_PROJECT
→ /razraba initialization
→ Active Window 01 implementation