feat(epic4): безопасные повторы и отмена durable Task (Story 4.4)
CI / UI Checks (pull_request) Successful in 8s
CI / Rust Checks (pull_request) Successful in 20m46s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
CI / UI Checks (pull_request) Successful in 8s
CI / Rust Checks (pull_request) Successful in 20m46s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
Durable per-outbound attempt до отправки запроса, bounded retry/read, server-owned verified writes, честный cancel/unknown, deadline/fencing, additive schema v29. Staged renames task.rs/tasks.rs разложены на модули. Includes disclosed cosmetic parity exception: единственная правка вне принятой дельты — удалена лишняя пустая строка в конце scripts/ci-story-checks.sh (EOF blank line); story-код не менялся.
This commit is contained in:
1 parent
8c02380762
commit
a3057de51e
44 files changed
+4547
-815
No files matched your search
@@ -213,6 +213,7 @@ impl TaskApplication {
|
||||
deadline: Instant::now() + Duration::from_millis(policy.deadline_ms.max(1)),
|
||||
retention_ms: TaskService::default_retention_ms(),
|
||||
approval_reference: None,
|
||||
retry: task_retry_policy(&tool),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -274,6 +275,45 @@ impl TaskApplication {
|
||||
}
|
||||
}
|
||||
|
||||
/// Owner-scoped cancellation of one Task of the addressed published Tool (Story 4.4).
|
||||
///
|
||||
/// Cancellation is decided by the durable store under a row lock: before the dispatch checkpoint
|
||||
/// it is an honest cancellation with zero outbound calls, after it the Task becomes the
|
||||
/// non-terminal uncertain outcome instead of a plain cancel or a retry.
|
||||
pub async fn cancel(
|
||||
&self,
|
||||
principal: &TaskPrincipal,
|
||||
tool_name: &str,
|
||||
task_id: TaskId,
|
||||
expected_version: Option<u32>,
|
||||
) -> Result<crank_core::TaskCancelOutcome, TaskApplicationError> {
|
||||
let access = self.task_access(principal, tool_name).await?;
|
||||
match self
|
||||
.service
|
||||
.cancel(&access, task_id, expected_version, "user_cancelled")
|
||||
.await
|
||||
{
|
||||
Ok(outcome) => Ok(outcome),
|
||||
Err(TaskError::NotFound) => Err(TaskApplicationError::NotFound),
|
||||
Err(error) => Err(TaskApplicationError::Task(error)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Owner-scoped attempt history of one Task of the addressed published Tool.
|
||||
pub async fn attempts(
|
||||
&self,
|
||||
principal: &TaskPrincipal,
|
||||
tool_name: &str,
|
||||
task_id: TaskId,
|
||||
) -> Result<Vec<crank_core::TaskAttempt>, TaskApplicationError> {
|
||||
let access = self.task_access(principal, tool_name).await?;
|
||||
match self.service.attempts(&access, task_id).await {
|
||||
Ok(attempts) => Ok(attempts),
|
||||
Err(TaskError::NotFound) => Err(TaskApplicationError::NotFound),
|
||||
Err(error) => Err(TaskApplicationError::Task(error)),
|
||||
}
|
||||
}
|
||||
|
||||
async fn task_access(
|
||||
&self,
|
||||
principal: &TaskPrincipal,
|
||||
@@ -320,3 +360,18 @@ impl TaskApplication {
|
||||
Ok(tool)
|
||||
}
|
||||
}
|
||||
|
||||
/// Bounded retry snapshot pinned from the exact published operation at acceptance. A later
|
||||
/// publication, a restart or a new binary never changes the numbers an accepted Task was admitted
|
||||
/// with; a missing or oversized policy is clamped to the closed story bound.
|
||||
fn task_retry_policy(tool: &PublishedAgentTool) -> crank_core::TaskRetryPolicy {
|
||||
let max_attempts = tool
|
||||
.operation
|
||||
.execution_config
|
||||
.retry_policy
|
||||
.as_ref()
|
||||
.map_or(1, |policy| {
|
||||
policy.max_attempts.clamp(1, crank_core::TASK_MAX_ATTEMPTS)
|
||||
});
|
||||
crank_core::TaskRetryPolicy::new(max_attempts, 1)
|
||||
}
|
||||
Reference in new issue
Block a user