Frontend sends fullName to POST /users/create and PUT /users/ while FastAPI's UserBase expects full_name. Returns 200 OK and silently persists empty names to MongoDB. Caught in 210 ms.
Single-language typecheckers stop at the HTTP boundary. Cloud AI PR reviewers are slow and probabilistic. ProjectBrain is a local Tree-sitter CST & Python AST contract firewall, PR SARIF gate, and optional MCP coordinate router for FastAPI/Pydantic ↔ React/TS repos.
We ran projectbrain audit --profile fullstack zero-write across 43 active starred repositories (20,604 source files) and manually verified every headline bug.
Frontend sends fullName to POST /users/create and PUT /users/ while FastAPI's UserBase expects full_name. Returns 200 OK and silently persists empty names to MongoDB. Caught in 210 ms.
processWebSearch sends { query, collection_name } to POST /api/v1/retrieval/process/web/search while backend SearchForm expects queries: list[str] (guaranteed 422; drifted client helper still exported & imported).
FilesMenuCommandBox defined inside FilesMenu() remounts <CommandInput> and wipes search text on every file toggle; uncancelled useEffect fetches on [pageNumber] and [selectedFile] overwrite active file previews.
ToolResultDocument defined inside ToolCard() remounts stateful <JSONTree /> and collapses expanded nodes on parent renders; uncancelled getMyBot(botId) overwrites 15+ form fields on rapid navigation.
Works standalone as a CLI or CI PR gate without writing dotfiles or wiring MCP. Enable hooks or the lean 5-tool MCP server only when you want them.
# Non-overlapping profile alongside ruff / pyright / tsc / eslint (writes zero dotfiles):
uvx --from projectbrain-mcp projectbrain audit --profile fullstack
# Satellite Coordinate Router: exact file:Lstart-Lend spans + callers + covering tests (~500 tokens):
uvx --from projectbrain-mcp projectbrain route "how are invoices validated and settled"
# Day-1 architecture & boundary learning (optional):
uvx --from projectbrain-mcp projectbrain learn
# Permanent install via uv or pip:
uv tool install projectbrain-mcp
name: ProjectBrain Cross-Stack & Architecture Gate
on: [pull_request]
jobs:
guardrail:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v4
- name: Cross-stack schema, React lifecycle & architecture check
run: |
uvx --from projectbrain-mcp projectbrain check --base main --profile fullstack --ci --format sarif
# Or sticky Mermaid PR summary: projectbrain check --base main --format pr-comment
# .projectbrain.toml (or [tool.projectbrain] in pyproject.toml)
profile = "fullstack" # all | fullstack | governance
ignore = ["PB010"]
exclude = ["generated/*", "migrations/*"]
# Code-native business invariants (automatically surfaced & AST-hash locked):
# @pb-invariant: Must remain idempotent on duplicate invoice_id
@router.patch("/invoices/{invoice_id}")
def patch_invoice(invoice_id: str, payload: InvoicePatch):
data = payload.model_dump(exclude_unset=True) # safe partial update
# Inline escape hatch for intentional exceptions:
# pb:ignore PB013 -- deliberate full reset
{
"mcpServers": {
"projectbrain": {
"command": "uvx",
"args": ["--from", "projectbrain-mcp", "projectbrain-mcp", "--lean", "/path/to/your/repo"]
}
}
}
Built on bundled Tree-sitter C grammars (6 languages), Python AST dataflow, and a Salsa early-cutoff SQLite WAL code graph.
Verifies fetch, axios, and 1–2 hop client wrappers against FastAPI/Pydantic v1/v2, SQLModel, TypedDict, and @dataclass schemas — catching 422 missing fields, camelCase ↔ snake_case drift, response shape bugs, and HTTP verb mismatches.
Uses Tree-sitter CST to prove inline nested component remounts, post-mount loading early-returns unmounting stateful children, and uncancelled useEffect([dep]) async setState races.
Flow-sensitively catches .model_dump() / .dict() without exclude_unset=True clobbering columns in PATCH/update sinks (respecting exclude={...}) and silent except: pass around .commit() or outbound HTTP mutations.
Enforces --forbid architectural boundaries, tracks code-native @pb-invariant: AST hashes, and blocks AI agents from deleting or weakening .projectbrain.toml / governance rules in PRs.
Returns exact file:Lstart-Lend GPS coordinates, 1-hop callers/callees, HTTP route peers, covering tests, and invariants in ~500 tokens — letting agents use native read_file/edit_file without truncated dumps.
Diffs multi-commit PRs cleanly against git merge-base and outputs text, JSON, GitHub annotations, sticky Mermaid PR impact summaries, or OASIS SARIF v2.1.0 with zero cloud code egress.
pb)Need multi-repo contract linking, polyglot support beyond Python/TS, or sub-100 ms warm incremental checks? The core contract graph and Satellite MCP engine are also built as a 5-crate native Rust workspace.
pb-parser — Parallel rayon + blake3 + tree-sitter AST extractors across TypeScript/TSX/JS, Python, Go, Rust, Kotlin, Protobuf (.proto), OpenAPI, Prisma, and SQL.pb-graph — Incremental rusqlite WAL index (.pb/index.db), multi-repo pb.workspace.toml linker, Ochiai co-change graph, and brownfield baseline ratchet.pb-bundles & pb-reporters — Multiplex PPR Satellite Locator (pb_locate) with secret-redacting config fallback, <7,800-char inline MCP, Mermaid PR comments, and SARIF.pb-cli — Single stripped native binary (pb) with local CLI, editor hooks, GitHub Action, and stdio MCP server.# Clone & build the native Rust binary (`pb`)
git clone https://github.com/Johanabhishek/projectbrain-rs
cd projectbrain-rs
cargo build --release --bin pb
cargo test --workspace
# Index single repo or multi-repo workspace (pb.workspace.toml)
pb index
# Deterministic cross-stack & org contract PR gate
pb check --ci --base origin/main --new-only --format pr-comment
# Sub-60ms warm Satellite Locator over local graph
pb locate "invoice checkout route and schema"
| Layer | What It Catches | Blind Spot | ProjectBrain's Slot (--profile fullstack) |
|---|---|---|---|
ruff / pyright / tsc / eslint |
Single-language syntax, static types, lints | Blind across Python ↔ TS HTTP boundaries & repo invariants | Cross-stack schema solver (PB011), React races (PB012), Pydantic clobbers (PB013) |
| Cloud AI PR Reviewers | High-level logic & prose review | 30–90s latency, probabilistic noise, cloud code egress | <2s deterministic local/CI SARIF gate, zero API keys, Apache-2.0 |
| Coding Agents & Swarms | Fast rg, parallel edits, multi-file refactors |
Break uninspected callers, drift past invariants, tamper with configs | Post-edit hooks, tamper-locked rules (PB007), shared ~500-token coordinate routing |
fetch or axios clients.~515ms body edits on 3,051-file Django repos via SQLite WAL + Salsa early-cutoff).PB011: Split frontend/backend repos and generated OpenAPI SDKs (where tsc already checks generated types) don't need PB011.verify honestly returns UNKNOWN.