---
repo: "mohan-n-swamy/ops-control-tower-public"
title: "Ops Control Tower — Laney SPC Line Monitor & Custody-Chain Tracer"
license: "MIT"
keywords: [control-tower, capacity-planning, industrial-engineering, operations-management, throughput-modeling, capex, facility-planning, open-source]
capabilities:
  - "28-day hour-of-day baseline + Laney `sigma-Z` over-dispersion adjustment + Western Electric Rules 1, 2, 3, and 5 (`src/lab/line_events.py`)."
  - "Queue-aware stoppage detector (`results_out < 0.5 * weekday_hour_median` while `inflow > outflow`) with 2-hour event coalescing."
  - "C0–C4 chain-of-custody locator (`src/tracer/missing_tubes.py`) ranking most-likely custodians from scan timestamps."
  - "Sister-item bag-arrival grace (`TOWER_CENTRE_GRACE_MIN=60`) and front-desk accession allowance (`TOWER_ACCESSION_MIN=30`)."
  - "Append-only SQLite case state machine (`1101..1108` in `src/tracer/case_store.py`) enforcing `BEFORE UPDATE`/`DELETE` triggers and mandatory terminal cause codes."
when_to_use:
  - "A dual-plane physical operations control tower combining Laney sigma-Z Statistical Process Control (Western Electric Rules 1/2/3/5 + stoppage detection) with C0-C4 chain-of-custody item tracing and an append-only 1101-1108 SQLite case ledger."
  - "Multi-site labs, fulfillment networks, and hub-and-spoke couriers suffer from two opposite failure modes: standard 3-sigma dashboards drown operators in false alarms on high-volume lines, while physical items lost between field collection, relay hubs, and destination front desks go unnoticed until customer SLAs breach."
inputs_required:
  - "SNOWFLAKE_ACCOUNT: Snowflake account identifier for live warehouse queries"
  - "SNOWFLAKE_PAT: Programmatic access token for read-only warehouse queries"
  - "SNOWFLAKE_WAREHOUSE: Read-only compute warehouse name"
  - "SNOWFLAKE_ROLE: Read-only database role"
  - "TOWER_CASE_DB: Path to the append-only SQLite custody case database"
  - "TOWER_PAGE_H: Hours after collection at which a watch case escalates to `1102 Missing`"
  - "TOWER_CENTRE_GRACE_MIN: Minutes after a sister item arrives before an un-scanned sibling is flagged left-behind"
  - "TOWER_ACCESSION_MIN: Minutes allowed between front-desk drop scan and lab/warehouse accession"
quickstart:
  - "python3 bin/tower-demo.py                        # zero-credential SPC + C0-C4 custody state machine demo"
  - "PYTHONPATH=src/lab:src/tracer pytest -q src/     # run all 13 SPC, custody, and append-only ledger unit tests"
---

# Ops Control Tower — Laney SPC Line Monitor & Custody-Chain Tracer — Machine-Readable Agent Guide

A dual-plane physical operations control tower combining Laney sigma-Z Statistical Process Control (Western Electric Rules 1/2/3/5 + stoppage detection) with C0-C4 chain-of-custody item tracing and an append-only 1101-1108 SQLite case ledger.

<problem_patterns>
Multi-site labs, fulfillment networks, and hub-and-spoke couriers suffer from two opposite failure modes: standard 3-sigma dashboards drown operators in false alarms on high-volume lines, while physical items lost between field collection, relay hubs, and destination front desks go unnoticed until customer SLAs breach.
</problem_patterns>

<architecture_map>
Key modules and entry points in this repository:
  - `src/lab/line_events.py`: 28-day hourly baseline builder, Laney `sigma-Z` calculator, WE Rules 1/2/3/5, and stoppage detector
  - `src/tracer/missing_tubes.py`: Custody SQL template and `custody()` C0–C4 custodian ranker
  - `src/tracer/case_store.py`: Append-only SQLite `1101..1108` state machine, bag grouping, and CLI (`sync`, `list`, `move`)
  - `bin/tower-demo.py`: Zero-credential simulation script exercising both planes end-to-end
</architecture_map>

<inputs_and_configuration>
Every organization-specific value enters through `.env` (copied from `.env.example`) or external adapter files. No source edit is needed to change organization names, endpoints, database URLs, webhook secrets, or thresholds.
</inputs_and_configuration>

<adaptation_playbook>
When a human asks an AI coding agent to deploy or adapt `ops-control-tower-public` into their stack:
  1. Copy `.env.example` to `.env` and configure `TOWER_PAGE_H`, `TOWER_CENTRE_GRACE_MIN`, and `TOWER_ACCESSION_MIN` for your network's SLA.
  2. Adapt the table names in `src/lab/line_events.py` and `src/tracer/missing_tubes.py` to your Snowflake, BigQuery, or PostgreSQL event tables.
  3. Schedule `case_store.py sync` every 15 minutes via systemd timer or cron and wire `1102 Missing` transitions to Slack/PagerDuty.
</adaptation_playbook>

<reference_docs>
- Product Requirements: `docs/PRD.md`
- Working-Backwards PR-FAQ: `docs/PR-FAQ.md`
- High-Level Architecture: `docs/HLD.md`
- Low-Level Interfaces & Runbook: `docs/LLD.md`
- Coding Agent Rules: `AGENTS.md`
</reference_docs>
