Skip to content

fix(worker): reject NaN in float checker - #76

Closed
sainimal1ba-hue wants to merge 4 commits into
stjosephsplacements:developmentfrom
sainimal1ba-hue:float-checker-nan
Closed

sainimal1ba-hue wants to merge 4 commits into
stjosephsplacements:developmentfrom
sainimal1ba-hue:float-checker-nan

Conversation

@sainimal1ba-hue

@sainimal1ba-hue sainimal1ba-hue commented Oct 21, 2026 •

Copy link
Copy Markdown

Summary

Fix an incorrect Accepted verdict in the floating-point output checker when either output contains NaN.

Motivation

strconv.ParseFloat recognizes NaN as a valid floating-point value. However, the existing epsilon comparison does not detect mismatches involving NaN, because comparisons involving NaN return false.

Consequently, a submission can incorrectly receive an Accepted verdict even when its numeric output is invalid.

Implementation notes

Added an explicit math.IsNaN check before applying epsilon comparison.

The change preserves existing behavior for ordinary floating-point values, infinity values, and nonnumeric tokens. It introduces no dependencies or API changes.

Questions for the reviewer

Q1 — What existing tests cover the code you changed?

A: The existing TestJudgeFloat test in internal/worker/judge_test.go covers finite floating-point comparisons, epsilon tolerance, token counts, and nonnumeric tokens.

Q2 — What new tests did you add, and what cases do they cover?

A: Added TestJudgeFloatRejectsNaN, covering NaN in expected output, actual output, both outputs, and later tokens. The test also checks infinity handling and an ordinary finite comparison.

Q3 — Does this change affect any authenticated or unauthenticated API paths? If yes, how?

A: It does not change authentication, routing, or API contracts. It corrects floating-point judging behavior for submitted executions regardless of caller authentication.

Q4 — Did you run golangci-lint run locally and get 0 issues?

A: [Fill in your actual result after running lint.]

Q5 — Is this the only open PR you have against development?

A: [Confirm your actual PR status.]

Checklist

  • go test -race -count=1 -timeout=120s ./... passes locally
  • golangci-lint run --timeout=5m reports 0 issues
  • gofmt -s -l . reports no unformatted files
  • All five reviewer questions are answered
  • No secrets or credentials included
  • No new dependencies
  • Related issue linked, if applicable

Summary by CodeRabbit

  • Bug Fixes
    • Float-based output comparisons now reject NaN values as incorrect answers.
    • Comparisons involving positive infinity continue to follow expected matching and mismatch behavior.
    • Valid numeric comparisons continue to use the configured tolerance.
  • Tests
    • Added coverage for NaN, infinity, later-token mismatches, and normally matching float outputs.

Add NaN checks for expected and actual values in judge function.

Signed-off-by: a12san <sainimal1ba@gmail.com>
Signed-off-by: a12san <sainimal1ba@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: stjosephsplacements/AetherCode-Execution-Engine/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e332ff1a-5c16-4b72-bee3-f20e9f7900b7
📥 Commits

Reviewing files that changed from the base of the PR and between 3daee54 and f47ec93.

📒 Files selected for processing: 2
  • internal/worker/judge.go
  • internal/worker/judge_nan_test.go
💤 Files with no reviewable changes: 1
  • internal/worker/judge.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Float output judging now returns WrongAnswer when either parsed value is NaN. Tests cover NaN inputs, infinity comparisons, and matching regular floats.

Changes

Float output judging

Layer / File(s) Summary
NaN rejection and float verdict tests
internal/worker/judge.go, internal/worker/judge_nan_test.go
judgeFloat rejects NaN values before applying the epsilon comparison. Table-driven tests cover NaN, matching and differing infinities, and regular float values.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to f47ec

The change correctly rejects NaN float outputs while preserving existing comparison behavior, with no identified merge-blocking risk.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the change, motivation, implementation, tests, and affected API paths. Q4 and Q5 still contain placeholders, so two required reviewer questions are unanswered. The checklist a… Replace the Q4 and Q5 placeholders with the actual lint result and confirmation of open PR status. Update the checklist to reflect the completed answers. Add a related issue number after “Closes #” or confirm that no issue applies, accordin…
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: rejecting NaN values in the worker float checker.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the change, motivation, implementation, tests, and affected API paths. Q4 and Q5 still contain placeholders, so two required reviewer questions are unanswered. The checklist also incorrectly marks all questions as answered.

Resolution

Replace the Q4 and Q5 placeholders with the actual lint result and confirmation of open PR status. Update the checklist to reflect the completed answers. Add a related issue number after “Closes #” or confirm that no issue applies, according to repository policy.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 21, 2026
@sainimal1ba-hue

Copy link
Copy Markdown
Author

fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant