References
- Issue #3364 — the filed report, the manual reproduction, and the 2026-11-13 update
- PR #3430 — the merged fix and regression test
- Nim
system.toOpenArraydocumentation — the inclusive-bound convention and its example - Axiom verification evidence, 2026-11-13 — the campaign record, guards, digests, and scope caveats
- Axiom repository — the engine and its stated scope
- Post-fix
bytesview.nimand test file
In November 2026, nim-libp2p merged PR #3430. The change is one line in libp2p/utils/bytesview.nim and eleven lines of tests. BytesView.toOpenArray(b, e) now uses inclusive bounds relative to the unconsumed data, and the merge closes issue #3364 — a report filed with a counterexample produced by Axiom.
The defect had survived sixteen months of green CI. BytesView shipped in July 2025 with a test that asserted the truncated length, so the suite agreed with the bug. More examples of the same kind would have kept agreeing. The finding came from a different instrument: a length law stated independently of the implementation, searched by an SMT solver over a bounded domain, which returned a concrete input where the law fails.
That is the result this post records. The law is arithmetic, the search is mechanical, and the answer is a finite object a maintainer can reproduce by hand. Axiom did not write the patch; richard-ramos did. That division is the normal shape of an upstream contribution.
The sections below follow the chain: the arithmetic, the law, the verdict, the fix, and the boundary between what the merge establishes and what it does not.
Background: terminology
BytesView is nim-libp2p's non-owning view over a byte sequence. It holds a seq[byte] and a read position rpos; len is the number of unconsumed bytes. A view avoids copying when a protocol parses a frame, slices a field, or hands a buffer to a decoder.
openArray is Nim's borrowed-array parameter type: a pointer plus a length, with no ownership. system.toOpenArray(x, first, last) returns such a view over x from index first through index last inclusive. The Nim documentation is explicit about the convention, and its example is the one this story turns on:
proc test(x: openArray[int]) = doAssert x == [1, 2, 3] let s = @[0, 1, 2, 3, 4] s.toOpenArray(1, 3).test Bounded model checking asks whether a claim fails for some input inside a bound; a satisfiable answer comes with a concrete counterexample. Axiom is the verification engine this project builds. It takes an adopted proposition, lowers it to a solver query, records a verdict, and preserves a run record. Its scope is bounded: deterministic results within a supported kernel scope, not a proof of every program property.
1) The arithmetic
The pre-fix subject was iftech/nim-libp2p at commit a130a7f32219909bdcda14b7f1e64d0804fc832c. The module under test was pinned by hash:
libp2p/utils/bytesview.nim sha256 b205c969ba04f4199d8fd4a121d4b6fccdc82c426e336add0e1e9fd0e961e5ee The template read, before the fix:
template toOpenArray*(v: BytesView, b, e: int): openArray[byte] = v.data.toOpenArray(v.rpos + b, v.rpos + e - b) The intent is a slice relative to the unconsumed data: b is the first relative index, e the last, both inclusive. The start is advanced by b. The end should also be advanced by b — but the expression subtracts it. At rpos = 0, the underlying inclusive range becomes [b, e - b], whose length is e - 2b + 1. The inclusive law for a view-relative slice is e - b + 1. The result is exactly b elements short.
The fix removes the second subtraction:
template toOpenArray*(v: BytesView, b, e: int): openArray[byte] = v.data.toOpenArray(v.rpos + b, v.rpos + e) The behavioral table for a view over [1, 2, 3, 4, 5, 6] at rpos = 0 makes the gap visible:
b | e | inclusive law (e - b + 1) | before fix (e - 2b + 1) | after fix |
|---|---|---|---|---|
| 0 | 4 | 5 | 5 | 5 |
| 1 | 1 | 1 | 0 | 1 |
| 1 | 3 | 3 | 2 | 3 |
| 1 | 4 | 4 | 3 | 4 |
| 1 | 5 | 5 | 4 | 5 |
| 2 | 5 | 4 | 2 | 4 |
| 4 | 5 | 2 | -2 | 2 |
At b = 0 the two formulas coincide, which is why the defect survived in production. Both call sites are in noise.nim (read_e and read_s), and both pass a literal zero start. A caller with a nonzero start received a shorter view than it asked for, with no error and no signal. For b = e > 0 the old formula produced a zero-length view for a valid one-element slice; for 2b > e it could produce a negative length, which raises RangeDefect when materialized into a sequence. The fix also makes out-of-range ends stricter: an end that the old code silently truncated now raises IndexDefect. In-tree callers guard their lengths before slicing, so neither path is exercised there.
2) The law
A test executes one input and compares the result to an expected value. When the expected value is derived from the same mistaken arithmetic, the test passes. That is what the sixteen-month record shows. The proposition separates the expected length from the implementation: for a view-relative inclusive slice the length is e - b + 1, independent of how the template computes its bounds. The engine searches the bounded domain for a valuation that violates the law. The answer is an input the law selects, not an example someone chose.
SPEC-LIBP2P-BV-SLICE rule: external:libp2p/bytesview/slice-length-law domain: 1 <= e <= 5, b = 1, rpos = 0 fixture: BytesView.init(@[byte 1, 2, 3, 4, 5, 6]) law: bvSliceLenLaw1(e) == e actual: bvSliceLenActual(e) == e - 1 With b pinned at 1, the law says the slice from relative index 1 through e has length e; the implementation produces e - 1. The counterexample is the smallest instance: (b = 1, e = 4) returns 3 bytes where the law requires 4.
The issue body stated the status of that law:
The expected behavior stated in this report is INFERRED and adopted by the verifying run. The project has NOT been shown to guarantee this behavior — this report does not claim such a promise. Requirement source status: unrecorded.
Nim's system.toOpenArray documents inclusive bounds for sequences, but BytesView.toOpenArray is a separate template with its own contract. The claim was that the wrapper should follow the convention of the primitive it wraps. At the moment of filing, the requirement was adopted rather than inherited from an upstream promise. Authorship and authority were separated as well: the proposition content was written by the investigation agent chain, and the authority to verify it came from a committed overlay plus a contract. The overlay's provenance note reads Authorship confers NO authority.
The engine verifies a model. toOpenArray is a template, so the carrier is constructed IR — the arithmetic of indices and lengths, not an extracted function body. The connection to the code is a static reading of that arithmetic plus a replay harness on the fixture bytes.
3) The verdict
The campaign classified the result as DISPROVED_REPRODUCIBLE:
{ "campaign_class": "DISPROVED_REPRODUCIBLE", "reason": "exit 1 on both legs; all 5 guards passed; canonical digests equal", "accepted": true } Five guards passed on both legs:
input_mismatch pass determinism_mismatch pass vacuous_blocked pass zero_footprint_violation pass environment_mismatch pass The two CI legs produced identical canonical_digest values:
1603765c7df1c2f183e3f224d9b1fbb61ae3a1b77a1e5455cff7abea4953d14a The run recorded prove_exit: 1, a state_canonical_run_digest of 29418089…, and the toolchain:
Axiom 0.6.3 Nim 2.2.10 Z3 4.13.3 Lean 4.33.0 DISPROVED_REPRODUCIBLE means that a live-generated proposition was consistently refuted in two runs and that the refutation is reproducible. It does not mean PROVED. The vocabulary is asymmetric on purpose: a counterexample is a finite object that can be checked, while a universal correctness claim is a much stronger artifact that the engine's supported scope does not produce for the whole library.
4) The upstream fix
The upstream timeline is short:
| Date (UTC) | Event |
|---|---|
| 2026-10-31 16:23 | Issue #3364 filed with the manual reproduction |
| 2026-11-13 08:23 | Update comment with the machine verification record |
| 2026-11-16 13:17 | Issue assigned to richard-ramos |
| 2026-11-16 13:21 | PR #3430 opened by richard-ramos |
| 2026-11-16 15:04 | PR merged; issue closed two seconds later |
The PR body states the contract in one paragraph:
Make
BytesView.toOpenArray(b, e)use inclusive bounds relative to the unconsumed data. Nonzero starts previously truncated the result:(1, 4)returned three bytes instead of four, and some valid single-element slices produced invalid lengths.
The fix is the one line shown above. The test change is more interesting, because the old expectation was not an accident. BytesView was introduced in July 2025 by PR #1497, a noise-handshake memory optimization, and the same PR added check @(b.toOpenArray(1, 3)) == @([byte 2, 3]) — a three-wide slice asserted to have two elements. The defect was born with its own specification. For sixteen months, green CI asserted the wrong length, which is why the arithmetic could look deliberate. An example-based test cannot separate the implementation from the understanding that produced it when both live in the same assertion. The fix corrected the expectation to [2, 3, 4]:
- check @(b.toOpenArray(1, 3)) == @([byte 2, 3]) + check @(b.toOpenArray(1, 3)) == @([byte 2, 3, 4]) and added a regression test that quantifies over every valid slice, at every consumption offset:
test "inclusive slice bounds": var b = BytesView.init(@[byte 1, 2, 3, 4, 5, 6]) for consumed in 0 .. 5: let remaining = @(b.data()) for first in 0 ..< b.len: for last in first ..< b.len: check @(b.toOpenArray(first, last)) == remaining[first .. last] b.consume(1) The loop runs 56 differential checks: six consumption states, with remaining lengths from 6 down to 1, and every valid (first, last) pair in each. It does not cover the empty view, e >= len, b > e, or negative bounds, so the stricter out-of-range behavior is not pinned by this test. What it does pin is the contract the old expectation got wrong. The test runs against the function itself, in the project's own suite, over the full space of valid pairs and consumption offsets, rather than a five-element domain with b pinned at 1. Anyone who clones the repository can run it, with no engine, no release bundle, and no access to my infrastructure.
The maintainer wrote the fix independently. Axiom supplied the proposition, the counterexample, and the report; it did not supply the patch. That division is the contribution model working as intended.
5) What the merge proves
The behavior was wrong under the adopted law. The pre-fix template returned e - 2b + 1 elements for a view-relative inclusive slice. The maintainers reproduced the nonzero-start truncation, accepted the convention, changed the code, and added a test that compares every valid slice against ordinary sequence slicing. That is independent confirmation, in the project's own repository, by people who did not run Axiom.
The upstream question is settled. A reader who wants to know whether Axiom's report identified a defect in nim-libp2p can read the answer in the merged diff: it did. The maintainer wrote the fix from the report, and the test now enforces the corrected behavior on every pull request.
6) What the merge does not prove
It does not establish that the Axiom verdict can be re-run. Maintainer acceptance confirms that the defect existed; it does not confirm the reproducibility record behind the report. The public path to re-execute that record no longer resolves. CI run 43363278211 returns 404 because the fork Archright/nim-libp2p was deleted. The reproduction instructions cite v0.6.3 of Archright/axiom-cli; that repository was created on 2026-11-18, five days after the evidence document, and its releases begin at v0.6.5. The cited bundle hash and engine_build_id cannot be checked against a public artifact today.
It is one lane, not the library. The proposition covers one template, one length law, one pinned domain (1 <= e <= 5, b = 1, rpos = 0), and a constructed arithmetic model. The evidence document scopes it the same way, records that the prompt named the length law and the off-by-b, and calls the result a guided observation, not autonomous defect discovery. An issue comment also describes a third-party cold replay; the execution was local, against a published procedure. The claim here is narrower than autonomy: a stated law and a solver turn a hypothesis into a checkable counterexample, and a maintainer confirmed the defect in the project's own code.
7) What remains
A verdict is a statement about a run. A merged test is a constraint on every future run. The first can expire when a fork is deleted, a release is moved, or a document's links rot. The second is executed by the project's CI on every pull request, including ones written by people who have never heard of Axiom.
That asymmetry is the lesson from this campaign. The most valuable output was not DISPROVED_REPRODUCIBLE. It was the eleven-line test that fails if anyone reintroduces the double subtraction. The law and the counterexample are what produced that test; the existing suite could not, because it had already accepted the wrong length. The second was the issue body's statement that the requirement was inferred and adopted, because that sentence let a maintainer evaluate the claim instead of accepting an authority.
There is a design consequence for Axiom. A verification record should ship with the version it cites, or cite only versions that already exist. It should keep the run under an identity the author controls, not a fork that can be deleted. And it should distinguish a local replay, a third-party replay, and a third-party-accessible procedure in its own vocabulary.
The upstream result is now part of nim-libp2p's history: a one-line correction, a test that enumerates the valid slice space, and a merge. The Axiom run is a paragraph in an evidence document whose links no longer resolve. The first is the artifact that carries the claim forward, and it exists because a law was stated before a patch was written.
