Cognos Session Memory

io.github.base76-research-labPublished by GitHub account base76-research-labv0.1.0Updated Oct 24, 2026

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

The publisher's own server: Memory.fit

VerifiedSTDIODesktop onlyKnowledge & MemoryAI & ML

Overview

AI-generated overview

A local MCP server that saves session summaries to SQLite, trust-scores them with a CognOS formula, and reloads verified context in later conversations.

What you can do
Save a structured session summary, optionally tagged with a project, and have it trust-scored and persisted to a local SQLite trace database. Load the last verified context, with an optional trust threshold, so a new conversation can start from prior decisions and open questions. Context is scored with a confidence formula and either injected, flagged for review, or withheld depending on the resulting risk level.
When to use it
Useful when you want continuity across separate conversations with an AI assistant and prefer scored, auditable context over plain vector recall. Suited to long-running research or engineering work where decisions and open questions should carry over between sessions.
Requirements
Runs as a local Python process installed from the PyPI package, typically launched with python3. Needs a writable SQLite database path, configurable via the COGNOS_TRACE_DB environment variable (default data/traces.sqlite3). No authentication is declared.
Before you install
Session summaries are written to a local SQLite file, so anything captured there persists on disk and should be reviewed before saving sensitive material. The README also describes a force mode that injects context regardless of trust score, which bypasses the review gate.

Installation

In SourceWeft

  1. Open Cognos Session Memory in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

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

Source: README.md at commit 32fd411

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

1
  1. v0.1.0LatestSep 16, 2026

Score

40% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts

    Declare a license in the repository or the registry entry.

Other Memory integrations