summaryrefslogtreecommitdiff
path: root/scripts/debug-execution
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-19 23:17:16 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-19 23:17:16 +0000
commit1e4649ebbeb1a51cc48f32c7195fe854847d1b10 (patch)
tree3f3e53e567dc59587259d101457a34b0a7193a5e /scripts/debug-execution
parenteeee3b60a1fd8dc8b8b92997f709ef65e4b2097f (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'scripts/debug-execution')
-rwxr-xr-xscripts/debug-execution34
1 files changed, 24 insertions, 10 deletions
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 <execution-id-or-prefix>
+# 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 <execution-id-or-prefix>}"
+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