STET

agent_patch

runs/2026-02-28__18-27-22__gpt-5-1-codex-mini/flux-pr-1908/flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/agent-logs/agent.patch

10623 bytes

Back to adjudication
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/ast/ddl.rs b/app/src/ast/ddl.rs
index 9134412..6592d43 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/ast/ddl.rs
+++ b/app/src/ast/ddl.rs
@@ -68,7 +68,11 @@ impl fmt::Display for ReplicaIdentity {
 #[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
 pub enum AlterTableOperation {
     /// `ADD <table_constraint>`
-    AddConstraint(TableConstraint),
+    AddConstraint {
+        constraint: TableConstraint,
+        /// `NOT VALID` modifier (PostgreSQL only)
+        not_valid: bool,
+    },
     /// `ADD [COLUMN] [IF NOT EXISTS] <column_def>`
     AddColumn {
         /// `[COLUMN]`.
@@ -137,6 +141,13 @@ pub enum AlterTableOperation {
         name: Ident,
         drop_behavior: Option<DropBehavior>,
     },
+
+    /// `VALIDATE CONSTRAINT <name>`
+    ///
+    /// PostgreSQL-specific operation that rechecks an existing constraint.
+    ValidateConstraint {
+        name: Ident,
+    },
     /// `DROP [ COLUMN ] [ IF EXISTS ] <column_name> [ CASCADE ]`
     DropColumn {
         has_column_keyword: bool,
@@ -494,7 +505,13 @@ impl fmt::Display for AlterTableOperation {
                 display_separated(new_partitions, " "),
                 ine = if *if_not_exists { " IF NOT EXISTS" } else { "" }
             ),
-            AlterTableOperation::AddConstraint(c) => write!(f, "ADD {c}"),
+            AlterTableOperation::AddConstraint { constraint, not_valid } => {
+                write!(f, "ADD {constraint}")?;
+                if *not_valid {
+                    write!(f, " NOT VALID")?;
+                }
+                Ok(())
+            }
             AlterTableOperation::AddColumn {
                 column_keyword,
                 if_not_exists,
@@ -610,6 +627,9 @@ impl fmt::Display for AlterTableOperation {
                     }
                 )
             }
+            AlterTableOperation::ValidateConstraint { name } => {
+                write!(f, "VALIDATE CONSTRAINT {name}")
+            }
             AlterTableOperation::DropPrimaryKey => write!(f, "DROP PRIMARY KEY"),
             AlterTableOperation::DropForeignKey { name } => write!(f, "DROP FOREIGN KEY {name}"),
             AlterTableOperation::DropIndex { name } => write!(f, "DROP INDEX {name}"),
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/ast/spans.rs b/app/src/ast/spans.rs
index 0088260..e5fa7cd 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/ast/spans.rs
+++ b/app/src/ast/spans.rs
@@ -1075,7 +1075,7 @@ impl Spanned for CreateTableOptions {
 impl Spanned for AlterTableOperation {
     fn span(&self) -> Span {
         match self {
-            AlterTableOperation::AddConstraint(table_constraint) => table_constraint.span(),
+            AlterTableOperation::AddConstraint { constraint, .. } => constraint.span(),
             AlterTableOperation::AddColumn {
                 column_keyword: _,
                 if_not_exists: _,
@@ -1106,6 +1106,7 @@ impl Spanned for AlterTableOperation {
                 name,
                 drop_behavior: _,
             } => name.span,
+            AlterTableOperation::ValidateConstraint { name } => name.span,
             AlterTableOperation::DropColumn {
                 has_column_keyword: _,
                 column_name,
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/parser/mod.rs b/app/src/parser/mod.rs
index 6360817..0cd1454 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/parser/mod.rs
+++ b/app/src/parser/mod.rs
@@ -8477,7 +8477,12 @@ impl<'a> Parser<'a> {
     pub fn parse_alter_table_operation(&mut self) -> Result<AlterTableOperation, ParserError> {
         let operation = if self.parse_keyword(Keyword::ADD) {
             if let Some(constraint) = self.parse_optional_table_constraint()? {
-                AlterTableOperation::AddConstraint(constraint)
+                let not_valid = dialect_of!(self is PostgreSqlDialect)
+                    && self.parse_keywords(&[Keyword::NOT, Keyword::VALID]);
+                AlterTableOperation::AddConstraint {
+                    constraint,
+                    not_valid,
+                }
             } else if dialect_of!(self is ClickHouseDialect|GenericDialect)
                 && self.parse_keyword(Keyword::PROJECTION)
             {
@@ -8780,6 +8785,11 @@ impl<'a> Parser<'a> {
         {
             let new_owner = self.parse_owner()?;
             AlterTableOperation::OwnerTo { new_owner }
+        } else if dialect_of!(self is PostgreSqlDialect)
+            && self.parse_keywords(&[Keyword::VALIDATE, Keyword::CONSTRAINT])
+        {
+            let name = self.parse_identifier()?;
+            AlterTableOperation::ValidateConstraint { name }
         } else if dialect_of!(self is ClickHouseDialect|GenericDialect)
             && self.parse_keyword(Keyword::ATTACH)
         {
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/test_utils.rs b/app/src/test_utils.rs
index db7b3dd..e419bb0 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/test_utils.rs
+++ b/app/src/test_utils.rs
@@ -479,19 +479,22 @@ pub fn index_column(stmt: Statement) -> Expr {
             }
         }
         Statement::AlterTable { operations, .. } => match operations.first().unwrap() {
-            AlterTableOperation::AddConstraint(TableConstraint::Index { columns, .. }) => {
-                columns.first().unwrap().column.expr.clone()
-            }
-            AlterTableOperation::AddConstraint(TableConstraint::Unique { columns, .. }) => {
-                columns.first().unwrap().column.expr.clone()
-            }
-            AlterTableOperation::AddConstraint(TableConstraint::PrimaryKey { columns, .. }) => {
-                columns.first().unwrap().column.expr.clone()
-            }
-            AlterTableOperation::AddConstraint(TableConstraint::FulltextOrSpatial {
-                columns,
+            AlterTableOperation::AddConstraint {
+                constraint: TableConstraint::Index { columns, .. },
+                ..
+            } => columns.first().unwrap().column.expr.clone(),
+            AlterTableOperation::AddConstraint {
+                constraint: TableConstraint::Unique { columns, .. },
+                ..
+            } => columns.first().unwrap().column.expr.clone(),
+            AlterTableOperation::AddConstraint {
+                constraint: TableConstraint::PrimaryKey { columns, .. },
+                ..
+            } => columns.first().unwrap().column.expr.clone(),
+            AlterTableOperation::AddConstraint {
+                constraint: TableConstraint::FulltextOrSpatial { columns, .. },
                 ..
-            }) => columns.first().unwrap().column.expr.clone(),
+            } => columns.first().unwrap().column.expr.clone(),
             _ => panic!("Expected an index, unique, primary, full text, or spatial constraint (foreign key does not support general key part expressions)"),
         },
         _ => panic!("Expected CREATE INDEX, ALTER TABLE, or CREATE TABLE, got: {stmt:?}"),
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/tests/sqlparser_common.rs b/app/tests/sqlparser_common.rs
index 380bd47..f792236 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/tests/sqlparser_common.rs
+++ b/app/tests/sqlparser_common.rs
@@ -4956,7 +4956,8 @@ fn parse_alter_table_constraints() {
         match alter_table_op(verified_stmt(&format!(
             "ALTER TABLE tab ADD {constraint_text}"
         ))) {
-            AlterTableOperation::AddConstraint(constraint) => {
+            AlterTableOperation::AddConstraint { constraint, not_valid } => {
+                assert!(!not_valid, "expected constraint to be valid by default");
                 assert_eq!(constraint_text, constraint.to_string());
             }
             _ => unreachable!(),
diff --git a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/tests/sqlparser_postgres.rs b/app/tests/sqlparser_postgres.rs
index e1a49c6..fed43e1 100644
--- a/tmp/agent-patch-flux-pr-1908.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/tests/sqlparser_postgres.rs
+++ b/app/tests/sqlparser_postgres.rs
@@ -606,9 +606,12 @@ fn parse_alter_table_constraints_unique_nulls_distinct() {
         .verified_stmt("ALTER TABLE t ADD CONSTRAINT b UNIQUE NULLS NOT DISTINCT (c)")
     {
         Statement::AlterTable { operations, .. } => match &operations[0] {
-            AlterTableOperation::AddConstraint(TableConstraint::Unique {
-                nulls_distinct, ..
-            }) => {
+            AlterTableOperation::AddConstraint {
+                constraint: TableConstraint::Unique {
+                    nulls_distinct, ..
+                },
+                ..
+            } => {
                 assert_eq!(nulls_distinct, &NullsDistinctOption::NotDistinct)
             }
             _ => unreachable!(),
@@ -619,6 +622,38 @@ fn parse_alter_table_constraints_unique_nulls_distinct() {
     pg_and_generic().verified_stmt("ALTER TABLE t ADD CONSTRAINT b UNIQUE (c)");
 }
 
+#[test]
+fn parse_alter_table_add_constraint_not_valid() {
+    match pg().verified_stmt(
+        "ALTER TABLE tab ADD CONSTRAINT ck CHECK (val > 0) NOT VALID",
+    ) {
+        Statement::AlterTable { operations, .. } => match &operations[0] {
+            AlterTableOperation::AddConstraint { constraint, not_valid } => {
+                assert!(not_valid);
+                assert_eq!(
+                    "CONSTRAINT ck CHECK (val > 0)",
+                    constraint.to_string()
+                );
+            }
+            _ => unreachable!(),
+        },
+        _ => unreachable!(),
+    }
+}
+
+#[test]
+fn parse_alter_table_validate_constraint() {
+    match pg().verified_stmt("ALTER TABLE tab VALIDATE CONSTRAINT ck") {
+        Statement::AlterTable { operations, .. } => match &operations[0] {
+            AlterTableOperation::ValidateConstraint { name } => {
+                assert_eq!(name.to_string(), "ck");
+            }
+            _ => unreachable!(),
+        },
+        _ => unreachable!(),
+    }
+}
+
 #[test]
 fn parse_alter_table_disable() {
     pg_and_generic().verified_stmt("ALTER TABLE tab DISABLE ROW LEVEL SECURITY");