Skip to content

fix(run): fidelity readout never rounds a near-unity F to a bare 1 - #96

Merged
kateebonner merged 1 commit into
local/amicodefrom
kate/run-fidelity-precision
Jul 28, 2026
Merged

fix(run): fidelity readout never rounds a near-unity F to a bare 1#96
kateebonner merged 1 commit into
local/amicodefrom
kate/run-fidelity-precision

Conversation

@kateebonner

Copy link
Copy Markdown
Contributor

What

formatFidelity (problem.ts) rendered with toFixed(4), so any $F \geq 0.99995$ displayed as a flat "F = 1" in the run chip, the ring-2 Run hero, and the Run modal — Kate hit this today on a transmon X-gate solve that finished at F ≈ 1 but almost certainly not exactly 1.

How

Adaptive precision in the one shared formatter: ordinary values keep the 4-decimal form (existing renders unchanged — F=0.9998 · 60 iter, solving… F=0.968), but when rounding would collapse the value to exactly 1 or 0, precision extends one digit at a time (capped at 10) until the gap survives. Only a true 1/0 renders bare. The gap from perfect is the result; the display must never erase it.

Applies automatically to every consumer of runChipText/runVerdict — chip, hero, modal.

Verification

  • bun test src/amicode/problem.test.ts: 34 pass, including new near-unity cases (0.99997 → F=0.99997, 0.99999997 → F=0.99999997, solving f=3e-5 → F=0.99997, true 1 → F=1)
  • npm run lint: 0 errors; tsgo -b in packages/app: clean

🤖 Generated with Claude Code

formatFidelity's toFixed(4) collapsed any F ≥ 0.99995 to "1" in the run
chip, ring-2 Run hero, and Run modal — hiding exactly the number that
matters. Precision now extends a digit at a time (cap 10) until the gap
from 1 (or 0) survives rounding; ordinary values keep the 4-decimal form
and only a true 1 renders bare.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kateebonner
kateebonner requested a review from Rchari1 July 28, 2026 23:12
@kateebonner
kateebonner merged commit e0105cd into local/amicode Jul 28, 2026
1 of 4 checks passed
@kateebonner
kateebonner deleted the kate/run-fidelity-precision branch July 28, 2026 23:58
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.

1 participant