How asheriff-bot/loop works
Purpose and Entry Points
This repository combines a playable Mastermind-style Locksmith game with a coursework-sized AI development automation system implementing Plan–Execute–Summary (PES). Run the Flask game through ./script/server; operate the engineering loop through ./loop.sh or python -m loop_engine. Primary application startup is in game/__main__.py and loop CLI startup is in loop_engine/__main__.py.
Game Web Application
The game is a Flask server backed by SQLite. game/app.py owns HTTP routes, app construction, and integration between request handlers, persistence, and game rules. Browser UI is rendered from game/templates/index.html, with client behavior in game/static/game.js. The server boundary is local HTTP at port 5055 per the supplied server script.
Game Domain and Persistence
Core Locksmith/Mastermind rules—including guesses and feedback—belong in game/logic.py. game/db.py encapsulates SQLite storage and separates durable game state from request/UI logic. game/daily.py provides daily-game behavior, making date-derived challenge selection a distinct product concern. Relevant paths: game/logic.py, game/db.py, game/daily.py.
PES Agent Orchestration
PESAgent coordinates iterative Plan → Execute → Summary processing until a completion promise is returned or the configured iteration limit is reached. loop_engine/agent.py is the high-level control loop; loop_engine/stages.py tracks the explicit assignment workflow stages (specify, review, plan, build) and step completion. This is the principal boundary between the automation framework and repository work.
Planning, Execution, and Summarization
Planning converts project context and stage requirements into proposed work via loop_engine/planner.py. Execution dispatches an agent/backend and applies its output through loop_engine/executor.py. Summarization records outcomes and feeds subsequent iterations through loop_engine/summarizer.py and loop_engine/memory.py. Prompt templates define role-specific instructions in prompts/PROMPT_plan.md, prompts/PROMPT_execute.md, and prompts/PROMPT_summary.md.
Backends and External Integrations
The backend abstraction in loop_engine/backends.py supports offline dry_run, filesystem-oriented echo, and GitHub Copilot CLI execution. loop_engine/config.py loads project and backend settings from config.yaml; loop_engine/models.py carries shared loop-domain structures. Copilot is the only declared external AI service/tool dependency; dry-run enables deterministic local testing without an LLM.
Evaluation, Git, and Durable Loop State
loop_engine/evaluator.py provides evaluation metrics and can gate automated PES progress. loop_engine/git_ops.py supports stage-level commit workflow. Operational artifacts bridge agent iterations and human review: IMPLEMENTATION_PLAN.md is the living plan, prompts.txt records prompt history, and running.md documents execution. Product requirements and rubric constraints are authoritative inputs under specs/00-assignment-rubric.md and related specs.
Main entry points: app.py Flask app and routes · agent.py PES agent · executor.py Executor · planner.py Planner
Components 21
Locksmith Game
Playable Flask Mastermind application.
- Game startup
game/__main__.py - Flask app and routes · Serves the local game API and UI on port 5055.
game/app.py - Browser UI
game/templates/index.html - Client behavior
game/static/game.js - Mastermind rules · Computes guesses and feedback.
game/logic.py - Daily challenge · Selects date-derived challenges.
game/daily.py - Game persistence · Encapsulates durable game state.
game/db.py
PES Automation
Plan–Execute–Summary engineering loop.
- Loop CLI startup
loop_engine/__main__.py - PES agent · Repeats Plan → Execute → Summary until completion or iteration limit.
loop_engine/agent.py - Assignment stages · Tracks specify, review, plan, and build progress.
loop_engine/stages.py - Planner
loop_engine/planner.py - Executor · Dispatches work and applies backend output.
loop_engine/executor.py - Summarizer
loop_engine/summarizer.py - Loop memory · Carries outcomes into later iterations.
loop_engine/memory.py - Agent backends · Selects dry-run, echo, or Copilot CLI execution.
loop_engine/backends.py - Evaluator · Provides metrics that can gate PES progress.
loop_engine/evaluator.py - Git workflow
loop_engine/git_ops.py - Loop configuration · Loads project and backend settings.
loop_engine/config.py
Project Context
Requirements, prompts, and operational artifacts.
- Role prompts · Plan, execute, and summary instructions.
prompts/PROMPT_plan.md - Assignment requirements · Rubric and related specifications constrain work.
specs/00-assignment-rubric.md - Work artifacts · Living plan, prompt history, and execution record.
IMPLEMENTATION_PLAN.md
Connections 23
- Game startup → Flask app and routes: starts
- Flask app and routes → Browser UI: renders
- Browser UI → Client behavior: loads
- Client behavior → Flask app and routes: local HTTP
- Flask app and routes → Mastermind rules: applies rules
- Flask app and routes → Daily challenge: selects challenge
- Flask app and routes → Game persistence: reads and writes state
- Loop CLI startup → PES agent: starts
- PES agent → Assignment stages: tracks progress
- PES agent → Planner: plan
- Planner → Executor: proposed work
- Executor → Summarizer: execution outcome
- Summarizer → Loop memory: records outcome
- Loop memory → Planner: iteration context
- Executor → Agent backends: dispatches
- PES agent → Evaluator: evaluates progress
- Executor → Git workflow: stage commits
- Loop configuration → PES agent: iteration settings
- Role prompts → Planner: plan instructions
- Role prompts → Executor: execute instructions
- Role prompts → Summarizer: summary instructions
- Assignment requirements → Planner: work constraints
- Work artifacts → PES agent: review context