From f04c12275113e7eba725e2f9896ff262bfb73d8d Mon Sep 17 00:00:00 2001 From: jeremiah-masters <168492100+jeremiah-masters@users.noreply.github.com> Date: Fri, 14 Aug 2026 14:50:07 +1000 Subject: [PATCH] Add an entry-placement invariant for the two-generation gate rsEntryHomePure requires a live slot entry to sit in the bin its key hashes to at that bin's generation. It is the slotVal counterpart of hashConsistency, which only constrains the slot key word and goes vacuous once a slot has been sentinelled, so without it the anchor could place a live entry in a bin no key routes to. That gap produced the two maxGen=2 consecution counterexamples, rsChildFreeSlot and rsChildKeyFresh. --- spec/consecution_sweep.sh | 21 +++++++---- spec/invariants.qnt | 40 ++++++++++++++++++++- spec/system_induction.qnt | 1 + spec/verify/induction_resize_1gen_1proc.qnt | 1 + spec/verify/induction_resize_1gen_2proc.qnt | 1 + spec/verify/induction_resize_2gen_2proc.qnt | 1 + 6 files changed, 57 insertions(+), 8 deletions(-) diff --git a/spec/consecution_sweep.sh b/spec/consecution_sweep.sh index 63a9946..67fcbe0 100755 --- a/spec/consecution_sweep.sh +++ b/spec/consecution_sweep.sh @@ -2,14 +2,14 @@ # Parallel, memory-safe consecution sweep — the practical way to discharge the # system consecution gate (inv ∧ rsInv INDUCTIVE over systemStep) when the # monolithic `quint verify --invariant=inv --max-steps=1` is too slow (~15h at -# 2-proc 1gen). Splits the 47 g_* family localizers into N groups, each checked +# 2-proc 1gen). Splits the 48 g_* family localizers into N groups, each checked # concurrently as one `quint verify --invariants ...` on its OWN Apalache server # (--server-endpoint distinct port — the "one verify at a time" limit is only the # shared default port 8822). # # SOUNDNESS: every group runs from the SAME full anchor (init = systemIndInit = -# invPure ∧ rsInvPure), and the 47 families are a complete, distinct partition of -# inv ∧ rsInv (count==47 AND sort -u ==47 asserted below). So ALL groups [ok] is +# invPure ∧ rsInvPure), and the 48 families are a complete, distinct partition of +# inv ∧ rsInv (count==48 AND sort -u ==48 asserted below). So ALL groups [ok] is # equivalent to the monolithic consecution [ok]. (A SWEEP_FAMILIES SUBSET proves # ONLY those families, NOT the full gate — the OVERALL verdict says so.) Verdict is read from the # `[ok] No violation found` / `[violation]` markers, NOT the process exit code @@ -48,9 +48,9 @@ SHED_DELTA=9999999 # swap-growth trigger DISABLED on purpose (avail is the only [[ -f "$CFG" ]] || { echo "FATAL: config not found: $CFG (run from spec/ or pass a valid path)"; exit 1; } mkdir -p "$LOGDIR" -# The complete g_* partition of inv ∧ rsInv (33 invPure families incl typeOK + 14 rsInvPure). +# The complete g_* partition of inv ∧ rsInv (33 invPure families incl typeOK + 15 rsInvPure). # SWEEP_FAMILIES (space-separated g_* names) overrides this with a SUBSET for -# targeted re-verification of specific families; the full-47 completeness assertion +# targeted re-verification of specific families; the full-48 completeness assertion # is skipped for a subset, but the no-duplicates assertion always applies. if [[ -n "${SWEEP_FAMILIES:-}" ]]; then FAMILIES=($SWEEP_FAMILIES); else FAMILIES=( @@ -68,10 +68,11 @@ FAMILIES=( g_rsCursorCoherence g_rsCompleteness g_rsChildFreeSlot g_rsClaimContinuity g_h0LoadedNoTransfer g_rsChildKeyFresh g_hLoopLoadedNoTransfer g_shadowGhostForm g_lc10AtDone g_tryingOwnerUnique g_carriedClaimExists + g_rsEntryHome ) fi TOTAL=${#FAMILIES[@]} -[[ -n "${SWEEP_FAMILIES:-}" ]] || [[ "$TOTAL" -eq 47 ]] || { echo "FATAL: expected 47 families, got $TOTAL"; exit 1; } +[[ -n "${SWEEP_FAMILIES:-}" ]] || [[ "$TOTAL" -eq 48 ]] || { echo "FATAL: expected 48 families, got $TOTAL"; exit 1; } UNIQ=$(printf '%s\n' "${FAMILIES[@]}" | sort -u | wc -l | tr -d ' '); [[ "$UNIQ" -eq "$TOTAL" ]] || { echo "FATAL: duplicate families ($UNIQ unique of $TOTAL)"; exit 1; } avail_mb() { vm_stat 2>/dev/null | awk '/page size of/{for(i=1;i<=NF;i++) if($i ~ /^[0-9]+$/){ps=$i;break}} /^Pages free/{gsub(/\./,"",$3);f=$3} /^Pages inactive/{gsub(/\./,"",$3);n=$3} /^Pages speculative/{gsub(/\./,"",$3);s=$3} /^Pages purgeable/{gsub(/\./,"",$3);p=$3} END{if(ps>0) print int((f+n+s+p)*ps/1048576); else print -1}'; } @@ -103,7 +104,13 @@ base_swap=$(swap_used_mb) [[ $any -eq 0 ]] && break if [[ $reaped -eq 0 && $t -ge $REAP_AFTER ]]; then reaped=1 for g in $(seq 0 $((N-1))); do kill -0 "${PID[$g]}" 2>/dev/null || continue - [[ "$(server_cpu_on_port ${PORT[$g]})" -lt 15 ]] && { echo "MONITOR: group $g handshake-hung — killing" >>"$LOGDIR/grp${g}.log"; kill_group $g; } + # A completed gRPC handshake is signalled by Apalache emitting ANY + # `PASS #N` line; its absence after REAP_AFTER is the true hang. The old + # CPU-time heuristic parsed `ps -o time=` as macOS `MM:SS.ff` and thus + # UNDERCOUNTED on Linux (`HH:MM:SS`), false-killing healthy 2gen solves + # (which reach BoundedChecker with <15 parsed "seconds"). Log-progress is + # platform-independent and is the signal we actually mean. + grep -qE 'PASS #[0-9]' "$LOGDIR/grp${g}.log" 2>/dev/null || { echo "MONITOR: group $g handshake-hung (no Apalache PASS after ${REAP_AFTER}s) — killing" >>"$LOGDIR/grp${g}.log"; kill_group $g; } done fi av=$(avail_mb); sw=$(( $(swap_used_mb) - base_swap )) diff --git a/spec/invariants.qnt b/spec/invariants.qnt index 32b522c..30247f3 100644 --- a/spec/invariants.qnt +++ b/spec/invariants.qnt @@ -1131,6 +1131,43 @@ module invariants { | None => true })) + // R24 (2gen consecution support — counterexample-driven, grp3 rsChildFreeSlot + // + grp4 rsChildKeyFresh): ENTRY placement. Every live entry sits in the bin + // its key hashes to FOR THAT BIN'S GENERATION: + // slotVal[b][s] == Some(e) ==> binFor(e.k, genOfBin(b)) == b. + // + // This is the ENTRY (slotVal) analogue of hashConsistency, which pins only + // the slotKey WORD. The two diverge exactly at a sentineled slot: rsMove + // rewrites slotKey -> HSentinel but (deliberately, per R11's no-clear rule) + // does NOT clear slotVal, so a mid-transfer parent slot carries slotKey == + // HSentinel while still holding its original entry. hashConsistency's HKey + // arm is then vacuous and NOTHING constrains that entry's key — so the anchor + // was free to fabricate a sentineled slot in bin b holding an entry whose key + // routes to a DIFFERENT bin. rsChildFreeSlot (R12b) and rsChildKeyFresh (R16) + // both route the pending entry by slotVal.k (they must — the slotKey is a + // sentinel), so a misrouted entry made them target the wrong child and fail: + // two gen-1 bins carrying the same key into one gen-2 child (grp4 collision), + // or a concurrent insert filling the child that a misrouted carry then needs + // (grp3 exhaustion). Both CEX pre-states park a live entry in a bin NO key + // hashes to (bin3, gen1-odd, in the k1->0/k2->2 configs) — impossible for a + // reachable slotVal. + // Reachable-true because every slotVal WRITE is binFor-addressed: Insert / + // LC publish to binFor(k, local.gen) (== b, with genOfBin(b) == local.gen); + // rsMove / rsShadowCarry publish the child at binFor(k, genOfBin(parent)+1) + // (== cb, with genOfBin(cb) == genOfBin(parent)+1); Delete / abort clear to + // None (vacuous). No step writes an entry to a non-home bin, so this anchor + // conjunct is SELF-SUPPORTING (inductive with no new support lemma). + // In rsInvPure, not invPure: at maxGen=0 there is one bin and binFor(_,0) + // == 1 for every key, so the clause is trivially true (Phase-0 inert), and + // the sentinel divergence that motivates it cannot occur without a resize. + pure def rsEntryHomePure(st: SpecState): bool = + binDomain.forall(b => + slotIdx.forall(s => + match st.slotVal.get(b).get(s) { + | Some(e) => binFor(e.k, genOfBin(b)) == b + | None => true + })) + // R12: cross-generation claim continuity (§7.7, the PRECISE form): at most // one Shadow-k among NoTransfer bins (parent InTransfer exempt during the // carry window; dead parents exempt forever). @@ -1266,7 +1303,8 @@ module invariants { shadowGhostFormPure(st) and lc10AtDonePure(st) and tryingOwnerUniquePure(st) and - carriedClaimExistsPure(st) + carriedClaimExistsPure(st) and + rsEntryHomePure(st) // (The live rsInv wrapper lives in system.qnt per the wiring rule — NOT // here.) diff --git a/spec/system_induction.qnt b/spec/system_induction.qnt index e5eb719..c33d762 100644 --- a/spec/system_induction.qnt +++ b/spec/system_induction.qnt @@ -167,4 +167,5 @@ module system_induction { def g_lc10AtDone = lc10AtDonePure(currentSpecState) def g_tryingOwnerUnique = tryingOwnerUniquePure(currentSpecState) def g_carriedClaimExists = carriedClaimExistsPure(currentSpecState) + def g_rsEntryHome = rsEntryHomePure(currentSpecState) } diff --git a/spec/verify/induction_resize_1gen_1proc.qnt b/spec/verify/induction_resize_1gen_1proc.qnt index e9f81f7..6299b01 100644 --- a/spec/verify/induction_resize_1gen_1proc.qnt +++ b/spec/verify/induction_resize_1gen_1proc.qnt @@ -69,4 +69,5 @@ module induction_resize_1gen_1proc { def g_lc10AtDone = sysi::g_lc10AtDone def g_tryingOwnerUnique = sysi::g_tryingOwnerUnique def g_carriedClaimExists = sysi::g_carriedClaimExists + def g_rsEntryHome = sysi::g_rsEntryHome } diff --git a/spec/verify/induction_resize_1gen_2proc.qnt b/spec/verify/induction_resize_1gen_2proc.qnt index 6ad34a9..1690177 100644 --- a/spec/verify/induction_resize_1gen_2proc.qnt +++ b/spec/verify/induction_resize_1gen_2proc.qnt @@ -67,4 +67,5 @@ module induction_resize_1gen_2proc { def g_lc10AtDone = sysi::g_lc10AtDone def g_tryingOwnerUnique = sysi::g_tryingOwnerUnique def g_carriedClaimExists = sysi::g_carriedClaimExists + def g_rsEntryHome = sysi::g_rsEntryHome } diff --git a/spec/verify/induction_resize_2gen_2proc.qnt b/spec/verify/induction_resize_2gen_2proc.qnt index 9b74af0..2429f57 100644 --- a/spec/verify/induction_resize_2gen_2proc.qnt +++ b/spec/verify/induction_resize_2gen_2proc.qnt @@ -69,4 +69,5 @@ module induction_resize_2gen_2proc { def g_lc10AtDone = sysi::g_lc10AtDone def g_tryingOwnerUnique = sysi::g_tryingOwnerUnique def g_carriedClaimExists = sysi::g_carriedClaimExists + def g_rsEntryHome = sysi::g_rsEntryHome }