{
  "for_llm": "This page documents the LeadLift OS app (React on Cloudflare Pages, data in Supabase) and the ops-system stage it rests on. No Make scenario. To change it, open the repo in code.repo and read the stage file and code.files. change_policy: green = a column the app may write (os/app/src/lib/writes.ts plus the live column grants); amber = a named rule with a test (change rule + test together, merge through the gate); red = a contract (routes, tables, stage names), a setting or secret. The stage file text is older than the build in places: see known_issues.",
  "system": "LeadLift OS Walkthrough",
  "unit": {
    "index": 1,
    "of": 2,
    "node": "Operating system overview"
  },
  "platform": "code (React app on Cloudflare Pages + Modal server + Supabase)",
  "component": "LeadLift OS app",
  "code": {
    "repo": "https://github.com/Icarus-Growth/leadlift-os",
    "ref": "main (read at e0a8709, 12 Oct 2026)",
    "stage": "os/process/ll-ops-system.md",
    "boxes": [],
    "files": [
      "os/app/src/shell/nav.ts",
      "os/app/src/shell/SignIn.tsx",
      "os/app/src/lib/auth.ts",
      "os/app/src/lib/writes.ts",
      "os/app/src/lib/ladders.ts",
      "os/app/src/areas/home/",
      "os/app/src/areas/tables/index.tsx",
      "os/app/src/areas/client/index.tsx",
      "os/app/src/areas/boards/index.tsx",
      "os/app/src/areas/records/boardPanels.tsx",
      "os/app/src/areas/dashboards/",
      "os/web/_worker.js (sign-in: POST /api/auth/code)",
      "os/db/migration-unwritten-fields.sql (clients_active_needs_baseline)",
      "os/deploy_app.py"
    ]
  },
  "trigger": {
    "type": "a person signs in with an emailed 6-digit code",
    "routes": [
      "route.auth_magic_link",
      "route.record_field_write"
    ]
  },
  "reads": [
    {
      "table": "clients"
    },
    {
      "table": "team"
    },
    {
      "table": "editing_pipeline"
    },
    {
      "table": "scripts"
    },
    {
      "table": "tasks"
    },
    {
      "table": "launches"
    },
    {
      "table": "onboarding_steps"
    },
    {
      "table": "onboarding_form_submissions"
    },
    {
      "table": "call_recordings"
    },
    {
      "table": "ai_documentation"
    },
    {
      "table": "stage_events"
    },
    {
      "view": "v_team_capacity"
    },
    {
      "view": "v_client_health"
    },
    {
      "view": "v_onboarding_steps_overdue"
    },
    {
      "function": "editing_moves_by_day"
    }
  ],
  "writes": [
    {
      "table": "clients",
      "why": "client record fields in writes.ts"
    },
    {
      "table": "team"
    },
    {
      "table": "editing_pipeline"
    },
    {
      "table": "scripts"
    },
    {
      "table": "tasks"
    },
    {
      "table": "launches"
    },
    {
      "table": "onboarding_steps",
      "why": "the 3 manual steps"
    },
    {
      "table": "ai_documentation"
    },
    {
      "table": "leads",
      "why": "client_rating only"
    }
  ],
  "notifies": [
    {
      "via": "database triggers on editing_pipeline, scripts, tasks, launches call the Modal server (POST /editing/moved, POST /boards/moved); the server posts in Slack",
      "see_unit": 2
    }
  ],
  "schedules": [],
  "screens": [
    "My Work",
    "Clients",
    "Team",
    "Onboarding",
    "Editing Pipeline",
    "Scripts",
    "Tasks",
    "Launches",
    "AI Documentation",
    "Creatives Dashboard",
    "Launch Dates",
    "Load Distribution",
    "Task Completion",
    "Client record",
    "Walkthrough"
  ],
  "edges": {
    "upstream": [],
    "downstream": [
      {
        "node": "Slack channel system",
        "unit": 2,
        "via": "card moves -> database triggers -> Modal server -> Slack"
      }
    ],
    "other_systems": [
      {
        "system": "Onboarding",
        "href": "../onboarding/",
        "via": "Whop payment creates the client row and onboarding steps; the form links answers"
      },
      {
        "system": "Editing Pipeline",
        "href": "../editing-pipeline/",
        "via": "Raw Footage scan creates editing cards"
      }
    ]
  },
  "capabilities": [
    "Sign-in with an emailed 6-digit code (Resend); only Active team rows with an email, or app_access rows, get in; every table re-checks",
    "My Work: waits on you / waits on others, group by, filters, sort, View as (non-team only)",
    "Client record: Drive buttons, company, contract, delivery, 4 targets, provisioning, onboarding steps, linked work, onboarding form panel",
    "A client cannot be Active without target_cost_per_lead, target_leads_per_week, expected_quality_mix, drift_threshold and baseline_confirmed (database check)",
    "Team page: capacity_limit; at_capacity when clients >= limit (v_team_capacity)",
    "Boards: Editing Pipeline, Scripts, Tasks, Launches (5 prerequisites; Module 3 only on Done-With-You)",
    "4 dashboards: Creatives, Launch Dates, Load Distribution, Task Completion",
    "Refresh button; the app does not subscribe to realtime"
  ],
  "boundaries": [
    "The app writes only the columns in os/app/src/lib/writes.ts",
    "The app has no delete button for a client; a delete in Supabase cascades to 19 linked tables",
    "App errors show only on screen; nothing goes to #sentry",
    "App previews write to the live database"
  ],
  "change_policy": {
    "green": [
      "clients: details, targets, baseline_confirmed, status, ads_manager_url, slack_channel_id, client_reviews_edits (client record)",
      "team: name, job_title, email, phone, slack_user_id, capacity_limit, status (Team page)",
      "editing_pipeline, scripts, tasks, launches: stage moves and fields in writes.ts",
      "ai_documentation (AI Documentation page)"
    ],
    "amber": [
      "clients_active_needs_baseline check (Box 3; test tests/e2e/ops_system/test_unwritten_fields.py)",
      "the writable-columns list os/app/src/lib/writes.ts (change + app release)"
    ],
    "red": [
      "route.auth_magic_link and the sign-in worker os/web/_worker.js; app_access allow list; Cloudflare settings SUPABASE_URL, SUPABASE_SECRET_KEY, RESEND_API_KEY, RESEND_FROM",
      "all tables and columns (os/contracts)",
      "stage names in os/app/src/lib/ladders.ts (Slack messages and the connector match exact names)",
      "Modal server URL (in 3 pg_net database rules and every saved connector)",
      "SUPABASE_SECRET_KEY in .env, Modal secret leadlift-os-secrets and Cloudflare"
    ]
  },
  "known_issues": [
    "As of 12 Oct no LeadLift person has signed in; only 2 Icarus Growth app_access accounts exist",
    "All working rows belong to 8 test clients; the delete is written, not run",
    "App errors are not reported anywhere but the screen",
    "Load Distribution labels the reviewer load 'SMM Load'; Sheni says it will be renamed",
    "Targets typed on the client record go to clients columns; the daily cost-per-lead check and weekly report read kpi_baselines (gap)",
    "Stage file drift: Box 5 says a sign-in link and fourteen screens (built: a 6-digit code, 15 screens); Box 2a/7 say editing_pipeline, creative_bank and stage_events are folded or dropped (live: still present, dashboards read stage_events); Box 6 says the app writes angles (stopped 11 Oct); owns lists point at the retired os/web/js files",
    "The Onboarding page lists clients on the way in; the forms open from the client record (the video says the page holds the forms)"
  ],
  "recovery": {
    "git": "every change is a commit on main, merged through the gate",
    "rollback": "app: python3 os/deploy_app.py --rollback <id>; server: modal app rollback leadlift-os"
  }
}