Skip to main content

Contextual Ambiguity & Trust Scoring — trust intelligence for OSINT sources

Project description

CATS — Contextual Ambiguity & Trust Scoring

Trust intelligence for OSINT sources — not fact-checking, but source reliability over time.

CI Coverage Python 3.11+ License: MIT GDPR EU AI Act


What is CATS?

❌ Fact-checking ✅ CATS
"Is this information true?" "How reliable is this source, in this context, right now?"

CATS analyses the behavioural patterns of a source over time — narrative consistency, sentiment volatility, temporal gaps, and signs of algorithmic manipulation — and returns a transparent, explainable trust score.


Signals

Signal What it measures Method
Coherence Entity/argument consistency across messages spaCy NER + Jaccard (or optional Sentence-BERT) similarity
Volatility Abrupt narrative tone changes TextBlob (or optional BERT) sentiment spike detection
Silence Anomalous temporal gaps in publishing Gap analysis vs. source-type thresholds
Gaming Signs of algorithmic manipulation Repetition + TTR + burst + vocab diversity

Try it in 5 lines (no infrastructure)

No database, no Redis, no API keys — the signal pipeline as a plain library call:

from cats.lite import score

result = score([
    {"timestamp": "2026-01-01T08:00:00Z", "text": "Il governo annuncia un piano economico."},
    {"timestamp": "2026-01-01T12:00:00Z", "text": "I sindacati commentano il piano."},
    {"timestamp": "2026-01-02T09:00:00Z", "text": "Il parlamento discute la legge di bilancio."},
], source_type="news")

print(result["trust_score"], result["band"], result["explanation"]["primary_driver"])

Install with pip install -r requirements.txt (plus make nlp-download for full-fidelity coherence — without it the NER backend degrades to a neutral value). The full API below adds persistence, auditing and GDPR endpoints.

Or try it in the browser: Open In Colab


Quick Start (full deployment)

# 1. Clone and configure
git clone https://github.com/Leapfrog-LSA/CATS-Contextual-Ambiguity-Trust-Scoring.git && cd CATS-Contextual-Ambiguity-Trust-Scoring
cp .env.example .env          # fill in secrets (see .env.example)

# 2. Install
make dev-install              # deps + pre-commit hooks
make nlp-download             # spaCy it_core_news_lg + TextBlob corpora

# 3. Start services and run
make docker-up                # PostgreSQL 16 + Redis 7
make db-migrate               # Alembic migrations
uvicorn cats.api.main:app --reload

# 4. Test
make test

Generate a secure AUDIT_ENCRYPTION_KEY: make generate-key


API Example

curl -s -X POST http://localhost:8000/v1/cats/evaluate \
  -H "Authorization: Bearer $CATS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "source_id": "twitter:example_handle",
    "messages": [
      {"timestamp": "2026-01-01T08:00:00Z", "text": "Governo annuncia piano economico."},
      {"timestamp": "2026-01-01T09:00:00Z", "text": "Protesta dei lavoratori in piazza."},
      {"timestamp": "2026-01-01T10:00:00Z", "text": "Parlamento discute la legge di bilancio."}
    ],
    "context": {"source_type": "social"}
  }' | jq
{
  "trace_id": "550e8400-e29b-41d4-a716-446655440000",
  "score": 68.4,
  "band": "medium_high",
  "requires_review": false,
  "signals": [
    {"name": "coherence",  "value": 71.2, "confidence": 0.3},
    {"name": "volatility", "value": 55.0, "confidence": 0.15},
    {"name": "silence",    "value": 0.0,  "confidence": 0.1},
    {"name": "gaming",     "value": 12.8, "confidence": 0.06}
  ]
}

Trust Score Bands

Score Band Recommended Action
80–100 high Usable for OSINT
60–79 medium_high Cross-validate key claims
40–59 medium Human review recommended
20–39 low Human review required
0–19 very_low Do not use without validation

⚠️ Scores are ordinal rankings, not absolute probabilities (WP 4.3).


Architecture

CATS — 9-phase OSINT evaluation pipeline

Client (HTTPS + Bearer token)
        │
   nginx (TLS 1.3 · rate 30 req/min)
        │
   FastAPI — 9-phase pipeline
   ├─ POST /v1/cats/evaluate
   ├─ POST /v1/cats/batch                ← evaluate up to 50 sources at once
   ├─ GET  /v1/cats/explain/{trace_id}   ← GDPR Art.14/22
   ├─ POST /v1/cats/contest/{trace_id}   ← GDPR Art.22
   ├─ GET  /v1/cats/stats
   └─ GET  /health  /metrics
        │                │
     Redis 7          PostgreSQL 16
  (rate limiting)   (AES-256 audit log)
                    + APScheduler purge

The nginx reverse proxy (TLS, rate limiting, security headers) is configured in deploy/nginx.conf and started by make docker-up.

See docs/architecture.md for full signal and security details.


Documentation

Document Description
docs/api.md Full API reference
docs/architecture.md Signal algorithms, weight matrix, security design
docs/compliance.md GDPR + EU AI Act compliance
docs/eu_ai_act/ EU AI Act conformity scaffold (Annex IV, Art. 9/10)
docs/calibration.md Empirical weight calibration (genetic search)
CHANGELOG.md Version history
CONTRIBUTING.md Development guide
SECURITY.md Vulnerability reporting

Known Limitations (WP 4.1)

  • NLP accuracy ~55–62% (default): spaCy NER + TextBlob; optional BERT sentiment and Sentence-BERT coherence backends are available for higher accuracy (see .env.example)
  • Uncalibrated parameters: thresholds are initial estimates; signal weights can now be empirically tuned with cats.calibration, but band thresholds remain unvalidated
  • Small validation set (July 2026): calibration/validation currently rests on 50 RSS-labelled sources; see calibration findings for the honest numbers (full-dataset concordance 0.78, holdout 0.71) and their caveats
  • Italian-optimised: using it_core_news_lg; other languages degrade accuracy
  • Ordinal scoring only: not suitable as sole basis for autonomous decisions

Roadmap

Version Status Key features
v1.0 spaCy NER · 9-phase pipeline · GDPR API · Docker
v1.1 BERT Italian sentiment · multi-tenant PostgreSQL · batch endpoint · Prometheus /metrics · nginx
v1.2 Sentence-BERT coherence · explainer attribution · weight calibration
v1.3 Signal-polarity fix in aggregation · distant-supervision dataset (MBFC + disinfo networks) · snapshot accumulation
v2.0 2027 AUC-ROC ≥ 0.78 · full EU AI Act Annex IV technical documentation

License

MITtechnical@cats-system.org

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cats_scoring-1.3.0.tar.gz (49.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cats_scoring-1.3.0-py3-none-any.whl (60.5 kB view details)

Uploaded Python 3

File details

Details for the file cats_scoring-1.3.0.tar.gz.

File metadata

  • Download URL: cats_scoring-1.3.0.tar.gz
  • Upload date:
  • Size: 49.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cats_scoring-1.3.0.tar.gz
Algorithm Hash digest
SHA256 45de2ee5a326b009e52a4e10d48695fed95c1f5358c72266ef2e5e89b2b29b7c
MD5 a17a9d0e998937ec2265e7297df3f715
BLAKE2b-256 b5e6aeeae5cdf319afb46b89112f2a83fcc64b24ebf1eb867dd953b8c08b0cc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cats_scoring-1.3.0.tar.gz:

Publisher: release.yml on Leapfrog-LSA/CATS-Contextual-Ambiguity-Trust-Scoring

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cats_scoring-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: cats_scoring-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 60.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cats_scoring-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d04f0f09c1ce5b3090975763f39729a64e430aac89d4ff5a108cdc220ecddbe8
MD5 a190a55cb2560394b038a0db3f3c9e4e
BLAKE2b-256 61cc821fc36297c4dd68389aa68d0d709bf1674956fe795cd26e7afe162b40e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for cats_scoring-1.3.0-py3-none-any.whl:

Publisher: release.yml on Leapfrog-LSA/CATS-Contextual-Ambiguity-Trust-Scoring

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page