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-код не менялся.
88 lines
2.5 KiB
Rust
88 lines
2.5 KiB
Rust
//! V29 schema guard: durable per-outbound attempt history, pinned retry policy and cancellation
|
|
//! (Story 4.4).
|
|
|
|
use sqlx::{PgConnection, Row, query};
|
|
|
|
use super::authority::MigrationError;
|
|
use super::schema_guard::{column_exists, relation_exists};
|
|
|
|
const TASKS: &str = "tasks";
|
|
const ATTEMPTS: &str = "task_attempts";
|
|
|
|
pub(super) async fn validate_v29_absent(
|
|
connection: &mut PgConnection,
|
|
) -> Result<bool, MigrationError> {
|
|
if relation_exists(connection, TASKS).await? {
|
|
if column_exists(connection, TASKS, "max_attempts").await? {
|
|
return Ok(false);
|
|
}
|
|
if relation_exists(connection, ATTEMPTS).await? {
|
|
return Ok(false);
|
|
}
|
|
}
|
|
Ok(true)
|
|
}
|
|
pub(super) async fn validate_v29_durable_attempts(
|
|
connection: &mut PgConnection,
|
|
) -> Result<(), MigrationError> {
|
|
// The V28 column set is still required and unchanged; V29 only appends columns and one table.
|
|
for column in [
|
|
"platform_api_key_id",
|
|
"max_attempts",
|
|
"retry_backoff_step_ms",
|
|
"next_attempt_at",
|
|
"cancel_requested_at",
|
|
"cancel_reason",
|
|
] {
|
|
if !column_exists(connection, TASKS, column).await? {
|
|
return Err(invalid(29, "v29.columns"));
|
|
}
|
|
}
|
|
// Exact total column count for version 29: the 38 V28 columns + 5 V29 columns.
|
|
let count: i64 = query(
|
|
"select count(*)::bigint as count from information_schema.columns
|
|
where table_schema = current_schema() and table_name = $1",
|
|
)
|
|
.bind(TASKS)
|
|
.fetch_one(&mut *connection)
|
|
.await
|
|
.map_err(|_| MigrationError::storage("preflight.schema"))?
|
|
.try_get("count")
|
|
.map_err(|_| MigrationError::storage("preflight.schema"))?;
|
|
if count != 43_i64 {
|
|
return Err(invalid(29, "v29.columns"));
|
|
}
|
|
if !relation_exists(connection, ATTEMPTS).await? {
|
|
return Err(invalid(29, "v29.attempts"));
|
|
}
|
|
for column in [
|
|
"attempt_id",
|
|
"task_id",
|
|
"ordinal",
|
|
"owner",
|
|
"fence",
|
|
"input_fingerprint",
|
|
"upstream_key_digest",
|
|
"retry_allowed",
|
|
"checkpoint_at",
|
|
"resolved_at",
|
|
"outcome",
|
|
"certainty",
|
|
"phase",
|
|
] {
|
|
if !column_exists(connection, ATTEMPTS, column).await? {
|
|
return Err(invalid(29, "v29.attempts"));
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
fn invalid(version: i64, stage: &'static str) -> MigrationError {
|
|
MigrationError::new(
|
|
"partial_sequence",
|
|
stage,
|
|
Some(version),
|
|
"restore_known_good_backup",
|
|
)
|
|
}
|