{
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "bearerFormat": "Co-Author Email (scampbell@torbrokerage.com | daeki.lee@hanwhalife.nyc | wjkoh@cwrk.ai)",
        "description": "Enter your pre-seeded co-author email address (e.g. wjkoh@cwrk.ai, scampbell@torbrokerage.com, or daeki.lee@hanwhalife.nyc) as the Bearer token.",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "ConnectRPC HTTP/JSON and OpenAPI 3.1 interface for collaborative authoring of the Project Barbell Master Book.\n\n### Editorial Rules (Strunk \u0026 White Standard)\n1. **Active Voice and Unpacked Clauses:** Use direct subjects and active verbs.\n2. **Omit Needless Words:** Eliminate throat-clearing introductions and empty qualifiers.\n3. **Zero Inline Backtick Clutter in Prose and Tables:** Never wrap numbers, percentages, basis points, dollar amounts, dates, token tickers, protocol names, or company names in inline backticks. Write `$1B` rather than `$1,000M`.\n4. **Punctuation, Math, and Typographic Discipline:** Suppress em dashes in prose; use native Unicode arrows/operators (`→`, `←`, `×`, `≤`, `≥`); format inline math with `\\(...\\)` and display math with `$$...$$`.\n5. **Institutional Precision:** Refer to the platform as **Project Barbell** and leadership as **ELT**; avoid 'sovereign' buzzwords.\n6. **Surgical Authoring Workflow:** Always call `ReadChapter` before `PatchChapter`.",
    "title": "Project Barbell · Master Book API Reference",
    "version": "1.0.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/book.v1.BookService/AddEditorialComment": {
      "post": {
        "description": "Stores a review comment anchored to a quote or heading in SQLite without polluting chapter Markdown.",
        "operationId": "AddEditorialComment",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "anchor_quote": {
                    "description": "Exact quoted phrase or heading",
                    "example": "Feature 1: Unified Multi-Custodian Balance Sheet",
                    "type": "string"
                  },
                  "comment_body": {
                    "description": "Review comment body",
                    "example": "Let's expand the Addepar comparison table here.",
                    "type": "string"
                  },
                  "slug": {
                    "description": "Chapter slug",
                    "example": "03-five-killer-features",
                    "type": "string"
                  }
                },
                "required": [
                  "slug",
                  "anchor_quote",
                  "comment_body"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "Add an editorial review comment to a chapter",
        "tags": [
          "Editorial Review Comments"
        ]
      }
    },
    "/book.v1.BookService/CreateChapter": {
      "post": {
        "description": "Creates a new Markdown chapter file, adds it to SUMMARY.md, commits to Git, and indexes in FTS5.",
        "operationId": "CreateChapter",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "commit_message": {
                    "description": "Commit message",
                    "example": "Add Chapter 8 on regulatory compliance",
                    "type": "string"
                  },
                  "initial_markdown": {
                    "description": "Initial Markdown content",
                    "type": "string"
                  },
                  "slug": {
                    "description": "New chapter slug",
                    "example": "08-regulatory-compliance",
                    "type": "string"
                  },
                  "title": {
                    "description": "Chapter title",
                    "example": "Chapter 8: Cross-Border Regulatory Architecture",
                    "type": "string"
                  }
                },
                "required": [
                  "slug",
                  "title",
                  "initial_markdown"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "Create a new chapter and register in SUMMARY.md",
        "tags": [
          "Surgical Authoring"
        ]
      }
    },
    "/book.v1.BookService/GetChapterBlame": {
      "post": {
        "description": "Computes section-by-section blame attribution for a chapter via go-git.",
        "operationId": "GetChapterBlame",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "slug": {
                    "description": "Chapter slug",
                    "example": "01-mfo-stack-teardown",
                    "type": "string"
                  }
                },
                "required": [
                  "slug"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "Get section-level Git blame attribution",
        "tags": [
          "Git History \u0026 Audit"
        ]
      }
    },
    "/book.v1.BookService/GetCommitDiff": {
      "post": {
        "description": "Returns the unified diff for a specific commit SHA.",
        "operationId": "GetCommitDiff",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "commit_sha": {
                    "description": "Commit SHA",
                    "example": "HEAD",
                    "type": "string"
                  },
                  "slug": {
                    "description": "Optional chapter slug",
                    "type": "string"
                  }
                },
                "required": [
                  "commit_sha"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "Get unified Markdown diff for a commit",
        "tags": [
          "Git History \u0026 Audit"
        ]
      }
    },
    "/book.v1.BookService/GetTableOfContents": {
      "post": {
        "description": "Returns SUMMARY.md, word counts, open comment counts, and live URLs for all chapters.",
        "operationId": "GetTableOfContents",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {},
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "Return Table of Contents and chapter metadata",
        "tags": [
          "Reading \u0026 Search"
        ]
      }
    },
    "/book.v1.BookService/ListAgentActivity": {
      "post": {
        "description": "Returns recent MCP and ConnectRPC tool invocations from the SQLite audit log.",
        "operationId": "ListAgentActivity",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "author_id": {
                    "description": "Optional author ID filter (woojong, sam, daeki)",
                    "type": "string"
                  },
                  "limit": {
                    "description": "Max entries",
                    "example": 20,
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "List recent AI agent tool calls",
        "tags": [
          "Git History \u0026 Audit"
        ]
      }
    },
    "/book.v1.BookService/ListEditorialComments": {
      "post": {
        "description": "Lists editorial comments from SQLite filtered by chapter slug and status.",
        "operationId": "ListEditorialComments",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "slug": {
                    "description": "Optional chapter slug",
                    "example": "01-mfo-stack-teardown",
                    "type": "string"
                  },
                  "status": {
                    "description": "open, resolved, or all",
                    "example": "open",
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "List open or resolved editorial comments",
        "tags": [
          "Editorial Review Comments"
        ]
      }
    },
    "/book.v1.BookService/ListRecentChanges": {
      "post": {
        "description": "Lists recent Git commits across the book or for a single chapter.",
        "operationId": "ListRecentChanges",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "limit": {
                    "description": "Max commits",
                    "example": 15,
                    "type": "integer"
                  },
                  "slug": {
                    "description": "Optional chapter slug",
                    "example": "",
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "List recent Git commits",
        "tags": [
          "Git History \u0026 Audit"
        ]
      }
    },
    "/book.v1.BookService/PatchChapter": {
      "post": {
        "description": "Replaces old_text with new_text, commits to Git via go-git under the authenticated author, updates FTS5, and re-renders the book.",
        "operationId": "PatchChapter",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "author_name": {
                    "description": "Optional author email or name override",
                    "type": "string"
                  },
                  "commit_message": {
                    "description": "Concise Git commit summary",
                    "example": "Refine MFO custody fee comparison",
                    "type": "string"
                  },
                  "expected_revision_sha": {
                    "description": "Optional optimistic lock SHA",
                    "type": "string"
                  },
                  "new_text": {
                    "description": "Replacement Markdown text",
                    "type": "string"
                  },
                  "old_text": {
                    "description": "Exact contiguous Markdown text to replace",
                    "type": "string"
                  },
                  "slug": {
                    "description": "Target chapter slug",
                    "example": "01-mfo-stack-teardown",
                    "type": "string"
                  }
                },
                "required": [
                  "slug",
                  "old_text",
                  "new_text",
                  "commit_message"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "Apply surgical search-and-replace edit to a chapter",
        "tags": [
          "Surgical Authoring"
        ]
      }
    },
    "/book.v1.BookService/ReadChapter": {
      "post": {
        "description": "Reads full Markdown prose, current Git revision SHA, and open SQLite editorial comments.",
        "operationId": "ReadChapter",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "slug": {
                    "description": "Chapter slug (e.g. 01-mfo-stack-teardown)",
                    "example": "01-mfo-stack-teardown",
                    "type": "string"
                  }
                },
                "required": [
                  "slug"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "Read chapter Markdown and open comments",
        "tags": [
          "Reading \u0026 Search"
        ]
      }
    },
    "/book.v1.BookService/ResolveEditorialComment": {
      "post": {
        "description": "Marks a comment as resolved in SQLite with a resolution note.",
        "operationId": "ResolveEditorialComment",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "comment_id": {
                    "description": "Comment ID",
                    "example": 1,
                    "type": "integer"
                  },
                  "resolution_note": {
                    "description": "Resolution note",
                    "example": "Addressed in latest commit.",
                    "type": "string"
                  }
                },
                "required": [
                  "comment_id"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "Resolve an editorial comment",
        "tags": [
          "Editorial Review Comments"
        ]
      }
    },
    "/book.v1.BookService/RevertChapterRevision": {
      "post": {
        "description": "Creates a forward Git commit restoring a chapter to a historical commit SHA.",
        "operationId": "RevertChapterRevision",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "description": "Reason for reverting",
                    "type": "string"
                  },
                  "slug": {
                    "description": "Chapter slug",
                    "example": "01-mfo-stack-teardown",
                    "type": "string"
                  },
                  "target_commit_sha": {
                    "description": "Target historical commit SHA",
                    "type": "string"
                  }
                },
                "required": [
                  "slug",
                  "target_commit_sha"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "Restore a chapter to a prior commit SHA",
        "tags": [
          "Git History \u0026 Audit"
        ]
      }
    },
    "/book.v1.BookService/SearchBook": {
      "post": {
        "description": "Searches all chapters using SQLite FTS5 BM25 ranking and returns highlighted snippets.",
        "operationId": "SearchBook",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "limit": {
                    "description": "Maximum matches to return",
                    "example": 10,
                    "type": "integer"
                  },
                  "query": {
                    "description": "Search query phrase",
                    "example": "Sand Hill Global Advisors",
                    "type": "string"
                  }
                },
                "required": [
                  "query"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Successful ConnectRPC JSON response"
          }
        },
        "summary": "Search chapters via SQLite FTS5 BM25",
        "tags": [
          "Reading \u0026 Search"
        ]
      }
    }
  },
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "servers": [
    {
      "description": "Project Barbell Master Book Server",
      "url": "https://136-87-183-68.sslip.io"
    }
  ],
  "tags": [
    {
      "description": "Inspect the Table of Contents, read chapter Markdown, and run SQLite FTS5 BM25 full-text queries.",
      "name": "Reading \u0026 Search"
    },
    {
      "description": "Apply exact search-and-replace patches or create new chapters backed by pure-Go go-git commits.",
      "name": "Surgical Authoring"
    },
    {
      "description": "Add, list, and resolve anchored review comments in SQLite WAL without polluting chapter prose.",
      "name": "Editorial Review Comments"
    },
    {
      "description": "Inspect chronological Git commits, unified diffs, section-level blame, and multi-agent audit logs.",
      "name": "Git History \u0026 Audit"
    }
  ]
}
