[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,111 +2,199 @@
|
||||
id: wiki-2026-0508-system-protocol-standard
|
||||
title: System Protocol Standard
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [Protocol Standardization, Wire Protocol Design, Interface Standards]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [Protocol, State Machine, Data Exchange, Lifecycle]
|
||||
confidence_score: 0.85
|
||||
verification_status: applied
|
||||
tags: [protocol, standard, interoperability, design]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: multi
|
||||
framework: protobuf-grpc
|
||||
---
|
||||
|
||||
# 표준 시스템 통신 프로토콜 및 상태 제어
|
||||
# System Protocol Standard
|
||||
|
||||
## 📡 데이터 교환 규약 (Standard Protocol)
|
||||
모든 컴포넌트 간 통신은 예측 가능한 형태를 유지해야 합니다.
|
||||
- **포맷**: `{ type: 'ACTION_TYPE', payload: { data: value } }`
|
||||
- **주요 액션 타입**:
|
||||
- `INIT`: 시스템 초기화 및 동기화 시작.
|
||||
- `KEY_INPUT`: 사용자 인터랙션 데이터 전송.
|
||||
- `UPDATE`: 엔진 계산 결과의 브로드캐스트.
|
||||
## 매 한 줄
|
||||
> **"매 system 간 wire-level contract 의 versioned, versionable specification"**. 매 protocol standard 의 — message format + transport + semantics + evolution rules. 2026 의 modern stack 의 protobuf + gRPC + OpenAPI + AsyncAPI 의 dominant.
|
||||
|
||||
## 🔄 시스템 생명 주기 (Life Cycle)
|
||||
시스템은 [초기화 $\rightarrow$ 활성 루프 $\rightarrow$ 종료/정리]의 명확한 단계를 거쳐야 리소스 누수([[memory|memory]] Leak)를 방지할 수 있습니다.
|
||||
## 매 핵심
|
||||
|
||||
## 🚨 상태 머신 (State Machine) 도입
|
||||
시스템 복잡도가 임계치를 넘을 경우, `READY`, `RUNNING`, `PAUSED` 등 상태를 명시적으로 제어하는 **State Machine** 적용을 원칙으로 삼습니다.
|
||||
### 매 components of protocol spec
|
||||
- **Syntax**: 매 wire format (binary, JSON, XML).
|
||||
- **Semantics**: 매 message meaning + state machine.
|
||||
- **Transport**: TCP, UDP, HTTP/2, QUIC, WebSocket.
|
||||
- **Versioning**: 매 backward / forward compat rules.
|
||||
- **Error model**: 매 status codes, retry semantics.
|
||||
|
||||
## 🔗 연결된 지식
|
||||
- Project_Architecture_Guidelines
|
||||
- [[Single_Source_of_Truth|Single_Source_of_Truth]]
|
||||
### 매 design 원칙
|
||||
- **Forward compat**: 매 old client 의 new server 의 read.
|
||||
- **Backward compat**: 매 new client 의 old server 의 read (graceful).
|
||||
- **Self-describing**: 매 schema 의 embed (JSON-Schema, protobuf descriptor).
|
||||
- **Idempotency**: 매 retry 의 safe.
|
||||
- **Explicit versioning**: 매 URL `/v1/`, header, or schema `apiVersion`.
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
### 매 standard families
|
||||
- **RPC**: gRPC, Thrift, Cap'n Proto, JSON-RPC.
|
||||
- **REST**: HTTP + OpenAPI 3.1.
|
||||
- **Message**: AMQP, MQTT, Kafka wire, NATS, AsyncAPI 3.0.
|
||||
- **Streaming**: WebRTC, RTSP, HLS, WebTransport.
|
||||
|
||||
> *(TODO: 한 문장으로 핵심 통찰을 작성. "X는 Y 조건에서 Z 효과를 낸다" 구조 권장.)*
|
||||
### 매 응용
|
||||
1. Microservice contracts.
|
||||
2. IoT device protocols.
|
||||
3. Inter-org B2B (EDI → modern API).
|
||||
4. Embedded → cloud telemetry.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
## 💻 패턴
|
||||
|
||||
**추출된 패턴:**
|
||||
> *(TODO)*
|
||||
### Protobuf — versionable schema
|
||||
```protobuf
|
||||
syntax = "proto3";
|
||||
package order.v1;
|
||||
|
||||
**세부 내용:**
|
||||
- *(TODO)*
|
||||
message Order {
|
||||
string id = 1;
|
||||
string customer_id = 2;
|
||||
repeated LineItem items = 3;
|
||||
google.protobuf.Timestamp created_at = 4;
|
||||
reserved 5, 6; // burned fields — never reuse
|
||||
reserved "deprecated_field";
|
||||
}
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
|
||||
- **과거 데이터와의 충돌:** 없음
|
||||
- **정책 변화:** 없음
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
|
||||
- **Parent:** [[10_Wiki/Topics]]
|
||||
- **Related:** *(TODO: 최소 2개)*
|
||||
- **Opposite / Trade-off:** *(TODO)*
|
||||
- **Raw Source:** 직접 입력
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
message LineItem {
|
||||
string sku = 1;
|
||||
int32 qty = 2;
|
||||
Money price = 3;
|
||||
}
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### gRPC service contract
|
||||
```protobuf
|
||||
service OrderService {
|
||||
rpc Create(CreateOrderRequest) returns (Order);
|
||||
rpc Get(GetOrderRequest) returns (Order);
|
||||
rpc Stream(StreamOrdersRequest) returns (stream Order);
|
||||
}
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### OpenAPI 3.1 — REST contract
|
||||
```yaml
|
||||
openapi: 3.1.0
|
||||
info:
|
||||
title: Order API
|
||||
version: 1.4.0
|
||||
paths:
|
||||
/v1/orders/{id}:
|
||||
get:
|
||||
operationId: getOrder
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema: { type: string }
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json:
|
||||
schema: { $ref: '#/components/schemas/Order' }
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Versioning — semver + deprecation
|
||||
```http
|
||||
GET /v1/orders/123
|
||||
Sunset: Wed, 01 Jan 2027 00:00:00 GMT
|
||||
Deprecation: true
|
||||
Link: </v2/orders/123>; rel="successor-version"
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### Schema evolution rules (protobuf)
|
||||
```
|
||||
ALLOWED:
|
||||
- Add new optional field (new tag #)
|
||||
- Rename field name (tag # is contract)
|
||||
- Add new RPC
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
FORBIDDEN:
|
||||
- Change tag #
|
||||
- Change field type (int32 → string)
|
||||
- Make optional → required
|
||||
- Reuse reserved tag
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### Error model — gRPC + RFC 7807
|
||||
```protobuf
|
||||
message Error {
|
||||
string code = 1; // RESOURCE_NOT_FOUND
|
||||
string message = 2;
|
||||
string trace_id = 3;
|
||||
google.protobuf.Any details = 4;
|
||||
}
|
||||
```
|
||||
|
||||
```json
|
||||
// REST RFC 7807
|
||||
{
|
||||
"type": "https://api.example.com/errors/insufficient-funds",
|
||||
"title": "Insufficient funds",
|
||||
"status": 422,
|
||||
"detail": "Account balance is $5; tried to withdraw $100",
|
||||
"instance": "/accounts/12345/withdraw"
|
||||
}
|
||||
```
|
||||
|
||||
### AsyncAPI — event protocol
|
||||
```yaml
|
||||
asyncapi: 3.0.0
|
||||
info: { title: Order Events, version: 1.0.0 }
|
||||
channels:
|
||||
order.created:
|
||||
address: order.v1.created
|
||||
messages:
|
||||
OrderCreated:
|
||||
payload:
|
||||
$ref: '#/components/schemas/Order'
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Internal microservice, polyglot | gRPC + protobuf |
|
||||
| Public API | REST + OpenAPI 3.1 |
|
||||
| Browser real-time | WebSocket / WebTransport |
|
||||
| Event-driven | AsyncAPI + Kafka/NATS |
|
||||
| Embedded / IoT | MQTT + protobuf |
|
||||
|
||||
**기본값**: 매 protobuf + gRPC (internal), 매 OpenAPI + JSON (external).
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[API Design]] · [[Distributed Systems]]
|
||||
- 변형: [[gRPC]] · [[REST]] · [[GraphQL]] · [[AsyncAPI]]
|
||||
- 응용: [[Microservices]] · [[IoT Protocols]] · [[B2B Integration]]
|
||||
- Adjacent: [[Backward Compatibility]] · [[Schema Registry]] · [[Idempotency]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: schema generation, migration plan (v1 → v2), client SDK scaffolding.
|
||||
**언제 X**: final wire format approval (security/perf review 의 human).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **No versioning**: 매 v1 의 미래 의 painful breaking change.
|
||||
- **Reuse reserved tags**: 매 silent data corruption.
|
||||
- **Required fields in proto3**: 매 forward-compat 의 break.
|
||||
- **Stringly-typed enums**: 매 typo + drift — 매 enum 의 사용.
|
||||
- **"Dump it all"**: 매 message 의 too-fat — 매 Single Responsibility 의.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Google API Design Guide; gRPC docs; OpenAPI 3.1; RFC 7807).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — protobuf, OpenAPI, AsyncAPI, versioning rules |
|
||||
|
||||
Reference in New Issue
Block a user