AWS Flywheel

Autonomous multi-branch release engine — 3 bug + 1 UX fix per branch, every hour, self-learning, self-healing.

21 branches 24h cooldown 1 release/hour 253+ releases

Full source: github.com/unclehowell/datro/tree/cnei/flywheel

Architecture

A cron job (0 * * * *) on an AWS EC2 instance selects one branch via round-robin rotation, runs 4 automated fix passes against its working tree, commits and tags, and publishes a GitHub release with structured notes. An executive-coach meta-review runs separately at 00:00 UTC daily on a command machine, reviewing AWS output and self-improving the flywheel code.

Cron (HH:00) Select branch Pass 1: AI → Pool → Fallback Pass 2: Pool only Pass 3: Fallback guaranteed Pass 4 UX: AI → Pool → Fallback Build validate → Commit → Tag → Push GitHub Release Cloudflare Deploy

Components

FileRole
multi-branch-release.shBash orchestrator — cron entrypoint, branch selection, pass dispatch, git/release
intelligence.pyPython intelligence pipeline — builds LLM prompts, applies fixes, manages profiles, self-learns
gather_review_data.pyLog parser — extracts fix source ratios (AI vs Pool vs Fallback) from AWS logs for meta-review
meta-review.shExecutive coach — fetches AWS state, runs intelligence.py --type meta, syncs profile learnings
release-state.jsonState file — rotation index, cooldowns, release counters, fix/ux rotation pointers
profiles.jsonPer-branch profiles — LLM rotation lists, learned patterns, skill libraries, branch knowledge
agent/branches/*.mdBranch context files — soul/manifest/memory per branch, category, cornerstone mission

21 Branches

Each branch deploys independently via Cloudflare Pages at {branch}.datro.xyz:

BranchCategoryDomainReleases
financechequeE-commercefinancecheque.uk150
ccanCommunityccan.datro.xyz16
altheaCommunityalthea.datro.xyz7
bpvsbucklerE-commercebpvsbuckler.datro.xyz5
carfinancechequeE-commercecarfinancecheque.datro.xyz5
ceoPlatformceo.datro.xyz7
dashPlatformdash.datro.xyz5
datroMetadatro.xyz6
dccCommunitydcc.datro.xyz6
guiPlatformgui.datro.xyz6
hbnbE-commercehbnb.datro.xyz6
libraryDocumentationlibrary.datro.xyz6
llmwikiDocumentationllmwiki.datro.xyz5
subreposPlatformsubrepos.datro.xyz4
uiPlatformui.datro.xyz5
wavePlatformwave.datro.xyz5
waybackArchivewayback.datro.xyz4
whitepaperDocumentationwhitepaper.datro.xyz3
archivesArchivearchives.datro.xyz5
cneiMetacnei.datro.xyz
greathousefarmAdvocacygreathousefarm.datro.xyz1

All content lives under static/{branchname}/ in the repo. Cloudflare Pages root_dir is set per project to that prefix.

Pass Strategy — Fix Diversity Enforcement

The original loop (for pass in 1 2 3) always let the AI win, resulting in 105/105 console.log removals. The strategy was redesigned into individually-controlled passes:

PassSourcePurpose
1 (Bug)AI → Rotating Pool → FallbackAI finds professional improvements (SEO, structured data, accessibility). If AI fails, pool rotates through 32 fix functions. Last resort: guaranteed fallback.
2 (Bug)Rotating Pool onlyGuarantees pool diversity — skips AI entirely so the rotating pool always gets a turn.
3 (Bug)Guaranteed FallbackAlways runs — catches triple-blank-lines via rg -U multiline matching.
4 (UX)AI → Rotating Pool → FallbackUser-experience improvements (viewport, tap targets, hover styles, skip links, print styles, etc.).

Rotating Fix Pool — 32 Bug Functions

CategoryFix Functions
SEOfix_meta_description, fix_canonical_url, fix_og_tags, fix_twitter_card, seo_structured_data, seo_keywords_meta
Accessibilityfix_lang_attribute, fix_aria_label, fix_label_for, fix_button_type, fix_heading_hierarchy
HTML Standardsfix_doctype, fix_charset_meta, fix_viewport_meta, fix_self_closing, fix_br_syntax, fix_http_equiv, fix_form_charset, fix_bom
Security/Performancefix_link_noopener, fix_script_defer, fix_img_dimensions, fix_inline_handlers
Code Qualityfix_console_log, fix_commented_code, fix_trailing_whitespace, fix_blank_lines, fix_tabs_vs_spaces, fix_duplicate_ids, fix_404_title

Rotating UX Pool — 17 UX Functions

CategoryFix Functions
Mobileux_viewport, ux_mobile_tap, ux_touch_action, ux_table_responsive
Interactionux_hover_styles, ux_button_states, ux_smooth_scroll, ux_focus_visible, ux_keyboard_nav
Layoutux_css_order, ux_z_index, ux_spacing, ux_type_scale, ux_cls_fix
Accessibility/UXux_skip_link, ux_breadcrumb, ux_print_styles, ux_loading_indicator

Each pool function:

Cornerstone Missions

Instead of telling the AI to "find a bug", the system prompts it to "Benchmark this site against professional standards for its category." Each branch has a category (ecommerce, community, platform, documentation, advocacy, archive, meta) with a custom checklist:

CategoryFocus Areas
E-commerceJSON-LD Product/Offer, OG tags, cookie consent, payment security, trust signals, GDPR privacy policy, returns policy, sitemap.xml, robots.txt, checkout UX, search filter
CommunityJSON-LD DiscussionForum, signup/login flow, moderation tools, privacy policy, member profiles, notifications, search, pagination, onboarding
PlatformJSON-LD WebApplication, API docs, status page, rate limiting, auth flows, dashboard UX, error pages, changelog
DocumentationJSON-LD TechArticle, table of contents, search, breadcrumbs, code copy buttons, dark mode, version selector, last-updated timestamps

The --constraint CLI parameter injects blacklist rules: the AI is told what NOT to do (no console.log removal, no whitespace cleanup, no comment deletion — those belong to the pool).

Self-Learning Profiles

Every branch has a profile in profiles.json with:

After every fix, learn_from_fix() updates the profile atomically. The AI prompt dynamically injects recent reflections, successful patterns, branch knowledge, and the skill library so each run builds on prior context.

AI Fix Pipeline

  1. intelligence.py loads the branch context (branch.md + category checklist), profile (history + skills + reflections), and builds a prompt with the Cornerstone Mission
  2. The prompt is sent to the LLM rotation (first available API endpoint)
  3. The LLM returns a JSON fix specification (file_path, bug_description, tool, new_str or sed old_str)
  4. intelligence.py --apply applies the fix to the working tree
  5. If package.json exists, npx eslint runs on the changed file for build validation
  6. If lint fails, the fix is reverted (git checkout -- file) and the error is fed back for up to 3 self-correction attempts
  7. On success, the branch memory, global memory, and profile are updated

Meta-Review (Executive Coach)

Runs daily at 00:00 UTC on a separate command machine via meta-review.sh:

  1. SSH into the AWS server and fetch the last 200 log lines and release-state.json
  2. Run gather_review_data.py to parse log for fix source classification (AI vs POOL vs FALLBACK, unique fix types per session)
  3. Run intelligence.py --type meta --branch aws to analyze AWS performance and suggest improvements
  4. Apply suggested changes to the flywheel scripts
  5. Sync back: download AWS profiles, merge successful_fixes/skill_library/reflections/learned_patterns/branch_knowledge
  6. Push updated code to GitHub

Versioning & Releases

Tags follow {branch}-v0.0.{patch}.{build:02d}:

release_number = total_releases[branch] + 1
patch  = release_number / 100          # increments every 100 releases
build  = release_number % 100          # 0–99, zero-padded
version = 0.0.{patch}.{build:02d}

Each GitHub release contains:

## [{tag}] - YYYY-MM-DD

### Fixed
- fix(branch): Add JSON-LD structured data for SEO
- fix(branch): Add meta description tag for SEO
- fix(branch): Remove duplicate blank lines (guaranteed fallback)

### Changed
- ux(branch): Add skip-to-content link for keyboard accessibility

After release, the system:

Cooldown & Branch Selection

24-hour cooldown per branch, enforced by comparing last GitHub release timestamp against current time. Selection is round-robin via rotation_index in state file. If all branches are on cooldown, the script finds the branch closest to expiry and sleeps up to 1 hour. A FORCE_BRANCH env var bypasses rotation for manual targeting.

Cloudflare Pages Integration

Every branch has a Cloudflare Pages project with:

Deploy Your Own

Server Setup

# Ubuntu 24.04 EC2 (t3.small+)
sudo apt update && sudo apt install -y git python3 ripgrep nodejs npm
npm install -g wrangler
sudo apt install -y gh && gh auth login

Clone & Configure

git clone https://github.com/YOUR_USER/YOUR_REPO.git ~/repo
mkdir -p ~/.fcukproxy
cp multi-branch-release.sh intelligence.py profiles.json ~/.fcukproxy/
# Edit BRANCHES array and GITHUB_REPO in multi-branch-release.sh
# Add 24h cron:
0 * * * * /home/ubuntu/.fcukproxy/multi-branch-release.sh >> ~/logs/multi-branch-release.log 2>&1

Required Files

Security Model

State File Reference

{
  "rotation_index": 1,
  "total_releases": { "financecheque": 150, "archives": 5, ... },
  "last_release":   { "financecheque": 1779506355, "archives": 1779500752, ... },
  "fix_rotation": 23,
  "ux_rotation": 0
}

Licence

MIT — use freely, adapt for your own repos. Source at github.com/unclehowell/datro/tree/cnei/flywheel.


Generated by the cnei branch — source · Last update: May 2026