@gotcos/glasses-server 6.91.1 → 6.93.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/.env.example +64 -2
  2. package/CHANGELOG.md +154 -29
  3. package/README.md +90 -1
  4. package/docs/active-query-jobs.md +1 -1
  5. package/docs/test-plan-6.71.7.md +1 -1
  6. package/managed-runtime-contract.json +10 -1
  7. package/package.json +2 -1
  8. package/server/lib/ask-session-id.ts +2 -1
  9. package/server/lib/claude-circuit.ts +8 -4
  10. package/server/lib/claude-text-runner.ts +113 -0
  11. package/server/lib/dictation-fillers-fixture-cases.ts +214 -0
  12. package/server/lib/dictation-fillers.ts +30 -0
  13. package/server/lib/dictation-meaning-guard.ts +47 -0
  14. package/server/lib/dictation-polish-pipeline.ts +90 -12
  15. package/server/lib/embedding-eviction.ts +60 -2
  16. package/server/lib/fuzzy-correct.ts +1 -1
  17. package/server/lib/hallucination-filter.ts +1 -1
  18. package/server/lib/imported-library-rows.ts +4 -2
  19. package/server/lib/live-cos-ask.ts +3 -2
  20. package/server/lib/mac-live-voices.ts +57 -0
  21. package/server/lib/mac-recording-asr.ts +16 -8
  22. package/server/lib/mac-speaker-projection.ts +211 -0
  23. package/server/lib/mac-stream-diarizer.ts +185 -0
  24. package/server/lib/mac-voice-assignment.ts +361 -0
  25. package/server/lib/mac-voice-labels.ts +70 -8
  26. package/server/lib/mac-window-replay.ts +271 -0
  27. package/server/lib/mac-window-voices.ts +390 -0
  28. package/server/lib/meeting-actions.ts +1 -1
  29. package/server/lib/meeting-ask-owner.ts +4 -4
  30. package/server/lib/meeting-ask-transcript-sources.ts +41 -3
  31. package/server/lib/meeting-audio-archive.ts +4 -0
  32. package/server/lib/meeting-batch-transcribe.ts +7 -1
  33. package/server/lib/meeting-context-keys.ts +6 -3
  34. package/server/lib/meeting-corrections.ts +4 -4
  35. package/server/lib/meeting-fact-check.ts +3 -3
  36. package/server/lib/meeting-parse.ts +1 -1
  37. package/server/lib/meeting-relabel-enrolment.ts +8 -8
  38. package/server/lib/meeting-relabel.ts +3 -3
  39. package/server/lib/meeting-scribe-content.ts +1 -1
  40. package/server/lib/meeting-speaker-review.ts +8 -8
  41. package/server/lib/meeting-store.ts +19 -9
  42. package/server/lib/nemotron-final.ts +114 -9
  43. package/server/lib/nemotron-live.ts +58 -6
  44. package/server/lib/phone-recording.ts +114 -0
  45. package/server/lib/prompt-edit.ts +84 -3
  46. package/server/lib/prompt-tail-guard.ts +1 -1
  47. package/server/lib/speaker-embeddings.ts +154 -28
  48. package/server/lib/speaker-name.ts +1 -1
  49. package/server/lib/stranded-session-actions.ts +7 -2
  50. package/server/lib/token-audit.ts +6 -1
  51. package/server/lib/training-audio-provenance.ts +3 -2
  52. package/server/lib/transcript-cleanup-context.ts +3 -3
  53. package/server/lib/transcript-cleanup-model.ts +1 -1
  54. package/server/lib/transcript-cleanup-spans.ts +10 -10
  55. package/server/lib/transcript-cleanup-text.ts +4 -4
  56. package/server/lib/transcript-cleanup.ts +1 -1
  57. package/server/lib/unsaved-audio-quarantine.ts +10 -1
  58. package/server/lib/voice-directory.ts +1 -1
  59. package/server/lib/voice-evidence-guard.ts +2 -1
  60. package/server/lib/voice-profile-store.ts +11 -5
  61. package/server/lib/whisper-local.ts +1 -1
  62. package/server/routes/dictation-polish-settings.ts +8 -1
  63. package/server/routes/health.ts +8 -0
  64. package/server/routes/meeting.ts +189 -19
  65. package/server/routes/meetings.ts +9 -5
  66. package/server/routes/prompt-drafts.ts +3 -2
  67. package/server/routes/prompt-edit.ts +47 -5
  68. package/server/routes/transcribe-stream.ts +140 -15
  69. package/server/routes/voice.ts +12 -4
  70. package/server/scripts/dictation-parity-6920-mutation-gate.mjs +229 -0
  71. package/server/scripts/generate-dictation-fillers-fixture.ts +18 -0
  72. package/server/scripts/mac-voice-assignment-6930-mutation-gate.mjs +225 -0
  73. package/server/scripts/mac-window-voices-6930-mutation-gate.mjs +193 -0
@@ -0,0 +1,193 @@
1
+ #!/usr/bin/env node
2
+ // 6.93.0 mutation gate: live Mac window replay (lib/mac-window-voices.ts, lib/mac-window-replay.ts), its hook in
3
+ // lib/nemotron-live.ts and the Mac chunk route. Engine copied unchanged from mac-voices-6900-mutation-gate.mjs;
4
+ // mutations run only in a disposable copy of the checkout.
5
+ //
6
+ // What it proves, in order:
7
+ // 0. The target suites are GREEN unmutated. A gate over a red suite reads every mutant as killed and proves nothing.
8
+ // 1. Each target string appears EXACTLY ONCE in its file, so the mutation is unambiguous.
9
+ // 2. The mutated file differs from the original, so the edit landed.
10
+ // 3. A NAMED test fails ("FAIL server/x.test.ts > name"); a build error or a harness failure is not a kill.
11
+ // 4. The file is restored byte for byte (compared) before the next mutant.
12
+ // Usage: node server/scripts/mac-window-voices-6930-mutation-gate.mjs [--list] [name…]
13
+ import { mkdtempSync, cpSync, readFileSync, writeFileSync, symlinkSync, rmSync } from 'node:fs'
14
+ import { tmpdir } from 'node:os'
15
+ import { resolve, join, dirname, basename } from 'node:path'
16
+ import { fileURLToPath } from 'node:url'
17
+ import { spawnSync } from 'node:child_process'
18
+
19
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), '../..')
20
+ const UNIT_T = ['server/lib/mac-window-voices.test.ts']
21
+ const REPLAY_T = ['server/lib/mac-window-replay.test.ts']
22
+ const LABELS_T = ['server/lib/mac-voice-labels.test.ts']
23
+ const LIVE_T = ['server/lib/nemotron-live.test.ts']
24
+ const FINAL_T = ['server/lib/nemotron-final-mac-voices.test.ts']
25
+ const MAC_T = ['server/routes/mac-recording.test.ts']
26
+ const ALL = [...UNIT_T, ...REPLAY_T, ...LABELS_T, ...LIVE_T, ...FINAL_T, ...MAC_T]
27
+ const W = 'server/lib/mac-window-voices.ts', RP = 'server/lib/mac-window-replay.ts', L = 'server/lib/nemotron-live.ts', TS = 'server/routes/transcribe-stream.ts'
28
+ const VL = 'server/lib/mac-voice-labels.ts', NF = 'server/lib/nemotron-final.ts'
29
+ const m = (name, file, edits, tests) => ({ name, file, edits: typeof edits[0] === 'string' ? [edits] : edits, tests })
30
+
31
+ const mutations = [
32
+ // ── Switch (QA B1: with every switch off a Mac recording is 6.92.0) ──
33
+ // Default ON (Miles 2026-10-26): unset is the window; only an explicit off (0, false, no) or COS_MAC_VOICE_LABELS off is 6.92.0.
34
+ m('live-default-off', VL, [" }\n return 'window'\n}", " }\n return 'off'\n}"], [...LABELS_T, ...UNIT_T, ...REPLAY_T, ...MAC_T]),
35
+ m('live-default-anchors', VL, [" }\n return 'window'\n}", " }\n return 'anchors'\n}"], [...LABELS_T, ...UNIT_T, ...MAC_T]),
36
+ m('anchors-unselectable', VL, [" if (raw === 'anchors') return 'anchors'\n", ''], [...LABELS_T, ...UNIT_T]),
37
+ m('explicit-off-ignored', VL, [" if (OFF_WORDS.includes(raw)) return 'off'\n", ''], [...LABELS_T, ...UNIT_T, ...MAC_T]),
38
+ // Every spelling of off is its own guard (6.93.0 added none, disable, disabled, never).
39
+ ...['0', 'false', 'off', 'no', 'none', 'disable', 'disabled', 'never'].map(word => {
40
+ const list = ['0', 'false', 'off', 'no', 'none', 'disable', 'disabled', 'never']
41
+ const quote = items => '[' + items.map(x => `'${x}'`).join(', ') + ']'
42
+ return m(`off-word-${word}-dropped`, VL, [`export const OFF_WORDS: readonly string[] = ${quote(list)}`, `export const OFF_WORDS: readonly string[] = ${quote(list.filter(x => x !== word))}`], LABELS_T)
43
+ }),
44
+ // ── W9: an unrecognised value is window and says so once ──
45
+ m('unrecognised-not-warned', VL, [' warn(`[mac-voices] mac_live_voices_unrecognised', ' void(`[mac-voices] mac_live_voices_unrecognised'], LABELS_T),
46
+ m('unrecognised-warned-every-time', VL, ["raw !== 'window' && !warnedUnrecognised.has(raw)) {", "raw !== 'window') {"], LABELS_T),
47
+ m('window-value-warned', VL, ["if (raw !== '' && raw !== 'window' && !warnedUnrecognised", "if (raw !== '' && !warnedUnrecognised"], LABELS_T),
48
+ m('empty-value-warned', VL, ["if (raw !== '' && raw !== 'window' && !warnedUnrecognised", "if (raw !== 'window' && !warnedUnrecognised"], LABELS_T),
49
+ m('anchors-value-warned', VL, [" if (raw === 'anchors') return 'anchors'\n if (raw !==", " if (raw !=="], LABELS_T),
50
+ m('explicit-off-case-sensitive', VL, ["const raw = String(env.COS_MAC_LIVE_VOICES ?? '').trim().toLowerCase()", "const raw = String(env.COS_MAC_LIVE_VOICES ?? '').trim()"], LABELS_T),
51
+ m('voice-labels-off-not-master', VL, [" if (!macVoiceLabelsEnabled(env)) return 'off'\n const raw", ' const raw'], [...LABELS_T, ...UNIT_T, ...MAC_T]),
52
+ m('voice-shape-unchecked', VL, ['return Array.isArray(segments) && segments.some(', 'return segments.some('], LABELS_T),
53
+ m('anchors-run-when-off', TS, ["macLiveVoicesMode() === 'anchors' ? {", "macLiveVoicesMode() !== 'window' ? {"], MAC_T),
54
+ m('anchors-run-in-window-mode', TS, ["macLiveVoicesMode() === 'anchors' ? {", "macLiveVoicesMode() !== 'off' ? {"], MAC_T),
55
+ m('projection-when-off', TS, ["labels.diarizer?.engine === 'nemotron' && macLiveVoicesMode() !== 'off'", "labels.diarizer?.engine === 'nemotron'"], MAC_T),
56
+ m('g2-takes-window', TS, ['const macWindowOn = MAC_CAPTURE_ID.test(sessionId) && macWindowVoicesEnabled()', 'const macWindowOn = macWindowVoicesEnabled()'], MAC_T),
57
+ m('final-restricts-without-live-voices', NF, ['const liveMap = liveNumbers.length ? mapChannelsToLiveVoices(timeline.windows, activity) : null', 'const liveMap = mapChannelsToLiveVoices(timeline.windows, activity)'], [...FINAL_T, ...MAC_T]),
58
+ m('final-leaves-unproven-ext', NF, ['channels = found.channels.filter(channel => !liveMap || liveMap.has(channel) || unproven.includes(channel))', 'channels = found.channels.filter(channel => !liveMap || liveMap.has(channel))'], FINAL_T),
59
+ m('final-numbers-contradicted-channel', NF, ['return channels.filter(channel => !claims.has(channel))', 'return channels'], FINAL_T),
60
+ m('final-number-collides-with-live', NF, ['let next = Math.max(...liveNumbers)', 'let next = 0'], FINAL_T),
61
+ // ── Carry across the boundary ──
62
+ m('carry-min-ignored', W, ['if (c.count < MAC_WINDOW_CARRY_MIN_FRAMES || ', 'if ('], UNIT_T),
63
+ m('carry-agreement-ignored', W, [' || c.count / exclusiveInOverlap.get(c.slot)! < MAC_WINDOW_CARRY_AGREEMENT) continue', ') continue'], UNIT_T),
64
+ m('carry-not-one-to-one', W, ['if (slotTrack.has(c.slot) || usedTracks.has(c.track)) continue', 'if (slotTrack.has(c.slot)) continue'], UNIT_T),
65
+ // The denominator counts untracked exclusive frames too (they are why a slot of mixed history is not carried).
66
+ m('untracked-not-in-denominator', W, [
67
+ [' exclusiveInOverlap.set(slot, (exclusiveInOverlap.get(slot) ?? 0) + 1)\n const track = codes[i]\n if (track < 0) continue\n', ' const track = codes[i]\n if (track < 0) continue\n exclusiveInOverlap.set(slot, (exclusiveInOverlap.get(slot) ?? 0) + 1)\n'],
68
+ ], UNIT_T),
69
+ // ── The current chunk must agree (QA W1) ──
70
+ m('agreement-skipped', W, ['if (chunkAgreesWithSlot(window, start, length, slot, input.chunkAlone)) continue', 'if (true) continue'], UNIT_T),
71
+ m('agreement-without-a-view', W, ['if (!alone || alone.probs.length !== alone.frames * NEMOTRON_CHANNELS) return false', 'if (!alone) return true\n if (alone.probs.length !== alone.frames * NEMOTRON_CHANNELS) return false'], UNIT_T),
72
+ m('agreement-coverage-ignored', W, ['if (covered === 0 || covered < own * MAC_WINDOW_AGREE_COVERAGE) return false', 'if (covered === 0) return false'], UNIT_T),
73
+ m('agreement-purity-ignored', W, ['return Math.max(...perChannel.values()) / covered >= MAC_WINDOW_AGREE_PURITY', 'return true'], UNIT_T),
74
+ m('withheld-slot-still-coded-tracked', W, ['slotTrack.delete(slot)\n withheld++', 'withheld++'], UNIT_T),
75
+ m('silent-carried-slot-counted-as-disagreement', W, [' if ((exclusiveNew.get(slot) ?? 0) === 0) { slotTrack.delete(slot); continue }\n', ''], UNIT_T),
76
+ // ── Repeated window timeouts stop the window for the capture (QA R3) ──
77
+ m('disable-threshold-off-by-one', RP, ['timeouts >= MAC_WINDOW_BACKOFF_TIMEOUTS && !windowDisabled.has(sessionId)', 'timeouts > MAC_WINDOW_BACKOFF_TIMEOUTS && !windowDisabled.has(sessionId)'], [...REPLAY_T, ...MAC_T]),
78
+ m('backoff-window-of-one', RP, ['.slice(-MAC_WINDOW_BACKOFF_OF_LAST)', '.slice(-1)'], REPLAY_T),
79
+ m('backoff-window-unbounded', RP, ['.slice(-MAC_WINDOW_BACKOFF_OF_LAST)', '.slice(-1000)'], REPLAY_T),
80
+ m('backoff-counts-non-timeout', RP, ['const timeouts = recent.filter(Boolean).length', 'const timeouts = recent.length'], REPLAY_T),
81
+ m('timeout-not-counted', RP, [' noteWindowRun(input.sessionId, !outcome.ok && outcome.reason === \'timeout\', log)\n', ''], [...REPLAY_T, ...MAC_T]),
82
+ m('disable-logged-every-time', RP, ['timeouts >= MAC_WINDOW_BACKOFF_TIMEOUTS && !windowDisabled.has(sessionId)', 'timeouts >= MAC_WINDOW_BACKOFF_TIMEOUTS'], REPLAY_T),
83
+ m('route-ignores-disabled-window', TS, [' && !macWindowDisabledFor(sessionId)\n', '\n'], MAC_T),
84
+ // ── A re-run over the pass's own output reads the live label, not its own (QA R-N2) ──
85
+ m('rerun-reads-speaker', NF, ["return typeof chunk?.originalSpeaker === 'string' ? chunk.originalSpeaker : chunk?.speaker", 'return chunk?.speaker'], FINAL_T),
86
+ m('rerun-numbers-read-speaker', NF, ['entries.flatMap(entry => [liveLabelOf(entry.chunk), ', 'entries.flatMap(entry => [entry.chunk?.speaker, '], FINAL_T),
87
+ m('agreement-view-dropped', RP, ['crossed = cross(outcome.run, solo.ok ? solo.run : null, plan)', 'crossed = cross(outcome.run, null, plan)'], [...REPLAY_T, ...MAC_T]),
88
+ m('agreement-run-unconditional', RP, ['if (crossed.stats.carried > 0) {', 'if (true) {'], REPLAY_T),
89
+ m('agreement-run-failure-allowed', RP, ['crossed = cross(outcome.run, solo.ok ? solo.run : null, plan)', 'crossed = cross(outcome.run, solo.ok ? solo.run : soloOf(outcome.run, plan), plan)\n function soloOf(run, p) { const before = p.chunks.slice(0, -1).reduce((n, c) => n + c.samples, 0); const f0 = Math.floor(before / 160); const n = run.frames - f0; return { frames: n, probs: run.probs.slice(f0 * 8, (f0 + n) * 8) } }'], REPLAY_T),
90
+ // ── New tracks, eviction, cap ──
91
+ m('new-track-despite-overlap', W, ['if (slotTrack.has(slot) || votes.has(slot) || n < MAC_WINDOW_NEW_TRACK_FRAMES) continue', 'if (slotTrack.has(slot) || n < MAC_WINDOW_NEW_TRACK_FRAMES) continue'], UNIT_T),
92
+ m('new-track-any-length', W, ['if (slotTrack.has(slot) || votes.has(slot) || n < MAC_WINDOW_NEW_TRACK_FRAMES) continue', 'if (slotTrack.has(slot) || votes.has(slot)) continue'], UNIT_T),
93
+ m('track-cap-ignored', W, [' if (id >= MAC_WINDOW_MAX_TRACKS) { capped++; continue }\n', ''], UNIT_T),
94
+ m('no-eviction', W, ['state.tracks = state.tracks.filter(t => referenced.has(t.id))', 'state.tracks = state.tracks'], UNIT_T),
95
+ m('eviction-drops-referenced', W, ['state.tracks = state.tracks.filter(t => referenced.has(t.id))', 'state.tracks = state.tracks.filter(t => t.voice !== null)'], UNIT_T),
96
+ m('max-voice-ignored', W, [' if (state.voices >= MAX_VOICE) { t.proofs.pop(); continue }\n', ''], UNIT_T),
97
+ // ── Proof and numbering ──
98
+ m('one-proof-confirms', W, [' if (t.proofs.length >= MAC_WINDOW_PROOFS) {', ' if (t.proofs.length >= 1) {'], [...UNIT_T, ...MAC_T]),
99
+ m('duplicate-audio-proof', W, ['if (t.proofs.some(p => p.chunk === current.chunk || p.audioSha256 === audioSha256)) continue', 'if (t.proofs.some(p => p.chunk === current.chunk)) continue'], UNIT_T),
100
+ m('proof-purity-ignored', W, ['if (ex < MAC_WINDOW_PROOF_FRAMES || purity < MAC_WINDOW_PROOF_PURITY || t.voice !== null) continue', 'if (ex < MAC_WINDOW_PROOF_FRAMES || t.voice !== null) continue'], UNIT_T),
101
+ m('proof-any-length', W, ['if (ex < MAC_WINDOW_PROOF_FRAMES || purity < MAC_WINDOW_PROOF_PURITY || t.voice !== null) continue', 'if (purity < MAC_WINDOW_PROOF_PURITY || t.voice !== null) continue'], UNIT_T),
102
+ // ── Untrusted input ──
103
+ m('geometry-unchecked', W, [' if (window.frames !== macWindowFrameCount(sample)) return null\n', ''], UNIT_T),
104
+ m('geometry-tail-fft-wrong', W, ['export const MAC_WINDOW_FFT_SAMPLES = 512', 'export const MAC_WINDOW_FFT_SAMPLES = 500'], UNIT_T),
105
+ m('geometry-tail-window-wrong', W, ['export const MAC_WINDOW_FRAME_SAMPLES = 400', 'export const MAC_WINDOW_FRAME_SAMPLES = 399'], UNIT_T),
106
+ m('geometry-hop-wrong', W, ['Math.round(MAC_AUDIO.sampleRate * NEMOTRON_FRAME_SEC)', 'Math.round(MAC_AUDIO.sampleRate * NEMOTRON_FRAME_SEC) + 1'], UNIT_T),
107
+ m('window-ceiling-wrong', W, ['MAC_AUDIO.sampleRate * (MAC_AUDIO.maxChunkMs / 1000)', 'MAC_AUDIO.sampleRate * (MAC_AUDIO.maxChunkMs / 1000) - 1'], UNIT_T),
108
+ m('values-unchecked', W, [' for (const v of window.probs) if (!Number.isFinite(v) || v < 0 || v > 1) return null\n', ''], UNIT_T),
109
+ m('invalid-state-accepted', W, ['if (!validMacWindowVoices(input.state) || !SHA.test(audioSha256)', 'if (!SHA.test(audioSha256)'], UNIT_T),
110
+ m('voice-above-highwater', W, ['if (!isIndex(t.voice) || t.voice < 1 || t.voice > s.voices || voices.has(t.voice)', 'if (!isIndex(t.voice) || t.voice < 1 || voices.has(t.voice)'], UNIT_T),
111
+ m('duplicate-voice-accepted', W, ['|| t.voice > s.voices || voices.has(t.voice) ||', '|| t.voice > s.voices ||'], UNIT_T),
112
+ m('unproven-number-accepted', W, [' } else if (t.proofs.length >= MAC_WINDOW_PROOFS) return false\n', ' }\n'], UNIT_T),
113
+ m('recent-order-unchecked', W, ['if (!r || !isIndex(r.chunk) || r.chunk <= last) return false', 'if (!r || !isIndex(r.chunk)) return false'], UNIT_T),
114
+ m('frame-codes-unchecked', W, ['codes.some(c => c < UNTRACKED || (c >= 0 && !ids.has(c)))', 'codes.some(c => c < UNTRACKED)'], UNIT_T),
115
+ m('frame-length-cap-ignored', W, ['frames.length > 64_000 || ', ''], UNIT_T),
116
+ // ── Plan and bounds ──
117
+ m('plan-bridges-gap', W, ['if (!isIndex(n) || n === 0 || total + n > MAC_WINDOW_MAX_SAMPLES) break', 'if (!isIndex(n) || n === 0 || total + n > MAC_WINDOW_MAX_SAMPLES) continue'], UNIT_T),
118
+ m('plan-sample-cap-ignored', W, ['if (!isIndex(n) || n === 0 || total + n > MAC_WINDOW_MAX_SAMPLES) break', 'if (!isIndex(n) || n === 0) break'], UNIT_T),
119
+ m('recent-unbounded', W, [' .slice(-(MAC_WINDOW_MAX_CHUNKS - 1))\n', ''], [...UNIT_T, ...MAC_T]),
120
+ // ── Timeouts and fallback (QA W4) ──
121
+ m('window-budget-per-chunk', RP, ['const timeoutMs = liveBudgetForAudioSec(windowSec)', 'const timeoutMs = 1500'], [...REPLAY_T, ...MAC_T]),
122
+ m('timeout-no-fallback', RP, ["return outcome.reason === 'timeout' ? fallback('timeout', outcome.ms) : outcome", 'return outcome'], [...REPLAY_T, ...MAC_T]),
123
+ m('other-failures-fall-back', RP, ["return outcome.reason === 'timeout' ? fallback('timeout', outcome.ms) : outcome", "return fallback('timeout', outcome.ms)"], REPLAY_T),
124
+ m('geometry-no-fallback', RP, ["let crossed = cross(outcome.run, null, plan)\n if (!crossed) return fallback('geometry', undefined)", "let crossed = cross(outcome.run, null, plan)\n if (!crossed) return { ok: false, reason: 'bad_output' } as LiveDiarizeOutcome"], REPLAY_T),
125
+ m('window-timeout-trips-breaker', L, ["if (RUN_FAILURES.has(reason) && !(reason === 'timeout' && options.timeoutTripsBreaker === false)) {", 'if (RUN_FAILURES.has(reason)) {'], LIVE_T),
126
+ m('window-exempt-from-all-failures', L, ["if (RUN_FAILURES.has(reason) && !(reason === 'timeout' && options.timeoutTripsBreaker === false)) {", 'if (RUN_FAILURES.has(reason) && options.timeoutTripsBreaker !== false) {'], LIVE_T),
127
+ m('timeout-option-ignored', L, ['timeoutMs: options.timeoutMs ?? this.budget(),', 'timeoutMs: this.budget(),'], LIVE_T),
128
+ m('budget-not-scaled', L, ['Math.max(LIVE_BUDGET_MS, Math.ceil(LIVE_BUDGET_MS * (Number.isFinite(audioSec) ? audioSec : 0) / LIVE_BUDGET_REFERENCE_AUDIO_SEC))', 'LIVE_BUDGET_MS'], LIVE_T),
129
+ m('window-tripping-diarize-call', TS, ['diarizeWindow: (wavPath, timeoutMs) => nemotronLive.diarize(wavPath, { timeoutMs, timeoutTripsBreaker: false }),', 'diarizeWindow: (wavPath, timeoutMs) => nemotronLive.diarize(wavPath, { timeoutMs }),'], MAC_T),
130
+ // ── Telemetry (QA W8) ──
131
+ m('withheld-state-not-noted', TS, [' if (macWindowWithheld) noteMacWindowWithheld(sessionId, macWindowWithheld)\n', ''], MAC_T),
132
+ m('withheld-noted-every-chunk', RP, [' if (seenWithheld.has(key)) return\n', ''], REPLAY_T),
133
+ m('window-line-not-logged', RP, [' log(`[mac-window] chunk #${input.chunkIndex} window ${plan.chunks.length} chunks', ' void (`[mac-window] chunk #${input.chunkIndex} window ${plan.chunks.length} chunks'], REPLAY_T),
134
+ // ── I/O half and route ──
135
+ m('restart-after-voice-labels', RP, [" return chunks.some(chunkShowsVoiceLabel) ? 'earlier_voice_labels' : null\n", ' return null\n'], [...REPLAY_T, ...MAC_T]),
136
+ m('corrupt-state-accepted', RP, ["return validMacWindowVoices(saved) ? null : 'corrupt_state'", 'return null'], [...REPLAY_T, ...MAC_T]),
137
+ m('corrupt-state-restarted', RP, [
138
+ [' if (macWindowWithheldReason(saved, chunks)) return null\n', " if (macWindowWithheldReason(saved, chunks) === 'earlier_voice_labels') return null\n"],
139
+ ['return saved === undefined ? emptyMacWindowVoices() : saved as MacWindowVoiceState', 'return saved === undefined || !validMacWindowVoices(saved) ? emptyMacWindowVoices() : saved as MacWindowVoiceState'],
140
+ ], [...REPLAY_T, ...MAC_T]),
141
+ m('window-wav-kept', RP, [' let cleaned = false\n const cleanup = () => {\n if (cleaned) return\n cleaned = true\n', ' let cleaned = false\n const cleanup = () => {\n if (cleaned || true) return\n cleaned = true\n'], [...REPLAY_T, ...MAC_T]),
142
+ m('channel-label-dropped', L, [' if (label && isVoiceLabel(label)) names.set(track.channel, { speaker: label, similarity: 0 })\n } else if (input.anonymousVoice', ' } else if (input.anonymousVoice'], MAC_T),
143
+ m('voice-overwrites-name', L, [' if (current && isRealLabel(current.speaker)) continue\n const label = input.anonymousChannel(track.channel)', ' const label = input.anonymousChannel(track.channel)'], MAC_T),
144
+ m('window-state-not-committed', TS, [' if (macWindowNext !== undefined) session.macWindowVoices = macWindowNext\n', ''], MAC_T),
145
+ m('window-state-not-persisted', TS, [' ...(session.macWindowVoices !== undefined ? { macWindowVoices: session.macWindowVoices } : {}),\n', ''], MAC_T),
146
+ ]
147
+
148
+ const args = process.argv.slice(2)
149
+ if (args.includes('--list')) { for (const { name } of mutations) console.log(name); process.exit(0) }
150
+ const selected = args.length ? mutations.filter(({ name }) => args.includes(name)) : mutations
151
+ if (args.length && selected.length !== args.length) throw new Error('Unknown mutation name in: ' + args.join(' '))
152
+ if (new Set(mutations.map(x => x.name)).size !== mutations.length) throw new Error('Duplicate mutation name')
153
+
154
+ // Record exactly which code this run proved (QA R-N1): the commit, and whether the tree matched it.
155
+ const rev = spawnSync('git', ['-C', root, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).stdout.trim()
156
+ const modified = spawnSync('git', ['-C', root, 'status', '--porcelain', '--untracked-files=no'], { encoding: 'utf8' }).stdout.split('\n').filter(Boolean).length
157
+ console.log(`commit ${rev || 'unknown'} (${modified ? `${modified} modified files: NOT the committed code` : 'clean tree'})`)
158
+ const scratch = mkdtempSync(join(tmpdir(), 'mac-window-voices-6930-mutations-'))
159
+ try {
160
+ const skip = new Set(['data', 'models', 'certs', 'node_modules'])
161
+ cpSync(join(root, 'server'), join(scratch, 'server'), { recursive: true, filter: src => !(skip.has(basename(src)) && dirname(src) === join(root, 'server')) })
162
+ for (const dir of ['shared', 'work-task-runtime', 'bin', 'docs', 'memory-runtime']) cpSync(join(root, dir), join(scratch, dir), { recursive: true })
163
+ for (const file of ['vitest.config.ts', 'package.json', 'managed-runtime-contract.json']) cpSync(join(root, file), join(scratch, file))
164
+ symlinkSync(join(root, 'node_modules'), join(scratch, 'node_modules'), 'dir')
165
+ const run = tests => spawnSync(process.execPath, [join(root, 'node_modules/vitest/vitest.mjs'), 'run', '--maxWorkers=1', ...tests], {
166
+ cwd: scratch, env: { PATH: process.env.PATH, HOME: scratch, TMPDIR: process.env.TMPDIR, COS_DATA_DIR: join(scratch, 'data'), COS_PROFILE_PATH: join(scratch, 'data', 'profile.json') },
167
+ encoding: 'utf8', timeout: 300000,
168
+ })
169
+ const baseline = run(ALL)
170
+ if (baseline.status !== 0) throw new Error('Baseline failed; a gate over a red suite proves nothing:\n' + baseline.stdout + '\n' + baseline.stderr)
171
+ const totals = /Tests\s+(\d+) passed/.exec(baseline.stdout)
172
+ console.log(`baseline PASS (${totals ? totals[1] : '?'} tests in ${ALL.length} files)`)
173
+ let killed = 0
174
+ for (const { name, file, edits, tests } of selected) {
175
+ const target = join(scratch, file), original = readFileSync(target, 'utf8')
176
+ let mutated = original
177
+ for (const [find, replacement] of edits) {
178
+ if (mutated.split(find).length !== 2) throw new Error(`Mutation ${name} does not match exactly once in ${file}: ${find.slice(0, 80)}`)
179
+ mutated = mutated.replace(find, () => replacement)
180
+ }
181
+ if (mutated === original) throw new Error(`Mutation ${name} did not change ${file}`)
182
+ writeFileSync(target, mutated)
183
+ let result
184
+ try { result = run(tests) } finally { writeFileSync(target, original) }
185
+ if (readFileSync(target, 'utf8') !== original) throw new Error(`Restore failed for ${file} after ${name}`)
186
+ const output = result.stdout + '\n' + result.stderr
187
+ const killers = [...new Set([...output.matchAll(/FAIL\s+(server\/\S+\.test\.ts > [^\n]+)/g)].map(x => x[1].trim()))]
188
+ if (result.status === 0 || result.error || !killers.length) { console.log(`${name} SURVIVED or harness failed\n${output.slice(-3000)}`); process.exitCode = 1; continue }
189
+ killed += 1
190
+ console.log(`${name} KILLED by ${killers.slice(0, 2).join(' | ')}${killers.length > 2 ? ` (+${killers.length - 2} more)` : ''}`)
191
+ }
192
+ console.log(`${killed} of ${selected.length} Mac window replay 6.93.0 mutations killed`)
193
+ } finally { rmSync(scratch, { recursive: true, force: true }) }