Skip to main content

JVS — Temporal-Causal Knowledge Graph & Cross-Session Causal QA (v2.0)

English | 简体中文

JVS CI Python 3.11+ License: MIT

JVS is a lightweight, local-first temporal-causal knowledge graph and cross-session causal QA engine designed for personal AI agents. Unlike generic RAG or flat agent memory systems, JVS enforces:

  1. Directed Causal Ontology & Confidence Gating: Events (subject / action / object / before / after / reason / ts / source_hash) connected by typed, strength-graded edges (strong, weak, pending). Low-confidence (<= 0.6) edges are kept as 1-hop clues (pending) and prevented from polluting multi-hop reasoning.
  2. Two-State Causal Traversal: Separate clue_seen and expanded state in bidirectional BFS so weak 1-hop clues never block longer strong causal chains.
  3. M1-11 Graceful Degradation: Automatic classification (no_chain, low_confidence, weak_only) driven by assets/fallback.yaml, preventing fabricated causal claims when evidence is thin.
  4. Fail-Closed Outbound Privacy Gate: Inspects all payloads for known names (NFKC + casefold), credentials, and PII before any LLM or embedding call.
  5. Zero External Server Dependencies: Runs on a single local SQLite file with FTS5 trigram full-text search, optional sqlite-vec vector search, NetworkX structural analytics, Typer CLI, and an MCPServer (mcp >= 2.0).

Architecture

flowchart LR
    A["Raw Notes / Events"] --> B["PrivacyGate (Fail-Closed)"]
    B --> C["SQLite FTS5 + sqlite-vec RRF"]
    C --> D["Causal Graph (strong / weak / pending)"]
    D --> E["2-State Bidirectional BFS"]
    E --> F["M1-11 Graceful Degradation"]
    F --> G["CLI / Python SDK / MCP 2.x Server"]

See docs/ARCHITECTURE.md for layered dependency boundaries, confidence gating rules, and evaluation guarantees.


Quickstart

1. Install

Install via pip (PyPI package name: jvs-causal-graph, Python 3.11+):

pip install jvs-causal-graph
# With sqlite-vec vector search & MCP 2.x Server extras:
pip install "jvs-causal-graph[vec,mcp]"

Or install editable from source for local development:

pip install -e ".[all]"

Configure environment variables by copying .env.example to .env:

cp .env.example .env
# Set JVS_LLM_PROVIDER (openai | deepseek | doubao | sensenova | ollama | custom)
# and JVS_LLM_API_KEY

2. 1-Minute Offline Demo (examples/)

Run a complete graph ingestion, multi-hop traversal, offline QA, and rule evaluation walkthrough with zero API keys using the sanitized sample dataset in examples/:

jvs graph init --db demo.db
jvs graph ingest --db demo.db --events examples/events.jsonl --edges examples/edges.jsonl
jvs graph stats --db demo.db
jvs graph why EX1 --db demo.db --max-hops 3
jvs qa ask "为什么把数据库连接池从20扩容到60?" --db demo.db --offline
jvs qa run --db demo.db --questions examples/questions.jsonl --out demo_out --offline
jvs eval score --answers demo_out/answers.jsonl --questions demo_out/gold.jsonl

3. CLI Commands (jvs)

# Inspect graph stats & search (supports read-only legacy SQLite DBs)
jvs graph stats --db jvs_causal.db
jvs graph search "连接池扩容" --db jvs_causal.db --k 5
jvs graph why E1 --db jvs_causal.db --max-hops 3
jvs graph timeline --db jvs_causal.db --subject "连接池配置"

# Ingest raw notes into events + causal edges (LLM + PrivacyGate)
jvs graph ingest-text --db jvs_causal.db --file notes.md --corpus worklog

# Or run deterministic pipeline stages individually
jvs pipeline extract --file notes.md --out events.jsonl
jvs pipeline candidates --events events.jsonl --out pairs.jsonl
jvs pipeline judge-edges --events events.jsonl --candidates pairs.jsonl --out edges.jsonl
jvs graph ingest --db jvs_causal.db --events events.jsonl --edges edges.jsonl

# Single-question QA & batch evaluation
jvs qa ask "为什么扩容连接池?" --db jvs_causal.db
jvs qa ask "为什么扩容连接池?" --db jvs_causal.db --offline
jvs qa run --db jvs_causal.db --questions questions.jsonl --out out/
jvs qa prompt --db jvs_causal.db --questions questions.jsonl --out prompts_out/

# Evaluation & multi-run readout
jvs eval score --answers out/answers.jsonl --questions questions.jsonl
jvs eval judge --answers out/answers.jsonl --questions questions.jsonl --out out/scores.json
jvs eval readout judge-result.e1.md judge-result.e2.md judge-result.e3.md

# Fail-closed privacy & credential scan
jvs privacy scan ./workspace --names names.json

# Start MCP Server (stdio / sse / streamable-http)
jvs mcp serve --db jvs_causal.db

4. Python SDK (CausalEngine)

from jvs import CausalEngine, JVSSettings

with CausalEngine("jvs_causal.db", settings=JVSSettings()) as engine:
    engine.init()
    hits = engine.search("连接池扩容", k=5)
    traversal, assessment = engine.why("E1")
    answer = engine.ask("为什么扩容连接池?", use_llm=False)

5. MCP Integration (OpenClaw / Claude Code / Cursor / Antigravity)

Register JVS as a local stdio MCP server:

{
  "mcpServers": {
    "jvs-causal-graph": {
      "command": "jvs",
      "args": ["mcp", "serve", "--db", "/path/to/jvs_causal.db"]
    }
  }
}

Exposed MCP tools: causal_search, causal_why, causal_timeline, causal_ask, causal_ingest_event, causal_link_events, causal_graph_stats, plus resource jvs://graph/summary.


Project Layout

jvs-causal-graph/
├── LICENSE                  # MIT License
├── README.md                # English documentation
├── README.zh-CN.md          # Simplified Chinese documentation
├── pyproject.toml           # Package manifest, dependencies, pytest & ruff config
├── .env.example             # Safe configuration template
├── .github/workflows/       # GitHub Actions CI & PyPI OIDC publish workflows
├── assets/                  # Versioned prompts & M1-11 fallback.yaml
├── examples/                # Sanitized runnable sample dataset
├── src/jvs/
│   ├── assets/              # Packaged copy of prompts & fallback.yaml for wheel installs
│   ├── config.py            # pydantic-settings configuration & provider presets
│   ├── domain/              # Pure Pydantic models, causal rules, 2-state BFS, NetworkX analytics
│   ├── infrastructure/      # PrivacyGate, SQLite+FTS5+sqlite-vec store, Hybrid RRF, OpenAI+Tenacity
│   ├── application/         # Extraction, QA orchestration, Evaluation, CausalEngine facade
│   ├── cli/                 # Typer + Rich CLI
│   └── mcp/                 # MCPServer (mcp >= 2.0)
├── tests/                   # Offline pytest suite
├── scripts/
│   └── check.py             # Unified quality gate (ruff + pytest + hygiene)
└── docs/
    └── ARCHITECTURE.md      # Technical architecture & design decisions

Run quality checks anytime with:

python scripts/check.py

License

Released under the MIT License.

Metadata

Release files for jvs-causal-graph 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jvs-causal-graph 2.0.1
File Size Uploaded Provenance Actions
jvs_causal_graph-2.0.1.tar.gz 88.1 kB With provenance Details for jvs_causal_graph-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jvs-causal-graph 2.0.1
File Interpreter ABI Platform Actions
jvs_causal_graph-2.0.1-py3-none-any.whl Python 3 none any Details for jvs_causal_graph-2.0.1-py3-none-any.whl

Total release size: 170.9 kB

Release files / jvs_causal_graph-2.0.1.tar.gz

Download URL jvs_causal_graph-2.0.1.tar.gz
Size 88.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1393c90a8f42ea88fdc61ad06d20de9e31ad8d012d046ddfe632b15daa5a1bbc
BLAKE2b-256 checksum
How to use checksums
76e0c19943f43b1fe0ca5be73e8c89d5af2b5034dbd7e712aa6ed362869d33bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / jvs_causal_graph-2.0.1-py3-none-any.whl

Download URL jvs_causal_graph-2.0.1-py3-none-any.whl
Size 82.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
874ea160f3b2f93c794cc1aa42a1b188eefc6be735f015e78503dcfc14be9067
BLAKE2b-256 checksum
How to use checksums
46f519dac98ec2fd8ceb1ec0e206e1ab851756e4eb655e434bf0fa4312d459b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for jvs-causal-graph 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for jvs_causal_graph-2.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page