How mohdsaleh/loops-engineering-for-coding-agents works
Purpose and Entry Points
This repository implements Loop Engineering v3.0 as a local, file-backed orchestration system for coding-agent goals. It operationalizes the documented nine-phase loop with Python CLIs, JSON schemas, event history, projections, and agent-facing packets.
Primary entry points:
• install.py installs/bootstrap-copies the system into a target workspace.
• system/scripts/agenticctl.py is the control-plane CLI for lifecycle operations.
• system/protocol/LOOP-ENGINEERING-v3.0.md defines the canonical agent execution contract.
Workspace and Contract Boundary
A target workspace is represented by structured JSON state and requirements, seeded from:
• system/templates/workspace.json
• system/templates/REQUIREMENTS.json
• system/templates/PROJECT-SPEC.md
Schemas make workspace state, goals, requirements, versions, events, and packet formats machine-validatable. This is the key boundary between an LLM/agent’s actions and deterministic protocol enforcement:
• system/schemas/workspace.schema.json
• system/schemas/goal.schema.json
• system/schemas/state.schema.json
Goal Intake and Versioned Lifecycle
Goal registration validates and records a new goal before it can enter execution. Goals have explicit lifecycle state and sequential versioning/checkpoint semantics, preventing uncontrolled context carryover between completed and subsequent work.
• system/scripts/register_goal.py
• system/scripts/transition.py
• system/schemas/versions.schema.json
The example goal document shows the expected project-task input shape:
• examples/goal.project-task.json
Event Store and Materialized Projections
The system uses append-only event recording as the audit source of truth. Current status and other queryable state are rebuilt as projections rather than treated as independently authoritative mutable state.
• system/scripts/append_event.py
• system/scripts/event_store.py
• system/scripts/rebuild_projections.py
This creates an observable, interruptible control flow: lifecycle commands emit events; projections summarize those events into workspace/project status.
Planning, Agent Packets, and Knowledge Graph
Execution context is assembled into role-specific packets for maker and verifier agents. A lightweight knowledge graph captures nodes, edges, and manifests for goal-related context and dependencies.
• system/scripts/build_packets.py
• system/scripts/kg.py
• system/schemas/maker-packet.schema.json
• system/schemas/verifier-packet.schema.json
• system/schemas/kg-manifest.schema.json
Packets are the agent integration boundary: this repository governs inputs, state transitions, and validation, while an external coding agent performs the actual plan/execution work.
Verification, Repair Limits, and Stop Gates
Verification is deterministic and schema/requirement-driven before repair is considered. Attempts are recorded, scope is checked, and a stop gate provides explicit termination when retry, confidence, token, or step budgets are exceeded.
• system/scripts/verify_goal.py
• system/scripts/verify_scope.py
• system/scripts/record_attempt.py
• system/scripts/stop_gate.py
Relevant contracts include:
• system/schemas/project-status.schema.json
• system/schemas/verifier-packet.schema.json
• system/schemas/event.schema.json
Runtime and Deployment Model
The implementation runtime is Python 3.9+ with dependencies declared in system/scripts/requirements.txt. It is local-file based: no database, hosted service, LLM provider, queue, or web server is present in the repository. External agentic IDEs or LLM runners consume the protocol/templates and invoke the CLI or scripts.
Operational installation and migration guidance is maintained in:
• DEPLOYMENT-GUIDE.md
• MIGRATION-v2.1-to-v3.0.md
Main entry points: register_goal.py Goal registration · agenticctl.py agenticctl · append_event.py Event writer · build_packets.py Packet builder
Components 19
Protocol & Contracts
Machine-validatable workspace and agent boundaries.
- Loop protocol · Canonical nine-phase agent contract.
system/protocol/LOOP-ENGINEERING-v3.0.md - Workspace templates · Initial workspace, requirements, and project specification.
system/templates/workspace.json - Workspace schemas · Validates workspace, goal, and lifecycle state.
system/schemas/workspace.schema.json - Version schema · Enforces sequential versions and checkpoints.
system/schemas/versions.schema.json - Agent packet schemas · Defines maker, verifier, and knowledge-graph packet formats.
system/schemas/maker-packet.schema.json
Lifecycle Control
Local CLI-driven goal orchestration.
- agenticctl · Runs lifecycle operations in the local workspace.
system/scripts/agenticctl.py - Goal registration · Validates and records goals before execution.
system/scripts/register_goal.py - State transitions · Applies explicit goal lifecycle changes.
system/scripts/transition.py - Append-only event store · Authoritative record of lifecycle activity.
system/scripts/event_store.py - Event writer
system/scripts/append_event.py - Status projections · Rebuilds queryable workspace and project status from events.
system/scripts/rebuild_projections.py
Agent Execution & Verification
Packets, deterministic checks, and bounded repair.
- Packet builder · Builds role-specific execution packets.
system/scripts/build_packets.py - Knowledge graph · Captures goal dependencies, nodes, edges, and manifests.
system/scripts/kg.py - External coding agent · Consumes packets and performs plan or implementation work.
- Goal verification · Checks requirements and schema-driven completion.
system/scripts/verify_goal.py - Scope check · Prevents repairs outside allowed scope.
system/scripts/verify_scope.py - Attempt recorder
system/scripts/record_attempt.py - Stop gate · Terminates retries when configured limits are exceeded.
system/scripts/stop_gate.py
Other components
- Installer · Copies the system into a target workspace.
install.py
Connections 22
- Installer → Workspace templates: installs
- Installer → agenticctl: bootstraps
- Loop protocol → agenticctl: governs
- Workspace templates → Workspace schemas: seed data validated by
- agenticctl → Goal registration: invokes
- Goal registration → Workspace schemas: validates goal and state
- Goal registration → Version schema: assigns version under
- Goal registration → Event writer: records
- agenticctl → State transitions: invokes
- State transitions → Event writer: emits lifecycle event
- Event writer → Append-only event store: appends to
- Append-only event store → Status projections: rebuilt into
- Status projections → Packet builder: supplies current context
- Knowledge graph → Packet builder: supplies dependencies
- Agent packet schemas → Packet builder: constrains output
- Packet builder → External coding agent: delivers maker/verifier packets
- External coding agent → Goal verification: submits work for
- Goal verification → Scope check: on repair path
- Scope check → Attempt recorder: approved attempts
- Attempt recorder → Stop gate: reports retries
- Stop gate → State transitions: permits or halts lifecycle
- Goal verification → Event writer: records outcome