Skip to content

sambhal-labs/cas

Repository files navigation

CAS — Context Alignment Score

The CAS platform ensures AI agents and developers always work from the right context.

A developer drops an updated rule into .cas/. Within seconds, every active agent has that change injected into their context. A CAS score is shown at session end.


V0 Quickstart

Prerequisites

  • Docker + Docker Compose
  • An LLM API key (OpenAI, Anthropic, or Ollama for local)

1. Clone and configure

git clone https://github.com/sambhal-labs/cas.git
cd cas
cp .env.example .env
# Edit .env — add your LLM API key
cp litellm-config.yaml.example litellm-config.yaml
# Edit litellm-config.yaml — configure your LLM provider

2. Start the stack

docker-compose up -d

Services started:

  • FalkorDB — graph memory store (localhost:6379, browser UI localhost:3000)
  • Temporal — SDLC workflow orchestration (localhost:7233)
  • Temporal UI — workflow visibility (localhost:8080)
  • LiteLLM — unified LLM proxy (localhost:4000)
  • cas-guide — MCP context injection server (localhost:8765)
  • cas-watcher — folder watcher + episode creator (internal)

3. Connect your IDE

Add cas-guide as an MCP server in Claude Code:

cp examples/mcp-config/claude-code-mcp.json ~/.claude/mcp.json

Or add to your existing MCP config:

{
  "mcpServers": {
    "cas-guide": {
      "type": "http",
      "url": "http://localhost:8765/mcp"
    }
  }
}

4. Use it

In any agent session, call cas_start_task before starting work:

cas_start_task(
  story_id="story-001",
  agent_role="developer",
  tenant_id="my-org",
  project_id="my-project"
)

The agent receives: story context, architecture constraints, active ADRs, hard/soft gates, and relevant historical episodes.

5. The aha moment

Edit .cas/gates/hard-gates.yaml — add or update a gate. Within 10 seconds, the next cas_start_task call returns the updated context.


Architecture

.cas/ policy folder
       │
       ▼ (5s poll)
cas-watcher (Temporal Activity)
       │ detect-secrets scrubbing
       ▼
Graphiti + FalkorDB (agile memory)
       │ episodes created
       ▼
Temporal signals → ProjectWorkflow → StoryWorkflows
       │
       ▼
cas-guide MCP server → agent context injection

See docs/adr/ for all architectural decisions.


CAS Score (V0)

V0 computes Context Injection Rate only: was the right context injected before the agent started the task?

Call cas_get_score(session_id=<id>) at the end of a session to see the score.

Full multi-dimensional scoring (Policy Alignment, Architectural Drift, MCP Compliance, Temporal Alignment) ships in V1. See ADR-003.


Project Structure

cas/
├── src/cas-guide/       # MCP Server — context injection (FastMCP)
├── src/cas-watcher/     # Temporal worker — folder watching + episode creation
├── docs/adr/            # Architecture Decision Records (ADR-001 to ADR-007)
├── .cas/                # Example policy folder — watched by cas-watcher
└── examples/            # BMAD project example + MCP client configs

What's NOT in V0

  • cas-guardian (gate checking MCP server) — V1
  • Pathway streaming — V1 (V0 uses Temporal polling)
  • Dashboard UI — V1
  • Multi-tenant enterprise provisioning — V1
  • Presidio PII detection — V1 (V0 uses detect-secrets)

About

CAS - Context Alignment Score for Agentic SDLC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors