Repository navigation
Add deterministic fixed-decimal SQL aggregation compiler - #347
Draft
seyoung4503 wants to merge 4 commits into
Draft
seyoung4503 wants to merge 4 commits into
seyoung4503 wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A prior Spider execution produced 6.47 instead of 6.48 for a requested two-decimal average because ROUND(AVG(...)) rounded a binary floating-point midpoint. Add a reusable SQLite fixed-decimal AVG/SUM compiler. It accepts explicitly scaled integers, uses integer quotient/remainder for half-away-from-zero rounding after aggregation, and emits plain SQL CTEs. Noninteger inputs and conservative overflow bounds invalidate the whole group; NULL inputs follow aggregate exclusion.
The tool is registered in the existing internal and MCP runtimes and read-only benchmark whitelist. It performs no DB access, chooses no source precision/currency conversion, and still requires guarded run_sql execution. After the tool-only attempt failed because the model did not call the tool, the existing numeric-result guidance bullet was updated to route known fixed-scale aggregates to the compiler after source precision checks. Gold references and graders are unchanged. Scales 0–6 and a conservative exact-integer bound are explicit limitations; rounded_units remains integer and rounded_value is its REAL representation.
Validation: 339 root tests passed, 1 skipped. Tests cover grouped seeded comparisons with Decimal for AVG/SUM at five scale combinations, signed midpoint ties, NULLs, invalid types, unsafe magnitude, invalid compiler parameters, and actual MCP stdio execution. Ruff and diff checks pass (the system-prompt module has a pre-existing BLE001 violation excluded from this scoped lint run). No CODE MAP generator exists. The tool-only Astra/high retry of local152 scored 0/1 and did not call fixed_decimal_sql; all failure artifacts and an offline Decimal diagnosis are preserved. The second fresh original-input retry with compiler-use guidance scored 1/1 (local152 0 → 1). It independently checked one-decimal source precision, called fixed_decimal_sql, executed the emitted CTEs to verify all 3,603 director groups had status=ok and zero invalid inputs, then wrote a shorter integer-rounding final SQL for the verified positive ratings. The final SQL was not a verbatim compiler copy. Its two midpoint values changed 6.47→6.48 and 6.22→6.23. Exact prompts, events, SQL, CSV, scores, paired comparisons and SHA-256 indexes for both attempts are archived under
bench/accuracy/mcp-review-results/fixed-decimal*. A single successful attempt does not establish repeated reliability or broader regression freedom. Neither is a full benchmark score. Calendar tooling from parent #346 is retained, so changes from the older baseline are not a single-factor ablation. Stacked PR; no merge requested.