codeant-ai-for-open-source[bot] commented on code in PR #42863:
URL: https://github.com/apache/superset/pull/42863#discussion_r3736199984


##########
superset/commands/deletion_retention/audit.py:
##########
@@ -182,6 +197,146 @@ def block(record_id: UUID | None) -> None:
     finalize(record_id, STATUS_BLOCKED)
 
 
+def _capture_recovery_snapshot(record: PurgeAuditLog) -> 
_AuditRecoverySnapshot:
+    """Capture the content-free fields needed for fail-safe recovery."""
+    return _AuditRecoverySnapshot(
+        id=cast(UUID, record.id),
+        actor=str(record.actor),
+        entity_type=str(record.entity_type),
+        entity_uuid=record.entity_uuid,
+        created_on=cast(datetime, record.created_on),
+    )
+
+
+def _retention_predecessor(
+    session: Session, current: PurgeAuditLog
+) -> PurgeAuditLog | None:
+    """Return the latest row that could unambiguously precede ``current``."""
+    return session.execute(
+        sa.select(PurgeAuditLog)
+        .where(PurgeAuditLog.entity_uuid == current.entity_uuid)
+        .where(PurgeAuditLog.entity_type == current.entity_type)
+        .where(PurgeAuditLog.trigger == TRIGGER_RETENTION)
+        .where(PurgeAuditLog.created_on <= current.created_on)
+        .where(PurgeAuditLog.id != current.id)
+        .order_by(PurgeAuditLog.created_on.desc())
+        .limit(1)
+    ).scalar_one_or_none()

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > For retention audit predecessor handling, preserve the current row when 
the predecessor is pending; do not require strict serialization or locking for 
deduplication because the evidence-preserving behavior is intentional and must 
remain portable across supported databases.
   
   **Applied to:**
     - `superset/commands/deletion_retention/audit.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to