URL accepted; no network traversal beyond safety/normalization.
01 / Главный контракт
Mass crawl запрещён, пока сервис не понимает хотя бы на достаточном уровне, где у ресурса статьи, какими путями они перечисляются, какие hosts допустимы и что будет считаться концом обхода.
Здесь механизм только строит структуру и вероятные patterns. Точное INCLUDE/EXCLUDE каждой страницы относится к SP-06. Сомнительные страницы не должны насильно попадать в базу.
02 / State machine preflight
Normalize URL, resolve host rules, confirm allowed crawl scope.
Fetch and parse robots.txt where available.
Discover sitemap declarations and conventional sitemap locations.
Discover RSS/Atom/JSON feeds from HTML and conventional paths.
Inspect archive/category/tag/pagination surfaces as navigation candidates.
Sample candidate pages and listing pages to infer URL/page patterns.
Choose a deterministic article ordering strategy with evidence/confidence.
Compile traversal graph, include/exclude rules and stop conditions.
Plan is coherent enough to show the user and unlock first-batch crawl.
Some structures unavailable, but a bounded defensible plan exists.
No credible bounded route to article corpus; mass crawl must not start.
03 / Слои исследования источника
Normalize scheme/host, strip fragments, detect canonical host, decide allowed same-site host variants.
Read robots.txt for access policy, crawl-delay/request-rate hints and sitemap declarations.
Parse sitemap index and nested sitemaps with bounded recursion; record URL count and types.
Find RSS/Atom/JSON feed links; use as ordering/candidate evidence, not necessarily full historical corpus.
Discover archive, category, tag, issue, pagination and date-based listing pages.
Sample likely article/listing/service pages to infer structural differences without crawling entire source.
Infer candidate article URL patterns and obvious exclude patterns from evidence.
Evaluate chronological archive, datePublished metadata, feed order, sitemap order and deterministic fallback.
Build traversal nodes/edges, priorities, bounds, limits, retry rules and termination criteria.
Render human plan + machine manifest; do not start bulk crawl unless plan status permits.
04 / Как выбирать порядок статей
| Priority | Strategy | Rule |
|---|---|---|
| 1 | Official chronological archive/category sequence | Prefer when listings explicitly represent publication chronology and samples confirm it. |
| 2 | Article-level publication metadata | Use datePublished or equivalent only if present consistently and plausibly across samples. |
| 3 | Official feed order | Useful when feed is complete enough for target scope; often only recent history, so coverage must be stated. |
| 4 | Sitemap order | Allowed only if evidence shows it reflects publication order; XML element order alone is not proof. |
| 5 | Deterministic discovery order | Fallback using a stable traversal order derived from the selected source graph. |
lastmod часто означает последнее изменение URL, а не дату публикации. Механизм может использовать его только после source-specific proof. Иначе ordering должен опираться на другой источник.
05 / Machine-readable crawl_plan
| Field | Purpose |
|---|---|
| plan_id | Stable per-job preflight plan ID. |
| job_id | Job that owns the plan. |
| source_id | Stable dataset/source identity. |
| input_url | Exact user input. |
| normalized_source_url | Canonical source root chosen by preflight. |
| allowed_hosts[] | Hosts permitted for crawl. |
| blocked_hosts[] | Explicitly disallowed external/private hosts. |
| robots | Fetched URL, status, parsed policy, sitemaps. |
| sitemaps[] | URL, type, parent, child count, status. |
| feeds[] | URL, type, item count/sample, coverage note. |
| navigation_surfaces[] | Archive/category/tag/pagination candidates and confidence. |
| candidate_patterns[] | Observed patterns likely to contain article pages. |
| exclude_patterns[] | Observed service/listing/video-only/utility patterns. |
| ordering_strategy | Selected strategy. |
| ordering_confidence | HIGH / MEDIUM / LOW. |
| ordering_evidence[] | Concrete observations supporting the strategy. |
| estimated_candidate_count | Estimate only; may be unknown. |
| coverage_notes[] | Known blind spots and limitations. |
| traversal_nodes[] | Ordered crawl graph nodes. |
| limits | Depth, pages, recursion, concurrency/rate placeholders. |
| termination_conditions[] | When this plan considers source exhausted. |
| status | READY / PARTIAL / FAILED. |
| generated_at | Timestamp. |
| evidence_refs[] | Paths/URLs/log events supporting decisions. |
06 / Ограничители против плохого обхода
Do not follow arbitrary external links discovered inside articles. External assets and referenced websites are not part of the source corpus.
www/non-www or equivalent redirects may be unified when verified; do not invent cross-domain equivalence.
User-supplied URL and redirects must later pass SSRF/private-network rules from SP-13 before fetch.
Prevent sitemap-index loops and pathological nesting; track visited sitemap URLs.
Detect repeated/looping pages; maintain visited normalized listing URLs and stable termination signals.
If only 17 valid articles exist, stop at 17. Do not include uncertain pages to reach 30.
lastmod can mean page update. Treat as publication date only after source-specific proof.
CAPTCHA/login/challenge is a blocker/partial condition, not permission to stealth-bypass.
A URL regex/prefix becomes a rule only after observed samples support it.
Bulk candidate enumeration starts only after PREFLIGHT_READY/PARTIAL with explicit scope and stop conditions.
07 / Минимальный объём evidence до READY
| Surface | Sample | Что доказывает |
|---|---|---|
| Homepage | 1–3 pages | Navigation, feed links, archive/category entry points, canonical host. |
| robots.txt | 1 | Access policy + sitemap declarations. |
| Sitemap index | all discovered index files within bounded recursion | Corpus topology, child sitemaps. |
| Sitemap samples | small sample per sitemap type | URL shape, possible content type separation. |
| Archive/category pages | 2–5 per pattern | Pagination, ordering, article-link structure. |
| Candidate article pages | 5–15 representative samples | Canonical, title, text/image presence, date metadata, article structure. |
| Non-article pages | 5–10 representative samples | Service/category/video-only patterns for exclusion evidence. |
Preflight должен быть дешёвым относительно полного crawl: topology + representative sampling + decision evidence. Полная enumeration кандидатов начинается в SP-05.
08 / Failure modes
| ID | Situation | Required behavior |
|---|---|---|
| F-01 | robots disallows relevant paths | Mark blocked scope; do not bypass; plan may become PARTIAL/FAILED. |
| F-02 | no sitemap exists | Use feeds + archive/category/pagination + bounded link discovery; disclose lower confidence. |
| F-03 | sitemap contains mixed content | Partition by sampled patterns; do not treat every URL as article. |
| F-04 | sitemap huge | Use sitemap topology and bounded sampling to infer routes before mass enumeration; crawler later streams/paginates. |
| F-05 | JS-only archive | Mark browser-required navigation surface; Playwright fallback considered only for that surface. |
| F-06 | dates contradictory | Do not silently merge; select another deterministic ordering or mark LOW confidence. |
| F-07 | infinite calendar/tag space | Restrict to evidence-backed archive branches and visited normalized URLs. |
| F-08 | redirect leaves source domain | Stop unless destination is a verified canonical host of the same source. |
| F-09 | source has <30 articles | Preflight/crawl remains valid; first owner gate uses the smaller complete set. |
| F-10 | no credible bounded traversal | PREFLIGHT_FAILED; require rule tuning or owner intervention. |
09 / Definition of Done
| ID | Criterion |
|---|---|
| A-04-01 | One URL is sufficient to start preflight. |
| A-04-02 | Mass crawling never begins before scope, traversal surfaces and stop conditions are established. |
| A-04-03 | The UI can render a plain-language crawl plan from the machine plan. |
| A-04-04 | Every sitemap/feed/archive surface in the plan has evidence and status. |
| A-04-05 | Allowed hosts and cross-domain redirect behavior are explicit. |
| A-04-06 | Ordering strategy is deterministic and has confidence/evidence. |
| A-04-07 | Sitemap lastmod is not silently treated as publication date. |
| A-04-08 | Potential article and obvious non-article patterns are both represented. |
| A-04-09 | Traversal has explicit loop prevention and termination conditions. |
| A-04-10 | If the source cannot be mapped defensibly, status is FAILED rather than blind crawl. |
| A-04-11 | Plan output is persisted with the job so logs and later crawler behavior can reference the same plan_id. |
| A-04-12 | Preflight result is compact enough for Luna Medium task context: full raw corpus is evidence, not embedded prompt text. |
10 / Bounded implementation под Luna Medium
| Block | Scope | Outcome |
|---|---|---|
| LUNA-04-A | URL + scope normalization | Implement only source identity/allowed-host decision and tests. |
| LUNA-04-B | robots + sitemap discovery | Implement bounded robots/sitemap topology, visited-set and evidence. |
| LUNA-04-C | feed + archive discovery | Implement feed declarations and listing-surface discovery. |
| LUNA-04-D | sample classifier signals | Extract structural samples only; do not implement final SP-06 classifier. |
| LUNA-04-E | ordering analyzer | Implement strategy scoring/evidence contract. |
| LUNA-04-F | plan compiler | Compile machine crawl_plan + human-readable plan payload. |
| LUNA-04-G | preflight integration tests | Run against representative static fixtures and later real benchmark sources. |
Нельзя выдавать Luna одну задачу «сделай весь preflight». Сначала URL/scope, затем robots/sitemaps, затем feeds/listings, затем ordering, затем plan compiler, затем интеграционные fixtures.