cancelling actions works now

This commit is contained in:
2026-03-10 19:53:20 -05:00
parent 5b45b17fa6
commit 71ea3f34ca
30 changed files with 482 additions and 1071 deletions

View File

@@ -1133,6 +1133,7 @@ pub mod execution {
pub enforcement: Option<Id>,
pub executor: Option<Id>,
pub worker: Option<Id>,
pub status: ExecutionStatus,
pub result: Option<JsonDict>,

View File

@@ -54,6 +54,7 @@ pub struct ExecutionWithRefs {
pub parent: Option<Id>,
pub enforcement: Option<Id>,
pub executor: Option<Id>,
pub worker: Option<Id>,
pub status: ExecutionStatus,
pub result: Option<JsonDict>,
pub started_at: Option<DateTime<Utc>>,
@@ -73,7 +74,7 @@ pub struct ExecutionWithRefs {
/// are NOT in the Rust struct, so `SELECT *` must never be used.
pub const SELECT_COLUMNS: &str = "\
id, action, action_ref, config, env_vars, parent, enforcement, \
executor, status, result, started_at, workflow_task, created, updated";
executor, worker, status, result, started_at, workflow_task, created, updated";
pub struct ExecutionRepository;
@@ -93,6 +94,7 @@ pub struct CreateExecutionInput {
pub parent: Option<Id>,
pub enforcement: Option<Id>,
pub executor: Option<Id>,
pub worker: Option<Id>,
pub status: ExecutionStatus,
pub result: Option<JsonDict>,
pub workflow_task: Option<WorkflowTaskMetadata>,
@@ -103,6 +105,7 @@ pub struct UpdateExecutionInput {
pub status: Option<ExecutionStatus>,
pub result: Option<JsonDict>,
pub executor: Option<Id>,
pub worker: Option<Id>,
pub started_at: Option<DateTime<Utc>>,
pub workflow_task: Option<WorkflowTaskMetadata>,
}
@@ -113,6 +116,7 @@ impl From<Execution> for UpdateExecutionInput {
status: Some(execution.status),
result: execution.result,
executor: execution.executor,
worker: execution.worker,
started_at: execution.started_at,
workflow_task: execution.workflow_task,
}
@@ -158,8 +162,8 @@ impl Create for ExecutionRepository {
{
let sql = format!(
"INSERT INTO execution \
(action, action_ref, config, env_vars, parent, enforcement, executor, status, result, workflow_task) \
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) \
(action, action_ref, config, env_vars, parent, enforcement, executor, worker, status, result, workflow_task) \
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) \
RETURNING {SELECT_COLUMNS}"
);
sqlx::query_as::<_, Execution>(&sql)
@@ -170,6 +174,7 @@ impl Create for ExecutionRepository {
.bind(input.parent)
.bind(input.enforcement)
.bind(input.executor)
.bind(input.worker)
.bind(input.status)
.bind(&input.result)
.bind(sqlx::types::Json(&input.workflow_task))
@@ -208,6 +213,13 @@ impl Update for ExecutionRepository {
query.push("executor = ").push_bind(executor_id);
has_updates = true;
}
if let Some(worker_id) = input.worker {
if has_updates {
query.push(", ");
}
query.push("worker = ").push_bind(worker_id);
has_updates = true;
}
if let Some(started_at) = input.started_at {
if has_updates {
query.push(", ");

View File

@@ -42,6 +42,7 @@ async fn test_create_execution_basic() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -76,6 +77,7 @@ async fn test_create_execution_without_action() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -110,6 +112,7 @@ async fn test_create_execution_with_all_fields() {
parent: None,
enforcement: None,
executor: None, // Don't reference non-existent identity
worker: None,
status: ExecutionStatus::Scheduled,
result: Some(json!({"status": "ok"})),
workflow_task: None,
@@ -146,6 +149,7 @@ async fn test_create_execution_with_parent() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Running,
result: None,
workflow_task: None,
@@ -164,6 +168,7 @@ async fn test_create_execution_with_parent() {
parent: Some(parent.id),
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -203,6 +208,7 @@ async fn test_find_execution_by_id() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -257,6 +263,7 @@ async fn test_list_executions() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -303,6 +310,7 @@ async fn test_list_executions_ordered_by_created_desc() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -354,6 +362,7 @@ async fn test_update_execution_status() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -399,6 +408,7 @@ async fn test_update_execution_result() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Running,
result: None,
workflow_task: None,
@@ -445,6 +455,7 @@ async fn test_update_execution_executor() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -489,6 +500,7 @@ async fn test_update_execution_status_transitions() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -580,6 +592,7 @@ async fn test_update_execution_failed_status() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Running,
result: None,
workflow_task: None,
@@ -625,6 +638,7 @@ async fn test_update_execution_no_changes() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -669,6 +683,7 @@ async fn test_delete_execution() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Completed,
result: None,
workflow_task: None,
@@ -736,6 +751,7 @@ async fn test_find_executions_by_status() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: *status,
result: None,
workflow_task: None,
@@ -783,6 +799,7 @@ async fn test_find_executions_by_enforcement() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -801,6 +818,7 @@ async fn test_find_executions_by_enforcement() {
parent: None,
enforcement: None, // Can't reference non-existent enforcement
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -845,6 +863,7 @@ async fn test_parent_child_execution_hierarchy() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Running,
result: None,
workflow_task: None,
@@ -865,6 +884,7 @@ async fn test_parent_child_execution_hierarchy() {
parent: Some(parent.id),
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -909,6 +929,7 @@ async fn test_nested_execution_hierarchy() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Running,
result: None,
workflow_task: None,
@@ -927,6 +948,7 @@ async fn test_nested_execution_hierarchy() {
parent: Some(grandparent.id),
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Running,
result: None,
workflow_task: None,
@@ -945,6 +967,7 @@ async fn test_nested_execution_hierarchy() {
parent: Some(parent.id),
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -987,6 +1010,7 @@ async fn test_execution_timestamps() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -1058,6 +1082,7 @@ async fn test_execution_config_json() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -1091,6 +1116,7 @@ async fn test_execution_result_json() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: ExecutionStatus::Running,
result: None,
workflow_task: None,

View File

@@ -49,6 +49,7 @@ async fn test_create_inquiry_minimal() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -109,6 +110,7 @@ async fn test_create_inquiry_with_response_schema() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -167,6 +169,7 @@ async fn test_create_inquiry_with_timeout() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -221,6 +224,7 @@ async fn test_create_inquiry_with_assigned_user() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -310,6 +314,7 @@ async fn test_find_inquiry_by_id() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -372,6 +377,7 @@ async fn test_get_inquiry_by_id() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -443,6 +449,7 @@ async fn test_list_inquiries() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -504,6 +511,7 @@ async fn test_update_inquiry_status() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -560,6 +568,7 @@ async fn test_update_inquiry_status_transitions() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -645,6 +654,7 @@ async fn test_update_inquiry_response() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -703,6 +713,7 @@ async fn test_update_inquiry_with_response_and_status() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -761,6 +772,7 @@ async fn test_update_inquiry_assignment() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -828,6 +840,7 @@ async fn test_update_inquiry_no_changes() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -905,6 +918,7 @@ async fn test_delete_inquiry() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -965,6 +979,7 @@ async fn test_delete_execution_cascades_to_inquiries() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -1032,6 +1047,7 @@ async fn test_find_inquiries_by_status() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -1111,6 +1127,7 @@ async fn test_find_inquiries_by_execution() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -1129,6 +1146,7 @@ async fn test_find_inquiries_by_execution() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -1193,6 +1211,7 @@ async fn test_inquiry_timestamps_auto_managed() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,
@@ -1260,6 +1279,7 @@ async fn test_inquiry_complex_response_schema() {
parent: None,
enforcement: None,
executor: None,
worker: None,
status: attune_common::models::enums::ExecutionStatus::Requested,
result: None,
workflow_task: None,