# SARA: agentic software factory

Jun 2026 – present · Staff · Not shipped · live demo

SARA is my own initiative, self-funded so far: a software factory that makes software-development work agentic and automated. It turns a plain-English feature request or bug report into a reviewed, tested pull request. I have presented it to the CEO, the CTO and team leads, and other teams asked to use it. It is not shipped; a live demo is available.

**Scale:** 121 API routes · 44 migrations · 638 test files · 12 model-provider adapters

- Request to pull request: agents run a gated pipeline (investigate, requirements, design, code, review, test); a stage passes only when its typed output meets its requirements, and failures send work back.
- Grounded in the code: it builds a product-feature catalog and a code graph from a company’s repositories, so agents work from what the code actually does.
- Model routing: each stage runs on a model tier (bulk, balanced, quality) across several providers, including local and open-weight models, with usage metering and spend caps.
- One hard problem: open-weight models stopped after a single tool call, so I rebuilt their execution loop.
- Built for many companies: workspace data is isolated across Postgres row-level security, the graph database and file storage, with role-based access and a human-approved learning library.

**Stack:** Next.js, TypeScript, Python, Postgres RLS, pgvector, Memgraph

**My role:** My own initiative: creator, lead and sole owner, built with AI coding agents under my design and review.

## Context

Coding agents are fast, but left alone they skip steps. SARA runs them through a disciplined development process and enforces it in code: a stage passes only when its typed result meets its requirements.

It is aimed at two uses: the company’s own engineering, and a paid product for customers.

## Timeline

- **Jun 2026:** Started: dev pipelines, code graph, workspaces and roles.
- **Jul 2026:** Isolation across stores, four-tier memory, the Bedrock lane.
- **Aug 2026:** The open-model tool loop, Fireworks, the local Gemma interaction lane, tier-first model routing.
- **Sep 2026:** Human steering, the run-state layer, spend tracking.
- **Oct 2026:** SARA as an MCP server: export and import of tasks.

## Architecture

The pipeline executor is the hub. Every stage reads the code graph, runs on its model tier, and writes runs and usage per workspace.

- **Ask and answer:** Request (A feature request or bug report, in plain English or from a ticket); A person (Pauses, steers, approves learnings); Pull request (Reviewed and tested)
- **Pipeline · Next.js server:** Pipeline executor (Stage loop, typed gates, send-back); Run workspace (Cloned repositories, per-repo setup)
- **Grounding, models and data:** Code graph and catalog (Memgraph; features built from the code); Model router (Bulk, balanced and quality tiers); Memory (Recall pointers, pgvector, learning library); Postgres (Row-level security per workspace)

Flows:

1. Request → Pipeline executor: Starts a feature or bug run
2. Pipeline executor → Run workspace: Clones the repositories and runs the code
3. Pipeline executor → Code graph and catalog: Investigate against what the code actually does
4. Pipeline executor → Model router: Each stage runs on its tier, across providers
5. Pipeline executor → Memory: Repeated tool output becomes recall pointers; approved learnings come back
6. Pipeline executor → Postgres: Runs, usage and spend, scoped to the workspace
7. A person → Pipeline executor: Pause and steer a run
8. Pipeline executor → Pull request: Only a passing, typed result moves on; review failures send work back

## Inside the system

### A process agents cannot skip

- Stages from investigate, requirements and design through code, review and test, each with a typed submit schema.
- Mandatory requirements review, plan-only gating, and unfinished tasks that block progress.
- Failures send work back to an earlier stage; a person can pause and steer.

### Grounded in the code

- A polyglot code graph: Python indexers resolve syntax trees and route tables, then load the graph into Memgraph.
- A product-feature catalog built from the code by grouping and reconcile agents, anchored to the graph.

### Models across vendors

- Each stage asks for a tier (bulk, balanced, quality); the router resolves it to a provider and model.
- 12 model-provider adapters: Claude, Bedrock, Fireworks, OpenAI-compatible, Codex and open models, plus a local Gemma model for always-on interaction.
- A pre-run credential gate, a guard that fails loudly on mismatched vendors, and a usage ledger with prices and spend caps.

### Memory a person curates

- Four tiers: a context sweeper that replaces repeated tool output with recall pointers, semantic recall on pgvector, knowledge shared within a run, and a learning library.
- A topic two or more stages agree on becomes a provisional learning; a person approves it before later runs see it.

### Many workspaces, shared stores

- Postgres row-level security through a transaction-local workspace setting.
- Composite (id, workspace) keys in the graph and a query guard that fails closed.
- Personal and organization workspaces with role-based access, and a leak-gate test that tries cross-workspace reads.

## Hard problems

### Open-weight models that stopped after one tool call

**Problem.** Open-weight models served over an Anthropic-style messages transport narrated a plan, made one tool call and stopped. That made them useless as coding agents.

**What I did.**

- Tested the first hypothesis, prompt caching; disabling it alone did not fix the stall, so I rejected it.
- Rebuilt the lane as a Vercel AI SDK loop over an OpenAI-compatible endpoint through a self-hosted LiteLLM proxy, with explicit stop conditions.
- A bridge from the coding tools to AI SDK tools, with reply caps, abort propagation and a git-gated submit.

**Result.** Open models run full tool loops, two earlier drivers were retired, and the Claude lane is unchanged. Tool-call success rates were not benchmarked.

### Isolation that fails closed

**Problem.** Every workspace shares the same Postgres and Memgraph instances. One missing filter would leak one organization’s code graph or runs to another.

**What I did.**

- Postgres: a transaction-local workspace setting and forced row-level security policies.
- Memgraph: composite keys on every merge, traversal scoped by edge, and a guard that rejects queries without a workspace.
- A leak-gate regression test that tries cross-workspace reads.

**Result.** Isolation is enforced by both stores and by a query seam, not by each caller remembering a filter.

### Knowing a run is alive

**Problem.** Run state lived in one process. On a shared pool of dev instances, that is not enough to know whether another instance’s run is still alive.

**What I did.**

- A lease with a heartbeat on each run record in Postgres.
- One set of run statuses, and a reconcile step at boot.
- A run-driver seam, so the same runs can move to a workflow service later.

**Result.** One instance cannot declare another’s live run dead, or start a second executor for it.

## Decisions

- **Process:** chose typed stage results, checked by gates, over instructions in the prompt alone. An agent can skip a step it was asked to take; it cannot pass a gate whose schema it has not filled.
- **Model choice:** chose tiers per stage, resolved by a router, over a model hardcoded per stage. Providers and models change. A stage asks for a tier, and guards fail loudly on a mismatch.
- **Open models:** chose a new tool loop over an OpenAI-compatible endpoint, over tuning the existing transport. Disabling prompt caching was tested and did not fix the stall; a loop with explicit stop conditions did.

## Outcomes

- Presented to the CEO, the CTO, team leads and my own team; other teams asked to use it.
- 121 API routes, 27 pages and 44 database migrations.
- 638 test files.
- 12 model-provider adapters.
- 3,849 commits since Jun 2026, as the sole committer.

## Limits

- Not shipped and not in production; a live demo is available.
- No token, cost or latency figures are quoted, and tool-call success rates were not benchmarked.
