Skip to content

Commit a7a0f2a

Browse files
committed
fix: address bugbot findings (round 4)
- Preserve top-level $ref in refsUsed when composition branch is taken, so computeDependencyDepths correctly tracks cross-operation schema sharing for oneOf/anyOf/allOf/discriminator schemas - Return constraintClarity=1 when totalSchemaProperties is 0, matching errorClarity's "no data" pattern — avoids unfairly penalizing DELETE and binary-returning endpoints that have no schema properties Made-with: Cursor
1 parent fdb8c94 commit a7a0f2a

4 files changed

Lines changed: 14 additions & 8 deletions

File tree

packages/cli/src/commands/score/collect-metrics.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ export function collectMetrics({
211211
if (allOfStats) result = addStats(result, allOfStats);
212212
if (polyStats) result = addStats(result, polyStats);
213213
if (discStats) result = addStats(result, discStats);
214+
215+
if (ref) {
216+
result = { ...result, refsUsed: [ref, ...result.refsUsed] };
217+
}
214218
} else {
215219
result = walkSchemaRaw(schemaNode, debug);
216220
}

packages/cli/src/commands/score/scoring.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ export function computeOperationSubscores(
3131
const descTotal = 1 + metrics.parameterCount + metrics.totalSchemaProperties;
3232
const documentationQuality = descTotal > 0 ? clamp01(descCount / descTotal) : 1;
3333

34-
const propCount = metrics.totalSchemaProperties || 1;
35-
const constraintClarity = clamp01(metrics.constraintCount / propCount);
34+
const constraintClarity =
35+
metrics.totalSchemaProperties > 0
36+
? clamp01(metrics.constraintCount / metrics.totalSchemaProperties)
37+
: 1;
3638

3739
const examplePoints =
3840
(metrics.requestExamplePresent ? 1 : 0) + (metrics.responseExamplePresent ? 1 : 0);

tests/e2e/score/score-json/snapshot.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"parameterSimplicity": 0.8625,
66
"schemaSimplicity": 0.796875,
77
"documentationQuality": 0.9017857142857143,
8-
"constraintClarity": 0.4375,
8+
"constraintClarity": 0.5625,
99
"exampleCoverage": 0.875,
1010
"errorClarity": 1,
1111
"dependencyClarity": 0.7291666666666669,
@@ -309,12 +309,12 @@
309309
}
310310
},
311311
"getTicketCode": {
312-
"agentReadiness": 69,
312+
"agentReadiness": 81,
313313
"subscores": {
314314
"parameterSimplicity": 0.9,
315315
"schemaSimplicity": 1,
316316
"documentationQuality": 1,
317-
"constraintClarity": 0,
317+
"constraintClarity": 1,
318318
"exampleCoverage": 0,
319319
"errorClarity": 1,
320320
"dependencyClarity": 1,
@@ -338,7 +338,7 @@
338338
"path": "/tickets/{ticketId}/qr",
339339
"method": "get",
340340
"operationId": "getTicketCode",
341-
"agentReadinessScore": 69,
341+
"agentReadinessScore": 81,
342342
"reasons": [
343343
"Missing response examples"
344344
]

tests/e2e/score/score-stylish/snapshot.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Parameter Simplicity [█████████████████░░░] 86%
99
Schema Simplicity [████████████████░░░░] 80%
1010
Documentation Quality [██████████████████░░] 90%
11-
Constraint Clarity [█████████░░░░░░░░░░░] 44%
11+
Constraint Clarity [███████████░░░░░░░░░] 56%
1212
Example Coverage [██████████████████░░] 88%
1313
Error Clarity [████████████████████] 100%
1414
Dependency Clarity [███████████████░░░░░] 73%
@@ -30,7 +30,7 @@
3030
Top 1 Hotspot Operations
3131

3232
GET /tickets/{ticketId}/qr (getTicketCode)
33-
Agent Readiness: 69.0
33+
Agent Readiness: 81.0
3434
- Missing response examples
3535

3636

0 commit comments

Comments
 (0)