cnei - DATRO Flywheel Engine

v0.0.2.15 Cloudflare Workers autonomous release pipeline. Runs 24/7 on */10 cron: every branch every 2h, cnei every 1h in between. Steered via command.datro.xyz joystick (left/right MD file bias).

2h
Regular branch cadence
1h
CNEI cadence
20
Branches in rotation
24/7
Cron uptime

Architecture

Runtime
Cloudflare Workers (datro-flywheel) running on a */10 * * * * cron schedule. KV namespace FLYWHEEL_STATE for persistent state (rotation index, index cards, cooldowns, hypothesis trees, eval metrics, lesson store, agent memories). No database or external runtime dependencies.
Branch Rotation (2h / 1h) FIXED
Bug fix: cooldown now correctly applies 2h for regular branches and 1h for cnei. Previously regular branches got 1h and cnei got 30min at gear 3.
Honcho Memory API FIXED
Now tries both honcho.ai and honcho.dev endpoints, falls back gracefully if both unreachable. No more silent failures.
Agent Memory Tools NEW

The agent can now self-manage its memory across runs via KV-backed tools:

Memory index maintained automatically; limit 200 entries per branch.

Lesson Store NEW

Every agent run reads lessons_{branch} KV at startup — the agent sees what went wrong in prior runs before making decisions. Lessons are recorded:

50 most recent lessons stored per branch.

Eval System

Multi-Metric Scoring IMPROVED

Each run now scores on a composite metric:

Score = max(0, (planAdherence * 0.4 + changeScore * 0.6) - mcpPenalty)

benchmarkAgainstHistory() compares against last 10 runs, detects saturation and trends.

Post-Agent Self-Verification NEW

After agent commits changes, the flywheel re-reads each modified HTML file and validates:

Release Pipeline (per branch)

  1. Check branch exists via GitHub API
  2. Compute next version from latest tag (branch-vX.X.X.XX)
  3. Load index card from KV (branch state, cycle count, failures)
  4. Load lesson store — read what failed before
  5. Run git diff analysis against last release
  6. Fetch contextual research (Semantic Scholar) + flywheel research
  7. Scan MCP tools (EAA accessibility, AccessScore)
  8. Apply wing-file visual steering blocks
  9. Run agentic AI loop (PLAN/DO/CHECK protocol, memory tools, brainstorm + MCP tools)
  10. Record multi-metric eval + benchmark against history
  11. Post-agent self-verification (HTML structural check)
  12. Generate admin note with actionable human tasks
  13. If agent made changes -> tag & release; else fallback to best-practice engine
  14. If no improvements -> audit-only release (with evals + admin note)
  15. Sync index card + eval data to Monday.com (no duplicates)

Branches

19 Branches in Rotation
BranchCategoryPurpose
cneiplatformFlywheel engine - releases itself + all other branches
waybackarchiveWayback evidence library at wayback.datro.xyz
bpvsbucklerfrontendMain application
datrofrontendLanding/documentation portal at datro.directory
+ 15 more (althea, archives, carfinancecheque, ccan, ceo, dash, dcc, financecheque, gui, hbnb, library, llmwiki, piratelaw, subrepos, ui, wave)

KV Configuration

Namespace: FLYWHEEL_STATE
KeyPurpose
index_{branch}Index card per branch (release count, cycle count, hypothesis tree)
eval_{branch}Eval metrics history (scores, trends, saturation)
failure_{branch}Failure log (last 20 entries)
lessons_{branch}Lesson store (last 50 lessons read before each agent run) NEW
memory_{branch}_{key}Agent-managed episodic memories NEW
memory_index_{branch}Memory key index for listing NEW
last_run_{branch}Unix timestamp of last run (cooldown tracking)
rotationRound-robin state (regular_index, cnei_queue, lap, mode)
configGear setting (1-10, higher = faster cycles)
biasSteering bias (direction, magnitude, risk tolerance)
brain_updatedTimestamp of last brain memory refresh (cached 1h) NEW
lockConcurrency lock (TTL 1 hour)
wallet_{branch}_{type}Branch wallet cache (TTL 24h)
bounty_{branch}Gitlawv bounty claim history
last_cnei_releaseLatest cnei release tag + timestamp
mcp_last_scanLast MCP scan cache

Agent Tools (MCP Schema)

14 Tools with JSON Schema inputSchema
ToolDescription
read_fileRead a file from any branch
write_fileWrite content to a file (commits immediately)
list_branchesList all branches and their latest commit
search_codeSearch codebase for a pattern
run_scanRun a third-party MCP scan on a URL
honcho_memoryRead/write Honcho memory for this branch
wallet_infoGet crypto wallet info for any branch
brainstormAsk the LLM a question for creative thinking
rememberNEW Store a persistent fact/memory/lesson
recallNEW Retrieve a stored memory
forgetNEW Delete a stored memory
list_memoriesNEW List all memory keys for this branch
gitlawv_bounty_listList open gitlawb bounties
gitlawv_bounty_claimClaim a gitlawb bounty
gitlawv_bounty_submitSubmit completed work for a claimed bounty

Quota Management

KV Operations Budget

Cloudflare Workers free-plan KV limits: 100K reads / 1K writes per day.

Optimisations applied to stay within budget:

Estimated daily usage: ~400 reads / ~300 writes.

Consider adding a free D1 database for eval/failure/memory storage (100K writes/day vs KV's 1K).

Branch-Specific Quotas NEW v0.0.2.15

Mandatory Unique Improvements Per Release
BranchQuota
bpvsbuckler1 new original timeline event (BP vs Buckler 1987, Great House Farm)
wayback1 new evidence item (photo, text, video, PDF) added to catalogue
all others1 unique feature (SEO, legal, agent-readability, or API endpoint) + bug fixes
Joystick MD Bias FIXED
Joystick -5..5 scale now normalises to 1..5 flywheel bias. Left/W favours *.left.md wing files; Right/E favours *.right.md. Up/N favours *.high.md; Down/S favours *.low.md. Set via command.datro.xyz.

Missing left/right wing files are auto-seeded on first release cycle per branch (ensureWingFiles).

Evidence Discovery (Wayback)

Great House Farm - Llandough (nr. Penarth)

Each wayback re-release adds at least 1 new evidence entry to the library at wayback.datro.xyz — enforced by BRANCH_QUOTAS.wayback in the flywheel agent prompt.

Deployment

CI/CD Pipeline
Push to cnei branch -> GitHub Action (cnei-safe-release.yml)
  -> wrangler deploy -> Cloudflare Workers (datro-flywheel)
  -> Cron every 10 min -> Cooldown: 2h regular / 1h cnei
  -> Each cycle: lessons -> plan -> research -> agent loop
     -> eval (multi-metric) -> self-verify -> release
  -> GitHub releases + Monday.com sync (dedup'd) + admin notes

Known Issues

Forensics Findings (v0.0.2.13)
✅ Cooldown: regular=2h, cnei=1h (was regular=1h, cnei=30min)
✅ CNEI_RATIO=1 (was 6 — cnei fired every 12h instead of every 2h)
✅ Honcho: tries .ai AND .dev endpoints (was hardcoded to .ai, possibly dead)
✅ Agent memory: remember/recall/forget/list_memories tools (was read-only passive context)
✅ Lesson store: read at agent startup (was starting blind each run)
✅ aggregateMemory: cached 1h (was running every 10min = 19+ API calls per cycle)
✅ Post-agent self-verification: HTML structural checks after commits
✅ Eval: multi-metric (plan adherence + change count - MCP penalty)
✅ Monday.com: checks for existing item before creating new one
✅ MCP JSON Schema: tool descriptions now show proper inputSchema
⚠️ Honcho endpoints may both be dead — test via curl if you see "No Honcho memory" consistently
⚠️ MCP scan tools (EAA, AccessScore) are third-party APIs — may expire without notice
⚠️ No D1 database yet — eval/failure/memory data competes for KV writes (1K/day ceiling)