95cd8bb891
- 코드 그라운딩: 기술 주제 문서의 '적용 사례'에 실제 레포 구현 위치
(file:line)+커밋 자동 주입 (예: 문서 청킹 전략→connectai/src/retrieval/chunker.ts).
멱등 마커(CODE-GROUNDING)로 재실행 시 갱신.
- MOC: 39개 클러스터 폴더에 _MOC.md 학습지도 생성(진입점+통찰 주석).
도구: Datacollect/scripts/{code_grounding,moc_generator}.mjs
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5.4 KiB
5.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-p-reinforce | P-Reinforce | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
P-Reinforce
매 한 줄
"매 wiki entry 의 자동 강화 marker". P-Reinforce 는 Claude Code agent 가 wiki node 를 재방문할 때마다 frontmatter 의
last_reinforced를 갱신하고 missing graph link 을 보충하는 light-weight reinforcement loop. 매 hand-curated knowledge graph 의 staleness 방지.
매 핵심
매 trigger 조건
- agent 가 file 을 Read 하고 substantive change (>= 3 lines) 을 적용한 경우.
- backlink resolver 가 dangling
[[X]]을 발견 후 stub 을 만든 경우. - weekly cron (
/loop 7d /reinforce) 의 sweep.
매 frontmatter 의 강화 field
last_reinforced— ISO date.confidence_score— 0..1, decay 0.02/month, +0.05 per reinforcement.verification_status—applied|pending|redirected.source_trust_level— A/B/C.
매 응용
- Wiki staleness audit —
last_reinforced < 90d의 file 을 batch 로 재방문. - Confidence-weighted retrieval — RAG 가 high-confidence node 을 prefer.
- Graph hygiene — orphan / dangling link 을 reinforcement pass 에서 fix.
💻 패턴
Frontmatter reinforcement (Python)
import re, yaml, datetime, pathlib
def reinforce(path: pathlib.Path, bump: float = 0.05):
text = path.read_text()
m = re.match(r"^---\n(.*?)\n---\n(.*)$", text, re.DOTALL)
if not m:
return False
fm = yaml.safe_load(m.group(1)) or {}
fm["last_reinforced"] = datetime.date.today().isoformat()
fm["confidence_score"] = min(0.99, fm.get("confidence_score", 0.5) + bump)
fm["verification_status"] = "applied"
new = "---\n" + yaml.safe_dump(fm, sort_keys=False, allow_unicode=True) + "---\n" + m.group(2)
path.write_text(new)
return True
Decay sweep (cron)
from datetime import date, timedelta
def decayed(fm: dict, days: int = 90) -> bool:
last = date.fromisoformat(fm.get("last_reinforced", "1970-01-01"))
return (date.today() - last) > timedelta(days=days)
stale = [p for p in pathlib.Path("10_Wiki").rglob("*.md")
if decayed(load_fm(p))]
Dangling link harvest
import re
LINK = re.compile(r"\[\[([^\]|#]+)")
def dangling(root):
existing = {p.stem for p in root.rglob("*.md")}
for md in root.rglob("*.md"):
for tgt in LINK.findall(md.read_text()):
if tgt not in existing:
yield md, tgt
Reinforcement-aware retrieval (BM25 + confidence)
def score(doc, query):
bm = bm25(doc.text, query)
conf = doc.frontmatter.get("confidence_score", 0.5)
age = days_since(doc.frontmatter["last_reinforced"])
decay = max(0.5, 1 - age / 365)
return bm * conf * decay
Claude Code hook (settings.json)
{
"hooks": {
"Stop": [{
"command": "python ~/scripts/reinforce_touched.py"
}]
}
}
매 결정 기준
| 상황 | Approach |
|---|---|
| 매 active editing | inline reinforcement on Write |
| 매 background hygiene | weekly cron sweep |
| 매 large refactor | manual verification_status: applied bump |
| 매 redirect/duplicate | verification_status: redirected, no decay |
기본값: Stop hook + weekly sweep 의 조합.
🔗 Graph
- 부모: Knowledge Graph
- 응용: RAG · Agent-Memory
🤖 LLM 활용
언제: 매 long-lived wiki / second-brain 의 staleness 가 문제일 때. 언제 X: 매 ephemeral note / scratchpad — overhead > benefit.
❌ 안티패턴
- Reinforce without read: blind date bump — confidence 의 의미를 잃음.
- Unbounded confidence growth: cap 없이 +0.05 누적 — 매 1.0 saturation. cap 0.99.
- Decay-only no-bump: stale 만 잡고 fresh 강화는 없음 — graph 가 균질하게 늙음.
🧪 검증 / 중복
- Verified (in-house spec, CLEANUP_SPEC.md).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — full content for P-Reinforce framework |
🛠️ 적용 사례 (Applied in summary)
🔎 코드베이스 근거 (자동 추출 — E:\Wiki 레포)
실제 구현/사용 위치:
Datacollect/src/components/EmailPanel.tsx:17— * Gmail 읽기전용 연결 → 최근 스레드 수집 → 스레드별 P-Reinforce wiki 합성 →Datacollect/scripts/web_extract.mjs:5— * P-Reinforce v3.0 위키 문서로 LLM 합성한다.connectai/src/retrieval/terminologyBlock.ts:5— *P-Reinforcevsp-reinforce,Chroniclevs크로니클.connectai/src/features/datacollect/handlers.ts:424— [Omitted long matching line]
관련 커밋:
connectai eeb527c feat(datacollect): /youtube 개편·/wikify 신규·출력 위생 (v2.2.48)connectai a714017 feat(engine): complete stability overhaul - added state resume, deduplication, and P-Reinforce formattingDatacollect 4e00342 feat(wiki): RAG 포맷 강화 + 링크 해소 도구
자동 생성: code_grounding.mjs · 재실행 시 갱신됨