Repository navigation
Conversation
…e correct behavior has been settled for over a year and it was just cruft
Changing PathMap::restrict and WriteZipper::restrict to return None instead of Identity when the destination started empty
…nsistent behavior around zippers positioned at dangling paths Adam-Vandervorst#104
…ng out tests, and updating the API to match "blind zipper" patterns. Improving documentation and adding a diagram to illustrate behavior Adam-Vandervorst#104
…s the purview of Adam-Vandervorst#117, so it doesn't appear as a new divergence
…rune when a lredy empty and a zero-arg was passed, and an infinite loop when already empty
merkleize recursed into empty child links, and the second one found the first in its memo and tried to replace it in the parent, which refuses to hand out an empty child. Empty children have nothing to share, so skip them.
…he wrong place ACTZipper::val_count reset the zipper first, so it counted every value below the zipper root wherever the focus was. ProductZipper::val_count delegated to the core zipper, which only sees the current factor, and asserted elsewhere. Both now walk a copy below the focus.
Meets and joins keep the left operand's value on a collision, but a byte node paired with a list node ran the operation with operands swapped and kept the list node's values. join_k_path_into also folded k-paths in reverse, both in the byte node and in a list node's two slots, including the values exactly k deep that become the focus value. Values now follow operand order and path order. Ported from fuzz-fixes-v3 3dae731 onto focus_value_consistency's drop_head_dyn, which collects the values at the cut into root_val.
When a list node holds a value and a child under the same key and the child meets an empty node, the meet left an empty child (a dangling sentinel) next to the value, which validate_node rejects. The value already keeps the path, so drop the sentinel. Reachable once the value-bias fix put the empty node on the left of the child meet: EmptyNode's meet keeps a dangling tip, while the other order returned None.
DenseByteNode::join_child_into passed on the None that two empty nodes join to. merge_from_list_node merges the per-slot statuses, so a list node holding only dangling paths the byte node also has made the whole join None, and the byte node's other contents were dropped. Two dangling paths joined stay one dangling path, which is no change: Identity. join_child_into_left already did this. This is the debug assertion the algebraic fuzzer reported as finding 6, and one way a join lost values.
Grafting nothing at a branch must neither create nor destroy a location: an existing branch is emptied and survives as a dangling path, an absent one stays absent, as after graft of an empty source. graft_child_maps' slow path left the old branch in place for an empty map or one without a root value, its fast path grafted an empty node (tripping a debug assertion) and created the focus, and graft_masked_branches created the focus when every masked branch was absent from the source. Ported from fuzz-fixes-v3 3a16a57. Also a regression test for a join with a map of shared dangling paths, which fix/alg-fuzzer-findings fixed.
…d nodes At a focus with nothing below it, these answered according to whether an empty node happened to exist there (after create_path or remove_val, say) rather than according to the trie's paths and values: - take_map returned Some(empty map) instead of None; - join_map_into of an empty map reported None or Identity depending on the node; it now reports Identity exactly when the focus exists; - restricting with a dangling source focus erased the destination's branches and returned true; either side with nothing below its focus now leaves the destination alone and returns false.
u64 and u16 psubtract returned Element(*self) when nothing was subtracted. Nodes propagate identity masks, so subtract_into reported Element for an unchanged trie.
WriteZipperCore::try_borrow_focus_mut took any child the focus key reached as the focus node. After prune_path below a zipper root that survives as a dangling path, the focus key runs through that empty node, which the node stack does not descend into, so the child it found ended short of the focus. A debug build tripped the consumed-bytes assertion; a release build merged the grafted branches into the node above, two bytes too shallow. A child that does not end at the focus is not the focus node.
…alues meet_into and meet_k_path_into with prune = true now remove every dangling path below the focus, not only the chain at the focus, then prune the focus as before. With prune = false a meet may leave dangling paths (which ones is unspecified), but the status and return value depend only on the values: a result holding none is None / false. meet_2, which has no prune flag, follows prune = false. Two tests encoded the old rule and are updated: write_zipper_meet_into_test4 kept a dangling-only intersection under prune = true and reported Element, and write_zipper_prune_flag_test assumed prune = true equals prune = false plus prune_path at the focus, which no longer holds for meet_into.
Ports the model and harness state that fix/fvc-leftovers was validated against (PathMap-zippy-fvc working tree): meet rule v2 (prune=true leaves no dangling path below the focus, prune=false may leave some and the harness drops them, status by values), meet_k_path_into via remove_subtrie, the k=0 and empty-path skips removed, and the masks the fvc fixes made unnecessary lifted. graft_child_maps is no longer quarantined. 20000 native + 10000 ACT random inputs agree except one pre-existing crate divergence (empty graft_masked_branches then remove_val(prune) keeps the path).
run_ops is now generic over the write zipper (WriteTarget: untracked, tracked or owned) and the read zipper (ReadSource), and each ReadSource names its own skip token. A source is selected with --source NAME on pathmap_trace, pathmap-oracle, differential.py and shrink.py (--act stays as an alias for --source act). On the Lean side a Source is a view (the trie the read zipper presents, computed from the seeded maps) plus capabilities (fork, make_map, merge, get_val, to_next_get_val); every read/movement/iteration op is the existing Zip specification applied to the view. The trace gains a SRC line: the read source reset and walked from its root after the program. First new source: tracker (PathTracker over the native read zipper). Also registers the remove_val(prune) divergence found on the baseline as a known crate bug, with its shrunk input in lean/corpus.
A second op table over three PathMaps, for the parts of the crate that are not a zipper walking a trie. Selector ranges are assigned to groups up front, each in its own file on both sides (lean/PathMapModel/MapFuzz/<Group>.lean, differential/src/mapfuzz/<group>.rs): core PathMap surface 0-19, lattice 20-29, serialization 30-39, ACT 40-49, morphisms 50-59, ZipperHead 60-69, experimental zippers 70-79. Only get/insert/remove/contains exist so far; every other selector is a nop on both sides. Inputs use the PMFUZZ header with MAP_NOPS = 80.
OverlayZipper, ProductZipperG and DependentProductZipperG leave val_count todo!()/unimplemented!(), and the per-step fingerprint calls it on every op.
Core: path_exists_at/contains_path/val_at/get_val_at/val, remove_val_at, get_val_mut_at, get_val_or_set_mut(_with)_at, remove_branches_at, prune_path, create_path, val_count/goat_val_count/is_empty (+merkleize), iter, Debug, FromIterator (three impls), IntoIterator, clone (shared_node_id soundness), single/From/single_in/new/default, read_zipper_at_borrowed_path/read_zipper_at_path/into_read_zipper, into_write_zipper. Path operands pick existing values, dangling tips or locations half the time. Lattice: join/meet/subtract/restrict, pjoin/pmeet/psubtract rendered as class/dump through each AlgebraicResult accessor with mask soundness checked, join_into, join_all. Meets compared by values. Two crate bugs behind named skips (skip:debug-root-val, skip:map-ident), join_into's layout-dependent status as a src:map KNOWN entry with corpus inputs. differential.py: classify() sees the source, map lines get no zipper shape classes and only src:map KNOWN entries.
overlay / overlay-filter: OverlayZipper over map1 at root1 and a snapshot of map0 at root0, with the default mapping and a value-filtering one. The view is the union of locations with mapping(a, b) as the value. diff: DiffZipper over two read zippers of map1, native view. Two OverlayZipper bugs recorded as KNOWN with shrunk corpus inputs: ascend_until misses branches formed by the union and stops at filtered values; descend_until stops at filtered values. classify() now sees the source name so per-source KNOWN entries cannot hide other sources. FullZipper and NullZipper are private, so map ops 70-79 stay nop.
…l_wz to the write side The generic ascend_until entry (a write-zipper bug) matched any ascend_until divergence and silently absorbed read-source bugs (found by the overlay workstream). Op-line divergences are now tagged WRITE-SIDE or READ-SIDE.
dependent / dependent-lazy: DependentProductZipperG over map1 at root1, the next factor picked per joint from snapshots of map0 and map1 by a deterministic closure. The view grafts the chosen factor below every leaf, the joint keeping the earlier factor's value. The campaign closure keeps away from two entry defects (root joint not entered until a descend; a stacked factor after an empty one entered only on a later call); the lazy variant replays them. val_at/get_val_at ignoring later factors is KNOWN. Findings in lean/findings/dependent.md, repros in bin/dependent_repros.
Without it the lazy source's divergences were credited to the generic CONTENT-DROPPED shape class.
…r WRITE-SIDE The op line alone cannot say which zipper a differing return value came from (reported by the dependent workstream).
A third op table for the public parts of pathmap that are neither a zipper nor a PathMap. Stateless ops, one trace line each. Selector ranges: ByteMask / BitMask / utils 0-29, ring.rs lattices and AlgebraicResult 30-59, PathInteger 60-79, path sorting and the rest 80-99; every selector is a nop so far. UTIL_NOPS = 100.
…t the Lean model Every public item of src/utils/mod.rs is driven by an op whose answer is the set-level meaning (UtilFuzz/Mask.lean, with #guard law batteries). showAlgResult / show_alg_result render AlgebraicResult for reuse. Findings (lean/findings/u-mask.md): join_all over empty masks answers by argument-count parity (allowed; skip:join-all-empty), the inclusive-range edits act on an exhausted RangeInclusive (KNOWN), and they debug_assert on an empty a..=b with a > b.
…tice, checked against the Lean model Value types as sets, maps, Boolean algebra, left-projection tokens and Option's added bottom; law batteries per type; L1 (SetLattice meet swaps operands) as skip:setlattice-meet-swap with a skip-free ring_pmeet! repro.
…wap, L2 merge for meet, L3 IDEMPOTENT promise
…nt_range for every PathInteger type differential.py: only src:util KNOWN entries apply to util traces.
…s features in the differential crate
…:default in op 86
…ut the trailing newline u-mask and u-lattice key their entries "src:util\n"; the filter u-ints added compared the bare "src:util" by list membership, so both were dropped and their hits reported as new.
…end_to(-).graft(y)) Product.graft2 / graftProd, written literally with the model's write-zipper operations, selectable as Semantics.graft (sources stay on .leaf, what the crate does). #guards: equal to prod2 with the joint value changed and to Composition exactly when x has values only on its leaves; associative over the battery; one example each for the three deviations of the crate's leaf product and for nested keys against Composition. 17% of random product inputs agree with it. Findings: product.md section and BUGS.md S1-S3.
Master's Adam-Vandervorst#200 made open_mmap return Err for a file shorter than the 16-byte header (magic + root offset) instead of panicking below 8 bytes and opening 8-15-byte prefixes. Drop skip:act_open_short; trunc= is now err below 16 bytes and ok from 16 on, on both sides.
prune_path_internal started pruning wherever the node holding the focus was empty. That gave two wrong answers when a dangling path is held as an empty node: - A pruning remove at a focus that doesn't exist removed the dangling parent above it, because the missing focus is inside that empty node too. This happens below a stump a ZipperHead writer leaves, and below what an empty graft_masked_branches leaves. Below an ordinary dangling path the same remove does nothing, which is what the docs say: prune = true is the remove with prune = false followed by prune_path. - A dangling tip held as a link to an empty node wasn't pruned, because the node holding the link isn't empty. A ZipperHead leaves such a node at a leaf head root after splitting it off for a read zipper, so remove() left the location dangling. remove_val, remove_branches, remove_subtrie and remove_unmasked_branches now prune only when the focus exists on entry. prune_path_internal also starts at a valueless link to an empty node.
…pty node With the focus below a dangling path whose node is empty, node_get_child finds that empty node, having consumed less of the key than the focus needs. try_borrow_focus and try_borrow_focus_mut handed it out as if it were the focus's node; a debug build failed the consumed == key length assertion. The node is above the focus, and the focus doesn't exist, so both now answer None, as the read zipper does.
TrieRefOwned::new_with_node_and_val_in(None, val, ..) returned an invalid ref and dropped val. None there means the location has no node below it, not that it doesn't exist. So TrieRefOwned::from / TrieRef::from a childless map reported path_exists() == false and lost its root value. Every write zipper's get_trie_ref() did the same at a childless focus, while the zipper itself reported the location and its value. Give such a ref the empty node instead, keeping the value. Non-slim_ptrs builds fall back to an allocated empty node. WriteZipperCore::get_trie_ref now checks path_exists() first, since get_focus() is also None at a focus that doesn't exist, and that one must stay invalid.
Op 60 rebuilt every map from scratch after a ZipperHead session, and skipped a writer's pruning remove at a focus that doesn't exist (skip:prune-absent-focus). Both kept H4 (a dropped writer's stump pruned from below) and H5 (a reader's empty node blocking a prune) out of later ops. The crate fixes for them are carried on this branch, so both workarounds go: the map goes on as the session left it, and the remove runs. Without the crate fixes, 20000 inputs biased towards op 60 and the core remove / prune / create ops give 33 new divergences (18 H4, 2 H5, the rest the same representation in later ops). With them, 0; also 0 new over 40000 random map inputs and every zipper source. BUGS.md marks 21-25 fixed.
…erlay does ascend_until and ascend_until_branch let each source ascend to its own nearest value or branch, and took the nearer stop. descend_until took the sources' stops the same way. But the overlay's trie is the union, with values from the mapping: - A branch formed by the union (one child in each source, a different byte) is a branch of the overlay. ascend_until climbed past it. - A source value the mapping filters out is not a value of the overlay. ascend_until and descend_until stopped at it. ascend_until / ascend_until_branch now climb a byte at a time and stop where the overlay branches or has a value. descend_until keeps the source-driven descent, which already stops at union branches, and carries on from a stop where the overlay has one child and no value. descend_until_max_bytes follows. This is the same reasoning as the descend_to_val fix in 7eed493.
to_next_val_observed, to_next_get_val_observed and to_next_get_val_with_witness_observed returned false/None without moving. The trait says a false return means the iteration came back around to the root, and every other zipper (the native one, PrefixZipper since 70d3dd3) ends there. This is the same class as issue Adam-Vandervorst#137, whose fix (b5a0fb9) covered to_next_k_path but not to_next_val. They now rewind to the root and report the ascent to the observer. Every other iteration method already matched a read zipper over an empty map.
…Zipper rewind The crate fixes are carried on this branch (fix/overlay-zipper-until-moves, fix/empty-zipper-to-next-val-rewind), so the five entries that claimed those divergences go: [overlay_ascend_until_union_branch], [overlay_descend_until_filtered_value], and the three [empty: to_next_val_no_rewind]. 20000 inputs per source with --strict, each divergence classified. Without the fixes: 77 / 247 unclaimed divergences on overlay / overlay-filter, and the empty sources' to_next_val divergences were claimed by the generic [to_next_val_after_step] entry. With them, none on any of the four. Only the write-side trie_ref_owned_empty_node and wz_try_borrow_focus_below_dangling remain, as on every source. The corpus repros agree; 0 new over 20000 inputs on native, prefix, product, dependent, head and map.
A location on the prefix holds "the rest of the prefix, then the source", with the source's root value at the end of the prefix; a location off the prefix holds nothing. The subtrie methods ignored both: * get_focus / get_focus_at / try_borrow_focus forwarded to the source zipper, which sits at its own root while the focus is on the prefix, so graft, join_into, meet_into, subtract_into, restrict, graft_src_at and graft_masked_branches from the prefix read the source's root node, and from off the prefix the whole source. * trie_ref_at_path handed the path to the source without stripping the rest of the prefix, and read the source off the prefix. * make_map / try_make_map returned the whole source off the prefix, and over an empty source lost the prefix chain that path_exists and child_count report (it is a dangling path). The source's root value was dropped unless graft_root_vals is on. The prefix part is now built as an owned trie over the source's nodes (stem_map), as get_trie_ref already did; try_borrow_focus answers None on the prefix, since no stored node backs it. A location on the prefix can't be expressed with the source's TrieRefT, so PrefixZipper's TrieRefT becomes TrieRef.
* descend_until (and descend_until_max_bytes) consumed the rest of the prefix and kept descending into the source even when the source's root has a value or branches; it now stops there. * to_next_sibling_byte / to_prev_sibling_byte returned None one byte off the prefix, where the next prefix byte is a sibling, so to_next_step and to_prev_step from there stopped instead of moving to the next existing path. * to_next_k_path from off the prefix gave up, although the prefix may sort after the focus and hold the next location at that depth. * val_count off the prefix reported the source's whole count instead of 0.
…refix veto The crate fixes are carried on this branch (fix/prefix-zipper-view), so every src:prefix KNOWN entry goes (val_count_off_prefix, make_map_off_prefix x2, make_map_drops_empty_stem x2, descend_until_crosses_seam_value, sibling_off_prefix x2, trie_ref_ignores_prefix, ops prefix_focus_ignores_prefix), and so does the veto that skipped merges unless the focus was in the source (merge_at in sources/prefix.rs, prefixMergeAt in Sources/Prefix.lean): merges from the prefix are now checked against the model. --source prefix, 20000 inputs, seed 93. Without the fixes: 1077 unclaimed divergences, and generic entries claim 5274 more (meet_keeps_dangling 1780, join_into_empty_dst 817, graft_child_maps 726, subtract_drops_value 519, ...). With them: 0 new; the 1114 known hits left are write-side bugs fixed on other branches or unrelated (trie_ref_owned_empty_node, wz_try_borrow_focus, finding 8, join_into_empty_dst, meet_2 W1). The seven prefix corpus repros for these bugs agree; 0 new over 20000 inputs on native, empty, empty-new, overlay, map.
# Conflicts: # lean/differential.py # lean/findings/BUGS.md
set_/clear_/toggle_inclusive_bit_range read only the range's start() and end(). A RangeInclusive iterated to its end is empty, but both bounds then read `end`, so the methods acted on that bit; ByteMask::from of the same range (through RangeBounds) is correctly empty. An ordinary empty `a..=b` with a > b tripped BlockRange's debug_assert, though release did the right thing. Both are caught by RangeInclusive::is_empty, which is not const, so the three methods are no longer const fns. Nothing in the crate (or MORK) calls them in a const context.
The crate fix is carried on this branch (fix/byte-mask-empty-inclusive-range), so [u-mask M2: incl_range_exhausted] goes, and the notes about the debug-build assertion on `a > b` (M3) with it. --source util, 20000 inputs, seed 96: without the fix 274 unclaimed divergences, with it 0 new (the 3 known hits left are the SetLattice pmeet argument order, u-lattice). A debug build of the trace binary no longer panics in the bit-range edits.
… they take Carries the revised fix/byte-mask-empty-inclusive-range (e84c156): the three methods stay const and read emptiness from the bounds, so `a > b` does nothing (36a), while a range iterated to its end, whose bounds read `end..=end`, is documented as not taken (32a, documented rather than changed). Op 20 therefore no longer passes an exhausted range: its shape 2 is now `a..=b` after one next() when a < b (tag `p`), in Rust and in the Lean model. Op 2 still checks ByteMask::from on an exhausted range. No KNOWN entry. --source util, 20000 inputs, seed 96: 0 new (3 known hits, SetLattice pmeet). Debug build: no panics in the bit-range edits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Lean models and differential fuzzers for the parts of the API that were only crash-fuzzed or never run at all.
Coverage is measured against the 1428 functions that no fuzzer checked before; about 830–960 of them now have their
answers checked against a model.
one. There are 19 sources: native, act, tracker, overlay(-filter), diff, dependent(-lazy), head, owned, empty(-new),
prefix, product(g)(-full) and diff-product. Each has a Lean model of what it presents and which ops it can serve. KNOWN
entries can be keyed per source, so one zipper's bug can't hide another's.
k-path overrun and the path iterator. They come after master's 60–74.
ops, serialization and ACT files, catamorphisms/anamorphisms, prefix-tree round trips and ZipperHead sessions.
sort_paths(_par), and the viz/random/counters modules.
reproducer for each. Per-component write-ups are in lean/findings/*.md.