diff --git a/README.md b/README.md
index d93fd48..bd15652 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,46 @@
+
+
# Git0
-**Agents get their own memory branches. FalkorDB merges what they learned by meaning, not by text, and every answer shows the commit path it came from.**
+**Agents get their own memory branches. FalkorDB merges what they learned by meaning, not by text,
and every answer shows the commit path it came from.**
+
+[](https://15-252-11-70.sslip.io)
+[](https://15-252-11-70.sslip.io/ide/)
+[](https://15-252-11-70.sslip.io/docs)
+[](https://github.com/HXMAN76/git0/actions/workflows/ci.yml)
+[](https://www.falkordb.com)
+[](LICENSE)
-**Live demo: https://15-252-11-70.sslip.io** · IDE demo: https://15-252-11-70.sslip.io/ide/ · API docs: https://15-252-11-70.sslip.io/docs
+**WeMakeDevs × FalkorDB Graph Hacks** · Track 02 **Agent Memory and Coordination** (main) · also Track 03 **Company Brain**
-Built for **WeMakeDevs × FalkorDB Graph Hacks**. Tracks entered: **Track 02 Agent Memory and Coordination** (main), also **Track 03 Company Brain**.
+
+
+| Read this if you have... | |
+|-|-|
+| 60 seconds | [Try it in 60 seconds](#try-it-in-60-seconds) |
+| 3 minutes | [The problem](#the-problem) → [How it works](#how-it-works) → [Without FalkorDB](#what-happens-without-falkordb) → [Why not SQLite?](#why-not-just-use-sqlite) |
+| 10 minutes | [Graph data model](#graph-data-model) → [Key Cypher queries](#key-cypher-queries) → [Pipeline](#pipeline-what-runs-where) → [Quickstart](#quickstart-3-commands) |
## Try it in 60 seconds
-Open the live link. You get your own team room (a private FalkorDB graph) seeded with a launch plan: 37 facts on `main`, and a Scheduler branch that booked the venue and sent invites for **Friday**.
-1. Tell **Planner**: *"The launch moved to Monday."* (one click in the "Try the demo" bar). Planner commits `launch|deadline = monday` to its own branch.
-2. Click **Merge Scheduler**. Its Friday bookings join team memory. No disagreement yet.
-3. Click **Merge Planner**. The card says **"Planner and Scheduler disagree"**: the venue, invites and catering were built on Friday, and Planner changed Friday. The Arbiter explains it in plain words.
-4. **Pick a side.** One merge commit lands. If you pick Monday, the three Friday tasks are removed and the **Arbiter asks Scheduler to re-plan only those**. The other facts stay untouched.
-5. Click **why?** on any agent answer: the fact, the commit, the agent and the chat turn light up in the memory graph. Ask about something nobody said (e.g. the caterer's contact): the agent replies *"Not in team memory (no path from HEAD)"* instead of guessing.
+### Memory branches: https://15-252-11-70.sslip.io
+You get your own team room, a private FalkorDB graph seeded with a launch plan: 37 facts on `main`, plus a Scheduler branch that booked the venue, sent invites and set catering, all for **Friday**.
+
+1. **Tell Planner "The launch moved to Monday."** It's one click in the "Try the demo" bar. Planner commits `launch|deadline = monday` to *its own* branch.
+2. **Click Merge Scheduler.** Its Friday bookings join team memory. No disagreement yet.
+3. **Click Merge Planner.** The card says **"Planner and Scheduler disagree"**. Venue, invites and catering were built on Friday, and Planner just changed Friday. A line-based merge would call this clean, because they are different keys. The Arbiter explains the disagreement in plain words.
+4. **Pick a side.** One merge commit lands. Pick Monday, and the three Friday tasks are removed and the **Arbiter asks Scheduler to re-plan only those**. Every other fact stays untouched.
+5. **Click "why?" on any answer.** The fact, the commit, the agent and the chat turn light up in the memory graph. Ask about something nobody said, like the caterer's contact, and the agent replies *"Not in team memory (no path from HEAD)"* instead of guessing.
+
+### Code relay: https://15-252-11-70.sslip.io/ide/
+1. Click **Run the scenario**. Alice's agent adds regional tax (`apply_tax(amount, region)`). Bob's agent adds free shipping to the same `calculate_total`.
+2. Bob's write is **stopped before it happens**. The PreToolUse hook asked FalkorDB "does this collide with anything a teammate changed?" and the answer was yes.
+3. **You decide:** pull Alice's change and rework on top, keep yours, or pause. The graph panel lights up the collision path, and **Merge check** shows what plain `git merge-file` would have said versus what Git0 knows.
## The problem
-Multi-agent systems share one memory, and the last write wins. Planner moves the launch to Monday. Scheduler already booked the venue for Friday. Nothing flags it: Scheduler's tasks now rest on a value that is no longer true, and no one finds out until the venue is empty on Monday.
+Multi-agent systems share one memory, and the last write wins. Planner moves the launch to Monday, but Scheduler already booked the venue for Friday. Nothing flags it. Scheduler's tasks now rest on a value that is no longer true, and nobody finds out until the venue is empty on Monday.
-Text-based "git for memory" doesn't fix this either. Venue and deadline are different lines, so a line merge calls it clean.
+Text-based "git for memory" doesn't help either. Venue and deadline are different lines, so a line merge calls it clean. The same thing happens with code: two AI agents edit different lines of the same function, git merges it cleanly, and the logic is broken.
## How it works
@@ -43,42 +65,76 @@ flowchart TB
H -. "invalidated facts" .-> A["Arbiter LLM
explains, asks owners to re-plan"]
```
-- **Branch per agent.** Each agent (Planner, Scheduler, Notes) writes facts `(subject, predicate, object)` to its own branch. Agents read memory **only** through `checkout(branch)`. There are no caches and no agent-to-agent messages, so FalkorDB is the only channel between them.
+- **Branch per agent.** Planner, Scheduler and Notes each write facts `(subject, predicate, object)` to their own branch. Agents read memory **only** through `checkout(branch)`. There are no caches and no agent-to-agent messages, so FalkorDB is the only channel between them.
- **Every commit is one Cypher query** with compare-and-set on the branch HEAD. If HEAD moved, 0 rows come back, nothing is written, and the client retries. Concurrent agents never lose an update.
-- **3-way semantic merge** (`src/git0/core/merge.py`). Merge base vs ours vs theirs, keyed by `subject|predicate`. Per-predicate `(:Rule)` nodes decide: `deadline` and `owner` need review, `preference` is latest-wins. A one-sided change is still flagged (`reason=dependency`) when the other side **derived new facts from the value being replaced**. That is the Friday/Monday case, and a line merge cannot see it.
-- **Deterministic authority.** Cypher rules plus the human decide. The Arbiter LLM only writes the explanation and re-derives the invalidated facts. If the LLM fails, the API returns a 502 and the UI shows a red banner. There is no canned output.
+- **3-way semantic merge** ([`core/merge.py`](src/git0/core/merge.py)). Merge base vs ours vs theirs, keyed by `subject|predicate`. Per-predicate `(:Rule)` nodes decide: `deadline` and `owner` need review, `preference` is latest-wins. A one-sided change is still flagged (`reason=dependency`) when the other side **derived new facts from the value being replaced**. That's the Friday/Monday case.
+- **Deterministic authority.** Cypher rules and the human decide. The Arbiter LLM only writes the explanation and re-derives the invalidated facts. If the LLM fails, the API returns 502 and the UI shows a red banner. There is never canned output.
- **Precedent.** Each resolution is saved as a `(:Precedent)`. The next conflict on the same predicate shows which side the team picked before and how many times (e.g. "target chosen 2x").
+- **Code relay** ([`code/relay.py`](src/git0/code/relay.py), [`ide/`](src/git0/ide/)). The same idea applied to code. A code-context graph holds files, symbols, `CALLS` edges, each agent's `Change`s and announced `Intent`s. After a write, `code_record_edit` records which symbols changed and whether a signature changed. Before a write, `code_check_edit` checks the peer's unseen changes: the same function, a call to a function whose signature changed, or a function the peer's new code reaches through `CALLS*1..3`. A hit blocks the write. Any MCP harness (Claude Code, Cursor, Gemini CLI) can use the same tools at `/mcp/`. See [mcp.md](mcp.md).
+
+## What happens without FalkorDB
+**The application stops working. There is no other store to fall back on.**
+
+We tested it: we started the API pointed at a port with no FalkorDB behind it.
+- `/api/health`, `/seed`, `/checkout` and `/scorecard` all return **500** (`redis.exceptions.ConnectionError: Connection refused`).
+- An agent turn fails before it says a word. The first thing `agents.base.step` does is `checkout(branch)`, and that is a Cypher query. Agents hold no state between turns, so with the graph gone **they know nothing**, not even their own past answers.
+- The IDE hooks fail too. `code_check_edit` and `code_record_edit` are graph queries, so no collision can be detected.
-### Git0 Relay: the same idea for code (IDE demo, `/ide/`)
-Two AI coding agents ("Alice" and "Bob") work in separate clones of a small Python shop (`demo_project/`). Every tool call goes through Pre/PostToolUse hooks that call the **git0 MCP server** (`/mcp`, streamable HTTP). The server keeps one code-context graph in FalkorDB: files, symbols, `CALLS` edges, each agent's `Change`s and announced `Intent`s.
-- After a write, `code_record_edit` records which symbols changed and whether a signature changed.
-- Before a write, `code_check_edit` checks the peer's unseen changes: the same function, a call to a function whose signature the peer changed, or a function the peer's new code reaches through `CALLS*1..3`. A hit **blocks the write**, and the human chooses: pull the peer's change, keep mine, or pause.
-- The merge check compares `git merge-file` (line-based) with the symbol/call analysis, so you can see git call a merge "clean" that is still broken.
+Here is what each feature loses:
-The agents are pydantic-ai on Gemini. Each visitor gets a private graph `ide_`, deleted on End session, on tab close, or after 15 min idle. Any MCP harness (Claude Code, Cursor, Gemini CLI) can connect: see [mcp.md](mcp.md). Spec: [docs/plans/2026-10-18-ide-demo.md](docs/plans/2026-10-18-ide-demo.md).
+| Feature | Runs as | Without FalkorDB |
+|-|-|-|
+| Agent memory (checkout) | [`checkout.cypher`](cypher/checkout.cypher) | agents have no facts and cannot answer |
+| Writing memory | one CAS query, [`commit_cas.cypher`](cypher/commit_cas.cypher) | nothing is saved; concurrent writes can't be ordered |
+| Merge + dependency conflicts | [`merge_base`](cypher/merge_base.cypher), [`dependents_visible`](cypher/dependents_visible.cypher), [`merge_commit`](cypher/merge_commit.cypher) | no "Planner and Scheduler disagree" card |
+| Why-path, "not in memory" | [`why_path`](cypher/why_path.cypher), [`fact_lookup`](cypher/fact_lookup.cypher) | answers can't be traced or proven absent |
+| Precedent, scorecard | [`precedent_lookup`](cypher/precedent_lookup.cypher), [`scorecard`](cypher/scorecard.cypher) | no learned decisions, no live counters |
+| Tenant rooms | one graph per room `team_` | no isolation, no TTL sweep |
+| Code relay | [`code_conflicts_*`](cypher/), [`code_record_edit`](cypher/code_record_edit.cypher) | the agents' collision goes unnoticed until git merge time |
+
+## Why not just use SQLite?
+To be fair: SQLite could store these rows, and SQLite has transactions, so a compare-and-set commit is possible there too. Here is what the same product would cost on SQLite.
+
+| Need | FalkorDB (what we run) | SQLite equivalent |
+|-|-|-|
+| "What was built on Friday?" | `(d:Fact)-[:DERIVED_FROM*1..6]->(f)`, one pattern | a recursive CTE over a `derived_from` join table, with a depth counter and a cycle guard, re-joined to commit visibility |
+| "Does my edit reach code Bob changed?" | `(caller)-[:CALLS*1..3]->(target)` and `nodes(p)` returns the path the UI lights up | a recursive CTE that builds the path as a string, then parses it back out |
+| Why-path for an answer | one match: fact ← commit ← agent → episode | a 4-table join written per question |
+| Many writers on many machines | a network server: the API, the MCP endpoint and hooks on two "laptops" all talk to one graph | a file with one writer at a time on one host; the MCP clients would need a server in front of it anyway |
+| One memory per team | `GRAPH.QUERY team_`, `GRAPH.DELETE`, list graphs on one server | a file per tenant plus your own cleanup and routing |
+| New memory kinds (`Procedure`, `Intent`, `Change`) | new labels and edges, no migration | a new table and migration each time |
+| Show the memory | the FalkorDB Browser and `@falkordb/canvas` render the graph as stored | build nodes and links yourself |
+
+The bigger point: Git0's core questions are path questions ("what depends on this?", "what reaches this function?", "where did this answer come from?"). In a graph database they are one Cypher pattern each. In SQL they become recursive CTEs.
+
+## Pipeline: what runs where
-## What breaks without FalkorDB
-Everything. Checkout, commit (CAS), log, merge base, conflict detection, dependents, the revert cascade, why-paths, "not in memory" proofs, precedents, tenant isolation, the scorecard and the code relay are all Cypher queries. Agents hold no state between turns. Stop the container and the agents know nothing.
+
-Graph features the product leans on: the `DERIVED_FROM*1..6` traversal finds what depends on a value, `CALLS*1..3` finds code that reaches a changed function, `GRAPH.QUERY`'s per-query atomicity makes the one-query CAS commit safe, and one graph per room gives isolation.
+1. **Browser (React).** The team room (`/`) and the IDE (`/ide/`) are served as one static build by FastAPI on the AWS EC2 host, behind Caddy (auto-HTTPS on `sslip.io`).
+2. **Agents.** In the IDE demo, two **Pydantic AI** harness agents (Alice and Bob) each work in their own clone. Memory-branch agents (Planner, Scheduler, Notes, Arbiter) run a plain loop: `checkout → LLM → commit`.
+3. **Model inference.** The IDE agents call **Gemini** on Google Cloud. The memory agents call **Groq** `openai/gpt-oss-20b` with a strict JSON schema and fall back to Gemini. Every output is validated with Pydantic, and a failure surfaces as an error.
+4. **Tool hooks → MCP → FalkorDB.** Every agent tool call passes Pre/PostToolUse hooks, which call the git0 MCP server (`/mcp/`). That server runs the `code_*` Cypher queries against **FalkorDB in Docker** on the same host. FalkorDB's port is never public.
+5. **FastAPI (Python)** owns every write: one Cypher query each, loaded by name from [`cypher/`](cypher/). It also runs the room TTL sweep and the IDE session sweeper.
+6. **Deploy.** A push to `main` runs CI (ruff, Cypher-docs drift check, pytest against a real FalkorDB, web tests and build). When CI is green, GitHub Actions builds the image, pushes it to ECR and redeploys the EC2 host over SSM.
## Track 02 focus items → live features
-The right panel of the app shows a live scorecard, read from the graph by one Cypher query ([`cypher/scorecard.cypher`](cypher/scorecard.cypher)).
+The right panel of the app shows a live scorecard, read from the graph by one query ([`scorecard.cypher`](cypher/scorecard.cypher)).
| Track 02 focus item | Git0 feature | Scorecard counter |
|-|-|-|
| Semantic memory | `(:Fact {s,p,o})`, visible per branch | Facts in team memory |
| Episodic memory | `(:Episode)` per chat turn, linked to the commit it produced | Chat turns remembered |
-| Procedural memory | versioned `(:Procedure)` plus `(:Rule)` and `(:Precedent)` reused on the next conflict | Learned procedures · Past decisions reused |
+| Procedural memory | versioned `(:Procedure)`, plus `(:Rule)` and `(:Precedent)` reused on the next conflict | Learned procedures · Past decisions reused |
| Persistent conversation history | `(:Session)-[:HAS_TURN]->(:Episode)`; agents resume from `checkout` + `log` after a restart | Sessions |
-| Shared state and handoffs | merge into `main`; `POST /api/{t}/agents/{a}/kill` hands a branch to a successor, which reads the branch and commits a `handoff` | Merges · Handoffs |
+| Shared state and handoffs | merge into `main`; `POST /api/{t}/agents/{a}/kill` hands a branch to a successor, which reads it and commits a `handoff` | Merges · Handoffs |
| High-concurrency reads/writes | one-query CAS commit + retry | Memory updates |
-| Separate memory per tenant | one graph per room `team_` (idle rooms swept after 2 h) | Live team rooms |
+| Separate memory per tenant | one graph per room `team_` (idle rooms swept after 2 h); one graph per IDE session `ide_` | Live team rooms |
-Track 03 fit: every fact traces back to its agent, commit and chat turn (why-path), `owner` is a first-class predicate, and merges keep knowledge current as plans change.
+**Track 03 fit:** every fact traces back to its agent, commit and chat turn (why-path); `owner` is a first-class predicate; merges keep knowledge current as plans change.
## Graph data model
-One graph per team room (`team_`). Full model with invariants: [docs/ARCHITECTURE.md §2](docs/ARCHITECTURE.md#2-graph-model-per-tenant-graph-team_id).
+One graph per team room (`team_`). The full model with invariants is in [docs/ARCHITECTURE.md §2](docs/ARCHITECTURE.md#2-graph-model-per-tenant-graph-team_id).
```
(:Branch {name})-[:HEAD]->(:Commit {id, seq, kind, ancestors:[ids]})-[:PARENT]->(:Commit) // 2 parents on a merge
@@ -91,7 +147,13 @@ One graph per team room (`team_`). Full model with invariants: [docs/ARCHITE
(:Rule {p, strategy}) // deadline: needs-review, preference: latest-wins
```
-Code relay graph (`ide_`): `(:File)-[:DEFINES]->(:Symbol)-[:CALLS]->(:Symbol)`, `(:Agent)-[:MADE]->(:Change)-[:TOUCHED]->(:Symbol)`, `(:Agent)-[:INTENDS]->(:Intent)-[:TARGETS]->(:Symbol)`, `(:Agent)-[:ACKED]->(:Change)`.
+Code relay graph (one per IDE session, `ide_`):
+```
+(:File {path})-[:DEFINES]->(:Symbol {id, signature, body_hash})-[:CALLS]->(:Symbol)
+(:Agent)-[:MADE]->(:Change {kind, old_signature, new_signature})-[:TOUCHED]->(:Symbol)
+(:Agent)-[:INTENDS]->(:Intent {task, active})-[:TARGETS]->(:Symbol)
+(:Agent)-[:ACKED]->(:Change) // "I have seen this change"
+```
## Key Cypher queries
All 39 queries live in [`cypher/`](cypher/), one file each, with a comment saying why it exists. [docs/CYPHER.md](docs/CYPHER.md) lists them all (generated; CI checks it is current).
@@ -107,7 +169,7 @@ WHERE none(x IN rs WHERE x IN anc)
RETURN DISTINCT f
```
-**Commit with compare-and-set** (start of [`commit_cas.cypher`](cypher/commit_cas.cypher)). A stale `$expected` matches nothing, so nothing is written. Facts, removals, episodes and derivations follow in `CALL { WITH n UNWIND ... }` unit subqueries, all in the same query.
+**Commit with compare-and-set** (the start of [`commit_cas.cypher`](cypher/commit_cas.cypher)). A stale `$expected` matches nothing, so nothing is written. Facts, removals, episodes and derivations follow in `CALL { WITH n UNWIND ... }` unit subqueries, all in the same query.
```cypher
MATCH (b:Branch {name: $branch})-[r:HEAD]->(h:Commit {id: $expected})
CREATE (n:Commit {id: $id, seq: h.seq + 1, kind: $kind, ancestors: h.ancestors + [h.id]})-[:PARENT]->(h)
@@ -123,7 +185,7 @@ MATCH (c:Commit) WHERE c.id IN aa AND c.id IN bb
RETURN c.id ORDER BY c.seq DESC LIMIT 1
```
-**Dependents still visible at a commit**: what goes stale if a value changes. Powers dependency conflicts and the revert cascade.
+**Dependents still visible at a commit**: what goes stale if a value changes. This powers dependency conflicts and the revert cascade.
```cypher
MATCH (d:Fact)-[:DERIVED_FROM*1..6]->(:Fact {id: $fid})
MATCH (h:Commit {id: $head})
@@ -148,10 +210,18 @@ Also: [`why_path`](cypher/why_path.cypher), [`merge_commit`](cypher/merge_commit
These are measured in this repo. We don't publish results we don't have.
- **20 concurrent writers on one branch: 20 commits land, linear history, 0 lost** ([`test_concurrent_writers_lose_nothing`](tests/core/test_repo.py), runs in CI against a real FalkorDB).
- **Checkout at 250 / 500 / 1000 linear commits: 17 / 40 / 103 ms. Merge base: 2 / 3 / 6 ms** (FalkorDB v4.22.1, local; [ARCHITECTURE §3](docs/ARCHITECTURE.md#3-verified-falkordb-behaviour-tested-2026-10-16-on-falkordbfalkordblatest)).
-- The benchmark harness (Git0 vs last-write-wins vs text-git) is scaffolded in [`bench/`](bench/), but **there are no results yet**, so we report none.
+- **Without FalkorDB, every API route returns 500** (tested as described [above](#what-happens-without-falkordb)).
+- The benchmark (Git0 vs last-write-wins vs text-git) is only a skeleton in [`bench/`](bench/), and there are **no results yet**, so we report none.
## Tech stack
-FalkorDB v4.22.1 (one graph per room) · Python 3.12, FastAPI, `falkordb` async client · Groq `openai/gpt-oss-20b` (strict JSON schema) with Gemini fallback for agents and Arbiter · pydantic-ai + Gemini for the IDE agents · MCP server (streamable HTTP) · React + Vite + Tailwind, `@falkordb/canvas` memory graph, xyflow commit DAG · Docker on AWS EC2 behind Caddy, auto-deployed from `main` after CI.
+| Layer | What |
+|-|-|
+| Graph | FalkorDB v4.22.1, one graph per team room / IDE session |
+| Backend | Python 3.12, FastAPI, `falkordb` async client, Pydantic v2 |
+| LLM | Groq `openai/gpt-oss-20b` (strict JSON schema) → Gemini fallback (memory agents + Arbiter); **Pydantic AI** + Gemini (IDE agents) |
+| Agent tooling | MCP server (streamable HTTP at `/mcp/`), Pre/PostToolUse hooks, `ast`-based Python parser |
+| Frontend | React 19, Vite, Tailwind v4, `@falkordb/canvas` memory graph, xyflow + dagre commit DAG, Monaco (IDE) |
+| Infra | Docker on AWS EC2 (ap-south-1) behind Caddy; GitHub Actions → ECR → SSM deploy after green CI |
## Quickstart (3 commands)
Needs `uv`, `pnpm`, and Docker or Podman.
@@ -164,7 +234,9 @@ make db-up
```bash
make test
```
-`make setup` installs Python and web deps, `make db-up` starts FalkorDB on `:6379` (browser UI on `:3000`), and `make test` runs the test suite against the real graph. To run the app: `cp .env.example .env`, add a `GROQ_API_KEY` and/or `GEMINI_API_KEY`, then `make api` (http://localhost:8000/docs) and `make web` (http://localhost:5173, the IDE demo at http://localhost:5173/ide/).
+`make setup` installs the Python and web deps. `make db-up` starts FalkorDB on `:6379` (browser UI on `:3000`). `make test` runs the test suite against the real graph.
+
+To run the app: `cp .env.example .env`, add a `GROQ_API_KEY` and/or `GEMINI_API_KEY`, then `make api` (http://localhost:8000/docs) and `make web` (http://localhost:5173, IDE demo at http://localhost:5173/ide/).
## Repo map
| Path | What |
@@ -172,12 +244,13 @@ make test
| [`cypher/`](cypher/) | every query, one file each (single source of truth) |
| [`src/git0/core/`](src/git0/core/) | `MemoryRepo` (commit, checkout, log, merge base, why), 3-way merge, revert cascade, models |
| [`src/git0/agents/`](src/git0/agents/), [`llm/`](src/git0/llm/) | Planner / Scheduler / Notes / Arbiter, handoff, LLM client (fails loudly, no fallback text) |
-| [`src/git0/code/`](src/git0/code/), [`ide/`](src/git0/ide/) | code parser + relay graph, IDE sessions, hooks, coding agents, merge check |
+| [`src/git0/code/`](src/git0/code/), [`ide/`](src/git0/ide/) | code parser + relay graph, IDE sessions, hooks, Pydantic AI coding agents, merge check |
| [`src/git0/mcp/`](src/git0/mcp/) | MCP server (memory tools + `code_*` relay tools) |
| [`src/git0/api/`](src/git0/api/) | FastAPI app, tenant rooms and TTL sweep |
| [`web/`](web/) | React app (`/`) and IDE demo (`/ide/`) |
+| [`demo_project/`](demo_project/) | the small Python shop every IDE visitor gets a fresh copy of |
| [`tests/`](tests/) | pytest against a real FalkorDB (throwaway graph per test) |
-| [`docs/`](docs/) | [architecture](docs/ARCHITECTURE.md), [all Cypher](docs/CYPHER.md), [ADRs](docs/adr/), [team split](docs/team/README.md) |
+| [`docs/`](docs/) | [architecture](docs/ARCHITECTURE.md), [all Cypher](docs/CYPHER.md), [stack](docs/STACK.md), [ADRs](docs/adr/), [team split](docs/team/README.md) |
## Team
| Name | Role |
diff --git a/bench/README.md b/bench/README.md
index 98295d1..c6284bc 100644
--- a/bench/README.md
+++ b/bench/README.md
@@ -3,6 +3,8 @@
Git0 vs last-write-wins vs text-git across scripted multi-agent scenarios.
Plan, scenario format and metrics: [docs/team/person-c-bench-concurrency.md](../docs/team/person-c-bench-concurrency.md).
+**Status (2026-10-18): skeleton only.** There is no runner (`bench/run.py`) and no scenarios or results yet, so `make bench` fails. The concurrency proof that does exist is `tests/core/test_repo.py::test_concurrent_writers_lose_nothing` (20 writers, 0 lost), which runs in CI.
+
```bash
-make bench # -> bench/results//.json
+make bench # planned: -> bench/results//.json
```
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 1b4cbbe..990b255 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -97,6 +97,26 @@ Invariants (tests enforce these; do not break them):
Checkout, commit (CAS), log, merge-base, conflict detection, dependents/revert cascade, why-path, "not in memory" proofs, tenant isolation and the scorecard all run as Cypher. Agents hold no state between turns. Stop the container and agents know nothing. Demo this.
+## 5b. Git0 Relay: code-context graph (IDE demo, `/ide/`)
+
+Same rules (one query per write, Cypher in `cypher/code_*.cypher`), different graph: one per IDE session, `ide_`.
+
+```
+(:File {path})-[:DEFINES]->(:Symbol {id: "::", signature, body_hash, line, end_line})
+(:Symbol)-[:CALLS]->(:Symbol) // rebuilt for a file on every recorded write
+(:Agent {id: 'A'|'B'})-[:MADE]->(:Change {kind, old_signature, new_signature})-[:TOUCHED]->(:Symbol)
+(:Agent)-[:INTENDS]->(:Intent {task, active})-[:TARGETS]->(:Symbol)
+(:Agent)-[:ACKED]->(:Change) // seen/absorbed: pulled, or the human said override
+```
+
+Flow (`src/git0/ide/`): two Pydantic AI agents on Gemini (`harness.py`), each in its own copy of `demo_project/`. Every tool call passes `RelayHooks` (`hooks.py`), which call the MCP server mounted at `/mcp/` in the same FastAPI process:
+- **PostToolUse** (after a write): `code_record_edit` parses the file (`code/parse.py`, stdlib `ast`) and records changed symbols and signature changes.
+- **PreToolUse** (before a write): `code_check_edit` runs `code_conflicts_same_symbol`, `code_conflicts_dependency` (calls a function whose signature the peer changed), `code_conflicts_reverse` (the peer's new code reaches the target through `CALLS*1..3`) and `code_conflicts_intent`. A blocking hit denies the write and asks the human: pull the peer's change, keep mine, or pause.
+- **PreToolUse** (before a read): `code_peer_activity` adds heads-ups about teammate changes to the agent's context.
+- **Merge check** (`mergecheck.py`): `git merge-file` (line-based) vs the symbol/call analysis, so the UI shows git calling a broken merge clean.
+
+Sessions (`session.py`): at most `IDE_MAX_SESSIONS` (8); graph and workspaces are deleted on End session, on tab close (sendBeacon), after 15 min idle, and orphans on process start. The room sweeper only touches `team_*`.
+
## 6. Integration contracts (who depends on whom)
| Contract | Owner | Consumers | File |
@@ -119,7 +139,7 @@ Checkout, commit (CAS), log, merge-base, conflict detection, dependents/revert c
| `POST /api/{t}/commits` | `CommitRequest` → `{commit, retries}` | A | done |
| `GET /api/{t}/facts/{id}/why` | → why-path rows | A | done |
| `GET /api/{t}/branches/{name}/procedures` | → `Procedure[]` | A | done |
-| `POST /api/{t}/agents/{agent}/messages` | `{message, session_id}` → `AgentReply` (plain JSON; unknown agent 404). SSE streaming (`token`, `commit`, `error`, `: ping` every 15 s) is issue #10 | B `agents.step` | done (JSON) |
+| `POST /api/{t}/agents/{agent}/messages` | `{text, session_id?}` → SSE stream: `token` (reply text), `commit` (`commit_id`, `cited_fact_ids`, `branch`, `usage`), `error` (LLM failure). Unknown agent 404 | B `agents.step` | done (SSE) |
| `POST /api/{t}/merge/preview` | `{source, target}` → `MergeResult` | A `plan_merge` | done |
| `POST /api/{t}/merge/resolve` | `{source, target, choices, agent_id?, target_head?, source_head?}` → `MergeApplied` (`invalidated` = facts for the Arbiter to re-derive). Send the previewed heads back: if either branch moved since, 409 "preview again" | A `apply_merge` | done |
| `POST /api/{t}/revert` | `{branch, commit_id, agent_id?}` → `RevertResult` | A `revert` | done |
@@ -127,9 +147,9 @@ Checkout, commit (CAS), log, merge-base, conflict detection, dependents/revert c
| `POST /api/{t}/merge/explain` | `{source, target}` → `ConflictExplanation[]` (`{key, text}`, one per conflict; one LLM call, cached) | B `arbiter.explain` | done |
| `POST /api/{t}/arbiter/rederive` | `{target, fact_ids, session_id?}` → `RederiveResult` (`replies`, `tokens` spent, `owners`, `skipped`). Send `MergeApplied.invalidated[].id` as `fact_ids` | B `arbiter.rederive` | done |
| `POST /api/{t}/agents/{agent}/kill` | → `HandoffResult` (`successor`, `branch`, `inherited: Fact[]`, `commits`, `commit_id`, `summary`). Unknown agent or branch is 404 | B `handoff` | done |
-| `POST /api/{t}/load-test` | `{writers}` → `{commits, lost, retries, p50_ms, p95_ms}` | C `run_load` | P2 |
+| `POST /api/{t}/load-test` | `{writers}` → `{commits, lost, retries, p50_ms, p95_ms}` | C `run_load` | not built (the 20-writer proof is `test_concurrent_writers_lose_nothing`) |
| `GET /api/{t}/scorecard` | → live Track 02 counts | A `scorecard.cypher` | done |
-| `POST /api/{t}/fork` | → `{graph, ms}` (GRAPH.COPY) | A | P3 |
+| `POST /api/{t}/fork` | → `{graph, ms}` (GRAPH.COPY) | A | not built |
Any `LLMError` (provider failure, offline cache miss, tenant rate limit) comes back as **502 `{detail}`**, never 429 and never fabricated output (M12); the UI shows `detail` in a red banner. An SSE stream that has already started cannot use the 502: it sends an `error` event instead.
diff --git a/docs/STACK.md b/docs/STACK.md
index 8e14a19..a63be30 100644
--- a/docs/STACK.md
+++ b/docs/STACK.md
@@ -7,13 +7,14 @@ Versions are what `uv sync` / `pnpm install` resolved today. Full research with
|-|-|-|-|
| Language | Python | 3.12 (`.python-version`) | Every FalkorDB/LLM SDK is first-class. Matches the Docker image |
| Package mgr | uv | 0.12+ | Lockfile, fast CI, `uv sync --frozen` in Docker |
-| Graph DB | FalkorDB | `falkordb/falkordb:latest` | Track sponsor. Multigraph per tenant, Cypher, algorithms, GRAPH.COPY |
+| Graph DB | FalkorDB | `falkordb/falkordb:v4.22.1` (pinned in compose, CI and the AWS host) | Track sponsor. Multigraph per tenant, Cypher, algorithms, GRAPH.COPY |
| DB client | `falkordb` (asyncio) | 1.8.0 | `FalkorDB.from_url`, `select_graph`, `query`/`ro_query` with params |
| API | FastAPI + uvicorn | 0.143 | Native SSE (`fastapi.sse`, ≥0.135), OpenAPI → typed TS client |
| Models | Pydantic v2 + pydantic-settings | 2.14 | Shared contracts. LLM output validation |
| LLM primary | `groq` SDK, `openai/gpt-oss-20b` | 1.7 | Strict `json_schema` structured outputs (gpt-oss only). Fast |
-| LLM fallback | `google-genai`, Gemini Flash | 2.31 | Free tier, response schema. Check the model name in AI Studio |
-| MCP | `mcp` SDK | 2.3 | Should-have: Git0 as memory for Claude Code/Cursor |
+| LLM fallback | `google-genai`, Gemini (`gemini-3.1-flash-lite`, then the `GEMINI_FALLBACK_MODELS` chain) | 2.31 | Free tier, response schema |
+| MCP | `mcp` SDK | 2.3 | Streamable HTTP, mounted at `/mcp/` in the API: memory tools + `code_*` relay tools for Claude Code, Cursor, Gemini CLI |
+| IDE agents | `pydantic-ai-slim[google,mcp]` + Gemini | 2.x | The two coding agents in `/ide/`; hooks call the MCP server |
| Tests | pytest + pytest-asyncio | 9.1 / 1.4 | Run against a **real** FalkorDB, never mocks |
| Lint | ruff | 0.17 | Lint + format in CI |
@@ -25,7 +26,8 @@ Versions are what `uv sync` / `pnpm install` resolved today. Full research with
| Commit DAG | `@xyflow/react` + `@dagrejs/dagre` | Clickable nodes, path highlight. gitgraph.js is unmaintained |
| Memory graph | `@falkordb/canvas` (web component, v0.3.x) | Same renderer as the FalkorDB Browser. Fallback: `force-graph` |
| Data | TanStack Query + `openapi-fetch` (types from `/openapi.json`) | One source of truth for the API shape |
-| Realtime | SSE (`EventSource`) | One-way stream of agent replies + scorecard. Simpler than WS |
+| Realtime | SSE over `fetch` + `ReadableStream` (agent replies are a POST, which `EventSource` can't send); the scorecard and logs poll | Simpler than WS |
+| IDE editor | `@monaco-editor/react` | VS Code-like view of both clones in `/ide/` |
| Tests | Vitest + Testing Library | |
## Infra
diff --git a/docs/context.md b/docs/context.md
index 79b6239..2ffd80e 100644
--- a/docs/context.md
+++ b/docs/context.md
@@ -1,5 +1,7 @@
# Person D — Implementation Context & Demo Guide
+> Updated 2026-10-18 to match the code. The judge flow and the IDE demo are summarised in the [README](../README.md#try-it-in-60-seconds).
+
**Issues:** #10 (SSE route + 3-column shell + CommitDag) · #15 (ChatPanel, ConflictCard, WhyPath, Scorecard)
---
@@ -18,14 +20,8 @@ Streams agent replies as Server-Sent Events:
Uses `StreamingResponse(media_type="text/event-stream")` with `X-Accel-Buffering: no` to prevent Caddy buffering.
-#### Gemini Fallback Chain (`src/git0/config.py`, `src/git0/llm/client.py`)
-Primary model: `gemini-3.6-flash`. On 503/overload, retries in order:
-1. `gemini-3.8-flash`
-2. `gemini-3.5-flash-lite`
-3. `gemini-3.1-flash-lite`
-4. `gemini-2.5-flash-lite`
-
-First success wins. Only raises `LLMError` if all five fail simultaneously.
+#### LLM provider chain (`src/git0/config.py`, `src/git0/llm/client.py`)
+Providers are tried in order; the first valid answer wins: **Groq** `openai/gpt-oss-20b` (strict JSON schema, when `GROQ_API_KEY` is set), then **Gemini** `GEMINI_MODEL` (default `gemini-3.1-flash-lite`) and each model in `GEMINI_FALLBACK_MODELS` (default `gemini-3.5-flash-lite`, `gemini-3.5-flash`). Every output is validated with Pydantic. Only when all providers fail does it raise `LLMError` (API: 502, UI: red banner).
#### Agent Update Rule (`src/git0/agents/specs.py`)
Added to `_RULES` shared across all agents: when asked to UPDATE or CHANGE an existing fact, the agent must add the new value to `facts` AND put the old key in `removed_keys` so the old value is retracted. Without this, agents answered update requests conversationally without writing to the graph.
@@ -47,7 +43,7 @@ SSE via `fetch` + `ReadableStream` (not `EventSource` — that's GET-only):
`onAgentChange(agentId)` tells App which branch is active (drives ConflictCard source).
#### CommitDag (`web/src/components/CommitDag.tsx`)
-Fetches `/branches/{name}/log` for planner / scheduler / notes / main every 4s. Infers parent edges from `seq` ordering within each branch (the API `Commit` schema has no explicit `parents` field). Uses `@dagrejs/dagre` with `rankdir: TB` for layout. Branch color coding: planner=purple, scheduler=blue, notes=green, main=pink.
+Fetches `/branches/{name}/log` for planner / scheduler / notes / main every 4s and draws edges from each commit's `parents` (exposed in PR #33, so merge commits show both parents). Uses `@dagrejs/dagre` with `rankdir: LR` (left to right) for layout. Branch color coding: planner=purple, scheduler=blue, notes=green, main=pink.
#### ConflictCard (`web/src/components/ConflictCard.tsx`)
"Merge `{branch}` → main" button at the bottom of the left column. Flow:
@@ -63,7 +59,7 @@ Branch label updates when user switches agent tabs.
On "why?" click: calls `GET /api/{tenant}/facts/{fact_id}/why`. The route returns provenance rows with `fact_id`, `commit_id`, `agent_id`, `episode_id`. All four are graph node IDs — WhyPath collects them all and passes to App's `highlight` state. MemoryCanvas dims everything not in the set.
#### Scorecard (`web/src/components/Scorecard.tsx`)
-Polls `GET /api/{tenant}/scorecard` every 3s. Maps 7 Track 02 counters: facts on main, episodes, procedures, sessions resumed, handoffs, total commits, tenants live.
+Polls `GET /api/{tenant}/scorecard` every 3s. Shows 12 live counters (facts, chat turns, procedures, sessions, agents, memory updates, merges, disagreements settled, past decisions reused, undos, handoffs, live team rooms), all from one Cypher query.
---
@@ -71,15 +67,9 @@ Polls `GET /api/{tenant}/scorecard` every 3s. Maps 7 Track 02 counters: facts on
### Setup
```bash
-# Terminal 1 — FalkorDB
-docker run -p 6380:6379 falkordb/falkordb
-
-# Terminal 2 — API (from git0/)
-set -a && source .env && set +a
-uv run uvicorn git0.api.app:app --reload --port 8000
-
-# Terminal 3 — Frontend (from git0/web/)
-pnpm run dev
+make db-up # FalkorDB v4.22.1 on :6379 (browser UI on :3000)
+make api # FastAPI on :8000 (reads .env)
+make web # Vite on :5173, proxies /api and /mcp to :8000
```
Open `http://localhost:5173`. The seed endpoint runs automatically on first room visit.
diff --git a/docs/img/pipeline.png b/docs/img/pipeline.png
new file mode 100644
index 0000000..698ab3c
Binary files /dev/null and b/docs/img/pipeline.png differ
diff --git a/docs/team/README.md b/docs/team/README.md
index 6d72e3e..d9061f6 100644
--- a/docs/team/README.md
+++ b/docs/team/README.md
@@ -32,25 +32,25 @@ D.deploy (P0) ────────────────────► ev
```
Nobody waits: code against the contract (`core/models.py` + stub signatures). The stub raises `NotImplementedError`, so use a local fake in your tests until the real one merges.
-## Must-have tracker (tick at each gate, on `main` + deployed)
+## Must-have tracker (status checked against the code on 2026-10-18)
| # | Must-have | Owner | P | Status |
|-|-|-|-|-|
-| M1 | Semantic 3-way merge with dependents + Arbiter | A (+B) | 2 | ☐ |
-| M2 | Graph is the only channel between agents | B | 1 | ☐ |
-| M3 | All Track 02 focus items live on the scorecard | D (+A counts) | 2-3 | ☐ |
-| M4 | Deterministic merge authority (Cypher rules, LLM explains only) | A | 2 | ☐ |
-| M5 | Why-path on every answer | A + D | 2 | ☐ |
-| M6 | Concurrency proof (20 writers, 0 lost, p95) | C (+A) | 2-3 | ☐ baseline test exists |
-| M7 | Tenant isolation by graph | D (+A) | 3 | ☐ |
-| M8 | Benchmark vs 2 baselines, JSON in repo | C | 2-3 | ☐ |
-| M9 | Precedent reuse | A | 2-3 | ☐ |
-| M10 | "Not in memory" no-path proof | A + B | 2 | ☐ query exists |
-| M11 | Live 60 s judge flow | D | 2 | ☐ |
-| M12 | Fail loudly (no canned output) | B + D | 3 | ☐ |
-| M13 | Submission basics (repo, README, Cypher list, video, URL, disclosure) | C + D | 4 | ☐ |
-| M14 | Everyone explains model + queries | All | 4 | ☐ |
+| M1 | Semantic 3-way merge with dependents + Arbiter | A (+B) | 2 | ☑ `core/merge.py` + `agents/arbiter.py` |
+| M2 | Graph is the only channel between agents | B | 1 | ☑ agents read only `checkout` |
+| M3 | All Track 02 focus items live on the scorecard | D (+A counts) | 2-3 | ☑ `scorecard.cypher` + `Scorecard.tsx` |
+| M4 | Deterministic merge authority (Cypher rules, LLM explains only) | A | 2 | ☑ `(:Rule)` + human; LLM explains |
+| M5 | Why-path on every answer | A + D | 2 | ☑ `why_path.cypher` + `WhyPath.tsx` |
+| M6 | Concurrency proof (20 writers, 0 lost, p95) | C (+A) | 2-3 | ◐ 20-writer CAS test in CI; no load button or p95 |
+| M7 | Tenant isolation by graph | D (+A) | 3 | ☑ graph per room + TTL sweep |
+| M8 | Benchmark vs 2 baselines, JSON in repo | C | 2-3 | ☐ `bench/` skeleton only, no results |
+| M9 | Precedent reuse | A | 2-3 | ☑ `(:Precedent)` on the conflict card |
+| M10 | "Not in memory" no-path proof | A + B | 2 | ☑ "Not in team memory (no path)" |
+| M11 | Live 60 s judge flow | D | 2 | ☑ live, "Try the demo" bar |
+| M12 | Fail loudly (no canned output) | B + D | 3 | ☑ `LLMError` → 502 / red banner |
+| M13 | Submission basics (repo, README, Cypher list, video, URL, disclosure) | C + D | 4 | ◐ repo, README, Cypher list, URL, disclosure done; video pending |
+| M14 | Everyone explains model + queries | All | 4 | ☐ team walkthrough |
| M15 | Every commit is one atomic Cypher query | A | 0 | ☑ `commit_cas.cypher` |
-| M16 | Entity reuse + strict JSON extraction | B | 1 | ☐ |
+| M16 | Entity reuse + strict JSON extraction | B | 1 | ☑ entity list in prompt + strict schema |
## Rituals (short, fixed)
- **Stand-ups (10 min):** 09:00, 14:00, 21:00 IST. Each person answers: done since last, next, blocked on whom.
diff --git a/web/README.md b/web/README.md
index 4ba646d..910e19b 100644
--- a/web/README.md
+++ b/web/README.md
@@ -16,25 +16,25 @@ React + TypeScript + Vite frontend for the Git0 hackathon app.
## Folder map
+Two pages from one build (`vite.config.ts` has two Rollup inputs): the team room at `/` and the relay IDE at `/ide/`.
+
```
-src/
- main.tsx entry: StrictMode + TanStack QueryClientProvider
- App.tsx 3-column shell: ChatPanel | CommitDag/MemoryCanvas tabs | Scorecard
- index.css Tailwind v4 (`@import "tailwindcss"`)
- api/
- client.ts openapi-fetch client typed by schema.d.ts (baseUrl "")
- schema.d.ts generated by `pnpm gen:api`; placeholder `paths {}` until then
- sse.ts subscribe(url, onEvent) wrapper around EventSource
- components/ placeholders owned by Person D (see docs/team/person-d-ui.md)
- ChatPanel.tsx, CommitDag.tsx (React Flow + dagre demo), MemoryCanvas.tsx (),
- ConflictCard.tsx, Scorecard.tsx, WhyPath.tsx
+index.html, src/main.tsx team room entry
+src/App.tsx shell: chat + merge bar | commit DAG / memory graph tabs | scorecard
+src/components/ ChatPanel (SSE over fetch), MergeBar + ConflictCard (preview -> explain -> resolve -> rederive),
+ CommitDag (xyflow + dagre), MemoryCanvas (@falkordb/canvas), WhyPath, Scorecard,
+ DemoGuide ("Try the demo" bar), BranchPicker, TenantGate (per-visitor room), ErrorBanner
+src/api/ openapi-fetch client + generated schema.d.ts
+src/lib/ shared hooks (branch logs, tenant)
+ide/index.html, src/ide/ relay IDE: App, useIdeSession (SSE events), tour + coach marks,
+ components/ (AgentPanel, Workspace (Monaco), GraphCanvas/GraphOverlay, BottomPanel)
```
`@/` is an alias for `src/` (Vite and tsconfig).
## How the API proxy works
-In dev, `vite.config.ts` forwards any request whose path starts with `/api` to
+In dev, `vite.config.ts` forwards any request whose path starts with `/api` or `/mcp` to
`http://localhost:8000`. The browser only talks to the Vite origin, so there is no CORS
setup and `EventSource` streams (SSE) pass straight through.