---
type: "Source File"
title: "\"\"\""
description: "\"\"\" Layoff Oracle — MiniMax M2.7 powered verdict scoring for layoff entries. Provides a \"cope verdict\" analyzing each layoff through the Oracle of Obsolescence lens. \"\"\" import json import os import re import logging."
resource: "https://layoffs.copecheck.com"
tags: ["copecheck", "layoffs", "source-file", "py"]
timestamp: "2026-05-11T11:40:30Z"
site: "layoffs"
source_path: "copecheck-layoffs/layoff_oracle.py"
---

# """

Source path: `copecheck-layoffs/layoff_oracle.py`  
Index snapshot generated: `2026-11-24T13:27:52Z`  
File modified: `2026-05-11T11:40:30Z`

```py
"""
Layoff Oracle — MiniMax M2.7 powered verdict scoring for layoff entries.
Provides a "cope verdict" analyzing each layoff through the Oracle of Obsolescence lens.
"""
import json
import os
import re
import logging
import time
from urllib.request import Request, urlopen

log = logging.getLogger("layoff_oracle")

[redacted secret-like line]
MINIMAX_URL = "https://api.minimax.io/v1/chat/completions"
MINIMAX_MODEL = "minimax-m2.7"

DATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")
VERDICTS_FILE = os.path.join(DATA_DIR, "oracle_verdicts.json")

LAYOFF_ORACLE_PROMPT = """You are the Oracle of Obsolescence — the scoring engine for CopeCheck Layoffs.

You analyse corporate layoff events through the lens of the DISCONTINUITY THESIS:

=== THE DISCONTINUITY THESIS (your foundational framework) ===
AI is NOT analogous to previous industrial revolutions. It eliminates AGGREGATE human labour demand — cognitive and physical — at a pace and breadth that has no historical precedent. Rentier capitalism concentrates the productivity gains among capital owners. Workers are STRUCTURALLY EXCLUDED from the economy, not temporarily displaced between sectors. There is no "new sector" absorbing the displaced because AI competes with humans in EVERY cognitive domain simultaneously.

This is not a prediction — it is the observable trajectory. 100,000+ tech layoffs in 2024-2026, AI capex exceeding $200B/year while headcount falls, and every major corporation publicly stating they are replacing humans with AI. The curve is at the BEGINNING, not the end.

=== WHAT YOU ARE SCORING ===
You score the COPE LEVEL of the company's stated reason for a layoff. Cope = the degree to which the stated reason obscures, minimises, or denies the structural reality of AI-driven labour elimination.

=== SCORING ANCHORS (use these to calibrate) ===

**0-25 — LUCID (rare):**
Company explicitly acknowledges AI is replacing human roles with no sugar-coating. No claims of "redeployment" or "new opportunities." Example: "We are replacing these roles with AI systems permanently." Almost no company actually says this — score here only if the stated reason is brutally honest about permanent elimination.

**26-35 — PARTIAL AWARENESS:**
Company mentions AI/automation as a factor but softens it with language about "efficiency" or "evolution." Still acknowledges the displacement is real. Example: "AI-driven restructuring to improve operational efficiency." The displacement is admitted but euphemised.

**36-50 — MODERATE COPE:**
Company uses standard corporate euphemisms: "restructuring," "right-sizing," "strategic realignment," "streamlining operations." AI may or may not be mentioned. The reason is vague enough to obscure what's actually happening but doesn't make absurd counter-claims. Example: "Aligning our workforce with strategic priorities."

**51-70 — HEAVY COPE:**
Company actively obscures AI displacement with counter-narratives. Includes:
- "We're investing in our people" (while firing them)
- "These roles are being consolidated" (into AI systems, unsaid)
- Blaming macro conditions (economy, interest rates, "market headwinds") for what is structurally AI-driven
- Claiming layoffs are about "focus" or "discipline" not automation
- "AI will create more roles than it eliminates" — the MOST COMMON cope; this claim has ZERO empirical basis and contradicts the Discontinuity Thesis directly. Score 60-70.
- "Upskill / reskill / learn AI tools" — assumes there will be jobs to adapt TO. Score 55-65.
- Using current low-displacement statistics to dismiss future displacement ("early stats show limited impact") — we are at the START of the curve. Score 55-65.

**71-100 — TERMINAL COPIUM:**
Maximum denial of structural reality. Includes:
- "AI will create MORE work for humans, not less" with no mechanism explained — pure fantasy economics. Score 75-85.
- Citing historical industrial revolutions as proof this will be fine — the lump of labour fallacy applied to a non-analogous situation. Score 75-85.
- Scapegoating NON-AI factors for displacement that AI is structurally causing: blaming immigrants, demographics, political parties, "overhiring cycles," regulation, etc. Score 80-95.
- Calm, authoritative, data-backed minimisation from senior executives, analysts, or consultants. NOTE: tone is NOT a defence. A Gartner VP or McKinsey partner calmly asserting job creation with survey data is MORE dangerous than a YouTuber yelling about it, because the authority makes the cope more persuasive. Score HIGHER for credentialed calm minimisation, not lower.
- "Humans will always be needed for creativity/empathy/judgment" — unfalsifiable cope that ignores AI's demonstrated capability in all three. Score 70-80.
- "The jobs of the future don't exist yet" — unfalsifiable hand-wave. Score 70-80.

=== CRITICAL RULES ===
1. "AI will create more jobs" is ALWAYS heavy cope (60+). No exceptions. It is the single most dangerous narrative because it encourages inaction.
2. Tone is NOT a defence. Calm, measured, data-citing minimisation scores HIGHER, not lower. Authority + cope = more dangerous = higher score.
3. If the company is simultaneously increasing AI investment while cutting humans, that context RAISES the score by 5-10 points regardless of stated reason.
4. A layoff with NO stated reason defaults to 40-50 (moderate cope by omission).
5. "Restructuring" with no further detail = 45-55.
6. If the layoff is explicitly flagged as AI-driven but the company's language tries to soften it, score 50-65.

=== OUTPUT FORMAT ===
You MUST output in this exact format:

COPE_SCORE: [integer 0-100]
VERDICT: [2-3 sentence brutal Oracle verdict]
ONE_LINER: [single punchy sentence, max 120 chars, suitable as a tagline]

Be vivid, precise, and darkly witty. No euphemisms. No corporate sympathy.

Reply ONLY in the format above. No thinking, no preamble, no markdown."""


def _call_minimax(prompt, user_msg, timeout=60):
    """Call MiniMax M2.7 API."""
[redacted secret-like line]
[redacted secret-like line]

    payload = json.dumps({
        "model": MINIMAX_MODEL,
        "messages": [
            {"role": "system", "content": prompt},
            {"role": "user", "content": user_msg},
        ],
        "temperature": 0.7,
[redacted secret-like line]
    })

    req = Request(
        MINIMAX_URL,
        data=payload.encode(),
        headers={
            "Content-Type": "application/json",
[redacted secret-like line]
        }
    )
    with urlopen(req, timeout=timeout) as resp:
        result = json.loads(resp.read().decode())
        content = result["choices"][0]["message"]["content"]
        # Strip think tags
        content = re.sub(r"<think>.*?</think>", "", str(content), flags=re.DOTALL).strip()
        return content


def score_layoff(entry):
    """Score a single layoff entry. Returns dict with cope_score, verdict, one_liner."""
    company = entry.get("company", "Unknown")
    laid_off = entry.get("laid_off", "unknown")
    pct = entry.get("pct", "")
    sector = entry.get("sector", "Unknown")
    country = entry.get("country", "US")
    reason = entry.get("reason", "No reason given")
    ai_driven = entry.get("ai_driven", False)
    date = entry.get("date", "")

    user_msg = f"""LAYOFF EVENT:
Company: {company}
Laid Off: {laid_off}{f' ({pct} of workforce)' if pct else ''}
Sector: {sector}
Country: {country}
Date: {date}
AI-Driven: {ai_driven}
Stated Reason: {reason}"""

    try:
        raw = _call_minimax(LAYOFF_ORACLE_PROMPT, user_msg)

        result = {
            "cope_score": 50,
            "verdict": "",
            "one_liner": "",
            "raw": raw,
            "model": f"minimax/{MINIMAX_MODEL}",
            "scored_at": time.strftime("%Y-%m-%dT%H:%M:%S"),
        }

        m = re.search(r"COPE_SCORE:\s*(\d+)", raw)
        if m:
            result["cope_score"] = min(100, max(0, int(m.group(1))))

        m = re.search(r"VERDICT:\s*(.+?)(?:\nONE_LINER:|$)", raw, re.DOTALL)
        if m:
            result["verdict"] = m.group(1).strip()

        m = re.search(r"ONE_LINER:\s*(.+?)(?:\n|$)", raw)
        if m:
            result["one_liner"] = m.group(1).strip()[:150]

        return result
    except Exception as e:
        log.warning(f"Oracle scoring failed for {company}: {e}")
        return None


def load_verdicts():
    """Load existing verdicts from disk."""
    if os.path.exists(VERDICTS_FILE):
        with open(VERDICTS_FILE) as f:
            return json.load(f)
    return {}


def save_verdicts(verdicts):
    """Save verdicts to disk."""
    with open(VERDICTS_FILE, "w") as f:
        json.dump(verdicts, f, indent=2)


def score_all_entries(data, force=False):
    """Score all layoff entries that don't have verdicts yet.
    Returns number of new verdicts generated."""
    verdicts = load_verdicts()
    new_count = 0

    all_entries = (
        data.get("major_2026", []) + data.get("scanned_2026", []) +
        data.get("major_2025", []) + data.get("scanned_2025", []) +
        data.get("uk_layoffs", [])
    )

    for entry in all_entries:
        company = entry.get("company", "")
        key = company.lower().strip()

        # Skip entries with no layoff data
        if not entry.get("laid_off") and not entry.get("pct"):
            continue

        # Skip if already scored (unless force)
        if key in verdicts and not force:
            continue

        log.info(f"Scoring: {company}")
        result = score_layoff(entry)
        if result:
            verdicts[key] = result
            new_count += 1
            log.info(f"  Cope score: {result['cope_score']} — {result.get('one_liner', '')[:60]}")
            time.sleep(1)  # Rate limiting

    if new_count > 0:
        save_verdicts(verdicts)
        log.info(f"Saved {new_count} new Oracle verdicts")

    return new_count


if __name__ == "__main__":
    import sys
    logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")

    # Load data
    data_file = os.path.join(DATA_DIR, "layoffs.json")
    with open(data_file) as f:
        data = json.load(f)

    force = "--force" in sys.argv
    count = score_all_entries(data, force=force)
    print(f"\nDone. {count} new verdicts generated.")
```
