Files
codex/.github/scripts/watch_voice_bazel.py
Benjamin Carlsson ce7fbb373b Bundle native voice runtimes in Windows releases (#44922)
## Why

Windows release packages need the voice helper and native audio libraries. Realtime TLS connections on fresh Windows installations also need platform certificate validation so Windows can retrieve missing trusted roots on demand.

## What changed

- Build and sign the voice helper and audio DLLs for Windows x64 and ARM64, bundle a pinned Microsoft CRT DLL, and verify signatures and runtime receipts before packaging.
- Add verified, pinned Cygwin and native build tools plus MSVC linker, compiler, and path handling fixes for the Windows Bazel builds.
- Include voice resources in primary release archives and WinGet packages. Preserve WinGet executable names, update manifest hashes, and recognize the package root through matching entrypoint metadata. Keep Python runtime wheels voice-free to preserve their existing Windows support floor.
- Use Windows platform TLS validation for realtime WebSockets when no custom CA bundle is configured, preserving custom CA behavior.

## Testing

Add coverage for build-input integrity and unsafe paths, signed Windows runtime assembly, WinGet file and hash preservation, package discovery, and TLS trust selection, untrusted certificate rejection, and hostname validation.

GitOrigin-RevId: 423da35872fa5549d69fd4ca97d922bb49599386
2026-09-11 21:59:24 +00:00

80 lines
2.6 KiB
Python

"""Capture one bounded diagnostic when the ARM64 voice build goes silent."""
import os
from pathlib import Path
import shutil
import subprocess
import sys
import threading
import time
def diagnose():
root = Path(os.environ.get("BAZEL_OUTPUT_BASE", ""))
if not root.is_absolute():
print("Bazel output base unavailable; skipping diagnostics", flush=True)
return
for relative in ("command.log", "server/jvm.out"):
try:
with (root / relative).open("rb") as source:
source.seek(max(0, source.seek(0, 2) - 16384))
print(
f"Bazel {relative} tail:\n{source.read(16384).decode(errors='replace')}",
flush=True,
)
except OSError as error:
print(f"Cannot read {relative}: {error}", flush=True)
try:
pid = str(int((root / "server/server.pid.txt").read_text().strip()))
jstack = shutil.which("jstack")
if not jstack:
print("jstack unavailable; log tails retained", flush=True)
return
result = subprocess.run([jstack, pid], capture_output=True, timeout=20)
print(
f"jstack exit {result.returncode}:\n{(result.stdout + result.stderr)[-65536:].decode(errors='replace')}",
flush=True,
)
except (OSError, ValueError, subprocess.TimeoutExpired) as error:
print(f"Cannot capture JVM stacks: {error}", flush=True)
def main():
with subprocess.Popen(
sys.argv[1:], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
) as process:
last_output = time.monotonic()
def forward():
nonlocal last_output
for line in process.stdout:
last_output = time.monotonic()
sys.stdout.buffer.write(line)
sys.stdout.buffer.flush()
reader = threading.Thread(target=forward)
reader.start()
captured = False
while process.poll() is None:
if (
not captured
and os.environ.get("VOICE_ARCH") == "aarch64"
and time.monotonic() - last_output >= 600
):
captured = True
print(
"ARM64 Bazel silent for ten minutes; capturing diagnostics",
flush=True,
)
diagnose()
time.sleep(1)
reader.join()
if process.returncode and not captured:
print("Bazel command failed; capturing diagnostics", flush=True)
diagnose()
return process.returncode
if __name__ == "__main__":
sys.exit(main())