From 5277e8d58206133d9b1254daee9f79461011cde4 Mon Sep 17 00:00:00 2001 From: Midia Kiasat Date: Mon, 9 Mar 2026 17:30:37 +0100 Subject: [PATCH] Harden irrevocull judgment contract and repository precondition --- irrevocull.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/irrevocull.sh b/irrevocull.sh index 4c1e713..dca9e07 100755 --- a/irrevocull.sh +++ b/irrevocull.sh @@ -1,18 +1,30 @@ #!/bin/sh -# IRREVOCULL v0.0.0 +# IRREVOCULL v0.1.0 # Irreversible Judgment Utility # Judgment only. No execution. No mitigation. No appeal. set -eu -# Read stdin (verbatim) +# --- Preconditions --------------------------------------------------------- + +git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { + printf '%s\n' "IRREVOCULL: not a git repository" >&2 + exit 2 +} + +# --- Input ----------------------------------------------------------------- + INPUT="$(cat)" -# Rule 0 — Silence is invalid -[ -z "$INPUT" ] && { printf '%s\n' "INVALID"; exit 2; } +[ -z "$INPUT" ] && { + printf '%s\n' "DENIED" + exit 1 +} TEXT="$(printf '%s' "$INPUT")" +# --- Judgment Rules -------------------------------------------------------- + # Rule 1 — Incompleteness is terminal printf '%s' "$TEXT" | grep -Eiq \ '(^|[^a-z])(todo|tbd|fixme|wip|partial|incomplete|later|edge case|skipped|hack)([^a-z]|$)' \ @@ -21,15 +33,15 @@ printf '%s' "$TEXT" | grep -Eiq \ # Rule 2 — Uncertainty voids judgment printf '%s' "$TEXT" | grep -Eiq \ '(^|[^a-z])(maybe|might|could|should|approx|guess|try|attempt|assume|probably)([^a-z]|$)' \ - && { printf '%s\n' "INVALID"; exit 2; } + && { printf '%s\n' "DENIED"; exit 1; } # Rule 3 — Questions indicate misalignment printf '%s' "$TEXT" | grep -Eq '\?' \ - && { printf '%s\n' "INVALID"; exit 2; } + && { printf '%s\n' "DENIED"; exit 1; } # Rule 4 — Over-explanation signals lack of conviction LINES="$(printf '%s' "$TEXT" | wc -l | tr -d ' ')" -[ "$LINES" -gt 300 ] && { printf '%s\n' "INVALID"; exit 2; } +[ "$LINES" -gt 300 ] && { printf '%s\n' "DENIED"; exit 1; } # Rule 5 — Excessive qualification density WORDS="$(printf '%s' "$TEXT" | wc -w | tr -d ' ')" @@ -37,8 +49,8 @@ QUALS="$(printf '%s' "$TEXT" | grep -Eio \ '(however|but|although|generally|typically|in most cases)' | wc -l | tr -d ' ')" [ "$WORDS" -gt 0 ] && [ "$QUALS" -gt $((WORDS / 100)) ] && { - printf '%s\n' "INVALID" - exit 2 + printf '%s\n' "DENIED" + exit 1 } printf '%s\n' "PASS"