#!/bin/bash
# Final verification test - RUN THIS AS THE CHECK COMMAND
# Exit code 0 = all artifacts verified, non-zero = failure

# Check artifacts exist
[ -f /root/.hermes/wizard-outputs/spark/env-check.sh ] || exit 1
[ -f /root/.hermes/wizard-outputs/spark/results.txt ] || exit 2
[ -f /root/troupe-standup/wizard-work/spark/env-check.sh ] || exit 3
[ -f /root/troupe-standup/wizard-work/spark/results.txt ] || exit 4
[ -f /root/troupe-standup/wizard-work/spark/INSPECTION_REPORT.md ] || exit 5

# Check OS contains Linux
grep -q "Linux" /root/.hermes/wizard-outputs/spark/results.txt || exit 6

# Check CURRENT_USER contains root  
grep -q "root" /root/.hermes/wizard-outputs/spark/results.txt || exit 7

# Check profile directory exists
[ -d /root/.hermes/profiles/spark ] || exit 8

# Check scratch directory exists
[ -d /root/.hermes/profiles/spark/cache/scratch ] || exit 9

# Check Python 3 available
python3 --version 2>&1 | grep -q "Python" || exit 10

# Check SKILL_SYSTEM_VERIFICATION.md exists (my artifact)
[ -f /root/troupe-standup/wizard-work/spark/SKILL_SYSTEM_VERIFICATION.md ] || exit 12

# Check file contains skill system test evidence
grep -q "SKILLS_LIST_TEST: PASS" /root/troupe-standup/wizard-work/spark/SKILL_SYSTEM_VERIFICATION.md || exit 13
grep -q "SKILL_VIEW_TEST: PASS" /root/troupe-standup/wizard-work/spark/SKILL_SYSTEM_VERIFICATION.md || exit 14

# Check git commit pushed with artifact
git -C /root/troupe-standup rev-parse a24e531 >/dev/null 2>&1 || exit 15
git -C /root/troupe-standup ls-tree a24e531 -- wizard-work/spark/SKILL_SYSTEM_VERIFICATION.md >/dev/null 2>&1 || exit 16

echo "VERIFIED"
exit 0