From 87b3530b293ed8635204d606cdca1b3756525fa1 Mon Sep 17 00:00:00 2001 From: bchanot Date: Sat, 14 Nov 2026 18:48:41 +0100 Subject: [PATCH 1/2] fix(tests): mods suite hung in a terminal, CLI under timeout now reads /dev/null --- lib/tests/mods.test.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tests/mods.test.sh b/lib/tests/mods.test.sh index f0efe1b..0ae2be2 100644 --- a/lib/tests/mods.test.sh +++ b/lib/tests/mods.test.sh @@ -17,13 +17,15 @@ ko() { fail=$((fail+1)); echo "FAIL $1"; } check() { if [ "$2" = "$3" ]; then ok "$1"; else ko "$1: got[$2] want[$3]"; fi; } # bounded CMD...: stdout+stderr on stdout, rc 124 on timeout. +# stdin from /dev/null: a CLI touching an inherited tty from timeout's +# background group gets SIGTTOU, which stops timeout too. bounded() { local t t=$(command -v timeout || command -v gtimeout || true) - if [ -n "$t" ]; then "$t" "$CLI_TIMEOUT" "$@" 2>&1; return; fi + if [ -n "$t" ]; then "$t" "$CLI_TIMEOUT" "$@" &1; return; fi local out rc=0 pid i=0 out=$(mktemp) || return 1 - "$@" >"$out" 2>&1 & pid=$! + "$@" "$out" 2>&1 & pid=$! while kill -0 "$pid" 2>/dev/null && [ "$i" -lt "$CLI_TIMEOUT" ]; do sleep 1; i=$((i+1)) done From adc0dff72d91a07d4236ec8cc9ef3ada291a4c60 Mon Sep 17 00:00:00 2001 From: bchanot Date: Sat, 14 Nov 2026 18:48:43 +0100 Subject: [PATCH 2/2] chore(memory): mods tty hang journal, LRN --- .claude/memory/journal.md | 1 + .claude/memory/learnings.md | 5 ++++ .../2026-11-14-mods-test-tty-hang-1300.md | 23 +++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 .claude/tasks/contracts/2026-11-14-mods-test-tty-hang-1300.md diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 9e39d4f..4649208 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -755,3 +755,4 @@ rules: - /bugfix perl-timeout-group: perl fallback runner leads own process group, kills group at deadline, TERMs leftovers (490ad83); challenge r1 FATAL (digest assertion impossible without tty, single quotes = SC2016, timeout(1) misread) → r3; verifier CONFORME (flip red), security PASS. Phase 4b-4d closed: digest-after-compaction proven by this run's auto-compact. Residue TODO: design-tool-gate.sh:70 same idiom. - BDR-125 close-out J: /reconcile clean (BLK-017 + 3 upstream), CHANGELOG BDR-125 delivered + gate 1 57 % + H6a + BLK-049 (69eb53f), D4 BUGS-FOUND items closed with reason, block I + phase 4b-4d TODO closed, EVAL-059 capitalized; close ritual: nothing new (LRN-289/290 already). User leftovers: E3 npm -g hand edit, faunosteo merge, LRN-270 bisect, W4-B AC9, game status words, cc oom proof. - E3 npm -g deny rows removed by user (692e4a5, merged 98e1800); my step list sent user to a 69-commit-stale branch, rebased by stash+ff. mods.test.sh hangs in a tty: claude CLI under timeout = background pgrp, SIGTTOU stops whole group incl. timeout → hotfix next. +- /hotfix mods-test-tty-hang: bounded() runs CLI with ' /dev/null`, not only headless runs. diff --git a/.claude/tasks/contracts/2026-11-14-mods-test-tty-hang-1300.md b/.claude/tasks/contracts/2026-11-14-mods-test-tty-hang-1300.md new file mode 100644 index 0000000..75660c0 --- /dev/null +++ b/.claude/tasks/contracts/2026-11-14-mods-test-tty-hang-1300.md @@ -0,0 +1,23 @@ +# CONTRACT — mods-test-tty-hang +- date: 2026-11-14 | flow: hotfix | branch: bugfix/mods-test-tty-hang (off develop) +- status: active + +## REQUEST (verbatim — IMMUTABLE) +lib/tests/mods.test.sh hangs forever when `make test` runs from an interactive terminal (user report 2026-11-14, stuck after "model-routing census: 141 pass" at "== lib/tests/mods.test.sh"; ps: `timeout 120 claude plugin validate --strict /tmp/…/cleanfix` and the claude child both in state T for 4h30). Root cause: timeout(1) without --foreground puts the command in its own (background) process group; the claude CLI inherits the tty on stdin and touches it, SIGTTOU stops the whole group including timeout, whose alarm then never fires. Non-tty runs (Claude sessions) are unaffected. Fix: `bounded()` (lib/tests/mods.test.sh:20-33) runs the command with stdin from /dev/null in both branches (timeout line :23 and the background fallback :26). 1 file. + +## CLARIFICATIONS +- [gated 2026-11-14] challenge skipped (stdin redirect, no control-flow change). Proof = pty reproduction with util-linux `script` before/after. + +## ACCEPTANCE CRITERIA +1. Both branches of bounded() read stdin from /dev/null. + CHECK: cd /home/bchanot/Documents/claude && sed -n '/^bounded()/,/^}/p' lib/tests/mods.test.sh | grep -c '