Skip to content

test(function): consolidate decimal contracts and fix full-scale alignment - #29608

Merged
XuPeng-SH merged 27 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/quality-29249-20261003
Oct 4, 2026
Merged

XuPeng-SH merged 27 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/quality-29249-20261003

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Closes #29607. Refs #29249; the wider test-quality task remains ongoing.

What this PR does / why we need it:

Decimal256 arithmetic could fail when operand scales differed by more than38. Fix all eight fused Add/Sub vector preparations through their existing checked scaling owner, and guard modulo narrowing by its actual scale domain. Preserve representable remainders when intermediate scale alignment overflows.

Successful alignment also exposed an existing high-bit modulo defect: 2e18 % (2^126 × 10^-58) could loop forever, while the 4e18 variant returned the dividend. Replace the shared truncating Decimal256 division with exact unsigned quotient/remainder arithmetic. One-limb divisors reuse the existing native helper; wide division processes at most192 bits without signed comparisons, dividend doubling, or modulo's overflow-prone q*y reconstruction. Formatting uses the same exact native small-divisor helper, including MinInt256. Existing rounded division and scale-overflow modular fallbacks retain their contracts.

Consolidate arithmetic tests around their real owners, retire unused division entrypoints and unreachable Decimal64 fallbacks, and preserve result scale, error, NULL, metadata and cleanup assertions. Remove the unused scale-test error field. Add independent unsigned/signed math/big boundary checks, integer-division consumer checks, masked-output sentinels, and permanent column-backed parser/planner/executor regressions. Extend the existing SQL fixture with five rows for high-bit modulo, signs, NULL and zero divisors.

Validation

Current code, Go1.26.4 on linux/amd64 with verified matching CPU native artifacts:

  • Complete types, function and plan package tests: PASS, no exclusions.
  • Focused raw high-bit division/modulo/formatting, vector zero and NULL policy, widened integer division and public executor regressions: PASS.
  • Incremental gofmt, vet and configured golangci-lint over the three changed Go package closures: PASS. The repository-pinned molint invocation completed with six diagnostics in unchanged unsafe/recover callers; the identical six diagnostics were reproduced on verified clean b92845. No new molint diagnostic was introduced.
  • Normal mo-tester comparison twice on the same ready, test-owned single CN:42/42 each, zero failed/ignored/abnormal. Result metadata is compared; all fixture tables are gone after each run. The test-owned service shut down completely.
  • Separately invoked gpt-6.1-sol / xhigh design and overall implementation review: accepted, with no unresolved material blocker.

Successful native division/modulo remains allocation-free. Matched terminating inputs measured small-divisor modulo around10ns versus23ns before, and representative wide division/modulo around0.2µs versus1.95µs. Common truncating division remains around9–10ns. These are primitive microbenchmarks, not whole-query speedup claims. A fitted scale58 modulo measured529ns with zero allocation; the unchanged scale-overflow fallback measured3.48µs,1440B/31 allocations. Timing varies with host load.

CI is pending and is not claimed green. Historical broader test-consolidation/race evidence belongs to earlier revisions; current validation above covers this final arithmetic correction.

Refs matrixorigin#29249. Reuse canonical result admission and cleanup, preserve all benchmark scenarios, retire duplicate DateFormat setup, and verify real counts and timed error polarity. Local normal, affected race and static checks pass; full-package regexp2 race gate remains open.
Refs matrixorigin#29249. Preserve partial error results, remove duplicate preparation, and verify decimal benchmark literals. Full-package race remains blocked by matrixorigin#29592.
Refs matrixorigin#29249. Retain domain, mask and NULL reuse controls, strengthen valid-row literal assertions. Local normal/race, mutants and incremental static checks passed; independent gpt-6.1-sol xhigh approved local closure. Full-package race gate matrixorigin#29592 remains open.
Refs matrixorigin#29249. Retain literal rows in existing fixtures, replace misleading conversion coverage with three real resolver controls, and retire the unfreed direct comparison path. Normal/race, actual mutants, vet and incremental lint passed; gpt-6.1-sol xhigh approved local closure. Full-package race remains blocked by matrixorigin#29592.
Refs matrixorigin#29249. Preserve four retired function-package method scenarios with independent coefficient and scale oracles, deterministic limb boundaries, and exact overflow contracts. Focused normal/race, mutants, vet and incremental lint passed; gpt-6.1-sol xhigh approved local closure. Inherited Float skip and full-function race matrixorigin#29592 remain open.
Consolidate deterministic Decimal64/128 forward conversion checks, remove the invalid skipped roundtrip, and retain inverse/Scale paths with independent literal results. Whole types normal and race: 213 passed, zero skipped. Incremental vet/lint and three focused helper mutants verified; actual gpt-6.1-sol xhigh local-checkpoint review approved. Raw evidence files were externally removed after checks; terminal results and final independent review are preserved in the QA evidence record. Production comparison defect matrixorigin#29593 remains separate and open. Overall function race remains FAILED under matrixorigin#29592; no push.

Refs matrixorigin#29249
Retain all twelve final/chunk overflow paths and both downscale scenarios in one existing owner. Assert typed errors and independent literal diagnostics, and verify inplace downscaling instead of ignoring its result. Net 75 fewer Go lines with fifteen scalar calls retained. Owning normal/race: 212 passed, zero skipped; incremental vet/molint/golangci pass. Two real mutants survive the old weak tests and fail the strengthened oracles. Actual gpt-6.1-sol xhigh local-checkpoint review approved. Separate Decimal64 signed Scale boundary diagnostic and matrixorigin#29593 remain unresolved; no production change or push. Overall function race matrixorigin#29592 remains failed.

Refs matrixorigin#29249
Move three successful remainder-alignment cases to the existing Mod owner, assert complete values and scales, and add minimal nonzero remainder controls. Retain seven real arithmetic overflow inputs with typed errors and independent original-operand diagnostics. Net 24 fewer Go lines; no new fixtures or UT functions. Whole types normal/race: 212 passed, zero skipped. Incremental vet/molint/lint pass. Three actual mutants survive old smoke tests and fail the new owner oracles. Actual gpt-6.1-sol xhigh final local-checkpoint review approved. Production matrixorigin#29593/matrixorigin#29594 remain unresolved; overall function race matrixorigin#29592 remains failed. No push.

Refs matrixorigin#29249
Retain all 24 parse calls and replace cross-parser formatting comparisons with full typed literal coefficients. Require InvalidInput for all rejected exponents. Two real producer mutants survive the old assertions and fail the new ones.

Validation: types normal and race 212 PASS each, zero skips; vet, molint and incremental golangci-lint pass. Reviewed with gpt-6.1-sol xhigh. Test-only scope needs no BVT; no measured CPU/RSS speedup claim. Overall function race remains blocked by matrixorigin#29592, and matrixorigin#29593/matrixorigin#29594 remain unresolved. Local checkpoint only.

Refs matrixorigin#29249
Retain four scalar calls in the existing owner, replacing the random inverse-only check with independent coefficients and scales. Require the Add overflow class and exact diagnostic; assert the formerly ignored scaled subtraction succeeds with the exact negative coefficient. Retire the separate smoke owner.

Types normal/race: 211 PASS each, zero skips. Vet, molint and incremental lint pass. Two producer mutants survive old assertions and fail new ones. Actual gpt-6.1-sol xhigh review approves this local checkpoint. Test-only change needs no BVT; net -9 lines, no measured CPU/RSS claim. Overall function race matrixorigin#29592 remains unwaived; matrixorigin#29593/matrixorigin#29594 unresolved. No push.

Refs matrixorigin#29249
Retain both existing scalar owners and all four calls. Replace random inverse-only checks with literal independent products, full coefficients, exact scales and explicit successful errors. Preserve the 128-bit high-limb divisor domain and existing boundary/error owners.

Normal/race types: 211 PASS each, zero skips. Vet, molint and incremental lint pass. Both producer mutant variants survive the old two UTs and fail the new two UTs. Actual gpt-6.1-sol xhigh review approves this local checkpoint. Test-only scope needs no BVT; five RNG calls removed, net -3 lines, no measured speedup claim. Overall function race matrixorigin#29592 remains unwaived; matrixorigin#29593/matrixorigin#29594 unresolved. No push.

Refs matrixorigin#29249
Retain eight original scenarios using canonical FunctionTestCase construction, preparation and Free. Register case cleanup before evaluation, check native and heap accounts after every child and before Process.Free, and assert exact values/types/NULL/error classes instead of accepting either outcome. Net -112 lines; no production or fixture framework changes.

Focused normal/race: two UTs and eight children each, zero skips. Vet and configured incremental lint exit0; molint exit0 with two unsafe-import diagnostics in files byte-identical to baseline f1137a6, no new unsafe diagnostic. Both real producer mutants survive old assertions and fail only intended new assertions, with cleanup checks intact. Old mutant executions retain112 native+344 heap bytes, not a clean-baseline CPU/RSS measurement. Actual gpt-6.1-sol xhigh approves local checkpoint. No BVT needed for test-only closure. Overall function race matrixorigin#29592 remains FAILED/unwaived; matrixorigin#29593/matrixorigin#29594 unresolved; no push.

Refs matrixorigin#29249
Preserve all ten format evaluations with thirteen deterministic rows, canonical cleanup, and exact per-row comparisons. Refs matrixorigin#29249.
Reuse the canonical case owner for 27 deterministic dispatch evaluations, preserving copy and checked conversion while strengthening values, NULL, metadata and typed error checks. Refs matrixorigin#29249.
Reuse canonical kernel owners, retire 15 overlapping wrappers, and preserve independent boundary, rounding, NULL continuation, overflow and zero-policy witnesses. Production and shared framework remain unchanged.

Refs matrixorigin#29249. Focused normal/race and incremental static validation pass. Ten producer variants are rejected by 26 semantic assertions. Three controlled pairs measure lower selected test-body CPU and Go allocation. Full function race remains failed under matrixorigin#29592; this is a local non-final checkpoint.
Preserve independent coefficient, NULL, overflow and cleanup assertions with smaller fixtures. Retain four known-failing scale39 regressions as explicit local checkpoint blockers; this is not an all-green delivery.
Reuse checked chunked scaling beyond the two-factor domain and admit modulo narrowing only when its scale difference is bounded. Preserve fused loops, NULL masks, overflow errors and modulo recovery.

Cover raw, planner/executor and SQL frontend boundaries with exact coefficient oracles and declared precision errors. Refs matrixorigin#29249.
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@LeftHandCold LeftHandCold left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 21f711a7b852238394417e547282e14dce8660d9 → 99a79815a7984fbf285d20b8c5d28d8b46cd6d1a. No blocking findings.

  • Checked the unsigned Decimal256 quotient/remainder invariant, high-bit and minimum-signed-magnitude consumers, zero-divisor behavior, and formatting. The wide-divisor loop is bounded and preserves the one-limb fast path.
  • Traced full-scale alignment through scalar/vector add, subtract and modulo, including scale gaps above 38. Checked overflow, sign restoration, NULL and strict/permissive divide-by-zero behavior, and the bounds that make the removed Decimal64 fallbacks unreachable.
  • Reviewed all 27 changed files, including removed-test mappings, independent result/error/metadata assertions, public SQL coverage, and fixture admission/reset/cleanup ownership.

Validation: reused the verified exact-head CI run. Required CI passed, including Ubuntu UT, arm64 SCA, shared build and both active compose BVT jobs. UT logs confirm successful race runs covering types and function, and all eight planner shards passed. The pessimistic BVT log reports decimal_256_literal.test: 42/42 passed, with no failures, ignored cases or abnormal results. Local git diff --check also passed. MO package tests/BVT were not duplicated locally; skipped optional CI jobs were not treated as passes.

@XuPeng-SH
XuPeng-SH merged commit c3fbe9c into matrixorigin:main Oct 4, 2026
@XuPeng-SH
XuPeng-SH deleted the codex/quality-29249-20261003 branch October 4, 2026 17:20

This branch was previously deployed

1 inactive deployment
ci — 8e5c0bde Deployed Oct 4, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/refactor Code refactor kind/test-ci size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Decimal256 vector alignment and modulo panic beyond 38-digit scale differences

3 participants