Range errors for strength and confidence format numbers differently in TypeScript

Aperta Adatta ai principianti
#379 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
backend, testing

Direzione di ricerca

Leggi typescript/src/validate.ts intorno a requireUnit e confrontane la formattazione con pyRepr in typescript/src/maintenance.ts. Controlla i punti di chiamata della forza della preferenza e della confidenza delle prove indicati nell’issue, quindi esegui i test TypeScript pertinenti per questi messaggi di validazione. Il lavoro è completato quando entrambi gli errori formattano i numeri in notazione esponenziale come Python e come il messaggio esistente di min_relevance.

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

Descrizione

The "must be between 0 and 1" errors for a preference strength and an evidence confidence print the number differently in the two SDKs when it is written in exponent form. AGENTS.md asks for identical error text. TypeScript already prints these numbers the Python way in other messages, such as maintenance.prune(min_relevance=...), so the two TypeScript messages are also inconsistent with each other.

Tested at 04862c4 (current main), Python 3.14 and Node 26.12.

Reproduce
await g.preferences.create("t:a", "k", "t:b", strength=1e16)
await g.preferences.create("t:a", "k", "t:b", strength=-1e-7)
await g.relations.create("t:a", "R", "t:b", evidence=[{"source_id": "s", "confidence": -1e20}])
await g.maintenance.prune(min_relevance=1e16)
call Python TypeScript
strength=1e16 preference strength must be between 0 and 1, got 1e+16 ... got 10000000000000000
strength=-1e-7 ... got -1e-07 ... got -1e-7
confidence=-1e20 evidence confidence must be between 0 and 1, got -1e+20 ... got -100000000000000000000
min_relevance=1e16 min_relevance must be between 0 and 1, got 1e+16 min_relevance must be between 0 and 1, got 1e+16

The code (invalid_argument) is the same; only the message differs, so an agent or a test that matches on the text sees two different errors.

Cause

TypeScript's requireUnit (typescript/src/validate.ts:297) interpolates the raw number (got ${value}), which uses JavaScript's number formatting. The Python side (src/selfgraph/ids.py:180) uses Python's repr form. The TypeScript maintenance checks format the value with pyRepr (requireNumber, typescript/src/maintenance.ts:80), which matches Python. Using the same helper in requireUnit would make the messages identical. requireUnit is used for preference strength (typescript/src/ops.ts:237) and evidence confidence (typescript/src/ops.ts:338, typescript/src/models.ts:367).

Lingua principale
TypeScript
Stelle
173
Fork
58
Merge medio
6h
PR unite (30g)
120

Preparare l'ambiente

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 hydra-db/selfgraph

Tutte le issue di hydra-db/selfgraph

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.