-
Notifications
You must be signed in to change notification settings - Fork 1
Phase 7: full WorldlineState replay and checkpoint-backed playback #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5810cbe
219ba2c
a6ffe8f
e1e8e4b
dfd31bd
9d29321
7874587
4ab2bd7
8f868fb
2c2086a
1d94c7d
9f62438
3ae7143
c8df037
e753280
a78999e
7124311
754bd88
de346c9
a7b3355
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # © James Ross Ω FLYING•ROBOTS <https://github.com/flyingrobots> | ||
|
|
||
| hook_timing_now_ns() { | ||
| if command -v python3 >/dev/null 2>&1; then | ||
| python3 - <<'PY' | ||
| import time | ||
|
|
||
| print(time.monotonic_ns()) | ||
| PY | ||
| else | ||
| printf '%s000000000\n' "$(date +%s)" | ||
| fi | ||
| } | ||
|
|
||
| hook_timing_prepare() { | ||
| DX_HOOK_REPO_ROOT="$1" | ||
| DX_HOOK_NAME="$2" | ||
| DX_HOOK_START_NS="$(hook_timing_now_ns)" | ||
| DX_HOOK_TIMING_RECORDED=0 | ||
| } | ||
|
|
||
| hook_timing_append() { | ||
| local exit_code="${1:-$?}" | ||
| if [[ "${DX_HOOK_TIMING_RECORDED:-0}" == "1" ]]; then | ||
| return 0 | ||
| fi | ||
| DX_HOOK_TIMING_RECORDED=1 | ||
|
|
||
| local repo_root="${DX_HOOK_REPO_ROOT:-}" | ||
| local hook_name="${DX_HOOK_NAME:-}" | ||
| local start_ns="${DX_HOOK_START_NS:-}" | ||
| if [[ -z "$repo_root" || -z "$hook_name" || -z "$start_ns" ]]; then | ||
| return 0 | ||
| fi | ||
|
|
||
| local end_ns elapsed_ns elapsed_ms csv_dir csv_file timestamp_utc | ||
| end_ns="$(hook_timing_now_ns)" | ||
| elapsed_ns=$(( end_ns - start_ns )) | ||
| if (( elapsed_ns < 0 )); then | ||
| elapsed_ns=0 | ||
| fi | ||
| elapsed_ms=$(( elapsed_ns / 1000000 )) | ||
| csv_dir="${repo_root}/.dx-debug" | ||
| csv_file="${csv_dir}/${hook_name}-times.csv" | ||
| timestamp_utc="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" | ||
|
|
||
| mkdir -p "$csv_dir" 2>/dev/null || return 0 | ||
| if [[ ! -f "$csv_file" ]]; then | ||
| printf 'timestamp_utc,elapsed_ms,exit_code,pid\n' >>"$csv_file" 2>/dev/null || return 0 | ||
| fi | ||
|
Comment on lines
+49
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial CSV header write has a minor race condition. Two hooks starting simultaneously could both see a missing file and both append headers. For local dev tooling this is cosmetic. 🤖 Prompt for AI Agents |
||
| printf '%s,%s,%s,%s\n' \ | ||
| "$timestamp_utc" \ | ||
| "$elapsed_ms" \ | ||
| "$exit_code" \ | ||
| "$$" >>"$csv_file" 2>/dev/null || true | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,12 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # SPDX-License-Identifier: Apache-2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Parallel pre-push hook - runs stages concurrently with isolated target dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REPO_ROOT="$(cd "$HOOK_DIR/.." && pwd)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # shellcheck source=.githooks/_timing.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source "$HOOK_DIR/_timing.sh" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hook_timing_prepare "$REPO_ROOT" "pre-push-parallel" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd "$REPO_ROOT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PINNED_FROM_FILE=$(awk -F '"' '/^channel/ {print $2}' rust-toolchain.toml 2>/dev/null || echo "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PINNED="${PINNED:-${PINNED_FROM_FILE:-1.90.0}}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -31,16 +37,38 @@ fi | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "🐰 BunBun 🐇 (parallel mode)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOGDIR="" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOGDIR=$(mktemp -d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Trap EXIT, INT, TERM: kill background jobs then clean up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cleanup() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local exit_code="${1:-0}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Kill any background jobs from this script | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Avoid GNU-only xargs -r by checking if pids is non-empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pids=$(jobs -p 2>/dev/null) || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ -n "$pids" ] && echo "$pids" | xargs kill 2>/dev/null || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -rf "$LOGDIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -n "${LOGDIR:-}" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -rf "$LOGDIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hook_timing_append "$exit_code" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| on_exit() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local exit_code=$? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cleanup "$exit_code" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| on_signal() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local signal_name="$1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local exit_code=1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$signal_name" == "INT" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit_code=130 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif [[ "$signal_name" == "TERM" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit_code=143 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cleanup "$exit_code" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit "$exit_code" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trap cleanup EXIT INT TERM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trap on_exit EXIT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trap 'on_signal INT' INT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trap 'on_signal TERM' TERM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+54
to
+71
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '[repo]\n'
sed -n '54,71p' .githooks/pre-push-parallel
printf '\n[demo]\n'
bash <<'BASH' || true
set -euo pipefail
count=0
cleanup() { count=$((count + 1)); printf 'cleanup:%s\n' "$count"; }
on_exit() { cleanup; }
on_signal() { cleanup; exit 130; }
trap on_exit EXIT
trap 'on_signal' INT
kill -INT $$
BASHRepository: flyingrobots/echo Length of output: 453 🏁 Script executed: #!/bin/bash
# Examine the full cleanup function and timing append logic
cat -n .githooks/pre-push-parallel | sed -n '1,100p'Repository: flyingrobots/echo Length of output: 3715 🏁 Script executed: #!/bin/bash
# Check for early exits before trap registration (line 69)
grep -n "exit\|return" .githooks/pre-push-parallel | head -20Repository: flyingrobots/echo Length of output: 536 🏁 Script executed: #!/bin/bash
# Look for hook_timing_append to understand the timing side effects
rg "hook_timing_append|LOGDIR" .githooks/pre-push-parallel -A 2 -B 2Repository: flyingrobots/echo Length of output: 1428 🏁 Script executed: #!/bin/bash
# Examine the timing module to understand append side effects
cat .githooks/_timing.shRepository: flyingrobots/echo Length of output: 1561 Disarm the EXIT trap in the signal path. Line 66 calls 🔧 Proposed fix on_signal() {
local signal_name="$1"
local exit_code=1
if [[ "$signal_name" == "INT" ]]; then
exit_code=130
elif [[ "$signal_name" == "TERM" ]]; then
exit_code=143
fi
+ trap - EXIT
cleanup "$exit_code"
exit "$exit_code"
}Run the demo in the original comment to confirm Bash trap behavior. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Stage functions - each uses its own target dir and the pinned toolchain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run_fmt() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| set -euo pipefail | ||
| HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| REPO_ROOT="$(cd "$HOOK_DIR/.." && pwd)" | ||
| # shellcheck source=.githooks/_timing.sh | ||
| source "$HOOK_DIR/_timing.sh" | ||
| hook_timing_prepare "$REPO_ROOT" "pre-rebase" | ||
| trap 'hook_timing_append $?' EXIT | ||
| echo "[pre-rebase] Rebase is disallowed for this repository. Use merge instead." >&2 | ||
| exit 1 | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,8 @@ target-clippy | |||||||||
| target-test | ||||||||||
| target-doc | ||||||||||
| .githooks/timing.jsonl | ||||||||||
| .dx-debug/* | ||||||||||
| blog/* | ||||||||||
|
Comment on lines
+14
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Gitignore patterns may not cover nested subdirectories.
-.dx-debug/*
-blog/*
+.dx-debug/
+blog/📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| docs/.vitepress/cache | ||||||||||
|
|
||||||||||
| # Editor cruft | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Fallback mixing could produce invalid deltas if python3 availability changes mid-hook.
If
python3is available athook_timing_preparebut not athook_timing_append(or vice versa), you'll subtract epoch-seconds-as-nanoseconds from monotonic nanoseconds, producing garbage. The negative clamp at line 41-43 catches the symptom but masks the cause.This is local dev tooling and the scenario is unlikely, so low priority.
Possible fix: cache the timing method at prepare time
hook_timing_prepare() { DX_HOOK_REPO_ROOT="$1" DX_HOOK_NAME="$2" + if command -v python3 >/dev/null 2>&1; then + DX_HOOK_TIMING_METHOD="python" + else + DX_HOOK_TIMING_METHOD="date" + fi DX_HOOK_START_NS="$(hook_timing_now_ns)" DX_HOOK_TIMING_RECORDED=0 }Then use
DX_HOOK_TIMING_METHODinhook_timing_now_nsto ensure consistent method.🤖 Prompt for AI Agents