Skip to content

calibration: capture bounded raw context for the remaining isConfiguredGateBlocker codes, excluding secret_leak #8130

Description

@JSONbored

Context

#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.

Requirements

  • Add an exported constant (e.g. RAW_CONTEXT_EXCLUDED_CODES = new Set<string>(["secret_leak"])) near the recordRuleFired call 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).
  • 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.

Links & Resources

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    Status
    Done
    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions