Lesson 107: Property-based assertions (Hypothesis)
Focus
Treat the excerpt as executable notes: Advanced drills Property-based assertions (Hypothesis); spin token 879588 makes this page unlike its neighbours.
Key ideas
- Angle
Advanced: micro cadence7mixesProperty-based assertions (Hypothesis); spin55004. - Ritual: Swap one benign literal twice to see binding effects.
- Guardrail: name the surprise that triggered when literals shifted.
Example (LESSON_UID = "advanced-107")
# Advanced drill L107 topic-10 micro-6 pattern-7
LESSON_UID = "advanced-107"
spin_a, spin_b, spin_c = 12, 614, 6
src = [((k + 107) * spin_a + 6) % 241 for k in range(4 + 6 % 3)]
derived = [v * v if v % 2 == 0 else v + spin_b for v in src]
print("src", src)
print("derived", derived)
print("zip_sum", sum(x + y for x, y in zip(src, derived)))
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-107.txt"
snap = [120, 142, 164, 186, 208]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (6 + 131))
import asyncio
async def finalize(seed, spin):
await asyncio.sleep(0)
blend = (seed * 131 + 10 * (10 % 997) + 6 * (6 % 853) + spin) % 900001
return blend
async def harness(loop_seed):
print("async_result", await finalize(loop_seed, 22267))
asyncio.run(harness(67171))
Practice
Practice 16: Inject a benign off-by-one, observe drift, revert with notes. Literal nudge 16.
Fingerprints
- lesson_uid:
advanced-107 - umbrella band:
Property-based assertions (Hypothesis)(7/10) - lesson_index:
3435