Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
666b8cf
test: fix real comparison harness and add simple/v2/complex variants
AyunnnA Apr 10, 2026
a5f834e
feat: tighten verification and record benchmark evidence
AyunnnA Apr 10, 2026
c34392a
feat: persist research summaries across runtime
AyunnnA Apr 10, 2026
97a138f
fix: stabilize research summary progress rendering
AyunnnA Apr 10, 2026
82d142c
docs: align skill frontmatter with runtime profile fields
AyunnnA Apr 10, 2026
cd08eb0
docs: add concrete skill upgrade notes
AyunnnA Apr 10, 2026
2849028
docs: add router keyword examples
AyunnnA Apr 10, 2026
914e79b
docs: add paper research notes for memory and skill evolution
AyunnnA Apr 10, 2026
b1a993f
feat: add benchmark-driven memory and skill proposals
AyunnnA Apr 10, 2026
d72db32
test: clarify benchmark and memory validation boundaries
AyunnnA Apr 10, 2026
d9d4c33
docs: add metaharness evoskills research note
AyunnnA Apr 10, 2026
5181f05
docs: summarize runtime flow and mechanisms in bilingual readmes
AyunnnA Apr 10, 2026
0e1b58f
docs: align bilingual readmes with v6.3 runtime
AyunnnA Apr 10, 2026
c596543
feat: add proposal verifier gate for self-improvement
AyunnnA Apr 10, 2026
9efcf6a
feat: harden proposal gate with revise blocking and thresholds
AyunnnA Apr 10, 2026
4473f2f
fix: align planning init sidecar summaries
AyunnnA Apr 10, 2026
5f60806
feat: strengthen planning contracts
AyunnnA Apr 10, 2026
a9c6df9
feat: enrich research and thinking summaries
AyunnnA Apr 10, 2026
6e09005
feat: harden execution contract gate
AyunnnA Apr 10, 2026
8106d4c
feat: add skill rerank and shared memory capsule
AyunnnA Apr 10, 2026
548fd1d
fix: tighten workflow consistency and e2e coverage
AyunnnA Apr 11, 2026
a04b9e6
feat: harden proposal lifecycle and verifier gates
AyunnnA Apr 11, 2026
daf09ac
fix: harden review contract coverage
AyunnnA Apr 11, 2026
55f99a1
feat: add structured debug summaries
AyunnnA Apr 11, 2026
accfc3f
fix: complete improvement backlog — safety, tests, cleanup
AyunnnA Apr 11, 2026
40dc091
docs: clarify memory system authority hierarchy in experience_store d…
AyunnnA Apr 11, 2026
5eb2eb8
refactor: extract phase_transitions and frontier_scheduler from workf…
AyunnnA Apr 11, 2026
ffeb78b
refactor: extract error_classifier and task_validator from workflow_e…
AyunnnA Apr 11, 2026
2f5abb7
refactor: extract snapshot_builder and workflow_helpers from workflow…
AyunnnA Apr 11, 2026
2f3f470
feat: implement tiered skill injection with real activation_level gra…
AyunnnA Apr 11, 2026
7022865
feat(p2-p4): add tier-aware routing and adaptive tier resolution
AyunnnA Apr 11, 2026
3212208
feat(p2-p4): wire adaptive tier resolution into execution pipeline
AyunnnA Apr 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ tests/*.json.backup
*.json.backup
tests/bench/ab_experiment_results/
tests/benchmark_results.md
tests/real_comparison_results/
tests/simple_comparison_results/
tests/complex_comparison_results/

# Temporary files
*.tmp
Expand Down
16 changes: 16 additions & 0 deletions .self-improvement/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ This directory contains the self-improvement program artifacts for the agentic-w
## Files

- `results.tsv` - Ledger of improvement runs (hypothesis, files changed, outcome)
- `results_v2.jsonl` - Structured ledger with benchmark/proposal/verifier metadata
- `baseline_check.sh` - Pre-mutation baseline validation script
- `scripts/proposal_registry.py` - Event-sourced proposal lifecycle index
- `zones.md` - Protected core vs mutable surface definitions

## Usage
Expand All @@ -23,6 +25,20 @@ After the run, record outcome:
run_id=<timestamp> hypothesis=<what> files_changed=<paths> checks_passed=<summary> status=<keep|discard|rollback> notes=<details>
```

If the run is driven by benchmark evidence, include a `benchmark_evidence=<path-or-id>` prefix in `notes` or export `BENCHMARK_EVIDENCE=<path-or-id>` before calling `self_improve.sh`.

The runner will:
- generate a reviewable skill proposal artifact under `knowledge/skill_proposals/`
- verify the proposal via `scripts/proposal_verifier.py`
- append proposal lifecycle events to `knowledge/skill_proposals/index.jsonl`
- record both proposal and verification artifact paths in the ledger
- append a structured JSONL record to `results_v2.jsonl` alongside the TSV ledger

Default gate policy:
- `reject`: abort run initialization and record `discard`
- `revise`: also abort by default; pass `--allow-revise` only when you intentionally accept manual override
- `approve`: continue run initialization

## Principles

- Establish baseline before mutating
Expand Down
94 changes: 85 additions & 9 deletions .self-improvement/record_result.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#
# Usage:
# record_result.sh --run-id <id> --hypothesis <text> --files <paths> \
# --checks <summary> --status <keep|discard|rollback|stabilization> [--notes <text>]
# --checks <summary> --status <keep|discard|rollback|stabilization> \
# [--proposal-id <id>] [--benchmark-evidence <ref>] [--skill-proposal <ref>] \
# [--proposal-verification <ref>] [--proposal-decision <decision>] [--notes <text>]
#
# Shorthand:
# record_result.sh <hypothesis> <files> <status> [notes]
Expand All @@ -13,18 +15,25 @@
# record_result.sh "improve routing heuristics" "scripts/router.py" "keep" "routing +5%"
# record_result.sh --run-id 20260401-01 --hypothesis "tighten REVIEWING" \
# --files "scripts/workflow_engine.py" --checks "10/10 gates" --status keep \
# --proposal-id "skill-evolution-20260411T010101Z" \
# --benchmark-evidence "tests/bench/ab_experiment_results/ab_experiment_20260408_223414.json" \
# --skill-proposal "knowledge/skill_proposals/...md" \
# --proposal-verification "knowledge/skill_proposals/verifications/...json" \
# --proposal-decision "approve" \
# --notes "review targeting improved"

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LEDGER="$SCRIPT_DIR/results.tsv"
LEDGER_V2="$SCRIPT_DIR/results_v2.jsonl"
HELPER="$SCRIPT_DIR/_record_helper.py"

usage() {
echo "Usage: record_result.sh [--run-id <id>] --hypothesis <text> --files <paths>"
echo " --checks <summary> --status <keep|discard|rollback|stabilization>"
echo " [--notes <text>]"
echo " [--proposal-id <id>] [--benchmark-evidence <ref>] [--skill-proposal <ref>]"
echo " [--proposal-verification <ref>] [--proposal-decision <decision>] [--notes <text>]"
echo ""
echo " Shorthand: record_result.sh <hypothesis> <files> <status> [notes]"
echo ""
Expand All @@ -38,6 +47,11 @@ HYPOTHESIS=""
FILES=""
CHECKS=""
STATUS=""
PROPOSAL_ID=""
BENCHMARK_EVIDENCE=""
SKILL_PROPOSAL=""
PROPOSAL_VERIFICATION=""
PROPOSAL_DECISION=""
NOTES=""

if [[ "$#" -eq 0 ]]; then
Expand All @@ -62,6 +76,16 @@ if [[ "$1" == "--"* ]]; then
CHECKS="$2"; shift 2;;
--status)
STATUS="$2"; shift 2;;
--proposal-id)
PROPOSAL_ID="$2"; shift 2;;
--benchmark-evidence)
BENCHMARK_EVIDENCE="$2"; shift 2;;
--skill-proposal)
SKILL_PROPOSAL="$2"; shift 2;;
--proposal-verification)
PROPOSAL_VERIFICATION="$2"; shift 2;;
--proposal-decision)
PROPOSAL_DECISION="$2"; shift 2;;
--notes)
NOTES="$2"; shift 2;;
--*)
Expand Down Expand Up @@ -104,18 +128,26 @@ if [[ -z "$RUN_ID" ]]; then
fi

# Use Python helper for locked TSV append (cross-platform fcntl)
python3 - "$LEDGER" "$RUN_ID" "$HYPOTHESIS" "$FILES" "${CHECKS:-passed}" "$STATUS" "$NOTES" << 'PYEOF'
python3 - "$LEDGER" "$LEDGER_V2" "$RUN_ID" "$HYPOTHESIS" "$FILES" "${CHECKS:-passed}" "$STATUS" "$BENCHMARK_EVIDENCE" "$SKILL_PROPOSAL" "$PROPOSAL_VERIFICATION" "$PROPOSAL_DECISION" "$NOTES" "$PROPOSAL_ID" << 'PYEOF'
import sys
import fcntl
import os
import json
from datetime import datetime, timezone

ledger_path = sys.argv[1]
run_id = sys.argv[2]
hypothesis = sys.argv[3]
files = sys.argv[4]
checks = sys.argv[5]
status = sys.argv[6]
notes = sys.argv[7]
ledger_v2_path = sys.argv[2]
run_id = sys.argv[3]
hypothesis = sys.argv[4]
files = sys.argv[5]
checks = sys.argv[6]
status = sys.argv[7]
benchmark_evidence = sys.argv[8]
skill_proposal = sys.argv[9]
proposal_verification = sys.argv[10]
proposal_decision = sys.argv[11]
notes = sys.argv[12]
proposal_id = sys.argv[13] if len(sys.argv) > 13 else ""

# TSV-safe cleaning: replace tabs and newlines with spaces
def tsv_clean(value):
Expand All @@ -125,14 +157,50 @@ hypothesis = tsv_clean(hypothesis)
files = tsv_clean(files)
checks = tsv_clean(checks)
notes = tsv_clean(notes)
benchmark_evidence = tsv_clean(benchmark_evidence)
skill_proposal = tsv_clean(skill_proposal)
proposal_verification = tsv_clean(proposal_verification)
proposal_decision = tsv_clean(proposal_decision)
proposal_id = tsv_clean(proposal_id)

if benchmark_evidence:
notes = f"benchmark_evidence={benchmark_evidence}" + (f" | {notes}" if notes else "")
if skill_proposal:
notes = f"skill_proposal={skill_proposal}" + (f" | {notes}" if notes else "")
if proposal_verification:
notes = f"proposal_verification={proposal_verification}" + (f" | {notes}" if notes else "")
if proposal_decision:
notes = f"proposal_decision={proposal_decision}" + (f" | {notes}" if notes else "")
if proposal_id:
notes = f"proposal_id={proposal_id}" + (f" | {notes}" if notes else "")

lock_path = ledger_path + '.lock'
lock_path_v2 = ledger_v2_path + '.lock'

# Ensure ledger exists with proper header
header_line = "run_id\thypothesis\tfiles_changed\tchecks_passed\tstatus\tnotes"
if not os.path.exists(ledger_path):
with open(ledger_path, 'w') as f:
f.write(header_line + '\n')
if not os.path.exists(ledger_v2_path):
with open(ledger_v2_path, 'w') as f:
f.write("")

record = {
"schema_version": 2,
"recorded_at": datetime.now(timezone.utc).isoformat(),
"run_id": run_id,
"hypothesis": hypothesis,
"files_changed": files,
"checks_passed": checks,
"status": status,
"notes": notes,
"proposal_id": proposal_id or None,
"benchmark_evidence": benchmark_evidence or None,
"skill_proposal": skill_proposal or None,
"proposal_verification": proposal_verification or None,
"proposal_decision": proposal_decision or None,
}

# Lock and append
with open(lock_path, 'w') as lock_f:
Expand All @@ -141,6 +209,14 @@ with open(lock_path, 'w') as lock_f:
with open(ledger_path, 'a') as f:
row = '\t'.join([run_id, hypothesis, files, checks, status, notes])
f.write(row + '\n')
with open(lock_path_v2, 'w') as lock_f_v2:
fcntl.flock(lock_f_v2.fileno(), fcntl.LOCK_EX)
try:
with open(ledger_v2_path, 'a') as f_v2:
f_v2.write(json.dumps(record, ensure_ascii=False) + '\n')
finally:
fcntl.flock(lock_f_v2.fileno(), fcntl.LOCK_UN)
os.remove(lock_path_v2)
finally:
fcntl.flock(lock_f.fileno(), fcntl.LOCK_UN)
os.remove(lock_path)
Expand Down
119 changes: 117 additions & 2 deletions .self-improvement/self_improve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# Usage:
# self_improve.sh --hypothesis <text> [--zone B] [--allow-dirty]
# BENCHMARK_EVIDENCE=<ref> self_improve.sh --hypothesis <text>
#
# This script:
# 1. Creates a dedicated self-improve branch (or validates current context)
Expand All @@ -19,16 +20,24 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
LEDGER="$SCRIPT_DIR/results.tsv"
RECORD_HELPER="$SCRIPT_DIR/record_result.sh"
PROPOSAL_REGISTRY="$PROJECT_ROOT/scripts/proposal_registry.py"
BENCHMARK_EVIDENCE="${BENCHMARK_EVIDENCE:-}"
SKILL_PROPOSAL=""
PROPOSAL_VERIFICATION=""
PROPOSAL_DECISION=""
PROPOSAL_ID=""

usage() {
echo "Self-Improvement Runner"
echo ""
echo "Usage: $0 --hypothesis <text> [--zone B|A|C] [--allow-dirty]"
echo "Usage: $0 --hypothesis <text> [--zone B|A|C] [--allow-dirty] [--allow-revise]"
echo ""
echo "Options:"
echo " --hypothesis <text> What this improvement run tries to achieve (required)"
echo " --zone <A|B|C> Which zone to target (default: B - Guided Mutable Surface)"
echo " --allow-dirty Allow dirty tree (only for exploratory work)"
echo " --allow-revise Continue when proposal verifier returns revise"
echo " BENCHMARK_EVIDENCE Optional benchmark report path/reference to attach"
echo " --help, -h Show this help"
echo ""
echo "Examples:"
Expand All @@ -41,6 +50,7 @@ usage() {
HYPOTHESIS=""
ZONE="B"
ALLOW_DIRTY=0
ALLOW_REVISE=0

while [[ "$#" -gt 0 ]]; do
case "$1" in
Expand All @@ -50,6 +60,8 @@ while [[ "$#" -gt 0 ]]; do
ZONE="$2"; shift 2;;
--allow-dirty)
ALLOW_DIRTY=1; shift;;
--allow-revise)
ALLOW_REVISE=1; shift;;
--help|-h)
usage;;
*)
Expand All @@ -62,6 +74,11 @@ if [[ -z "$HYPOTHESIS" ]]; then
usage
fi

BENCHMARK_ARGS=()
if [[ -n "$BENCHMARK_EVIDENCE" ]]; then
BENCHMARK_ARGS+=(--benchmark-evidence "$BENCHMARK_EVIDENCE")
fi

cd "$PROJECT_ROOT"

echo "=== Self-Improvement Runner ==="
Expand Down Expand Up @@ -125,6 +142,7 @@ if [[ "$baseline_result" == "FAIL" ]]; then
--files "baseline check failed" \
--checks "0/10 gates passed" \
--status "$status" \
"${BENCHMARK_ARGS[@]}" \
--notes "Baseline failed before any changes - context not ready"

echo ""
Expand All @@ -138,6 +156,85 @@ echo "[3/4] Baseline passed - ready for improvement"
echo ""
echo "=== Baseline PASSED - Ready for improvement ==="
echo ""
if [[ -n "$BENCHMARK_EVIDENCE" ]]; then
echo "[3/4] Generating skill evolution proposal from benchmark evidence..."
SKILL_PROPOSAL=$(python3 "$PROJECT_ROOT/scripts/skill_evolution.py" \
--benchmark "$BENCHMARK_EVIDENCE" \
--output-dir "$PROJECT_ROOT/knowledge/skill_proposals" \
--registry-path "$PROJECT_ROOT/knowledge/skill_proposals/index.jsonl")
echo " Proposal: $SKILL_PROPOSAL"
proposal_json="${SKILL_PROPOSAL%.md}.json"
if [[ -f "$proposal_json" ]]; then
PROPOSAL_ID=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1], encoding="utf-8"))["proposal_id"])' "$proposal_json")
echo " Verifying proposal..."
verifier_output=$(python3 "$PROJECT_ROOT/scripts/proposal_verifier.py" \
--proposal "$proposal_json" \
--benchmark "$BENCHMARK_EVIDENCE" \
--output-dir "$PROJECT_ROOT/knowledge/skill_proposals/verifications" \
--registry-path "$PROJECT_ROOT/knowledge/skill_proposals/index.jsonl")
PROPOSAL_DECISION=$(python3 -c 'import json,sys; print(json.loads(sys.argv[1]).get("decision","reject"))' "$verifier_output")
PROPOSAL_VERIFICATION=$(python3 -c 'import json,sys; print(json.loads(sys.argv[1]).get("verification_path",""))' "$verifier_output")
echo " Verification decision: $PROPOSAL_DECISION"
[[ -n "$PROPOSAL_VERIFICATION" ]] && echo " Verification: $PROPOSAL_VERIFICATION"
if [[ "$PROPOSAL_DECISION" == "reject" ]] || [[ "$PROPOSAL_DECISION" == "revise" && $ALLOW_REVISE -eq 0 ]]; then
if [[ "$PROPOSAL_DECISION" == "reject" ]]; then
echo " Proposal verification rejected. Aborting run initialization."
else
echo " Proposal verification returned revise. Use --allow-revise to continue."
fi
if [[ -n "$PROPOSAL_ID" ]]; then
final_status="discarded"
python3 "$PROPOSAL_REGISTRY" record \
--index-path "$PROJECT_ROOT/knowledge/skill_proposals/index.jsonl" \
--proposal-id "$PROPOSAL_ID" \
--status "$final_status" \
--event-type "run_aborted" \
--source-reference "$proposal_json" \
--benchmark-version "$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1], encoding="utf-8")).get("benchmark_version","unknown"))' "$proposal_json")" \
--proposal-path "$proposal_json" \
--verification-path "$PROPOSAL_VERIFICATION" \
--decision "$PROPOSAL_DECISION" \
--run-id "$run_id" \
--hypothesis "$HYPOTHESIS" \
--benchmark-evidence "$BENCHMARK_EVIDENCE" \
--notes "run aborted after proposal gate"
fi
"$RECORD_HELPER" \
--run-id "$run_id" \
--hypothesis "$HYPOTHESIS" \
--files "proposal verification rejected" \
--checks "proposal_verifier=$PROPOSAL_DECISION" \
--status "discard" \
"${BENCHMARK_ARGS[@]}" \
--proposal-id "$PROPOSAL_ID" \
--skill-proposal "$SKILL_PROPOSAL" \
--proposal-verification "$PROPOSAL_VERIFICATION" \
--proposal-decision "$PROPOSAL_DECISION" \
--notes "Proposal blocked by verifier gate"
exit 1
fi

if [[ -n "$PROPOSAL_ID" ]]; then
final_status="approved"
python3 "$PROPOSAL_REGISTRY" record \
--index-path "$PROJECT_ROOT/knowledge/skill_proposals/index.jsonl" \
--proposal-id "$PROPOSAL_ID" \
--status "$final_status" \
--event-type "run_approved" \
--source-reference "$proposal_json" \
--benchmark-version "$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1], encoding="utf-8")).get("benchmark_version","unknown"))' "$proposal_json")" \
--proposal-path "$proposal_json" \
--verification-path "$PROPOSAL_VERIFICATION" \
--decision "$PROPOSAL_DECISION" \
--run-id "$run_id" \
--hypothesis "$HYPOTHESIS" \
--benchmark-evidence "$BENCHMARK_EVIDENCE" \
--notes "run approved by proposal gate"
fi
fi
echo ""
fi

echo "Run ID: $run_id"
echo "Branch: $new_branch"
echo ""
Expand All @@ -156,13 +253,31 @@ echo ""
# Step 4: Pre-record the run start in ledger
echo "[4/4] Recording run start..."
files_placeholder="(no changes yet)"
notes_text="Zone $ZONE improvement - branch: $new_branch"
if [[ -n "$BENCHMARK_EVIDENCE" ]]; then
notes_text="benchmark_evidence=$BENCHMARK_EVIDENCE | ${notes_text}"
fi
if [[ -n "$SKILL_PROPOSAL" ]]; then
notes_text="skill_proposal=$SKILL_PROPOSAL | ${notes_text}"
fi
if [[ -n "$PROPOSAL_DECISION" ]]; then
notes_text="proposal_decision=$PROPOSAL_DECISION | ${notes_text}"
fi
if [[ $ALLOW_REVISE -eq 1 && "$PROPOSAL_DECISION" == "revise" ]]; then
notes_text="manual_override=true | ${notes_text}"
fi
"$RECORD_HELPER" \
--run-id "$run_id" \
--hypothesis "$HYPOTHESIS" \
--files "$files_placeholder" \
--checks "10/10 baseline gates passed" \
--status "in_progress" \
--notes "Zone $ZONE improvement - branch: $new_branch"
"${BENCHMARK_ARGS[@]}" \
--proposal-id "$PROPOSAL_ID" \
--skill-proposal "$SKILL_PROPOSAL" \
--proposal-verification "$PROPOSAL_VERIFICATION" \
--proposal-decision "$PROPOSAL_DECISION" \
--notes "$notes_text"

echo ""
echo "Run initialized: $run_id"
Expand Down
Loading
Loading