[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,96 +2,197 @@
|
||||
id: wiki-2026-0508-architecture-refactor
|
||||
title: Architecture Refactor
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [550e8400-e29b-41d4-a716-446655440001]
|
||||
aliases: [strangler-fig, big-bang-rewrite, modernization]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.95
|
||||
tags: [skybound, architecture, performance, zero-leak]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [architecture, refactor, strangler-fig, modernization]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-21
|
||||
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: polyglot
|
||||
framework: strangler-fig
|
||||
---
|
||||
|
||||
# Skybound 아키텍처 리팩토링
|
||||
# Architecture Refactor
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> 엔진-모듈 간의 '의도(Intent)' 기반 통신과 선언적 파이프라인 도입을 통해 시스템 신뢰도와 성능을 동시에 확보하는 'Zero-Leak' 아키텍처로 진화함.
|
||||
## 매 한 줄
|
||||
> **"매 incremental 의 always wins"**. 매 architecture refactor 의 default approach 의 Martin Fowler 의 Strangler Fig (2004) — 매 old system 의 around 의 new system 의 gradual 의 grow. 매 big-bang rewrite 의 historically failure rate >70% (Ousterhout, Brooks). 매 2026 의 typical pattern: 매 monolith → modular monolith → selective service extraction.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **추출된 패턴:**
|
||||
- **Intent-Based Communication**: 엔진의 핵심 상태를 직접 조작하는 대신 허용된 Intent 인터페이스를 통해 시스템 간 격리를 강화.
|
||||
- **Phase-Aware Pipeline**: 시스템 실행 순서를 선언적으로 관리하여 비동기 레이스 컨디션을 원천 차단.
|
||||
- **세부 내용:**
|
||||
- `EntityPool` 최적화를 통해 루프 연산 시 CPU 점유율을 15-20% 개선.
|
||||
- 불필요한 이벤트 리스너 재등록을 차단하여 장기 실행 시의 메모리 누수 방지.
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 기존의 파편화된 비동기 호출 방식(Ghost UI 발생 원인)을 대체함.
|
||||
- **정책 변화:** 성능보다는 '예측 가능성(Predictability)'을 우선하는 설계 원칙 수립.
|
||||
### 매 refactor strategies
|
||||
- **Strangler Fig**: 매 facade 의 routing — 매 traffic 의 incrementally 의 new system 의 redirect.
|
||||
- **Branch by Abstraction**: 매 abstraction layer 의 introduce — 매 dual 의 implementation — 매 old 의 remove.
|
||||
- **Parallel Run**: 매 old + new 의 동시 실행 — 매 output 의 compare.
|
||||
- **Big Bang Rewrite**: 매 last resort — 매 only 매 system 의 small + scope 의 frozen 의 가능.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Parent:** 10_Wiki/Projects/Skybound
|
||||
- **Related:** 10_Wiki/Decisions/Skybound/IDE_Stability_Fix, 10_Wiki/Decisions/Skybound/Frame_Type_Restoration
|
||||
- **Raw Source:** 00_Raw/2026-04-21-Skybound_Architecture_Refactor_Plan
|
||||
### 매 refactor 의 prerequisite
|
||||
- **Test coverage**: 매 characterization tests (Feathers) 의 minimum.
|
||||
- **Observability**: 매 metrics + traces 의 before/after diff.
|
||||
- **Feature flag**: 매 reversibility 의 prerequisite.
|
||||
- **ADR**: 매 decision rationale 의 documented.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
### Related Concepts (Auto-Linked)
|
||||
* [[Architecture]]
|
||||
* [[Frame_Type_Restoration]]
|
||||
* [[IDE_Stability_Fix]]
|
||||
* [[decisions]]
|
||||
### 매 응용
|
||||
1. Monolith → modular monolith — 매 module boundary 의 enforce (ArchUnit).
|
||||
2. Service extraction — 매 bounded context 의 따라.
|
||||
3. Database split — 매 most expensive — 매 last 의 do.
|
||||
4. Framework upgrade — 매 incremental migration.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
## 💻 패턴
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### Strangler Fig — Nginx routing facade
|
||||
```nginx
|
||||
upstream legacy { server legacy.internal:8080; }
|
||||
upstream new { server new.internal:8080; }
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
server {
|
||||
listen 443 ssl;
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
# New endpoints — gradual rollout
|
||||
location /api/v2/orders { proxy_pass http://new; }
|
||||
location /api/v2/users { proxy_pass http://new; }
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
# Everything else still legacy
|
||||
location / { proxy_pass http://legacy; }
|
||||
}
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Branch by Abstraction (Java)
|
||||
```java
|
||||
// Step 1 — extract interface
|
||||
interface PaymentGateway {
|
||||
Receipt charge(Order o);
|
||||
}
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
// Step 2 — wrap legacy
|
||||
class LegacyStripeGateway implements PaymentGateway { /* ... */ }
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
// Step 3 — new impl behind flag
|
||||
class AdyenGateway implements PaymentGateway { /* ... */ }
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
// Step 4 — feature-flag pick
|
||||
class GatewayFactory {
|
||||
PaymentGateway pick(String tenant) {
|
||||
return flags.isOn("adyen", tenant)
|
||||
? new AdyenGateway()
|
||||
: new LegacyStripeGateway();
|
||||
}
|
||||
}
|
||||
// Step 5 — once 100% rollout, delete LegacyStripeGateway
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### Parallel Run (shadow traffic)
|
||||
```ts
|
||||
async function chargeShadow(order: Order): Promise<Receipt> {
|
||||
const [primary, shadow] = await Promise.allSettled([
|
||||
legacy.charge(order),
|
||||
newImpl.charge(order) // never persists, just observes
|
||||
]);
|
||||
if (shadow.status === 'fulfilled' && primary.status === 'fulfilled') {
|
||||
diff.record('charge', primary.value, shadow.value);
|
||||
}
|
||||
return primary.status === 'fulfilled' ? primary.value : Promise.reject(primary.reason);
|
||||
}
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### Database Strangling — dual write + read switch
|
||||
```python
|
||||
# Phase 1: dual write
|
||||
def save_order(o: Order):
|
||||
legacy_db.insert(o)
|
||||
try:
|
||||
new_db.insert(o)
|
||||
except Exception as e:
|
||||
log.warn("shadow write failed", e=e)
|
||||
|
||||
# Phase 2: dual read + diff
|
||||
def get_order(id: str):
|
||||
a = legacy_db.get(id)
|
||||
b = new_db.get(id)
|
||||
if a != b: metrics.increment("order.read.diverge")
|
||||
return a # legacy still source of truth
|
||||
|
||||
# Phase 3: flip read source
|
||||
def get_order(id: str):
|
||||
return new_db.get(id)
|
||||
|
||||
# Phase 4: stop legacy write, decommission
|
||||
```
|
||||
|
||||
### Module extraction (modular monolith → service)
|
||||
```bash
|
||||
# 1. Codify module boundary first (ArchUnit)
|
||||
# 2. Replace direct calls with in-process interface
|
||||
# 3. Add feature flag: in-process vs HTTP/gRPC
|
||||
# 4. Deploy as separate process behind flag
|
||||
# 5. Remove in-process path
|
||||
```
|
||||
|
||||
### Characterization test (Feathers)
|
||||
```python
|
||||
import json, pytest
|
||||
|
||||
@pytest.mark.parametrize("fixture", load_fixtures("legacy_outputs/*.json"))
|
||||
def test_legacy_behavior_preserved(fixture):
|
||||
inputs = fixture["input"]
|
||||
expected = fixture["legacy_output"]
|
||||
actual = new_impl.run(**inputs)
|
||||
assert actual == expected, f"divergence: {fixture['id']}"
|
||||
```
|
||||
|
||||
### Refactor scoreboard (CI)
|
||||
```yaml
|
||||
# refactor-progress.yml — auto-generated dashboard
|
||||
metrics:
|
||||
- name: legacy-endpoints-remaining
|
||||
cmd: grep -r "@legacy" src/ | wc -l
|
||||
- name: new-coverage
|
||||
cmd: jacoco --module=new-impl
|
||||
- name: traffic-on-new
|
||||
promql: sum(rate(http_requests_total{service="new"}[5m]))
|
||||
/ sum(rate(http_requests_total[5m]))
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Strategy |
|
||||
|---|---|
|
||||
| Active legacy + traffic | Strangler Fig |
|
||||
| Library/abstraction swap | Branch by Abstraction |
|
||||
| Risk-critical (payment, billing) | Parallel Run |
|
||||
| DB schema change | Dual-write + flip read |
|
||||
| Tiny system, frozen scope | Big Bang (rare) |
|
||||
| Distributed monolith | Reverse first → modular monolith → extract |
|
||||
|
||||
**기본값**: Strangler Fig + feature flag + parallel-run on critical paths.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Software Architecture]] · [[Refactoring]]
|
||||
- 변형: [[Strangler-Fig]] · [[Branch-by-Abstraction]]
|
||||
- 응용: [[Modular-Monolith]] · [[Microservices]]
|
||||
- Adjacent: [[Architecture Erosion (아키텍처 침식)]] · [[Architectural-Constraint-Enforcement]] · [[Architecture Review (아키텍처 및 설계 리뷰)]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 legacy code → modern equivalent translation, 매 codemod plan generation, 매 ADR draft.
|
||||
**언제 X**: 매 production cutover decision — 매 human + traffic data 의 필수.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Big bang rewrite**: 매 70%+ failure rate — 매 last resort.
|
||||
- **Refactor without tests**: 매 silent regression 의 guarantee.
|
||||
- **No flag, no rollback**: 매 forward-only deploy — 매 incident magnification.
|
||||
- **Premature service extraction**: 매 distributed monolith 의 worst-of-both.
|
||||
- **Stop midway**: 매 두 system 의 forever maintain — 매 cost 의 doubled.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Fowler — *StranglerFigApplication*; Feathers — *Working Effectively with Legacy Code*; Newman — *Monolith to Microservices*).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — Strangler Fig + Branch-by-Abstraction + parallel-run patterns |
|
||||
|
||||
Reference in New Issue
Block a user