Tacit Context Gap Detection for Handover-oriented RAG
Project description
HandoverGap RAG
日本語 | Repository version: README.ja.md
HandoverGap RAG detects tacit context that is missing from otherwise correct organizational memories.
Correct memories are not always transferable.
A normal RAG system may retrieve:
For Company A, use CSV for this release. The API will come in the next phase.
The statement can be correct while still being unsafe for a customer-support successor. They may not know:
- whether the customer was informed;
- what “this release” covers;
- what support is authorized to promise;
- what fallback or escalation path to use.
HandoverGap performs role-conditioned slot checks, blocks unsafe transfer, and generates clarification questions.
Quickstart
pip install handovergap
handovergap demo
handovergap detect --scenario S001 --role CS
handovergap evaluate --compare
No TiDB account, OpenAI key, or external dataset is required.
Demo
Install the optional Streamlit UI:
pip install "handovergap[demo]"
handovergap serve
The demo defaults to Japanese and includes an English language switch. It compares:
naive_rag: answers directly;hybrid_rag: adds related evidence;handovergap: withholds unsafe answers and asks questions.
Evaluation
handovergap evaluate --compare runs the bundled synthetic HandoverGapBench mini dataset.
| Method | Tacit Gap Recall | Unsafe Transfer Prevention | Question Coverage | Safe Transfer Allowance | Blocked Precision |
|---|---|---|---|---|---|
| naive_rag | 0.00 | 0.00 | 0.00 | 1.00 | 0.00 |
| hybrid_rag | 0.26 | 0.59 | 0.26 | 1.00 | 1.00 |
| handovergap | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 |
These are deterministic results from the bundled 20-scenario dataset. The benchmark is synthetic and intentionally small; it demonstrates reproducible behavior rather than production accuracy.
For a small unknown holdout set with adjudicated synthetic reviewer labels and slot-filling stress profiles:
handovergap evaluate --dataset holdout --stress-filling
| Method | Tacit Gap Recall | Unsafe Transfer Prevention | Question Coverage | Safe Transfer Allowance | Blocked Precision |
|---|---|---|---|---|---|
| handovergap/provided | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 |
| handovergap/conservative | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 |
| handovergap/optimistic | 0.64 | 1.00 | 0.64 | 1.00 | 1.00 |
The optimistic profile simulates an LLM over-filling ambiguous slots. It shows a real failure mode: recall drops even though unsafe transfers are still blocked in this holdout.
With optional live OpenAI semantic slot filling:
python harness/validation/openai_slot_filling_check.py --dataset holdout --persist-tidb
Observed with gpt-4.1-mini: tacit gap recall 0.82, unsafe transfer prevention 1.00, safe transfer allowance 1.00, blocked precision 1.00. The detailed per-scenario output is saved to article/openai_slot_filling_results.json.
Optional TiDB Store
pip install "handovergap[tidb]"
handovergap schema --dialect tidb
from handovergap import TiDBStore
store = TiDBStore("mysql+pymysql://user:password@host:4000/handovergap")
store.create_schema()
The packaged schema models source evidence, memories, role requirements, slot-fill attempts, context gaps, clarification questions, transfer assessments, and evaluation runs. Live persistence methods are available for slot-fill attempts, context gaps, transfer assessments, and evaluation runs.
Live TiDB Validation
After creating a TiDB Cloud cluster, open Connect, choose a public Python/SQLAlchemy-compatible connection, generate or reset the password, and export the connection values locally:
export TIDB_HOST="..."
export TIDB_PORT="4000"
export TIDB_USER="..."
export TIDB_PASSWORD="..."
export TIDB_DB_NAME="test"
export TIDB_CA_PATH="/path/to/ca-certificates.crt"
Then run:
python harness/validation/tidb_live_check.py --create-schema
The check creates the packaged schema if needed, writes one synthetic memory, persists a slot-fill attempt, a context gap, a transfer assessment, and the holdout stress evaluation runs, then prints row counts as JSON. Do not commit .env files or TiDB credentials.
Python API
from handovergap import HandoverGapDetector, InMemoryStore
store = InMemoryStore.from_builtin_dataset()
detector = HandoverGapDetector(store)
result = detector.detect(scenario_id="S001", successor_role="CS")
print(result.transferability_status)
print(result.gaps)
print(result.questions)
Development
python3 -m venv .venv
.venv/bin/python -m pip install -e ".[dev,demo]"
.venv/bin/pytest
Limitations
- The bundled detector and baselines are deterministic rules, not learned models.
- HandoverGapBench mini and holdout contain synthetic scenarios.
- Slot-filling stress profiles simulate LLM variance; they are not a replacement for a live LLM evaluation.
- Live OpenAI slot filling is optional and not required for first-run usage.
- Semantic equivalence scoring for generated questions is not implemented in the MVP.
- Live TiDB integration requires the optional
tidbextra and a configured database.
License
MIT
日本語
HandoverGap RAGは、正しい業務記憶に不足している暗黙前提を、引き継ぎ先の役割ごとに検出します。
正しい記憶でも、引き継げるとは限らない。
pip install handovergap
handovergap demo
handovergap detect --scenario S001 --role CS
handovergap evaluate --compare
Streamlitデモは日本語がデフォルトで、英語へ切り替えられます。
pip install "handovergap[demo]"
handovergap serve
詳細な日本語ドキュメントはREADME.ja.mdを参照してください。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file handovergap-0.1.0.tar.gz.
File metadata
- Download URL: handovergap-0.1.0.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76f753e8738cd36a442b90c325500a7ddab76e83860d1f963affbb9e1fb53a0c
|
|
| MD5 |
25e85f13925fe22bae5ab4ec09b5a7b2
|
|
| BLAKE2b-256 |
4be246d480597d262b490b89e1db084e62109050adfbd01310108ddfefa08494
|
File details
Details for the file handovergap-0.1.0-py3-none-any.whl.
File metadata
- Download URL: handovergap-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba9546c4868f80384fc68dadf657030b33feac7808e410715e4cd0e1eff4122e
|
|
| MD5 |
ceb4cc38c7a9e6858a1f9e1f8685dc26
|
|
| BLAKE2b-256 |
a59b43ed097334adfacf3b4e4b310008e4d511b8dd3d7040ebe86bca6affdaf6
|