#!/usr/bin/env bash set -euo pipefail if [[ $# -ne 1 ]]; then echo "Usage: $0 /path/to/qa-evidence-YYYYMMDD-HHMMSS.zip" >&2 exit 2 fi evidence_zip="$1" if [[ ! -f "$evidence_zip" ]]; then echo "Evidence zip not found: $evidence_zip" >&2 exit 2 fi workdir="$(mktemp -d)" cleanup() { rm -rf "$workdir" } trap cleanup EXIT unzip -q "$evidence_zip" -d "$workdir" find_one() { local name="$1" find "$workdir" -type f -name "$name" -print -quit } require_file() { local name="$1" local path path="$(find_one "$name")" if [[ -z "$path" ]]; then echo "FAIL missing $name" >&2 return 1 fi echo "$path" } check_pattern() { local label="$1" local file="$2" local pattern="$3" if rg -q "$pattern" "$file"; then echo "PASS $label" return 0 fi echo "FAIL $label" return 1 } failures=0 qa_results="$(require_file "qa-results.tsv")" || failures=$((failures + 1)) app_log="$(require_file "app.log")" || failures=$((failures + 1)) target_text="$(require_file "qa-target-dictation-text.txt")" || failures=$((failures + 1)) system_info="$(require_file "system-info.txt")" || failures=$((failures + 1)) if [[ -n "${qa_results:-}" ]]; then if rg -q '^NEEDS_EVIDENCE' "$qa_results"; then echo "FAIL qa-results.tsv contains NEEDS_EVIDENCE" rg '^NEEDS_EVIDENCE' "$qa_results" || true failures=$((failures + 1)) else echo "PASS qa-results.tsv has no NEEDS_EVIDENCE" fi fi if [[ -n "${app_log:-}" ]]; then check_pattern "startup log" "$app_log" 'PrivateVoice Dictation starting' || failures=$((failures + 1)) check_pattern "engine ready log" "$app_log" 'ASR engine ready|Engine initialized' || failures=$((failures + 1)) check_pattern "recording log" "$app_log" 'Recording started' || failures=$((failures + 1)) check_pattern "recognized text log" "$app_log" 'Recognized:' || failures=$((failures + 1)) check_pattern "paste success log" "$app_log" 'PERF paste_done.*result=success|PERF fallback_type_done.*result=success' || failures=$((failures + 1)) fi if [[ -n "${target_text:-}" ]]; then if [[ -s "$target_text" ]] && [[ -n "$(tr -d '[:space:]' < "$target_text")" ]]; then echo "PASS Notepad target text captured" else echo "FAIL Notepad target text is empty" failures=$((failures + 1)) fi fi if [[ -n "${system_info:-}" ]]; then check_pattern "Windows system info" "$system_info" 'Windows|Microsoft|CsSystemType|WindowsProductName' || failures=$((failures + 1)) fi echo if [[ "$failures" -eq 0 ]]; then echo "WINDOWS_QA_EVIDENCE_PASS" exit 0 fi echo "WINDOWS_QA_EVIDENCE_FAIL failures=$failures" exit 1