๐ Standard Operating Procedures
Runbooks for operating and recovering the Blind Monkeys platform.
Architecture Quick Map
blindmonkeys.org (main Flask site) โ Cloudflare DNS โ Cloud Run service
portfolio-agent-public, project project-46559977-eb74-48c3-a1e, region us-central1.
Dynamic data โ GCS bucket portfolio-agent-data-388170800364 (users, scans, P/L, settings; written by the 15-min crons).
Scanner + trader โ Cloud Run blind-monkeys-scanner / blind-monkeys-trader, project gen-lang-client-0223878158, region europe-west1; trader state in bucket blind-monkeys-trader-state.
Source of truth โ git.sr.ht/~deanpowers/blind-monkeys (public repo, mirrors production).
Dynamic data โ GCS bucket portfolio-agent-data-388170800364 (users, scans, P/L, settings; written by the 15-min crons).
Scanner + trader โ Cloud Run blind-monkeys-scanner / blind-monkeys-trader, project gen-lang-client-0223878158, region europe-west1; trader state in bucket blind-monkeys-trader-state.
Source of truth โ git.sr.ht/~deanpowers/blind-monkeys (public repo, mirrors production).
Restore blindmonkeys.org from Google Cloud
SOP #1
Step 1 โ Diagnose: find out WHAT is broken
Run these checks in order and compare with the expected results:
curl -s https://blindmonkeys.org/ | grep -o '<title>.*</title>'
# expect: <title>Blind Monkeys</title> (anything else = wrong content is being served)
curl -s -o /dev/null -w '%{http_code}\n' https://blindmonkeys.org/performance
# expect: 200
dig +short blindmonkeys.org
# expect: Google IPs (172.217.x.x โฆ) when grey-cloud, or Cloudflare IPs
# (104.21.x / 172.67.x) when orange โ but title check above is the real test
gcloud run services list --project project-46559977-eb74-48c3-a1e --region us-central1
# portfolio-agent-public must be present and serving
gcloud beta run domain-mappings list --project project-46559977-eb74-48c3-a1e --region us-central1
# blindmonkeys.org -> portfolio-agent-public must show status True (healthy cert)
Then pick the matching scenario below:
- Title is not "Blind Monkeys" โ Scenario A (domain is serving something else)
- Cloud Run service missing, erroring, or a bad revision is live โ Scenario B (redeploy / rollback)
- Site loads but data is gone (users, history, scans) โ Scenario C (data bucket restore)
Scenario A โ Domain serves the wrong content (hijack or bad DNS)
What happened 2026-11-02: a Next.js deployment on Cloudflare claimed blindmonkeys.org as a Worker custom domain and replaced the Flask site with a blank scaffold. The Flask app and data were untouched โ only routing was wrong.
- In Cloudflare โ Workers & Pages โ open the offending site โ Settings โ Domains & Routes โ remove the blindmonkeys.org custom domain. This releases the hostname.
- In DNS โ Records, set the apex records for blindmonkeys.org to Google
Cloud Run, proxy OFF (grey cloud):
AAAA @ 2001:4860:4802:32::15 (grey) AAAA @ 2001:4860:4802:34::1 (grey) AAAA @ 2001:4860:4802:36::15 (grey) AAAA @ 2001:4860:4802:38::15 (grey) A @ 216.239.32.21 (grey) A @ 216.239.34.21 (grey) A @ 216.239.36.21 (grey) A @ 216.239.38.21 (grey)
- Leave the TXT records (DMARC, google-site-verification) and the subdomain CNAMEs (scan / charts / positions / thumbnails โ ghs.googlehosted.com, grey) as they are.
- Wait for DNS to propagate (usually minutes), then re-run the Step 1 checks.
Note: orange-cloud (proxied) apex records pointing at Google IPs also
work โ Cloudflare proxies to Cloud Run โ but grey-cloud with Google's managed cert is the
pre-incident baseline. If Cloudflare reports "A DNS record managed by Workers already exists
on that host", remove the Worker custom domain first (step 1), then edit DNS.
Scenario B โ App is down, broken, or a bad revision is live
- Check service health on its direct URL:
curl -s -o /dev/null -w '%{http_code}\n' https://portfolio-agent-public-388170800364.us-central1.run.app/ gcloud run revisions list --project project-46559977-eb74-48c3-a1e --region us-central1 --service portfolio-agent-public
- Fastest fix โ roll back to the last known-good revision:
gcloud run services update-traffic portfolio-agent-public \ --to-revisions PREVIOUS_REVISION=100 \ --region us-central1 --project project-46559977-eb74-48c3-a1e
- Or redeploy from source (run from the repo / workspace root โ this is what runs in production):
gcloud run deploy portfolio-agent-public --source . \ --region us-central1 --project project-46559977-eb74-48c3-a1eEnvironment variables and Secret Manager bindings persist across deploys โ no extra flags needed.
- Verify with the Step 1 checks, plus key APIs:
curl -s https://blindmonkeys.org/api/ai-visibility | head -c 200 curl -s https://blindmonkeys.org/api/bot-pnl | head -c 200
The canonical source lives at git.sr.ht/~deanpowers/blind-monkeys and
must mirror production. Deploy from a checkout of that repo.
Scenario C โ Data bucket was wiped (restore from GCS soft delete)
All buckets have soft delete enabled with 7-day retention โ objects deleted (or overwritten) stay recoverable for a week.
- Inventory what was deleted (recursive โ subdirectory objects are easy to miss):
gcloud storage ls -l --soft-deleted --recursive gs://portfolio-agent-data-388170800364/ # trader state: gcloud storage ls -l --soft-deleted --recursive gs://blind-monkeys-trader-state/
- Read the output carefully. Each line ends with objectname#GENERATION. The highest generation number per object name is the newest pre-incident version โ restore that one.
- Restore each object via the REST API (gcloud 589 has no
objects restore command yet):
TOKEN=$(gcloud auth print-access-token) curl -X POST \ -H "Authorization: Bearer $TOKEN" \ "https://storage.googleapis.com/storage/v1/b/portfolio-agent-data-388170800364/o/OBJECT_NAME/restore?generation=GENERATION"URL-encode the object name (slashes become %2F). Restore fails if a live object with the same name exists โ back up and delete the live one first if needed.
- Restore the trader-state bucket the same way (same command, bucket blind-monkeys-trader-state).
- If an entire bucket was deleted (not just its contents):
gcloud storage buckets restore gs://BUCKET_NAME
Beware false alarms: files rewritten every 15 minutes by the crons
(admin_stats.jsonl, latest_scan_*.json, alerts.json, โฆ) accumulate thousands of soft-deleted
generations from normal overwrite churn. A real wipe shows every object soft-deleted at the
same moment. Check the describe output before panicking:
gcloud storage objects describe --soft-deleted \
gs://portfolio-agent-data-388170800364/FILE.json#GENERATION \
--format="value(name, generation, softDeleteTime)"
Soft-deleted objects older than 7 days expire permanently, and objects
deleted while soft delete was disabled on the bucket are not recoverable. Act quickly.
Step 2 โ Final verification checklist
- โ curl -s https://blindmonkeys.org/ โ 200, title "Blind Monkeys"
- โ /performance, /scan, /financials โ 200 and tables render
- โ /api/ai-visibility and /api/bot-pnl return real JSON data
- โ scan.blindmonkeys.org/summary โ 200
- โ Telegram: grid/futures alerts still arriving (check the newest message age)
- โ Bybit: positions and bots intact, balance unchanged
- โ gcloud run services list in both projects โ all revisions serving
- โ gcloud scheduler jobs list โ jobs enabled, last run OK
- โ Log the incident and fix in CHANGELOG.md, and update CONTINUITY.md if architecture changed
- โ Push the docs + any code changes to git.sr.ht/~deanpowers/blind-monkeys
Upcoming SOPs
Planned: SOP #2 โ Full platform wind-down (pause Cloud Scheduler in both projects,
DRY_RUN=true on the trader, liquidate via Bybit โ see CONTINUITY.md ยง8).
To add a new SOP, edit templates/admin_sops.html
and give it the next number.