From 1e4649ebbeb1a51cc48f32c7195fe854847d1b10 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Thu, 19 Mar 2026 23:17:16 +0000 Subject: chore: improve debug-execution script and add ADR-007 - debug-execution: default to most recent execution when no ID given - docs/adr/007: planning layer and story model design decisions Co-Authored-By: Claude Sonnet 4.6 --- scripts/debug-execution | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/debug-execution b/scripts/debug-execution index 87540b7..b4873b9 100755 --- a/scripts/debug-execution +++ b/scripts/debug-execution @@ -1,13 +1,14 @@ #!/usr/bin/env bash # debug-execution: Show details for a failed task execution from the production DB. -# Usage: ./scripts/debug-execution +# Usage: ./scripts/debug-execution [execution-id-or-prefix] # Example: ./scripts/debug-execution c74c877f +# If no ID is given, defaults to the most recent execution. set -euo pipefail DB="/site/doot.terst.org/data/claudomator.db" DATA_DIR="/site/doot.terst.org/data" -PREFIX="${1:?Usage: $0 }" +PREFIX="${1:-}" if [[ ! -f "$DB" ]]; then echo "ERROR: DB not found at $DB" >&2 @@ -15,16 +16,29 @@ if [[ ! -f "$DB" ]]; then fi # Look up execution -ROW=$(sqlite3 "$DB" " - SELECT id, task_id, exit_code, status, stdout_path, stderr_path, error_msg - FROM executions - WHERE id LIKE '${PREFIX}%' - ORDER BY start_time DESC - LIMIT 1; -") +if [[ -z "$PREFIX" ]]; then + ROW=$(sqlite3 "$DB" " + SELECT id, task_id, exit_code, status, stdout_path, stderr_path, error_msg + FROM executions + ORDER BY start_time DESC + LIMIT 1; + ") +else + ROW=$(sqlite3 "$DB" " + SELECT id, task_id, exit_code, status, stdout_path, stderr_path, error_msg + FROM executions + WHERE id LIKE '${PREFIX}%' + ORDER BY start_time DESC + LIMIT 1; + ") +fi if [[ -z "$ROW" ]]; then - echo "ERROR: No execution found matching '${PREFIX}'" >&2 + if [[ -z "$PREFIX" ]]; then + echo "ERROR: No executions found in DB" >&2 + else + echo "ERROR: No execution found matching '${PREFIX}'" >&2 + fi exit 1 fi -- cgit v1.2.3