RupuContext
Lint the pack. Don't pay twice.
Part of the Rupu family.
Local CLI. Deterministic JSON audit reports. Policy gates for CI. Technical signals — not certification, not token pricing, not another LLM call to "evaluate."
Install
Requires Python 3.9+.
pip install rupucontext
rupucontext --help
Quick start
rupucontext scan fixtures/dup-pack.jsonl
rupucontext scan fixtures/dup-pack.jsonl --fail-on-overlap
rupucontext compare fixtures/corpus.jsonl fixtures/questions.jsonl
Policy gates exit 2 when thresholds are exceeded. Exit 1 is reserved for errors. The JSON audit report (including gate) is written either way.
Commands
| Command | Role |
|---|---|
scan pack.jsonl |
Overlap inside the pack: retrieve∩retrieve, system∩retrieve, user∩retrieve, … |
compare corpus.jsonl questions.jsonl |
RAG leak signal (eval text in the KB) |
scan reports retrieve duplicates in exact_duplicates / near_duplicates, and cross-role overlap in cross_segment (e.g. policy pasted in system and retrieve). compare uses the same segment_text unit as scan.
A JSONL file with one or more pack_id values always emits result.results[] (one element per pack).
Gates are flags, not subcommands:
| Flag | Command | Meaning |
|---|---|---|
--fail-on-overlap |
scan, compare | Exit 2 if any overlap is found |
--max-duplicate-rate |
scan | Exit 2 if exact duplicate_rate exceeds threshold |
--max-near-duplicate-rate |
scan | Exit 2 if near-duplicate record_rate exceeds threshold |
--max-overlap-rate |
compare | Exit 2 if overlap rate exceeds threshold |
duplicate_rate and record_rate use retrieve segments only as the denominator (rate_denominator: retrieve_segments). --near-duplicate-threshold (default 0.85) controls detection of near-duplicates. Policy gates use rates, not the Jaccard cutoff.
Input format (JSONL)
One line per segment. Group by pack_id:
{"pack_id": "req-001", "role": "system", "text": "You are a helpful assistant..."}
{"pack_id": "req-001", "role": "retrieve", "chunk_id": "c42", "text": "Refund policy: items within 30 days..."}
{"pack_id": "req-001", "role": "retrieve", "chunk_id": "c17", "text": "Refund policy: items within 30 days..."}
{"pack_id": "req-001", "role": "user", "text": "Can I return this?"}
Roles: system, retrieve, history, user (extensible). chunk_id optional but recommended for retrieve segments.
Audit report
Reports follow: input → configuration → method → result → (optional) gate.
{
"tool": "rupucontext",
"version": "0.1.0",
"command": "scan",
"input": {
"path": "fixtures/policy-twice.jsonl",
"segments": 3,
"packs": 1
},
"configuration": {
"near_duplicate_threshold": 0.85,
"fail_on_overlap": true
},
"method": {
"unit": "segment_text",
"exact": "text_exact_v1",
"normalized": "text_normalized_v1",
"near": "jaccard_char_shingles_v1"
},
"result": {
"results": [
{
"pack_id": "req-policy",
"segment_count": 3,
"retrieve_segment_count": 1,
"exact_duplicates": {
"pairs": 0,
"segments_flagged": 0,
"duplicate_bytes": 0,
"duplicate_rate": 0.0,
"rate_denominator": "retrieve_segments",
"evidence": []
},
"near_duplicates": {
"pairs": 0,
"segments_flagged": 0,
"record_rate": 0.0,
"rate_denominator": "retrieve_segments",
"evidence": []
},
"cross_segment": [
{"from": "retrieve", "to": "system", "method": "exact", "overlap": 1.0}
]
}
]
},
"gate": {
"passed": false,
"rules": [
{"metric": "overlap_pairs", "actual": 1, "threshold": 0, "passed": false}
]
}
}
fixtures/dup-pack.jsonl (quick start) flags retrieve∩retrieve duplicates; cross_segment may be [] when no cross-role overlap is detected.
Byte counts and overlap ratios — not token estimates. Contract details: docs/AUDIT.md.
Exit codes
| Code | Meaning |
|---|---|
0 |
Success (no policy failure) |
1 |
Usage error — invalid file or schema |
2 |
Policy gate failed |
# .github/workflows/rupucontext.yml
- run: rupucontext scan fixtures/clean-pack.jsonl --fail-on-overlap
What it is not
- Not token pricing (no tiktoken, no USD)
- Not prompt versioning or observability proxy
- Not semantic / paraphrase matching (on purpose)
If you can't export a pack or a trace, you're not the user yet.
Development
git clone https://github.com/EmanuelCorreaAR/rupucontext.git
cd rupucontext
pip install -e ".[dev]"
pytest
Status
0.1.0 — scan + compare; policy gate flags; deterministic audit JSON.
Next: stabilize audit contract toward 1.0.
License
Apache License 2.0
Release files for rupucontext 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rupucontext-0.1.0.tar.gz | 19.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rupucontext-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.8 kB
Release files / rupucontext-0.1.0.tar.gz
| Download URL | rupucontext-0.1.0.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3ab2c66b852f3338a54c24df205b261704d0e180eeaf0fef2fba9ed00d2389f
|
|
BLAKE2b-256 checksum How to use checksums |
0f5dac90bc6a79be3c3d15fed54b0f4d23b8a4b1c85a6699a67b51cdda92cc08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / rupucontext-0.1.0-py3-none-any.whl
| Download URL | rupucontext-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b0bcd6af1eec5b73355f714106232e5649744107ab8759b27485d208f3d488c
|
|
BLAKE2b-256 checksum How to use checksums |
4882ff24b53b634d05f30017b6660aea87290965d67d9301c2791dff82058eef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|