fix(telemetry): one-shot setup events never sweep other sessions' pending markers

gstack-telemetry-log finalizes every .pending-<session> marker that is not
the caller's own as outcome:unknown and deletes it. setup's onboarding
events (_setup_welcome, _setup_playwright) have no session of their own, so
a Chromium bootstrap failure during a live skill session recorded a false
unknown for that session and removed its marker.

New --no-sweep flag skips the stale-marker pass; both setup call sites use
it (the synthetic --session-id did not prevent the sweep). Surfaced by the
Codex adversarial pass.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-09-04 17:28:00 +00:00
co-authored by Claude Fable 5.1
parent b23b784bcf
commit 29237ff9a8
3 changed files with 35 additions and 4 deletions
+10
View File
@@ -10,6 +10,11 @@
# gstack-telemetry-log --skill qa --duration 142 --outcome success \
# --used-browse true --session-id "12345-1710756600"
#
# --no-sweep one-shot events with no session of their own (setup's
# onboarding events) must not finalize OTHER sessions' in-flight
# .pending markers as outcome:unknown — only a skill's own
# epilogue may sweep.
#
# Env overrides (for testing):
# GSTACK_STATE_DIR — override ~/.gstack state directory
# GSTACK_DIR — override auto-detected gstack root
@@ -48,9 +53,11 @@ SEC_PAYLOAD_HASH=""
SEC_CONFIDENCE=""
SEC_LAYER=""
SEC_VERDICT=""
NO_SWEEP=""
while [ $# -gt 0 ]; do
case "$1" in
--no-sweep) NO_SWEEP=1; shift ;;
--skill) SKILL="$2"; shift 2 ;;
--duration) DURATION="$2"; shift 2 ;;
--outcome) OUTCOME="$2"; shift 2 ;;
@@ -93,7 +100,10 @@ fi
# ─── Finalize stale .pending markers ────────────────────────
# Each session gets its own .pending-$SESSION_ID file to avoid races
# between concurrent sessions. Finalize any that don't match our session.
# --no-sweep (one-shot events from setup) skips this: a marker that is not
# ours is another live session's, not a stale one.
for PFILE in "$PENDING_DIR"/.pending-*; do
[ -z "$NO_SWEEP" ] || break
[ -f "$PFILE" ] || continue
# Skip our own session's marker (it's still in-flight)
PFILE_BASE="$(basename "$PFILE")"