Jump to content

IdiotProof/agent/IDIOTPROOF PROTOCOL

From MindAttic Docs

IdiotProof agent protocol

How an assistant (Claude Code, any MCP host, any LLM with a shell) drives IdiotProof on a person's behalf. The person speaks plainly; you turn it into exact idiotproof <noun> <verb> commands or mcp__idiotproof__<noun>_<verb> tool calls, all served by the IdiotProof Hub. This file is the etiquette and the map; the full command reference is generated: docs/CLI_COMMANDS.md, docs/MCP_TOOLS.md and docs/agent/operation-catalog.json (regenerate all three with idiotproof agent export).

1. Bootstrap (every session, first)

idiotproof agent bootstrap            # Hub health, owner, catalog size, docs, etiquette, exit codes
idiotproof agent bootstrap --json     # the same, machine-readable
  • agent bootstrap runs in the CLI itself and works with the Hub down. If it says the Hub is not running, start it: idiotproof hub start (with IDIOTPROOF_HUB_MONITOR=0 in the environment the trading loop stays off; without it the Hub also hosts the Monitor, which places real orders for active strategies). Never stop or restart a Hub you did not start unless the person asks.
  • Then learn the surface: idiotproof help, idiotproof <noun> --help, idiotproof agent catalog --json (the MCP server exposes the same catalog as tools).
  • The catalog describes itself, so read it before guessing (everything in it is generated from the code that enforces it):
    • each parameter of each operation has its type, value_kind, format, required, default, enum_values and an example the binder accepts (example_source says whether it was declared, taken from an example command, the default, or only the type's sample);
    • value_formats says, per value kind, what is accepted (dates yyyy-MM-dd, ET times HH:mm, numbers, flags), what is refused but corrected for you, and what is never corrected;
    • errors lists every status with its exit code and gives the JSON Schema of a usage error's data (errors[], fix with command_line, argv, args, changes), the meaning of each change kind, and how to apply the corrected call;
    • dsl lists every IdiotScript diagnostic code (IPS001...) with what its fix does or why it has none, the schema of the repair payload (diagnostics, fixes, corrected_script), and strategy_schema, the JSON Schema of the canonical strategy JSON.
  • Every command acts for one owner: --user <guid>, else the saved default (idiotproof users use <guid>), else the Hub's default when only one user exists. idiotproof users whoami says which and why.

2. The rules

  1. Everything goes through the Hub. Never call Alpaca, the database or Vault yourself, and never edit C:\Apps\IdiotProof or the SQL tables to "make something happen". If an operation does not exist, say so and offer to file a ticket.
  2. Exit codes mean something. 0 ok · 1 failed (or Hub not running) · 2 usage error (fix the command, use --help) · 3 blocked by a safety gate · 4 confirmation required.
  3. Exit 3 is final. A gate (Risk Guardian, kill switch, market-hours guard, Mock-feed guard, Live elevation) said no. Report the reason verbatim. Do not retry with different numbers, another mode, or another command to get around it.
  4. Exit 4 means nothing happened yet. The result carries a preview and a single-use code (6 characters, about 2 minutes, bound to the exact action). Show the person the preview verbatim and ask. Only on their explicit yes, re-run the identical command with --confirm <CODE> (MCP: the same tool with confirmation_code). Never confirm on your own, never reuse a code, never change the arguments between preview and confirm (any change voids the code).
  5. Modes. Sandbox is IdiotProof's simulator (always safe), Paper is Alpaca's paper account, Live is real money. Sandbox and Paper run immediately; every Live order, cancel, replace, close, exercise and crypto order needs the confirm step; funding and transfers always do. Do not pick Live unless the person said Live.
  6. Times are Eastern. Every time IdiotProof prints is ET (America/New_York). Quote it as ET; never convert to UTC or the person's local zone.
  7. Read before you write. Prefer read operations (list, show, status, preview) to answer questions. Use --json when you will parse the output; show people the human text.
  8. No secrets in chat. For keys set, pass --secret - so the value is read from stdin; never echo a key back.
  9. A strategy says everything the person said, or it isn't made. Every price level, count, order of events ("dips to X, then reclaims Y") and threshold in the request must appear in the script. Before strategy create, put each part of the request next to the verb that carries it. If any part has no verb (check dsl verbs), tell the person which part can't be expressed and stop. Never arm a strategy that drops, weakens or approximates a condition, and never swap in a "closest" verb without the person's explicit yes to the weaker version. Example: "dips to 275.60, then reclaims 276.10, with at least 2 higher lows" is .DippedTo(275.60).BreaksAbove(276.10).HigherLows(2), not .BreaksAbove(276.10).IsHigherLow().

3. Intent → operation

The person says Run
"How's my account / what's my P&L today?" account summary, account history --period 1M
"Is the market open?" account clock, account calendar
"What do I own?" / "close my NVDA" positions list, positions close NVDA (gateway; Live → code)
"Buy 10 AAPL" / "short TSLA" trade buy AAPL 10 --stop 180 --mode paper, trade short TSLA 5 --stop 260 (a stop is required: IP-LAW-2; trade preview shows the gate checks without sending)
"Spend $500 on SPY" trade notional SPY 500
"Bracket order with a stop" orders bracket ..., orders oco, orders oto
"What orders are working? cancel them" orders list, orders cancel <id>, orders cancel-all
"Quote / chart / news on X" market quote X, market chart X, market news X, market snapshot X
"What's moving?" market movers, market most-actives, scan movers
"Options on X" options chain X, options quote <contract>, options greeks, options buy/sell
"Crypto" crypto latest BTC/USD, crypto buy BTC/USD 0.01, crypto positions
"Make a strategy: buy NVDA if it reclaims VWAP, 2% stop" strategy from-text "..." --mode sandbox, then strategy show, strategy stamp
"Turn it on / off" strategy activate <id>, strategy deactivate <id> (Live → code)
"Why didn't it fire?" strategy progress <id>, strategy fires <id>, monitor status
"Gappers this morning" gapper profiles, gapper arm ..., gapper list, gapper auto status
"Replay / backtest it" replay run ..., backtest run ...
"Is the Risk Guardian on? kill everything" risk status, risk kill-switch on
"What does the LLM panel think?" llm panel, llm vote ...
"Research on X" research ticker X, research claims
"What did I trade?" diary list, diary pnl, audit tail

4. Knowing the project (docs operations)

The Hub indexes the BIBLE, AMENDMENTS, README, user stories, tickets, every library's XML doc comments with path:line, and the static catalogs. Use these instead of guessing:

idiotproof docs search <words>        # ranked across everything
idiotproof docs law 3                 # an IP-LAW in full (docs law = the list)
idiotproof docs section 4             # a BIBLE section (docs section = table of contents)
idiotproof docs story K1              # a user story with its status and proving tests
idiotproof docs explain TransactionGateway   # doc comment, declaration path:line, callers
idiotproof docs ticket IP-T259        # a ticket with its commits and dependencies
idiotproof docs dsl StopLoss          # an IdiotScript verb: phase, signatures, example
idiotproof docs dsl IPS006            # a diagnostic code: meaning, and what its fix does
idiotproof dsl diagnostics            # every diagnostic code (dsl verbs --json carries them too)
idiotproof dsl schema                 # the canonical strategy JSON: every key, type and required key

The laws in docs/BIBLE.md §5 are non-negotiable; if a request would break one (for example "skip the stop loss" breaks IP-LAW-2), say so instead of looking for a way.

5. MCP specifics

  • One tool per operation, named <noun>_<verb> (spaces and hyphens become _). Tool input is the operation's parameters in snake_case; money and destructive tools also take confirmation_code.
  • Read tools may be allow-listed. Money tools (trade_*, orders_* that change orders, positions_close*, options_buy|sell|close|exercise, crypto_buy|sell|withdraw) are deliberately not, so the host asks the person before a Live action is confirmed.
  • Resources: idiotproof://docs/bible, idiotproof://docs/user-stories, idiotproof://docs/protocol and idiotproof://catalog serve the BIBLE, the stories, this file and the live operation catalog.

6. When something fails

  • Hub not running → idiotproof hub start, then retry once.
  • Usage error → if the result shows a Corrected call (in --json and MCP: data.fix with command_line, argv, args and the changes made), check it is what you meant and resend it: it was not run, and it exists only when every problem had one certain correction. Otherwise each entry in data.errors names the parameter; read idiotproof <noun> <verb> --help and fix the arguments. A corrected call is an ordinary call: exit 3 and exit 4 apply to it as to any other.
  • A script that fails dsl validate → each syntax finding carries its fix (offset, length, replacement) and corrected_script is the whole script with the fixes applied, when that re-checks clean. dsl validate --fix (or dsl parse --fix) returns the corrected script as the result. Commands that save or activate a strategy never apply a fix: send the corrected script yourself, after checking it says what was meant. dsl diagnostics <code> explains a code; one that has no fix says why, and that part needs the person's decision.
  • Canonical strategy JSON the strict reader refuses → there is no fix payload; the message names the key or value. Correct it against dsl schema (the reader is the authority; the schema lists exactly the keys it accepts).
  • Blocked → report it (rule 3).
  • Anything else → show the message; idiotproof hub logs has the Hub side.
Part of IdiotProof.
From IdiotProof/docs/agent/IDIOTPROOF_PROTOCOL.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.