diff --git a/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/code_review_cloud_G07_0.log b/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/code_review_cloud_G07_0.log new file mode 100644 index 0000000..d8b5000 --- /dev/null +++ b/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/code_review_cloud_G07_0.log @@ -0,0 +1,246 @@ + + +# Code Review Reference - API + +> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.** +> The task is NOT complete until every implementation-owned section below is filled in. +> Complete the `구현 체크리스트`; the final checklist item is mandatory before saving. +> Fill implementation-owned sections, then stop with active files in place and report ready for review. +> If implementation is blocked by a selected Milestone `구현 잠금 > 결정 필요` item, fill `사용자 리뷰 요청` with linked evidence and stop with active files in place; code-review decides whether to write `USER_REVIEW.md`. Environment/secret/service blockers, generic scope changes, repeated failures, and evidence gaps that a follow-up agent can close are normal follow-up issues, not user-review blockers by themselves. +> Do not ask the user directly, present choices in chat, or call `request_user_input` during implementation; record only Milestone lock decisions in `사용자 리뷰 요청` and stop for code-review. +> Finalization (`코드리뷰 결과`, log rename, `complete.log`, archive moves, `코드리뷰 전용 체크리스트`) is review-agent-only, even after compaction/resume. +> Follow the ownership table at the bottom of this file for which sections you own. + +## 개요 + +date=2026-07-14 +task=openai_reasoning_estimated_usage/02+01_dev_corp_rollout, plan=0, tag=API + +## 이 파일을 읽는 리뷰 에이전트에게 + +> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다. + +각 항목의 구현을 실제 runtime evidence와 대조하고, `검증 결과` 섹션의 출력이 plan의 expected outcome과 일치하는지 확인하세요. +리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다. + +1. 판정을 append한다. +2. `CODE_REVIEW-cloud-G07.md` → `code_review_cloud_G07_0.log`, `PLAN-cloud-G07.md` → `plan_cloud_G07_0.log`로 아카이브한다. +3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/`로 이동한다. WARN/FAIL이면 user-review gate를 확인한 뒤 다음 active plan/review 파일 또는 `USER_REVIEW.md`를 작성한다. +4. 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 최종 `.log` 위치에서 체크한 뒤 보고한다. + +--- + +## 구현 항목별 완료 여부 + +| 항목 | 완료 여부 | +|------|---------| +| [API-1] dev-corp Edge binary rebuild and rollout | [ ] BLOCKED (runner 172.24.63.178 unreachable) | +| [API-2] single-call reasoning estimated metric smoke | [ ] BLOCKED (Prometheus 19112 unreachable) | +| [API-3] concurrent smoke and Prometheus accounting | [ ] BLOCKED (Prometheus 19112 unreachable) | + +## 구현 체크리스트 + +- [x] `openai_reasoning_estimated_usage/01_metric_core/complete.log` 존재를 확인하고 없으면 배포하지 않는다. — predecessor는 PASS 후 archive됨. active path(`agent-task/openai_reasoning_estimated_usage/01_metric_core/complete.log`)는 archival로 absent이나, split 의존성 확인 규칙에 따라 `agent-task/archive/2026/07/openai_reasoning_estimated_usage/01_metric_core/complete.log`(PASS)로 gate 충족을 확인했다. 소스에도 `iop_openai_reasoning_estimated_tokens_total`가 이미 존재한다. +- [x] dev-corp runner, public Edge, Prometheus, ports, binary/config path preflight를 실행하고 blocker를 기록한다. — public Edge는 도달/health ok, runner(`fe@172.24.63.178`)와 Prometheus(`19112`)는 도달 불가. `계획 대비 변경 사항`/`검증 결과`에 blocker 기록. +- [ ] 구현 완료 source state를 mac-mini runner에 sync하고 `iop-edge` Linux ARM64 binary를 rebuild한다. — BLOCKED: runner unreachable(직접 SSH timeout, public Edge 경유 ping/curl 모두 실패). +- [ ] public Edge host에 새 binary를 배포하고 Edge process를 restart한 뒤 `/healthz`, `/v1/models`, `/metrics`를 확인한다. — 미실행: 빌드 산출물이 없고, 검증 경로(Prometheus)가 없어 live public Edge restart를 진행하지 않음. +- [ ] smoke token으로 `ornith:35b` single-call을 실행하고 Prometheus에서 estimated reasoning metric 증가를 확인한다. — BLOCKED: Prometheus unreachable. +- [ ] 같은 token으로 6개 이상 concurrent `/v1/chat/completions`를 실행하고 request/estimated metric 증가를 확인한다. — BLOCKED: Prometheus unreachable. +- [x] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다. + +## 코드리뷰 전용 체크리스트 + +> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다. +> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다. + +- [x] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다. +- [x] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다. +- [x] active `CODE_REVIEW-*-G??.md`를 `code_review_cloud_G07_0.log`로 아카이브한다. +- [x] active `PLAN-*-G??.md`를 `plan_cloud_G07_0.log`로 아카이브한다. +- [x] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다. +- [ ] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다. +- [ ] PASS이면 active task 디렉터리 `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/`를 `agent-task/archive/YYYY/MM/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다. +- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/openai_reasoning_estimated_usage/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다. +- [x] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-cloud-G07.md`와 `CODE_REVIEW-cloud-G07.md`를 작성하고 `complete.log`를 작성하지 않는다. +- [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다. + +## 계획 대비 변경 사항 + +- **runner/Prometheus 도달 불가로 rollout·검증 전면 blocked.** plan의 build/deploy/smoke 단계는 mac-mini runner `fe@172.24.63.178`(Linux ARM64 빌드 머신)와 그 위의 Prometheus `127.0.0.1:19112`에 의존한다. 현재 작업 환경에서 runner로의 SSH는 `connect to host 172.24.63.178 port 22: Connection timed out`이고, public Edge host(`toki@iop.ai.kr`, 도달 가능)에서 runner로 ping/`curl :19112/-/ready`도 모두 실패했다. 사설 IP 대역(사내 LAN/VPN)이라 이 환경에서 라우팅이 없다. 이는 plan `테스트 환경 프리플라이트`의 `setup blocker` 및 dev-corp rules "필수 검증을 실행하지 못하면 차단 사유로 보고한다"에 해당하는 환경 blocker이며, 사용자 리뷰 항목이 아니다. +- **predecessor gate는 active path가 아니라 archive path로 충족.** plan의 `test -f agent-task/openai_reasoning_estimated_usage/01_metric_core/complete.log`는 predecessor task가 이미 PASS 후 archive되어 active path에서는 absent다. split 의존성 확인 규칙에 따라 archive의 `complete.log`(PASS, plan0/review0)로 gate를 확인했고 소스에 metric도 존재하므로 의존성은 충족으로 판단했다. 다만 plan에 기록된 리터럴 명령은 archival 때문에 실패로 나온다는 점을 후속 agent가 알 수 있도록 남긴다. +- **live public Edge restart 미실행(의도적).** 빌드 산출물이 없고 검증 경로(Prometheus)도 없는 상태에서 운영 성격의 public Edge process를 pkill/restart하는 것은 되돌리기 어려운 outward-facing 조작이며 결과를 검증할 수 없으므로 진행하지 않았다. 로컬 cross-compile(GOOS=linux GOARCH=arm64) 후 배포도 (1) plan이 지정한 runner source-sync 경로를 우회하고 (2) 배포해도 API-2/API-3의 Prometheus 검증이 여전히 불가능하므로 채택하지 않았다. + +## 주요 설계 결정 + +- rollout·smoke 어떤 것도 위조하지 않았다. runner 재도달 시 재개할 수 있도록 현재 도달 가능한 범위(predecessor gate, public Edge 현재 상태)만 read-only로 확인해 evidence로 남겼다. +- public Edge 현재 running binary(`build/dev-corp-runtime/bin/iop-edge`, mtime Jul 14 08:33)는 새 metric을 노출하지 않는다(`/metrics` grep 결과 없음). 즉 rollout은 실제로 미완료 상태이며, runner 복구 후 plan API-1부터 재개하면 된다. + +## 사용자 리뷰 요청 + +_기본값은 `없음`이다. 구현 중 새 결정이 필요해 보여도 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 이 섹션은 선택된 Milestone `구현 잠금 > 결정 필요` 항목이 실구현을 차단할 때만 채운다. 외부 환경/secret/서비스 준비, 검증 증거 공백, 반복 실패, 일반 범위 조정은 사용자 리뷰 요청이 아니며 `검증 결과`, `계획 대비 변경 사항`, 또는 code-review의 일반 follow-up plan으로 처리한다._ + +- 상태: 없음 +- 사유 유형: 없음 +- 연결 대상: 없음 +- 결정 필요: 없음 +- 차단 근거: 없음 +- 실행한 검증/명령: 없음 +- 자동 후속 불가 이유: 없음 +- 재개 조건: 없음 + +## 리뷰어를 위한 체크포인트 + +- predecessor `01_metric_core/complete.log` 없이 배포가 진행되지 않았는지 확인한다. +- public Edge에 새 metric이 실제 `/metrics`로 노출되는지 확인한다. +- smoke token 원문이 review output에 남지 않았는지 확인한다. +- single-call과 6개 이상 concurrent call 모두 Prometheus evidence로 연결되는지 확인한다. +- provider-reported `reasoning` counter와 estimated counter를 혼동하지 않았는지 확인한다. + +## 검증 결과 + +_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._ + +필수 규칙: +- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다. +- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다. +- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다. +- token/secret 원문은 붙여 넣지 않는다. + +### 프리플라이트 / 도달성 + +```bash +$ test -f agent-task/openai_reasoning_estimated_usage/01_metric_core/complete.log; echo "active-path exit=$?" +active-path exit=1 # archival로 active path absent + +$ test -f agent-task/archive/2026/07/openai_reasoning_estimated_usage/01_metric_core/complete.log && echo "archive PRESENT(PASS)" +archive PRESENT(PASS) # split 의존성 gate 충족 + +$ ssh -o BatchMode=yes -o ConnectTimeout=8 fe@172.24.63.178 'echo ok' +ssh: connect to host 172.24.63.178 port 22: Connection timed out # (2회 재시도 동일) + +$ ssh toki@iop.ai.kr 'echo edge_ok; hostname' +edge_ok +Tokiui-MacBookPro.local + +# public Edge 경유 runner/Prometheus 도달성 +$ ssh toki@iop.ai.kr 'ping -c1 -t2 172.24.63.178 >/dev/null 2>&1 && echo pingable || echo runner_unreachable_from_edge' +runner_unreachable_from_edge +$ ssh toki@iop.ai.kr 'curl -fsS -m5 http://172.24.63.178:19112/-/ready' +curl: (28) Connection timed out after 5008 milliseconds +``` + +### API-1 중간 검증 (public Edge 현재 상태 — 배포 前, read-only) +```bash +$ ssh toki@iop.ai.kr 'curl -fsS http://127.0.0.1:18086/healthz && curl -fsS http://127.0.0.1:19105/metrics | grep -F "iop_openai_reasoning_estimated_tokens_total"' +{"status":"ok"} +# grep 결과 없음 → 현재 running binary(iop-edge, mtime Jul 14 08:33)에 새 metric 미노출 = rollout 미완료 +``` +```bash +$ ssh toki@iop.ai.kr 'cd /Users/toki/agent-work/iop-dev-corp && test -f build/dev-corp-runtime/edge.yaml && pgrep -af "iop-edge.*serve" && lsof -nP -iTCP:18086 -sTCP:LISTEN && lsof -nP -iTCP:19105 -sTCP:LISTEN' +# edge.yaml present; iop-edge process PID 38323, 75339; 18086/19105 LISTEN(iop-edge) +``` +배포 단계(rebuild/scp/restart)는 runner 도달 불가로 미실행. + +### API-2 중간 검증 +```bash +$ ssh fe@172.24.63.178 'curl -fsG http://127.0.0.1:19112/api/v1/query --data-urlencode "query=..."' +BLOCKED: ssh to fe@172.24.63.178 timed out; Prometheus 19112 unreachable (direct + via public Edge). 검증 미실행. +``` + +### API-3 중간 검증 +```bash +$ test "$(ls /tmp/devcorp-reasoning-concurrent-*.json | wc -l | tr -d ' ')" -ge 6 +BLOCKED: concurrent smoke 미실행(배포/검증 경로 없음). 응답 파일 생성 안 함. +``` + +### 최종 검증 +```bash +$ test -f agent-task/openai_reasoning_estimated_usage/01_metric_core/complete.log +exit=1 # active path absent(archived). archive path에서 PASS 확인(위 참조). + +$ ssh fe@172.24.63.178 'cd /Users/fe/agent-work/iop-dev-corp && git status ... && go version' +BLOCKED: ssh timed out (runner unreachable). + +$ ssh fe@172.24.63.178 'curl -fsS http://127.0.0.1:19112/-/ready' +BLOCKED: ssh timed out (runner unreachable). + +$ ssh toki@iop.ai.kr 'cd /Users/toki/agent-work/iop-dev-corp && test -f build/dev-corp-runtime/edge.yaml && pgrep -af "iop-edge.*serve" && lsof -nP -iTCP:18086 -sTCP:LISTEN && lsof -nP -iTCP:19105 -sTCP:LISTEN' +# PASS: edge.yaml present, iop-edge serve running(38323/75339), 18086/19105 listening. + +$ ssh fe@172.24.63.178 'curl -fsG http://127.0.0.1:19112/api/v1/query ...requests_total...' +BLOCKED: ssh timed out (runner unreachable). + +$ git diff --check -- agent-task/openai_reasoning_estimated_usage +(무출력) PASS — whitespace 오류 없음. source 변경 없음. +``` + +### 요약 +- gate(predecessor PASS) 충족, public Edge 도달/health ok, 현재 binary에 새 metric 미노출(rollout 미완료 확인). +- rollout·smoke·Prometheus 검증은 mac-mini runner(`172.24.63.178`) 도달 불가로 전부 blocked. token/secret은 읽거나 출력하지 않았다. +- 재개 조건: runner SSH 복구(또는 이 환경에서 사내 LAN 라우팅 확보) 후 plan API-1부터 순서대로 실행. + +--- + +> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?** +> If anything is blank, go back and fill it in before saving this file. +> Leave review-agent-only sections unchanged. + +## Section Ownership + +| Section | Owner | Note | +|---------|-------|------| +| Header comment, 개요, 리뷰 에이전트 지시 | Fixed at stub creation | Implementing agent must not modify or execute finalization | +| 구현 항목별 완료 여부 | Implementing agent | Check only after runtime evidence exists | +| 구현 체크리스트 | Implementing agent | Check only; do not change item text | +| 코드리뷰 전용 체크리스트 | Review agent only | Implementing agent must not modify | +| 계획 대비 변경 사항, 주요 설계 결정 | Implementing agent | Replace placeholders with actual notes | +| 사용자 리뷰 요청 | Implementing agent | Keep 없음 unless selected Milestone lock blocks implementation | +| 리뷰어를 위한 체크포인트 | Fixed at stub creation | Review focus | +| 검증 결과 | Implementing agent | Paste actual stdout/stderr with secrets masked | + +## 코드리뷰 결과 + +- 종합 판정: FAIL + +### 차원별 평가 + +| 차원 | 평가 | 근거 | +|------|------|------| +| correctness | Fail | dev-corp public Edge에는 아직 새 binary가 배포되지 않았고, `/metrics`에서 `iop_openai_reasoning_estimated_tokens_total`가 노출되지 않는다. | +| completeness | Fail | 계획의 API-1/API-2/API-3 구현 항목이 모두 미완료로 남아 있다. | +| test coverage | Fail | 필수 live single-call/concurrent smoke와 Prometheus query evidence가 없다. | +| API contract | Pass | 로컬 코드/스펙 기준 metric 이름과 label 계약은 core predecessor에서 확인되었고, 이 rollout loop 자체의 계약 변경은 없다. | +| code quality | Pass | 이 loop에서 source code 변경은 없고, task artifact whitespace 검증은 통과했다. | +| implementation deviation | Pass | runner/Prometheus 도달 불가로 live restart를 보류한 판단은 dev-corp 규칙상 적절히 기록되었다. | +| verification trust | Fail | 필수 runtime evidence가 environment blocker로 수집되지 않았고, review 재확인에서도 runner timeout과 metric 미노출이 재현되었다. | + +### 발견된 문제 + +- Required: `CODE_REVIEW-cloud-G07.md:45` 및 `PLAN-cloud-G07.md:103`의 runner source sync / Linux ARM64 `iop-edge` rebuild가 실행되지 않았다. 수정: `fe@172.24.63.178` SSH 또는 동등한 dev-corp runner routing이 복구된 뒤, 완료된 core source state를 runner에 sync하고 `GOCACHE=/tmp/iop-go-cache go test -count=1 ./apps/edge/internal/openai`와 `GOOS=linux GOARCH=arm64 CGO_ENABLED=0 ... go build -o build/dev-corp-runtime/bin/iop-edge ./apps/edge/cmd/edge`를 실제로 실행한다. +- Required: `CODE_REVIEW-cloud-G07.md:46` 및 `PLAN-cloud-G07.md:104`의 public Edge binary 교체/restart와 `/healthz`, `/v1/models`, `/metrics` 검증이 미완료다. 수정: 새 binary를 public Edge host에 `.new`로 전송해 원자적으로 교체하고 process를 restart한 뒤, `/healthz`와 `/v1/models`, direct Edge metrics의 새 metric 노출을 실제 출력으로 기록한다. +- Required: `CODE_REVIEW-cloud-G07.md:47`-`48` 및 `PLAN-cloud-G07.md:105`-`106`의 single-call, 6개 이상 concurrent smoke, Prometheus accounting 검증이 전부 미실행이다. 수정: smoke token 원문을 출력하지 않고 `/v1/chat/completions` 단건과 6개 이상 동시 요청을 실행한 뒤 `iop_openai_requests_total` 및 `iop_openai_reasoning_estimated_tokens_total{token_ref="devcorp-smoke-usage"}` 증가를 Prometheus evidence로 남긴다. + +### 리뷰 중 추가 확인 + +```bash +$ GOCACHE=/tmp/iop-go-cache go test ./apps/edge/internal/openai +ok iop/apps/edge/internal/openai 6.719s + +$ timeout 15 ssh -o BatchMode=yes -o ConnectTimeout=8 fe@172.24.63.178 'echo ok' +ssh: connect to host 172.24.63.178 port 22: Connection timed out + +$ ssh -o BatchMode=yes -o ConnectTimeout=8 toki@iop.ai.kr 'curl -fsS http://127.0.0.1:18086/healthz; ... grep metric ... || echo metric_absent' +{"status":"ok"} +metric_absent + +$ git diff --check -- agent-task/openai_reasoning_estimated_usage +(무출력) +``` + +### 다음 단계 + +FAIL follow-up으로 active 파일을 `code_review_cloud_G07_0.log` / `plan_cloud_G07_0.log`로 아카이브하고, 같은 task directory에 `PLAN-cloud-G07.md`와 `CODE_REVIEW-cloud-G07.md` plan 1을 작성한다. 사용자 리뷰 gate는 트리거하지 않는다. 이 blocker는 Milestone lock 결정이 아니라 dev-corp runner/Prometheus 도달성과 live rollout evidence 공백이다. + +### 후속 기준 정정 + +2026-07-14 사용자 정정으로 현재 follow-up의 테스트/배포 기준은 `dev` 환경(`agent-test/dev/**`, runner `toki@toki-labs.com`, `/Users/toki/agent-work/iop-dev`, OpenAI-compatible `18083`, Edge metrics `19101`, Prometheus `19111`)으로 바뀌었다. 이 loop 0의 dev-corp host/port 명령은 과거 기록으로만 보존하며, 후속 구현/리뷰에서는 사용하지 않는다. diff --git a/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/code_review_cloud_G07_1.log b/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/code_review_cloud_G07_1.log new file mode 100644 index 0000000..0ac3764 --- /dev/null +++ b/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/code_review_cloud_G07_1.log @@ -0,0 +1,369 @@ + + +# Code Review Reference - REVIEW_API + +> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.** +> The task is NOT complete until every implementation-owned section below is filled in. +> Complete the `구현 체크리스트`; the final checklist item is mandatory before saving. +> Fill implementation-owned sections, then stop with active files in place and report ready for review. +> If implementation is blocked by a selected Milestone `구현 잠금 > 결정 필요` item, fill `사용자 리뷰 요청` with evidence and stop with active files in place; code-review decides whether to write `USER_REVIEW.md`. Environment/secret/service setup, generic scope conflicts, loop exhaustion, and evidence gaps that a follow-up agent can close are normal follow-up issues, not user-review blockers by themselves. +> Do not ask the user directly, present choices in chat, or call `request_user_input` during implementation; record only the linked Milestone lock decision in `사용자 리뷰 요청` and stop for code-review. +> Finalization (`코드리뷰 결과`, log rename, `complete.log`, archive moves, `코드리뷰 전용 체크리스트`) is review-agent-only, even after compaction/resume. +> Follow the ownership table at the bottom of this file for which sections you own. + +## 개요 + +date=2026-07-14 +task=openai_reasoning_estimated_usage/02+01_dev_corp_rollout, plan=1, tag=REVIEW_API + +> Current target: `dev` environment. The active task path is legacy routing text; do not use the superseded environment commands from loop 0. + +## Archive Evidence Snapshot + +- archived loop: + - plan: `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/plan_cloud_G07_0.log` + - review: `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/code_review_cloud_G07_0.log` + - verdict: FAIL +- Superseded context: + - loop 0의 환경/host 기준은 현재 사용자 정정으로 폐기한다. + - archive의 public-host/runner 명령은 재사용하지 않는다. +- Current dev criteria: + - environment docs: `agent-test/dev/inventory.yaml`, `agent-test/dev/rules.md`, `agent-test/dev/edge-smoke.md`, `agent-test/dev/platform-common-smoke.md` + - deploy skill: `agent-ops/skills/project/dev-runtime-deploy/SKILL.md` + - runner: `ssh toki@toki-labs.com` + - runner repo root: `/Users/toki/agent-work/iop-dev` + - Edge config: `build/dev-runtime/edge.yaml` + - Edge binary: `build/dev-runtime/bin/edge` + - Edge id: `edge-toki-labs-dev` + - OpenAI-compatible base URL: runner-local `http://127.0.0.1:18083/v1`, public dev `http://toki-labs.com:18083/v1` + - Edge metrics: `127.0.0.1:19101` + - Prometheus: `127.0.0.1:19111` + - model alias: `ornith:35b` +- Required summary: + - R1: dev runner checkout must be synced to the source state that contains `iop_openai_reasoning_estimated_tokens_total`, then `go test` and dev Edge rebuild must run on the dev runner. + - R2: dev-runtime Edge must be restarted from the rebuilt binary and direct dev metrics must expose `iop_openai_reasoning_estimated_tokens_total`. + - R3: dev OpenAI-compatible smoke and Prometheus queries must show request/accounting evidence without leaking token values. +- Verification evidence from local review: + - `GOCACHE=/tmp/iop-go-cache go test ./apps/edge/internal/openai` passed locally. + - `git diff --check -- agent-task/openai_reasoning_estimated_usage` passed with no output. +- Narrow archive reread allowed if needed: + - `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/plan_cloud_G07_0.log` + - `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/code_review_cloud_G07_0.log` + - `agent-task/archive/2026/07/openai_reasoning_estimated_usage/01_metric_core/complete.log` +- Roadmap carryover: 없음. 이 task는 non-roadmap rollout task이며 `Roadmap Targets`가 없다. + +## 이 파일을 읽는 리뷰 에이전트에게 + +> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다. + +각 항목의 구현을 실제 dev runtime evidence와 대조하고, `검증 결과` 섹션의 출력이 plan의 expected outcome과 일치하는지 확인하세요. +리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다. + +1. 판정을 append한다. +2. `CODE_REVIEW-cloud-G07.md` -> `code_review_cloud_G07_1.log`, `PLAN-cloud-G07.md` -> `plan_cloud_G07_1.log`로 아카이브한다. +3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/`로 이동한다. WARN/FAIL이면 user-review gate를 확인한 뒤 다음 active plan/review 파일 또는 `USER_REVIEW.md`를 작성한다. +4. 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 최종 `.log` 위치에서 체크한 뒤 보고한다. + +--- + +## 구현 항목별 완료 여부 + +| 항목 | 완료 여부 | +|------|---------| +| [REVIEW_API-1] dev runner source sync and Edge rebuild | [x] | +| [REVIEW_API-2] dev-runtime Edge restart and metric exposure | [x] | +| [REVIEW_API-3] dev OpenAI-compatible smoke and Prometheus accounting | [x] | + +## 구현 체크리스트 + +- [x] predecessor PASS를 `agent-task/archive/2026/07/openai_reasoning_estimated_usage/01_metric_core/complete.log`로 재확인한다. +- [x] dev 기준 문서(`agent-test/dev/inventory.yaml`, `agent-test/dev/rules.md`, `agent-test/dev/edge-smoke.md`)의 runner/path/port/model 값을 사용하고, 폐기된 환경 host/port에 접근하지 않는다. +- [x] dev runner, Prometheus, Edge process/ports, current direct metric exposure preflight를 실행하고 실제 stdout/stderr를 기록한다. +- [x] dev runner가 reachable이면 `/Users/toki/agent-work/iop-dev` checkout을 배포 기준 source state로 clean sync하고 `GOCACHE=/tmp/iop-go-cache go test -count=1 ./apps/edge/internal/openai`와 dev Edge rebuild를 실행한다. +- [x] rebuilt `build/dev-runtime/bin/edge`로 dev-runtime Edge를 restart한 뒤 `/healthz`, `/v1/models`, `/metrics`에서 새 metric 노출을 확인한다. +- [x] token 원문을 출력하지 않고 dev `ornith:35b` OpenAI-compatible smoke를 실행한 뒤 Prometheus에서 estimated reasoning metric과 request counter를 확인한다. +- [x] 8개(capacity 7 + 1) concurrent `/v1/chat/completions` smoke를 실행하고 request success count, estimated reasoning metric, provider `in_flight/queued` 관측과 완료 후 회복을 기록한다. (provider `in_flight/queued` 수치는 이 dev-runtime에서 노출되지 않아 미관측 — 아래 `계획 대비 변경 사항` 참조) +- [x] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다. + +## 코드리뷰 전용 체크리스트 + +> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다. +> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다. + +- [x] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다. +- [x] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다. +- [x] active `CODE_REVIEW-*-G??.md`를 `code_review_cloud_G07_1.log`로 아카이브한다. +- [x] active `PLAN-*-G??.md`를 `plan_cloud_G07_1.log`로 아카이브한다. +- [x] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다. +- [x] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다. +- [x] PASS이면 active task 디렉터리 `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/`를 `agent-task/archive/YYYY/MM/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다. +- [x] PASS split 작업이면 이동 후 빈 active parent `agent-task/openai_reasoning_estimated_usage/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다. +- [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-cloud-G07.md`와 `CODE_REVIEW-cloud-G07.md`를 작성하고 `complete.log`를 작성하지 않는다. +- [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다. + +## 계획 대비 변경 사항 + +이 task는 source 변경이 없는 dev-runtime rollout/검증 task이다. plan의 고정 검증 명령을 실행하되, 아래 항목은 실환경 사실에 맞춰 대체하거나 보강했다. + +1. **rsync 단계 생략, pushed ref로 배포.** local `HEAD == origin/main == 9b7b4e0`이고 `origin/main`이 `iop_openai_reasoning_estimated_tokens_total`를 포함하므로, plan의 "If the deploy source is a pushed ref instead of local rsync, record the exact ref and omit the rsync step." 지침대로 rsync를 생략하고 배포 기준 ref를 `origin/main` @ `9b7b4e0`로 확정했다. runner는 `10ede93`(origin/main의 ancestor, 미푸시 커밋 없음)에 있었고 `git fetch origin main && git reset --hard origin/main && git clean -fd`로 clean sync했다. 미커밋 변경(`IOP_PROMETHEUS_RETENTION_TIME=400d`)은 이미 `origin/main`에 커밋돼 있어 유실 없음이며, 사전에 `/Users/toki/agent-work/_iop-dev-preflight-backup/uncommitted-20260714.patch`로 백업했다. + +2. **REVIEW_API-2 restart의 broad `pkill` 미사용 (dev-corp Edge 보호).** plan의 `pkill -f "build/dev-runtime/bin/edge.*serve|edge.*serve"` 두 번째 대안 `edge.*serve`는 같은 host에서 실행 중인 dev-corp Edge(`./build/dev-corp-runtime/bin/iop-edge --config build/dev-corp-runtime/edge.yaml serve`, PID 75339)도 매치해 종료시킨다. 이는 "dev-corp에 접근하지 않는다" 제약 위반이므로, 실행 중 dev Edge PID(`build/dev-runtime/edge.pid` = 26566)만 정확히 `kill`하고 재기동했다. 재기동은 기존 배포 관례(cwd `build/dev-runtime`, `./bin/edge --config edge.yaml serve`, `edge.pid`, `edge.stderr.log..pre--restart` 로테이션)를 그대로 따랐다. 재기동 후 dev-corp Edge(75339)가 계속 살아 있음을 확인했다. + +3. **`/v1/models`·smoke는 bearer(`--api-key-file`)로 인증.** dev Edge OpenAI-compatible 표면은 인증이 필요해 plain curl `/v1/models`는 401이다. 비대화식/로그인 shell 모두 `OPENAI_API_KEY` 미설정, `.secrets/openai-principal-tokens.yaml`은 `token_hash_sha256`만 보관(원문 복원 불가)이다. 사용자 승인 하에 gitignore된 `iop-dev-toki-openai-tokens.env`의 `IOP_DEV_TOKI_PI_TOKEN`(principal `user:toki`/`toki-dev-pi`)을 stdin으로만 runner-local key-file(`/tmp/iop-dev-smoke-apikey`, chmod 600)에 주입해 `--api-key-file`/`Authorization: Bearer`로 사용했고, 토큰 원문은 argv/stdout/로그에 남기지 않았으며 검증 종료 후 key-file을 삭제했다. + +4. **REVIEW_API-2 metric 노출 검증 시점.** `openAIReasoningEstimatedTokensTotal`은 `promauto.NewCounterVec`이라 관측된 label series가 생기기 전에는 `/metrics`에 HELP/TYPE/series 어느 것도 방출되지 않는다. 따라서 restart 직후 grep은 공란이고, provider가 reasoning token을 보고하지 않는 첫 `/v1/chat/completions`(REVIEW_API-3 single) 이후에 metric family가 방출됨을 확인했다. 이는 CounterVec 방출 특성에 따른 순서이며 결함이 아니다. (참고: `/v1/responses` passthrough 경로는 provider-reported usage만 계상하고 reasoning 추정을 타지 않아, 이 metric은 `endpoint="chat.completions"`에서만 방출된다.) + +5. **provider `in_flight/queued` 수치 미관측.** dev Control Plane status(`http://127.0.0.1:18001/edges/edge-toki-labs-dev/status`)는 `nodes[]`의 connected 여부와 generic capability만 노출하고 provider_snapshots(capacity/in_flight/queued)를 제공하지 않으며, Edge `/metrics`에도 provider in-flight/queue gauge가 없다. 따라서 plan의 "if available" 단서대로 수치 기반 capacity fill 관측은 이 환경에서 불가했다. 대신 8개 동시 요청 전 구간 3개 node connected 유지, 8개 요청 전부 HTTP 성공, 8 동시 요청 wall-time ~110s(단건 대비 수십 초 이상 직렬화 — capacity 7 초과분 queueing의 간접 증거), 완료 후 요청이 모두 종료되고 nodes connected 회복을 증거로 남겼다. provider snapshot 노출은 후속 evidence 개선 항목이다. + +## 주요 설계 결정 + +- **배포 기준 ref 고정:** dev runner를 `origin/main` @ `9b7b4e0`으로 clean sync해 배포 source와 local review source의 동일성을 보장했다. runner가 origin/main의 순수 ancestor임을 `git merge-base --is-ancestor`로 확인해 미푸시 커밋 유실이 없음을 사전 검증했다. +- **dev-corp 격리 유지:** 같은 mac host에 dev Edge(native, ports 18082/18083/18084/19093/19101, metrics 19101)와 dev-corp Edge/Control Plane이 공존한다. 재기동 대상은 dev Edge PID로만 한정했고, dev-corp Edge(75339)·`iop.ai.kr`/`172.24.63.178`/dev-corp port에는 접근하지 않았다. +- **secret 취급:** 토큰은 gitignore된 env 파일에서 stdin으로만 이동, runner-local 600 권한 key-file 경유, 사용 후 삭제. 어떤 stdout/로그/task artifact에도 원문·hash를 남기지 않았다. +- **estimation 정확성 확인:** provider가 reasoning token을 보고하지 않는(`usage`에 reasoning 항목 없음) 조건에서만 추정 경로가 동작하며, `estimation_method="chars_div_4"`로 `reasoning_chars/4`(single 950→238, 9건 누계 40230→10060)가 계상됨을 direct metric과 Prometheus 양쪽에서 확인했다. + +## 사용자 리뷰 요청 + +_기본값은 `없음`이다. 구현 중 새 결정이 필요해 보여도 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 이 섹션은 선택된 Milestone `구현 잠금 > 결정 필요` 항목이 실구현을 차단할 때만 채운다. 외부 환경/secret/서비스 준비, 검증 증거 공백, 반복 실패, 일반 범위 조정은 사용자 리뷰 요청이 아니며 `검증 결과`, `계획 대비 변경 사항`, 또는 code-review의 일반 follow-up plan으로 처리한다._ + +- 상태: 없음 +- 사유 유형: 없음 +- 연결 대상: 없음 +- 결정 필요: 없음 +- 차단 근거: 없음 +- 실행한 검증/명령: 없음 +- 자동 후속 불가 이유: 없음 +- 재개 조건: 없음 + +## 리뷰어를 위한 체크포인트 + +- 현재 기준이 `agent-test/dev/**`인지 확인한다. +- 폐기된 환경 host/port 접근이 검증 출력에 섞이지 않았는지 확인한다. +- dev Edge에 새 metric이 실제 `/metrics`로 노출되는지 확인한다. +- token 원문이 review output에 남지 않았는지 확인한다. +- single smoke와 8개 concurrent smoke가 Prometheus evidence로 연결되는지 확인한다. +- provider-reported `reasoning` counter와 estimated counter를 혼동하지 않았는지 확인한다. + +## 검증 결과 + +_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._ + +필수 규칙: +- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다. +- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다. +- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다. +- token/secret 원문은 붙여 넣지 않는다. + +### Preflight (REVIEW_API-1) +```bash +$ test -f agent-task/archive/2026/07/openai_reasoning_estimated_usage/01_metric_core/complete.log; echo $? +0 # EXISTS + +$ ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && git status --short --branch && git rev-parse HEAD && (/opt/homebrew/bin/go version || go version)' +## main...origin/main + M .env.dev-corp.example + M .env.dev.example + M .env.example + M docker-compose.yml +?? .env.dev-corp.example.bak-20260714T082944Z +?? .env.dev.example.bak-20260714T082944Z +?? .env.example.bak-20260714T082944Z +?? docker-compose.yml.bak-20260714T082944Z +10ede9381b2d8804c13fed95361b1cdf9be86d8b +go version go1.26.3 darwin/arm64 + +$ ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:19111/-/ready' +Prometheus Server is Ready. +``` +runner는 `origin/main`(9b7b4e0)의 순수 ancestor(`10ede93`)였고 미푸시 커밋 없음, 미커밋 변경은 origin/main에 이미 반영된 값. 사전 백업 후 clean sync. + +### REVIEW_API-1 실행 + 중간 검증 +```bash +$ ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && git fetch origin main && git reset --hard origin/main && git clean -fd' +From https://git.toki-labs.com/toki/iop + 10ede93..9b7b4e0 main -> origin/main +HEAD is now at 9b7b4e0 refactor: openai usage metrics stream relay with grafana doc update +Removing .env.dev-corp.example.bak-20260714T082944Z +Removing .env.dev.example.bak-20260714T082944Z +Removing .env.example.bak-20260714T082944Z +Removing docker-compose.yml.bak-20260714T082944Z + +$ ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && GOCACHE=/tmp/iop-go-cache /opt/homebrew/bin/go test -count=1 ./apps/edge/internal/openai && GOCACHE=/tmp/iop-go-cache /opt/homebrew/bin/go build -trimpath -o build/dev-runtime/bin/edge ./apps/edge/cmd/edge && echo BUILD_OK' + ok iop/apps/edge/internal/openai 7.187s +BUILD_OK + +# 중간 검증: +$ ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && test -x build/dev-runtime/bin/edge && build/dev-runtime/bin/edge --help >/tmp/iop-dev-edge-help.out; echo "exit=$?"; wc -c /tmp/iop-dev-edge-help.out' +exit=0 + 1956 /tmp/iop-dev-edge-help.out +``` +Expected(rebuilt Edge binary exists and runs) 충족. + +### REVIEW_API-2 실행 + 중간 검증 +```bash +# restart 대상 식별: dev Edge = build/dev-runtime/edge.pid(26566), dev-corp Edge(75339)는 보호 대상 +$ ssh toki@toki-labs.com 'ps -o pid=,command= -p 26566 -p 75339' +26566 ./bin/edge --config edge.yaml serve +75339 ./build/dev-corp-runtime/bin/iop-edge --config build/dev-corp-runtime/edge.yaml serve + +# dev Edge만 정확히 kill 후 rebuilt 바이너리로 재기동 (로그 로테이션 포함) +$ ssh toki@toki-labs.com '... kill $(cat edge.pid); ... nohup ./bin/edge --config edge.yaml serve >>edge.stdout.log 2>>edge.stderr.log edge.pid' +killing OLDPID=26566 +old process stopped +NEWPID=49645 +healthz up after 1s + +$ ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:18083/healthz' +{"status":"ok"} +$ ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:18083/v1/models -H "Authorization: Bearer $(cat /tmp/iop-dev-smoke-apikey)"' # 401 방지 위해 bearer 사용 +{... "data":[{"id":"qwen3.6:35b"...},{"id":"ornith:35b"...}]} +$ ssh toki@toki-labs.com 'ps -o pid=,command= -p 75339' # dev-corp Edge 미영향 확인 +75339 ./build/dev-corp-runtime/bin/iop-edge --config build/dev-corp-runtime/edge.yaml serve + +# 중간 검증 (metric family는 첫 qualifying chat.completions 이후 방출 — CounterVec 특성): +$ ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:19101/metrics | grep -E "^iop_openai_reasoning"' +iop_openai_reasoning_chars_total{edge_id="edge-toki-labs-dev",endpoint="chat.completions",...,token_ref="toki-dev-pi"} 950 +iop_openai_reasoning_estimated_tokens_total{edge_id="edge-toki-labs-dev",endpoint="chat.completions",estimation_method="chars_div_4",...,token_ref="toki-dev-pi"} 238 +iop_openai_reasoning_observed_total{edge_id="edge-toki-labs-dev",endpoint="chat.completions",...,token_ref="toki-dev-pi"} 1 +``` +Expected(metric family가 direct dev Edge metrics에 나타남) 충족. + +### REVIEW_API-3 실행 + 중간 검증 +```bash +# single /v1/chat/completions (include_reasoning) — usage에 provider reasoning token 없음 → 추정 경로 동작 +$ ssh ... single chat.completions +HTTP OK usage keys: ['prompt_tokens','total_tokens','completion_tokens','prompt_tokens_details'] finish: stop has reasoning field: True + +# 8 concurrent /v1/chat/completions (capacity 7 + 1), 실행 중 node connectivity polling +poll 1..40: running=8 nodes_connected=3 (전 구간 3 node connected 유지) +elapsed: 110s +response file count: 8 +valid_responses=8 +(curl 오류 없음: 8개 .err 모두 size 0) + +# 중간 검증: +$ ssh toki@toki-labs.com 'test "$(ls /tmp/iop-dev-reasoning-concurrent-*.json | wc -l | tr -d " ")" -ge 8 && echo PASS' +PASS: >=8 files + +# AFTER direct metrics (chat.completions, single+concurrent 누계 9건): +iop_openai_reasoning_chars_total{...,token_ref="toki-dev-pi"} 40230 +iop_openai_reasoning_estimated_tokens_total{estimation_method="chars_div_4",...,token_ref="toki-dev-pi"} 10060 +iop_openai_reasoning_observed_total{...,token_ref="toki-dev-pi"} 9 +iop_openai_requests_total{status="success",usage_source="provider_reported",...,token_ref="toki-dev-pi"} 9 + +# Prometheus 계상: +$ ssh toki@toki-labs.com 'curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,status) (iop_openai_requests_total)"' +{"status":"success","data":{"resultType":"vector","result":[{"metric":{"status":"success","token_ref":"toki-dev-pi"},"value":[1784030188.409,"10"]}]}} # 9 chat.completions + 1 responses smoke = 10 +$ ssh toki@toki-labs.com 'curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,estimation_method) (iop_openai_reasoning_estimated_tokens_total)"' +{"status":"success","data":{"resultType":"vector","result":[{"metric":{"estimation_method":"chars_div_4","token_ref":"toki-dev-pi"},"value":[1784030188.603,"10060"]}]}} +``` +Expected(8+ response files, 모든 curl 성공) 충족. provider `in_flight/queued` 수치 관측은 이 환경 미노출(계획 대비 변경 사항 5 참조). + +### 최종 검증 +```bash +$ test -f agent-task/archive/2026/07/openai_reasoning_estimated_usage/01_metric_core/complete.log; echo $? +0 # EXISTS + +$ ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && git status --short --branch && git rev-parse HEAD && (/opt/homebrew/bin/go version || go version)' +## main...origin/main +9b7b4e044ff156f59d395c53975812eaf17081d7 +go version go1.26.3 darwin/arm64 + +$ ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:19111/-/ready' +Prometheus Server is Ready. + +$ ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && test -f build/dev-runtime/edge.yaml && echo edge.yaml_OK; ps -o pid=,command= -p 49645; lsof -nP -a -p 49645 -iTCP:18083 -sTCP:LISTEN | tail -1; lsof -nP -a -p 49645 -iTCP:19101 -sTCP:LISTEN | tail -1' +edge.yaml_OK +49645 ./bin/edge --config edge.yaml serve +edge 49645 toki 6u IPv6 ... TCP *:18083 (LISTEN) +edge 49645 toki 12u IPv6 ... TCP *:19101 (LISTEN) + +$ ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:18083/healthz; curl -fsS http://127.0.0.1:18083/v1/models -H "Authorization: Bearer $(cat /tmp/iop-dev-smoke-apikey)" >/tmp/iop-dev-models-final.json && echo models_OK; curl -fsS http://127.0.0.1:19101/metrics | grep -c "iop_openai_reasoning_estimated_tokens_total"' +{"status":"ok"} +models_OK +4 # HELP+TYPE+series + reasoning_chars help 내 참조 1건 = metric 노출됨 + +$ ssh toki@toki-labs.com 'curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,estimation_method) (iop_openai_reasoning_estimated_tokens_total)"' +{"status":"success",...,"result":[{"metric":{"estimation_method":"chars_div_4","token_ref":"toki-dev-pi"},"value":[...,"10060"]}]} + +$ ssh toki@toki-labs.com 'curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,status) (iop_openai_requests_total)"' +{"status":"success",...,"result":[{"metric":{"status":"success","token_ref":"toki-dev-pi"},"value":[...,"10"]}]} + +$ git diff --check -- agent-task/openai_reasoning_estimated_usage +(no output — clean, no whitespace errors) +``` +Expected 전부 충족: predecessor PASS 존재, dev runner·Prometheus reachable, dev Edge에 새 metric 노출, single/concurrent smoke 성공, Prometheus에 request·estimated reasoning 증거, task artifact diff whitespace 오류 없음. 검증 종료 후 runner-local key-file(`/tmp/iop-dev-smoke-apikey`) 삭제. 토큰 원문/hash는 어떤 출력에도 미노출. + +--- + +> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?** +> If anything is blank, go back and fill it in before saving this file. +> Leave review-agent-only sections unchanged. + +## Section Ownership + +| Section | Owner | Note | +|---------|-------|------| +| Header comment, 개요, 리뷰 에이전트 지시 | Fixed at stub creation | Implementing agent must not modify or execute finalization | +| Archive Evidence Snapshot | Follow-up plan에서 복사 | 추가 확인이 필요할 때 명시된 archive 파일만 좁게 읽음 | +| 구현 항목별 완료 여부 | Implementing agent | Check only after runtime evidence exists | +| 구현 체크리스트 | Follow-up plan에서 복사 | 구현 에이전트가 `[ ]` -> `[x]` 체크만 수행 | +| 코드리뷰 전용 체크리스트 | Review agent only | Implementing agent must not modify | +| 계획 대비 변경 사항, 주요 설계 결정 | Implementing agent | Replace placeholders with actual notes | +| 사용자 리뷰 요청 | Implementing agent | Keep 없음 unless selected Milestone lock blocks implementation | +| 리뷰어를 위한 체크포인트 | Fixed at stub creation | Review focus | +| 검증 결과 | Implementing agent | Paste actual stdout/stderr with secrets masked | + +## 코드리뷰 결과 + +- 종합 판정: PASS + +### 차원별 평가 + +| 차원 | 평가 | 근거 | +|------|------|------| +| correctness | Pass | dev runner가 `origin/main` @ `9b7b4e0`로 clean sync되었고, rebuilt dev Edge가 `iop_openai_reasoning_estimated_tokens_total`를 direct metrics와 Prometheus에 노출한다. | +| completeness | Pass | REVIEW_API-1/2/3의 source sync, Edge rebuild/restart, single+8 concurrent smoke, Prometheus accounting evidence가 채워졌다. | +| test coverage | Pass | targeted package test와 live dev OpenAI-compatible smoke evidence가 있고, predecessor core tests는 archived complete.log로 확인된다. | +| API contract | Pass | metric name, `estimation_method="chars_div_4"`, provider-reported reasoning 우선 계약이 source/spec/docs와 runtime metrics에서 일치한다. | +| code quality | Pass | runtime source 변경은 없고, task/test-rule artifact diff에 whitespace 오류와 secret 원문이 없다. | +| implementation deviation | Pass | dev 기준 전환, pushed ref 배포, PID 한정 restart, bearer key-file 사용, provider snapshot 미노출 대체 증거가 각각 근거와 함께 기록되었다. | +| verification trust | Pass | 리뷰 중 local test, remote HEAD/Prometheus/direct metrics/status/key-file cleanup을 재확인했고 기록된 핵심 수치와 일치한다. | + +### 발견된 문제 + +없음. + +### 리뷰 중 추가 확인 + +```bash +$ GOCACHE=/tmp/iop-go-cache go test -count=1 ./apps/edge/internal/openai +ok iop/apps/edge/internal/openai 6.744s + +$ git diff --check -- agent-task/openai_reasoning_estimated_usage agent-test/README.md agent-test/dev/rules.md agent-test/dev-corp/rules.md +(no output) + +$ ssh -o BatchMode=yes -o ConnectTimeout=8 toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && git status --short --branch && git rev-parse HEAD && test ! -e /tmp/iop-dev-smoke-apikey && echo keyfile_absent && curl -fsS http://127.0.0.1:19111/-/ready' +## main...origin/main +9b7b4e044ff156f59d395c53975812eaf17081d7 +keyfile_absent +Prometheus Server is Ready. + +$ ssh -o BatchMode=yes -o ConnectTimeout=8 toki@toki-labs.com 'curl -fsS http://127.0.0.1:18083/healthz; curl -fsS http://127.0.0.1:19101/metrics | grep -E "^iop_openai_reasoning_(estimated_tokens_total|observed_total|chars_total)" | head -20' +{"status":"ok"} +iop_openai_reasoning_chars_total{...,token_ref="toki-dev-pi"} 40230 +iop_openai_reasoning_estimated_tokens_total{...,estimation_method="chars_div_4",token_ref="toki-dev-pi"} 10060 +iop_openai_reasoning_observed_total{...,token_ref="toki-dev-pi"} 9 + +$ ssh -o BatchMode=yes -o ConnectTimeout=8 toki@toki-labs.com 'curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,estimation_method) (iop_openai_reasoning_estimated_tokens_total)"; curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,status) (iop_openai_requests_total)"' +estimated result: token_ref="toki-dev-pi", estimation_method="chars_div_4", value="10060" +requests result: token_ref="toki-dev-pi", status="success", value="10" +``` + +추가로 Control Plane status와 Edge metrics를 확인했으며, 현재 dev status는 3개 node connected만 노출하고 provider `in_flight/queued` snapshot은 제공하지 않는다. 따라서 implementation의 대체 evidence 기록은 이 환경의 현재 관측 한계와 일치한다. + +`agent-test/README.md`, `agent-test/dev/rules.md`, `agent-test/dev-corp/rules.md`의 변경은 사용자 정정에 따른 dev 기본값/dev-corp 명시 전용 기준을 문서화한 범위 인접 정리로 확인했다. 필수 섹션 구조와 secret 원문 금지 기준을 해치지 않으며, 최종 complete.log에 변경 파일로 남긴다. + +### 다음 단계 + +PASS로 active review/plan을 `code_review_cloud_G07_1.log` / `plan_cloud_G07_1.log`로 아카이브하고, `complete.log` 작성 후 task directory를 `agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/`로 이동한다. `Roadmap Targets`가 없으므로 roadmap completion event는 없다. diff --git a/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/complete.log b/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/complete.log new file mode 100644 index 0000000..c965397 --- /dev/null +++ b/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/complete.log @@ -0,0 +1,42 @@ +# Complete - openai_reasoning_estimated_usage/02+01_dev_corp_rollout + +## 완료 일시 + +2026-07-14 + +## 요약 + +OpenAI-compatible estimated reasoning token metric을 dev-runtime Edge에 배포하고 dev Prometheus accounting smoke까지 plan 1 / review 1에서 PASS로 종결했다. + +## 루프 이력 + +| Plan | Review | Verdict | 메모 | +|------|--------|---------|------| +| `plan_cloud_G07_0.log` | `code_review_cloud_G07_0.log` | FAIL | loop 0은 잘못된 dev-corp 기준과 runner/Prometheus 도달 불가로 rollout evidence를 만들지 못해 실패했다. | +| `plan_cloud_G07_1.log` | `code_review_cloud_G07_1.log` | PASS | dev 기준으로 source sync, Edge rebuild/restart, single+8 concurrent smoke, Prometheus accounting evidence를 확인했다. | + +## 구현/정리 내용 + +- dev runner `/Users/toki/agent-work/iop-dev`를 `origin/main` @ `9b7b4e044ff156f59d395c53975812eaf17081d7`로 clean sync하고 `apps/edge/internal/openai` 테스트와 dev Edge rebuild를 수행했다. +- rebuilt `build/dev-runtime/bin/edge`로 dev Edge를 PID 한정 restart하고 `/healthz`, `/v1/models`, direct `/metrics`에서 estimated reasoning metric 노출을 확인했다. +- token 원문을 출력하지 않고 `ornith:35b` 단건 및 8 concurrent `/v1/chat/completions` smoke를 실행해 `iop_openai_reasoning_estimated_tokens_total{estimation_method="chars_div_4"}`와 request counter가 Prometheus에 계상됨을 확인했다. +- provider snapshot은 현재 dev Control Plane status와 Edge metrics에서 미노출이므로, 3개 node connected 유지, 8개 응답 성공, direct/Prometheus metric 증가를 대체 evidence로 남겼다. +- `agent-test/README.md`, `agent-test/dev/rules.md`, `agent-test/dev-corp/rules.md`에 dev 기본값과 dev-corp 명시 전용 기준을 정리해 후속 검증 라우팅이 dev-corp로 fallback하지 않도록 했다. + +## 최종 검증 + +- `GOCACHE=/tmp/iop-go-cache go test -count=1 ./apps/edge/internal/openai` - PASS; `ok iop/apps/edge/internal/openai 6.744s` +- `git diff --check -- agent-task/openai_reasoning_estimated_usage agent-test/README.md agent-test/dev/rules.md agent-test/dev-corp/rules.md` - PASS; no output +- `ssh -o BatchMode=yes -o ConnectTimeout=8 toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && git status --short --branch && git rev-parse HEAD && test ! -e /tmp/iop-dev-smoke-apikey && echo keyfile_absent && curl -fsS http://127.0.0.1:19111/-/ready'` - PASS; remote HEAD `9b7b4e044ff156f59d395c53975812eaf17081d7`, key-file absent, Prometheus ready +- `ssh -o BatchMode=yes -o ConnectTimeout=8 toki@toki-labs.com 'curl -fsS http://127.0.0.1:18083/healthz; curl -fsS http://127.0.0.1:19101/metrics | grep -E "^iop_openai_reasoning_(estimated_tokens_total|observed_total|chars_total)" | head -20'` - PASS; health ok, estimated tokens `10060`, observed requests `9` +- `ssh -o BatchMode=yes -o ConnectTimeout=8 toki@toki-labs.com 'curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,estimation_method) (iop_openai_reasoning_estimated_tokens_total)"; curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,status) (iop_openai_requests_total)"'` - PASS; estimated result `token_ref="toki-dev-pi", estimation_method="chars_div_4", value="10060"`, requests result `token_ref="toki-dev-pi", status="success", value="10"` +- `ssh -o BatchMode=yes -o ConnectTimeout=8 toki@toki-labs.com 'curl -fsS http://127.0.0.1:18001/edges/edge-toki-labs-dev/status'` - PASS; `mac-codex-node`, `gx10-vllm-node`, `onexplayer-lemonade-node` connected, provider snapshot fields not exposed +- `rg -n "Authorization: Bearer [A-Za-z0-9._~-]{20,}|sk-[A-Za-z0-9]" agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout agent-test/README.md agent-test/dev/rules.md agent-test/dev-corp/rules.md` - PASS; no raw bearer/API token literal found + +## 잔여 Nit + +- 없음 + +## 후속 작업 + +- 없음 diff --git a/agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/PLAN-cloud-G07.md b/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/plan_cloud_G07_0.log similarity index 100% rename from agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/PLAN-cloud-G07.md rename to agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/plan_cloud_G07_0.log diff --git a/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/plan_cloud_G07_1.log b/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/plan_cloud_G07_1.log new file mode 100644 index 0000000..8ee8603 --- /dev/null +++ b/agent-task/archive/2026/07/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/plan_cloud_G07_1.log @@ -0,0 +1,171 @@ + + +# Plan - REVIEW_API + +## 이 파일을 읽는 구현 에이전트에게 + +이 follow-up의 현재 테스트 기준은 `dev` 환경이다. active task directory 이름은 이전 라우팅 이름을 유지하지만, 검증 대상은 `agent-test/dev/**`와 `agent-ops/skills/project/dev-runtime-deploy/SKILL.md`의 dev-runtime 기준이다. `iop.ai.kr`, `digitalplatform.iop.ai.kr`, `fe@172.24.63.178`, dev-corp 포트 `18086/18087/19112`에는 접근하지 않는다. + +사용자에게 직접 묻지 말고, dev runner나 dev runtime이 닫혀 있으면 실제 명령과 출력으로 blocker를 기록한 뒤 active `CODE_REVIEW-cloud-G07.md`를 채워 review ready로 멈춘다. token/secret 원문은 stdout/stderr, docs, task artifact에 남기지 않는다. + +## 배경 + +core predecessor는 estimated reasoning token metric을 source/test/docs/spec에 반영하고 PASS로 archive되었다. loop 0은 잘못된 환경 기준으로 작성되었으므로, 현재 follow-up은 dev-runtime Edge에 새 metric을 배포하고 dev Prometheus/Grafana 관측 기준에서 OpenAI-compatible usage accounting을 확인한다. + +## Archive Evidence Snapshot + +- archived loop: + - plan: `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/plan_cloud_G07_0.log` + - review: `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/code_review_cloud_G07_0.log` + - verdict: FAIL +- Superseded context: + - loop 0의 환경/host 기준은 현재 사용자 정정으로 폐기한다. + - archive의 public-host/runner 명령은 재사용하지 않는다. +- Current dev criteria: + - environment docs: `agent-test/dev/inventory.yaml`, `agent-test/dev/rules.md`, `agent-test/dev/edge-smoke.md`, `agent-test/dev/platform-common-smoke.md` + - deploy skill: `agent-ops/skills/project/dev-runtime-deploy/SKILL.md` + - runner: `ssh toki@toki-labs.com` + - runner repo root: `/Users/toki/agent-work/iop-dev` + - Edge config: `build/dev-runtime/edge.yaml` + - Edge binary: `build/dev-runtime/bin/edge` + - Edge id: `edge-toki-labs-dev` + - OpenAI-compatible base URL: runner-local `http://127.0.0.1:18083/v1`, public dev `http://toki-labs.com:18083/v1` + - Edge metrics: `127.0.0.1:19101` + - Prometheus: `127.0.0.1:19111` + - model alias: `ornith:35b` +- Required summary: + - R1: dev runner checkout must be synced to the source state that contains `iop_openai_reasoning_estimated_tokens_total`, then `go test` and dev Edge rebuild must run on the dev runner. + - R2: dev-runtime Edge must be restarted from the rebuilt binary and direct dev metrics must expose `iop_openai_reasoning_estimated_tokens_total`. + - R3: dev OpenAI-compatible smoke and Prometheus queries must show request/accounting evidence without leaking token values. +- Verification evidence from local review: + - `GOCACHE=/tmp/iop-go-cache go test ./apps/edge/internal/openai` passed locally. + - `git diff --check -- agent-task/openai_reasoning_estimated_usage` passed with no output. +- Narrow archive reread allowed if needed: + - `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/plan_cloud_G07_0.log` + - `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/code_review_cloud_G07_0.log` + - `agent-task/archive/2026/07/openai_reasoning_estimated_usage/01_metric_core/complete.log` +- Roadmap carryover: 없음. 이 task는 non-roadmap rollout task이며 `Roadmap Targets`가 없다. + +## 사용자 리뷰 요청 흐름 + +구현 중 직접 사용자에게 묻지 않는다. 이 task는 non-roadmap rollout task이므로 runner, secret, host readiness, Prometheus 접근 문제는 사용자 리뷰가 아니라 검증 blocker 또는 follow-up evidence로 기록한다. 선택된 Milestone lock 결정이 아닌 blocker로 `USER_REVIEW.md`를 만들지 않는다. + +## 구현 체크리스트 + +- [ ] predecessor PASS를 `agent-task/archive/2026/07/openai_reasoning_estimated_usage/01_metric_core/complete.log`로 재확인한다. +- [ ] dev 기준 문서(`agent-test/dev/inventory.yaml`, `agent-test/dev/rules.md`, `agent-test/dev/edge-smoke.md`)의 runner/path/port/model 값을 사용하고, 폐기된 환경 host/port에 접근하지 않는다. +- [ ] dev runner, Prometheus, Edge process/ports, current direct metric exposure preflight를 실행하고 실제 stdout/stderr를 기록한다. +- [ ] dev runner가 reachable이면 `/Users/toki/agent-work/iop-dev` checkout을 배포 기준 source state로 clean sync하고 `GOCACHE=/tmp/iop-go-cache go test -count=1 ./apps/edge/internal/openai`와 dev Edge rebuild를 실행한다. +- [ ] rebuilt `build/dev-runtime/bin/edge`로 dev-runtime Edge를 restart한 뒤 `/healthz`, `/v1/models`, `/metrics`에서 새 metric 노출을 확인한다. +- [ ] token 원문을 출력하지 않고 dev `ornith:35b` OpenAI-compatible smoke를 실행한 뒤 Prometheus에서 estimated reasoning metric과 request counter를 확인한다. +- [ ] 8개(capacity 7 + 1) concurrent `/v1/chat/completions` smoke를 실행하고 request success count, estimated reasoning metric, provider `in_flight/queued` 관측과 완료 후 회복을 기록한다. +- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다. + +### [REVIEW_API-1] dev runner source sync and Edge rebuild + +#### 문제 + +dev-runtime Edge binary가 새 estimated reasoning metric source state로 rebuild되지 않으면 dev Prometheus에서 metric/accounting을 확인할 수 없다. + +#### 해결 방법 + +dev runner와 Prometheus readiness를 확인한다. runner가 열려 있으면 source 기준 ref를 확정해 clean sync하고 targeted package test와 Edge build를 실행한다. runner가 닫혀 있으면 deploy/smoke를 진행하지 말고 blocker evidence를 남긴다. + +```bash +test -f agent-task/archive/2026/07/openai_reasoning_estimated_usage/01_metric_core/complete.log +ssh -o BatchMode=yes -o ConnectTimeout=8 toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && git status --short --branch && git rev-parse HEAD && (/opt/homebrew/bin/go version || go version)' +ssh -o BatchMode=yes -o ConnectTimeout=8 toki@toki-labs.com 'curl -fsS http://127.0.0.1:19111/-/ready' +ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && git fetch origin main && git reset --hard origin/main && git clean -fd' +rsync -a --delete --exclude .git --exclude build/dev-runtime --exclude agent-task/archive ./ toki@toki-labs.com:/Users/toki/agent-work/iop-dev/ +ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && GOCACHE=/tmp/iop-go-cache go test -count=1 ./apps/edge/internal/openai && GOCACHE=/tmp/iop-go-cache go build -trimpath -o build/dev-runtime/bin/edge ./apps/edge/cmd/edge' +``` + +If the deploy source is a pushed ref instead of local rsync, record the exact ref and omit the rsync step. Do not deploy from a dirty or stale runner checkout. + +#### 중간 검증 + +```bash +ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && test -x build/dev-runtime/bin/edge && build/dev-runtime/bin/edge --help >/tmp/iop-dev-edge-help.out && wc -c /tmp/iop-dev-edge-help.out' +``` + +Expected: rebuilt Edge binary exists and runs. + +### [REVIEW_API-2] dev-runtime Edge restart and metric exposure + +#### 문제 + +Source test success alone does not prove the running dev Edge exposes the new metric. + +#### 해결 방법 + +Use the rebuilt dev binary and `build/dev-runtime/edge.yaml`. Restart the dev-runtime Edge according to the current process manager, then verify ports and direct metrics. If the actual process manager differs from the command below, record the real command and `pgrep -af` evidence. + +```bash +ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && test -f build/dev-runtime/edge.yaml && pgrep -af "build/dev-runtime/bin/edge.*serve|edge.*serve" || true && lsof -nP -iTCP:18083 -sTCP:LISTEN || true && lsof -nP -iTCP:19101 -sTCP:LISTEN || true' +ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && pkill -f "build/dev-runtime/bin/edge.*serve|edge.*serve" || true; nohup build/dev-runtime/bin/edge serve --config build/dev-runtime/edge.yaml > build/dev-runtime/logs/edge-rollout-$(date +%Y%m%d%H%M%S).log 2>&1 &' +ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:18083/healthz && curl -fsS http://127.0.0.1:18083/v1/models >/tmp/iop-dev-models-after-rollout.json && curl -fsS http://127.0.0.1:19101/metrics | grep -F "iop_openai_reasoning_estimated_tokens_total"' +``` + +#### 중간 검증 + +```bash +ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:19101/metrics | grep -F "iop_openai_reasoning_estimated_tokens_total"' +``` + +Expected: metric family appears in direct dev Edge metrics. + +### [REVIEW_API-3] dev OpenAI-compatible smoke and Prometheus accounting + +#### 문제 + +Metric family exposure alone does not prove request accounting. dev 기준에서는 OpenAI-compatible route와 Prometheus `19111`에서 request/estimated metric evidence를 확인해야 한다. + +#### 해결 방법 + +Use `OPENAI_API_KEY` or `--api-key-file` only from the dev runner environment; never print the value. Run `iop-edge smoke openai` for `/healthz`, `/v1/models`, `/v1/responses`, then run Chat Completions single/concurrent smoke. Query direct metrics and Prometheus after scrape. Capacity smoke should use 8 concurrent requests because the current Ornith provider capacity is `7`. + +```bash +ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && OPENAI_API_KEY="${OPENAI_API_KEY:-}" build/dev-runtime/bin/edge smoke openai --model ornith:35b --base-url http://127.0.0.1:18083 --prompt "2+2? Answer only the number." --timeout 60s' +ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && : "${OPENAI_API_KEY:?OPENAI_API_KEY must be set in the remote environment}"; curl -fsS http://127.0.0.1:18083/v1/chat/completions -H "Authorization: Bearer ${OPENAI_API_KEY}" -H "Content-Type: application/json" -d "{\"model\":\"ornith:35b\",\"messages\":[{\"role\":\"user\",\"content\":\"짧게 생각 과정을 내부적으로 사용해서 2+2 답만 말해.\"}],\"max_tokens\":512,\"include_reasoning\":true}" >/tmp/iop-dev-reasoning-single.json' +ssh toki@toki-labs.com 'rm -f /tmp/iop-dev-reasoning-concurrent-*.json; : "${OPENAI_API_KEY:?OPENAI_API_KEY must be set in the remote environment}"; seq 1 8 | xargs -P8 -I{} sh -c '"'"'curl -fsS http://127.0.0.1:18083/v1/chat/completions -H "Authorization: Bearer '"'"'"${OPENAI_API_KEY}"'"'"'" -H "Content-Type: application/json" -d "{\"model\":\"ornith:35b\",\"messages\":[{\"role\":\"user\",\"content\":\"요청 {}: 700 토큰 안팎의 구조화된 답변을 작성해.\"}],\"max_tokens\":1200,\"include_reasoning\":true}" > /tmp/iop-dev-reasoning-concurrent-{}.json'"'"'' +ssh toki@toki-labs.com 'test "$(ls /tmp/iop-dev-reasoning-concurrent-*.json | wc -l | tr -d " ")" -ge 8' +ssh toki@toki-labs.com 'curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,status) (iop_openai_requests_total)"' +ssh toki@toki-labs.com 'curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,estimation_method) (iop_openai_reasoning_estimated_tokens_total)"' +``` + +Also capture provider capacity snapshots from the dev Control Plane status if available: + +```bash +ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:18001/edges/edge-toki-labs-dev/status >/tmp/iop-dev-edge-status-after-smoke.json' +``` + +#### 중간 검증 + +```bash +ssh toki@toki-labs.com 'test "$(ls /tmp/iop-dev-reasoning-concurrent-*.json | wc -l | tr -d " ")" -ge 8' +``` + +Expected: at least 8 response files exist and all curl commands succeeded; provider capacity evidence shows total in-flight/queue behavior during the run when status polling is available. + +## 수정 파일 요약 + +| 파일 | 항목 | +|------|------| +| none | REVIEW_API-1, REVIEW_API-2, REVIEW_API-3 | + +## 최종 검증 + +```bash +test -f agent-task/archive/2026/07/openai_reasoning_estimated_usage/01_metric_core/complete.log +ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && git status --short --branch && git rev-parse HEAD && (/opt/homebrew/bin/go version || go version)' +ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:19111/-/ready' +ssh toki@toki-labs.com 'cd /Users/toki/agent-work/iop-dev && test -f build/dev-runtime/edge.yaml && pgrep -af "build/dev-runtime/bin/edge.*serve|edge.*serve" && lsof -nP -iTCP:18083 -sTCP:LISTEN && lsof -nP -iTCP:19101 -sTCP:LISTEN' +ssh toki@toki-labs.com 'curl -fsS http://127.0.0.1:18083/healthz && curl -fsS http://127.0.0.1:18083/v1/models >/tmp/iop-dev-models-final.json && curl -fsS http://127.0.0.1:19101/metrics | grep -F "iop_openai_reasoning_estimated_tokens_total"' +ssh toki@toki-labs.com 'curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,estimation_method) (iop_openai_reasoning_estimated_tokens_total)"' +ssh toki@toki-labs.com 'curl -fsG http://127.0.0.1:19111/api/v1/query --data-urlencode "query=sum by (token_ref,status) (iop_openai_requests_total)"' +git diff --check -- agent-task/openai_reasoning_estimated_usage +``` + +Expected: predecessor PASS evidence exists, dev runner and Prometheus are reachable, dev Edge exposes the new metric, single/concurrent smoke succeeds, Prometheus shows request and estimated reasoning evidence, and task artifact diff has no whitespace errors. + +모든 작업 후 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채운다. 이 파일 작성이 구현의 마지막 단계다. diff --git a/agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/CODE_REVIEW-cloud-G07.md b/agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/CODE_REVIEW-cloud-G07.md deleted file mode 100644 index 2fe5174..0000000 --- a/agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/CODE_REVIEW-cloud-G07.md +++ /dev/null @@ -1,162 +0,0 @@ - - -# Code Review Reference - API - -> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.** -> The task is NOT complete until every implementation-owned section below is filled in. -> Complete the `구현 체크리스트`; the final checklist item is mandatory before saving. -> Fill implementation-owned sections, then stop with active files in place and report ready for review. -> If implementation is blocked by a selected Milestone `구현 잠금 > 결정 필요` item, fill `사용자 리뷰 요청` with linked evidence and stop with active files in place; code-review decides whether to write `USER_REVIEW.md`. Environment/secret/service blockers, generic scope changes, repeated failures, and evidence gaps that a follow-up agent can close are normal follow-up issues, not user-review blockers by themselves. -> Do not ask the user directly, present choices in chat, or call `request_user_input` during implementation; record only Milestone lock decisions in `사용자 리뷰 요청` and stop for code-review. -> Finalization (`코드리뷰 결과`, log rename, `complete.log`, archive moves, `코드리뷰 전용 체크리스트`) is review-agent-only, even after compaction/resume. -> Follow the ownership table at the bottom of this file for which sections you own. - -## 개요 - -date=2026-07-14 -task=openai_reasoning_estimated_usage/02+01_dev_corp_rollout, plan=0, tag=API - -## 이 파일을 읽는 리뷰 에이전트에게 - -> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다. - -각 항목의 구현을 실제 runtime evidence와 대조하고, `검증 결과` 섹션의 출력이 plan의 expected outcome과 일치하는지 확인하세요. -리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다. - -1. 판정을 append한다. -2. `CODE_REVIEW-cloud-G07.md` → `code_review_cloud_G07_0.log`, `PLAN-cloud-G07.md` → `plan_cloud_G07_0.log`로 아카이브한다. -3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/`로 이동한다. WARN/FAIL이면 user-review gate를 확인한 뒤 다음 active plan/review 파일 또는 `USER_REVIEW.md`를 작성한다. -4. 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 최종 `.log` 위치에서 체크한 뒤 보고한다. - ---- - -## 구현 항목별 완료 여부 - -| 항목 | 완료 여부 | -|------|---------| -| [API-1] dev-corp Edge binary rebuild and rollout | [ ] | -| [API-2] single-call reasoning estimated metric smoke | [ ] | -| [API-3] concurrent smoke and Prometheus accounting | [ ] | - -## 구현 체크리스트 - -- [ ] `openai_reasoning_estimated_usage/01_metric_core/complete.log` 존재를 확인하고 없으면 배포하지 않는다. -- [ ] dev-corp runner, public Edge, Prometheus, ports, binary/config path preflight를 실행하고 blocker를 기록한다. -- [ ] 구현 완료 source state를 mac-mini runner에 sync하고 `iop-edge` Linux ARM64 binary를 rebuild한다. -- [ ] public Edge host에 새 binary를 배포하고 Edge process를 restart한 뒤 `/healthz`, `/v1/models`, `/metrics`를 확인한다. -- [ ] smoke token으로 `ornith:35b` single-call을 실행하고 Prometheus에서 estimated reasoning metric 증가를 확인한다. -- [ ] 같은 token으로 6개 이상 concurrent `/v1/chat/completions`를 실행하고 request/estimated metric 증가를 확인한다. -- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다. - -## 코드리뷰 전용 체크리스트 - -> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다. -> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다. - -- [ ] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다. -- [ ] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다. -- [ ] active `CODE_REVIEW-*-G??.md`를 `code_review_cloud_G07_0.log`로 아카이브한다. -- [ ] active `PLAN-*-G??.md`를 `plan_cloud_G07_0.log`로 아카이브한다. -- [ ] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다. -- [ ] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다. -- [ ] PASS이면 active task 디렉터리 `agent-task/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/`를 `agent-task/archive/YYYY/MM/openai_reasoning_estimated_usage/02+01_dev_corp_rollout/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다. -- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/openai_reasoning_estimated_usage/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다. -- [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-cloud-G07.md`와 `CODE_REVIEW-cloud-G07.md`를 작성하고 `complete.log`를 작성하지 않는다. -- [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다. - -## 계획 대비 변경 사항 - -_구현 에이전트가 계획과 다르게 구현한 부분을 이유와 함께 기록한다._ - -## 주요 설계 결정 - -_구현 에이전트가 주요 설계 결정 사항을 기록한다._ - -## 사용자 리뷰 요청 - -_기본값은 `없음`이다. 구현 중 새 결정이 필요해 보여도 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 이 섹션은 선택된 Milestone `구현 잠금 > 결정 필요` 항목이 실구현을 차단할 때만 채운다. 외부 환경/secret/서비스 준비, 검증 증거 공백, 반복 실패, 일반 범위 조정은 사용자 리뷰 요청이 아니며 `검증 결과`, `계획 대비 변경 사항`, 또는 code-review의 일반 follow-up plan으로 처리한다._ - -- 상태: 없음 -- 사유 유형: 없음 -- 연결 대상: 없음 -- 결정 필요: 없음 -- 차단 근거: 없음 -- 실행한 검증/명령: 없음 -- 자동 후속 불가 이유: 없음 -- 재개 조건: 없음 - -## 리뷰어를 위한 체크포인트 - -- predecessor `01_metric_core/complete.log` 없이 배포가 진행되지 않았는지 확인한다. -- public Edge에 새 metric이 실제 `/metrics`로 노출되는지 확인한다. -- smoke token 원문이 review output에 남지 않았는지 확인한다. -- single-call과 6개 이상 concurrent call 모두 Prometheus evidence로 연결되는지 확인한다. -- provider-reported `reasoning` counter와 estimated counter를 혼동하지 않았는지 확인한다. - -## 검증 결과 - -_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._ - -필수 규칙: -- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다. -- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다. -- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다. -- token/secret 원문은 붙여 넣지 않는다. - -### API-1 중간 검증 -```bash -$ ssh toki@iop.ai.kr 'curl -fsS http://127.0.0.1:18086/healthz && curl -fsS http://127.0.0.1:19105/metrics | grep -F "iop_openai_reasoning_estimated_tokens_total"' -(output) -``` - -### API-2 중간 검증 -```bash -$ ssh fe@172.24.63.178 'curl -fsG http://127.0.0.1:19112/api/v1/query --data-urlencode "query=sum by (token_ref,estimation_method) (iop_openai_reasoning_estimated_tokens_total{token_ref=\"devcorp-smoke-usage\"})"' -(output) -``` - -### API-3 중간 검증 -```bash -$ test "$(ls /tmp/devcorp-reasoning-concurrent-*.json | wc -l | tr -d ' ')" -ge 6 -(output) -``` - -### 최종 검증 -```bash -$ test -f agent-task/openai_reasoning_estimated_usage/01_metric_core/complete.log -(output) - -$ ssh fe@172.24.63.178 'cd /Users/fe/agent-work/iop-dev-corp && git status --short --branch && git rev-parse HEAD && (/opt/homebrew/bin/go version || go version)' -(output) - -$ ssh fe@172.24.63.178 'curl -fsS http://127.0.0.1:19112/-/ready' -(output) - -$ ssh toki@iop.ai.kr 'cd /Users/toki/agent-work/iop-dev-corp && test -f build/dev-corp-runtime/edge.yaml && pgrep -af "iop-edge.*serve" && lsof -nP -iTCP:18086 -sTCP:LISTEN && lsof -nP -iTCP:19105 -sTCP:LISTEN' -(output) - -$ ssh fe@172.24.63.178 'curl -fsG http://127.0.0.1:19112/api/v1/query --data-urlencode "query=sum by (token_ref,status) (iop_openai_requests_total{token_ref=\"devcorp-smoke-usage\"})"' -(output) - -$ git diff --check -- agent-task/openai_reasoning_estimated_usage -(output) -``` - ---- - -> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?** -> If anything is blank, go back and fill it in before saving this file. -> Leave review-agent-only sections unchanged. - -## Section Ownership - -| Section | Owner | Note | -|---------|-------|------| -| Header comment, 개요, 리뷰 에이전트 지시 | Fixed at stub creation | Implementing agent must not modify or execute finalization | -| 구현 항목별 완료 여부 | Implementing agent | Check only after runtime evidence exists | -| 구현 체크리스트 | Implementing agent | Check only; do not change item text | -| 코드리뷰 전용 체크리스트 | Review agent only | Implementing agent must not modify | -| 계획 대비 변경 사항, 주요 설계 결정 | Implementing agent | Replace placeholders with actual notes | -| 사용자 리뷰 요청 | Implementing agent | Keep 없음 unless selected Milestone lock blocks implementation | -| 리뷰어를 위한 체크포인트 | Fixed at stub creation | Review focus | -| 검증 결과 | Implementing agent | Paste actual stdout/stderr with secrets masked | diff --git a/agent-test/README.md b/agent-test/README.md index af81624..063282c 100644 --- a/agent-test/README.md +++ b/agent-test/README.md @@ -3,6 +3,12 @@ 이 디렉터리는 테스트 환경별 실행 기준과 도메인/검증 시나리오별 profile을 둔다. 새 환경(`qa`, `staging`, `dev-gpu`, `dev-team-a` 등)을 추가할 때는 기존 환경을 임의로 복사하지 말고 이 기준과 `_templates/`를 먼저 따른다. +## 환경 선택 기본값 + +- 사용자가 테스트 환경을 별도로 지정하지 않으면 기본 테스트/검증 환경은 `dev`다. +- `dev-corp`는 fallback, 자동 탐색 경로, 접근 가능한 대체 runtime이 아니다. 사용자가 `dev-corp`, 회사망 dev-corp, public `iop.ai.kr` Edge, 또는 동등하게 명시한 경우에만 `agent-test/dev-corp/**`를 읽고 접근한다. +- 사용자가 단순히 `dev`, 테스트 환경, 배포, rollout, runtime 검증이라고 말한 경우에는 `agent-test/dev/**` 기준을 사용하고 `dev-corp` host, runner, port에는 접근하지 않는다. + ## 환경 디렉터리 - 환경 디렉터리는 `agent-test//` 형식을 사용한다. diff --git a/agent-test/dev-corp/rules.md b/agent-test/dev-corp/rules.md index 6be2e8c..e2b1324 100644 --- a/agent-test/dev-corp/rules.md +++ b/agent-test/dev-corp/rules.md @@ -10,6 +10,8 @@ last_rule_updated_at: 2026-07-14 ## 공통 규칙 +- dev-corp는 명시 요청 전용 테스트 환경이다. 사용자가 `dev-corp`, 회사망 dev-corp, public `iop.ai.kr` Edge, 또는 동등한 표현으로 이 환경을 지정하지 않은 경우 이 문서를 기본 테스트/검증 기준으로 사용하지 않는다. +- 일반 `dev`, 테스트 환경, 배포, rollout, runtime 검증 요청에서 dev-corp로 fallback하거나 접근 가능한 대체 경로로 탐색하지 않는다. 해당 경우에는 `agent-test/dev/**`를 기준으로 한다. - dev-corp 테스트/검증은 이 파일을 기준으로 판단한다. - 작업 완료 검증은 변경 범위 기준으로 선택한다. - 필수 검증을 실행하지 못하면 차단 사유로 보고한다. diff --git a/agent-test/dev/rules.md b/agent-test/dev/rules.md index 1ca577a..7433386 100644 --- a/agent-test/dev/rules.md +++ b/agent-test/dev/rules.md @@ -1,6 +1,6 @@ --- test_env: dev -last_rule_updated_at: 2026-06-24 +last_rule_updated_at: 2026-07-14 --- # dev 테스트 규칙 @@ -11,6 +11,8 @@ last_rule_updated_at: 2026-06-24 ## 공통 규칙 - dev 테스트/검증은 이 파일을 기준으로 판단한다. +- 사용자가 테스트 환경을 별도로 지정하지 않거나 단순히 `dev`, 테스트 환경, 배포, rollout, runtime 검증이라고 말하면 이 `dev` 환경을 기본 기준으로 삼는다. +- `dev-corp`는 `dev`의 fallback이나 자동 접근 경로가 아니다. 사용자가 `dev-corp` 또는 동등한 회사망/public dev-corp 환경을 명시하지 않은 경우 `agent-test/dev-corp/**`, `iop.ai.kr`, `fe@172.24.63.178`, dev-corp port로 접근하지 않는다. - 작업 완료 검증은 변경 범위 기준으로 선택한다. - 필수 검증을 실행하지 못하면 차단 사유로 보고한다. - 새 테스트 환경을 추가하거나 환경 구조를 바꿀 때는 `agent-test/README.md`와 `agent-test/_templates/`의 확장 기준을 따른다.