# Netra — Multimodal Vision PPE, Uniform & SOP Compliance Auditor — Complete AI & LLM Reference Corpus (`llms-full.txt`)
- Repository: https://github.com/mohan-n-swamy/netra-public
- Web Discovery URL: https://mohan-n-swamy.github.io/repos/netra-public/
- License: MIT
- Keywords: computer-vision, multimodal-ai, compliance-automation, quality-control, ppe-detection, field-operations, vision-llm, python, open-source
---
## File: `AI-README.md` — AI-README.md
---
repo: "mohan-n-swamy/netra-public"
title: "Netra — Multimodal Vision PPE, Uniform & SOP Compliance Auditor"
license: "MIT"
keywords: [computer-vision, multimodal-ai, compliance-automation, quality-control, ppe-detection, field-operations, vision-llm, python, open-source]
capabilities:
- "Declarative `config/rubric.example.yaml` + `netra/rubric_loader.py` supporting custom cell weights and fair `CANNOT_ASSESS` denominator adjustment."
- "9-cell multimodal vision scoring engine (`netra/appearance.py`, `netra/audit_run.py`) with idempotent SQLite/PostgreSQL persistence."
- "Perceptual hash (`ImageHash`) duplicate/replay detection and strict `MEDIA_URL_ALLOWED_HOSTS` SSRF protection."
- "Built-in token & USD daily budget circuit breaker (`netra/cost.py`) and dry-run evaluation mode."
- "Flask manager review, cohort analytics, and adjudication UI (`frontend/`)."
when_to_use:
- "A production multimodal Vision-Language Model (VLM) compliance auditor and human calibration workbench (Python, Flask, SQLite/PostgreSQL, Pillow/ImageHash) that scores workforce check-in or site inspection photos against a declarative YAML rubric with `PASS` / `FAIL` / `CANNOT_ASSESS` fairness, perceptual-hash replay detection, SSRF media guards, and daily USD spend breakers."
- "Manual QA teams reviewing hundreds of daily uniform, PPE, store-opening, or hygiene photos suffer reviewer fatigue and inconsistent standards — while naive AI scripts unfairly penalize workers when a camera angle crops out footwear or lighting obscures a badge. `netra-public` pairs structured multimodal VLM scoring with 3-state fairness (`CANNOT_ASSESS`), anti-replay perceptual hashing, cost caps, and a manager appeal UI."
inputs_required:
- "OPENAI_API_KEY: Vision LLM API key (or OpenAI-compatible vLLM/Ollama endpoint)"
- "NETRA_VISION_MODEL: Multimodal model identifier used for cell evaluation"
- "NETRA_RUBRIC_YAML: Declarative compliance rubric file"
- "NETRA_DAILY_BUDGET_USD: Hard daily USD ceiling enforced before each VLM call"
- "MEDIA_URL_ALLOWED_HOSTS: Comma-separated HTTPS hostnames permitted for signed image downloads"
- "NETRA_DRY_RUN: Score and persist locally without firing external notifications or write-backs"
quickstart:
- "python3 bin/netra-demo.py # run zero-credential declarative rubric & fair-score demo"
- "pytest -q tests/test_rubric_loader.py tests/test_cost.py tests/test_decisions_thresholds.py"
- "python3 frontend/server.py # launch local review & cohort dashboard"
---
# Netra — Multimodal Vision PPE, Uniform & SOP Compliance Auditor — Machine-Readable Agent Guide
A production multimodal Vision-Language Model (VLM) compliance auditor and human calibration workbench (Python, Flask, SQLite/PostgreSQL, Pillow/ImageHash) that scores workforce check-in or site inspection photos against a declarative YAML rubric with `PASS` / `FAIL` / `CANNOT_ASSESS` fairness, perceptual-hash replay detection, SSRF media guards, and daily USD spend breakers.
Manual QA teams reviewing hundreds of daily uniform, PPE, store-opening, or hygiene photos suffer reviewer fatigue and inconsistent standards — while naive AI scripts unfairly penalize workers when a camera angle crops out footwear or lighting obscures a badge. `netra-public` pairs structured multimodal VLM scoring with 3-state fairness (`CANNOT_ASSESS`), anti-replay perceptual hashing, cost caps, and a manager appeal UI.
Key modules and entry points in this repository:
- `config/rubric.example.yaml & netra/rubric_loader.py`: Declarative cell definitions, weights, and `CANNOT_ASSESS`-aware score calculator
- `netra/config.py & netra/appearance.py`: Submission contract, SSRF host allowlist, and structured multimodal prompt builder
- `netra/cost.py & netra/database.py`: Per-run token/USD accounting breaker and idempotent audit storage
- `netra/eval/backtest.py`: Offline prompt accuracy backtester against human-labeled adjudication sets
- `frontend/server.py`: Flask web workbench for focused failure review, exceptions, and cohort trends
- `bin/netra-demo.py & tests/`: Zero-credential CLI demo and automated unit tests
Every organization-specific value enters through `.env` (copied from `.env.example`) or external adapter files. No source edit is needed to change organization names, endpoints, database URLs, webhook secrets, or thresholds.
When a human asks an AI coding agent to deploy or adapt `netra-public` into their stack:
1. Copy `config/rubric.example.yaml` to `config/rubric.yaml` and define your 4-8 visual compliance checks and weights.
2. Set `MEDIA_URL_ALLOWED_HOSTS` in `.env` to your S3/GCS/CDN domain.
3. Run in `NETRA_DRY_RUN=true` mode alongside human reviewers for 50 submissions to verify >90% cell agreement before automating alerts.
- Product Requirements: `docs/PRD.md`
- Working-Backwards PR-FAQ: `docs/PR-FAQ.md`
- High-Level Architecture: `docs/HLD.md`
- Low-Level Interfaces & Runbook: `docs/LLD.md`
- Coding Agent Rules: `AGENTS.md`
---
## File: `.env.example` — Environment Contract (.env.example)
```ini
# netra-public — Multimodal Vision Uniform, PPE & SOP Compliance Auditor
OPENAI_API_KEY=replace_with_vision_llm_key
NETRA_VISION_MODEL=gpt-4o
NETRA_RUBRIC_YAML=./config/rubric.example.yaml
NETRA_DB_PATH=./netra_audit.sqlite3
NETRA_DAILY_BUDGET_USD=15.00
MEDIA_URL_ALLOWED_HOSTS=media.ops.example.org
NETRA_DRY_RUN=true
```
---
## File: `AGENTS.md` — AGENTS.md
# AGENTS.md — Netra — Multimodal Vision PPE, Uniform & SOP Compliance Auditor
Read this file first before modifying `netra-public`.
## Purpose
A production multimodal Vision-Language Model (VLM) compliance auditor and human calibration workbench (Python, Flask, SQLite/PostgreSQL, Pillow/ImageHash) that scores workforce check-in or site inspection photos against a declarative YAML rubric with `PASS` / `FAIL` / `CANNOT_ASSESS` fairness, perceptual-hash replay detection, SSRF media guards, and daily USD spend breakers.
## Commands
```bash
python3 bin/netra-demo.py # run zero-credential declarative rubric & fair-score demo
pytest -q tests/test_rubric_loader.py tests/test_cost.py tests/test_decisions_thresholds.py
python3 frontend/server.py # launch local review & cohort dashboard
```
## Module Map
- `config/rubric.example.yaml & netra/rubric_loader.py`: Declarative cell definitions, weights, and `CANNOT_ASSESS`-aware score calculator
- `netra/config.py & netra/appearance.py`: Submission contract, SSRF host allowlist, and structured multimodal prompt builder
- `netra/cost.py & netra/database.py`: Per-run token/USD accounting breaker and idempotent audit storage
- `netra/eval/backtest.py`: Offline prompt accuracy backtester against human-labeled adjudication sets
- `frontend/server.py`: Flask web workbench for focused failure review, exceptions, and cohort trends
- `bin/netra-demo.py & tests/`: Zero-credential CLI demo and automated unit tests
## Invariants
1. Keep all organization names, credentials, domains, and thresholds in `.env` or external config files. Never hardcode company names, host IPs, or secrets in source files.
2. Deterministic business logic belongs in code and lookup tables, not inside LLM prompts.
3. Update `docs/HLD.md`, `docs/LLD.md`, and `.env.example` in the same commit whenever an interface or environment variable changes.
4. Run the repository smoke check and secret scan before opening a pull request.
---
## File: `docs/PRD.md` — Product Requirements Document (docs/PRD.md)
# Product Requirements Document — Netra — Multimodal Vision PPE, Uniform & SOP Compliance Auditor
A production multimodal Vision-Language Model (VLM) compliance auditor and human calibration workbench (Python, Flask, SQLite/PostgreSQL, Pillow/ImageHash) that scores workforce check-in or site inspection photos against a declarative YAML rubric with `PASS` / `FAIL` / `CANNOT_ASSESS` fairness, perceptual-hash replay detection, SSRF media guards, and daily USD spend breakers.
## 1. Problem
Manual QA teams reviewing hundreds of daily uniform, PPE, store-opening, or hygiene photos suffer reviewer fatigue and inconsistent standards — while naive AI scripts unfairly penalize workers when a camera angle crops out footwear or lighting obscures a badge. `netra-public` pairs structured multimodal VLM scoring with 3-state fairness (`CANNOT_ASSESS`), anti-replay perceptual hashing, cost caps, and a manager appeal UI.
## 2. Users and Jobs-to-be-Done
| Persona | Job-to-be-Done |
|---|---|
| Safety / Quality / Field Operations Lead | Audit 100% of daily shift check-in or store-readiness photos consistently at <$0.01 per submission. |
| Site Supervisor / Reviewer | Inspect flagged failures and worker appeals in a fast side-by-side web UI (`frontend/server.py`). |
| ML / Platform Engineer | Swap rubrics via `config/rubric.example.yaml` and benchmark VLM prompts against human ground-truth sheets (`netra/eval/backtest.py`). |
## 3. Core Capabilities
- Declarative `config/rubric.example.yaml` + `netra/rubric_loader.py` supporting custom cell weights and fair `CANNOT_ASSESS` denominator adjustment.
- 9-cell multimodal vision scoring engine (`netra/appearance.py`, `netra/audit_run.py`) with idempotent SQLite/PostgreSQL persistence.
- Perceptual hash (`ImageHash`) duplicate/replay detection and strict `MEDIA_URL_ALLOWED_HOSTS` SSRF protection.
- Built-in token & USD daily budget circuit breaker (`netra/cost.py`) and dry-run evaluation mode.
- Flask manager review, cohort analytics, and adjudication UI (`frontend/`).
## 4. Configurable Inputs
Adopters configure the system for their own organization without editing core application logic:
| Variable | Default / Example | Purpose |
|---|---|---|
| `OPENAI_API_KEY` | `sk-...` | Vision LLM API key (or OpenAI-compatible vLLM/Ollama endpoint) |
| `NETRA_VISION_MODEL` | `gpt-4o` | Multimodal model identifier used for cell evaluation |
| `NETRA_RUBRIC_YAML` | `./config/rubric.example.yaml` | Declarative compliance rubric file |
| `NETRA_DAILY_BUDGET_USD` | `15.00` | Hard daily USD ceiling enforced before each VLM call |
| `MEDIA_URL_ALLOWED_HOSTS` | `media.ops.example.org` | Comma-separated HTTPS hostnames permitted for signed image downloads |
| `NETRA_DRY_RUN` | `true` | Score and persist locally without firing external notifications or write-backs |
## 5. Phasing and Stability Exit Criteria
1. **Phase 1 (Local Synthetic Run):** Clone the repository, copy `.env.example` to `.env`, and run the quickstart commands against synthetic seed data. Exit criterion: smoke checks pass with zero external credentials.
2. **Phase 2 (Read-Only Shadow Wiring):** Connect read-only credentials or webhook listeners in shadow/dry-run mode. Exit criterion: 100 consecutive events or queries reconcile cleanly against source records.
3. **Phase 3 (Production Cutover):** Enable live writes, alerts, or routing behind bounded retry and idempotency guards.
## 6. Non-Goals
- Shipping organization-specific business rules hardcoded in application source.
- Storing credentials, personal customer records, or tenant URLs inside version control.
- Replacing deterministic validation or arithmetic with unconstrained model prompts.
---
## File: `docs/PR-FAQ.md` — Working-Backwards PR-FAQ (docs/PR-FAQ.md)
# Working-Backwards PR-FAQ — Netra — Multimodal Vision PPE, Uniform & SOP Compliance Auditor
**Release Summary:** `netra-public` gives engineering and operations teams a self-hosted, open-source implementation of Netra — Multimodal Vision PPE, Uniform & SOP Compliance Auditor that configures via `.env` and runs on standard infrastructure in minutes.
## Press Release
Operations and engineering teams often rebuild the same internal workflows behind closed doors or pay per-seat SaaS markups for rigid tools that cannot match their field reality. `netra-public` open-sources a battle-tested implementation of Netra — Multimodal Vision PPE, Uniform & SOP Compliance Auditor, stripped of all single-company assumptions and packaged with clear adapter boundaries, synthetic demo data, and machine-readable agent documentation.
Any team can fork `netra-public`, supply their own `.env` inputs and taxonomy config, and deploy locally or in production with Docker, Python, or Node. AI coding assistants such as Claude Code, Codex, and Cursor can read `AI-README.md` and `llms.txt` to wire custom ERP, CRM, or warehouse adapters in a single session.
## External Adopter FAQ
**Q1: How long does it take to run locally after cloning?**
Under five minutes. Copy `.env.example` to `.env` and run the quickstart commands in `README.md`. Synthetic fixtures let you inspect the workflow before connecting live credentials.
**Q2: Do I need to rewrite source files to use my own company name, channels, or rules?**
No. Organization names, endpoints, thresholds, and credentials sit in `.env` and declarative config files. External system specifics live behind narrow adapter modules documented in `docs/LLD.md`.
**Q3: What license governs this repository?**
MIT License. You can fork, modify, self-host, and use it commercially without restriction.
## Internal Engineering & Security FAQ
**Q4: How do we prevent tenant or employer data from ever entering a public fork?**
The repository starts from a clean git history, excludes raw exports and binary dumps, validates every commit through `gitleaks`, and ships only synthetic fixtures.
**Q5: What happens when an upstream API or model provider is slow or unavailable?**
Inbound webhooks persist raw payloads before processing, outbound writes carry idempotency keys with bounded exponential backoff, and model-backed paths fail open to deterministic rules or explicit human queues.
---
## File: `docs/HLD.md` — High-Level Design (docs/HLD.md)
# High-Level Design (HLD) — Netra — Multimodal Vision PPE, Uniform & SOP Compliance Auditor
A production multimodal Vision-Language Model (VLM) compliance auditor and human calibration workbench (Python, Flask, SQLite/PostgreSQL, Pillow/ImageHash) that scores workforce check-in or site inspection photos against a declarative YAML rubric with `PASS` / `FAIL` / `CANNOT_ASSESS` fairness, perceptual-hash replay detection, SSRF media guards, and daily USD spend breakers.
## 1. System Topology
```mermaid
flowchart LR
Photos["Shift / Site Photos"] --> Guard["SSRF Host Allowlist + pHash Check"]
Guard --> Budget["Daily USD Spend Breaker"]
Budget --> VLM["Multimodal VLM Scorer"]
Rubric["config/rubric.example.yaml"] --> VLM
VLM -->|"PASS / FAIL / CANNOT_ASSESS"| DB["SQLite / PostgreSQL Audit Store"]
DB --> UI["Flask Review & Calibration UI"]
```
## 2. Architectural Decisions and Rejected Alternatives
| Decision | Why It Holds | Rejected Alternative |
|---|---|---|
| Three-state `PASS` / `FAIL` / `CANNOT_ASSESS` verdicts | Prevents cropped or dim photos from generating false-positive worker penalties; tracks `CANNOT_ASSESS` separately for camera coaching. | Binary pass/fail forcing guesses on occluded items |
| Declarative YAML rubric + fixed JSON output contract | Lets warehouses (hard hat/vest/boots), kitchens (hairnet/gloves/apron), and field fleets share the exact same scorer and UI. | Rewriting prompts and DB columns per industry |
| Pre-request USD spend breaker (`netra/cost.py`) | Caps worst-case daily API spend deterministically even during retry storms or batch backfills. | Relying solely on monthly cloud billing alerts |
## 3. Data Flow and Failure Boundaries
1. **Configuration Boundary:** Startup validates `.env` variables and declarative config schemas before accepting traffic or running scheduled jobs.
2. **Adapter Boundary:** External services (databases, chat channels, HRMS, warehouses, or LLM providers) sit behind explicit adapter modules so failures stay isolated and testable with local mocks.
3. **Observability and Audit:** State transitions and job executions emit structured logs and deterministic status records rather than mutating state silently.
## 4. Scaling Notes
- **1x to 10x load:** Single-node Docker Compose or process supervisor handles standard team workloads with indexed database queries and bounded worker concurrency.
- **First bottleneck at 10x+:** High-frequency webhook or batch ingestion queues; mitigate by separating the stateless HTTP receiver from background worker processes sharing Redis or PostgreSQL locks.
---
## File: `docs/LLD.md` — Low-Level Design & Runbook (docs/LLD.md)
# Low-Level Design (LLD) & Operations Runbook — Netra — Multimodal Vision PPE, Uniform & SOP Compliance Auditor
This document defines the module responsibilities, environment contract, and operational procedures for `netra-public`.
## 1. Module and File Inventory
| Path | Responsibility |
|---|---|
| `config/rubric.example.yaml & netra/rubric_loader.py` | Declarative cell definitions, weights, and `CANNOT_ASSESS`-aware score calculator |
| `netra/config.py & netra/appearance.py` | Submission contract, SSRF host allowlist, and structured multimodal prompt builder |
| `netra/cost.py & netra/database.py` | Per-run token/USD accounting breaker and idempotent audit storage |
| `netra/eval/backtest.py` | Offline prompt accuracy backtester against human-labeled adjudication sets |
| `frontend/server.py` | Flask web workbench for focused failure review, exceptions, and cohort trends |
| `bin/netra-demo.py & tests/` | Zero-credential CLI demo and automated unit tests |
## 2. Environment Variable Contract
| Variable | Default / Example | Required | Description |
|---|---|---|---|
| `OPENAI_API_KEY` | `sk-...` | Yes | Vision LLM API key (or OpenAI-compatible vLLM/Ollama endpoint) |
| `NETRA_VISION_MODEL` | `gpt-4o` | Yes | Multimodal model identifier used for cell evaluation |
| `NETRA_RUBRIC_YAML` | `./config/rubric.example.yaml` | Yes | Declarative compliance rubric file |
| `NETRA_DAILY_BUDGET_USD` | `15.00` | Yes | Hard daily USD ceiling enforced before each VLM call |
| `MEDIA_URL_ALLOWED_HOSTS` | `media.ops.example.org` | Yes | Comma-separated HTTPS hostnames permitted for signed image downloads |
| `NETRA_DRY_RUN` | `true` | Yes | Score and persist locally without firing external notifications or write-backs |
## 3. Extension Recipe
1. Copy `config/rubric.example.yaml` to `config/rubric.yaml` and define your 4-8 visual compliance checks and weights.
2. Set `MEDIA_URL_ALLOWED_HOSTS` in `.env` to your S3/GCS/CDN domain.
3. Run in `NETRA_DRY_RUN=true` mode alongside human reviewers for 50 submissions to verify >90% cell agreement before automating alerts.
## 4. Operations Runbook
### 1. Run offline rubric & cost-guard unit tests
```bash
pytest -q tests/test_rubric_loader.py tests/test_cost.py tests/test_decisions_thresholds.py
```
### 2. Execute dry-run audit batch without downstream side effects
```bash
NETRA_DRY_RUN=true python3 -m netra.audit_run
```
### 3. Backtest rubric changes against labeled fixture set
```bash
python3 -m netra.eval.backtest
```
---
## File: `docs/RESEARCH-2026.md` — 2026 Research & Landscape Notes (docs/RESEARCH-2026.md)
# 2026 Multimodal VLM SOP & PPE Compliance Auditing Research
Traditional YOLO bounding-box detectors answer *"is a helmet in the frame?"* but fail on contextual SOP nuances (*"is the ID badge worn visibly on the collar, uniform unwrinkled, and nitrile gloves intact?"*). In 2026, multimodal Vision-Language Models (`GPT-4o`, `Gemini 2.5 Pro`, local `Qwen2.5-VL`) solve fine-grained visual SOP rubrics at pennies per audit — provided four production guardrails surround the model:
1. **3-Valued Scoring (`PASS` / `FAIL` / `CANNOT_ASSESS`):** Occluded or blurry regions must never default to a punitive `FAIL`.
2. **Perceptual Hashing (`ImageHash`):** Prevents photo replay fraud across shifts.
3. **Declarative YAML Rubrics (`config/rubric.example.yaml`):** Decouples industry-specific PPE/grooming/kitchen criteria from scoring and calibration infrastructure.
4. **Human-in-the-Loop Calibration (`netra/eval/` + `frontend/`):** Measures cell-by-cell agreement against human QA adjudicators before enabling automated actions.