#!/usr/bin/env bash
set -euo pipefail
# Run after adding Missing Home Codex through Settings > Providers > Add provider
# > Codex > Configure manually, with shadow home empty and health interval 0.
# Each side uses its own initially absent CODEX_HOME. Keep Settings open and record.
# First invocation creates the home and writes auth.json together. Invoke again
# after 70 seconds to test a later auth.json write, then observe for 30 seconds.
side=${1:?base or head}
case "$side" in base|head) ;; *) exit 2;; esac
proof_home="/tmp/factory-pr-48867-evidence-1/run2/$side/fresh-codex-home"
printf 'UTC: '; date -u +%FT%TZ
mkdir -p "$proof_home"
printf '%s\n' 'synthetic-evidence-key' | CODEX_HOME="$proof_home" codex -c cli_auth_credentials_store=file login --with-api-key
CODEX_HOME="$proof_home" codex login status
