SUBTASK #63: Calculate confidence score (2.2.4.3)

Aperta
#67 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Edgeless6 ci sta già lavorando.

Dal 30/10/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
1
Fork
1
Merge medio
9h 31m
PR unite (30g)
36

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Bearkat-Professionals/Software-Engineering-Project

Tutte le issue di Bearkat-Professionals/Software-Engineering-Project

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.