Cognos Session Memory

io.github.base76-research-lab由 GitHub 帳號 base76-research-lab 發布v0.1.0更新於 Oct 24, 2026

CognOS trust scoring (C=p·(1-Ue-Ua)) and session trace storage as MCP tools.

發布方自己的服務:Memory.fit

已驗證STDIO僅桌面知識與記憶AI 與機器學習

概覽

AI 產生的概覽

一個本機 MCP 伺服器,將工作階段摘要存入 SQLite,以 CognOS 公式計算信任分數,並在後續對話中重新載入經驗證的上下文。

可以做什麼
儲存結構化的工作階段摘要,可附上專案標籤,並對其進行信任評分後寫入本機 SQLite 軌跡資料庫。依可選的信任門檻載入最近一次經驗證的上下文,讓新對話從既有決策與待解決問題開始。上下文經信心公式評分後,依風險等級被注入、標記待人工複核或不予注入。
適用情境
適合希望在不同對話之間保持連續性,並偏好使用可評分、可稽核的上下文而非一般向量檢索的情境。適用於長期研究或工程工作,需要在工作階段之間延續決策與待解決問題。
執行需求
以本機 Python 程序執行,從 PyPI 套件安裝,通常以 python3 啟動。需要一個可寫入的 SQLite 資料庫路徑,可透過環境變數 COGNOS_TRACE_DB 設定(預設 data/traces.sqlite3)。未宣告任何身分驗證。
安裝前請注意
工作階段摘要會寫入本機 SQLite 檔案,所記錄的內容會持久保存在磁碟上,儲存敏感資料前應先確認。README 亦描述了 force 模式,會無視信任分數直接注入上下文,因而繞過複核機制。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Cognos Session Memory,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

CognOS Session Memory

mcp-name: io.github.base76-research-lab/cognos-session-memory

Verified context injection via epistemic trust scoring for LLMs.

Solves session fragmentation by maintaining verified, high-confidence session context between conversations.

Problem

Large language models suffer from session fragmentation: each new conversation starts without verified context of previous work. This forces repeated explanations, loses decision history, and breaks long-running workflows.

Existing solutions (persistent memory systems, vector retrieval) either:

  • Lack trust scores before injection → hallucinations propagate
  • Don't audit which context was injected → compliance gaps
  • Treat all past information equally → noise overwhelms signal

Solution

A plan-mode gateway that:

  1. Extracts structured context from 3-5 recent traces
  2. Scores context quality via CognOS epistemic formula: C = p · (1 − Ue − Ua)
  3. Injects as system prompt only if C > threshold
  4. Flags for manual review if C < threshold
  5. Audits every context injection with trace IDs → EU AI Act compliance

Architecture

recent_traces (n=5)    ↓extract_context() → ContextField + coverage    ↓compute_trust_score(p, ue, ua) → C, R, decision    ↓if C > threshold:    system_prompt ← injectelse:    flagged_reason ← manual review

Core Formula

C = p · (1 − Ue − Ua)R = 1 − C
where:  p   = prediction confidence (coverage of required fields)  Ue  = epistemic uncertainty (divergence between traces)  Ua  = aleatoric uncertainty (mean risk in traces)

Action Gate

R < 0.25       → PASS      (inject without review)0.25 ≤ R < 0.60 → REFINE   (inject with caution)R ≥ 0.60       → ESCALATE  (flag for manual review)

API

POST /v1/plan

Extract and score context.

Request:

json
{  "n": 5,  "trust_threshold": 0.75,  "mode": "auto"}

Response (if injected):

json
{  "status": "injected",  "trust_score": 0.82,  "confidence": 0.82,  "risk": 0.18,  "decision": "PASS",  "context": {    "active_project": "CognOS mHC research",    "last_decision": "Verify P1 hypothesis",    "open_questions": ["How does routing entropy scale?"],    "current_output": "exp_008 complete",    "recent_models": ["gpt-4", "claude-3", "mistral"]  },  "system_prompt": "## CognOS Context...",  "trace_ids": ["uuid-1", "uuid-2", ...]}

Response (if flagged):

json
{  "status": "flagged",  "trust_score": 0.45,  "decision": "REFINE",  "flagged_reason": "Trust score 0.45 below threshold 0.75. Manual review recommended.",  "trace_ids": [...]}

Modes

  • auto (default) — inject if trust_score ≥ threshold, else flag
  • force — always inject (for testing)
  • dry_run — compute score but never inject

Claude Code Integration

As a /compact replacement

bash
# In any Claude Code session:/save

Claude writes a structured summary, trust-scores it, and persists it to SQLite. Next session: automatically injected as SESSION_CONTEXT before your first prompt.

See docs/COMPACT_ALTERNATIVE.md for a full comparison.

As an MCP server

Add to ~/.claude/settings.json:

json
{  "mcpServers": {    "cognos-session-memory": {      "command": "python3",      "args": ["/path/to/cognos-session-memory/mcp_server.py"]    }  }}

Tools exposed:

ToolDescription
save_session(summary, project?)Trust-score and persist a session summary
load_session(threshold?)Retrieve last verified context (default threshold: 0.45)

Quick Start

Installation

bash
git clone https://github.com/base76-research-lab/cognos-session-memorycd cognos-session-memorypip install -e .

Run Gateway

bash
python3 -m uvicorn --app-dir src main:app --port 8788

Test /v1/plan (dry_run)

bash
curl -X POST http://127.0.0.1:8788/v1/plan \  -H 'Content-Type: application/json' \  -d '{"n": 5, "mode": "dry_run"}'

Test /v1/plan (auto)

bash
curl -X POST http://127.0.0.1:8788/v1/plan \  -H 'Content-Type: application/json' \  -d '{"n": 5, "trust_threshold": 0.75, "mode": "auto"}'

Modules

  • trust.py — CognOS confidence formula, action gate, signal extractors
  • trace_store.py — SQLite persistence (write/read/purge)
  • plan.py — Context extraction, trust scoring, system prompt building
  • main.py — FastAPI gateway + middleware
  • mcp_server.py — MCP stdio server (save_session, load_session)

Testing

bash
pytest tests/ -v --cov=src

Documentation

Research Paper

See docs/PAPER.md — "Verified Context Injection: Epistemically Scored Session Memory for Large Language Models"

Status: Independent research — Base76 Research Lab, 2026 Authors: Björn André Wikström (Base76)

Citation

bibtex
@software{wikstrom2026cognos,  author = {Wikström, Björn André},  title = {{CognOS Session Memory}: Verified Context Injection via Epistemic Trust Scoring},  year = {2026},  url = {https://github.com/base76-research-lab/cognos-session-memory}}

License

MIT

Contact

來源:README.md,提交 32fd411

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

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

其他 Memory 整合