Credence — Epistemic Guard

io.github.Lakshmi-Chakradhar-Vijayarao由 GitHub 账号 Lakshmi-Chakradhar-Vijayarao 发布v1.2.5更新于 Oct 24, 2026

Epistemic guard for AI coding: tracks uncertain values and blocks writes until verified.

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

一个面向 AI 编程的本地认知守卫:记录你声明为不确定的数值,并在你确认前阻止写入或执行包含这些数值的文件与命令。

可以做什么
通过被动观察钩子在助手回应前登记你提示中不确定的数值,并保存在本地 SQLite 注册表中,支持会话跟踪与约束数量上限。拦截包含未验证或过期数值的 Write、Edit、Bash 与 NotebookEdit 操作,确认数值后解除拦截。查看待处理约束,以及门禁统计与反馈标记。在命令行运行演示冒烟测试与延迟报告。
适用场景
当助手编写的代码会硬编码你只是猜测的配置值、限额、版本或过期时间,而你想在这些猜测进入文件或命令前强制拦截时适用。适合希望强制执行而非仅提示的 Claude Code 用户。
运行要求
需要本地 Python 环境并安装 credence-guard 包;README 还提到可选的 Rust 门禁。配置需在项目设置中添加 MCP 服务器条目以及 UserPromptSubmit 和 PreToolUse 的 Claude Code 钩子。无需 API 密钥。可选环境变量用于设置注册表路径、会话 ID、事件日志与约束上限。
安装前请注意
门禁会阻止写入与命令,在确认数值前编辑可能被中断;它只捕获你明确表达的不确定性,也不判断数值是否正确。它会在工作目录写入 SQLite 注册表,并在主目录下生成本地事件日志,两者均可改路径或关闭。仅限桌面端,且依赖 Claude Code 的钩子配置。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Credence — Epistemic Guard,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Credence

AI doesn't remember what it wasn't sure about. Credence does.

[PyPI] [CI] [Python] [License: Apache 2.0]

bash
pip install credence-guardcredence demo   # 30-second smoke test, no API key required

[mcp] adds the FastMCP server for Claude Code. Core package has zero hard dependencies.


The problem

You say: "The rate limit is probably around 50 — I haven't confirmed it yet."

Fifteen turns later, Claude writes:

python
RATE_LIMIT = 50   # no warning. no flag. shipped.

The API rejects every request at 2am. The real limit was 10. Claude forgot you weren't sure.

This isn't hallucination. The model reproduced exactly what it read. What it read had the qualifier stripped — by context compression, fifteen turns back.


What Credence does

Tracks uncertain values the moment you state them. Blocks writes that embed those values until you confirm them.

you say "rate limit is probably 50"    → observer registers it (before Claude responds)    → Claude writes: RATE_LIMIT = 50  # ⚠ CREDENCE[unverified]    → write blocked until you confirm

Every other tool warns. Credence enforces.


What it looks like

python
# Claude generates this. Credence intercepts before it ships.
class StripeClient:    API_VERSION  = "2023-10-16"  # ⚠⚠ CREDENCE[stale]: API date versions change on release — verify before shipping    RATE_LIMIT   = 100           # ⚠  CREDENCE[unverified]: I think Stripe rate limit is around 100 req/min    TOKEN_EXPIRY = 3600          # ⚠⚠ CREDENCE[stale]: Token/session lifetime values are set by the vendor — verify    MAX_RETRIES  = 3    TIMEOUT_MS   = 5000
credence: blocked Edit — 2 unverified value(s)  → I think Stripe rate limit is around 100 req/min | TOKEN_EXPIRY = 3600  Verify first, then retry. Use credence_constraints to see all pending.

After you confirm: "Confirmed — rate limit is 100 req/min per stripe.com/docs" → gate clears.

[Gate demo]


Setup

1. Add to .mcp.json:

json
{ "mcpServers": { "credence": { "command": "credence-server" } } }

2. Add to .claude/settings.json:

json
{  "hooks": {    "UserPromptSubmit": [      { "hooks": [{ "type": "command", "command": "python3 -m credence.observer" }] }    ],    "PreToolUse": [      {        "matcher": "Write|Edit|Bash|NotebookEdit",        "hooks": [{ "type": "command", "command": "python3 -m credence.hooks" }]      }    ]  }}

Done. No API key required.

Registry: Credence creates epistemic_registry.db in your working directory. Add *.db to your .gitignore, or set CREDENCE_DB=~/.credence/registry.db to keep it global.

Session tracking: Set CREDENCE_SESSION_ID=my-project to keep constraints stable across directory changes and terminal restarts.

Event log: The gate writes block/allow events to ~/.credence/events.jsonl (local only, never sent anywhere). Set CREDENCE_NO_LOG=1 to disable.

Constraint cap: The registry allows up to 500 constraints per session by default. Override with CREDENCE_MAX_CONSTRAINTS=<n>.


How it works

Two layers, neither requires model cooperation:

LayerHookRole
ObserverUserPromptSubmitPassive listener — registers uncertain values before Claude generates anything
GatePreToolUseBlocks writes that embed unverified values

The observer fires before the model processes your message. If you say "I think the rate limit is 50", the registry has that entry before Claude generates a single token.


What gets blocked

credence: blocked Edit — 2 unverified value(s)  → rate limit is probably 50 req/min | token expires in 3600s  Verify first, then retry. Use credence_constraints to see all pending.

Once verified, the gate clears.


What Credence does NOT do

  • Does not verify facts — it cannot tell you if a value is correct
  • Does not catch uncertainty that was never stated
  • Does not block the model from saying a wrong value in prose — only from writing it to a file or command

Known issue (November 2026): the PreToolUse gate (python3 -m credence.hooks) only enforces when CREDENCE_SESSION_ID is set. Without it, the observer files constraints under an id derived from the working directory, which the gate never reads, so nothing is blocked. The Rust gate filters by Claude Code's own session id and reads CREDENCE_DB_PATH rather than CREDENCE_DB, so it can miss them too. Making the ids match is planned, together with a stricter value-level match: the current two-shared-words rule over-blocks once it enforces.


Measured results

46% of uncertainty qualifiers are stripped by Claude Haiku during context compression. Credence's probe skips compression for 100% of those segments (n=50), so no qualifier is lost.

Validated across 7 open-weight models (Qwen, Mistral, Llama, Phi, Gemma) from 5 organizations: same failure mode, same block rate.

bash
credence demo                     # smoke test, no API keycredence stats                    # false-positive rate from real gate usagecredence feedback 1|2|3           # tag last gate block: correct / noise / skippython3 -m pytest tests/ -q       # 829 testspython3 -m evals.latency_report   # P50/P95/P99

Full methodology: docs/TECHNICAL_REPORT.md


Project layout

credence/         pip-installable package  observer.py     passive UserPromptSubmit hook  hooks.py        PreToolUse enforcement gate  mcp_server.py   17-tool MCP server  registry.py     SQLite constraint store  memory.py       cross-session persistencetests/            829 testsevals/            validation studies + multi-model benchmarksdocs/             technical report, architecture, ETP speccredence_gate/    Rust gate (alternative to Python hooks.py)experimental/     Phase 2 work — not yet shippedpaper/            Research paper draft + figures

Research

The scientific basis for Credence is documented in paper/ (EQL / EQLR / FCR).

The companion geometry thesis — on confabulation detection and why the detection axis is dissociable from the causal control axis — lives in a separate repo: → Detection Without Control


Built by

Lakshmi Chakradhar Vijayarao — GitHub · LinkedIn · X

Apache 2.0 License

来源:README.md,提交 a75329a

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.2.5最新Sep 16, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。