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.4 KiB
6.4 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-executable-documentation | Executable Documentation | 10_Wiki/Topics | verified | self |
|
none | A | 0.92 | applied |
|
2026-05-10 | pending |
|
Executable Documentation
매 한 줄
"매 docs 의 CI 의 run — 매 stale 의 fail". 매 docs 의 prose 의 not — 매 examples / scenarios / API specs 의 매 actually-execute. 매 1990s Donald Knuth literate programming + Python doctest 의 origin, 매 2020s Cucumber/BDD 의 popularize, 매 2026 의 매 LLM-assisted doc generation + verification 의 standard practice.
매 핵심
매 종류
- Doctest — 매 docstring 안의 example 의 run (Python doctest, Rust doctests).
- BDD — Gherkin (
Given/When/Then) 의 step 의 bind (Cucumber, Behave). - API docs from spec — OpenAPI → contract test (Schemathesis, Dredd).
- Notebook docs — Jupyter / Quarto / Marimo 의 매 cell 의 run.
- Markdown code-fence test —
mdsh,mdocc,markdown-doctest. - AI-verified docs — 매 LLM 의 docs 의 read + code 의 inspect + drift 의 detect.
매 왜 valuable
- 매 docs 의 truth = code 의 truth.
- 매 onboarding example 의 매 always working.
- 매 API contract 의 single source of truth.
- 매 refactor 시 docs 의 break — 매 catch.
매 응용
- SDK / library docs (매 examples 의 always-correct).
- API contract testing (OpenAPI + Schemathesis).
- BDD acceptance tests (매 PM-readable).
- Tutorial CI (매 step-by-step 의 verify).
💻 패턴
Pattern 1: Python doctest
def fibonacci(n: int) -> int:
"""Return the n-th Fibonacci number.
>>> fibonacci(0)
0
>>> fibonacci(10)
55
>>> [fibonacci(i) for i in range(7)]
[0, 1, 1, 2, 3, 5, 8]
"""
a, b = 0, 1
for _ in range(n): a, b = b, a + b
return a
# pytest --doctest-modules
Pattern 2: Rust doctest
/// Adds two numbers.
///
/// # Examples
/// ```
/// use mycrate::add;
/// assert_eq!(add(2, 3), 5);
/// ```
pub fn add(a: i32, b: i32) -> i32 { a + b }
// cargo test --doc
Pattern 3: Cucumber BDD (TS)
# features/checkout.feature
Feature: Checkout
Scenario: Successful purchase
Given a cart with 2 items totaling $50
And a valid Stripe token "tok_visa"
When the user submits checkout
Then the order status should be "paid"
And a confirmation email is queued
// step defs
import { Given, When, Then } from "@cucumber/cucumber";
Given("a cart with {int} items totaling ${int}", function (n, total) {
this.cart = makeCart(n, total);
});
When("the user submits checkout", async function () {
this.result = await checkout(this.cart, this.token);
});
Then("the order status should be {string}", function (status) {
expect(this.result.status).toBe(status);
});
Pattern 4: OpenAPI contract test (Schemathesis)
schemathesis run https://api.example.com/openapi.json \
--checks all \
--hypothesis-deadline 5000
# 매 매 endpoint 의 spec 의 conform 의 verify (property-based).
Pattern 5: Markdown code-fence test
// scripts/test-readme.ts
import { readFileSync } from "fs";
import { execSync } from "child_process";
const md = readFileSync("README.md", "utf8");
const blocks = [...md.matchAll(/```typescript\n([\s\S]*?)\n```/g)];
for (const [, code] of blocks) {
const tmp = `/tmp/snippet-${Date.now()}.ts`;
require("fs").writeFileSync(tmp, code);
execSync(`tsx ${tmp}`, { stdio: "inherit" });
}
Pattern 6: Quarto / Marimo notebook
# 매 marimo notebook — 매 reactive, 매 git-friendly
import marimo as mo
@mo.cell
def fetch():
import requests
return requests.get("https://api.example.com/users").json()
@mo.cell
def show(fetch):
return mo.ui.table(fetch)
# 매 marimo run notebook.py — 매 docs + working app.
Pattern 7: AI-verified doc drift (2026)
import Anthropic from "@anthropic-ai/sdk";
const ai = new Anthropic();
async function checkDocDrift(docPath: string, codeGlob: string) {
const docs = readFileSync(docPath, "utf8");
const code = await loadFiles(codeGlob);
const res = await ai.messages.create({
model: "claude-opus-4-7",
max_tokens: 2000,
system: "You verify docs match code. Output JSON: {drifts:[{location, doc_says, code_actually}]}",
messages: [{
role: "user",
content: `DOCS:\n${docs}\n\nCODE:\n${code}\n\nFind drift.`,
}],
});
return JSON.parse(res.content[0].text);
}
// CI 의 매 fail 의 drift 의 found 시.
Pattern 8: Architecture decision record (ADR) with assertion
# ADR-0042: Use Postgres for primary store
## Decision
PostgreSQL 16 의 single-tenant DB.
## Verification (run in CI)
\`\`\`bash
# 매 docs 의 claim 의 verify
psql $DATABASE_URL -c "SELECT version();" | grep -q "PostgreSQL 16"
\`\`\`
매 결정 기준
| 상황 | Approach |
|---|---|
| Library / SDK | doctest (Python/Rust) |
| REST API | OpenAPI + Schemathesis |
| Acceptance test (PM) | Cucumber BDD |
| Tutorial / book | Markdown code-fence test |
| Data analysis | Quarto / Marimo |
| Architecture docs | AI drift detector |
기본값: 매 README 예제 의 매 CI 의 run, 매 API 의 OpenAPI 의 contract test.
🔗 Graph
- 부모: Docs as Code
- 응용: OpenAPI
- Adjacent: Property-Based Testing · Contract Testing
🤖 LLM 활용
언제: 매 docs drift detection, 매 example generation 의 verify, 매 BDD step 의 generate. 언제 X: 매 internal scratchpad notes — 매 over-engineering.
❌ 안티패턴
- Doctest 의 too many: 매 docstring 의 cluttered — 매 separate test 가 better.
- BDD 의 implementation detail: 매 Given/When/Then 이 SQL 의 mention — 매 wrong abstraction.
- Spec drift: 매 OpenAPI 의 stale — 매 generate-from-code or test 의 mandatory.
- No CI: 매 executable 의 X — 매 prose docs 의 same.
🧪 검증 / 중복
- Verified (Knuth literate programming, Python doctest stdlib, Cucumber.io, Schemathesis docs, Marimo docs).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — doctest/BDD/OpenAPI/Marimo/AI-drift |