FA-5386 / Integer arithmetic / Open access
Unsigned rotate left · case 01
A logical shift discards bits that must rotate back in.
ROOT CAUSE
A logical shift discards bits that must rotate back in.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return ((n << (k%bits)) | (n >> ((bits-k)%bits))) & ((1<<bits)-1)
Unsuccessful approach: The wrap shift uses k instead of width minus k.
Case contract
Integer arguments; denominators, steps, moduli, and bit widths are positive. Unsigned word inputs fit the specified width except where masking is explicitly the operation. Sequence sizes are nonnegative. n is an unsigned word and k is nonnegative; rotate by k modulo bits. Exact operational definition: ((n << (k%bits)) | (n >> ((bits-k)%bits))) & ((1<<bits)-1)
Why this case matters
Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Integer mathematics results depend on the stated convention.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(n, k, bits):
return (n << k) & ((1<<bits)-1)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (129, 1, 8)', solve(*(129, 1, 8)), 3)
check('fixture 2: (3, 2, 8)', solve(*(3, 2, 8)), 12)
check('fixture 3: (128, 8, 8)', solve(*(128, 8, 8)), 128)
check('fixture 4: (15, 0, 8)', solve(*(15, 0, 8)), 15)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: (129, 1, 8) | 2 | 3 | Failed |
| fixture 2: (3, 2, 8) | 12 | 12 | Passed |
| fixture 3: (128, 8, 8) | 0 | 128 | Failed |
| fixture 4: (15, 0, 8) | 15 | 15 | Passed |
SHA-256 / cdac53d182d99208b6906027ba329e713f7d01ec1ca42e426323dbcac5ea81b4
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(n, k, bits):
return ((n << k) | (n >> k)) & ((1<<bits)-1)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (129, 1, 8)', solve(*(129, 1, 8)), 3)
check('fixture 2: (3, 2, 8)', solve(*(3, 2, 8)), 12)
check('fixture 3: (128, 8, 8)', solve(*(128, 8, 8)), 128)
check('fixture 4: (15, 0, 8)', solve(*(15, 0, 8)), 15)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: (129, 1, 8) | 66 | 3 | Failed |
| fixture 2: (3, 2, 8) | 12 | 12 | Passed |
| fixture 3: (128, 8, 8) | 0 | 128 | Failed |
| fixture 4: (15, 0, 8) | 15 | 15 | Passed |
SHA-256 / 7af9760d086ba58a680b811cd5d812b60d09a5846ae84d0e6eb538d89d10fe10
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(n, k, bits):
return ((n << (k%bits)) | (n >> ((bits-k)%bits))) & ((1<<bits)-1)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (129, 1, 8)', solve(*(129, 1, 8)), 3)
check('fixture 2: (3, 2, 8)', solve(*(3, 2, 8)), 12)
check('fixture 3: (128, 8, 8)', solve(*(128, 8, 8)), 128)
check('fixture 4: (15, 0, 8)', solve(*(15, 0, 8)), 15)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: (129, 1, 8) | 3 | 3 | Passed |
| fixture 2: (3, 2, 8) | 12 | 12 | Passed |
| fixture 3: (128, 8, 8) | 128 | 128 | Passed |
| fixture 4: (15, 0, 8) | 15 | 15 | Passed |
SHA-256 / 4b934a9b15aae3bdcab3fb518504ced755c9da3721086dbd7c7e96b872a11b0a
Verification & scope
This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:37:48.834272+00:00.
Case digest / 6a3d28b6569599679e9d44f3b1cd3551a5b8680ffcdafd6ae5ab8e1570c7f387