From f8befb15f434edd483c4fcbef034d21165663b82 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 22 Nov 2026 21:13:14 -0300 Subject: test/daemon.py: `--upgrade` keeps what a failure leaves: at any failure of `upgrades()` (`keep_evidence`, in .scratch/daemon/kept/upgrade--/, its path in the error) each terminal's bytes, its client's check file and stats (PARDES_REPLICA_STATS now set for the two clients of the build running), its process alive or not and where each of its threads waits (`where_waits`: state, wchan, syscall, fds), the session's screen and /log over 9P (dialled with its timeout), `pardes --ps`, the crash file and the session's and daemon's processes; the rejoin step says which client was not back and when the session was (its pass line when each came back), the kept-views step names the join before its assertion; the gate's upgrade-back row (release to Debug) had failed 2 of 6 at "the client joined again" keeping nothing of the clients (merge51, merge57); the first natural failure kept (one CPU, both builds fixed for the next two changes) showed it: client f gone, its last line "the session's dump loaded as another session (a build's dump is not complete)", the session back 0.3 s after the Upgrade, client e joined again Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/daemon.py | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 91 insertions(+), 8 deletions(-) (limited to 'test/daemon.py') diff --git a/test/daemon.py b/test/daemon.py index 9e0047e5..a2a6ae33 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -3271,6 +3271,64 @@ def ppid(pid): return int(open(f'/proc/{pid}/stat').read().rsplit(')', 1)[1].split()[1]) +def where_waits(pid): + """A process's state, a line each thread (its name, state, kernel wait + channel and the syscall it is in): alive or not, and blocked where.""" + if not alive(pid): + return f'{pid}: gone\n' + rows = [f'{pid}: alive, {b" ".join(cmdline(pid)).decode(errors="replace")[:300]}'] + try: + for tid in sorted(os.listdir(f'/proc/{pid}/task'), key=int): + t = f'/proc/{pid}/task/{tid}' + row = [] + for leaf in ('comm', 'wchan', 'syscall'): + try: + row.append(open(f'{t}/{leaf}').read().strip().split(' ')[0]) + except OSError: + row.append('?') + state = open(f'{t}/stat').read().rsplit(')', 1)[1].split()[0] + rows.append(f' {tid} {row[0]} {state} wchan {row[1]} syscall {row[2]}') + except OSError: + pass + return '\n'.join(rows + [f' fd {link}' for link in links(pid)]) + '\n' + + +def keep_evidence(label, root, env, binary, sock, pids, clients): + """What a failed step leaves for its reader, in a directory the run's + cleanup does not remove (.scratch/daemon/kept/