feat: Evolution-to-PR Pipeline — selfmodel self-evolution upstream contributions#19
Merged
Conversation
…istics, and safety rules Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add evolution detection engine to selfmodel CLI: - cmd_evolve() with flag parsing and routing - evolve_detect(): scan playbook/hooks/scripts diffs against upstream baseline - evolve_status(): display pipeline status counts from evolution.jsonl - evolve_establish_baseline(): upstream remote → SHA file → error chain - evolve_scan_diffs(): git diff --numstat for playbook/hooks/scripts paths - evolve_scan_lessons(): parse lessons-learned.md for validated entries - evolve_scan_intercepts(): parse hook-intercepts.log for recurring patterns - 5 generalizability heuristics: PATH_DETECTION, PROJECT_NAME_DETECTION, GENERIC_PATTERN, HOOK_FIX, SCORING_CALIBRATION - evolve_score_heuristics(): composite scoring with clamped weighted average - evolve_append_candidate(): JSONL entry creation with full schema - Duplicate detection prevents re-adding existing CANDIDATE entries - --stage/--submit/--track print explicit stub messages (Sprint C scope) - main() routing and help text updated with evolve subcommand - All new code passes shellcheck with zero warnings
Add Step 8.5 between CHECKPOINT (Step 8) and CHECK context health (Step 9): - Triggers every 10 MERGED sprints based on team.json tracking - Runs evolution detection (equivalent to selfmodel evolve --detect) - Logs detection event and candidate count - Notifies user when candidates found - Updates team.json last_review_sprint to prevent re-triggering
Replace stub implementations with full functionality: - evolve_stage(): interactive CANDIDATE classification with diff preview, heuristic recommendations, S/R/K prompts, patch.diff + metadata.json generation in evolution-staging/ - evolve_submit(): pre-flight checks (gh CLI, auth), shell lint on .sh patches, path/secrets audit, PR preview + human confirmation gate, gh pr create with evidence template, STAGED→SUBMITTED transition - evolve_track(): query SUBMITTED PRs via gh pr view, update status to ACCEPTED/REJECTED_UPSTREAM, detect changes_requested reviews - evolve_status(): enhanced with timestamps (detect/submit/staged), submitted PR URLs with status icons, total entry count - cmd_evolve(): updated routing and help text for all phases
…--submit, --track)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
selfmodel evolveCLI subcommand with 5 phases:--detect,--stage,--submit,--track,--status/selfmodel:evolveslash command for guided workflowWhat's New
Evolution Protocol (
evolution-protocol.md)Complete protocol document (681 lines) defining:
evolution.jsonlschema (22 fields, 8 lifecycle statuses)Detection Engine (
selfmodel.sh)selfmodel evolve --detect: Scans playbook/hooks/scripts diffs against upstream baselineStage + Submit + Track
--stage: Interactive classification — display diff preview + heuristic recommendation, user decides Stage/Reject/Keep--submit: Pre-checks (shellcheck, path audit, secrets scan) → human confirmation →gh pr createwith evidence template--track: Query submitted PR status viagh pr view, auto-update evolution.jsonlDocumentation Integration
evolvesub-command entryFiles Changed (9 files, +3086 lines)
.selfmodel/playbook/evolution-protocol.mdskill/references/evolution-protocol.mdcommands/evolve.md.selfmodel/state/evolution.jsonlscripts/selfmodel.sh.selfmodel/playbook/orchestration-loop.mdCLAUDE.mdREADME.mdskill/SKILL.mdTest Plan
shellcheck scripts/selfmodel.sh— zero new warningsselfmodel evolve --help— shows all 5 phasesselfmodel evolve --status— displays empty pipelineselfmodel evolve --detect— runs detection (needs upstream baseline)selfmodel evolve --stage— interactive classification flowselfmodel evolve --submit— graceful error withoutghCLIselfmodel status— no regressions🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com