Публичный контракт Orchestration должен быть engine-neutral: клиент работает с canonical workflow/run/task объектами, а Temporal, Prefect, LangGraph, Kestra или собственный runner остаются сменяемыми execution adapters.
WORKFLOWS orchestration.workflow.create orchestration.workflow.get orchestration.workflow.list orchestration.workflow.update orchestration.workflow.validate orchestration.workflow.publish orchestration.workflow.deprecate RUNS orchestration.run.start orchestration.run.get orchestration.run.list orchestration.run.pause orchestration.run.resume orchestration.run.cancel orchestration.run.retry_failed orchestration.run.recover orchestration.run.export TASKS / STEPS orchestration.task.get orchestration.task.list orchestration.task.claim orchestration.task.heartbeat orchestration.task.complete orchestration.task.fail orchestration.task.defer orchestration.task.release HANDOFF orchestration.handoff.create orchestration.handoff.get orchestration.handoff.accept orchestration.handoff.reject orchestration.handoff.return HUMAN GATES orchestration.approval.request orchestration.approval.get orchestration.approval.approve orchestration.approval.reject orchestration.approval.expire OBSERVABILITY / AUDIT orchestration.events.list orchestration.audit.get orchestration.timeline.get orchestration.health.get
| Layer | Owns | Does not own |
|---|---|---|
| Orchestration API | run state, task delivery, routing, retry, timeout, approvals, cancellation, audit | truth, publication quality, causal verdict, experiment validity, permanent RAG promotion |
| Domain module API | module-specific decision + canonical objects | global workflow scheduling |
| Engine adapter | execution mechanics | canonical IDs, domain policy, authorization model |
WorkflowRun.status:
CREATED -> READY -> RUNNING
-> WAITING_MODULE
-> WAITING_HUMAN
-> PAUSED
-> RECOVERING
-> COMPLETED
-> FAILED
-> CANCELLED
-> PARTIALLY_COMPENSATED
engine_run_id = metadata only
canonical run_id = source of truth
Каждая мутация protected state принимает expected_revision. Изменение workflow definition после старта не переписывает уже запущенный run: он остаётся привязан к workflow_version.
Фиксирует immutable input refs, workflow version, actor, policy refs, resource class и correlation IDs.
Не теряет lease/task state; resume проходит canonical validation.
Используется при UNKNOWN/ambiguous engine state; не маркирует run успешным без reconciliation.
ModuleHandoff {
handoff_id,
run_id,
from_module,
to_module,
contract_name,
input_refs[],
expected_output_schema,
permission_scope,
idempotency_key,
deadline_at?,
status,
created_by,
policy_version,
revision
}
Handoff не должен передавать сырой системный prompt другого модуля или секреты. Вход — только минимально необходимый canonical context + refs. Получатель возвращает typed result/ref, а Orchestration решает только следующий transition согласно workflow policy.
| Route | Typical purpose | Mandatory guard |
|---|---|---|
| Researcher | missing evidence / web research | no permanent write |
| Skeptic | claim/draft verification | cannot silently publish |
| Investigator | causal investigation | correlation != cause |
| Experiment | controlled discriminating test | design/run policy + reproducibility |
| Curator | promotion decision | only Curator path may authorize permanent RAG write |
| Writer | draft generation/editing | read-only knowledge access |
TaskLease {
task_id,
lease_id,
worker_id,
claimed_at,
expires_at,
heartbeat_at,
attempt,
idempotency_key,
input_hash,
execution_engine_ref?
}
RetryPolicy: retryable_error_classes[] max_attempts backoff jitter timeout_per_attempt total_deadline requires_reconciliation compensation_on_exhaustion NEVER_AUTO_RETRY examples: permission_denied schema_violation policy_block human_rejection unknown_irreversible_side_effect
Engine-specific retry settings переводятся в canonical policy. Orchestration хранит причину каждого attempt и не маскирует retry-exhausted как generic success.
ApprovalRequest {
approval_id,
run_id,
gate_id,
protected_input_hash,
requested_action,
approver_role,
status: PENDING|APPROVED|REJECTED|EXPIRED|INVALIDATED,
expires_at?,
policy_version,
decision_reason,
decided_by,
decided_at
}
INVALIDATED.| Action | Meaning |
|---|---|
| cancel | запретить дальнейшие planned steps |
| terminate | аварийно остановить worker/engine execution |
| compensate | выполнить явные inverse/mitigation actions |
| reconcile | установить фактическое состояние внешних side effects |
CompensationRecord: compensation_id original_step_ref action status reversible: true|false|partial evidence_refs[] completed_at
Если часть эффектов необратима, итоговый статус обязан это отражать: например PARTIALLY_COMPENSATED, а не ложный CANCELLED_CLEAN.
AuditEvent {
event_id,
run_id,
task_id?,
handoff_id?,
event_type,
actor_type,
actor_id,
from_state?,
to_state?,
reason_code,
input_refs[],
output_refs[],
policy_version,
engine_ref?,
correlation_id,
created_at
}
Audit append-only. Engine logs дополняют, но не заменяют canonical audit. Для replay/debug должны быть доступны workflow version, inputs, outputs, handoffs, attempts, approvals, failures и compensation records.
unauthorized module route accepted = 0 Curator permanent-write bypass = 0 mandatory Skeptic/human gate bypass = 0 stale approval accepted after protected input change= 0 duplicate irreversible side effect after retry = 0 expired lease completing protected task = 0 engine callback mutating canonical state unchecked = 0 workflow version silently changed mid-run = 0 Qwen output treated as authorization = 0 secret leaked into prompt/audit/engine metadata = 0 cancel reported as rollback without compensation = 0 cross-scope handoff without permission = 0 terminal run without audit trail = 0
AI_orchestration_7_execution_recovery_и_observability.html