SUBTASK #63: Calculate confidence score (2.2.4.3)

Open
#67 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@Edgeless6 is already working on this.

Since Oct 30, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
70/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start with the evidence weights and shared evidence record from #64, then read conflict resolution in #66 for Resolution.kept and count_points. Implement backend/services/scan/calculate_score.py and cover the listed cases in tests/services/scan/test_calculate_score.py. Done means the breakdown traces points to retained evidence, contributions use a fixed order, and the score stays between 0 and 100.

Written by the indexing model from the issue text.

Description

backend Medium Priority subtask

What to do

A pure function that turns the evidence kept by conflict resolution into a 0–100 confidence score, together with a breakdown showing exactly which evidence earned which points, so every part of the score traces to stored evidence (spec 7.1).

Background

  • Spec 7.1: the score comes from the evidence stored for the device, runs from 0% to 100%, and "every part of a score shall trace to stored evidence."
  • System design 2.2.4.3: "Sum the weights of retained evidence into 0% to 100%."
  • Spec FR-10, OUT-02 (a score per device, with the evidence that produced it) and DI-08 (0 to 100).
  • The input is Resolution.kept from #66, so dropped (conflicting) evidence is never scored.
  • The counting rule (count_points, each evidence type once) and MAX_SCORE are in evidence.py (#64, #66).
  • Rules are in #63.

Steps

  • ScoreBreakdown record in calculate_score.py:
    • score: the final 0–100 whole number
    • contributions: one entry per evidence type, with the points it added and the evidence behind it
    • capped: True when the points added up to more than MAX_SCORE
  • calculate_score(kept) -> ScoreBreakdown, pure:
    • Points come from count_points, the same function conflict resolution uses
    • The score is those points, capped at MAX_SCORE
    • No evidence gives a score of 0, not an error
    • Contributions come back in a fixed order (by evidence type), so the device detail page always lists them the same way
  • Unit tests:
    • No evidence: 0
    • OUI evidence only: the OUI weight (20 with the agreed weights)
    • Different evidence types add up
    • Several pieces of one evidence type count once, and the breakdown lists all of them under that type
    • More than 100 points: the score is 100 and capped is True
    • The contributions always add up to the uncapped points: nothing in the score comes from nowhere
    • Built from a Resolution, dropped evidence adds nothing
    • Over many generated evidence sets, the score is always a whole number from 0 to 100

Where

  • backend/services/scan/calculate_score.py
  • tests/services/scan/test_calculate_score.py

Done when

  • All the tests above pass without a database or network
  • The score can't go outside 0 to 100, whatever evidence comes in

Depends on

  • Evidence weights and the shared evidence record (#64)
  • Resolve conflicting evidence (#66), for count_points and Resolution
Dominant language
Python
Stars
1
Forks
1
Avg merge
9h 31m
Merged PRs (30d)
36

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Bearkat-Professionals/Software-Engineering-Project

All issues in Bearkat-Professionals/Software-Engineering-Project

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.