Inspiration

Freelancers sign bad contracts because they have no memory. The unlimited-revisions clause that cost you forty unpaid hours in March is invisible in June — every negotiation restarts from zero. Meanwhile the other side negotiates with institutional memory: playbooks, precedents, a legal department that never forgets.

We asked a simple question: what if one person could have the same thing? Freelance Guardian gives a solo freelancer what the other side's lawyers have — perfect memory.

What it does

Paste a client contract. The agent:

  • recalls your standing rules and every clause pattern that has burned you before (semantic memory, vector search),
  • reopens this client's negotiation thread, so it never re-demands something you already conceded (episodic memory),
  • scores commercial risk 0–100, redlines the contract in place, and drafts a send-ready counter-offer,
  • writes the whole reasoning trail to an append-only audit log and checkpoints the workflow after every node (procedural + audit memory).

All of it lives in one CockroachDB cluster — not as a cache, but as the agent's mind. A judge can log in and SELECT the agent's memory.

How we built it

Memory model — three kinds, one cluster, via langchain-cockroachdb:

Memory Primitive Table
Semantic (what I believe) AsyncCockroachDBVectorStore guardian_memory
Episodic (what happened) CockroachDBChatMessageHistory guardian_chat_history
Procedural (where I was) AsyncCockroachDBSaver (LangGraph) checkpoints
Audit (what I decided) plain SQL, append-only agent_audit_log

CockroachDB tools used:

  1. Distributed Vector Indexing — a C-SPANN index over the embedding column, prefixed by namespace because every retrieval filters on it. Proven in the query path with EXPLAIN, not merely present.
  2. ccloud CLIscripts/cluster_info.sh uses it for cluster inventory and to hand back the connection string, so no credential is ever transcribed by hand.

Also shipped, deliberately not counted: the Managed MCP Server (.mcp.json + an audit-memory Agent Skill) as a read-only inspection surface, so any AI tool — or judge — can interrogate the agent's brain in natural language.

AWS services used:

  • AWS Lambda (ap-south-1, same region as the cluster) — every review executes here.
  • Amazon S3 — each contract is archived before analysis; the URI is stored in the audit row, so every decision points at the exact bytes it was made from.
  • Amazon CloudFront — serves the public demo.

Challenges we faced

  • An index that isn't in the EXPLAIN plan is decoration. Our first vector index sat unused: an L2 index cannot serve a cosine (<=>) query, and without namespace as a prefix column the planner fell back to a plain index. Fixing both — and proving it with EXPLAIN — taught us more than any tutorial.
  • Anonymous access to our serverless backend was blocked account-wide, so the public demo path was re-architected through CloudFront in front of the serverless API.
  • Honesty as a design constraint. The analyser is a deterministic clause engine by default — no API key, same contract, same verdict, every time — because the subject of this project is the memory, not the model. We also claim only the tools that are wired into code; the rest we document as "present, but not counted."

Accomplishments we're proud of

  • The dashboard's core insight, computed live from the audit log: a clause flagged across many clients isn't a client problem — it's a missing term in your own contract.
  • The "Memory consulted" panel: every verdict shows exactly which rules, past risks and client history were recalled.
  • The entire stack runs on free tiers: CockroachDB Basic, Lambda, S3, CloudFront.

What we learned

Agentic memory is not one thing. Semantic, episodic and procedural memory are read at different moments, written by different code, and live for different lengths of time. Collapsing them into a single vector store is what makes agents feel amnesiac despite "having RAG." And an agent whose memory is a real database is an agent you can audit — which is the difference between a demo and a system of record.

What's next

An optional LLM drafter behind the same interface (MOCK_MODE=false), hybrid full-text + vector search, row-level TTL on checkpoints, and multi-tenant namespaces so every freelancer gets an isolated mind on the same cluster.

Try it yourself

The repo ships two sample contracts: sample_data/risky_contract.md (scores 93 → reject, 11 findings) and sample_data/clean_contract.md (scores 0 → accept). Load both in the live demo — the second one proves the agent discriminates instead of rejecting everything. A guardian that can also say "yes" is a judge, not a paranoia engine.

Built With

Share this project:

Updates