cto-legends · module overview · infrastructure · MIT
legends-temporal: Durable Schedules, Delayed Timers, ScriptJob Workers & History Diagnosis
Replace fragile crontabs, sleep loops, and rate-limited chat-app schedulers with server-side Temporal schedules, one-shot start_delay timers, first-class cto-legends --module scheduling, live orphaned-queue and inventory drift audits, local/Docker/systemd cluster bootstrap blueprints, and single-screen event-history failure verdicts.
GitHub Repository (https://github.com/avalonreset/legends-temporal)
Running production automation on host crontabs, OS task schedulers, or background sleep loops breaks as soon as a laptop sleeps, a container restarts, or an agent session closes. Yet rewriting every existing Python script, shell command, webhook, and agent prompt as a custom Temporal workflow DAG introduces sandbox determinism traps and replay bugs whenever business logic changes.
legends-temporal bridges that gap by giving AI coding agents and operators direct CLI and stdio MCP control over any local dev, self-hosted PostgreSQL, or Temporal Cloud cluster. One replay-safe ScriptJob workflow with a fixed 11-field wire contract orchestrates on an always-on control queue while dispatching scripts, inline Python, arbitrary argv commands, env-held webhooks, and agent session turns to the exec queue where your data and credentials live.
Every schedule and timer mutation supports offline --dry-run previews, destructive schedule deletions and workflow terminations require --yes, and secrets remain in worker environment variables out of Temporal event history. When a job fails, workflow history --diagnose distills the raw protobuf event stream into a compact JSON verdict with the exact script exit code, worker identity, output tail, notice delivery status, timeline, and remediation hint.
Deterministic Execution Boundary
Why Host Crontabs, Local Sleep Loops, and Raw Protobuf Histories Fail Coding Agents
Unguided agents often spawn background sleep commands that die with the shell, rewrite simple scripts into non-deterministic workflow code that breaks replay, dump raw secrets into workflow arguments where Temporal stores them in plaintext history, or flood their own context window with hundreds of raw HistoryEvent protobuf objects.
- Server-Side Clocks with Overlap & Catchup Control: Replaces fragile crontabs and local sleep timers with Temporal server schedules (5-field cron or intervals, IANA timezones, jitter, SKIP/BUFFER_ONE/ALLOW_ALL overlap policies, and 12-hour catchup windows) plus one-shot start_delay timers up to 366 days.
- Zero-Rewrite 11-Field ScriptJob Across Split Control & Exec Planes: Keeps workflow orchestration tiny and permanently replay-safe on an always-on control queue while executing unchanged scripts, inline code, argv commands, webhooks, and agent turns on remote or workstation exec queues that can sleep and reconnect within wait_for_worker_s.
- Single-Screen History Verdicts Instead of Raw Protobuf Dumps: workflow history --diagnose parses the full protobuf event stream locally and returns a compact verdict: workflow status, failed activity, script_exit_code (including 124 timeout and 127 missing binary), worker identity, bounded output tail, log/notice confirmation, and an actionable hint.
- History-Safe Secret Hygiene & Preview-First Mutations: API keys (api_key_env), webhook URLs (--webhook-env), and notifier private keys are read from environment variables or files on the worker at runtime so secrets never enter Temporal history. Schedule creation, batch apply, and timers support offline --dry-run previews.
CLI Subcommands & Capability Surface
- Offline & Live Cluster, Queue Poller, UI & SSH Doctor: Verifies Python 3.11+, temporalio SDK version, profile resolution, and knowledge-pack schema offline, or runs live gRPC latency, namespace state, task-queue workflow/activity poller freshness (<=120s), optional Web UI HTTP, and read-only SSH systemd unit checks.
- Declarative & cto-legends --module Durable Schedules: Schedules any installed cto-legends module (--module legends-empire, legends-geogrid, legends-dataforseo, etc.), script, inline Python, or agent turn from CLI flags, JSON/YAML files, or Python inventories with offline --dry-run previews.
- One-Shot Durable Delayed Timers (start_delay): Schedules one-shot delayed jobs (30s, 15m, 2h, 3d, 1h30m) held by the Temporal server via start_delay to run a script, inline Python, arbitrary argv command, env-held webhook POST, or agent session turn.
- Compact Event-History Failure Diagnosis: Filters workflow executions via SQL-like visibility queries (--status, --type, --id-prefix, --query) and distills event histories into a structured verdict with script exit code, attempts, worker identity, output tail, notice state, and timeline.
- Split Control & Exec ScriptJob Worker Runtime: Hosts the sandboxed ScriptJobWorkflow and log_failure activity on the control queue and run_script plus configurable failure notices (stdout, webhook, buzz, none) on the exec queue with maximum_attempts=1 script safety.
- Schedule Drift & Poller Auditor, Bootstrap & 10-Tool MCP Server: Audits schedules for orphaned queues (0 live pollers), leaked secrets, and 3-way inventory drift; bootstraps SQLite-persisted local dev servers or hardened 127.0.0.1 Docker Compose stacks; serves 10 stdio MCP tools; and attaches the 7-note Empire knowledge pack.
Raw Frontier LLM vs. legends-temporal Execution Matrix
- Clock Durability & Sleep Survival: Standard AI Chat (Uses local sleep commands or host crontabs that vanish on reboot, miss ticks when a laptop sleeps, and lack overlap or catchup rules.) vs. With legends-temporal (Stores schedules and start_delay timers inside Temporal Server with IANA timezones, overlap policies (SKIP by default), 12h catchup windows, and 6h worker wait tolerances.) · schedule describe and workflow describe report server-side next_runs, catchup_window_s, and start_delay_s.
- Workflow Determinism & Rewrites: Standard AI Chat (Rewrites operational scripts into custom @workflow.defn code that hits sandbox violations or non-determinism errors on replay.) vs. With legends-temporal (Wraps any script, inline code, argv command, webhook, or agent turn unchanged inside a fixed 11-field ScriptJob payload with maximum_attempts=1.) · runtime.to_wire() enforces exact 11-field payload compatibility across control and exec workers.
- Failure Triage & Context Efficiency: Standard AI Chat (Dumps hundreds of raw protobuf HistoryEvent JSON objects into chat context or fails silently when a cron job exits non-zero.) vs. With legends-temporal (Logs failures on the control plane, dispatches a bounded notice on the exec plane, and distills history via --diagnose into exit code, worker, tail, and hint.) · workflow history <id> --diagnose returns verdict.ok, script_exit_code, output_tail, failure_logged, and timeline.
- Secret Hygiene in History: Standard AI Chat (Passes raw webhook URLs, bearer tokens, or API keys in CLI arguments that are persisted in plaintext Temporal workflow history.) vs. With legends-temporal (Reads API keys (api_key_env), webhook URLs (--webhook-env), and notifier keys from worker environment variables or local files at execution time.) · config show reports only api_key_present: bool and webhook_job payloads contain only the env var name.
Explicit Safety Boundaries & Exclusions
- Never embeds Temporal API keys, webhook target URLs, or notification private keys in workflow inputs, event history payloads, or config show output.
- Never deletes a schedule or terminates a workflow execution without an explicit --yes confirmation flag.
- Never retries non-idempotent user scripts automatically inside a single run (run_script uses maximum_attempts=1 so side-effecting scripts do not double-fire).
- Never executes cluster mutations from the stdio MCP server except temporal_timer_schedule when confirm: true is explicitly provided.
Operator FAQ
- Do I have to rewrite my existing Python or shell scripts as Temporal workflows to use legends-temporal?
- No. legends-temporal ships a single replay-safe ScriptJob workflow with a stable 11-field wire contract. You pass --script, --code, --command, --webhook-env, or --session/--spawn on the CLI (or in a JSON/YAML schedule file), and the exec worker runs your existing script or command unchanged with shell=False and a hard timeout.
- What happens if my workstation or GPU exec machine is asleep when a scheduled job fires?
- By splitting the control queue (workflow_queue on an always-on server) from the exec queue (exec_queue on the machine that owns the files or hardware), the workflow starts on time and holds the run_script activity in the exec queue for up to wait_for_worker_s (6 hours by default). As soon as the exec machine wakes up and its worker polls the queue, the job runs.
- How does workflow history --diagnose differ from standard Temporal history commands?
- Standard history commands dump dozens of raw protobuf HistoryEvent objects that can consume thousands of tokens in an agent's context window. workflow history --diagnose parses those events locally and returns a compact verdict containing the terminal status, failed activity, script exit code (including 124 for timeouts and 127 for missing binaries), worker identity, the last lines of script output, notice delivery status, a relative-time timeline, and a remediation hint.
- How does legends-temporal prevent secrets and webhook URLs from leaking into Temporal workflow history?
- Temporal persists workflow inputs and activity payloads in its database and displays them in the Web UI. legends-temporal keeps secrets out of payloads by referencing environment variable names instead of values: --webhook-env passes only the env var name to the worker, api_key_env names the env var holding your Temporal Cloud API key, and notifier credentials are read from the worker's local filesystem at call time.
Work Directly With Benjamin (Async-First Advisory & 48-Hour Diagnostics)
Message Benjamin directly by text or voice note at /dm, or start at /home#home-offer: Step 1: Missing customers study ($256) (48-hour service-area Google Maps heatmap, competitor demand report, site teardown, and ranked fix checklist), Step 2: Tech & marketing game plan ($1,024) (full study plus software/vendor/agency cut list, custom AI workflow map, and 90-day execution plan), or Step 3: Fractional CTO retainer ($4,096/mo) (same-day direct line to Benjamin, study and game plan kept current, second opinion on every quote or hire, and on-demand live screen-shares under the one-page retainer agreement).
All cto-legends Packages (CLI Router + On-Demand Modules)
cto-legends · GitHub: Stop memorizing CLI flags and managing dozens of skill folders. Register one vendor-agnostic router skill with any AI coding agent, speak to your coding agent in plain english, and let it load curated open-source tools on demand with every change previewed first.
legends-empire · GitHub: Turn your local Markdown vault into source-cited AI agent memory: ships the Seven Provinces starter map (Work, Money, Craft, Home, People, Self, Ambition), instant local search, SHA-256 research intake, the Ontology Engine, and hash-locked transactions.
legends-hetzner · GitHub: Scan live European Hetzner Cloud CX43, CX33, CX23, and CAX stock, compare Fractional CTO x86 and ARM64 sizing, and enforce 10-check SHA-256 preflight plans before provisioning or sniping any server.
legends-coolify · GitHub: Audit your self-hosted Coolify v4 servers, Docker container states, deployment queues, Dockerfile/Compose environment variable keys, and database backup schedules over pinned read-only HTTPS with zero secret exposure.
legends-cloudflare · GitHub: Execute preview-first Cloudflare DNS updates and cutovers that preserve orange-cloud proxy states, guard multi-record hostnames, and verify every change via live API readback.
legends-astro · GitHub: Migrate WordPress, Next.js, or legacy HTML sites to Astro v7 with a pre-build route and SEO parity contract, offline documentation, and post-build verification.
legends-github · GitHub: GitHub repository audit, release readiness, DataForSEO 20-topic SEO discovery, non-destructive README scoring, and 1280x640 Open Graph social preview pixel-parity CLI for coding agents.
legends-stripe · GitHub: Audit Stripe .env price IDs, issue orphan-free B2B Hosted Invoices and scan overdue receivables, sync Test and Live price ladders behind SHA-256 plan locks, reconcile fixed-fee drag and net retained cash to the cent, and verify raw-body HMAC webhooks with zero dependencies.
legends-gohighlevel · GitHub: Operate GoHighLevel sub-accounts, batch-clone V2 snapshots with headless PIT minting, X-ray and rebrand internal workflow steps, stage A2P 10DLC Trust Center profiles, and enforce 5-layer agency permissions and 4-store SaaS rebilling markups.
legends-dataforseo · GitHub: Query a 53-route DataForSEO v3 catalog covering Google SERPs, AI Optimization LLM citations, Google AI Mode, Maps, Labs, Backlinks, and On-Page Lighthouse JSON with fail-closed decoy SERP defense, automatic Page-1 /goto domain unmasking, 5x search-operator cost guards, and SHA-256 local evidence banking.
legends-geogrid · GitHub: Map your entire Google Maps territory on a true circular lattice up to 30 positions deep at wholesale DataForSEO rates: ships with a 1,249-point Austin pizza study, 7 interactive and print views, a CSP-safe embeddable viewer with Location and Competitors map-recoloring tabs, multi-angle Street View signage dossiers, and vector PDF strategy reports.
legends-firecrawl · GitHub: Run the 15-route Firecrawl v2 catalog (lfc) and 114-provider Alexandria data catalog (lax) with fail-closed SERP verification, /goto platform resolution, local PDF/DOCX parsing, 43M research papers, and SHA-256 local evidence banking.
legends-grant · GitHub: Search federal, state, and foundation grants across 56 US jurisdictions, verify verbatim eligibility rules against your private company facts, and check proposal budgets to the cent.
legends-youtube · GitHub: Unified YouTube Data API v3, Analytics API v2, Studio packaging, and verified yt-dlp media archiving CLI: 2-unit channel inventory, 0-quota outlier and public readback radar, Perfect Video Score idea scoring, anonymous SHA-256 yt-dlp batch capture, GPU word-timed FFmpeg clips, lossless ETag metadata updates, SHA-256 private-draft uploads, and an 18-file Empire knowledge pack.
legends-obs · GitHub: Automate OBS Studio over its local WebSocket v5 server with scene and source filter topology audits, audio gain and track preflight, idle-only profile backups, window-aware scene switching, and FFprobe canary clip verification.
legends-captions · GitHub: Repair misheard technical terms, lock letter-by-letter acronym timing, render frame-accurate 9:16 and 16:9 ASS subtitles, and format injection-safe FFmpeg burn-in filtergraphs.
legends-stable-audio-3 · GitHub: Preview-first Stable Audio text-to-audio, audio-to-audio, and inpainting CLI studio with duration/seed/credit guardrails, SHA-256 WAV/MP3 stem banking, and active-cue loudness mastering.
legends-hyperyap · GitHub: Push-to-talk local GPU voice dictation for Windows, macOS, and Linux: transcribe speech offline with NVIDIA Parakeet and paste straight into your active editor or terminal.
legends-ambient-intelligence · GitHub: Offline voice-memo and field-recording transcription pipeline: archive USB voice recorders with SHA-256 deduplication, run local faster-whisper or Parakeet ASR, stitch 15-minute recorder rollovers, and distill structured legends-empire Markdown notes.
legends-temporal · GitHub: Replace fragile crontabs, sleep loops, and rate-limited chat-app schedulers with server-side Temporal schedules, one-shot start_delay timers, first-class cto-legends --module scheduling, live orphaned-queue and inventory drift audits, local/Docker/systemd cluster bootstrap blueprints, and single-screen event-history failure verdicts.
legends-jev · GitHub: Local Python OCR and visual verification for UI screenshots, exact original-image pixel_box coordinates, Street View storefront signage audits, and 120s-gated UI action advice.
legends-buzz · GitHub: Operate self-hosted Block Buzz Nostr relays, validate NIP-01/NIP-19 secp256k1 Bech32 and hex keys, route all 26 Buzz domains through token-compact CLI calls, diagnose NIP-29 and NIP-FI membership 403s, isolate reply threads, and lock relay publishing behind SHA-256 plan hashes.