Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cd6a01363 | ||
|
|
327800798a | ||
|
|
7bb2b88857 | ||
|
|
63b3f50e48 | ||
|
|
8583353c3e | ||
|
|
0bca43ed95 | ||
|
|
69b32eae30 | ||
|
|
1a7f817fd6 | ||
|
|
3683839a13 | ||
|
|
5c36e8b470 | ||
|
|
b67d5343c4 | ||
|
|
3da02e571f |
@@ -21,7 +21,7 @@ claude-harness ─┬─ 플러그인 harness ──(claude plugin install)─
|
||||
|
||||
| 장치 | 때 | 하는 일 |
|
||||
|---|---|---|
|
||||
| H12 차단 | Bash 실행 직전 | 되돌릴 수 없는 명령을 막는다: 호스팅 원격으로 force push·`--mirror`·보호 브랜치 지우기, 작업 폴더·/tmp 밖이나 너무 넓은 `rm -r`, DB·볼륨·migration 삭제(DROP·TRUNCATE, flyway clean, `-p` 없는 `compose down -v`, `volume rm`, `kubectl delete pvc·ns`). `ssh '…'` 안도 본다 |
|
||||
| H12 차단 | Bash 실행 직전 | 되돌릴 수 없는 명령을 막는다: 호스팅 원격으로 force push·`--mirror`·보호 브랜치 지우기, 작업 폴더·/tmp 밖이나 너무 넓은 `rm -r`, 작업 폴더 안이라도 git checkout(등록된 worktree 포함)을 통째로 지우거나 옆 worktree 안을 지우는 `rm -r`, DB·볼륨·migration 삭제(DROP·TRUNCATE, flyway clean, `-p` 없는 `compose down -v`, `volume rm`, `kubectl delete pvc·ns`). `ssh '…'` 안도 본다 |
|
||||
| N4 알림 | 파일을 쓴 직후 | 비밀 값처럼 보이는 것(개인 키, 토큰, 값이 있는 password 등)을 몇 줄로 알린다. 막지 않는다 |
|
||||
| 장부 기록 | 세션 시작·턴 끝 | 세션 id와 기록 경로를 `~/.claude/harness/sessions.jsonl`에, 누적 실측(시간·호출·토큰)을 `~/.claude/harness/usage/<세션>.json`에 쓴다. 출력이 없어 컨텍스트 비용이 0이다 |
|
||||
| 회고 넛지 | 세션 시작 | repo 장부에 회고 안 한 빗나간 예측이나 효과 판정할 개선이 있으면, repo마다 하루 한 번 한 줄로 알린다. 없으면 출력이 없다 |
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
| 12 | 플러그인은 분야 전문가 협업 장치(`lead`·`new-expert`·`harness-eval`, 장부 `eval`)만 싣고, 분야 전문가(스킬·서브에이전트)는 각 템플릿 `.claude/`에 둔다 | 설계(v1)에 없음. v2 설계는 `docs/experts.md` | 기준이 스택마다 다르다. 플러그인 에이전트는 `harness:` 아래 이름이라 템플릿 것과 둘 다 목록에 떠 설명 비용과 고르기 혼란만 는다 |
|
||||
| 13 | 새 스킬 셋(`lead`·`new-expert`·`harness-eval`)도 모델 호출형이고 설명에 발동 조건을 쓴다. `harness-eval`은 설명에 "시킬 때만"을 쓴다 | 13절 Q9와 같음 | 비싼 평가가 저절로 돌지 않게 하는 것은 설명 문장이다. 사용자 호출 전용으로 바꾸려면 Q9를 다시 정해야 한다 |
|
||||
| 14 | `ledger.py usage`의 `agent_return_chars`는 Agent 도구 결과와, 대기열로 들어온 백그라운드 결과(`queued_command`의 `<agent-message`·`<task-notification` 머리)를 센다 | 설계에 없음 | 백그라운드 서브에이전트의 결과는 tool_result가 아니라 알림으로 온다(2026-11-11 세션 기록에서 확인). 기록 모양이 바뀌면 이 값이 0으로 떨어진다(시험이 모양을 고정한다) |
|
||||
| 15 | `rm -r`은 허용 폴더 안이라도 git checkout(등록된 worktree 포함)이나 그것을 품은 폴더를 통째로 지우거나, 옆 worktree 안을 지우면 막는다. /tmp·앱 임시 작업 폴더 아래는 예외 | 설계는 「이 worktree·scratchpad·`/tmp/claude-<uid>` 밖」을 막는다. 구현이 main checkout도 허용 폴더에 넣어서 그 안의 worktree 자신·옆 worktree가 열려 있었다 | `docs/retro/2026-11-08.md` C6. main checkout 안을 치우는 일(main checkout 세션이 worktree 안을 비우기 등)은 그대로 둔다. 「이 세션 작업 폴더」는 cwd의 checkout으로 먼저 잡는다. 앱이 worktree 세션의 프로젝트 폴더(`CLAUDE_PROJECT_DIR`)를 main checkout으로 주므로, 프로젝트 폴더를 먼저 보면 옆 worktree 안이 열린다(실제 세션에서 확인). 소유자 기계 세션 기록의 `rm -r` 647개(지금 있는 worktree 35곳에서 실행한 338개 포함)를 프로젝트 폴더 없이, 또 main checkout으로 주고 옛 판정과 새 판정으로 돌렸다. 바뀐 것은 이 작업의 확인 명령 1개뿐이었다 |
|
||||
|
||||
## 확인한 것과 못 한 것
|
||||
|
||||
|
||||
+27
-3
@@ -271,6 +271,29 @@
|
||||
|
||||
- **결정**: 설계는 그대로 간다(소유자 승인 2026-11-11). 다음 두 가지를 템플릿 적용 때 고친다. (1) 분야 스킬 호출률: `.claude/rules/expert-skills.md`에 "고치기 전에 그 분야 스킬" 두 줄을 넣었다(7.3: 규칙은 읽히지만 스킬 호출은 셋 중 하나). (2) 프로젝트 스킬 상태의 시작 비용과 구현 과제는 7.3에서 다시 쟀다. 서브에이전트 방식은 v2가 못한 지표가 없어 다시 시험하지 않는다. 장부 `harness-v2-eval-real` 줄 24개.
|
||||
|
||||
### 7.4 분야 스킬 호출률을 올린 뒤 (2026-11-12, 두 템플릿)
|
||||
|
||||
7.3에서 규칙은 읽혀도 분야 스킬을 부른 세션은 셋 중 하나였다. 9절 F1의 "절반 아래"에 걸린다. 두 템플릿의 `.claude/rules/expert-skills.md`를 고쳤다(백엔드 `5feb5a1b`, 프론트 `6805ed62`). 분야 파일을 처음 Edit·Write하기 전에 Skill 도구로 부르고, 관련 문서를 읽었어도 부른다. 고칠 것 → 스킬 짝을 한 줄로 적어 `docs/work/experts.md` 표를 다시 읽지 않아도 되게 했다. 7.3과 같은 방식(`claude -p`, opus-5-5, 사용자 전역 설정, Slack 도구 막음)으로 다시 쟀다.
|
||||
|
||||
프론트는 이번에 구현 과제 B를 처음 돌렸다. 디자인 시스템에 지울 수 있는 필터 칩 `Chip`을 더하는 일이고, repo 규칙 검사는 9개다(primitive 한 파일, 배럴 export, 아이콘 facade, 지우기 버튼 이름, 날 색 없음, 닫힌 API, 갤러리 story, 컴포넌트 시험, 골든을 다시 찍지 않고 안내).
|
||||
|
||||
| 판 | 규칙 검사(3번) | 첫 편집 전에 분야 스킬 | 세션별 분야 스킬 호출 수 | 작업 중 분 · 호출 · 출력(중앙값) |
|
||||
|---|---|---|---|---|
|
||||
| 백엔드 v2(이전 규칙, 7.3) | 8/8 ×3 | 1/3 | 0 · 2 · 0 | 22 · 214 · 17.9만 |
|
||||
| 백엔드 v2r(새 규칙) | 8/8 ×3 | **3/3** | 3 · 6 · 7 | 27 · 222 · 18.6만 |
|
||||
| 프론트 v1(main, 분야 스킬 없음) | 9/9 ×3 | — | 0 · 0 · 0 | 15 · 121 · 7.9만 |
|
||||
| 프론트 v2(이전 규칙) | 9/9 ×3 | 1/3 | 0 · 4 · 0 | 15 · 143 · 13.1만 |
|
||||
| 프론트 v2r(새 규칙) | 9/9 ×3 | **3/3** | 5 · 4 · 5 | 13 · 133 · 10.8만 |
|
||||
|
||||
- 호출률은 두 템플릿 모두 1/3에서 3/3이 됐다. 여섯 번 모두 첫 Edit·Write 전에 불렀다.
|
||||
- 정답률: 백엔드는 v2와 같은 8/8이다(나빠지지 않음). 프론트 과제 B는 세 판 모두 9/9라 변별력이 없다. 프론트 repo의 디자인 시스템 설계 기록(`docs/design/2026-07-26-design-system-platform-design.md`) 11절 「컴포넌트 추가 Recipe」가 자세해서, 스킬 없이 문서를 따라가도 맞는다. 7.2의 리뷰 과제와 같은 천장이다.
|
||||
- 시작 컨텍스트(프론트): v1 49,152 → v2 49,612(+0.9%) → v2r 49,645(+1.0%). 규칙은 `paths`가 맞는 파일을 열 때만 실린다.
|
||||
- 비용: 프론트 출력은 v1 대비 v2 1.65배, v2r 1.37배다. 백엔드 v2r은 v2보다 작업 시간이 5분 길고 출력은 4% 많다. 새 규칙은 과제와 먼 분야(마이그레이션 과제에 `be-security`·`be-performance`)까지 부르게 한다. 9절 F7로 지켜본다.
|
||||
- 채점기: 프론트 검사 둘을 첫 결과를 본 뒤 넓혔다. `IconButton` primitive로 만든 지우기 버튼과, CHANGELOG에 적은 골든 안내를 맞는 답인데도 떨어뜨렸기 때문이다. 세 판 모두에 같게 적용했다.
|
||||
- `claude -p`는 백그라운드 서브에이전트를 600초 뒤 끊는다(5개 세션 stderr). 결과 JSON의 시간·토큰에는 그 뒤 일이 빠진다. 장부 값은 세션 기록에서 `ledger.py eval`로 다시 계산했다.
|
||||
|
||||
- **결정**: 새 규칙 문구로 간다. 분야 스킬 호출률은 9절 F1 기준을 넘었다. 프론트의 변별력 있는 구현 과제(문서에 recipe가 없는 규칙을 건드리는 일)는 아직 없다. 장부 `harness-v2-eval-real`에 12줄을 더했다(case `impl-priority-real-be-r2`, `impl-chip-real-fe`).
|
||||
|
||||
---
|
||||
|
||||
## 8. 버린 대안
|
||||
@@ -292,17 +315,18 @@
|
||||
|
||||
| # | 가정 | 틀렸다면 보이는 곳 |
|
||||
|---|---|---|
|
||||
| F1 | `paths` 지식 스킬은 그 파일을 만질 때 목록에 뜨고, 메인이 그것을 부른다 | 적용 뒤 세션 기록에서 그 분야 파일을 고친 세션의 `Skill` 호출이 절반 아래다 → 설명의 말을 고치거나 rules에 "이 스킬을 부른다" 한 줄 |
|
||||
| F1 | `paths` 지식 스킬은 그 파일을 만질 때 목록에 뜨고, 메인이 그것을 부른다 | 적용 뒤 세션 기록에서 그 분야 파일을 고친 세션의 `Skill` 호출이 절반 아래다 → 설명의 말을 고치거나 rules에 "이 스킬을 부른다" 한 줄. 7.3에서 1/3로 드러났고, 7.4에서 규칙을 고쳐 3/3이 됐다 |
|
||||
| F2 | 렌즈(스킬 경로를 읽게 함)가 분야 정의를 미리 싣는 것만큼 판정을 좁힌다 | 과제 A·B에서 v2 리뷰어 발견이 렌즈 분야 밖으로 흩어지거나 렌즈 분야 결함을 놓친다 |
|
||||
| F3 | 넘김 한 번이면 충분하다 | 보고 「남은 문제」의 넘김이 큰 일마다 2건 넘게 남는다 |
|
||||
| F4 | 시작 비용 증가가 작다 | 과제 C에서 `start_context` 증가가 5%를 넘는다 |
|
||||
| F5 | 지식 스킬이 리뷰보다 먼저 결함을 막는다 | 적용 뒤 2주의 확인 리뷰·게이트 실패 중 그 분야 함정에 이미 적힌 것이 되풀이된다 |
|
||||
| F6 | 리뷰-수정 세 번 상한이 품질을 해치지 않는다 | 세 번째에서 멈춘 일의 다음 확인 리뷰에서 High가 나온다 |
|
||||
| F7 | 규칙이 과제에 걸리는 분야 스킬만 부르게 한다 | 장부 eval에서 세션별 분야 스킬 호출 수 중앙값이 5를 넘거나 출력이 v1의 1.5배를 넘는다 → 규칙의 짝 줄을 좁힌다(7.4: 백엔드 6, 프론트 5·1.37배) |
|
||||
|
||||
## 10. 확인 못 한 것
|
||||
|
||||
- ~~`paths` 스킬이 목록에서 빠지는지~~ → 확인함(7.2절): 프로젝트 스킬은 빠지고, 플러그인 스킬은 `paths`가 있어도 목록에 든다(CLI 2.1.287).
|
||||
- 서브에이전트 `skills:`가 `paths`가 걸린 스킬도 싣는지(`arch-reviewer`·`verify-app`에 쓴다).
|
||||
- 데스크톱 앱(2.1.321)과 노트북 CLI(2.1.287)의 동작 차이.
|
||||
- 프론트 과제 B와 프론트 지식 스킬(초안 없음).
|
||||
- 실제 템플릿(프로젝트 스킬) 상태의 시작 비용과 스킬 호출률.
|
||||
- ~~프론트 과제 B~~ → 돌림(7.4절). 다만 세 판 모두 9/9라 변별력 있는 프론트 구현 과제는 아직 없다.
|
||||
- ~~실제 템플릿(프로젝트 스킬) 상태의 시작 비용과 스킬 호출률~~ → 확인함(7.3·7.4절).
|
||||
|
||||
@@ -45,3 +45,19 @@
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2", "case": "impl-priority-real-be", "run": 1, "active_minutes": 28, "calls": 214, "output_tokens": 183616, "input_tokens_total": 51734893, "start_context": 49918, "max_context": 425866, "subagents": 1, "agent_calls": 1, "findings": 8, "false_findings": null, "note": "실제 템플릿 상태 실제 세션(claude -p, opus-5-5, 사용자 전역 설정 그대로, Slack 도구 막음). v1 = relayout 123fc0bf, v2 = c611b06f(프로젝트 be-* 스킬·reviewer·expert-skills 규칙). repo 규칙 검사 8개 중 통과 8, 놓친 것 []. 부른 스킬 ['slack-briefing']. 비용 $18.782086799999995", "recorded_at": "2026-11-12T00:05+09:00"}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2", "case": "impl-priority-real-be", "run": 2, "active_minutes": 20, "calls": 113, "output_tokens": 99475, "input_tokens_total": 29713150, "start_context": 49919, "max_context": 411491, "subagents": 0, "agent_calls": 0, "findings": 8, "false_findings": null, "note": "실제 템플릿 상태 실제 세션(claude -p, opus-5-5, 사용자 전역 설정 그대로, Slack 도구 막음). v1 = relayout 123fc0bf, v2 = c611b06f(프로젝트 be-* 스킬·reviewer·expert-skills 규칙). repo 규칙 검사 8개 중 통과 8, 놓친 것 []. 부른 스킬 ['be-persistence', 'be-api-contract', 'slack-briefing']. 비용 $10.961340399999997", "recorded_at": "2026-11-12T00:05+09:00"}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2", "case": "impl-priority-real-be", "run": 3, "active_minutes": 22, "calls": 257, "output_tokens": 179053, "input_tokens_total": 64290729, "start_context": 49919, "max_context": 416710, "subagents": 1, "agent_calls": 1, "findings": 8, "false_findings": null, "note": "실제 템플릿 상태 실제 세션(claude -p, opus-5-5, 사용자 전역 설정 그대로, Slack 도구 막음). v1 = relayout 123fc0bf, v2 = c611b06f(프로젝트 be-* 스킬·reviewer·expert-skills 규칙). repo 규칙 검사 8개 중 통과 8, 놓친 것 []. 부른 스킬 []. 비용 $None (40분 제한에 걸려 결과 JSON 없음, 파일로 채점)", "recorded_at": "2026-11-12T00:05+09:00"}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v1", "case": "start-context-fe", "run": 1, "active_minutes": 0, "start_context": 47425, "note": "실제 세션(claude -p, opus-5-5) 첫 호출 입력 토큰. v1 = 프론트 main 38c0dc7d, v2 = 그 위 b5e7f54b. 둘 다 scratchpad 복제. 세션 12e7113f. fe-* 9개는 시작 목록에 없음", "recorded_at": "2026-11-12T00:08+09:00"}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2", "case": "start-context-fe", "run": 1, "active_minutes": 0, "start_context": 47891, "note": "실제 세션(claude -p, opus-5-5) 첫 호출 입력 토큰. v1 = 프론트 main 38c0dc7d, v2 = 그 위 b5e7f54b. 둘 다 scratchpad 복제. 세션 19891dbb. fe-* 9개는 시작 목록에 없음", "recorded_at": "2026-11-12T00:08+09:00"}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v1", "case": "start-context-fe", "run": 2, "active_minutes": 0, "start_context": 47424, "note": "실제 세션(claude -p, opus-5-5) 첫 호출 입력 토큰. v1 = 프론트 main 38c0dc7d, v2 = 그 위 b5e7f54b. 둘 다 scratchpad 복제. 세션 04328a44. fe-* 9개는 시작 목록에 없음", "recorded_at": "2026-11-12T00:08+09:00"}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2", "case": "start-context-fe", "run": 2, "active_minutes": 0, "start_context": 47891, "note": "실제 세션(claude -p, opus-5-5) 첫 호출 입력 토큰. v1 = 프론트 main 38c0dc7d, v2 = 그 위 b5e7f54b. 둘 다 scratchpad 복제. 세션 1d028a6d. fe-* 9개는 시작 목록에 없음", "recorded_at": "2026-11-12T00:08+09:00"}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2r", "case": "impl-priority-real-be-r2", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "dffb4c40-ebc3-4d0c-ba27-ee89f150ff19", "active_minutes": 27, "calls": 150, "output_tokens": 127096, "input_tokens_total": 52773209, "start_context": 49925, "max_context": 550020, "subagents": 0, "subagent_calls": 0, "agent_calls": 0, "agent_return_chars": 0, "findings": 8, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 5feb5a1b(c611b06f + 규칙에 파일→스킬 짝). repo 규칙 검사 8개 중 통과 8, 놓친 것 []. 분야 스킬 ['be-persistence', 'be-api-contract', 'be-docs'](첫 Edit·Write 전). 그 밖 스킬 [].", "run": 1}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2r", "case": "impl-priority-real-be-r2", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "80f7a06f-b562-42fd-92c9-6a601d5c36c3", "active_minutes": 28, "calls": 222, "output_tokens": 194020, "input_tokens_total": 57892175, "start_context": 49923, "max_context": 479912, "subagents": 1, "subagent_calls": 95, "agent_calls": 1, "agent_return_chars": 6369, "findings": 8, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 5feb5a1b(c611b06f + 규칙에 파일→스킬 짝). repo 규칙 검사 8개 중 통과 8, 놓친 것 []. 분야 스킬 ['be-persistence', 'be-persistence', 'be-api-contract', 'be-performance', 'be-testing', 'be-docs'](첫 Edit·Write 전). 그 밖 스킬 ['slack-briefing'].", "run": 2}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2r", "case": "impl-priority-real-be-r2", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "f0f157e3-2424-4b5a-8996-13e124454de8", "active_minutes": 23, "calls": 272, "output_tokens": 186371, "input_tokens_total": 62867645, "start_context": 49920, "max_context": 450604, "subagents": 2, "subagent_calls": 123, "agent_calls": 2, "agent_return_chars": 13150, "findings": 8, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 5feb5a1b(c611b06f + 규칙에 파일→스킬 짝). repo 규칙 검사 8개 중 통과 8, 놓친 것 []. 분야 스킬 ['be-persistence', 'be-api-contract', 'be-persistence', 'be-api-contract', 'be-testing', 'be-security', 'be-docs'](첫 Edit·Write 전). 그 밖 스킬 [].", "run": 3}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v1", "case": "impl-chip-real-fe", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "d45e36da-aeb8-40fa-bfe5-27a06fa95bdf", "active_minutes": 17, "calls": 125, "output_tokens": 96949, "input_tokens_total": 17389284, "start_context": 49154, "max_context": 250386, "subagents": 1, "subagent_calls": 38, "agent_calls": 1, "agent_return_chars": 1213, "findings": 9, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 main 38c0dc7d. repo 규칙 검사 9개 중 통과 9, 놓친 것 []. 분야 스킬 [](안 부름). 그 밖 스킬 ['slack-briefing'].", "run": 1}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v1", "case": "impl-chip-real-fe", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "af9177ba-0974-42b6-9f76-900c46ec3c27", "active_minutes": 11, "calls": 75, "output_tokens": 56041, "input_tokens_total": 12082282, "start_context": 49150, "max_context": 225442, "subagents": 0, "subagent_calls": 0, "agent_calls": 0, "agent_return_chars": 0, "findings": 9, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 main 38c0dc7d. repo 규칙 검사 9개 중 통과 9, 놓친 것 []. 분야 스킬 [](안 부름). 그 밖 스킬 ['slack-briefing'].", "run": 2}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v1", "case": "impl-chip-real-fe", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "89d465e8-c84a-43ea-9d31-eaeeda0a88c3", "active_minutes": 15, "calls": 121, "output_tokens": 79329, "input_tokens_total": 15247684, "start_context": 49153, "max_context": 225456, "subagents": 1, "subagent_calls": 44, "agent_calls": 1, "agent_return_chars": 1213, "findings": 9, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 main 38c0dc7d. repo 규칙 검사 9개 중 통과 9, 놓친 것 []. 분야 스킬 [](안 부름). 그 밖 스킬 ['slack-briefing'].", "run": 3}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2", "case": "impl-chip-real-fe", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "b495a3a7-25db-4f28-95e7-db996a15222f", "active_minutes": 20, "calls": 146, "output_tokens": 138496, "input_tokens_total": 22691156, "start_context": 49610, "max_context": 293994, "subagents": 2, "subagent_calls": 59, "agent_calls": 2, "agent_return_chars": 2426, "findings": 9, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 b5e7f54b(fe-* 스킬·reviewer·이전 규칙). repo 규칙 검사 9개 중 통과 9, 놓친 것 []. 분야 스킬 [](안 부름). 그 밖 스킬 ['desktop-gates', 'slack-briefing'].", "run": 1}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2", "case": "impl-chip-real-fe", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "4a3e15f1-f7e3-4d9f-92ce-451ce598b788", "active_minutes": 13, "calls": 143, "output_tokens": 109081, "input_tokens_total": 21674589, "start_context": 49614, "max_context": 252278, "subagents": 1, "subagent_calls": 59, "agent_calls": 1, "agent_return_chars": 1213, "findings": 9, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 b5e7f54b(fe-* 스킬·reviewer·이전 규칙). repo 규칙 검사 9개 중 통과 9, 놓친 것 []. 분야 스킬 ['fe-design-system', 'fe-design-system', 'fe-a11y', 'fe-testing'](첫 Edit·Write 전). 그 밖 스킬 ['slack-briefing'].", "run": 2}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2", "case": "impl-chip-real-fe", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "8bc51348-ecee-401d-87b8-becceeaff0f3", "active_minutes": 15, "calls": 131, "output_tokens": 130941, "input_tokens_total": 22150117, "start_context": 49611, "max_context": 273671, "subagents": 1, "subagent_calls": 60, "agent_calls": 1, "agent_return_chars": 1213, "findings": 9, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 b5e7f54b(fe-* 스킬·reviewer·이전 규칙). repo 규칙 검사 9개 중 통과 9, 놓친 것 []. 분야 스킬 [](안 부름). 그 밖 스킬 [].", "run": 3}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2r", "case": "impl-chip-real-fe", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "3b808129-48b3-4f7d-a502-05b942d5760e", "active_minutes": 13, "calls": 127, "output_tokens": 107342, "input_tokens_total": 20439452, "start_context": 49643, "max_context": 247357, "subagents": 1, "subagent_calls": 54, "agent_calls": 1, "agent_return_chars": 1214, "findings": 9, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 6805ed62(규칙에 파일→스킬 짝). repo 규칙 검사 9개 중 통과 9, 놓친 것 []. 분야 스킬 ['fe-design-system', 'fe-design-system', 'fe-a11y', 'fe-react', 'fe-testing'](첫 Edit·Write 전). 그 밖 스킬 ['desktop-gates'].", "run": 1}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2r", "case": "impl-chip-real-fe", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "c21d1f4c-378c-43c7-ba8e-1f2b70007aab", "active_minutes": 20, "calls": 162, "output_tokens": 143817, "input_tokens_total": 28628034, "start_context": 49647, "max_context": 296851, "subagents": 1, "subagent_calls": 71, "agent_calls": 1, "agent_return_chars": 4855, "findings": 9, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 6805ed62(규칙에 파일→스킬 짝). repo 규칙 검사 9개 중 통과 9, 놓친 것 []. 분야 스킬 ['fe-design-system', 'fe-a11y', 'fe-design-system', 'fe-react'](첫 Edit·Write 전). 그 밖 스킬 ['desktop-gates', 'slack-briefing'].", "run": 2}
|
||||
{"schema": 1, "kind": "eval", "task": "harness-v2-eval-real", "arm": "v2r", "case": "impl-chip-real-fe", "recorded_at": "2026-11-12T05:32+09:00", "transcript": "8f26b150-3b34-48e5-a453-8ba169008b7c", "active_minutes": 13, "calls": 133, "output_tokens": 108073, "input_tokens_total": 19774466, "start_context": 49644, "max_context": 247277, "subagents": 1, "subagent_calls": 48, "agent_calls": 1, "agent_return_chars": 1214, "findings": 9, "false_findings": null, "result": "done", "note": "2차 실제 세션(claude -p, opus-5-5, 사용자 전역 설정, Slack 도구 막음). 판 6805ed62(규칙에 파일→스킬 짝). repo 규칙 검사 9개 중 통과 9, 놓친 것 []. 분야 스킬 ['fe-design-system', 'fe-design-system', 'fe-a11y', 'fe-react', 'fe-testing'](첫 Edit·Write 전). 그 밖 스킬 [].", "run": 3}
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
| C3 | architecture | 사용자 전역 설정 | 응답 언어를 설정으로 고정할 수 있는지 확인한다. H11 뒤에도 영어 초안이 9번 막혔다 | 5절 |
|
||||
| C4 | user(권한) | 소유자 권한 설정 | 리뷰를 마친 PR 병합, 공개 repo 만들기처럼 분류기가 막는 일을 소유자가 미리 허락하는 규칙. 총괄 세션의 승인은 하위 세션에 넘어가지 않는다 | h2 약 10시간 대기, p1 소유자 개입 2, x2 PR 병합 막힘 |
|
||||
| C5 | instructions | 백엔드 템플릿 장부 | 아래 7절의 retro 줄 3개를 더한다. 그래야 그 repo의 넛지가 멈추고 `calib-median` 판정이 그 장부에서도 돈다 | 3절 |
|
||||
| C6 | gate | 사용자 전역 훅과 이 repo `guard_bash.py`(둘을 같이) | main checkout 안 worktree(`.claude/worktrees/…`)에서 `rm -rf ./*`(worktree 자신)와 `rm -rf ../옆-worktree`가 통과한다. H12 허용 폴더에 main checkout이 들어가서다. 이 repo 시험에 알려진 빈틈(`expectedFailure`)으로 표시했다. 고치면 그 시험이 「뜻밖의 통과」로 실패해 표시를 지우게 한다 | 이번 `check.sh` |
|
||||
| C6 | gate | 사용자 전역 훅과 이 repo `guard_bash.py`(둘을 같이) | main checkout 안 worktree(`.claude/worktrees/…`)에서 `rm -rf ./*`(worktree 자신)와 `rm -rf ../옆-worktree`가 통과한다. H12 허용 폴더에 main checkout이 들어가서다. 이 repo 시험에 알려진 빈틈(`expectedFailure`)으로 표시했다. 고치면 그 시험이 「뜻밖의 통과」로 실패해 표시를 지우게 한다. **2026-11-13 고침**: 등록된 worktree를 통째로 지우거나 옆 worktree 안을 지우면 막는다(플러그인 0.3.1과 전역 훅의 같은 절, `docs/README.md` 15번) | 이번 `check.sh` |
|
||||
| C7 | instructions | design-docs 위임 매뉴얼 8절 | 위임 장부에는 회고했는지 적는 자리가 없다. `estimate_ref`가 있는 줄은 그 repo 장부의 retro 줄로, 없는 줄은 이 문서 같은 회고 기록으로 닫는다고 한 줄 | 회고 0 |
|
||||
|
||||
## 7. 백엔드 장부에 더할 retro 줄 (C5)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "harness",
|
||||
"displayName": "Harness",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"description": "프로젝트와 상관없는 공통 하네스: 되돌릴 수 없는 명령 차단(H12), 비밀 값 알림(N4), 예측·실측 장부 훅, 회고 넛지, estimate·retro·techdebt 스킬, 분야 전문가 협업(lead·new-expert)과 하네스 판 비교(harness-eval)",
|
||||
"author": {
|
||||
"name": "donghyeon.kang"
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
보내는 force push는 운반이라 통과하되, 보호 브랜치를 덮거나 대상 ref가 없으면 막는다.
|
||||
- `rm -r`: 대상이 이 세션의 git 작업 폴더·/tmp·앱 임시 작업 폴더 밖이거나, 너무 넓다
|
||||
(`/`, `~`, `~/workspace/<묶음>`, `.git`, 빈 변수로 `/`가 되는 경로, `폴더/*`로 작업 폴더를 통째 비움).
|
||||
작업 폴더 안이라도 git checkout(등록된 worktree 포함)이나 그것을 품은 폴더를 통째로 지우거나, 옆 worktree
|
||||
안을 지우면 막는다(main checkout 안 worktree에서 `rm -rf ./*`, `rm -rf ../옆-worktree`, `rm -rf ../옆-worktree/src`).
|
||||
/tmp·앱 임시 작업 폴더 아래는 예외다.
|
||||
- DB·볼륨·migration 삭제: SQL 클라이언트의 DROP DATABASE·SCHEMA·TABLE·TRUNCATE, redis FLUSHALL·FLUSHDB,
|
||||
flyway clean·flywayClean, liquibase drop-all, `-p` 없는 compose `down -v`, `volume rm|prune`,
|
||||
`system prune --volumes`, `kubectl delete pvc|pv|ns`.
|
||||
@@ -410,6 +413,7 @@ VAR_RE = re.compile(r"\$(?:\{([A-Za-z_][A-Za-z0-9_]*)([^}]*)\}|([A-Za-z_][A-Za-z
|
||||
OPAQUE = "\x00" # 명령 치환처럼 값을 알 수 없지만 비지 않는 값
|
||||
H12_HOME = os.path.expanduser("~")
|
||||
H12_TMP = "/tmp/claude-%d" % os.getuid()
|
||||
H12_TEMP_ROOTS = ("/tmp", os.path.join(H12_HOME, ".config", "Claude", "scratch-workspaces"))
|
||||
H12_HOME_KEEP = {".ssh", ".config", ".local", ".claude", ".gradle", ".m2", ".cache", ".kube", ".docker",
|
||||
"workspace", "Documents", "Desktop", "Downloads"}
|
||||
|
||||
@@ -517,10 +521,12 @@ class H12Visitor:
|
||||
remote가 참이면 ssh 원격 명령이다. 원격은 작업 폴더를 모르므로 너무 넓은 대상만 막는다.
|
||||
"""
|
||||
|
||||
def __init__(self, cwd, roots, remote=False):
|
||||
def __init__(self, cwd, roots, checkouts=(), foreign=(), remote=False):
|
||||
self.home = "~" if remote else H12_HOME
|
||||
self.cwd = cwd
|
||||
self.roots = roots
|
||||
self.checkouts = checkouts
|
||||
self.foreign = foreign
|
||||
self.remote = remote
|
||||
self.vars = {}
|
||||
self.raw = self.remember
|
||||
@@ -586,6 +592,16 @@ class H12Visitor:
|
||||
return "rm -r %s(너무 넓은 대상: %s)" % (t, path)
|
||||
if not self.remote and not any(under_root(path, r) for r in self.roots):
|
||||
return "rm -r %s(이 작업 폴더·scratchpad 밖: %s)" % (t, path)
|
||||
if not any(under_root(path, r) for r in H12_TEMP_ROOTS):
|
||||
# 허용 폴더(main checkout) 안이라도 checkout 자신이나 그것을 품은 폴더는 통째로 지우지 않고,
|
||||
# 옆 worktree 안도 지우지 않는다. main checkout 안 worktree에서 worktree 자신(`./*`),
|
||||
# 옆 worktree(`../x`), 그 안(`../x/src`)을 지우는 것을 막는다
|
||||
hit = next((c for c in self.checkouts if path == c or under_root(c, path)), None)
|
||||
if hit:
|
||||
return "rm -r %s(git checkout 통째: %s)" % (t, hit)
|
||||
hit = next((c for c in self.foreign if under_root(path, c)), None)
|
||||
if hit:
|
||||
return "rm -r %s(다른 worktree 안: %s)" % (t, hit)
|
||||
return None
|
||||
|
||||
def __call__(self, argv, heredocs):
|
||||
@@ -656,8 +672,15 @@ def data_violation(argv, heredocs):
|
||||
|
||||
|
||||
def h12_roots(cwd):
|
||||
"""rm -r을 허용하는 폴더: 프로젝트와 cwd의 git 작업 폴더(와 그 main checkout), /tmp, 앱 임시 작업 폴더."""
|
||||
roots = ["/tmp", os.path.join(H12_HOME, ".config", "Claude", "scratch-workspaces")]
|
||||
"""(rm -r을 허용하는 폴더, 지킬 checkout, 옆 worktree).
|
||||
|
||||
허용 폴더: 프로젝트와 cwd의 git 작업 폴더(와 그 main checkout), /tmp, 앱 임시 작업 폴더.
|
||||
지킬 checkout: 그 작업 폴더들과, 그 repo에 등록된 모든 worktree. 허용 폴더 안에 있어도 통째로 지우지 못한다.
|
||||
옆 worktree: 지킬 checkout 중 이 세션 작업 폴더와 같지도, 그것을 품지도, 그 안에 있지도 않은 것. 그 안도 못 지운다.
|
||||
이 세션 작업 폴더는 cwd의 checkout이고, cwd가 git 밖일 때만 프로젝트 폴더의 checkout이다. 세션의 프로젝트 폴더가
|
||||
main checkout이고 cwd가 그 안 worktree일 때 옆 worktree를 남의 것으로 보기 위해서다.
|
||||
"""
|
||||
roots, checkouts, tops = list(H12_TEMP_ROOTS), set(), {}
|
||||
for start in {os.environ.get("CLAUDE_PROJECT_DIR"), cwd} - {None, ""}:
|
||||
if not os.path.isdir(start):
|
||||
continue
|
||||
@@ -671,7 +694,20 @@ def h12_roots(cwd):
|
||||
out = os.path.dirname(out)
|
||||
if out and not too_broad(os.path.realpath(out), H12_HOME):
|
||||
roots.append(os.path.realpath(out))
|
||||
return roots
|
||||
checkouts.add(os.path.realpath(out))
|
||||
if args[-1] == "--show-toplevel":
|
||||
tops[start] = os.path.realpath(out)
|
||||
try:
|
||||
r = subprocess.run(["git", "-C", start, "worktree", "list", "--porcelain"],
|
||||
capture_output=True, text=True, timeout=5)
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
continue
|
||||
if r.returncode == 0:
|
||||
checkouts.update(os.path.realpath(line[len("worktree "):]) for line in r.stdout.splitlines()
|
||||
if line.startswith("worktree "))
|
||||
mine = tops.get(cwd) or tops.get(os.environ.get("CLAUDE_PROJECT_DIR"))
|
||||
foreign = [c for c in checkouts if mine and not (c == mine or under_root(mine, c) or under_root(c, mine))]
|
||||
return roots, sorted(checkouts), sorted(foreign)
|
||||
|
||||
|
||||
H12_HINTS = {
|
||||
@@ -694,7 +730,8 @@ def check_h12(command, cwd=None):
|
||||
"""H12 막을 이유(메시지). 통과면 None."""
|
||||
if not re.search(r"(?i)push|rm|drop|truncate|flush|clean|down|volume|prune|delete", command):
|
||||
return None
|
||||
what = walk(command, H12Visitor(os.path.realpath(cwd) if cwd else None, h12_roots(cwd)))
|
||||
roots, checkouts, foreign = h12_roots(cwd)
|
||||
what = walk(command, H12Visitor(os.path.realpath(cwd) if cwd else None, roots, checkouts, foreign))
|
||||
if not what:
|
||||
return None
|
||||
return H12_MESSAGE.format(what=what, hint=H12_HINTS[what.split(":", 1)[0]])
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -13,11 +14,8 @@ import unittest
|
||||
|
||||
SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "scripts")
|
||||
REPO = os.path.dirname(os.path.dirname(os.path.dirname(SCRIPTS)))
|
||||
_COMMON = subprocess.run(["git", "-C", REPO, "rev-parse", "--path-format=absolute", "--git-common-dir"],
|
||||
capture_output=True, text=True).stdout.strip()
|
||||
# main checkout 안에 만든 worktree(.claude/worktrees/…)에서 도는가. 이때 H12 허용 폴더에 main checkout이 들어가
|
||||
# worktree 자신(`rm -rf ./*`)이나 옆 worktree(`../x`)를 지우는 것이 통과한다(알려진 빈틈, 전역 훅과 같이 고친다)
|
||||
NESTED_WORKTREE = bool(_COMMON) and os.path.realpath(REPO).startswith(os.path.dirname(os.path.realpath(_COMMON)) + "/")
|
||||
# 시험용 checkout을 둘 /tmp 밖 후보. H12는 /tmp 아래 rm을 일부러 허용하므로 /tmp 안에서는 작업 폴더 판정이 안 보인다
|
||||
OUTSIDE_TMP_BASES = ("/var/tmp", os.path.expanduser("~"))
|
||||
|
||||
|
||||
def run(script, args=(), payload=None, env=None, cwd=None):
|
||||
@@ -33,20 +31,38 @@ def bash(command, cwd=REPO):
|
||||
"tool_input": {"command": command}, "cwd": cwd}
|
||||
|
||||
|
||||
class GuardBashTest(unittest.TestCase):
|
||||
"""H12. 여기 사례는 판정의 대표만 둔다. 많은 사례는 소유자 기계 전역 훅 시험에 있다."""
|
||||
def git(cwd, *args):
|
||||
"""시험용 git. 사용자 설정(서명·훅·기본 브랜치)에 따라 결과가 달라지지 않게 부른다."""
|
||||
subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@example.com", "-c", "commit.gpgsign=false",
|
||||
"-c", "core.hooksPath=/dev/null", "-c", "init.defaultBranch=main", "-C", cwd, *args],
|
||||
check=True, capture_output=True, text=True, timeout=30)
|
||||
|
||||
|
||||
def outside_tmp_base():
|
||||
"""OUTSIDE_TMP_BASES 중 쓸 수 있는 첫 폴더. 없으면 시험을 건너뛰지 않고 오류로 멈춘다."""
|
||||
for base in OUTSIDE_TMP_BASES:
|
||||
real = os.path.realpath(base)
|
||||
if os.path.isdir(real) and os.access(real, os.W_OK) and not (real + "/").startswith("/tmp/"):
|
||||
return real
|
||||
raise RuntimeError("/tmp 밖에 시험용 checkout을 만들 곳이 없다: %s" % ", ".join(OUTSIDE_TMP_BASES))
|
||||
|
||||
|
||||
class H12Asserts:
|
||||
ALWAYS = {"HARNESS_H12": "always"}
|
||||
|
||||
def assert_blocked(self, command, cwd=REPO):
|
||||
r = run("guard_bash.py", payload=bash(command, cwd), env=self.ALWAYS)
|
||||
def assert_blocked(self, command, cwd=REPO, env=None):
|
||||
r = run("guard_bash.py", payload=bash(command, cwd), env={**self.ALWAYS, **(env or {})})
|
||||
self.assertEqual(r.returncode, 2, "막혀야 한다: %s\n%s" % (command, r.stderr))
|
||||
self.assertIn("[H12", r.stderr)
|
||||
|
||||
def assert_passed(self, command, cwd=REPO):
|
||||
r = run("guard_bash.py", payload=bash(command, cwd), env=self.ALWAYS)
|
||||
def assert_passed(self, command, cwd=REPO, env=None):
|
||||
r = run("guard_bash.py", payload=bash(command, cwd), env={**self.ALWAYS, **(env or {})})
|
||||
self.assertEqual(r.returncode, 0, "통과해야 한다: %s\n%s" % (command, r.stderr))
|
||||
|
||||
|
||||
class GuardBashTest(H12Asserts, unittest.TestCase):
|
||||
"""H12. 여기 사례는 판정의 대표만 둔다. 많은 사례는 소유자 기계 전역 훅 시험에 있다."""
|
||||
|
||||
def test_force_push_to_hosting_remote_is_blocked(self):
|
||||
for c in ("git push --force origin main", "git push -f", "git push origin +feature/x",
|
||||
"git push --force-with-lease origin claude/x", "git push --mirror origin",
|
||||
@@ -67,11 +83,6 @@ class GuardBashTest(unittest.TestCase):
|
||||
"ssh build 'rm -rf ~/workspace/some-repo'"):
|
||||
self.assert_blocked(c)
|
||||
|
||||
@(unittest.expectedFailure if NESTED_WORKTREE else (lambda f: f))
|
||||
def test_rm_whole_checkout_or_sibling_is_blocked(self):
|
||||
for c in ("rm -rf ./*", "rm -rf ../other-repo/src"):
|
||||
self.assert_blocked(c)
|
||||
|
||||
def test_rm_inside_project_tmp_and_known_vars_pass(self):
|
||||
for c in ("rm -rf build dist", "rm -rf /tmp/some-build-x", 'T=$(mktemp -d) && rm -rf "$T"',
|
||||
"S=/tmp/x; rm -rf $S/out", 'rm -rf "${OUT:?}/build"', "ssh build 'rm -rf ~/x-logs'"):
|
||||
@@ -109,6 +120,61 @@ class GuardBashTest(unittest.TestCase):
|
||||
self.assertEqual(r.returncode, 1)
|
||||
|
||||
|
||||
class GuardRmCheckoutTest(H12Asserts, unittest.TestCase):
|
||||
"""H12가 작업 폴더 안 삭제는 통과시키고 작업 폴더 자신·옆 폴더 삭제는 막는지.
|
||||
|
||||
이 repo의 checkout을 cwd로 쓰면 결과가 checkout 위치에 따라 달라진다(/tmp 아래면 /tmp 허용에 걸려 통과하고,
|
||||
main checkout 안의 worktree면 main checkout 허용에 걸려 통과한다). 그래서 /tmp 밖에 checkout과 그 안의
|
||||
worktree를 직접 만들어 cwd로 넘긴다.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
base = tempfile.mkdtemp(prefix="h12-test-", dir=outside_tmp_base())
|
||||
cls.addClassCleanup(shutil.rmtree, base, True)
|
||||
cls.checkout = os.path.join(base, "repo")
|
||||
git(base, "init", "-q", cls.checkout)
|
||||
git(cls.checkout, "commit", "-q", "--allow-empty", "-m", "init")
|
||||
cls.worktree = os.path.join(cls.checkout, ".claude", "worktrees", "w")
|
||||
cls.sibling = os.path.join(cls.checkout, ".claude", "worktrees", "w2")
|
||||
for wt in (cls.worktree, cls.sibling):
|
||||
git(cls.checkout, "worktree", "add", "-q", "--detach", wt)
|
||||
# scratchpad처럼 /tmp 아래 둔 worktree. /tmp 아래는 일부러 허용하므로 통째로 지워도 통과해야 한다
|
||||
cls.tmp_worktree = os.path.join(tempfile.mkdtemp(prefix="h12-test-", dir="/tmp"), "wt")
|
||||
cls.addClassCleanup(shutil.rmtree, os.path.dirname(cls.tmp_worktree), True)
|
||||
git(cls.checkout, "worktree", "add", "-q", "--detach", cls.tmp_worktree)
|
||||
|
||||
def test_rm_inside_checkout_and_worktree_passes(self):
|
||||
# 둘 다 허용 폴더로 잡힌다. 아래 시험이 막히는 것은 위치를 몰라서가 아니라 대상이 넓어서다
|
||||
for cwd in (self.checkout, self.worktree):
|
||||
for c in ("rm -rf build", "rm -rf build dist node_modules/.cache", "rm -rf ./out/*"):
|
||||
self.assert_passed(c, cwd=cwd)
|
||||
self.assert_passed("rm -rf ../../build", cwd=self.worktree) # main checkout 안, worktree 밖(.claude/build)
|
||||
self.assert_passed("rm -rf .claude/worktrees/w/build", cwd=self.checkout) # main checkout이 worktree 안을 치운다
|
||||
|
||||
def test_rm_tmp_worktree_passes(self):
|
||||
for cwd in (self.checkout, self.worktree):
|
||||
self.assert_passed("rm -rf %s" % self.tmp_worktree, cwd=cwd)
|
||||
|
||||
def test_rm_whole_checkout_or_sibling_is_blocked(self):
|
||||
for c in ("rm -rf ./*", "rm -rf ../other-repo/src", "rm -rf .claude/worktrees", "rm -rf .claude/worktrees/w"):
|
||||
self.assert_blocked(c, cwd=self.checkout)
|
||||
|
||||
def test_rm_nested_worktree_itself_or_sibling_is_blocked(self):
|
||||
"""main checkout 안 worktree에서 worktree 자신, 옆 worktree, 그 안, 둘을 품은 폴더를 지우지 못한다."""
|
||||
for c in ("rm -rf ./*", "rm -rf ../w2", "rm -rf ../w2/src", "rm -rf ..", "rm -rf ../.."):
|
||||
self.assert_blocked(c, cwd=self.worktree)
|
||||
|
||||
def test_project_dir_main_checkout_still_guards_nested_worktree(self):
|
||||
"""앱이 worktree 세션의 CLAUDE_PROJECT_DIR를 main checkout으로 줄 때도 같은 판정이다(세션 cwd가 먼저다)."""
|
||||
env = {"CLAUDE_PROJECT_DIR": self.checkout}
|
||||
for c in ("rm -rf ./*", "rm -rf ../w2", "rm -rf ../w2/src"):
|
||||
self.assert_blocked(c, cwd=self.worktree, env=env)
|
||||
for c in ("rm -rf build", "rm -rf ../../build"):
|
||||
self.assert_passed(c, cwd=self.worktree, env=env)
|
||||
self.assert_passed("rm -rf .claude/worktrees/w/build", cwd=self.checkout, env=env)
|
||||
|
||||
|
||||
class NudgeSecretsTest(unittest.TestCase):
|
||||
def nudge(self, content, tool="Write"):
|
||||
key = "content" if tool == "Write" else "new_string"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "redteam",
|
||||
"displayName": "Red Team",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"description": "두 템플릿을 공격하는 red team 장치: 역할별 서브에이전트(정찰·인증/인가·입력·의존성·설정·프론트), 발동 스킬, 핀 고정 오픈소스 도구 실행 래퍼와 발견 수집 도구. 훅은 두지 않는다(요청할 때만 돈다).",
|
||||
"author": {
|
||||
"name": "donghyeon.kang"
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
## 도구와 라이선스
|
||||
| 도구 | 라이선스 | 비고 |
|
||||
|---|---|---|
|
||||
| gitleaks | MIT | 비밀 값 |
|
||||
| gitleaks | MIT | 비밀 값(`--redact`로 결과 파일에 값 원문을 남기지 않음) |
|
||||
| semgrep CE | 엔진 LGPL-2.1 | SAST(공식 이미지, 룰은 런타임·`--metrics=off`로 코드 안 보냄) |
|
||||
| trivy | Apache-2.0 | 의존성/이미지 — 기존 게이트와 공유 |
|
||||
| osv-scanner | Apache-2.0 | lockfile 교차검증 |
|
||||
| checkov | Apache-2.0 | IaC·compose·Dockerfile |
|
||||
| hadolint | GPL-3.0 | Dockerfile(실행만) |
|
||||
| OWASP ZAP | Apache-2.0 | DAST baseline·api |
|
||||
| OWASP ZAP | Apache-2.0 | DAST baseline·api(`-z "-silent"`로 텔레메트리·업데이트 확인을 끔) |
|
||||
| nuclei | MIT | 노출 템플릿(로컬 대상만) |
|
||||
| schemathesis | MIT | OpenAPI 퍼징 |
|
||||
| trufflehog | AGPL-3.0 | 심층 비밀 값(실행만, 배포 안 함) |
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
# bash redteam-scan.sh <mode> --target <소스경로|URL> --out <결과폴더> [옵션]
|
||||
#
|
||||
# 모드:
|
||||
# secrets gitleaks: 소스·git 히스토리의 비밀 값
|
||||
# secrets gitleaks: 소스·git 히스토리의 비밀 값(--redact로 결과에 값 원문을 남기지 않음)
|
||||
# sast semgrep CE: 정적 분석(룰은 런타임에 레지스트리에서, --metrics=off로 코드 안 보냄)
|
||||
# deps trivy fs: 의존성 취약점(HIGH/CRIT 요약)
|
||||
# config checkov + hadolint: compose·Dockerfile·IaC 오구성
|
||||
# dast-baseline OWASP ZAP baseline: 띄운 앱에 수동(passive) 스캔(헤더·쿠키·CSP)
|
||||
# dast-baseline OWASP ZAP baseline: 띄운 앱에 수동(passive) 스캔(헤더·쿠키·CSP). ZAP은 -silent로
|
||||
# call home(텔레메트리·업데이트 확인·뉴스)을 끈다(dast-api도 같다)
|
||||
# dast-api ZAP api-scan + schemathesis: OpenAPI 기반 능동·퍼징 (--api 필요)
|
||||
# nuclei nuclei: 알려진 노출·오구성 템플릿 (대상은 내 로컬 URL만)
|
||||
# pin tools.lock의 모든 도구를 받아 실제 digest를 출력(고정에 붙여 쓴다)
|
||||
@@ -89,9 +90,11 @@ case "${MODE}" in
|
||||
do_pin
|
||||
;;
|
||||
secrets)
|
||||
# --redact: 찾은 값 원문 대신 REDACTED를 쓴다. 이 결과를 읽는 에이전트 컨텍스트에 비밀 값이 들어가지 않게.
|
||||
# 위치(파일·줄·커밋·규칙)는 그대로 남으니 고칠 곳을 찾는 데는 모자라지 않다.
|
||||
ref="$(image_ref gitleaks)"; ensure_image "${ref}"
|
||||
docker run --rm -v "${TARGET}:/repo:ro" "${ref}" \
|
||||
detect --source=/repo --no-banner --report-format json --report-path /dev/stdout \
|
||||
detect --source=/repo --no-banner --redact --report-format json --report-path /dev/stdout \
|
||||
> "${OUT}/secrets.json" 2> "${OUT}/secrets.log" || true
|
||||
echo "→ ${OUT}/secrets.json"
|
||||
;;
|
||||
@@ -126,7 +129,7 @@ case "${MODE}" in
|
||||
[ -n "${TARGET}" ] || { echo "--target <URL> 필요" >&2; exit 2; }
|
||||
ref="$(image_ref zap)"; ensure_image "${ref}"
|
||||
docker run --rm "${netarg[@]}" -v "${OUT}:/zap/wrk:rw" "${ref}" \
|
||||
zap-baseline.py -t "${TARGET}" -J dast-baseline.json -r dast-baseline.html \
|
||||
zap-baseline.py -t "${TARGET}" -J dast-baseline.json -r dast-baseline.html -z "-silent" \
|
||||
> "${OUT}/dast-baseline.log" 2>&1 || true
|
||||
echo "→ ${OUT}/dast-baseline.json"
|
||||
;;
|
||||
@@ -134,7 +137,7 @@ case "${MODE}" in
|
||||
[ -n "${API}" ] || { echo "--api <OpenAPI URL|파일> 필요" >&2; exit 2; }
|
||||
ref="$(image_ref zap)"; ensure_image "${ref}"
|
||||
docker run --rm "${netarg[@]}" -v "${OUT}:/zap/wrk:rw" "${ref}" \
|
||||
zap-api-scan.py -t "${API}" -f openapi -J dast-api.json -r dast-api.html \
|
||||
zap-api-scan.py -t "${API}" -f openapi -J dast-api.json -r dast-api.html -z "-silent" \
|
||||
> "${OUT}/dast-api.log" 2>&1 || true
|
||||
st="$(image_ref schemathesis)"; ensure_image "${st}"
|
||||
docker run --rm "${netarg[@]}" "${st}" \
|
||||
|
||||
@@ -6,6 +6,7 @@ finding.py의 정규화·검사·정렬·보고 로직과, tools.lock·redteam-s
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -150,5 +151,62 @@ class ScanScriptTest(unittest.TestCase):
|
||||
self.assertIn(mode, r.stdout + r.stderr, "help에 모드 없음: %s" % mode)
|
||||
|
||||
|
||||
FAKE_DOCKER = """#!/usr/bin/env bash
|
||||
# 시험용 docker: 받은 인자를 한 줄(\\x1f로 구분)로 남기고, 이미지가 이미 있다고 답한다.
|
||||
printf '%s\\x1f' "$@" >> "$FAKE_DOCKER_LOG"; printf '\\n' >> "$FAKE_DOCKER_LOG"
|
||||
exit 0
|
||||
"""
|
||||
|
||||
|
||||
class ScanEgressTest(unittest.TestCase):
|
||||
"""도구가 찾은 비밀 값 원문을 결과 파일에 남기지 않고, 밖으로 사용 정보를 보내지 않게 부르는지 본다.
|
||||
|
||||
가짜 docker로 redteam-scan.sh가 실제로 넘기는 인자를 받아 확인한다(docker를 띄우지 않는다).
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.dir = tempfile.mkdtemp()
|
||||
os.makedirs(os.path.join(self.dir, "bin"))
|
||||
docker = os.path.join(self.dir, "bin", "docker")
|
||||
with open(docker, "w", encoding="utf-8") as fh:
|
||||
fh.write(FAKE_DOCKER)
|
||||
os.chmod(docker, 0o755)
|
||||
self.log = os.path.join(self.dir, "docker.log")
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.dir, ignore_errors=True)
|
||||
|
||||
def run_calls(self, *args):
|
||||
"""모드를 돌리고 `docker run` 호출마다 인자 목록을 돌려준다."""
|
||||
# 필요한 값만 넘긴다: 가짜 docker가 먼저 잡히는 PATH와 기록 파일.
|
||||
env = {"PATH": os.path.join(self.dir, "bin") + os.pathsep + os.defpath, "FAKE_DOCKER_LOG": self.log}
|
||||
r = subprocess.run(["bash", os.path.join(SCRIPTS, "redteam-scan.sh"), *args,
|
||||
"--out", os.path.join(self.dir, "out")],
|
||||
capture_output=True, text=True, timeout=30, env=env)
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
with open(self.log, encoding="utf-8") as fh:
|
||||
calls = [line.rstrip("\n").rstrip("\x1f").split("\x1f") for line in fh if line.strip()]
|
||||
return [c for c in calls if c[:1] == ["run"]]
|
||||
|
||||
def test_secrets_redacts_values_in_report(self):
|
||||
calls = self.run_calls("secrets", "--target", self.dir)
|
||||
self.assertEqual(len(calls), 1)
|
||||
self.assertIn("--redact", calls[0], "gitleaks 결과 파일에 비밀 값 원문이 남는다")
|
||||
|
||||
def test_sast_keeps_metrics_off(self):
|
||||
calls = self.run_calls("sast", "--target", self.dir)
|
||||
self.assertIn("--metrics=off", calls[0])
|
||||
|
||||
def test_zap_runs_silent(self):
|
||||
for args, script in ((("dast-baseline", "--target", "http://127.0.0.1:9"), "zap-baseline.py"),
|
||||
(("dast-api", "--api", "http://127.0.0.1:9/openapi.json"), "zap-api-scan.py")):
|
||||
open(self.log, "w").close()
|
||||
zap = [c for c in self.run_calls(*args) if script in c]
|
||||
self.assertEqual(len(zap), 1, script)
|
||||
c = zap[0]
|
||||
self.assertIn("-z", c, "%s에 ZAP 옵션(-z)이 없다" % script)
|
||||
self.assertIn("-silent", c[c.index("-z") + 1].split(), "%s가 ZAP call home(텔레메트리·업데이트 확인)을 끄지 않는다" % script)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user