forked from ChuyueSun/VeriStruct
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_timeout_implementation.py
More file actions
182 lines (142 loc) · 4.85 KB
/
Copy pathverify_timeout_implementation.py
File metadata and controls
182 lines (142 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/env python3
"""
Quick verification script for repair round timeout implementation.
Checks that all necessary components are in place.
"""
import json
import sys
from pathlib import Path
def verify_config():
"""Verify config has the timeout parameter."""
config_path = Path("src/configs/config-azure.json")
if not config_path.exists():
print(f"❌ Config file not found: {config_path}")
return False
with open(config_path) as f:
config = json.load(f)
if "repair_round_timeout" in config:
timeout = config["repair_round_timeout"]
print(f"✓ Config has repair_round_timeout: {timeout}s")
return True
else:
print("❌ Config missing repair_round_timeout parameter")
return False
def verify_main_py():
"""Verify main.py uses the timeout."""
main_path = Path("src/main.py")
if not main_path.exists():
print(f"❌ Main file not found: {main_path}")
return False
content = main_path.read_text()
checks = [
("repair_round_timeout = config.get", "Extract timeout from config"),
("round_timeout=repair_round_timeout", "Pass timeout to repair_all"),
("round_start_time=repair_round_start", "Pass start time to repair_all"),
]
all_passed = True
for check_str, description in checks:
if check_str in content:
print(f"✓ main.py: {description}")
else:
print(f"❌ main.py missing: {description}")
all_passed = False
return all_passed
def verify_repair_registry():
"""Verify repair_registry.py has timeout checks."""
registry_path = Path("src/modules/repair_registry.py")
if not registry_path.exists():
print(f"❌ Registry file not found: {registry_path}")
return False
content = registry_path.read_text()
checks = [
("round_timeout: Optional[float]", "Timeout parameter in repair_all"),
("round_start_time: Optional[float]", "Start time parameter in repair_all"),
("def check_round_timeout():", "Timeout check helper function"),
("check_round_timeout()", "Timeout check calls"),
]
all_passed = True
for check_str, description in checks:
if check_str in content:
print(f"✓ repair_registry.py: {description}")
else:
print(f"❌ repair_registry.py missing: {description}")
all_passed = False
# Count timeout check calls
check_count = content.count("check_round_timeout()")
if check_count >= 4:
print(f"✓ repair_registry.py: {check_count} timeout checks (≥4 expected)")
else:
print(f"⚠ repair_registry.py: Only {check_count} timeout checks (4+ recommended)")
return all_passed
def verify_docs():
"""Verify documentation exists."""
docs = [
"docs/repair_round_timeout.md",
"REPAIR_ROUND_TIMEOUT_IMPLEMENTATION.md",
"examples/repair_round_timeout_comparison.md",
]
all_exist = True
for doc in docs:
doc_path = Path(doc)
if doc_path.exists():
print(f"✓ Documentation: {doc}")
else:
print(f"❌ Documentation missing: {doc}")
all_exist = False
return all_exist
def verify_tests():
"""Verify test file exists."""
test_path = Path("tests/test_repair_round_timeout.py")
if not test_path.exists():
print(f"❌ Test file not found: {test_path}")
return False
print(f"✓ Test file exists: {test_path}")
return True
def main():
print("=" * 70)
print("REPAIR ROUND TIMEOUT IMPLEMENTATION VERIFICATION")
print("=" * 70)
print()
results = []
print("1. Configuration File")
print("-" * 70)
results.append(verify_config())
print()
print("2. Main Entry Point (main.py)")
print("-" * 70)
results.append(verify_main_py())
print()
print("3. Repair Registry (repair_registry.py)")
print("-" * 70)
results.append(verify_repair_registry())
print()
print("4. Documentation")
print("-" * 70)
results.append(verify_docs())
print()
print("5. Test Suite")
print("-" * 70)
results.append(verify_tests())
print()
print("=" * 70)
if all(results):
print("✅ ALL VERIFICATIONS PASSED")
print("=" * 70)
print()
print("Repair round timeout is properly implemented!")
print()
print("Configuration:")
print(" - Default timeout: 900 seconds (15 minutes)")
print(" - Config location: src/configs/config-azure.json")
print()
print("To test:")
print(" python tests/test_repair_round_timeout.py")
print()
return 0
else:
print("❌ SOME VERIFICATIONS FAILED")
print("=" * 70)
print("Please review the failed checks above.")
return 1
if __name__ == "__main__":
sys.exit(main())