System Overview
AutoBook V4 is a tiered dispatch system for autonomous book production. It routes every task to the simplest, cheapest tier that can handle it — from free shell scripts up to Claude Code on a Pro Max plan.
What It Does
V4 manages the full lifecycle of self-published fiction: manuscript authoring, editorial QA, cover art, marketing, Amazon Ads campaigns, KDP publishing, and cross-role coordination. It runs across three physical machines with four execution tiers.
The Four Tiers at a Glance
| Tier | Engine | Cost | Latency | Use For |
| 0 |
Shell / Python scripts |
Free |
<5s |
Git status, inbox sweeps, file checks, email, reports |
| 1 |
Ollama (local LLMs) |
Free |
10–120s |
Summarization, first-draft content, validation, triage |
| 2 |
Browser AI (Playwright) |
Subscription |
60–300s |
Chunk production, QA passes, editorial, image gen |
| 3 |
Claude Code CLI |
Pro Max quota |
30–1200s |
Complex multi-step tasks, repair, orchestration |
Key Entry Points
| What You Want | Command |
| Talk to a role interactively | python talk.py codexthewriter |
| Ask a role a one-off question | python ask.py reviewer "Is chapter 7 ready?" |
| Dispatch a task | python dispatch/dispatcher.py --role adsmanager --task pulse_review |
| Queue work for later | python batch/batch_submit.py codexthewriter chunk_production ... |
| Check system health | python monitoring/health_dashboard.py |
| Check costs/usage | python monitoring/cost_tracker.py --days 30 |
Architecture & Dispatch Flow
Every task flows through the same pipeline: gate → classify → execute → validate → done or escalate.
TASK (cron, bus message, manual, batch queue)
│
▼
┌─────────────────────────────────┐
│ Pre-Dispatch Gate │
│ • Deduplication (5 min window) │
│ • Dependency check │
│ • Staleness filter (24h) │
│ • Rate limit check │
│ • Substrate availability │
└──────────────┬──────────────────┘
▼
┌─────────────────────────────────┐
│ Classifier │
│ (role, task_type) → tier 0–3 │
│ Uses classification_table.json │
└──────────────┬──────────────────┘
▼
┌─────────────────────────────────┐
│ Context Injection │
│ Dynamic file loading per task │
└──────────────┬──────────────────┘
▼
┌─────────────────────────────────┐
│ Tier Execution │
│ Run handler for assigned tier │
└──────────────┬──────────────────┘
▼
┌─────────────────────────────────┐
│ Validator │
│ Output quality check │
└──────────┬──────────┬───────────┘
│ │
PASS ✓ FAIL ✗
│ │
Done Escalate +1 tier
(max 2 hops)
│
Tier 3 fail?
→ NEEDS_USER
Escalation Rules
- Maximum 2 escalation hops per task
- Tier 0 → 1 → 2 → 3 (but can skip tiers based on classification)
- Tier 3 failure →
NEEDS_USER status, bus message to GM
- Each tier has its own timeout; exceeding it counts as failure
Pre-Dispatch Filters
| Filter | File | Purpose |
| Deduplicator | dispatch/filters/deduplicator.py | Prevents duplicate messages (5 min window) |
| Substrate Checker | dispatch/filters/substrate_checker.py | Verifies tier is available before dispatch |
| Dependency Checker | dispatch/filters/dependency_checker.py | Checks task prerequisites are met |
Classification
The classifier maps (role, task_type) → tier using dispatch/config/classification_table.json. Examples:
| Role | Task Type | Tier |
| codexthewriter | chunk_production | 3 |
| codexthewriter | chapter_validation | 1 |
| codexthewriter | manuscript_assembly | 0 |
| adsmanager | strategy_review | 3 |
| adsmanager | pulse_review | 1 |
| generalmanager | inbox_sweep | 0 |
| coverartist | image_generation | 2 |
Tier 0 — Deterministic Scripts
Free, fast (<5s), no AI. Shell and Python scripts for file operations, status checks, and notifications.
Handler Scripts
| Script | Purpose |
tiers/tier0/inbox_sweep.py | Scan all role inboxes, report status, flag blockers and staleness |
tiers/tier0/production_status.py | Check book production readiness across series |
tiers/tier0/manuscript_sync_check.py | Verify manuscript files match across hosts |
tiers/tier0/email_sender.py | Send operational notification emails |
tiers/tier0/ads_report_cycle.py | Daily ads data fetch and organization |
tiers/tier0/daily_report_assembler.py | Assemble daily brief from multiple sources |
tiers/tier0/paperback_geometry.py | Calculate paperback wrap dimensions (spine width, bleed, etc.) |
tiers/tier0/ebook_crop.py | Crop ebook cover images to Amazon specs |
Configuration
| Setting | Value |
| Timeout | 30 seconds |
| Retry on fail | No |
| Escalate to | None (tier 0 tasks don't escalate) |
| Handlers directory | tiers/tier0/ |
Tier 1 — Ollama (Local LLMs)
Free inference on local GPUs. Summarization, first-draft content, validation, triage.
Infrastructure
| Host | URL | Hardware | Role |
| ubuntu2 primary |
http://192.168.6.67:11434 |
2x RTX 4070 Super, 125GB RAM |
43 models available |
| ubuntu1 fallback |
http://192.168.6.120:11434 |
RTX 3060, 62GB RAM |
9 models available |
Models
| Purpose | Model |
| Default / Reasoning / Coding | qwen3-coder:30b |
| Long context | glm-4.7-flash:128k |
| Large context | glm-4.7-flash:96k |
| Fast | qwen3:8b |
Handlers
| Handler | File | Purpose |
| Summarizer | tiers/tier1/summarizer.py | Summarize documents, create briefs |
| Content Drafter | tiers/tier1/content_drafter.py | Draft marketing copy, KDP content |
| Validator | tiers/tier1/validator.py | Validate manuscript quality, structure |
| Role Prompt Builder | tiers/tier1/role_prompt.py | Build system prompts for role sessions |
| Bus Writer | tiers/tier1/bus_writer.py | Format and write bus messages |
| Bus Tools | tiers/tier1/bus_tools.py | Ollama function-calling tools for bus |
Configuration
| Setting | Value |
| Timeout | 300 seconds |
| Max retries | 1 |
| Escalate to | Tier 2 |
| Temperature | 0.7 |
| Max context tokens | 128,000 |
Tier 2 — Browser AI (Playwright)
Subscription-tier AI via managed Chrome sessions on ubuntu1. Claude.ai, ChatGPT, and Perplexity for production-grade content work.
Browser Instances
| Instance | CDP Port | Host | Chrome Profile | Tabs |
| coverartist |
9226 |
ubuntu1 |
codex_cover_lab |
ChatGPT, Claude, Perplexity, Canva |
| writer |
9229 |
ubuntu1 |
codex_writer |
ChatGPT, Claude, Perplexity |
| reviewer |
9230 |
ubuntu1 |
codex_reviewer |
ChatGPT, Claude, Perplexity |
Platform Routing
Each task type routes to the best AI platform:
| Platform | Task Types |
| Claude.ai |
editorial, structural, developmental, chunk_production, chunk_repair, qa_pass, deep_read, inflation, content_polish, manuscript_review, evaluation |
| ChatGPT |
image_generation, cover_prompts, cover_review |
| Perplexity |
continuity_check, truth_check, fact_checking, research |
Configuration
| Setting | Value |
| Timeout | 600 seconds |
| Max retries | 1 |
| Escalate to | Tier 3 |
| Auth check interval | 300 seconds |
| Fallback host | Mac |
Tier 3 — Claude Code CLI
Pro Max plan Claude Code. Last resort for complex multi-step tasks, chunk repair, and orchestration. Rate-limited with a 5-hour rolling window.
Hosts (tried in order)
| Host | Type | Command | Project Root |
| ubuntu1 |
Local |
/home/fred/.local/bin/claude |
(local cwd) |
| ubuntu2 |
SSH |
/usr/bin/claude |
/home/fred/autobookv4 |
| Mac |
SSH |
claude |
/Users/fred/src/autobookv4 |
Rate Limiting
Matches Anthropic's real billing model — a 5-hour rolling window shared across all Claude surfaces.
| Setting | Value |
| Rolling window | 5 hours |
| Max runs per window | 40 (soft cap) |
| Min gap between runs | 30 seconds |
| Off-hours only | No (disabled) |
| Lock file | logs/tier3/.lock |
| Usage log | logs/tier3/usage.jsonl |
Prompt Caching (Session Reuse)
Tier 3 supports session reuse via --resume to take advantage of Anthropic's prompt caching (~84% token savings on batch runs). Sessions expire after 4.5 minutes (with a 30-second margin before the 5-minute cache TTL).
| Setting | Value |
| Session max age | 270 seconds (4.5 min) |
| Session storage | logs/tier3/sessions/ |
| Cache TTL (Anthropic) | 5 minutes |
Configuration
| Setting | Value |
| Timeout | 1200 seconds (20 min) |
| Escalate to | human (NEEDS_USER) |
Infrastructure
Three physical machines on the local network. Services, ports, and roles for each host.
Host Inventory
| Host | IP | Hardware | Primary Role |
| ubuntu2 |
192.168.6.67 |
2x RTX 4070 Super, 125GB RAM |
Ollama primary, Claude Code host |
| ubuntu1 |
192.168.6.120 |
RTX 3060, 62GB RAM |
Ollama fallback, Browser AI (Playwright), Claude Code host |
| Mac |
(local) |
MacBook |
Interactive Claude Code (Pro Max), development |
Port Map
| Port | Host | Service |
11434 | ubuntu2 (primary) | Ollama API |
11434 | ubuntu1 (fallback) | Ollama API |
9226 | ubuntu1 | Chrome CDP — coverartist browser |
9229 | ubuntu1 | Chrome CDP — writer browser |
9230 | ubuntu1 | Chrome CDP — reviewer browser |
8484 | (configurable) | Bus API server (HTTP REST) |
Network Diagram
┌─────────────────────┐ ┌─────────────────────┐
│ Mac (laptop) │ │ ubuntu2 │
│ │ │ 192.168.6.67 │
│ • Interactive use │ SSH │ │
│ • Claude Code CLI │────▶│ • Ollama :11434 │
│ • Development │ │ (PRIMARY, 43 models)│
│ • Git primary │ │ • Claude Code CLI │
└─────────┬───────────┘ └──────────────────────┘
│
│ SSH
▼
┌─────────────────────────────────────────────┐
│ ubuntu1 — 192.168.6.120 │
│ │
│ • Ollama :11434 (FALLBACK, 9 models) │
│ • Chrome CDP :9226 (coverartist) │
│ • Chrome CDP :9229 (writer) │
│ • Chrome CDP :9230 (reviewer) │
│ • Claude Code CLI (local) │
│ • Bus API :8484 │
│ • Batch Runner (systemd) │
└─────────────────────────────────────────────┘
Systemd Services
| Service | Host | Purpose |
batch-runner.service |
ubuntu1 / ubuntu2 |
Batch queue daemon — processes queued tasks autonomously |
bus-api.service |
ubuntu1 |
Bus HTTP API server |
Roles
Nine specialized roles, each with their own prompt, expertise, authority boundaries, and bus inbox. All report to the General Manager (except GM, who is top-level).
Role Directory
| Role | Trigger Phrases | Prompt File | Reports To |
| generalmanager |
"GM," "general manager" |
dispatch/config/roles/generalmanager.md |
(top-level) |
| codexthewriter |
"the writer," "codex" |
dispatch/config/roles/codexthewriter.md |
generalmanager |
| reviewer |
"reviewer," "review mode" |
dispatch/config/roles/reviewer.md |
generalmanager |
| productionmanager |
"production manager" |
dispatch/config/roles/productionmanager.md |
generalmanager |
| adsmanager |
"ads manager," "ads" |
dispatch/config/roles/adsmanager.md |
generalmanager |
| coverartist |
"cover artist," "covers" |
dispatch/config/roles/coverartist.md |
generalmanager |
| marketingmanager |
"marketing manager" |
dispatch/config/roles/marketingmanager.md |
generalmanager |
| gitmanager |
"git manager," "git" |
dispatch/config/roles/gitmanager.md |
generalmanager |
| tiktokmanager |
"tiktok," "booktok" |
dispatch/config/roles/tiktokmanager.md |
marketingmanager |
Reporting Hierarchy
generalmanager
/ | \ \ \ \
/ | \ \ \ \
codexthewriter reviewer productionmanager adsmanager coverartist gitmanager
|
marketingmanager
|
tiktokmanager
Interactive Mode
Roles are activated via talk.py or by saying their trigger phrase in a Claude Code session. When activated:
- Role prompt loaded from
dispatch/config/roles/{role}.md
- Startup files read (series bibles, recovery docs, etc.)
- Bus inbox checked for pending messages
- Role identity adopted — it discusses, proposes, and pushes back
- Handoffs create real bus messages to target roles
Role Rate Limits
| Role | Max Tasks/Hour |
| generalmanager | 6 |
| productionmanager | 4 |
| codexthewriter | 4 |
| gitmanager | 4 |
| marketingmanager | 4 |
| coverartist | 3 |
| adsmanager | 3 |
| tiktokmanager | 3 |
| reviewer | 3 |
| Global max: 20/hour |
Bus & Messaging
Filesystem-based inter-role messaging. Roles communicate by dropping JSON files into each other's inboxes. Optional HTTP API for remote clients.
How It Works
Role A Role B
│ │
│ bus.send_message(to="B",...) │
│ ─────────────────────────▶ │
│ │
│ bus/inboxes/B/new/msg.json │
│ │
│ (dispatcher reads inbox)
│ │
│ bus/inboxes/B/processed/ │
│ │
Directory Structure
bus/
bus.py # Core send/read functions
api_server.py # HTTP API (port 8484)
email_bridge.py # Email notifications
templates/ # Email templates
inboxes/
{role}/
new/ # Unprocessed messages
processed/ # Archive
Message Format
{
"id": "20260315T143000Z_sender_receiver",
"from": "codexthewriter",
"to": "reviewer",
"type": "READY_FOR_HANDOFF",
"subject": "Chapter 7 ready for QA",
"summary": "Completed chunk production for SP04 ch7",
"refs": ["series/shady_pines/books/04/production/..."],
"dispatch": {
"task_type": "manuscript_review",
"quality_bar": "publication_ready"
},
"priority": "normal",
"timestamp": "2026-03-15T14:30:00Z"
}
Message Types
| Type | Meaning |
BLOCKER | Something is blocked — needs attention |
CLEAR | A previous blocker has been resolved |
READY_FOR_HANDOFF | Work product ready for next role |
NEEDS_REVIEW | Requesting review of deliverable |
NEEDS_USER | Human intervention required |
CRON | Scheduled/automated task trigger |
Bus API (HTTP)
| Endpoint | Method | Purpose |
/bus/send | POST | Send a message |
/bus/escalate | POST | Escalate to department boss |
/bus/inbox/<role> | GET | Check role inbox |
/bus/email | POST | Send operational email |
/bus/status | GET | Health check + summary |
/bus/roles | GET | List valid roles and bosses |
Auth: Bearer token via env BUS_API_TOKEN or secrets/bus_api_token.txt
Batch Queue
Queue up tasks before closing the laptop. The batch runner drains them sequentially on ubuntu — no races, no parallelism.
Architecture
You (on Mac) ubuntu (daemon)
───────────── ────────────────
batch_submit.py batch_runner.py (systemd)
│ │
│ flock(queue.lock) │ flock(queue.lock)
│ write to queue.json │ read from queue.json
│ release lock │ mark task "running"
│ │ release lock
▼ │
Close laptop. ▼
Go to sleep. dispatch(role, task)
│
validate result
│
┌────┴────┐
pass fail
│ │
mark done mark failed
bus → GM
Commands
# Submit a single task
python batch/batch_submit.py codexthewriter chunk_production \
--subject "Write chapter 7" \
--refs series/shady_pines/books/04/chunks/ch07.md
# Submit a range of chunks
python batch/batch_submit.py codexthewriter chunk_production \
--chunks 7-20 --series shady_pines --book 04
# Check queue status
python batch/batch_submit.py --status
# Run queue (one-shot)
python batch/batch_runner.py
# Run as daemon (poll every 60s)
python batch/batch_runner.py --daemon 60
# Monitor health (cron, every 15 min)
python batch/batch_monitor.py --notify
Task States
| State | Meaning |
pending | Queued, waiting to run |
running | Currently being dispatched |
done | Completed successfully |
failed | Failed (GM notified via bus) |
paused | Queue paused (e.g., auth expired) |
Safety Features
- File locking —
fcntl.flock on queue.lock prevents concurrent access
- Sequential draining — one task at a time, never parallel
- Rate-limit backoff — returns task to pending and sleeps for
wait_seconds
- Auth expiry detection — pauses queue and sends CRITICAL to GM
- Stuck task detection — monitor flags tasks running >45 minutes
- Failure rate alerting — monitor flags >50% failure rate
Systemd Service
# Install on ubuntu
bash batch/systemd/install.sh
# Manage
systemctl --user start batch-runner
systemctl --user stop batch-runner
systemctl --user status batch-runner
journalctl --user -u batch-runner -f
Ads System (Amazon Sponsored Products)
34-tool system for Amazon Ads API. Strategy vocabulary, campaign lifecycle, bid optimization, and automated pulse analysis.
Strategy Vocabulary
Discovery
Auto/Broad campaigns find converting search terms. Higher ACOS acceptable — we're learning.
Harvesting
Promote winners from auto to manual exact. Requires 2+ orders below target ACOS.
Scale
Increase bids on profitable terms. Maximize impression share where we're already winning.
Defend
Brand/ASIN defense. Protect own product pages from competitor ads.
Per-Series Goals
| Series | Target ACOS | Daily Budget | Campaigns |
| Reset | 35% | $15/day | auto + manual exact |
| Salon Deck | 40% | $20/day | auto + manual retarget |
| Shady Pines | 30% | $30/day | auto + manual + keyword exact defense |
Safety Guards
| Guard | Value |
| Max actions per pulse | 20 |
| Max bid decrease | $0.10/pulse |
| Max bid increase | $0.15/pulse |
| Change cooldown | 48 hours per target |
| Bid ceiling | $2.00 |
| Max spend increase | $5/day |
| Min data requirement | 3 days |
Core Modules
| Module | File | Purpose |
| Tool Dispatcher | ads/tool.py | Unified CLI/HTTP/Python interface (34 tools) |
| API Client | ads/client.py | Amazon Ads API wrapper |
| Scanner | ads/scanner.py | Campaign analysis (ACOS, waste, performers) |
| Decider | ads/decider.py | Classify actions (approve/escalate/hold) |
| Applier | ads/applier.py | Apply approved actions to Amazon |
| Puller | ads/puller.py | Download reports |
| Pulse | ads/pulse.py | Periodic analysis (8, 14, 20 UTC) |
| Auth | ads/auth_setup.py | OAuth token setup and refresh |
Tool Complexity Tiers
| Tier | Type | Speed | Example |
| A | File reads (cached) | Sub-second | campaign_status |
| B | API list calls | <5s | list_campaigns |
| C | Async report queries | 30–60s | pull_search_term_report |
| D | Actions (write) | Variable | update_bid, add_negative |
Quick Commands
# CLI
python -m ads.tool campaign_status
python -m ads.tool series_strategy --args '{"series_name": "Shady Pines"}'
# HTTP
curl -X POST http://localhost:8484/ads/tool \
-d '{"tool": "campaign_status"}'
# Python
from ads.tool import AdsTool
AdsTool().call("campaign_status", {})
Scheduling
Cron-based task scheduling. Each scheduled task dispatches through the standard pipeline.
How It Works
# Cron calls the runner script
*/30 * * * * /path/to/scheduling/runner.sh generalmanager_inbox_sweep
# Runner parses schedule.json, calls dispatcher.py
# Dispatcher handles classification, execution, validation
Commands
# Run a specific scheduled task
./scheduling/runner.sh generalmanager_inbox_sweep
# Check which schedules are due
./scheduling/runner.sh --check-schedule
# Generate crontab entries from schedule.json
./scheduling/runner.sh --generate-crontab
# Install the generated crontab
./scheduling/runner.sh --generate-crontab | crontab -
Configuration
Schedules are defined in scheduling/schedule.json. Each entry specifies role, task_type, cron expression, and enabled state. Logs go to logs/cron/.
Key Scheduled Tasks
| Task | Schedule | Role |
| Inbox sweep | Every 30 min | generalmanager |
| Batch queue monitor | Every 15 min | (system) |
| Ads pulse | 8, 14, 20 UTC | adsmanager |
| Daily brief | Daily | generalmanager |
Monitoring
Health dashboard and cost tracker for understanding system state and tier usage.
Health Dashboard
# Today's health
python monitoring/health_dashboard.py
# Specific date
python monitoring/health_dashboard.py --date 2026-03-10
# Raw JSON output
python monitoring/health_dashboard.py --json
Reports: per-tier task counts, per-role task counts, failure/escalation counts, inbox status, infrastructure health.
Cost Tracker
# Last 7 days
python monitoring/cost_tracker.py
# Last 30 days
python monitoring/cost_tracker.py --days 30
# Raw JSON
python monitoring/cost_tracker.py --json
Tracks tier usage and verifies lower-tier adoption. Tier labels: 0 = Scripts (free), 1 = Ollama (free), 2 = Browser AI (subscription), 3 = Claude Code (Pro Max quota).
Batch Monitor
# Check batch queue health (run from cron every 15 min)
python batch/batch_monitor.py --notify
Detects: paused queue, stuck running tasks (>45 min), high failure rate (>50%), stale pending tasks (>4h). Posts BLOCKER to GM inbox when unhealthy.
Log Locations
| Log | Location | Format |
| Dispatch runs | logs/dispatch/run_{date}_{time}/dispatch.jsonl | JSONL events |
| Tier 3 usage | logs/tier3/usage.jsonl | JSONL with timing, host, cost |
| Batch daemon | logs/batch/daemon.log | Plaintext |
| Cron tasks | logs/cron/ | Per-task logs |
Commands Quick Reference
Every command you need, organized by task.
Dispatching
# Dispatch a task
python dispatch/dispatcher.py --role generalmanager --task inbox_sweep
# Process a role's inbox
python dispatch/dispatcher.py --role codexthewriter --inbox
# Dispatch a specific message
python dispatch/dispatcher.py --role reviewer --message path/to/message.json
# Dry run (classify only, don't execute)
python dispatch/dispatcher.py --role adsmanager --task strategy_review --dry-run
Interactive Roles
# Start a role conversation
python talk.py codexthewriter
python talk.py adsmanager --model qwen3-coder:30b
# Ask a one-off question
python ask.py reviewer "Is the QA report for SP04 ready?"
Batch Queue
# Submit task
python batch/batch_submit.py codexthewriter chunk_production \
--subject "Write chapter 7" \
--refs series/shady_pines/books/04/chunks/ch07.md
# Submit chunk range
python batch/batch_submit.py codexthewriter chunk_production \
--chunks 7-20 --series shady_pines --book 04
# Import from JSON file
python batch/batch_submit.py --import tasks.json
# Queue status
python batch/batch_submit.py --status
# Run queue (one-shot or daemon)
python batch/batch_runner.py
python batch/batch_runner.py --daemon 60
Monitoring
python monitoring/health_dashboard.py
python monitoring/health_dashboard.py --date 2026-03-10 --json
python monitoring/cost_tracker.py --days 30
python batch/batch_monitor.py --notify
Scheduling
./scheduling/runner.sh generalmanager_inbox_sweep
./scheduling/runner.sh --check-schedule
./scheduling/runner.sh --generate-crontab | crontab -
Ads
python -m ads.tool campaign_status
python -m ads.tool series_strategy --args '{"series_name": "Shady Pines"}'
python -m ads.tool pull_search_term_report
Infrastructure
# Install batch runner systemd service
bash batch/systemd/install.sh
# Manage batch runner
systemctl --user start batch-runner
systemctl --user status batch-runner
journalctl --user -u batch-runner -f
Entry Points
The main executable files and what they do.
Root-Level Scripts
| File | What It Does |
talk.py |
Interactive role conversation. Loads a role's full prompt, reads its startup files, checks its bus inbox, then opens a persistent chat session. The role adopts its identity and can send bus messages. Usage: python talk.py codexthewriter |
ask.py |
One-off role question. Send a question to a role and get an answer through the dispatch pipeline. No persistent session. Usage: python ask.py reviewer "Is chapter 7 ready?" |
dispatch/dispatcher.py |
Central dispatcher. The core routing engine. Classifies tasks, runs pre-dispatch filters, executes on the assigned tier, validates output, and escalates on failure. |
batch/batch_submit.py |
Queue tasks for autonomous processing. Add tasks to the batch queue before closing the laptop. Supports single tasks, chunk ranges, and JSON imports. |
batch/batch_runner.py |
Batch queue daemon. Drains the queue sequentially, one task at a time. Runs as a systemd service or one-shot command. |
batch/batch_monitor.py |
Queue health checker. Detects stuck tasks, high failure rates, and paused queues. Posts alerts to GM's bus inbox. |
monitoring/health_dashboard.py |
System health report. Per-tier/per-role task counts, failures, escalations, inbox status. |
monitoring/cost_tracker.py |
Tier usage analysis. Tracks which tiers handle which work over time. Verifies cost optimization. |
bus/api_server.py |
Bus HTTP API. REST API for sending bus messages, checking inboxes, and system status. Port 8484. |
ads/tool.py |
Ads tool dispatcher. 34 Amazon Ads tools accessible via CLI, HTTP, or Python. Campaign management, bid optimization, reporting. |
scheduling/runner.sh |
Cron task runner. Entry point for scheduled tasks. Parses schedule.json and dispatches through the pipeline. |
Series & Book Data
All book data lives in series/. Each series has its own directory with manuscripts, production files, covers, and QA reports.
Active Series
| Series | Directory | Genre |
| Shady Pines | series/shady_pines/ | Cozy mystery |
| Reset | series/reset/ | Thriller |
| Salon Deck | series/salon_deck/ | Cozy mystery |
| Georgetown | series/georgetown/ | Fiction |
| Bellweather | series/bellweather/ | Fiction |
| KT Trent | series/kt_trent/ | Fiction |
| Pridehouse Chronicles | series/pridehouse_chronicles/ | Fiction |
| Signed Sealed Suspect | series/signed_sealed_suspect/ | Fiction |
| The Ledger | series/the_ledger/ | Fiction |
| Tidy Tails | series/tidy_tails/ | Fiction |
| Mr. Fred Guides | series/mr_fred_guides/ | Non-fiction |
| TikTok Beginners | series/tiktok_beginners/ | Non-fiction |
Per-Series File Structure
series/{name}/
SERIES_BIBLE.md # Genre, timeline, character bibles
metadata.json # Publication dates, ISBNs
MASTER_TIMELINE.md # Character/event chronology
latest/ # Latest master manuscripts
01_{title}__manuscript.md
02_{title}__manuscript.md
books/
{num}_{title}/
{title}.md # Full manuscript
production/ # Production files
output/ # Chunk breakdown (chunk_01.md, ...)
cover/ # COVER_BRIEF.md, images
QA_REPORT.md
archive/ # Historical versions
QA System
25-pass QA system (from V3) at qa system/. Latest version: manuscript_qa_system_v7/. Covers continuity, truth checking, fact verification, beat analysis, word count gates, and structural validation.
Templates
Production templates at templates/ — BEAT_WRITING_GUIDE, CHUNK_HANDOFF_TEMPLATE, PRODUCTION_TEMPLATE, COVER_TEMPLATE, MARKETING_BIBLE_TEMPLATE, MYSTERY_DESIGN_TEMPLATE, KDP_A_PLUS_TEMPLATE, etc.
Scripts & Tools
100+ scripts in scripts/. Key utilities organized by function.
Ads Management
| Script | Purpose |
adsmanager_daily_cycle.py | Daily ads cycle runner |
adsmanager_analyze_reports.py | Analyze downloaded reports |
adsmanager_apply_actions.js | Apply bid changes (Node.js) |
adsmanager_download_reports.js | Download reports from Amazon (Node.js) |
amazon_ads_report_pull.py | Pull specific reports |
amazon_ads_update_bid.py | Update individual bids |
Book Production
| Script | Purpose |
produce_book.py | Main book production (V3) |
produce_book_ollama.py | Ollama-based production |
build_kindle.py | Kindle format build |
rebuild_chunks.py | Rebuild manuscript chunks |
rebuild_chunks_batch.py | Batch chunk rebuild |
KDP & Publishing
| Script | Purpose |
build_kdp_dashboard_data.py | KDP dashboard data |
build_kdp_master_inventory.py | Master book inventory |
kdp_live_metadata_audit.py | Audit live KDP metadata |
publish_inventory.py | Publication inventory |
publish_validate.py | Pre-publish validation |
Browser Automation
| Script | Purpose |
codex_writer_browser.py | Writer's managed browser |
general_manager_browser.py | GM's managed browser |
cover_review_browser.py | Cover review via browser |
private_playwright_browser.py | Private Chrome profile launcher |
launch_private_chrome_profile.py | Chrome profile management |
QA & Validation
| Script | Purpose |
master_fiction_qa.py | Master fiction QA runner |
check_reset_continuity.py | Series continuity checks |
check_story_arcs.py | Story arc verification |
chunk_repair_guard.py | Chunk repair validation |
Git Operations
| Script | Purpose |
git_day_start.sh | Daily git startup routine |
git_preflight.sh | Pre-push safety checks |
git_mark_publish.sh | Mark books as published in git |
git_enable_guards.sh | Enable git hooks and guards |
Other Utilities
| Script | Purpose |
benchmark_ollama_models.py | Model performance testing |
generate_atlas_packet.py | Atlas packaging |
send_ads_report_email.py | Email ads reports |
tiktok_audio.py | TikTok audio handling |
bootstrap_envs.sh | Environment setup |
Directory Map
Complete directory layout of AutoBook V4.
autobookv4/
│
├── CLAUDE.md # Project instructions (V4 dispatch)
├── README.md # Quick-start guide
├── V4_RECOVERY.md # Recovery state for roles
├── talk.py # Interactive role conversations
├── ask.py # One-off role questions
│
├── dispatch/ # Central dispatch engine
│ ├── dispatcher.py # Main dispatcher
│ ├── classifier.py # (role, task_type) → tier
│ ├── validator.py # Output quality validation
│ ├── filters/ # Pre-dispatch gates
│ │ ├── deduplicator.py
│ │ ├── substrate_checker.py
│ │ └── dependency_checker.py
│ └── config/ # All configuration
│ ├── tier_config.json # Tier definitions
│ ├── classification_table.json # Task → tier mapping
│ ├── rate_limits.json # Per-role rate limits
│ └── roles/ # 9 role prompt files
│
├── tiers/
│ ├── tier0/ # Deterministic scripts
│ ├── tier1/ # Ollama client + handlers
│ ├── tier2/ # Browser AI (Playwright)
│ └── tier3/ # Claude Code dispatch
│ └── claude_code_dispatch.py
│
├── bus/ # Inter-role messaging
│ ├── bus.py # Core functions
│ ├── api_server.py # HTTP API (:8484)
│ ├── email_bridge.py # Email notifications
│ ├── templates/ # Email templates
│ └── inboxes/ # Per-role message queues
│ └── {role}/new/
│
├── batch/ # Autonomous task queue
│ ├── batch_submit.py # Queue tasks
│ ├── batch_runner.py # Process queue
│ ├── batch_monitor.py # Health monitoring
│ └── systemd/ # Service files
│
├── ads/ # Amazon Ads (34 tools)
│ ├── tool.py # Unified dispatcher
│ ├── config.json # Campaign config
│ ├── strategy.md # Decision framework
│ ├── client.py # API wrapper
│ ├── scanner.py # Analysis
│ ├── decider.py # Action classification
│ ├── applier.py # Action execution
│ └── pulse.py # Periodic analysis
│
├── scheduling/ # Cron scheduling
│ ├── runner.sh # Cron entry point
│ └── schedule.json # Schedule definitions
│
├── monitoring/ # Health & cost tracking
│ ├── health_dashboard.py
│ └── cost_tracker.py
│
├── series/ # All book data (12+ series)
│ └── {series_name}/
│ ├── SERIES_BIBLE.md
│ ├── latest/
│ └── books/
│
├── templates/ # Production templates
├── qa system/ # 25-pass QA system
├── scripts/ # 100+ utility scripts
├── tracking/ # Coordination state
├── models/ # Ollama model definitions
├── tools/ # Integration tools
├── logs/ # All logs
│ ├── dispatch/
│ ├── tier3/
│ ├── batch/
│ └── cron/
└── docs/ # This documentation