diff --git a/internal/schemavalidators/internal_schemas/aisecuritycontext/ai-security-context-0.1.schema.json b/internal/schemavalidators/internal_schemas/aisecuritycontext/ai-security-context-0.1.schema.json index 6f378114d..311decfd1 100644 --- a/internal/schemavalidators/internal_schemas/aisecuritycontext/ai-security-context-0.1.schema.json +++ b/internal/schemavalidators/internal_schemas/aisecuritycontext/ai-security-context-0.1.schema.json @@ -515,6 +515,11 @@ "retryable": { "type": "boolean", "description": "Whether a later run should re-examine this commit: a transient diff-load, triage, or backend/adjudication failure. Absent (false) for a deterministic hole (oversize diff) or a context written before this field existed." + }, + "attempts": { + "type": "integer", + "minimum": 0, + "description": "How many times triage tried and failed to classify this commit: the agentic large-diff triage for an oversize commit, or the one-shot triage for any other. At the cap the hole stops retrying and retryable becomes false. Absent (0) for a deterministic skip and on contexts written before this field existed." } } }, diff --git a/internal/schemavalidators/schemavalidators_test.go b/internal/schemavalidators/schemavalidators_test.go index d5cd22b0f..bebe7f4b6 100644 --- a/internal/schemavalidators/schemavalidators_test.go +++ b/internal/schemavalidators/schemavalidators_test.go @@ -668,6 +668,38 @@ func TestValidateSecurityContextTriageFields(t *testing.T) { require.NoError(t, schemavalidators.ValidateSecurityContext(payload, "")) }) + t.Run("an unresolved entry carrying a triage attempts count", func(t *testing.T) { + testCases := []struct { + name string + attempts any + wantErr string + }{ + {name: "zero attempts validates", attempts: 0}, + {name: "positive attempts validates", attempts: 2}, + {name: "negative attempts is rejected", attempts: -1, wantErr: "minimum"}, + {name: "fractional attempts is rejected", attempts: 1.5, wantErr: "integer"}, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + payload, scan := load(t) + scan["unresolved"] = []any{map[string]any{ + "sha": "8c948c742bdfc09c4aae6b3c386faeb98f925ff2", + "reason": "triage: provider error", + "retryable": true, + "attempts": tc.attempts, + }} + + err := schemavalidators.ValidateSecurityContext(payload, "") + if tc.wantErr != "" { + require.ErrorContains(t, err, tc.wantErr) + return + } + require.NoError(t, err) + }) + } + }) + t.Run("an unknown unresolved field is still rejected", func(t *testing.T) { payload, scan := load(t) scan["unresolved"] = []any{map[string]any{