Files
selfheal-lab-apps/ai
seon b0ff118841 fix(ai): external responder on its own listener with random turn ids and reply tokens
보안 리뷰 반영. 외부 응답은 곧 진단이고 자동 승인 아래서는 실행 조치가 되므로,
/external/next·/external/reply 를 에이전트 포트에서 떼어 EXTERNAL_ADDR 리스너(기본 꺼짐,
VM compose 는 127.0.0.1:8090 에만 매핑해 IAP SSH 터널로만 도달)로 옮기고, 턴 id 를 난수로
만들며, 응답마다 그 턴을 가져간 클라이언트만 아는 reply_token 을 요구해 상수 시간으로
비교한다. /selfcheck 는 리스너가 꺼져 있으면 external_responder: "off" 를 보인다.
2026-10-16 09:09:22 +09:00
..

ai

AI VM services of the self-healing lab (experiment design 6). Module github.com/selfheal-lab/selfheal-lab-apps/ai.

command role port
cmd/agent POST /diagnose: Responses API tool loop over the read-only tools (internal/tools, design 6.2), strict submit_diagnosis (design 6.3, internal/diag), sessions and prompt versions in pgvector (internal/rag), then proposal + HITL post or escalation (design 6.5/6.6, internal/agent) 8080
cmd/hitl Discord gateway bot (internal/hitl): Approve/Reject buttons, harness approval + execution, expiry to the escalation channel, escalation threads with the runbook 8081

Contracts: harness POST /diagnose {"alert","run_id","scenario_id"} -> diagnosis fields at top level plus session_id, model, prompt_version, disposition. Harness side: POST /proposals (registers the proposal at diagnosis time, returns the approval token), POST /proposals/{token}/approve, POST /proposals/{token}/reject, POST /actions/execute.

OpenAI: POST /v1/responses with function tools (strict: true, every property required, additionalProperties: false), previous_response_id chaining, function_call_output items; embeddings text-embedding-3-small (1536). Model id from OPENAI_MODEL.

Build: gcloud builds submit ai --project cms-d-414903 --config ai/cloudbuild.yaml --substitutions=_TAG=$(git rev-parse --short HEAD). Tests: cd ai && go test ./... (mock Responses API and Mimir; no network).