# Chain Brain brief (Robinhood Chain), for a new Cowork session

Owner: Ben (Bangkok). Written 5 Oct 2026 by the coin brain session. Read all of this before doing anything.

## 1. The job

Build an elite **chain regime brain** for Robinhood Chain (RH) that answers two questions every 5 to 15 minutes:

1. **PEAK:** is the whole RH memecoin market topping out, about to pull back hard? (cool down coming)
2. **REHEAT:** after a cool down, is the chain starting to heat up again? (next wave starting)

Output is a single state plus a score. The coin brain (another session, folder `/opt/brain`) reads it as its on/off switch before every alert.

## 2. Required output (the contract)

Write atomically (tmp file then rename) every run to `/opt/brain/chain.json`:

```
{"ts": <unix>, "bkk": "05 Oct 14:05", "state": "HOT" | "PEAKING" | "COOLING" | "COLD" | "REHEATING",
 "risk": "on" | "off", "peak_p": 0.0-1.0, "reheat_p": 0.0-1.0,
 "why": "one plain sentence", "receipts": {"<feature>": value, ...}, "model": "<version>", "stale_after": <unix>}
```

`risk` is the only field the coin brain must obey (off = no buy alerts). Also publish a copy to the public folder (section 4) as `chain.json` so Ben can open it on his phone.

## 3. Ben's rules (non negotiable)

* Talk to Ben like he is 5: very short bullets, plain words, no jargon, **no dashes or em dashes**. One action word per alert (buy, hold, sell, risk on, risk off).
* **Bangkok time (UTC+7)** in everything he reads. Servers log UTC: convert.
* **Never put a secret on screen.** Inspect configs with `/opt/common/showcfg.py`, never `cat`. Secret files chmod 600.
* **Breaks fix themselves**, with REDUNDANT checkers (systemd timer AND cron, flock). Ben is alerted only when every fix failed, through `/opt/common/alertgate.py` (`from alertgate import down, back`). No "back" without a prior "down".
* First principles: state what must be true mechanically, then test it. A prior conclusion is an input to re-test, not a premise.
* Push back when there is a better way. Do things now, not later.
* Every new trading insight goes into the memory file `/areas/trading-edge-hub.md` ledger (rule, receipt, status) the same turn.
* Read memory first: `/areas/trading-edge-hub.md`, `/areas/rotation-watch.md`, `/areas/macro-direction.md`, `/areas/system-benchmark.md`, `/areas/bottom-timing.md`, `/areas/long-eco-bottom.md`, `/areas/claude-api-brain.md`.

## 4. How to reach the server

* Droplet "kookwatch", 159.223.88.168. 2 CPUs, 4 GB RAM, often load 4 to 5. 44 GB disk free. **Run heavy jobs with `nice -n 15`.** Do not starve the live pickers (they have a priority mode that pauses research jobs; respect it).
* Cloud sessions cannot SSH (port 22 blocked). Route: Ben's Mac via Desktop Commander, then `cd ~/kookwatch; python3 dbridge.py run '<shell cmd>' <timeout_s>`. Device calls time out at about 60 s, so start long jobs with `nohup ... &` and poll their log.
* To send a file to the droplet: gzip plus base64, echo through dbridge, decode on the droplet (chunks under about 12 KB).
* Public folder (no login, port 80): `/opt/launchwatch/pub/hx-c9ois/...` is served as `http://159.223.88.168/hx-c9ois/...`. Use it to move data out to the cloud container (curl) for heavy analysis, then delete large temp files.
* Telegram goes only through alertgate (config in `/opt/watchdog/config.json`).

## 5. Data that already exists (use it, do not rebuild it)

* **`/opt/hist/rh/YYYY-MM-DD.db`** (service `hist-rh`, `rh_rebuild.py`): every RH launch of this cycle rebuilt from chain logs, one SQLite per Bangkok day. Done back to 15 Sep, still filling back to 3 Jul (newest first). Tables: `launches` (token, ts, creator, factory, name, symbol, decimals, supply), `pools` (rowid = pid, c0, c1, fee, hooks, block), `transfers` (first 30 min only), `swaps` (first 6 h), **`bars` = 1 minute bars for 14 days for every pool that came alive** (pid, t, o, h, l, c, a0_pos, a0_neg, n_pos, n_neg). kv key `complete` marks a finished day.
  * **Trap 1:** bar price is currency1 per currency0. When the token is currency1 (token address > quote address), price must be inverted (1/p) and hi/lo swapped.
  * **Trap 2:** a0 is the trader's delta of currency0. a0 < 0 = trader paid currency0. So when quote is currency0, buys = a0_neg, n_neg. When the token is currency0, buys = a0_pos (token units).
  * **Trap 3:** no trades = no bar. Hold price flat; dead coins must stay in every index (survivorship killed a past study).
  * Hourly export of all bars: `/opt/brain/exp_bars.py` writes `http://159.223.88.168/hx-c9ois/brx/bars1h.csv.gz` (+ `launches.csv.gz`).
* **`/opt/runtrack/runtrack.db`** (services `runtrack`, `rhledger`): every RH coin that reached $500k ATH. `rh_flow` (10 min: real user holders, buy/sell USD, buyers, sellers, from Transfer logs, no double counting), `kline` (GMGN hourly), `rh_wnet` (hourly net per wallet), `snaps`, `tokens`.
* **`/opt/price-predict-rh/paper/gstream.db`** (`gmgnstream`): GMGN live RH feeds every 60 s since 3 Oct (smart money, KOL buys, signals, trenches lists, hot searches).
* **`/opt/rotation`** (Rotation Watch, already live): `http://159.223.88.168/rotation.json` is Ben's current risk on/off light. **Upgrade it, do not duplicate it.** Read its code and memory file first.
* `/opt/hist/analysis/` (launch pickers aipick, aipick30, aipick5 + sentinel, pickguard, reconcile): live paper results by hour are a crowd heat signal too.
* Candle bundles: `/opt/launchwatch/pub/hx-c9ois/tsb/` (mtf1.tgz, pit.tgz: 1h to 1d candles, RH, SOL, Base, Jul to Oct).
* Keys (never print): `/opt/common/rpc_keys.json` (dRPC), `gmgn_key` (GMGN Plus, ~20 req/s, 429 bans extend on retry: never retry loop), `twitterapi_key` (pay per use), `anthropic.json` (Claude API: fields key + workspace; send header `anthropic-workspace-id`; credits are small, about $15: use Haiku, cache, batch, and warn Ben when credits run low).
* RH public RPC `https://rpc.mainnet.chain.robinhood.com` needs a browser User-Agent, ~5 req/s. Block time ~0.1013 s. Uniswap v4 PoolManager `0x8366a39cc670b4001a1121b8f6a443a643e40951`. WETH `0x0bd7d308f8e1639fab988df18a8011f41eacad73`. fomo fill router `0x039ec98a76f111092d4751365ff09dd2aec301e8` (its logs mark real retail fills).

## 6. What past studies already found (re-test, do not assume)

* Best single filter in a 112 system benchmark: **equal weight chain basket above its EMA (200 on 1h, 50 on 4h)** gave +3.7 points per trade, win rate about 62%, positive in all four cells.
* 56 to 82% of RH and SOL coins have **negative autocorrelation**: trend systems lose on single coins. A chain level index may behave differently: test it.
* Price only rules for big upside died on untouched holdouts. Big moves need information earlier than price: flows, wallets, X.
* "72h losers" huge gains were survivorship and dead pool prints. Always use a point in time universe that includes dead coins.
* Robinhood "asset added" listing: +228% in the 24 h BEFORE the public post, then minus 31% by day 3.

## 7. What to build

**Labels (define precisely, point in time, no peeking):**
* Chain index = equal weight (and a liquidity weighted twin) of every RH coin alive at that moment, dead coins held flat, rebalanced hourly. Also a "breadth" index: share of alive coins above their own 24 h average.
* PEAK at time t = within the next 24 to 72 h the index falls at least X% (pick X from the data, for example 25%) from its max of t..t+12h, before it rises Y%.
* REHEAT at time t = after a drawdown of at least X%, within the next 24 to 72 h the index rises at least Y% before making a new low.
* Report base rates. Score with lead time: how many hours before the top or bottom the signal fires, and how many false alarms per week.

**Candidate signals (test all, keep only those that beat the baselines out of sample):**
* Money in: ETH bridged into RH per hour (find the bridge or inbox contract, verify it on chain), stablecoin inflow, new funded wallets per hour.
* Crowd: fomo router fills per hour and unique fomo buyers, share of buys that are fomo vs bots.
* Breadth: alive coins, share up on the day, new highs vs new lows, launches per hour, share of launches that come alive, median first-hour multiple of launches (launch picker results), time to first sell.
* Flow: chain wide buy share, net buy, buyers vs sellers, holder growth across runtrack coins, smart wallet net (rh_wnet with wallets scored only on their past).
* Leaders: AI, MOO, MEME and the other top caps vs the small caps (rotation down the cap curve near tops, leaders first on reheats).
* Exhaustion: volume climax, buy count up while price falls (distribution), divergence of index vs breadth, RSI on the index, distance from index EMA.
* Outside: ETH and SOL trend, BTC, US stock market hours (many RH coins are paired to stocks), weekends.
* X: mentions per hour of RH, Robinhood, long.xyz, fomo keywords (twitterapi.io, cheap, forward only, start logging now).

**Method:**
* Baselines it must beat: (a) basket above EMA, (b) Rotation Watch as is, (c) always on.
* Walk forward by week with an embargo, final untouched holdout of the most recent days. Shuffle test for luck. Report lift, precision, lead time, false alarms per week.
* Small, simple, robust models first (logistic or LightGBM with monotone sanity, few features). The sample is small (RH is about 3 months old), so fewer features beat more.
* Log every live state change with timestamp to a SQLite ledger and score it automatically 72 h later (forward scorecard).
* Start the new collectors (bridge inflow, fomo fills, breadth, X counts) immediately so history accumulates while modelling.

## 8. Deliverables

1. Service(s) under `/opt/chainbrain` with systemd + cron redundancy and a staleness self fix.
2. `/opt/brain/chain.json` updated every run, plus public copy.
3. A Telegram message to Ben only on state changes that matter: "PEAKING: risk off" or "REHEATING: risk on", one sentence, three receipts, Bangkok time.
4. A short memory file `/areas/chain-brain.md` with what exists, where, and what was proven or killed.
5. Final reply to Ben: 5 short bullets, how sure you are, what is still unknown.

## 9. Coordination

* The coin brain lives in `/opt/brain` (coin features from `bars1h.csv.gz`, hourly scorer). Do not edit its files. It only reads `/opt/brain/chain.json`.
* Do not touch the launch pickers in `/opt/hist` (aipick*, sentinel, pickguard, reconcile) or `hist-rh`.
