main
John Lauer v1.3.3 (insiders): Grok Bot's computer state: computerReachable on readiness, chat and webhook verbs, fast no_transcrip… 85caf75 6d ago
#!/usr/bin/env bash
# promote.sh — move an INSIDERS build of grok-bridge to the PUBLIC tier, on a human's exact words.
#
#   tools/promote.sh <version> "<the human's exact words>" --by "<name>"
#
# The public manifest (adom-bridge-grok-manifest.json, the updateManifestUrl every non-insider
# desktop follows) moves ONLY through this script, and it REFUSES without an attestation. An AI
# passes the human's words through verbatim or does not promote, never on its own judgment.
# The words travel in the public manifest (promotion_attestation / promoted_by / promoted_at).
# The bytes are already a release on adom/grok-bridge (tools/ship.sh); promote re-points the
# public manifest at that same asset after re-checking its sha256.
set -euo pipefail
VER="${1:?usage: tools/promote.sh <version> \"<attestation words>\" --by <name>}"
ATTEST="${2:-}"
shift 2 || true
BY="${ADOM_PROMOTED_BY:-}"
while [ $# -gt 0 ]; do case "$1" in --by) BY="$2"; shift 2;; *) shift;; esac; done
REPO="$(cd "$(dirname "$0")/.." && pwd)"; cd "$REPO"
PAGE="adom/grok-bridge"
INSIDERS_PAGE="adom/insiders"
MAN="adom-bridge-grok-manifest.json"

echo "== 0. attestation gate =="
A="$(printf '%s' "$ATTEST" | tr -s '[:space:]' ' ' | sed 's/^ //;s/ $//')"
if [ "${#A}" -lt 8 ] || printf '%s' "$A" | grep -qiE '^(ok|yes|promote|ship it|go|approved|test|placeholder|x+)$'; then
  echo "REFUSED: promoting to the PUBLIC tier needs the human's exact words (>= 8 chars, not a placeholder)."
  exit 2
fi
[ -n "$BY" ] || { echo "REFUSED: say who promoted (--by \"<name>\" or ADOM_PROMOTED_BY)."; exit 2; }
echo "   by $BY: \"$A\""

echo "== 1. the insiders record for $VER =="
INS=$(adom-wiki repo show "$INSIDERS_PAGE" grok-bridge/version.json)
python3 - "$VER" "$INS" <<'PY'
import json, sys
ver, raw = sys.argv[1:3]
d = json.loads(raw)
assert d.get('version') == ver, f"insiders manifest is at {d.get('version')}, not {ver}; ship {ver} first"
PY
URL=$(printf '%s' "$INS" | python3 -c "import json,sys;print(json.load(sys.stdin)['url'])")
WANT=$(printf '%s' "$INS" | python3 -c "import json,sys;print(json.load(sys.stdin)['sha256'])")
GOT=$(curl -sL "$URL" | sha256sum | cut -d' ' -f1)
[ "$GOT" = "$WANT" ] || { echo "REMOTE ASSET MISMATCH: $URL serves $GOT, insiders record says $WANT; refusing"; exit 1; }
echo "   $URL matches the insiders record (sha256 $WANT)"

echo "== 2. public manifest =="
python3 - "$INS" "$A" "$BY" "$MAN" <<'PY'
import datetime, json, sys
ins, words, by, path = json.loads(sys.argv[1]), sys.argv[2], sys.argv[3], sys.argv[4]
now = datetime.datetime.now(datetime.timezone.utc).isoformat(timespec='seconds').replace('+00:00', 'Z')
m = json.load(open(path))
m.update({'version': ins['version'], 'url': ins['url'], 'sha256': ins['sha256'], 'size': ins['size'],
          'insiders_released_at': ins.get('released_at'), 'released_at': now,
          'promotion_attestation': words, 'promoted_by': by, 'promoted_at': now})
m.pop('tier', None)
for k in ('rollback_attestation', 'rolled_back_by', 'rolled_back_at'):
    m.pop(k, None)
json.dump(m, open(path, 'w'), indent=2); open(path, 'a').write('\n')
print(f"   {path} -> {ins['version']}")
PY
adom-wiki repo push "$PAGE" --files "$MAN" -m "v${VER}: promoted to public by ${BY}: ${A}" >/dev/null

echo "== 3. mark the insiders release-log entry =="
TMP=$(mktemp -d)
mkdir -p "$TMP/grok-bridge"
adom-wiki repo show "$INSIDERS_PAGE" grok-bridge/README.md > "$TMP/grok-bridge/README.md"
python3 - "$TMP/grok-bridge/README.md" "$VER" "$A" "$BY" <<'PY'
import datetime, sys
path, ver, words, by = sys.argv[1:5]
s = open(path).read()
i = s.find(f"- **{ver}** insiders")
if i < 0:
    print(f"   no release-log entry for {ver}"); sys.exit(0)
j = s.find("\n", i)
line = s[i:j].replace(" Not promoted.", "")
line += f" Promoted to public on {datetime.date.today().isoformat()} by {by}: \"{words}\"."
open(path, 'w').write(s[:i] + line + s[j:]); print(f"   {ver} marked promoted")
PY
( cd "$TMP" && adom-wiki repo push "$INSIDERS_PAGE" --files grok-bridge/README.md -m "grok-bridge ${VER}: promoted to public by ${BY}" >/dev/null ) \
  || echo "   (release-log push failed; the public manifest is already promoted)"

echo "== 4. verify =="
LIVE=$(curl -s "https://wiki.adom.inc/api/v1/pages/grok-bridge/files/$MAN" | python3 -c "import json,sys;print(json.load(sys.stdin).get('version'))")
[ "$LIVE" = "$VER" ] && echo "PROMOTED $VER to PUBLIC (by $BY)" || { echo "live public manifest reads $LIVE, not $VER"; exit 1; }