chore(brain): ASTRA 성장 자산 동기화 — 기능 인벤토리·growth(약점프로필/학습큐)·일화기억·장기기억·회의록 원문
This commit is contained in:
+192
@@ -0,0 +1,192 @@
|
||||
---
|
||||
id: wiki-2026-0508-code-splitting-lazy-loading
|
||||
title: Code Splitting & Lazy Loading
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-REINFORCE-AUTO-B933B1, Code Splitting, Lazy Loading]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.95
|
||||
verification_status: applied
|
||||
tags: [web, performance, bundling, react, vite]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: typescript
|
||||
framework: react+vite
|
||||
---
|
||||
|
||||
# Code Splitting & Lazy Loading
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 ship-only-what-you-execute"**. 매 Code Splitting 은 single bundle 을 route/component-bound chunk 로 분할하여 initial JS payload 의 minimization. Lazy Loading 은 매 chunk 를 user-interaction 시점에 fetch. 매 2026 의 standard 는 Vite + React.lazy + dynamic import + RSC (React Server Components) hybrid.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 split 차원
|
||||
- **Route-based**: 매 page 의 lazy import — `/dashboard`, `/settings`.
|
||||
- **Component-based**: 매 heavy widget (chart, code-editor) 의 deferred load.
|
||||
- **Vendor split**: 매 third-party (React, lodash) 의 separate chunk → long-term cache.
|
||||
- **Dynamic feature flag**: 매 A/B variant 의 gated import.
|
||||
|
||||
### 매 핵심 메커니즘
|
||||
- **Dynamic `import()`**: 매 ES module spec — Promise 반환.
|
||||
- **Bundler chunk splitting**: Webpack/Vite 의 `splitChunks` heuristic.
|
||||
- **HTTP/2 push 의 deprecation**: 매 modern preload + modulepreload 로 대체.
|
||||
- **Streaming SSR + RSC**: 매 chunk 의 server-streamed delivery.
|
||||
|
||||
### 매 응용
|
||||
1. SaaS dashboard — `/admin` route 의 lazy chunk.
|
||||
2. E-commerce — checkout flow 만 separate bundle.
|
||||
3. Editor app (Notion-like) — markdown/code-editor lazy.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### 패턴 1: React.lazy + Suspense
|
||||
```tsx
|
||||
import { lazy, Suspense } from "react";
|
||||
import { Routes, Route } from "react-router-dom";
|
||||
|
||||
const Dashboard = lazy(() => import("./pages/Dashboard"));
|
||||
const Settings = lazy(() => import("./pages/Settings"));
|
||||
|
||||
export function App() {
|
||||
return (
|
||||
<Suspense fallback={<Skeleton />}>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />} />
|
||||
<Route path="/dashboard" element={<Dashboard />} />
|
||||
<Route path="/settings" element={<Settings />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### 패턴 2: Vite manual chunks
|
||||
```ts
|
||||
// vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (id.includes("node_modules/react")) return "react-vendor";
|
||||
if (id.includes("node_modules/@radix-ui")) return "radix";
|
||||
if (id.includes("/src/charts/")) return "charts";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### 패턴 3: Preload on hover (intent-based prefetch)
|
||||
```tsx
|
||||
function NavLink({ to, children }: { to: string; children: React.ReactNode }) {
|
||||
const prefetch = () => {
|
||||
if (to === "/dashboard") import("./pages/Dashboard");
|
||||
};
|
||||
return <Link to={to} onMouseEnter={prefetch} onFocus={prefetch}>{children}</Link>;
|
||||
}
|
||||
```
|
||||
|
||||
### 패턴 4: Conditional dynamic import
|
||||
```tsx
|
||||
async function loadChart(type: "line" | "bar" | "heatmap") {
|
||||
switch (type) {
|
||||
case "line": return (await import("./charts/Line")).default;
|
||||
case "bar": return (await import("./charts/Bar")).default;
|
||||
case "heatmap": return (await import("./charts/Heatmap")).default;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 패턴 5: React Server Component (RSC) split
|
||||
```tsx
|
||||
// app/dashboard/page.tsx (Next.js 15+)
|
||||
import { Suspense } from "react";
|
||||
import { HeavyChart } from "./HeavyChart"; // server component
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<Suspense fallback={<ChartSkeleton />}>
|
||||
<HeavyChart /> {/* streamed independently */}
|
||||
</Suspense>
|
||||
</>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### 패턴 6: Bundle analyzer pipeline
|
||||
```bash
|
||||
# Vite + rollup-plugin-visualizer
|
||||
npm i -D rollup-plugin-visualizer
|
||||
```
|
||||
```ts
|
||||
import { visualizer } from "rollup-plugin-visualizer";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [visualizer({ open: true, gzipSize: true })]
|
||||
});
|
||||
```
|
||||
|
||||
### 패턴 7: Module federation (micro-frontend)
|
||||
```ts
|
||||
// host vite.config.ts
|
||||
import federation from "@originjs/vite-plugin-federation";
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
federation({
|
||||
name: "host",
|
||||
remotes: { checkout: "http://cdn/checkout/remoteEntry.js" },
|
||||
shared: ["react", "react-dom"]
|
||||
})
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Multi-page SPA | route-based React.lazy |
|
||||
| Heavy single widget | component-level dynamic import |
|
||||
| Multi-team monorepo | module federation |
|
||||
| Server-rendered Next.js | RSC + Suspense streaming |
|
||||
| Legacy Webpack 4 | upgrade to Vite/Webpack 5 first |
|
||||
| Initial paint > 3s | bundle analyzer + manualChunks |
|
||||
|
||||
**기본값**: Vite + React.lazy(route) + intent-prefetch on hover.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Web Performance]]
|
||||
- 변형: [[Module Federation]]
|
||||
- 응용: [[React Server Components]]
|
||||
- Adjacent: [[Vite]] · [[Rollup]] · [[esbuild]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: bundle analysis 의 chunk strategy 추천, lazy boundary 후보 식별, manualChunks rule 작성.
|
||||
**언제 X**: 매 production runtime 의 dynamic decision — 매 bundler-time static analysis 의 영역.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Over-splitting**: 매 component 마다 lazy — 매 too many waterfalls. 매 100KB+ threshold.
|
||||
- **Suspense boundary 의 미사용**: 매 React.lazy 의 fallback 없음 → throw.
|
||||
- **Preload everything**: 매 idle prefetch 의 abuse — bandwidth waste.
|
||||
- **Dynamic import in render**: 매 매 render 마다 import() 호출 → re-fetch.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (web.dev code-splitting docs, Vite docs, React.lazy spec, RFC#118).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — substantive content + 2026 stack (Vite, RSC, module federation) |
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
---
|
||||
id: wiki-2026-0508-description-logics
|
||||
title: Description Logics
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-REINFORCE-AUTO-088907, DL, ALC, SROIQ]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
verification_status: applied
|
||||
tags: [logic, knowledge-representation, ontology, owl, semantic-web]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: python
|
||||
framework: owlready2+hermit
|
||||
---
|
||||
|
||||
# Description Logics
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 decidable fragment of first-order logic"**. 매 Description Logics (DL) 은 concept (class), role (property), individual 을 formal language 로 표현하여 ontology reasoning 의 mathematical foundation. 매 OWL 2 (Web Ontology Language) 는 SROIQ(D) DL 의 syntactic dialect — 매 2026 의 Knowledge Graph + LLM grounding 의 backbone.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 DL family (expressivity)
|
||||
- **AL** (Attributive Language): atomic concept, conjunction, universal restriction.
|
||||
- **ALC**: AL + full negation. 매 baseline.
|
||||
- **ALCN**: ALC + cardinality.
|
||||
- **SHIQ**: + role hierarchy, inverse role, qualified cardinality.
|
||||
- **SROIQ**: SHIQ + role chain, self-restriction, nominal — OWL 2 DL 의 base.
|
||||
|
||||
### 매 reasoning task
|
||||
- **Subsumption**: C ⊑ D (concept inclusion).
|
||||
- **Consistency**: ontology 의 모순 검증.
|
||||
- **Instance check**: a ∈ C.
|
||||
- **Classification**: 전체 concept hierarchy 의 compute.
|
||||
- **Realization**: 매 individual 의 most-specific class.
|
||||
|
||||
### 매 응용
|
||||
1. Biomedical ontology (SNOMED CT, GO) — drug-disease reasoning.
|
||||
2. Knowledge graph 의 schema validation (Wikidata, Schema.org).
|
||||
3. LLM grounding — RAG 의 ontology-constrained retrieval.
|
||||
4. Configuration management — feature compatibility reasoning.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### 패턴 1: ALC concept 정의 (Owlready2)
|
||||
```python
|
||||
from owlready2 import *
|
||||
|
||||
onto = get_ontology("http://example.org/family.owl")
|
||||
|
||||
with onto:
|
||||
class Person(Thing): pass
|
||||
class Parent(Person): pass
|
||||
class hasChild(Person >> Person): pass
|
||||
|
||||
class Mother(Parent):
|
||||
equivalent_to = [Parent & ~onto.search(is_a=onto.Male)[0]]
|
||||
# ALC: Mother ≡ Parent ⊓ ¬Male
|
||||
```
|
||||
|
||||
### 패턴 2: SROIQ role chain (grandparent)
|
||||
```python
|
||||
with onto:
|
||||
class hasGrandchild(Person >> Person):
|
||||
# role chain: hasChild ∘ hasChild ⊑ hasGrandchild
|
||||
property_chain = [[hasChild, hasChild]]
|
||||
```
|
||||
|
||||
### 패턴 3: Reasoner 실행 (HermiT)
|
||||
```python
|
||||
from owlready2 import sync_reasoner_hermit
|
||||
|
||||
with onto:
|
||||
sync_reasoner_hermit(infer_property_values=True)
|
||||
|
||||
# inferred axioms inspect
|
||||
for cls in onto.classes():
|
||||
print(cls, "⊑", cls.is_a)
|
||||
```
|
||||
|
||||
### 패턴 4: Tableau algorithm (mini ALC)
|
||||
```python
|
||||
def alc_satisfiable(concept, world=None):
|
||||
"""Naive tableau for ALC C ⊓ ¬C unsatisfiability check."""
|
||||
world = world or {"individuals": {}, "constraints": []}
|
||||
if concept[0] == "AND":
|
||||
for sub in concept[1:]:
|
||||
if not alc_satisfiable(sub, world):
|
||||
return False
|
||||
return True
|
||||
if concept[0] == "NOT":
|
||||
atom = concept[1]
|
||||
if ("ATOM", atom) in world["constraints"]:
|
||||
return False # clash
|
||||
world["constraints"].append(("NOT_ATOM", atom))
|
||||
return True
|
||||
if concept[0] == "ATOM":
|
||||
if ("NOT_ATOM", concept[1]) in world["constraints"]:
|
||||
return False
|
||||
world["constraints"].append(("ATOM", concept[1]))
|
||||
return True
|
||||
# ∃R.C, ∀R.C handled by spawning fresh individual ...
|
||||
```
|
||||
|
||||
### 패턴 5: SPARQL over OWL inference
|
||||
```sparql
|
||||
PREFIX owl: <http://www.w3.org/2002/07/owl#>
|
||||
PREFIX : <http://example.org/family#>
|
||||
|
||||
SELECT ?gp ?gc WHERE {
|
||||
?gp :hasGrandchild ?gc . # inferred via property_chain
|
||||
}
|
||||
```
|
||||
|
||||
### 패턴 6: LLM-grounded ontology query
|
||||
```python
|
||||
import anthropic
|
||||
from owlready2 import get_ontology
|
||||
|
||||
client = anthropic.Anthropic()
|
||||
onto = get_ontology("./family.owl").load()
|
||||
|
||||
def grounded_answer(question: str) -> str:
|
||||
classes = [c.name for c in onto.classes()]
|
||||
response = client.messages.create(
|
||||
model="claude-opus-4-7-20260301",
|
||||
max_tokens=512,
|
||||
system=f"Use only these ontology classes: {classes}. Answer with class names.",
|
||||
messages=[{"role": "user", "content": question}]
|
||||
)
|
||||
return response.content[0].text
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Web ontology / Linked Data | OWL 2 DL (SROIQ) + Protégé |
|
||||
| Lightweight inference | OWL 2 EL (medical) or RL (rule-based) |
|
||||
| Real-time reasoning | RDFS + custom rules (avoid full DL) |
|
||||
| Research / proof-of-concept | ALC + custom tableau |
|
||||
| Fact-heavy KG (Wikidata) | SHACL validation > full DL reasoning |
|
||||
| LLM grounding | EL/RL profile + SPARQL |
|
||||
|
||||
**기본값**: OWL 2 EL (tractable PTIME) + HermiT/ELK reasoner.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Logic]] · [[Knowledge Representation]]
|
||||
- Adjacent: [[Knowledge Graphs]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: ontology design review, axiom suggestion, SPARQL 생성, RAG 의 ontology-grounded prompt.
|
||||
**언제 X**: 매 reasoning soundness 의 결정 — DL reasoner (HermiT, ELK) 의 영역. LLM 은 hint only.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Open-world misunderstanding**: 매 absent fact 가 false 라 가정 — DL 은 OWA (open world).
|
||||
- **Unique Name Assumption 가정**: 매 individual a ≠ b 자동 아님 — `differentFrom` 명시 필요.
|
||||
- **Undecidable extension**: 매 SROIQ 의 추가 expressivity (full datatype reasoning) → 결정불가.
|
||||
- **Reasoner 없이 inference**: 매 axiom 만 작성 + 매 reasoner 미실행 → no inferred triples.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Baader et al. "DL Handbook", W3C OWL 2 spec, Owlready2 docs).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — substantive content + 2026 stack (Owlready2, HermiT, LLM grounding) |
|
||||
Reference in New Issue
Block a user