Campaign Asset Handoff Auditor (CAHI)

n8n + Python + Claude Vision 64/64 Tests · 7.92s ~850 Python LOC Production · Animoart

A dual-runtime n8n and Python delivery engine that audits commercial asset handoffs, enforcing a strict 0.20 AI score contribution cap and a ≥ 0.76 delivery threshold to eliminate pre-launch delivery panics.


Campaign Handoff Failures

Campaign asset handoffs between creative agencies and media buyers are a known failure point. A package of 40 ad creatives ships to the media buyer. The brief specified: “16:9 at 1920x1080, H.264, max 30s, broadcast safe, caption file required.”

What actually arrives: 3 files at wrong aspect ratios, 2 videos over 30 seconds, and 1 missing caption track.

The media buyer’s ad ops team catches this at upload time, shortly before the global campaign goes live. This leads to emergency re-renders and potential penalty fees for the creative agency.


Separating Deterministic Checks from AI Inspection

Most handoff rejections come from deterministic checks like missing metadata or wrong resolution. Codec, dimensions, duration, bitrate, and file hashes can be verified locally. AI models shouldn't be used to ask: “Is this video 1080p?”

The second rule addresses AI confidence. If an AI vision model is asked which render is final, its score contribution is capped at 0.20.

The delivery threshold is ≥ 0.76. An asset needs to pass both deterministic metadata checks and human review to ship — AI confidence alone isn't enough.

The system separates deterministic file science from bounded AI visual inspection, ending with an n8n human sign-off form for borderline edge cases before files are staged.


Deterministic Pre-Flight and Bounded Vision

CAHI combines an n8n orchestration workflow with Python CLI workers. It mounts the project directory in read-only mode, extracts SHA-256 and DCT perceptual hashes to eliminate duplicate renders locally, and normalizes messy filename version stems (_v2, _final_FINAL). It invokes Claude 3.5 Sonnet on ambiguous clusters under a 0.20 contribution cap, verifies the ≥ 0.76 score rule, and stages verified files into organized output folders with a hash-based delivery receipt.

This process reduces media buyer rejections and emergency re-renders before launch.

SAMPLE OUTPUT · delivery_receipt.jsonSHA-256 checksum
{
  "campaign": "SS26_Global_Launch",
  "assets_audited": 184,
  "exact_duplicates_purged": 42,
  "spec_failures_blocked": 6,
  "delivered_count": 64,
  "delivery_threshold_min": 0.76,
  "max_ai_score_contribution": 0.198,
  "manifest_sha256": "8f4e2ba4..."
}
04 — The Architecture

6-Stage Dual-Runtime Delivery Engine

n8n coordinates orchestration while Python CLI workers execute byte hashing and stream probing. AI confidence contributes up to 0.198 points, so passing the threshold requires deterministic metadata checks and human sign-off. Click any stage card to inspect its implementation, input state, and output state.

Read-Only Mount ($0.00) → SHA-256 + DCT pHash ($0.00) → Version Stemming ($0.00) → Claude Vision (0.20 cap, ~$0.01) → Score & Sign-off (≥ 0.76) → Copy-Only Bundle ($0.00)

CA
creative_asset_handoff.workflow:cahi_engine
6 Hybrid Stages•n8n Orchestrator•Python SHA-256 Worker•0.198 AI Invariant
Swipe horizontally · Tap stage to inspect below ↓
Stage 01 · TriggerRead-Only Mount
Manual Ingestion
n8n.manualTrigger
Folder Mounted
Stage 02 · ScienceSHA-256 + DCT
File Science
phase_file_science()
Deterministic
Stage 03 · StemRegex Normalize
Stem Normalizer
normalize_stems()
Version Clustered
Stage 04 · VisionClaude 3.5 (0.20)
Bounded Vision
ai_vision_subflow
Max 0.198 Pts
Stage 05 · Sign-offThreshold ≥ 0.76
Scoring & Gate
n8n_form_wait
Producer Signed
Stage 06 · PackageSHA-256 Receipt
Copy Packager
stage_delivery_bundle()
SHA-256

Stage 01 — Manual Kickoff & Ingestion

n8n-nodes-base.manualTrigger · Orchestration Entry
Runtime: n8n Node ProcessCompute: Free ($0.00)
What This Stage Does

Mounts target campaign export folder in read-only mode. Reads media buyer delivery manifest and initializes immutable execution state ledger in assets.json.

🛡️Invariant
Immutable Source Directory: The source export directory is mounted with read-only permissions; original project files are structurally prohibited from in-place edits.
Code · Input State · Output State

            

Three Decisions That Define the Architecture

Decision 01

Deterministic File Science (SHA-256 & Perceptual DCT Hashing)

Creative agencies frequently re-export files under panicked names: Promo_v3.mp4, Promo_v3_fixed.mp4, Promo_FINAL_FINAL.mp4. Sending both renders to a multimodal vision API burns budget rating identical pixels.

CAHI runs a Python worker that computes full SHA-256 byte hashes and 64-bit DCT perceptual hashes. Exact duplicates are eliminated instantly at zero API cost; near-duplicate renders (differing only by export container flags) are flagged locally. Zero cloud tokens spent on duplicate renders.

science.py · Dual Hash FingerprintingDeterministic math
def phase_file_science(file_path: Path) -> AssetFingerprint:
    sha = compute_sha256(file_path)
    phash = compute_dct_phash(extract_keyframe(file_path))
    meta = probe_stream_metadata(file_path)
    return AssetFingerprint(sha256=sha, phash=phash, metadata=meta)
Duplicate detection runs locally using byte comparison and DCT hashing. No API calls needed for this step.
Decision 02

Bounded AI Score and ≥ 0.76 Delivery Threshold

Multimodal vision models can be overly confident, claiming a video is compliant even when a required disclaimer frame is missing. Letting AI make delivery decisions on its own is unreliable.

CAHI caps the maximum AI score contribution at 0.198. The passing threshold for automated delivery is set at ≥ 0.76. This means an asset must accumulate sufficient points from deterministic metadata checks (exact naming pattern, resolution match, recency) before AI confidence can tip it into delivery. AI alone is not enough to approve an asset.

scoring.js · Bounded Composite Scoring0.198 safety cap
// AI score is multiplied by 0.20 and strictly capped
const aiPoints = Math.min(0.20, (response.confidence || 0) * 0.20);

let score = 0.0;
if (matchesNamingPattern(asset)) score += 0.35;
if (isMostRecent(asset)) score += 0.20;
if (matchesManifestSpecs(asset)) score += 0.15;
score += Math.min(0.198, aiPoints);

const passesDelivery = (score >= 0.76);
AI confidence contributes up to 0.198 points. The rest of the score comes from deterministic metadata checks, so a file can't pass on AI judgment alone.
Decision 03

Copy-Only Non-Destructive Packaging

Automated delivery tools that modify files in-place risk altering agency source footage or master project files.

CAHI operates on a read-only mounted volume. During Stage 06, approved files are copied into organized delivery buckets (Social/, Broadcast/, Display/). It generates a delivery_receipt.json containing SHA-256 hashes of every delivered file, providing a delivery record for media buyers.

delivery.py · Copy-Only Staging EngineRead-only safety
def stage_delivery_bundle(approved_assets: list[AssetRecord], dest_dir: Path) -> Receipt:
    dest_dir.mkdir(parents=True, exist_ok=True)
    for asset in approved_assets:
        shutil.copy2(asset.source_path, dest_dir / asset.filename)
    return generate_delivery_receipt(dest_dir)
Source directories are mounted read-only. File integrity is verified with SHA-256 checksums on delivery.

Run the Full Suite Locally in Under 8 Seconds

TERMINAL · LOCAL REPRODUCTION 64/64 Tests Passing (7.92s)
# 1. Clone repository and install CLI cd creative-asset-handoff-intelligence && pip install -e ".[dev]" # 2. Run offline unit tests — zero API keys required pytest -v tests/ ✓ 64 passed in 7.92s # 3. Import n8n workflow and audit campaign export directory n8n import:workflow --input=workflows/creative-asset-handoff.json cahi audit --project-dir ./client_delivery/ --threshold 0.76

The complete test suite runs offline against pre-computed DCT hash tables and synthetic video container fixtures. Zero API keys, zero network connectivity, zero compute spend required to verify.