Skip to content

Latest commit

Β 

History

94 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ClearFrame

Autonomous rights clearance and chain-of-title investigation for film and television.

Google Cloud Parallel AI PostgreSQL Cloud Run TypeScript License

Live Demo β€’ The Problem β€’ Architecture β€’ Dual-Chain Rights β€’ Guarantees β€’ Quick Start β€’ Documentation


Live Deployment

Service Endpoint / Access
Web Workspace https://clearframe-web-690834564732.us-central1.run.app
Demo Access Register a workspace at /register (or see private hackathon testing instructions)
API Base URL https://clearframe-api-690834564732.us-central1.run.app
Infrastructure Serverless Google Cloud Run (us-central1) + Google Cloud SQL + Cloud Storage (GCS)

The Problem

No film or television production reaches an audience without clearance. Every song, visible brand, artwork, depicted real person, and archival clip must be traced to whoever controls the rights today. A distributor will not accept delivery without Errors & Omissions (E&O) insurance, and underwriters will not issue a policy without an exhaustive, auditable clearance report.

A standard 110-page feature screenplay routinely yields 200 to 400 distinct clearable items.

Today, this process is broken:

  • The Manual Grind: Handled via spreadsheets, clearance coordinators, and weeks of paralegal hours.
  • Instant Obsolescence: The moment the director issues a revision (e.g. from shooting draft to blue revision), the clearance spreadsheet is immediately out of date.
  • Post-Signoff Blindness: If a music catalog is acquired or an estate lawsuit is filed after sign-off, the production remains blind until hit with a cease-and-desist.

The Dual-Chain Music Trap

A single song represents two separate legal properties with independent chains of title:

  1. The Master Recording (controlled by a record label).
  2. The Underlying Composition (controlled by publishers, songwriters, or fractured estates).

Licensing one clears nothing. A standard database lookup finds the label. Only a live investigation uncovers the probate dispute or unadministered catalog split sitting on the composition.


System Architecture

ClearFrame is built around four decoupled planes. The API never invokes an LLM directly; instead, it writes a job to a durable PostgreSQL queue (FOR UPDATE SKIP LOCKED) and returns in milliseconds. Background workers execute the multi-stage research pipeline, and live updates travel back through PostgreSQL LISTEN/NOTIFY into Server-Sent Events (SSE).

ClearFrame System Context

   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  EXPERIENCE PLANE           React 19 Β· Vite Β· Server-Sent Events (SSE) β”‚
   β”‚  Producer β”‚ Coordinator β”‚ Legal Counsel β”‚ Underwriting Reviewer        β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚  REST + JWT
                                    β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  CONTROL PLANE              Fastify API Β· Zod Validation Β· RBAC Gates  β”‚
   β”‚                                                                        β”‚
   β”‚      β˜… THE API NEVER CALLS A MODEL DIRECTLY β˜…                          β”‚
   β”‚      Validates input β†’ INSERTS job to queue β†’ Returns in milliseconds  β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚  PostgreSQL Job Queue (SKIP LOCKED)
                                    β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  EXECUTION PLANE            Worker Daemon Β· Resumable Step Pipeline    β”‚
   β”‚                                                                        β”‚
   β”‚   Breakdown ──► Recon ──► Synthesis ──► Verify ──► Trace ──► Assess    β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                                                   β”‚
            β–Ό                                                   β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  GEMINI (Vertex)   β”‚                          β”‚  PARALLEL AI           β”‚
   β”‚  Reasons & Judges. β”‚                          β”‚  Retrieves & Scrapes.  β”‚
   β”‚  Never retrieves.  β”‚                          β”‚  Never reasons.        β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                                                   β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  MEMORY PLANE      PostgreSQL 16 (14 Tables) Β· Cloud Storage (GCS)     β”‚
   β”‚  Findings Β· Evidence Citations Β· SHA-256 Ledger Β· Cost Events Β· Audits β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚  PostgreSQL LISTEN / NOTIFY
                                    └──────────► SSE Stream ──► Back to UI

End-to-End Clearance Pass Sequence

When a screenplay PDF is uploaded, ClearFrame executes an orchestrated sequence across specialized autonomous agents:

ClearFrame Clearance Pass Sequence

  1. Breakdown Agent (gemini-2.5-pro): Extracts all clearable cues anchored to scene slugline, page number, context, and prominence (hero, featured, background).
  2. Recon & Retrieval (parallel-web): Queries live-web registries and archives, capturing HTML crawl snapshots.
  3. Continuity Verifier Agent (gemini-2.5-pro): Adversarially red-teams findingsβ€”challenging stale sources (>24 months) and conflicting registry claims before risk scoring.
  4. Studio Risk Counsel Agent (gemini-2.5-pro): Maps findings to E&O underwriting standards (GREEN, AMBER, RED) with costed mitigations.
  5. Outreach Drafting Agent (gemini-2.5-flash): Auto-drafts sync license inquiries held strictly behind human legal counsel authorization.

The Dual-Chain Music Breakthrough

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Scene 42 β€” "Midnight City" (Cover Version)  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                           β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό                                              β–Ό
          ╔═════════════════════╗                        ╔═════════════════════╗
          β•‘   MASTER CHAIN  β„—   β•‘                        β•‘ COMPOSITION CHAIN Β© β•‘
          β•‘  (This Performance) β•‘                        β•‘ (The Written Work)  β•‘
          β•šβ•β•β•β•β•β•β•β•β•β•€β•β•β•β•β•β•β•β•β•β•β•β•                        β•šβ•β•β•β•β•β•β•β•β•β•€β•β•β•β•β•β•β•β•β•β•β•β•
                    β”‚                                              β”‚
                    β–Ό                                              β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ Indie Label Roster  β”‚                        β”‚ Original Publisher  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚                                              β”‚
                    β”‚                                              β–Ό
                    β”‚                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚                                    β”‚ Catalog Acquisition β”‚
                    β”‚                                    β”‚ (2023 Transfer)     β”‚
                    β”‚                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚                                              β”‚
                    β”‚                                              β–Ό
                    β”‚                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚                                    β”‚ ESTATE LITIGATION   β”‚
                    β”‚                                    β”‚ (Disputed Split)    β”‚
                    β”‚                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β–Ό                                              β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚   Status: CLEAR     β”‚                        β”‚  Status: CONTESTED  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚                                              β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                           β–Ό
                             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                             β”‚  Clearable ⟺ ALL Chains   β”‚
                             β”‚  Resolve Clear.           β”‚
                             β”‚                           β”‚
                             β”‚  β†’ FLAGGED FOR COUNSEL    β”‚
                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

ClearFrame enforces a mathematical rule: clearance is a conjunction, not an average. If the master is 100% clear but the composition is disputed, the item is strictly flagged for human counsel resolution.


Delta Re-Clearance Engine

When a director submits a revised screenplay cut (Pass $N+1$), ClearFrame hashes scene content: $$\text{ContentHash} = \text{SHA256}(\text{scene} ,|, \text{page} ,|, \text{context})$$

ClearFrame Delta Re-Clearance

  • Unchanged Items: Carried forward with full evidence and counsel decisions intact ($0.00 compute spend).
  • Modified Items: Re-queued and re-investigated in context.
  • Deleted Items: Marked withdrawnβ€”never deleted from the audit ledger.

Core Guarantees & Invariants

The One Rule: Every finding, source URL, spend penny, risk score, and report originates from a real user action or live pipeline execution. Where data does not exist, the UI renders an empty state rather than inventing placeholder content.

Guarantee Enforcement Mechanism Code Location
Zero Hallucinated Citations Model-emitted URLs not present in the live Parallel retrieval pool are dropped at the gateway services/api/src/pipeline/stages.ts
Tamper-Proof Audit History SHA-256 hash-chained ledger; PostgreSQL trigger unconditionally rejects UPDATE and untagged DELETE services/api/src/core/ledger.ts
No Floating Point Money 64-bit integer micro-dollars (bigint); token counts and retrieval units deduct atomically in the same statement services/api/src/core/db.ts
Authority is Server-Side Only authenticated legal counsel can resolve findings, release outreach, or sign reports services/api/src/core/auth.ts
No Rogue Outbound Messages System contains zero email-sending mechanisms; licensing inquiries are draft-only services/api/src/pipeline/stages.ts

Cryptographic Ledger Integrity

Every finding lifecycle event, adversarial challenge, counsel decision, and spend record appends to an immutable SHA-256 hash chain:

$$\text{Hash}_n = \text{SHA256}\big(,\mathcal{C}(\text{production_id},\ \text{seq}_n,\ ts_n,\ \text{actor}_n,\ \text{event}_n,\ \text{Hash}_{n-1}),\big)$$

ClearFrame Ledger Integrity

Underwriters can verify mathematical chain integrity at any time via GET /api/productions/:id/integrity or by clicking "Verify Chain" in the workspace.


Quick Start

Option A: Docker Compose (Recommended)

# 1. Clone and configure environment
cp .env.example .env

# Configure your keys in .env:
# - GOOGLE_CLOUD_PROJECT
# - PARALLEL_API_KEY
# - DATABASE_URL=postgres://clearframe:clearframe@localhost:5433/clearframe

# 2. Boot PostgreSQL, API, Worker, and Web
make up

# 3. Verify provider connectivity
make smoke

Option B: Bare-Metal Development

# Install all workspace dependencies
make install

# Initialize database
createdb clearframe
make migrate

# Start API, Worker, and React Web concurrently
make dev
  • Web Workspace: http://localhost:3000
  • API Server: http://localhost:8080

Testing & Verification Suite

make typecheck   # Strict TypeScript across all workspaces (noUncheckedIndexedAccess)
make test        # 22 integration tests against a live PostgreSQL instance
make smoke       # Live round-trip connectivity test to Vertex AI & Parallel AI

make test covers SHA-256 hash chaining, adversarial tamper detection, PostgreSQL trigger immutability, concurrent advisory locking under 10 parallel workers, queue stall reaping, integer money attribution, and citation pool containment.


Role-Based Access Control (RBAC)

Role Permissions Restricted Actions
Producer Upload cuts, start passes, raise budgets, read all findings Cannot resolve findings, release outreach, or sign reports
Coordinator Correct item metadata, prioritize items, view all findings Cannot resolve findings, release outreach, or sign reports
Counsel Full access + approve/license findings, authorize outreach, sign E&O reports Cannot delete ledger history (nobody can)
Reviewer Read-only access to register, evidence snapshots, and reports Cannot modify any production state

Production Deployment Topology

ClearFrame runs serverlessly on Google Cloud Platform in us-central1:

ClearFrame Deployment Topology

  • Google Cloud Run: clearframe-web (SPA), clearframe-api (Fastify REST/SSE), and clearframe-worker (Background Daemon).
  • Google Cloud SQL: Managed PostgreSQL 16 database with advisory locks and row-level security triggers.
  • Google Cloud Storage (GCS): Secure bucket storage for screenplay PDFs, signed PDF reports, and immutable HTML crawl snapshots.
  • Google Cloud Scheduler: Automated cron triggering periodic job sweeps and Sentinel watch schedules.

Documentation Suite

Comprehensive technical guides and specifications are available in the docs/ directory:


Licence

Licensed under the Apache-2.0 License. See NOTICE, SECURITY.md, and CONTRIBUTING.md.

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages