You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#8104 (closed, merged) wired recordRuleFired generically for every isConfiguredGateBlocker code except linked_issue_scope_mismatch, but only captured { confidence } (when present) — no raw input. Same limitation #8101 had before its own raw-context follow-up: without it, these codes' corpora can only validate threshold changes (e.g. DEFAULT_AI_REVIEW_CLOSE_CONFIDENCE), never logic/detection changes.
⚠️ Scope: excludes secret_leak deliberately, permanently. Capturing the diff that triggered a secret_leak finding would mean storing the leaked secret itself in the calibration audit trail — a real security regression, not an acceptable tradeoff for backtest coverage. This exclusion must be an explicit, named, exported constant (not an inline if (code !== "secret_leak") buried in a loop) so a future sensitive code can be added to it deliberately, without re-deriving this reasoning from scratch or missing the precedent.
At that same call site, for every finding whose code is NOT in RAW_CONTEXT_EXCLUDED_CODES, extend metadata to include the diff text that produced the finding, bounded to 120000 characters — mirror src/services/ai-review.ts's own input.diff.slice(0, 120000) bound exactly, reuse that number rather than inventing a different one.
For ai_consensus_defect/ai_review_split specifically: the diff is whatever LoopOverAiReviewInput.diff was for the review that produced the finding — thread it from wherever it's already in scope, do not re-fetch or re-derive it.
For the remaining non-excluded codes (missing_linked_issue, duplicate_pr_risk, pre_merge_check_required, manifest_missing_tests, cla_check_unresolved, the review-thread code): capture the same bounded diff text where a diff is genuinely what that code evaluated. Audit each one's own detection function before assuming this — if a specific code's detection doesn't naturally have a diff in scope (e.g. cla_check_unresolved reads a check-run's conclusion, not diff content), record whatever raw signal that code actually evaluated instead of forcing a diff into its metadata.
Deliverables
RAW_CONTEXT_EXCLUDED_CODES (or equivalently named/shaped constant), with secret_leak in it and a comment explaining why.
Raw context captured in metadata for every non-excluded code, per Requirements above (diff for diff-evaluating codes; the real raw signal for any code that isn't diff-based).
A test explicitly confirming secret_leak's fired event NEVER includes diff or other raw content in its metadata, even when it fires with confidence or other fields present — a security-relevant negative test, not optional, not just implied by the exclusion existing.
Tests confirming at least ai_consensus_defect and one non-diff-based deterministic code (if one exists after the audit above) correctly capture their own real raw context.
Test Coverage Requirements
99%+ patch coverage (branch-counted), including the secret_leak exclusion branch as an explicit, separately-asserted test case.
Expected Outcome
Every isConfiguredGateBlocker code's corpus — except secret_leak, by permanent design — becomes rich enough to backtest logic/detection changes, not just threshold changes.
src/services/ai-review.ts (input.diff.slice(0, 120000), the bound to reuse)
src/rules/advisory.ts (isConfiguredGateBlocker — audit every non-excluded code's own detection function before assuming its raw input shape)
Boundaries
secret_leak's exclusion from raw-context capture is permanent, not a temporary gap to fill in later — do not file or accept a future PR that adds diff capture for secret_leak without an explicit, separate, maintainer-reviewed redaction design first.
Context
#8104 (closed, merged) wired
recordRuleFiredgenerically for everyisConfiguredGateBlockercode exceptlinked_issue_scope_mismatch, but only captured{ confidence }(when present) — no raw input. Same limitation #8101 had before its own raw-context follow-up: without it, these codes' corpora can only validate threshold changes (e.g.DEFAULT_AI_REVIEW_CLOSE_CONFIDENCE), never logic/detection changes.Requirements
RAW_CONTEXT_EXCLUDED_CODES = new Set<string>(["secret_leak"])) near therecordRuleFiredcall site calibration: wire recordRuleFired/recordHumanOverride for the remaining isConfiguredGateBlocker codes (excludes linked_issue_scope_mismatch, covered by #8101) #8104 added, with a comment explaining why (mirror this issue's own Context section).codeis NOT inRAW_CONTEXT_EXCLUDED_CODES, extendmetadatato include the diff text that produced the finding, bounded to 120000 characters — mirrorsrc/services/ai-review.ts's owninput.diff.slice(0, 120000)bound exactly, reuse that number rather than inventing a different one.ai_consensus_defect/ai_review_splitspecifically: the diff is whateverLoopOverAiReviewInput.diffwas for the review that produced the finding — thread it from wherever it's already in scope, do not re-fetch or re-derive it.missing_linked_issue,duplicate_pr_risk,pre_merge_check_required,manifest_missing_tests,cla_check_unresolved, the review-thread code): capture the same bounded diff text where a diff is genuinely what that code evaluated. Audit each one's own detection function before assuming this — if a specific code's detection doesn't naturally have a diff in scope (e.g.cla_check_unresolvedreads a check-run's conclusion, not diff content), record whatever raw signal that code actually evaluated instead of forcing a diff into its metadata.Deliverables
RAW_CONTEXT_EXCLUDED_CODES(or equivalently named/shaped constant), withsecret_leakin it and a comment explaining why.metadatafor every non-excluded code, per Requirements above (diff for diff-evaluating codes; the real raw signal for any code that isn't diff-based).secret_leak's fired event NEVER includes diff or other raw content in its metadata, even when it fires withconfidenceor other fields present — a security-relevant negative test, not optional, not just implied by the exclusion existing.ai_consensus_defectand one non-diff-based deterministic code (if one exists after the audit above) correctly capture their own real raw context.Test Coverage Requirements
99%+ patch coverage (branch-counted), including the
secret_leakexclusion branch as an explicit, separately-asserted test case.Expected Outcome
Every
isConfiguredGateBlockercode's corpus — exceptsecret_leak, by permanent design — becomes rich enough to backtest logic/detection changes, not just threshold changes.Links & Resources
src/services/ai-review.ts(input.diff.slice(0, 120000), the bound to reuse)src/rules/advisory.ts(isConfiguredGateBlocker— audit every non-excluded code's own detection function before assuming its raw input shape)Boundaries
secret_leak's exclusion from raw-context capture is permanent, not a temporary gap to fill in later — do not file or accept a future PR that adds diff capture forsecret_leakwithout an explicit, separate, maintainer-reviewed redaction design first.