Skip to content

Commit c99d1f8

Browse files
authored
add operations catalog validation (#722)
Description of changes: - Fix jobs_config.yaml path resolution in ACK workflow - Add validation for operations_catalog structure: - Enforce exactly 5 required keys - Ensure CRUD operations have exactly 1 operation each By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 0ef8bf3 commit c99d1f8

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

prow/agent-workflows/agents/ack_model_agent/prompt.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
2727
A. OPERATION ANALYSIS
2828
- Identify all available operations for the resource
29-
- Classify operations by type (create, read, update, delete, list, tag operations)
29+
- Classify operations by type (create, read, update, delete, tag operations)
3030
- Extract ALL input/output fields for each operation (not just shape names)
3131
- Document complete field structures including nested objects
3232
- Determine required vs optional parameters with constraints
@@ -67,14 +67,12 @@
6767
Create these comprehensive data structures with COMPLETE field analysis:
6868
6969
# Core Operations Inventory
70-
In case there are multiple operations with the same name, choose the one that is most similar to the other operations. Prefer single resource operations over multiple resource operations unless that leads to a mismatch in the field names.
7170
operations_catalog = {
72-
"create_operations": ["CreateRepository", "PutRepository"],
73-
"read_operations": ["GetRepository", "DescribeRepository", "DescribeRepositories"],
74-
"update_operations": ["UpdateRepository", "ModifyRepository"],
71+
"create_operations": ["CreateRepository"],
72+
"read_operations": ["GetRepository"], (prefer "Get" over "Describe")
73+
"update_operations": ["UpdateRepository"],
7574
"delete_operations": ["DeleteRepository"],
76-
"tag_operations": ["TagResource", "UntagResource", "GetTagsForResource"],
77-
"other_operations": ["GetRepositoryPolicy", "SetRepositoryPolicy"]
75+
"tag_operations": ["TagResource", "UntagResource", "GetTagsForResource"]
7876
}
7977
8078
# Field Catalog with Classifications
@@ -220,12 +218,7 @@
220218
4. save_error_catalog(error_catalog, service, resource)
221219
5. save_resource_characteristics(resource_characteristics, service, resource)
222220
223-
5. Report Analysis Summary
224-
- Operations discovered and classified
225-
- Field types and characteristics identified
226-
- Error conditions cataloged
227-
- Resource behavior patterns noted
228-
- Data completeness assessment
221+
5. Report Analysis Summary - Small Summary of the the resource files
229222
230223
Response Format:
231224
1. "Analyzing AWS {service} {resource} resource..."

prow/agent-workflows/agents/ack_model_agent/tools.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,38 @@ def save_operations_catalog(operations_catalog: Dict[str, List[str]], service: s
4848
"""Save comprehensive catalog of all operations related to the resource.
4949
5050
Args:
51-
operations_catalog: Dictionary mapping operation types to lists of operation names
51+
operations_catalog: Dictionary with exactly these 5 keys:
52+
- create_operations: operation that create the resource
53+
- read_operations: operation that read the resource
54+
- update_operations: operation that update the resource
55+
- delete_operations: operation that delete the resource
56+
- tag_operations: List of operations that manage tags on the resource
5257
service: AWS service name (e.g., 's3', 'dynamodb')
5358
resource: Resource name (e.g., 'Bucket', 'Table')
5459
5560
Returns:
5661
str: Confirmation message with file path where catalog was saved
5762
"""
63+
# Validate that operations_catalog has exactly the required 5 keys
64+
required_keys = {"create_operations", "read_operations", "update_operations", "delete_operations", "tag_operations"}
65+
provided_keys = set(operations_catalog.keys())
66+
67+
if provided_keys != required_keys:
68+
missing_keys = required_keys - provided_keys
69+
extra_keys = provided_keys - required_keys
70+
error_msg = f"Operations catalog must have exactly these 5 keys: {required_keys}."
71+
if missing_keys:
72+
error_msg += f" Missing: {missing_keys}."
73+
if extra_keys:
74+
error_msg += f" Extra: {extra_keys}."
75+
return f"Error: {error_msg}"
76+
77+
# Validate that first 4 keys have exactly 1 operation each
78+
single_operation_keys = {"create_operations", "read_operations", "update_operations", "delete_operations"}
79+
for key in single_operation_keys:
80+
if len(operations_catalog[key]) != 1:
81+
return f"Error: {key} must have exactly 1 operation, got {len(operations_catalog[key])}: {operations_catalog[key]}"
82+
5883
ensure_ack_directories()
5984
resource_dir = ensure_service_resource_directories(service, resource)
6085
cache_file = os.path.join(resource_dir, "operations_catalog.json")

prow/agent-workflows/agents/workflows/ack_resource_workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _load_supported_services(self) -> List[str]:
7474
"""Load the list of supported AWS services from jobs_config.yaml."""
7575
try:
7676
# Go up to test-infra root, then to prow/jobs/jobs_config.yaml
77-
config_path = Path(__file__).parent.parent.parent.parent / "prow" / "jobs" / "jobs_config.yaml"
77+
config_path = Path(__file__).parent.parent.parent.parent / "jobs" / "jobs_config.yaml"
7878

7979
with open(config_path, 'r') as f:
8080
config = yaml.safe_load(f)

0 commit comments

Comments
 (0)