Skip to main content
Glama

SCAP Coordination (scap-coordination)

Drop-in MCP server & automatic hook guardrails that catch same-signature Silent Behavioral Drift and agent sycophancy mid-flight across Python, TypeScript, JSON Schema, and Terraform.

Why this matters now: A November 2026 study by Harvard and Anthropic ("Aligning AI Teams") found that teams of AI agents act less safely than a single agent alone — even with frontier models — because each agent sticks to its own lane and assumes someone else is checking the whole system. Group chats and peer reviews didn't fix it. What worked: one shared, strict rulebook plus a dedicated, independent safety referee.

SCAP is the open-source engineering layer that enforces exactly that.

Most "multi-agent frameworks" are just parallel processing with a group chat. They work fine on separate chores, then silently break the moment two agents touch shared code: every agent's own tests pass, and the merged branch ships a broken contract or a flipped billing rule.


Why Static Locks & Type Checkers Aren't Enough (The $2.00 vs $8.00 Bug)

Suppose 3 parallel coding agents work on a billing service (pricing.py, checkout.py, invoice.py):

  • calculate_discount(price_cents: int, tier: str) -> int starts returning the discount amount (200 for a $10.00 VIP order).

  • checkout writes subtotal_cents - calculate_discount(...).

  • Mid-flight, pricing changes calculate_discount to return the final discounted price (800), keeping the exact same function name, arguments, and types (price_cents: int, tier: str) -> int.

  • Every compiler, mypy, tsc, file lock, and AST diff says 0 errors. Yet customers on a $10.00 VIP order are silently charged $2.00 instead of $8.00 (1000 - 800 = 200).

How SCAP stops it automatically:

  1. On post-edit, SCAP runs pinned behavioral probes in an isolated subprocess (auto-discovered from docstrings or auto-synthesized for pure functions with zero docstrings).

  2. It catches SILENT_BEHAVIORAL_DRIFT (200 -> 800) even though the signature never changed.

  3. It automatically blocks checkout (direct import) and invoice (transitive import) at pre-complete with the exact behavioral diff until both update cleanly.


Related MCP server: Hoplon

What SCAP Gives Your Agent Team

  • Shared Live Truth Store (SQLite WAL): Versioned contracts with atomic Compare-And-Swap (CAS) and exclusive/read resource leases — no external database needed.

  • Zero-Ceremony Multi-Language Tracking: Automatically parses Python AST, TypeScript/JS, JSON Schema, and Terraform .tf modules and traces cross-file dependencies across multiple hops.

  • Same-Signature Behavioral Probes: Catches silent logic flips on both documented and undocumented pure Python functions (with a built-in AST safety filter that refuses to auto-probe I/O, disk, network, or subprocess code).

  • Evidence-Hashed Facts & Context-Isolated Referee: Rejects unverified prose claims, shares dead ends so agents don't repeat failed work, and settles disputes strictly on hashed test outputs (blocking persuasive wrong teammates).

  • Built-In Layer-2 Training Pipeline: Records every conflict and recovery as (chosen, rejected) DPO preference pairs (dpo_pairs.jsonl) + ships a ready-to-run LoRA/DPO training script (coordination_lab/training/train_dpo.py).


30-Second Quickstart

Zero external dependencies required for core runtime, CLI, MCP server, and hooks (Python 3.10+).

pip install -e ".[dev]"

# 1. Watch both live demos ($2 vs $8 Silent Behavioral Drift + Zero-Docstring Auth Bypass)
scap-demo

# 2. Run all unit & integration tests
python -W error::ResourceWarning -m unittest discover -s tests -v

# 3. Preview the 20-task live API benchmark cost before spending $0.01
scap-live-bench --dry-run --max-tasks 5

Drop Into Your Repo (Claude Code / Antigravity / Cursor / Gemini CLI)

# 1. Index your repo safely (100% static read-only, zero code execution)
scap-hook --no-probes --db .scap/state.db --workspace . bootstrap

# 2. Generate ready-to-paste Claude Code hooks + MCP server config
scap-install --workspace . --write

# 3. Watch live team state in a second terminal
scap-watch --db .scap/state.db --watch

MCP Server Config (Any MCP-Compatible Agent)

{
  "mcpServers": {
    "scap-coordination": {
      "command": "scap-mcp",
      "args": ["--db", ".scap/state.db", "--workspace", "."]
    }
  }
}

Architecture

flowchart TD
    A1["Worker Agent A"] <--> HOOK["Automatic Middleware Hooks (PreToolUse / PostToolUse / Stop)"]
    A2["Worker Agent B"] <--> HOOK
    HOOK --> EXT["Multi-Language Extractors (Python AST, TS/JS, JSON Schema, Terraform)"]
    HOOK --> PROBE["Behavioral Probe Fingerprinter (Docstring + Auto-Synthesized Pure Probes)"]
    EXT --> SG["Layer 1: SQLite WAL StateGraph (CAS Contracts, Leases, Invalidation Bus)"]
    PROBE --> SG
    SG -->|"Deterministic Block + Exact Diff"| HOOK
    SG --> BUS["Layer 3: Typed DiffBus (VerifiedFacts + DeadEnds)"]
    BUS --> ARB["Layer 4: Tier-A Test Gate + Context-Isolated Tier-B Arbiter"]
    SG --> DPO["Layer 2: Trajectory Logger -> DPO Training Pairs"]

Verified Empirical Results

Live Real-Agent Experiments (Hidden pytest Integration Graders)

Real-Codebase Experiment

Setup

Hidden pytest Result

What Happened

payment_service (4 files, mid-flight float -> int field break)

3 Naive Parallel Agents

FAILED (1/3)

All 3 passed local checks; crashed with AttributeError: amount_usd.

payment_service

3 SCAP CLI Agents

PASSED (3/3)

Exclusive lease + CAS v2 + event_id: 1 invalidated both peers cleanly.

payment_service

3 Auto-Hook Agents (zero manual sync)

PASSED (3/3)

Transitive AST tracking blocked consumer & reporter until v2 convergence.

pricing_service (same signature, flipped return semantics)

3 Naive Parallel Agents

FAILED (1/3)

Every type check green; silently charged $2.00 instead of $8.00.

pricing_service

3 Behavioral-SCAP Agents

PASSED (3/3)

Probe caught SILENT_BEHAVIORAL_DRIFT (200->800); blocked peers until fixed.

auth_service (zero docstrings, adversarial unsigned admin bypass)

3 Adversarial SCAP Agents

PASSED (3/3)

Auto-synthesized probes caught False->True; isolated Tier-B Arbiter reverted bypass.

Simulated CoupledBench-Mini (realistic_frontier, 50 trials / archetype)

System

Pass %

Silent Conflict %

Wasted Work %

Sycophancy %

Wall vs B0

Tokens vs B0

B0 (Single Agent)

95.3%

1.3%

0.0%

0.0%

1.00x

1.00x

B1 (Parallel Fan-Out)

0.0%

81.3%

42.2%

18.0%

0.60x

0.79x

B2 (Chat Swarm)

42.7%

43.3%

19.8%

20.0%

0.64x

1.04x

T1 (SCAP)

98.7%

1.3%

11.7%

0.0%

0.61x

0.85x

Honest Failure Boundaries — When NOT to Use SCAP

  • Uncoupled / embarrassingly parallel tasks: Plain parallel fan-out (B1) wins — SCAP adds ~29% extra token overhead for zero accuracy gain when contracts never change.

  • Small sequential searches: A single strong agent (B0) beats every multi-agent setup on speed and cost (Brooks's Law).

  • Use SCAP when concurrent agents share mutable contracts, schemas, Terraform modules, or business logic where silent drift is expensive.


Docs & Guides

License

MIT — see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Multi-agent orchestration MCP server that lets Claude Code delegate backend, frontend, and tooling tasks to specialized AI agents (Codex, Kimi, Grok) with contract-first sequencing and workspace mutation guards.
      4
      8
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI coding agents and hosts to enforce deterministic repository boundaries via MCP, providing structured reads, supervised edits, snapshots, audits, and recovery with machine-readable evidence.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      An MCP server that enables AI coding agents to coordinate by sharing environment snapshots and diffs, surfacing overlapping work, exchanging debug-session messages, handing off tasks, and enforcing policy preflight checks.
      Elastic 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables teams of AI coding agents (Claude Code, Cursor, Codex) to share persistent, time-aware graph memory and coordinate their work via MCP, so agents recall verified fixes at the moment of failure, learn procedures automatically, avoid file conflicts, claim tasks race-free, and hand off facts and decisions between sessions.
      2
      MIT