Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2791-native-worker-stale-ctime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Termux native worker: serving≠installed also sees a tar redeploy (#2791 2a).** `a2a_native_worker_stale_report` compares each process start with the later of the file's mtime and ctime, not the mtime alone. A tar redeploy keeps the build's mtime — on 2026-11-24 `dist/worker.js` kept `10:29:40` on both Termux nodes while its ctime was the deploy (~3.5 h later) — so a worker that kept serving old code after such a deploy would not have been reported. Still warn-only: nothing is restarted; a chmod/chown after start now also shows as changed. New test (mutation-checked): a worker.js with a 2000-01-01 mtime replaced after its process started is reported.
8 changes: 8 additions & 0 deletions scripts/a2a-termux-native-worker-health.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,14 @@ report=$(a2a_native_worker_stale_report "$TMP/elsewhere")
ok "worker_root limits workers but not the supervise loop" \
'! grep -qF "file=$WJS" <<<"$report" && grep -qF "file=$SUP_FILE" <<<"$report"'

# #2791 2a: a tar redeploy keeps the build's mtime, so only the ctime shows the
# file was replaced after its process started.
sleep 1.1
python3 -c 'import os, sys; os.utime(sys.argv[1], (946684800, 946684800))' "$WJS"
report=$(A2A_NATIVE_WORKER_STALE_SLACK_SECONDS=0 a2a_native_worker_stale_report "$STALE_DIR/wroot")
ok "a redeployed worker.js with its build mtime is caught by its ctime" \
'grep -F "file=$WJS" <<<"$report" | grep -q "^kind=worker pids=$W_FAKE "'

rm -f "$WJS"
report=$(a2a_native_worker_stale_report "$STALE_DIR/wroot")
ok "a deleted worker.js is reported as installed=missing" \
Expand Down
10 changes: 7 additions & 3 deletions scripts/lib/a2a-native-worker-stale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
# Scans this user's processes for the canonical supervise loop
# (`a2a-termux-native-worker.sh supervise`) and for `.../dist/worker.js`
# workers. Each process is compared with the file it actually runs: when that
# file's mtime is newer than the process start (plus a small slack) or the file
# is gone, one line per (kind, file) is printed:
# file changed after the process start (plus a small slack) or the file is
# gone, one line per (kind, file) is printed. "Changed" is the later of mtime
# and ctime: a tar redeploy keeps the build's mtime (2026-11-24: worker.js
# mtime 10:29:40 on both Termux nodes, deployed ~3.5 h later), and only the
# ctime says the file was replaced:
# kind=<supervise|worker> pids=<p1,p2> started=<UTC> installed=<UTC|missing> file=<path>
# With worker_root, only `<worker_root>/dist/worker.js` counts as a worker.
# Prints nothing when nothing is stale or when the check cannot run
Expand Down Expand Up @@ -91,7 +94,8 @@ for proc in glob.glob("/proc/[0-9]*"):
continue
started = wall_now - (boot_now - start_ticks / tick)
try:
installed = os.stat(path).st_mtime
st = os.stat(path)
installed = max(st.st_mtime, st.st_ctime) # tar keeps the build's mtime; ctime is the install (#2791 2a)
except OSError:
installed = None
if installed is not None and installed <= started + slack:
Expand Down
Loading