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
+14
View File
@@ -332,6 +332,20 @@ describe('gstack-telemetry-log', () => {
});
describe('.pending marker', () => {
test('--no-sweep (one-shot setup events) leaves other sessions\' in-flight markers untouched', () => {
setConfig('telemetry', 'anonymous');
const analyticsDir = path.join(tmpDir, 'analytics');
fs.mkdirSync(analyticsDir, { recursive: true });
const marker = path.join(analyticsDir, '.pending-live-456');
fs.writeFileSync(marker, '{"skill":"ship","ts":"2026-09-04T00:00:00Z","session_id":"live-456","gstack_version":"1.79.0.0"}');
run(`${BIN}/gstack-telemetry-log --event-type onboarding --skill _setup_playwright --outcome chromium-install --no-sweep`);
expect(fs.existsSync(marker)).toBe(true);
const events = parseJsonl();
expect(events).toHaveLength(1);
expect(events[0].event_type).toBe('onboarding');
expect(events[0].outcome).toBe('chromium-install');
});
test('finalizes stale .pending from another session as outcome:unknown', () => {
setConfig('telemetry', 'anonymous');