feat(ql3): add postgres cancellation dispatch

This commit is contained in:
whyour
2026-08-19 06:24:11 +08:00
parent 36035ac43e
commit 1809fbb8d3
29 changed files with 2265 additions and 133 deletions
@@ -21,12 +21,13 @@ export interface PostgresSchemaContractTrigger {
export interface PostgresSchemaContract {
readonly schema: 'ql3';
readonly contractName: 'control-core';
readonly contractVersion: 64;
readonly migrationId: 'pg-0065-approved-action-manual-recovery';
readonly contractVersion: 65;
readonly migrationId: 'pg-0066-cancellation-dispatch';
readonly minimumServerMajor: 16;
readonly maximumServerMajor: 18;
readonly capabilities: Readonly<{
run_core: 1;
run_cancellation_dispatch: 1;
run_attempt_log_retention: 1;
run_management_boundary: 1;
run_management_stop: 1;
@@ -118,8 +119,8 @@ export const postgresqlControlSchemaContract: PostgresSchemaContract =
Object.freeze({
schema: 'ql3',
contractName: 'control-core',
contractVersion: 64,
migrationId: 'pg-0065-approved-action-manual-recovery',
contractVersion: 65,
migrationId: 'pg-0066-cancellation-dispatch',
minimumServerMajor: 16,
maximumServerMajor: 18,
capabilities: Object.freeze({
@@ -167,6 +168,7 @@ export const postgresqlControlSchemaContract: PostgresSchemaContract =
project_policy: 1,
project_tool_definition_snapshot: 1,
run_core: 1,
run_cancellation_dispatch: 1,
run_attempt_log_retention: 1,
run_management_boundary: 1,
run_management_stop: 1,
@@ -1289,6 +1291,21 @@ export const postgresqlControlSchemaContract: PostgresSchemaContract =
'error_code',
'error_summary',
]),
table('run_cancellation_dispatches', [
'run_id',
'attempt_id',
'status',
'version',
'dispatch_count',
'next_attempt_at_ms',
'lease_owner',
'lease_token_digest',
'lease_expires_at_ms',
'last_result',
'last_dispatched_at_ms',
'created_at_ms',
'updated_at_ms',
]),
table('run_attempt_log_retention_controls', [
'attempt_id',
'project_id',
@@ -1770,9 +1787,13 @@ export const postgresqlControlSchemaContract: PostgresSchemaContract =
'ql3_result_retirement_catalog_idx',
'run_attempts_pkey',
'ql3_run_attempts_run_attempt_uidx',
'ql3_run_attempts_run_id_uidx',
'ql3_run_attempts_dispatch_candidates_idx',
'ql3_run_attempts_recovery_idx',
'ql3_run_attempts_lease_idx',
'run_cancellation_dispatches_pkey',
'ql3_run_cancellation_dispatch_due_idx',
'ql3_run_cancellation_dispatch_lease_expiry_idx',
'run_attempt_log_retention_controls_pkey',
'ql3_run_log_retention_control_artifact_key',
'ql3_run_log_retention_retry_idx',
@@ -2106,6 +2127,13 @@ export const postgresqlControlSchemaContract: PostgresSchemaContract =
'ql3_runs_cancel_reason_check',
'ql3_run_attempts_attempt_check',
'ql3_run_attempts_status_check',
'ql3_run_cancellation_dispatch_status_check',
'ql3_run_cancellation_dispatch_result_check',
'ql3_run_cancellation_dispatch_counter_check',
'ql3_run_cancellation_dispatch_time_check',
'ql3_run_cancellation_dispatch_lease_digest_check',
'ql3_run_cancellation_dispatch_shape_check',
'ql3_run_cancellation_dispatch_result_state_check',
'ql3_run_attempts_pid_check',
'ql3_run_attempts_lease_expiry_check',
'ql3_run_attempts_worker_session_id_check',
@@ -2445,6 +2473,8 @@ export const postgresqlControlSchemaContract: PostgresSchemaContract =
'ql3_result_rekey_head_overlay_fk',
'ql3_result_retirement_catalog_fk',
'ql3_run_attempts_run_fk',
'ql3_run_cancellation_dispatch_run_fk',
'ql3_run_cancellation_dispatch_attempt_fk',
'ql3_run_attempts_step_run_fk',
'ql3_run_log_retention_control_attempt_fk',
'ql3_run_log_retention_control_run_fk',