Skip to content

Loop-engineer comic generation - #25

Draft
elasticdotventures wants to merge 3 commits into
mainfrom
agent/loop-engineered-comics
Draft

Loop-engineer comic generation#25
elasticdotventures wants to merge 3 commits into
mainfrom
agent/loop-engineered-comics

Conversation

@elasticdotventures

Copy link
Copy Markdown
Member

Summary

  • replace one-shot comic generation with a typed writers-room loop that builds briefs, generates and ranks premises, and selects distinct mechanisms for A/B variants
  • evaluate scripts for surprise, specificity, compression, visuality, character voice, and archive novelty, with a bounded rewrite and TRIZ inversion pass
  • retain briefs, premise rankings, editorial decisions, and rewrite counts as reproducible R2 artifacts
  • add deterministic screenText rendering for dashboards, logs, eval files, alerts, and approval screens
  • disable production generation-on-read and refresh the local bootstrap comics to demonstrate the new composition
  • document the nested control loops and add focused generator, loop, renderer, and API contract coverage

Why

The previous pipeline selected a broad topic randomly, generated two scripts directly, and rendered them without a comedy-specific quality gate or feedback path. It also mandated the same robot-thought and deadpan-closer rhythm, producing structurally repetitive strips.

This change turns generation into bounded, inspectable feedback loops. Weak drafts receive targeted correction, repeated jokes are penalized against editorial memory, and the renderer can display the exact technical evidence that carries a visual payoff.

Impact

  • /api/today, voting, archive, and existing comic response shapes remain compatible.
  • Authenticated generation responses now expose the structured brief, selected premises, and final evaluations.
  • Production serves the latest completed comic instead of generating synchronously during a reader request.
  • Local development retains deterministic bootstrap generation through just dev.

Validation

  • just test: 9 loop/generator/renderer tests and existing API contracts passed
  • just build: Vue type-check and Vite production build passed
  • ./scripts/smoke-local.sh: D1 initialization, Pages Worker startup, /api/today, SVG streaming, vote upsert, archive, and push-default checks passed
  • git diff --check: passed

Remaining Validation

Production Workers AI inference was not invoked locally. An authenticated AI-enabled staging generation should be reviewed before merging for model-specific output quality and latency.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 12, 2026

Copy link
Copy Markdown

Deploying promptexecutionwebsite with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4fa6090
Status: ✅  Deploy successful!
Preview URL: https://22b67a44.promptexecutionwebsite.pages.dev
Branch Preview URL: https://agent-loop-engineered-comics.promptexecutionwebsite.pages.dev

View logs

Rewrite comic script generation into a scored writers-room loop: typed
brief/premise generation, heuristic scoring (surprise, specificity,
compression, visuality, character voice, archive novelty), and a bounded
rewrite -> TRIZ-inversion -> reject state machine. Retains briefs, premise
rankings, editorial decisions, and rewrite counts as reproducible R2
artifacts. Adds deterministic screenText rendering for dashboards, logs,
eval files, alerts, and approval screens, integrated alongside the
existing scene/pose/expression composition system. Disables
production generation-on-read and refreshes the local bootstrap comics.

Rebased onto main after PR #24 (scenario/improv-menu system and model
lineup diversification); both feature sets are merged so comic panels
carry scene, pose, beat, expression, cameo, AND screenText, and prompts
combine the shared improv menu with the structured brief/premise.

Co-authored-by: brianh <brianh@promptexecution.com>
@elasticdotventures
elasticdotventures force-pushed the agent/loop-engineered-comics branch from 06bb3c3 to 4804a60 Compare September 1, 2026 01:33
@elasticdotventures

Copy link
Copy Markdown
Member Author

Triage update: rebased, scope cleaned up, CI green — still needs a human validation pass before merge

I rebased this branch onto current main and split out unrelated scope. Draft status is unchanged; I have not merged this and am not recommending an automatic merge.

1. Conflicts resolved

main had advanced past this branch's fork point via PR #24 ("Update comic rendering pipeline"), which added its own scene/pose/expression composition system and a model-diversity/improv-menu layer — overlapping heavily with this PR's writers-room loop in the same files. I rebuilt this branch as a clean cherry-pick of only the real feature commit (feat: loop-engineer comic generation) onto current main, then manually merged the two feature sets rather than picking one side:

  • functions/lib/comic-generator.tsComicPanel now carries both main's scene/beat/visualFocus/expression/cameo fields and this PR's screenText field; the JSON schema and prompts were updated to advertise all of them together.
  • functions/lib/svg-renderer.tsdrawSceneBackdrop (main) now delegates to drawTerminalScene (this PR) using panel.screenText || panel.visualFocus, so exact on-screen text renders in-place instead of being a separate code path; detectScene combines both heuristics.
  • functions/lib/agentic-comic-workflow.ts — the biggest merge. buildComicPlan now runs both main's scenario/improv-menu generation and this PR's editorial-memory/premise-room/premise-ranking loop, and buildStandardPrompt includes both the shared improv menu and the structured brief/premise for each variant.
  • functions/lib/local-bootstrap-comic.ts — merged both PRs' demo panels into one bootstrap script that exercises scene/pose/expression composition and screenText together.
  • scripts/test-api-contracts.mjs — kept both PRs' assertions on the plan shape (scenario_setup/improv_menu and brief/premise_rankings).

One real bug surfaced during merge and is fixed: drawTerminalScene's trailing caption line still referenced the old focus parameter name after the signature was renamed to screenText, which threw a ReferenceError at render time (caught by bun run test:comic-loops, not by vue-tsc, since functions/ isn't in the Vue type-check tree). Removed the stale caption since the exact text now renders directly on the monitor.

2. Unrelated scope removed

Dropped entirely (verified via git log on each path — none were touched by any comic-generation-related commit, all came from an earlier "ledgrrr governance" documentation effort dragged along on this branch):

  • ARTIFACT_GOVERNANCE_COMPLETE.md, ARTIFACT_WORKFLOW_DIAGRAM.md, CODEGEN_VERIFICATION.md
  • SUBAGENT2_ARTIFACTS.txt, SUBAGENT2_DELIVERY.md, SUBAGENT2_IMPLEMENTATION_REPORT.md
  • UX_DISPLAY_DESIGN.md, VALIDATION_EXECUTION_ROADMAP.md, VALIDATION_TEST_PLAN.md
  • The .claude/settings.local.json diff (local tool permissions, unrelated)
  • The functions/lib/ledgrrr-wasm/*.d.ts regen (trivial exportexport declare wasm-bindgen version bump, unrelated to comic generation — main has since renamed this file to .wasm.types.txt anyway, so the old diff no longer even applies)

The PR is now 17 files / +1212 −104, scoped entirely to comic generation.

3. CI status: green

  • verify (build + contract tests): passing
  • Cloudflare Pages preview deploy: passing (failed once on a transient Cloudflare-side build error unrelated to this code — confirmed by retriggering with an empty commit against the identical tree, which succeeded)
  • Locally also ran bun run test:comic-loops (the new comic-loop/generator/renderer suite, not wired into the GitHub Actions verify job, only into just test/ci:local) and ./scripts/smoke-local.sh end-to-end — both pass.

4. Outstanding — needs a human, not me

This PR's own description says production Workers AI inference was never actually invoked/tested locally, and that "an authenticated AI-enabled staging generation should be reviewed before merging for model-specific output quality and latency." That's still true after this rebase — I only exercised the deterministic fallback/bootstrap path (env.AI unset), never real model output through the new brief → premise-ranking → scoring → rewrite/TRIZ-inversion loop. I do not have Workers AI or staging deploy access from this environment, so I cannot perform or claim that validation. Recommend the repo owner either run an authenticated staging generation and eyeball a handful of real comics before merging, or explicitly accept that risk.

Leaving this as a draft per the task — not merging.

…test:comic-loops into CI

decideScriptLoopAction (comic-loop.ts) only reaches 'reject' when
evaluation.passed is false after the bounded rewrite+invert attempts
are exhausted, but runAgenticComicWorkflow never checked .passed
before rendering/persisting - a script that failed editorial review
three times still shipped as the daily comic. Now throws before any
R2/D1 write if either variant's evaluation.passed is false. Every
existing caller already handles this gracefully: today.ts falls back
to the most recent comic, test-generate.ts returns a 500 with the
rejection scores, and the cron scheduled() handler logs + re-throws
(visible failure, no partial writes, fresh attempt next day since the
R2 existence-check means nothing was written).

Also wires test:comic-loops (9 tests covering comic-loop/comic-generator/
svg-renderer) into .github/workflows/build.yaml - it existed and passed
locally but wasn't part of the actual CI gate. Verified locally before
committing: bun run build, test:comic-loops (9/9 pass), test:contracts,
and the full smoke:local suite (including /api/today, which exercises
this exact code path) all pass with this change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015kUr7Kf9wN15TPqDiKsiKw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants