Skip to content

feat: Evolution-to-PR Pipeline — selfmodel self-evolution upstream contributions#19

Merged
VictorVVedtion merged 16 commits into
mainfrom
feat/evolution-pipeline
Apr 7, 2026
Merged

feat: Evolution-to-PR Pipeline — selfmodel self-evolution upstream contributions#19
VictorVVedtion merged 16 commits into
mainfrom
feat/evolution-pipeline

Conversation

@VictorVVedtion
Copy link
Copy Markdown
Owner

Summary

  • Add Evolution-to-PR Pipeline: detect local framework improvements, classify generalizability, and submit PRs to upstream selfmodel
  • New selfmodel evolve CLI subcommand with 5 phases: --detect, --stage, --submit, --track, --status
  • New /selfmodel:evolve slash command for guided workflow
  • Orchestration loop Step 8.5 auto-triggers detection every 10 merged sprints

What's New

Evolution Protocol (evolution-protocol.md)

Complete protocol document (681 lines) defining:

  • 4-phase pipeline: DETECT → STAGE → SUBMIT → TRACK
  • evolution.jsonl schema (22 fields, 8 lifecycle statuses)
  • 5 generalizability heuristics (PATH_DETECTION, PROJECT_NAME_DETECTION, GENERIC_PATTERN, HOOK_FIX, SCORING_CALIBRATION)
  • PR template with evidence tables
  • Safety rules (human approval gate, no secrets, append-only)

Detection Engine (selfmodel.sh)

  • selfmodel evolve --detect: Scans playbook/hooks/scripts diffs against upstream baseline
  • 5 heuristic functions score each candidate 0.0–1.0 for generalizability
  • Sources: playbook diffs, hook diffs, script diffs, validated lessons, hook intercept patterns, quality trends

Stage + 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 create with evidence template
  • --track: Query submitted PR status via gh pr view, auto-update evolution.jsonl

Documentation Integration

  • CLAUDE.md: Evolution section expanded, On-Demand Loading table, Danger Zones, Directory Structure
  • skill/SKILL.md: New evolve sub-command entry
  • README.md: Evolution Pipeline section with 4-phase overview

Files Changed (9 files, +3086 lines)

File Change
.selfmodel/playbook/evolution-protocol.md NEW — full protocol (681 lines)
skill/references/evolution-protocol.md NEW — identical copy for skill
commands/evolve.md NEW — slash command definition
.selfmodel/state/evolution.jsonl NEW — empty state file
scripts/selfmodel.sh +1595 — cmd_evolve() with all 5 phases
.selfmodel/playbook/orchestration-loop.md +10 — Step 8.5 EVOLUTION CHECK
CLAUDE.md +10/-1 — Evolution section, loading table, danger zones
README.md +9 — Evolution Pipeline section
skill/SKILL.md +1 — evolve sub-command

Test Plan

  • shellcheck scripts/selfmodel.sh — zero new warnings
  • selfmodel evolve --help — shows all 5 phases
  • selfmodel evolve --status — displays empty pipeline
  • selfmodel evolve --detect — runs detection (needs upstream baseline)
  • selfmodel evolve --stage — interactive classification flow
  • selfmodel evolve --submit — graceful error without gh CLI
  • selfmodel status — no regressions

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

VictorVVedtion and others added 16 commits April 6, 2026 17:01
…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
@VictorVVedtion VictorVVedtion merged commit 73e53b8 into main Apr 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant