Repository navigation
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Some harnesses invoke undefined behavior, and bounded inputs leave required unbounded and reachable-state cases unproven.
Review effort: Balanced
Findings: 1
Open (4)
What changed in this PR
Adds Kani verification for Challenge 22’s str iterator safety obligations.
Changes:
- Adds 30 iterator and contract harnesses.
- Models searcher behavior and symbolic strings.
- Enables required unstable APIs under Kani.
| File | Description |
|---|---|
library/alloc/src/str.rs |
Adds Challenge 22 verification harnesses and helpers. |
library/alloc/src/lib.rs |
Enables remainder API features for Kani builds. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
feliperodri
left a comment
There was a problem hiding this comment.
Challenge 22 requires: "The verification must be unbounded---it must hold for str of arbitrary length." That requirement is final. A Kani solution will only be accepted if it is unbounded in the input size for every required function. This PR still verifies at least part of the challenge with bounded harnesses (kani::unwind bounds and/or fixed-size inputs), so I'm requesting changes until every required function is verified without a bound on the input size.
…sses Address Copilot review on model-checking#706: - symbolic_str now uses alloc_zeroed (valid UTF-8, no read of uninitialized memory); merge the former symbolic_str_zeroed into it since the content-independent proofs stub the searcher and never depend on nondeterministic content. - Add mixed front/back advanced-state harnesses for the double-ended Split/Matches iterators, exercising the both-cursors-moved state. The searcher stubs gain a two-sided no-cross clause (DoubleEndedSearcher consistency), a no-op for the single-direction harnesses.
|
The update makes every required function's verification unbounded — symbolic string length throughout, plus a symbolic count for |


Towards #279.
Updated: Every verification unbounded for every required function. The 2026-11-03 request for changes:
__iterator_get_uncheckedcontract proven for fresh and advanced iterator stateBeyond that bar:
advance_byandnthalso take a fully symbolic count (no count window); every loop contract declares its write-set explicitly rather than relying on inference; and two should-panic twins keep the proofs' adequacy machine-checked on every CI run. All 56 harnesses in thestriter verify modules pass with a local Kani build at the pinned commit (9834c96).Success Criteria
advance_by/nthcount axis__iterator_get_uncheckedproof_for_contract, fresh + advanced stateadvance_byThe crux is
advance_by: its three decode loops now carry loop contracts. The invariants read two#[cfg(kani)]raw-field accessors onslice::Iterrather thanas_slice()/len(), whose pointer verification conditions do not discharge under loop havoc at this pin. The inner 32-byte fold becomes a loop-free model undercfg(kani)— proven equal to the real fold bycheck_fold_model_eq, with a wrong-model twin that must panic; thecfg(not(kani))path is the original fold verbatim.Two challenge-granted assumptions:
advance_byis stubbed with its documented contract —Okiff the count is within the remaining length, exhausted onErr— so theunwrap_uncheckedobligations stay live, discharged by the invariants.kani::assume(slurp <= remaining)at the slurp site, restating what UTF-8 validity grants there. The symbolic-length harnesses use ASCII content (width 1), so it cannot launder a width bug; multi-byte width rides the bounded companions, and the real body is also checked stub-free at bounded count.check_advance_by_chars_unbounded_mutantasserts success for a count the string cannot satisfy; it must panic and does. Remainingkani::unwindattributes bound harness structure, never input size; their unwinding assertions discharge.-Z valid-value-checks:goto-instrumentaborts (DFCC invariant violation,dfcc_cfg_info.cpp:666) when combined with loop contracts at this pin; the same flag ran clean at the previous pin (c5e65fd).-Z uninit-checks: rejected on the pre-existing recursion inSplitInternal::next_back(core/src/str/iter.rs:789).By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.