groundwork

rouafi/groundwork Checked 10 hours ago

Grounded AI on top of any SaaS, client after client.

Grounded AI on top of any SaaS, client after client. A deployment kit: one reusable core, a pack per client, a 5-day playbook to fill it. Companies want AI on top of the tools they already use (a CRM such as HubSpot, a billing tool, a help desk), but every project starts from zero: the facts are in the software, the know-how is in people's heads, and nobody checks what the AI says before it reaches a customer.

Summary extracted from the README.

In 30 seconds

Companies want AI on top of the tools they already use (a CRM such as HubSpot, a billing tool, a help desk), but every project starts from zero: the facts are in the software, the know-how is in people's heads, and nobody checks what the AI says before it reaches a customer.

This kit lets a team reuse most of the work from one client to the next and customize only the last part, through a 5-day playbook. The demo rewrites sales emails on top of HubSpot-shaped data for two fictional clients, and checks every email against the client's own facts and rules before anything is sent: a wrong price is blocked, an email to a customer waits for a person to approve it.

All data in this repository is synthetic.


See it run

make demo   # replays recorded runs: no API key, no network

It shows, for each client, an email that waits for a person, one that is sent automatically (internal only), and one that is blocked (by a stand-in agent that lets a bad draft through, to show the checks hold when the model fails), each with the reason. The 3-minute walkthrough script is in docs/demo.md.


Results: two levels of checks before anything reaches a customer

Level What When
1. Automated Facts vs CRM, rule violations, tone (LLM judge) on a golden set per client, replayed offline Every commit (CI checks the report; thresholds are not enforced yet)
2. Human External emails go through an approval queue; every approval is recorded, and every rejection needs a reason In production

Results of the evals on each client's golden set, from recorded runs replayed offline (synthetic data). Generated from evals/report.md; never typed.

Pack Cases Result
acme 20 FAIL (rule_violations, tone_mean)
beta 20 FAIL (fact_false_claims, rule_violations, tone_mean, routing_accuracy)

acme, before and after the agent:

Raw draft Harmonized
False claims 8 0
Forbidden-pattern hits 5 0
Tone, mean from 1 to 5 2.35 3.75

beta, before and after the agent:

Raw draft Harmonized
False claims 4 2
Forbidden-pattern hits 5 1
Tone, mean from 1 to 5 2.00 3.10

A pack ships only when every threshold passes. Packs marked FAIL are below at least one of theirs, and the report says which.

How the judge is calibrated, why a pack can miss its thresholds, and what the numbers do not prove: docs/evals.md and ADR 0010.


Playbook: a new client in 5 days

Every step produces a validated artifact in client_packs/<client>/. The playbook is not a document next to the code: it is how the code gets its inputs.

Day Step Artifact Exit criteria
1 Needs collection: use case, users, internal vs external, systems, success metric, risks discovery.yaml Sponsor signs off the use case and the metric
2 Facts: connect the CRM, load its export config.yaml, fixtures/ Fixtures load and agree with the domain schema
3 Know-how capture: 3 to 5 expert interviews, extraction, human review interviews/, rules.yaml Every rule has provenance and scope
4 Golden set: 20 cases built with the experts, thresholds agreed golden.jsonl, thresholds.yaml, rubric.md, judge_calibration.jsonl At least 20 cases, thresholds and calibration present
5 Go-live: policies, rollout plan, monitoring policies.yaml, go_live.md Checklist ticked, level-1 evals pass the thresholds

uv run groundwork new-pack <client> builds the skeleton from playbook/ (discovery canvas, interview script, go-live checklist); uv run groundwork validate-packs --pack <client> --stage dayN says whether day N is done. The sign-off, rule approvals and go-live ticks stay with people. In Claude Code, the client-onboarding skill walks the days. Details: docs/playbook.md.


The layers

Layer Contains Changes Owned by Code allowed
Core Ontology engine, MCP context server, agent harness, eval runner, tracing Rarely Platform team Yes
Domain pack Domain ontology schema (facts + know-how concepts), skills and prompts, policy templates, eval scorers Per new domain FDE lead Minimal
Client pack Ontology instances, interviews, extracted rules, connector config, thresholds, golden set Per client FDE on the engagement No: data and config only

Precedence: client > domain > core, through config only. Every client pack is schema-validated in CI: if it does not validate, it does not ship.


For engineers

Two ontologies that talk

graph LR
  subgraph Facts["Facts (structured, from CRM)"]
    Company --> Contact
    Contact --> Deal
    Deal --> Product
  end
  subgraph KnowHow["Know-how (unstructured, from interviews)"]
    Rule --> Tone
    Rule --> Claim
    Rule -->|provenance| Interview
  end
  Product <-->|bridge| Claim
  Contact -->|segment, persona| Rule
  • Facts come from the client's systems (a CRM such as HubSpot or Salesforce, an ERP, a billing tool...). They are the source of truth for names, prices, deal stages.
  • Know-how is extracted from expert interviews by Claude, reviewed by a human, and stored with its provenance (interview, quote) and scope (internal/external, segment, persona).
  • The bridge (Product, Segment, Persona) lets the agent ask: "what can I say to this contact, and how?"

How it runs

graph LR
  Draft[Draft + contact id] --> Harness
  Harness -->|context pack| MCP[MCP context server]
  MCP --> Facts & KnowHow
  Harness --> Check{check_claims}
  Check -->|internal, valid| Send[Auto-send]
  Check -->|external| Queue[Human approval]
  Check -->|false claim| Block[Blocked]
  • Headless: CLI, HTTP API, webhooks from the client's SaaS (e.g. a CRM event). No UI.
  • Context sharing: the same MCP server feeds the headless agent and Claude Desktop. Sales asks the ontology in Claude; the agent uses the exact same context.
  • Traceable: every output cites the ontology nodes it used.

Swap any SaaS

Every external system (CRM, email, vector store, model) sits behind a port. Each client pack picks its adapters in config:

# client_packs/acme/config.yaml
crm: fixture        # CRM-shaped fixtures; live adapters (e.g. HubSpot, Salesforce) plug in here
messaging: console
vector_store: lancedb
model: claude       # or: replay (used by make demo)
domain: comms       # domain pack under domains/

To add Salesforce: write one adapter in adapters/crm/, pass tests/contracts/, change one line of config.

Quickstart

make demo   # replays recorded runs, no API key needed
make live   # runs with ANTHROPIC_API_KEY
make evals  # runs the golden set for every client pack

Rewrite a draft for a contact, check it against the CRM, and route it (send, approval or blocked). Every run leaves a trace in traces/; external emails wait in a queue until a person approves them:

uv run groundwork harmonize --pack acme --contact acme-c-5 --channel external --draft draft.txt
uv run groundwork approvals list --pack acme
uv run groundwork approvals show <id> --pack acme      # read the email before deciding
uv run groundwork approvals approve <id> --pack acme   # records the answer and sends, once

With the default replay, only recorded cases run; GROUNDWORK_MODEL=claude (and GROUNDWORK_EMBEDDING=voyage for passages) runs live. The flow is in docs/architecture.md, the guarantees in docs/security.md.

Repo layout

src/groundwork/
  core/          domain, ports, services (harness, context, policies, evals)
  adapters/      CRM, vector store, embeddings, model, replay...
  entrypoints/   CLI, HTTP API, MCP server
domains/comms/   ontology schema, skills, eval scorers
client_packs/    acme/, beta/: config, fixtures, interviews, rules, golden set
docs/            architecture, knowledge, MCP guide, evals, security, conventions, playbook, ADRs
tests/           unit, contracts, integration

All data in this repo is synthetic.

Development

make setup then make check. To use a client's context from Claude Desktop, follow docs/mcp.md. Rules for humans and for Claude Code: CLAUDE.md and docs/conventions.md. To report a vulnerability, see SECURITY.md.

Design decisions

  • Client packs are data, not code. That is what makes the 10th client cheaper than the 1st.
  • Shared context through MCP. One source of truth for every agent and every human using Claude.
  • Evals before rollout, humans on external. Trust is earned per client, not assumed.
  • Provenance everywhere. Every rule traces back to an interview, every fact to the CRM.

Origin

This pattern comes from deploying AI for manufacturers: structured production data on one side, plant experts' tacit know-how captured through LLM-assisted interviews on the other, validated in two levels before reaching production.


License

MIT, see LICENSE.