1. Purpose
Доказать, что Job lifecycle теперь хранится в каноническом durable state layer,
не восстанавливается по логам, защищён state_version, выдерживает concurrent mutations,
сохраняет owner approval и не допускает stale-worker overwrite после restart/lease replacement.
2. Entry gate
| Requirement | Expected | Actual | Evidence |
|---|---|---|---|
| TASK-001 | VERIFIED | REAL_VALUE | REAL_REF |
| TASK-002 | VERIFIED | REAL_VALUE | REAL_REF |
| ADR-02 | Accepted persistence/queue decision | REAL_VALUE | REAL_REF |
| Persistence adapter | Real runtime capability confirmed | REAL_VALUE | REAL_REF |
| Transaction/locking semantics | Known and testable | REAL_VALUE | REAL_REF |
3. Execution identity
| Field | Value |
|---|---|
| Project | Autonomous Site Research Pipeline / Statiya_poluchatel_1 |
| Window | AW-01 |
| Task | TASK-003 |
| Specification | EXEC-28 — Persistent Job State + Transition Guard |
| Evidence document | EXEC-42 |
| Result | UNFILLED / BLOCKED UNTIL TASK-002 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 PERSISTENCE_ADAPTER=REAL_VALUE DATABASE_OR_STORAGE=REAL_VALUE TRANSACTION_PRIMITIVE=REAL_VALUE LOCK_OR_LEASE_PRIMITIVE=REAL_VALUE MIGRATION_SYSTEM=REAL_VALUE TEST_RUNNER=REAL_VALUE TASK_001_EVIDENCE_REF=REAL_VALUE TASK_002_EVIDENCE_REF=REAL_VALUE ADR_02_REF=REAL_VALUE PROJECT_STATE_REF=REAL_VALUE
5. Reuse-before-build review
| Capability | Existing? | Action | Ref |
|---|---|---|---|
| Job persistence model | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
| Repository abstraction | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
| Transaction helper | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
| Optimistic concurrency primitive | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
| Idempotency store/helper | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
| Lease/lock primitive | REAL_VALUE | REUSE / EXTEND / CREATE | REAL_REF |
6. Changed files / migrations
{
"changed_files": [
{
"path": "REAL_PATH",
"change_type": "ADDED | MODIFIED | DELETED",
"purpose": "REAL_DESCRIPTION"
}
],
"migrations": [
{
"id": "REAL_VALUE",
"path": "REAL_PATH",
"purpose": "REAL_DESCRIPTION"
}
]
}
Must remain out of scope
- crawler logic;
- HTTP worker;
- preflight discovery;
- persistent crawl queue mechanics beyond required state-side interfaces;
- classifier;
- renderer;
- deploy.
7. State repository implementation
| Operation | Status | Implementation ref | Test ref |
|---|---|---|---|
| create_job | REAL_VALUE | REAL_REF | REAL_REF |
| get_job | REAL_VALUE | REAL_REF | REAL_REF |
| compare_and_update | REAL_VALUE | REAL_REF | REAL_REF |
| record/get idempotency | REAL_VALUE | REAL_REF | REAL_REF |
| acquire worker lease | REAL_VALUE | REAL_REF | REAL_REF |
| renew worker lease | REAL_VALUE | REAL_REF | REAL_REF |
| release worker lease | REAL_VALUE | REAL_REF | REAL_REF |
| recover/list nonterminal jobs | REAL_VALUE | REAL_REF | REAL_REF |
8. Transition guard evidence
Проверить exact lifecycle:
CREATED -> PREFLIGHT PREFLIGHT -> PREFLIGHT_READY PREFLIGHT_READY -> RUNNING_FIRST_BATCH RUNNING_FIRST_BATCH -> WAITING_FOR_OWNER WAITING_FOR_OWNER -> RUNNING_FULL RUNNING_FULL -> VALIDATING VALIDATING -> DEPLOYING DEPLOYING -> VERIFYING_LIVE VERIFYING_LIVE -> DONE
Side outcomes
PARTIAL FAILED CANCELLED
Required proof
- allowed transitions succeed;
- illegal backward/jump transitions reject;
- DONE cannot be written directly from CREATED/PREFLIGHT/DEPLOYING;
- WAITING_FOR_OWNER cannot auto-transition without approval;
- transition rules live in code, not only comments.
9. state_version / optimistic concurrency
READ state_version = N MUTATE with expected_state_version = N SUCCESS -> persisted state_version = N+1 concurrent second mutation with expected N -> CONFLICT -> no overwrite -> reload required
Evidence
{
"state_version_test": "PASS | FAIL",
"concurrent_update_test": "PASS | FAIL",
"stale_expected_version_rejected": "PASS | FAIL",
"version_increment_exactly_once": "PASS | FAIL",
"evidence_refs": []
}
10. Idempotency evidence
Minimum operations
- Create Job if externally repeatable;
- OWNER_CONTINUE;
- controlled retry command;
- other mutating commands introduced by implementation.
Required scenarios
- same key + same payload → same durable result;
- same key + different payload → conflict;
- client timeout + retry → no duplicate state transition;
- duplicate Continue → no duplicate RUNNING_FULL work launch.
11. Durable owner gate
Проверить persisted fields:
{
"required": true,
"status": "WAITING | APPROVED | REJECTED",
"preview_build_ref": "...",
"approval_version": 1,
"approved_at": "...",
"approval_idempotency_key": "..."
}
Required proof
- WAITING survives repository/service recreation;
- approval survives restart;
- Continue allowed only from WAITING unless returning idempotent prior result;
- approval and transition to RUNNING_FULL occur atomically;
- logs are not needed to know approval state.
12. Worker lease / fencing evidence
{
"job_id": "...",
"worker_id": "...",
"lease_id": "...",
"fencing_token": 42,
"expires_at": "..."
}
Required tests
- single active mutating worker;
- new lease gets newer fencing token;
- old token rejected after replacement;
- expired lease can be recovered;
- renewal requires correct worker/token;
- stale worker cannot transition Job or write checkpoint.
13. Restart recovery
| State at restart | Expected after recreation | Actual |
|---|---|---|
| PREFLIGHT | resume/safe re-run from checkpoint | REAL_VALUE |
| RUNNING_FIRST_BATCH | resume exact phase; no reset to CREATED | REAL_VALUE |
| WAITING_FOR_OWNER | remain waiting | REAL_VALUE |
| RUNNING_FULL | resume from durable checkpoint | REAL_VALUE |
| VALIDATING | safe validation retry | REAL_VALUE |
| DONE | no automatic re-run | REAL_VALUE |
Critical assertion
Recovery должен читать canonical state repository, а не восстанавливать lifecycle по логам.
14. Atomicity / transaction boundaries
| Mutation | Atomic? | Evidence |
|---|---|---|
| Status transition + state_version | REAL_VALUE | REAL_REF |
| Owner approval + RUNNING_FULL + idempotency | REAL_VALUE | REAL_REF |
| Lease acquisition + fencing token | REAL_VALUE | REAL_REF |
| Terminal failure + last_error | REAL_VALUE | REAL_REF |
| DONE + verified live-build evidence ref | REAL_VALUE | REAL_REF |
Crash test where feasible
Если backend/test framework позволяет, симулировать crash между substeps и доказать отсутствие partial mutation.
15. Tests executed
| Test group | Command | Result | Evidence |
|---|---|---|---|
| Repository persistence | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Transition matrix | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Optimistic concurrency | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Idempotency | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Owner gate | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Lease/fencing | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Restart recovery | REAL_COMMAND | PASS / FAIL | REAL_REF |
| DONE gate | REAL_COMMAND | PASS / FAIL | REAL_REF |
| Regression suite | REAL_COMMAND | PASS / FAIL | REAL_REF |
16. Negative / concurrency cases
- CREATED → DONE rejected;
- PREFLIGHT → RUNNING_FULL rejected;
- DEPLOYING → DONE rejected;
- Continue outside WAITING rejected;
- stale expected_state_version rejected;
- stale fencing token rejected;
- same idempotency key with different payload rejected;
- duplicate Continue produces same result;
- restart WAITING does not auto-continue;
- DONE without live-verification evidence rejected.
{
"negative_tests": {
"illegal_transition": "PASS | FAIL",
"stale_version": "PASS | FAIL",
"stale_fence": "PASS | FAIL",
"idempotency_conflict": "PASS | FAIL",
"duplicate_continue": "PASS | FAIL",
"done_without_verify": "PASS | FAIL"
}
}
17. Acceptance checklist
| Acceptance item | Result | Evidence |
|---|---|---|
| Job state is actually durable | PASS / FAIL | REAL_REF |
| Logs are not canonical state | PASS / FAIL | REAL_REF |
| Transition guard enforced in code | PASS / FAIL | REAL_REF |
| state_version monotonic/CAS works | PASS / FAIL | REAL_REF |
| Continue idempotent | PASS / FAIL | REAL_REF |
| Owner approval durable | PASS / FAIL | REAL_REF |
| WAITING survives restart | PASS / FAIL | REAL_REF |
| Single mutating worker enforced | PASS / FAIL | REAL_REF |
| Stale worker fenced | PASS / FAIL | REAL_REF |
| Restart resumes correct phase | PASS / FAIL | REAL_REF |
| DONE requires live verify evidence | PASS / FAIL | REAL_REF |
| No unrelated subsystem added | PASS / FAIL | REAL_REF |
18. Gaps / blockers
{
"blockers": [],
"known_gaps": [],
"unproven_atomicity": [],
"blocks_TASK_004": true
}
Automatic blockers
- state stored only in memory;
- WAITING lost on restart;
- duplicate Continue starts duplicate work;
- stale worker can write;
- CAS conflict silently overwritten;
- DONE possible without verification evidence;
- state reconstructed from logs;
- transaction boundary cannot prevent partial owner approval transition.
19. Final result
VERIFIED PARTIAL FAILED BLOCKED
20. Project state update
If VERIFIED
{
"active_window_id": "AW-01",
"last_verified_task": "TASK-003",
"completed_tasks": ["TASK-001", "TASK-002", "TASK-003"],
"current_task_id": "TASK-004",
"last_evidence_ref": "EXEC-42_FILLED_REAL_REF",
"repo_revision": "REAL_REVISION_AFTER",
"open_blockers": [],
"state_version": "INCREMENT_REAL_VALUE"
}
If not VERIFIED
{
"current_task_id": "TASK-003",
"last_task_result": "PARTIAL | FAILED | BLOCKED",
"open_blockers": ["..."],
"next_action": "TASK_003_REPAIR_OR_PERSISTENCE_REVIEW"
}
21. 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-003",
"packet_ref": "EXEC-28",
"evidence_document_ref": "EXEC-42",
"result": "BLOCKED_UNTIL_TASK_002_VERIFIED",
"task_002_evidence_ref": "REAL_VALUE",
"persistence_adapter": "REAL_VALUE",
"repo": {
"root": "REAL_VALUE",
"revision_before": "REAL_VALUE",
"revision_after": "REAL_VALUE"
},
"migrations": [],
"changed_files": [],
"reused_components": [],
"created_components": [],
"tests": [],
"acceptance_checks": [],
"blockers": [],
"known_gaps": [],
"next_task_allowed": false,
"next_task_id_if_verified": "TASK-004",
"next_packet_if_verified": "EXEC-29",
"created_at": "REAL_VALUE"
}
22. Next exact action
Этот EXEC-42 заполняется только после реального TASK-002 = VERIFIED и исполнения EXEC-28.
If TASK-003 = VERIFIED
Следующий execution step: TASK-004 / EXEC-29 — Source Preflight V1.
If TASK-003 ≠ VERIFIED
Создать bounded persistence/state repair record и не переходить к TASK-004.