Credence — Epistemic Guard

io.github.Lakshmi-Chakradhar-Vijayarao由 GitHub 帳號 Lakshmi-Chakradhar-Vijayarao 發布v1.2.5更新於 Nov 10, 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 分

    請在儲存庫或註冊中心條目中宣告授權條款。