121 lines
7.1 KiB
Markdown
121 lines
7.1 KiB
Markdown
---
|
|
spec_doc_type: spec
|
|
spec_id: runtime/provider-pool-config-refresh
|
|
status: 부분
|
|
source_evidence:
|
|
- type: contract
|
|
path: agent-contract/inner/edge-config-runtime-refresh.md
|
|
notes: Edge config, provider pool, config refresh, Node payload 연결 계약
|
|
- type: code
|
|
path: packages/go/config/config.go
|
|
notes: Edge config struct, provider/model validation, adapter normalization
|
|
- type: code
|
|
path: configs/edge.yaml
|
|
notes: provider-pool 권장 설정 예시와 live refresh 설정 예시
|
|
- type: code
|
|
path: apps/edge/internal/service/model_queue.go
|
|
notes: provider/resource capacity, priority, queue, long-context slot admission
|
|
- type: code
|
|
path: apps/edge/internal/configrefresh/classify.go
|
|
notes: dry-run/apply classification과 changed path report 생성
|
|
- type: code
|
|
path: apps/edge/internal/bootstrap/runtime.go
|
|
notes: mutable config apply, runtime snapshot 교체, Node refresh push
|
|
- type: test
|
|
path: packages/go/config/config_test.go
|
|
notes: config load/validation 검증
|
|
- type: test
|
|
path: apps/edge/internal/configrefresh/classify_test.go
|
|
notes: refresh classification 검증
|
|
---
|
|
|
|
# 스펙: Provider Pool과 Config Refresh
|
|
|
|
## 목적
|
|
|
|
Edge 설정에서 provider-pool이 어떻게 모델 실행 후보를 고르고, 어떤 설정 변경이 재시작 없이 반영되는지 설명한다.
|
|
|
|
## 기능 목록
|
|
|
|
| 기능 | 설명 |
|
|
|------|------|
|
|
| model catalog | `models[].id`는 외부 OpenAI-compatible `model` key이자 provider-pool `ModelGroupKey`다. |
|
|
| provider mapping | `models[].providers`는 provider id를 실제 served model name으로 매핑한다. |
|
|
| node provider catalog | `nodes[].providers[]`는 Node 아래 resource/provider catalog이며 provider id는 Edge config에서 전역 유일해야 한다. |
|
|
| config validation | config load가 provider id 참조, served model membership, numeric bounds, long-context budget을 검증한다. |
|
|
| provider 후보 필터링 | dispatch는 connected node의 provider 후보 중 catalog match, enabled, healthy/available, capacity 조건을 만족하는 후보만 사용한다. |
|
|
| capacity/priority dispatch | in-flight가 capacity 미만인 후보를 고르고, 동률이면 낮은 `priority`와 round-robin을 적용한다. |
|
|
| long-context admission | estimated input token이 threshold 이상이면 `context_class=long`으로 분류하고, provider long slot이 있으면 일반 capacity slot과 함께 점유한다. |
|
|
| config refresh dry-run/apply | loopback admin HTTP `POST /refresh`가 candidate config를 dry-run 또는 apply한다. |
|
|
| refresh classification | listener, Edge identity, bootstrap path, adapter structural 변경 등은 restart-required로 분류한다. |
|
|
| mutable apply | 적용 가능한 변경은 Edge `Cfg`, `NodeStore`, service/input model catalog, OpenAI long-context threshold를 copy-on-write로 교체한다. |
|
|
| Node config refresh push | 변경이 있으면 Edge가 연결된 Node에 node-specific `NodeConfigRefreshRequest`를 push한다. |
|
|
| Node registry swap | Node는 refresh payload로 새 adapter registry를 만들고 router registry를 swap한다. old registry stop은 active run이 있으면 drain 이후로 지연한다. |
|
|
| principal token mapping config | `openai.principal_tokens[]`는 raw token 없이 `token_ref`, `token_hash_sha256`, `principal_ref`, optional alias를 관리하고 OpenAI usage metering의 principal/token label 후보를 제공한다. 같은 principal에 여러 token entry를 둘 수 있다. |
|
|
|
|
## 범위
|
|
|
|
- 포함: Edge config load/default/validation, provider-pool dispatch, queue admission, long-context admission, config refresh classification/apply, Node config refresh payload.
|
|
- 제외: 개별 adapter의 provider API 호출 세부, OpenAI HTTP request/response shape, Control Plane 원격 config 변경 UX, private credential 관리.
|
|
|
|
## 주요 흐름
|
|
|
|
```mermaid
|
|
sequenceDiagram
|
|
participant Caller
|
|
participant Service as Edge service
|
|
participant Queue as Provider queue
|
|
participant Node
|
|
|
|
Caller->>Service: SubmitRun(model)
|
|
Service->>Queue: provider 후보 선택
|
|
Queue-->>Service: adapter + served target
|
|
Service->>Node: RunRequest(adapter, target)
|
|
|
|
participant Operator
|
|
participant Refresh as Config refresh
|
|
Operator->>Refresh: POST /refresh(apply)
|
|
Refresh->>Refresh: load, validate, classify
|
|
Refresh->>Node: NodeConfigRefreshRequest
|
|
```
|
|
|
|
## 계약
|
|
|
|
- `iop.edge-config-runtime-refresh`: `agent-contract/inner/edge-config-runtime-refresh.md`
|
|
- `iop.edge-node-runtime-wire`: `agent-contract/inner/edge-node-runtime-wire.md`
|
|
- proto 원문: `proto/iop/runtime.proto`
|
|
|
|
## 설정/데이터/이벤트
|
|
|
|
- `long_context_threshold_tokens` 기본 예시는 `100000`이고 0 이하 값은 config load에서 거부된다.
|
|
- provider `enabled=false`는 dispatch pool에서 제외하지만 adapter process lifecycle 변경을 의미하지 않는다.
|
|
- provider capacity, priority, max queue, queue timeout, enabled toggle, model generation policy는 live apply 대상으로 분류된다.
|
|
- Edge listener, control plane, openai/a2a listener, bootstrap artifact path, node 추가/삭제, node token/alias, adapter 설정 변경은 restart-required 대상이다.
|
|
- `openai.principal_tokens[]`는 `token_ref`와 `token_hash_sha256` 중복을 거부하고, raw token 원문은 tracked config에 저장하지 않는다.
|
|
- 여러 `openai.principal_tokens[]` entry가 같은 `principal_ref`를 공유할 수 있으며, 이때 `token_ref`가 앱/통합/용도별 사용량 분해 기준이다.
|
|
- `openai.principal_tokens[]` 변경은 credential/hash 변경으로 보고 restart-required로 분류된다.
|
|
- refresh result는 changed nodes/providers/models와 restart-required paths를 stable non-nil slice로 보고한다.
|
|
|
|
## 검증
|
|
|
|
- `go test ./packages/go/config`
|
|
- `go test ./apps/edge/internal/configrefresh`
|
|
- `go test ./apps/edge/internal/service`
|
|
- `go test ./apps/edge/internal/node`
|
|
- `go test ./apps/node/internal/adapters ./apps/node/internal/node`
|
|
|
|
## 한계와 주의사항
|
|
|
|
- provider health는 현재 config/provider snapshot 기반이다. 모든 runtime에 대한 active health probe가 완성된 것은 아니다.
|
|
- refresh admin API는 operator-local 표면이다. 접근 제어 없이 public interface에 노출하지 않는다.
|
|
- adapter structural 변경은 contract상 restart-required로 분류된다. Node handler가 registry swap을 지원하더라도 Edge refresh classifier가 허용한 변경만 apply해야 한다.
|
|
- no-change apply는 runtime snapshot을 교체하지만 Node push는 생략한다.
|
|
- `NodeRuntimeConfig.concurrency`는 legacy metadata이며 provider-pool admission의 node-wide capacity로 쓰지 않는다.
|
|
- credential, private endpoint, bearer token 원문은 tracked config/docs/spec에 남기지 않는다.
|
|
- principal token mapping은 완성된 사용자/테넌트 source of truth가 아니라 외부 `principal_ref` 또는 내부 alias에 대한 얇은 운영 매핑이다.
|
|
|
|
## 변경 기록
|
|
|
|
- 2026-07-07: 현재 코드, 계약, config 예시 기준으로 bootstrap spec 작성.
|
|
- 2026-07-07: 기능 목록 중심으로 축소하고 주요 흐름을 Mermaid sequence diagram으로 정리.
|
|
- 2026-07-10: OpenAI usage metering용 principal token hash mapping config와 restart-required 기준을 반영.
|