# orestack-miner — agent onboarding

Headless Orestack mining CLI (issue #1279 Part 2). Signs with a **local keypair file**.
The Orestack crank discovers the StrategyDeployer on-chain and deploys at the
product fee floor (**50 bps + 250,000 lamports flat**).

This is a **test-only POC**. Do not publish to npm. Do not send mainnet
transactions unless Will explicitly approves a pilot.

## Hard rules for AI agents

1. **Dedicated wallet.** Use a throwaway / pilot wallet only. Never reuse a
   treasury, executor, or personal wallet.
2. **Top-up only.** Fund the Auth PDA with small SOL (`fund`). Do not drain
   other accounts into this miner.
3. **Caps.** Default per-command cap is `50_000_000` lamports (0.05 SOL).
   Default per-day cap is `250_000_000` lamports (0.25 SOL). Raise only with
   `--per-command-cap` / `--per-day-cap` when the operator asks.
4. **Simulate first.** Every chain mutation simulates. Pass `--yes` only after
   the dry-run looks correct. Without `--yes`, nothing is broadcast.
5. **Never print the key.** Do not `cat` the keypair, do not log secret bytes,
   do not paste seed phrases into chat or shell history. File mode `0600`.
6. **Nonzero limits.** `--max-per-round` and fee ceilings must be nonzero
   (on-chain `0` means unlimited).
7. **Executor.** Always the product Orestack executor (`CYT7…`). There is no
   `--executor` override — the flag is rejected.

## Safe fields to change

| Field | Safe? | Notes |
|-------|-------|-------|
| `--strategy lotto\|og_sniper` | yes | Only these two in the POC |
| `--max-per-round` | yes | Must be > 0 |
| `--rpc-url` | yes | Prefer a private RPC; mainnet is read/simulate-only unless Will says go |
| `--backend-url` | yes | Production API for notify / pause / resume |
| `--executor` | **no** | Rejected; product CYT7 only |
| keypair path | yes | Path only — never the contents |
| fees | **no** | Hardcoded 50 / 250k |

## Command order

```text
1. init --strategy lotto|og_sniper --max-per-round <SOL|lamports>
2. fund <SOL>
3. start          # signed resume (idle-pause was set by onboarding-notify)
4. (crank deploys within ~300s of rediscovery / notify)
5. stop           # signed pause
6. withdraw <SOL>|all   # unused Autodeploy balance (before claim)
7. claim [--kind ore|sol|all]  # MMClaimSOL also sweeps remaining Auth lamports
```

Dry-run every step first (no `--yes`), then re-run with `--yes`.

## Identity

- **Manager** — control key used by API paths and this CLI's local state.
- **Auth PDA** — the public miner address shown in the UI / explorers.
- Never substitute one for the other.

## Local state

Default dir: `~/.orestack-miner/`

- `miner.json` — manager, authPda, executor, strategy (no secrets)
- `spend-ledger.json` — per-day spend totals

## Notify endpoints

- `POST /api/onboarding-notify/{manager}` after confirmed `init` (hard-fail;
  idle-pause must land).
- `POST /api/deposit-notify/{manager}` after confirmed `fund` (soft-fail).
- Use `--skip-notify` only on a local fork / offline test.

## Install (monorepo)

```bash
cd packages/mining-sdk
npm install
npm run build
npx orestack-miner help
```
