Commit Graph

26 Commits

Author SHA1 Message Date
aditya 2f69358dcf test: sim12, sim14, sim17 — verify multi-file DoD compliance after prompt fix
All 3 simulations tested with the fixed generate prompt that passes
the original DoD to the LLM. Results:

- SIM12 (Rate Limiter): 7 files — algorithms.py, store.py, middleware.py,
  config.py, example_app.py, requirements.txt, __init__.py
- SIM14 (JSON Validator): 6 files — validator.py, types.py, errors.py,
  cli.py, requirements.txt, __init__.py
- SIM17 (API Tester): 7 files — runner.py, assertions.py, variables.py,
  reporter.py, cli.py, requirements.txt, test_suite_example.yaml

All Python files pass compile() syntax check. All DoD files present.
Files written directly via --output-dir, no manual cleanup needed.
2026-03-13 14:12:13 +00:00
aditya e5a142ef76 fix: pass original prompt with DoD to code generation LLM
The generate prompt only received the analyze_requirements summary,
which often compressed the file-by-file DoD into a brief paragraph.
The LLM then produced 1 file instead of the 5-6 specified.

Fix: added {original_prompt} variable to the generate prompt template
so the LLM sees both the architecture analysis AND the original DoD
with explicit file listings. Also strengthened the instruction to
"output ALL files mentioned in the Definition of Done."

Verified: sim10 (CSV Analyzer) now produces 6 files matching DoD
(loader.py, analyzer.py, reporter.py, cli.py, requirements.txt).
2026-03-13 14:12:12 +00:00
aditya 9840828836 feat: add --output-dir flag to lifecycle-apply command
Files were always written to CWD, requiring manual mv and cleanup
(README.md overwrites, stray files in project root). Now users can
specify where generated files should go:

  python -m cleveragents plan lifecycle-apply PLAN_ID --output-dir simulations/sim9

The directory is created automatically if it doesn't exist.
Updated sim_test_commands.md to use the new flag.
2026-03-13 14:12:10 +00:00
aditya ff52ef4f69 test: sim9 multi-file RAG application with src/ subdirectory (10 files)
First simulation testing subdirectory output support. RAG app with
separate modules: document_loader, chunker, embeddings, vector_store,
retriever, generator — plus config.py and main.py CLI entry point.
All Python files pass syntax check. 9/10 DoD checks pass.

Also adds sim_test_commands.md with 9 new simulation definitions
(SIM9-SIM17) for manual terminal testing.
2026-03-13 14:09:48 +00:00
aditya 1b8fba684f test: sim8 basic RAG application — end-to-end V3 simulation (2 files)
User-triggered simulation via terminal commands. RAG app with OpenAI
embeddings, FAISS vector store, document chunking, and CLI interface.
2026-03-13 11:56:25 +00:00
aditya d21baa0f86 fix: broken pending migration detection causing repeated prompts
get_pending_migrations() had a logic bug where the break condition
(rev.revision == current_rev) was inside the (rev.revision != current_rev)
guard, making it unreachable. This caused every CLI command to falsely
detect pending migrations and prompt for approval even when the DB was
already at head.
2026-03-13 11:56:24 +00:00
aditya 9fe3196827 test: re-run all 7 simulations with improved pipeline
All sims re-run after pipeline fixes (better prompts, real syntax
validation, fenced-block extraction fix). Results: 7/7 PASS,
20 files total, all Python files pass compile() syntax check.

Includes run_all_sims.py runner script and rag-basic action config.
2026-03-13 11:56:24 +00:00
aditya daefb63e53 docs: annotate comparative review with implementation responses
Add [RESPONSE] annotations to each finding in the comparative review:
- Findings A, B, C, E: acknowledged as valid with action items
- Finding D (binary apply): noted as low priority / theoretical
- Finding F (simulation artifacts): corrected — reviewer checked raw
  LLM outputs (sim*-<name>/generated.py) instead of extracted files
  (sim*/todo.py etc.) which all pass py_compile

Also fix CommittingSessionService._commit() to log exceptions instead
of silently swallowing them (valid Finding E).
2026-03-13 11:56:15 +00:00
aditya 85cc67aa5a fix: improve code generation pipeline prompts, validation, and file extraction
Problems fixed:
- Generation prompt was vague ("produce production-ready code") with no
  output format specification. LLM had to guess the multi-file format.
- Validation was fake: `is_valid = "PASS" in text or len(code) > 10`
  auto-passed any code longer than 10 chars.
- Single-file fallback used keyword guessing ("test" -> test_generated.py)
  instead of parsing the filename from LLM output.

Changes:
- Rewrite analyze_prompt with structured sections (Files to Create,
  Dependencies, Key Requirements, Architecture Notes)
- Rewrite generate_prompt with explicit multi-file output format rules
  (**filename.ext** + fenced code block) and quality constraints
- Rewrite validate_prompt with specific review checklist
- Replace fake validation with real Python syntax check (compile()) +
  LLM review where first line must be PASS or FAIL
- Add _extract_single_file() for robust single-file fallback that
  parses the filename from the LLM output header
- Remove keyword-based path guessing (test/error/generated.py)
- Re-ran SIM1: now produces todo.py (matching DoD) instead of main.py
2026-03-13 11:36:45 +00:00
aditya 92803df337 test: sim7 URL shortener — end-to-end V3 simulation (4 files)
Flask URL shortener with base62 encoding, POST /shorten, GET /<code>
redirect, input validation, and HTML templates (index + error page).
Multi-file extraction correctly handled nested templates/ directory.
2026-03-13 11:36:37 +00:00
aditya 51c40631dc test: sim6 weather CLI dashboard — end-to-end V3 simulation (2 files)
New simulation: OpenWeatherMap CLI with WeatherData dataclass, argparse,
formatted terminal output, and retry-enabled HTTP client.
Multi-file extraction correctly produced weather.py + requirements.txt.
2026-03-13 11:36:29 +00:00
aditya 4f1dcd8dac test: sim2 bookstore REST API extracted output (4 files) 2026-03-13 11:36:16 +00:00
aditya 4ff19f4fad chore: add docs/camodif.md to .gitignore 2026-03-13 11:35:57 +00:00
aditya c20f22053d fix: multi-file extraction skips headers inside fenced code blocks
_extract_files_from_markdown now builds a set of fenced-block character
ranges and filters out any FILE_HEADER_RE matches that fall within them.
This prevents dependency lines like "requests>=2.31.0" from being
misidentified as file headers, which was causing requirements.txt to be
missed in sim4's output. Re-extracted sim4 with correct scraper.py and
requirements.txt.
2026-03-13 11:35:47 +00:00
aditya c8473dd5c6 refactor: use existing infrastructure for v3 plan lifecycle
Replace custom JSON file persistence, string-split provider resolution,
and raw change tracking with the project's existing infrastructure:
- ActorService for provider/model resolution from DB
- ChangeSetStore (InMemoryChangeSetStore) for audit-grade change tracking
- Sandbox directories for cross-process file persistence
- Definition of Done included in LLM prompts
2026-03-13 11:35:39 +00:00
aditya 4d446827ba feat: v3 simulation action configs and improved multi-file extraction
Add 5 action YAML configs for v3 simulation stress tests (todo-cli,
bookstore-api, websocket-chat, hn-scraper, flask-auth). Update
multi-file markdown extraction regex to also match bold-only headers
(**filename.py**) without requiring # prefix.
2026-03-13 11:35:30 +00:00
aditya a5774b7186 feat: wire real LLM calls into v3 plan lifecycle
The v3 lifecycle (action create → plan use → plan execute → plan
lifecycle-apply) now invokes the actual AI provider during the execute
phase and writes generated files to disk during the apply phase.

Key changes:
- Add ai_provider and provider_registry to PlanLifecycleService
- Add run_execute() method that resolves provider, creates legacy Plan
  adapter, calls generate_changes(), and persists changeset to JSON
- Add run_apply() method that loads persisted changeset and writes
  files to filesystem with path traversal protection
- Wire ai_provider and provider_registry in DI container
- Update CLI execute/lifecycle-apply commands to use new methods
- Load .env via python-dotenv so API keys are available without shell
  export
- Pass API keys from settings into LLM factory kwargs
2026-03-13 11:35:23 +00:00
aditya 4fe72b7e9f feat: multi-file code generation from LLM output
PlanGenerationGraph._generate_plan() now parses markdown-formatted LLM
output to extract individual files from ## headers and fenced code blocks.
Previously, all LLM output was crammed into a single generated.py file.

Now: ## main.py + ```python``` blocks are parsed into separate Change
objects, each written to its own file path. Supports nested paths like
templates/base.html, numbered headers (## 1. file.py), backtick-wrapped
and bold filenames. Falls back to single-file behavior when < 2 file
headers are detected.

Tested against 5 real Anthropic LLM outputs — correctly extracts 2-11
files per generation including .py, .txt, .html, .css, and .md files.
2026-03-13 11:35:12 +00:00
aditya 3c0b326c0d test: 5 real-LLM simulation outputs from end-to-end workflow stress test
Each simulation ran the full legacy lifecycle (init → tell → build → apply)
with real Anthropic Claude API calls:

1. sim1-todo-cli: Click-based todo app (add/list/delete)
2. sim2-bookstore-api: FastAPI CRUD with SQLite (5 code files)
3. sim3-websocket-chat: async websocket chat server
4. sim4-hn-scraper: HN top stories scraper with JSON output
5. sim5-flask-auth: Flask + Flask-Login authentication app

All 5 generated correct, production-quality Python code matching
the requested task specifications.
2026-03-13 11:35:02 +00:00
aditya cd5e40f88e fix: add property setters to LangChainChatProvider for name and model_id
PlanService._resolve_ai_provider_for_actor() sets name and model_id on the
provider instance, but LangChainChatProvider only had read-only properties.
This caused AttributeError when building plans with a real LLM provider.

Also adds .gitignore (protecting .env with API keys) and example action YAML.
2026-03-13 11:34:53 +00:00
aditya da8c17c15e fix: session persistence uses shared SQLAlchemy session for proper commit
The session factory was creating new sessions on each call, so flush() in
the repo and commit() in CommittingSessionService operated on different
sessions. Now uses a shared session instance so changes are properly
committed to the database.
2026-03-13 11:34:44 +00:00
aditya 5aa93ba722 fix: add 'audit' to valid CLI commands list
The audit command was registered as a subcommand but missing from the
valid_cmds whitelist in main(), causing 'Invalid command' errors.
2026-03-13 11:34:33 +00:00
aditya 9919ad6e58 fix: session CLI now persists to database via CommittingSessionService
The session CLI was using container.db() which didn't exist. Replaced with
proper SQLAlchemy session factory pattern. Created CommittingSessionService
that wraps PersistentSessionService with auto-commit after each mutating
operation, since the CLI doesn't use a UoW wrapper for transactions.
2026-03-13 11:34:21 +00:00
aditya 6361e8fd88 fix: v3 plan lifecycle auto-advances through phases and persists correctly
- execute command now auto-advances plans from strategize/queued through
  start_strategize and complete_strategize before executing
- lifecycle-apply command auto-advances from execute/queued through
  start_execute and complete_execute before applying
- list_plans now queries the persistence layer (same fix as list_actions)
- start_strategize loads the action from DB into cache before preflight
  checks, fixing "Action not found in registry" when action was only in DB

The full v3 lifecycle now works end-to-end:
  action create → plan use → plan execute → plan lifecycle-apply
2026-03-13 11:34:11 +00:00
aditya 8b7866bd0b fix: use container-wired PlanLifecycleService for persistence in CLI commands
Both action.py and plan.py CLI commands were creating PlanLifecycleService
with only settings (no UnitOfWork), causing in-memory-only storage that lost
data between CLI invocations. Now uses container.plan_lifecycle_service()
which injects a real UnitOfWork for database persistence.

Also fixed list_actions() to query the persistence layer instead of only
reading from the in-memory cache, which was always empty on fresh service
instances.
2026-03-13 11:32:56 +00:00
aditya e58717d16b chore: initial: original codebase as received 2026-03-13 10:48:39 +00:00