Skip to content

feat: severity-weighted safety score and attack success rate#197

Merged
jithin23-kv merged 1 commit into
masterfrom
feat/severity-weighted-scores
Jul 14, 2026
Merged

feat: severity-weighted safety score and attack success rate#197
jithin23-kv merged 1 commit into
masterfrom
feat/severity-weighted-scores

Conversation

@arunSunnyKVS

@arunSunnyKVS arunSunnyKVS commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Problem

The current safetyScore and attackSuccessRate in the report summary treat every attack with equal weight, regardless of the evaluator's severity. A FAIL on a low severity evaluator (e.g. ambiguous helpfulness) has the same impact on the headline score as a FAIL on a critical severity evaluator (e.g. full PII dump), misrepresenting the actual risk posture.

Solution

Introduce severity-based weights so critical failures dominate the headline scores:

Severity Weight
critical 4
high 3
medium 2
low 1

Each attack's contribution to safetyScore and attackSuccessRate is scaled by its evaluator's severity weight. The raw total/passed/failed/errors counts remain unweighted for transparency.

Changes

  • core/src/execute/aggregate.ts — added SEVERITY_WEIGHTS map, severityWeight() helper, and computeWeightedScores() function; updated buildUnifiedReport() to use weighted scores
  • runners/extension/popup.js — added the same severity weight logic to the browser extension's parallel score calculation in buildReport()

Issue

Closes #196

How to test

  1. npm run build && npm test — all 159 tests pass (existing buildUnifiedReport test uses a single severity band, so weighted = unweighted)
  2. Run against a test agent with mixed-severity evaluators:
    opfor run --config tests/e2e/agents/vanilla-chat/opfor.config.json
  3. Check the JSON report — summary.safetyScore and summary.attackSuccessRate now reflect severity weighting. When results are mixed across severity bands, critical FAILs will pull the score down more than low FAILs.

Screenshots

N/A — no visual changes; the scores are computed identically, just weighted.

Made with Cursor

Summary by CodeRabbit

  • Improvements
    • Report safety scores and attack success rates now use severity-weighted results, giving greater influence to critical and high-severity findings.
    • Overall totals for passed, failed, and errors are preserved and shown alongside the new severity-weighted scores.
    • Scoring behavior is aligned across generated reports and the browser extension for consistent results.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: faeecc2c-6ffa-49b9-b014-ba6a1601a144

📥 Commits

Reviewing files that changed from the base of the PR and between e8fef48 and bcdf5e9.

📒 Files selected for processing (2)
  • core/src/execute/aggregate.ts
  • runners/extension/popup.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/src/execute/aggregate.ts
  • runners/extension/popup.js

Walkthrough

Report headline scores now weight PASS and FAIL attack results by evaluator severity in both core aggregation and the browser extension, while raw total, passed, failed, and error counts remain unweighted.

Changes

Severity-weighted scoring

Layer / File(s) Summary
Core weighted scoring
core/src/execute/aggregate.ts
Adds severity weights and weighted score calculation while preserving unweighted report counts.
Extension scoring parity
runners/extension/popup.js
Updates browser extension scoring to use severity-weighted PASS and FAIL ratios.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant EvaluatorResults
  participant computeWeightedScores
  participant buildUnifiedReport
  EvaluatorResults->>computeWeightedScores: supply verdicts and evaluator severities
  computeWeightedScores->>buildUnifiedReport: return weighted headline scores
  buildUnifiedReport->>buildUnifiedReport: retain unweighted verdict counts
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: severity-weighted safety and attack success scoring.
Description check ✅ Passed The description follows the template and includes problem, solution, changes, issue, testing, and screenshots sections.
Linked Issues check ✅ Passed The PR matches #196 by adding severity-based weighting in core and extension while preserving unweighted counts.
Out of Scope Changes check ✅ Passed The changes stay within the scoring update scope and only touch the two expected files.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/severity-weighted-scores

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Each attack's contribution to safetyScore and attackSuccessRate is now
scaled by its evaluator's severity weight (critical=4, high=3, medium=2,
low=1), so critical failures dominate the headline report scores.
The unweighted passed/failed/errors counts are preserved for transparency.

Closes #196

Co-authored-by: Cursor <cursoragent@cursor.com>
@arunSunnyKVS arunSunnyKVS force-pushed the feat/severity-weighted-scores branch from e8fef48 to bcdf5e9 Compare July 14, 2026 06:17
@jithin23-kv jithin23-kv merged commit b207c86 into master Jul 14, 2026
8 checks passed
@jithin23-kv jithin23-kv deleted the feat/severity-weighted-scores branch July 14, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: severity-weighted safety score and attack success rate

2 participants