From 2ed525b9f5751861f7820a1abe0864526b79d4d1 Mon Sep 17 00:00:00 2001 From: oqyude Date: Sat, 24 Oct 2026 02:28:32 +0300 Subject: [PATCH] chore: anchor the `scripts` ignore rule and keep the guard verifier (T48) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .gitignore had `scripts` as an unanchored pattern. A pattern without a slash matches a directory of that name at ANY depth, so a future modules/*/scripts/ would have been silently ignored — the kind of thing that only shows up as "why is my file not in git". It is anchored to /scripts/ now. No tracked file was matched before or after (verified with `git ls-files | git check-ignore --stdin --no-index`, empty both ways). The 22 scripts in .temp/ are not committed wholesale: they are eight iterations of one T4 test (t4-final-v5..v8), three of another (t4-live-test{,v2,v3}), plus one-shot deploy/cleanup/diagnose scripts that hardcode `cd /mnt/s/Git/nixos` and perform umount / mount --move. Committing them would be noise, not knowledge. One of them is reusable and non-destructive, so it is preserved: .ci/verify/guard-non-destructive-verify.sh. It creates two throwaway systemd units (ConditionPathIsMountPoint=/nonexistent must refuse to start, =/mnt/services must start) and resets them, so it can be run against a live host to prove the condition is evaluated at all. That is the check the owner needs for T52. Content is byte-identical to the .temp original (md5 b0ac8081aae568a3db921fb64f4c0a05) and passes shellcheck -S error. Not pushed. --- .ci/verify/guard-non-destructive-verify.sh | 54 ++++++++++++++++++++++ .gitignore | 5 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .ci/verify/guard-non-destructive-verify.sh diff --git a/.ci/verify/guard-non-destructive-verify.sh b/.ci/verify/guard-non-destructive-verify.sh new file mode 100644 index 0000000..ec9993b --- /dev/null +++ b/.ci/verify/guard-non-destructive-verify.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Non-destructive verification of ConditionPathIsMountPoint guard logic. +# Creates two test systemd units: +# 1. ConditionPathIsMountPoint=/nonexistent — should FAIL to start +# 2. ConditionPathIsMountPoint=/mnt/services — should SUCCEED (real mount) +# Proves the guard condition is evaluated correctly by systemd. + +set -uo pipefail + +echo "=== postgresql guard in runtime (real production unit) ===" +systemctl show postgresql -p ConditionPathIsMountPoint -p RequiresMountsFor +echo + +echo "=== Test 1: ConditionPathIsMountPoint=/nonexistent (should FAIL) ===" +sudo systemd-run \ + --unit=test-guard-nonexistent \ + --property=ConditionPathIsMountPoint=/nonexistent/path/does/not/exist \ + --property=Type=oneshot \ + --property=ExecStart=/bin/true \ + --no-block 2>&1 +sleep 1 +STATE1=$(systemctl is-active test-guard-nonexistent 2>&1) +echo " is-active: $STATE1" +JOURNAL1=$(journalctl -u test-guard-nonexistent -n 5 --no-pager 2>&1 | grep -iE "condition|failed|skipped" | head -3) +echo " journal: $JOURNAL1" +sudo systemctl reset-failed test-guard-nonexistent 2>/dev/null || true +echo + +echo "=== Test 2: ConditionPathIsMountPoint=/mnt/services (should PASS) ===" +sudo systemd-run \ + --unit=test-guard-real \ + --property=ConditionPathIsMountPoint=/mnt/services \ + --property=Type=oneshot \ + --property=ExecStart=/bin/true \ + --no-block 2>&1 +sleep 1 +STATE2=$(systemctl is-active test-guard-real 2>&1) +echo " is-active: $STATE2" +JOURNAL2=$(journalctl -u test-guard-real -n 5 --no-pager 2>&1 | grep -iE "condition|started|active" | head -3) +echo " journal: $JOURNAL2" +sudo systemctl reset-failed test-guard-real 2>/dev/null || true +echo + +echo "=== Verdict ===" +if [ "$STATE1" = "inactive" ] || [ "$STATE1" = "failed" ]; then + echo " Test 1 (nonexistent path): CORRECT — unit refused to start (condition false)" +else + echo " Test 1 (nonexistent path): UNEXPECTED — unit started despite condition" +fi +if [ "$STATE2" = "active" ] || [ "$STATE2" = "activating" ]; then + echo " Test 2 (real mount /mnt/services): CORRECT — unit started (condition true)" +else + echo " Test 2 (real mount /mnt/services): UNEXPECTED — unit did not start" +fi diff --git a/.gitignore b/.gitignore index be8a925..ea68b90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,10 @@ .vscode .omo __pycache__ -scripts +# Anchored on purpose: the unanchored pattern matched any directory named +# `scripts` at any depth, so a future modules/*/scripts/ would have been +# silently ignored. Only the repo-root debris dir is meant here. +/scripts/ .temp .opencode/ # H_fix.* regression session debris (helper scripts + in-place edit backups).