Platform / 08 Compass Governance

Compass Governance

Compass is a full MCP-server-backed governance service running on Cloudflare Workers. It provides institutional memory, blessed pattern enforcement, ADR ledger management, drift scanning, temporal analysis, and LLM-powered advisory capabilities through 47 MCP tools.

Public endpoint: https://compass.stackbilt.dev/mcp

Protocol: MCP 2025-03-26 (Streamable HTTP) + SSE fallback

Integration Status: Pending Activation

Compass is live as a standalone MCP server and can be connected to directly by any MCP client. The EdgeStack flow-pipeline integration (GovernanceClient, quality gating, automatic ADR persistence) is code-complete but not yet active in production — the CSA_MCP_TOKEN credential has not been configured. Flows currently run with local-only quality evaluation. All architecture described below is accurate to the codebase and will activate once the credential is set.

Architecture

Compass runs as an independent Cloudflare Worker (compass) with its own data layer. EdgeStack connects via Cloudflare Service Binding (CSA_SERVICE bound to digital-csa) for zero-latency internal calls, or via external HTTP to compass.stackbilt.dev/mcp as fallback.

Agent (Claude Code / Desktop)

  └── MCP ──► compass.stackbilt.dev/mcp

                ├── CompassMcpAgentV3 (Durable Object — stateful sessions)
                ├── CompassBrainDO (autonomous action queue, hash-chained audit)
                ├── D1 (compass-db — ledger, patterns, protocols, projects)
                ├── R2 (csa-audit — immutable audit records)
                ├── KV (COMPASS_ACTIONS — action envelopes)
                └── Analytics Engine (MCP_ANALYTICS — tool call observability)

EdgeStack (FlowDO)

  └── Service Binding (CSA_SERVICE → digital-csa)

        └── GovernanceClient ──► Compass MCP tools via JSON-RPC 2.0

MCP Tools by Domain

Compass exposes 47 tools organized across 14 domains. Each tool is tier-gated: free-tier users get read-only access, pro/enterprise users unlock mutations and LLM-powered analysis.

Context Management

ToolTierDescription
set_contextFreeInject project context (files, decisions, constraints) for the session. Up to 500KB
get_contextFreeView current session context
get_historyFreeRetrieve conversation history from this session
clear_sessionFreeClear conversation history and context

Advisory (LLM-Powered)

ToolTierDescription
briefFreeTranslate technical content for non-technical stakeholders
governanceProCheck authority against governance exhibits, validate requests, detect boundary violations
strategyProStrategic architectural advice, precedent setting for edge cases
drafterProGenerate ADRs, SOPs, policies in governed voice
red_teamProHostile security and architecture review

Ledger (ADRs, Policies, SOPs)

ToolTierDescription
list_ledger_entriesFreeQuery ledger entries with filters
get_ledger_entryFreeGet single entry by ID with full content
get_ledger_audit_statsFreeAggregated statistics (counts by type, project, status)
create_ledger_entryProCreate ADR, policy, SOP, or ruling. Can atomically create linked pattern
update_ledger_entryProUpdate entry status (ACTIVE, SUPERSEDED, ARCHIVED)
batch_persist_recordsProBatch-persist up to 20 ledger entries atomically with per-record validation

Blessed Patterns

ToolTierDescription
list_patternsFreeQuery blessed patterns with ecosystem + project override resolution
get_patterns_for_architectureFreeRetrieve patterns for architecture planning (pre-approved tech stack)
create_patternProCreate pattern with category, solution, rationale, and anti-patterns

Governance Requests

ToolTierDescription
list_requestsFreeList governance requests with status and project filters
submit_requestFreeSubmit formal governance request for triage
detect_resolvedFreeDetect requests silently completed by matching against recent entries
resolve_requestProResolve request with summary and optional linked ledger entry

Protocols (RFCs)

ToolTierDescription
list_protocolsFreeList protocols/RFCs with search and project filters
create_protocolProCreate protocol (RFC) with title, description, and content

Projects

ToolTierDescription
list_projectsFreeList all projects (optionally include inactive)
create_projectProCreate new project with name and description

Architect Integration

ToolTierDescription
validate_architectureProValidate blueprint against blessed patterns. Returns PASS/WARN/FAIL with violations
persist_architecture_adrProPersist ADR from SPRINT mode into governance ledger with flow traceability
set_integration_modeProToggle governance mode: PASSIVE, ADVISORY, ENFORCED

Decision Learning

ToolTierDescription
find_precedentsFreeSearch past governance decisions with confidence scores
get_decision_reviewFreeGenerate decision review for a period (week, month, quarter)
track_outcomeProRecord outcome of a governance decision for learning

Temporal Analysis (4D Lens)

ToolTierDescription
list_temporal_analysesFreeList past temporal analyses with filters
get_temporal_analysisFreeGet specific temporal analysis by ID
temporal_analysisProApply 4D lens: 1yr/3yr horizons, locked-in futures, invisible debt

Change Control

ToolTierDescription
list_change_classificationsFreeList past change classifications by class, status, or recommendation
classify_changeProClassify change as SURFACE/LOCAL/CROSS_CUTTING. Auto-triggers temporal analysis for cross-cutting

Experiments

ToolTierDescription
list_experimentsFreeList experiments with status and project filters
get_experimentFreeGet experiment by ID with full details
propose_experimentProPropose experiment with hypothesis and success criteria (sandbox-only scope)
update_experimentProAdvance lifecycle: PROPOSED, APPROVED, RUNNING, REVIEWING, PROMOTED, REJECTED
review_experimentProAnalyze results and generate structured change package for promotion

Notary and Quality

ToolTierDescription
get_project_snapshotFreeExport governance receipt (ledger, patterns, constraints) for a project
evaluate_artifact_qualityProEvaluate artifact specificity. Issues NOTARY_STAMP ledger entry on PASS
assess_artifactProUnified quality + architecture assessment. Runs evaluation and optional validation in parallel. 64KB artifact limit

Drift Scanning

ToolTierDescription
scan_codebase_complianceProScan file content for state drift against active governance patterns. Returns drift score and violations

Flow Context

ToolTierDescription
get_flow_contextFreePer-mode governance context for EdgeStack flows. Deterministic (no LLM). Returns patterns, constraints, ledger summaries filtered per mode. Includes version hash for cache invalidation

Tier Gating

Tool access is controlled by plan tier. The gating logic lives in EdgeStack (compass-tier-config.ts) and is applied before forwarding calls to Compass.

PlanTool AccessGovernance Mode Cap
Free24 read-only tools (context, ledger reads, pattern reads, project snapshots, precedent search)PASSIVE
ProAll 47 tools (+ 23 pro-only: mutations, LLM advisory, drift scanning, architecture validation)ADVISORY
EnterpriseAll 47 toolsENFORCED

Free-tier users get full read access to governance data. They can browse patterns, query the ledger, search precedents, and submit requests. They cannot create entries, validate architecture, or invoke LLM-powered tools.

EdgeStack Integration

Not yet active. The GovernanceClient is fully implemented but disabled in production — CSA_MCP_TOKEN is not set, so all governance calls return early without contacting Compass. Flows complete using local-only quality evaluation. The integration below describes the designed behavior that will activate once the credential is configured.

EdgeStack calls Compass tools through the GovernanceClient class, which handles transport selection, retry logic, circuit breaking, and session management.

Service Binding

In production, EdgeStack connects via Cloudflare Service Binding for zero-network-hop calls:

# Edgestack-Architech/wrangler.toml (production)
[[env.production.services]]
binding = "CSA_SERVICE"
service = "digital-csa"

The binding name is CSA_SERVICE. The service name is digital-csa (historical name, predates the Compass rebrand).

Transport Selection

The GovernanceClient supports three transport modes, configurable via CSA_TRANSPORT:

ModeBehavior
external_httpAlways use https://compass.stackbilt.dev/mcp
service_bindingAlways use the CSA_SERVICE binding (falls back to HTTP if binding unavailable)
autoCanary-based: routes a configurable percentage (CSA_CANARY_PERCENT) through the service binding, remainder through HTTP

Production currently runs at CSA_CANARY_PERCENT = 100 (all traffic routed through the service binding).

What EdgeStack Calls

During a flow execution, the GovernanceClient calls these Compass MCP tools:

Before ARCHITECT mode:
  get_flow_context(projectId, modes, categories)   → patterns, constraints, ledger summaries
  get_patterns_for_architecture(projectId)          → blessed stack patterns

After ARCHITECT mode:
  validate_architecture(blueprint, projectId)       → PASS / WARN / FAIL

After each mode:
  assess_artifact(artifact, mode, projectId)        → quality score + notary stamp
  evaluate_artifact_quality(artifact, projectId)     → structured quality feedback

After SPRINT mode:
  persist_architecture_adr(adrs, flowId, projectId) → ledger writes
  batch_persist_records(entries)                     → bulk ADR persistence

Circuit Breaking

The GovernanceClient includes per-flow and per-mode call budgets. If Compass is unresponsive or returning errors, the circuit opens and all subsequent calls in that flow return gracefully without blocking the pipeline.

ConfigDefaultPurpose
CSA_TIMEOUT_MS10,000Per-call timeout
CSA_RETRY_MAX_ATTEMPTS3Max retries per tool call
CSA_THROTTLE_MAX_INFLIGHT8Max concurrent in-flight calls

Infrastructure

Compass runs on Cloudflare’s edge with a full persistence stack:

ResourceBindingPurpose
D1 DatabaseDB (compass-db)Ledger entries, patterns, protocols, projects, temporal analyses, experiments, change classifications, decision learning
R2 BucketCOMPASS_AUDIT (csa-audit)Immutable append-only audit records
KV NamespaceCOMPASS_ACTIONSAgent action envelopes and status (ADR-207)
Durable ObjectCompassMcpAgentV3Stateful MCP sessions (SQLite-backed)
Durable ObjectCompassBrainDOAutonomous action queue with hash-chained audit
Durable ObjectMCPClientDOOutbound MCP client connections
Analytics EngineMCP_ANALYTICS (mcp_tool_calls)Tool call observability (ADR-022)

Cron Triggers

Five scheduled tasks run on UTC cron triggers:

ScheduleTask
0 2 * * * (2 AM daily)Audit cleanup (90-day retention)
0 3 * * * (3 AM daily)Pattern aggregation (decision learning)
0 4 * * * (4 AM daily)Governance heartbeat (pattern drift, staleness, conflicts)
0 5 * * * (5 AM daily)Agent reconciliation (stale action cleanup)
0 9 * * 1 (Mon 9 AM)Weekly decision review

Citation System

Compass includes a deterministic citation system for governance responses. All advisory tool outputs reference specific ledger entries, patterns, and protocols by ID. The system operates in three strictness phases:

PhaseBehavior
PERMISSIVELog citation violations
WARNShow banners on violations (current default)
STRICTReject responses with invalid citations

Client Configuration

Claude Code / Claude Desktop

{
  "mcpServers": {
    "compass": {
      "url": "https://compass.stackbilt.dev/mcp",
      "transport": { "type": "streamable-http" },
      "headers": {
        "Authorization": "Bearer <YOUR_TOKEN>"
      }
    }
  }
}

Unified Auth

Use a StackBilt access key to get a JWT that works at both StackBilt and Compass:

curl -X POST https://stackbilt.dev/api/auth/token \
  -H "X-Access-Key: ska_..." \
  -H "Content-Type: application/json" \
  -d '{"expires_in": 3600}'

The returned JWT is RS256-signed. Compass verifies it via JWKS at compass.stackbilt.dev/api/.well-known/jwks.json.

Governance Modes

Governance mode determines how violations affect the flow pipeline:

ModeBehaviorPlan Cap
PASSIVELog only — never blocksFree
ADVISORYWarn on issues, flow continuesPro
ENFORCEDBlock on FAIL, require remediationEnterprise

Pass a governance config when starting a flow to control enforcement:

governance: {
  mode: 'ADVISORY',
  projectId: 'my-project',
  autoPersist: true,
  qualityThreshold: 80,
  transport: 'auto',
  transportCanaryPercent: 100
}
  • MCP Integration — StackBilt MCP server (22 tools for flow execution)
  • Platform — 6-mode pipeline, scaffold engine, plan tiers
  • Ecosystem — How Compass fits into the StackBilt service map