9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
6.3 KiB
6.3 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-exhaustiveness-checking | Exhaustiveness Checking | 10_Wiki/Topics | verified | self |
|
none | A | 0.95 | applied |
|
2026-05-10 | pending |
|
Exhaustiveness Checking
매 한 줄
"매 type-level 의 매 case 의 covered 의 verify". 매 switch / match 의 missing branch 의 compile-time 의 catch. 매 TypeScript
never, 매 Rustmatch, 매 Kotlin sealed. 매 modern: 매 type-driven design 의 핵심.
매 핵심
매 mechanism
- Discriminated union + 매 switch.
- Sealed types: 매 known set.
- never type (TS): 매 unreachable.
- Pattern match (Rust, Scala, Kotlin).
매 응용
- State machine: 매 모든 state 의 handle.
- Event handler: 매 모든 event.
- Error type: 매 union of errors.
- API response.
- Theme / variant.
💻 패턴
TypeScript (never)
type Shape =
| { kind: 'circle'; radius: number }
| { kind: 'square'; side: number }
| { kind: 'rectangle'; w: number; h: number };
function area(s: Shape): number {
switch (s.kind) {
case 'circle': return Math.PI * s.radius ** 2;
case 'square': return s.side ** 2;
case 'rectangle': return s.w * s.h;
default: {
const _exhaustive: never = s; // 매 compile error if Shape grows
throw new Error(`Unhandled: ${_exhaustive}`);
}
}
}
assertNever helper
function assertNever(x: never): never {
throw new Error(`Unexpected: ${JSON.stringify(x)}`);
}
function handle(s: Shape) {
switch (s.kind) {
case 'circle': return ...;
case 'square': return ...;
case 'rectangle': return ...;
default: return assertNever(s);
}
}
Rust (match)
enum Shape {
Circle { radius: f64 },
Square { side: f64 },
Rectangle { w: f64, h: f64 },
}
fn area(s: &Shape) -> f64 {
match s {
Shape::Circle { radius } => std::f64::consts::PI * radius * radius,
Shape::Square { side } => side * side,
Shape::Rectangle { w, h } => w * h,
// 매 missing arm = compile error
}
}
Kotlin sealed class
sealed class Shape {
data class Circle(val r: Double) : Shape()
data class Square(val side: Double) : Shape()
}
fun area(s: Shape) = when (s) {
is Shape.Circle -> Math.PI * s.r * s.r
is Shape.Square -> s.side * s.side
// 매 exhaustive — 매 compiler enforces
}
State machine (TS)
type AppState =
| { status: 'idle' }
| { status: 'loading'; startedAt: Date }
| { status: 'success'; data: Data }
| { status: 'error'; message: string };
function render(s: AppState) {
switch (s.status) {
case 'idle': return <Welcome />;
case 'loading': return <Spinner />;
case 'success': return <Display data={s.data} />;
case 'error': return <Error msg={s.message} />;
default: return assertNever(s);
}
}
Result type
type Result<T, E> = { tag: 'ok'; value: T } | { tag: 'err'; error: E };
function handle<T, E>(r: Result<T, E>): T {
switch (r.tag) {
case 'ok': return r.value;
case 'err': throw r.error;
default: return assertNever(r);
}
}
Reducer (Redux)
type Action =
| { type: 'add'; value: number }
| { type: 'sub'; value: number }
| { type: 'reset' };
function reducer(state: number, action: Action): number {
switch (action.type) {
case 'add': return state + action.value;
case 'sub': return state - action.value;
case 'reset': return 0;
default: return assertNever(action);
}
}
Type predicate (narrow)
function isCircle(s: Shape): s is Extract<Shape, { kind: 'circle' }> {
return s.kind === 'circle';
}
TS 4.4+ template literal (string union)
type HttpStatus = 200 | 404 | 500;
function describe(s: HttpStatus): string {
switch (s) {
case 200: return 'OK';
case 404: return 'Not Found';
case 500: return 'Server Error';
default: return assertNever(s);
}
}
Compile fail demo
type Theme = 'light' | 'dark' | 'sepia';
function bg(t: Theme): string {
switch (t) {
case 'light': return '#fff';
case 'dark': return '#000';
// 매 missing 'sepia'
default: const _: never = t; // ❌ Type 'sepia' is not assignable to 'never'
return '';
}
}
ESLint rule
// .eslintrc
{
rules: {
'@typescript-eslint/switch-exhaustiveness-check': 'error',
}
}
Rust if-let / match guard
match (state, action) {
(State::Idle, Action::Start) => State::Running,
(State::Running, Action::Stop) => State::Idle,
(s, _) => s, // 매 catchall — 매 explicit 의 careful
}
매 결정 기준
| 상황 | Approach |
|---|---|
| TS state machine | Discriminated union + never |
| Rust enum | match (built-in) |
| Kotlin | sealed + when |
| Redux | tagged action + assertNever |
| API variant | Discriminated union |
| Throwaway script | Skip |
기본값: 매 TS = discriminated union + assertNever + ESLint rule. 매 Rust = match. 매 Kotlin = sealed when.
🔗 Graph
- 부모: TypeScript 타입 시스템 (TypeScript Type System) · Static-Analysis
- 변형: Discriminated-Union · Sealed-Class · Pattern-Matching
- 응용: State-Machine · Result Type
- Adjacent: Encapsulation-of-Domain-Invariants · Type-Driven-Design · Never-Type
🤖 LLM 활용
언제: 매 type-rich domain. 매 state machine. 매 reducer. 언제 X: 매 dynamic / heterogeneous.
❌ 안티패턴
- Catchall default: 매 exhaustiveness 의 lose.
- String enum 의 boolean check: 매 brittle.
- No assertNever: 매 default 의 silent.
- Mix kind tag: 매 narrow 의 fail.
- Lint disabled: 매 enforce X.
🧪 검증 / 중복
- Verified (TS handbook, Rust book, Effective TypeScript).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — never + 매 TS / Rust / Kotlin / Redux exhaustive code |