## §OIP SYSTEM ARTICLE — Cloudflare D1 (4 operations)
A generated article for one OIP shelf. It lists every operation in this API/CLI/MCP/device/model/core subsystem, links each leaf article, and gives the ledger path for proof.

### Read Order
- scan operations
- open a leaf doc
- run via run_now or POST /api/dispatch
- open receipt
- repair/replay if needed

### Operations
- **D1_QUERY** — Run a SELECT query on the D1 database.
  when: any read operation on D1 tables.
  args: $1 = the full SQL SELECT. Pipes and || are preserved now; inline literal values and double any single quotes. No bound parameters.
  doc: https://miscsubjects.com/api/dispatch?key=D1_QUERY&format=markdown
  run: https://miscsubjects.com/api/dispatch?invoke=D1_QUERY&body=SELECT%20*%20FROM%20directory%20WHERE%20key%20%3D%20'ROUTER'&share=<TOKEN>
  history: https://miscsubjects.com/api/invocations?object_id=D1_QUERY
- **D1_EXEC** — Run a non-SELECT D1 query (INSERT/UPDATE/DELETE).
  when: writing data to D1.
  args: $1 = the full SQL. Pipes and || are preserved; inline literal values and double any single quotes. No bound parameters — do not append ?|value, write the value inline.
  doc: https://miscsubjects.com/api/dispatch?key=D1_EXEC&format=markdown
  run: https://miscsubjects.com/api/dispatch?invoke=D1_EXEC&body=UPDATE%20directory%20SET%20category%20%3D%20'content-ops'%20WHERE%20key%20%3D%20'VOXEL_EDIT'&share=<TOKEN>
  history: https://miscsubjects.com/api/invocations?object_id=D1_EXEC
- **D1_TO_2D_ARRAY** — Run a SQL SELECT and return a 2D array (header row + values) suitable for sheets_replace_tab. $1=SQL
  when: you need to d1 to 2d array
  args: $1
  doc: https://miscsubjects.com/api/dispatch?key=D1_TO_2D_ARRAY&format=markdown
  run: https://miscsubjects.com/api/dispatch?invoke=D1_TO_2D_ARRAY&body=%3Carg1%3E&share=<TOKEN>
  history: https://miscsubjects.com/api/invocations?object_id=D1_TO_2D_ARRAY
- **D1_REPAIR** — Repair a bad row in a governed table (work_tasks, work_actions, articles, article_slots) with a raw statement 
  when: a row is genuinely wrong — a stuck lease, a mis-typed priority, a duplicated slot — and there is no task to submit evidence against. NOT for
  args: $1 = reason, at least a dozen characters, written into the audit row. $2 = the full SQL. Inline literal values; double any single quotes.
  doc: https://miscsubjects.com/api/dispatch?key=D1_REPAIR&format=markdown
  run: https://miscsubjects.com/api/dispatch?invoke=D1_REPAIR&body=clearing%20a%20lease%20held%20by%20a%20session%20that%20died%20mid-turn%7CUPDATE%20work_tasks%20SET%20lease_holder%3DNULL%2C%20lease_token%3DNULL%20WHERE%20id%20%3D%20'WT-0039'&share=<TOKEN>
  history: https://miscsubjects.com/api/invocations?object_id=D1_REPAIR

### Troubleshooting
- If a row's example has placeholders, replace only the placeholder values and preserve separators.
- If a call fails, open its receipt and repair it with POST /api/dispatch {key, body, repairs:'inv_ID'}.
- If token scope denies this system, ask the owner for a row:/rows:/pfx: token scoped to the exact operation set.

Back to the tree: https://miscsubjects.com/api/dispatch?map=1&format=markdown