1. Purpose
Доказать, что link discovery создаёт deterministic set of discovered targets/observations из уже fetched HTML, но не принимает решение «это статья», не выполняет logical identity merge и не обходит persistent queue.
2. Entry gate
| Requirement | Expected | Actual | Evidence |
|---|---|---|---|
| TASK-002 | VERIFIED security/scope guard | REAL_VALUE | REAL_REF |
| TASK-003 | VERIFIED Job fencing/state | REAL_VALUE | REAL_REF |
| TASK-005 | VERIFIED persistent queue | REAL_VALUE | REAL_REF |
| TASK-006 | VERIFIED FetchResult | REAL_VALUE | REAL_REF |
| Successful HTML FetchResult fixture | Available | REAL_VALUE | REAL_REF |
| HTML parser | Real approved implementation | REAL_VALUE | REAL_REF |
3. Execution identity
| Field | Value |
|---|---|
| Project | Autonomous Site Research Pipeline / Statiya_poluchatel_1 |
| Window | AW-01 |
| Task | TASK-007 |
| Specification | EXEC-32 — Candidate Link Discovery + Emission |
| Evidence document | EXEC-46 |
| Result | UNFILLED / BLOCKED UNTIL TASK-006 VERIFIED |
| Executed by | REAL_VALUE |
| Started / completed | REAL_VALUE |
4. Environment facts
REPO_ROOT=REAL_VALUE BRANCH=REAL_VALUE REVISION_BEFORE=REAL_VALUE REVISION_AFTER=REAL_VALUE HTML_PARSER=REAL_VALUE URL_RESOLUTION_LIBRARY=REAL_VALUE QUEUE_ADAPTER=REAL_VALUE TEST_RUNNER=REAL_VALUE TASK_002_EVIDENCE_REF=REAL_VALUE TASK_005_EVIDENCE_REF=REAL_VALUE TASK_006_EVIDENCE_REF=REAL_VALUE PROJECT_STATE_REF=REAL_VALUE
5. Reuse-before-build review
| Capability | Existing? | Action | Ref |
|---|---|---|---|
| HTML parser | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
| href extractor | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
| rel=canonical parser | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
| rel=next/prev parser | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
| base href resolver | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
| Candidate/provenance model | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
6. Changed files
{
"changed_files": [
{
"path": "REAL_PATH",
"change_type": "ADDED | MODIFIED | DELETED",
"purpose": "REAL_DESCRIPTION"
}
]
}
Allowed scope
- bounded HTML discovery parser;
- link observation extraction;
- Candidate emission;
- provenance/depth;
- safe base/final URL resolution;
- asset/scheme discovery filters;
- queue enqueue integration;
- fixtures/tests.
Out of scope
- HTTP requests;
- classification;
- content-image qualification;
- logical identity merge;
- canonical article selection;
- final publication ordering;
- renderer.
7. Input contract
Discovery accepts only bounded successful HTML-like FetchResult.
{
"fetch_id": "...",
"queue_item_id": "...",
"job_id": "...",
"requested_url": "...",
"final_url": "...",
"status_code": 200,
"content_type": "text/html",
"body": {
"content_ref": "...",
"bytes": 12345
},
"result_code": "FETCH_OK | FETCH_OK_REDIRECTED"
}
Reject / skip
- failed FetchResult;
- binary/non-HTML response;
- missing body;
- body beyond upstream contract;
- stale Job fence;
- cancelled Job.
8. Safe parser evidence
Required
- parser does not execute JavaScript;
- parser does not fetch images/styles/scripts/subresources;
- parser does not resolve external entities;
- malformed HTML handled without worker crash;
- bounded DOM/link processing;
- text/attributes treated as untrusted input;
- no browser fallback in this task.
{
"parser_safety": {
"javascript_execution": false,
"network_side_effects": false,
"external_entities": false,
"malformed_html_test": "PASS | FAIL",
"evidence_refs": []
}
}
9. Link extraction evidence
Primary discovery
Основной target source — <a href>.
Extract metadata
- raw href;
- anchor text where bounded/useful;
- DOM position/index;
- parent FetchResult;
- discovery relation;
- source element kind;
- resolved absolute URL if valid.
Do not enqueue as ordinary crawl targets
- stylesheet/script/image src;
- font/media assets;
- mailto/tel/javascript/data;
- fragment-only links;
- obvious downloadable assets where excluded by policy.
10. URL resolution evidence
Resolution base
- start with FetchResult
final_url; - if document has safe valid
<base href>, resolve it against final_url; - base URL itself must pass appropriate validation before use;
- resolve each relative href;
- send result through TASK-002 normalization/security/scope.
Required tests
- relative path;
- root-relative path;
- protocol-relative URL;
- query-only link;
- fragment-only link;
- safe base href;
- unsafe/out-of-scope base href;
- redirected final URL as correct base.
{
"url_resolution_tests": {
"relative": "PASS | FAIL",
"root_relative": "PASS | FAIL",
"protocol_relative": "PASS | FAIL",
"query_only": "PASS | FAIL",
"fragment_only_rejected": "PASS | FAIL",
"safe_base": "PASS | FAIL",
"unsafe_base": "PASS | FAIL",
"redirect_final_url_base": "PASS | FAIL"
}
}
11. Typed observations
Некоторые links — не обычные crawl targets, а structural evidence.
Required observation types
OBS_CANONICAL OBS_NEXT OBS_PREV OBS_ALTERNATE OBS_FEED_LINK OBS_OTHER_REL
Example
{
"observation_id": "...",
"job_id": "...",
"fetch_id": "...",
"type": "OBS_CANONICAL",
"raw_url": "../article",
"resolved_url": "https://example.test/article",
"security_decision": "ALLOW",
"scope_decision": "IN_SCOPE",
"dom_index": 12
}
Important
Observation не означает, что canonical/next/prev уже доверены как final identity/order truth. Они становятся evidence для следующих stages.
12. Candidate provenance / depth
{
"candidate_id": "...",
"job_id": "...",
"discovered_url": "...",
"normalized_url": "...",
"parent_fetch_id": "...",
"parent_queue_item_id": "...",
"parent_candidate_id": "...",
"depth": 2,
"dom_index": 17,
"anchor_text": "...",
"discovery_relation": "ANCHOR",
"discovered_at": "..."
}
Required proof
- depth = parent depth + 1;
- root seeds follow explicit depth contract;
- parent link trace persists;
- same request URL discovered from multiple parents does not lose all useful provenance if architecture supports edge records;
- depth limit checked before enqueue.
13. Discovery filtering
Filtering here is structural/network-oriented, not article classification.
Allowed discovery rejects
- empty href;
- fragment-only;
- unsupported scheme;
- asset/download pattern;
- explicit CrawlPlan excluded pattern;
- out-of-scope target;
- security rejection;
- invalid URL;
- depth limit;
- page link limit;
- cancelled Job/stale fence.
Forbidden here
- «title looks non-article»;
- «page probably has no content image»;
- «same title as another article»;
- «canonical means merge»;
- «archive order means article order already final».
14. Queue emission evidence
Required flow
resolved href ↓ TASK-002 normalize/security/scope ↓ structural discovery filter ↓ Candidate/provenance record ↓ TASK-005 enqueue(request identity) ↓ ENQUEUED | ALREADY_ENQUEUED | REJECTED
Proof
- discovery never fetches target directly;
- all work enters persistent queue;
- duplicate request enqueue returns deterministic outcome;
- Candidate record/emission is replay-safe;
- queue item links back to discovery provenance where contract supports it.
15. Determinism / replay
Same FetchResult replay must produce
- same ordered observations;
- same normalized target list;
- same reason-code distribution;
- no duplicate queue work;
- no duplicate Candidate if Candidate identity is idempotent by contract;
- same DOM-index/provenance ordering.
Ordering baseline
Preserve deterministic DOM discovery order for this stage. This is not final publication order.
{
"replay_test": "PASS | FAIL",
"first_run_emitted": 0,
"second_run_new_queue_items": 0,
"semantic_diff": [],
"evidence_refs": []
}
16. Budgets / hard limits
| Limit | Configured | Observed | PASS? |
|---|---|---|---|
| Max links inspected per page | REAL_VALUE | REAL_VALUE | PASS / FAIL |
| Max emitted candidates per page | REAL_VALUE | REAL_VALUE | PASS / FAIL |
| Max depth | REAL_VALUE | REAL_VALUE | PASS / FAIL |
| Max retained anchor length | REAL_VALUE | REAL_VALUE | PASS / FAIL |
| Max observations per page | REAL_VALUE | REAL_VALUE | PASS / FAIL |
17. Stable reason codes evidence
DISCOVERY_IN_SCOPE DISCOVERY_ALREADY_ENQUEUED OBS_CANONICAL OBS_NEXT OBS_PREV OBS_ALTERNATE OBS_FEED_LINK REJECT_EMPTY_HREF REJECT_FRAGMENT_ONLY REJECT_UNSUPPORTED_SCHEME REJECT_ASSET REJECT_EXCLUDED_PATTERN REJECT_OUT_OF_SCOPE REJECT_SECURITY REJECT_INVALID_URL REJECT_DEPTH_LIMIT REJECT_PAGE_LINK_LIMIT REJECT_STALE_FENCE REJECT_JOB_CANCELLED REJECT_PARSE_FAILURE
Evidence requirement
Если implementation использует отличающиеся имена, записать mapping и подтвердить, что downstream/evidence semantics остаются стабильными.
18. Tests executed
| Test group | Command | Result | Evidence |
|---|---|---|---|
| Basic anchor discovery | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Relative/final URL resolution | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Safe/unsafe base href | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Canonical/next/prev observations | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Unsupported schemes/assets | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Security/scope rejection | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Depth/page limits | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Queue enqueue dedup | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Replay determinism | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Malformed HTML | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Stale fence/cancelled Job | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Regression suite | REAL_COMMAND | PASS / FAIL | REAL_REF |
19. Negative cases
- javascript: link → rejected;
- data: link → rejected;
- mailto/tel → rejected;
- fragment-only → rejected;
- private/out-of-scope target → rejected before enqueue;
- unsafe base href cannot redirect resolution context silently;
- asset links do not flood queue;
- very large link page hits hard limit;
- malformed HTML does not crash pipeline;
- replay does not create duplicate request work;
- discovery does not emit INCLUDE/EXCLUDE article decision;
- discovery does not merge articles by canonical/title.
{
"negative_tests": {
"unsupported_scheme": "PASS | FAIL",
"private_target": "PASS | FAIL",
"unsafe_base": "PASS | FAIL",
"asset_filter": "PASS | FAIL",
"page_limit": "PASS | FAIL",
"malformed_html": "PASS | FAIL",
"no_classification_leak": "PASS | FAIL",
"no_logical_dedup_leak": "PASS | FAIL"
}
}
20. Acceptance checklist
| Acceptance item | Result | Evidence |
|---|---|---|
| Consumes only successful bounded HTML FetchResult | PASS / FAIL | REAL_REF |
| Parser has no JS/network side effects | PASS / FAIL | REAL_REF |
| Relative URLs resolved from final URL | PASS / FAIL | REAL_REF |
| Safe base href handling | PASS / FAIL | REAL_REF |
| Every target passes TASK-002 | PASS / FAIL | REAL_REF |
| Typed observations captured | PASS / FAIL | REAL_REF |
| Provenance/depth persisted | PASS / FAIL | REAL_REF |
| Assets/unsupported schemes bounded/rejected | PASS / FAIL | REAL_REF |
| Emission only through TASK-005 queue | PASS / FAIL | REAL_REF |
| Replay is idempotent/deterministic | PASS / FAIL | REAL_REF |
| Page/depth budgets enforced | PASS / FAIL | REAL_REF |
| No article classification performed | PASS / FAIL | REAL_REF |
| No logical article dedup performed | PASS / FAIL | REAL_REF |
| No direct fetch performed | PASS / FAIL | REAL_REF |
| No unrelated diff | PASS / FAIL | REAL_REF |
21. Gaps / blockers
{
"blockers": [],
"known_gaps": [],
"unproven_replay_cases": [],
"blocks_TASK_008": true
}
Automatic blockers
- parser executes JS or fetches subresources;
- links bypass TASK-002 guard;
- discovery fetches targets directly;
- queue bypass;
- same FetchResult replay creates uncontrolled duplicate work;
- unbounded page-link processing;
- unsafe base href changes resolution context without validation;
- classification/logical dedup leaks into discovery stage;
- provenance/depth lost.
22. Final result
VERIFIED PARTIAL FAILED BLOCKED
23. Project state update
If VERIFIED
{
"active_window_id": "AW-01",
"last_verified_task": "TASK-007",
"completed_tasks": [
"TASK-001",
"TASK-002",
"TASK-003",
"TASK-004",
"TASK-005",
"TASK-006",
"TASK-007"
],
"current_task_id": "TASK-008",
"last_evidence_ref": "EXEC-46_FILLED_REAL_REF",
"repo_revision": "REAL_REVISION_AFTER",
"open_blockers": [],
"state_version": "INCREMENT_REAL_VALUE"
}
If not VERIFIED
{
"current_task_id": "TASK-007",
"last_task_result": "PARTIAL | FAILED | BLOCKED",
"open_blockers": ["..."],
"next_action": "TASK_007_REPAIR_OR_DISCOVERY_REVIEW"
}
24. Canonical machine-readable result
{
"schema": "STATIYA_TASK_EXECUTION_EVIDENCE",
"schema_version": "1.0",
"project_id": "autonomous-site-research-pipeline",
"active_window_id": "AW-01",
"task_id": "TASK-007",
"packet_ref": "EXEC-32",
"evidence_document_ref": "EXEC-46",
"result": "BLOCKED_UNTIL_TASK_006_VERIFIED",
"task_006_evidence_ref": "REAL_VALUE",
"html_parser": "REAL_VALUE",
"repo": {
"root": "REAL_VALUE",
"revision_before": "REAL_VALUE",
"revision_after": "REAL_VALUE"
},
"changed_files": [],
"reused_components": [],
"created_components": [],
"tests": [],
"acceptance_checks": [],
"blockers": [],
"known_gaps": [],
"next_task_allowed": false,
"next_task_id_if_verified": "TASK-008",
"next_packet_if_verified": "EXEC-33",
"created_at": "REAL_VALUE"
}
25. Next exact action
EXEC-46 заполняется только после реального TASK-006 = VERIFIED и исполнения EXEC-32.
If TASK-007 = VERIFIED
Следующий execution step: TASK-008 / EXEC-33 — Article Classifier V1.
If TASK-007 ≠ VERIFIED
Создать bounded discovery/parser repair record и не переходить к TASK-008.