Skip to content

Commit 7b388c3

Browse files
Address code review feedback for GATE-004
- Removed duplicate conflict tracking (use only checker.conflicts) - Record all conflict pairs for 3+ duplicates (not just first two) - Improved finding message to include occurrence count - Tested with 3-way duplicate scenario Co-authored-by: AmedeoPelliccia <164860269+AmedeoPelliccia@users.noreply.github.com>
1 parent 8c33add commit 7b388c3

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

scripts/check_ata99_registry.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -266,24 +266,19 @@ def run_gate_004(db_path: str = "plc_ontology.db", directory: Path = Path('.'))
266266
for entry in entries:
267267
namespace_to_paths[entry.namespace_id].append(entry.artifact_path)
268268

269-
conflicts = []
270269
for namespace_id, paths in namespace_to_paths.items():
271270
if len(paths) > 1:
272-
# Record conflict
273-
conflict_id = checker.db.record_namespace_conflict(
274-
namespace_id=namespace_id,
275-
artifact_path_1=paths[0],
276-
artifact_path_2=paths[1],
277-
conflict_type='DUPLICATE_ID'
278-
)
279-
conflicts.append({
280-
'conflict_id': conflict_id,
281-
'namespace_id': namespace_id,
282-
'count': len(paths),
283-
'paths': paths
284-
})
271+
# Record all conflicts in the database (for 3+ duplicates, record multiple conflict pairs)
272+
for i in range(len(paths) - 1):
273+
checker.db.record_namespace_conflict(
274+
namespace_id=namespace_id,
275+
artifact_path_1=paths[i],
276+
artifact_path_2=paths[i + 1],
277+
conflict_type='DUPLICATE_ID'
278+
)
279+
280+
# Add to checker's conflict list (used for reporting)
285281
checker.conflicts.append({
286-
'conflict_id': conflict_id,
287282
'namespace_id': namespace_id,
288283
'count': len(paths),
289284
'paths': paths
@@ -299,23 +294,23 @@ def run_gate_004(db_path: str = "plc_ontology.db", directory: Path = Path('.'))
299294
execution_time_ms = int((time.time() - start_time) * 1000)
300295

301296
# Record gate run in database
302-
passed = len(conflicts) == 0
297+
passed = len(checker.conflicts) == 0
303298
run_id = checker.db.record_gate_run(
304299
gate_code='GATE-004',
305300
passed=passed,
306-
error_count=len(conflicts),
301+
error_count=len(checker.conflicts),
307302
warning_count=0,
308303
execution_time_ms=execution_time_ms,
309304
metadata=report
310305
)
311306

312307
# Record findings
313-
for conflict in conflicts:
308+
for conflict in checker.conflicts:
314309
checker.db.record_gate_finding(
315310
run_id=run_id,
316311
gate_code='GATE-004',
317312
severity='ERROR',
318-
message=f"Duplicate namespace ID: {conflict['namespace_id']}",
313+
message=f"Duplicate namespace ID: {conflict['namespace_id']} ({conflict['count']} occurrences)",
319314
finding_code='NAMESPACE_DUPLICATE',
320315
details=conflict
321316
)

0 commit comments

Comments
 (0)