# 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

- 없음

## 후속 작업

- 없음
