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 集成