# joaovitorsesma/codex-reset-monitor architecture

> Architecture diagram of the GitHub repository joaovitorsesma/codex-reset-monitor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joaovitorsesma/codex-reset-monitor
- Repository: https://github.com/joaovitorsesma/codex-reset-monitor

## Overview

Codex Reset Monitor collects public reset announcements, interprets and groups evidence into reset events, then sends status-aware Discord alerts. Its main path runs through GitHub Actions: the monitor fetches OpenAI and independent tracker sources, classifies signals, updates persistent event/source-health state, and notifies Discord. Cloudflare independently schedules dispatches and directly reports workflow watchdog failures. README documents these capabilities; details of unsampled workflow wiring and some monitor stages are represented only where documented.

Main entry points: [`src/monitor.py`](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py) (Monitor runtime), [`cloudflare/worker.js`](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/cloudflare/worker.js) (Cloudflare Worker), [`src/run_monitor.py`](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/run_monitor.py) (Monitor entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Signal collection"]
  node_monitor_entry["Monitor entry<br/>[run_monitor.py]"]
  node_monitor["Monitor runtime<br/>[monitor.py]"]
  node_openai_sources["OpenAI sources<br/>[monitor.py]"]
  node_trackers["Reset trackers<br/>[monitor.py]"]
end

subgraph group_interpretation["Event interpretation"]
  node_normalize["Signal normalization<br/>[monitor.py]"]
  node_classifier["Reset classifier<br/>[monitor.py]"]
  node_time_conversion["BRT conversion<br/>[monitor.py]"]
  node_event_engine["Event engine<br/>[monitor.py]"]
  node_state[("Monitor state<br/>[monitor.py]")]
end

subgraph group_delivery["Alert delivery"]
  node_time_payload["Time-aware payload<br/>[run_monitor.py]"]
  node_discord(("Discord channel"))
end

subgraph group_operations["Scheduling and health"]
  node_actions["GitHub Actions"]
  node_cloudflare["Cloudflare Worker<br/>[worker.js]"]
  node_github_api["GitHub API"]
  node_watchdog_state[("Watchdog KV")]
  node_external_clock(("Cloudflare Cron"))
end

node_user(("Repository operator"))

node_user -.->|"configures"| node_actions
node_actions -.->|"runs"| node_monitor_entry
node_monitor_entry -->|"delegates to"| node_monitor
node_monitor -->|"fetches"| node_openai_sources
node_monitor -->|"fetches"| node_trackers
node_openai_sources -.->|"provides signals"| node_normalize
node_trackers -.->|"provides signals"| node_normalize
node_normalize -.->|"normalizes for"| node_classifier
node_classifier -.->|"interprets times"| node_time_conversion
node_monitor -.->|"processes signals"| node_event_engine
node_event_engine -->|"updates"| node_state
node_monitor -->|"loads and saves"| node_state
node_monitor_entry -->|"installs formatter"| node_time_payload
node_time_payload -->|"wraps payload"| node_monitor
node_monitor -.->|"sends alerts"| node_discord
node_external_clock -.->|"triggers"| node_cloudflare
node_cloudflare -->|"checks and dispatches"| node_github_api
node_github_api -.->|"dispatches workflow"| node_actions
node_cloudflare -->|"sends watchdog alerts"| node_discord
node_cloudflare -->|"records incidents"| node_watchdog_state
node_cloudflare -->|"checks recovery"| node_github_api

click node_monitor_entry "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/run_monitor.py"
click node_monitor "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py"
click node_openai_sources "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py"
click node_trackers "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py"
click node_normalize "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py"
click node_classifier "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py"
click node_time_conversion "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py"
click node_event_engine "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py"
click node_state "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py"
click node_time_payload "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/run_monitor.py"
click node_cloudflare "https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/cloudflare/worker.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_monitor_entry,node_monitor,node_openai_sources,node_trackers toneBlue
class node_normalize,node_classifier,node_time_conversion,node_event_engine,node_state toneAmber
class node_time_payload,node_discord toneMint
class node_actions,node_cloudflare,node_github_api,node_watchdog_state,node_external_clock toneRose
class node_user toneIndigo
```

## Components

### Signal collection

- [Monitor entry](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/run_monitor.py): `src/run_monitor.py`
- [Monitor runtime](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py): `src/monitor.py`
- [OpenAI sources](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py): `src/monitor.py`
- [Reset trackers](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py): `src/monitor.py`

### Event interpretation

- [Signal normalization](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py): `src/monitor.py`
- [Reset classifier](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py): `src/monitor.py`
- [BRT conversion](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py): `src/monitor.py`
- [Event engine](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py): `src/monitor.py`
- [Monitor state](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/monitor.py): `src/monitor.py`

### Alert delivery

- [Time-aware payload](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/src/run_monitor.py): `src/run_monitor.py`
- **Discord channel**

### Scheduling and health

- **GitHub Actions**
- [Cloudflare Worker](https://github.com/joaovitorsesma/codex-reset-monitor/blob/main/cloudflare/worker.js): `cloudflare/worker.js`
- **GitHub API**
- **Watchdog KV**
- **Cloudflare Cron**

### Other components

- **Repository operator**

## Connections

- Repository operator → GitHub Actions: configures (evidence: `README.md`)
- GitHub Actions → Monitor entry: runs (evidence: `README.md`)
- Monitor entry → Monitor runtime: delegates to (evidence: `src/run_monitor.py`)
- Monitor runtime → OpenAI sources: fetches (evidence: `src/monitor.py`)
- Monitor runtime → Reset trackers: fetches (evidence: `src/monitor.py`)
- OpenAI sources → Signal normalization: provides signals (evidence: `README.md`)
- Reset trackers → Signal normalization: provides signals (evidence: `README.md`)
- Signal normalization → Reset classifier: normalizes for (evidence: `README.md`)
- Reset classifier → BRT conversion: interprets times (evidence: `README.md`)
- Monitor runtime → Event engine: processes signals (evidence: `README.md`)
- Event engine → Monitor state: updates (evidence: `src/monitor.py`)
- Monitor runtime → Monitor state: loads and saves (evidence: `src/monitor.py`)
- Monitor entry → Time-aware payload: installs formatter (evidence: `src/run_monitor.py`)
- Time-aware payload → Monitor runtime: wraps payload (evidence: `src/run_monitor.py`)
- Monitor runtime → Discord channel: sends alerts (evidence: `README.md`)
- Cloudflare Cron → Cloudflare Worker: triggers (evidence: `README.md`)
- Cloudflare Worker → GitHub API: checks and dispatches (evidence: `cloudflare/worker.js`)
- GitHub API → GitHub Actions: dispatches workflow (evidence: `README.md`)
- Cloudflare Worker → Discord channel: sends watchdog alerts (evidence: `cloudflare/worker.js`)
- Cloudflare Worker → Watchdog KV: records incidents (evidence: `cloudflare/worker.js`)
- Cloudflare Worker → GitHub API: checks recovery (evidence: `cloudflare/worker.js`)
