# jamespino20/saphene architecture

> Architecture diagram of the GitHub repository jamespino20/saphene, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jamespino20/saphene
- Repository: https://github.com/jamespino20/saphene

## Overview

Saphene is a claim-to-code evidence verifier and drift gate for workspace memory, specifications, and requirements. Its central workflow turns documents into claims, searches target repositories for literal evidence, records verdicts with receipts in a ledger, and compares later runs to detect drift. The product also offers audits, consistency and profile checks, SARIF ingestion, and CLI/MCP interfaces. Several subsystem links are supported by the README and SOURCE INDEX references; unsampled implementation details are not expanded.

Main entry points: [`src/verify.ts`](https://github.com/jamespino20/saphene/blob/main/src/verify.ts) (Evidence Verification), [`src/cli.ts`](https://github.com/jamespino20/saphene/blob/main/src/cli.ts) (Command Line), [`src/mcp.ts`](https://github.com/jamespino20/saphene/blob/main/src/mcp.ts) (MCP Server), [`src/ledger.ts`](https://github.com/jamespino20/saphene/blob/main/src/ledger.ts) (Claim Ledger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Claim Inputs"]
  node_documents["Memory and Specs"]
  node_extract["Claim Extraction<br/>[extract.ts]"]
  node_model["Model Client<br/>[model.ts]"]
end

subgraph group_verification["Evidence Verification"]
  node_aliases["Alias Rules<br/>[aliases.ts]"]
  node_verify["Evidence Verification<br/>[verify.ts]"]
  node_schema["Claim and Verdict Types<br/>[schema.ts]"]
  node_audit["Persona Audit<br/>[audit.ts]"]
  node_consistency["Document Consistency<br/>[consistency.ts]"]
  node_profile["Mechanical Profiles<br/>[profile.ts]"]
  node_standards["Audit Standards<br/>[standards.ts]"]
end

subgraph group_state["Ledger and Review"]
  node_ledger[("Claim Ledger<br/>[ledger.ts]")]
  node_review["PR Drift Gate<br/>[review.ts]"]
  node_suppressions["Drift Suppressions<br/>[suppressions.ts]"]
  node_ingest["SARIF Ingestion<br/>[ingest.ts]"]
end

subgraph group_interfaces["Product Interfaces"]
  node_cli["Command Line<br/>[cli.ts]"]
  node_mcp["MCP Server<br/>[mcp.ts]"]
end

node_user(("Engineer"))
node_target[("Target Repository")]
node_mcpclient(("Agent Clients"))
node_modelapi{{"Model API"}}
node_github{{"GitHub Actions"}}

node_user -->|"writes claims"| node_documents
node_documents -->|"provides claims"| node_extract
node_extract -->|"requests extraction"| node_model
node_model -->|"calls chat API"| node_modelapi
node_cli -->|"runs verification"| node_verify
node_verify -->|"extracts claims"| node_extract
node_verify -->|"expands evidence"| node_aliases
node_verify -->|"searches evidence"| node_target
node_verify -->|"uses claim types"| node_schema
node_cli -->|"saves verdicts"| node_ledger
node_review -->|"checks claims"| node_verify
node_review -->|"diffs baseline"| node_ledger
node_review -->|"filters drift"| node_suppressions
node_github -->|"gates pull requests"| node_review
node_cli -->|"runs audit"| node_audit
node_audit -->|"requests model review"| node_model
node_audit -->|"verifies findings"| node_verify
node_audit -->|"records findings"| node_ledger
node_cli -->|"checks contradictions"| node_consistency
node_cli -->|"runs profile checks"| node_profile
node_cli -->|"ingests SARIF"| node_ingest
node_ingest -->|"writes findings"| node_ledger
node_cli -->|"uses audit standards"| node_standards
node_mcpclient -->|"invokes tools"| node_mcp
node_mcp -->|"dispatches verification"| node_verify
node_mcp -->|"dispatches consistency"| node_consistency
node_mcp -->|"dispatches profiles"| node_profile
node_mcp -->|"uses ledger"| node_ledger

click node_extract "https://github.com/jamespino20/saphene/blob/main/src/extract.ts"
click node_model "https://github.com/jamespino20/saphene/blob/main/src/model.ts"
click node_aliases "https://github.com/jamespino20/saphene/blob/main/src/aliases.ts"
click node_verify "https://github.com/jamespino20/saphene/blob/main/src/verify.ts"
click node_schema "https://github.com/jamespino20/saphene/blob/main/src/schema.ts"
click node_ledger "https://github.com/jamespino20/saphene/blob/main/src/ledger.ts"
click node_review "https://github.com/jamespino20/saphene/blob/main/src/review.ts"
click node_suppressions "https://github.com/jamespino20/saphene/blob/main/src/suppressions.ts"
click node_audit "https://github.com/jamespino20/saphene/blob/main/src/audit.ts"
click node_consistency "https://github.com/jamespino20/saphene/blob/main/src/consistency.ts"
click node_profile "https://github.com/jamespino20/saphene/blob/main/src/profile.ts"
click node_standards "https://github.com/jamespino20/saphene/blob/main/src/standards.ts"
click node_ingest "https://github.com/jamespino20/saphene/blob/main/src/ingest.ts"
click node_cli "https://github.com/jamespino20/saphene/blob/main/src/cli.ts"
click node_mcp "https://github.com/jamespino20/saphene/blob/main/src/mcp.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_documents,node_extract,node_model,node_mcpclient toneBlue
class node_aliases,node_verify,node_schema,node_audit,node_consistency,node_profile,node_standards,node_target toneAmber
class node_ledger,node_review,node_suppressions,node_ingest,node_modelapi toneMint
class node_cli,node_mcp toneRose
class node_user,node_github toneIndigo
```

## Components

### Claim Inputs

- **Memory and Specs**
- [Claim Extraction](https://github.com/jamespino20/saphene/blob/main/src/extract.ts): `src/extract.ts`
- [Model Client](https://github.com/jamespino20/saphene/blob/main/src/model.ts): `src/model.ts`

### Evidence Verification

- [Alias Rules](https://github.com/jamespino20/saphene/blob/main/src/aliases.ts): `src/aliases.ts`
- [Evidence Verification](https://github.com/jamespino20/saphene/blob/main/src/verify.ts): `src/verify.ts`
- [Claim and Verdict Types](https://github.com/jamespino20/saphene/blob/main/src/schema.ts): `src/schema.ts`
- [Persona Audit](https://github.com/jamespino20/saphene/blob/main/src/audit.ts): `src/audit.ts`
- [Document Consistency](https://github.com/jamespino20/saphene/blob/main/src/consistency.ts): `src/consistency.ts`
- [Mechanical Profiles](https://github.com/jamespino20/saphene/blob/main/src/profile.ts): `src/profile.ts`
- [Audit Standards](https://github.com/jamespino20/saphene/blob/main/src/standards.ts): `src/standards.ts`

### Ledger and Review

- [Claim Ledger](https://github.com/jamespino20/saphene/blob/main/src/ledger.ts): `src/ledger.ts`
- [PR Drift Gate](https://github.com/jamespino20/saphene/blob/main/src/review.ts): `src/review.ts`
- [Drift Suppressions](https://github.com/jamespino20/saphene/blob/main/src/suppressions.ts): `src/suppressions.ts`
- [SARIF Ingestion](https://github.com/jamespino20/saphene/blob/main/src/ingest.ts): `src/ingest.ts`

### Product Interfaces

- [Command Line](https://github.com/jamespino20/saphene/blob/main/src/cli.ts): `src/cli.ts`
- [MCP Server](https://github.com/jamespino20/saphene/blob/main/src/mcp.ts): `src/mcp.ts`

### Other components

- **Engineer**
- **Target Repository**
- **Agent Clients**
- **Model API**
- **GitHub Actions**

## Connections

- Engineer → Memory and Specs: writes claims (evidence: `README.md`)
- Memory and Specs → Claim Extraction: provides claims (evidence: `README.md`)
- Claim Extraction → Model Client: requests extraction (evidence: `src/extract.ts`)
- Model Client → Model API: calls chat API (evidence: `src/model.ts`)
- Command Line → Evidence Verification: runs verification (evidence: `src/cli.ts`)
- Evidence Verification → Claim Extraction: extracts claims (evidence: `src/verify.ts`)
- Evidence Verification → Alias Rules: expands evidence (evidence: `src/verify.ts`)
- Evidence Verification → Target Repository: searches evidence (evidence: `README.md`)
- Evidence Verification → Claim and Verdict Types: uses claim types (evidence: `src/verify.ts`)
- Command Line → Claim Ledger: saves verdicts (evidence: `src/cli.ts`)
- PR Drift Gate → Evidence Verification: checks claims (evidence: `src/review.ts`)
- PR Drift Gate → Claim Ledger: diffs baseline (evidence: `src/review.ts`)
- PR Drift Gate → Drift Suppressions: filters drift (evidence: `src/review.ts`)
- GitHub Actions → PR Drift Gate: gates pull requests (evidence: `README.md`)
- Command Line → Persona Audit: runs audit (evidence: `README.md`)
- Persona Audit → Model Client: requests model review (evidence: `src/audit.ts`)
- Persona Audit → Evidence Verification: verifies findings (evidence: `src/audit.ts`)
- Persona Audit → Claim Ledger: records findings (evidence: `src/audit.ts`)
- Command Line → Document Consistency: checks contradictions (evidence: `src/cli.ts`)
- Command Line → Mechanical Profiles: runs profile checks (evidence: `src/cli.ts`)
- Command Line → SARIF Ingestion: ingests SARIF (evidence: `README.md`)
- SARIF Ingestion → Claim Ledger: writes findings (evidence: `src/ingest.ts`)
- Command Line → Audit Standards: uses audit standards (evidence: `src/cli.ts`)
- Agent Clients → MCP Server: invokes tools (evidence: `README.md`)
- MCP Server → Evidence Verification: dispatches verification (evidence: `src/mcp.ts`)
- MCP Server → Document Consistency: dispatches consistency (evidence: `src/mcp.ts`)
- MCP Server → Mechanical Profiles: dispatches profiles (evidence: `src/mcp.ts`)
- MCP Server → Claim Ledger: uses ledger (evidence: `src/mcp.ts`)
