1
0
This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Timmy-time-dashboard/src/self_coding/__init__.py

50 lines
1.5 KiB
Python
Raw Normal View History

feat: Self-Coding Foundation (Phase 1) Implements the foundational infrastructure for Timmy's self-modification capability: ## New Services 1. **GitSafety** (src/self_coding/git_safety.py) - Atomic git operations with rollback capability - Snapshot/restore for safe experimentation - Feature branch management (timmy/self-edit/{timestamp}) - Merge to main only after tests pass 2. **CodebaseIndexer** (src/self_coding/codebase_indexer.py) - AST-based parsing of Python source files - Extracts classes, functions, imports, docstrings - Builds dependency graph for blast radius analysis - SQLite storage with hash-based incremental indexing - get_summary() for LLM context (<4000 tokens) - get_relevant_files() for task-based file discovery 3. **ModificationJournal** (src/self_coding/modification_journal.py) - Persistent log of all self-modification attempts - Tracks outcomes: success, failure, rollback - find_similar() for learning from past attempts - Success rate metrics and recent failure tracking - Supports vector embeddings (Phase 2) 4. **ReflectionService** (src/self_coding/reflection.py) - LLM-powered analysis of modification attempts - Generates lessons learned from successes and failures - Fallback templates when LLM unavailable - Supports context from similar past attempts ## Test Coverage - 104 new tests across 7 test files - 95% code coverage on self_coding module - Green path tests: full workflow integration - Red path tests: errors, rollbacks, edge cases - Safety constraint tests: test coverage requirements, protected files ## Usage from self_coding import GitSafety, CodebaseIndexer, ModificationJournal git = GitSafety(repo_path=/path/to/repo) indexer = CodebaseIndexer(repo_path=/path/to/repo) journal = ModificationJournal() Phase 2 will build the Self-Edit MCP Tool that orchestrates these services.
2026-02-26 11:08:05 -05:00
"""Self-Coding Layer — Timmy's ability to modify its own source code safely.
This module provides the foundational infrastructure for self-modification:
- GitSafety: Atomic git operations with rollback capability
- CodebaseIndexer: Live mental model of the codebase
- ModificationJournal: Persistent log of modification attempts
- ReflectionService: Generate lessons learned from attempts
Usage:
from self_coding import GitSafety, CodebaseIndexer, ModificationJournal
from self_coding import ModificationAttempt, Outcome, Snapshot
# Initialize services
git = GitSafety(repo_path="/path/to/repo")
indexer = CodebaseIndexer(repo_path="/path/to/repo")
journal = ModificationJournal()
# Use in self-modification workflow
snapshot = await git.snapshot()
# ... make changes ...
if tests_pass:
await git.commit("Changes", ["file.py"])
else:
await git.rollback(snapshot)
"""
from self_coding.git_safety import GitSafety, Snapshot
from self_coding.codebase_indexer import CodebaseIndexer, ModuleInfo, FunctionInfo, ClassInfo
from self_coding.modification_journal import (
ModificationJournal,
ModificationAttempt,
Outcome,
)
from self_coding.reflection import ReflectionService
__all__ = [
# Core services
"GitSafety",
"CodebaseIndexer",
"ModificationJournal",
"ReflectionService",
# Data classes
"Snapshot",
"ModuleInfo",
"FunctionInfo",
"ClassInfo",
"ModificationAttempt",
"Outcome",
]