grok-bot-install.md
# Grok Bot Installation & Deployment Guide (v4 — Synchronized 2-of-2 Cosign Release)
**Target Runtime:** Grok Bot (`/workspace/docs` and `albertlane.net`)
**License:** Albert Lane Proprietary Software License v100.0 (Sovereign Aegis Protocol)
**Prior Art SHA-256:** `79a8d61919906449cc8baf1ef64d8982aed7ac0535e693d1eecfd72b4d3ad123`
---
## 1. Extract & Verify Integrity (`SHA256SUMS`)
```bash
mkdir -p /workspace/docs/staging
tar -xzf albertlane-studio-grok-bot-bundle-v4.tar.gz -C /workspace/docs/staging
cd /workspace/docs/staging/albertlane-studio-grok-bot-bundle
sha256sum -c SHA256SUMS
```
Confirm every file reports `: OK` before running `install.sh`.
---
## 2. Automated Installation onto Grok Bot (`/workspace/docs`)
```bash
chmod +x install.sh
./install.sh --target /workspace/docs/studio-bundle
```
`install.sh` verifies `SHA256SUMS`, installs all 18 Studio artifacts, `almanac/index.html`, and `cloudflare/` into `/workspace/docs/studio-bundle`, runs `python3 /workspace/docs/studio-bundle/artifacts/pompous_v1_2.py`, and writes `INSTALL_RECEIPT.json` recording the synced SHA-256 digests for `almanac/index.html` and `cloudflare/almanac_worker.py`.
---
## 3. Configure 2-of-2 Albert + Robot Cosigner & Deploy Worker
Co-signing defaults to **OFF (HTTP 503)** until both `ALBERT_SIGNING_ADDRESS` and `ROBOT_SIGNING_ADDRESS` (or `ROBOT_SIGNING_KEY` secret) are configured:
1. Edit `/workspace/docs/studio-bundle/cloudflare/wrangler.toml` to set your `AUDIT_EVIDENCE_KV` namespace ID and `ALBERT_SIGNING_ADDRESS` / `ROBOT_SIGNING_ADDRESS` (plus optional `albertlane-cosigner` service binding or `COSIGNER_D1` database binding).
2. Store Robot's secp256k1 signing secret (if signing locally inside the Worker rather than via `COSIGNER_SERVICE`):
```bash
cd /workspace/docs/studio-bundle/cloudflare
npx wrangler secret put ROBOT_SIGNING_KEY
```
3. Mount `/workspace/docs/studio-bundle/almanac/index.html` at `albertlane.net/almanac`.
4. Preview or deploy the Cloudflare Worker + D1/R2 sync:
```bash
# Dry-run preview
./deploy_worker.sh --dry-run --audio-dir ../audio --sql-out /tmp/audio_worm_receipts.sql
# Live apply (D1 schema + optional R2 audio receipts + Worker deploy + smoke check)
./deploy_worker.sh --smoke-url "https://${ALMANAC_HOST}/almanac/api/snapshot"
```
*(If you exported Studio audio files into `/workspace/docs/studio-bundle/audio/`, pass `--audio-dir ../audio` to hash, upload to R2 `forensic-worm-archive-lock`, and append `AUDIO_OVERVIEW_RECEIPT` records to D1 automatically.)*
---
## 4. Synchronized Frontend ↔ Worker API Endpoints
- `GET /almanac/api/snapshot` — Serves the N=10 paired matrix, `cosign_status`, `sovereign_binding_summary`, `zip_pledges`, `worm_records`, `cosign_log`, and `audio_overview_receipts`.
- `GET /almanac/api/cosign/status` — Returns `signing_enabled`, `albert_address`, `robot_address`, `ledger_counts`, and `recent_attestations` (pass `?strict=true` for HTTP 503 while keys are unset).
- `GET /almanac/api/cosign/digest/<record_key>` — Returns `eip191_digest` / `canonical_digest` for any WORM record.
- `POST /almanac/api/cosign/attest` — Verifies Robot's Llama 3.3 70B verdict (VETO is immutable) + dual ECDSA secp256k1 EIP-191 signatures and promotes `PENDING_2_OF_2` → `VERIFIED_2_OF_2`.
- `POST /almanac/api/crowd/zip-pledge` & `POST /almanac/api/crowd/submit-audit` — Accepts both frontend dashboard payloads and direct API payloads, storing `PENDING_2_OF_2` records in D1 and mirroring receipts to R2.
- `GET /almanac/api/worm` & `GET /almanac/api/audio/<record_key>` — Serves WORM chain records and streams R2 audio binaries (or JSON receipt metadata for non-binary/WORM entries or `?meta=1`).