Skip to main content
Glama
README.md
![BriefGate — Turn Client Briefs into Verifiable Delivery Contracts](assets/social-preview.png)

> **Live Zero-Install Browser Tools (Safe-Zone Checker · Subtitle & FTC QA · US Matrix Generator):** https://waterdolphinkiller.github.io/briefgate/

# BriefGate

**The Creative Delivery Contract & Verification Platform**  
*Turn client briefs into verifiable delivery contracts — local-first, evidence-backed, and open source.*

> A client gives you a brief. Your team delivers a folder of creative assets. **BriefGate verifies that the two actually match.**

---


https://github.com/user-attachments/assets/cddbbf50-c225-4c52-95d4-1c60595a1495


## Why BriefGate?

Traditional media QC tools check whether a single file meets a technical spec, and project trackers track tasks — yet neither proves that a campaign delivery folder actually satisfies the active client brief.

BriefGate bridges that gap with three core systems:

1. **Brief → Executable Manifest (CDM v1.0):** Parses client PDF, DOCX, XLSX, CSV, TXT, and Email briefs into traceable **Requirement Evidence** (exact file, page, paragraph, excerpt, confidence, and Draft/Confirmed status) and compiles a schema-validated **Creative Delivery Manifest**.
2. **Cross-Asset Consistency + Requirement Change Impact:** Validates all 5 QC layers across an entire campaign — catching missing deliverables, CMYK/VFR/black-frame/loudness defects, subtitle drift, cross-asset price/promo-code mismatches, and pinpointing exactly which assets must be re-exported when a client updates the brief (e.g., 9:16 max duration tightened from `15s` to `12s`).
3. **Evidence-Based Delivery Receipt:** Binds the exact Brief version, Manifest SHA-256, rule-pack versions, asset SHA-256 hashes, 6-state QC results, and human approval records into a canonical `delivery-receipt.json` plus printable HTML and PDF certificates.

---

## Who It's For

- **Performance Marketing Agencies** shipping multi-market, multi-aspect-ratio Meta, TikTok, YouTube, and Google Ads creatives.
- **Video Production Studios** managing master cuts, cutdowns, clean/captioned variants, and subtitle sync.
- **Creative Content Studios & Marketing Ops** enforcing consistent pricing, promo codes, disclaimers, and file naming across channels.

---

## 30-Second Quick Start

```bash
# 1. Install BriefGate (requires Python 3.10+ and FFmpeg)
pip install -e ".[ocr]"

# 2. Initialize a campaign workspace
briefgate init ./my-campaign

# 3. Parse a client brief into traceable Requirement Evidence & draft Manifest
briefgate brief parse examples/summer-campaign/client-brief-v1.txt -o draft-manifest.yaml

# 4. Validate a Creative Delivery Manifest (CDM v1.0)
briefgate manifest validate examples/summer-campaign/campaign-v1.yaml

# 5. Run the 5-Layer QC Engine against a delivery folder & export Receipt + PDF
briefgate check ./my-campaign/delivery --manifest examples/summer-campaign/campaign-v1.yaml --export-dir ./reports

# 6. Analyze Requirement Change Impact (Brief v1 -> Brief v2)
briefgate impact --old examples/summer-campaign/campaign-v1.yaml --new examples/summer-campaign/campaign-v2.yaml --delivery ./my-campaign/delivery

# 7. Launch the Local-First 6-Screen Web Dashboard
briefgate serve --port 8420
```

---

## Supported Files & 5-Layer QC Engine

| Layer | Scope | Examples |
|---|---|---|
| **Layer 1: File Integrity** | All files | Corruption/decode test, 0-byte, MIME vs extension mismatch, duplicate SHA-256, executable safety |
| **Layer 2: Technical Compliance** | Video, Image, Audio, Subtitle, PDF/DOCX/XLSX, HTML5 | Resolution, aspect ratio, codec/container, duration, FPS, VFR vs CFR, rotation tag, black frames, freeze frames, EBU R128 LUFS/True Peak/silence, CMYK vs RGB, SRT/VTT timeline, HTML5 `clickTag` & KB budget |
| **Layer 3: Content Compliance** | Images, Video Keyframes, Subtitles | Local Tesseract OCR, required/banned copy, QR code decode, human-gated brand logo review |
| **Layer 4: Cross-Asset Consistency** | Campaign-wide | Price, promo code, campaign dates, landing URLs, disclaimers, subtitle-to-video duration sync |
| **Layer 5: Delivery Contract** | Manifest & Slots | Conditional delivery matrix expansion, missing slots, unassigned files, naming convention templates, confidence-gated slot matching |

Every check emits one of **6 explicit states** — `PASS`, `FAIL`, `WARNING`, `REVIEW_REQUIRED`, `NOT_APPLICABLE`, or `BLOCKED_UNKNOWN` — and AI/OCR checks never silently auto-PASS without human confirmation.

---

## Local-First Privacy

Raw unreleased video and creative assets are large and confidential. BriefGate processes **100% of media inspection, hashing, OCR, FFmpeg/FFprobe analysis, and SQLite evidence storage locally on your machine**. No raw files are uploaded to external servers.

---

## Included Platform Rule Packs

- `meta/instagram-reels`
- `tiktok/in-feed`
- `youtube/video-ads`
- `google-ads/pmax`
- `broadcast/atsc-a85-us` (US NTSC 23.976–59.94 fps, -24 LKFS, -2.0 dBTP)
- `broadcast/ebu-r128`
- `custom-client/summer-promo`

---

## Running the Test Suite

```bash
python -m unittest discover -s tests -p "test_*.py" -v
```


---

## v2.0 Engine Architecture & Verified Benchmarks

BriefGate v2.0 upgrades the core verification engine for high-volume agency deliveries:

- **Single-Pass FFmpeg Filtergraph (`media_probe.py`)**: Combines `blackdetect`, `freezedetect`, `ebur128`, and `silencedetect` into **1** decode pass per video (shared across Video + Audio validators).
- **Bounded Multi-Core Worker Pool + SQLite WAL Two-Tier Cache (`cache.py`)**: L1 `(path, mtime_ns, size)` instant hits + L2 `SHA-256` deduplication across renamed/copied exports.
- **Unified Declarative Rule Evaluator (`rule_evaluator.py`)**: Single source of truth shared by both the 5-Layer QC Engine and Requirement Change Impact Analysis, plus `custom_rules` expressions.
- **5-Pillar Extensibility Interfaces (`interfaces.py`)**: Decoupled `StorageBackend`, `AIProvider`, `EntityExtractor` (EN/MS/ZH), `RemediationProvider`, `EventBus`/`WebhookSink`, plus non-blocking async QC jobs with SSE progress streaming (`/api/qc/jobs/{id}/stream`).

### 50-Asset Stress Benchmark (16 unique 10s videos + 30 1080p PNGs + 4 SRTs, 2 vCPUs)

| Mode | Wall Time | Speedup vs v1.0 | FAIL Count (Zero Regression) |
|---|---:|---:|---:|
| **v1.0 Baseline** (Serial + 4-pass FFmpeg + no cache) | `28.78 s` | `1.0×` | `16` |
| **v2.0 Cold Run** (Single-pass FFmpeg + 2-core pool, unique SHA-256) | `9.86 s` | **`2.92×`** *(scales with cores; `20.87×` on duplicate exports)* | `16` |
| **v2.0 Warm Incremental Run** (1 file modified, 49 cached via SQLite WAL) | `0.018 s` | **`1,586×`** | `16` |

Reproduce locally:
```bash
PYTHONPATH=. python3 benchmarks/bench_v1_vs_v2.py
```


---

## v3.0 Competitive Differentiators (AI-Native & Zero-Upload)

1. **Native MCP Server (`briefgate mcp`)**: Zero-dependency JSON-RPC 2.0 Model Context Protocol server exposing 6 tools (`briefgate_parse_brief`, `briefgate_validate_manifest`, `briefgate_run_qc`, `briefgate_analyze_impact`, `briefgate_remediate_assets`, `briefgate_export_review_bundle`) so Claude Code, Cursor, and AI creative agents can self-verify deliverables before handoff.
2. **Visual Safe-Zone Overlays (`visual_evidence.py`)**: Automatically composites translucent platform UI obstruction masks (TikTok, Instagram Reels, YouTube Shorts, or custom `safe_zone`) onto video keyframes and image thumbnails.
3. **Zero-Upload Interactive Client Review Bundle (`briefgate review-bundle`)**: Exports a single offline HTML review file with embedded safe-zone previews, 6-state QC evidence, per-asset Approve/Reject/Exception buttons, and tamper-evident SHA-256 `client-approval-receipt.json` export — zero cloud storage fees, zero client login.
4. **Reusable GitHub Action (`action.yml`) & Slack/PR Reporter (`briefgate ci-report`)**: Drop `uses: waterdolphinkiller/briefgate@v3` into any repository to gate creative drops and post Requirement Change Impact summaries directly to Pull Requests and Slack.
5. **Official Ad Spec Change Tracker (`.github/workflows/spec-tracker.yml`)**: Weekly automated drift detection across official platform spec URLs that opens a human-review GitHub Issue whenever Meta/TikTok/YouTube/Google specs change (never silently auto-mutating active contracts).

---

## License

Released under the [MIT License](LICENSE). Note: FFmpeg is invoked as an external system binary and is not bundled in this repository; review FFmpeg's LGPL/GPL licensing terms before redistributing FFmpeg binaries.