Relevance score can reach 1.0, outside the documented [0, 1)

Abierto
#355 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
64/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python, typescript

Línea de trabajo

Read src/selfgraph/_maintenance.py and typescript/src/maintenance.ts, then compare their rounding behavior with the [0, 1) contract in docs/maintenance.md. Reproduce the issue using the values in the report and check how prune(min_relevance=1) behaves. Done means the score and prune behavior match the chosen documented range in both SDKs.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

approved-for-pr area: maintenance bug effort: S P3

docs/maintenance.md says "A score lies in [0, 1)", but relevance_score returns exactly 1.0 once the signal is large and the item is fresh.

Tested at 5a277c9 (current main).

Reproduce
from datetime import datetime, timezone
from selfgraph._maintenance import relevance_score

t = datetime(2020, 1, 1, tzinfo=timezone.utc)
relevance_score([t], t, 30, 999_998)        # 0.999999
relevance_score([t], t, 0.25, 999_999_999)  # 1.0

relevanceScore in typescript/src/maintenance.ts uses the same formula and returns the same 1.

Cause

src/selfgraph/_maintenance.py:68 computes recency * (1 + frequency) / 2 and rounds half up to six decimals. With recency at or near 1 and frequency = signal / (signal + 1) at or above 0.999999 (a signal of about one million or more), the unrounded value is at least 0.9999995, and rounding takes it to 1.0. The signal is the source count plus, for an entity, its degree, so a heavily linked hub entity scored right after a write reaches it.

Impact

prune(min_relevance=...) accepts a threshold up to 1 and removes items whose relevance is below it. With the documented range, min_relevance=1 matches every scored item; in practice an item scored 1.0 is kept. Anything else that relies on the documented upper bound is affected the same way in both SDKs.

Suggested fix

Either cap the rounded score below 1 (for example min(score, 0.999999)) in both SDKs, or change the docs to [0, 1] and the prune description to match.

Lenguaje dominante
TypeScript
Estrellas
173
Forks
58
Merge medio
6 h
PR fusionados (30 d)
120

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de hydra-db/selfgraph

Todos los issues de hydra-db/selfgraph

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.