fix: M8 review findings (restore ownership, barrier tool, World0 claimRef, CI selection, drill verdicts)

P1: restore-world.sh claims its objects path (mkdir) and the database (a held
session with a restore try-lock and the exclusive upgrade lock), and removes only
what it created, so a losing restore never drops a winner's schema.
P2: barrier Ready-pod selection via shared jsonpath helper with fixtures; barrier
pod fsGroup; script-generated pods inspected by the policy check; World0 PV claim
references protected; ci-paths.sh uses the event's real base and runs on
uncertainty; fault-drill asserts RTO and needs positive quarantine evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-09-30 22:53:11 -04:00
co-authored by Claude Opus 5.5
parent 5b482ad6a3
commit 3a34ae39bc
21 changed files with 584 additions and 80 deletions
+34
View File
@@ -0,0 +1,34 @@
# Fault-drill verdicts (sourced by tools/ops/fault-drill.sh; tested offline with
# fixtures by tools/ci/ops-lib-check.sh). Each prints PASS, or FAIL/INCONCLUSIVE with
# a reason; the drill passes a scenario only on PASS (review M8 P2: a missing
# observation is never a pass).
# rto_verdict <rto_ms> <budget_ms>: the ratified objective (ADR-0075: 60 s for dev/stage).
rto_verdict() {
if [[ "${1:-}" =~ ^[0-9]+$ ]] && [ "$1" -le "$2" ]; then echo PASS; else echo "FAIL rto ${1:-unknown} ms > ${2} ms"; fi
}
# empty_verdict <restarts> <last_exit_code> <quarantined_lines> <log_lines>
# Positive evidence only: the replacement host ran and logged "phase quarantined"
# (on an empty volume the database and builds are unchanged, so unavailable committed
# state is the only cause), and if its container ended, it ended with exit 4.
# Another exit (image, permission, crash) is a FAIL; no evidence is INCONCLUSIVE.
empty_verdict() {
local restarts="${1:-0}" code="${2:-}" quarantined="${3:-0}" lines="${4:-0}"
if [ -n "$code" ] && [ "$code" != 4 ]; then
echo "FAIL the host exited $code, not 4 (quarantined)"
elif [ "$quarantined" -gt 0 ]; then
echo PASS
elif [ "$restarts" = 0 ] && [ "$lines" = 0 ]; then
echo "INCONCLUSIVE the replacement host never ran (Pending, image pull or start failure?)"
else
echo "INCONCLUSIVE the host ran but logged no quarantine"
fi
}
# acks_verdict <dead_acked_max> <recovered_committed>: every acknowledgement the dead
# owner was observed to make is at or below the head its successor recovered.
acks_verdict() {
if [[ "${1:-}" =~ ^[0-9]+$ && "${2:-}" =~ ^[0-9]+$ ]] && [ "$1" -le "$2" ]; then echo PASS
else echo "FAIL acknowledged ${1:-?} > recovered ${2:-?}"; fi
}
+22
View File
@@ -0,0 +1,22 @@
# Shared pod-status helpers for the operations scripts (sourced, not executed).
#
# POD_STATUS_JSONPATH renders one line per pod, "<name>|<Ready status>|<deletion>",
# with plain kubectl jsonpath (no template variables): the Ready status is "True",
# "False" or empty when the pod has no Ready condition yet, and the deletion field is
# empty unless the pod is being deleted. single_ready_pod reads such lines on stdin
# and prints the one Ready pod not being deleted; zero or several candidates fail
# (review M8 P2: never concatenate names or guess). tools/ci/ops-lib-check.sh tests it
# offline with fixtures.
# shellcheck disable=SC2034 # Used by the scripts that source this file.
POD_STATUS_JSONPATH='{range .items[*]}{.metadata.name}{"|"}{.status.conditions[?(@.type=="Ready")].status}{"|"}{.metadata.deletionTimestamp}{"\n"}{end}'
single_ready_pod() {
local ready count
ready="$(awk -F'|' 'NF >= 2 && $1 != "" && $2 == "True" && $3 == "" {print $1}')"
count="$(grep -c . <<< "$ready" || true)"
if [ "$count" != 1 ]; then
echo "expected exactly one Ready pod, found $count${ready:+: ${ready//$'\n'/ }}" >&2
return 1
fi
printf '%s\n' "$ready"
}