정적 API 키 대신 Workload Identity Federation을 쓴다. 에이전트는 AI VM의 Google 서명 ID 토큰(메타데이터 서버, audience https://api.anthropic.com, format=full)을 POST /v1/oauth/token(jwt-bearer)으로 교환해 단기 access token을 받고 Authorization: Bearer로 호출한다. 토큰은 캐시하고 만료 120초 전에 재교환하며, 401이면 한 번 재교환한다. 규칙·조직·서비스 계정·워크스페이스 ID 4개는 비밀이 아니므로 ai.env 환경 변수로 받고, 비어 있으면 기존 키 파일 경로로 동작한다. /selfcheck가 auth 모드와 실제 교환 결과를 보고해 캠페인 없이 설정을 검증할 수 있다. 테스트: 교환 1회 재사용·401 재교환·만료 전 갱신·거부 응답·불완전 ID 무시.
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).