Harness refine

From Jonghakseo/my-pi · View interactive version

Harness refine is an AI agent skill from the GitHub repository Jonghakseo/my-pi. 현재 Pi 세션을 회고해 하네스(AGENTS.md·스킬·메모리 등) 개선점을 찾을 때 사용한다.

How to use this skill

Skill file

harness-refine

현재 세션의 시행착오를 durable harness 개선 후보로 변환한다. 분석 전용 dry-run이며 리포트 파일 저장 외에 어떤 파일이나 메모리도 변경하지 않는다.

Hard Rules

Session Inspector

이 스킬 디렉터리의 scripts/session_inspect.py를 사용한다. 경로는 현재 읽은 SKILL.md의 디렉터리를 기준으로 해석한다.

# 첫 호출에서 analysis.cutoff_leaf_id를 확보한다.
python3 <skill-dir>/scripts/session_inspect.py summary --exclude-current-turn --pretty

# 이후 모든 호출은 같은 cutoff leaf를 사용한다.
python3 <skill-dir>/scripts/session_inspect.py patterns --leaf-id <cutoff> --min-count 2 --examples 2 --example-chars 300 --limit 30 --pretty
python3 <skill-dir>/scripts/session_inspect.py search --leaf-id <cutoff> --errors-only --include-results --limit 50 --max-chars 1200 --pretty
python3 <skill-dir>/scripts/session_inspect.py search --leaf-id <cutoff> --tool bash --query "test" --include-results --pretty
python3 <skill-dir>/scripts/session_inspect.py tools --leaf-id <cutoff> --tool bash --limit 50 --max-chars 600 --pretty
python3 <skill-dir>/scripts/session_inspect.py timeline --leaf-id <cutoff> --limit 300 --max-chars 1200 --pretty

Commands

Workflow

1. 분석 범위 확정

사용자가 /skill:harness-refine 뒤에 초점을 적었다면 해당 범위를 우선한다. 초점이 없으면 전체 세션을 분석한다.

먼저 summary --exclude-current-turn을 실행하고 응답의 analysis.cutoff_leaf_id를 고정한다. 이후 모든 inspector 명령에 --leaf-id <cutoff>를 전달한다.

다음을 Coverage와 Session metrics에 보존한다.

2. 증거 수집

고정한 cutoff leaf를 사용해 다음 순서로 필요한 데이터만 확장한다.

  1. search --errors-only --include-results로 실제 실패를 확인한다.
  2. patterns로 반복 tool·operation·argument shape을 bounded output으로 확인한다.
  3. timeline으로 사용자 교정, 재시도 이유, 최종 검증 결과를 연결한다.
  4. 특정 절차가 의심될 때만 search --tool ... --query ... --include-results 또는 tools --tool ...로 좁힌다.

필터 없는 tools 호출과 --limit 0 전체 덤프는 사용하지 않는다.

후보 신호:

제외 신호:

3. 기존 Harness와 중복 확인

후보가 생긴 뒤에만 관련 대상을 좁게 확인한다.

중복이면 새 후보를 만들지 말고 기존 target의 update 또는 merge로 제안한다.

4. Scope Ceiling & Generalization Gate

솔루션이나 target을 고르기 전에 증거가 허용하는 최대 적용 범위(scope ceiling)를 정한다. 같은 기능에서 연쇄 결함이 여러 번 발견된 것은 원인에 대한 깊이 증거이지, 일반화의 폭 증거가 아니다.

Evidence breadth는 적용 범위만 표현한다.

Promotion basis는 별도 축으로 하나 이상 기록한다.

Scope eligibility:

Counterfactual scope check:

  1. 현재 repo·기능의 고유 명사, ID 형식, 내부 상태명을 제거한다.
  2. 같은 프로젝트의 다른 기능에서도 lesson이 유지되는지 먼저 확인한다.
  3. 다른 프로젝트에서도 Proposed change가 거의 그대로 유효한지 별도로 확인한다.
  4. 추상 문장만 남겨 억지로 일반화하지 않는다. 통과하지 못하면 scope를 좁히거나 hold/reject한다.

Candidate consolidation:

5. Promotion Gate

Scope ceiling 안에서 다음 중 하나를 만족해야 lesson을 Candidate 검토 대상으로 올린다.

“같은 근본 원인의 실패 2회 이상”은 선택된 scope 안에서의 승격 근거일 뿐 evidence breadth를 넓히지 않는다. 각 후보에는 concrete entry id, timestamp, tool call id 중 하나 이상을 포함한다.

근거는 있으나 재발 가능성·정책 정본·구현 타당성이 아직 부족하면 Held ideas에 보존하고, 다시 승격할 조건을 적는다. 일시적이거나 잘못된 신호는 Rejected signals에 overfit, insufficient breadth, transient, duplicated 등 구체 사유를 남긴다.

6. Solution-Fit Gate

Candidate의 lesson과 evidence를 고정한 뒤에만 해결책을 설계한다. 다음 순서를 건너뛰지 않는다.

  1. Native mechanism 확인: 기존 repo script·config·package command·CLI 오류/옵션, 기존 skill·instruction, shell composition(&&, 명시적 cwd), 이미 존재하는 checker 순으로 확인한다.
  2. Semantic determinism 판정: 위반 여부를 명시적 입력과 로컬 상태만으로 결정할 수 있으면 deterministic, 사용자 목적·작업 의미·암묵적 의존성을 추론해야 하면 context-dependent로 기록한다.
  3. 작은 대안 비교: 새 static/tool을 만들기 전에 기존 native mechanism 또는 더 좁은 repo-local 변경으로 해결 가능한지 적는다.
  4. 비례성 판정: 재발 빈도·영향과 구현 복잡도·유지비·오탐 비용을 비교해 acceptable | excessive로 기록한다.
  5. Hold/Reject: context-dependent인데 명시적 계약이 없거나, 비례성이 excessive면 새 static/tool 후보로 만들지 않는다. 명시적 workflow·shell 조합·instruction으로 충분하면 그쪽으로 좁히고, 그렇지 않으면 hold/reject한다.

Global mechanism 추가 조건:

각 Candidate에 Native mechanism considered, Smaller alternative, Semantic determinism, Proportionality를 기록한다.

7. Target & Enforcement 선택

references/output-schema.md의 Target mapping을 따른다. 먼저 문제를 소유한 위치와 Target locality를 정한다.

그다음 같은 owner·scope·비용의 대안끼리만 enforcement 강도를 tie-breaker로 비교한다.

  1. static: 기계적으로 참/거짓을 판정하고 허용 가능한 오탐으로 위반을 차단
  2. tool: 올바른 동작을 실행 경로에 내장
  3. instruction: semantic judgment나 절차를 모델이 읽고 수행
  4. memory: static·tool·instruction으로 의미 손실 없이 표현할 수 없는 사실·결정·선호·gotcha

“구현 가능하다”는 이유만으로 더 강하거나 넓은 수단을 선택하지 않는다. 가장 작은 native mechanism이 충분하면 그것을 선택한다. 한 lesson은 한 target에만 제안한다.

8. 메모리 승격·폐기 후보 확인

기존 harness 중복 확인 과정에서 조회한 관련 메모리를 다시 검토한다. 메모리 삭제만을 목적으로 새 enforcement를 발명하지 않는다. 독립적으로 정당화된 Candidate 또는 이미 존재하는 mechanism이 메모리를 온전히 대체할 때만 upgrade를 제안한다.

9. 보고

references/output-schema.md 형식을 정확히 따른다. 보고는 두 단계다.

  1. 풀 리포트를 파일로 저장: ~/.pi/agent/retrospective/refine-reports/sessions/<session-id>.md
  1. 채팅에는 후보당 세 줄로 요약: 수정 대상, 바꿀 내용, 근거를 각각 한 줄로 쓴다. 구체적인 형식은 references/output-schema.md를 따른다.

Validation

완료 전 확인한다.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.