# Clone
git clone https://github.com/ChanChiChoi/log2repro.git
cd log2repro
# Install with dev dependencies
uv sync --group dev
# Verify setup
uv run pytest --co -q # list tests without runningsrc/log2repro/ # Main package
├── cli.py # CLI entry point
├── eval_metrics.py # Quality metrics
├── parsers/ # Log parsing
├── extractors/ # AST extraction
├── generators/ # LLM generation
├── validators/ # Sandbox + auto-fix
└── utils/ # I/O helpers
tests/ # Test suite
├── fixtures/ # 30+ error trace samples
└── test_*.py # Test modules
benchmarks/ # Benchmark framework
# All tests (385 tests, ~2.5 min)
uv run pytest -v
# Specific module
uv run pytest tests/test_sandbox.py -v
# With coverage
uv run pytest --cov=log2repro --cov-report=term-missing
# Stop on first failure
uv run pytest -x- Formatter/Linter: Ruff
- Line length: 88 characters (Black-compatible)
- Type hints: Required for public functions
- Docstrings: Google style for public APIs
# Lint
uv run ruff check src/ tests/
# Format
uv run ruff format src/ tests/- Create
src/log2repro/parsers/my_parser.py - Implement
BaseParserinterface:
from log2repro.parsers.base import BaseParser, ParsedTrace
class MyParser(BaseParser):
def can_parse(self, text: str) -> bool:
# Return True if this parser handles the input
...
def parse(self, text: str) -> list[ParsedTrace]:
# Parse text and return traces
...- Add tests in
tests/test_my_parser.py - Add fixture traces in
tests/fixtures/ - Register in
cli.pyparser chain
- Add function to
src/log2repro/eval_metrics.py - Integrate into
evaluate_single() - Add tests in
tests/test_eval_metrics.py - Update
BatchEvalResult.report()if needed
- Edit
src/log2repro/generators/prompts.py - Run benchmarks to compare:
uv run python -m benchmarks.runner- Update
CODE_LOGIC.mdsection 6.1
Add real-world error traces to tests/fixtures/:
tests/fixtures/
├── connection_error.txt
├── sqlalchemy_not_found.txt
├── chained_exception.txt
├── sentry_payload.json
└── ci_log_ansi.txt
Each fixture should be a minimal, self-contained error trace.
All LLM calls go through _call_llm() in code_gen.py. Mock it in tests:
from unittest.mock import patch
def test_my_feature():
mock_response = "```python\nprint('hello')\n```"
with patch("log2repro.generators.code_gen._call_llm", return_value=mock_response):
# Your test code
...Sandbox tests run real Python scripts in venvs. They are slower but test actual behavior:
def test_sandbox_execution():
result = run_in_sandbox(
script_path=Path("test_script.py"),
timeout=10,
expected_error="ValueError: test",
)
assert result.error_reproduced- Create a feature branch from
main - Write code + tests
- Run full test suite:
uv run pytest -v - Run linter:
uv run ruff check src/ tests/ - Update
CODE_LOGIC.mdif changing module logic - Submit PR with clear description
Follow conventional commits:
feat: add Sentry JSON parser
fix: handle underscore-prefixed exception types
docs: update CODE_LOGIC.md for sandbox changes
test: add edge case for chained exceptions
refactor: extract _call_llm for testability
When modifying code, update these docs as needed:
| Change | Update |
|---|---|
| New module | CODE_LOGIC.md + docs/architecture.md |
| New CLI flag | docs/user-guide.md + CODE_LOGIC.md §9 |
| New metric | docs/evaluation.md + CODE_LOGIC.md §8 |
| New parser | docs/parser-reference.md + CODE_LOGIC.md §4 |
| Prompt change | docs/llm-prompt-design.md + CODE_LOGIC.md §6 |