fhan688 commented on code in PR #20302:
URL: https://github.com/apache/hudi/pull/20302#discussion_r4281559188


##########
hudi-agent-gateway/skills/hudi-architect/validate_flink_design.py:
##########
@@ -992,6 +1100,109 @@ def assess_design(
                 f"pass-through overrides are not rendered: 
{verified_overrides}",
             )
 
+    if mutable_mor_contract:
+        table_services = _dict(
+            contract.get("table_services"), "table_services", assessment
+        )
+        _check_keys(table_services, {"compaction"}, "table_services", 
assessment)
+        compaction = _dict(
+            table_services.get("compaction"),
+            "table_services.compaction",
+            assessment,
+        )
+        compaction_keys = {
+            "async_enabled",
+            "delta_commits",
+            "mode",
+            "operation_execute_async_enabled",
+            "owner",
+            "schedule_enabled",
+            "trigger_strategy",
+        }
+        tuning_keys = {
+            "delta_seconds",
+            "target_io_mb",
+            "tasks",
+            "timeout_seconds",
+        }
+        unknown_compaction_keys = set(compaction) - compaction_keys
+        if unknown_compaction_keys & tuning_keys:
+            assessment.add(
+                "FLINK_MOR_COMPACTION_TUNING_UNSUPPORTED",
+                "Detailed compaction tuning is outside the bounded Architect 
path: "
+                f"{sorted(unknown_compaction_keys & tuning_keys)}",
+            )
+        remaining_unknown = unknown_compaction_keys - tuning_keys
+        if remaining_unknown:
+            assessment.add(
+                "FLINK_DESIGN_CONTRACT_INVALID",
+                "table_services.compaction contains unsupported fields: "
+                f"{sorted(remaining_unknown)}",
+            )
+        owner = compaction.get("owner")
+        if owner is None:
+            assessment.add(
+                "FLINK_MOR_COMPACTION_OWNER_REQUIRED",
+                "The MOR compaction owner must be explicit",
+            )
+        elif owner == "standalone_service":
+            assessment.add(
+                "FLINK_MULTI_WRITER_REVIEW",
+                "A standalone compactor is an independent table-service 
writer",
+            )
+        elif owner != "flink_writer":
+            assessment.add(
+                "FLINK_WRITER_MODEL_UNRESOLVED",
+                "The MOR compaction owner is unresolved",
+            )
+        expected_compaction = {
+            "async_enabled": True,
+            "delta_commits": 5,
+            "mode": "async",
+            "operation_execute_async_enabled": True,
+            "schedule_enabled": True,
+            "trigger_strategy": "num_commits",
+        }
+        mismatches = [
+            key
+            for key, expected_value in expected_compaction.items()
+            if compaction.get(key) != expected_value
+        ]
+        if mismatches:
+            assessment.add(
+                "FLINK_MOR_COMPACTION_CONFIGURATION_UNSUPPORTED",
+                "The bounded MOR compaction contract has incompatible fields: "
+                f"{mismatches}",
+            )
+
+        read = _dict(contract.get("read"), "read", assessment)
+        _check_keys(
+            read,
+            {"query_modes", "read_optimized_freshness"},
+            "read",
+            assessment,
+        )
+        query_modes = _string_list(read.get("query_modes"), 
"read.query_modes", assessment)
+        allowed_query_modes = {"snapshot", "read_optimized"}
+        if not query_modes or not 
set(query_modes).issubset(allowed_query_modes):
+            assessment.add(
+                "FLINK_MOR_QUERY_REQUIREMENT_UNRESOLVED",
+                "MOR readers must explicitly require snapshot and/or 
read_optimized queries",
+            )
+        read_optimized_freshness = read.get("read_optimized_freshness")
+        if "read_optimized" in query_modes:
+            if read_optimized_freshness != "after_compaction":

Review Comment:
   Thanks for pointing out the distinction. Missing or unknown read-optimized 
freshness now returns `INCOMPLETE` with 
`FLINK_MOR_QUERY_REQUIREMENT_UNRESOLVED`, while an explicit strict freshness 
requirement remains `BLOCKED`. Regression tests cover both cases.



-- 
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]

Reply via email to