Files
selfheal-lab-apps/ai
seon 13797e5741 feat(ai): redesign the Jev triage state and add JEV_MODE=enforce review rules
第 2 回キャンペーンの突き合わせ結果を反映した。triage の state にコードで計算した
最新値の要約(now: プローブ、1 分 p95、1 分エラー率、再起動数、slo_now_ok)と
直近 5 分のエラーログ抜粋を加え、recovering は slo_now_ok を読むだけにした。
layer の choice を irreversible_needed の noul に置き換え、target_valid は
カタログ action のときだけ尋ねる。JEV_MODE=enforce では review の 2 ルール
(best_action 不一致かつ確信度 0.9 以上、target_valid 0.5 未満)で提案を
escalate に格下げし、判断を res.jev.enforced に記録する。既定は shadow のまま。
2026-10-08 17:45:28 +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).