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

TierEngineCostLatencyUse 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 WantCommand
Talk to a role interactivelypython talk.py codexthewriter
Ask a role a one-off questionpython ask.py reviewer "Is chapter 7 ready?"
Dispatch a taskpython dispatch/dispatcher.py --role adsmanager --task pulse_review
Queue work for laterpython batch/batch_submit.py codexthewriter chunk_production ...
Check system healthpython monitoring/health_dashboard.py
Check costs/usagepython 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

Pre-Dispatch Filters

FilterFilePurpose
Deduplicatordispatch/filters/deduplicator.pyPrevents duplicate messages (5 min window)
Substrate Checkerdispatch/filters/substrate_checker.pyVerifies tier is available before dispatch
Dependency Checkerdispatch/filters/dependency_checker.pyChecks task prerequisites are met

Classification

The classifier maps (role, task_type) → tier using dispatch/config/classification_table.json. Examples:

RoleTask TypeTier
codexthewriterchunk_production3
codexthewriterchapter_validation1
codexthewritermanuscript_assembly0
adsmanagerstrategy_review3
adsmanagerpulse_review1
generalmanagerinbox_sweep0
coverartistimage_generation2

Tier 0 — Deterministic Scripts

Free, fast (<5s), no AI. Shell and Python scripts for file operations, status checks, and notifications.

Handler Scripts

ScriptPurpose
tiers/tier0/inbox_sweep.pyScan all role inboxes, report status, flag blockers and staleness
tiers/tier0/production_status.pyCheck book production readiness across series
tiers/tier0/manuscript_sync_check.pyVerify manuscript files match across hosts
tiers/tier0/email_sender.pySend operational notification emails
tiers/tier0/ads_report_cycle.pyDaily ads data fetch and organization
tiers/tier0/daily_report_assembler.pyAssemble daily brief from multiple sources
tiers/tier0/paperback_geometry.pyCalculate paperback wrap dimensions (spine width, bleed, etc.)
tiers/tier0/ebook_crop.pyCrop ebook cover images to Amazon specs

Configuration

SettingValue
Timeout30 seconds
Retry on failNo
Escalate toNone (tier 0 tasks don't escalate)
Handlers directorytiers/tier0/

Tier 1 — Ollama (Local LLMs)

Free inference on local GPUs. Summarization, first-draft content, validation, triage.

Infrastructure

HostURLHardwareRole
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

PurposeModel
Default / Reasoning / Codingqwen3-coder:30b
Long contextglm-4.7-flash:128k
Large contextglm-4.7-flash:96k
Fastqwen3:8b

Handlers

HandlerFilePurpose
Summarizertiers/tier1/summarizer.pySummarize documents, create briefs
Content Draftertiers/tier1/content_drafter.pyDraft marketing copy, KDP content
Validatortiers/tier1/validator.pyValidate manuscript quality, structure
Role Prompt Buildertiers/tier1/role_prompt.pyBuild system prompts for role sessions
Bus Writertiers/tier1/bus_writer.pyFormat and write bus messages
Bus Toolstiers/tier1/bus_tools.pyOllama function-calling tools for bus

Configuration

SettingValue
Timeout300 seconds
Max retries1
Escalate toTier 2
Temperature0.7
Max context tokens128,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

InstanceCDP PortHostChrome ProfileTabs
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:

PlatformTask 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

SettingValue
Timeout600 seconds
Max retries1
Escalate toTier 3
Auth check interval300 seconds
Fallback hostMac

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)

HostTypeCommandProject 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.

SettingValue
Rolling window5 hours
Max runs per window40 (soft cap)
Min gap between runs30 seconds
Off-hours onlyNo (disabled)
Lock filelogs/tier3/.lock
Usage loglogs/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).

SettingValue
Session max age270 seconds (4.5 min)
Session storagelogs/tier3/sessions/
Cache TTL (Anthropic)5 minutes

Configuration

SettingValue
Timeout1200 seconds (20 min)
Escalate tohuman (NEEDS_USER)

Infrastructure

Three physical machines on the local network. Services, ports, and roles for each host.

Host Inventory

HostIPHardwarePrimary 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

PortHostService
11434ubuntu2 (primary)Ollama API
11434ubuntu1 (fallback)Ollama API
9226ubuntu1Chrome CDP — coverartist browser
9229ubuntu1Chrome CDP — writer browser
9230ubuntu1Chrome 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

ServiceHostPurpose
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

RoleTrigger PhrasesPrompt FileReports 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:

  1. Role prompt loaded from dispatch/config/roles/{role}.md
  2. Startup files read (series bibles, recovery docs, etc.)
  3. Bus inbox checked for pending messages
  4. Role identity adopted — it discusses, proposes, and pushes back
  5. Handoffs create real bus messages to target roles

Role Rate Limits

RoleMax Tasks/Hour
generalmanager6
productionmanager4
codexthewriter4
gitmanager4
marketingmanager4
coverartist3
adsmanager3
tiktokmanager3
reviewer3
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

TypeMeaning
BLOCKERSomething is blocked — needs attention
CLEARA previous blocker has been resolved
READY_FOR_HANDOFFWork product ready for next role
NEEDS_REVIEWRequesting review of deliverable
NEEDS_USERHuman intervention required
CRONScheduled/automated task trigger

Bus API (HTTP)

EndpointMethodPurpose
/bus/sendPOSTSend a message
/bus/escalatePOSTEscalate to department boss
/bus/inbox/<role>GETCheck role inbox
/bus/emailPOSTSend operational email
/bus/statusGETHealth check + summary
/bus/rolesGETList 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

StateMeaning
pendingQueued, waiting to run
runningCurrently being dispatched
doneCompleted successfully
failedFailed (GM notified via bus)
pausedQueue paused (e.g., auth expired)

Safety Features

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

SeriesTarget ACOSDaily BudgetCampaigns
Reset35%$15/dayauto + manual exact
Salon Deck40%$20/dayauto + manual retarget
Shady Pines30%$30/dayauto + manual + keyword exact defense

Safety Guards

GuardValue
Max actions per pulse20
Max bid decrease$0.10/pulse
Max bid increase$0.15/pulse
Change cooldown48 hours per target
Bid ceiling$2.00
Max spend increase$5/day
Min data requirement3 days

Core Modules

ModuleFilePurpose
Tool Dispatcherads/tool.pyUnified CLI/HTTP/Python interface (34 tools)
API Clientads/client.pyAmazon Ads API wrapper
Scannerads/scanner.pyCampaign analysis (ACOS, waste, performers)
Deciderads/decider.pyClassify actions (approve/escalate/hold)
Applierads/applier.pyApply approved actions to Amazon
Pullerads/puller.pyDownload reports
Pulseads/pulse.pyPeriodic analysis (8, 14, 20 UTC)
Authads/auth_setup.pyOAuth token setup and refresh

Tool Complexity Tiers

TierTypeSpeedExample
AFile reads (cached)Sub-secondcampaign_status
BAPI list calls<5slist_campaigns
CAsync report queries30–60spull_search_term_report
DActions (write)Variableupdate_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

TaskScheduleRole
Inbox sweepEvery 30 mingeneralmanager
Batch queue monitorEvery 15 min(system)
Ads pulse8, 14, 20 UTCadsmanager
Daily briefDailygeneralmanager

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

LogLocationFormat
Dispatch runslogs/dispatch/run_{date}_{time}/dispatch.jsonlJSONL events
Tier 3 usagelogs/tier3/usage.jsonlJSONL with timing, host, cost
Batch daemonlogs/batch/daemon.logPlaintext
Cron taskslogs/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

FileWhat 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

SeriesDirectoryGenre
Shady Pinesseries/shady_pines/Cozy mystery
Resetseries/reset/Thriller
Salon Deckseries/salon_deck/Cozy mystery
Georgetownseries/georgetown/Fiction
Bellweatherseries/bellweather/Fiction
KT Trentseries/kt_trent/Fiction
Pridehouse Chroniclesseries/pridehouse_chronicles/Fiction
Signed Sealed Suspectseries/signed_sealed_suspect/Fiction
The Ledgerseries/the_ledger/Fiction
Tidy Tailsseries/tidy_tails/Fiction
Mr. Fred Guidesseries/mr_fred_guides/Non-fiction
TikTok Beginnersseries/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

ScriptPurpose
adsmanager_daily_cycle.pyDaily ads cycle runner
adsmanager_analyze_reports.pyAnalyze downloaded reports
adsmanager_apply_actions.jsApply bid changes (Node.js)
adsmanager_download_reports.jsDownload reports from Amazon (Node.js)
amazon_ads_report_pull.pyPull specific reports
amazon_ads_update_bid.pyUpdate individual bids

Book Production

ScriptPurpose
produce_book.pyMain book production (V3)
produce_book_ollama.pyOllama-based production
build_kindle.pyKindle format build
rebuild_chunks.pyRebuild manuscript chunks
rebuild_chunks_batch.pyBatch chunk rebuild

KDP & Publishing

ScriptPurpose
build_kdp_dashboard_data.pyKDP dashboard data
build_kdp_master_inventory.pyMaster book inventory
kdp_live_metadata_audit.pyAudit live KDP metadata
publish_inventory.pyPublication inventory
publish_validate.pyPre-publish validation

Browser Automation

ScriptPurpose
codex_writer_browser.pyWriter's managed browser
general_manager_browser.pyGM's managed browser
cover_review_browser.pyCover review via browser
private_playwright_browser.pyPrivate Chrome profile launcher
launch_private_chrome_profile.pyChrome profile management

QA & Validation

ScriptPurpose
master_fiction_qa.pyMaster fiction QA runner
check_reset_continuity.pySeries continuity checks
check_story_arcs.pyStory arc verification
chunk_repair_guard.pyChunk repair validation

Git Operations

ScriptPurpose
git_day_start.shDaily git startup routine
git_preflight.shPre-push safety checks
git_mark_publish.shMark books as published in git
git_enable_guards.shEnable git hooks and guards

Other Utilities

ScriptPurpose
benchmark_ollama_models.pyModel performance testing
generate_atlas_packet.pyAtlas packaging
send_ads_report_email.pyEmail ads reports
tiktok_audio.pyTikTok audio handling
bootstrap_envs.shEnvironment 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