interplane.Get Omega
Read in your language

synapse

A component of the AienOS ecosystem.

Brought by drakestapleton

branch main Branches Tags History

synapse / evidence / g2-content-defined-chunking / red-green / run-mutations.sh

37 lines · 2351 bytes Raw Blame History
1#!/usr/bin/env bash
2# Mutation runs for ADR 0003 G2 (issue #45): each mutation breaks one rule of the chunk
3# store, the G2 tests run, the output excerpt is saved, and the source is restored.
4# Run from the repository root on a clean tree: evidence/g2-content-defined-chunking/red-green/run-mutations.sh
5set -u
6out=evidence/g2-content-defined-chunking/red-green
7src=crates/synapse-store/src
8run() { # id file perl-substitution description
9 local id=$1 file=$2 subst=$3 desc=$4
10 cp "$src/$file" "/tmp/g2-mut-$file.bak"
11 perl -0pi -e "$subst" "$src/$file"
12 if cmp -s "$src/$file" "/tmp/g2-mut-$file.bak"; then echo "mutation $id did not apply" >&2; exit 1; fi
13 {
14 echo "## mutation $id: $desc"
15 cargo test --locked -p synapse-store --lib g2_tests 2>&1 \
16 | grep -E '^test .* \.\.\. |panicked at|^[a-z].*(assertion|must|differ|adds|chunk|refuse)|test result' \
17 | grep -v '^test result: ok. 0' | head -40
18 } > "$out/mutation-$id.txt"
19 cp "/tmp/g2-mut-$file.bak" "$src/$file"
20 grep -c 'FAILED$' "$out/mutation-$id.txt" | sed "s/^/$id failed tests: /"
21}
22run M1 lib.rs 's/ if drops \{\n let rebuilt/ if false && drops {\n let rebuilt/' \
23 "commit keeps every chunk (no deduplication against the chunk index)"
24run M2 segment.rs 's/let v2 = !self.chunks.is_empty\(\) \|\| !self.manifests.is_empty\(\);/let v2 = false;/' \
25 "the checkpoint segment index drops chunks and manifests"
26run M3 lib.rs 's/Some\(loc\) if loc.len == \*clen => \{\}/Some(_) | None if true => {}/' \
27 "replay accepts a manifest whose chunks are not indexed"
28run M4 chunk.rs 's/len as u64 > self.threshold_bytes/len as u64 >= self.threshold_bytes/' \
29 "a blob of exactly T bytes is chunked (threshold off by one)"
30run M5 lib.rs 's/if at != len \|\| computed != digest \{/if at != len {/' \
31 "a chunked read skips the BlobDigest check"
32run M6 lib.rs 's/overlay\.chunks\.extend\(enc\.chunks\.iter\(\)\.map\(\|\(d, _, _\)\| \*d\)\);/let _ = &enc.chunks;/' \
33 "chunks of records earlier in the same batch do not count as indexed"
34run M7 lib.rs 's/self\.blob_chunks\.entry\(m\.blob\)\.or_insert\(m\);/let _ = m;/' \
35 "replay forgets the manifests of replayed frames"
36run M8 wal2.rs 's/if ChunkDigest::compute\(bytes\) != d \{/if false \&\& ChunkDigest::compute(bytes) != d {/' \
37 "WAL v2 decode skips the chunk digest check"