A counter falls from 5 to 4, yet its computed difference is positive 255. The array has the expected shape, the readings remain in their original order, and the calculation returns a normal integer array. A check that merely requires successful execution or nonnegative output can therefore approve the wrong subtraction.
The synthetic readings in this playbook are [5, 4, 255, 0], stored as uint8. Their exact adjacent differences are [-1, 251, -255]. The supplied commissioning run instead observed [255, 251, 1] from native np.diff. The operational question is precise: does each retained result equal the mathematical subtraction of its two identified source readings?
Answering that question requires qualifying representation before interpreting the counter. A signed conversion before subtraction repairs the small fixture. A conversion afterward does not. Larger controls show why neither int64 nor float64 is a universal replacement: the former cannot represent every uint64 operand, while the latter can erase a unit change.
The following laboratory preserves the source, checks thirteen cases, and reconciles every interval against an independent Python-integer reference. It supports bounded arithmetic acceptance and a repair plan for derived outputs. It does not identify a physical reset, rollover, or ordering error. Those conclusions need evidence from the counter's domain owner. Until that evidence exists, an exact negative delta can be accepted as arithmetic while its operational interpretation remains on hold.
Define the exact difference before interpreting the counter
Define the transformation over one ordered, one-dimensional sequence. For every interval ri→ri+1, the required result is int(ri+1) - int(ri), with each operand converted independently before subtraction. An input containing n readings contributes exactly n-1 adjacent intervals. The first interval joins positions zero and one; the final interval joins positions n-2 and n-1.
Here, the identifiers r0, r1, r2, and r3 belong permanently to the four authored readings. They are part of the expected-answer manifest. Array position supplies the declared order for this laboratory; it does not establish that an arbitrary telemetry file is chronologically trustworthy.
NumPy's first-order difference contract defines subtraction of the earlier element from the following element and explicitly documents unsigned output for unsigned input. That documentary claim explains the library operation. Our acceptance requirement adds something the unsigned result cannot always provide: equality to the exact signed mathematical difference.
Write the requirement before looking at a reassuring number. A result of 251 for r1→r2 is acceptable because 255-4 is 251. A result of 255 for r0→r1 is unacceptable because 4-5 is -1. The sign alone is never the acceptance rule; agreement with the identified operands is.
This boundary also keeps tolerance-reference validation in its appropriate context. This playbook requires exact integer equality for every interval. There is no error allowance to tune when one integer has become another.
Record the intended units and counter identity alongside the formula. Even perfect subtraction cannot establish whether two readings belong to the same instrument, generation, or counting process. Arithmetic review can certify the calculation over declared inputs. Approval of those declarations belongs to the team that understands how the readings were produced.
Record the raw representation and admissible input
Capture the original array before experimenting with conversions. Retain its dtype, dimensionality, shape, values, reading identifiers, source artifact, and ingestion revision. For stored binary data, retain enough format information to interpret its bytes, including byte order where relevant. A displayed list of decimal values does not replace that representation record.
The fixture admits only a plain np.ndarray with one dimension, at least two readings, and unsigned integer dtype kind 'u'. It rejects unsupported inputs instead of attempting to infer a suitable representation. This is the laboratory's deliberately narrow admission policy, not a claim that NumPy cannot operate on other inputs.
D11 contains seven rejection subcontrols: a Python list, an empty unsigned array, a singleton unsigned array, a two-dimensional unsigned array, a Boolean array, a floating array, and a signed integer array. The plain-type check also excludes subclasses by construction; there is no additional subclass case in the driver.
Both endpoints must survive for each interval. If a partition starts with r2, its internal difference to r3 does not reconstruct the missing r1→r2 boundary. Identify that boundary explicitly when defining the input manifest rather than silently manufacturing a predecessor.
A dtype label is part of the data contract
Keep the dtype beside the readings throughout review. NumPy's array-scalar documentation distinguishes sized signed and unsigned integer types. The uint8 label establishes an unsigned eight-bit representation; it does not identify the device's physical modulus or reset behavior.
For this fixture, store uint8, shape (4,), the order r0,r1,r2,r3, and the values 5,4,255,0 together. D13 later checks that these values remain unchanged during execution. That local check cannot authenticate an earlier export or prove that a producer supplied the correct sequence.
The neighboring discussion of eager arithmetic and output validation reinforces the need to inspect what an operation actually computes. Here, the relevant boundary is the integer representation at subtraction. Do not silently convert a list, flatten an array, or accept a signed input merely to get this laboratory to run.
Run the reproducible counter fixture
These are authored test inputs, not sensor measurements. The independent expected manifest fixes both order and mathematical results before inspecting NumPy output:
Input | Dtype | Ordered readings | Exact adjacent deltas |
raw | uint8 | 5, 4, 255, 0 | -1, 251, -255 |
u32 | uint32 | 0, 2**32-1, 0 | 2**32-1, -(2**32-1) |
u64 | uint64 | 0, 2**64-1, 0 | 2**64-1, -(2**64-1) |
large | uint64 | 2**63+5, 2**63+4 | -1 |
Save the following complete source as numpy_diff.py, preserving its final newline. Its SHA-256 is aeb3bd4ea545635714ea699012ba290bef629d6399d14af2e5cef2c920f9d004.
from __future__ import annotations
import json, platform, sys
import numpy as np
class ContractError(ValueError):
pass
def exact_delta(a: np.ndarray) -> list[int]:
if type(a) is not np.ndarray or a.ndim != 1 or a.size < 2:
raise ContractError('plain one-dimensional ndarray, at least two readings')
if a.dtype.kind != 'u':
raise ContractError('unsigned integer dtype required')
values = [int(x) for x in a]
return [values[i + 1] - values[i] for i in range(len(values) - 1)]
def checked_int64(a: np.ndarray) -> np.ndarray:
# Qualify operands AND possible differences before choosing fixed-width math.
reference = exact_delta(a)
bounds = np.iinfo(np.int64)
if any(int(x) > bounds.max for x in a):
raise ContractError('operand outside int64 range')
if any(x < bounds.min or x > bounds.max for x in reference):
raise ContractError('difference outside int64 range')
result = np.diff(a.astype(np.int64))
if result.tolist() != reference:
raise AssertionError('per-interval disagreement')
return result
def main():
rows = []
def record(id, observed, expected, decision):
assert observed == expected, (id, observed, expected)
rows.append(dict(id=id, observed=observed, expected=expected, decision=decision))
raw = np.array([5, 4, 255, 0], dtype=np.uint8)
original = raw.copy()
record('D1', np.diff(raw).tolist(), [255, 251, 1], 'REPAIR')
record('D2', np.diff(raw).astype(np.int16).tolist(), [255, 251, 1], 'LATE_CAST_NOT_REPAIR')
record('D3', np.diff(raw.astype(np.int16)).tolist(), [-1, 251, -255], 'ACCEPT_ARITHMETIC')
record('D4', exact_delta(raw), [-1, 251, -255], 'REFERENCE')
u32 = np.array([0, 2**32-1, 0], dtype=np.uint32)
record('D5', checked_int64(u32).tolist(), [2**32-1, -(2**32-1)], 'ACCEPT_ARITHMETIC')
u64 = np.array([0, 2**64-1, 0], dtype=np.uint64)
record('D6', np.diff(u64.astype(np.int64)).tolist(), [-1, 1], 'BLIND_INT64_NOT_REPAIR')
record('D7', exact_delta(u64), [2**64-1, -(2**64-1)], 'ACCEPT_EXACT_INTEGER_ARITHMETIC')
large = np.array([2**63+5, 2**63+4], dtype=np.uint64)
record('D8', np.diff(large.astype(np.float64)).tolist(), [0.0], 'FLOAT_CAST_LOSES_UNIT_CHANGE')
record('D9', exact_delta(large), [-1], 'ACCEPT_EXACT_INTEGER_ARITHMETIC')
try:
checked_int64(u64)
except ContractError:
record('D10', 'REJECTED', 'REJECTED', 'USE_EXACT_PATH_OR_HOLD')
else:
raise AssertionError('uint64 boundary was silently admitted')
rejected = []
bad = [[], np.array([], dtype=np.uint8), np.array([1], dtype=np.uint8), np.array([[1, 2]], dtype=np.uint8), np.array([True, False]), np.array([1., 2.]), np.array([1, 2], dtype=np.int64)]
for item in bad:
try:
exact_delta(item)
except ContractError:
rejected.append(True)
else:
raise AssertionError('invalid representation was admitted')
record('D11', len(rejected), 7, 'REJECT_UNSUPPORTED_INPUTS')
tampered = [0, 250, -255] # Same total as [-1, 251, -255].
record('D12', [sum(tampered) == int(raw[-1])-int(raw[0]), tampered == exact_delta(raw)], [True, False], 'TOTAL_ONLY_GATE_REJECTED')
record('D13', np.array_equal(raw, original), True, 'RAW_VALUES_UNCHANGED')
intervals = [dict(id=f'r{i}->r{i+1}', left=int(raw[i]), right=int(raw[i+1]), delta=delta) for i, delta in enumerate(exact_delta(raw))]
print(json.dumps(dict(python=sys.version, numpy=np.__version__, platform=platform.platform(), intervals=intervals, cases=rows, status='PASS_13_CASES'), indent=2))
if __name__ == '__main__':
main()
# For the commissioning configuration, select CPython 3.13.5 as python, create a disposable environment, and install the pinned dependency.
python -m venv .venv
. .venv/bin/activate
python -m pip install "numpy==2.3.5"
python -c 'import sys, numpy; print(sys.version); print(numpy.__version__)'
sha256sum numpy_diff.py
Compare the reported versions and digest before execution. Run without -O; the driver's assert checks must remain enabled. This Bash wrapper creates a fresh evidence directory and retains the command's real exit status:
(
run_dir="$(mktemp -d ./numpy-diff-run.XXXXXX)" || exit 1
sha256sum numpy_diff.py > "$run_dir/source.sha256"
printf '%s\n' 'PYTHONOPTIMIZE=0 python numpy_diff.py' \
> "$run_dir/command.txt"
if PYTHONOPTIMIZE=0 python numpy_diff.py \
> "$run_dir/numpy-diff-evidence.json" \
2> "$run_dir/stderr.txt"; then
status=0
else
status=$?
fi
printf '%s\n' "$status" > "$run_dir/exit-status.txt"
exit "$status"
)
Case | Diagnostic purpose |
D1 | Observe native unsigned differences. |
D2 | Expose a late cast. |
D3 | Qualify early int16 conversion. |
D4 | Check the independent exact reference. |
D5 | Admit the checked uint32 boundary. |
D6 | Expose blind uint64→int64 conversion. |
D7 | Preserve full-domain exact differences. |
D8 | Expose floating-point unit loss. |
D9 | Recover the exact large-operand difference. |
D10 | Reject full-domain operands from checked_int64. |
D11 | Reject seven unsupported-input subcontrols. |
D12 | Reject total-only reconciliation. |
D13 | Check preservation of raw values. |
Inspect the captured report rather than accepting its status field alone. Require thirteen unique IDs in D1–D13 order and compare each observed value with its authored expected value. Check the three printed interval records against the independent manifest. D11 must report seven rejected subcontrols, D12 must retain its differing Boolean outcomes, and D13 must report unchanged raw values. Keep these checks tied to the source digest and actual command. The JSON contains runtime versions but does not contain the source digest or shell exit status; those accompanying artifacts are part of the evidence record, not facts to reconstruct from a successful-looking report.
Recorded tests: the supplied commissioning record reports PASS_13_CASES on CPython 3.13.5, NumPy 2.3.5, and Linux x86_64. A separate saved validation run of the unchanged, hash-verified source reports PASS_13_CASES, exit status 0, and empty stderr on CPython 3.12.14, NumPy 2.3.5, and Linux-6.18.55-x86_64-with-glibc2.39. All thirteen observations matched their authored expectations, assertions were enabled, and the source digest remained unchanged.
That separate validation did NOT RUN the CPython 3.13.5 configuration.
The driver prints JSON only after its checks finish. An assertion failure can therefore leave empty output; retain stderr and status rather than treating the file's existence as success. Any source modification needs a new digest and rerun. Production ingestion, storage round trips, physical counters, and the proposed historical repair remain NOT RUN.
Watch an unsigned decrease become a positive result
D1 returns [255, 251, 1]. Each element has a plausible counter-increment appearance, but two fail the exact manifest. Inspect the arithmetic interval by interval before constructing any downstream summary.
For the eight-bit unsigned representation, the relevant arithmetic modulus is 256. The mathematical result -1 is represented as 255 after reduction modulo 256. The result -255 is represented as 1. The middle result, 251, already lies within the representation's range and remains 251. These calculations explain the three observed values without changing the input sequence.
That mix is diagnostically useful. D1 is not an array of obviously nonsensical outputs. One interval agrees with the reference, while two decreases become positive values. A rule that approves the entire transformation because one increasing interval worked would miss the defect the fixture was designed to expose.
Successful execution supplies no additional arithmetic approval. The returned array has the expected three positions, and every value is representable in its output dtype. Those properties answer structural and representation questions. They do not establish equality with the required subtraction.
Do not confuse two different kinds of wraparound
Library wraparound describes how the chosen fixed-width arithmetic represents a result. Physical rollover describes how an instrument advances its stored counter after reaching a device-defined limit. The fixture establishes the first behavior; it contains no instrument capable of establishing the second.
For example, the pair 255 followed by 0 could fit a hypothetical eight-bit device rollover. It could also cross a reset or join incorrectly ordered observations. The exact subtraction remains -255 in every one of those interpretations. Choosing a device-level increment requires an additional rule and supporting evidence.
Even agreement between a modular arithmetic result and a possible physical increment is insufficient. D1's final 1 does not prove that exactly one event occurred. The device may use a different counter width, and the retained readings do not reveal how many physical rollovers occurred between them.
Label D1 REPAIR because it fails this article's exact-difference contract. Retain its output as diagnostic evidence, together with the endpoints that explain the discrepancy. Do not classify the physical event from its wrapped value, and do not infer that all positive deltas elsewhere are suspect. The review criterion remains exact equality for each declared interval.
Show why converting the result is too late
D2 computes the unsigned difference first and then converts the result to int16. Its output is still [255, 251, 1]. The conversion can faithfully preserve those three already-produced integers while leaving the intended subtraction wrong.
NumPy's documentation for ndarray.astype describes a separate conversion operation and gives casting='unsafe' as the default. A successful call is therefore not a range-validation gate. More fundamentally, even a value-preserving conversion of the result would not establish how that result was obtained.
Locate the loss precisely. For r0→r1, the mathematical -1 became unsigned 255 during subtraction. At the later conversion boundary, the visible operand is 255. Expanding its storage to a signed type does not give the conversion access to the earlier 5 and 4 or to the intended mathematical result.
The ambiguity is concrete: unsigned 255 can correspond to the exact difference -1 for one pair, or +255 for another. Wrapped output alone does not identify which signed answer was intended. Recovering an answer from additional constraints would require those constraints to be declared and proved; D2 supplies none.
Repair before the lossy operation
D3 moves the conversion to the operands: np.diff(raw.astype(np.int16)). D4 independently converts each source scalar to Python int before subtracting. Both produce [-1, 251, -255] in the recorded executions.
The order of operations is the repair. Preserve the unsigned source, choose a representation that can retain its operand values and required results, and then recompute. Keep the original output long enough to reconcile changes and explain why the old path failed.
Do not replace this process with a reinterpretation of the wrapped values' sign bits. That would introduce a different mapping and additional assumptions about the original differences. Likewise, subtracting 256 from every positive result would damage the valid +251 interval.
The review should identify the first lossy operation in the actual pipeline, including any earlier parser or storage conversion. Moving a cast before np.diff only helps when the readings reaching that cast still retain their original integer values.
Choose a signed path only after checking its range
A signed target is sufficient when it represents the admitted operands and every required difference exactly. NumPy's iinfo machine-limit interface supplies integer minima and maxima for these explicit checks. Those limits describe storage; the application must decide which values and operations require admission.
For the entire uint8 operand domain, values lie between 0 and 255, and adjacent mathematical differences lie between -255 and 255. Both ranges fit int16, whose limits are -32768 and 32767. D3 therefore uses a sufficient representation for this unsigned domain, not merely a cast that happens to work on one decreasing pair.
The same reasoning qualifies the D5 uint32 control. Its extreme operands are 0 and 4294967295. The required differences are +4294967295 and -4294967295, which fit int64. The helper also compares every computed interval with the independent reference before returning its result.
Source domain | Required difference range | Demonstrated signed path |
uint8 | [-255, 255] | Convert operands to int16. |
uint32 | [-4294967295, 4294967295] | Use checked_int64. |
Full uint64 | [-(2**64-1), 2**64-1] | int64 is insufficient. |
Read checked_int64 as a correctness demonstrator. It computes the exact reference first, rejects any operand above np.iinfo(np.int64).max, checks the reference results against both signed limits, and reconciles the candidate vector. It makes no speed claim.
Perform result-range checks in the exact representation. Inspecting extrema of already-wrapped unsigned differences would qualify the wrong values. The reference must establish what needs representation before a candidate dtype can be admitted; the candidate cannot provide its own unchecked range evidence.
For this unsigned contract, admitted operands are nonnegative. Once all lie between zero and np.iinfo(np.int64).max, their differences necessarily lie between -np.iinfo(np.int64).max and np.iinfo(np.int64).max. The separate result-range check is consequently redundant within that admitted subset, but states the second representation obligation explicitly.
D10 rejects at the operand gate. It does not separately exercise the result-rejection branch. Keep that coverage limitation visible. Also distinguish a conservative sufficient admission test from a complete catalogue of every possible exact algorithm; rejecting this signed path does not imply that the subtraction itself is impossible.
Keep uint64 out of a blind int64 repair
D6 begins with [0, 2**64-1, 0] as uint64, converts blindly to int64, and computes [-1, 1]. The exact answer in D7 is [18446744073709551615, -18446744073709551615]. The apparent repair has lost the operand representation before differencing begins.
The boundary is explicit: int64 reaches a maximum of 2**63-1, while uint64 reaches 2**64-1. Equal storage width does not imply equal nonnegative range. In this observed conversion, the large middle operand becomes -1; differencing the converted sequence then produces the misleading small results. The signed subtractions in D6 fit int64; conversion has already changed the middle operand.
A uint64 array whose actual operands satisfy the helper's admission checks can use that helper. The full-domain control cannot.
Convert each operand before subtracting
The Python integer contract provides unlimited integer precision, subject to available resources. The reference uses that representation by evaluating int(right) - int(left). Both conversions happen before subtraction, so fixed-width NumPy arithmetic does not produce an intermediate wrapped delta.
The alternative int(right - left) is too late when right and left remain unsigned NumPy scalars. The outer conversion receives the result of the inner subtraction. An independent reference must cross the representation boundary at the operands, not repeat the candidate's loss inside a differently named function.
The reference is independent of NumPy's subtraction, but it shares the retained input with the candidate. Both can agree on the same corrupted readings. Equality therefore qualifies arithmetic over those inputs; authenticating the inputs requires the separate provenance record.
D7 accepts the full-domain results as exact Python integers. Keeping them exact downstream remains a separate requirement: a destination that narrows these values to int64 would reopen the same representation problem. The fixture does not test a database or serialization consumer.
D9 adds a different lesson. Its two operands exceed np.iinfo(np.int64).max, but their exact delta is only -1. By inspection, the helper's conservative operand gate would reject that pair; the driver does not execute that additional helper call. A small result does not make a value-preserving operand cast possible.
Keep shape and pair-identity checks as prerequisites while reviewing representation. These controls already use one-dimensional arrays and fixed adjacent pairs. Changing shape would not rescue either the full-domain operands or their exact differences.
Reject a float conversion that erases unit changes
D8 uses [2**63+5, 2**63+4] as uint64. The second reading is exactly one smaller than the first. After converting the operands to float64, the observed difference is [0.0]; D9's independent integer result is [-1].
This failure occurs despite converting before subtraction. Conversion order is necessary to fix D2, but the chosen operand representation must also preserve the relevant values. A wider-looking or familiar numerical type is not sufficient evidence of that property.
The NumPy description of floating scalar types identifies the limited mantissa of float64. Its range of magnitudes does not mean it can distinguish every integer within that range. For these authored operands, both converted values round to the same floating value; subtracting them therefore loses the unit change. That explanation follows from the representation, while D8 records the resulting zero.
Neither a finite-value check nor an expected-shape check would reject that zero. Even knowing that -1 itself is representable as a floating value would not rescue the calculation: the distinct inputs were merged before that result could be computed.
For an exact counter-delta requirement, reject this floating path and recompute from retained integer readings. Do not lower the requirement to an approximate comparison merely because a conversion has erased the evidence. The fixture gives no authority for such a policy change.
The preservation boundary may occur before NumPy receives the data. If an export already stored the readings as rounded floating values, constructing an unsigned array later does not recreate the missing unit. Establish the original integer provenance first. When only rounded operands survive, place recovery on HOLD rather than calling a new subtraction exact relative to readings that are no longer available.
Reconcile every interval rather than only the total
The principal ledger makes each disagreement attributable to two readings. Its exact column is specified independently in the manifest and checked by D4. D3 supplies the early-cast comparison; D1 and D2 expose the unacceptable paths.
Interval ID | Left | Right | Exact delta | D1 / D2 | D3 / D4 |
r0->r1 | 5 | 4 | -1 | 255 | -1 |
r1->r2 | 4 | 255 | 251 | 251 | 251 |
r2->r3 | 255 | 0 | -255 | 1 | -255 |
Preserve this mapping before reducing results. A candidate vector must have the expected length, occupy the same interval order, and equal the exact reference at every position. Matching counts alone does not establish matching interval identities.
The fixture's Python-list equality compares complete ordered vectors. Its generated interval IDs bind positions to the retained raw readings. It does not accept an external identity table or verify a production join, so those integration checks remain separate from the observed arithmetic agreement.
A correct total can hide wrong intervals
D12 deliberately submits [0, 250, -255]. Its total is -5, matching both the correct vector's sum and the exact endpoint subtraction 0-5. Nevertheless, its first interval is wrong by +1 and its second by -1. Their errors cancel in the aggregate.
The recorded result [True, False] means that the endpoint-total comparison passes while the full-vector comparison fails. The diagnostic is successful precisely because it refuses to promote that total into interval acceptance.
A telescoping sum is useful supporting evidence when evaluated exactly, but it discards the allocation of changes among intervals. It also cannot recover omitted reading identities. Keep the complete ledger even when a reporting interface displays only a summary.
For an affected dataset, report each differing interval's source IDs, operands, candidate delta, and reference delta. Record the total number of compared intervals and retain every mismatch. A reviewer should be able to reproduce a disagreement directly from its two endpoints without guessing which reordered or filtered rows supplied them.
Separate numerical repair from reset and rollover policy
An exact negative delta establishes a decrease between the retained numerical readings in their declared order. It does not establish why that decrease occurred. Separate the arithmetic review from the device or application policy that interprets it.
Ask the domain owner for evidence appropriate to the counter, rather than selecting whichever explanation produces a convenient positive increment:
Evidence | Question it helps answer |
Device specification and modulus | What counter range and rollover rule actually apply? |
Generation, boot, or reset marker | Do these readings cross a declared counter restart? |
Sequence numbers and ordering contract | Does the retained order represent the intended observation sequence? |
Event and ingestion timestamps | Is there evidence of delayed or reordered delivery? |
Counter identity and units | Are both endpoints observations of the same quantity? |
These fields support investigation; none is a universal classifier. A timestamp alone may not resolve equal-time observations or an undocumented producer clock. Likewise, a counter near its maximum does not establish that only one rollover occurred before the next sample.
The arithmetic record should remain unchanged while this evidence is reviewed. If an approved domain rule later derives a rollover-adjusted count, retain it as a separately defined result with its policy revision. Do not overwrite the exact adjacent subtraction and lose the ability to inspect the original decrease.
Maintain upstream data-cleaning provenance when examining exports and ingestion decisions. Sorting readings by value changes the interval sequence. Taking absolute values changes the subtraction. Clipping negatives or filling presumed resets inserts an interpretation that the numeric fixture has not authorized.
Assign unresolved semantics to a named device, telemetry, or application owner. A useful handoff contains the two original readings, interval identity, exact delta, and missing evidence. HOLD can then be specific: arithmetic is qualified, but a physical increment or reset classification awaits the identified source information. An unanswered domain question should remain visible in the release decision.
Recompute affected outputs from retained readings
Begin historical review with the transformations that used unsigned subtraction or a lossy operand conversion. Define the affected dataset versions, dtype histories, and interval range. Searching only for negative stored deltas would miss D1's central symptom: its incorrect results are positive.
Use an owned, staged recomputation procedure:
Assign scope and ownership. The data owner identifies the candidate partitions and consumers; the engineering owner identifies the faulty expression and its deployed revisions.
Recover intact sources. Verify original integer values, dtypes, order, and reading IDs. If only wrapped differences or rounded operands survive, record the unresolved recovery requirement and hold replacement.
Include interval boundaries. Retain both endpoints for every affected interval, including predecessors or successors needed across the chosen partition limits. Document which boundary intervals belong to the review.
Stage the corrected outputs. Recompute with a qualified signed path or the exact integer path under a versioned transformation. Keep the old derived data available for comparison.
Reconcile before promotion. Compare every interval, its identity, and its output representation. Establish that the destination and downstream readers preserve the accepted integers.
Approve the replacement. Record the reviewed scope, unresolved holds, consumer impact, and responsible release owner before switching consumers to the new version.
These historical and integration actions are a recovery plan, NOT RUN in the fixture. Implementing them requires their own source revision, evidence capture, and acceptance checks; changing the published diagnostic is not a substitute.
Rollback should reverse the deployment or consumer selection without deleting either evidence set. If the previous output is known to violate the contract, restoring access to it does not restore arithmetic validity. Suspend affected derived use when necessary until a qualified version is available. Preserve raw readings throughout; they are the basis for recomputation, comparison, and any later domain investigation.
Make acceptance and hold decisions explicit
Use decisions that identify the layer being approved. The fixture's descriptive labels remain intact in its JSON; the operational matrix below groups them into actions for review.
Evidence or condition | Decision | Owner and next action |
D3 or D5: admitted signed operands and exact interval agreement | ACCEPT_ARITHMETIC | Numerical reviewer accepts the bounded transformation. |
D7 or D9: exact Python-integer deltas | ACCEPT_ARITHMETIC | Data engineer preserves exact output representation. |
D1, D2, D6, or D8: wrong deltas with intact sources | REPAIR | Engineering owner recomputes affected intervals. |
D11: unsupported input schema | REJECT | Ingestion owner resolves the contract violation. |
D10: operands outside the selected signed path | REJECT that path | Use the qualified exact path or hold. |
D12: correct total but wrong intervals | REPAIR | Reviewer refuses interval acceptance and requests recomputation. |
Missing source, identity, or trustworthy order | HOLD | Data owner supplies provenance before broader approval. |
Exact deltas with unresolved physical interpretation | HOLD domain approval | Counter owner supplies semantics and evidence. |
D7 and D9 use the literal label ACCEPT_EXACT_INTEGER_ARITHMETIC in the unchanged driver. Grouping them under arithmetic acceptance does not authorize narrowing their outputs. D4 is the independent reference check, and D13 is supporting evidence about source preservation; neither grants domain approval.
Arithmetic acceptance is not domain approval
PASS_13_CASES means the executed diagnostic matched its authored expectations, including the intentionally wrong paths. D1 must produce its wrapped values for that diagnostic to pass. It would still fail as the transformation used to publish exact deltas.
Acceptance requires admitted inputs, retained pair identities, representable operands and results, and complete equality with the independent reference. For this local experiment, those requirements apply to the declared synthetic sequence. Additional approval is needed before claiming that the sequence reflects a physical counter's true chronology or increments.
Record decisions separately when necessary: ACCEPT_ARITHMETIC for the exact -1 and HOLD for its interpretation. Name the unresolved evidence and its owner. That distinction allows useful numerical work to proceed without turning a successful calculation into an unsupported statement about what happened upstream.
Keep the dtype contract in regression and review
Rerun the boundary fixture whenever a parser, dtype declaration, storage format, conversion helper, or numerical-library revision changes the path from source readings to differences. Include output consumers in that review when they may narrow an accepted result. A transformation can preserve exactness locally and lose it at the next representation boundary.
Keep the literal expectations independent of candidate output. Replacing an expected vector with the current implementation's result would eliminate the check's ability to detect its own regression. The small unsigned decrease, the full uint32 and uint64 boundaries, and the large operands differing by one each challenge a different proposed shortcut.
Retain the thirteen-case inventory. D11's seven subcontrols should remain visible within that one case, and D12 must continue failing interval equality despite its matching total. A broad exception handler that converts any error into a successful rejection would weaken the evidence; expected exceptions belong only to the controls that deliberately request them.
Capture the executed source digest, interpreter and NumPy versions, command, assertion settings, stdout, stderr, and exit status for each fresh run. The documentation basis here is the NumPy 2.3 and Python 3.13 families, checked on October 19, 2026. An access date identifies the research check; executed patch versions belong in the run record.
Apply the provenance discipline also used for missing-value lineage: retain how a derived value acquired its meaning. Here, zero from D8 is the result of lost operand distinction. It is not evidence that the original counter was unchanged or that an absent reading was legitimately filled.
If documentation, versioned source, and execution disagree, preserve the conflicting artifacts and HOLD the disputed conclusion. Do not change an expectation simply to restore a green run. Investigate the exact inputs, environment, and operation first.
The regression fixture establishes agreement for its enumerated cases. It is not a performance study, exhaustive dtype conformance suite, or production integration test. Extending coverage requires new identified cases and evidence, while keeping the original boundary failures reproducible and their decisions understandable.
Build broader numerical data-science practice
The durable skill in this exercise is tracing a numerical claim back through its representation. A reviewer should be able to identify the original operands, the operation that first changed their meaning, and the evidence that supports the proposed correction. That discipline makes the choice of arithmetic reviewable instead of habitual.
Use the fixture as a structured discussion between engineering and analytical reviewers. Have one person explain why D3 is sufficient for the admitted unsigned domain, another explain why D6 fails before subtraction, and a third explain why D12 defeats a total-only gate. Their explanations should refer to the retained readings and exact expectations, not merely the final status string.
Then ask a separate question: what can be published about the counter itself? An analyst may have exact deltas while still lacking authority to describe resets or physical increments. Writing that boundary clearly is part of numerical practice. It prevents an arithmetic repair from quietly changing the meaning of a dataset.
Carry the same evidence standard into subsequent project work: preserve inputs, define the expected calculation, test a counterexample to the tempting shortcut, and retain the unresolved interpretation with a named owner. A positive output then becomes something to explain through its operands, rather than a reason to assume growth.
Refonte Learning's program-specific information names Python, statistical modeling, machine learning, and practical projects. It lists three months and 12–14 hours per week. Those details describe the advertised learning opportunity; this playbook is an independently specified numerical laboratory.
For structured work with Python, statistics, and practical data-science projects, review the Data Science Program and its current admission details.
