Compare commits
372
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c81fa0cb5 | ||
|
|
c3815afcd4 | ||
|
|
8800160564 | ||
|
|
bdbc4a1bf7 | ||
|
|
597090bc45 | ||
|
|
af36c410b4 | ||
|
|
4dcd606c10 | ||
|
|
bbd5a7fa48 | ||
|
|
6dc37ccb66 | ||
|
|
b84906283e | ||
|
|
af0dcdf76a | ||
|
|
f1e1cde597 | ||
|
|
a7c5630e5b | ||
|
|
82151d6bc3 | ||
|
|
c93e7ad598 | ||
|
|
290b271cf6 | ||
|
|
a686bdbeaf | ||
|
|
2b84c62875 | ||
|
|
2de786fc64 | ||
|
|
2ddf034983 | ||
|
|
b2043f4f84 | ||
|
|
52eae52061 | ||
|
|
e451ea64ae | ||
|
|
eb6e4028ff | ||
|
|
ea45493941 | ||
|
|
da70f0e00c | ||
|
|
8bf3707511 | ||
|
|
804eeef858 | ||
|
|
36658f12fe | ||
|
|
f0e675ffd8 | ||
|
|
90911c1074 | ||
|
|
1729e0b40d | ||
|
|
70b3169e7f | ||
|
|
315a1c0945 | ||
|
|
b9316c693d | ||
|
|
820e52d869 | ||
|
|
444e8e4206 | ||
|
|
e6f2c8b4e8 | ||
|
|
f6b7652219 | ||
|
|
3cd00ab5cf | ||
|
|
0feae50d90 | ||
|
|
d79c55fc64 | ||
|
|
98a6f5c480 | ||
|
|
0fa4aa7280 | ||
|
|
3b192e2eed | ||
|
|
2794d26181 | ||
|
|
7b56f696d6 | ||
|
|
ead1b8c1bc | ||
|
|
b8126e00c4 | ||
|
|
62f8f4b313 | ||
|
|
21924541dc | ||
|
|
197242ca42 | ||
|
|
7922734dce | ||
|
|
afd7675425 | ||
|
|
8b3b343645 | ||
|
|
6713f342c3 | ||
|
|
79bb8a143c | ||
|
|
d03a181536 | ||
|
|
8e5304c156 | ||
|
|
c487db6534 | ||
|
|
0ca54f429e | ||
|
|
6c62f64784 | ||
|
|
3282f85007 | ||
|
|
b186569750 | ||
|
|
7cde2462ec | ||
|
|
c0b96f7c05 | ||
|
|
3a88caac69 | ||
|
|
31457e9240 | ||
|
|
307335a733 | ||
|
|
4eb5e34ea7 | ||
|
|
f4be219790 | ||
|
|
53591b6f27 | ||
|
|
a14d0bb7cb | ||
|
|
c2802e7cb3 | ||
|
|
c7f2815f1d | ||
|
|
afc90fe992 | ||
|
|
2f9ce824a0 | ||
|
|
a39b2a6950 | ||
|
|
70fa95966c | ||
|
|
10479014d5 | ||
|
|
148e22aa7d | ||
|
|
a9fe6196f7 | ||
|
|
ae20665a66 | ||
|
|
ccbf078463 | ||
|
|
cd1e46784f | ||
|
|
b49d97b8d7 | ||
|
|
3d44de9d87 | ||
|
|
987b3c1770 | ||
|
|
25bc6544c4 | ||
|
|
b241ae753b | ||
|
|
2041771b14 | ||
|
|
b5958a9f63 | ||
|
|
c05dbd4b3b | ||
|
|
44e468fc21 | ||
|
|
5f358d329b | ||
|
|
59fe8154f2 | ||
|
|
d5b2e9bb8f | ||
|
|
3a3907e1b6 | ||
|
|
f66cdc70b2 | ||
|
|
e299a497a7 | ||
|
|
eefb29d2ad | ||
|
|
668c485037 | ||
|
|
c83d5bb970 | ||
|
|
8638b3c95b | ||
|
|
c9b55c16f7 | ||
|
|
a3b9d53d06 | ||
|
|
215915cee2 | ||
|
|
df9271ed81 | ||
|
|
97e73a0fa0 | ||
|
|
e2ebe98e7f | ||
|
|
345e30de71 | ||
|
|
0084160e12 | ||
|
|
7280c111f0 | ||
|
|
763de11d2b | ||
|
|
9c0de3eeb2 | ||
|
|
9c81e9fbf1 | ||
|
|
40603f1652 | ||
|
|
4a34da31ad | ||
|
|
6e394faab1 | ||
|
|
25d0895cac | ||
|
|
f5f93cfb12 | ||
|
|
cf1ebe9d6f | ||
|
|
dd0d4ff8b1 | ||
|
|
98103f3270 | ||
|
|
a740ebb42e | ||
|
|
7c79f820cb | ||
|
|
f3b2326304 | ||
|
|
4eded247c5 | ||
|
|
3ffb857181 | ||
|
|
ec92906399 | ||
|
|
87671640ea | ||
|
|
c725e984bb | ||
|
|
8f05b57744 | ||
|
|
120b0147f2 | ||
|
|
ae695b4b15 | ||
|
|
89fee685c3 | ||
|
|
23eb9a21c8 | ||
|
|
a009efe91c | ||
|
|
dbd3111adf | ||
|
|
2b35e0c07a | ||
|
|
ba3354df03 | ||
|
|
7c8c19f416 | ||
|
|
35f83241cb | ||
|
|
5297f9b47e | ||
|
|
cbc50ec4eb | ||
|
|
198cc291e2 | ||
|
|
cb8c3a6ea6 | ||
|
|
66f597bbba | ||
|
|
fe237c8b4b | ||
|
|
ec7b08a625 | ||
|
|
9dd728579d | ||
|
|
0a6ca00f64 | ||
|
|
6e856ce05f | ||
|
|
1b8b78cfe9 | ||
|
|
49508d9f87 | ||
|
|
63a660223e | ||
|
|
2cbc2e2f43 | ||
|
|
eb2ad44755 | ||
|
|
c3979142a6 | ||
|
|
1a30de6bfc | ||
|
|
8c0df47966 | ||
|
|
4c177378ae | ||
|
|
a2db175819 | ||
|
|
2d0f050524 | ||
|
|
2d2b78edb3 | ||
|
|
627fa80f3e | ||
|
|
96cbbb093e | ||
|
|
6551308f14 | ||
|
|
9ccc2badd4 | ||
|
|
07a83bdeb7 | ||
|
|
224dfb6588 | ||
|
|
d8d6c68ac2 | ||
|
|
3e369e5464 | ||
|
|
abaaba97f9 | ||
|
|
bd49467d26 | ||
|
|
b44524e1a9 | ||
|
|
0319667f8e | ||
|
|
4c3ad1f83c | ||
|
|
a7a845187a | ||
|
|
e14a9a11d2 | ||
|
|
d7ce757d65 | ||
|
|
6f5447c316 | ||
|
|
727b67811c | ||
|
|
a85fb68015 | ||
|
|
2dfe7328cc | ||
|
|
cfc0a0ca8f | ||
|
|
2b1c7fe20d | ||
|
|
d5e1d9c09b | ||
|
|
554540451e | ||
|
|
c10134c22b | ||
|
|
9175b3a045 | ||
|
|
0ecae44888 | ||
|
|
a9c2a10fb5 | ||
|
|
e11094e5fa | ||
|
|
38913dc3e1 | ||
|
|
dd2b7932a2 | ||
|
|
2051e187ba | ||
|
|
ca817a8cc4 | ||
|
|
2d815f5902 | ||
|
|
0abdc647c9 | ||
|
|
fded2db73e | ||
|
|
2274c9faf5 | ||
|
|
280b236490 | ||
|
|
ef2c144cdd | ||
|
|
634cf0ff1b | ||
|
|
2dc3d5c169 | ||
|
|
fcad1fdfaa | ||
|
|
5c6cdfb5e1 | ||
|
|
1d6ba761a8 | ||
|
|
893ba6c8f4 | ||
|
|
a835eff14b | ||
|
|
029b4d8a6e | ||
|
|
0053b45691 | ||
|
|
f46812d1d2 | ||
|
|
8495df961b | ||
|
|
abc8be1077 | ||
|
|
84baf27f7e | ||
|
|
1a08d904f9 | ||
|
|
31ca9a95d7 | ||
|
|
ade91b26c3 | ||
|
|
d797957abc | ||
|
|
104ddddb96 | ||
|
|
c8c4c7fa00 | ||
|
|
3111a26229 | ||
|
|
26ef257e06 | ||
|
|
6864ea7b53 | ||
|
|
c2ecc15d89 | ||
|
|
9bbcc0952b | ||
|
|
179ec4d38b | ||
|
|
02a61cdf0d | ||
|
|
6a84b4e5aa | ||
|
|
497a9b9d58 | ||
|
|
c5972be618 | ||
|
|
43e77c4c6b | ||
|
|
d66985e597 | ||
|
|
ff4bed99c9 | ||
|
|
2b4c1b83bd | ||
|
|
f85aa8f604 | ||
|
|
e5ca3c4177 | ||
|
|
0f2f8208e3 | ||
|
|
ba17516814 | ||
|
|
c0979b69e2 | ||
|
|
4b5c33bb90 | ||
|
|
1ea4d53061 | ||
|
|
17b548e9b0 | ||
|
|
5755eb1f08 | ||
|
|
e2f15324d7 | ||
|
|
b0b0802a56 | ||
|
|
e14cc8b758 | ||
|
|
55c6a5058c | ||
|
|
52d5d01337 | ||
|
|
93ceff7f17 | ||
|
|
0a891cfd95 | ||
|
|
66adc6a354 | ||
|
|
e99f1c2ba0 | ||
|
|
f52a9face8 | ||
|
|
4fcf22131c | ||
|
|
d27324f8dd | ||
|
|
dd86a15555 | ||
|
|
28d173b8fd | ||
|
|
b4b7ea76ab | ||
|
|
6ea452cc3f | ||
|
|
6e0e965883 | ||
|
|
6b4b3ce2ba | ||
|
|
18cdbab885 | ||
|
|
ebca9b4caf | ||
|
|
6945ef8ddc | ||
|
|
f20bf03ee1 | ||
|
|
7cda15553d | ||
|
|
3c67fd5f9b | ||
|
|
0150931df4 | ||
|
|
5ff1b06009 | ||
|
|
5279bcae18 | ||
|
|
daa58e6b27 | ||
|
|
589d021744 | ||
|
|
e58b9c8ada | ||
|
|
507c28e006 | ||
|
|
2d74fe4057 | ||
|
|
e8312268d2 | ||
|
|
f4cd1e51c0 | ||
|
|
60e707e7df | ||
|
|
0d6eb4dac4 | ||
|
|
80d8f986bd | ||
|
|
9ee3bb9007 | ||
|
|
8a07010704 | ||
|
|
314fc8ac94 | ||
|
|
b46e5461a7 | ||
|
|
ada7c1797d | ||
|
|
54197995f5 | ||
|
|
13e510dd9c | ||
|
|
5c937fbffe | ||
|
|
58bce0ea19 | ||
|
|
3e888cc669 | ||
|
|
78446c74d3 | ||
|
|
51f08f193c | ||
|
|
4872374a6e | ||
|
|
81c1400ef4 | ||
|
|
298c1fb180 | ||
|
|
f8108bd724 | ||
|
|
65c40b287f | ||
|
|
13e50d4695 | ||
|
|
791cda23af | ||
|
|
466ea64e63 | ||
|
|
f5e6fcc097 | ||
|
|
9ef2e8d397 | ||
|
|
4637091125 | ||
|
|
43a8c80508 | ||
|
|
9362064ad1 | ||
|
|
23952aa3c5 | ||
|
|
79e19c85eb | ||
|
|
62d8299480 | ||
|
|
8f342ea2d3 | ||
|
|
5d5de06290 | ||
|
|
d7e5f398f0 | ||
|
|
5bf5316af5 | ||
|
|
d9fd6d8a8f | ||
|
|
e672eade8b | ||
|
|
ec346905ed | ||
|
|
c9cbbbfcb9 | ||
|
|
93739935b7 | ||
|
|
6a293e842e | ||
|
|
f4abb1d873 | ||
|
|
8f48701ea0 | ||
|
|
6f32c60c47 | ||
|
|
e040fcc0dd | ||
|
|
305089fcf6 | ||
|
|
f9c0b5df19 | ||
|
|
77fa57a2a6 | ||
|
|
dcb02dd194 | ||
|
|
35338dea64 | ||
|
|
c34df96839 | ||
|
|
0617163c42 | ||
|
|
47797ecd29 | ||
|
|
897d0c9e6d | ||
|
|
6c25d76135 | ||
|
|
22885a4857 | ||
|
|
a807cc8bd1 | ||
|
|
c2954b5663 | ||
|
|
8f97f42618 | ||
|
|
0a116ea3f4 | ||
|
|
aa7d0190c8 | ||
|
|
af5d0a0c91 | ||
|
|
fb016c6c6a | ||
|
|
77732445ea | ||
|
|
1b833f76ce | ||
|
|
b394cadf73 | ||
|
|
f3b6166daa | ||
|
|
ce720090ec | ||
|
|
bf2149bbeb | ||
|
|
80a7db0e54 | ||
|
|
47e6d56b21 | ||
|
|
df33293621 | ||
|
|
a202c53594 | ||
|
|
4f54e750b2 | ||
|
|
5478be60c1 | ||
|
|
3deb99f053 | ||
|
|
8df2069c6f | ||
|
|
d790c0ef75 | ||
|
|
fb4bf79841 | ||
|
|
1ee66450b1 | ||
|
|
643a672045 | ||
|
|
38fd7420ff | ||
|
|
da2bbf72a6 | ||
|
|
1f54f8136b | ||
|
|
fd30e2c026 | ||
|
|
7f9981bf31 | ||
|
|
4faf86fbbf | ||
|
|
d9e30d5fb4 | ||
|
|
41d43c2bb6 | ||
|
|
cb30dbb23c | ||
|
|
12dd67fbb5 | ||
|
|
364502244a |
No files matched your search
+31
-12
@@ -1,22 +1,36 @@
|
||||
# .gitea/workflows/deploy.yml
|
||||
name: Deploy mindnet to llm-node
|
||||
on: { push: { branches: [ "main" ] } }
|
||||
# on: {}
|
||||
|
||||
concurrency: { group: deploy-mindnet, cancel-in-progress: false }
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
|
||||
concurrency:
|
||||
group: deploy-mindnet
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: linux_host
|
||||
env:
|
||||
DEPLOY_DIRS: "app scripts schemas docker requirements.txt README.md"
|
||||
TARGET_BASE: "/home/llmadmin/mindnet"
|
||||
TARGET_BASE: /home/llmadmin/mindnet
|
||||
DEPLOY_DIRS: "app scripts schemas docker tests config requirements.txt README.md"
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
- name: Ensure target base
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Ensure target base exists
|
||||
run: install -d "$TARGET_BASE"
|
||||
- name: Deploy whitelisted
|
||||
|
||||
- name: Stop API (graceful)
|
||||
continue-on-error: true
|
||||
run: |
|
||||
if systemctl --user list-unit-files | grep -q '^mindnet-api.service'; then
|
||||
systemctl --user stop mindnet-api.service || true
|
||||
fi
|
||||
|
||||
- name: Deploy whitelisted (rsync)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
IFS=' ' read -r -a DIRS <<< "$DEPLOY_DIRS"
|
||||
@@ -24,22 +38,27 @@ jobs:
|
||||
if [ -e "$d" ]; then
|
||||
if [ -d "$d" ]; then
|
||||
install -d "$TARGET_BASE/$d"
|
||||
rsync -a --delete --exclude='.git' \
|
||||
--exclude='.env' --exclude='.env.*' --exclude='**/.env*' \
|
||||
rsync -a --delete \
|
||||
--exclude='.git' \
|
||||
--exclude='.env*' \
|
||||
--exclude='.venv' \
|
||||
--exclude='hf_cache' --exclude='hf_cache/**' \
|
||||
"$d"/ "$TARGET_BASE/$d"/
|
||||
else
|
||||
rsync -a "$d" "$TARGET_BASE/$d"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
- name: Python venv (idempotent)
|
||||
|
||||
- name: Python venv & requirements
|
||||
run: |
|
||||
cd "$TARGET_BASE"
|
||||
[ -d .venv ] || python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install --upgrade pip
|
||||
[ -f requirements.txt ] && pip install -r requirements.txt || true
|
||||
- name: Optional — restart mindnet-api
|
||||
|
||||
- name: Start/Restart mindnet-api
|
||||
continue-on-error: true
|
||||
run: |
|
||||
if systemctl --user list-unit-files | grep -q '^mindnet-api.service'; then
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
"""
|
||||
app — mindnet API package
|
||||
|
||||
Zweck:
|
||||
Markiert 'app/' als Python-Paket, damit 'from app.main import create_app'
|
||||
in Tests und Skripten funktioniert.
|
||||
Kompatibilität:
|
||||
Python 3.12+
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Hinweise:
|
||||
Keine Logik – nur Paketinitialisierung.
|
||||
"""
|
||||
|
||||
__version__ = "0.1.0"
|
||||
+17
-2
@@ -1,6 +1,14 @@
|
||||
"""
|
||||
Version 0.1
|
||||
app/config.py — zentrale Konfiguration (ENV → Settings)
|
||||
|
||||
Version:
|
||||
0.2.0 (WP-04: Retriever-Gewichte & Defaults ergänzt; keine Verhaltensänderung für bestehende Nutzung)
|
||||
Stand:
|
||||
2025-10-06
|
||||
Hinweis:
|
||||
Bestehende Attribute bleiben erhalten; neue WP-04 Felder sind optional.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
import os
|
||||
from functools import lru_cache
|
||||
@@ -16,7 +24,14 @@ class Settings:
|
||||
MODEL_NAME: str = os.getenv("MINDNET_MODEL", "sentence-transformers/all-MiniLM-L6-v2")
|
||||
# API
|
||||
DEBUG: bool = os.getenv("DEBUG", "false").lower() == "true"
|
||||
# WP-04 Retriever Defaults (optional; können per ENV überschrieben werden)
|
||||
RETRIEVER_W_SEM: float = float(os.getenv("MINDNET_WP04_W_SEM", "0.70"))
|
||||
RETRIEVER_W_EDGE: float = float(os.getenv("MINDNET_WP04_W_EDGE", "0.25"))
|
||||
RETRIEVER_W_CENT: float = float(os.getenv("MINDNET_WP04_W_CENT", "0.05"))
|
||||
RETRIEVER_TOP_K: int = int(os.getenv("MINDNET_WP04_TOP_K", "10"))
|
||||
RETRIEVER_EXPAND_DEPTH: int = int(os.getenv("MINDNET_WP04_EXPAND_DEPTH", "1"))
|
||||
RETRIEVER_EDGE_TYPES: str = os.getenv("MINDNET_WP04_EDGE_TYPES", "references,belongs_to,prev,next")
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
return Settings()
|
||||
return Settings()
|
||||
+176
-33
@@ -1,37 +1,180 @@
|
||||
# chunk_payload.py
|
||||
from __future__ import annotations
|
||||
from typing import Dict, List
|
||||
from .chunker import Chunk
|
||||
from .parser import extract_wikilinks
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
import os, json, pathlib, re, yaml, hashlib
|
||||
|
||||
FRONTMATTER_RE = re.compile(r"^---\s*\n.*?\n---\s*\n?", re.DOTALL)
|
||||
|
||||
def _as_dict(note: Any) -> Dict[str, Any]:
|
||||
if isinstance(note, dict):
|
||||
return note
|
||||
d: Dict[str, Any] = {}
|
||||
for attr in ("id","note_id","title","path","frontmatter","meta","metadata","body","text","content","raw","markdown","type","chunks"):
|
||||
if hasattr(note, attr):
|
||||
d[attr] = getattr(note, attr)
|
||||
fm = d.get("frontmatter") or d.get("meta") or d.get("metadata") or {}
|
||||
d["frontmatter"] = fm if isinstance(fm, dict) else {}
|
||||
return d
|
||||
|
||||
def _pick_args(*args, **kwargs) -> Tuple[Optional[str], Optional[Dict[str,Any]]]:
|
||||
path = kwargs.get("path")
|
||||
types_cfg = kwargs.get("types_config")
|
||||
for a in args:
|
||||
if path is None and isinstance(a, (str, pathlib.Path)):
|
||||
path = str(a)
|
||||
if types_cfg is None and isinstance(a, dict):
|
||||
types_cfg = a
|
||||
return path, types_cfg
|
||||
|
||||
def _load_types_config(explicit: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||
if isinstance(explicit, dict):
|
||||
return explicit
|
||||
for rel in ("config/config.yaml", "config/types.yaml"):
|
||||
p = pathlib.Path(rel)
|
||||
if p.exists():
|
||||
with p.open("r", encoding="utf-8") as f:
|
||||
data = yaml.safe_load(f) or {}
|
||||
if isinstance(data, dict) and "types" in data and isinstance(data["types"], dict):
|
||||
return data["types"]
|
||||
return data if isinstance(data, dict) else {}
|
||||
return {}
|
||||
|
||||
def _coalesce(*vals):
|
||||
for v in vals:
|
||||
if v is not None:
|
||||
return v
|
||||
return None
|
||||
|
||||
def _text_from_note(n: Dict[str, Any], path_hint: Optional[str]) -> str:
|
||||
# häufige Felder
|
||||
cand = [
|
||||
n.get("body"),
|
||||
n.get("text"),
|
||||
n.get("markdown"),
|
||||
n.get("raw"),
|
||||
]
|
||||
content = n.get("content")
|
||||
if isinstance(content, str):
|
||||
cand.append(content)
|
||||
elif isinstance(content, dict):
|
||||
for k in ("text","body","raw","markdown","content"):
|
||||
v = content.get(k)
|
||||
if isinstance(v, str):
|
||||
cand.append(v)
|
||||
for t in cand:
|
||||
if isinstance(t, str) and t.strip():
|
||||
return t
|
||||
|
||||
# Fallback: Datei lesen und Frontmatter entfernen
|
||||
p = n.get("path") or path_hint
|
||||
if p:
|
||||
try:
|
||||
pth = pathlib.Path(p)
|
||||
if pth.exists():
|
||||
txt = pth.read_text(encoding="utf-8", errors="ignore")
|
||||
if txt:
|
||||
return FRONTMATTER_RE.sub("", txt).strip()
|
||||
except Exception:
|
||||
pass
|
||||
return ""
|
||||
|
||||
def _iter_chunks(n: Dict[str, Any], profile: str, fulltext: str) -> List[Dict[str, Any]]:
|
||||
# 1) vorhandene Chunks nehmen, wenn sinnvoll
|
||||
existing = n.get("chunks")
|
||||
out: List[Dict[str, Any]] = []
|
||||
if isinstance(existing, list) and existing:
|
||||
for i, c in enumerate(existing):
|
||||
text = ""
|
||||
if isinstance(c, dict):
|
||||
text = c.get("text") or c.get("body") or c.get("raw") or ""
|
||||
elif isinstance(c, str):
|
||||
text = c
|
||||
if text and text.strip():
|
||||
out.append({"index": i, "text": text})
|
||||
if out:
|
||||
return out
|
||||
|
||||
# 2) Fallback: profilabhängige Bündelung
|
||||
if not isinstance(profile, str):
|
||||
profile = "medium"
|
||||
size = {"short": 600, "medium": 1200, "long": 2400}.get(profile, 1200)
|
||||
if not fulltext:
|
||||
return []
|
||||
paras = re.split(r"\n{2,}", fulltext)
|
||||
buf = ""
|
||||
chunks: List[str] = []
|
||||
for p in paras:
|
||||
p = (p or "").strip()
|
||||
if not p:
|
||||
continue
|
||||
if len(buf) + (2 if buf else 0) + len(p) <= size:
|
||||
buf = (buf + "\n\n" + p).strip() if buf else p
|
||||
else:
|
||||
if buf: chunks.append(buf)
|
||||
if len(p) <= size:
|
||||
buf = p
|
||||
else:
|
||||
for i in range(0, len(p), size):
|
||||
chunks.append(p[i:i+size])
|
||||
buf = ""
|
||||
if buf: chunks.append(buf)
|
||||
return [{"index": i, "text": c} for i, c in enumerate(chunks)]
|
||||
|
||||
def make_chunk_payloads(note: Any, *args, **kwargs) -> List[Dict[str, Any]]:
|
||||
n = _as_dict(note)
|
||||
path_arg, types_cfg_explicit = _pick_args(*args, **kwargs)
|
||||
types_cfg = _load_types_config(types_cfg_explicit)
|
||||
|
||||
fm = n.get("frontmatter") or {}
|
||||
note_type = str(fm.get("type") or n.get("type") or "note")
|
||||
cfg_for_type = types_cfg.get(note_type, {}) if isinstance(types_cfg, dict) else {}
|
||||
|
||||
try:
|
||||
default_rw = float(os.environ.get("MINDNET_DEFAULT_RETRIEVER_WEIGHT", 1.0))
|
||||
except Exception:
|
||||
default_rw = 1.0
|
||||
|
||||
retriever_weight = _coalesce(fm.get("retriever_weight"), cfg_for_type.get("retriever_weight"), default_rw)
|
||||
try:
|
||||
retriever_weight = float(retriever_weight)
|
||||
except Exception:
|
||||
retriever_weight = default_rw
|
||||
|
||||
chunk_profile = _coalesce(fm.get("chunk_profile"), cfg_for_type.get("chunk_profile"), os.environ.get("MINDNET_DEFAULT_CHUNK_PROFILE","medium"))
|
||||
chunk_profile = chunk_profile if isinstance(chunk_profile, str) else "medium"
|
||||
|
||||
note_id = n.get("note_id") or n.get("id") or fm.get("id")
|
||||
title = n.get("title") or fm.get("title") or ""
|
||||
path = n.get("path") or path_arg
|
||||
if isinstance(path, pathlib.Path):
|
||||
path = str(path)
|
||||
path = path or "" # immer vorhanden
|
||||
|
||||
fulltext = _text_from_note(n, path)
|
||||
chunks = _iter_chunks(n, chunk_profile, fulltext)
|
||||
|
||||
payloads: List[Dict[str, Any]] = []
|
||||
for c in chunks:
|
||||
idx = c.get("index", len(payloads))
|
||||
text = c.get("text") if isinstance(c, dict) else (str(c) if c is not None else "")
|
||||
text = text if isinstance(text, str) else str(text or "")
|
||||
|
||||
key = f"{note_id}|{idx}"
|
||||
h = hashlib.sha1(key.encode("utf-8")).hexdigest()[:12] if note_id else hashlib.sha1(f"{path}|{idx}".encode("utf-8")).hexdigest()[:12]
|
||||
chunk_id = f"{note_id}-{idx:03d}-{h}" if note_id else f"{h}"
|
||||
|
||||
def make_chunk_payloads(note_meta: Dict, path: str, chunks: List[Chunk]) -> List[Dict]:
|
||||
res = []
|
||||
for ch in chunks:
|
||||
wikilinks = extract_wikilinks(ch.text)
|
||||
payload = {
|
||||
"id": ch.id,
|
||||
"note_id": note_meta["id"],
|
||||
"note_title": note_meta["title"],
|
||||
"chunk_index": ch.index,
|
||||
"char_start": ch.char_start,
|
||||
"char_end": ch.char_end,
|
||||
"token_count": ch.token_count,
|
||||
"type": note_meta.get("type"),
|
||||
"area": note_meta.get("area"),
|
||||
"project": note_meta.get("project"),
|
||||
"tags": note_meta.get("tags", []),
|
||||
"section_title": ch.section_title,
|
||||
"section_path": ch.section_path,
|
||||
"lang": note_meta.get("lang"),
|
||||
"wikilinks": wikilinks,
|
||||
"external_links": [], # (optional später ergänzen)
|
||||
"references": [{"target_id": w, "kind": "wikilink"} for w in wikilinks],
|
||||
"neighbors": {
|
||||
"prev": ch.neighbors_prev,
|
||||
"next": ch.neighbors_next
|
||||
},
|
||||
"path": path,
|
||||
"note_id": note_id,
|
||||
"chunk_id": chunk_id,
|
||||
"index": idx,
|
||||
"title": title,
|
||||
"type": note_type,
|
||||
"path": path, # <- garantiert vorhanden
|
||||
"text": text, # <- nie leer, sonst werden keine Chunks erzeugt
|
||||
"retriever_weight": retriever_weight,
|
||||
"chunk_profile": chunk_profile,
|
||||
}
|
||||
# None/Leere bereinigen
|
||||
payload = {k: v for k, v in payload.items() if v not in (None, [], {})}
|
||||
res.append(payload)
|
||||
return res
|
||||
json.loads(json.dumps(payload, ensure_ascii=False))
|
||||
payloads.append(payload)
|
||||
|
||||
return payloads
|
||||
+121
-85
@@ -1,95 +1,131 @@
|
||||
# app/core/derive_edges.py
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Modul: app/core/derive_edges.py
|
||||
Version: 1.4.0
|
||||
Datum: 2025-10-01
|
||||
|
||||
Zweck
|
||||
-----
|
||||
Robuste Kantenbildung für mindnet (Notes/Chunks):
|
||||
- belongs_to (chunk -> note)
|
||||
- next / prev (chunk-Kette)
|
||||
- references (chunk-scope) aus Chunk.window/text
|
||||
- optional references/backlink (note-scope)
|
||||
|
||||
Wichtig: Wikilinks werden mit der Parser-Funktion `extract_wikilinks` extrahiert,
|
||||
damit Varianten wie [[id#anchor]] oder [[id|label]] korrekt auf 'id' reduziert werden.
|
||||
|
||||
Erwartete Chunk-Payload-Felder:
|
||||
{
|
||||
"note_id": "...",
|
||||
"chunk_id": "...", # Alias "id" ist zulässig
|
||||
"id": "...",
|
||||
"chunk_index": int,
|
||||
"seq": int,
|
||||
"window": str,
|
||||
"text": str,
|
||||
"path": "rel/path.md",
|
||||
...
|
||||
}
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import re
|
||||
import unicodedata
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
# [[Ziel]], [[Ziel|Alias]], [[Ziel#Heading]], [[Ziel#Heading|Alias]]
|
||||
WIKILINK_RE = re.compile(r"\[\[([^\]|#]+)(?:#([^\]|]+))?(?:\|([^\]]+))?\]\]")
|
||||
from typing import Dict, List, Optional, Iterable
|
||||
|
||||
def _slug(s: str) -> str:
|
||||
s = s.strip()
|
||||
if s.endswith(".md"):
|
||||
s = s[:-3]
|
||||
s = unicodedata.normalize("NFKD", s)
|
||||
s = "".join(ch for ch in s if not unicodedata.combining(ch))
|
||||
s = s.replace("\\", "/")
|
||||
s = s.split("/")[-1]
|
||||
s = s.lower().replace(" ", "-")
|
||||
s = re.sub(r"[^a-z0-9\-]+", "", s)
|
||||
s = re.sub(r"-{2,}", "-", s).strip("-")
|
||||
return s
|
||||
# WICHTIG: benutze die Parser-Extraktion für saubere Wikilinks
|
||||
from app.core.parser import extract_wikilinks
|
||||
|
||||
def build_note_index(notes_payloads: List[dict]) -> Tuple[Dict[str, dict], Dict[str, dict], Dict[str, dict]]:
|
||||
by_id: Dict[str, dict] = {}
|
||||
by_slug: Dict[str, dict] = {}
|
||||
by_file_slug: Dict[str, dict] = {}
|
||||
for n in notes_payloads:
|
||||
nid = n.get("note_id") or n.get("id")
|
||||
if not nid:
|
||||
continue
|
||||
by_id[nid] = n
|
||||
title = n.get("title", "")
|
||||
path = n.get("path", "")
|
||||
file_slug = _slug(path.split("/")[-1]) if path else ""
|
||||
if title:
|
||||
by_slug[_slug(title)] = n
|
||||
if file_slug:
|
||||
by_file_slug[file_slug] = n
|
||||
return by_id, by_slug, by_file_slug
|
||||
def _get(d: dict, *keys, default=None):
|
||||
for k in keys:
|
||||
if k in d and d[k] is not None:
|
||||
return d[k]
|
||||
return default
|
||||
|
||||
def resolve_target(note_like: str, idx: Tuple[Dict[str,dict],Dict[str,dict],Dict[str,dict]]):
|
||||
by_id, by_slug, by_file_slug = idx
|
||||
key = note_like.strip()
|
||||
if key in by_id:
|
||||
return by_id[key]["note_id"], "by_id"
|
||||
s = _slug(key)
|
||||
if s in by_slug:
|
||||
return by_slug[s]["note_id"], "by_slug"
|
||||
if s in by_file_slug:
|
||||
return by_file_slug[s]["note_id"], "by_file_slug"
|
||||
return None, "unresolved"
|
||||
def _chunk_text_for_refs(chunk: dict) -> str:
|
||||
# bevorzugt 'window' → dann 'text' → 'content' → 'raw'
|
||||
return (
|
||||
_get(chunk, "window")
|
||||
or _get(chunk, "text")
|
||||
or _get(chunk, "content")
|
||||
or _get(chunk, "raw")
|
||||
or ""
|
||||
)
|
||||
|
||||
def derive_wikilink_edges(note_payload: dict, chunks_payloads: List[dict], note_index) -> List[dict]:
|
||||
def _dedupe(seq: Iterable[str]) -> List[str]:
|
||||
seen = set()
|
||||
out: List[str] = []
|
||||
for s in seq:
|
||||
if s not in seen:
|
||||
seen.add(s)
|
||||
out.append(s)
|
||||
return out
|
||||
|
||||
def _edge(kind: str, scope: str, source_id: str, target_id: str, note_id: str, extra: Optional[dict] = None) -> dict:
|
||||
pl = {
|
||||
"kind": kind,
|
||||
"scope": scope, # "chunk" | "note"
|
||||
"source_id": source_id,
|
||||
"target_id": target_id,
|
||||
"note_id": note_id, # Träger/Quelle der Kante (aktuelle Note)
|
||||
}
|
||||
if extra:
|
||||
pl.update(extra)
|
||||
return pl
|
||||
|
||||
def build_edges_for_note(
|
||||
note_id: str,
|
||||
chunks: List[dict],
|
||||
note_level_references: Optional[List[str]] = None,
|
||||
include_note_scope_refs: bool = False,
|
||||
) -> List[dict]:
|
||||
"""
|
||||
Erzeugt Kanten für eine Note.
|
||||
|
||||
- belongs_to: für jeden Chunk (chunk -> note)
|
||||
- next / prev: zwischen aufeinanderfolgenden Chunks
|
||||
- references: pro Chunk aus window/text
|
||||
- optional note-scope references/backlinks: dedupliziert über alle Chunk-Funde + note_level_references
|
||||
"""
|
||||
edges: List[dict] = []
|
||||
source_note_id = note_payload["note_id"]
|
||||
|
||||
def _make_edge(kind: str, src: str, tgt: str, seq=None, extra: dict|None=None):
|
||||
e = {"edge_id": None, "kind": kind, "source_id": src, "target_id": tgt}
|
||||
if seq is not None:
|
||||
e["seq"] = seq
|
||||
if extra:
|
||||
e.update(extra)
|
||||
return e
|
||||
|
||||
# Links im Volltext (falls vorhanden)
|
||||
fulltext = note_payload.get("fulltext") or note_payload.get("body") or ""
|
||||
if fulltext:
|
||||
for m in WIKILINK_RE.finditer(fulltext):
|
||||
raw_target, heading, alias = m.groups()
|
||||
target_id, how = resolve_target(raw_target, note_index)
|
||||
extra = {"raw": raw_target, "alias": alias, "heading": heading, "resolution": how}
|
||||
if target_id:
|
||||
edges.append(_make_edge("references", source_note_id, target_id, extra=extra))
|
||||
edges.append(_make_edge("backlink", target_id, source_note_id, extra=extra))
|
||||
else:
|
||||
extra["status"] = "unresolved"
|
||||
extra["target_label"] = raw_target
|
||||
edges.append(_make_edge("references", source_note_id, raw_target, extra=extra))
|
||||
|
||||
# Links in Chunks (wenn übergeben)
|
||||
for i, ch in enumerate(chunks_payloads, start=1):
|
||||
txt = ch.get("text") or ch.get("content") or ""
|
||||
if not txt:
|
||||
# belongs_to
|
||||
for ch in chunks:
|
||||
cid = _get(ch, "chunk_id", "id")
|
||||
if not cid:
|
||||
continue
|
||||
for m in WIKILINK_RE.finditer(txt):
|
||||
raw_target, heading, alias = m.groups()
|
||||
target_id, how = resolve_target(raw_target, note_index)
|
||||
extra = {"raw": raw_target, "alias": alias, "heading": heading, "resolution": how}
|
||||
if target_id:
|
||||
edges.append(_make_edge("references_at", ch["chunk_id"], target_id, seq=i, extra=extra))
|
||||
else:
|
||||
extra["status"] = "unresolved"
|
||||
extra["target_label"] = raw_target
|
||||
edges.append(_make_edge("references_at", ch["chunk_id"], raw_target, seq=i, extra=extra))
|
||||
edges.append(_edge("belongs_to", "chunk", cid, note_id, note_id, {"chunk_id": cid}))
|
||||
|
||||
# next/prev
|
||||
for i in range(len(chunks) - 1):
|
||||
a, b = chunks[i], chunks[i + 1]
|
||||
a_id = _get(a, "chunk_id", "id")
|
||||
b_id = _get(b, "chunk_id", "id")
|
||||
if not a_id or not b_id:
|
||||
continue
|
||||
edges.append(_edge("next", "chunk", a_id, b_id, note_id, {"chunk_id": a_id}))
|
||||
edges.append(_edge("prev", "chunk", b_id, a_id, note_id, {"chunk_id": b_id}))
|
||||
|
||||
# references (chunk-scope) – Links aus window bevorzugen (Overlap-fest)
|
||||
refs_all: List[str] = []
|
||||
for ch in chunks:
|
||||
cid = _get(ch, "chunk_id", "id")
|
||||
if not cid:
|
||||
continue
|
||||
txt = _chunk_text_for_refs(ch)
|
||||
refs = extract_wikilinks(txt) # <— Parser-Logik, kompatibel zu deinem System
|
||||
for r in refs:
|
||||
edges.append(_edge("references", "chunk", cid, r, note_id, {"chunk_id": cid, "ref_text": r}))
|
||||
refs_all.extend(refs)
|
||||
|
||||
# optional: note-scope references/backlinks
|
||||
if include_note_scope_refs:
|
||||
refs_note = refs_all[:]
|
||||
if note_level_references:
|
||||
refs_note.extend([r for r in note_level_references if isinstance(r, str) and r])
|
||||
refs_note = _dedupe(refs_note)
|
||||
for r in refs_note:
|
||||
edges.append(_edge("references", "note", note_id, r, note_id))
|
||||
edges.append(_edge("backlink", "note", r, note_id, note_id))
|
||||
|
||||
return edges
|
||||
+108
-33
@@ -1,45 +1,120 @@
|
||||
from __future__ import annotations
|
||||
from typing import List, Dict
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Modul: app/core/edges.py
|
||||
Version: 1.0.0
|
||||
Datum: 2025-09-09
|
||||
|
||||
def deriv_edges_for_note(note_meta: Dict, chunk_payloads: List[Dict]) -> List[Dict]:
|
||||
Zweck
|
||||
-----
|
||||
Zentrale, konsistente Erzeugung von Edge-Payloads im **neuen Schema**:
|
||||
- kind : "belongs_to" | "next" | "prev" | "references" | "backlink"
|
||||
- source_id : ID des Quellknotens (Chunk- oder Note-ID)
|
||||
- target_id : ID des Zielknotens
|
||||
- scope : "chunk" | "note"
|
||||
- note_id : Owner-Note (für performantes Filtern/Löschen)
|
||||
- seq : optional (z. B. Reihenfolge von Vorkommen)
|
||||
|
||||
Hinweise
|
||||
--------
|
||||
- Edges werden dedupliziert (key=(kind,source_id,target_id,scope)).
|
||||
- Für Chunk-Edges wird `note_id` aus dem Chunk-Payload entnommen.
|
||||
- Für Note-Scope-Edges ist `note_id` die Quell-Note-ID.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import Dict, List
|
||||
|
||||
def build_edges_for_note(
|
||||
note_id: str,
|
||||
chunk_payloads: List[Dict],
|
||||
note_level_refs: List[str] | None,
|
||||
*,
|
||||
include_note_scope_refs: bool = False,
|
||||
) -> List[Dict]:
|
||||
edges: List[Dict] = []
|
||||
|
||||
# Chunk → Note (belongs_to) + prev/next
|
||||
for idx, ch in enumerate(chunk_payloads):
|
||||
# Chunk-Scope: belongs_to / prev / next / references
|
||||
for ch in chunk_payloads:
|
||||
cid = ch["id"]
|
||||
owner = ch.get("note_id") or note_id
|
||||
# belongs_to
|
||||
edges.append({
|
||||
"src_id": ch["id"], "dst_id": note_meta["id"],
|
||||
"edge_type": "belongs_to", "scope": "chunk"
|
||||
"kind": "belongs_to",
|
||||
"source_id": cid,
|
||||
"target_id": note_id,
|
||||
"scope": "chunk",
|
||||
"note_id": owner,
|
||||
})
|
||||
prev_id = ch.get("neighbors",{}).get("prev")
|
||||
next_id = ch.get("neighbors",{}).get("next")
|
||||
# Nachbarn
|
||||
nb = ch.get("neighbors") or {}
|
||||
prev_id = nb.get("prev")
|
||||
next_id = nb.get("next")
|
||||
if prev_id:
|
||||
edges.append({"src_id": ch["id"], "dst_id": prev_id, "edge_type": "next", "scope": "chunk"})
|
||||
edges.append({"src_id": prev_id, "dst_id": ch["id"], "edge_type": "prev", "scope": "chunk"})
|
||||
edges.append({
|
||||
"kind": "prev",
|
||||
"source_id": cid,
|
||||
"target_id": prev_id,
|
||||
"scope": "chunk",
|
||||
"note_id": owner,
|
||||
})
|
||||
edges.append({
|
||||
"kind": "next",
|
||||
"source_id": prev_id,
|
||||
"target_id": cid,
|
||||
"scope": "chunk",
|
||||
"note_id": owner,
|
||||
})
|
||||
if next_id:
|
||||
edges.append({"src_id": ch["id"], "dst_id": next_id, "edge_type": "next", "scope": "chunk"})
|
||||
edges.append({"src_id": next_id, "dst_id": ch["id"], "edge_type": "prev", "scope": "chunk"})
|
||||
|
||||
# references aus wikilinks (Chunk-Scope)
|
||||
for ref in ch.get("references", []):
|
||||
edges.append({
|
||||
"kind": "next",
|
||||
"source_id": cid,
|
||||
"target_id": next_id,
|
||||
"scope": "chunk",
|
||||
"note_id": owner,
|
||||
})
|
||||
edges.append({
|
||||
"kind": "prev",
|
||||
"source_id": next_id,
|
||||
"target_id": cid,
|
||||
"scope": "chunk",
|
||||
"note_id": owner,
|
||||
})
|
||||
# references aus Chunk
|
||||
for ref in (ch.get("references") or []):
|
||||
tid = ref.get("target_id")
|
||||
if not tid: continue
|
||||
edges.append({"src_id": ch["id"], "dst_id": tid, "edge_type": "references", "scope": "chunk"})
|
||||
edges.append({"src_id": tid, "dst_id": ch["id"], "edge_type": "backlink", "scope": "chunk"})
|
||||
if not tid:
|
||||
continue
|
||||
edges.append({
|
||||
"kind": "references",
|
||||
"source_id": cid,
|
||||
"target_id": tid,
|
||||
"scope": "chunk",
|
||||
"note_id": owner,
|
||||
})
|
||||
|
||||
# depends_on / assigned_to (Note-Scope, aus Frontmatter)
|
||||
for dep in note_meta.get("depends_on", []) or []:
|
||||
edges.append({"src_id": note_meta["id"], "dst_id": dep, "edge_type": "depends_on", "scope": "note"})
|
||||
for ass in note_meta.get("assigned_to", []) or []:
|
||||
edges.append({"src_id": note_meta["id"], "dst_id": ass, "edge_type": "assigned_to", "scope": "note"})
|
||||
|
||||
# Note-Level references (optional: falls du im Note-Payload `references` sammelst)
|
||||
for tid in note_meta.get("references", []) or []:
|
||||
edges.append({"src_id": note_meta["id"], "dst_id": tid, "edge_type": "references", "scope": "note"})
|
||||
edges.append({"src_id": tid, "dst_id": note_meta["id"], "edge_type": "backlink", "scope": "note"})
|
||||
# Note-Scope: backlink (immer); references (optional)
|
||||
unique_refs = list(dict.fromkeys(note_level_refs or []))
|
||||
for tid in unique_refs:
|
||||
if include_note_scope_refs:
|
||||
edges.append({
|
||||
"kind": "references",
|
||||
"source_id": note_id,
|
||||
"target_id": tid,
|
||||
"scope": "note",
|
||||
"note_id": note_id,
|
||||
})
|
||||
edges.append({
|
||||
"kind": "backlink",
|
||||
"source_id": tid,
|
||||
"target_id": note_id,
|
||||
"scope": "note",
|
||||
"note_id": note_id,
|
||||
})
|
||||
|
||||
# Dedupe
|
||||
uniq = {}
|
||||
dedup = {}
|
||||
for e in edges:
|
||||
k = (e["src_id"], e["edge_type"], e["dst_id"], e.get("scope","note"))
|
||||
uniq[k] = e
|
||||
return list(uniq.values())
|
||||
k = (e["kind"], e["source_id"], e["target_id"], e.get("scope", ""))
|
||||
dedup[k] = e
|
||||
return list(dedup.values())
|
||||
@@ -0,0 +1,94 @@
|
||||
# app/core/edges_writer.py
|
||||
from __future__ import annotations
|
||||
import hashlib
|
||||
from typing import Dict, List, Iterable, Tuple
|
||||
|
||||
try:
|
||||
# Dein Modul mit der Schemadefinition und der Builder-Funktion
|
||||
from app.core.edges import build_edges_for_note # noqa: F401
|
||||
except Exception as e:
|
||||
raise RuntimeError("Konnte app.core.edges nicht importieren. "
|
||||
"Bitte sicherstellen, dass app/core/edges.py vorhanden ist.") from e
|
||||
|
||||
def _edge_uid(kind: str, source_id: str, target_id: str, scope: str) -> str:
|
||||
"""
|
||||
Deterministische, kurze ID für eine Edge.
|
||||
Kollisionen sind praktisch ausgeschlossen (BLAKE2s über den Kanonischen Schlüssel).
|
||||
"""
|
||||
key = f"{kind}|{source_id}|{target_id}|{scope}"
|
||||
return hashlib.blake2s(key.encode("utf-8"), digest_size=12).hexdigest()
|
||||
|
||||
def ensure_edges_collection(qdrant_client, collection: str) -> None:
|
||||
"""
|
||||
Legt die Edge-Collection an, falls sie nicht existiert.
|
||||
Minimal: 1D-Vector (Dummy), Cosine. Payload-only-Collections sind je nach Qdrant-Version heikel.
|
||||
"""
|
||||
from qdrant_client.http import models as qm
|
||||
|
||||
existing = [c.name for c in qdrant_client.get_collections().collections]
|
||||
if collection in existing:
|
||||
return
|
||||
|
||||
qdrant_client.recreate_collection(
|
||||
collection_name=collection,
|
||||
vectors_config=qm.VectorParams(size=1, distance=qm.Distance.COSINE),
|
||||
on_disk_payload=True,
|
||||
)
|
||||
|
||||
def edges_from_note(
|
||||
note_id: str,
|
||||
chunk_payloads: List[Dict],
|
||||
note_level_refs: Iterable[str] | None,
|
||||
*,
|
||||
include_note_scope_refs: bool = False,
|
||||
) -> List[Dict]:
|
||||
"""
|
||||
Ruft deinen Edge-Builder auf und gibt die (deduplizierten) Edge-Payloads zurück.
|
||||
Keine Schemaänderung – exakt das aus app/core/edges.py.
|
||||
"""
|
||||
return build_edges_for_note(
|
||||
note_id=note_id,
|
||||
chunk_payloads=chunk_payloads,
|
||||
note_level_refs=list(note_level_refs or []),
|
||||
include_note_scope_refs=include_note_scope_refs,
|
||||
)
|
||||
|
||||
def upsert_edges(
|
||||
qdrant_client,
|
||||
collection: str,
|
||||
edge_payloads: List[Dict],
|
||||
) -> Tuple[int, int]:
|
||||
"""
|
||||
Schreibt Edges als Points in Qdrant.
|
||||
- id: deterministisch aus (kind, source_id, target_id, scope)
|
||||
- vector: [0.0] Dummy
|
||||
- payload: Edge-Dict (unverändert, siehe Schema in app/core/edges.py)
|
||||
Gibt (anzahl_points, anzahl_unique_keys) zurück.
|
||||
"""
|
||||
from qdrant_client.models import PointStruct
|
||||
|
||||
if not edge_payloads:
|
||||
return 0, 0
|
||||
|
||||
points = []
|
||||
seen = set()
|
||||
for e in edge_payloads:
|
||||
key = (e.get("kind"), e.get("source_id"), e.get("target_id"), e.get("scope"))
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
eid = _edge_uid(*key)
|
||||
points.append(
|
||||
PointStruct(
|
||||
id=eid,
|
||||
vector=[0.0],
|
||||
payload=e,
|
||||
)
|
||||
)
|
||||
|
||||
if not points:
|
||||
return 0, 0
|
||||
|
||||
ensure_edges_collection(qdrant_client, collection)
|
||||
qdrant_client.upsert(collection_name=collection, points=points)
|
||||
return len(points), len(seen)
|
||||
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Datei: app/core/env_vars.py
|
||||
Version: 1.1.0 (2025-11-08)
|
||||
|
||||
Zweck
|
||||
Einheitliche Auflösung von ENV-Variablen (Prefix, Qdrant, Embeddings, Hashing)
|
||||
mit Abwärtskompatibilität.
|
||||
|
||||
Grundsatz
|
||||
- Für Qdrant-Funktionen ist 'COLLECTION_PREFIX' der Primärschlüssel.
|
||||
- 'MINDNET_PREFIX' bleibt für App-/UI-/Exporter-Kontexte nutzbar.
|
||||
- Fallbacks sorgen dafür, dass ältere Umgebungen weiter funktionieren.
|
||||
|
||||
Wichtig
|
||||
- Lädt optional eine .env (wenn python-dotenv verfügbar ist).
|
||||
- Überschreibt keine bereits gesetzten OS-Variablen (override=False).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Optional, Dict
|
||||
|
||||
# Optional: .env automatisch laden (ohne Hard-Fail, falls nicht vorhanden)
|
||||
try:
|
||||
from dotenv import load_dotenv, find_dotenv # type: ignore
|
||||
_p = find_dotenv()
|
||||
if _p:
|
||||
load_dotenv(_p, override=False)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# -------- Prefix-Auflösung --------
|
||||
|
||||
def get_collection_prefix(cli_override: Optional[str] = None) -> str:
|
||||
"""
|
||||
Für Qdrant-relevante Funktionen:
|
||||
1) CLI-Override (--prefix)
|
||||
2) ENV COLLECTION_PREFIX
|
||||
3) ENV MINDNET_PREFIX (Fallback)
|
||||
4) 'mindnet' (Default)
|
||||
"""
|
||||
if cli_override and str(cli_override).strip():
|
||||
return str(cli_override).strip()
|
||||
return (
|
||||
os.getenv("COLLECTION_PREFIX")
|
||||
or os.getenv("MINDNET_PREFIX")
|
||||
or "mindnet"
|
||||
)
|
||||
|
||||
def get_mindnet_prefix(cli_override: Optional[str] = None) -> str:
|
||||
"""
|
||||
Für App-/UI-/Exporter-Kontexte:
|
||||
1) CLI-Override (--prefix)
|
||||
2) ENV MINDNET_PREFIX
|
||||
3) ENV COLLECTION_PREFIX (Fallback)
|
||||
4) 'mindnet'
|
||||
"""
|
||||
if cli_override and str(cli_override).strip():
|
||||
return str(cli_override).strip()
|
||||
return (
|
||||
os.getenv("MINDNET_PREFIX")
|
||||
or os.getenv("COLLECTION_PREFIX")
|
||||
or "mindnet"
|
||||
)
|
||||
|
||||
def get_prefix(cli_override: Optional[str] = None, target: str = "qdrant") -> str:
|
||||
"""
|
||||
Universelle Hülle (abwärtskompatibel):
|
||||
target='qdrant' -> get_collection_prefix
|
||||
target='app' -> get_mindnet_prefix
|
||||
"""
|
||||
if target.lower() == "app":
|
||||
return get_mindnet_prefix(cli_override)
|
||||
return get_collection_prefix(cli_override)
|
||||
|
||||
# -------- Qdrant / Embeddings / Hashing --------
|
||||
|
||||
def get_qdrant_url(default: str = "http://127.0.0.1:6333") -> str:
|
||||
return os.getenv("QDRANT_URL", default)
|
||||
|
||||
def get_qdrant_api_key(default: str = "") -> str:
|
||||
return os.getenv("QDRANT_API_KEY", default)
|
||||
|
||||
def get_vector_dim(default: int = 384) -> int:
|
||||
try:
|
||||
return int(os.getenv("VECTOR_DIM", str(default)))
|
||||
except Exception:
|
||||
return default
|
||||
|
||||
def get_embed_url(default: Optional[str] = None) -> Optional[str]:
|
||||
return os.getenv("EMBED_URL", default)
|
||||
|
||||
def get_hash_env() -> Dict[str, str]:
|
||||
"""
|
||||
Liefert die Hash-Konfiguration (nur Aggregation; die Auswertung bleibt in den Skripten).
|
||||
"""
|
||||
return {
|
||||
"MINDNET_HASH_COMPARE": os.getenv("MINDNET_HASH_COMPARE", ""),
|
||||
"MINDNET_HASH_SOURCE": os.getenv("MINDNET_HASH_SOURCE", ""),
|
||||
"MINDNET_HASH_NORMALIZE": os.getenv("MINDNET_HASH_NORMALIZE", ""),
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
"""
|
||||
app/core/graph_adapter.py — Adjazenzaufbau & Subgraph-Expansion (WP-04)
|
||||
|
||||
Zweck:
|
||||
Baut aus Qdrant-Edges (Collection: *_edges) einen leichten In-Memory-Graph
|
||||
und liefert Edge-basierte Kennzahlen (In-Degree, Out-Degree, edge_bonus).
|
||||
Kompatibilität:
|
||||
Python 3.12+, qdrant-client 1.x
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
- WP-04 Edge-Gewichtungen und Heuristiken
|
||||
- app/core/qdrant_points.py (get_edges_for_sources)
|
||||
Nutzung:
|
||||
from app.core.graph_adapter import expand
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import Dict, List, Optional, DefaultDict
|
||||
from collections import defaultdict
|
||||
from qdrant_client import QdrantClient
|
||||
from app.core.qdrant_points import get_edges_for_sources
|
||||
|
||||
EDGE_BASE_WEIGHTS = {
|
||||
"references": 0.20,
|
||||
"belongs_to": 0.10,
|
||||
"next": 0.06,
|
||||
"prev": 0.06,
|
||||
"backlink": 0.04,
|
||||
"references_at": 0.08,
|
||||
}
|
||||
|
||||
|
||||
class Subgraph:
|
||||
"""Leichtgewichtiger Subgraph mit Adjazenzlisten & einfachen Kennzahlen."""
|
||||
|
||||
def __init__(self):
|
||||
self.adj: DefaultDict[str, List[Dict]] = defaultdict(list)
|
||||
self.in_degree: DefaultDict[str, int] = defaultdict(int)
|
||||
self.out_degree: DefaultDict[str, int] = defaultdict(int)
|
||||
|
||||
def add_edge(self, e: Dict):
|
||||
src = e["source"]; tgt = e["target"]; kind = e["kind"]
|
||||
weight = e.get("weight", EDGE_BASE_WEIGHTS.get(kind, 0.0))
|
||||
self.adj[src].append({"target": tgt, "kind": kind, "weight": weight})
|
||||
self.out_degree[src] += 1
|
||||
self.in_degree[tgt] += 1
|
||||
|
||||
def aggregate_edge_bonus(self, node_id: str) -> float:
|
||||
return sum(edge["weight"] for edge in self.adj.get(node_id, []))
|
||||
|
||||
def centrality_bonus(self, node_id: str) -> float:
|
||||
import math
|
||||
# Log-gedämpfter Bonus, hart begrenzt
|
||||
return min(math.log1p(self.in_degree.get(node_id, 0)) / 10.0, 0.15)
|
||||
|
||||
|
||||
def expand(client: QdrantClient, prefix: str, seeds: List[str],
|
||||
depth: int = 1, edge_types: Optional[List[str]] = None) -> Subgraph:
|
||||
"""
|
||||
Expandiert ab Seeds entlang von Edges (bis depth), optional gefiltert nach Typen.
|
||||
Seeds sind stabile payload-IDs (z. B. note_id, chunk_id).
|
||||
"""
|
||||
sg = Subgraph()
|
||||
frontier = set(seeds)
|
||||
visited = set()
|
||||
|
||||
for _ in range(max(depth, 0)):
|
||||
if not frontier:
|
||||
break
|
||||
|
||||
edges = get_edges_for_sources(client, prefix, list(frontier), edge_types=edge_types, limit=2048)
|
||||
next_frontier = set()
|
||||
for pl in edges:
|
||||
e = {
|
||||
"source": pl.get("source_id"),
|
||||
"target": pl.get("target_id"),
|
||||
"kind": pl.get("kind", "edge"),
|
||||
"weight": pl.get("weight", EDGE_BASE_WEIGHTS.get(pl.get("kind", "edge"), 0.0)),
|
||||
}
|
||||
sg.add_edge(e)
|
||||
if e["target"]:
|
||||
next_frontier.add(e["target"])
|
||||
|
||||
visited |= frontier
|
||||
frontier = next_frontier - visited
|
||||
|
||||
return sg
|
||||
+98
-33
@@ -1,39 +1,104 @@
|
||||
# note_payload.py
|
||||
from __future__ import annotations
|
||||
import os
|
||||
import hashlib
|
||||
from typing import Dict
|
||||
from .parser import ParsedNote
|
||||
from .parser import extract_wikilinks
|
||||
from typing import Any, Dict, Optional, Tuple
|
||||
import os, json, pathlib, yaml
|
||||
|
||||
def sha256_text(text: str) -> str:
|
||||
h = hashlib.sha256()
|
||||
h.update(text.encode("utf-8"))
|
||||
return h.hexdigest()
|
||||
def _as_dict(note: Any) -> Dict[str, Any]:
|
||||
if isinstance(note, dict):
|
||||
return note
|
||||
d: Dict[str, Any] = {}
|
||||
for attr in ("id","note_id","title","path","frontmatter","meta","metadata","type","created","modified","date","tags"):
|
||||
if hasattr(note, attr):
|
||||
d[attr] = getattr(note, attr)
|
||||
# Normalisiere Frontmatter
|
||||
fm = d.get("frontmatter") or d.get("meta") or d.get("metadata") or {}
|
||||
d["frontmatter"] = fm if isinstance(fm, dict) else {}
|
||||
return d
|
||||
|
||||
def make_note_payload(parsed: ParsedNote, vault_root: str) -> Dict:
|
||||
fm = parsed.frontmatter
|
||||
body = parsed.body
|
||||
rel_path = os.path.relpath(parsed.path, vault_root) if vault_root else parsed.path
|
||||
def _pick_args(*args, **kwargs) -> Tuple[Optional[str], Optional[Dict[str,Any]]]:
|
||||
path = kwargs.get("path")
|
||||
types_cfg = kwargs.get("types_config")
|
||||
# legacy positional: (path, types_config) oder (types_config, ...)
|
||||
for a in args:
|
||||
if path is None and isinstance(a, (str, pathlib.Path)):
|
||||
path = str(a)
|
||||
if types_cfg is None and isinstance(a, dict):
|
||||
types_cfg = a
|
||||
return path, types_cfg
|
||||
|
||||
def _load_types_config(explicit: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||
if isinstance(explicit, dict):
|
||||
return explicit
|
||||
for rel in ("config/config.yaml", "config/types.yaml"):
|
||||
p = pathlib.Path(rel)
|
||||
if p.exists():
|
||||
with p.open("r", encoding="utf-8") as f:
|
||||
data = yaml.safe_load(f) or {}
|
||||
if isinstance(data, dict) and "types" in data and isinstance(data["types"], dict):
|
||||
return data["types"]
|
||||
return data if isinstance(data, dict) else {}
|
||||
return {}
|
||||
|
||||
def _coalesce(*vals):
|
||||
for v in vals:
|
||||
if v is not None:
|
||||
return v
|
||||
return None
|
||||
|
||||
def _env_float(name: str, default: float) -> float:
|
||||
try:
|
||||
return float(os.environ.get(name, default))
|
||||
except Exception:
|
||||
return default
|
||||
|
||||
def _ensure_list(x) -> list:
|
||||
if x is None: return []
|
||||
if isinstance(x, list): return [str(i) for i in x]
|
||||
if isinstance(x, (set, tuple)): return [str(i) for i in x]
|
||||
return [str(x)]
|
||||
|
||||
def make_note_payload(note: Any, *args, **kwargs) -> Dict[str, Any]:
|
||||
n = _as_dict(note)
|
||||
path_arg, types_cfg_explicit = _pick_args(*args, **kwargs)
|
||||
types_cfg = _load_types_config(types_cfg_explicit)
|
||||
|
||||
fm = n.get("frontmatter") or {}
|
||||
note_type = str(fm.get("type") or n.get("type") or "note")
|
||||
cfg_for_type = types_cfg.get(note_type, {}) if isinstance(types_cfg, dict) else {}
|
||||
|
||||
default_rw = _env_float("MINDNET_DEFAULT_RETRIEVER_WEIGHT", 1.0)
|
||||
retriever_weight = _coalesce(fm.get("retriever_weight"), cfg_for_type.get("retriever_weight"), default_rw)
|
||||
try:
|
||||
retriever_weight = float(retriever_weight)
|
||||
except Exception:
|
||||
retriever_weight = default_rw
|
||||
|
||||
chunk_profile = _coalesce(fm.get("chunk_profile"), cfg_for_type.get("chunk_profile"), os.environ.get("MINDNET_DEFAULT_CHUNK_PROFILE","medium"))
|
||||
chunk_profile = chunk_profile if isinstance(chunk_profile, str) else "medium"
|
||||
|
||||
edge_defaults = _ensure_list(_coalesce(fm.get("edge_defaults"), cfg_for_type.get("edge_defaults"), []))
|
||||
|
||||
note_id = n.get("note_id") or n.get("id") or fm.get("id")
|
||||
title = n.get("title") or fm.get("title") or ""
|
||||
path = n.get("path") or path_arg
|
||||
if isinstance(path, pathlib.Path):
|
||||
path = str(path)
|
||||
|
||||
payload = {
|
||||
"note_id": fm.get("id"),
|
||||
"title": fm.get("title"),
|
||||
"type": fm.get("type"),
|
||||
"status": fm.get("status"),
|
||||
"created": fm.get("created"),
|
||||
"updated": fm.get("updated"),
|
||||
"tags": fm.get("tags") or [],
|
||||
"priority": fm.get("priority"),
|
||||
"effort_min": fm.get("effort_min"),
|
||||
"due": fm.get("due"),
|
||||
"people": fm.get("people") or [],
|
||||
"aliases": fm.get("aliases") or [],
|
||||
"depends_on": fm.get("depends_on") or [],
|
||||
"assigned_to": fm.get("assigned_to") or [],
|
||||
"references": list(sorted(set(extract_wikilinks(body)))),
|
||||
"lang": fm.get("lang") or None,
|
||||
"path": rel_path.replace("\\", "/"),
|
||||
"hash_fulltext": sha256_text(body.strip()),
|
||||
"note_id": note_id,
|
||||
"title": title,
|
||||
"type": note_type,
|
||||
"path": path or "", # immer vorhanden
|
||||
"retriever_weight": retriever_weight,
|
||||
"chunk_profile": chunk_profile,
|
||||
"edge_defaults": edge_defaults,
|
||||
}
|
||||
# Entferne None-Werte für saubere Payloads
|
||||
return {k: v for k, v in payload.items() if v not in (None, [])}
|
||||
|
||||
tags = fm.get("tags") or fm.get("keywords") or n.get("tags")
|
||||
if tags: payload["tags"] = _ensure_list(tags)
|
||||
for k in ("created","modified","date"):
|
||||
v = fm.get(k) or n.get(k)
|
||||
if v: payload[k] = str(v)
|
||||
|
||||
json.loads(json.dumps(payload, ensure_ascii=False))
|
||||
return payload
|
||||
+244
-45
@@ -1,67 +1,266 @@
|
||||
from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
import re
|
||||
import os
|
||||
import unicodedata
|
||||
import yaml
|
||||
from typing import Tuple, Dict
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Modul: app/core/parser.py
|
||||
Version: 1.7.1 (fault-tolerant, API-kompatibel)
|
||||
Datum: 2025-10-01
|
||||
|
||||
FRONTMATTER_RE = re.compile(r"^---\s*\n(.*?)\n---\s*\n?", re.DOTALL) # YAML-Frontmatter am Anfang
|
||||
Zweck
|
||||
-----
|
||||
Fehlertolerantes Einlesen von Markdown-Dateien mit YAML-Frontmatter.
|
||||
Kompatibel zur bisherigen Parser-API, aber robust gegenüber Nicht-UTF-8-Dateien:
|
||||
- Versucht nacheinander: utf-8 → utf-8-sig → cp1252 → latin-1.
|
||||
- Bei Fallback wird ein JSON-Warnhinweis auf stdout ausgegeben; der Import bricht NICHT ab.
|
||||
- YAML-Frontmatter wird mit '---' am Anfang und '---' als Abschluss erkannt.
|
||||
- extract_wikilinks() normalisiert [[id#anchor|label]] → 'id'.
|
||||
|
||||
Öffentliche API (kompatibel):
|
||||
- class ParsedNote(frontmatter: dict, body: str, path: str)
|
||||
- read_markdown(path) -> ParsedNote | None
|
||||
- normalize_frontmatter(fm) -> dict
|
||||
- validate_required_frontmatter(fm, required: tuple[str,...]=("id","title")) -> None
|
||||
- extract_wikilinks(text) -> list[str]
|
||||
- FRONTMATTER_RE (Kompatibilitäts-Konstante; Regex für '---'-Zeilen)
|
||||
|
||||
Beispiele
|
||||
---------
|
||||
from app.core.parser import read_markdown, normalize_frontmatter, validate_required_frontmatter
|
||||
parsed = read_markdown("./vault/30_projects/project-demo.md")
|
||||
fm = normalize_frontmatter(parsed.frontmatter)
|
||||
validate_required_frontmatter(fm)
|
||||
body = parsed.body
|
||||
|
||||
from app.core.parser import extract_wikilinks
|
||||
links = extract_wikilinks(body)
|
||||
|
||||
Abhängigkeiten
|
||||
--------------
|
||||
- PyYAML (yaml)
|
||||
|
||||
Lizenz: MIT (projektintern)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Dict, Optional, Tuple, Iterable, List
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
|
||||
try:
|
||||
import yaml # PyYAML
|
||||
except Exception as e: # pragma: no cover
|
||||
yaml = None # Fehler wird zur Laufzeit geworfen, falls wirklich benötigt
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Datamodell
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
@dataclass
|
||||
class ParsedNote:
|
||||
frontmatter: Dict
|
||||
frontmatter: Dict[str, Any]
|
||||
body: str
|
||||
path: str
|
||||
|
||||
def _strip_bom(text: str) -> str:
|
||||
return text.lstrip("\ufeff")
|
||||
|
||||
def _normalize_text(t: str) -> str:
|
||||
# Unicode-NFKC + vereinheitlichte Zeilenenden + Trim
|
||||
t = unicodedata.normalize("NFKC", t)
|
||||
t = t.replace("\r\n", "\n").replace("\r", "\n")
|
||||
return t
|
||||
# ---------------------------------------------------------------------
|
||||
# Frontmatter-Erkennung
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
def read_markdown(path: str) -> ParsedNote:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
raw = _strip_bom(f.read())
|
||||
raw = _normalize_text(raw)
|
||||
# Öffentliche Kompatibilitäts-Konstante: frühere Skripte importieren FRONTMATTER_RE
|
||||
FRONTMATTER_RE = re.compile(r"^\s*---\s*$") # <— public
|
||||
# Zusätzlich interner Alias (falls jemand ihn referenziert)
|
||||
FRONTMATTER_END = FRONTMATTER_RE # <— public alias
|
||||
|
||||
m = FRONTMATTER_RE.match(raw)
|
||||
front, body = {}, raw
|
||||
if m:
|
||||
yaml_block = m.group(1)
|
||||
body = raw[m.end():]
|
||||
# interne Namen bleiben bestehen
|
||||
_FRONTMATTER_HEAD = FRONTMATTER_RE
|
||||
_FRONTMATTER_END = FRONTMATTER_RE
|
||||
|
||||
|
||||
def _split_frontmatter(text: str) -> Tuple[Dict[str, Any], str]:
|
||||
"""
|
||||
Zerlegt Text in (frontmatter: dict, body: str).
|
||||
Erkennt Frontmatter nur, wenn die erste Zeile '---' ist und später ein zweites '---' folgt.
|
||||
YAML-Fehler im Frontmatter führen NICHT zum Abbruch: es wird dann ein leeres dict benutzt.
|
||||
"""
|
||||
lines = text.splitlines(True) # keep line endings
|
||||
if not lines:
|
||||
return {}, ""
|
||||
|
||||
if not _FRONTMATTER_HEAD.match(lines[0]):
|
||||
# kein Frontmatter-Header → gesamter Text ist Body
|
||||
return {}, text
|
||||
|
||||
end_idx = None
|
||||
# Suche nach nächstem '---' (max. 2000 Zeilen als Sicherheitslimit)
|
||||
for i in range(1, min(len(lines), 2000)):
|
||||
if _FRONTMATTER_END.match(lines[i]):
|
||||
end_idx = i
|
||||
break
|
||||
|
||||
if end_idx is None:
|
||||
# unvollständiger Frontmatter-Block → behandle alles als Body
|
||||
return {}, text
|
||||
|
||||
fm_raw = "".join(lines[1:end_idx])
|
||||
body = "".join(lines[end_idx + 1:])
|
||||
|
||||
data: Dict[str, Any] = {}
|
||||
if yaml is None:
|
||||
raise RuntimeError("PyYAML ist nicht installiert (pip install pyyaml).")
|
||||
|
||||
try:
|
||||
loaded = yaml.safe_load(fm_raw) or {}
|
||||
if isinstance(loaded, dict):
|
||||
data = loaded
|
||||
else:
|
||||
data = {}
|
||||
except Exception as e:
|
||||
# YAML-Fehler nicht fatal machen
|
||||
print(json.dumps({"warn": "frontmatter_yaml_parse_failed", "error": str(e)}))
|
||||
data = {}
|
||||
|
||||
# optionales kosmetisches Trim: eine führende Leerzeile im Body entfernen
|
||||
if body.startswith("\n"):
|
||||
body = body[1:]
|
||||
|
||||
return data, body
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Robustes Lesen mit Encoding-Fallback
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
_FALLBACK_ENCODINGS: Tuple[str, ...] = ("utf-8", "utf-8-sig", "cp1252", "latin-1")
|
||||
|
||||
|
||||
def _read_text_with_fallback(path: str) -> Tuple[str, str, bool]:
|
||||
"""
|
||||
Liest Datei mit mehreren Decodierungsversuchen.
|
||||
Rückgabe: (text, used_encoding, had_fallback)
|
||||
- had_fallback=True, falls NICHT 'utf-8' verwendet wurde (oder 'utf-8-sig').
|
||||
"""
|
||||
last_err: Optional[str] = None
|
||||
for enc in _FALLBACK_ENCODINGS:
|
||||
try:
|
||||
front = yaml.safe_load(yaml_block) or {}
|
||||
if not isinstance(front, dict):
|
||||
raise ValueError("Frontmatter must be a mapping")
|
||||
except yaml.YAMLError as e:
|
||||
raise ValueError(f"Invalid YAML frontmatter in {path}: {e}") from e
|
||||
with io.open(path, "r", encoding=enc, errors="strict") as f:
|
||||
text = f.read()
|
||||
# 'utf-8-sig' zählt hier als Fallback (weil BOM), aber ist unproblematisch
|
||||
return text, enc, (enc != "utf-8")
|
||||
except UnicodeDecodeError as e:
|
||||
last_err = f"{type(e).__name__}: {e}"
|
||||
continue
|
||||
|
||||
return ParsedNote(frontmatter=front, body=body, path=path)
|
||||
# Letzter, extrem defensiver Fallback: Bytes → UTF-8 mit REPLACE (keine Exception)
|
||||
with open(path, "rb") as fb:
|
||||
raw = fb.read()
|
||||
text = raw.decode("utf-8", errors="replace")
|
||||
print(json.dumps({
|
||||
"path": path,
|
||||
"warn": "encoding_fallback_exhausted",
|
||||
"info": last_err or "unknown"
|
||||
}, ensure_ascii=False))
|
||||
return text, "utf-8(replace)", True
|
||||
|
||||
RE_WIKILINK = re.compile(r"\[\[([^\]\|#]+)(?:#[^\]]+)?(?:\|[^\]]+)?\]\]") # [[id]] | [[id#anchor]] | [[id|label]]
|
||||
|
||||
def extract_wikilinks(text: str) -> list[str]:
|
||||
return list({m.group(1).strip() for m in RE_WIKILINK.finditer(text)})
|
||||
# ---------------------------------------------------------------------
|
||||
# Öffentliche API
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
def validate_required_frontmatter(fm: dict, required=("title","id","type","status","created")):
|
||||
missing = [k for k in required if k not in fm or fm[k] in (None, "")]
|
||||
def read_markdown(path: str) -> Optional[ParsedNote]:
|
||||
"""
|
||||
Liest eine Markdown-Datei fehlertolerant:
|
||||
- Erlaubt verschiedene Encodings (UTF-8 bevorzugt, cp1252/latin-1 als Fallback).
|
||||
- Schlägt NICHT mit UnicodeDecodeError fehl.
|
||||
- Gibt ParsedNote(frontmatter, body, path) zurück oder None, falls die Datei nicht existiert.
|
||||
|
||||
Bei Decoding-Fallback wird ein JSON-Warnhinweis geloggt:
|
||||
{"path": "...", "warn": "encoding_fallback_used", "used": "cp1252"}
|
||||
"""
|
||||
if not os.path.exists(path):
|
||||
return None
|
||||
|
||||
text, enc, had_fb = _read_text_with_fallback(path)
|
||||
if had_fb:
|
||||
print(json.dumps({"path": path, "warn": "encoding_fallback_used", "used": enc}, ensure_ascii=False))
|
||||
|
||||
fm, body = _split_frontmatter(text)
|
||||
return ParsedNote(frontmatter=fm or {}, body=body or "", path=path)
|
||||
|
||||
|
||||
def validate_required_frontmatter(fm: Dict[str, Any],
|
||||
required: Tuple[str, ...] = ("id", "title")) -> None:
|
||||
"""
|
||||
Prüft, ob alle Pflichtfelder vorhanden sind.
|
||||
Default-kompatibel: ('id', 'title'), kann aber vom Aufrufer erweitert werden, z. B.:
|
||||
validate_required_frontmatter(fm, required=("id","title","type","status","created"))
|
||||
|
||||
Hebt ValueError, falls Felder fehlen oder leer sind.
|
||||
"""
|
||||
if fm is None:
|
||||
fm = {}
|
||||
missing = []
|
||||
for k in required:
|
||||
v = fm.get(k)
|
||||
if v is None:
|
||||
missing.append(k)
|
||||
elif isinstance(v, str) and not v.strip():
|
||||
missing.append(k)
|
||||
if missing:
|
||||
raise ValueError(f"Missing required frontmatter fields: {', '.join(missing)}")
|
||||
|
||||
# einfache Plausibilitäten
|
||||
if not isinstance(fm.get("tags", []), (list, tuple)):
|
||||
if "tags" in fm and fm["tags"] not in (None, ""):
|
||||
raise ValueError("tags must be a list of strings")
|
||||
# Plausibilitäten: 'tags' sollte eine Liste sein, wenn vorhanden
|
||||
if "tags" in fm and fm["tags"] not in (None, "") and not isinstance(fm["tags"], (list, tuple)):
|
||||
raise ValueError("frontmatter 'tags' must be a list of strings")
|
||||
|
||||
def normalize_frontmatter(fm: dict) -> dict:
|
||||
# kleinere Normalisierungen ohne die Semantik zu verändern
|
||||
out = dict(fm)
|
||||
if "tags" in out and isinstance(out["tags"], list):
|
||||
out["tags"] = [str(t).strip() for t in out["tags"]]
|
||||
|
||||
def normalize_frontmatter(fm: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
Sanfte Normalisierung ohne Semantikänderung:
|
||||
- 'tags' → Liste von Strings (Trim)
|
||||
- 'embedding_exclude' → bool
|
||||
- andere Felder unverändert
|
||||
"""
|
||||
out = dict(fm or {})
|
||||
if "tags" in out:
|
||||
if isinstance(out["tags"], str):
|
||||
out["tags"] = [out["tags"].strip()] if out["tags"].strip() else []
|
||||
elif isinstance(out["tags"], list):
|
||||
out["tags"] = [str(t).strip() for t in out["tags"] if t is not None]
|
||||
else:
|
||||
out["tags"] = [str(out["tags"]).strip()] if out["tags"] not in (None, "") else []
|
||||
if "embedding_exclude" in out:
|
||||
out["embedding_exclude"] = bool(out["embedding_exclude"])
|
||||
return out
|
||||
|
||||
|
||||
# ------------------------------ Wikilinks ---------------------------- #
|
||||
|
||||
# Basismuster für [[...]]; die Normalisierung (id vor '#', vor '|') macht extract_wikilinks
|
||||
_WIKILINK_RE = re.compile(r"\[\[([^\]]+)\]\]")
|
||||
|
||||
|
||||
def extract_wikilinks(text: str) -> List[str]:
|
||||
"""
|
||||
Extrahiert Wikilinks wie [[id]], [[id#anchor]], [[id|label]], [[id#anchor|label]].
|
||||
Rückgabe sind NUR die Ziel-IDs (ohne Anchor/Label), führend/folgend getrimmt.
|
||||
Keine aggressive Slug-Normalisierung (die kann später im Resolver erfolgen).
|
||||
"""
|
||||
if not text:
|
||||
return []
|
||||
out: List[str] = []
|
||||
for m in _WIKILINK_RE.finditer(text):
|
||||
raw = (m.group(1) or "").strip()
|
||||
if not raw:
|
||||
continue
|
||||
# Split an Pipe (Label) → links vor '|'
|
||||
if "|" in raw:
|
||||
raw = raw.split("|", 1)[0].strip()
|
||||
# Split an Anchor
|
||||
if "#" in raw:
|
||||
raw = raw.split("#", 1)[0].strip()
|
||||
if raw:
|
||||
out.append(raw)
|
||||
return out
|
||||
+76
-72
@@ -1,18 +1,27 @@
|
||||
# app/core/qdrant.py
|
||||
from __future__ import annotations
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Name: app/core/qdrant.py
|
||||
Version: v1.4.0 (2025-09-09)
|
||||
|
||||
Kurzbeschreibung:
|
||||
Qdrant-Client & Collection-Setup für mindnet.
|
||||
- Stellt sicher, dass {prefix}_notes / {prefix}_chunks / {prefix}_edges existieren.
|
||||
- Edges-Collection nutzt 1D Dummy-Vektor.
|
||||
- NEW: ensure_payload_indexes(...) legt sinnvolle Payload-Indizes an.
|
||||
|
||||
Aufruf:
|
||||
from app.core.qdrant import QdrantConfig, get_client, ensure_collections, ensure_payload_indexes
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from qdrant_client import QdrantClient
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
|
||||
# -------------------------------
|
||||
# Konfiguration
|
||||
# -------------------------------
|
||||
|
||||
@dataclass
|
||||
class QdrantConfig:
|
||||
url: str
|
||||
@@ -22,99 +31,94 @@ class QdrantConfig:
|
||||
|
||||
@staticmethod
|
||||
def from_env() -> "QdrantConfig":
|
||||
# URL (bevorzugt) oder Host/Port
|
||||
url = os.getenv("QDRANT_URL")
|
||||
if not url:
|
||||
host = os.getenv("QDRANT_HOST", "127.0.0.1")
|
||||
port = int(os.getenv("QDRANT_PORT", "6333"))
|
||||
url = f"http://{host}:{port}"
|
||||
api_key = os.getenv("QDRANT_API_KEY") or None
|
||||
|
||||
# Collection-Prefix und Vektor-Dimension
|
||||
prefix = os.getenv("COLLECTION_PREFIX", "mindnet")
|
||||
dim = int(os.getenv("VECTOR_DIM", "384")) # MiniLM-384 by default
|
||||
|
||||
dim = int(os.getenv("VECTOR_DIM", "384"))
|
||||
return QdrantConfig(url=url, api_key=api_key, prefix=prefix, dim=dim)
|
||||
|
||||
|
||||
# -------------------------------
|
||||
# Client / Setup
|
||||
# -------------------------------
|
||||
|
||||
def get_client(cfg: QdrantConfig) -> QdrantClient:
|
||||
"""
|
||||
Erstellt einen QdrantClient basierend auf der Config.
|
||||
"""
|
||||
return QdrantClient(url=cfg.url, api_key=cfg.api_key)
|
||||
|
||||
|
||||
def ensure_collections(client: QdrantClient, prefix: str, dim: int) -> None:
|
||||
"""
|
||||
Stellt sicher, dass die drei Collections existieren:
|
||||
- {prefix}_notes : Vektor-Dim = dim (COSINE)
|
||||
- {prefix}_chunks : Vektor-Dim = dim (COSINE)
|
||||
- {prefix}_edges : Vektor-Dim = 1 (DOT) <-- Dummy-Vektor, damit der Python-Client kein 'vector' zwingt
|
||||
Falls {prefix}_edges bereits vektorlos existiert, wird sie gelöscht und mit 1D neu erstellt.
|
||||
"""
|
||||
def _create_notes(client: QdrantClient, name: str, dim: int) -> None:
|
||||
if not client.collection_exists(name):
|
||||
client.create_collection(
|
||||
collection_name=name,
|
||||
vectors_config=rest.VectorParams(size=dim, distance=rest.Distance.COSINE),
|
||||
)
|
||||
|
||||
def _create_chunks(client: QdrantClient, name: str, dim: int) -> None:
|
||||
if not client.collection_exists(name):
|
||||
client.create_collection(
|
||||
collection_name=name,
|
||||
vectors_config=rest.VectorParams(size=dim, distance=rest.Distance.COSINE),
|
||||
)
|
||||
|
||||
def _create_edges(client: QdrantClient, name: str) -> None:
|
||||
if not client.collection_exists(name):
|
||||
client.create_collection(
|
||||
collection_name=name,
|
||||
vectors_config=rest.VectorParams(size=1, distance=rest.Distance.DOT), # 1D-Dummy
|
||||
)
|
||||
|
||||
|
||||
def ensure_collections(client: QdrantClient, prefix: str, dim: int, destructive: bool = False) -> None:
|
||||
notes = f"{prefix}_notes"
|
||||
chunks = f"{prefix}_chunks"
|
||||
edges = f"{prefix}_edges"
|
||||
|
||||
# Notes
|
||||
if not client.collection_exists(notes):
|
||||
client.create_collection(
|
||||
collection_name=notes,
|
||||
vectors_config=rest.VectorParams(size=dim, distance=rest.Distance.COSINE),
|
||||
)
|
||||
_create_notes(client, notes, dim)
|
||||
_create_chunks(client, chunks, dim)
|
||||
|
||||
# Chunks
|
||||
if not client.collection_exists(chunks):
|
||||
client.create_collection(
|
||||
collection_name=chunks,
|
||||
vectors_config=rest.VectorParams(size=dim, distance=rest.Distance.COSINE),
|
||||
)
|
||||
|
||||
# Edges: 1D Dummy-Vektor (Workaround)
|
||||
recreate_edges = False
|
||||
if client.collection_exists(edges):
|
||||
try:
|
||||
info = client.get_collection(edges)
|
||||
# Prüfen, ob Vektor-Konfig existiert
|
||||
vectors_cfg = getattr(getattr(info.result, "config", None), "params", None)
|
||||
# Neuere Clients: info.result.config.params.vectors kann VectorParams oder dict sein
|
||||
has_vectors = getattr(vectors_cfg, "vectors", None) is not None
|
||||
if not has_vectors:
|
||||
recreate_edges = True
|
||||
except Exception:
|
||||
# Wenn Metadaten nicht lesbar → sicherheitshalber neu anlegen
|
||||
recreate_edges = True
|
||||
has_vectors = True
|
||||
if not has_vectors:
|
||||
if destructive:
|
||||
client.delete_collection(edges)
|
||||
_create_edges(client, edges)
|
||||
else:
|
||||
print(f"[ensure_collections] WARN: '{edges}' ohne VectorConfig; destructive=False.", flush=True)
|
||||
else:
|
||||
# Existiert noch nicht → wird gleich erstellt
|
||||
pass
|
||||
|
||||
if recreate_edges and client.collection_exists(edges):
|
||||
client.delete_collection(edges)
|
||||
|
||||
if not client.collection_exists(edges):
|
||||
client.create_collection(
|
||||
collection_name=edges,
|
||||
vectors_config=rest.VectorParams(size=1, distance=rest.Distance.DOT),
|
||||
)
|
||||
_create_edges(client, edges)
|
||||
|
||||
|
||||
# -------------------------------
|
||||
# (Optionale) Utility-Funktionen
|
||||
# -------------------------------
|
||||
|
||||
def collection_names(prefix: str) -> tuple[str, str, str]:
|
||||
"""Hilfsfunktion, falls du die Namen an einer Stelle brauchst."""
|
||||
def collection_names(prefix: str) -> Tuple[str, str, str]:
|
||||
return (f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges")
|
||||
|
||||
|
||||
def wipe_collections(client: QdrantClient, prefix: str) -> None:
|
||||
"""
|
||||
Löscht alle drei Collections (nur nutzen, wenn du bewusst neu aufsetzen willst).
|
||||
"""
|
||||
for name in collection_names(prefix):
|
||||
if client.collection_exists(name):
|
||||
client.delete_collection(name)
|
||||
# -------------------------------
|
||||
# NEW: Payload-Indexing
|
||||
# -------------------------------
|
||||
|
||||
def _safe_create_index(client: QdrantClient, col: str, field: str, schema: rest.PayloadSchemaType):
|
||||
try:
|
||||
client.create_payload_index(
|
||||
collection_name=col,
|
||||
field_name=field,
|
||||
field_schema=schema,
|
||||
)
|
||||
except Exception:
|
||||
# bereits vorhanden oder nicht unterstütztes Schema → ignorieren
|
||||
pass
|
||||
|
||||
def ensure_payload_indexes(client: QdrantClient, prefix: str) -> None:
|
||||
notes, chunks, edges = collection_names(prefix)
|
||||
# Notes
|
||||
_safe_create_index(client, notes, "note_id", rest.PayloadSchemaType.KEYWORD)
|
||||
# Chunks
|
||||
_safe_create_index(client, chunks, "note_id", rest.PayloadSchemaType.KEYWORD)
|
||||
_safe_create_index(client, chunks, "chunk_index", rest.PayloadSchemaType.INTEGER)
|
||||
# Edges
|
||||
for f in ("kind", "scope", "source_id", "target_id", "note_id"):
|
||||
_safe_create_index(client, edges, f, rest.PayloadSchemaType.KEYWORD)
|
||||
+174
-38
@@ -1,45 +1,46 @@
|
||||
from __future__ import annotations
|
||||
import uuid
|
||||
from typing import List, Tuple
|
||||
from qdrant_client.http import models as rest
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
app/core/qdrant_points.py - robust points helpers for Qdrant
|
||||
|
||||
- Single source of truth for building PointStruct for notes/chunks/edges
|
||||
- Backward-compatible payloads for edges
|
||||
- Handles both Single-Vector and Named-Vector collections
|
||||
- Deterministic overrides via ENV to avoid auto-detection traps:
|
||||
* NOTES_VECTOR_NAME, CHUNKS_VECTOR_NAME, EDGES_VECTOR_NAME
|
||||
* MINDNET_VECTOR_NAME (fallback)
|
||||
> Set to a concrete name (e.g. "text") to force Named-Vector with that name
|
||||
> Set to "__single__" (or "single") to force Single-Vector
|
||||
|
||||
Version: 1.5.0 (2025-11-08)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import os
|
||||
import uuid
|
||||
from typing import List, Tuple, Iterable, Optional, Dict, Any
|
||||
|
||||
from qdrant_client.http import models as rest
|
||||
from qdrant_client import QdrantClient
|
||||
|
||||
# --------------------- ID helpers ---------------------
|
||||
|
||||
def _to_uuid(stable_key: str) -> str:
|
||||
return str(uuid.uuid5(uuid.NAMESPACE_URL, stable_key))
|
||||
|
||||
def _names(prefix: str) -> Tuple[str, str, str]:
|
||||
return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges"
|
||||
|
||||
# --------------------- Points builders ---------------------
|
||||
|
||||
def _to_uuid(stable_key: str) -> str:
|
||||
"""Stabile UUIDv5 aus einem String-Key (deterministisch)."""
|
||||
return str(uuid.uuid5(uuid.NAMESPACE_URL, stable_key))
|
||||
|
||||
|
||||
def points_for_note(
|
||||
prefix: str,
|
||||
note_payload: dict,
|
||||
note_vec: List[float] | None,
|
||||
dim: int,
|
||||
) -> Tuple[str, List[rest.PointStruct]]:
|
||||
"""Notes-Collection: falls kein Note-Embedding -> Nullvektor der Länge dim."""
|
||||
def points_for_note(prefix: str, note_payload: dict, note_vec: List[float] | None, dim: int) -> Tuple[str, List[rest.PointStruct]]:
|
||||
notes_col, _, _ = _names(prefix)
|
||||
vector = note_vec if note_vec is not None else [0.0] * int(dim)
|
||||
# Qdrant-Point-ID MUSS int/UUID sein
|
||||
raw_note_id = note_payload.get("note_id") or note_payload.get("id") or "missing-note-id"
|
||||
point_id = _to_uuid(raw_note_id)
|
||||
pt = rest.PointStruct(id=point_id, vector=vector, payload=note_payload)
|
||||
return notes_col, [pt]
|
||||
|
||||
|
||||
def points_for_chunks(
|
||||
prefix: str,
|
||||
chunk_payloads: List[dict],
|
||||
vectors: List[List[float]],
|
||||
) -> Tuple[str, List[rest.PointStruct]]:
|
||||
"""
|
||||
Chunks-Collection: erwartet pro Chunk einen Vektor.
|
||||
Robustheit:
|
||||
- Fehlt 'chunk_id', nutze 'id', sonst baue '${note_id}#${i}' (1-basiert).
|
||||
- Schreibe die abgeleitete ID zurück in die Payload (pl['chunk_id']).
|
||||
"""
|
||||
def points_for_chunks(prefix: str, chunk_payloads: List[dict], vectors: List[List[float]]) -> Tuple[str, List[rest.PointStruct]]:
|
||||
_, chunks_col, _ = _names(prefix)
|
||||
points: List[rest.PointStruct] = []
|
||||
for i, (pl, vec) in enumerate(zip(chunk_payloads, vectors), start=1):
|
||||
@@ -47,37 +48,172 @@ def points_for_chunks(
|
||||
if not chunk_id:
|
||||
note_id = pl.get("note_id") or pl.get("parent_note_id") or "missing-note"
|
||||
chunk_id = f"{note_id}#{i}"
|
||||
pl["chunk_id"] = chunk_id # persistenter Fallback in Payload
|
||||
pl["chunk_id"] = chunk_id
|
||||
point_id = _to_uuid(chunk_id)
|
||||
points.append(rest.PointStruct(id=point_id, vector=vec, payload=pl))
|
||||
return chunks_col, points
|
||||
|
||||
def _normalize_edge_payload(pl: dict) -> dict:
|
||||
kind = pl.get("kind") or pl.get("edge_type") or "edge"
|
||||
source_id = pl.get("source_id") or pl.get("src_id") or "unknown-src"
|
||||
target_id = pl.get("target_id") or pl.get("dst_id") or "unknown-tgt"
|
||||
seq = pl.get("seq") or pl.get("order") or pl.get("index")
|
||||
|
||||
pl.setdefault("kind", kind)
|
||||
pl.setdefault("source_id", source_id)
|
||||
pl.setdefault("target_id", target_id)
|
||||
if seq is not None and "seq" not in pl:
|
||||
pl["seq"] = seq
|
||||
return pl
|
||||
|
||||
def points_for_edges(prefix: str, edge_payloads: List[dict]) -> Tuple[str, List[rest.PointStruct]]:
|
||||
"""
|
||||
Edges-Collection mit 1D-Dummy-Vektor.
|
||||
- Fehlt 'edge_id', konstruieren wir eine stabile ID aus (kind, source_id, target_id, seq).
|
||||
- vector=[0.0] erfüllt die Client-Validierung.
|
||||
"""
|
||||
_, _, edges_col = _names(prefix)
|
||||
points: List[rest.PointStruct] = []
|
||||
for pl in edge_payloads:
|
||||
for raw in edge_payloads:
|
||||
pl = _normalize_edge_payload(raw)
|
||||
edge_id = pl.get("edge_id")
|
||||
if not edge_id:
|
||||
kind = pl.get("kind", "edge")
|
||||
s = pl.get("source_id", "unknown-src")
|
||||
t = pl.get("target_id", "unknown-tgt")
|
||||
seq = pl.get("seq") or pl.get("order") or ""
|
||||
seq = pl.get("seq") or ""
|
||||
edge_id = f"{kind}:{s}->{t}#{seq}"
|
||||
pl["edge_id"] = edge_id
|
||||
point_id = _to_uuid(edge_id)
|
||||
points.append(rest.PointStruct(id=point_id, vector=[0.0], payload=pl))
|
||||
return edges_col, points
|
||||
|
||||
# --------------------- Vector schema & overrides ---------------------
|
||||
|
||||
def _preferred_name(candidates: List[str]) -> str:
|
||||
for k in ("text", "default", "embedding", "content"):
|
||||
if k in candidates:
|
||||
return k
|
||||
return sorted(candidates)[0]
|
||||
|
||||
def _env_override_for_collection(collection: str) -> Optional[str]:
|
||||
"""
|
||||
Returns:
|
||||
- "__single__" to force single-vector
|
||||
- concrete name (str) to force named-vector with that name
|
||||
- None to auto-detect
|
||||
"""
|
||||
base = os.getenv("MINDNET_VECTOR_NAME")
|
||||
if collection.endswith("_notes"):
|
||||
base = os.getenv("NOTES_VECTOR_NAME", base)
|
||||
elif collection.endswith("_chunks"):
|
||||
base = os.getenv("CHUNKS_VECTOR_NAME", base)
|
||||
elif collection.endswith("_edges"):
|
||||
base = os.getenv("EDGES_VECTOR_NAME", base)
|
||||
|
||||
def upsert_batch(client, collection: str, points: List[rest.PointStruct]) -> None:
|
||||
if not base:
|
||||
return None
|
||||
val = base.strip()
|
||||
if val.lower() in ("__single__", "single"):
|
||||
return "__single__"
|
||||
return val # concrete name
|
||||
|
||||
def _get_vector_schema(client: QdrantClient, collection_name: str) -> dict:
|
||||
"""
|
||||
Return {"kind": "single", "size": int} or {"kind": "named", "names": [...], "primary": str}.
|
||||
"""
|
||||
try:
|
||||
info = client.get_collection(collection_name=collection_name)
|
||||
vecs = getattr(info, "vectors", None)
|
||||
# Single-vector config
|
||||
if hasattr(vecs, "size") and isinstance(vecs.size, int):
|
||||
return {"kind": "single", "size": vecs.size}
|
||||
# Named-vectors config (dict-like in .config)
|
||||
cfg = getattr(vecs, "config", None)
|
||||
if isinstance(cfg, dict) and cfg:
|
||||
names = list(cfg.keys())
|
||||
if names:
|
||||
return {"kind": "named", "names": names, "primary": _preferred_name(names)}
|
||||
except Exception:
|
||||
pass
|
||||
return {"kind": "single", "size": None}
|
||||
|
||||
def _as_named(points: List[rest.PointStruct], name: str) -> List[rest.PointStruct]:
|
||||
out: List[rest.PointStruct] = []
|
||||
for pt in points:
|
||||
vec = getattr(pt, "vector", None)
|
||||
if isinstance(vec, dict):
|
||||
if name in vec:
|
||||
out.append(pt)
|
||||
else:
|
||||
# take any existing entry; if empty dict fallback to [0.0]
|
||||
fallback_vec = None
|
||||
try:
|
||||
fallback_vec = list(next(iter(vec.values())))
|
||||
except Exception:
|
||||
fallback_vec = [0.0]
|
||||
out.append(rest.PointStruct(id=pt.id, vector={name: fallback_vec}, payload=pt.payload))
|
||||
elif vec is not None:
|
||||
out.append(rest.PointStruct(id=pt.id, vector={name: vec}, payload=pt.payload))
|
||||
else:
|
||||
out.append(pt)
|
||||
return out
|
||||
|
||||
# --------------------- Qdrant ops ---------------------
|
||||
|
||||
def upsert_batch(client: QdrantClient, collection: str, points: List[rest.PointStruct]) -> None:
|
||||
if not points:
|
||||
return
|
||||
|
||||
# 1) ENV overrides come first
|
||||
override = _env_override_for_collection(collection)
|
||||
if override == "__single__":
|
||||
client.upsert(collection_name=collection, points=points, wait=True)
|
||||
return
|
||||
elif isinstance(override, str):
|
||||
client.upsert(collection_name=collection, points=_as_named(points, override), wait=True)
|
||||
return
|
||||
|
||||
# 2) Auto-detect schema
|
||||
schema = _get_vector_schema(client, collection)
|
||||
if schema.get("kind") == "named":
|
||||
name = schema.get("primary") or _preferred_name(schema.get("names") or [])
|
||||
client.upsert(collection_name=collection, points=_as_named(points, name), wait=True)
|
||||
return
|
||||
|
||||
# 3) Fallback single-vector
|
||||
client.upsert(collection_name=collection, points=points, wait=True)
|
||||
|
||||
# --- Optional search helpers ---
|
||||
|
||||
def _filter_any(field: str, values: Iterable[str]) -> rest.Filter:
|
||||
return rest.Filter(should=[rest.FieldCondition(key=field, match=rest.MatchValue(value=v)) for v in values])
|
||||
|
||||
def _merge_filters(*filters: Optional[rest.Filter]) -> Optional[rest.Filter]:
|
||||
fs = [f for f in filters if f is not None]
|
||||
if not fs:
|
||||
return None
|
||||
if len(fs) == 1:
|
||||
return fs[0]
|
||||
must = []
|
||||
for f in fs:
|
||||
if getattr(f, "must", None):
|
||||
must.extend(f.must)
|
||||
if getattr(f, "should", None):
|
||||
must.append(rest.Filter(should=f.should))
|
||||
return rest.Filter(must=must)
|
||||
|
||||
def _filter_from_dict(filters: Optional[Dict[str, Any]]) -> Optional[rest.Filter]:
|
||||
if not filters:
|
||||
return None
|
||||
parts = []
|
||||
for k, v in filters.items():
|
||||
if isinstance(v, (list, tuple, set)):
|
||||
parts.append(_filter_any(k, [str(x) for x in v]))
|
||||
else:
|
||||
parts.append(rest.Filter(must=[rest.FieldCondition(key=k, match=rest.MatchValue(value=v))]))
|
||||
return _merge_filters(*parts)
|
||||
|
||||
def search_chunks_by_vector(client: QdrantClient, prefix: str, vector: List[float], top: int = 10, filters: Optional[Dict[str, Any]] = None) -> List[Tuple[str, float, dict]]:
|
||||
_, chunks_col, _ = _names(prefix)
|
||||
flt = _filter_from_dict(filters)
|
||||
res = client.search(collection_name=chunks_col, query_vector=vector, limit=top, with_payload=True, with_vectors=False, query_filter=flt)
|
||||
out: List[Tuple[str, float, dict]] = []
|
||||
for r in res:
|
||||
out.append((str(r.id), float(r.score), dict(r.payload or {})))
|
||||
return out
|
||||
@@ -0,0 +1,56 @@
|
||||
"""
|
||||
app/core/ranking.py — Kombiniertes Scoring (WP-04)
|
||||
|
||||
Zweck:
|
||||
Zusammenführen von semantischem Score (normalisiert), Edge-Bonus und
|
||||
Centrality-Bonus in einen Gesamtscore für die Ergebnisreihung.
|
||||
Kompatibilität:
|
||||
Python 3.12+
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
WP-04 Ranking-Formel (w_sem, w_edge, w_cent)
|
||||
Nutzung:
|
||||
from app.core.ranking import combine_scores
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import List, Tuple, Dict
|
||||
|
||||
|
||||
def normalize_scores(values: List[float]) -> List[float]:
|
||||
"""Min-Max-Normalisierung über die Kandidatenmenge (Fallback 0.5 bei Konstanz)."""
|
||||
if not values:
|
||||
return values
|
||||
lo, hi = min(values), max(values)
|
||||
if hi - lo < 1e-9:
|
||||
return [0.5] * len(values)
|
||||
return [(v - lo) / (hi - lo) for v in values]
|
||||
|
||||
|
||||
def combine_scores(
|
||||
hits: List[Tuple[str, float, dict]], # (id, semantic_score, payload)
|
||||
edge_bonus_map: Dict[str, float],
|
||||
centrality_map: Dict[str, float],
|
||||
w_sem: float = 0.70,
|
||||
w_edge: float = 0.25,
|
||||
w_cent: float = 0.05,
|
||||
) -> List[Tuple[str, float, float, float, float]]:
|
||||
"""
|
||||
Liefert Liste von (point_id, total_score, edge_bonus, centrality_bonus, raw_semantic_score),
|
||||
absteigend nach total_score sortiert.
|
||||
"""
|
||||
sem = [h[1] for h in hits]
|
||||
sem_n = normalize_scores(sem)
|
||||
out = []
|
||||
for (pid, s, payload), s_norm in zip(hits, sem_n):
|
||||
e = edge_bonus_map.get(pid, 0.0)
|
||||
c = centrality_map.get(pid, 0.0)
|
||||
total = w_sem * s_norm + w_edge * e + w_cent * c
|
||||
out.append((pid, total, e, c, s))
|
||||
out.sort(key=lambda t: t[1], reverse=True)
|
||||
return out
|
||||
@@ -0,0 +1,121 @@
|
||||
"""
|
||||
app/core/retriever.py — Semantischer/Edge-Aware/Hybrid Retriever (WP-04)
|
||||
|
||||
Zweck:
|
||||
Kandidatenfindung via Vektorsuche in *_chunks, optionale Edge-Expansion
|
||||
und kombiniertes Ranking zur Rückgabe von Top-K Treffern.
|
||||
Erweiterung (0.2.0): Text→Embedding, falls kein query_vector übergeben wurde.
|
||||
|
||||
Kompatibilität:
|
||||
Python 3.12+, qdrant-client 1.x
|
||||
Version:
|
||||
0.2.0 (Text→Embedding ergänzt; bestehendes Verhalten unverändert)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
- app/core/graph_adapter.py (expand)
|
||||
- app/core/ranking.py (combine_scores)
|
||||
- app/core/qdrant_points.py (search_chunks_by_vector)
|
||||
- app/services/embeddings_client.py (embed_text)
|
||||
- app/models/dto.py (QueryRequest/Response)
|
||||
Änderungsverlauf:
|
||||
0.2.0 (2025-10-07) – Text→Embedding (embed_text_if_needed).
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
import time
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
from qdrant_client import QdrantClient
|
||||
|
||||
from app.models.dto import QueryRequest, QueryResponse, QueryHit
|
||||
from app.core.ranking import combine_scores
|
||||
from app.core.graph_adapter import expand
|
||||
from app.core import qdrant_points as qp
|
||||
from app.config import get_settings
|
||||
from app.services.embeddings_client import embed_text
|
||||
|
||||
|
||||
def _vector_from_request(req: QueryRequest) -> List[float]:
|
||||
"""
|
||||
Query-Vektor bestimmen:
|
||||
- Falls query_vector gesetzt: unverändert verwenden (Back-compat, Tests).
|
||||
- Sonst, falls query gesetzt: serverseitig einbetten.
|
||||
- Andernfalls: Fehler.
|
||||
"""
|
||||
if req.query_vector:
|
||||
return req.query_vector
|
||||
if req.query:
|
||||
return embed_text(req.query)
|
||||
raise ValueError("query_vector fehlt. Alternativ 'query' (Text) übergeben, wird serverseitig eingebettet.")
|
||||
|
||||
|
||||
def semantic_retrieve(req: QueryRequest) -> QueryResponse:
|
||||
"""Nur semantische Kandidaten, keine Edge-Expansion (depth=0)."""
|
||||
t0 = time.time()
|
||||
s = get_settings()
|
||||
client = QdrantClient(url=s.QDRANT_URL, api_key=s.QDRANT_API_KEY)
|
||||
|
||||
q_vec = _vector_from_request(req)
|
||||
raw_hits = qp.search_chunks_by_vector(client, s.COLLECTION_PREFIX, q_vec, top=req.top_k, filters=req.filters)
|
||||
|
||||
results: List[QueryHit] = []
|
||||
for pid, s_score, payload in raw_hits:
|
||||
results.append(QueryHit(
|
||||
node_id=pid,
|
||||
note_id=payload.get("note_id"),
|
||||
semantic_score=float(s_score),
|
||||
edge_bonus=0.0,
|
||||
centrality_bonus=0.0,
|
||||
total_score=float(s_score), # un-normalisiert: ok für quick semantic mode
|
||||
paths=None,
|
||||
source={"path": payload.get("path"), "section": payload.get("section_title")}
|
||||
))
|
||||
dt = int((time.time() - t0) * 1000)
|
||||
return QueryResponse(results=results, used_mode="semantic", latency_ms=dt)
|
||||
|
||||
|
||||
def hybrid_retrieve(req: QueryRequest) -> QueryResponse:
|
||||
"""Semantik + Edge-Expansion + kombiniertes Ranking."""
|
||||
t0 = time.time()
|
||||
s = get_settings()
|
||||
client = QdrantClient(url=s.QDRANT_URL, api_key=s.QDRANT_API_KEY)
|
||||
|
||||
q_vec = _vector_from_request(req)
|
||||
|
||||
# 1) Semantische Seeds (top_k * 3 für breitere Basis)
|
||||
raw_hits = qp.search_chunks_by_vector(client, s.COLLECTION_PREFIX, q_vec, top=req.top_k * 3, filters=req.filters)
|
||||
id2payload = {pid: payload for (pid, _, payload) in raw_hits}
|
||||
seeds = [pid for (pid, _, _) in raw_hits]
|
||||
|
||||
# 2) Edge-Expansion
|
||||
edge_types = req.expand.get("edge_types") if req.expand else None
|
||||
depth = req.expand.get("depth", 1) if req.expand else 1
|
||||
sg = expand(client, s.COLLECTION_PREFIX, seeds, depth=depth, edge_types=edge_types)
|
||||
|
||||
edge_bonus_map = {pid: sg.aggregate_edge_bonus(pid) for pid in seeds}
|
||||
centrality_map = {pid: sg.centrality_bonus(pid) for pid in seeds}
|
||||
|
||||
# 3) Combined Ranking
|
||||
scored = combine_scores(
|
||||
raw_hits, edge_bonus_map, centrality_map,
|
||||
w_sem=s.RETRIEVER_W_SEM, w_edge=s.RETRIEVER_W_EDGE, w_cent=s.RETRIEVER_W_CENT
|
||||
)
|
||||
|
||||
# 4) Antwortobjekte (Chunk-Ebene)
|
||||
results: List[QueryHit] = []
|
||||
for pid, total, e, c, s_score in scored[: req.top_k]:
|
||||
payload = id2payload[pid]
|
||||
results.append(QueryHit(
|
||||
node_id=pid,
|
||||
note_id=payload.get("note_id"),
|
||||
semantic_score=float(s_score),
|
||||
edge_bonus=float(e),
|
||||
centrality_bonus=float(c),
|
||||
total_score=float(total),
|
||||
paths=None,
|
||||
source={"path": payload.get("path"), "section": payload.get("section_title")}
|
||||
))
|
||||
|
||||
dt = int((time.time() - t0) * 1000)
|
||||
return QueryResponse(results=results, used_mode="hybrid", latency_ms=dt)
|
||||
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Modul: app/core/type_registry.py
|
||||
Version: 1.0.0
|
||||
Datum: 2025-11-08
|
||||
|
||||
Zweck
|
||||
-----
|
||||
Lädt eine optionale Typ-Registry (config/types.yaml) und stellt
|
||||
komfortable Zugriffsfunktionen bereit. Die Registry ist *optional*:
|
||||
- Fehlt die Datei oder ist das YAML defekt, wird ein konservativer
|
||||
Default (Typ "concept") verwendet und es wird eine Warnung ausgegeben.
|
||||
- Änderungen an der Datei greifen nach einem Neustart des Prozesses.
|
||||
|
||||
Öffentliche API
|
||||
---------------
|
||||
- load_type_registry(path: str = "config/types.yaml") -> dict
|
||||
- get_type_config(note_type: str, reg: dict) -> dict
|
||||
- resolve_note_type(fm_type: str | None, reg: dict) -> str
|
||||
- effective_chunk_profile(note_type: str, reg: dict) -> str | None
|
||||
- profile_overlap(profile: str | None) -> tuple[int,int] # nur Overlap-Empfehlung
|
||||
|
||||
Hinweis
|
||||
-------
|
||||
Die Registry steuert KEINE Breaking Changes. Ohne Datei/Typ bleibt das
|
||||
Verhalten exakt wie im Release-Stand 20251105.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from functools import lru_cache
|
||||
from typing import Dict, Any, Optional, Tuple
|
||||
import os
|
||||
|
||||
try:
|
||||
import yaml # PyYAML
|
||||
except Exception:
|
||||
yaml = None # wird erst benötigt, wenn eine Datei gelesen werden soll
|
||||
|
||||
# Konservativer Default – bewusst minimal
|
||||
_DEFAULT_REGISTRY: Dict[str, Any] = {
|
||||
"version": "1.0",
|
||||
"types": {
|
||||
"concept": {
|
||||
"chunk_profile": "medium",
|
||||
"edge_defaults": ["references", "related_to"],
|
||||
"retriever_weight": 1.0,
|
||||
}
|
||||
},
|
||||
"_using_defaults": True,
|
||||
"_warning": "types.yaml missing or invalid – using built-in defaults (type=concept).",
|
||||
}
|
||||
|
||||
# Chunk-Profile → Overlap-Empfehlungen (nur für synthetische Fensterbildung)
|
||||
# Die absoluten Chunk-Längen bleiben Aufgabe des Chunkers (assemble_chunks).
|
||||
_PROFILE_TO_OVERLAP: Dict[str, Tuple[int, int]] = {
|
||||
"short": (20, 30),
|
||||
"medium": (40, 60),
|
||||
"long": (60, 80),
|
||||
}
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def load_type_registry(path: str = "config/types.yaml") -> Dict[str, Any]:
|
||||
"""
|
||||
Lädt die Registry aus 'path'. Bei Fehlern wird ein konserviver Default geliefert.
|
||||
Die Rückgabe ist *prozessweit* gecached.
|
||||
"""
|
||||
if not path:
|
||||
return dict(_DEFAULT_REGISTRY)
|
||||
|
||||
if not os.path.isfile(path):
|
||||
return dict(_DEFAULT_REGISTRY)
|
||||
|
||||
if yaml is None:
|
||||
# PyYAML fehlt → auf Default zurückfallen
|
||||
return dict(_DEFAULT_REGISTRY)
|
||||
|
||||
try:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
data = yaml.safe_load(f) or {}
|
||||
# Minimal validieren
|
||||
if not isinstance(data, dict) or "types" not in data or not isinstance(data["types"], dict):
|
||||
return dict(_DEFAULT_REGISTRY)
|
||||
data.setdefault("version", "1.0")
|
||||
data.setdefault("_using_defaults", False)
|
||||
return data
|
||||
except Exception:
|
||||
return dict(_DEFAULT_REGISTRY)
|
||||
|
||||
|
||||
def get_type_config(note_type: Optional[str], reg: Dict[str, Any]) -> Dict[str, Any]:
|
||||
t = (note_type or "concept").strip().lower()
|
||||
types = (reg or {}).get("types", {}) if isinstance(reg, dict) else {}
|
||||
return types.get(t) or types.get("concept") or _DEFAULT_REGISTRY["types"]["concept"]
|
||||
|
||||
|
||||
def resolve_note_type(fm_type: Optional[str], reg: Dict[str, Any]) -> str:
|
||||
"""Liefert einen gültigen Typ (unbekannt → 'concept')."""
|
||||
t = (fm_type or "concept").strip().lower()
|
||||
types = (reg or {}).get("types", {}) if isinstance(reg, dict) else {}
|
||||
return t if t in types else "concept"
|
||||
|
||||
|
||||
def effective_chunk_profile(note_type: Optional[str], reg: Dict[str, Any]) -> Optional[str]:
|
||||
cfg = get_type_config(note_type, reg)
|
||||
prof = cfg.get("chunk_profile")
|
||||
if isinstance(prof, str) and prof.strip():
|
||||
return prof.strip().lower()
|
||||
return None
|
||||
|
||||
|
||||
def profile_overlap(profile: Optional[str]) -> Tuple[int, int]:
|
||||
"""Gibt eine Overlap-Empfehlung (low, high) für das Profil zurück."""
|
||||
if not profile:
|
||||
return _PROFILE_TO_OVERLAP["medium"]
|
||||
return _PROFILE_TO_OVERLAP.get(profile.strip().lower(), _PROFILE_TO_OVERLAP["medium"])
|
||||
@@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Modul: app/graph/service.py
|
||||
Version: 0.1.0
|
||||
Datum: 2025-09-10
|
||||
|
||||
Zweck
|
||||
-----
|
||||
Leichtgewichtiger Graph-Layer über Qdrant:
|
||||
- get_note(note_id)
|
||||
- get_chunks(note_id)
|
||||
- neighbors(source_id, kinds=[...], scope=['note','chunk'], depth=1)
|
||||
- walk_bfs(source_id, kinds, max_depth)
|
||||
- context_for_note(note_id, max_neighbors): heuristische Kontextsammlung
|
||||
|
||||
Hinweise
|
||||
--------
|
||||
- Nutzt die bestehenden Collections <prefix>_notes/_chunks/_edges.
|
||||
- Edges werden über Payload-Felder (`kind`, `source_id`, `target_id`) abgefragt.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
from typing import List, Dict, Any, Optional, Iterable, Set, Tuple
|
||||
from qdrant_client.http import models as rest
|
||||
from app.core.qdrant import QdrantConfig, get_client
|
||||
|
||||
def _cols(prefix: str):
|
||||
return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges"
|
||||
|
||||
class GraphService:
|
||||
def __init__(self, cfg: Optional[QdrantConfig] = None, prefix: Optional[str] = None):
|
||||
self.cfg = cfg or QdrantConfig.from_env()
|
||||
if prefix:
|
||||
self.cfg.prefix = prefix
|
||||
self.client = get_client(self.cfg)
|
||||
self.notes_col, self.chunks_col, self.edges_col = _cols(self.cfg.prefix)
|
||||
|
||||
# ------------------------ fetch helpers ------------------------
|
||||
def _scroll(self, col: str, flt: Optional[rest.Filter] = None, limit: int = 256):
|
||||
out = []
|
||||
nextp = None
|
||||
while True:
|
||||
pts, nextp = self.client.scroll(
|
||||
collection_name=col,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=limit,
|
||||
offset=nextp,
|
||||
scroll_filter=flt,
|
||||
)
|
||||
if not pts:
|
||||
break
|
||||
out.extend(pts)
|
||||
if nextp is None:
|
||||
break
|
||||
return out
|
||||
|
||||
# ------------------------ public API ---------------------------
|
||||
def get_note(self, note_id: str) -> Optional[Dict[str, Any]]:
|
||||
f = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=note_id))])
|
||||
pts, _ = self.client.scroll(self.notes_col, with_payload=True, with_vectors=False, limit=1, scroll_filter=f)
|
||||
return (pts[0].payload or None) if pts else None
|
||||
|
||||
def get_chunks(self, note_id: str) -> List[Dict[str, Any]]:
|
||||
f = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=note_id))])
|
||||
pts = self._scroll(self.chunks_col, f)
|
||||
# Sortierung analog Export
|
||||
def key(pl):
|
||||
p = pl.payload or {}
|
||||
s = p.get("seq") or 0
|
||||
ci = p.get("chunk_index") or 0
|
||||
n = 0
|
||||
cid = p.get("chunk_id") or ""
|
||||
if isinstance(cid, str) and "#" in cid:
|
||||
try:
|
||||
n = int(cid.rsplit("#", 1)[-1])
|
||||
except Exception:
|
||||
n = 0
|
||||
return (int(s), int(ci), n)
|
||||
pts_sorted = sorted(pts, key=key)
|
||||
return [p.payload or {} for p in pts_sorted]
|
||||
|
||||
def neighbors(self, source_id: str, kinds: Optional[Iterable[str]] = None,
|
||||
scope: Optional[Iterable[str]] = None, depth: int = 1) -> Dict[str, List[Dict[str, Any]]]:
|
||||
"""
|
||||
Liefert eingehende & ausgehende Nachbarn (nur nach kind gefiltert).
|
||||
depth==1: direkte Kanten.
|
||||
"""
|
||||
kinds = list(kinds) if kinds else None
|
||||
must = [rest.FieldCondition(key="source_id", match=rest.MatchValue(value=source_id))]
|
||||
if kinds:
|
||||
must.append(rest.FieldCondition(key="kind", match=rest.MatchAny(any=kinds)))
|
||||
f = rest.Filter(must=must)
|
||||
edges = self._scroll(self.edges_col, f)
|
||||
out = {"out": [], "in": []}
|
||||
for e in edges:
|
||||
out["out"].append(e.payload or {})
|
||||
# Inverse Richtung (eingehend)
|
||||
must_in = [rest.FieldCondition(key="target_id", match=rest.MatchValue(value=source_id))]
|
||||
if kinds:
|
||||
must_in.append(rest.FieldCondition(key="kind", match=rest.MatchAny(any=kinds)))
|
||||
f_in = rest.Filter(must=must_in)
|
||||
edges_in = self._scroll(self.edges_col, f_in)
|
||||
for e in edges_in:
|
||||
out["in"].append(e.payload or {})
|
||||
return out
|
||||
|
||||
def walk_bfs(self, source_id: str, kinds: Iterable[str], max_depth: int = 2) -> Set[str]:
|
||||
visited: Set[str] = {source_id}
|
||||
frontier: Set[str] = {source_id}
|
||||
kinds = list(kinds)
|
||||
for _ in range(max_depth):
|
||||
nxt: Set[str] = set()
|
||||
for s in frontier:
|
||||
neigh = self.neighbors(s, kinds=kinds)
|
||||
for e in neigh["out"]:
|
||||
t = e.get("target_id")
|
||||
if isinstance(t, str) and t not in visited:
|
||||
visited.add(t)
|
||||
nxt.add(t)
|
||||
frontier = nxt
|
||||
if not frontier:
|
||||
break
|
||||
return visited
|
||||
|
||||
def context_for_note(self, note_id: str, kinds: Iterable[str] = ("references","backlink"), max_neighbors: int = 12) -> Dict[str, Any]:
|
||||
"""
|
||||
Heuristischer Kontext: eigene Chunks + Nachbarn nach Kantenarten, dedupliziert.
|
||||
"""
|
||||
note = self.get_note(note_id) or {}
|
||||
chunks = self.get_chunks(note_id)
|
||||
neigh = self.neighbors(note_id, kinds=list(kinds))
|
||||
targets = []
|
||||
for e in neigh["out"]:
|
||||
t = e.get("target_id")
|
||||
if isinstance(t, str):
|
||||
targets.append(t)
|
||||
for e in neigh["in"]:
|
||||
s = e.get("source_id")
|
||||
if isinstance(s, str):
|
||||
targets.append(s)
|
||||
# de-dupe
|
||||
seen = set()
|
||||
uniq = []
|
||||
for t in targets:
|
||||
if t not in seen:
|
||||
seen.add(t)
|
||||
uniq.append(t)
|
||||
uniq = uniq[:max_neighbors]
|
||||
neighbor_notes = [self.get_note(t) for t in uniq]
|
||||
return {
|
||||
"note": note,
|
||||
"chunks": chunks,
|
||||
"neighbors": [n for n in neighbor_notes if n],
|
||||
"edges_out": neigh["out"],
|
||||
"edges_in": neigh["in"],
|
||||
}
|
||||
|
||||
# Optional: Mini-CLI
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
import argparse, json
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", help="Collection-Prefix (überschreibt ENV)")
|
||||
ap.add_argument("--note-id", required=True)
|
||||
ap.add_argument("--neighbors", action="store_true", help="Nur Nachbarn anzeigen")
|
||||
args = ap.parse_args()
|
||||
svc = GraphService(prefix=args.prefix)
|
||||
if args.neighbors:
|
||||
out = svc.neighbors(args.note_id, kinds=["references","backlink","prev","next","belongs_to"])
|
||||
else:
|
||||
out = svc.context_for_note(args.note_id)
|
||||
print(json.dumps(out, ensure_ascii=False, indent=2))
|
||||
+21
-3
@@ -1,13 +1,23 @@
|
||||
"""
|
||||
Version 0.3
|
||||
app/main.py — mindnet API bootstrap (WP-04 Hooks)
|
||||
Version: 0.4.2 • Stand: 2025-10-07
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from __future__ import annotations
|
||||
from fastapi import FastAPI
|
||||
from .config import get_settings
|
||||
from .routers.embed_router import router as embed_router
|
||||
from .routers.qdrant_router import router as qdrant_router
|
||||
|
||||
# WP-04 Router:
|
||||
from .routers.query import router as query_router
|
||||
from .routers.graph import router as graph_router
|
||||
from .routers.tools import router as tools_router
|
||||
# Optional:
|
||||
try:
|
||||
from .routers.admin import router as admin_router
|
||||
except Exception:
|
||||
admin_router = None
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
app = FastAPI(title="mindnet API", version="0.1.0")
|
||||
@@ -17,9 +27,17 @@ def create_app() -> FastAPI:
|
||||
def healthz():
|
||||
return {"status": "ok", "qdrant": s.QDRANT_URL, "prefix": s.COLLECTION_PREFIX}
|
||||
|
||||
# Bestehende Router (unverändert)
|
||||
app.include_router(embed_router)
|
||||
app.include_router(qdrant_router)
|
||||
|
||||
# WP-04 Endpunkte
|
||||
app.include_router(query_router, prefix="/query", tags=["query"])
|
||||
app.include_router(graph_router, prefix="/graph", tags=["graph"])
|
||||
app.include_router(tools_router, prefix="/tools", tags=["tools"])
|
||||
if admin_router:
|
||||
app.include_router(admin_router, prefix="/admin", tags=["admin"])
|
||||
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
app/models/__init__.py — Package-Init für mindnet DTOs (WP-04)
|
||||
Version: 0.1.0 • Stand: 2025-10-07
|
||||
"""
|
||||
|
||||
from .dto import (
|
||||
EdgeKind,
|
||||
NodeDTO,
|
||||
EdgeDTO,
|
||||
QueryRequest,
|
||||
QueryHit,
|
||||
QueryResponse,
|
||||
GraphResponse,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"EdgeKind",
|
||||
"NodeDTO",
|
||||
"EdgeDTO",
|
||||
"QueryRequest",
|
||||
"QueryHit",
|
||||
"QueryResponse",
|
||||
"GraphResponse",
|
||||
]
|
||||
@@ -0,0 +1,94 @@
|
||||
"""
|
||||
app/models/dto.py — Pydantic-Modelle (DTOs) für WP-04 Endpunkte
|
||||
|
||||
Zweck:
|
||||
Laufzeit-Modelle für FastAPI (Requests/Responses), getrennt von JSON-Schemas.
|
||||
Deckt die Graph-/Retriever-Endpunkte ab, ohne bestehende Funktionen zu ändern.
|
||||
Kompatibilität:
|
||||
Python 3.12+, Pydantic 2.x, FastAPI 0.110+
|
||||
Version:
|
||||
0.1.0 (Erstanlage für WP-04)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
- schemas/*.json (Speicherschema für Notes/Chunks/Edges)
|
||||
- WP-04 API-Design (Query- und Graph-Endpunkte)
|
||||
Nutzung:
|
||||
from app.models.dto import QueryRequest, QueryResponse, GraphResponse
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Literal, Optional, Dict
|
||||
|
||||
EdgeKind = Literal["references", "references_at", "backlink", "next", "prev", "belongs_to"]
|
||||
|
||||
|
||||
class NodeDTO(BaseModel):
|
||||
"""Darstellung eines Knotens (Note oder Chunk) im API-Graph."""
|
||||
id: str
|
||||
type: Literal["note", "chunk"]
|
||||
title: Optional[str] = None
|
||||
note_id: Optional[str] = None
|
||||
tags: Optional[List[str]] = None
|
||||
in_degree: Optional[int] = None
|
||||
out_degree: Optional[int] = None
|
||||
score: Optional[float] = None
|
||||
section_title: Optional[str] = None
|
||||
section_path: Optional[str] = None
|
||||
path: Optional[str] = None
|
||||
|
||||
|
||||
class EdgeDTO(BaseModel):
|
||||
"""Darstellung einer Kante im API-Graph."""
|
||||
id: str
|
||||
kind: EdgeKind
|
||||
source: str
|
||||
target: str
|
||||
weight: float
|
||||
direction: Literal["out", "in", "undirected"] = "out"
|
||||
|
||||
|
||||
class QueryRequest(BaseModel):
|
||||
"""
|
||||
Request für /query:
|
||||
- mode: 'semantic' | 'edge' | 'hybrid'
|
||||
- query: (optional) Freitext; Embedding wird später angebunden
|
||||
- query_vector: (optional) direkter Vektor (384d) für Quick-Tests ohne Embedding
|
||||
"""
|
||||
mode: Literal["semantic", "edge", "hybrid"] = "hybrid"
|
||||
query: Optional[str] = None
|
||||
query_vector: Optional[List[float]] = None
|
||||
top_k: int = 10
|
||||
expand: Dict = {"depth": 1, "edge_types": ["references", "belongs_to", "prev", "next"]}
|
||||
filters: Optional[Dict] = None
|
||||
ret: Dict = {"with_paths": True, "with_notes": True, "with_chunks": True}
|
||||
|
||||
|
||||
class QueryHit(BaseModel):
|
||||
"""Einzelnes Trefferobjekt für /query."""
|
||||
node_id: str
|
||||
note_id: Optional[str]
|
||||
semantic_score: float
|
||||
edge_bonus: float
|
||||
centrality_bonus: float
|
||||
total_score: float
|
||||
paths: Optional[List[List[Dict]]] = None
|
||||
source: Optional[Dict] = None
|
||||
|
||||
|
||||
class QueryResponse(BaseModel):
|
||||
"""Antwortstruktur für /query (Liste von Treffern + Telemetrie)."""
|
||||
results: List[QueryHit]
|
||||
used_mode: str
|
||||
latency_ms: int
|
||||
|
||||
|
||||
class GraphResponse(BaseModel):
|
||||
"""Antwortstruktur für /graph/{note_id} (Nachbarschaft)."""
|
||||
center_note_id: str
|
||||
nodes: List[NodeDTO]
|
||||
edges: List[EdgeDTO]
|
||||
stats: Dict[str, int]
|
||||
@@ -0,0 +1,38 @@
|
||||
"""
|
||||
app/models/__init__.py — Package-Init für mindnet DTOs
|
||||
|
||||
Zweck:
|
||||
Stellt zentrale API-/DTO-Modelle als Import-Fassade bereit.
|
||||
Kompatibilität:
|
||||
Python 3.12+, Pydantic 2.x
|
||||
Version:
|
||||
0.1.0 (Erstanlage für WP-04)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
Handbuch / Knowledge Design (WP-03/04)
|
||||
Nutzung:
|
||||
from app.models import QueryRequest, QueryResponse, GraphResponse
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from .dto import (
|
||||
EdgeKind,
|
||||
NodeDTO,
|
||||
EdgeDTO,
|
||||
QueryRequest,
|
||||
QueryHit,
|
||||
QueryResponse,
|
||||
GraphResponse,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"EdgeKind",
|
||||
"NodeDTO",
|
||||
"EdgeDTO",
|
||||
"QueryRequest",
|
||||
"QueryHit",
|
||||
"QueryResponse",
|
||||
"GraphResponse",
|
||||
]
|
||||
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
app/routers/admin.py — Admin-/Monitoring-Endpunkte (optional)
|
||||
|
||||
Zweck:
|
||||
Liefert einfache Kennzahlen zu Collections (Counts) und Config.
|
||||
Kompatibilität:
|
||||
Python 3.12+, FastAPI 0.110+, qdrant-client 1.x
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
- Qdrant Collections: *_notes, *_chunks, *_edges
|
||||
Nutzung:
|
||||
app.include_router(admin.router, prefix="/admin", tags=["admin"])
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from fastapi import APIRouter
|
||||
from qdrant_client import QdrantClient
|
||||
from app.config import get_settings
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/stats")
|
||||
def stats():
|
||||
s = get_settings()
|
||||
client = QdrantClient(url=s.QDRANT_URL, api_key=s.QDRANT_API_KEY)
|
||||
notes = f"{s.COLLECTION_PREFIX}_notes"
|
||||
chunks = f"{s.COLLECTION_PREFIX}_chunks"
|
||||
edges = f"{s.COLLECTION_PREFIX}_edges"
|
||||
|
||||
def _count(col: str) -> int:
|
||||
try:
|
||||
return client.count(collection_name=col, exact=True).count
|
||||
except Exception:
|
||||
return -1
|
||||
|
||||
return {
|
||||
"collections": {
|
||||
"notes": {"name": notes, "count": _count(notes)},
|
||||
"chunks": {"name": chunks, "count": _count(chunks)},
|
||||
"edges": {"name": edges, "count": _count(edges)},
|
||||
},
|
||||
"config": {
|
||||
"qdrant": s.QDRANT_URL,
|
||||
"prefix": s.COLLECTION_PREFIX,
|
||||
"vector_size": s.VECTOR_SIZE,
|
||||
"distance": s.DISTANCE,
|
||||
"retriever": {
|
||||
"w_sem": s.RETRIEVER_W_SEM,
|
||||
"w_edge": s.RETRIEVER_W_EDGE,
|
||||
"w_cent": s.RETRIEVER_W_CENT,
|
||||
"top_k": s.RETRIEVER_TOP_K,
|
||||
"expand_depth": s.RETRIEVER_EXPAND_DEPTH,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
"""
|
||||
app/routers/graph.py — Graph-Endpunkte (WP-04)
|
||||
|
||||
Zweck:
|
||||
Liefert die Nachbarschaft einer Note/ID als JSON-Graph (Nodes/Edges/Stats).
|
||||
Kompatibilität:
|
||||
Python 3.12+, FastAPI 0.110+, qdrant-client 1.x
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
- app/core/graph_adapter.py
|
||||
- app/models/dto.py
|
||||
Nutzung:
|
||||
app.include_router(graph.router, prefix="/graph", tags=["graph"])
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import List, Optional
|
||||
from fastapi import APIRouter, Query
|
||||
from qdrant_client import QdrantClient
|
||||
from app.models.dto import GraphResponse, NodeDTO, EdgeDTO
|
||||
from app.core.graph_adapter import expand
|
||||
from app.config import get_settings
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/{note_id}", response_model=GraphResponse)
|
||||
def get_graph(note_id: str, depth: int = 1, edge_types: Optional[List[str]] = Query(None)) -> GraphResponse:
|
||||
s = get_settings()
|
||||
client = QdrantClient(url=s.QDRANT_URL, api_key=s.QDRANT_API_KEY)
|
||||
|
||||
sg = expand(client, s.COLLECTION_PREFIX, [note_id], depth=depth, edge_types=edge_types)
|
||||
|
||||
# Seed-Node (Payload optional später ergänzen über get_note_payload)
|
||||
nodes = [NodeDTO(id=note_id, type="note",
|
||||
title=None, tags=[],
|
||||
in_degree=sg.in_degree.get(note_id, 0),
|
||||
out_degree=sg.out_degree.get(note_id, 0))]
|
||||
|
||||
# direkte Out-Kanten des Seeds
|
||||
edges = []
|
||||
for e in sg.adj.get(note_id, []):
|
||||
edges.append(EdgeDTO(
|
||||
id=f"{note_id}->{e['target']}:{e['kind']}",
|
||||
kind=e["kind"], source=note_id, target=e["target"],
|
||||
weight=float(e["weight"]), direction="out"
|
||||
))
|
||||
|
||||
return GraphResponse(center_note_id=note_id, nodes=nodes, edges=edges,
|
||||
stats={"node_count": len(nodes), "edge_count": len(edges)})
|
||||
@@ -0,0 +1,38 @@
|
||||
"""
|
||||
app/routers/query.py — Query-Endpunkte (WP-04)
|
||||
|
||||
Zweck:
|
||||
Stellt POST /query bereit und ruft den passenden Retriever-Modus auf.
|
||||
Kompatibilität:
|
||||
Python 3.12+, FastAPI 0.110+
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
- app/core/retriever.py
|
||||
- app/models/dto.py
|
||||
Nutzung:
|
||||
app.include_router(query.router, prefix="/query", tags=["query"])
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from app.models.dto import QueryRequest, QueryResponse
|
||||
from app.core.retriever import hybrid_retrieve, semantic_retrieve
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("", response_model=QueryResponse)
|
||||
def post_query(req: QueryRequest) -> QueryResponse:
|
||||
try:
|
||||
if req.mode == "semantic":
|
||||
return semantic_retrieve(req)
|
||||
# default: hybrid
|
||||
return hybrid_retrieve(req)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"query failed: {e}")
|
||||
@@ -0,0 +1,84 @@
|
||||
"""
|
||||
app/routers/tools.py — Tool-Definitionen für Ollama/n8n/MCP (read-only)
|
||||
|
||||
Zweck:
|
||||
Liefert Funktions-Schemas (OpenAI-/Ollama-kompatibles Tool-JSON) für:
|
||||
- mindnet_query -> POST /query
|
||||
- mindnet_subgraph -> GET /graph/{note_id}
|
||||
Kompatibilität:
|
||||
Python 3.12+, FastAPI 0.110+
|
||||
Version:
|
||||
0.1.1 (query ODER query_vector möglich)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Nutzung:
|
||||
app.include_router(tools.router, prefix="/tools", tags=["tools"])
|
||||
Änderungsverlauf:
|
||||
0.1.1 (2025-10-07) – mindnet_query: oneOf(query, query_vector).
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
TOOLS = {
|
||||
"tools": [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "mindnet_query",
|
||||
"description": "Hybrid-Retrieval über mindnet (Semantik + Edges).",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"oneOf": [
|
||||
{"required": ["query"]},
|
||||
{"required": ["query_vector"]}
|
||||
],
|
||||
"properties": {
|
||||
"query": {
|
||||
"type": "string",
|
||||
"description": "Freitext-Query; wird serverseitig in 384-d Embedding konvertiert."
|
||||
},
|
||||
"query_vector": {
|
||||
"type": "array",
|
||||
"items": {"type": "number"},
|
||||
"description": "Direkter 384-d Query-Vektor (optional)."
|
||||
},
|
||||
"top_k": {"type":"integer","default":10,"minimum":1,"maximum":50},
|
||||
"expand_depth": {"type":"integer","default":1,"minimum":0,"maximum":3},
|
||||
"edge_types": {
|
||||
"type":"array","items":{"type":"string"},
|
||||
"default": ["references","belongs_to","prev","next"]
|
||||
},
|
||||
"filters": {"type":"object","description":"payload-Filter (tags etc.)"}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "mindnet_subgraph",
|
||||
"description": "Gibt die Nachbarschaft (Edges) einer Note/Seed-ID zurück.",
|
||||
"parameters": {
|
||||
"type":"object",
|
||||
"properties": {
|
||||
"note_id":{"type":"string"},
|
||||
"depth":{"type":"integer","default":1,"minimum":0,"maximum":3},
|
||||
"edge_types":{
|
||||
"type":"array","items":{"type":"string"},
|
||||
"default":["references","belongs_to","prev","next","backlink"]
|
||||
}
|
||||
},
|
||||
"required":["note_id"]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@router.get("/ollama")
|
||||
def get_ollama_tools():
|
||||
return TOOLS
|
||||
@@ -0,0 +1,46 @@
|
||||
"""
|
||||
app/services/embeddings_client.py — Text→Embedding (WP-04)
|
||||
|
||||
Zweck:
|
||||
Liefert 384-d Embeddings für Textqueries (lazy load, einmal pro Prozess).
|
||||
Standard: Sentence-Transformers (MODEL_NAME aus app.config.Settings).
|
||||
Hinweis: Kein Netz-Zugriff; nutzt lokal installierte Modelle.
|
||||
Kompatibilität:
|
||||
Python 3.12+, sentence-transformers 5.x
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
- app/core/retriever.py (nutzt embed_text_if_needed)
|
||||
- app/config.py (MODEL_NAME, VECTOR_SIZE)
|
||||
Nutzung:
|
||||
from app.services.embeddings_client import embed_text
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import List
|
||||
from functools import lru_cache
|
||||
from app.config import get_settings
|
||||
|
||||
# Lazy import, damit Testläufe ohne Modell-Laden schnell sind
|
||||
def _load_model():
|
||||
from sentence_transformers import SentenceTransformer # import hier, nicht top-level
|
||||
s = get_settings()
|
||||
return SentenceTransformer(s.MODEL_NAME, device="cpu")
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def _cached_model():
|
||||
return _load_model()
|
||||
|
||||
def embed_text(text: str) -> List[float]:
|
||||
"""
|
||||
Erzeugt einen 384-d Vektor (oder laut Settings.VECTOR_SIZE) für den gegebenen Text.
|
||||
"""
|
||||
if not text or not text.strip():
|
||||
raise ValueError("embed_text: leerer Text")
|
||||
model = _cached_model()
|
||||
vec = model.encode([text], normalize_embeddings=True)[0]
|
||||
return vec.astype(float).tolist()
|
||||
@@ -0,0 +1,88 @@
|
||||
"""
|
||||
app/services/llm_ollama.py — Ollama-Integration & Prompt-Bau (WP-04)
|
||||
|
||||
Zweck:
|
||||
Prompt-Template & (optionaler) lokaler Aufruf von Ollama. Der Aufruf ist
|
||||
bewusst gekapselt und kann gefahrlos deaktiviert bleiben, bis ihr ein
|
||||
konkretes Modell konfigurieren wollt.
|
||||
Kompatibilität:
|
||||
Python 3.12+
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
WP-04/05 Kontextbereitstellung für LLM
|
||||
Nutzung:
|
||||
from app.services.llm_ollama import build_prompt, call_ollama
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import List, Dict, Optional
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
PROMPT_TEMPLATE = """System: You are a helpful expert.
|
||||
User: {question}
|
||||
|
||||
Context (ranked):
|
||||
{contexts}
|
||||
|
||||
Task: Answer precisely. At the end, list sources (note title + section) and important edge paths.
|
||||
"""
|
||||
|
||||
|
||||
def build_context_block(items: List[Dict]) -> str:
|
||||
"""Formatiert Top-K-Kontexte (Chunks) für den Prompt."""
|
||||
lines = []
|
||||
for i, it in enumerate(items, 1):
|
||||
note = it.get("note_title", "") or it.get("note_id", "")
|
||||
sec = it.get("section", "") or it.get("section_title", "")
|
||||
sc = it.get("score", 0)
|
||||
txt = it.get("text", "") or it.get("body", "") or ""
|
||||
lines.append(f"{i}) {note} — {sec} [score={sc:.2f}]\n{txt}\n")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def build_prompt(question: str, contexts: List[Dict]) -> str:
|
||||
"""Setzt Frage + Kontexte in ein konsistentes Template."""
|
||||
return PROMPT_TEMPLATE.format(question=question, contexts=build_context_block(contexts))
|
||||
|
||||
|
||||
def call_ollama(prompt: str, model: str = "llama3.1:8b", timeout_s: int = 120) -> Optional[str]:
|
||||
"""
|
||||
Optionaler lokaler Aufruf von `ollama run`.
|
||||
Rückgabe: generierter Text oder None bei Fehler/Abbruch.
|
||||
Hinweis: Nur nutzen, wenn Ollama lokal installiert/konfiguriert ist.
|
||||
"""
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
["ollama", "run", model],
|
||||
input=prompt.encode("utf-8"),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
timeout=timeout_s,
|
||||
check=False,
|
||||
)
|
||||
out = proc.stdout.decode("utf-8", errors="replace")
|
||||
# viele ollama Builds streamen JSON-Zeilen; robust extrahieren:
|
||||
try:
|
||||
# Falls JSONL, letztes "response" zusammenfassen
|
||||
texts = []
|
||||
for line in out.splitlines():
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
try:
|
||||
obj = json.loads(line)
|
||||
if "response" in obj:
|
||||
texts.append(obj["response"])
|
||||
except Exception:
|
||||
texts.append(line)
|
||||
return "".join(texts).strip()
|
||||
except Exception:
|
||||
return out.strip()
|
||||
except Exception:
|
||||
return None
|
||||
@@ -0,0 +1,18 @@
|
||||
version: 1.0
|
||||
types:
|
||||
concept:
|
||||
chunk_profile: medium
|
||||
edge_defaults: ["references", "related_to"]
|
||||
retriever_weight: 0.33
|
||||
task:
|
||||
chunk_profile: short
|
||||
edge_defaults: ["depends_on", "belongs_to"]
|
||||
retriever_weight: 0.8
|
||||
experience:
|
||||
chunk_profile: medium
|
||||
edge_defaults: ["derived_from", "inspired_by"]
|
||||
retriever_weight: 0.9
|
||||
project:
|
||||
chunk_profile: long
|
||||
edge_defaults: ["references", "depends_on"]
|
||||
retriever_weight: 0.95
|
||||
@@ -0,0 +1,21 @@
|
||||
# Changelog — WP-03 Type-Registry (2025-11-08)
|
||||
|
||||
## Added
|
||||
- `app/core/type_registry.py` — Loader & Helper (cached), robust Fallbacks.
|
||||
- `config/types.yaml` — Beispiel-Registry (version 1.0).
|
||||
- `scripts/import_markdown.py` v3.8.0 — Registry-Integration:
|
||||
- typvalidierung (unbekannt → `concept`, Warnung)
|
||||
- `chunk_profile` → an `make_chunk_payloads(...)`
|
||||
- `retriever_weight` → persistiert im Note-Payload
|
||||
- `edge_defaults["references"]` schaltet Note-Scope-Refs additiv ein
|
||||
- `app/core/chunk_payload.py` v2.3.0 — optionales `chunk_profile` für
|
||||
synthetische Overlaps (keine Schemaänderung).
|
||||
- `app/core/derive_edges.py` v1.5.0 — Type-Registry aktiviert note-scope
|
||||
References/Backlinks additiv.
|
||||
|
||||
## Changed
|
||||
- Keine Breaking Changes. Alle CLI-Flags, ENV-Variablen und Collection-
|
||||
Prefix-Logik bleiben unverändert.
|
||||
|
||||
## Removed
|
||||
- N/A
|
||||
@@ -0,0 +1,349 @@
|
||||
# 📘 Mindnet Skript-Handbuch (aktualisiert)
|
||||
|
||||
Dieses Handbuch dokumentiert die Skripte und Tests für das Projekt **mindnet Wissensnetzwerk**.
|
||||
Es beschreibt Zweck, Parameter, typische Aufrufe sowie aktuelle Verhaltensweisen (Hash-Modi, Parser-Robustheit, `window`/`text`-Trennung in Chunks, Export-Fixes).
|
||||
Alle Beispiele sind so formatiert, dass sie direkt kopierbar sind. **Code/CLI-Beispiele sind eingerückt**, damit die Markdown-Darstellung nicht abbricht.
|
||||
|
||||
---
|
||||
|
||||
## 0) Umgebung & Konfiguration
|
||||
|
||||
**Wichtige ENV-Variablen**
|
||||
|
||||
- `QDRANT_URL` – z. B. `http://localhost:6333`
|
||||
- `QDRANT_API_KEY` – API-Key (falls aktiviert)
|
||||
- `COLLECTION_PREFIX` – Prefix der drei Collections, Standard: `mindnet` → `mindnet_notes`, `mindnet_chunks`, `mindnet_edges`
|
||||
- `VECTOR_DIM` – Embedding-Dimension (Chunks), Standard: `384`
|
||||
|
||||
**Hash-Vergleich & Änderungserkennung**
|
||||
|
||||
- `MINDNET_HASH_COMPARE` – steuert, **welcher Anteil** für „changed“ verglichen wird
|
||||
Werte: `Body` (Standard), `Frontmatter`, `Full`
|
||||
- `MINDNET_HASH_SOURCE` – Quelle: `parsed` (Standard), `raw`, `file`
|
||||
- `MINDNET_HASH_NORMALIZE` – Normalisierung: `canonical` (Standard) oder `none`
|
||||
|
||||
**Beispiel (nur Body berücksichtigen, kanonisch, geparst):**
|
||||
|
||||
export MINDNET_HASH_COMPARE=Body
|
||||
export MINDNET_HASH_SOURCE=parsed
|
||||
export MINDNET_HASH_NORMALIZE=canonical
|
||||
source .venv/bin/activate
|
||||
|
||||
**Baseline-Signaturen (mehrere Modi):**
|
||||
Der Importer kann **Signaturen aller Modi** (Body/Frontmatter/Full) vorhalten, damit spätere Moduswechsel deterministisch sind (keine „Mass-Changes“). Siehe `--baseline-modes` unter **Importer**.
|
||||
|
||||
---
|
||||
|
||||
## 1) Vault anlegen (für Tests)
|
||||
|
||||
### `scripts/make_test_vault.py`
|
||||
|
||||
**Zweck:**
|
||||
Erstellt einen kleinen, nachvollziehbaren Test-Vault mit Markdown-Dateien.
|
||||
Szenarien: offene Links, nachträgliche Anlage fehlender Notes, geänderte Chunk-Grenzen.
|
||||
|
||||
**Parameter:**
|
||||
- `--out PATH` : Zielverzeichnis (Default: `./test_vault`)
|
||||
- `--force` : Existierenden Ordner löschen und neu anlegen
|
||||
- `--with-missing` : Optional – auch die `missing-note` gleich anlegen
|
||||
|
||||
**Hinweise für Tests**
|
||||
1. Erster Import (dry-run oder `--apply`): Es gibt einen „leeren“ Link `[[missing-note]]`.
|
||||
2. Lege danach eine Datei für „missing-note“ an (mit gleicher `id` im YAML) und importiere erneut:
|
||||
→ Erwartung: Edges für ehemals leeren Link werden korrekt nachgezogen (`references` + `backlink`).
|
||||
3. Ändere den Body von `exp-one.md` so, dass andere Chunk-Grenzen entstehen und importiere erneut:
|
||||
→ Erwartung: Chunks/Edges/Note werden für betroffene Noten aktualisiert.
|
||||
|
||||
**Kompatibilität:**
|
||||
- `note.schema.json`: `created`/`updated` sind Strings.
|
||||
|
||||
**Beispiele:**
|
||||
|
||||
python3 -m scripts.make_test_vault --out ./test_vault --force
|
||||
python3 -m scripts.make_test_vault --out ./test_vault --force --with-missing
|
||||
|
||||
---
|
||||
|
||||
## 2) Import in Qdrant
|
||||
|
||||
### `scripts/import_markdown.py`
|
||||
|
||||
**Zweck:**
|
||||
Importiert Notes/Chunks/Edges aus einem Vault nach Qdrant.
|
||||
- validiert Frontmatter
|
||||
- chunked Inhalte + Embeddings
|
||||
- erzeugt Edges (`references`, `references_at`, `backlink`, `next`, `prev`, `belongs_to`)
|
||||
- erkennt geänderte Dateien **modusgesteuert** (Body/Frontmatter/Full)
|
||||
- optional: Purge der alten Chunks/Edges pro Note
|
||||
|
||||
**Parameter:**
|
||||
- `--vault PATH` : (Pflicht) Vault-Verzeichnis
|
||||
- `--apply` : Änderungen wirklich durchführen (ohne: Dry-Run)
|
||||
- `--purge-before-upsert` : Vor Upsert alte Chunks/Edges **nur der geänderten Notes** löschen
|
||||
- `--prefix STR` : überschreibt `COLLECTION_PREFIX`
|
||||
- `--note-id ID` : nur eine bestimmte Note importieren
|
||||
- `--note-scope-refs` : zusätzlich **note-weite** `references` erzeugen (nicht nur chunk-weise)
|
||||
- `--baseline-modes` : berechne & speichere Hash-Signaturen für **alle** Modi (`Body`, `Frontmatter`, `Full`) als Baseline
|
||||
|
||||
**Erwartetes Verhalten:**
|
||||
- Unveränderte Notes → `"changed": false`, Entscheidung: `apply-skip-unchanged` (bei `--apply`)
|
||||
- Geänderte Notes → `"changed": true` (abhängig von `MINDNET_HASH_COMPARE`)
|
||||
- Idempotenz: mehrfacher Lauf ohne Änderungen erzeugt **keine** neuen Punkte
|
||||
- Baseline: Bei `--baseline-modes` erscheinen Felder wie `hash_signature`, `hash_fulltext`, ggf. `hash_frontmatter` und `needs_baseline_for_mode: false` bei Folgeläufen.
|
||||
|
||||
**Beispiele:**
|
||||
|
||||
# Dry-Run (zeigt Änderungen, schreibt NICHT)
|
||||
python3 -m scripts.import_markdown --vault ./vault --prefix mindnet
|
||||
|
||||
# Apply + gezielte Vorreinigung pro geänderter Note
|
||||
python3 -m scripts.import_markdown --vault ./vault --prefix mindnet --apply --purge-before-upsert
|
||||
|
||||
# Baseline-Signaturen aller Modi vorhalten
|
||||
python3 -m scripts.import_markdown --vault ./vault --apply --baseline-modes
|
||||
|
||||
**Hash-Modi in der Praxis:**
|
||||
- `MINDNET_HASH_COMPARE=Body` → Änderungen im Body werden erkannt; reine Frontmatter-Änderungen bleiben **ohne Effekt**.
|
||||
- `MINDNET_HASH_COMPARE=Frontmatter` → nur Frontmatter maßgeblich.
|
||||
- `MINDNET_HASH_COMPARE=Full` → beide Anteile zählen.
|
||||
|
||||
---
|
||||
|
||||
## 3) Konsistenzprüfungen
|
||||
|
||||
### `scripts/audit_vault_vs_qdrant.py`
|
||||
|
||||
**Zweck:**
|
||||
Vergleicht Vault-Inhalte mit Qdrant.
|
||||
- Zählt Notes/Chunks/Edges
|
||||
- Verifiziert Anzahl Wikilinks vs. Edges
|
||||
- Meldet Deltas (z. B. `references` im Vault vs. in Qdrant)
|
||||
|
||||
**Parameter:**
|
||||
- `--vault PATH` : Vault-Verzeichnis
|
||||
- `--prefix STR` : Prefix für Qdrant-Collections (Default: `mindnet`)
|
||||
|
||||
**Beispiel:**
|
||||
|
||||
python3 -m scripts.audit_vault_vs_qdrant --vault ./vault --prefix mindnet
|
||||
|
||||
### `scripts/validate_edges.py`
|
||||
|
||||
**Zweck:**
|
||||
Prüft die Edges-Collection in Qdrant.
|
||||
- Zählt Edges pro Typ (`references`, `references_at`, `backlink`, `next`, `prev`, `belongs_to`)
|
||||
- Kontrolliert Invarianten (z. B. jede `references` hat einen `backlink`)
|
||||
- Listet `unresolved` Edges auf
|
||||
|
||||
**Parameter:**
|
||||
- `--prefix STR` : Prefix für Qdrant-Collections
|
||||
- `--details` : Detailausgabe mit Beispielen
|
||||
|
||||
**Beispiel:**
|
||||
|
||||
python3 -m scripts.validate_edges --prefix mindnet --details
|
||||
|
||||
---
|
||||
|
||||
## 4) Export Qdrant → Markdown (Vault)
|
||||
|
||||
### `scripts/export_markdown.py`
|
||||
|
||||
**Zweck:**
|
||||
Exportiert Notes + rekonstruierten Body in einen Zielordner.
|
||||
- Pfade werden **relativ** aus `note.payload.path` abgeleitet (führende `/` entfernt, Backslashes → Slashes; Unicode-NFC empfohlen)
|
||||
- **Body-Rekonstruktion** priorisiert:
|
||||
1. `fulltext` (falls in Note-Payload vorhanden)
|
||||
2. sonst **Chunks**: Sortierung `seq` → `chunk_index` → Nummer in `chunk_id`; **nur `text`** (Overlap bereits entfernt)
|
||||
- `--prefix` (CLI) wird unterstützt (oder ENV `COLLECTION_PREFIX`)
|
||||
|
||||
**Parameter:**
|
||||
- `--out PATH` : Ziel-Root (muss existieren)
|
||||
- `--overwrite` : vorhandene Dateien überschreiben
|
||||
- `--note-id ID` : nur eine bestimmte Note exportieren
|
||||
- `--prefix STR` : überschreibt `COLLECTION_PREFIX`
|
||||
- `--include-edges {none,footer,yaml}` *(optional, falls aktiviert)*: Edges als YAML-Liste im Frontmatter oder im Footer beilegen
|
||||
|
||||
**Beispiele:**
|
||||
|
||||
export COLLECTION_PREFIX="mindnet"
|
||||
python3 -m scripts.export_markdown --out ./_exportVault
|
||||
|
||||
# Nur eine bestimmte Note:
|
||||
python3 -m scripts.export_markdown --out ./_exportVault --note-id 20250821-architektur-ki-trainerassistent-761cfe
|
||||
|
||||
# Existierende Dateien überschreiben:
|
||||
python3 -m scripts.export_markdown --out ./_exportVault --overwrite
|
||||
|
||||
---
|
||||
|
||||
## 5) Qdrant zurücksetzen
|
||||
|
||||
### `scripts/reset_qdrant.py`
|
||||
|
||||
**Zweck:**
|
||||
Setzt die Qdrant-Collections zurück.
|
||||
- `wipe`: löscht Collections komplett (inkl. Schema)
|
||||
- `truncate`: löscht nur Inhalte, behält Collections
|
||||
- `truncate-edges`: löscht nur Punkte in `*_edges`
|
||||
|
||||
**Parameter:**
|
||||
- `--mode {wipe,truncate,truncate-edges}`
|
||||
- `--prefix STR` : Prefix der Collections (Default: `mindnet`)
|
||||
- `--yes` : Automatische Bestätigung
|
||||
- `--dry-run` : Nur anzeigen, nicht ausführen
|
||||
|
||||
**Beispiele:**
|
||||
|
||||
python3 -m scripts.reset_qdrant --mode truncate-edges --prefix mindnet
|
||||
python3 -m scripts.reset_qdrant --mode truncate --prefix mindnet --yes
|
||||
python3 -m scripts.reset_qdrant --mode wipe --prefix mindnet --yes
|
||||
|
||||
---
|
||||
|
||||
## 6) Diagnose & Tools
|
||||
|
||||
### `scripts/diagnose_changed.py`
|
||||
|
||||
**Zweck:**
|
||||
Prüft, ob Datei-Hashes (`sha256`) mit gespeicherten `hash_*` in Qdrant übereinstimmen.
|
||||
Hilft, wenn der Importer zu viele Dateien als „changed“ erkennt oder Moduswechsel geplant sind.
|
||||
|
||||
**Parameter:**
|
||||
- `--vault PATH` : Vault-Verzeichnis
|
||||
- `--prefix STR` : Prefix (Default: `mindnet`)
|
||||
- `--note-id ID` : Nur bestimmte Note prüfen
|
||||
- `--all` : Alle Notes prüfen
|
||||
|
||||
**Beispiel:**
|
||||
|
||||
python3 -m scripts.diagnose_changed --vault ./vault --prefix mindnet --all
|
||||
|
||||
### `scripts/resolve_unresolved_references.py`
|
||||
|
||||
**Zweck:**
|
||||
Prüft offene Wikilinks (`status=unresolved`) und fügt Edges nach, wenn inzwischen passende Notizen existieren.
|
||||
Ersetzt `unresolved` durch gültige `references`/`backlink`.
|
||||
|
||||
**Parameter:**
|
||||
- `--prefix STR` : Prefix für Qdrant-Collections
|
||||
- `--apply` : Änderungen wirklich ausführen (sonst nur Vorschau)
|
||||
|
||||
**Beispiele:**
|
||||
|
||||
python3 -m scripts.resolve_unresolved_references --prefix mindnet
|
||||
python3 -m scripts.resolve_unresolved_references --prefix mindnet --apply
|
||||
|
||||
---
|
||||
|
||||
## 7) Parser-Verhalten (robust & abwärtskompatibel)
|
||||
|
||||
- Der Parser liest Markdown **fehlertolerant** (UTF-8 mit Fallbacks), extrahiert YAML-Frontmatter und Body.
|
||||
- Keine harten Abhängigkeiten von alten Regex-Symbolen (`FRONTMATTER_RE` entfällt zugunsten interner Marker).
|
||||
- `read_markdown(path)` gibt `(frontmatter_dict, body_str)` zurück.
|
||||
- **Sonderfälle aus Fremd-Tools** (z. B. Silverbullet-Dateien wie `CONFIG.md`, `index.md`) werden **nicht importiert**, sofern sie nicht zum Vault gehören.
|
||||
|
||||
---
|
||||
|
||||
## 8) Chunk-Payload (Fenster vs. Kern)
|
||||
|
||||
- **`window`** = kontextualisierter Fenster-Text (mit linkem Overlap)
|
||||
- **`text`** = **Kerntext** ohne das vom vorherigen Chunk übernommene Overlap
|
||||
- Felder: `start`, `end`, `overlap_left`, `overlap_right`, `chunk_index`, `seq`, `path`, `section_title`, `section_path`, `token_count` (falls vorhanden)
|
||||
- **Fallback (synthetisch):** Falls der Chunker **keinen** Overlap-Fenstertext liefert, erzeugt die Payload-Schicht Fenster mit typgerechtem Overlap aus `chunk_config.get_sizes(type)['overlap']` (unterer Wert).
|
||||
- **Edges** werden aus `window` abgeleitet (um Links an Chunk-Grenzen nicht zu verlieren); der **Export** rekonstruiert den Body aus `text` (Overlap-frei).
|
||||
|
||||
---
|
||||
|
||||
## 9) Edge-Modell & IDs
|
||||
|
||||
- Collections:
|
||||
`*_notes` (optional Vektor / Nullvektor), `*_chunks` (384-d Embeddings), `*_edges` (1-d Dummy-Vektor)
|
||||
- **Deterministische IDs** (UUIDv5 / stabile Keys):
|
||||
- `note_id` stabil aus Frontmatter/Slug
|
||||
- `chunk_id` i. d. R. `note_id#<n>`
|
||||
- `edge_id` stabil aus `(kind, source_id, target_id, seq)`
|
||||
- Kantenarten: `references`, `references_at`, `backlink`, `next`, `prev`, `belongs_to`
|
||||
- `unresolved` wird gekennzeichnet und kann per Resolver später aufgelöst werden.
|
||||
|
||||
---
|
||||
|
||||
## 10) Tests & Qualitätssicherung
|
||||
|
||||
**Tests unter `tests/`**
|
||||
|
||||
- `check_chunks_window_vs_text.py` – vergleicht je Chunk `window` vs. `text`, schätzt Overlap
|
||||
- `compare_vaults.py` – rekursiver Vault-Vergleich (Body/Frontmatter/All, Key: auto/id/title/filename), Unicode-NFC-robust
|
||||
- `verify_chunks_integrity.py` – prüft, ob Rekonstruktion aus Chunks (`text`) zu `fulltext` bzw. zum Vault-Body passt
|
||||
- `list_md_seen_by_importer.py` – zeigt, welche `.md` der Importer sieht (inkl. Gründe/Filter)
|
||||
- `inspect_one_note.py` – Parser-Diagnose für eine konkrete Datei
|
||||
- `run_e2e_roundtrip.sh` – End-to-End: Reset → Import → Audit → (optional) Hash-Reporter → Export → Vergleich
|
||||
|
||||
**Typische Aufrufe:**
|
||||
|
||||
# Overlap-Qualität (Fenster vs. Kern)
|
||||
python3 tests/check_chunks_window_vs_text.py --prefix "$COLLECTION_PREFIX"
|
||||
|
||||
# Roundtrip-Vergleich (rekursiv)
|
||||
python3 tests/compare_vaults.py --src ./vault --dst ./_exportVault --focus body
|
||||
|
||||
# Chunks-Rekonstruktion (gegen Vault-Body)
|
||||
python3 tests/verify_chunks_integrity.py --prefix "$COLLECTION_PREFIX" --vault ./vault
|
||||
|
||||
---
|
||||
|
||||
## 11) Typische Workflows
|
||||
|
||||
**A) Clean-Start mit Test-Vault**
|
||||
|
||||
python3 -m scripts.make_test_vault --out ./test_vault --force
|
||||
python3 -m scripts.reset_qdrant --mode truncate --prefix mindnet --yes
|
||||
python3 -m scripts.import_markdown --vault ./test_vault --prefix mindnet
|
||||
python3 -m scripts.import_markdown --vault ./test_vault --prefix mindnet --apply --purge-before-upsert
|
||||
python3 -m scripts.audit_vault_vs_qdrant --vault ./test_vault --prefix mindnet
|
||||
python3 -m scripts.validate_edges --prefix mindnet --details
|
||||
export COLLECTION_PREFIX="mindnet"
|
||||
python3 -m scripts.export_markdown --out ./_exportVault
|
||||
|
||||
**B) Änderungs-Propagation & Idempotenz**
|
||||
|
||||
python3 -m scripts.import_markdown --vault ./test_vault --prefix mindnet
|
||||
python3 -m scripts.import_markdown --vault ./test_vault --prefix mindnet --apply --purge-before-upsert
|
||||
python3 -m scripts.audit_vault_vs_qdrant --vault ./test_vault --prefix mindnet
|
||||
python3 -m scripts.validate_edges --prefix mindnet --details
|
||||
python3 -m scripts.import_markdown --vault ./test_vault --prefix mindnet
|
||||
|
||||
**C) Unresolved Links lösen**
|
||||
|
||||
python3 -m scripts.import_markdown --vault ./test_vault --apply --prefix mindnet
|
||||
python3 -m scripts.resolve_unresolved_references --prefix mindnet --apply
|
||||
python3 -m scripts.validate_edges --prefix mindnet --details
|
||||
|
||||
**D) Export & Roundtrip (Produkt-Vault)**
|
||||
|
||||
export COLLECTION_PREFIX="mindnet"
|
||||
python3 -m scripts.import_markdown --vault ./vault --apply --purge-before-upsert --prefix "$COLLECTION_PREFIX"
|
||||
python3 -m scripts.export_markdown --out ./_exportVault --prefix "$COLLECTION_PREFIX"
|
||||
python3 tests/compare_vaults.py --src ./vault --dst ./_exportVault --focus body
|
||||
|
||||
---
|
||||
|
||||
## 12) Troubleshooting (kurz)
|
||||
|
||||
- **Importer markiert alle als changed (Moduswechsel):**
|
||||
→ `--baseline-modes` einmalig laufen lassen; sicherstellen: `MINDNET_HASH_COMPARE` passt zum Ziel.
|
||||
- **Edges verschwinden / nur 1 Edge sichtbar:**
|
||||
→ `app/core/qdrant_points.py` muss Edge-Payload normalisieren (Schema Alt/Neu) und `edge_id` eindeutig bilden.
|
||||
- **Export ohne Body / falsches Zielverzeichnis:**
|
||||
→ Exporter nutzt relativierte Pfade und rekonstruiert Body aus `fulltext` oder Chunks (`text`). ENV/CLI `--prefix` beachten.
|
||||
- **Parser-Fehler (UTF-8):**
|
||||
→ Neuer Parser arbeitet mit Fallbacks; mit `tests/inspect_one_note.py` prüfen, was ankommt.
|
||||
- **„Fehlende“ Dateien im Vergleich:**
|
||||
→ Prüfe, ob Dateien **wirklich zum Vault gehören** (z. B. Silverbullet-Artefakte `CONFIG.md`, `index.md` ausblenden).
|
||||
|
||||
---
|
||||
|
||||
## 13) Hinweise zu Silverbullet-Dateien
|
||||
|
||||
- Dateien wie `CONFIG.md` oder `index.md`, die **nicht** zum inhaltlichen Vault gehören, werden **nicht importiert** und erscheinen daher nicht im Export-Roundtrip.
|
||||
- Diese Dateien bitte vom produktiven Vault trennen oder im Vergleich (`tests/compare_vaults.py
|
||||
@@ -0,0 +1,74 @@
|
||||
# Kurzhandbuch — Type-Registry (WP-03)
|
||||
|
||||
## Zweck
|
||||
Die Type-Registry macht den `type:`-Wert im Frontmatter maschinenlesbar
|
||||
und steuert:
|
||||
- Chunk-Profile (indirekt über Overlap bei fensterlosen Chunks),
|
||||
- typabhängige Default-Kanten (hier: Aktivierung von Note-Scope-References),
|
||||
- optionale Retriever-Gewichtungen (`retriever_weight`) für WP‑04.
|
||||
|
||||
## Aktivierung
|
||||
1. Legen Sie `config/types.yaml` an (siehe Beispiel in diesem Paket).
|
||||
2. Starten Sie Import/Server neu. Die Registry wird beim Prozessstart
|
||||
geladen und gecached.
|
||||
|
||||
Fehlt die Datei oder ist sie defekt, bleibt das System voll funktionsfähig
|
||||
(der Typ `concept` wird genutzt; Warnhinweis im Log).
|
||||
|
||||
## Schema (Beispiel)
|
||||
```yaml
|
||||
version: 1.0
|
||||
types:
|
||||
concept:
|
||||
chunk_profile: long
|
||||
edge_defaults: ["references", "related_to"]
|
||||
retriever_weight: 1.0
|
||||
task:
|
||||
chunk_profile: short
|
||||
edge_defaults: ["depends_on", "belongs_to"]
|
||||
retriever_weight: 0.8
|
||||
experience:
|
||||
chunk_profile: medium
|
||||
edge_defaults: ["derived_from", "inspired_by"]
|
||||
retriever_weight: 0.9
|
||||
project:
|
||||
chunk_profile: medium
|
||||
edge_defaults: ["references", "depends_on"]
|
||||
retriever_weight: 0.95
|
||||
```
|
||||
|
||||
## Verhalten
|
||||
- **Chunking**: Die eigentliche Chunk-Länge bleibt weiterhin typabhängig über
|
||||
`chunk_config.get_sizes(type)` gesteuert. Falls der Chunker keine Fenster
|
||||
mit Overlap liefert, werden in `chunk_payload` synthetische Fenster erzeugt.
|
||||
Hier greift das `chunk_profile` mit folgenden Overlap-Empfehlungen:
|
||||
- short → (20,30), medium → (40,60), long → (60,80).
|
||||
- **Edges**: Enthält `edge_defaults` den Eintrag `references`, werden Note-
|
||||
Scope-References/Backlinks additiv aktiviert (kein Abbruch, keine Duplikate).
|
||||
Weitere Kantenarten bleiben unverändert.
|
||||
- **Retriever**: `retriever_weight` wird in der Note gespeichert und kann von
|
||||
WP‑04 im Ranking/Scoring berücksichtigt werden.
|
||||
|
||||
## Tests / Validierung
|
||||
- Dry-Run:
|
||||
```bash
|
||||
python3 -m scripts.import_markdown --vault ./test_vault
|
||||
```
|
||||
- Vollimport + Purge:
|
||||
```bash
|
||||
python3 -m scripts.import_markdown --vault ./test_vault --apply --purge-before-upsert --prefix "$COLLECTION_PREFIX"
|
||||
```
|
||||
- Chunks-Qualität (Window vs Text):
|
||||
```bash
|
||||
python3 tests/check_chunks_window_vs_text.py --prefix "$COLLECTION_PREFIX"
|
||||
```
|
||||
- Roundtrip:
|
||||
```bash
|
||||
python3 -m scripts.export_markdown --out ./_exportVault --prefix "$COLLECTION_PREFIX"
|
||||
python3 tests/compare_vaults.py --src ./test_vault --dst ./_exportVault --focus body
|
||||
```
|
||||
|
||||
## Fallbacks & Robustheit
|
||||
- Registry nicht vorhanden/ungültig → `concept`, Warnung, keine Abbrüche.
|
||||
- Alle bestehenden ENV/Flags bleiben identisch.
|
||||
- Keine Änderungen an Punkt-IDs, Feldern oder Vektoren.
|
||||
+106
-116
@@ -13,74 +13,67 @@ Entwickle eine robuste, parser-freundliche **Chunking-Strategie** für Markdown-
|
||||
---
|
||||
|
||||
## 2) Annahmen aus `knowledge_design.md`
|
||||
- **Stabile IDs** & Dateinamen-Schema (z. B. `YYYYMMDD-HHMM-type-slug` bzw. `type-slug`).
|
||||
- **Pflichtfelder** in YAML: `title`, `id`, `type`, `status`, `created`, `tags` (empfohlene Felder ggf. mehr).
|
||||
- **Abschnitts-Konventionen** je `type` (z. B. `## Zusammenfassung`, `## Kontext` …) → ideale **Chunk-Grenzen**.
|
||||
- **Edge-Typen**: `belongs_to`, `references`, `backlink`, `depends_on`, `assigned_to`, `discussed_in`, `authored_by`, `related`. Für Chunking primär `belongs_to` & `references` (+ optionale `prev`/`next`).
|
||||
- **IDs**: deterministische, stabile `id` pro Note (Slug / semantischer Identifier), ggf. `aliases`.
|
||||
- **Dateinamen**: entweder `YYYY-MM-DD_title.md` oder `slug.md`; Pfade sind **relativ** zum Vault.
|
||||
- **Frontmatter-Pflichtfelder**: `id`, `title`, `type`, `created`, `updated` (Details in `knowledge_design.md`).
|
||||
- **Backlink-/Link-Regeln**: Wikilinks `[[id]]` im Body; am Ende optional redaktionelle Sektion „Mögliche Verbindungen“ (erzeugt **keine** Kanten).
|
||||
|
||||
---
|
||||
|
||||
## 3) Chunking-Prinzipien
|
||||
1. **Frontmatter extrahieren** → als strukturiertes `metadata` (nicht in `text` des Chunks).
|
||||
2. **Markdown AST** (oder strukturierter Parser) nutzen:
|
||||
- Primäre Grenzen: **Überschriftenebene H2/H3** (H1 = Dokumenttitel).
|
||||
- Sekundär: **Absätze**, **nummerierte/unnummerierte Listen** als atomare Einheiten, **Codeblöcke** als zusammenhängender Block (nicht splitten).
|
||||
3. **Längensteuerung**: Semantik vor harter Länge. Wenn Abschnitt > Zielgröße, **weich segmentieren** entlang von Absätzen/Listenpunkten.
|
||||
4. **Referenz-Extraktion**: `[[Wikilinks]]` + Markdown-Links → `references`. Backlinks werden downstream generiert.
|
||||
5. **Kontext-Overlap**: Chunks erhalten **Überlappung** über Satz-/Absatzgrenzen, um Kohärenz beim Retrieval zu erhöhen.
|
||||
- **Semantische Schnitte**: Chunks enden an Absätzen, Überschriften, Listenpunkten, Codeblöcken, Zitaten.
|
||||
- **Frontmatter**: YAML **nicht** embedden; stattdessen komplett im Note-Payload speichern.
|
||||
- **Verlustfreiheit**:
|
||||
- Note-Payload: `fulltext` (gesamter Body).
|
||||
- Chunk-Payload: `text` (Originalchunk).
|
||||
Damit kann der Export den Body **verlustfrei** rekonstruieren (erst `fulltext`, sonst Chunks).
|
||||
|
||||
---
|
||||
|
||||
## 4) Optimale Chunkgrößen & Overlaps
|
||||
> Ziel: gutes Recall@k, wenig Fragmentierung, stabile Antwortqualität.
|
||||
- **Zielgröße**: 250–400 Tokens (Richtwert, abhängig vom `type`).
|
||||
- **Maxgröße**: 600–800 Tokens (nur in Ausnahmen).
|
||||
- **Mingröße**: 80–120 Tokens (sonst mit Nachbar verschmelzen).
|
||||
- **Overlap**: 40–60 Tokens, um Kontextverlust zu vermeiden.
|
||||
- **Kontextabhängig**:
|
||||
- `concept`, `thought`, `experience`: 250–350 Tokens
|
||||
- `task`, `project`: eher 200–300 Tokens (mehr Bullet-Struktur)
|
||||
- `journal`: 300–400 Tokens (tagesabschnittsweise)
|
||||
|
||||
| Notiz-Typ (`type`) | Inhalt | Zielgröße (Tokens) | Max. Größe (Tokens) | Overlap (Tokens) | Hinweise |
|
||||
|---|---|---:|---:|---:|---|
|
||||
| `thought` | kurze Thesen/Ideen | 150–250 | 300 | 30–40 | meist 1–2 Chunks |
|
||||
| `experience` | Kontext/Beobachtung/Interpretation | 250–350 | 450 | 40–60 | Trenne entlang der Template-Sektionen |
|
||||
| `journal` | Tagebuch, episodisch | 200–300 | 400 | 30–50 | Tagesabschnitte bündeln |
|
||||
| `task` | knapp, Checklisten | 120–200 | 250 | 20–30 | Listen nicht splitten |
|
||||
| `project` | Scope/WPs/Risiken/Status | 300–450 | 600 | 50–70 | Pro Hauptsektion ein Chunk |
|
||||
| `concept` | definierte Begriffe, Erklärungen | 250–400 | 550 | 40–60 | Definition separat halten |
|
||||
| `source` | Metadaten + Auszüge/Notizen | 200–350 | 500 | 30–50 | Zitate als eigene Chunks (Urheberrecht) |
|
||||
---
|
||||
|
||||
## 4.1 Overlap-Regeln
|
||||
- Overlap **nie mitten im Satz** beenden → mindestens **ein kompletter Satz** wandert in den nächsten Chunk.
|
||||
- An **Absatzgrenzen** ausrichten, wenn möglich.
|
||||
- Bei **Listen** ggf. den vorherigen Punkt als Overlap mitführen (falls < 50 Tokens).
|
||||
- Codeblöcke und Tabellen **nicht splitten**; wenn sie größer als `Max-Tokens` sind, als **eigener Chunk** belassen (Ausnahmefall zulassen).
|
||||
**Daumenregel (zeichenzentriert):** ~4 Zeichen ≈ 1 Token → 800–1600 Zeichen Ziel; Overlap ~120–240 Zeichen (≈ 30–60 Tokens).
|
||||
**Mindestanforderung:** Keine Trennung innerhalb von Sätzen. Sicherstellung, dass immer an Satzenden gechunct wird
|
||||
**Default für mindnet:** **~300 Tokens** + **~50 Tokens Overlap**; per `type` feinjustieren (siehe Tabelle).
|
||||
- Overlap betrifft **nur den Body**; die YAML-Frontmatter bleibt **außerhalb**.
|
||||
- Keine Overlaps, die Codeblöcke oder Tabellen „aufreißen“. Falls nötig: Chunk-Grenze an Blockgrenze ziehen.
|
||||
- Bei reinen Listen: zusammenhängende Bullets gruppieren, ggf. kleinere Overlaps.
|
||||
|
||||
---
|
||||
|
||||
## 5) Semantische Regeln je Strukturelement
|
||||
- **Überschriften (H2/H3)**: new chunk start; speichere `section_path` (z. B. `/Kontext/Beobachtung`).
|
||||
- **Absätze**: Primäre Untereinheiten; wenn Zusammenfassung + Beispiel direkt folgen, zusammen lassen.
|
||||
- **Listen**: Jeder **Listeneintrag** bleibt zusammen mit seinem einleitenden Satz (falls vorhanden). Große Listen → in **logische Blöcke** (5–8 Items) splitten.
|
||||
- **Codeblöcke**: Nicht splitten; ggf. separater Chunk, **aber** im Retrieval **downweighten** (optional).
|
||||
- **Zitate/Blockquotes**: zusammenhalten; Quelle im `references_meta` anreichern (falls Link vorhanden).
|
||||
- **Tabellen**: als ein Chunk; zusätzlich **Plain-Text-Extrakt** (Header + 1–2 Zeilen) in `summary` für Retriever, falls Modelle Tabellen schlechter verarbeiten.
|
||||
- **Überschriften**: vorzugsweise an H2/H3 trennen; H1 meist Dokumenttitel → Teil der Frontmatter.
|
||||
- **Absätze**: primäre Trennkandidaten.
|
||||
- **Listen**: zusammenhängende Gruppe als ein Chunk, wenn sie einen semantischen Block bilden.
|
||||
- **Codeblöcke**: niemals splitten; Code bleibt in einem Chunk.
|
||||
- **Zitate**: ab 2+ Zeilen als eigener Chunk.
|
||||
- **Bilder/Anhänge**: Referenzen im Text belassen; Pfade relativ halten.
|
||||
|
||||
---
|
||||
|
||||
## 6) Normalisierung & Preprocessing
|
||||
- **Nicht embedden:** YAML-Frontmatter (aber spezifische Felder als `metadata.*` mitschreiben: `type`, `tags`, `area`, `project`, `priority`, `people`, `aliases`).
|
||||
- **Bereinigen:** führende/trailing Spaces, Mehrfach-Leerzeilen → 1; Unicode-NFKC; Zeilenenden normalisieren.
|
||||
- **Bewahren:** Markdown-Semantik (Überschriften-Hashes, Listenpräfixe, Codefences) **im Text beibehalten**, damit RAG-Antworten sauber zitieren können.
|
||||
- **Sprachhinweis:** `lang` heuristisch bestimmen (DE/EN/…); in `metadata.lang` ablegen → später für sprachspezifische Embeddings nützlich.
|
||||
- **Stop-Abschnitte:** „Mögliche Verbindungen“ am Ende **separat** chunken (nur Links), um Link-Graph sauber zu extrahieren.
|
||||
- **Zeilenenden**: `\r\n` → `\n`, trailing spaces trimmen (nur für Hashing, nicht für Anzeige).
|
||||
- **Whitespace**: mehrfach-Blankzeilen reduzieren (optional, Hash-Modus beachten).
|
||||
- **Links**: `[[Titel|id]]` zu `(display="Titel", target_id="id")` normalisieren.
|
||||
- **Pfade**: `path` im Payload **zwingend relativ** (Backslashes → Slashes).
|
||||
|
||||
---
|
||||
|
||||
## 7) Edge-Modell (Graph)
|
||||
- **Chunk → Note:** `belongs_to(note_id)` (obligatorisch).
|
||||
- **Chunk → Chunk (gleiche Note):** `prev`, `next` (lineare Leserichtung).
|
||||
- **Note/Chunk → Note:** `references(target_id)` aus `[[Wikilinks]]` & Markdown-Links; optional `related` (schwach).
|
||||
- **Backlink:** systemisch generiert: inverse Kante `backlink`.
|
||||
- **Sektionen:** `has_section(note_id, section_path)` (optional, für Navigations-UI).
|
||||
- **Task-Spezialfälle:** `depends_on`, `assigned_to(person-id)` bleiben **Note-Level** (nicht Chunk-Level).
|
||||
- **Chunk → Note:** `belongs_to(note_id)` (obligatorisch; Edge-Payload enthält zusätzlich `note_id` als Owner-Note).
|
||||
- **Chunk → Chunk (gleiche Note):** `prev`, `next` (symmetrisch für lineare Navigation; beide Richtungen werden erzeugt).
|
||||
- **Chunk → Note:** `references(target_id)` aus `[[Wikilinks]]` oder Markdown-Links im Chunk-Text (Standard; *Chunk-Scope*).
|
||||
- **Note → Note:** `backlink(target_id)` automatisch generiert, dedupliziert pro Note (*Note-Scope*).
|
||||
- **Optional:** `references:note` (Note-Scope-References) per Flag/ENV aktivierbar; **Default = aus**, um Doppelzählungen zu vermeiden.
|
||||
- **Unresolved:** Wenn `target_id` nicht existiert, wird eine Kante mit `status: "unresolved"` angelegt (später durch Resolver/Agent heilbar).
|
||||
|
||||
---
|
||||
|
||||
@@ -100,26 +93,49 @@ Entwickle eine robuste, parser-freundliche **Chunking-Strategie** für Markdown-
|
||||
"project": "project-mindnet",
|
||||
"tags": ["area/mindnet","type/thought","topic/yaml"],
|
||||
"chunk_index": 2,
|
||||
"char_start": 1240,
|
||||
"char_end": 2012,
|
||||
"token_count": 305,
|
||||
"char_start": 1024,
|
||||
"char_end": 1789,
|
||||
"section_title": "Begründung / Details",
|
||||
"section_path": "/Begründung / Details",
|
||||
"lang": "de",
|
||||
"wikilinks": ["concept-vektorsuche-qdrant","source-obsidian-properties"],
|
||||
"external_links": [],
|
||||
"references": [
|
||||
{"target_id": "concept-vektorsuche-qdrant", "kind": "wikilink"}
|
||||
],
|
||||
"neighbors": {"prev": "#c01", "next": "#c03"},
|
||||
"created_at": "2025-09-02T18:35:00+02:00"
|
||||
"section_path": "Begründung / Details",
|
||||
"neighbors": {"prev": "…#c01", "next": "…#c03"},
|
||||
"wikilinks": ["concept-yaml-styleguide"],
|
||||
"references": [{"kind":"wikilink", "target_id":"concept-yaml-styleguide"}],
|
||||
"text": "… ursprünglicher Chunk-Text …"
|
||||
}
|
||||
}
|
||||
|
||||
**Collection-Einstellungen (Empfehlung)**
|
||||
- `distance`: `Cosine` (gemischte Textlängen)
|
||||
- `vectors`: 384–1024 Dim (abh. Embedding-Modell)
|
||||
- `hnsw_ef_construct`: 128–256; `m`: 16–32 (Workload-abhängig)
|
||||
**Point (Note)**
|
||||
|
||||
{
|
||||
"id": "20250902-1830-thought-yaml-recall",
|
||||
"vector": [/* optional Nullvektor oder Zentroid */],
|
||||
"payload": {
|
||||
"note_id": "20250902-1830-thought-yaml-recall",
|
||||
"title": "Gedanke: Einheitliche YAML-Standards steigern Recall",
|
||||
"type": "thought",
|
||||
"status": "draft",
|
||||
"created": "2025-09-02",
|
||||
"updated": "2025-09-02",
|
||||
"path": "10_thoughts/20250902-1830-thought-yaml-recall.md",
|
||||
"tags": ["area/mindnet","type/thought","topic/yaml"],
|
||||
"hash_fulltext": "sha256:…",
|
||||
"fulltext": "… gesamter Body für verlustfreie Rekonstruktion …",
|
||||
"references": ["concept-yaml-styleguide"] // Fallback für Note-Level-Backlinks
|
||||
}
|
||||
}
|
||||
|
||||
**Edges (Payload; neues Schema)**
|
||||
|
||||
{
|
||||
"kind": "references" | "backlink" | "belongs_to" | "prev" | "next",
|
||||
"source_id": "<chunk_id|note_id>",
|
||||
"target_id": "<note_id|chunk_id>",
|
||||
"scope": "chunk" | "note",
|
||||
"note_id": "<owner-note-id>", // neu: für schnelles Filtern/Purge
|
||||
"status": "ok" | "unresolved" // optional
|
||||
}
|
||||
|
||||
**Performance-Hinweis (Qdrant):** Für schnelle Filter/Deletes Payload-Indizes anlegen: **edges** → `kind`, `scope`, `source_id`, `target_id`, `note_id`; **chunks** → `note_id`, `chunk_index`; **notes** → `note_id`.
|
||||
|
||||
---
|
||||
|
||||
@@ -136,79 +152,53 @@ Entwickle eine robuste, parser-freundliche **Chunking-Strategie** für Markdown-
|
||||
blocks = group_blocks(sec, keep_code=True, keep_lists=True)
|
||||
for group in soft_wrap(blocks, target_tokens=target_size(meta["type"]),
|
||||
max_tokens=max_size(meta["type"])):
|
||||
raw_chunks.append(render_markdown(group))
|
||||
raw_chunks.append(render_md(group))
|
||||
|
||||
chunks = apply_overlap(raw_chunks, overlap_tokens=overlap_size(meta["type"]))
|
||||
chunks = trim_whitespace(chunks)
|
||||
chunks = apply_overlap(raw_chunks, overlap_tokens=overlap(meta["type"]))
|
||||
chunks = normalize_chunks(chunks) # trim, fix code fences, etc.
|
||||
|
||||
# link extraction
|
||||
for i, ch in enumerate(chunks):
|
||||
ch.payload.update({
|
||||
"wikilinks": extract_wikilinks(ch.text),
|
||||
"external_links": extract_md_links(ch.text),
|
||||
"references": [{"target_id": t, "kind": "wikilink"} for t in extract_wikilinks(ch.text)],
|
||||
"neighbors": {"prev": f"#c{i-1}" if i>0 else None,
|
||||
"next": f"#c{i+1}" if i<len(chunks)-1 else None}
|
||||
})
|
||||
# IDs & Nachbarn
|
||||
for i, ch in enumerate(chunks, start=1):
|
||||
ch.id = f"{meta['id']}#c{i:02d}"
|
||||
ch.index = i
|
||||
ch.neighbors_prev = chunks[i-2].id if i > 1 else None
|
||||
ch.neighbors_next = chunks[i].id if i < len(chunks) else None
|
||||
|
||||
# attach metadata
|
||||
for idx, ch in enumerate(chunks):
|
||||
ch.id = f'{meta["id"]}#c{idx:02d}'
|
||||
ch.payload |= minimal_payload_from_meta(meta, file_path, idx, ch)
|
||||
# Wikilinks je Chunk
|
||||
for ch in chunks:
|
||||
ch.wikilinks = extract_wikilinks(ch.text)
|
||||
|
||||
return chunks
|
||||
|
||||
**Hinweise zur Implementierung**
|
||||
- **Tokenizer**: gleiche Tokenizer-Funktion für **Längensteuerung** und **Embedding** nutzen (Leak vermeiden).
|
||||
- **Overlap** implementieren auf **Satz-/Absatzebene**; notfalls anhand Token-Fenster (kein Wort-Cut).
|
||||
- **Heuristik** für `target_size`/`overlap_size` per `type` (siehe Tabelle).
|
||||
- **Später**: Re-Chunking ermöglichen (idempotente Re-Runs), Chunk-IDs stabil halten (Index + Hash über `section_path + first_64_tokens`).
|
||||
|
||||
---
|
||||
|
||||
## 10) Einbettung (Embeddings)
|
||||
- **Standard:** nur `chunk.text` embedden (ohne YAML), **aber**:
|
||||
- `aliases`, `title` können als **synthetischer Kontext** *vorangestellt* werden (konkateniert, durch Trennzeichen), falls Recall für Synonyme wichtig ist.
|
||||
- **Mehrsprachigkeit:** pro Chunk die Sprache detektieren; ggf. **mehrsprachige Modelle**/Pipelines verwenden.
|
||||
- **Code-Gewichtung:** optional zweite Vektor-Spur für Code (separate Collection) falls viel Technik.
|
||||
- Modell: MiniLM/all-MiniLM-L6-v2 (384d) oder E5 (besseres Retrieval, ggf. multilingual).
|
||||
- **Note-Embeddings** optional (Zentroid der Chunks).
|
||||
- **Hashing für Change-Detection** (Importer):
|
||||
- `MINDNET_HASH_MODE = body|frontmatter|body+frontmatter` (Default: `body`)
|
||||
- `MINDNET_HASH_NORMALIZE = canonical|none` (Default: `canonical`)
|
||||
|
||||
---
|
||||
|
||||
## 11) Qualitätssicherung
|
||||
- **Unit-Tests**: Gold-Notes mit erwarteten Section-Splits und Link-Graph.
|
||||
- **Metrics**: Retrieval-Eval (nDCG@k, Recall@k) auf internen QA-Fragen.
|
||||
- **Linting**: Pre-commit prüft Pflichtfelder & Link-Integrität (IDs, Dateinamen, Wikilinks).
|
||||
- **Zähler**: `notes/chunks/edges` je Lauf prüfen.
|
||||
- **Edge-Invarianten**:
|
||||
- `belongs_to == #Chunks`
|
||||
- `next == prev == Σ(max(chunks_in_note-1, 0))`
|
||||
- `references (chunk) == Σ(Chunk-Wikilinks)`
|
||||
- `backlink == Σ(eindeutige Wikilinks je Note)`
|
||||
- **Unresolved**: sollten durch Resolver-Jobs über Zeit abnehmen.
|
||||
- **Roundtrip-Test**: Import → Export → Diff; exakt rekonstruierbare Bodies.
|
||||
|
||||
---
|
||||
|
||||
## 12) Deliverables
|
||||
1. **Python-Modul** `mindnet_chunker/` (Parser, Chunker, Link-Extractor, Qdrant-Client).
|
||||
2. **CLI** `mindnet-chunk` (stdin→stdout, oder Datei→NDJSON).
|
||||
3. **Docs**: README mit Schema & Beispielen; Tests + Fixtures.
|
||||
- Code: Parser, Chunker, Importer, Exporter, Edges.
|
||||
- Schemas: `note.schema.json`, Payload-Layouts.
|
||||
- Tests: Mini-Vault (`scripts/make_test_vault.py`), Audit/Validate.
|
||||
|
||||
---
|
||||
|
||||
## 13) Prompt für neues Chatfenster (kopieren & einfügen)
|
||||
|
||||
**Projekt:** mindnet Wissensnetzwerk
|
||||
**Rolle:** Du bist mein Assistent für NLP-Strategien.
|
||||
**Ziel:** Hilf mir, eine robuste Chunking-Strategie für Markdown-Notizen zu entwickeln, die später in Qdrant gespeichert werden.
|
||||
|
||||
**Anforderungen:**
|
||||
- Nutze das YAML-Frontmatter-Schema und die Strukturregeln aus `knowledge_design.md`. (Pflichtfelder, Abschnitts-Konventionen, Edge-Typen)
|
||||
- Definiere optimale Chunkgrößen (Tokens) nach Notiz-Typ, inkl. **Overlap-Empfehlungen**.
|
||||
- Beschreibe, wie **logische Abschnitte** (Überschriften/Absätze/Listen/Code) als Grenzen dienen.
|
||||
- Erkläre das **Edge-Modell** zwischen **Chunks** und **Notizen** (`belongs_to`, `references`, `backlink`, `prev/next`).
|
||||
- Ergebnis: ein **konkretes Konzept + Python-Outline**, das ich direkt implementieren kann (inkl. Datenmodell für Qdrant).
|
||||
|
||||
**Kontext zum System:**
|
||||
- IDs/Dateinamen/Tags gemäß `knowledge_design.md`.
|
||||
- Zielgröße pro Chunk ~**300 Tokens**, **Overlap ~50 Tokens** als Default; per `type` feinjustiert (Tabelle).
|
||||
- YAML wird **nicht** in die Embeddings gemischt; ausgewählte Felder als `payload`.
|
||||
|
||||
Bitte liefere:
|
||||
1) Zusammenfassung der Strategie,
|
||||
2) Tabelle mit Größen/Overlaps,
|
||||
3) Python-Pseudocode für Chunker,
|
||||
4) Qdrant-Payload-Beispiel,
|
||||
5) Test-Plan kurz.
|
||||
*(Unverändert)*
|
||||
+186
-373
@@ -1,436 +1,249 @@
|
||||
---
|
||||
title: "mindnet – Knowledge Design"
|
||||
id: "design-knowledge-architecture"
|
||||
type: "guide"
|
||||
status: "active"
|
||||
version: "1.2.0"
|
||||
created: 2025-09-02
|
||||
updated: 2025-09-02
|
||||
tags: ["type/guide","area/mindnet","topic/obsidian","topic/knowledge-architecture"]
|
||||
owner: "Ich"
|
||||
---
|
||||
# mindnet – Knowledge Design
|
||||
**Version:** 1.4.0 (aktualisiert 2025-10-06)
|
||||
|
||||
# mindnet – Knowledge Design
|
||||
## 1. Gesamtziel und Systemverständnis
|
||||
|
||||
## 1. Gesamtziel, Anspruch & Nutzen
|
||||
**mindnet** ist ein lokales Wissensnetzwerk, das alle meine Notizen, Projekte, Gedanken, Erfahrungen und Pläne als Markdown-Dateien speichert, automatisch importiert, semantisch in **Chunks** zerlegt und als **Graph-Struktur in Qdrant** ablegt.
|
||||
Es ist die Grundlage für ein agentenfähiges, lokal betriebenes LLM-System, das meine Daten verknüpft, abfragt und erweitert.
|
||||
|
||||
**Ziel:**
|
||||
*mindnet* ist ein persönliches Wissensnetzwerk, das **alle** relevanten Inhalte – Gedanken, Erfahrungen, Aufgaben, Projekte, Quellen, Personen, Meetings, Tagebuch/Journal, Wendepunkte und Leitbilder – **einheitlich** in Markdown + YAML ablegt. Es bildet einen **Spiegel der Persönlichkeit** (Werte, Überzeugungen, Erlebnisse) und ist zugleich so strukturiert, dass Tools (Dataview, Embeddings, Vektorsuche/Qdrant, Agenten) es **maschinenlesbar** nutzen können.
|
||||
**Zentrale Ziele**
|
||||
- Vollständige Repräsentation persönlichen Wissens in strukturierter, maschinenlesbarer Form
|
||||
- Reproduzierbare Verarbeitung: Import → Chunking → Embedding → Edges → Graph
|
||||
- Verlustfreie Roundtrip-Fähigkeit (Import ⇄ Export)
|
||||
- Erweiterbarkeit für Agenten, RAG-Retriever und semantische Suche
|
||||
|
||||
**Anspruch an die Struktur:**
|
||||
- **Stabil**: robuste IDs, deterministische Dateinamen, konsistente Feldnamen
|
||||
- **Atomar**: ein Kerninhalt pro Datei (keine Sammelcontainer)
|
||||
- **Erweiterbar**: neue Typen (z. B. `milestone`, `manifesto`) jederzeit möglich
|
||||
- **Portabel**: reines Markdown + YAML → funktioniert in Obsidian, Git und Parsern
|
||||
- **Vernetzbar**: systematische Links/Backlinks erzeugen ein sinnvoll navigierbares Netz
|
||||
- **Parser-freundlich**: wiederkehrende Abschnittsüberschriften; Felder/Enums klar definiert
|
||||
|
||||
**Späterer Nutzen / Einsatzzwecke:**
|
||||
- **Schnelles Wiederfinden**: Dataview-Abfragen, Filter, Dashboards
|
||||
- **Selbstreflexion & Entwicklung**: persönliche Werte, Wendepunkte, Kinderentwicklung, Lernpfade
|
||||
- **Automatisierung**: Vektor-Index (Qdrant), Embeddings, LLM-Q&A, Agenten-Workflows
|
||||
- **Langfristiges Gedächtnis**: eigene Lebens-/Projektchronik reproduzierbar pflegen
|
||||
- **Aufgaben-/Projektsteuerung**: im selben System, vernetzt mit Kontextwissen
|
||||
**Prinzipien**
|
||||
- **Deterministisch:** IDs, Hashes und Edges wiederholbar
|
||||
- **Portabel:** Markdown + YAML
|
||||
- **Robust:** fehlertoleranter Parser
|
||||
- **Idempotent:** keine Duplikate bei Re-Import
|
||||
- **Erweiterbar:** neue Typen und Edge-Arten ohne Migration
|
||||
|
||||
---
|
||||
|
||||
## 2. YAML-Frontmatter-Schema
|
||||
|
||||
> **Pflichtfelder:** `title`, `id`, `type`, `status`, `created`, `tags`
|
||||
> **Empfohlen:** `updated`, `area`, `project`, `priority`, `aliases` (u. a.)
|
||||
| Feld | Typ | Beschreibung |
|
||||
|-------|-----|--------------|
|
||||
| `title` | string | Menschlich lesbarer Titel |
|
||||
| `id` | string | Eindeutige Note-ID (Slug) |
|
||||
| `type` | enum | `concept`, `thought`, `experience`, `task`, `project`, `journal`, `person`, `meeting`, `milestone` |
|
||||
| `status` | enum | `draft`, `active`, `done`, `archived` |
|
||||
| `created` | date | ISO-Datum |
|
||||
| `updated` | date | Letzte Änderung |
|
||||
| `area` | string | Themen- oder Lebensbereich |
|
||||
| `project` | string | Zugehöriges Projekt |
|
||||
| `tags` | list | Strukturierte Tags (`area/…`, `topic/…`) |
|
||||
| `depends_on` | list | IDs anderer Notizen |
|
||||
| `assigned_to` | list | Beteiligte Personen |
|
||||
| `embedding_exclude` | bool | Falls `true`, keine Embeddings |
|
||||
| `hash_mode` | enum | Hash-Modus beim Import (`body`, `frontmatter`, `full`) |
|
||||
| `priority` | enum/int | 1–5 oder `low` / `med` / `high` |
|
||||
| `effort_min`, `due` | int/date | Aufwand / Termin |
|
||||
| `aliases` | list | Alternative IDs |
|
||||
| `lang` | string | ISO-Sprachcode |
|
||||
| `source` | string | Herkunft / Referenzquelle |
|
||||
|
||||
### 2.1 Feldübersicht
|
||||
|
||||
| Feld | Typ | Bedeutung | Beispiel(e) |
|
||||
|---------------------|-------------------------------|---------------------------------------------------------------------------|------------------------------------------------------------------------------|
|
||||
| `title` | string | Menschlich lesbarer Titel | `"Vektorsuche in Qdrant"` |
|
||||
| `id` | string (slug/identifier) | **Stabile** technische ID (nie umbenennen) | `"20250902-1710-thought-obsidian-struktur"`, `"concept-persoenliches-leitbild"` |
|
||||
| `type` | enum | Notiz-Typ | `thought`, `experience`, `task`, `project`, `source`, `concept`, `person`, `meeting`, `journal`, `milestone` |
|
||||
| `status` | enum | Lebenszyklus | `idea`, `draft`, `active`, `paused`, `blocked`, `done`, `archived` |
|
||||
| `created` | date/datetime | Erstellzeitpunkt | `2025-09-02` oder `2025-09-02T17:10:00+02:00` |
|
||||
| `updated` | date/datetime | Letzte inhaltliche Änderung | `2025-09-02T18:05:00+02:00` |
|
||||
| `tags` | string[] | Schlagwörter gemäß Taxonomie | `["area/mindnet","topic/obsidian","type/thought"]` |
|
||||
| `area` | enum/string | Lebens-/Arbeitsbereich | `mindnet`, `family`, `karate`, `travel`, `health`, `home-automation`, … |
|
||||
| `role` | string | Rolle/Hut (Filter) | `"father"`, `"researcher"`, `"project-owner"` |
|
||||
| `project` | string | Zugehöriges Projekt (ID oder sprechend) | `"project-mindnet"` |
|
||||
| `priority` | int (1–5) | 1 = hoch, 5 = niedrig | `2` |
|
||||
| `effort_min` | int | Aufwand in Minuten (für `task`) | `90` |
|
||||
| `due` | date | Fälligkeit (Task/Projekt) | `2025-09-10` |
|
||||
| `start` | date | geplanter Start (Task/Projekt) | `2025-09-05` |
|
||||
| `people` | string[] (Wikilinks erlaubt) | Beteiligte Personen | `["Ich","[[person-kathie]]"]` |
|
||||
| `location` | string | Ort/Platz | `"Home Office"`, `"München"` |
|
||||
| `source_url` | url | Kanonische URL (für `source`) | `"https://qdrant.tech/docs/"` |
|
||||
| `authors` | string[] | Autoren (für `source`) | `["Jane Doe"]` |
|
||||
| `published` | date | Veröffentlichungsdatum (für `source`) | `2024-11-20` |
|
||||
| `accessed` | date | Zugriffsdatum (für `source`) | `2025-09-02` |
|
||||
| `aliases` | string[] | Alternative Namen/Titel | `["Manifest","Leitbild"]` |
|
||||
| `related_ids` | string[] | ID-basierte Verknüpfungen | `["concept-persoenliches-leitbild"]` |
|
||||
| `embedding_exclude` | boolean | Von Embeddings/Index ausschließen | `false` |
|
||||
|
||||
### 2.2 Konventionen
|
||||
- **IDs:** entweder Zeitstempel-basiert (`YYYYMMDD-HHMM-type-slug`) **oder** stabile, sprechende (`concept-*`, `project-*`, `person-*`).
|
||||
- **Datums-/Zeitformat:** ISO 8601, Zeiten möglichst mit TZ (z. B. `+02:00`).
|
||||
- **Felder:** klein geschrieben; zusammengesetzte Felder in `snake_case`.
|
||||
|
||||
### 2.3 Minimalbeispiel Frontmatter
|
||||
---
|
||||
title: "Kurzer, klarer Gedanke"
|
||||
id: "20250902-1715-thought-klarer-gedanke"
|
||||
type: "thought"
|
||||
status: "idea"
|
||||
created: 2025-09-02T17:15:00+02:00
|
||||
updated: 2025-09-02T17:15:00+02:00
|
||||
tags: ["area/mindnet","type/thought","topic/obsidian"]
|
||||
---
|
||||
|
||||
## 2.4 Enum-Werte
|
||||
|
||||
Zur Sicherstellung der Konsistenz werden für bestimmte Felder feste Wertemengen (Enums) verwendet:
|
||||
|
||||
- **type**
|
||||
- `idea` – spontane Gedanken, Inspirationen
|
||||
- `experience` – persönliche Erfahrungen, Reflexionen
|
||||
- `task` – konkrete Aufgaben
|
||||
- `project` – Projekte, bestehend aus mehreren Tasks
|
||||
- `concept` – abstrakte Konzepte, Modelle, Methoden
|
||||
- `milestone` – wichtige Ereignisse oder Wendepunkte
|
||||
- `person` – Personen (z. B. Kontakte, Vorbilder)
|
||||
- `meeting` – Besprechungen, Treffen, Gespräche
|
||||
- `resource` – externe Quellen (Artikel, Bücher, Links)
|
||||
- `journal` – Tagebuchnotizen
|
||||
|
||||
- **status**
|
||||
- `open`
|
||||
- `in-progress`
|
||||
- `done`
|
||||
- `blocked`
|
||||
- `canceled`
|
||||
|
||||
- **priority**
|
||||
- `low`
|
||||
- `medium`
|
||||
- `high`
|
||||
|
||||
- **area** (Beispiele – erweiterbar)
|
||||
- `personal`
|
||||
- `work`
|
||||
- `family`
|
||||
- `karate`
|
||||
- `health`
|
||||
- `finance`
|
||||
**Pflichtfelder:** `title`, `id`, `type`, `status`, `created`
|
||||
**Optionale Felder:** alle übrigen
|
||||
|
||||
---
|
||||
|
||||
## 3. Dateinamen-Konventionen
|
||||
## 3. Dateinamen und Ordner
|
||||
|
||||
> Keine Sonderzeichen wie `: / \` im Dateinamen.
|
||||
|
||||
- **Zeitbasierte Notizen (Gedanken, Journal, tagesgebundene Einträge):**
|
||||
`YYYYMMDD-HHMM-<type>-<slug>.md`
|
||||
Beispiel: `20250902-1710-thought-obsidian-struktur.md`
|
||||
|
||||
- **Zeitunabhängige Wissensknoten (Konzepte, Personen, Projekte, Leitbild):**
|
||||
`<type>-<slug>.md`
|
||||
Beispiele: `concept-vektorsuche-qdrant.md`, `project-mindnet.md`, `person-kathie.md`, `concept-persoenliches-leitbild.md`
|
||||
|
||||
- **Ordnerstruktur (Empfehlung):**
|
||||
00_inbox/
|
||||
10_thoughts/
|
||||
20_experiences/
|
||||
30_projects/
|
||||
31_tasks/
|
||||
40_concepts/
|
||||
50_sources/
|
||||
60_people/
|
||||
70_meetings/
|
||||
80_journal/
|
||||
90_templates/
|
||||
_attachments/
|
||||
_meta/
|
||||
- Format: `YYYY-MM-DD_title.md` oder `slug.md`
|
||||
- Strukturierte Ordner:
|
||||
- `10_thoughts/`, `20_concepts/`, `30_projects/`, `40_experiences/`, …
|
||||
- Alle Pfade relativ; Unterstriche statt Leerzeichen
|
||||
|
||||
---
|
||||
|
||||
## 4. Tagging-Regeln & Taxonomie
|
||||
## 4. Link- und Edge-Design
|
||||
|
||||
- **Hierarchische Tags:**
|
||||
- `area/*` – Lebens-/Arbeitsbereiche: `area/mindnet`, `area/family`, `area/karate`, `area/health`, …
|
||||
- `type/*` – optionaler Spiegel von `type`: `type/thought`, `type/experience`, …
|
||||
- `topic/*` – thematische Schwerpunkte: `topic/obsidian`, `topic/yaml`, `topic/qdrant`, `topic/werte`, …
|
||||
- optional: `place/*`, `person/*`, `level/*` (z. B. `person/rouven`, `person/rohan`)
|
||||
- **Regeln:**
|
||||
- Jede Notiz hat **mindestens ein** `area/*`.
|
||||
- `topic/*` sparsam, aber konsistent; ein Mapping in `_meta/tags.md` pflegen.
|
||||
- Möglichst **keine** losen Ein-Wort-Tags ohne Präfix (verhindert Wildwuchs).
|
||||
**Verlinkungen**
|
||||
- Wikilinks: `[[note-id]]` oder `[[Titel|note-id]]`
|
||||
- Automatische Edges aus Text und Frontmatter
|
||||
|
||||
**Edge-Typen in Qdrant**
|
||||
|
||||
| Typ | Bedeutung | Quelle | Scope |
|
||||
|------|------------|--------|--------|
|
||||
| `belongs_to` | Chunk → Note | intern | chunk |
|
||||
| `prev` / `next` | Reihenfolge | intern | chunk |
|
||||
| `references` | explizite Wikilinks | Text | chunk |
|
||||
| `backlink` | Gegenkante zu `references` | abgeleitet | note |
|
||||
| `depends_on` | YAML-Abhängigkeiten | YAML | note |
|
||||
| `assigned_to` | YAML-Zuweisung | YAML | note |
|
||||
| `unresolved` | Ziel fehlt (Stub) | abgeleitet | chunk |
|
||||
|
||||
**Edge-Schlüssel**
|
||||
- `source_id`, `target_id`, `kind`, `scope`, `note_id`
|
||||
- Dedup-Schlüssel: Kombination aus `(kind, source_id, target_id, scope)`
|
||||
|
||||
---
|
||||
|
||||
## 5. Backlink- & Link-Regeln
|
||||
## 5. Chunking-Modell
|
||||
|
||||
- **Wikilinks** verwenden: `[[stabile-id-oder-dateiname]]`
|
||||
- Im **Fließtext** bei erster Nennung verlinken; am **Ende** die Sektion **„Mögliche Verbindungen“** pflegen:
|
||||
**Chunk-Datenstruktur**
|
||||
| Feld | Beschreibung |
|
||||
|-------|---------------|
|
||||
| `note_id` | Zugehörige Note |
|
||||
| `chunk_index` | Laufende Nummer |
|
||||
| `text` | Originalabschnitt |
|
||||
| `window` | Text + Overlap links/rechts |
|
||||
| `overlap_left` | Länge des linken Overlaps |
|
||||
| `overlap_right` | Länge des rechten Overlaps |
|
||||
| `embedding` | 384-dimensionaler Vektor |
|
||||
| `tokens` | Tokenanzahl (optional) |
|
||||
|
||||
## Mögliche Verbindungen
|
||||
- [[concept-persoenliches-leitbild]]
|
||||
- [[project-mindnet]]
|
||||
|
||||
- **Linkrichtung:** „aufwärts“ (Detail → Konzept/Leitbild) und „seitwärts“ (verwandte Knoten).
|
||||
- Optional zusätzlich **ID-Relationen** im YAML (`related_ids`) für Parser.
|
||||
|
||||
## 5.1 Edge-Typen
|
||||
|
||||
Beziehungen zwischen Notizen, Chunks und Objekten werden als **Edges** gespeichert. Jeder Edge erhält einen `type` und optionale `meta`-Informationen (z. B. Gewichtung, Richtung).
|
||||
|
||||
- **belongs_to**
|
||||
Chunk → Note (ein Chunk gehört zu genau einer Note)
|
||||
|
||||
- **references**
|
||||
Note → Note (eine Notiz verweist auf eine andere)
|
||||
|
||||
- **backlink**
|
||||
Automatisch generiert: Gegenkante von `references`
|
||||
|
||||
- **depends_on**
|
||||
Task → Task oder Task → Project (Aufgabe hängt von anderer ab)
|
||||
|
||||
- **assigned_to**
|
||||
Task → Person (eine Aufgabe ist einer Person zugeordnet)
|
||||
|
||||
- **discussed_in**
|
||||
Note/Concept → Meeting (ein Thema wurde in einem Meeting behandelt)
|
||||
|
||||
- **authored_by**
|
||||
Note → Person (z. B. externer Autor oder eigene Urheberschaft)
|
||||
|
||||
- **related**
|
||||
Generische Relation für schwache Assoziationen
|
||||
**Chunking-Regeln (aus `chunking_strategy.md`)**
|
||||
- Trennung nach Absätzen, Überschriften, Listen, Tabellen
|
||||
- Token-Zielgröße 350–500 (max 600)
|
||||
- Overlap: 30–40 % für semantische Kohärenz
|
||||
- Overlap wird in `window` integriert, sodass `text ≠ window`
|
||||
|
||||
---
|
||||
|
||||
## 6. Abschnitts-Konventionen im Body
|
||||
## 6. Hash-Strategie und Änderungsverfolgung
|
||||
|
||||
Einheitliche Überschriften erleichtern spätere Parser und Abfragen.
|
||||
**Zweck:** Nur bei realer Inhaltsänderung re-indexieren
|
||||
|
||||
- **Gedanke (`thought`)**
|
||||
`## Zusammenfassung` · `## Begründung / Details` · `## Belege / Quellen` · `## Nächste Schritte` · `## Mögliche Verbindungen`
|
||||
- **Erfahrung (`experience`)**
|
||||
`## Kontext` · `## Beobachtung` · `## Interpretation` · `## Implikationen` · `## Mögliche Verbindungen`
|
||||
- **Aufgabe (`task`)**
|
||||
`## Checkliste` · `## Notizen` · `## Mögliche Verbindungen`
|
||||
- **Projekt (`project`)**
|
||||
`## Scope` · `## Arbeitspakete` · `## Risiken & Gegenmaßnahmen` · `## Status / Fortschritt` · `## Mögliche Verbindungen`
|
||||
- **Journal (`journal`)**
|
||||
`## Tageszusammenfassung` · `## Highlights` · `## Gelernt / Notizen` · `## Mögliche Verbindungen`
|
||||
| Umgebungsvariable | Beschreibung |
|
||||
|--------------------|--------------|
|
||||
| `MINDNET_HASH_COMPARE` | Vergleichsquelle (`Body`, `Full`, `Frontmatter`) |
|
||||
| `MINDNET_HASH_SOURCE` | Rohtext vs. geparst (`raw` / `parsed`) |
|
||||
| `MINDNET_HASH_NORMALIZE` | Normalisierung (`canonical` / `none`) |
|
||||
|
||||
**Basismodi**
|
||||
- `body` → Nur Textkörper
|
||||
- `frontmatter` → Nur Metadaten
|
||||
- `full` → Kombination
|
||||
- Hash = SHA-256(canonicalized_input)
|
||||
|
||||
Bei Änderung: Re-Import, neue Embeddings, Edges werden aktualisiert.
|
||||
|
||||
---
|
||||
|
||||
## 7. Abbildung persönlicher Inhalte auf Typen
|
||||
## 7. Qdrant-Speicherstruktur
|
||||
|
||||
- **Persönliches Leitbild** → `type: "concept"` (oder optional neuer Typ `manifesto`)
|
||||
Datei: `concept-persoenliches-leitbild.md` (zeitunabhängig)
|
||||
Verlinkt zu prägenden Erfahrungen und Wendepunkten.
|
||||
- **Erfahrungen, die dich geprägt haben** → `type: "experience"`
|
||||
Je **eine** prägende Erfahrung pro Datei; klarer Kontext + Interpretation.
|
||||
- **Wendepunkte im Leben** → `type: "milestone"`
|
||||
Je Wendepunkt ein Knoten; verlinkt zu den auslösenden Erfahrungen.
|
||||
- **Aktuelle Erfahrungen** → `type: "experience"`, `status: "active"`
|
||||
Bei Bedarf später in „prägende“ Erfahrungen überführen.
|
||||
- **Entwicklungsschritte der Kinder** → `type: "journal"` (chronologisch) **oder** `experience` (wenn es prägend ist); Tags `person/<name>`.
|
||||
- **Tagebucheinträge** → `type: "journal"`; ein Eintrag pro Tag; tagesbasierte Dateinamen.
|
||||
| Collection | Inhalt | Primärfelder | Embedding |
|
||||
|-------------|---------|---------------|------------|
|
||||
| `mindnet_notes` | Notes mit Fulltext & Hash | `note_id` | optional |
|
||||
| `mindnet_chunks` | Chunks mit Text, Window, Embedding | `chunk_id`, `note_id` | 384 d |
|
||||
| `mindnet_edges` | Graphkanten | `edge_id`, `source_id`, `target_id` | — |
|
||||
|
||||
Damit entsteht ein **netzartiges Persönlichkeitsprofil** mit klaren Pfaden zwischen Werten (Leitbild), Ereignissen (Erfahrungen), Wendepunkten und fortlaufenden Beobachtungen (Journal).
|
||||
**Upsert-Strategie**
|
||||
- Idempotente UUIDv5-IDs
|
||||
- Keine Duplikate durch deterministische Signaturen
|
||||
- `purge-before-upsert` zur Bereinigung
|
||||
|
||||
**Indizes**
|
||||
- notes: `note_id`, `hash_signature`
|
||||
- chunks: `note_id`, `chunk_index`
|
||||
- edges: `(kind, source_id, target_id, scope)`
|
||||
|
||||
---
|
||||
|
||||
## 8. Beispiel-Notizen
|
||||
## 8. Fehler-Toleranz und Parser-Robustheit
|
||||
|
||||
### 8.1 Gedanke (`thought`)
|
||||
---
|
||||
title: "Gedanke: Einheitliche YAML-Standards steigern Recall"
|
||||
id: "20250902-1830-thought-yaml-recall"
|
||||
type: "thought"
|
||||
status: "idea"
|
||||
created: 2025-09-02T18:30:00+02:00
|
||||
updated: 2025-09-02T18:30:00+02:00
|
||||
tags: ["area/mindnet","type/thought","topic/yaml","topic/recall"]
|
||||
area: "mindnet"
|
||||
project: "project-mindnet"
|
||||
aliases: []
|
||||
---
|
||||
|
||||
## Zusammenfassung
|
||||
Konsistente YAML-Felder verbessern Filter, Dataview-Queries und Vektor-Retrieval.
|
||||
|
||||
## Begründung / Details
|
||||
- Parser benötigen stabile Feldnamen (z. B. `type`, `status`).
|
||||
- Einheitliche Werte erleichtern Dashboards und Automationen.
|
||||
|
||||
## Belege / Quellen
|
||||
- [[source-obsidian-properties]]
|
||||
- [[concept-vektorsuche-qdrant]]
|
||||
|
||||
## Nächste Schritte
|
||||
- [ ] `tags`-Mapping in `_meta/tags.md` erstellen
|
||||
- [ ] Beispiel-Queries für Dataview hinterlegen
|
||||
|
||||
## Mögliche Verbindungen
|
||||
- [[project-mindnet]]
|
||||
- [[20250902-1730-task-yaml-standard-migration]]
|
||||
|
||||
### 8.2 Erfahrung (`experience`)
|
||||
---
|
||||
title: "Erfahrung: Journal → Erfahrung extrahieren erhöht Klarheit"
|
||||
id: "20250902-1840-experience-journal-extraktion"
|
||||
type: "experience"
|
||||
status: "active"
|
||||
created: 2025-09-02T18:40:00+02:00
|
||||
updated: 2025-09-02T18:40:00+02:00
|
||||
tags: ["area/personal","type/experience","topic/journal","topic/reflexion"]
|
||||
area: "personal"
|
||||
project: "project-mindnet"
|
||||
---
|
||||
|
||||
## Kontext
|
||||
Wiederkehrende Journaleinträge enthalten Rohmaterial für prägende Einsichten.
|
||||
|
||||
## Beobachtung
|
||||
Wird Material regelmäßig zu `experience`-Knoten verdichtet, sind spätere Bezüge einfacher.
|
||||
|
||||
## Interpretation
|
||||
Abstraktion + Verlinkung (z. B. auf [[concept-persoenliches-leitbild]]) erhöhen Nutzen und Wiederfindbarkeit.
|
||||
|
||||
## Implikationen
|
||||
Pro Woche 15–30 Minuten „Verdichtungs-Review“ einplanen.
|
||||
|
||||
## Mögliche Verbindungen
|
||||
- [[journal-20250902]]
|
||||
- [[concept-persoenliches-leitbild]]
|
||||
|
||||
### 8.3 Aufgabe (`task`)
|
||||
---
|
||||
title: "Task: YAML-Standard in Altbeständen ergänzen"
|
||||
id: "20250902-1850-task-yaml-migration"
|
||||
type: "task"
|
||||
status: "active"
|
||||
created: 2025-09-02
|
||||
updated: 2025-09-02
|
||||
due: 2025-09-10
|
||||
start: 2025-09-03
|
||||
priority: 2
|
||||
effort_min: 120
|
||||
area: "mindnet"
|
||||
project: "project-mindnet"
|
||||
tags: ["area/mindnet","type/task","topic/migration"]
|
||||
depends_on: []
|
||||
---
|
||||
|
||||
## Checkliste
|
||||
- [ ] Triage: Notiz-Typ bestimmen
|
||||
- [ ] Minimal-YAML ergänzen (Pflichtfelder)
|
||||
- [ ] Dateinamen vereinheitlichen
|
||||
- [ ] „Mögliche Verbindungen“ pflegen
|
||||
|
||||
## Notizen
|
||||
Beginne mit zuletzt genutzten Notizen (Pareto 20/80).
|
||||
|
||||
## Mögliche Verbindungen
|
||||
- [[project-mindnet]]
|
||||
- [[20250902-1830-thought-yaml-recall]]
|
||||
- UTF-8 mit Fallback: ersetzt ungültige Bytes (`errors="replace"`)
|
||||
- Ignoriert Nullbytes, BOM, exotische Zeilenenden
|
||||
- Erkennt defekte oder leere YAML-Header und überspringt sie
|
||||
- Logt Problemfälle (`read_markdown failed`, `make_note_payload returned non-dict`)
|
||||
- Bei Fehlern: Import → warn → continue
|
||||
|
||||
---
|
||||
|
||||
## 9. Schrittweise Migration bestehender freier Notizen
|
||||
## 9. Tests & Validierung
|
||||
|
||||
**Phase A – Triage (schnell)**
|
||||
1. Sichtung & **Typ** bestimmen (`type`).
|
||||
2. **Minimal-YAML** einfügen (`title`, `id`, `type`, `status=draft`, `created≈Dateidatum`, `tags`).
|
||||
3. **Dateiname** grob anpassen (Schema + Slug).
|
||||
**Integrationstests**
|
||||
- Roundtrip: Import → Export → Compare (`compare_vaults.py`)
|
||||
- Chunk-Integrität: `verify_chunks_integrity.py`
|
||||
- Hash-Audit: `hash_reporter.py`
|
||||
- Window-Vergleich: `check_chunks_window_vs_text.py`
|
||||
|
||||
**Phase B – Strukturieren (fokussiert)**
|
||||
1. **Abschnitte** nach Typ-Template ergänzen.
|
||||
2. **Zerlegen**: mehrere Gedanken/Ereignisse → je **eigene Datei**, ursprüngliche Datei wird zum **Index** mit Links.
|
||||
3. **Verlinken**: relevante `[[Knoten]]` + **„Mögliche Verbindungen“** pflegen.
|
||||
|
||||
**Phase C – Verfeinern (bei Bedarf)**
|
||||
1. **Status & Felder** pflegen (`status`, `priority`, `due`, `effort_min`).
|
||||
2. **Tag-Harmonisierung**: Mapping-Tabelle pflegen (`_meta/tags.md`).
|
||||
3. **Aliases** ergänzen (Such-/Linkvarianten).
|
||||
|
||||
**Priorisierung:** Starte mit **aktuellen & häufig genutzten** Notizen (Pareto-Prinzip), Altbestände nachziehen, wenn sie wieder gebraucht werden.
|
||||
**Erwartete Ergebnisse**
|
||||
- Alle Notes werden erkannt
|
||||
- `window ≠ text` bei > 60 % der Chunks
|
||||
- Roundtrip-Vergleich liefert „OK“
|
||||
- Edge-Anzahl entspricht Modell (belongs_to = #Chunks, next/prev ≈ #Chunks – 1)
|
||||
|
||||
---
|
||||
|
||||
## 10. Dataview-Beispiele (direkt nutzbar)
|
||||
## 10. Export & Roundtrip-Verhalten
|
||||
|
||||
**Offene Aufgaben dieser Woche (nach Priorität):**
|
||||
|
||||
TABLE due, priority, effort_min
|
||||
FROM "31_tasks"
|
||||
WHERE type = "task" AND status != "done"
|
||||
AND due >= date(today) - dur(1 week)
|
||||
AND due <= date(today) + dur(1 week)
|
||||
SORT priority ASC, due ASC
|
||||
|
||||
**Aktive Projekte mit Meilensteinen:**
|
||||
|
||||
LIST
|
||||
FROM "30_projects"
|
||||
WHERE type = "project" AND status = "active"
|
||||
SORT priority ASC, file.ctime DESC
|
||||
|
||||
**Gedanken im Bereich mindnet, jüngste zuerst:**
|
||||
|
||||
TABLE created, status
|
||||
FROM "10_thoughts"
|
||||
WHERE type = "thought" AND area = "mindnet"
|
||||
SORT created DESC
|
||||
LIMIT 50
|
||||
|
||||
**Quellen ohne `source_url` (Pflegebedarf):**
|
||||
|
||||
TABLE title, created
|
||||
FROM "50_sources"
|
||||
WHERE type = "source" AND (source_url = "" OR !source_url)
|
||||
- `export_markdown.py` erzeugt identische Markdown-Dateien
|
||||
- Schreibt YAML + Body in korrekter Reihenfolge
|
||||
- Roundtrip-Prüfung (`compare_vaults.py`) validiert:
|
||||
- vollständigen Body
|
||||
- unveränderte Hash-Signatur
|
||||
- gleiche Chunkzahl
|
||||
|
||||
---
|
||||
|
||||
## 11. Validierung & Pflege
|
||||
## 11. Graph-Schicht und WP-04-Integration
|
||||
|
||||
- **Wöchentlicher Review-Slot (15–30 Min.):**
|
||||
- Neue Notizen triagieren (`type`, `status`, `area`)
|
||||
- 5 Alt-Notizen migrieren (YAML + Dateiname + Verlinkung)
|
||||
- **Dataview-Checks:** fehlende `source_url`, offene Tasks, aktive Projekte, veraltete `status`.
|
||||
- **Optional (technisch):**
|
||||
- **Pre-commit Hook**: prüft Pflichtfelder (`title`, `id`, `type`, `status`, `created`, `tags`)
|
||||
- **ID-Generator**: `YYYYMMDD-HHMM-type-slug` bei Neuanlage
|
||||
- **Link-Linter**: prüft tote `[[Links]]`
|
||||
- Qdrant fungiert als Graph-Backend
|
||||
- `graph/service.py` (WP-04): stellt API für Mehrhop-Abfragen bereit
|
||||
- Unterstützt:
|
||||
- `expand(note_id, hops=2)`
|
||||
- `resolve_unresolved()`
|
||||
- `neighbors(kind=…)`
|
||||
- Grundlage für spätere **Retriever-Funktionen** (LLM / Agenten)
|
||||
|
||||
---
|
||||
|
||||
## 12. Versions- & Änderungsrichtlinien
|
||||
## 12. Agenten- und LLM-Integration
|
||||
|
||||
- Dieses Dokument pflegt `version` & `updated`.
|
||||
- **Breaking Changes** (z. B. Feldumbenennungen) in `_meta/changelog.md` dokumentieren.
|
||||
- **Migrationen** (Tag-Refactorings, Typänderungen) als Skript oder Batch-Checkliste planen.
|
||||
**Retriever-Pipeline**
|
||||
1. Suche top-k Chunks (cosine distance)
|
||||
2. Erweiterung um Edges (`references`, `backlinks`)
|
||||
3. Kontext-Assembling via `window`-Text
|
||||
4. Prompt-Generierung
|
||||
|
||||
**Agent-Use-Cases**
|
||||
- Automatisches Tagging (`type`, `status`)
|
||||
- Vorschläge für neue Edges
|
||||
- Auflösen von `unresolved`-Referenzen
|
||||
- Auto-Import externer Quellen (MediaWiki, PDFs, Webseiten)
|
||||
|
||||
---
|
||||
|
||||
## 13. Typen-Kurzreferenz
|
||||
## 13. Erweiterbarkeit
|
||||
|
||||
- `thought` – Gedanke/These
|
||||
- `experience` – Beobachtung/Erfahrung mit Interpretation & Implikationen
|
||||
- `task` – umsetzbare Arbeitseinheit (mit `due`, `effort_min`, `priority`)
|
||||
- `project` – Container für Ziele/Tasks/Meilensteine
|
||||
- `source` – externe Quelle (Artikel, Buch, Video)
|
||||
- `concept` – definierter Begriff / Prinzip / Leitbild
|
||||
- `person` – Bezugsperson/Kontakt
|
||||
- `meeting` – Termin mit Agenda, Notizen, erzeugten Aufgaben
|
||||
- `journal` – Tagebuch-/Reiseeintrag (tagesbasiert)
|
||||
- `milestone` – Wendepunkt / Meilenstein im Lebens-/Projektverlauf
|
||||
- Neue Edge-Typen: `inspired_by`, `relates_to`, `contradicts`
|
||||
- Neue Note-Typen: `decision`, `resource`, `recommendation`
|
||||
- Embedding-Engines austauschbar (MiniLM → LaBSE → E5)
|
||||
- Versionierte Chunking-Strategien (`chunk_config.py`)
|
||||
|
||||
---
|
||||
|
||||
## 14 Erweiterungen
|
||||
## 14. Qualitätssicherung und Best Practices
|
||||
|
||||
Zukünftige Typen möglich (z. B. decision, recommendation).
|
||||
- Validierung vor Upsert
|
||||
- Keine Leer-Chunks
|
||||
- Vollständige Metadaten in Notes
|
||||
- Tests in `tests/` automatisch ausführbar (`run_e2e_roundtrip.sh`)
|
||||
- Ergebnis: „Roundtrip OK“ und `verify_chunks_integrity` = OK
|
||||
|
||||
Personalisierung durch zusätzliche Properties (values, goals)
|
||||
---
|
||||
|
||||
## 15. Änderungsverlauf
|
||||
|
||||
**v1.4.0 (2025-10-06)**
|
||||
- Neu: `window` vs `text` Feld in `mindnet_chunks`
|
||||
- Neu: Hash-Modi (`body`, `frontmatter`, `full`) mit Env-Steuerung
|
||||
- Neu: Baseline-Modus für Vergleich
|
||||
- Parser → fehlertolerant (UTF-8 replace)
|
||||
- Roundtrip-Test vollständig integriert
|
||||
- Graph-Service und Mehrhop-Abfragen (WP-04-Vorbereitung)
|
||||
- `purge-before-upsert` und `--note-scope-refs` Parameter ergänzt
|
||||
|
||||
**v1.3.0 (2025-09-09)**
|
||||
- Hash-Normalisierung und Edge-Scope
|
||||
- Roundtrip-Tests, Agenten-Integration
|
||||
|
||||
**v1.2.0 (2025-09-02)**
|
||||
- Grundstruktur des Knowledge-Designs
|
||||
|
||||
---
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
|
||||
fastapi
|
||||
uvicorn[standard]
|
||||
qdrant-client
|
||||
pydantic>=2
|
||||
sentence-transformers
|
||||
torch
|
||||
python-frontmatter
|
||||
tqdm
|
||||
requests
|
||||
numpy
|
||||
+79
-27
@@ -2,37 +2,89 @@
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "mindnet_chunk",
|
||||
"type": "object",
|
||||
"required": ["id", "note_id", "chunk_index", "type", "path", "token_count", "lang"],
|
||||
"description": "Chunk-Payload (Qdrant). Kompatibel mit Alt-Feldern und neuen Feldern für Export/Roundtrip.",
|
||||
"required": ["id", "note_id", "chunk_index", "path"],
|
||||
"properties": {
|
||||
"id": {"type": "string"},
|
||||
"note_id": {"type": "string"},
|
||||
"note_title": {"type": "string"},
|
||||
"chunk_index": {"type": "integer"},
|
||||
"char_start": {"type": "integer"},
|
||||
"char_end": {"type": "integer"},
|
||||
"token_count": {"type": "integer"},
|
||||
"type": {"type": "string"},
|
||||
"area": {"type": "string"},
|
||||
"project": {"type": "string"},
|
||||
"tags": {"type": "array", "items": {"type": "string"}},
|
||||
"section_title": {"type": "string"},
|
||||
"section_path": {"type": "string"},
|
||||
"lang": {"type": "string"},
|
||||
"wikilinks": {"type": "array", "items": {"type": "string"}},
|
||||
"external_links": {"type": "array", "items": {"type": "string"}},
|
||||
"id": { "type": "string" },
|
||||
"scope": { "type": "string", "enum": ["chunk"] },
|
||||
"note_id": { "type": "string" },
|
||||
"note_title": { "type": "string" },
|
||||
"note_type": { "type": "string" },
|
||||
"note_status": { "type": "string" },
|
||||
"type": { "type": "string", "description": "Legacy: früherer Chunk-Typ; kann dem Note-Typ entsprechen" },
|
||||
"area": { "type": "string" },
|
||||
"project": { "type": "string" },
|
||||
"tags": { "type": "array", "items": { "type": "string" } },
|
||||
|
||||
"note_path": { "type": "string" },
|
||||
"path": { "type": "string" },
|
||||
|
||||
"chunk_index": { "type": "integer" },
|
||||
"section_title":{ "type": ["string","null"] },
|
||||
"section_path": { "type": ["string","null"] },
|
||||
|
||||
"char_start": { "type": ["integer","null"] },
|
||||
"char_end": { "type": ["integer","null"] },
|
||||
"char_len": { "type": "integer" },
|
||||
|
||||
"token_count": { "type": "integer", "description": "Legacy: frühere Token-Zahl" },
|
||||
"token_est": { "type": "integer", "description": "Neue grobe Token-Schätzung (≈ len(text)/4)" },
|
||||
|
||||
"neighbors": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prev": { "type": ["string","null"] },
|
||||
"next": { "type": ["string","null"] }
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"text": { "type": "string" },
|
||||
"text_sha256": { "type": "string", "pattern": "^sha256:[0-9a-fA-F]{64}$" },
|
||||
"lang": { "type": "string" },
|
||||
|
||||
"wikilinks": { "type": "array", "items": { "type": "string" } },
|
||||
"external_links": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{ "type": "string" },
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"href": { "type": "string" },
|
||||
"label": { "type": ["string","null"] }
|
||||
},
|
||||
"required": ["href"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"references": {
|
||||
"type": "array",
|
||||
"items": {"type": "object", "properties": {
|
||||
"target_id": {"type": "string"},
|
||||
"kind": {"type": "string"}
|
||||
}, "required": ["target_id", "kind"]}
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"target_id": { "type": "string" },
|
||||
"kind": { "type": "string" }
|
||||
},
|
||||
"required": ["target_id","kind"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"neighbors": {"type": "object", "properties": {
|
||||
"prev": {"type": ["string","null"]},
|
||||
"next": {"type": ["string","null"]}
|
||||
}},
|
||||
"path": {"type": "string"},
|
||||
"created_at": {"type": "string"}
|
||||
|
||||
"embed_model": { "type": "string" },
|
||||
"embed_dim": { "type": "integer" },
|
||||
"embed_version": { "type": "integer" },
|
||||
|
||||
"created_at": { "type": "string" }
|
||||
},
|
||||
|
||||
"allOf": [
|
||||
{ "anyOf": [ { "required": ["token_count"] }, { "required": ["token_est"] } ] },
|
||||
{ "anyOf": [ { "required": ["type"] }, { "required": ["note_type"] } ] }
|
||||
],
|
||||
|
||||
"additionalProperties": true
|
||||
}
|
||||
@@ -2,15 +2,30 @@
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "mindnet_edge",
|
||||
"type": "object",
|
||||
"required": ["src_id", "dst_id", "edge_type", "scope"],
|
||||
"description": "Edge-Payload (Qdrant). Unterstützt Legacy (edge_type/src_id/dst_id) und neues Schema (kind/source_id/target_id/note_id/status).",
|
||||
|
||||
"properties": {
|
||||
"src_id": {"type": "string"},
|
||||
"dst_id": {"type": "string"},
|
||||
"edge_type": {"type": "string"},
|
||||
"scope": {"type": "string", "enum": ["note","chunk"]},
|
||||
"weight": {"type": "number"},
|
||||
"meta": {"type": "object"},
|
||||
"created_at": {"type": "string"}
|
||||
"scope": { "type": "string", "enum": ["note","chunk"] },
|
||||
|
||||
"edge_type": { "type": "string", "description": "Legacy: z. B. references/backlink/belongs_to/prev/next" },
|
||||
"src_id": { "type": "string", "description": "Legacy: source_id" },
|
||||
"dst_id": { "type": "string", "description": "Legacy: target_id" },
|
||||
|
||||
"kind": { "type": "string", "description": "Neu: z. B. references/backlink/belongs_to/prev/next" },
|
||||
"source_id": { "type": "string" },
|
||||
"target_id": { "type": "string" },
|
||||
"note_id": { "type": "string", "description": "Owner-Note für diesen Edge (Filter/Purge)" },
|
||||
"status": { "type": "string", "description": "optional, z. B. 'unresolved'" },
|
||||
|
||||
"weight": { "type": "number" },
|
||||
"meta": { "type": "object" },
|
||||
"created_at":{ "type": "string" }
|
||||
},
|
||||
|
||||
"anyOf": [
|
||||
{ "required": ["src_id", "dst_id", "edge_type", "scope"] },
|
||||
{ "required": ["source_id", "target_id", "kind", "scope"] }
|
||||
],
|
||||
|
||||
"additionalProperties": true
|
||||
}
|
||||
+38
-40
@@ -1,47 +1,45 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "mindnet_note",
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "mindnet note payload",
|
||||
"type": "object",
|
||||
"required": ["note_id", "title", "type", "status", "created", "path"],
|
||||
"properties": {
|
||||
"note_id": { "type": "string" },
|
||||
"title": { "type": "string" },
|
||||
"type": { "type": "string" },
|
||||
"status": { "type": "string" },
|
||||
"created": { "type": "string" },
|
||||
"updated": { "type": "string" },
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"area": { "type": "string" },
|
||||
"project": { "type": "string" },
|
||||
"priority": { "type": "number" },
|
||||
"effort_min": { "type": "number" },
|
||||
"due": { "type": "string" },
|
||||
"people": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"aliases": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"references": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"depends_on": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"assigned_to": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"lang": { "type": "string" },
|
||||
"path": { "type": "string" },
|
||||
"hash_fulltext": { "type": "string" }
|
||||
"title": { "type": ["string","null"] },
|
||||
"type": { "type": ["string","null"] },
|
||||
"status": { "type": ["string","null"] },
|
||||
"created": { "type": ["string","null"] },
|
||||
"updated": { "type": ["string","null"] },
|
||||
"path": { "type": ["string","null"] },
|
||||
"tags": { "type": ["array","null"], "items": { "type": "string" } },
|
||||
"area": { "type": ["string","null"] },
|
||||
"project": { "type": ["string","null"] },
|
||||
"source": { "type": ["string","null"] },
|
||||
"lang": { "type": ["string","null"] },
|
||||
"slug": { "type": ["string","null"] },
|
||||
"aliases": { "type": ["array","null"], "items": { "type": "string" } },
|
||||
|
||||
"fulltext": { "type": ["string","null"] },
|
||||
"references": { "type": ["array","null"], "items": { "type": "string" } },
|
||||
|
||||
"hash_fulltext": { "type": ["string","null"], "pattern": "^[a-f0-9]{64}$" },
|
||||
"hash_signature": { "type": ["string","null"] },
|
||||
|
||||
"hash_body": { "type": ["string","null"], "pattern": "^[a-f0-9]{64}$" },
|
||||
"hash_frontmatter": { "type": ["string","null"], "pattern": "^[a-f0-9]{64}$" },
|
||||
"hash_full": { "type": ["string","null"], "pattern": "^[a-f0-9]{64}$" },
|
||||
|
||||
"hashes": {
|
||||
"type": ["object","null"],
|
||||
"description": "Mapping: <mode>:<source>:<normalize> -> sha256 hex",
|
||||
"patternProperties": {
|
||||
"^(body|frontmatter|full):(parsed|raw):(canonical|none)$": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-f0-9]{64}$"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["note_id"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Script: audit_edges_vs_expectations.py — Prüfe Kanten in Qdrant gegen Vault-Erwartungen
|
||||
Version: 1.0.0
|
||||
Datum: 2025-09-09
|
||||
|
||||
Zweck
|
||||
-----
|
||||
- Liest Edges/Chunks/Notes aus Qdrant.
|
||||
- Ermittelt erwartete Kanten-Anzahlen aus dem Vault:
|
||||
* belongs_to : sollte == #Chunks
|
||||
* next / prev : je Note (#Chunks_in_Note - 1)
|
||||
* references : Summe aller Chunk-Wikilinks
|
||||
* backlink : Summe einzigartiger Wikilinks pro Note (Note-Level)
|
||||
- Vergleicht IST vs. SOLL und meldet Abweichungen.
|
||||
|
||||
ENV/Qdrant
|
||||
----------
|
||||
QDRANT_URL, QDRANT_API_KEY (optional), COLLECTION_PREFIX (Default: mindnet)
|
||||
|
||||
Aufrufe
|
||||
-------
|
||||
# Gesamtaudit
|
||||
python3 -m scripts.audit_edges_vs_expectations --vault ./test_vault
|
||||
|
||||
# Mit anderem Prefix
|
||||
python3 -m scripts.audit_edges_vs_expectations --vault ./test_vault --prefix mindnet_dev
|
||||
|
||||
# Details anzeigen
|
||||
python3 -m scripts.audit_edges_vs_expectations --vault ./test_vault --details
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from collections import defaultdict, Counter
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
from qdrant_client import QdrantClient
|
||||
from qdrant_client.http import models as rest
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Projektmodule – nur leichtgewichtige Funktionen
|
||||
try:
|
||||
from app.core.parser import read_markdown
|
||||
except Exception:
|
||||
# sehr einfacher Fallback für Wikilinks
|
||||
read_markdown = None
|
||||
|
||||
WIKILINK_RE = re.compile(r"\[\[([^\]]+)\]\]")
|
||||
|
||||
# ------------------------------
|
||||
# Qdrant Helpers
|
||||
# ------------------------------
|
||||
|
||||
def _names(prefix: str) -> Tuple[str, str, str]:
|
||||
return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges"
|
||||
|
||||
def _scroll_all(client: QdrantClient, col: str, flt=None, with_payload=True, with_vectors=False, limit=256):
|
||||
out, next_page = [], None
|
||||
while True:
|
||||
pts, next_page = client.scroll(
|
||||
collection_name=col,
|
||||
scroll_filter=flt,
|
||||
with_payload=with_payload,
|
||||
with_vectors=with_vectors,
|
||||
limit=limit,
|
||||
offset=next_page,
|
||||
)
|
||||
if not pts:
|
||||
break
|
||||
out.extend(pts)
|
||||
if not next_page:
|
||||
break
|
||||
return out
|
||||
|
||||
# ------------------------------
|
||||
# Vault scan
|
||||
# ------------------------------
|
||||
|
||||
def _iter_md(root: str) -> List[str]:
|
||||
out: List[str] = []
|
||||
for dp, _, fns in os.walk(root):
|
||||
for fn in fns:
|
||||
if fn.lower().endswith(".md"):
|
||||
p = os.path.join(dp, fn)
|
||||
if "/.obsidian/" in p.replace("\\", "/"):
|
||||
continue
|
||||
out.append(p)
|
||||
return sorted(out)
|
||||
|
||||
def _wikilinks_in_text(text: str) -> List[str]:
|
||||
return WIKILINK_RE.findall(text or "")
|
||||
|
||||
def _wikilinks_per_note(vault_root: str) -> Dict[str, List[str]]:
|
||||
res: Dict[str, List[str]] = {}
|
||||
for p in _iter_md(vault_root):
|
||||
body = ""
|
||||
try:
|
||||
if read_markdown:
|
||||
parsed = read_markdown(p)
|
||||
body = parsed.body or ""
|
||||
fm = parsed.frontmatter or {}
|
||||
nid = fm.get("id") or fm.get("note_id") or os.path.splitext(os.path.basename(p))[0]
|
||||
else:
|
||||
with open(p, "r", encoding="utf-8") as f:
|
||||
txt = f.read()
|
||||
# sehr einfacher Split: YAML-Frontmatter rausnehmen
|
||||
if txt.lstrip().startswith("---"):
|
||||
parts = txt.split("\n---", 1)
|
||||
body = parts[1] if len(parts) > 1 else txt
|
||||
else:
|
||||
body = txt
|
||||
nid = os.path.splitext(os.path.basename(p))[0]
|
||||
res[nid] = _wikilinks_in_text(body)
|
||||
except Exception:
|
||||
continue
|
||||
return res
|
||||
|
||||
# ------------------------------
|
||||
# Main Audit
|
||||
# ------------------------------
|
||||
|
||||
def main():
|
||||
load_dotenv()
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--vault", required=True, help="Pfad zum Vault (für Erwartungswerte)")
|
||||
ap.add_argument("--prefix", default=os.environ.get("COLLECTION_PREFIX", "mindnet"), help="Collection-Prefix")
|
||||
ap.add_argument("--details", action="store_true", help="Detail-Listen ausgeben")
|
||||
args = ap.parse_args()
|
||||
|
||||
client = QdrantClient(url=os.environ.get("QDRANT_URL", "http://127.0.0.1:6333"),
|
||||
api_key=os.environ.get("QDRANT_API_KEY") or None)
|
||||
notes_col, chunks_col, edges_col = _names(args.prefix)
|
||||
|
||||
# Qdrant laden
|
||||
notes = _scroll_all(client, notes_col, with_payload=True, with_vectors=False)
|
||||
chunks = _scroll_all(client, chunks_col, with_payload=True, with_vectors=False)
|
||||
edges = _scroll_all(client, edges_col, with_payload=True, with_vectors=False)
|
||||
|
||||
# --- Ist-Zähler
|
||||
cnt_kind = Counter()
|
||||
cnt_scope = Counter()
|
||||
by_note_chunks: Dict[str, int] = defaultdict(int)
|
||||
chunk_wikilinks_total = 0
|
||||
|
||||
for p in chunks:
|
||||
pl = p.payload or {}
|
||||
by_note_chunks[pl.get("note_id")] += 1
|
||||
wl = pl.get("wikilinks") or []
|
||||
if isinstance(wl, list):
|
||||
chunk_wikilinks_total += len(wl)
|
||||
|
||||
for p in edges:
|
||||
pl = p.payload or {}
|
||||
kind = pl.get("kind") or pl.get("edge_type") or "?"
|
||||
scope = pl.get("scope") or "?"
|
||||
cnt_kind[kind] += 1
|
||||
cnt_scope[f"{kind}:{scope}"] += 1
|
||||
|
||||
total_chunks = sum(by_note_chunks.values())
|
||||
|
||||
# --- Soll-Zähler aus Vault
|
||||
wl_per_note = _wikilinks_per_note(args.vault)
|
||||
backlink_expected = sum(len(set(v)) for v in wl_per_note.values())
|
||||
|
||||
next_expected = sum(max(c - 1, 0) for c in by_note_chunks.values())
|
||||
prev_expected = next_expected # symmetrische Kanten
|
||||
|
||||
belongs_to_expected = total_chunks
|
||||
references_expected = chunk_wikilinks_total # aus Chunk-Payloads
|
||||
|
||||
# --- Ergebnis
|
||||
result = {
|
||||
"qdrant_counts": dict(cnt_kind),
|
||||
"qdrant_counts_by_scope": dict(cnt_scope),
|
||||
"chunks_total": total_chunks,
|
||||
"by_note_chunks": dict(by_note_chunks),
|
||||
"vault_expected": {
|
||||
"belongs_to": belongs_to_expected,
|
||||
"next": next_expected,
|
||||
"prev": prev_expected,
|
||||
"references": references_expected,
|
||||
"backlink": backlink_expected,
|
||||
},
|
||||
"deltas": {
|
||||
"belongs_to": cnt_kind.get("belongs_to", 0) - belongs_to_expected,
|
||||
"next": cnt_kind.get("next", 0) - next_expected,
|
||||
"prev": cnt_kind.get("prev", 0) - prev_expected,
|
||||
"references": cnt_kind.get("references", 0) - references_expected,
|
||||
"backlink": cnt_kind.get("backlink", 0) - backlink_expected,
|
||||
},
|
||||
"collections": {
|
||||
"notes": notes_col, "chunks": chunks_col, "edges": edges_col
|
||||
}
|
||||
}
|
||||
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
|
||||
if args.details:
|
||||
# optionale Stichproben (z. B. fehlerhafte Kantenarten)
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,201 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Name: scripts/audit_vault_vs_qdrant.py
|
||||
Version: v1.0.0 (2025-09-05)
|
||||
Kurzbeschreibung:
|
||||
Prüft die Konsistenz zwischen Obsidian-Vault und Qdrant:
|
||||
- Zählt Markdown-Dateien mit gültiger Frontmatter (title, id, type, status, created).
|
||||
- Zählt Wikilink-Vorkommen im Vault (regex wie in derive_edges.py).
|
||||
- Liest Zählungen aus Qdrant (Notes/Chunks/Edges je kind).
|
||||
- Vergleicht erwartete Wikilink-Anzahl (Vault) vs. tatsächlich importierte Edges (Qdrant).
|
||||
- Listet Auffälligkeiten pro Note (z. B. Wikilinks im Vault, aber keine references in Qdrant).
|
||||
|
||||
Aufruf (aus Projekt-Root, im venv):
|
||||
python3 -m scripts.audit_vault_vs_qdrant --vault ./vault --prefix mindnet
|
||||
|
||||
Parameter:
|
||||
--vault Pfad zum Vault (z. B. ./vault)
|
||||
--prefix Collection-Prefix in Qdrant (Default: mindnet)
|
||||
--limit Max. Punkte pro Scroll-Seite aus Qdrant (Default: 1000)
|
||||
|
||||
Voraussetzungen:
|
||||
- Aktives Python venv mit installiertem qdrant-client.
|
||||
- Zugriff auf Qdrant per ENV (QDRANT_URL, QDRANT_API_KEY optional).
|
||||
|
||||
Hinweise:
|
||||
- Der Wikilink-Regex entspricht dem in app/core/derive_edges.py verwendeten Muster. (Quelle: derive_edges.py) # :contentReference[oaicite:3]{index=3}
|
||||
- Pflicht-Frontmatter wird wie in app/core/parser.py geprüft. (Quelle: parser.py) # :contentReference[oaicite:4]{index=4}
|
||||
- Collection-Namen & 1D-Edge-Vektoren folgen app/core/qdrant.py / qdrant_points.py. (Quellen: qdrant.py, qdrant_points.py) #
|
||||
|
||||
Changelog:
|
||||
v1.0.0: Erste Version.
|
||||
|
||||
Autor:
|
||||
mindnet – Datenimporte & Sync
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse, os, glob, re, json
|
||||
from collections import Counter, defaultdict
|
||||
from typing import Dict, List, Tuple, Optional
|
||||
|
||||
from qdrant_client import QdrantClient
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
# --- Regex wie in derive_edges.py (Wikilinks)
|
||||
WIKILINK_RE = re.compile(r"\[\[([^\]|#]+)(?:#([^\]|]+))?(?:\|([^\]]+))?\]\]") # :contentReference[oaicite:6]{index=6}
|
||||
|
||||
# --- Frontmatter-Prüfung wie in parser.validate_required_frontmatter (vereinfachte Replik) :contentReference[oaicite:7]{index=7}
|
||||
REQUIRED = ("title","id","type","status","created")
|
||||
|
||||
def has_required_frontmatter(front: Dict) -> bool:
|
||||
return all(k in front and front[k] not in (None, "") for k in REQUIRED)
|
||||
|
||||
def read_front_and_body(path: str) -> Tuple[Dict, str]:
|
||||
# Minimal-Parser wie parser.read_markdown (kein YAML-Import hier, um Abh. zu vermeiden)
|
||||
import yaml, unicodedata
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
raw = f.read().lstrip("\ufeff")
|
||||
raw = unicodedata.normalize("NFKC", raw).replace("\r\n", "\n").replace("\r", "\n")
|
||||
if raw.startswith("---\n"):
|
||||
end = raw.find("\n---", 4)
|
||||
if end != -1:
|
||||
fm_raw = raw[4:end].strip()
|
||||
body = raw[end+4:].lstrip("\n")
|
||||
try:
|
||||
fm = yaml.safe_load(fm_raw) or {}
|
||||
if not isinstance(fm, dict):
|
||||
fm = {}
|
||||
except Exception:
|
||||
fm = {}
|
||||
return fm, body
|
||||
return {}, raw
|
||||
|
||||
def slug_file(path: str) -> str:
|
||||
import unicodedata
|
||||
s = os.path.basename(path)
|
||||
if s.endswith(".md"): s = s[:-3]
|
||||
s = unicodedata.normalize("NFKD", s)
|
||||
s = "".join(ch for ch in s if not unicodedata.combining(ch))
|
||||
s = s.lower().replace(" ", "-")
|
||||
s = re.sub(r"[^a-z0-9\-]+", "", s)
|
||||
s = re.sub(r"-{2,}", "-", s).strip("-")
|
||||
return s
|
||||
|
||||
def collect_vault_stats(vault_root: str) -> Tuple[List[Dict], int]:
|
||||
files = [p for p in glob.glob(os.path.join(vault_root, "**", "*.md"), recursive=True)]
|
||||
notes: List[Dict] = []
|
||||
wikilink_total = 0
|
||||
for p in files:
|
||||
pn = p.replace("\\","/")
|
||||
if any(ex in pn for ex in ("/.obsidian/", "/_backup_frontmatter/", "/_imported/")):
|
||||
continue
|
||||
fm, body = read_front_and_body(p)
|
||||
if not has_required_frontmatter(fm):
|
||||
continue
|
||||
nid = fm.get("id")
|
||||
title = fm.get("title") or os.path.basename(p).rsplit(".",1)[0]
|
||||
relpath = os.path.relpath(p, vault_root).replace("\\","/")
|
||||
links = list(WIKILINK_RE.finditer(body))
|
||||
wikilink_total += len(links)
|
||||
notes.append({
|
||||
"note_id": nid,
|
||||
"title": title,
|
||||
"path": relpath,
|
||||
"wikilink_count": len(links),
|
||||
"file_slug": slug_file(p),
|
||||
})
|
||||
return notes, wikilink_total
|
||||
|
||||
def qdrant_client_from_env() -> QdrantClient:
|
||||
import os
|
||||
url = os.getenv("QDRANT_URL", "http://127.0.0.1:6333")
|
||||
api_key = os.getenv("QDRANT_API_KEY") or None
|
||||
return QdrantClient(url=url, api_key=api_key)
|
||||
|
||||
def scroll_all(client: QdrantClient, collection: str, with_payload=True, limit=1000):
|
||||
next_offset = None
|
||||
while True:
|
||||
pts, next_offset = client.scroll(collection_name=collection, with_payload=with_payload, with_vectors=False, limit=limit, offset=next_offset)
|
||||
for p in pts:
|
||||
yield p
|
||||
if next_offset is None:
|
||||
break
|
||||
|
||||
def collect_qdrant_stats(prefix: str, limit: int=1000) -> Dict:
|
||||
client = qdrant_client_from_env()
|
||||
cols = {
|
||||
"notes": f"{prefix}_notes",
|
||||
"chunks": f"{prefix}_chunks",
|
||||
"edges": f"{prefix}_edges",
|
||||
}
|
||||
counts = {}
|
||||
for k, c in cols.items():
|
||||
n = 0
|
||||
for _ in scroll_all(client, c, with_payload=(k!="chunks"), limit=limit):
|
||||
n += 1
|
||||
counts[k] = n
|
||||
|
||||
# Edge-Kinds & unresolved zählen
|
||||
kinds = Counter()
|
||||
unresolved = Counter()
|
||||
per_note_refs = defaultdict(int)
|
||||
for p in scroll_all(client, cols["edges"], with_payload=True, limit=limit):
|
||||
pl = p.payload or {}
|
||||
k = pl.get("kind")
|
||||
if k: kinds[k] += 1
|
||||
if pl.get("status") == "unresolved":
|
||||
unresolved[k] += 1
|
||||
# für per-Note-Vergleich: references (Volltext) zählen
|
||||
if k == "references":
|
||||
src = pl.get("source_id")
|
||||
if src:
|
||||
per_note_refs[src] += 1
|
||||
|
||||
return {"collections": cols, "counts": counts, "kinds": kinds, "unresolved": unresolved, "per_note_refs": dict(per_note_refs)}
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--vault", required=True, help="Pfad zum Vault (z. B. ./vault)")
|
||||
ap.add_argument("--prefix", default="mindnet", help="Qdrant Collection-Prefix")
|
||||
ap.add_argument("--limit", type=int, default=1000, help="Scroll-Limit je Seite")
|
||||
args = ap.parse_args()
|
||||
|
||||
notes, wikilink_total = collect_vault_stats(args.vault)
|
||||
q = collect_qdrant_stats(args.prefix, args.limit)
|
||||
|
||||
notes_by_id = {n["note_id"]: n for n in notes}
|
||||
|
||||
# Abgleich pro Note: erwartete Wikilinks (Vault) vs. tatsächliche references (Qdrant)
|
||||
deltas = []
|
||||
for nid, n in notes_by_id.items():
|
||||
expected = n["wikilink_count"]
|
||||
actual = q["per_note_refs"].get(nid, 0)
|
||||
if expected != actual:
|
||||
deltas.append({
|
||||
"note_id": nid,
|
||||
"title": n["title"],
|
||||
"path": n["path"],
|
||||
"wikilinks_in_vault": expected,
|
||||
"references_in_qdrant": actual,
|
||||
"delta": actual - expected
|
||||
})
|
||||
|
||||
out = {
|
||||
"vault": {
|
||||
"notes_with_required_frontmatter": len(notes),
|
||||
"wikilink_occurrences_total": wikilink_total
|
||||
},
|
||||
"qdrant": {
|
||||
"collections": q["collections"],
|
||||
"counts": q["counts"],
|
||||
"edge_kinds": q["kinds"],
|
||||
"unresolved_by_kind": q["unresolved"]
|
||||
},
|
||||
"mismatch_notes": deltas[:50], # nur erste 50 ausgeben
|
||||
"mismatch_total": len(deltas)
|
||||
}
|
||||
print(json.dumps(out, ensure_ascii=False, indent=2))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
scripts/debug_note_payload.py
|
||||
Zeigt, welche app.core.note_payload geladen wird, ruft make_note_payload auf
|
||||
und druckt Typ/Preview der Rückgabe.
|
||||
|
||||
Aufruf:
|
||||
python3 -m scripts.debug_note_payload --file ./test_vault/40_concepts/concept-alpha.md --vault-root ./test_vault
|
||||
"""
|
||||
import argparse, json, os, pprint
|
||||
from app.core import note_payload as np
|
||||
from app.core.parser import read_markdown
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--file", required=True)
|
||||
ap.add_argument("--vault-root", default=None)
|
||||
ap.add_argument("--hash-mode", default=None)
|
||||
ap.add_argument("--hash-normalize", default=None)
|
||||
ap.add_argument("--hash-source", default=None)
|
||||
args = ap.parse_args()
|
||||
|
||||
print("module_path:", getattr(np, "__file__", "<unknown>"))
|
||||
parsed = read_markdown(args.file)
|
||||
res = np.make_note_payload(parsed, vault_root=args.vault_root,
|
||||
hash_mode=args.hash_mode,
|
||||
hash_normalize=args.hash_normalize,
|
||||
hash_source=args.hash_source,
|
||||
file_path=args.file)
|
||||
print("return_type:", type(res).__name__)
|
||||
if isinstance(res, dict):
|
||||
print("keys:", list(res.keys()))
|
||||
print(json.dumps(res, ensure_ascii=False, indent=2))
|
||||
else:
|
||||
preview = repr(res)
|
||||
if len(preview) > 600: preview = preview[:600] + "…"
|
||||
print("preview:", preview)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
scripts/debug_qdrant_state.py
|
||||
Zeigt Prefix, Collections und einfache Counts (notes/chunks/edges) + sample note_ids.
|
||||
|
||||
Aufruf:
|
||||
export COLLECTION_PREFIX="mindnet"
|
||||
python3 -m scripts.debug_qdrant_state
|
||||
# oder:
|
||||
python3 -m scripts.debug_qdrant_state --prefix mindnet
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse, os, json
|
||||
from app.core.qdrant import QdrantConfig, get_client
|
||||
|
||||
def count_points(client, collection: str) -> int:
|
||||
try:
|
||||
res = client.count(collection, exact=True)
|
||||
return int(getattr(res, "count", 0))
|
||||
except Exception:
|
||||
pts, _ = client.scroll(collection, limit=1)
|
||||
return 1 if pts else 0
|
||||
|
||||
def sample_ids(client, collection: str, id_key: str, limit: int = 5):
|
||||
pts, _ = client.scroll(collection, with_payload=True, with_vectors=False, limit=limit)
|
||||
out = []
|
||||
for p in pts or []:
|
||||
pl = p.payload or {}
|
||||
if id_key in pl:
|
||||
out.append(pl[id_key])
|
||||
return out
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", default=os.environ.get("COLLECTION_PREFIX", "mindnet"))
|
||||
args = ap.parse_args()
|
||||
|
||||
cfg = QdrantConfig.from_env()
|
||||
cfg.prefix = args.prefix
|
||||
client = get_client(cfg)
|
||||
|
||||
notes = f"{cfg.prefix}_notes"
|
||||
chunks = f"{cfg.prefix}_chunks"
|
||||
edges = f"{cfg.prefix}_edges"
|
||||
|
||||
print(json.dumps({
|
||||
"prefix": cfg.prefix,
|
||||
"collections": {"notes": notes, "chunks": chunks, "edges": edges},
|
||||
"counts": {
|
||||
"notes": count_points(client, notes),
|
||||
"chunks": count_points(client, chunks),
|
||||
"edges": count_points(client, edges),
|
||||
},
|
||||
"samples": {
|
||||
"notes.note_id": sample_ids(client, notes, "note_id"),
|
||||
"chunks.note_id": sample_ids(client, chunks, "note_id"),
|
||||
"edges.note_id": sample_ids(client, edges, "note_id"),
|
||||
}
|
||||
}, ensure_ascii=False, indent=2))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,227 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Script: scripts/export_markdown.py — Qdrant → Markdown (Vault)
|
||||
Version: 1.4.1
|
||||
Datum: 2025-09-10
|
||||
|
||||
Funktion
|
||||
--------
|
||||
Exportiert Notes (Frontmatter + Body) aus Qdrant in einen Zielordner. Der Body wird
|
||||
bevorzugt aus dem Feld `fulltext` rekonstruiert; falls leer/nicht vorhanden, aus Chunks
|
||||
(Sortierung: seq → chunk_index → Nummer in chunk_id). Pfade werden **relativ** geschrieben.
|
||||
|
||||
Optionen
|
||||
--------
|
||||
--out PATH Zielordner (erforderlich)
|
||||
--prefix TEXT Collection-Prefix (CLI überschreibt ENV COLLECTION_PREFIX)
|
||||
--note-id ID Nur eine Note exportieren
|
||||
--overwrite Existierende Dateien überschreiben
|
||||
--include-edges MODE none|yaml|footer (Default: none)
|
||||
--flatten-paths Alle Dateien flach schreiben; Originalpfad in FM: orig_path
|
||||
|
||||
ENV
|
||||
---
|
||||
COLLECTION_PREFIX, QDRANT_URL | QDRANT_HOST/QDRANT_PORT | QDRANT_API_KEY
|
||||
|
||||
Beispiele
|
||||
---------
|
||||
export COLLECTION_PREFIX="mindnet"
|
||||
python3 -m scripts.export_markdown --out ./_exportVault
|
||||
|
||||
# Nur eine Note, Edges als YAML-Feld 'references'
|
||||
python3 -m scripts.export_markdown --out ./_exportVault --note-id concept-alpha --include-edges yaml
|
||||
|
||||
# Flach schreiben mit Überschreiben
|
||||
python3 -m scripts.export_markdown --out ./_exportVault --flatten-paths --overwrite
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import json
|
||||
from typing import Dict, List, Optional, Tuple, Any
|
||||
|
||||
import yaml
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
from app.core.qdrant import QdrantConfig, get_client
|
||||
from app.core.qdrant import ensure_collections # safety
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
def collections(prefix: str) -> Tuple[str, str, str]:
|
||||
return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges"
|
||||
|
||||
def _norm_rel_path(path: str) -> str:
|
||||
p = (path or "").replace("\\", "/").lstrip("/")
|
||||
return p if p else ""
|
||||
|
||||
def _ensure_dir(path: str) -> None:
|
||||
d = os.path.dirname(path)
|
||||
if d and not os.path.exists(d):
|
||||
os.makedirs(d, exist_ok=True)
|
||||
|
||||
def _yaml_dump(data: Dict[str, Any]) -> str:
|
||||
return yaml.safe_dump(data, allow_unicode=True, sort_keys=False).strip()
|
||||
|
||||
def _frontmatter_block(fm: Dict[str, Any]) -> str:
|
||||
y = _yaml_dump(fm)
|
||||
return f"---\n{y}\n---\n"
|
||||
|
||||
def _scroll_all(client, collection: str, flt: Optional[rest.Filter] = None) -> List[Any]:
|
||||
out = []
|
||||
nextp = None
|
||||
while True:
|
||||
pts, nextp = client.scroll(
|
||||
collection_name=collection,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=256,
|
||||
scroll_filter=flt,
|
||||
offset=nextp,
|
||||
)
|
||||
if not pts:
|
||||
break
|
||||
out.extend(pts)
|
||||
if nextp is None:
|
||||
break
|
||||
return out
|
||||
|
||||
def _reconstruct_body_from_chunks(chunks: List[Any]) -> str:
|
||||
def seq_key(pl: Dict[str, Any]) -> Tuple[int, int, int]:
|
||||
s = pl.get("seq")
|
||||
ci = pl.get("chunk_index")
|
||||
cid = pl.get("chunk_id") or ""
|
||||
n = 0
|
||||
if isinstance(cid, str) and "#" in cid:
|
||||
try:
|
||||
n = int(cid.rsplit("#", 1)[-1])
|
||||
except Exception:
|
||||
n = 0
|
||||
return (int(s) if isinstance(s, int) else 0,
|
||||
int(ci) if isinstance(ci, int) else 0,
|
||||
n)
|
||||
chunks_sorted = sorted(chunks, key=lambda p: seq_key(p.payload or {}))
|
||||
texts: List[str] = []
|
||||
for p in chunks_sorted:
|
||||
pl = p.payload or {}
|
||||
t = pl.get("text") or pl.get("content") or pl.get("raw") or ""
|
||||
if isinstance(t, str) and t:
|
||||
texts.append(t)
|
||||
return "\n".join(texts).strip()
|
||||
|
||||
def _collect_forward_refs_from_edges(edges: List[Any]) -> List[str]:
|
||||
refs = []
|
||||
for p in edges:
|
||||
pl = p.payload or {}
|
||||
if pl.get("kind") == "references" and isinstance(pl.get("target_id"), str):
|
||||
refs.append(pl["target_id"])
|
||||
# de-dupe, preserve order
|
||||
seen = set()
|
||||
out = []
|
||||
for r in refs:
|
||||
if r not in seen:
|
||||
seen.add(r)
|
||||
out.append(r)
|
||||
return out
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Main
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
def main() -> None:
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--out", required=True, help="Zielordner für exportierte Markdown-Dateien")
|
||||
ap.add_argument("--prefix", help="Collection-Prefix (überschreibt ENV COLLECTION_PREFIX)")
|
||||
ap.add_argument("--note-id", help="Nur eine bestimmte Note-ID exportieren")
|
||||
ap.add_argument("--overwrite", action="store_true", help="Existierende Dateien überschreiben")
|
||||
ap.add_argument("--include-edges", choices=["none", "yaml", "footer"], default="none",
|
||||
help="Forward-Links mit exportieren (aus Edges oder Note-Payload)")
|
||||
ap.add_argument("--flatten-paths", action="store_true", help="Alle Dateien flach schreiben (orig_path in Frontmatter)")
|
||||
args = ap.parse_args()
|
||||
|
||||
cfg = QdrantConfig.from_env()
|
||||
if args.prefix:
|
||||
cfg.prefix = args.prefix.strip()
|
||||
client = get_client(cfg)
|
||||
ensure_collections(client, cfg.prefix, cfg.dim)
|
||||
|
||||
out_root = os.path.abspath(args.out)
|
||||
os.makedirs(out_root, exist_ok=True)
|
||||
|
||||
notes_col, chunks_col, edges_col = collections(cfg.prefix)
|
||||
|
||||
# Filter nach note-id (optional)
|
||||
flt = None
|
||||
if args.note_id:
|
||||
flt = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=args.note_id))])
|
||||
|
||||
notes = _scroll_all(client, notes_col, flt)
|
||||
total = 0
|
||||
for n in notes:
|
||||
pl = n.payload or {}
|
||||
nid = pl.get("note_id")
|
||||
rel_path = _norm_rel_path(pl.get("path") or "")
|
||||
if args.flatten_paths or not rel_path:
|
||||
fname = f"{(nid or 'note')}.md"
|
||||
out_path = os.path.join(out_root, fname)
|
||||
else:
|
||||
out_path = os.path.join(out_root, rel_path)
|
||||
out_path = out_path.replace("\\", "/")
|
||||
_ensure_dir(out_path)
|
||||
|
||||
# Frontmatter aufbauen (nur sinnvolle Felder)
|
||||
fm_fields = ["id","title","type","status","created","updated","tags","area","project","source","lang","slug","aliases"]
|
||||
fm: Dict[str, Any] = {}
|
||||
fm["id"] = nid
|
||||
for k in fm_fields:
|
||||
if k == "id":
|
||||
continue
|
||||
if k in pl and pl[k] is not None:
|
||||
fm[k] = pl[k]
|
||||
if args.flatten_paths and rel_path:
|
||||
fm["orig_path"] = rel_path
|
||||
|
||||
# Body ermitteln (fulltext oder Chunks)
|
||||
body = (pl.get("fulltext") or "").strip()
|
||||
if not body:
|
||||
flt_chunks = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=nid))])
|
||||
chunks = _scroll_all(client, chunks_col, flt_chunks)
|
||||
body = _reconstruct_body_from_chunks(chunks)
|
||||
|
||||
# Edges (optional)
|
||||
refs: List[str] = []
|
||||
if args.include_edges != "none":
|
||||
# aus Note-Payload, falls vorhanden
|
||||
if isinstance(pl.get("references"), list) and pl["references"]:
|
||||
refs = [r for r in pl["references"] if isinstance(r, str)]
|
||||
else:
|
||||
flt_edges = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=nid))])
|
||||
edges = _scroll_all(client, edges_col, flt_edges)
|
||||
refs = _collect_forward_refs_from_edges(edges)
|
||||
if args.include_edges == "yaml" and refs:
|
||||
fm["references"] = refs
|
||||
|
||||
# Datei schreiben
|
||||
if (not args.overwrite) and os.path.exists(out_path):
|
||||
print(json.dumps({"note_id": nid, "path": out_path, "decision": "skip-exists"}))
|
||||
continue
|
||||
|
||||
content = _frontmatter_block(fm) + (body + "\n" if body else "")
|
||||
if args.include_edges == "footer" and refs:
|
||||
content += "\n---\nLinks:\n" + "\n".join(f"- [[{r}]]" for r in refs) + "\n"
|
||||
|
||||
with open(out_path, "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
|
||||
print(json.dumps({"note_id": nid, "path": out_path, "decision": "write"}))
|
||||
total += 1
|
||||
|
||||
print(f"Done. Exported notes: {total}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,242 @@
|
||||
#!/usr/bin/env python3
|
||||
# scripts/gc_qdrant_after_vault_scan.py
|
||||
# Version: 1.0.0 (2025-09-05)
|
||||
#
|
||||
# Zweck
|
||||
# -----
|
||||
# Garbage-Collector für Qdrant: löscht Einträge (Edges, Chunks, Notes), deren Note-ID
|
||||
# nicht mehr im Obsidian-Vault vorhanden ist. So bleiben Vektorindex/Graph mit dem Vault konsistent.
|
||||
#
|
||||
# Aufrufparameter
|
||||
# ---------------
|
||||
# --vault PATH Pfad zum Obsidian-Vault (z. B. ./vault) [erforderlich]
|
||||
# --mode {edges,content,all}
|
||||
# edges -> nur Kanten mit source_id/target_id ∉ Vault-Notes löschen
|
||||
# content -> Chunks & Notes löschen, deren note_id ∉ Vault-Notes (keine Edges)
|
||||
# all -> zuerst edges, dann content
|
||||
# --prefix PREFIX Collection-Präfix (Default: aus ENV COLLECTION_PREFIX oder "mindnet")
|
||||
# --apply Ohne diesen Schalter: Dry-Run (nur Vorschau). Mit Schalter: ausführen.
|
||||
# --yes Sicherheitsabfrage überspringen (non-interaktiv)
|
||||
# --batch-size N Größe für In-Filter (Default: 1000)
|
||||
#
|
||||
# Hinweise
|
||||
# --------
|
||||
# - Benötigt funktionierendes Python-venv mit allen Abhängigkeiten von mindnet (qdrant-client usw.).
|
||||
# - Läuft gegen die drei Collections {prefix}_notes, {prefix}_chunks, {prefix}_edges (keine anderen Projekte).
|
||||
# - Nutzt OR-Filter (Filter.should) korrekt, keine minimum_should (Pydantic v2 lässt die Option nicht zu).
|
||||
#
|
||||
# Änderungen ggü. vorher
|
||||
# ----------------------
|
||||
# - Neu: eigenes GC-Tool; berührt ausschließlich das übergebene Projekt-Präfix.
|
||||
# - Sichere Dry-Run-Vorschau mit Zählung pro Collection; interaktive Bestätigung.
|
||||
# - Löscht Edges mittels Filter auf (source_id ∈ MISSING) ODER (target_id ∈ MISSING).
|
||||
# - Löscht Chunks/Notes mittels Filter auf note_id ∈ MISSING.
|
||||
#
|
||||
# Beispiele
|
||||
# ---------
|
||||
# DRY RUN: python3 -m scripts.gc_qdrant_after_vault_scan --vault ./vault --mode all
|
||||
# APPLY: python3 -m scripts.gc_qdrant_after_vault_scan --vault ./vault --mode all --apply
|
||||
# CI-Modus: python3 -m scripts.gc_qdrant_after_vault_scan --vault ./vault --mode edges --apply --yes
|
||||
#
|
||||
# Kompatibilität / Kontext
|
||||
# ------------------------
|
||||
# - Frontmatter-Validierung & Parsing wie im Projekt (parser.read_markdown, validate_required_frontmatter). :contentReference[oaicite:0]{index=0}
|
||||
# - Note-Payload-Schema (u. a. note_id, hash_fulltext) wie spezifiziert. :contentReference[oaicite:1]{index=1}
|
||||
# - Collection-Namen & Anlage-Logik über app.core.qdrant (notes/chunks = dim, edges = 1D). :contentReference[oaicite:2]{index=2}
|
||||
# - Edges nutzen Felder source_id/target_id; Chunks/Notes tragen note_id in payload. :contentReference[oaicite:3]{index=3} :contentReference[oaicite:4]{index=4}
|
||||
#
|
||||
from __future__ import annotations
|
||||
import argparse, os, glob, json, sys
|
||||
from typing import Iterable, Set, Tuple, List
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from qdrant_client import QdrantClient
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
from app.core.parser import read_markdown, normalize_frontmatter, validate_required_frontmatter # :contentReference[oaicite:5]{index=5}
|
||||
from app.core.qdrant import QdrantConfig, get_client, collection_names # :contentReference[oaicite:6]{index=6}
|
||||
|
||||
def iter_note_ids_from_vault(vault_root: str) -> Set[str]:
|
||||
"""Liest alle Markdown-Dateien im Vault und sammelt valide Frontmatter-IDs."""
|
||||
paths = [p for p in glob.glob(os.path.join(vault_root, "**", "*.md"), recursive=True)]
|
||||
out: Set[str] = set()
|
||||
for p in paths:
|
||||
try:
|
||||
parsed = read_markdown(p)
|
||||
fm = normalize_frontmatter(parsed.frontmatter)
|
||||
validate_required_frontmatter(fm)
|
||||
nid = fm.get("id") or fm.get("note_id")
|
||||
if nid:
|
||||
out.add(nid)
|
||||
except Exception:
|
||||
# ungültige oder Template-Dateien ohne Pflichtfelder ignorieren
|
||||
continue
|
||||
return out
|
||||
|
||||
def scroll_payload_values(client: QdrantClient, collection: str, field: str, limit: int = 2000) -> Set[str]:
|
||||
"""Scrollt eine Collection und sammelt alle Payload-Werte eines Feldes (falls vorhanden)."""
|
||||
out: Set[str] = set()
|
||||
offset = None
|
||||
while True:
|
||||
res = client.scroll(
|
||||
collection_name=collection,
|
||||
scroll_filter=None,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=limit,
|
||||
offset=offset
|
||||
)
|
||||
# qdrant-client (neuere Versionen) geben (points, next_offset)
|
||||
if isinstance(res, tuple) and len(res) == 2:
|
||||
points, offset = res
|
||||
else:
|
||||
# Fallback, falls sich API signifikant ändert
|
||||
points, offset = res[0], res[1] if len(res) > 1 else None
|
||||
|
||||
for pt in points or []:
|
||||
pl = getattr(pt, "payload", None) or {}
|
||||
v = pl.get(field)
|
||||
if isinstance(v, str):
|
||||
out.add(v)
|
||||
if not offset:
|
||||
break
|
||||
return out
|
||||
|
||||
def chunked(iterable: Iterable[str], n: int) -> Iterable[List[str]]:
|
||||
buf: List[str] = []
|
||||
for x in iterable:
|
||||
buf.append(x)
|
||||
if len(buf) >= n:
|
||||
yield buf
|
||||
buf = []
|
||||
if buf:
|
||||
yield buf
|
||||
|
||||
def count_matches(client: QdrantClient, collection: str, filter_: rest.Filter) -> int:
|
||||
"""Grober Zähler über scroll (Qdrant Count-API ist optional je Version)."""
|
||||
total = 0
|
||||
offset = None
|
||||
while True:
|
||||
points, offset = client.scroll(
|
||||
collection_name=collection,
|
||||
scroll_filter=filter_,
|
||||
with_payload=False,
|
||||
with_vectors=False,
|
||||
limit=2000,
|
||||
offset=offset
|
||||
)
|
||||
total += len(points or [])
|
||||
if not offset:
|
||||
break
|
||||
return total
|
||||
|
||||
def build_filters_for_missing(prefix: str, missing_note_ids: Set[str]) -> Tuple[rest.Filter, rest.Filter, rest.Filter]:
|
||||
"""
|
||||
Erzeugt je Collection passende Filter:
|
||||
- Notes/Chunks: note_id ∈ missing
|
||||
- Edges: (source_id ∈ missing) ODER (target_id ∈ missing)
|
||||
"""
|
||||
notes_col, chunks_col, edges_col = collection_names(prefix) # :contentReference[oaicite:7]{index=7}
|
||||
# MatchAny statt MatchValue für große Mengen
|
||||
any_missing = rest.MatchAny(any=list(missing_note_ids))
|
||||
|
||||
f_notes = rest.Filter(must=[rest.FieldCondition(key="note_id", match=any_missing)])
|
||||
f_chunks = rest.Filter(must=[rest.FieldCondition(key="note_id", match=any_missing)])
|
||||
f_edges = rest.Filter(should=[
|
||||
rest.FieldCondition(key="source_id", match=any_missing),
|
||||
rest.FieldCondition(key="target_id", match=any_missing),
|
||||
])
|
||||
return f_notes, f_chunks, f_edges
|
||||
|
||||
def preview(client: QdrantClient, prefix: str, missing: Set[str]) -> dict:
|
||||
"""Erstellt eine Dry-Run-Vorschau (Anzahl Treffer pro Collection)."""
|
||||
notes_col, chunks_col, edges_col = collection_names(prefix)
|
||||
f_notes, f_chunks, f_edges = build_filters_for_missing(prefix, missing)
|
||||
|
||||
return {
|
||||
"prefix": prefix,
|
||||
"collections": {"notes": notes_col, "chunks": chunks_col, "edges": edges_col},
|
||||
"missing_note_ids_count": len(missing),
|
||||
"to_delete_counts": {
|
||||
"edges": count_matches(client, edges_col, f_edges),
|
||||
"chunks": count_matches(client, chunks_col, f_chunks),
|
||||
"notes": count_matches(client, notes_col, f_notes),
|
||||
}
|
||||
}
|
||||
|
||||
def delete_with_filter(client: QdrantClient, collection: str, filter_: rest.Filter) -> int:
|
||||
"""Löscht alle Punkte, die den Filter matchen. Gibt grobe Trefferzahl zurück."""
|
||||
# erst zählen (für Feedback)
|
||||
to_del = count_matches(client, collection, filter_)
|
||||
if to_del == 0:
|
||||
return 0
|
||||
client.delete(
|
||||
collection_name=collection,
|
||||
points_selector=filter_,
|
||||
wait=True
|
||||
)
|
||||
return to_del
|
||||
|
||||
def main():
|
||||
load_dotenv()
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--vault", required=True, help="Pfad zum Obsidian-Vault (z. B. ./vault)")
|
||||
ap.add_argument("--mode", choices=["edges", "content", "all"], default="all",
|
||||
help="Löschmodus (edges=nur Kanten, content=Chunks+Notes, all=beides)")
|
||||
ap.add_argument("--prefix", help="Collection-Präfix (Default aus ENV COLLECTION_PREFIX)")
|
||||
ap.add_argument("--apply", action="store_true", help="Ohne diesen Schalter: Dry-Run")
|
||||
ap.add_argument("--yes", action="store_true", help="Rückfrage unterdrücken")
|
||||
ap.add_argument("--batch-size", type=int, default=1000, help="Batch-Größe für MatchAny")
|
||||
args = ap.parse_args()
|
||||
|
||||
cfg = QdrantConfig.from_env()
|
||||
if args.prefix:
|
||||
cfg.prefix = args.prefix
|
||||
client = get_client(cfg)
|
||||
|
||||
notes_col, chunks_col, edges_col = collection_names(cfg.prefix)
|
||||
|
||||
# 1) Vault lesen → Menge gültiger Note-IDs
|
||||
vault_root = os.path.abspath(args.vault)
|
||||
vault_ids = iter_note_ids_from_vault(vault_root)
|
||||
|
||||
# 2) Qdrant vorhandene Note-IDs einsammeln
|
||||
existing_note_ids = scroll_payload_values(client, notes_col, "note_id")
|
||||
|
||||
# 3) Differenz ermitteln
|
||||
missing = existing_note_ids - vault_ids
|
||||
|
||||
# 4) Vorschau
|
||||
summary = preview(client, cfg.prefix, missing)
|
||||
print(json.dumps({"mode": args.mode, "apply": args.apply, "summary": summary}, ensure_ascii=False, indent=2))
|
||||
|
||||
if not missing:
|
||||
# nichts zu tun
|
||||
return
|
||||
|
||||
if not args.apply:
|
||||
# Dry-Run Ende
|
||||
return
|
||||
|
||||
if not args.yes:
|
||||
resp = input("Fortfahren und die oben gezeigten Objekte löschen? (yes/no): ").strip().lower()
|
||||
if resp not in ("y", "yes"):
|
||||
print("Abgebrochen.")
|
||||
return
|
||||
|
||||
# 5) Löschen je Modus
|
||||
f_notes, f_chunks, f_edges = build_filters_for_missing(cfg.prefix, missing)
|
||||
report = {"deleted": {"edges": 0, "chunks": 0, "notes": 0}}
|
||||
|
||||
try:
|
||||
if args.mode in ("edges", "all"):
|
||||
report["deleted"]["edges"] = delete_with_filter(client, edges_col, f_edges)
|
||||
if args.mode in ("content", "all"):
|
||||
# Reihenfolge: erst chunks, dann notes
|
||||
report["deleted"]["chunks"] = delete_with_filter(client, chunks_col, f_chunks)
|
||||
report["deleted"]["notes"] = delete_with_filter(client, notes_col, f_notes)
|
||||
finally:
|
||||
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+505
-146
@@ -1,209 +1,568 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Name: scripts/import_markdown.py
|
||||
Version: v2.1.1 (2025-09-05)
|
||||
Kurzbeschreibung:
|
||||
Importiert Obsidian-Markdown-Notes in Qdrant (Notes/Chunks/Edges).
|
||||
Leitet Wikilink-Edges (references/backlink/references_at) direkt beim Import
|
||||
aus Volltext + echten Chunk-Texten ab. Keine Abhängigkeit zu edges.py (Legacy).
|
||||
scripts/import_markdown.py
|
||||
|
||||
Aufruf (aus Projekt-Root, im venv):
|
||||
python3 -m scripts.import_markdown --vault ./vault [--apply] [--note-id NOTE_ID] [--embed-note]
|
||||
Zweck
|
||||
-----
|
||||
- Liest Markdown-Notizen aus einem Vault ein
|
||||
- Erzeugt Note-Payload, Chunk-Payloads (+ optionale Embeddings) und Edges
|
||||
- Schreibt alles idempotent in Qdrant (Notes, Chunks, Edges)
|
||||
- Integriert eine optionale Type-Registry (types.yaml), um z. B. chunk_profile
|
||||
und retriever_weight pro Notiz-Typ zu steuern.
|
||||
|
||||
Parameter:
|
||||
--vault Pfad zum Vault (z. B. ./vault)
|
||||
--apply Führt Upserts in Qdrant aus (ohne Flag = Dry-Run mit JSON-Summaries)
|
||||
--note-id Bearbeite nur eine konkrete Note-ID
|
||||
--embed-note Optional: Note-Vektor (Volltext) zusätzlich einbetten
|
||||
Wesentliche Fixes ggü. vorherigen fehlerhaften Ständen
|
||||
------------------------------------------------------
|
||||
- `embed_texts` wird optional importiert und defensiv geprüft (kein NameError mehr)
|
||||
- `effective_chunk_profile` / `effective_retriever_weight` und Registry-Helfer
|
||||
sind VOR `main()` definiert (kein NameError mehr)
|
||||
- `retriever_weight` wird in Note- und Chunk-Payload zuverlässig gesetzt
|
||||
- Robuste Kantenbildung; Fehler bei Edges blockieren Notes/Chunks nicht
|
||||
- Korrekte Verwendung von `scroll_filter` beim Qdrant-Client
|
||||
- `--purge-before-upsert` entfernt alte Chunks/Edges einer Note vor dem Upsert
|
||||
|
||||
Umgebungsvariablen (optional):
|
||||
QDRANT_URL, QDRANT_API_KEY, COLLECTION_PREFIX, VECTOR_DIM (Default 384)
|
||||
Qdrant / ENV
|
||||
------------
|
||||
- QDRANT_URL | QDRANT_HOST/QDRANT_PORT | QDRANT_API_KEY
|
||||
- COLLECTION_PREFIX (Default: mindnet), via --prefix überschreibbar
|
||||
- VECTOR_DIM (Default: 384)
|
||||
- MINDNET_NOTE_SCOPE_REFS: true|false (Default: false)
|
||||
- MINDNET_TYPES_FILE: Pfad zu types.yaml (optional; Default: ./types.yaml)
|
||||
|
||||
Exitcodes:
|
||||
0 = OK, 2 = keine Markdown-Dateien gefunden
|
||||
Beispiele
|
||||
---------
|
||||
# Standard (Body, parsed, canonical)
|
||||
python3 -m scripts.import_markdown --vault ./vault
|
||||
|
||||
Wichtige Hinweise:
|
||||
- Verwendet ausschließlich app.core.derive_edges für Wikilink-Kanten.
|
||||
- Chunk-Texte werden an derive_wikilink_edges übergeben; nur so entstehen references_at.
|
||||
- Edges-IDs sind deterministisch (UUIDv5 in qdrant_points), idempotent.
|
||||
- Edges-Collection bleibt 1D-Dummy-Vektor (DOT), reine Payload-Nutzung.
|
||||
# Erstimport nach truncate (Create-Fall)
|
||||
python3 -m scripts.import_markdown --vault ./vault --apply --purge-before-upsert
|
||||
|
||||
Changelog:
|
||||
v2.1.1: Entfernt Abhängigkeit auf app.core.edges; direkte Nutzung von derive_wikilink_edges;
|
||||
sichert Übergabe der Chunk-Texte → references_at werden erzeugt.
|
||||
v2.1.0: Note-Index über gesamten Vault; erste Fassung mit direkter Edge-Ableitung.
|
||||
v2.0.x: Import Notes/Chunks/Embeddings, Edges via Backfill (separat).
|
||||
# Nur eine Datei (Diagnose)
|
||||
python3 -m scripts.import_markdown --vault ./vault --only-path ./vault/30_projects/project-demo.md --apply
|
||||
|
||||
# Sync-Deletes (Dry-Run → Apply)
|
||||
python3 -m scripts.import_markdown --vault ./vault --sync-deletes
|
||||
python3 -m scripts.import_markdown --vault ./vault --sync-deletes --apply
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from typing import List, Dict
|
||||
from typing import Dict, List, Optional, Tuple, Any, Set
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
# Core-Module (gemäß Projektstruktur)
|
||||
# --- Projekt-Imports ---
|
||||
from app.core.parser import (
|
||||
read_markdown,
|
||||
normalize_frontmatter,
|
||||
validate_required_frontmatter,
|
||||
)
|
||||
from app.core.note_payload import make_note_payload
|
||||
from app.core.validate_note import validate_note_payload
|
||||
from app.core.chunker import assemble_chunks
|
||||
from app.core.chunk_payload import make_chunk_payloads
|
||||
from app.core.embed import embed_texts, embed_one
|
||||
from app.core.qdrant import QdrantConfig, ensure_collections, get_client
|
||||
try:
|
||||
from app.core.derive_edges import build_edges_for_note
|
||||
except Exception: # pragma: no cover
|
||||
from app.core.edges import build_edges_for_note # type: ignore
|
||||
from app.core.qdrant import (
|
||||
QdrantConfig,
|
||||
get_client,
|
||||
ensure_collections,
|
||||
ensure_payload_indexes,
|
||||
)
|
||||
from app.core.qdrant_points import (
|
||||
points_for_chunks,
|
||||
points_for_note,
|
||||
points_for_edges,
|
||||
upsert_batch,
|
||||
)
|
||||
# Nur Wikilink-Ableitung (keine Kollision mit edges.py):
|
||||
from app.core.derive_edges import build_note_index, derive_wikilink_edges
|
||||
|
||||
# embeddings sind optional (z. B. im reinen Payload-Backfill)
|
||||
try:
|
||||
from app.core.embed import embed_texts # optional
|
||||
except Exception: # pragma: no cover
|
||||
embed_texts = None
|
||||
|
||||
|
||||
def iter_md(root: str, exclude=("/.obsidian/", "/_backup_frontmatter/", "/_imported/")) -> List[str]:
|
||||
files = [p for p in glob.glob(os.path.join(root, "**", "*.md"), recursive=True)]
|
||||
# ---------------------------------------------------------------------
|
||||
# Type-Registry (types.yaml) – Helper (robust, optional)
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
def _env(name: str, default: Optional[str] = None) -> Optional[str]:
|
||||
v = os.getenv(name)
|
||||
return v if v is not None else default
|
||||
|
||||
def _load_json_or_yaml(path: str) -> dict:
|
||||
import io
|
||||
data: dict = {}
|
||||
if not path or not os.path.exists(path):
|
||||
return data
|
||||
try:
|
||||
import yaml # type: ignore
|
||||
with io.open(path, "r", encoding="utf-8") as f:
|
||||
data = yaml.safe_load(f) or {}
|
||||
if not isinstance(data, dict):
|
||||
return {}
|
||||
return data
|
||||
except Exception:
|
||||
# YAML evtl. nicht installiert – versuche JSON
|
||||
try:
|
||||
with io.open(path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
if not isinstance(data, dict):
|
||||
return {}
|
||||
return data
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
def load_type_registry() -> dict:
|
||||
# Reihenfolge: ENV > ./types.yaml (im aktuellen Arbeitsverzeichnis)
|
||||
p = _env("MINDNET_TYPES_FILE", None)
|
||||
if p and os.path.exists(p):
|
||||
return _load_json_or_yaml(p)
|
||||
fallback = os.path.abspath("./types.yaml")
|
||||
return _load_json_or_yaml(fallback)
|
||||
|
||||
def get_type_config(note_type: Optional[str], reg: dict) -> dict:
|
||||
if not reg or not isinstance(reg, dict):
|
||||
return {}
|
||||
types = reg.get("types", {}) if isinstance(reg.get("types"), dict) else {}
|
||||
if note_type and isinstance(note_type, str) and note_type in types:
|
||||
return types[note_type] or {}
|
||||
# Fallback: concept
|
||||
return types.get("concept", {}) or {}
|
||||
|
||||
def resolve_note_type(requested: Optional[str], reg: dict) -> str:
|
||||
if requested and isinstance(requested, str):
|
||||
return requested
|
||||
# Fallback wenn nichts gesetzt ist
|
||||
types = reg.get("types", {}) if isinstance(reg.get("types"), dict) else {}
|
||||
return "concept" if "concept" in types else (requested or "concept")
|
||||
|
||||
def effective_chunk_profile(note_type: str, reg: dict) -> Optional[str]:
|
||||
cfg = get_type_config(note_type, reg)
|
||||
prof = cfg.get("chunk_profile")
|
||||
if isinstance(prof, str) and prof in {"short", "medium", "long"}:
|
||||
return prof
|
||||
return None
|
||||
|
||||
def effective_retriever_weight(note_type: str, reg: dict) -> Optional[float]:
|
||||
cfg = get_type_config(note_type, reg)
|
||||
w = cfg.get("retriever_weight")
|
||||
try:
|
||||
return float(w) if w is not None else None
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Sonstige Helper
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
def iter_md(root: str) -> List[str]:
|
||||
out: List[str] = []
|
||||
for p in files:
|
||||
pn = p.replace("\\", "/")
|
||||
if any(ex in pn for ex in exclude):
|
||||
continue
|
||||
out.append(p)
|
||||
for dirpath, _, filenames in os.walk(root):
|
||||
for fn in filenames:
|
||||
if not fn.lower().endswith(".md"):
|
||||
continue
|
||||
p = os.path.join(dirpath, fn)
|
||||
pn = p.replace("\\", "/")
|
||||
if any(ex in pn for ex in ["/.obsidian/", "/_backup_frontmatter/", "/_imported/"]):
|
||||
continue
|
||||
out.append(p)
|
||||
return sorted(out)
|
||||
|
||||
def collections(prefix: str) -> Tuple[str, str, str]:
|
||||
return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges"
|
||||
|
||||
def fetch_existing_note_payload(client, prefix: str, note_id: str) -> Optional[Dict]:
|
||||
notes_col, _, _ = collections(prefix)
|
||||
f = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=note_id))])
|
||||
points, _ = client.scroll(
|
||||
collection_name=notes_col,
|
||||
scroll_filter=f, # wichtig: scroll_filter (nicht: filter)
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=1,
|
||||
)
|
||||
if not points:
|
||||
return None
|
||||
return points[0].payload or {}
|
||||
|
||||
def list_qdrant_note_ids(client, prefix: str) -> Set[str]:
|
||||
notes_col, _, _ = collections(prefix)
|
||||
out: Set[str] = set()
|
||||
next_page = None
|
||||
while True:
|
||||
pts, next_page = client.scroll(
|
||||
collection_name=notes_col,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=256,
|
||||
offset=next_page,
|
||||
)
|
||||
if not pts:
|
||||
break
|
||||
for p in pts:
|
||||
pl = p.payload or {}
|
||||
nid = pl.get("note_id")
|
||||
if isinstance(nid, str):
|
||||
out.add(nid)
|
||||
if next_page is None:
|
||||
break
|
||||
return out
|
||||
|
||||
def purge_note_artifacts(client, prefix: str, note_id: str) -> None:
|
||||
_, chunks_col, edges_col = collections(prefix)
|
||||
filt = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=note_id))])
|
||||
for col in (chunks_col, edges_col):
|
||||
try:
|
||||
client.delete(
|
||||
collection_name=col,
|
||||
points_selector=rest.FilterSelector(filter=filt),
|
||||
wait=True
|
||||
)
|
||||
except Exception as e:
|
||||
print(json.dumps({"note_id": note_id, "warn": f"delete in {col} via filter failed: {e}"}))
|
||||
|
||||
def minimal_note_index_payload(abs_path: str, vault_root: str) -> Dict:
|
||||
"""Nur Felder, die der Resolver braucht (id/title/path)."""
|
||||
parsed = read_markdown(abs_path)
|
||||
fm = normalize_frontmatter(parsed.frontmatter)
|
||||
validate_required_frontmatter(fm)
|
||||
relpath = os.path.relpath(abs_path, vault_root).replace("\\", "/")
|
||||
return {
|
||||
"note_id": fm.get("id") or fm.get("note_id"),
|
||||
"title": fm.get("title"),
|
||||
"path": relpath,
|
||||
}
|
||||
def delete_note_everywhere(client, prefix: str, note_id: str) -> None:
|
||||
notes_col, chunks_col, edges_col = collections(prefix)
|
||||
filt = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=note_id))])
|
||||
for col in (edges_col, chunks_col, notes_col):
|
||||
try:
|
||||
client.delete(
|
||||
collection_name=col,
|
||||
points_selector=rest.FilterSelector(filter=filt),
|
||||
wait=True
|
||||
)
|
||||
except Exception as e:
|
||||
print(json.dumps({"note_id": note_id, "warn": f"delete in {col} failed: {e}"}))
|
||||
|
||||
|
||||
def main():
|
||||
# --- Neu: Existenz-Checks für Artefakte (fehlertoleranter Rebuild) ---
|
||||
|
||||
def _has_any_point(client, collection: str, note_id: str) -> bool:
|
||||
"""Prüft, ob es mind. einen Punkt mit note_id in der Collection gibt."""
|
||||
filt = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=note_id))])
|
||||
pts, _ = client.scroll(
|
||||
collection_name=collection,
|
||||
scroll_filter=filt,
|
||||
with_payload=False,
|
||||
with_vectors=False,
|
||||
limit=1,
|
||||
)
|
||||
return bool(pts)
|
||||
|
||||
def artifacts_missing(client, prefix: str, note_id: str) -> Tuple[bool, bool]:
|
||||
"""Gibt (chunks_missing, edges_missing) zurück."""
|
||||
_, chunks_col, edges_col = collections(prefix)
|
||||
chunks_missing = not _has_any_point(client, chunks_col, note_id)
|
||||
edges_missing = not _has_any_point(client, edges_col, note_id)
|
||||
return chunks_missing, edges_missing
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Main
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
def _resolve_mode(m: Optional[str]) -> str:
|
||||
m = (m or "body").strip().lower()
|
||||
return m if m in {"body", "frontmatter", "full"} else "body"
|
||||
|
||||
def main() -> None:
|
||||
load_dotenv()
|
||||
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--vault", required=True, help="Obsidian Vault Pfad (z.B. mindnet/vault)")
|
||||
ap.add_argument("--apply", action="store_true", help="Schreibt in Qdrant (sonst Dry-Run)")
|
||||
ap.add_argument("--note-id", help="Nur eine Note-ID verarbeiten")
|
||||
ap.add_argument("--embed-note", action="store_true", help="Auch Note-Volltext einbetten (optional)")
|
||||
ap = argparse.ArgumentParser(
|
||||
prog="scripts.import_markdown",
|
||||
description="Importiert Markdown-Notizen in Qdrant (Notes/Chunks/Edges)."
|
||||
)
|
||||
ap.add_argument("--vault", required=True, help="Pfad zum Vault (Ordner mit .md-Dateien)")
|
||||
ap.add_argument("--only-path", help="Nur diese Datei verarbeiten (absolut oder relativ)")
|
||||
ap.add_argument("--apply", action="store_true", help="Schreibt nach Qdrant (sonst Dry-Run)")
|
||||
ap.add_argument("--purge-before-upsert", action="store_true", help="Alte Chunks/Edges der Note vorher löschen")
|
||||
ap.add_argument("--force-replace", action="store_true", help="Note/Chunks/Edges unabhängig von Hash neu schreiben")
|
||||
ap.add_argument("--note-id", help="Nur Notes mit dieser ID verarbeiten (Filter)")
|
||||
ap.add_argument("--note-scope-refs", action="store_true", help="Note-scope References/Backlinks erzeugen")
|
||||
ap.add_argument("--hash-mode", help="body|frontmatter|full (Default body)")
|
||||
ap.add_argument("--hash-source", help="parsed|raw (Default parsed)")
|
||||
ap.add_argument("--hash-normalize", help="canonical|none (Default canonical)")
|
||||
ap.add_argument("--compare-text", action="store_true", help="Parsed fulltext zusätzlich direkt vergleichen")
|
||||
ap.add_argument("--baseline-modes", action="store_true", help="Fehlende Hash-Varianten still nachtragen (Notes)")
|
||||
ap.add_argument("--sync-deletes", action="store_true", help="Qdrant->Vault Lösch-Sync (Dry-Run; mit --apply ausführen)")
|
||||
ap.add_argument("--prefix", help="Collection-Prefix (überschreibt ENV COLLECTION_PREFIX)")
|
||||
args = ap.parse_args()
|
||||
|
||||
# Qdrant-Konfiguration (+ Collections sicherstellen)
|
||||
cfg = QdrantConfig(
|
||||
url=os.getenv("QDRANT_URL", "http://127.0.0.1:6333"),
|
||||
api_key=os.getenv("QDRANT_API_KEY") or None,
|
||||
prefix=os.getenv("COLLECTION_PREFIX", "mindnet"),
|
||||
dim=int(os.getenv("VECTOR_DIM", "384")),
|
||||
)
|
||||
mode = _resolve_mode(args.hash_mode) # body|frontmatter|full
|
||||
src = _env("MINDNET_HASH_SOURCE", args.hash_source or "parsed") # parsed|raw
|
||||
norm = _env("MINDNET_HASH_NORMALIZE", args.hash_normalize or "canonical") # canonical|none
|
||||
note_scope_refs_env = (_env("MINDNET_NOTE_SCOPE_REFS", "false") == "true")
|
||||
note_scope_refs = args.note_scope_refs or note_scope_refs_env
|
||||
compare_text = args.compare_text or (_env("MINDNET_COMPARE_TEXT", "false") == "true")
|
||||
|
||||
# Qdrant
|
||||
cfg = QdrantConfig.from_env()
|
||||
if args.prefix:
|
||||
cfg.prefix = args.prefix.strip()
|
||||
client = get_client(cfg)
|
||||
ensure_collections(client, cfg.prefix, cfg.dim)
|
||||
ensure_payload_indexes(client, cfg.prefix)
|
||||
|
||||
# Type-Registry laden (optional)
|
||||
reg = load_type_registry()
|
||||
|
||||
root = os.path.abspath(args.vault)
|
||||
files = iter_md(root)
|
||||
|
||||
# Dateiliste
|
||||
if args.only_path:
|
||||
only = os.path.abspath(args.only_path)
|
||||
files = [only]
|
||||
else:
|
||||
files = iter_md(root)
|
||||
if not files:
|
||||
print("Keine Markdown-Dateien gefunden.", file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
||||
# (1) Vorab-Lauf: Note-Index (robuste Auflösung via ID/Titel-Slug/File-Slug)
|
||||
index_payloads: List[Dict] = []
|
||||
for path in files:
|
||||
try:
|
||||
pl = minimal_note_index_payload(path, root)
|
||||
if not pl.get("note_id"):
|
||||
# Optional: Sync-Deletes vorab
|
||||
if args.sync_deletes:
|
||||
vault_note_ids: Set[str] = set()
|
||||
for path in files:
|
||||
try:
|
||||
parsed = read_markdown(path)
|
||||
if not parsed:
|
||||
continue
|
||||
fm = normalize_frontmatter(parsed.frontmatter)
|
||||
nid = fm.get("id")
|
||||
if isinstance(nid, str):
|
||||
vault_note_ids.add(nid)
|
||||
except Exception:
|
||||
continue
|
||||
if args.note_id and pl["note_id"] != args.note_id:
|
||||
continue
|
||||
index_payloads.append(pl)
|
||||
except Exception:
|
||||
# Einzeldefekte nicht fatal
|
||||
continue
|
||||
|
||||
note_index = build_note_index(index_payloads)
|
||||
|
||||
# (2) Hauptlauf: Import + direkte Wikilink-Edge-Ableitung
|
||||
total_notes = 0
|
||||
for path in files:
|
||||
parsed = read_markdown(path)
|
||||
fm = normalize_frontmatter(parsed.frontmatter)
|
||||
try:
|
||||
validate_required_frontmatter(fm)
|
||||
except Exception:
|
||||
continue
|
||||
if args.note_id and fm.get("id") != args.note_id:
|
||||
continue
|
||||
|
||||
total_notes += 1
|
||||
|
||||
# Note-Payload (vollständig für notes-Collection)
|
||||
note_pl = make_note_payload(parsed, vault_root=root)
|
||||
validate_note_payload(note_pl)
|
||||
|
||||
# Chunks aus Body gemäß Chunking-Strategie
|
||||
chunks = assemble_chunks(fm["id"], parsed.body, fm.get("type", "concept"))
|
||||
chunk_pls = make_chunk_payloads(fm, note_pl["path"], chunks)
|
||||
|
||||
# Embeddings (Chunks)
|
||||
texts = [ch.text for ch in chunks]
|
||||
vectors = embed_texts(texts)
|
||||
|
||||
# Optional: Note-Vektor (z. B. für Doc-Suche/Clustering)
|
||||
note_vec = None
|
||||
if args.embed_note:
|
||||
note_vec = embed_one(parsed.body)
|
||||
|
||||
# Edges direkt aus realen Chunks + Note-Index
|
||||
# ACHTUNG: derive_wikilink_edges erwartet Chunks mit Text → wir bauen eine
|
||||
# minimalistische Liste {"chunk_id","text"} in gleicher Reihenfolge.
|
||||
note_pl_for_edges = {
|
||||
"note_id": fm["id"],
|
||||
"title": fm.get("title"),
|
||||
"path": note_pl["path"],
|
||||
"fulltext": parsed.body,
|
||||
}
|
||||
chunks_for_links = []
|
||||
for i, pl in enumerate(chunk_pls):
|
||||
cid = pl.get("chunk_id") or pl.get("id")
|
||||
txt = chunks[i].text if i < len(chunks) else ""
|
||||
chunks_for_links.append({"chunk_id": cid, "text": txt})
|
||||
|
||||
edges = derive_wikilink_edges(note_pl_for_edges, chunks_for_links, note_index)
|
||||
|
||||
# Dry-Run-Summary
|
||||
qdrant_note_ids = list_qdrant_note_ids(client, cfg.prefix)
|
||||
to_delete = sorted(qdrant_note_ids - vault_note_ids)
|
||||
print(json.dumps({
|
||||
"note_id": fm["id"],
|
||||
"title": fm["title"],
|
||||
"action": "sync-deletes",
|
||||
"prefix": cfg.prefix,
|
||||
"qdrant_total": len(qdrant_note_ids),
|
||||
"vault_total": len(vault_note_ids),
|
||||
"to_delete_count": len(to_delete),
|
||||
"to_delete": to_delete[:50] + (["…"] if len(to_delete) > 50 else [])
|
||||
}, ensure_ascii=False))
|
||||
if args.apply and to_delete:
|
||||
for nid in to_delete:
|
||||
print(json.dumps({"action": "delete", "note_id": nid, "decision": "apply"}))
|
||||
delete_note_everywhere(client, cfg.prefix, nid)
|
||||
|
||||
key_current = f"{mode}:{src}:{norm}"
|
||||
|
||||
processed = 0
|
||||
for path in files:
|
||||
try:
|
||||
parsed = read_markdown(path)
|
||||
if not parsed:
|
||||
continue
|
||||
except Exception as e:
|
||||
print(json.dumps({"path": path, "error": f"read_markdown failed: {type(e).__name__}: {e}"}))
|
||||
continue
|
||||
|
||||
# --- Frontmatter prüfen ---
|
||||
try:
|
||||
fm = normalize_frontmatter(parsed.frontmatter)
|
||||
validate_required_frontmatter(fm)
|
||||
except Exception as e:
|
||||
print(json.dumps({"path": path, "error": f"Frontmatter invalid: {type(e).__name__}: {e}"}))
|
||||
continue
|
||||
|
||||
if args.note_id and not args.only_path and fm.get("id") != args.note_id:
|
||||
continue
|
||||
|
||||
processed += 1
|
||||
|
||||
# --- Type-Registry anwenden (chunk_profile / retriever_weight) ---
|
||||
try:
|
||||
note_type = resolve_note_type(fm.get("type"), reg)
|
||||
except Exception:
|
||||
note_type = (fm.get("type") or "concept")
|
||||
fm["type"] = note_type or fm.get("type") or "concept"
|
||||
|
||||
prof = effective_chunk_profile(note_type, reg)
|
||||
if prof:
|
||||
fm["chunk_profile"] = prof
|
||||
|
||||
weight = effective_retriever_weight(note_type, reg)
|
||||
if weight is not None:
|
||||
try:
|
||||
fm["retriever_weight"] = float(weight)
|
||||
except Exception:
|
||||
pass # falls FM string-inkonsistent ist
|
||||
|
||||
# --- Payload aufbauen (inkl. Hashes) ---
|
||||
try:
|
||||
note_pl = make_note_payload(
|
||||
parsed,
|
||||
vault_root=root,
|
||||
hash_mode=mode,
|
||||
hash_normalize=norm,
|
||||
hash_source=src,
|
||||
file_path=path,
|
||||
)
|
||||
except Exception as e:
|
||||
print(json.dumps({"path": path, "error": f"make_note_payload failed: {type(e).__name__}: {e}"}))
|
||||
continue
|
||||
|
||||
if not note_pl.get("fulltext"):
|
||||
note_pl["fulltext"] = getattr(parsed, "body", "") or ""
|
||||
|
||||
# retriever_weight sicher in Note-Payload spiegeln (für spätere Filter)
|
||||
if "retriever_weight" not in note_pl and fm.get("retriever_weight") is not None:
|
||||
try:
|
||||
note_pl["retriever_weight"] = float(fm.get("retriever_weight"))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
note_id = note_pl.get("note_id") or fm.get("id")
|
||||
if not note_id:
|
||||
print(json.dumps({"path": path, "error": "Missing note_id after payload build"}))
|
||||
continue
|
||||
|
||||
# --- bestehenden Payload laden (zum Diff) ---
|
||||
old_payload = None if args.force_replace else fetch_existing_note_payload(client, cfg.prefix, note_id)
|
||||
has_old = old_payload is not None
|
||||
|
||||
old_hashes = (old_payload or {}).get("hashes") or {}
|
||||
old_hash_exact = old_hashes.get(key_current)
|
||||
new_hash_exact = (note_pl.get("hashes") or {}).get(key_current)
|
||||
needs_baseline = (old_hash_exact is None)
|
||||
|
||||
hash_changed = (old_hash_exact is not None and new_hash_exact is not None and old_hash_exact != new_hash_exact)
|
||||
|
||||
text_changed = False
|
||||
if compare_text:
|
||||
old_text = (old_payload or {}).get("fulltext") or ""
|
||||
new_text = note_pl.get("fulltext") or ""
|
||||
text_changed = (old_text != new_text)
|
||||
|
||||
changed = args.force_replace or (not has_old) or hash_changed or text_changed
|
||||
do_baseline_only = (args.baseline_modes and has_old and needs_baseline and not changed)
|
||||
|
||||
# --- Chunks + Embeddings vorbereiten ---
|
||||
try:
|
||||
body_text = getattr(parsed, "body", "") or ""
|
||||
chunks = assemble_chunks(fm["id"], body_text, fm.get("type", "concept"))
|
||||
chunk_pls: List[Dict[str, Any]] = make_chunk_payloads(fm, note_pl["path"], chunks, note_text=body_text)
|
||||
except Exception as e:
|
||||
print(json.dumps({"path": path, "note_id": note_id, "error": f"chunk build failed: {type(e).__name__}: {e}"}))
|
||||
continue
|
||||
|
||||
# retriever_weight auf Chunk-Payload spiegeln
|
||||
if fm.get("retriever_weight") is not None:
|
||||
try:
|
||||
rw = float(fm.get("retriever_weight"))
|
||||
for pl in chunk_pls:
|
||||
# Feld nur setzen, wenn noch nicht vorhanden
|
||||
if "retriever_weight" not in pl:
|
||||
pl["retriever_weight"] = rw
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Embeddings (fallback: Nullvektoren)
|
||||
vecs: List[List[float]] = [[0.0] * int(cfg.dim) for _ in chunk_pls]
|
||||
if embed_texts and chunk_pls:
|
||||
try:
|
||||
texts_for_embed = [(pl.get("window") or pl.get("text") or "") for pl in chunk_pls]
|
||||
vecs = embed_texts(texts_for_embed)
|
||||
except Exception as e:
|
||||
print(json.dumps({"path": path, "note_id": note_id, "warn": f"embed_texts failed, using zeros: {e}"}))
|
||||
|
||||
# --- Fehlende Artefakte in Qdrant ermitteln ---
|
||||
chunks_missing, edges_missing = artifacts_missing(client, cfg.prefix, note_id)
|
||||
|
||||
# --- Edges (robust) ---
|
||||
edges: List[Dict[str, Any]] = []
|
||||
edges_failed = False
|
||||
should_build_edges = (changed and (not do_baseline_only)) or edges_missing
|
||||
if should_build_edges:
|
||||
try:
|
||||
note_refs = note_pl.get("references") or []
|
||||
edges = build_edges_for_note(
|
||||
note_id,
|
||||
chunk_pls,
|
||||
note_level_references=note_refs,
|
||||
include_note_scope_refs=note_scope_refs,
|
||||
)
|
||||
except Exception as e:
|
||||
edges_failed = True
|
||||
edges = []
|
||||
print(json.dumps({"path": path, "note_id": note_id, "warn": f"build_edges_for_note failed, skipping edges: {type(e).__name__}: {e}"}))
|
||||
|
||||
# --- Summary (stdout) ---
|
||||
summary = {
|
||||
"note_id": note_id,
|
||||
"title": fm.get("title"),
|
||||
"chunks": len(chunk_pls),
|
||||
"edges": len(edges),
|
||||
"edges_failed": edges_failed,
|
||||
"changed": changed,
|
||||
"chunks_missing": chunks_missing,
|
||||
"edges_missing": edges_missing,
|
||||
"needs_baseline_for_mode": needs_baseline,
|
||||
"decision": ("baseline-only" if args.apply and do_baseline_only else
|
||||
"apply" if args.apply and (changed or chunks_missing or edges_missing) else
|
||||
"apply-skip-unchanged" if args.apply and not (changed or chunks_missing or edges_missing) else
|
||||
"dry-run"),
|
||||
"path": note_pl["path"],
|
||||
}, ensure_ascii=False))
|
||||
"hash_mode": mode,
|
||||
"hash_normalize": norm,
|
||||
"hash_source": src,
|
||||
"prefix": cfg.prefix,
|
||||
}
|
||||
print(json.dumps(summary, ensure_ascii=False))
|
||||
|
||||
if args.apply:
|
||||
# Notes upsert (idempotent; UUIDv5)
|
||||
notes_col, note_pts = points_for_note(cfg.prefix, note_pl, note_vec, cfg.dim)
|
||||
upsert_batch(client, notes_col, note_pts)
|
||||
# --- Writes ---
|
||||
if not args.apply:
|
||||
continue
|
||||
|
||||
# Chunks upsert (idempotent)
|
||||
chunks_col, chunk_pts = points_for_chunks(cfg.prefix, chunk_pls, vectors)
|
||||
upsert_batch(client, chunks_col, chunk_pts)
|
||||
if do_baseline_only:
|
||||
merged_hashes = {}
|
||||
merged_hashes.update(old_hashes)
|
||||
merged_hashes.update(note_pl.get("hashes") or {})
|
||||
if old_payload:
|
||||
note_pl["hash_fulltext"] = old_payload.get("hash_fulltext", note_pl.get("hash_fulltext"))
|
||||
note_pl["hash_signature"] = old_payload.get("hash_signature", note_pl.get("hash_signature"))
|
||||
note_pl["hashes"] = merged_hashes
|
||||
notes_name, note_pts = points_for_note(cfg.prefix, note_pl, None, cfg.dim)
|
||||
upsert_batch(client, notes_name, note_pts)
|
||||
continue
|
||||
|
||||
# Edges upsert (idempotent; deterministisches edge_id)
|
||||
edges_col, edge_pts = points_for_edges(cfg.prefix, edges)
|
||||
upsert_batch(client, edges_col, edge_pts)
|
||||
# Wenn nichts geändert und keine Artefakte fehlen → nichts zu tun
|
||||
if not changed and not (chunks_missing or edges_missing):
|
||||
continue
|
||||
|
||||
print(f"Done. Processed notes: {total_notes}")
|
||||
# Purge nur bei echten Änderungen (unverändert + fehlende Artefakte ≠ Purge)
|
||||
if args.purge_before_upsert and has_old and changed:
|
||||
try:
|
||||
purge_note_artifacts(client, cfg.prefix, note_id)
|
||||
except Exception as e:
|
||||
print(json.dumps({"path": path, "note_id": note_id, "warn": f"purge failed: {e}"}))
|
||||
|
||||
# Note nur bei Änderungen neu schreiben
|
||||
if changed:
|
||||
notes_name, note_pts = points_for_note(cfg.prefix, note_pl, None, cfg.dim)
|
||||
upsert_batch(client, notes_name, note_pts)
|
||||
|
||||
# Chunks schreiben, wenn geändert ODER vorher fehlend
|
||||
if chunk_pls and (changed or chunks_missing):
|
||||
chunks_name, chunk_pts = points_for_chunks(cfg.prefix, chunk_pls, vecs)
|
||||
upsert_batch(client, chunks_name, chunk_pts)
|
||||
|
||||
# Edges schreiben, wenn vorhanden und (geändert ODER vorher fehlend)
|
||||
if edges and (changed or edges_missing):
|
||||
edges_name, edge_pts = points_for_edges(cfg.prefix, edges)
|
||||
upsert_batch(client, edges_name, edge_pts)
|
||||
|
||||
print(f"Done. Processed notes: {processed}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
make_test_vault.py — erzeugt einen minimalen, nachvollziehbaren Test-Vault
|
||||
|
||||
Version: 1.2 (2025-09-09)
|
||||
Änderungen ggü. 1.1:
|
||||
- Fügt **externe Links** (http/mailto) in `exp-two.md` hinzu, damit der Chunk-Payload-Exporter
|
||||
`external_links` realistisch testen kann.
|
||||
- Kleine Textanpassungen zur stabilen Chunk-Bildung (Absatzstruktur).
|
||||
|
||||
Zweck
|
||||
- Kleiner Obsidian-ähnlicher Vault zum Durchspielen des Importers (Chunks/Edges).
|
||||
- Szenarien: leere Links, spätere Anlage fehlender Noten, Chunk-Neuaufteilung, externe Links.
|
||||
|
||||
Struktur (Default: ./test_vault)
|
||||
- 40_concepts/concept-alpha.md
|
||||
- 20_experiences/exp-one.md (verlinkt auf [[concept-alpha]] und [[missing-note]])
|
||||
- 20_experiences/exp-two.md (verlinkt auf [[concept-alpha]] + externe Links)
|
||||
- 30_projects/project-demo.md (verlinkt auf [[concept-alpha]] und [[exp-one]])
|
||||
|
||||
Voraussetzungen
|
||||
- Keine. Rein Dateigenerierung.
|
||||
|
||||
Aufruf
|
||||
python3 -m scripts.make_test_vault [--out ./test_vault] [--force] [--with-missing]
|
||||
|
||||
Parameter
|
||||
--out Zielverzeichnis (Standard: ./test_vault)
|
||||
--force Bestehenden Ordner löschen und neu anlegen.
|
||||
--with-missing Auch die 'missing-note' direkt anlegen (Standard: erst im 2. Lauf)
|
||||
|
||||
Hinweise für Tests
|
||||
1) Erster Import (dry-run oder --apply): Es gibt einen „leeren“ Link [[missing-note]].
|
||||
2) Lege danach eine Datei für „missing-note“ an (mit gleicher ID im YAML) und importiere erneut:
|
||||
-> Erwartung: Edges für ehemals leeren Link werden korrekt nachgezogen (references + backlink).
|
||||
3) Ändere den Body von exp-one.md so, dass andere Chunk-Grenzen entstehen und importiere erneut:
|
||||
-> Erwartung: Chunks/Edges/Note werden für betroffene Noten aktualisiert.
|
||||
4) Prüfe externe Links (verify_chunk_texts.py betrifft nur Text; externe Links siehst du in chunk_payloads).
|
||||
|
||||
Kompatibel mit:
|
||||
- note.schema.json: 'created'/'updated' müssen strings sein. (Wichtig!)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
from datetime import datetime, timezone
|
||||
|
||||
def iso_now() -> str:
|
||||
# ISO 8601 mit Offset; als String zurückgeben
|
||||
return datetime.now(timezone.utc).astimezone().isoformat(timespec="seconds")
|
||||
|
||||
def q(s: str) -> str:
|
||||
# Sicheres Quoten für YAML-Frontmatter
|
||||
return f"\"{s}\""
|
||||
|
||||
TEMPLATE_CONCEPT = """---
|
||||
title: "Concept Alpha"
|
||||
id: "concept-alpha"
|
||||
type: "concept"
|
||||
status: "active"
|
||||
created: {created}
|
||||
updated: {updated}
|
||||
tags: ["area/mindnet","type/concept","topic/test"]
|
||||
---
|
||||
|
||||
## Beschreibung
|
||||
Dies ist ein einfaches Konzept für Testzwecke. Es wird von anderen Notizen referenziert.
|
||||
|
||||
## Mögliche Verbindungen
|
||||
- [[exp-one]]
|
||||
- [[project-demo]]
|
||||
"""
|
||||
|
||||
TEMPLATE_EXP_ONE = """---
|
||||
title: "Experience One"
|
||||
id: "exp-one"
|
||||
type: "experience"
|
||||
status: "active"
|
||||
created: {created}
|
||||
updated: {updated}
|
||||
tags: ["area/mindnet","type/experience","topic/test"]
|
||||
---
|
||||
|
||||
## Kontext
|
||||
Diese Notiz verlinkt auf ein existierendes Konzept und auf eine noch **fehlende** Note.
|
||||
|
||||
## Beobachtung
|
||||
- Bezug zu [[concept-alpha]]
|
||||
- Offener Verweis auf [[missing-note]]
|
||||
|
||||
## Interpretation
|
||||
Wenn später eine Datei für 'missing-note' angelegt wird, sollte der Importer die Kanten nachziehen.
|
||||
|
||||
## Mögliche Verbindungen
|
||||
- [[concept-alpha]]
|
||||
- [[missing-note]]
|
||||
"""
|
||||
|
||||
TEMPLATE_EXP_TWO = """---
|
||||
title: "Experience Two"
|
||||
id: "exp-two"
|
||||
type: "experience"
|
||||
status: "active"
|
||||
created: {created}
|
||||
updated: {updated}
|
||||
tags: ["area/mindnet","type/experience","topic/test"]
|
||||
---
|
||||
|
||||
## Kontext
|
||||
Zweite Experience, die auf dasselbe Konzept verweist, ergänzt um **externe Links**.
|
||||
|
||||
## Beobachtung
|
||||
Verweis auf [[concept-alpha]]. Zusätzliche Ressourcen:
|
||||
- Link: [Beispielseite](https://example.com "Referenz")
|
||||
- Kontakt: [E-Mail](mailto:info@example.com)
|
||||
|
||||
## Mögliche Verbindungen
|
||||
- [[concept-alpha]]
|
||||
"""
|
||||
|
||||
TEMPLATE_PROJECT = """---
|
||||
title: "Project Demo"
|
||||
id: "project-demo"
|
||||
type: "project"
|
||||
status: "active"
|
||||
created: {created}
|
||||
updated: {updated}
|
||||
tags: ["area/mindnet","type/project","topic/test"]
|
||||
---
|
||||
|
||||
## Scope
|
||||
Ein kleines Demo-Projekt, das andere Notizen referenziert.
|
||||
|
||||
## Arbeitspakete
|
||||
- AP-1: Zusammenhang erklären (siehe [[concept-alpha]])
|
||||
- AP-2: Ereignis berücksichtigen (siehe [[exp-one]])
|
||||
|
||||
## Mögliche Verbindungen
|
||||
- [[concept-alpha]]
|
||||
- [[exp-one]]
|
||||
"""
|
||||
|
||||
TEMPLATE_MISSING = """---
|
||||
title: "Missing Note (jetzt angelegt)"
|
||||
id: "missing-note"
|
||||
type: "concept"
|
||||
status: "active"
|
||||
created: {created}
|
||||
updated: {updated}
|
||||
tags: ["area/mindnet","type/concept","topic/test"]
|
||||
---
|
||||
|
||||
## Kontext
|
||||
Diese Notiz wurde **nachträglich** erstellt, um einen zuvor offenen Link zu schließen.
|
||||
|
||||
## Mögliche Verbindungen
|
||||
- [[exp-one]]
|
||||
"""
|
||||
|
||||
def write_file(path: str, content: str) -> None:
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
|
||||
def build_vault(base: str, include_missing_note: bool) -> None:
|
||||
created = q(iso_now())
|
||||
updated = q(iso_now())
|
||||
|
||||
# 40_concepts
|
||||
write_file(
|
||||
os.path.join(base, "40_concepts", "concept-alpha.md"),
|
||||
TEMPLATE_CONCEPT.format(created=created, updated=updated),
|
||||
)
|
||||
|
||||
# 20_experiences
|
||||
write_file(
|
||||
os.path.join(base, "20_experiences", "exp-one.md"),
|
||||
TEMPLATE_EXP_ONE.format(created=created, updated=updated),
|
||||
)
|
||||
write_file(
|
||||
os.path.join(base, "20_experiences", "exp-two.md"),
|
||||
TEMPLATE_EXP_TWO.format(created=created, updated=updated),
|
||||
)
|
||||
|
||||
# 30_projects
|
||||
write_file(
|
||||
os.path.join(base, "30_projects", "project-demo.md"),
|
||||
TEMPLATE_PROJECT.format(created=created, updated=updated),
|
||||
)
|
||||
|
||||
# Optional: zunächst NICHT anlegen (Szenario „leerer Link“),
|
||||
# später für den 2. Testlauf anlegen.
|
||||
if include_missing_note:
|
||||
write_file(
|
||||
os.path.join(base, "40_concepts", "missing-note.md"),
|
||||
TEMPLATE_MISSING.format(created=created, updated=updated),
|
||||
)
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--out", default="./test_vault", help="Zielverzeichnis für den Test-Vault")
|
||||
ap.add_argument("--force", action="store_true", help="Falls vorhanden: Verzeichnis löschen und neu anlegen")
|
||||
ap.add_argument("--with-missing", action="store_true",
|
||||
help="Auch die 'missing-note' direkt anlegen (Standard: erst im 2. Lauf)")
|
||||
args = ap.parse_args()
|
||||
|
||||
base = os.path.abspath(args.out)
|
||||
if os.path.exists(base):
|
||||
if args.force:
|
||||
shutil.rmtree(base)
|
||||
else:
|
||||
print(f"Ziel existiert bereits: {base}\nNutze --force zum Überschreiben.")
|
||||
return
|
||||
|
||||
build_vault(base, include_missing_note=args.with_missing)
|
||||
print(f"Test-Vault erstellt unter: {base}")
|
||||
print("Hinweis:")
|
||||
print(" 1) Zuerst ohne missing-note anlegen (Standard), importieren, Edges prüfen.")
|
||||
print(" 2) Dann erneut ausführen mit --force --with-missing (missing-note wird erzeugt),")
|
||||
print(" und Import wiederholen → Edges/Backlinks sollten nachgezogen werden.")
|
||||
print(" 3) In exp-two.md sind **externe Links** enthalten → prüfe `external_links` in Chunk-Payloads.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
scripts/ollama_tool_runner.py — Minimaler Tool-Caller für Ollama + mindnet
|
||||
|
||||
Zweck:
|
||||
Führt den Tool-Call-Loop für mindnet_query / mindnet_subgraph aus.
|
||||
Nutzt /tools/ollama (Schema) und deine FastAPI (/query, /graph).
|
||||
ENV:
|
||||
OLLAMA=http://127.0.0.1:11434
|
||||
API_BASE=http://127.0.0.1:8000
|
||||
MODEL=llama3.1
|
||||
Nutzung:
|
||||
python3 scripts/ollama_tool_runner.py "Frage an den Agenten"
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
import os, sys, json, requests
|
||||
|
||||
OLLAMA = os.getenv("OLLAMA", "http://127.0.0.1:11434")
|
||||
API_BASE = os.getenv("API_BASE", "http://127.0.0.1:8000")
|
||||
MODEL = os.getenv("MODEL", "llama3.1")
|
||||
|
||||
def load_tools():
|
||||
r = requests.get(f"{API_BASE}/tools/ollama", timeout=30)
|
||||
r.raise_for_status()
|
||||
return r.json()["tools"]
|
||||
|
||||
def call_model(messages, tools):
|
||||
payload = {
|
||||
"model": MODEL,
|
||||
"messages": messages,
|
||||
"tools": tools,
|
||||
"stream": False,
|
||||
"tool_choice": "auto",
|
||||
}
|
||||
r = requests.post(f"{OLLAMA}/api/chat", json=payload, timeout=180)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
def execute_tool(name: str, arguments: dict):
|
||||
if name == "mindnet_query":
|
||||
# mappe expand_depth/edge_types auf /query-Body
|
||||
body = {
|
||||
"mode": "hybrid",
|
||||
"top_k": int(arguments.get("top_k", 10)),
|
||||
"expand": {
|
||||
"depth": int(arguments.get("expand_depth", 1)),
|
||||
"edge_types": arguments.get("edge_types") or ["references","belongs_to","prev","next"],
|
||||
},
|
||||
"filters": arguments.get("filters"),
|
||||
}
|
||||
if "query_vector" in arguments:
|
||||
body["query_vector"] = arguments["query_vector"]
|
||||
if "query" in arguments:
|
||||
body["query"] = arguments["query"]
|
||||
r = requests.post(f"{API_BASE}/query", json=body, timeout=120)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
if name == "mindnet_subgraph":
|
||||
params = {
|
||||
"depth": int(arguments.get("depth", 1)),
|
||||
}
|
||||
edge_types = arguments.get("edge_types")
|
||||
if edge_types:
|
||||
# mehrfacher Query-Param 'edge_types' wird von requests automatisch gebaut
|
||||
params["edge_types"] = edge_types
|
||||
note_id = arguments["note_id"]
|
||||
r = requests.get(f"{API_BASE}/graph/{note_id}", params=params, timeout=60)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
raise ValueError(f"Unbekanntes Tool: {name}")
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python3 scripts/ollama_tool_runner.py \"Deine Frage\"")
|
||||
return 2
|
||||
|
||||
user_prompt = sys.argv[1]
|
||||
tools = load_tools()
|
||||
messages = [{"role": "user", "content": user_prompt}]
|
||||
|
||||
while True:
|
||||
resp = call_model(messages, tools)
|
||||
msg = resp.get("message") or {}
|
||||
tool_calls = msg.get("tool_calls") or []
|
||||
|
||||
if not tool_calls:
|
||||
# finale Antwort
|
||||
print("\n=== Antwort ===\n")
|
||||
print(msg.get("content", "").strip())
|
||||
return 0
|
||||
|
||||
# Führe Toolcalls nacheinander aus
|
||||
for tc in tool_calls:
|
||||
name = tc["function"]["name"]
|
||||
args = tc["function"].get("arguments") or {}
|
||||
if isinstance(args, str):
|
||||
try: args = json.loads(args)
|
||||
except Exception: args = {"raw": args}
|
||||
|
||||
print(f"[tool] {name}({args})")
|
||||
result = execute_tool(name, args)
|
||||
|
||||
# Übergib Toolresultat ans Modell zurück
|
||||
messages.append({"role": "tool", "content": json.dumps(result), "name": name})
|
||||
|
||||
# füttere auch die originale Antwort (falls enthalten) in den Verlauf
|
||||
if msg.get("content"):
|
||||
messages.append({"role": "assistant", "content": msg["content"]})
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,232 @@
|
||||
# scripts/prune_qdrant_vs_vault.py
|
||||
# -----------------------------------------------------------------------------
|
||||
# Name: prune_qdrant_vs_vault.py
|
||||
# Version: 1.0.0 (2025-09-08)
|
||||
# Zweck: Entfernt verwaiste Qdrant-Einträge (notes/chunks/edges), wenn
|
||||
# die zugehörigen Markdown-Dateien im Vault nicht mehr existieren.
|
||||
#
|
||||
# Was es macht:
|
||||
# - Liest alle note_id aus dem Vault (Frontmatter: id / note_id).
|
||||
# - Liest alle note_id aus Qdrant (mindnet_notes).
|
||||
# - Bildet die Differenz (nur in Qdrant vorhandene, im Vault fehlende).
|
||||
# - Löscht für jede verwaiste note_id:
|
||||
# * Notes-Point(s)
|
||||
# * Alle Chunks der Note
|
||||
# * Alle Edges, die auf diese Note referenzieren
|
||||
# (source_id == note_id ODER target_id == note_id ODER
|
||||
# source_note_id == note_id ODER target_note_id == note_id)
|
||||
#
|
||||
# Hinweise:
|
||||
# - Kein globaler Delete. Nur betroffene note_id.
|
||||
# - Dry-Run standardmäßig; tatsächliches Löschen erst mit --apply.
|
||||
# - Interaktive Bestätigung (abschaltbar mit --yes).
|
||||
#
|
||||
# Aufruf:
|
||||
# python3 -m scripts.prune_qdrant_vs_vault --vault ./vault --prefix mindnet
|
||||
# python3 -m scripts.prune_qdrant_vs_vault --vault ./vault --prefix mindnet --apply
|
||||
# python3 -m scripts.prune_qdrant_vs_vault --vault ./vault --prefix mindnet --apply --yes
|
||||
#
|
||||
# Voraussetzungen:
|
||||
# - Ausführung im aktivierten venv empfohlen: source .venv/bin/activate
|
||||
# - Qdrant läuft lokal (oder URL/API-Key in ENV), siehe app/core/qdrant.py
|
||||
#
|
||||
# Änderungen:
|
||||
# - 1.0.0: Erster Release.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Set, Tuple
|
||||
|
||||
from qdrant_client import QdrantClient
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
from app.core.qdrant import QdrantConfig, get_client, collection_names
|
||||
from app.core.parser import parse_markdown_file # nutzt euer bestehendes Parsing/Schema
|
||||
|
||||
|
||||
def read_vault_note_ids(vault_dir: Path) -> Set[str]:
|
||||
note_ids: Set[str] = set()
|
||||
for p in vault_dir.rglob("*.md"):
|
||||
try:
|
||||
parsed = parse_markdown_file(str(p))
|
||||
fm = parsed.frontmatter if hasattr(parsed, "frontmatter") else (parsed.get("frontmatter") or {})
|
||||
nid = fm.get("id") or fm.get("note_id")
|
||||
if nid:
|
||||
note_ids.add(str(nid))
|
||||
except Exception:
|
||||
# still und leise weiter – wir wollen robust sein
|
||||
continue
|
||||
return note_ids
|
||||
|
||||
|
||||
def qdrant_note_ids(client: QdrantClient, notes_col: str) -> Set[str]:
|
||||
ids: Set[str] = set()
|
||||
scroll_filter = None
|
||||
offset = None
|
||||
while True:
|
||||
res = client.scroll(
|
||||
collection_name=notes_col,
|
||||
scroll_filter=scroll_filter,
|
||||
offset=offset,
|
||||
limit=256,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
)
|
||||
points, next_offset = res
|
||||
for pt in points:
|
||||
pl = pt.payload or {}
|
||||
nid = pl.get("note_id")
|
||||
if nid:
|
||||
ids.add(str(nid))
|
||||
if next_offset is None:
|
||||
break
|
||||
offset = next_offset
|
||||
return ids
|
||||
|
||||
|
||||
def delete_by_filter(client: QdrantClient, collection: str, flt: rest.Filter) -> int:
|
||||
# Sammel erst IDs via scroll (robuster Überblick), lösche dann über point_ids (batch)
|
||||
to_delete: List[int] = []
|
||||
offset = None
|
||||
while True:
|
||||
pts, next_offset = client.scroll(
|
||||
collection_name=collection,
|
||||
scroll_filter=flt,
|
||||
offset=offset,
|
||||
limit=256,
|
||||
with_payload=False,
|
||||
with_vectors=False,
|
||||
)
|
||||
for pt in pts:
|
||||
to_delete.append(pt.id)
|
||||
if next_offset is None:
|
||||
break
|
||||
offset = next_offset
|
||||
if not to_delete:
|
||||
return 0
|
||||
client.delete(collection_name=collection, points_selector=rest.PointIdsList(points=to_delete), wait=True)
|
||||
return len(to_delete)
|
||||
|
||||
|
||||
def prune_for_note(
|
||||
client: QdrantClient,
|
||||
cols: Dict[str, str],
|
||||
note_id: str,
|
||||
dry_run: bool = True,
|
||||
) -> Dict[str, int]:
|
||||
stats = {"notes": 0, "chunks": 0, "edges": 0}
|
||||
|
||||
# Notes löschen (Filter auf payload.note_id)
|
||||
f_notes = rest.Filter(
|
||||
must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=note_id))]
|
||||
)
|
||||
|
||||
# Chunks löschen (Filter auf payload.note_id)
|
||||
f_chunks = rest.Filter(
|
||||
must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=note_id))]
|
||||
)
|
||||
|
||||
# Edges löschen: mehrere Teilmengen erfassen
|
||||
edge_filters = [
|
||||
rest.Filter(must=[rest.FieldCondition(key="source_id", match=rest.MatchValue(value=note_id))]),
|
||||
rest.Filter(must=[rest.FieldCondition(key="target_id", match=rest.MatchValue(value=note_id))]),
|
||||
rest.Filter(must=[rest.FieldCondition(key="source_note_id", match=rest.MatchValue(value=note_id))]),
|
||||
rest.Filter(must=[rest.FieldCondition(key="target_note_id", match=rest.MatchValue(value=note_id))]),
|
||||
]
|
||||
|
||||
if dry_run:
|
||||
# Zähle nur, was *wäre* gelöscht worden
|
||||
def count(flt: rest.Filter, col: str) -> int:
|
||||
total = 0
|
||||
offset = None
|
||||
while True:
|
||||
pts, next_offset = client.scroll(
|
||||
collection_name=col,
|
||||
scroll_filter=flt,
|
||||
offset=offset,
|
||||
limit=256,
|
||||
with_payload=False,
|
||||
with_vectors=False,
|
||||
)
|
||||
total += len(pts)
|
||||
if next_offset is None:
|
||||
break
|
||||
offset = next_offset
|
||||
return total
|
||||
|
||||
stats["notes"] = count(f_notes, cols["notes"])
|
||||
stats["chunks"] = count(f_chunks, cols["chunks"])
|
||||
stats["edges"] = sum(count(f, cols["edges"]) for f in edge_filters)
|
||||
return stats
|
||||
|
||||
# tatsächliches Löschen
|
||||
stats["notes"] = delete_by_filter(client, cols["notes"], f_notes)
|
||||
stats["chunks"] = delete_by_filter(client, cols["chunks"], f_chunks)
|
||||
e_deleted = 0
|
||||
for f in edge_filters:
|
||||
e_deleted += delete_by_filter(client, cols["edges"], f)
|
||||
stats["edges"] = e_deleted
|
||||
return stats
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description="Prune Qdrant data for notes missing in the Vault.")
|
||||
ap.add_argument("--vault", required=True, help="Pfad zum Vault-Verzeichnis (Root).")
|
||||
ap.add_argument("--prefix", default="mindnet", help="Collections-Präfix (Default: mindnet).")
|
||||
ap.add_argument("--apply", action="store_true", help="Ohne diesen Schalter wird nur ein Dry-Run gemacht.")
|
||||
ap.add_argument("--yes", action="store_true", help="Ohne Nachfrage ausführen.")
|
||||
args = ap.parse_args()
|
||||
|
||||
vault_root = Path(args.vault).resolve()
|
||||
if not vault_root.exists():
|
||||
print(f"Vault-Verzeichnis nicht gefunden: {vault_root}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
cfg = QdrantConfig()
|
||||
client = get_client(cfg)
|
||||
cols = collection_names(args.prefix)
|
||||
|
||||
vault_ids = read_vault_note_ids(vault_root)
|
||||
qdrant_ids = qdrant_note_ids(client, cols["notes"])
|
||||
orphans = sorted(qdrant_ids - vault_ids)
|
||||
|
||||
preview = {
|
||||
"mode": "APPLY" if args.apply else "DRY-RUN",
|
||||
"prefix": args.prefix,
|
||||
"vault_root": str(vault_root),
|
||||
"collections": cols,
|
||||
"counts": {
|
||||
"vault_note_ids": len(vault_ids),
|
||||
"qdrant_note_ids": len(qdrant_ids),
|
||||
"orphans": len(orphans),
|
||||
},
|
||||
"orphans_sample": orphans[:20],
|
||||
}
|
||||
print(json.dumps(preview, ensure_ascii=False, indent=2))
|
||||
|
||||
if not orphans:
|
||||
print("Keine verwaisten Einträge gefunden. Nichts zu tun.")
|
||||
return
|
||||
|
||||
if not args.yes:
|
||||
resp = input("\nFortfahren mit dem oben angezeigten Modus? (yes/no): ").strip().lower()
|
||||
if resp not in ("y", "yes", "j", "ja"):
|
||||
print("Abgebrochen.")
|
||||
return
|
||||
|
||||
total_stats = {"notes": 0, "chunks": 0, "edges": 0}
|
||||
for nid in orphans:
|
||||
s = prune_for_note(client, cols, nid, dry_run=(not args.apply))
|
||||
total_stats["notes"] += s["notes"]
|
||||
total_stats["chunks"] += s["chunks"]
|
||||
total_stats["edges"] += s["edges"]
|
||||
|
||||
print(json.dumps({"deleted": total_stats}, ensure_ascii=False, indent=2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Script: scripts/report_hashes.py — Übersicht & Lücken bei Mehrfach-Hashes
|
||||
Version: 1.0.0
|
||||
Datum: 2025-09-10
|
||||
|
||||
Funktion
|
||||
--------
|
||||
Listet je Note die vorhandenen Einträge im Feld `hashes` (Signaturen: <mode>:<source>:<normalize>)
|
||||
und meldet fehlende Soll-Keys. Eignet sich als CI-Check.
|
||||
|
||||
Optionen
|
||||
--------
|
||||
--prefix TEXT Collection-Prefix (CLI überschreibt ENV)
|
||||
--require K [K ...] Zusätzliche Soll-Keys (Default: body|frontmatter|full:parsed:canonical)
|
||||
--fail-on-missing Exitcode 2, wenn fehlende Keys gefunden werden
|
||||
|
||||
Beispiele
|
||||
---------
|
||||
python3 -m scripts.report_hashes --prefix mindnet
|
||||
python3 -m scripts.report_hashes --require frontmatter:raw:none --fail-on-missing
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from typing import List, Dict, Any
|
||||
|
||||
from qdrant_client.http import models as rest
|
||||
from app.core.qdrant import QdrantConfig, get_client
|
||||
|
||||
def collections(prefix: str):
|
||||
return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges"
|
||||
|
||||
def _scroll_all(client, collection: str):
|
||||
out = []
|
||||
nextp = None
|
||||
while True:
|
||||
pts, nextp = client.scroll(collection_name=collection, with_payload=True, with_vectors=False, limit=256, offset=nextp)
|
||||
if not pts:
|
||||
break
|
||||
out.extend(pts)
|
||||
if nextp is None:
|
||||
break
|
||||
return out
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", help="Collection-Prefix (überschreibt ENV COLLECTION_PREFIX)")
|
||||
ap.add_argument("--require", nargs="+", help="Zusätzliche Soll-Keys <mode>:<source>:<normalize>")
|
||||
ap.add_argument("--fail-on-missing", action="store_true", help="Exitcode 2 bei fehlenden Keys")
|
||||
args = ap.parse_args()
|
||||
|
||||
cfg = QdrantConfig.from_env()
|
||||
if args.prefix:
|
||||
cfg.prefix = args.prefix.strip()
|
||||
client = get_client(cfg)
|
||||
|
||||
notes_col, _, _ = collections(cfg.prefix)
|
||||
pts = _scroll_all(client, notes_col)
|
||||
|
||||
required = set(args.require or [])
|
||||
required |= {
|
||||
"body:parsed:canonical",
|
||||
"frontmatter:parsed:canonical",
|
||||
"full:parsed:canonical",
|
||||
}
|
||||
|
||||
missing_total = 0
|
||||
for p in pts:
|
||||
pl = p.payload or {}
|
||||
nid = pl.get("note_id")
|
||||
hashes = pl.get("hashes") or {}
|
||||
present = set(hashes.keys())
|
||||
missing = sorted(list(required - present))
|
||||
obj = {
|
||||
"note_id": nid,
|
||||
"present_count": len(present),
|
||||
"missing": missing,
|
||||
}
|
||||
print(json.dumps(obj, ensure_ascii=False))
|
||||
missing_total += len(missing)
|
||||
|
||||
if args.fail_on_missing and missing_total > 0:
|
||||
raise SystemExit(2)
|
||||
|
||||
print(json.dumps({"summary_missing_total": missing_total}))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,243 @@
|
||||
#!/usr/bin/env python3
|
||||
# scripts/resolve_unresolved_references.py
|
||||
"""
|
||||
resolve_unresolved_references.py — Unaufgelöste Wikilinks in Qdrant nachträglich auflösen
|
||||
|
||||
Version: 1.0.0 (2025-09-05)
|
||||
|
||||
Zweck
|
||||
------
|
||||
- Findet Edges in {prefix}_edges mit payload.status=="unresolved" und versucht, den Zielknoten
|
||||
anhand bereits vorhandener Notes in {prefix}_notes aufzulösen.
|
||||
- Aktualisiert die Edges (setzt target_id, entfernt status, setzt resolution), und erzeugt
|
||||
– NUR für Note-Level 'references' – die symmetrische 'backlink'-Kante.
|
||||
|
||||
Warum?
|
||||
------
|
||||
- Beim ersten Import können Links auf (noch) nicht existierende Notizen zeigen.
|
||||
- Sobald die Zielnotiz später existiert, kann dieses Skript die Kanten reparieren.
|
||||
|
||||
Aufruf
|
||||
------
|
||||
# Dry-Run (Standard):
|
||||
python3 -m scripts.resolve_unresolved_references --prefix mindnet
|
||||
|
||||
# Anwenden:
|
||||
python3 -m scripts.resolve_unresolved_references --prefix mindnet --apply
|
||||
|
||||
# Optional: nur X Edges anfassen
|
||||
python3 -m scripts.resolve_unresolved_references --prefix mindnet --apply --limit 500
|
||||
|
||||
Parameter
|
||||
---------
|
||||
--prefix : Collection-Prefix (Default: aus Env COLLECION_PREFIX oder "mindnet")
|
||||
--apply : Änderungen tatsächlich schreiben (ohne --apply = Dry-Run)
|
||||
--limit : Max. Anzahl unaufgelöster Edges, die in diesem Lauf bearbeitet werden (Default: keine Begrenzung)
|
||||
--batch : Upsert-Batchgröße (Default: 512)
|
||||
|
||||
Voraussetzungen / Hinweise
|
||||
--------------------------
|
||||
- Bitte im aktivierten venv laufen lassen (deine Umgebung: `.venv`).
|
||||
- Qdrant-URL/Key/Prefix/Vektor-Dim werden wie üblich aus ENV gelesen (sieh app/core/qdrant.py). # noqa
|
||||
- Nutzt die vorhandenen Utilities:
|
||||
- app/core/qdrant.py (Client/Collections)
|
||||
- app/core/qdrant_points.py (points_for_edges/upsert_batch)
|
||||
- app/core/derive_edges.py (build_note_index/resolve_target)
|
||||
|
||||
Änderungshistorie
|
||||
-----------------
|
||||
1.0.0 Erstveröffentlichung.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from typing import Any, Dict, List, Tuple, Iterable
|
||||
|
||||
from qdrant_client import QdrantClient
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
from app.core.qdrant import QdrantConfig, get_client, ensure_collections, collection_names # :contentReference[oaicite:3]{index=3}
|
||||
from app.core.qdrant_points import points_for_edges, upsert_batch # :contentReference[oaicite:4]{index=4}
|
||||
from app.core.derive_edges import build_note_index, resolve_target # :contentReference[oaicite:5]{index=5}
|
||||
|
||||
|
||||
def _scroll(client: QdrantClient, **kwargs):
|
||||
"""
|
||||
Wrapper um qdrant_client.scroll() für unterschiedliche Client-Versionen:
|
||||
neuere: (points, next_offset)
|
||||
ältere: (points, next_page_offset, _)
|
||||
"""
|
||||
res = client.scroll(**kwargs)
|
||||
if isinstance(res, tuple):
|
||||
if len(res) == 2:
|
||||
points, next_off = res
|
||||
else:
|
||||
# ältere Signatur: (points, next_off, _)
|
||||
points, next_off, _ = res[0], res[1], res[2]
|
||||
else:
|
||||
# sehr alte Clients -> konservativ behandeln
|
||||
points, next_off = res, None
|
||||
return points, next_off
|
||||
|
||||
|
||||
def _load_all_notes(client: QdrantClient, notes_col: str) -> List[Dict[str, Any]]:
|
||||
notes: List[Dict[str, Any]] = []
|
||||
next_off = None
|
||||
while True:
|
||||
pts, next_off = _scroll(
|
||||
client,
|
||||
collection_name=notes_col,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=1024,
|
||||
offset=next_off,
|
||||
)
|
||||
for p in pts or []:
|
||||
pl = getattr(p, "payload", {}) or {}
|
||||
# Erwartet Felder: note_id, title, path etc. (gemäß Schema) # :contentReference[oaicite:6]{index=6}
|
||||
if pl.get("note_id"):
|
||||
notes.append(pl)
|
||||
if not next_off:
|
||||
break
|
||||
return notes
|
||||
|
||||
|
||||
def _iter_unresolved_edges(client: QdrantClient, edges_col: str) -> Iterable[rest.Record]:
|
||||
"""
|
||||
Liefert alle Edge-Records mit payload.status == 'unresolved' und 'target_label' (string).
|
||||
"""
|
||||
f = rest.Filter(
|
||||
must=[
|
||||
rest.FieldCondition(key="status", match=rest.MatchValue(value="unresolved")),
|
||||
]
|
||||
)
|
||||
next_off = None
|
||||
while True:
|
||||
pts, next_off = _scroll(
|
||||
client,
|
||||
collection_name=edges_col,
|
||||
scroll_filter=f,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=1024,
|
||||
offset=next_off,
|
||||
)
|
||||
for p in pts or []:
|
||||
pl = getattr(p, "payload", {}) or {}
|
||||
if isinstance(pl.get("target_label"), str):
|
||||
yield p
|
||||
if not next_off:
|
||||
break
|
||||
|
||||
|
||||
def _make_backlink(source_note_id: str, target_note_id: str, extra: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
Baue eine 'backlink'-Edge-Payload source <- target (note-level).
|
||||
"""
|
||||
e = {
|
||||
"kind": "backlink",
|
||||
"source_id": target_note_id,
|
||||
"target_id": source_note_id,
|
||||
}
|
||||
# Metafelder aus dem Original übernehmen (ohne status)
|
||||
copy_keys = ["raw", "alias", "heading", "resolution"]
|
||||
for k in copy_keys:
|
||||
if k in extra:
|
||||
e[k] = extra[k]
|
||||
return e
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", help="Collection-Prefix (Default: Env/COLLECTION_PREFIX oder 'mindnet')")
|
||||
ap.add_argument("--apply", action="store_true", help="Änderungen schreiben (ohne Flag = Dry-Run)")
|
||||
ap.add_argument("--limit", type=int, default=0, help="Max. Anzahl unaufgelöster Edges bearbeiten (0 = alle)")
|
||||
ap.add_argument("--batch", type=int, default=512, help="Upsert-Batchgröße")
|
||||
args = ap.parse_args()
|
||||
|
||||
# Qdrant-Setup
|
||||
cfg = QdrantConfig.from_env()
|
||||
if args.prefix:
|
||||
cfg.prefix = args.prefix
|
||||
client = get_client(cfg)
|
||||
ensure_collections(client, cfg.prefix, cfg.dim) # sorgt u. a. für 1D-Vektor-Collection bei Edges :contentReference[oaicite:7]{index=7}
|
||||
notes_col, _, edges_col = collection_names(cfg.prefix) # :contentReference[oaicite:8]{index=8}
|
||||
|
||||
# Notes laden & Index bauen
|
||||
notes = _load_all_notes(client, notes_col)
|
||||
idx = build_note_index(notes) # (by_id, by_slug, by_file_slug) :contentReference[oaicite:9]{index=9}
|
||||
|
||||
# Unresolved-Edges scannen
|
||||
to_fix: List[dict] = []
|
||||
backlinks: List[dict] = []
|
||||
processed = 0
|
||||
resolved = 0
|
||||
|
||||
for rec in _iter_unresolved_edges(client, edges_col):
|
||||
if args.limit and processed >= args.limit:
|
||||
break
|
||||
processed += 1
|
||||
|
||||
pl = dict(rec.payload or {})
|
||||
kind = pl.get("kind") or "references"
|
||||
src = pl.get("source_id")
|
||||
tgt_label = pl.get("target_label") or pl.get("target_id") # Fallback
|
||||
|
||||
# Zielauflösung
|
||||
resolved_id, how = resolve_target(str(tgt_label), idx) # :contentReference[oaicite:10]{index=10}
|
||||
if not resolved_id:
|
||||
continue # weiterhin unresolved
|
||||
|
||||
# Edge-Update
|
||||
new_pl = dict(pl)
|
||||
new_pl["target_id"] = resolved_id
|
||||
new_pl["resolution"] = how
|
||||
if "status" in new_pl:
|
||||
del new_pl["status"]
|
||||
# ID stabil lassen -> points_for_edges erzeugt UUID aus edge_id/Fallback :contentReference[oaicite:11]{index=11}
|
||||
if "edge_id" not in new_pl:
|
||||
# stabiler Key aus (kind, src, tgt, evtl. seq)
|
||||
seq = new_pl.get("seq") or new_pl.get("order") or ""
|
||||
new_pl["edge_id"] = f"{kind}:{src}->{resolved_id}#{seq}"
|
||||
|
||||
to_fix.append(new_pl)
|
||||
resolved += 1
|
||||
|
||||
# Nur bei Note-Level references (nicht references_at) -> Backlink erzeugen
|
||||
if kind == "references":
|
||||
extra = {k: new_pl.get(k) for k in ("raw", "alias", "heading")}
|
||||
extra["resolution"] = how
|
||||
backlinks.append(_make_backlink(source_note_id=src, target_note_id=resolved_id, extra=extra))
|
||||
|
||||
# Ergebnis ausgeben
|
||||
summary = {
|
||||
"prefix": cfg.prefix,
|
||||
"scanned_unresolved": processed,
|
||||
"resolved": resolved,
|
||||
"backlinks_to_create": len(backlinks),
|
||||
"apply": bool(args.apply),
|
||||
}
|
||||
print(json.dumps(summary, ensure_ascii=False))
|
||||
|
||||
if not args.apply:
|
||||
return
|
||||
|
||||
# Upserts (in Batches)
|
||||
def _batched(items: List[dict], n: int) -> Iterable[List[dict]]:
|
||||
for i in range(0, len(items), n):
|
||||
yield items[i : i + n]
|
||||
|
||||
# 1) Updates für reparierte Edges
|
||||
for chunk in _batched(to_fix, args.batch):
|
||||
col, pts = points_for_edges(cfg.prefix, chunk) # sorgt für Edge-UUID & Dummy-Vector :contentReference[oaicite:12]{index=12}
|
||||
upsert_batch(client, col, pts)
|
||||
|
||||
# 2) Backlinks (nur references)
|
||||
for chunk in _batched(backlinks, args.batch):
|
||||
col, pts = points_for_edges(cfg.prefix, chunk)
|
||||
upsert_batch(client, col, pts)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Script: scripts/verify_chunk_texts.py
|
||||
Version: 1.0.0
|
||||
Datum: 2025-09-09
|
||||
|
||||
Kurzbeschreibung
|
||||
---------------
|
||||
Verifiziert, dass in Qdrant für jede Note die zugehörigen Chunks ein Textfeld
|
||||
enthalten und der Body (notes.payload.fulltext) aus den Chunk-Texten sinnvoll
|
||||
rekonstruiert werden kann.
|
||||
|
||||
Prüfungen pro Note:
|
||||
- Alle Chunks vorhanden (>=1).
|
||||
- Jedes Chunk-Payload hat einen nutzbaren Textschlüssel: "text" (bevorzugt), sonst "content", sonst "raw".
|
||||
- Reihenfolge der Chunks wird stabil bestimmt (payload.chunk_index -> Nummer aus chunk_id).
|
||||
- Coverage: Summe der im Fulltext gefundenen Chunk-Textsegmente / len(Fulltext) (Toleranz für Overlaps).
|
||||
-> OK wenn coverage >= 0.90 (konfigurierbar via --min-coverage)
|
||||
|
||||
Ausgabe:
|
||||
- JSON mit Gesamtsummen und Details je Note.
|
||||
|
||||
ENV:
|
||||
- QDRANT_URL | QDRANT_HOST/QDRANT_PORT | QDRANT_API_KEY
|
||||
- COLLECTION_PREFIX (Fallback, wenn --prefix fehlt)
|
||||
|
||||
Beispiele:
|
||||
# Alle Notes prüfen (Prefix aus ENV)
|
||||
python3 -m scripts.verify_chunk_texts
|
||||
|
||||
# Nur eine Note prüfen
|
||||
python3 -m scripts.verify_chunk_texts --note-id concept-alpha
|
||||
|
||||
# Prefix explizit setzen und strengere Coverage verlangen
|
||||
python3 -m scripts.verify_chunk_texts --prefix mindnet --min-coverage 0.95
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse, json, os, re, sys
|
||||
from typing import Dict, List, Tuple, Optional
|
||||
|
||||
from qdrant_client import QdrantClient
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
def _names(prefix: str) -> Tuple[str,str,str]:
|
||||
return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges"
|
||||
|
||||
def _client() -> QdrantClient:
|
||||
url = os.getenv("QDRANT_URL")
|
||||
if not url:
|
||||
host = os.getenv("QDRANT_HOST", "127.0.0.1")
|
||||
port = int(os.getenv("QDRANT_PORT", "6333"))
|
||||
url = f"http://{host}:{port}"
|
||||
api_key = os.getenv("QDRANT_API_KEY") or None
|
||||
return QdrantClient(url=url, api_key=api_key)
|
||||
|
||||
def _chunk_sort_key(p: Dict, pid: str) -> Tuple[int,int,str]:
|
||||
# Primär: payload.chunk_index, sekundär: Nummer am Ende der ID (#cNN oder #NN), sonst 0
|
||||
ci = p.get("chunk_index")
|
||||
n = 0
|
||||
m = re.search(r'#c?(\d+)$', pid or "")
|
||||
if m:
|
||||
try:
|
||||
n = int(m.group(1))
|
||||
except Exception:
|
||||
n = 0
|
||||
return (ci if isinstance(ci, int) else 1_000_000 + n, n, pid)
|
||||
|
||||
def _choose_text(payload: Dict) -> Optional[str]:
|
||||
for k in ("text", "content", "raw"):
|
||||
v = payload.get(k)
|
||||
if isinstance(v, str) and v.strip():
|
||||
return v
|
||||
return None
|
||||
|
||||
def _coverage(fulltext: str, pieces: List[str]) -> float:
|
||||
"""Berechnet die Abdeckungsquote der Stücke im Fulltext (sequenzielles Matching)."""
|
||||
if not fulltext:
|
||||
return 0.0 if pieces else 1.0
|
||||
cursor = 0
|
||||
covered = 0
|
||||
ft = fulltext
|
||||
for piece in pieces:
|
||||
if not piece:
|
||||
continue
|
||||
# Tolerant gegen Whitespace-Unterschiede: normalisieren nur \r\n→\n
|
||||
p = piece.replace("\r\n", "\n").replace("\r", "\n")
|
||||
idx = ft.find(p, cursor)
|
||||
if idx == -1:
|
||||
# Versuche ein paar Heuristiken: trimmen
|
||||
p2 = p.strip()
|
||||
if p2 and len(p2) > 8:
|
||||
idx = ft.find(p2, cursor)
|
||||
if idx != -1:
|
||||
covered += len(p)
|
||||
cursor = idx + len(p)
|
||||
# sonst: nicht abgedeckt
|
||||
return covered / max(1, len(ft))
|
||||
|
||||
def main() -> None:
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", help="Collection-Prefix (Default: ENV COLLECTION_PREFIX oder 'mindnet')")
|
||||
ap.add_argument("--note-id", help="Nur eine bestimmte Note prüfen")
|
||||
ap.add_argument("--min-coverage", type=float, default=0.90, help="Mindestabdeckung durch Chunks (Default: 0.90)")
|
||||
args = ap.parse_args()
|
||||
|
||||
prefix = args.prefix or os.getenv("COLLECTION_PREFIX", "mindnet")
|
||||
notes_col, chunks_col, _ = _names(prefix)
|
||||
cli = _client()
|
||||
|
||||
# Notes abrufen (optional filter by note_id)
|
||||
notes_filter = None
|
||||
if args.note_id:
|
||||
notes_filter = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=args.note_id))])
|
||||
|
||||
notes: List[Dict] = []
|
||||
off = None
|
||||
while True:
|
||||
pts, off = cli.scroll(collection_name=notes_col, scroll_filter=notes_filter,
|
||||
with_payload=True, with_vectors=False, limit=256, offset=off)
|
||||
if not pts:
|
||||
break
|
||||
for p in pts:
|
||||
notes.append({"id": p.id, "payload": p.payload or {}})
|
||||
if off is None:
|
||||
break
|
||||
|
||||
results = []
|
||||
total_missing_text = 0
|
||||
total_notes_ok = 0
|
||||
for n in notes:
|
||||
pl = n["payload"]
|
||||
nid = pl.get("note_id") or pl.get("id") or n.get("id")
|
||||
fulltext = pl.get("fulltext") or ""
|
||||
# Chunks der Note holen
|
||||
f = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=nid))])
|
||||
chunks = []
|
||||
off = None
|
||||
while True:
|
||||
pts, off = cli.scroll(collection_name=chunks_col, scroll_filter=f,
|
||||
with_payload=True, with_vectors=False, limit=256, offset=off)
|
||||
if not pts:
|
||||
break
|
||||
for p in pts:
|
||||
chunks.append({"id": p.id, "payload": p.payload or {}})
|
||||
if off is None:
|
||||
break
|
||||
# sortieren
|
||||
chunks.sort(key=lambda c: _chunk_sort_key(c["payload"], c["id"]))
|
||||
texts = []
|
||||
missing_text = 0
|
||||
for c in chunks:
|
||||
t = _choose_text(c["payload"])
|
||||
if t is None:
|
||||
missing_text += 1
|
||||
texts.append("")
|
||||
else:
|
||||
texts.append(t)
|
||||
cov = _coverage(fulltext, texts)
|
||||
ok = (missing_text == 0) and (cov >= args.min_coverage or not fulltext)
|
||||
if ok:
|
||||
total_notes_ok += 1
|
||||
total_missing_text += missing_text
|
||||
results.append({
|
||||
"note_id": nid,
|
||||
"title": pl.get("title"),
|
||||
"chunks": len(chunks),
|
||||
"missing_chunk_texts": missing_text,
|
||||
"coverage": round(cov, 4),
|
||||
"has_fulltext": bool(fulltext),
|
||||
"ok": ok
|
||||
})
|
||||
|
||||
out = {
|
||||
"collections": {"notes": notes_col, "chunks": chunks_col},
|
||||
"notes_checked": len(notes),
|
||||
"notes_ok": total_notes_ok,
|
||||
"total_missing_chunk_texts": total_missing_text,
|
||||
"min_coverage": args.min_coverage,
|
||||
"details": results
|
||||
}
|
||||
print(json.dumps(out, ensure_ascii=False, indent=2))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
scripts/wp04_smoketest.py — E2E-Schnelltest der WP-04 Endpunkte
|
||||
|
||||
Zweck:
|
||||
- Holt exemplarisch einen Vektor aus {prefix}_chunks (falls verfügbar),
|
||||
- ruft POST /query mit diesem Vektor auf,
|
||||
- ruft GET /graph/<note_id> für die Top-Note auf,
|
||||
- druckt Kurzresultate auf STDOUT.
|
||||
|
||||
Kompatibilität:
|
||||
Python 3.12+, requests, qdrant-client
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
WP-04 /query & /graph
|
||||
Nutzung:
|
||||
export QDRANT_URL="http://localhost:6333"
|
||||
export MINDNET_PREFIX="mindnet"
|
||||
python3 scripts/wp04_smoketest.py --api http://localhost:8000
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import argparse
|
||||
import requests
|
||||
from qdrant_client import QdrantClient
|
||||
|
||||
|
||||
def get_any_chunk_vector(client: QdrantClient, prefix: str):
|
||||
"""Holt eine beliebige Chunk-Vector/Note-ID-Kombi aus Qdrant (falls vorhanden)."""
|
||||
col = f"{prefix}_chunks"
|
||||
pts, _ = client.scroll(collection_name=col, limit=1, with_vectors=True, with_payload=True)
|
||||
if not pts:
|
||||
return None, None, None
|
||||
p = pts[0]
|
||||
vec = p.vector
|
||||
payload = p.payload or {}
|
||||
node_id = str(p.id)
|
||||
note_id = payload.get("note_id")
|
||||
return vec, node_id, note_id
|
||||
|
||||
|
||||
def run(api_base: str, qdrant_url: str, prefix: str) -> int:
|
||||
print(f"[i] API: {api_base}")
|
||||
print(f"[i] Qdrant: {qdrant_url}")
|
||||
client = QdrantClient(url=qdrant_url)
|
||||
|
||||
vec, node_id, note_id = get_any_chunk_vector(client, prefix)
|
||||
if vec is None:
|
||||
print("[!] Keine Chunks mit Vektoren gefunden. Bitte Import (WP-03) prüfen.")
|
||||
return 2
|
||||
|
||||
print(f"[i] Beispiel-Chunk-ID: {node_id}, Note-ID: {note_id}")
|
||||
print("[i] Rufe /query (hybrid) mit Beispielvektor auf ...")
|
||||
|
||||
q_payload = {
|
||||
"mode": "hybrid",
|
||||
"query_vector": vec, # 384d
|
||||
"top_k": 5,
|
||||
"expand": {"depth": 1, "edge_types": ["references", "belongs_to", "prev", "next"]},
|
||||
}
|
||||
r = requests.post(f"{api_base.rstrip('/')}/query", json=q_payload, timeout=60)
|
||||
print(f"[i] /query Status: {r.status_code}")
|
||||
if r.status_code != 200:
|
||||
print(r.text)
|
||||
return 3
|
||||
|
||||
data = r.json()
|
||||
hits = data.get("results", [])
|
||||
print(f"[i] Treffer: {len(hits)}")
|
||||
for i, h in enumerate(hits, 1):
|
||||
print(f" {i:02d}. node_id={h['node_id']} note_id={h.get('note_id')} total={h['total_score']:.3f}")
|
||||
|
||||
# Graph-Test (wenn Note-ID vorhanden)
|
||||
gid = note_id or (hits[0].get("note_id") if hits else None)
|
||||
if gid:
|
||||
print(f"[i] Rufe /graph/{gid} ...")
|
||||
r2 = requests.get(f"{api_base.rstrip('/')}/graph/{gid}?depth=1", timeout=60)
|
||||
print(f"[i] /graph Status: {r2.status_code}")
|
||||
if r2.status_code == 200:
|
||||
g = r2.json()
|
||||
print(f" Nodes: {len(g.get('nodes', []))}, Edges: {len(g.get('edges', []))}")
|
||||
else:
|
||||
print(r2.text)
|
||||
|
||||
print("[✔] Smoke-Test abgeschlossen.")
|
||||
return 0
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--api", default="http://localhost:8000", help="Basis-URL der FastAPI.")
|
||||
args = ap.parse_args()
|
||||
|
||||
qdrant_url = os.getenv("QDRANT_URL", "http://127.0.0.1:6333")
|
||||
prefix = os.getenv("MINDNET_PREFIX", "mindnet")
|
||||
sys.exit(run(args.api, qdrant_url, prefix))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests/audit_edges_now.py — Zählt Edges nach kind & scope und zeigt Chunk- und Note-Anzahl.
|
||||
"""
|
||||
import os, sys, json
|
||||
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
if PROJECT_ROOT not in sys.path:
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
|
||||
from qdrant_client.http import models as rest
|
||||
from app.core.qdrant import QdrantConfig, get_client
|
||||
|
||||
def scroll_all(c, col, flt=None):
|
||||
out, nextp = [], None
|
||||
while True:
|
||||
pts, nextp = c.scroll(collection_name=col, with_payload=True, with_vectors=False, limit=256, scroll_filter=flt, offset=nextp)
|
||||
if not pts: break
|
||||
out.extend(pts)
|
||||
if nextp is None: break
|
||||
return out
|
||||
|
||||
def main():
|
||||
cfg = QdrantConfig.from_env()
|
||||
c = get_client(cfg)
|
||||
notes = f"{cfg.prefix}_notes"
|
||||
chunks = f"{cfg.prefix}_chunks"
|
||||
edges = f"{cfg.prefix}_edges"
|
||||
|
||||
es = scroll_all(c, edges)
|
||||
counts = {}
|
||||
by_scope = {}
|
||||
for p in es:
|
||||
pl = p.payload or {}
|
||||
k = pl.get("kind") or "?"
|
||||
s = pl.get("scope") or "?"
|
||||
counts[k] = counts.get(k, 0) + 1
|
||||
key = f"{k}:{s}"
|
||||
by_scope[key] = by_scope.get(key, 0) + 1
|
||||
|
||||
print(json.dumps({
|
||||
"collections": {"notes": notes, "chunks": chunks, "edges": edges},
|
||||
"total_edges": len(es),
|
||||
"counts": counts,
|
||||
"counts_by_scope": by_scope
|
||||
}, ensure_ascii=False, indent=2))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests/check_chunks_window_vs_text.py
|
||||
Prüft pro Note und global:
|
||||
- ob window == text (sollte bei Overlap normalerweise NEIN sein)
|
||||
- ungefähre linke Overlap-Länge (Suffix von prev.text vs. Prefix von cur.window)
|
||||
- Größen & einfache Statistiken
|
||||
|
||||
Nutzung:
|
||||
python3 tests/check_chunks_window_vs_text.py --prefix mindnet [--vault ./test_vault]
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import os, sys, json, argparse
|
||||
from typing import List, Dict, Any, Tuple, Optional
|
||||
|
||||
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
if PROJECT_ROOT not in sys.path:
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
|
||||
from app.core.qdrant import QdrantConfig, get_client
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
def collections(prefix: str) -> Tuple[str, str, str]:
|
||||
return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges"
|
||||
|
||||
def scroll_chunks_by_note(client, chunks_col: str, note_id: str) -> List[Dict[str, Any]]:
|
||||
f = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=note_id))])
|
||||
out = []
|
||||
next_page = None
|
||||
while True:
|
||||
pts, next_page = client.scroll(
|
||||
collection_name=chunks_col,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=256,
|
||||
offset=next_page,
|
||||
scroll_filter=f,
|
||||
)
|
||||
if not pts:
|
||||
break
|
||||
out.extend([p.payload or {} for p in pts])
|
||||
if next_page is None:
|
||||
break
|
||||
# sortieren: seq -> chunk_index -> chunk_id
|
||||
def keyer(pl):
|
||||
return (pl.get("seq", 1<<30), pl.get("chunk_index", 1<<30), str(pl.get("chunk_id", "")))
|
||||
return sorted(out, key=keyer)
|
||||
|
||||
def list_note_ids(client, notes_col: str) -> List[str]:
|
||||
out = []
|
||||
next_page = None
|
||||
while True:
|
||||
pts, next_page = client.scroll(
|
||||
collection_name=notes_col,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=256,
|
||||
offset=next_page,
|
||||
)
|
||||
if not pts:
|
||||
break
|
||||
for p in pts:
|
||||
pl = p.payload or {}
|
||||
nid = pl.get("note_id")
|
||||
if isinstance(nid, str):
|
||||
out.append(nid)
|
||||
if next_page is None:
|
||||
break
|
||||
return sorted(set(out))
|
||||
|
||||
def common_overlap_len(a_suffix: str, b_prefix: str, max_probe: int = 256) -> int:
|
||||
"""
|
||||
Länge des längsten Suffix von a_suffix, das Prefix von b_prefix ist (bruteforce, begrenzt).
|
||||
"""
|
||||
n = min(len(a_suffix), len(b_prefix), max_probe)
|
||||
if n <= 0:
|
||||
return 0
|
||||
a = a_suffix[-n:]
|
||||
b = b_prefix[:n]
|
||||
# steigere den Match von 0..n
|
||||
for k in range(n, 0, -1):
|
||||
if a[-k:] == b[:k]:
|
||||
return k
|
||||
return 0
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", required=True)
|
||||
ap.add_argument("--vault", help="optional, nur für Vergleichsausgaben")
|
||||
args = ap.parse_args()
|
||||
|
||||
cfg = QdrantConfig.from_env()
|
||||
cfg.prefix = args.prefix
|
||||
client = get_client(cfg)
|
||||
|
||||
notes_col, chunks_col, _ = collections(cfg.prefix)
|
||||
note_ids = list_note_ids(client, notes_col)
|
||||
if not note_ids:
|
||||
print(json.dumps({"error": "no notes found in qdrant for this prefix"}))
|
||||
return
|
||||
|
||||
global_total = 0
|
||||
global_ident = 0
|
||||
global_left_ov_sum = 0
|
||||
detail = []
|
||||
|
||||
for nid in note_ids:
|
||||
chunks = scroll_chunks_by_note(client, chunks_col, nid)
|
||||
if not chunks:
|
||||
detail.append({"note_id": nid, "chunks": 0})
|
||||
continue
|
||||
ident = 0
|
||||
left_ov_sum = 0
|
||||
for i, ch in enumerate(chunks):
|
||||
txt = (ch.get("text") or "").replace("\r\n", "\n")
|
||||
win = (ch.get("window") or "").replace("\r\n", "\n")
|
||||
if txt == win:
|
||||
ident += 1
|
||||
if i > 0:
|
||||
prev_txt = (chunks[i-1].get("text") or "").replace("\r\n", "\n")
|
||||
left_ov = common_overlap_len(prev_txt, win, max_probe=1024)
|
||||
left_ov_sum += left_ov
|
||||
global_total += len(chunks)
|
||||
global_ident += ident
|
||||
global_left_ov_sum += left_ov_sum
|
||||
detail.append({
|
||||
"note_id": nid,
|
||||
"chunks": len(chunks),
|
||||
"identical_text_window": ident,
|
||||
"identical_share": round(ident / max(1, len(chunks)), 3),
|
||||
"avg_left_overlap_est": round(left_ov_sum / max(1, len(chunks)-1), 2) if len(chunks) > 1 else 0.0
|
||||
})
|
||||
|
||||
out = {
|
||||
"notes": len(note_ids),
|
||||
"chunks_total": global_total,
|
||||
"identical_total": global_ident,
|
||||
"identical_share_global": round(global_ident / max(1, global_total), 3),
|
||||
"avg_left_overlap_est_global": round(global_left_ov_sum / max(1, global_total - len(note_ids)), 2) if global_total > len(note_ids) else 0.0,
|
||||
"details": detail[:100] # capped
|
||||
}
|
||||
print(json.dumps(out, ensure_ascii=False, indent=2))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests/check_chunks_window_vs_text.py
|
||||
Prüft pro Note und global:
|
||||
- ob window == text (sollte bei Overlap normalerweise NEIN sein)
|
||||
- ungefähre linke Overlap-Länge (Suffix von prev.text vs. Prefix von cur.window)
|
||||
- Größen & einfache Statistiken
|
||||
|
||||
Nutzung:
|
||||
python3 tests/check_chunks_window_vs_text.py --prefix mindnet [--vault ./test_vault]
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import os, sys, json, argparse
|
||||
from typing import List, Dict, Any, Tuple, Optional
|
||||
|
||||
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
if PROJECT_ROOT not in sys.path:
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
|
||||
from app.core.qdrant import QdrantConfig, get_client
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
def collections(prefix: str) -> Tuple[str, str, str]:
|
||||
return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges"
|
||||
|
||||
def scroll_chunks_by_note(client, chunks_col: str, note_id: str) -> List[Dict[str, Any]]:
|
||||
f = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=note_id))])
|
||||
out = []
|
||||
next_page = None
|
||||
while True:
|
||||
pts, next_page = client.scroll(
|
||||
collection_name=chunks_col,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=256,
|
||||
offset=next_page,
|
||||
scroll_filter=f,
|
||||
)
|
||||
if not pts:
|
||||
break
|
||||
out.extend([p.payload or {} for p in pts])
|
||||
if next_page is None:
|
||||
break
|
||||
# sortieren: seq -> chunk_index -> chunk_id
|
||||
def keyer(pl):
|
||||
return (pl.get("seq", 1<<30), pl.get("chunk_index", 1<<30), str(pl.get("chunk_id", "")))
|
||||
return sorted(out, key=keyer)
|
||||
|
||||
def list_note_ids(client, notes_col: str) -> List[str]:
|
||||
out = []
|
||||
next_page = None
|
||||
while True:
|
||||
pts, next_page = client.scroll(
|
||||
collection_name=notes_col,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=256,
|
||||
offset=next_page,
|
||||
)
|
||||
if not pts:
|
||||
break
|
||||
for p in pts:
|
||||
pl = p.payload or {}
|
||||
nid = pl.get("note_id")
|
||||
if isinstance(nid, str):
|
||||
out.append(nid)
|
||||
if next_page is None:
|
||||
break
|
||||
return sorted(set(out))
|
||||
|
||||
def common_overlap_len(a_suffix: str, b_prefix: str, max_probe: int = 256) -> int:
|
||||
"""
|
||||
Länge des längsten Suffix von a_suffix, das Prefix von b_prefix ist (bruteforce, begrenzt).
|
||||
"""
|
||||
n = min(len(a_suffix), len(b_prefix), max_probe)
|
||||
if n <= 0:
|
||||
return 0
|
||||
a = a_suffix[-n:]
|
||||
b = b_prefix[:n]
|
||||
# steigere den Match von 0..n
|
||||
for k in range(n, 0, -1):
|
||||
if a[-k:] == b[:k]:
|
||||
return k
|
||||
return 0
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", required=True)
|
||||
ap.add_argument("--vault", help="optional, nur für Vergleichsausgaben")
|
||||
args = ap.parse_args()
|
||||
|
||||
cfg = QdrantConfig.from_env()
|
||||
cfg.prefix = args.prefix
|
||||
client = get_client(cfg)
|
||||
|
||||
notes_col, chunks_col, _ = collections(cfg.prefix)
|
||||
note_ids = list_note_ids(client, notes_col)
|
||||
if not note_ids:
|
||||
print(json.dumps({"error": "no notes found in qdrant for this prefix"}))
|
||||
return
|
||||
|
||||
global_total = 0
|
||||
global_ident = 0
|
||||
global_left_ov_sum = 0
|
||||
detail = []
|
||||
|
||||
for nid in note_ids:
|
||||
chunks = scroll_chunks_by_note(client, chunks_col, nid)
|
||||
if not chunks:
|
||||
detail.append({"note_id": nid, "chunks": 0})
|
||||
continue
|
||||
ident = 0
|
||||
left_ov_sum = 0
|
||||
for i, ch in enumerate(chunks):
|
||||
txt = (ch.get("text") or "").replace("\r\n", "\n")
|
||||
win = (ch.get("window") or "").replace("\r\n", "\n")
|
||||
if txt == win:
|
||||
ident += 1
|
||||
if i > 0:
|
||||
prev_txt = (chunks[i-1].get("text") or "").replace("\r\n", "\n")
|
||||
left_ov = common_overlap_len(prev_txt, win, max_probe=1024)
|
||||
left_ov_sum += left_ov
|
||||
global_total += len(chunks)
|
||||
global_ident += ident
|
||||
global_left_ov_sum += left_ov_sum
|
||||
detail.append({
|
||||
"note_id": nid,
|
||||
"chunks": len(chunks),
|
||||
"identical_text_window": ident,
|
||||
"identical_share": round(ident / max(1, len(chunks)), 3),
|
||||
"avg_left_overlap_est": round(left_ov_sum / max(1, len(chunks)-1), 2) if len(chunks) > 1 else 0.0
|
||||
})
|
||||
|
||||
out = {
|
||||
"notes": len(note_ids),
|
||||
"chunks_total": global_total,
|
||||
"identical_total": global_ident,
|
||||
"identical_share_global": round(global_ident / max(1, global_total), 3),
|
||||
"avg_left_overlap_est_global": round(global_left_ov_sum / max(1, global_total - len(note_ids)), 2) if global_total > len(note_ids) else 0.0,
|
||||
"details": detail[:100] # capped
|
||||
}
|
||||
print(json.dumps(out, ensure_ascii=False, indent=2))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,190 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
check_types_registry_edges.py
|
||||
--------------------------------------------------
|
||||
Prüft, ob die in config/types.yaml hinterlegten Default-Kanten
|
||||
pro Note-Typ tatsächlich in der Qdrant *edges*-Collection auftauchen.
|
||||
"""
|
||||
import os, sys, json
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Tuple, Set
|
||||
from dataclasses import dataclass, asdict
|
||||
|
||||
try:
|
||||
import yaml # PyYAML
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": f"PyYAML not installed: {e}"})); sys.exit(2)
|
||||
|
||||
try:
|
||||
from qdrant_client import QdrantClient
|
||||
from qdrant_client.http import models as rest # noqa: F401
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": f"qdrant-client not installed: {e}"})); sys.exit(2)
|
||||
|
||||
@dataclass
|
||||
class Cfg:
|
||||
url: str
|
||||
api_key: Optional[str]
|
||||
prefix: str
|
||||
notes: str
|
||||
edges: str
|
||||
types_file: Path
|
||||
|
||||
def _env_prefix() -> Optional[str]:
|
||||
for k in ("COLLECTION_PREFIX", "MINDNET_PREFIX"):
|
||||
v = os.environ.get(k, "").strip()
|
||||
if v:
|
||||
return v
|
||||
return None
|
||||
|
||||
def _load_types_yaml(path: Path) -> Dict:
|
||||
if not path.exists():
|
||||
print(json.dumps({"warn": f"types.yaml fehlt: {path}. Fallback: keine Vorgaben."}))
|
||||
return {}
|
||||
try:
|
||||
with path.open("r", encoding="utf-8") as f:
|
||||
data = yaml.safe_load(f) or {}
|
||||
return data if isinstance(data, dict) else {}
|
||||
except Exception as e:
|
||||
print(json.dumps({"warn": f"types.yaml defekt ({path}): {e}. Fallback: keine Vorgaben."}))
|
||||
return {}
|
||||
|
||||
def _cfg_from_env(argv_prefix: Optional[str]) -> Cfg:
|
||||
url = os.environ.get("QDRANT_URL", "http://127.0.0.1:6333").strip()
|
||||
api_key = os.environ.get("QDRANT_API_KEY", "").strip() or None
|
||||
prefix = (argv_prefix or _env_prefix() or "mindnet").strip()
|
||||
notes = f"{prefix}_notes"
|
||||
edges = f"{prefix}_edges"
|
||||
types_path = Path(os.environ.get("TYPES_FILE", "config/types.yaml")).resolve()
|
||||
return Cfg(url=url, api_key=api_key, prefix=prefix, notes=notes, edges=edges, types_file=types_path)
|
||||
|
||||
def _mk_client(cfg: Cfg) -> QdrantClient:
|
||||
return QdrantClient(url=cfg.url, api_key=cfg.api_key, timeout=30.0)
|
||||
|
||||
def _scroll_all_notes(client: QdrantClient, notes_col: str) -> Dict[str, Dict]:
|
||||
out = {}
|
||||
offset = None
|
||||
while True:
|
||||
points, offset = client.scroll(
|
||||
collection_name=notes_col,
|
||||
scroll_filter=None, limit=256, offset=offset,
|
||||
with_payload=True, with_vectors=False,
|
||||
)
|
||||
if not points:
|
||||
break
|
||||
for p in points:
|
||||
payload = p.payload or {}
|
||||
nid = payload.get("note_id") or payload.get("id") or payload.get("uid") or payload.get("slug")
|
||||
if not nid:
|
||||
nid = str(p.id)
|
||||
out[str(nid)] = payload
|
||||
return out
|
||||
|
||||
def _scroll_all_edges(client: QdrantClient, edges_col: str) -> List[Tuple[str, dict]]:
|
||||
out = []
|
||||
offset = None
|
||||
while True:
|
||||
points, offset = client.scroll(
|
||||
collection_name=edges_col,
|
||||
scroll_filter=None, limit=256, offset=offset,
|
||||
with_payload=True, with_vectors=False,
|
||||
)
|
||||
if not points:
|
||||
break
|
||||
for p in points:
|
||||
out.append((str(p.id), p.payload or {}))
|
||||
return out
|
||||
|
||||
def _guess_src_note_id(ed_pl: dict) -> Optional[str]:
|
||||
for k in ("src_note_id", "note_id", "src_id", "src"):
|
||||
nid = ed_pl.get(k)
|
||||
if nid:
|
||||
return str(nid)
|
||||
for k in ("src_ref", "from"):
|
||||
nid = ed_pl.get(k)
|
||||
if isinstance(nid, dict):
|
||||
for kk in ("note_id", "id"):
|
||||
if nid.get(kk):
|
||||
return str(nid[kk])
|
||||
elif isinstance(nid, str):
|
||||
return nid
|
||||
return None
|
||||
|
||||
def _edge_type(ed_pl: dict) -> Optional[str]:
|
||||
for k in ("edge_type", "type", "rel", "relation"):
|
||||
if ed_pl.get(k):
|
||||
return str(ed_pl[k])
|
||||
return None
|
||||
|
||||
def _cfg_to_jsonable(cfg: Cfg) -> dict:
|
||||
d = asdict(cfg)
|
||||
d["types_file"] = str(d.get("types_file"))
|
||||
return d
|
||||
|
||||
def main(argv=None):
|
||||
import argparse
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", help="Collection-Prefix (mindnet, etc.)")
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
cfg = _cfg_from_env(args.prefix)
|
||||
print(json.dumps({"cfg": _cfg_to_jsonable(cfg)}, ensure_ascii=False))
|
||||
|
||||
tr = _load_types_yaml(cfg.types_file)
|
||||
types_def = (tr.get("types") if isinstance(tr, dict) else {}) or {}
|
||||
print(json.dumps({"types_defined": list(types_def.keys())}, ensure_ascii=False))
|
||||
|
||||
client = _mk_client(cfg)
|
||||
|
||||
notes = _scroll_all_notes(client, cfg.notes)
|
||||
print(json.dumps({"notes_count": len(notes)}, ensure_ascii=False))
|
||||
|
||||
edges = _scroll_all_edges(client, cfg.edges)
|
||||
print(json.dumps({"edges_count": len(edges)}, ensure_ascii=False))
|
||||
|
||||
note_type = {}
|
||||
for nid, pl in notes.items():
|
||||
t = pl.get("type") or "concept"
|
||||
note_type[str(nid)] = str(t)
|
||||
|
||||
seen = {}
|
||||
counts = {}
|
||||
|
||||
for edge_pid, ed_pl in edges:
|
||||
et = _edge_type(ed_pl)
|
||||
if not et:
|
||||
continue
|
||||
src_nid = _guess_src_note_id(ed_pl)
|
||||
if not src_nid:
|
||||
continue
|
||||
t = note_type.get(src_nid)
|
||||
if not t:
|
||||
continue
|
||||
seen.setdefault(t, set()).add(et)
|
||||
counts.setdefault(t, {}).setdefault(et, 0)
|
||||
counts[t][et] += 1
|
||||
|
||||
expected = {}
|
||||
for tname, tdef in types_def.items():
|
||||
eddefs = (tdef or {}).get("edge_defaults") or []
|
||||
expected[tname] = set([str(x) for x in eddefs if x])
|
||||
|
||||
for tname, exp in expected.items():
|
||||
obs = seen.get(tname, set())
|
||||
missing = sorted(list(exp - obs))
|
||||
extra = sorted(list(obs - exp))
|
||||
print(json.dumps({
|
||||
"type": tname,
|
||||
"expected_defaults": sorted(list(exp)),
|
||||
"observed": sorted(list(obs)),
|
||||
"missing": missing,
|
||||
"extra": extra,
|
||||
"counts": counts.get(tname, {}),
|
||||
}, ensure_ascii=False))
|
||||
|
||||
if not expected:
|
||||
print(json.dumps({"warn": "Keine Typ-Defaults in types.yaml gefunden (edge_defaults leer?)."}))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,93 @@
|
||||
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import os, json, argparse, random
|
||||
from typing import Any, Dict, List, Tuple, Optional
|
||||
from qdrant_client import QdrantClient
|
||||
|
||||
def _get_prefix(explicit: Optional[str]) -> str:
|
||||
return (explicit or os.environ.get("COLLECTION_PREFIX") or os.environ.get("MINDNET_PREFIX") or "mindnet").strip()
|
||||
|
||||
def _names(prefix: str) -> Dict[str,str]:
|
||||
return {
|
||||
"notes": f"{prefix}_notes",
|
||||
"chunks": f"{prefix}_chunks",
|
||||
"edges": f"{prefix}_edges",
|
||||
}
|
||||
|
||||
def _scroll(client: QdrantClient, collection: str, *, limit=5, with_payload=True):
|
||||
# Support both modern and older SDKs (filter vs scroll_filter)
|
||||
try:
|
||||
return client.scroll(collection_name=collection, limit=limit, with_payload=with_payload)
|
||||
except TypeError as e:
|
||||
# older signatures might accept scroll_filter kw, but if we passed none it's fine
|
||||
return client.scroll(collection_name=collection, limit=limit, with_payload=with_payload)
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--host", default=os.environ.get("QDRANT_HOST", "127.0.0.1"))
|
||||
ap.add_argument("--port", default=int(os.environ.get("QDRANT_PORT", "6333")))
|
||||
ap.add_argument("--prefix", default=None)
|
||||
ap.add_argument("--limit", type=int, default=5)
|
||||
ap.add_argument("--note-id", default=None)
|
||||
args = ap.parse_args()
|
||||
|
||||
prefix = _get_prefix(args.prefix)
|
||||
names = _names(prefix)
|
||||
client = QdrantClient(host=args.host, port=args.port, prefer_grpc=False)
|
||||
|
||||
# Notes sample
|
||||
try:
|
||||
pts, _ = _scroll(client, names["notes"], limit=args.limit, with_payload=True)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": f"notes scroll failed: {type(e).__name__}: {e}", "collection": names["notes"]}))
|
||||
return
|
||||
|
||||
sample = []
|
||||
for p in pts:
|
||||
pl = (p.payload or {})
|
||||
sample.append({
|
||||
"point_id": str(p.id),
|
||||
"note_id": pl.get("note_id"),
|
||||
"id": pl.get("id"),
|
||||
"title": pl.get("title"),
|
||||
"type": pl.get("type"),
|
||||
"retriever_weight": pl.get("retriever_weight"),
|
||||
"chunk_profile": pl.get("chunk_profile"),
|
||||
})
|
||||
print(json.dumps({"notes_sample": sample}, ensure_ascii=False))
|
||||
|
||||
# Pick a note to fetch chunks
|
||||
target_note_id = args.note_id or None
|
||||
if not target_note_id:
|
||||
for s in sample:
|
||||
if s.get("note_id"):
|
||||
target_note_id = s["note_id"]
|
||||
break
|
||||
|
||||
if not target_note_id:
|
||||
print(json.dumps({"warn": "no note_id available to fetch chunks"}))
|
||||
return
|
||||
|
||||
# Chunks for target note
|
||||
try:
|
||||
# pull a few chunks and filter client-side by note_id
|
||||
pts, _ = _scroll(client, names["chunks"], limit=50, with_payload=True)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": f"chunks scroll failed: {type(e).__name__}: {e}", "collection": names["chunks"]}))
|
||||
return
|
||||
|
||||
chunks = [{
|
||||
"id": str(p.id),
|
||||
"chunk_id": (p.payload or {}).get("chunk_id"),
|
||||
"note_id": (p.payload or {}).get("note_id"),
|
||||
"type": (p.payload or {}).get("type"),
|
||||
"retriever_weight": (p.payload or {}).get("retriever_weight"),
|
||||
"window_len": len((p.payload or {}).get("window") or ""),
|
||||
"text_len": len((p.payload or {}).get("text") or ""),
|
||||
} for p in pts if (p.payload or {}).get("note_id") == target_note_id][:5]
|
||||
|
||||
print(json.dumps({"target_note_id": target_note_id, "chunk_samples": chunks}, ensure_ascii=False))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,177 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests/compare_vaults.py
|
||||
|
||||
Vergleicht zwei Markdown-Vaults rekursiv:
|
||||
- Schlüsselauswahl: id | title | filename | auto (default: auto = id>title>filename)
|
||||
- Fokus: body | frontmatter | all (default: body)
|
||||
- Unicode: NFC-Normalisierung für IDs/Titel/Dateinamen und Text
|
||||
|
||||
Beispiele:
|
||||
python3 tests/compare_vaults.py --src ./vault --dst ./_exportVault --focus body
|
||||
python3 tests/compare_vaults.py --src ./vault --dst ./_exportVault --key id --focus all
|
||||
|
||||
Ausgabe:
|
||||
- Einträge mit 'missing' (nur in src oder nur in dst)
|
||||
- Einträge mit 'diff' (vorhanden in beiden, aber Abweichungen gem. Fokus)
|
||||
- Summary-Objekt am Ende
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import argparse
|
||||
import unicodedata
|
||||
from typing import Dict, Tuple, Optional, Any
|
||||
|
||||
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
if PROJECT_ROOT not in sys.path:
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
|
||||
# Wir nutzen denselben Parser wie im Projekt (fehlertolerant)
|
||||
from app.core.parser import read_markdown # erwartet: (frontmatter, body)
|
||||
|
||||
MD_EXTS = {".md", ".markdown"}
|
||||
|
||||
def nfc(s: Optional[str]) -> str:
|
||||
return unicodedata.normalize("NFC", s or "")
|
||||
|
||||
def norm_text(txt: str) -> str:
|
||||
# normalize line endings + strip trailing spaces per line + NFC
|
||||
t = txt.replace("\r\n", "\n").replace("\r", "\n")
|
||||
t = "\n".join(line.rstrip() for line in t.split("\n")).strip()
|
||||
return nfc(t)
|
||||
|
||||
def iter_md_files(root: str):
|
||||
for base, _dirs, files in os.walk(root):
|
||||
for fn in files:
|
||||
ext = os.path.splitext(fn)[1].lower()
|
||||
if ext in MD_EXTS:
|
||||
yield os.path.join(base, fn)
|
||||
|
||||
def key_from(front: Dict[str, Any], path: str, pref: str) -> str:
|
||||
"""
|
||||
Liefert den Vergleichsschlüssel.
|
||||
pref in {"auto","id","title","filename"}
|
||||
"""
|
||||
if pref == "id":
|
||||
return nfc(str(front.get("id", "")).strip())
|
||||
if pref == "title":
|
||||
return nfc(str(front.get("title", "")).strip())
|
||||
if pref == "filename":
|
||||
name = os.path.splitext(os.path.basename(path))[0]
|
||||
return nfc(name.strip())
|
||||
|
||||
# auto: id > title > filename
|
||||
if "id" in front and str(front["id"]).strip():
|
||||
return nfc(str(front["id"]).strip())
|
||||
if "title" in front and str(front["title"]).strip():
|
||||
return nfc(str(front["title"]).strip())
|
||||
name = os.path.splitext(os.path.basename(path))[0]
|
||||
return nfc(name.strip())
|
||||
|
||||
def load_index(root: str, key_pref: str) -> Dict[str, Tuple[str, Dict[str, Any], str]]:
|
||||
"""
|
||||
Baut ein Index-Dict: key -> (path, frontmatter, body)
|
||||
"""
|
||||
idx: Dict[str, Tuple[str, Dict[str, Any], str]] = {}
|
||||
for p in iter_md_files(root):
|
||||
try:
|
||||
fm, body = read_markdown(p)
|
||||
k = key_from(fm or {}, p, key_pref)
|
||||
if not k:
|
||||
# Fallback: filename
|
||||
k = key_from({}, p, "filename")
|
||||
idx[k] = (p, fm or {}, body or "")
|
||||
except Exception as e:
|
||||
# Datei nicht parsebar -> trotzdem indexieren nach Dateiname (leer FM/Body)
|
||||
k = key_from({}, p, key_pref if key_pref != "auto" else "filename")
|
||||
idx[k] = (p, {}, "")
|
||||
return idx
|
||||
|
||||
def compare_entries(src: Tuple[str, Dict[str, Any], str],
|
||||
dst: Tuple[str, Dict[str, Any], str],
|
||||
focus: str) -> Dict[str, Any]:
|
||||
sp, sfm, sbody = src
|
||||
dp, dfm, dbody = dst
|
||||
|
||||
res = {"status": "ok"} # wird 'diff' falls Unterschiede
|
||||
diffs = {}
|
||||
|
||||
if focus in ("frontmatter", "all"):
|
||||
# Vergleiche FM minimal: id und title
|
||||
s_id = nfc(str(sfm.get("id", "")).strip())
|
||||
d_id = nfc(str(dfm.get("id", "")).strip())
|
||||
s_title = nfc(str(sfm.get("title", "")).strip())
|
||||
d_title = nfc(str(dfm.get("title", "")).strip())
|
||||
if s_id != d_id:
|
||||
diffs["frontmatter.id"] = {"src": s_id, "dst": d_id}
|
||||
if s_title != d_title:
|
||||
diffs["frontmatter.title"] = {"src": s_title, "dst": d_title}
|
||||
|
||||
if focus in ("body", "all"):
|
||||
if norm_text(sbody) != norm_text(dbody):
|
||||
diffs["body"] = {"src_len": len(sbody or ""), "dst_len": len(dbody or "")}
|
||||
|
||||
if diffs:
|
||||
res["status"] = "diff"
|
||||
res["diffs"] = diffs
|
||||
res["src_path"] = sp
|
||||
res["dst_path"] = dp
|
||||
return res
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--src", required=True, help="Quell-Vault-Ordner")
|
||||
ap.add_argument("--dst", required=True, help="Export-Vault-Ordner")
|
||||
ap.add_argument("--focus", choices=["body", "frontmatter", "all"], default="body")
|
||||
ap.add_argument("--key", choices=["auto", "id", "title", "filename"], default="auto",
|
||||
help="Vergleichsschlüssel (default: auto=id>title>filename)")
|
||||
args = ap.parse_args()
|
||||
|
||||
src_idx = load_index(args.src, args.key)
|
||||
dst_idx = load_index(args.dst, args.key)
|
||||
|
||||
src_keys = set(src_idx.keys())
|
||||
dst_keys = set(dst_idx.keys())
|
||||
|
||||
# Fehlende
|
||||
only_src = sorted(src_keys - dst_keys)
|
||||
only_dst = sorted(dst_keys - src_keys)
|
||||
|
||||
count = 0
|
||||
for k in only_src:
|
||||
print(json.dumps({"note_id": k, "status": "missing", "src": True, "dst": False}, ensure_ascii=False))
|
||||
count += 1
|
||||
for k in only_dst:
|
||||
print(json.dumps({"note_id": k, "status": "missing", "src": False, "dst": True}, ensure_ascii=False))
|
||||
count += 1
|
||||
|
||||
# Vergleiche, wo vorhanden
|
||||
diff_count = 0
|
||||
common = sorted(src_keys & dst_keys)
|
||||
for k in common:
|
||||
res = compare_entries(src_idx[k], dst_idx[k], args.focus)
|
||||
if res["status"] == "diff":
|
||||
res["note_id"] = k
|
||||
print(json.dumps(res, ensure_ascii=False))
|
||||
diff_count += 1
|
||||
|
||||
summary = {
|
||||
"summary": "OK" if (count == 0 and diff_count == 0) else "DIFFS",
|
||||
"missing_count": count,
|
||||
"diff_count": diff_count,
|
||||
"total_src": len(src_keys),
|
||||
"total_dst": len(dst_keys),
|
||||
"focus": args.focus,
|
||||
"key": args.key,
|
||||
}
|
||||
print(json.dumps(summary, ensure_ascii=False))
|
||||
# Exit-Code für CI
|
||||
if summary["summary"] != "OK":
|
||||
# non-zero exit optional; hier 0 lassen, damit CLI-Ausgaben sichtbar bleiben
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,6 @@
|
||||
# Sorgt dafür, dass 'app' als Paket importierbar ist,
|
||||
# wenn pytest aus dem Repo-Root oder aus 'tests/' gestartet wird.
|
||||
import os, sys
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
if ROOT not in sys.path:
|
||||
sys.path.insert(0, ROOT)
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
dump_edges_payload_sample.py
|
||||
-----------------------------------
|
||||
Zeigt einige Beispiel-Payloads aus der {prefix}_edges Collection,
|
||||
um Feldnamen (edge_type, src_note_id, src_id, etc.) zu verifizieren.
|
||||
|
||||
Nutzung:
|
||||
python3 tests/dump_edges_payload_sample.py --prefix mindnet --n 10
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
from qdrant_client import QdrantClient
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": f"qdrant-client not installed: {e}"}))
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
import argparse
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", default=os.environ.get("COLLECTION_PREFIX") or os.environ.get("MINDNET_PREFIX") or "mindnet")
|
||||
ap.add_argument("--n", type=int, default=10)
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
url = os.environ.get("QDRANT_URL", "http://127.0.0.1:6333").strip()
|
||||
api_key = os.environ.get("QDRANT_API_KEY") or None
|
||||
edges = f"{args.prefix}_edges"
|
||||
|
||||
client = QdrantClient(url=url, api_key=api_key, timeout=30)
|
||||
|
||||
left = args.n
|
||||
offset = None
|
||||
while left > 0:
|
||||
limit = min(left, 256)
|
||||
pts, offset = client.scroll(
|
||||
collection_name=edges,
|
||||
scroll_filter=None,
|
||||
limit=limit,
|
||||
offset=offset,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
)
|
||||
if not pts:
|
||||
break
|
||||
for p in pts:
|
||||
print(json.dumps({"point_id": str(p.id), "payload_keys": list((p.payload or {}).keys()), "payload": p.payload}, ensure_ascii=False))
|
||||
left -= len(pts)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests/inspect_one_note.py
|
||||
Diagnose einer einzelnen Markdown-Datei (kein Upsert).
|
||||
Usage:
|
||||
python3 tests/inspect_one_note.py --path ./test_vault/30_projects/project-demo.md
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import os, sys, json, argparse
|
||||
|
||||
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
if PROJECT_ROOT not in sys.path:
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
|
||||
from app.core.parser import read_markdown, normalize_frontmatter, validate_required_frontmatter
|
||||
from app.core.chunker import assemble_chunks
|
||||
from app.core.chunk_payload import make_chunk_payloads
|
||||
try:
|
||||
from app.core.derive_edges import build_edges_for_note
|
||||
except Exception:
|
||||
from app.core.edges import build_edges_for_note # type: ignore
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--path", required=True)
|
||||
args = ap.parse_args()
|
||||
p = os.path.abspath(args.path)
|
||||
|
||||
try:
|
||||
parsed = read_markdown(p)
|
||||
if parsed is None:
|
||||
print(json.dumps({"path": p, "error": "read_markdown returned None"}))
|
||||
return
|
||||
except Exception as e:
|
||||
print(json.dumps({"path": p, "error": f"read_markdown failed: {type(e).__name__}: {e}"}))
|
||||
return
|
||||
|
||||
try:
|
||||
fm = normalize_frontmatter(parsed.frontmatter)
|
||||
validate_required_frontmatter(fm)
|
||||
except Exception as e:
|
||||
print(json.dumps({"path": p, "error": f"frontmatter invalid: {type(e).__name__}: {e}"}))
|
||||
return
|
||||
|
||||
body = getattr(parsed, "body", "") or ""
|
||||
chunks = assemble_chunks(fm["id"], body, fm.get("type", "concept"))
|
||||
rel_for_payload = os.path.relpath(p, os.path.join(p, "..", ".."))
|
||||
chunk_pls = make_chunk_payloads(fm, rel_for_payload, chunks, note_text=body)
|
||||
|
||||
edge_error = None
|
||||
edges_count = 0
|
||||
try:
|
||||
edges = build_edges_for_note(fm["id"], chunk_pls, include_note_scope_refs=True)
|
||||
edges_count = len(edges)
|
||||
except Exception as e:
|
||||
edge_error = f"{type(e).__name__}: {e}"
|
||||
|
||||
print(json.dumps({
|
||||
"path": p,
|
||||
"id": fm.get("id"),
|
||||
"title": fm.get("title"),
|
||||
"body_len": len(body),
|
||||
"chunks": len(chunk_pls),
|
||||
"edges": edges_count,
|
||||
"edge_error": edge_error
|
||||
}, ensure_ascii=False, indent=2))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests/list_md_seen_by_importer.py
|
||||
Zeigt, welche Markdown-Dateien der Importer sehen würde (gleiche Filter & Sortierung).
|
||||
Usage:
|
||||
python3 tests/list_md_seen_by_importer.py --vault ./test_vault
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse, os, sys, json
|
||||
|
||||
def iter_md(root: str):
|
||||
out = []
|
||||
for dirpath, _, filenames in os.walk(root):
|
||||
for fn in filenames:
|
||||
p = os.path.join(dirpath, fn)
|
||||
pn = p.replace("\\", "/")
|
||||
item = {
|
||||
"path": os.path.abspath(p),
|
||||
"rel": os.path.relpath(p, root).replace("\\", "/"),
|
||||
"included": False,
|
||||
"reason": "",
|
||||
}
|
||||
if not fn.lower().endswith(".md"):
|
||||
item["reason"] = "skip_ext"
|
||||
elif "/.obsidian/" in pn or "/_backup_frontmatter/" in pn or "/_imported/" in pn:
|
||||
item["reason"] = "skip_special_dir"
|
||||
else:
|
||||
item["included"] = True
|
||||
item["reason"] = "ok"
|
||||
out.append(item)
|
||||
# auch die ausgeschlossenen zeigen:
|
||||
if not item["included"]:
|
||||
print(json.dumps(item, ensure_ascii=False))
|
||||
out_sorted = sorted(out, key=lambda x: x["rel"])
|
||||
for i, it in enumerate(out_sorted):
|
||||
it["order"] = i
|
||||
print(json.dumps(it, ensure_ascii=False))
|
||||
print(json.dumps({"summary":"done","included":len(out_sorted)}, ensure_ascii=False))
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--vault", required=True)
|
||||
args = ap.parse_args()
|
||||
root = os.path.abspath(args.vault)
|
||||
iter_md(root)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# tests/run_e2e_roundtrip.sh
|
||||
# End-to-End Testpipeline für mindnet WP-03
|
||||
#
|
||||
# Schritte:
|
||||
# 1) Qdrant truncate (Prefix!)
|
||||
# 2) Import (Apply + Purge) => Create-Fall
|
||||
# 3) Import (Apply - ohne Änderungen) => Idempotenz
|
||||
# 4) Hash-Reporter (Fehlende Hash-Varianten)
|
||||
# 5) Export nach _exportVault
|
||||
# 6) Vergleich Vault vs. Export (Body-Fokus)
|
||||
# 7) Sync-Deletes: Eine Datei temporär „entfernen“, Dry-Run + Apply, dann zurückrollen
|
||||
#
|
||||
# Aufrufe:
|
||||
# ./tests/run_e2e_roundtrip.sh [--vault ./test_vault] [--prefix mindnet]
|
||||
#
|
||||
# ENV:
|
||||
# COLLECTION_PREFIX (Default mindnet)
|
||||
|
||||
VAULT="./test_vault"
|
||||
PREFIX="${COLLECTION_PREFIX:-mindnet}"
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--vault) VAULT="$2"; shift 2;;
|
||||
--prefix) PREFIX="$2"; shift 2;;
|
||||
*) echo "Unbekannte Option: $1" >&2; exit 2;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "== E2E Roundtrip =="
|
||||
echo "Vault: $VAULT"
|
||||
echo "Prefix: $PREFIX"
|
||||
echo
|
||||
|
||||
export COLLECTION_PREFIX="$PREFIX"
|
||||
|
||||
echo "-- 1) Qdrant truncate"
|
||||
python3 -m scripts.reset_qdrant --mode truncate --prefix "$PREFIX"
|
||||
python3 -m scripts.debug_qdrant_state --prefix "$PREFIX"
|
||||
echo
|
||||
|
||||
echo "-- 2) Import (Create-Fall)"
|
||||
python3 -m scripts.import_markdown --vault "$VAULT" --apply --purge-before-upsert --prefix "$PREFIX"
|
||||
python3 -m scripts.debug_qdrant_state --prefix "$PREFIX"
|
||||
echo
|
||||
|
||||
echo "-- 3) Import (Idempotenz: keine Änderungen erwartet)"
|
||||
python3 -m scripts.import_markdown --vault "$VAULT" --apply --prefix "$PREFIX"
|
||||
python3 -m scripts.debug_qdrant_state --prefix "$PREFIX"
|
||||
echo
|
||||
|
||||
echo "-- 4) Hash-Reporter"
|
||||
python3 -m scripts.report_hashes --prefix "$PREFIX" || true
|
||||
echo
|
||||
|
||||
echo "-- 5) Export nach _exportVault"
|
||||
OUT_DIR="_exportVault"
|
||||
rm -rf "$OUT_DIR"
|
||||
python3 -m scripts.export_markdown --out "$OUT_DIR" --prefix "$PREFIX"
|
||||
echo
|
||||
|
||||
echo "-- 6) Vergleich Vault vs. Export (Body-Fokus)"
|
||||
python3 tests/compare_vaults.py --src "$VAULT" --dst "$OUT_DIR" --focus body
|
||||
echo
|
||||
|
||||
echo "-- 7) Sync-Deletes (simuliert)"
|
||||
# wähle eine Datei und verschiebe sie temporär weg
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
SAMPLE_MD="$(find "$VAULT" -type f -name '*.md' | head -n 1 || true)"
|
||||
if [[ -n "${SAMPLE_MD:-}" ]]; then
|
||||
mv "$SAMPLE_MD" "$TMP_DIR/"
|
||||
echo "Temporär entfernt: $(basename "$SAMPLE_MD")"
|
||||
|
||||
echo " 7a) Dry-Run"
|
||||
python3 -m scripts.import_markdown --vault "$VAULT" --sync-deletes --prefix "$PREFIX"
|
||||
echo " 7b) Apply"
|
||||
python3 -m scripts.import_markdown --vault "$VAULT" --sync-deletes --apply --prefix "$PREFIX"
|
||||
|
||||
# zurückrollen
|
||||
mv "$TMP_DIR/$(basename "$SAMPLE_MD")" "$SAMPLE_MD"
|
||||
rm -rf "$TMP_DIR"
|
||||
|
||||
echo " 7c) Re-Import (wieder anlegen)"
|
||||
python3 -m scripts.import_markdown --vault "$VAULT" --apply --prefix "$PREFIX"
|
||||
python3 -m scripts.debug_qdrant_state --prefix "$PREFIX"
|
||||
else
|
||||
echo "Hinweis: Keine MD-Datei im Vault gefunden – Sync-Deletes übersprungen."
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "== E2E Roundtrip abgeschlossen =="
|
||||
@@ -0,0 +1,20 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from app.main import create_app
|
||||
import app.core.graph_adapter as ga
|
||||
|
||||
def _fake_get_edges_for_sources(client, prefix, source_ids, edge_types=None, limit=2048):
|
||||
note_id = source_ids[0]
|
||||
return [
|
||||
{"source_id":note_id,"target_id":f"{note_id}#c1","kind":"references","weight":0.2},
|
||||
{"source_id":note_id,"target_id":f"{note_id}#c2","kind":"belongs_to","weight":0.1},
|
||||
]
|
||||
|
||||
def test_graph_neighbors(monkeypatch):
|
||||
monkeypatch.setattr(ga, "get_edges_for_sources", _fake_get_edges_for_sources, raising=False)
|
||||
app = create_app()
|
||||
with TestClient(app) as c:
|
||||
r = c.get("/graph/TEST-NOTE?depth=1")
|
||||
assert r.status_code == 200
|
||||
g = r.json()
|
||||
assert g["center_note_id"] == "TEST-NOTE"
|
||||
assert g["stats"]["edge_count"] == 2
|
||||
@@ -0,0 +1,11 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from app.main import create_app
|
||||
|
||||
def test_healthz_ok():
|
||||
app = create_app()
|
||||
with TestClient(app) as c:
|
||||
r = c.get("/healthz")
|
||||
assert r.status_code == 200
|
||||
body = r.json()
|
||||
assert body["status"] == "ok"
|
||||
assert "qdrant" in body and "prefix" in body
|
||||
@@ -0,0 +1,105 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# tests/test_importer_detect_changes.sh
|
||||
# Prüft Änderungserkennung:
|
||||
# - Body-Change -> wird erkannt bei hash-mode=body
|
||||
# - Frontmatter-Change -> wird NICHT erkannt bei hash-mode=body
|
||||
# - Frontmatter-Change -> wird erkannt bei hash-mode=frontmatter (bzw. MINDNET_HASH_COMPARE=Frontmatter)
|
||||
#
|
||||
# Aufruf:
|
||||
# ./tests/test_importer_detect_changes.sh [--vault ./test_vault] [--prefix mindnet] [--note-id concept-alpha]
|
||||
|
||||
VAULT="./test_vault"
|
||||
PREFIX="${COLLECTION_PREFIX:-mindnet}"
|
||||
NOTE_ID="concept-alpha"
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--vault) VAULT="$2"; shift 2;;
|
||||
--prefix) PREFIX="$2"; shift 2;;
|
||||
--note-id) NOTE_ID="$2"; shift 2;;
|
||||
*) echo "Unbekannte Option: $1" >&2; exit 2;;
|
||||
esac
|
||||
done
|
||||
export COLLECTION_PREFIX="$PREFIX"
|
||||
|
||||
# Hilfsfunktion: lese Pfad zur Note aus Frontmatter id:
|
||||
PYFIND=$(cat <<'PY'
|
||||
import sys, os, glob, yaml
|
||||
vault = sys.argv[1]
|
||||
nid = sys.argv[2]
|
||||
for p in glob.glob(os.path.join(vault, "**", "*.md"), recursive=True):
|
||||
with open(p, "r", encoding="utf-8") as f:
|
||||
s = f.read()
|
||||
if s.startswith("---"):
|
||||
try:
|
||||
fm_txt, body = s.split("\n---\n", 1)
|
||||
fm = yaml.safe_load(fm_txt.strip("- \n")) or {}
|
||||
except Exception:
|
||||
continue
|
||||
if fm.get("id") == nid:
|
||||
print(p)
|
||||
break
|
||||
PY
|
||||
)
|
||||
NOTE_PATH=$(python3 -c "$PYFIND" "$VAULT" "$NOTE_ID")
|
||||
if [[ -z "${NOTE_PATH:-}" ]]; then
|
||||
echo "Note mit id=$NOTE_ID nicht gefunden im Vault=$VAULT" >&2
|
||||
exit 3
|
||||
fi
|
||||
echo "Note: $NOTE_PATH"
|
||||
|
||||
# Backup
|
||||
ORIG="$(mktemp)"
|
||||
cp "$NOTE_PATH" "$ORIG"
|
||||
|
||||
cleanup() {
|
||||
cp "$ORIG" "$NOTE_PATH" || true
|
||||
rm -f "$ORIG"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Ausgangszustand importieren (Baseline)
|
||||
python3 -m scripts.import_markdown --vault "$VAULT" --apply --prefix "$PREFIX" >/dev/null
|
||||
|
||||
echo "-- Test A: Body-Änderung soll erkannt werden (hash-mode=body)"
|
||||
# Body um eine Zeile erweitern
|
||||
python3 - "$NOTE_PATH" <<'PY'
|
||||
import sys
|
||||
p=sys.argv[1]
|
||||
with open(p,"r+",encoding="utf-8") as f:
|
||||
s=f.read()
|
||||
if s.startswith("---"):
|
||||
fm, body = s.split("\n---\n",1)
|
||||
body = body + "\n\nBodyTest: Änderung A"
|
||||
f.seek(0); f.truncate(); f.write(fm+"\n---\n"+body)
|
||||
PY
|
||||
OUT=$(python3 -m scripts.import_markdown --vault "$VAULT" --prefix "$PREFIX" | grep "\"note_id\": \"$NOTE_ID\"" || true)
|
||||
echo "$OUT"
|
||||
echo "$OUT" | grep -q '"changed": true' || { echo "ERWARTET: changed=true (Body) — FEHLER"; exit 4; }
|
||||
|
||||
echo "-- Test B: Frontmatter-Änderung soll NICHT erkannt werden bei mode=body"
|
||||
# Frontmatter-Feld hinzufügen
|
||||
python3 - "$NOTE_PATH" <<'PY'
|
||||
import sys, yaml, io
|
||||
p=sys.argv[1]
|
||||
with open(p,"r+",encoding="utf-8") as f:
|
||||
s=f.read()
|
||||
if s.startswith("---"):
|
||||
fm_txt, body = s.split("\n---\n",1)
|
||||
fm = yaml.safe_load(fm_txt.strip("- \n")) or {}
|
||||
fm["test_flag"] = True
|
||||
buf = io.StringIO()
|
||||
yaml.safe_dump(fm, buf, allow_unicode=True, sort_keys=False)
|
||||
f.seek(0); f.truncate(); f.write("---\n"+buf.getvalue()+"---\n"+body)
|
||||
PY
|
||||
OUT=$(python3 -m scripts.import_markdown --vault "$VAULT" --prefix "$PREFIX" | grep "\"note_id\": \"$NOTE_ID\"" || true)
|
||||
echo "$OUT"
|
||||
echo "$OUT" | grep -q '"changed": false' || { echo "ERWARTET: changed=false (FM bei mode=body) — FEHLER"; exit 5; }
|
||||
|
||||
echo "-- Test C: Frontmatter-Änderung soll erkannt werden bei mode=frontmatter"
|
||||
OUT=$(MINDNET_HASH_COMPARE=Frontmatter python3 -m scripts.import_markdown --vault "$VAULT" --prefix "$PREFIX" | grep "\"note_id\": \"$NOTE_ID\"" || true)
|
||||
echo "$OUT"
|
||||
echo "$OUT" | grep -q '"changed": true' || { echo "ERWARTET: changed=true (FM bei mode=frontmatter) — FEHLER"; exit 6; }
|
||||
|
||||
echo "✔ Änderungserkennung: OK"
|
||||
@@ -0,0 +1,39 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from app.main import create_app
|
||||
import app.services.embeddings_client as ec
|
||||
import app.core.qdrant_points as qp
|
||||
import app.core.graph_adapter as ga
|
||||
|
||||
def _fake_embed_text(text: str):
|
||||
# Liefert stabilen 384-d Vektor ohne echtes Modell
|
||||
return [0.01] * 384
|
||||
|
||||
def _fake_search_chunks_by_vector(client, prefix, vector, top=10, filters=None):
|
||||
# einfache Hitliste
|
||||
return [
|
||||
("chunk:1", 0.9, {"note_id":"note:1","path":"a.md","section_title":"S1"}),
|
||||
("chunk:2", 0.7, {"note_id":"note:2","path":"b.md","section_title":"S2"}),
|
||||
("chunk:3", 0.5, {"note_id":"note:3","path":"c.md","section_title":"S3"}),
|
||||
]
|
||||
|
||||
def _fake_get_edges_for_sources(client, prefix, source_ids, edge_types=None, limit=2048):
|
||||
out=[]
|
||||
for sid in source_ids:
|
||||
out.append({"source_id":sid,"target_id":f"{sid}-x","kind":"references","weight":0.2})
|
||||
return out
|
||||
|
||||
def test_query_with_text(monkeypatch):
|
||||
# Patch Embedding + Qdrant-Aufrufe
|
||||
monkeypatch.setattr(ec, "embed_text", _fake_embed_text)
|
||||
monkeypatch.setattr(qp, "search_chunks_by_vector", _fake_search_chunks_by_vector)
|
||||
monkeypatch.setattr(ga, "get_edges_for_sources", _fake_get_edges_for_sources, raising=False)
|
||||
|
||||
app = create_app()
|
||||
with TestClient(app) as c:
|
||||
payload = {"mode":"hybrid","query":"karate trainingsplan", "top_k":2,
|
||||
"expand":{"depth":1,"edge_types":["references"]}}
|
||||
r = c.post("/query", json=payload)
|
||||
assert r.status_code == 200, r.text
|
||||
body = r.json()
|
||||
assert body["used_mode"] == "hybrid"
|
||||
assert len(body["results"]) == 2
|
||||
@@ -0,0 +1,38 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from app.main import create_app
|
||||
import app.core.qdrant_points as qp
|
||||
import app.core.graph_adapter as ga
|
||||
|
||||
def _fake_search_chunks_by_vector(client, prefix, vector, top=10, filters=None):
|
||||
return [
|
||||
("chunk:1", 0.8, {"note_id":"note:1","path":"a.md","section_title":"S1"}),
|
||||
("chunk:2", 0.6, {"note_id":"note:2","path":"b.md","section_title":"S2"}),
|
||||
("chunk:3", 0.4, {"note_id":"note:3","path":"c.md","section_title":"S3"}),
|
||||
]
|
||||
|
||||
def _fake_get_edges_for_sources(client, prefix, source_ids, edge_types=None, limit=2048):
|
||||
# Erzeuge ein paar Edges von den Seeds weg
|
||||
out=[]
|
||||
for sid in source_ids:
|
||||
out.append({"source_id":sid,"target_id":f"{sid}->n1","kind":"references","weight":0.2})
|
||||
out.append({"source_id":sid,"target_id":f"{sid}->n2","kind":"belongs_to","weight":0.1})
|
||||
return out
|
||||
|
||||
def test_query_hybrid_with_monkeypatch(monkeypatch):
|
||||
monkeypatch.setattr(qp, "search_chunks_by_vector", _fake_search_chunks_by_vector)
|
||||
monkeypatch.setattr(qp, "get_edges_for_sources", _fake_get_edges_for_sources) # falls indirekt genutzt
|
||||
# graph_adapter.expand ruft get_edges_for_sources via qp; wir patchen direkt dort:
|
||||
monkeypatch.setattr(ga, "get_edges_for_sources", _fake_get_edges_for_sources, raising=False)
|
||||
|
||||
app = create_app()
|
||||
with TestClient(app) as c:
|
||||
payload = {"mode":"hybrid","query_vector":[0.0]*384,"top_k":2,
|
||||
"expand":{"depth":1,"edge_types":["references","belongs_to"]}}
|
||||
r = c.post("/query", json=payload)
|
||||
assert r.status_code == 200, r.text
|
||||
data = r.json()
|
||||
assert data["used_mode"] == "hybrid"
|
||||
assert len(data["results"]) == 2
|
||||
# Scores absteigend
|
||||
tots = [h["total_score"] for h in data["results"]]
|
||||
assert tots[0] >= tots[1]
|
||||
@@ -0,0 +1,13 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from app.main import create_app
|
||||
|
||||
def test_tools_ollama_schema():
|
||||
app = create_app()
|
||||
with TestClient(app) as c:
|
||||
r = c.get("/tools/ollama")
|
||||
assert r.status_code == 200
|
||||
data = r.json()
|
||||
assert "tools" in data and isinstance(data["tools"], list)
|
||||
names = [t["function"]["name"] for t in data["tools"] if t.get("function")]
|
||||
assert "mindnet_query" in names
|
||||
assert "mindnet_subgraph" in names
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os, tempfile, textwrap
|
||||
from app.core.type_registry import load_type_registry, resolve_note_type, get_type_config, effective_chunk_profile, profile_overlap
|
||||
|
||||
def test_defaults_when_missing():
|
||||
# ensure default kicks in if file does not exist
|
||||
reg = load_type_registry(os.path.join("config", "does_not_exist.yaml"))
|
||||
assert reg.get("_using_defaults", False) is True
|
||||
t = resolve_note_type(None, reg)
|
||||
assert t == "concept"
|
||||
cfg = get_type_config(t, reg)
|
||||
assert cfg.get("chunk_profile") in ("medium", "long", "short")
|
||||
|
||||
def test_custom_file():
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
p = os.path.join(td, "types.yaml")
|
||||
with open(p, "w", encoding="utf-8") as f:
|
||||
f.write(textwrap.dedent('''
|
||||
version: 1.0
|
||||
types:
|
||||
concept:
|
||||
chunk_profile: medium
|
||||
edge_defaults: ["references"]
|
||||
retriever_weight: 1.0
|
||||
task:
|
||||
chunk_profile: short
|
||||
edge_defaults: ["depends_on"]
|
||||
retriever_weight: 0.8
|
||||
'''))
|
||||
reg = load_type_registry(p)
|
||||
assert resolve_note_type("task", reg) == "task"
|
||||
assert effective_chunk_profile("task", reg) == "short"
|
||||
assert profile_overlap("short")[0] < profile_overlap("long")[0]
|
||||
@@ -0,0 +1,193 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Script: tests/verify_chunks_integrity.py
|
||||
Version: 1.0.1
|
||||
Datum: 2025-09-10
|
||||
|
||||
Zweck
|
||||
-----
|
||||
Verifiziert die Text-Integrität der gespeicherten Chunks:
|
||||
1) Rekonstruiert den Body aus den Chunks (Sortierung: seq → chunk_index → # in chunk_id).
|
||||
2) Vergleicht mit dem in Qdrant gespeicherten Note-`fulltext` (falls vorhanden).
|
||||
3) Optional: Vergleicht zusätzlich mit dem Body der zugehörigen Markdown-Datei im Vault.
|
||||
|
||||
Aufrufe
|
||||
-------
|
||||
# Nur gegen Qdrant (fulltext vs. Chunks)
|
||||
python3 tests/verify_chunks_integrity.py --prefix mindnet
|
||||
|
||||
# Zusätzlich gegen den Vault abgleichen (Body der .md-Datei)
|
||||
python3 tests/verify_chunks_integrity.py --prefix mindnet --vault ./test_vault
|
||||
|
||||
# Streng + CI-geeignet (Fehlercode bei Abweichungen):
|
||||
python3 tests/verify_chunks_integrity.py --prefix mindnet --vault ./test_vault --strict --fail-on-mismatch
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
# --- FIX: Projekt-Root in sys.path aufnehmen, damit 'app.*' importierbar ist ---
|
||||
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
if PROJECT_ROOT not in sys.path:
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
|
||||
import yaml
|
||||
from qdrant_client.http import models as rest
|
||||
|
||||
from app.core.qdrant import QdrantConfig, get_client
|
||||
|
||||
# --------------------------- Helpers ---------------------------
|
||||
|
||||
def collections(prefix: str) -> Tuple[str, str, str]:
|
||||
return f"{prefix}_notes", f"{prefix}_chunks", f"{prefix}_edges"
|
||||
|
||||
def scroll_all(client, collection: str, flt: Optional[rest.Filter] = None, limit: int = 256) -> List[Any]:
|
||||
out: List[Any] = []
|
||||
nextp = None
|
||||
while True:
|
||||
pts, nextp = client.scroll(
|
||||
collection_name=collection,
|
||||
with_payload=True,
|
||||
with_vectors=False,
|
||||
limit=limit,
|
||||
offset=nextp,
|
||||
scroll_filter=flt,
|
||||
)
|
||||
if not pts:
|
||||
break
|
||||
out.extend(pts)
|
||||
if nextp is None:
|
||||
break
|
||||
return out
|
||||
|
||||
def sort_key_for_chunk_payload(pl: Dict[str, Any]) -> Tuple[int, int, int]:
|
||||
s = pl.get("seq") or 0
|
||||
ci = pl.get("chunk_index") or 0
|
||||
n = 0
|
||||
cid = pl.get("chunk_id") or ""
|
||||
if isinstance(cid, str) and "#" in cid:
|
||||
try:
|
||||
n = int(cid.rsplit("#", 1)[-1])
|
||||
except Exception:
|
||||
n = 0
|
||||
return (int(s), int(ci), int(n))
|
||||
|
||||
def reconstruct_from_chunks(chunks_points: List[Any]) -> Tuple[str, int, int]:
|
||||
"""Gibt (text, total_chunks, chunks_with_text) zurück."""
|
||||
chunks_sorted = sorted(chunks_points, key=lambda p: sort_key_for_chunk_payload(p.payload or {}))
|
||||
texts: List[str] = []
|
||||
have = 0
|
||||
for p in chunks_sorted:
|
||||
pl = p.payload or {}
|
||||
t = pl.get("text") or pl.get("content") or pl.get("raw") or ""
|
||||
if isinstance(t, str) and t:
|
||||
have += 1
|
||||
texts.append(t)
|
||||
return ("\n".join(texts).strip(), len(chunks_sorted), have)
|
||||
|
||||
def normalize(s: str, strict: bool = False) -> str:
|
||||
if s is None:
|
||||
return ""
|
||||
s = s.replace("\r\n", "\n").replace("\r", "\n")
|
||||
if strict:
|
||||
return s
|
||||
lines = [ln.rstrip() for ln in s.strip().split("\n")]
|
||||
return "\n".join(lines).strip()
|
||||
|
||||
def read_vault_body(vault_root: str, rel_path: str) -> Optional[str]:
|
||||
if not rel_path:
|
||||
return None
|
||||
p = os.path.join(vault_root, rel_path.replace("\\", "/").lstrip("/"))
|
||||
if not os.path.exists(p):
|
||||
return None
|
||||
with open(p, "r", encoding="utf-8") as f:
|
||||
s = f.read()
|
||||
if s.startswith("---"):
|
||||
try:
|
||||
fm_txt, body = s.split("\n---\n", 1)
|
||||
except Exception:
|
||||
return s
|
||||
else:
|
||||
body = s
|
||||
return body
|
||||
|
||||
# --------------------------- Main ------------------------------
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", help="Collection-Prefix (überschreibt ENV COLLECTION_PREFIX)")
|
||||
ap.add_argument("--vault", help="Optional: Vault-Wurzelordner für Abgleich gegen .md")
|
||||
ap.add_argument("--strict", action="store_true", help="Strikter Vergleich (kein Trimmen/Normalisieren)")
|
||||
ap.add_argument("--fail-on-mismatch", action="store_true", help="Exit 1, wenn ein Mismatch gefunden wurde")
|
||||
args = ap.parse_args()
|
||||
|
||||
cfg = QdrantConfig.from_env()
|
||||
if args.prefix:
|
||||
cfg.prefix = args.prefix.strip()
|
||||
client = get_client(cfg)
|
||||
|
||||
notes_col, chunks_col, _ = collections(cfg.prefix)
|
||||
notes = scroll_all(client, notes_col)
|
||||
|
||||
mismatches = 0
|
||||
total = 0
|
||||
|
||||
for n in notes:
|
||||
total += 1
|
||||
pl = n.payload or {}
|
||||
nid = pl.get("note_id")
|
||||
rel_path = (pl.get("path") or "").replace("\\", "/").lstrip("/")
|
||||
fulltext = (pl.get("fulltext") or "").strip()
|
||||
|
||||
flt = rest.Filter(must=[rest.FieldCondition(key="note_id", match=rest.MatchValue(value=nid))])
|
||||
chunks = scroll_all(client, chunks_col, flt)
|
||||
recon, cnt, have = reconstruct_from_chunks(chunks)
|
||||
|
||||
norm_recon = normalize(recon, strict=args.strict)
|
||||
norm_full = normalize(fulltext, strict=args.strict)
|
||||
|
||||
match_full = (bool(norm_full) and (norm_recon == norm_full))
|
||||
match_vault = None
|
||||
|
||||
issues: List[str] = []
|
||||
if cnt == 0:
|
||||
issues.append("no_chunks")
|
||||
if have < cnt:
|
||||
issues.append(f"missing_text_in_chunks:{cnt-have}/{cnt}")
|
||||
if norm_full == "":
|
||||
issues.append("note_fulltext_empty")
|
||||
if not match_full:
|
||||
issues.append("reconstructed_vs_fulltext_mismatch")
|
||||
|
||||
if args.vault:
|
||||
body = read_vault_body(args.vault, rel_path) or ""
|
||||
norm_body = normalize(body, strict=args.strict)
|
||||
match_vault = (norm_body == norm_recon)
|
||||
if not match_vault:
|
||||
issues.append("reconstructed_vs_vault_body_mismatch")
|
||||
|
||||
obj = {
|
||||
"note_id": nid,
|
||||
"path": rel_path,
|
||||
"chunks_count": cnt,
|
||||
"chunks_with_text": have,
|
||||
"match_fulltext": match_full,
|
||||
"match_vault": match_vault,
|
||||
"issues": issues,
|
||||
}
|
||||
print(json.dumps(obj, ensure_ascii=False))
|
||||
if ("reconstructed_vs_fulltext_mismatch" in issues) or ("reconstructed_vs_vault_body_mismatch" in issues):
|
||||
mismatches += 1
|
||||
|
||||
summary = {"summary": "OK" if mismatches == 0 else "DIFFS", "mismatch_count": mismatches, "notes": total}
|
||||
print(json.dumps(summary, ensure_ascii=False))
|
||||
if args.fail_on_mismatch and mismatches:
|
||||
raise SystemExit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: Freund – November-Fahrplan (30 Tage)
|
||||
id: freund-kanal-30tage-nov2025
|
||||
type: project
|
||||
status: active
|
||||
created: 2025-10-31
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [friend/new-circle, planning]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
depends_on:
|
||||
- freund-kanal-gewaltschutz-nov2025
|
||||
- freund-kanal-tanzen-nov2025
|
||||
---
|
||||
|
||||
# Kalender & Cadence
|
||||
- **KW45 (Nov W1):** Gewaltschutz-Termin & Tanz-Slot festlegen; Einladungen verschicken.
|
||||
- **KW46 (W2):** Infoabend Gewaltschutz #1 · Practice Night Tanz #1.
|
||||
- **KW47 (W3):** Practice Night #2 · 4–6 **1:1-Gespräche**.
|
||||
- **KW48 (W4):** Follow-ups & Retro; Dezember-Slots bestätigen.
|
||||
|
||||
# Minimal-Tracker (CSV)
|
||||
date,event,type,people,new_contacts,1on1_scheduled,notes
|
||||
@@ -0,0 +1,119 @@
|
||||
---
|
||||
title: Freund – Kanal 1: Gewaltschutz **Mini-Kurs** (Nov 2025)
|
||||
id: freund-kanal-gewaltschutz-minikurs-nov2025
|
||||
type: project
|
||||
status: active
|
||||
created: 2025-10-31
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [friend/new-circle, gewaltschutz, community, workshop, mini-course]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
depends_on:
|
||||
- leitbild-ziele-portfolio
|
||||
- leitbild-rollen
|
||||
- freund-kanal-30tage-nov2025
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
---
|
||||
|
||||
# Ziel & Zielgruppe
|
||||
- **Ziel:** Über einen **nüchternen**, wertschätzenden **Mini-Kurs** (3×90′) neue Kontakte **auf Augenhöhe** gewinnen – für gute Gespräche, gemeinsame Werte und Anschluss an deinen neuen Freundeskreis (ohne Alkoholmilieu).
|
||||
- **Zielgruppe (primär):** Erwachsene (Eltern, Lehrkräfte, Interessierte, **18+**).
|
||||
*Optional (separat ankündigen):* Eltern+Teen (16–17) – sensibel, ohne Rollenspiele mit Übergriffigkeitsinhalten.
|
||||
|
||||
# Format (3×90′)
|
||||
- **S1 – Bewusst & klar (Awareness & Haltung)**
|
||||
*Outcome:* Teilnehmende können Situationen besser **lesen**, **Grenzen** spüren/zeigen und **klar ansprechen**.
|
||||
**Ablauf:**
|
||||
1) Warm-in & Werte (5′) – „Prävention ohne Angst“
|
||||
2) Wahrnehmung & Distanz (20′) – Raum, Blick, Stimme
|
||||
3) Grenzen setzen (20′) – „Stopp“, Körpersprache, Ich-Botschaft
|
||||
4) Mini-Drills (30′) – Alltagsmikros: ÖPNV, Flur, Parkplatz (ohne Körperkontakt)
|
||||
5) Reflexion & Transfer (15′) – persönlicher Boundary-Satz, Heimübung
|
||||
|
||||
- **S2 – Deeskalation & Ausstiege (Verbal & taktisch)**
|
||||
*Outcome:* Teilnehmende **reduzieren Eskalation**, nutzen **sichere Ausstiege** und holen Hilfe.
|
||||
**Ablauf:**
|
||||
1) Kurzreview S1 (10′)
|
||||
2) Deeskalationsleitfaden (25′) – Ton, Tempo, Wörter
|
||||
3) Ausstiegsmuster (30′) – Positionswechsel, Tür-/Tresen-Taktik, „Buddy-Call“
|
||||
4) Bystander-Optionen (15′) – sicher intervenieren
|
||||
5) Plan A/B/C (10′) – persönlicher Ausstiegsplan
|
||||
|
||||
- **S3 – Alltag festigen (Routine & Netz)**
|
||||
*Outcome:* Teilnehmende **verankern Routinen**, kennen **Fallbacks** und haben **nächste Schritte** (auch sozial).
|
||||
**Ablauf:**
|
||||
1) Warm-in & Qs (10′)
|
||||
2) Alltagsszenarien (30′) – Feier/ÖPNV/Arbeit *ohne* Alkoholfokus
|
||||
3) Ritual & Check (25′) – „Wenn-dann“-Pläne, Buddy-System, Notfallkontakte
|
||||
4) Mikro-Netz (15′) – Einladungen zu **Walk & Talk**, **Buch/Essay-Abend**, **Tanzen**
|
||||
5) Abschluss & Feedback (10′)
|
||||
|
||||
# Einladung (Kurztext, Copy-Paste)
|
||||
**Gewaltschutz – Mini-Kurs (3×90′, alkoholfrei)**
|
||||
Prävention ohne Angst: klare Grenzen, Deeskalation, sichere Ausstiege – alltagstauglich.
|
||||
**Wann:** [Mi, 19:00–20:30 an: 12.11., 19.11., 26.11.] **/ Ort:** [Dojo/Vereinsraum, Adresse]
|
||||
**Plätze:** max. 14 · **Kosten:** kostenlos
|
||||
**Getränke:** Tee/Wasser (alkoholfrei)
|
||||
**Anmeldung:** [E-Mail/Link] – kurze Nachricht reicht.
|
||||
Ich freue mich auf gute Gespräche & ein starkes Netz. – Lars
|
||||
|
||||
# Orga & Material
|
||||
- Raum: Stühle im Halbkreis, ggf. Matten (nicht nötig), gute Akustik; Schild „alkoholfrei“.
|
||||
- Ausstattung: Flipchart/Marker, Timer, Wasser/Tee, **Feedback-Mini-Karte (3 Fragen)**, Teilnehmerliste.
|
||||
- Sicherheit: **keine** aggressiven Rollenspiele; **kein** körperlicher Zwang; Inhalte trauma-sensibel; Notfallnummern sichtbar.
|
||||
|
||||
# Messung (verknüpft mit Nordstern „Freund – Neuaufbau“)
|
||||
- **Leading:** ≥ **12 Anmeldungen**, **≥10** Teilnehmende gesamt, **≥6** 1:1-Folgetermine in 14 Tagen, **≥1** Mikro-Event-Einladung angenommen.
|
||||
- **Lagging:** **≥2** neue starke Bindungen bis Jan 2026.
|
||||
|
||||
# Follow-up (≤48 h nach jedem Termin)
|
||||
- Dankesmail + 1-Pager (3 Kernhebel)
|
||||
- Einladungen: **Walk & Talk**, **Buch/Essay-Abend**, **Tanzen – Practice Night**
|
||||
- 1:1-Einladungen an 2–4 passende Personen (Coffee/Walk)
|
||||
|
||||
# Checkliste (je Termin)
|
||||
- [ ] Raum vorbereitet (Schild „alkoholfrei“)
|
||||
- [ ] Teilnehmerliste / Einverständnis Foto **nein** (Standard: keine Fotos)
|
||||
- [ ] Inhalte: Folien/Flipchart-Skizzen vorbereitet
|
||||
- [ ] Wasser/Tee bereitgestellt
|
||||
- [ ] Feedback-Karten & Stifte
|
||||
- [ ] Timer, Notfallkontakte sichtbar
|
||||
|
||||
# ICS-Skelett (3 Events – Platzhalter anpassen)
|
||||
BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
PRODID:-//Lars//Gewaltschutz-Minikurs//DE
|
||||
BEGIN:VEVENT
|
||||
UID:mini1-20251112T190000Z@lars
|
||||
DTSTART:20251112T190000
|
||||
DTEND:20251112T203000
|
||||
SUMMARY:Gewaltschutz Mini-Kurs – Teil 1 (Prävention ohne Angst)
|
||||
LOCATION:[Ort/Adresse]
|
||||
DESCRIPTION:Awareness, Grenzen, Mini-Drills. Alkoholfrei.
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:mini2-20251119T190000Z@lars
|
||||
DTSTART:20251119T190000
|
||||
DTEND:20251119T203000
|
||||
SUMMARY:Gewaltschutz Mini-Kurs – Teil 2 (Deeskalation & Ausstiege)
|
||||
LOCATION:[Ort/Adresse]
|
||||
DESCRIPTION:Verbal deeskalieren, Ausstiege, Bystander-Optionen.
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:mini3-20251126T190000Z@lars
|
||||
DTSTART:20251126T190000
|
||||
DTEND:20251126T203000
|
||||
SUMMARY:Gewaltschutz Mini-Kurs – Teil 3 (Alltag festigen)
|
||||
LOCATION:[Ort/Adresse]
|
||||
DESCRIPTION:Wenn-dann-Pläne, Buddy-System, nächste Schritte.
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
|
||||
# Risiken & Guardrails
|
||||
- **Kein** „Heldentum“/Konfrontationsglorifizierung; Grenzen/Deeskalation vor „Technik“.
|
||||
- **Kein** Körperkontakt ohne explizite Zustimmung; **Abbruch-Signal** definieren.
|
||||
- **Keine** Minderjährigen ohne Begleitung (bei Eltern+Teen: separate Einladung, andere Beispiele).
|
||||
- **Familienzeit schützen:** pünktlicher Start/Schluss; Nachklang maximal 20′.
|
||||
@@ -0,0 +1,50 @@
|
||||
---
|
||||
title: Freund – Kanal 1: Gewaltschutz-Workshop (Nov 2025)
|
||||
id: freund-kanal-gewaltschutz-nov2025
|
||||
type: project
|
||||
status: active
|
||||
created: 2025-10-31
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [friend/new-circle, gewaltschutz, community, workshop]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
depends_on:
|
||||
- leitbild-ziele-portfolio
|
||||
- leitbild-rollen
|
||||
---
|
||||
|
||||
# Ziel
|
||||
Über einen **niedrigschwelligen Gewaltschutz-Impuls** neue Kontakte auf Augenhöhe knüpfen (eltern-/gemeinwohlorientiert, nüchternes Umfeld), die zu **guten Gesprächen** und **weiteren Treffen** führen.
|
||||
|
||||
# Format (wähle 1)
|
||||
- **A) Infoabend (75–90′, kostenlos)** – kurzer, starker Impuls, Q&A, Tee/Wasser.
|
||||
- **B) Mini-Kurs (3×90′, 3 Wochen)** – kleine, konstante Gruppe (max. 14), mehr Bindung.
|
||||
|
||||
# Agenda (Beispiel Infoabend 90′)
|
||||
1) Ankommen & Werte (5′) – „Warum Prävention ohne Angst“
|
||||
2) Aufmerksamkeit & Grenzen (15′) – Wahrnehmung, Stimme, Haltung
|
||||
3) Einfache Hebel (25′) – Distanz, klare Ansagen, Ausstiege
|
||||
4) Alltagsszenarien (20′) – Schule/ÖPNV/Feier (alkoholfrei)
|
||||
5) Q&A + Einladung zu weiterem Treffen (20′)
|
||||
|
||||
# Einladungstext (Kurzfassung, Copy-Paste)
|
||||
Liebe Nachbar:innen und Eltern,
|
||||
ich biete am **[Datum, Uhrzeit]** einen **kostenlosen Gewaltschutz-Infoabend (90′)** im **[Ort]** an. Es geht um **klare, alltagstaugliche Strategien** für Kinder/Jugendliche & Eltern – **ohne Angstmache, ohne Heldentum**.
|
||||
👉 Inhalte: Wahrnehmung schärfen, Grenzen setzen, einfache Ausstiege.
|
||||
Getränke: **Tee/Wasser**, **kein Alkohol**.
|
||||
**Anmeldung:** [Kontakt/Link] – max. **20 Plätze**. Ich freue mich auf gute Gespräche!
|
||||
– Lars
|
||||
|
||||
# Orga & Material
|
||||
- Raum (Matten optional), Stühle im Halbkreis, Flipchart/Marker, Timer, Haftungshinweis.
|
||||
- Teilnehmerliste, Namensschilder, Wasser/Tee, Feedback-Mini-Karte (3 Fragen).
|
||||
|
||||
# Messung (für „Freund“-Nordstern)
|
||||
- **Leading:** ≥ **12 Anmeldungen**, **10+ Teilnehmende**, **≥4** Folge-1:1s in 14 Tagen.
|
||||
- **Lagging:** **≥2** neue „starke Bindungen“ bis Jan 2026.
|
||||
|
||||
# Nachbereitung (innerh. 48 h)
|
||||
- Dankesmail + 1-Pager (3 Kernhebel) + Einladung zu **Walk & Talk / Buch-Abend**.
|
||||
- 1:1-Einladungen an 4–6 passende Kontakte (Coffee/Walk).
|
||||
@@ -0,0 +1,46 @@
|
||||
---
|
||||
title: Freund – Kanal 2: Tanzen (Nov 2025)
|
||||
id: freund-kanal-tanzen-nov2025
|
||||
type: project
|
||||
status: active
|
||||
created: 2025-10-31
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [friend/new-circle, tanzen, sport, community]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
depends_on:
|
||||
- leitbild-ziele-portfolio
|
||||
- leitbild-rollen
|
||||
---
|
||||
|
||||
# Ziel
|
||||
Über **körperliche Leichtigkeit + gute Gespräche** neue Kontakte auf Augenhöhe finden; Alkoholfreiheit, Respektkultur, klare Zeiten.
|
||||
|
||||
# Routen (wähle 1)
|
||||
- **A) Bestehenden Kurs/Community beitreten** (z. B. **Swing/Lindy Hop** oder **Tango Argentino** – kommunikationsstark, community-orientiert, häufig alkoholfrei).
|
||||
- **B) Eigene „Practice Night“ (60–90′, 1×/W)** – **Grundschritte + Balance + Musikgefühl**, offenes Ende mit Tee/Wasser.
|
||||
- **C) „Dance & Mobility“ im Dojo (Monat)** – leichter Mix aus Rhythmus, Koordination, Dehnung.
|
||||
|
||||
# Kickoff-Plan (30 Tage)
|
||||
- **W1:** Stil & Slot wählen; Raum sichern; 3-Zeiler Einladung schreiben.
|
||||
- **W2:** Startabend #1 (60–90′): Warm-up, 2–3 Basics, Partnerwechsel, 15′ Gesprächsrunde.
|
||||
- **W3:** Startabend #2; Interessentenliste pflegen; 1:1-Coffees anstoßen.
|
||||
- **W4:** Retrospektive; feste Cadence (z. B. Mi 19:00) festziehen.
|
||||
|
||||
# Einladungstext (eigene Practice Night)
|
||||
Lust auf **Tanzen ohne Druck**?
|
||||
Am **[Datum, Uhrzeit]** startet eine **kleine Practice Night (60–90′)** in **[Ort]** – **Basics, Rhythmus, Balance**, viel Lachen, **ohne Alkohol**.
|
||||
Alle Levels willkommen, Solo oder mit Partner:in.
|
||||
Bringt saubere Schuhe/Strümpfe mit. Danach kurzer Tee-Talk.
|
||||
**Anmeldung:** [Kontakt/Link] – **max. 16 Plätze**.
|
||||
– Lars
|
||||
|
||||
# Messung
|
||||
- **Leading:** **2 Startabende**, **≥12 Teilnehmende kumuliert**, **≥6** 1:1-Gespräche in 14 Tagen.
|
||||
- **Lagging:** **≥2** neue, regelmäßige Mittänzer:innen im Kernkreis bis Jan 2026.
|
||||
|
||||
# Guardrails
|
||||
- **Alkoholfrei**, respektvolle Ansprache, pünktlicher Start/Schluss (Familienzeit schützen).
|
||||
- Keine „Lehrerrolle“ übernehmen – **Facilitator-Modus**: Raum bieten, nicht dominieren.
|
||||
@@ -0,0 +1,91 @@
|
||||
---
|
||||
title: Leitbild – Start-Experiment (14 Tage · R1–R7)
|
||||
id: leitbild-start-experiment-2025-11-01
|
||||
type: project
|
||||
status: active
|
||||
created: 2025-10-31
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [experiment, rituale, NACh, tracker, review]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
depends_on:
|
||||
- leitbild-rituale-system
|
||||
- leitbild-review
|
||||
- leitbild-ziele-portfolio
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
---
|
||||
|
||||
# Zweck
|
||||
14-Tage-Testlauf, um die täglichen (R1–R3, R6), wöchentlichen (R5, R7) und 14-tägigen (R4) Rituale **unter realen Bedingungen** zu prüfen, Adhärenz zu messen und minimal zu tunen.
|
||||
|
||||
# Hypothesen
|
||||
- **H1 (Ich-Pflege):** R1/R2/R3 erhöhen Ruhe/Klarheit spürbar (Ruhe-Ø **+2** Punkte; Spannungsgefühl **−2**; Stimmung-Ø **≥7/10**).
|
||||
- **H2 (Vater):** R6 (1:1 Rohan) steigert Bindungsgefühl (Ø **+2** Punkte) und reduziert Konfliktlatenz.
|
||||
- **H3 (Partner):** R5 (Tanzen) erhöht Nähe/Verbundenheit (Ø **≥8/10**) und senkt Reibungen bei Entscheidungen (über R4).
|
||||
- **H4 (System):** Adhärenz **≥80 %** über alle täglich geplanten Rituale.
|
||||
|
||||
# Erfolgskriterien (DoD)
|
||||
- **Adhärenz:** R1, R2, R3 jeweils **≥6/7** pro Woche; R6 **≥5/7** pro Woche.
|
||||
- **Events:** R5 **≥1×/Woche**, R7 **≥1×/Woche**, R4 **falls fällig: 1×** in 14 Tagen.
|
||||
- **Wirkung:** Ruhe-Ø **+2**, Spannungsgefühl **−2**, Stimmung-Ø **≥7/10**; Bindung Rohan **+2**.
|
||||
|
||||
# Protokoll
|
||||
- **Start:** 2025-11-01 (Sa) · **Ende:** 2025-11-14 (Fr) · **Mid-Tune:** Tag 7 (2025-11-07).
|
||||
- **Täglicher Ablauf (2–3′):** Tracker ausfüllen (siehe Tabellen unten).
|
||||
- **Weekly Mini-Review (So/Mo):** Scoreboard füllen → 1 Decision Note.
|
||||
- **Regel bei Ausfall:** **Mini-Reset ≤24 h** (kein „alles-egal“).
|
||||
|
||||
# NACh-Reminder (Kurzfassung)
|
||||
- **R1** Meditation 20′ – *Trigger:* erster ruhiger 30′-Block – *Check:* Ruhe 1–10
|
||||
- **R2** Mobility 10′ – *Trigger:* erste 10′ des Lunch – *Check:* Spannung Δ
|
||||
- **R3** Journal – *Trigger:* bevor das Licht ausgeht – *Check:* Stimmung 1–10
|
||||
- **R6** 1:1 Rohan 5′ – *Trigger:* nach Abendessen – *Check:* Bindung 1–10
|
||||
- **R5** Tanzen So 17:00 (Backup Fr 20:00) – *Check:* Nähe 1–10
|
||||
- **R7** 1:1 Rouven Sa 11:00 (Backup Mi 19:30) – *Check:* Nähe 1–10
|
||||
- **R4** Familienrat So 14:00 (alle 2 Wochen; Backup Mo 19:00)
|
||||
|
||||
# Tages-Tracker (14 Tage)
|
||||
date,weekday,R1_y_n,R1_calm_1_10,R2_y_n,R2_tension_delta,R3_y_n,mood_1_10,R6_rohan_y_n,bond_rohan_1_10,R5_tanzen_y_n,closeness_partner_1_10,R7_rouven_y_n,closeness_rouven_1_10,R4_familienrat_y_n,notes
|
||||
2025-11-01,Sa,,,,,,,,,,,,,,"Starttag"
|
||||
2025-11-02,So,,,,,,,,,,,,,,"R5 Tanzen 17:00; ggf. Weekly Mini-Review"
|
||||
2025-11-03,Mo,,,,,,,,,,,,,,
|
||||
2025-11-04,Di,,,,,,,,,,,,,,
|
||||
2025-11-05,Mi,,,,,,,,,,,,,,"Backup-Slot R7 19:30 (falls Sa ausfiel)"
|
||||
2025-11-06,Do,,,,,,,,,,,,,,
|
||||
2025-11-07,Fr,,,,,,,,,,,,,,"Tag 7 – Mid-Tune"
|
||||
2025-11-08,Sa,,,,,,,,,,,,,,"R7 1:1 Rouven 11:00"
|
||||
2025-11-09,So,,,,,,,,,,,,,,"R5 Tanzen 17:00; R4 Familienrat 14:00 (falls fällig)"
|
||||
2025-11-10,Mo,,,,,,,,,,,,,,"Weekly Mini-Review (Backup)"
|
||||
2025-11-11,Di,,,,,,,,,,,,,,
|
||||
2025-11-12,Mi,,,,,,,,,,,,,,"Backup-Slot R7 19:30 (falls Sa ausfiel)"
|
||||
2025-11-13,Do,,,,,,,,,,,,,,
|
||||
2025-11-14,Fr,,,,,,,,,,,,,,"Abschluss – 30′ Abschlussreview"
|
||||
|
||||
# Weekly Mini-Scoreboard (2 Wochen)
|
||||
week_ending,R1_days,R2_days,R3_days,R6_days,R5_done_y_n,R7_done_y_n,bond_rohan_avg,closeness_partner_avg,closeness_rouven,notes
|
||||
2025-11-02,,,,,, , , , "Woche 1 (kurz)"
|
||||
2025-11-09,,,,,, , , , "Woche 2 (voll)"
|
||||
|
||||
# Mid-Tune (Tag 7 · 10 Minuten)
|
||||
- **Fragen:**
|
||||
1) *Was verhindert Adhärenz?* (Energie, Timing, Trigger, Umgebung)
|
||||
2) *Welche 1 Mini-Änderung* steigert die Chance auf „y“ morgen?
|
||||
- **Aktionen (Beispiele):** Meditationskissen sichtbar; Alarm „Lunch-10“; Journalkarte ans Bett; 20:30 Wecker für R6.
|
||||
- **Festhalten:** eine **Decision Note** mit genau **einer** Systemänderung.
|
||||
|
||||
# Abschluss-Review (30 Minuten · 2025-11-14)
|
||||
- **Fakten:** Adhärenz pro Ritual; Ø Ruhe/Spannung/Stimmung; Bindung Rohan.
|
||||
- **Wertung:** Welche Rituale tragen die größte Wirkung? Welche NACh-Teile (Trigger/Aktion/Check) werden fixiert?
|
||||
- **Entscheidung:**
|
||||
- **Behalten:** R1–R3–R6 (und ggf. R5/R7/R4) mit kleinen Anpassungen
|
||||
- **Start/Stop:** 1 neue Mikro-Gewohnheit **oder** 1 weglassen
|
||||
- **Review-System:** `leitbild-review` KPIs ggf. anpassen
|
||||
|
||||
# Verknüpfungen
|
||||
- **Basis & Details:** `leitbild-rituale-system`
|
||||
- **Reviews & KPIs:** `leitbild-review`
|
||||
- **Ziele/Nordsterne:** `leitbild-ziele-portfolio`
|
||||
@@ -0,0 +1,159 @@
|
||||
---
|
||||
title: Leitbild – Leitfaden (Betrieb & Rhythmus)
|
||||
id: leitbild-ops-guide
|
||||
type: concept
|
||||
status: active
|
||||
created: 2025-10-31
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [leitbild, operating-guide, review, habits, nordsterne, mindnet]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
depends_on:
|
||||
- leitbild-text
|
||||
- leitbild-rituale-system
|
||||
- leitbild-review
|
||||
- leitbild-ziele-portfolio
|
||||
- leitbild-rollen
|
||||
- leitbild-prinzipien
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# TL;DR – 80/20
|
||||
- **Täglich 10–15′:** R1/R2/R3 (+ R6) ausführen & im Tracker abhaken; abends **3-Zeilen-Journal** notieren.
|
||||
- **Wöchentlich 20–30′:** `leitbild-review` (Weekly) → Scoreboard füllen → **1 Decision Note** schreiben.
|
||||
- **Monatlich 45–60′:** Roll-up + Top-3 Outcomes festlegen.
|
||||
- **Quartalsweise 90′:** Nordsterne & Meilensteine prüfen, Kurs justieren.
|
||||
|
||||
Wenn gar nichts geht: **Mini-Reset ≤24 h** (kein „alles-egal“).
|
||||
|
||||
---
|
||||
|
||||
# 1) Deine Karte – „Welche Datei wofür?“
|
||||
- **`leitbild-text` (Kompass):** Kurz lesen, wenn du Richtung brauchst. *Wofür stehe ich? Was ist jetzt wichtig?*
|
||||
- **`leitbild-rituale-system` (System):** NACh-Formeln, Trigger, Fallbacks, Tracker. *Ausführen & abhaken.*
|
||||
- **`leitbild-review` (Steuerung):** Weekly/Monthly/Quarterly-Vorlagen, Scoreboards, Decision/Deviation Notes.
|
||||
- **`leitbild-ziele-portfolio` (Ziele):** Nordsterne → Jahresziele → Milestones. *Nur bei echter Planarbeit öffnen.*
|
||||
- **`leitbild-rollen` (Kontext):** Mission + Qualitätskriterien je Rolle. *Wenn Entscheidungen Rollen betreffen.*
|
||||
- **`leitbild-prinzipien` / `leitbild-werte` (Why & How):** Wenn du Dilemmata klärst oder Leitplanken schärfst.
|
||||
- **`leitbild-start-experiment-2025-11-01` (Pilot):** 14-Tage-Test – Logs & Mid-Tune.
|
||||
|
||||
---
|
||||
|
||||
# 2) Dein Tag in 3 Mikro-Ankern (≤15 Minuten Netto)
|
||||
**Morgens:**
|
||||
- **R1 Meditation 20′** (oder Fallback ≤5′).
|
||||
- *Gedanke (10 Sek.):* „Welche **eine Sache** zahlt heute **sichtbar** auf welchen **Nordstern** ein?“
|
||||
|
||||
**Mittags:**
|
||||
- **R2 Mobility 10′** (erste 10′ des Lunch; Fallback ≤3′).
|
||||
|
||||
**Abends:**
|
||||
- **R6 1:1 Rohan 5′** (nach dem Essen; Fallback: 3 Sätze).
|
||||
- **R3 Journal** – 3 Zeilen: *1 gut · 1 gelernt · 1 nächster Schritt.*
|
||||
- *Abhaken im Tracker* (in `leitbild-rituale-system`).
|
||||
|
||||
> **Hinweis:** R5 (Tanzen So 17:00) & R7 (Rouven Sa 11:00) sind **Termin-Rituale**. R4 (Familienrat So 14:00) alle 2 Wochen.
|
||||
|
||||
---
|
||||
|
||||
# 3) Weekly Review – SOP (20–30′, So Abend oder Mo früh)
|
||||
1. **Scoreboard füllen** (aus `leitbild-review`, Tabelle „Weekly“). *Nur Fakten, keine Bewertung.*
|
||||
2. **Kurz-Reflexion** (5 Fragen aus `leitbild-review` · 10′):
|
||||
- Was war **wirksam** für einen Nordstern?
|
||||
- Was **hinderte** Adhärenz (Energie/Timing/Scope)?
|
||||
- Wo brauchte es **Repair** (ehrlich klären/entschuldigen)?
|
||||
- 2–3 Momente von **Ruhe/Klarheit** – was wiederholen?
|
||||
- **Anerkennung** (Partner/Kinder/Team).
|
||||
3. **Fokus & Entscheidung** (5–10′):
|
||||
- **Top-3 Fokus** kommender Woche (je 1 Zeile, Nordstern zuordnen).
|
||||
- **Genau 1 Decision Note** anlegen (Titel, Entscheidung, Warum, Erfolgsmessung).
|
||||
4. **Kalender checken**: R5/R7/R4 Slots bestätigt? Wenn nicht: **verschieben, nicht streichen**.
|
||||
|
||||
---
|
||||
|
||||
# 4) Monthly Review – SOP (45–60′)
|
||||
- **Monats-Scoreboard** (Roll-up) befüllen.
|
||||
- **Rückblick**: Beste Entscheidung des Monats? Wo trugen Rituale auch an Low-Energy-Tagen? Welche Regel/Standard braucht Feinschliff?
|
||||
- **Plan & Risiken**: Top-3 Outcomes (mit Messgröße), Risiken & Gegenmaßnahmen.
|
||||
- **Decision Notes**: 1–2 Richtungsentscheide.
|
||||
- **Ziel-/Milestone-Check** in `leitbild-ziele-portfolio` (nur falls nötig).
|
||||
|
||||
---
|
||||
|
||||
# 5) Quarterly Review – SOP (90′)
|
||||
- **Nordsterne-Check**: noch gültig? Welche 1–2 Metriken je Nordstern waren am prädiktivsten?
|
||||
- **Strategie-Retro**: Keep/Start/Stop, System-Retro (Regeln/SLAs, Nein-Liste), Ritual-Tuning.
|
||||
- **Kurskorrektur**: Meilensteine datieren/verschieben, 1–2 größere **Decision Notes**.
|
||||
|
||||
---
|
||||
|
||||
# 6) Decision & Deviation – „Wie entscheide ich sauber?“
|
||||
- **Decision Note**: Eine Seite, ein Vorgang. *Kontext → Optionen → Entscheidung (Warum) → Erfolgsmetrik → Review-Datum.*
|
||||
- **Deviation („Schuldschein“)**: Wenn du bewusst von Regel/Prinzip abweichst. *Abweichung → Begründung → Impact → Repair → Next-Check.*
|
||||
- Beide Vorlagen stehen in `leitbild-review` (eingrückte Templates), damit du sie kopieren kannst.
|
||||
|
||||
---
|
||||
|
||||
# 7) Start-Experiment (14 Tage) nutzen
|
||||
- **Täglich 2–3′**: Zeile im Tages-Tracker füllen (R1/R2/R3/R6 …).
|
||||
- **Tag 7**: **Mid-Tune** – 1 kleine Systemänderung (z. B. Reminder, Cue, Fallback). **Als Decision Note festhalten.**
|
||||
- **Tag 14**: **Abschlussreview** – Was behalten/ändern/streichen? *Version bump* in `leitbild-rituale-system`.
|
||||
|
||||
---
|
||||
|
||||
# 8) Ordnung halten – Dateien, Edges, Versionen
|
||||
- **Edges**: In jeder Note `depends_on`/`references` prüfen (v. a. `leitbild-text` ↔ Werte/Prinzipien/Rollen/Rituale/Review).
|
||||
- **Versionen**: Bei jeder inhaltlichen Anpassung **version** + **Changelog** aktualisieren.
|
||||
- **Archiv/Git**: Commit + Tag, z. B. `leitbild-text-1.0.0`, `review-0.1.0`, `rituale-0.5.2`.
|
||||
|
||||
---
|
||||
|
||||
# 9) Optional: Kalender-Snippets (iCal, anpassbar)
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Weekly Review (Leitbild)
|
||||
RRULE:FREQ=WEEKLY;BYDAY=SU;BYHOUR=19;BYMINUTE=30;BYSECOND=0
|
||||
END:VEVENT
|
||||
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Monthly Review (Leitbild)
|
||||
RRULE:FREQ=MONTHLY;BYMONTHDAY=28;BYHOUR=18;BYMINUTE=0;BYSECOND=0
|
||||
END:VEVENT
|
||||
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Quarterly Review (Leitbild)
|
||||
RRULE:FREQ=MONTHLY;INTERVAL=3;BYMONTHDAY=2;BYHOUR=09;BYMINUTE=00;BYSECOND=0
|
||||
END:VEVENT
|
||||
|
||||
> Passe Tag/Uhrzeit an deine Slots an (oder lösche diesen Abschnitt, wenn du Kalender separat pflegst).
|
||||
|
||||
---
|
||||
|
||||
# 10) Wenn Zeit & Energie knapp sind
|
||||
- **Regel:** **„Weniger, dafür besser“** – Fallbacks **ziehen**, nicht auslassen.
|
||||
- **Heute nur 1 Sache:** *Welche Mini-Aktion bringt den größten Schritt für **einen** Nordstern?*
|
||||
- **Repair first:** Wenn etwas verletzt, **klären** (ehrlich, respektvoll).
|
||||
- **Mini-Reset ≤24 h**: Ausfall bleibt **Ereignis**, wird **nicht** zur neuen Regel.
|
||||
|
||||
---
|
||||
|
||||
# 11) Qualitätssicherung (Definition of Done)
|
||||
- Weekly Review in Kalender absolviert; **1 Decision Note pro Woche** geschrieben.
|
||||
- R1/R2/R3 **≥6/7**, R6 **≥5/7**, R5 **≥3/4**, R7 **≥1/1**, R4 **≥2/Monat**.
|
||||
- Alle Anpassungen mit **Version + Changelog** dokumentiert.
|
||||
- **Edges konsistent** (Backlinks zwischen Kompass, System, Review, Zielen, Rollen, Prinzipien).
|
||||
|
||||
---
|
||||
|
||||
# 12) Quick-Open (Was öffne ich, wenn …?)
|
||||
- **… ich mich verliere?** → `leitbild-text` (Kompass, 2 Minuten lesen).
|
||||
- **… mein Tag klemmt?** → `leitbild-rituale-system` (NACh + Fallbacks, 1 Aktion jetzt).
|
||||
- **… ich eine Entscheidung schiebe?** → `leitbild-review` → **Decision Note** anlegen.
|
||||
- **… Haushalt/Regeln knirschen?** → R4 Familienrat (Agenda) + Deviation/Decision Note.
|
||||
- **… ich Fokus brauche?** → Weekly Review „Top-3 Fokus“ erneut anschauen.
|
||||
|
||||
---
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
---
|
||||
title: Leitbild – Prinzipien
|
||||
id: leitbild-prinzipien
|
||||
type: concept
|
||||
status: active
|
||||
created: 2025-10-30
|
||||
updated: 2025-10-30
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags:
|
||||
- topic/prinzipien
|
||||
- method/values-to-principles
|
||||
- session/session2
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
depends_on:
|
||||
- leitbild-scope
|
||||
- leitbild-werte
|
||||
- leitbild-wertekompass
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
---
|
||||
|
||||
# Handlungsprinzipien (aus Top-5 Werten abgeleitet)
|
||||
|
||||
> **Tier 1 – Format je Prinzip:** Satz (aktiv) · 3 beobachtbare Signale · Grenzfall/Trade-off · Anti-Pattern-Wächterfrage
|
||||
> **Tier 2 – Mikro-Prinzipien:** 1 Satz · 2 Signale · 1 Wächterfrage
|
||||
|
||||
---
|
||||
|
||||
## P1 – Integrität
|
||||
**Satz:** *Ich spiegele jede wichtige Entscheidung am Werte-Modell und dokumentiere unvermeidbare Abweichungen als „Schuldschein“ binnen 24 h im mindnet.*
|
||||
|
||||
**Beobachtbare Signale**
|
||||
- Entscheidungsnotizen enthalten einen **Kompass-Check** (benannter Wert).
|
||||
- Bei Abweichungen existiert binnen **24 h** eine **decision/exception-Note** („Schuldschein“) mit Begründung, Gültigkeit, Wiedergutmachung.
|
||||
- Ich kann den **Wert hinter der Entscheidung** in **1 Satz** erklären; sonst kurze Vertagung.
|
||||
|
||||
**Grenzfall/Trade-off** Integrität ohne Rigidität – zügig entscheiden, ohne Perfektionismus.
|
||||
**Wächterfrage** *Weiche ich aus **Bequemlichkeit** oder **Prestige** vom Werte-Modell ab? Ist der Schuldschein sauber begründet/befristet?*
|
||||
|
||||
---
|
||||
|
||||
## P2 – Vertrauenswürdigkeit & Ehrlichkeit
|
||||
**Satz:** *Ich kündige drohende Abweichungen von Zusagen **proaktiv vor Fristende** an, **verhandle offen** eine Alternative (Termin/Scope/Compensation) und **liefere die neue Zusage verlässlich**.*
|
||||
|
||||
**Beobachtbare Signale**
|
||||
- Vor Fristende erfolgt **proaktive Info** mit Problem + realistischem Vorschlag.
|
||||
- Die **neue Vereinbarung** ist dokumentiert (Termin/Scope/Compensation).
|
||||
- Die **neue Zusage** wird ohne Nachhaken **on time** erfüllt.
|
||||
|
||||
**Grenzfall/Trade-off** Transparenz ohne Oversharing.
|
||||
**Wächterfrage** *Verschweige ich aus Konfliktvermeidung oder **schönige** ich Fakten?*
|
||||
|
||||
---
|
||||
|
||||
## P3 – Disziplin (Selbstführung)
|
||||
**Satz:** *Ich bin mir selbst gegenüber meinen Vorhaben und Plänen **konsequent**; **unangenehme Tätigkeiten** gehe ich **rechtzeitig** an und **schiebe sie nicht auf**.*
|
||||
|
||||
**Beobachtbare Signale**
|
||||
- **Prioritäten** sind im Kalender sichtbar und werden **vor** Opportunitäten abgearbeitet.
|
||||
- **Unangenehme Aufgaben** erhalten einen **klaren Startpunkt** und beginnen ohne Last-Minute-Hektik.
|
||||
- **Selbst-Fristen** halte ich ein oder ich **re-committe** frühzeitig (siehe P2).
|
||||
|
||||
**Grenzfall/Trade-off** Konsequenz ohne Selbstüberforderung; **Regeneration** bleibt geschützt.
|
||||
**Wächterfrage** *Weiche ich gerade aus **Bequemlichkeit/Müdigkeit** meinem Plan aus?*
|
||||
|
||||
### P3a – Disziplin (Ausprägung: Familienregeln)
|
||||
**Satz:** *Ich setze **wenige klare Regeln** ruhig und **zeitnah** durch, nachdem ich **Bedürfnisse geprüft** habe; Konsequenzen sind **angekündigt** und **verhältnismäßig**.*
|
||||
|
||||
**Beobachtbare Signale**
|
||||
- **Angekündigte Durchsetzungen** (z. B. „in 10 Minuten…“) erfolgen **zum genannten Zeitpunkt**.
|
||||
- Bei Abweichungen nutzen wir den **Familienrat**: Abweichung benennen · **kurzfristige Aufgaben** festlegen · **ohne Beschämung**.
|
||||
- **Elementare Bedürfnisse** gehen vor Dogma; Konsequenzen bleiben **respektvoll** (Bezug: *Respekt*, *Gerechtigkeit*).
|
||||
|
||||
**Grenzfall/Trade-off** Konsequenz vs. Empathie; **keine** dogmatische Strenge gegen Grundbedürfnisse.
|
||||
**Wächterfrage** *Weiche ich aus **Mitleid/Bequemlichkeit** meiner Ansage aus – oder kippe ich in **Starrheit**?*
|
||||
|
||||
---
|
||||
|
||||
## P4 – Gerechtigkeit & Fairness
|
||||
**Satz:** *Ich entscheide nach **klaren, transparenten Maßstäben**, höre **beide Seiten** und mache **begründete Ausnahmen** sichtbar – **ohne** Macht-/Wissensvorsprung auszunutzen.*
|
||||
|
||||
**Beobachtbare Signale**
|
||||
- **Steelman** der stärksten Gegenposition in **1 Satz**.
|
||||
- **Regeln gelten für alle**; **Ausnahmen** sind **begründet & dokumentiert** (Kontext/Bedarf).
|
||||
- **Konsequenzen** sind **angekündigt** und **verhältnismäßig**.
|
||||
|
||||
**Grenzfall/Trade-off** Gleichbehandlung vs. Bedarfsgerechtigkeit – Transparenz entscheidet.
|
||||
**Wächterfrage** *Würde ich diese Entscheidung **akzeptieren**, wenn ich die **andere Person** wäre?*
|
||||
|
||||
---
|
||||
|
||||
## P5 – Respekt
|
||||
**Satz:** *Ich antworte erst, wenn ich **verstanden** habe; ich **würdige Mühe/Prozess**, vermeide Abwertung und behandle **jeden** als gleichwertig.*
|
||||
|
||||
**Beobachtbare Signale**
|
||||
- **Aktives Zuhören** + **Steelman** vor der Antwort.
|
||||
- **Sprache ohne Abwertung**; Verhalten ≠ Person.
|
||||
- **Würdigung**: Einsatz/Fortschritt wird konkret benannt.
|
||||
|
||||
**Grenzfall/Trade-off** Respekt ohne Harmoniesucht; Grenzen bleiben klar.
|
||||
**Wächterfrage** *Reagiere ich auf **Annahmen** statt auf **Verständnis**?*
|
||||
|
||||
---
|
||||
|
||||
# Tier 2 – Mikro-Prinzipien („on deck“, 12 Monate)
|
||||
|
||||
### MP1 – Fürsorge & Familienbindung
|
||||
**Mikro-Prinzip:** *Ich schenke **tägliche Präsenz** (≥5′ bewusster Kontakt) und **schütze** unsere **wöchentliche Familienzeit** als Termin mit hoher Verbindlichkeit.*
|
||||
**Signale:** (1) **Bewusster Kontaktmoment/Tag** (ohne Handy) · (2) **Fixes Wochenritual** findet statt/ist rechtzeitig neu terminiert.
|
||||
**Wächterfrage:** *Ersetze ich gerade **Nähe** durch **Organisation**?*
|
||||
|
||||
### MP2 – Klarheit & Struktur
|
||||
**Mikro-Prinzip:** *Ich formuliere „**Wer macht was bis wann**“ und halte **Mindeststandards sichtbar**.*
|
||||
**Signale:** (1) Aufgaben haben **Owner + Fälligkeit** · (2) **Haushalts-Mindeststandards** sind sichtbar/auffindbar.
|
||||
**Wächterfrage:** *Ist das für **alle** verständlich & auffindbar?*
|
||||
|
||||
### MP3 – Lernorientierung
|
||||
**Mikro-Prinzip:** *Ich kultiviere **Neugier und Begeisterungsfähigkeit**: Ich wähle bewusst ein **aktuelles Interessensgebiet**, das ich **durchdringe und erlerne**.*
|
||||
**Signale:** (1) Pro Quartal ein **Deep-Dive-Thema** im mindnet (mit Leitfragen) · (2) **Wöchentliche Lernnotiz** + **monatlicher Teach-back**.
|
||||
**Wächterfrage:** *Verwechsele ich gerade **Sammeln** mit **Lernen** – wo ist die **Anwendung**?*
|
||||
|
||||
### MP4 – Großzügigkeit
|
||||
**Mikro-Prinzip:** *Ich teile **Zeit/Wissen/Anerkennung** **ohne Bilanzdenken** – **im richtigen Maß**.*
|
||||
**Signale:** (1) **Konkrete Anerkennung** 1×/Tag · (2) **Energiegrenzen** (Schlaf/Training) werden **nicht** geopfert.
|
||||
**Wächterfrage:** *Dient meine Großzügigkeit dem **System** – oder verbrenne ich mich?*
|
||||
|
||||
### MP5 – Mut
|
||||
**Mikro-Prinzip:** *Ich spreche **Unangenehmes früh & respektvoll** an und setze nötige **Neins**.*
|
||||
**Signale:** (1) **Heikle Themen** innerhalb **24 h** adressiert · (2) **Klartext in 1–2 Sätzen**, ohne Abwertung.
|
||||
**Wächterfrage:** *Weiche ich gerade aus **Bequemlichkeit** – oder spreche ich es an?*
|
||||
@@ -0,0 +1,209 @@
|
||||
---
|
||||
title: Leitbild – Review-System (Weekly · Monthly · Quarterly)
|
||||
id: leitbild-review
|
||||
type: meeting/journal
|
||||
status: active
|
||||
created: 2025-10-31
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [review, scoreboard, retro, habits, cadence, decision-notes]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 0.1.0
|
||||
depends_on:
|
||||
- leitbild-ziele-portfolio
|
||||
- leitbild-rituale-system
|
||||
- leitbild-rollen
|
||||
- leitbild-prinzipien
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
- mgmt-kpi-alignment-2026q1
|
||||
- ai-enablement-roadmap
|
||||
---
|
||||
|
||||
# Zweck
|
||||
Ein klares, leichtgewichtiges Review-System für deine Nordsterne und Rituale.
|
||||
Cadence: **Weekly (20–30′)** · **Monthly (45–60′)** · **Quarterly (90′)**.
|
||||
Prinzipien: **Fakten zuerst (Scoreboard)** → **kurze Reflexion** → **eine Entscheidung je Fokus** → **Decision Note**.
|
||||
|
||||
---
|
||||
|
||||
# 0) Cadence & Verantwortungen
|
||||
- **Weekly (So oder Mo):** Ich allein. Daten aus `leitbild-rituale-system` (R1–R5) & den Nordstern-KPIs.
|
||||
- **14-tägig (So 14:00):** Familienrat *light* (siehe `leitbild-rituale-system`, R4).
|
||||
- **Monthly:** Ich + (sofern sinnvoll) Sushi für Partner-/Familien-Themen.
|
||||
- **Quarterly:** Ich (Strategie) + Einbindung relevanter Stakeholder (z. B. Co-Trainer, Management für KPIs).
|
||||
|
||||
---
|
||||
|
||||
# 1) Weekly Review (Template) · 20–30 Minuten
|
||||
**Ablauf (Timebox):** 1) **Scoreboard** (10′) · 2) **Reflexion** (10′) · 3) **Fokus & Decision Note** (5–10′).
|
||||
|
||||
## 1.1 Scoreboard (Woche)
|
||||
> Trage die Zahlen ein; **keine Bewertung** bevor die Fakten stehen.
|
||||
|
||||
| Dimension | KPI (Lead/Lag) | Ziel | Ist | Ampel |
|
||||
|---|---|---:|---:|:--:|
|
||||
| **Ich-Pflege** | R1 Meditation Tage/W | ≥6 | | |
|
||||
| | R2 Mobility Tage/W | ≥6 | | |
|
||||
| | R3 Journal Tage/W | ≥6 | | |
|
||||
| | Ernährungstage im Plan (histamin-/glutenbewusst) | ≥6 | | |
|
||||
| | Monitoring-Logs (Gewicht/Taille/BP) | 1×/W | | |
|
||||
| **Vater** | 1:1-Tage je Sohn | ≥5 | | |
|
||||
| | Konsequenzen-Quote (zeitnah, fair) | ≥90% | | |
|
||||
| | Haushalts-Standards im Soll (Ablagen/Böden/Küche) | ≥80% | | |
|
||||
| | Bewegungseinheiten (Familie) | ≥2 | | |
|
||||
| **Partner** | Load-Check (10′ durchgeführt) | 1× | | |
|
||||
| | Paar-Ritual R5 (Tanzen) | ≥3/4 | | |
|
||||
| | Konflikte ≤48 h geklärt | ≥90% | | |
|
||||
| **Karate & Gewaltschutz** | Curriculum/Plan aktualisiert | 1× | | |
|
||||
| | Trainer-Pipeline Touches (Scouting/Co-Teach/Peer) | ≥3/W | | |
|
||||
| **Freund (Neuaufbau)** | Neue Kontakte qualifiziert | ≥2/Monat → ~0.5/W | | |
|
||||
| | 1:1-Gespräche | ≥4/Monat → ~1/W | | |
|
||||
| | Mikro-Event geplant/abgehalten | ≥1/Monat | | |
|
||||
| **Berufsrolle (AI-first)** | OTQ (On-time-quality, grob) | ≥90% | | |
|
||||
| | AI-Use-Log gepflegt (je Deliverable) | 100% | | |
|
||||
| | Asset-Progress (Prompt/Playbook/Dataset) | ≥0.5/W | | |
|
||||
|
||||
> Hinweis: Monatliche KPIs (z. B. neue Freunde/1:1/Mikro-Event, Karate-Events, AI-Assets, Clinics) werden **unten** zusätzlich monatlich verdichtet.
|
||||
|
||||
## 1.2 Reflexion (kurz)
|
||||
- **Wirksam:** Was hat diese Woche **messbar** einen Nordstern vorangebracht?
|
||||
- **Hindernis:** Was hat Adhärenz verhindert (Energie, Kontext, unklare Entscheidung, Scope-Creep)?
|
||||
- **Integrität & Repair:** Wo wich ich von Werten/Prinzipien ab? Habe ich repariert (z. B. ehrliche Klärung/Entschuldigung)?
|
||||
- **Energie:** Wo lagen 2–3 Momente echter Ruhe/Klarheit? Was davon will ich wiederholen?
|
||||
- **Beziehungen:** Eine Anerkennung (Partner/Kinder/Team).
|
||||
|
||||
## 1.3 Fokus & Decision Note
|
||||
- **Top-3 Fokus der nächsten Woche** (eine Zeile je Punkt; Nordstern zuordnen)
|
||||
- **Eine Entscheidung jetzt** (z. B. Nein sagen, Termin blocken, Experiment starten) → **Decision Note** ausfüllen.
|
||||
|
||||
---
|
||||
|
||||
# 2) Monthly Review (Template) · 45–60 Minuten
|
||||
**Ablauf:** 1) **Monats-Scoreboard** (15′) · 2) **Rückblick** (15′) · 3) **Plan & Risiken** (15–30′).
|
||||
|
||||
## 2.1 Monats-Scoreboard (Roll-up)
|
||||
| Dimension | KPI | Ziel/Monat | Ist | Ampel |
|
||||
|---|---|---:|---:|:--:|
|
||||
| **Ich-Pflege** | ≥8/12 Monate mit ≥4 Lead-Routinen/Woche | on track? | | |
|
||||
| | Arzt/Check-up/Lab (falls fällig) | Soll | | |
|
||||
| **Vater** | Quartalsprojekt-Fortschritt (Qx) | on track | | |
|
||||
| | Medienregel-Compliance Wochen | ≥80% | | |
|
||||
| **Partner** | Paar-Rituale durchgeführt | ≥3/4 | | |
|
||||
| | Konflikte ≤48 h geklärt | ≥90% | | |
|
||||
| **Karate & Gewaltschutz** | Events (KaraGames/Camp/Offen) | ≥1–3/Jahr | | |
|
||||
| | Trainer-Pipeline: Interessenten | ≥6/Jahr | | |
|
||||
| | Mentees aktiv | ≥4/Jahr | | |
|
||||
| | Co-Teachings/Mentee | ≥8/Jahr | | |
|
||||
| | Peer-Reviews | ≥2/Jahr | | |
|
||||
| **Freund (Neuaufbau)** | Neue Kontakte | ≥2 | | |
|
||||
| | 1:1-Gespräche | ≥4 | | |
|
||||
| | Mikro-Events | ≥1 | | |
|
||||
| **Berufsrolle (AI-first)** | AI-Assets erstellt | ≥2/Quartal | | |
|
||||
| | Clinics (A2) durchgeführt | ≥2/Monat (Ø≥4.5/5) | | |
|
||||
| | Research: Insight/Deep-Dive | 1/Monat · 1/Q | | |
|
||||
| | Stakeholder-NPS (intern) | ≥8/10 | | |
|
||||
|
||||
## 2.2 Rückblick (Kernfragen)
|
||||
- **Was war die beste Entscheidung des Monats – und warum?**
|
||||
- **Wo haben Rituale getragen (auch an Low-Energy-Tagen)?**
|
||||
- **Welche Regel/Standard im Haushalt braucht Feinschliff?**
|
||||
- **Welche Beziehung habe ich sichtbar gestärkt (wie genau)?**
|
||||
- **Was lasse ich bewusst weg (WIP-Limit)?**
|
||||
|
||||
## 2.3 Plan & Risiken
|
||||
- **Monat: Top-3 Outcomes** (mit Messgröße)
|
||||
- **Risiken & Anti-Pattern** (Overcommitment, Perfektionismus, Kontextwechsel) → Gegenmaßnahme (eine Zeile).
|
||||
- **Entscheidung(en)** → **Decision Note**.
|
||||
|
||||
---
|
||||
|
||||
# 3) Quarterly Review (Template) · 90 Minuten
|
||||
**Ablauf:** 1) **Nordsterne-Check** (30′) · 2) **Strategie-Retro** (30′) · 3) **Kurskorrektur & Commit** (30′).
|
||||
|
||||
## 3.1 Nordsterne-Check (2026–2029)
|
||||
- **Bleiben die 6 Nordsterne gültig?** (Vater · Ich-Pflege · Karate & Gewaltschutz (+ Traineraufbau) · Partner · Freund (Neuaufbau) · Berufsrolle AI-first)
|
||||
- **Messung (Lead/Lag):** Welche 1–2 Metriken je Nordstern waren am stärksten prädiktiv?
|
||||
- **Jahresziele 2026:** On-track? Wo droht Verzug?
|
||||
- **Meilensteine:** Termine halten oder verschieben?
|
||||
|
||||
## 3.2 Strategie-Retro (Was lernen wir?)
|
||||
- **Keep/Start/Stop:** Was behalten, beginnen, beenden?
|
||||
- **System-Retro:** Wo fehlt Klarheit (Regeln/Standards/SLAs), wo fehlen Grenzen (Nein-Liste)?
|
||||
- **Ritual-Tuning:** Welche NACh-Formeln anpassen (Trigger, Fallback, Check)?
|
||||
- **AI-first (Beruf):** Welche Assets/Guardrails fehlen, um Reuse & Compliance zu erhöhen?
|
||||
|
||||
## 3.3 Kurskorrektur & Commit
|
||||
- **Neue/angepasste Meilensteine** (Datum, Owner, Messung)
|
||||
- **Monats-Cadence aktualisieren**
|
||||
- **Decision Notes** für Kern-Kurswechsel
|
||||
|
||||
---
|
||||
|
||||
# 4) Entscheidung & Abweichung – Vorlagen
|
||||
|
||||
## 4.1 Decision Note (ein Vorgang = eine Seite)
|
||||
title: Decision Note – <kurzer Titel>
|
||||
date: <YYYY-MM-DD>
|
||||
context: <Worum geht es, warum jetzt?>
|
||||
options:
|
||||
- <Option A – Pros/Cons>
|
||||
- <Option B – Pros/Cons>
|
||||
decision: <getroffene Entscheidung + Warum>
|
||||
owner: <Name>
|
||||
review_date: <YYYY-MM-DD> # optional
|
||||
linked_nordstern: <id oder name>
|
||||
success_metric: <Wie messen wir die Wirksamkeit?>
|
||||
|
||||
## 4.2 „Schuldschein“ – bewusste Abweichung von Regel/Prinzip
|
||||
title: Deviation Note – <Regel/Prinzip>
|
||||
date: <YYYY-MM-DD>
|
||||
deviation: <Wovon bin ich abgewichen?>
|
||||
reasoning: <Begründung / Kontext>
|
||||
impact: <Risiken / Kosten>
|
||||
repair: <Konkreter Repair-Schritt (z. B. ehrliche Info/Entschuldigung)>
|
||||
next_check: <Datum für kurze Wirksamkeitskontrolle>
|
||||
|
||||
---
|
||||
|
||||
# 5) Erfassungs-CSV (für Sheets/Obsidian)
|
||||
|
||||
## 5.1 Weekly Log (eine Zeile pro Woche; Mo–So)
|
||||
week_ending,meditation_days,mobility_days,journal_days,nutrition_days,monitoring_done,one_on_one_days_rohan,one_on_one_days_rouven,consequence_rate,household_standards_ok_percent,family_movement_sessions,load_check_done,couple_dance_done,conflicts_resolved_48h,karate_pipeline_touches,friends_new_contacts,friends_one_on_ones,friends_micro_event,otq_percent,ai_use_log_complete,asset_progress_flag,notes
|
||||
2025-11-02,6,6,6,6,y,5,5,0.9,0.85,2,y,y,0.9,3,1,1,n,0.95,y,y,""
|
||||
|
||||
## 5.2 Monthly Roll-up
|
||||
month,meditation_adherence,mobility_adherence,journal_adherence,mini_resets,quartalsprojekt_familie_status,media_rules_weeks_ok,couple_ritual_count,conflict_48h_rate,karate_events,f_trainer_interessenten,f_mentees,co_teachings_per_mentee,peer_reviews,friends_new_contacts,friends_one_on_ones,friends_micro_events,ai_assets,clinics_done,clinics_avg_rating,research_insight,research_deep_dive,stakeholder_nps,notes
|
||||
2025-11,0.86,0.86,0.86,2,on_track,0.8,3,0.9,1,2,2,1,3,5,1,2,2,4.7,y,n,8.2,""
|
||||
|
||||
---
|
||||
|
||||
# 6) Kurz-Prompts für die Review (Copy-Paste)
|
||||
- **Weekly – Fokus finden:**
|
||||
„Angenommen, ich darf **nur eine Sache** kommende Woche richtig gut machen: **Welche** bringt die größte Wirkung für **welchen Nordstern**? Was ist die **nächste sichtbare Aktion**?“
|
||||
- **Repair vorziehen:**
|
||||
„Wen habe ich (auch unabsichtlich) verletzt/übergangen? Wie repariere ich es **diese Woche** respektvoll & klar?“
|
||||
- **Nein sagen:**
|
||||
„Welche Anfrage blockiert meine Nordsterne? Wie formuliere ich ein **wertschätzendes Nein** mit Alternativen?“
|
||||
|
||||
---
|
||||
|
||||
# 7) Verknüpfungen
|
||||
- **Rituale & Checks:** `leitbild-rituale-system` (R1–R5, NACh, Tracker)
|
||||
- **Ziele/Nordsterne:** `leitbild-ziele-portfolio` (Version **1.0.0**)
|
||||
- **Werte & Prinzipien:** `leitbild-werte`, `leitbild-prinzipien`
|
||||
- **Rollen:** `leitbild-rollen`
|
||||
- **Externe Abhängigkeit:** `mgmt-kpi-alignment-2026q1` (Savings-KPI; Berufsrolle A2)
|
||||
- **AI-Guardrails:** `ai-enablement-roadmap`
|
||||
|
||||
---
|
||||
|
||||
# 8) Nutzungshinweise
|
||||
- **Erst Fakten, dann Gefühl:** Scoreboard füllen **vor** der Reflexion.
|
||||
- **Klein halten:** Pro Review **eine** Decision Note reicht.
|
||||
- **Kein „alles-egal“:** Bei Ausfall **Mini-Reset ≤24 h** (siehe Rituale).
|
||||
- **Archiv:** Jede Weekly/Monthly/Quarterly-Review als eigene Meeting-Note (Backlink auf diese Master-Note).
|
||||
|
||||
---
|
||||
@@ -0,0 +1,149 @@
|
||||
---
|
||||
title: Leitbild – Rituale & Systeme
|
||||
id: leitbild-rituale-system
|
||||
type: project
|
||||
status: active
|
||||
created: 2025-10-31
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [rituale, habits, NACh, recovery, ich-pflege, journal, familienrat, paar-ritual, tanzen, vater, 1on1]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 0.5.2
|
||||
depends_on:
|
||||
- leitbild-ziele-portfolio
|
||||
- leitbild-prinzipien
|
||||
- leitbild-rollen
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
- leitbild-review
|
||||
---
|
||||
|
||||
# Ziel
|
||||
Ein kleines, verlässliches Ritualsystem für Recovery & Alltag – täglich:
|
||||
- R1: 20′ Meditation
|
||||
- R2: 10′ Flexibilität/Mobility
|
||||
- R3: Abends Journal
|
||||
- R6: 5′ 1:1 mit Rohan
|
||||
|
||||
sowie 14-tägig:
|
||||
- R4: Familienrat light (30–45′)
|
||||
|
||||
und wöchentlich:
|
||||
- R5: Paar-Ritual – Tanzen (45–60′)
|
||||
- R7: 1:1 mit Rouven (20–30′)
|
||||
|
||||
Alle Rituale mit NACh-Formel (Nächste Aktion + Trigger + Check), Fallbacks und klarer Messung.
|
||||
|
||||
---
|
||||
|
||||
# DAILY RITUALE
|
||||
|
||||
## R1 – Meditation (Zazen) · 20 Minuten
|
||||
NACh-Formel
|
||||
- Trigger (fest): erster ruhiger 30′-Block des Tages
|
||||
- Backup-Trigger: direkt nach dem ersten Heißgetränk
|
||||
- Aktion: Timer 20′ → aufrecht sitzen → Atem zählen (1–10; bei Abschweifen zurück auf 1)
|
||||
- Check: R1 abhaken; Ruhe-Skala 1–10
|
||||
- Umgebung/Cues (fix): Sitzkissen sichtbar am Sitzplatz; Handy-Fokus „Zazen“; Kopfhörer/NC optional
|
||||
Low-Energy-Fallback (≤5′): 60 Atemzüge oder 2× 4-7-8
|
||||
|
||||
## R2 – Flexibilität/Mobility · 10 Minuten
|
||||
NACh-Formel
|
||||
- Trigger (fest): die ersten 10′ der Mittagspause
|
||||
- Backup-Trigger: nach dem ersten >60′-Computerblock
|
||||
- Aktion (ca. 10′): Cat-Cow 60″ · Hüftbeuger-Lunge L/R 45″ · „Open Book“ BWS L/R 45″ · Hamstrings 60″ · Waden L/R 45″ · 5 Zwerchfellzüge
|
||||
- Check: R2 abhaken; Spannungsgefühl 1–10 (vor/nach)
|
||||
Low-Energy-Fallback (≤3′): 1× „Open Book“ je Seite + 5 Atemzüge in Bauchlage
|
||||
|
||||
## R3 – Abendliches Journal · 1 Seite (oder 3 Zeilen)
|
||||
NACh-Formel
|
||||
- Trigger (fest): bevor das Licht ausgeht
|
||||
- Backup-Trigger: direkt nach dem Zähneputzen
|
||||
- Aktion (Template): Wirksam heute (3) · Anerkennung (1 Satz) · Fokus morgen (1 Entscheidung)
|
||||
- Check: R3 abhaken; Stimmung 1–10
|
||||
- Umgebung/Cues (fix): Journal + Stift griffbereit am Bett
|
||||
Low-Energy-Fallback (≤60″): 3-Zeilen-Journal („1 gut · 1 gelernt · 1 nächster Schritt“)
|
||||
|
||||
## R6 – 1:1 mit Rohan · 5 Minuten
|
||||
NACh-Formel
|
||||
- Trigger (fest): direkt nach dem Abendessen (nach Abdecken/Abspülen)
|
||||
- Backup-Trigger: 20:30 Erinnerung, falls Abendessen zerfleddert
|
||||
- Aktion: Mini-Spot (Sofa/Schreibtisch/kurzer Gang) – 2 Fragen: „Was war heute gut?“ · „Was machen wir morgen?“ (ggf. 1 Mini-Aufgabe)
|
||||
- Check: R6 abhaken; Bindungsgefühl 1–10
|
||||
Low-Energy-Fallback (≤120″): 3-Satz-Check-in: „1 gut · 1 schwierig · 1 für morgen“
|
||||
|
||||
---
|
||||
|
||||
# WÖCHENTLICHE RITUALE
|
||||
|
||||
## R5 – Paar-Ritual Tanzen · 45–60 Minuten
|
||||
NACh-Formel
|
||||
- Trigger (fest): Sonntag, 17:00
|
||||
- Backup-Trigger: Freitag, 20:00
|
||||
- Aktion: Ankommen (5′) · Warm-up (5′) · Tanzen (30–40′) · Cool-down + 1 Anerkennung (5′)
|
||||
- Check: R5 abhaken; Nähe/Verbundenheit 1–10
|
||||
Low-Energy-Fallback (15–20′): „Slow Walk & Talk“ oder „2 Songs Wohnzimmer“ oder „gemeinsames Stretching“
|
||||
|
||||
## R7 – 1:1 mit Rouven · 20–30 Minuten
|
||||
NACh-Formel
|
||||
- Trigger (festgelegt): Samstag, 11:00 (Walk & Talk oder gemeinsames Projekt)
|
||||
- Backup-Trigger: Mittwoch, 19:30 (nach dem Abendessen)
|
||||
- Aktion (Beispiel): 5′ Check-in · 10–20′ Walk & Talk/Projekt (seine Wahl) · Abschlussfrage: „Wobei wünschst du dir Unterstützung – und was machst du als Nächstes?“
|
||||
- Check: R7 abhaken; Nähe/Verbundenheit 1–10
|
||||
Low-Energy-Fallback (≤5′): kurzer Türrahmen-Check-in (3 Fragen à 1 Satz)
|
||||
|
||||
---
|
||||
|
||||
# 14-TÄGIGES RITUAL
|
||||
|
||||
## R4 – Familienrat light · 30–45 Minuten
|
||||
NACh-Formel
|
||||
- Trigger (fest): jeder 2. Sonntag, 14:00 (direkt nach dem Mittagessen)
|
||||
- Backup-Trigger: Montag, 19:00 (dieselbe Woche)
|
||||
- Aktion (Agenda, timeboxed): Check-in (5′) · Anerkennung (5′) · Regeln/Standards (10′) · Woche voraus (10′) · Projekte/Medien (5′) · Entscheidungen (5′, schriftlich)
|
||||
- Check: Mini-Protokoll im Vault; Klärung ≤48 h offener Punkte
|
||||
|
||||
---
|
||||
|
||||
# MESSUNG & ZIELE
|
||||
- Wöchentlich: R1 ≥6/7 · R2 ≥6/7 · R3 ≥6/7 · R6 ≥5/7 · R7 ≥1/1 · R5 ≥3/4
|
||||
- 14-tägig: R4 ≥2/Monat (~26/Jahr); Klärung ≤48 h in ≥90 %; Protokollquote 100 %
|
||||
- Quartal (Ich-Pflege): ≥8/12 Monate mit ≥4 Lead-Routinen/Woche erfüllt
|
||||
- Relapse-Shield: Ausfall ⇒ Mini-Reset ≤24 h (kein „alles-egal“)
|
||||
|
||||
---
|
||||
|
||||
# TRACKER (Beispiele)
|
||||
Daily Log (eine Zeile je Tag)
|
||||
date,R1_meditation_y_n,R1_calm_1_10,R2_mobility_y_n,R2_tension_delta,R3_journal_y_n,mood_1_10,R6_1on1_rohan_y_n,bond_rohan_1_10,R5_couple_dance_y_n,closeness_1_10,R4_familienrat_y_n,decisions_logged_y_n,notes
|
||||
2025-11-02,y,7,y,-2,y,8,y,8,y,8,,,"Paar-Ritual #1"
|
||||
2025-11-09,y,7,y,-1,y,8,y,9,y,9,y,y,"Familienrat #1 (14:00)"
|
||||
|
||||
Weekly Roll-up (eine Zeile je Woche; Mo–So)
|
||||
week_ending,R1_days,R2_days,R3_days,R6_days,R5_done_y_n,R7_done_y_n,bond_rohan_avg,bond_rouven,household_standards_ok_percent,conflicts_resolved_48h,notes
|
||||
2025-11-09,6,6,6,6,y,y,8,7,0.85,0.9,""
|
||||
|
||||
---
|
||||
|
||||
# INTEGRATION & ANKER
|
||||
- Vater: R6 (Rohan täglich) + R7 (Rouven samstags) stützen 1:1-KPI
|
||||
- Partner: R5 stärkt Nähe & Kommunikation; R4 reduziert Reibung via klare Entscheidungen
|
||||
- Ich-Pflege: R1/R2/R3 als direkte Lead-KPIs; Journal (R3) enthält 1 Anerkennungssatz/Tag
|
||||
- Review: Wöchentliche/14-tägige Summen → leitbild-review (Weekly/Monthly/Quarterly)
|
||||
|
||||
---
|
||||
|
||||
# RISIKEN & GUARDRAILS
|
||||
- Überperfektionierung: 20′ ≠ 0′ – bei Zeitknappheit Fallback nutzen
|
||||
- Cheat-Day-Falle: Kein „alles-egal“ – Mini-Reset ≤24 h
|
||||
- Gesundheit: Mobility schmerzfrei; ggf. Übungen tauschen
|
||||
- Familie: Keine Beschämung; 1:1 ist Qualitätszeit, nicht Verhör
|
||||
|
||||
---
|
||||
|
||||
# CHANGELOG
|
||||
- 0.5.2: Standard-Cues fixiert (R1: Sitzkissen sichtbar; R3: Journal + Stift am Bett)
|
||||
- 0.5.1: R7 auf Samstag 11:00 (Backup Mi 19:30)
|
||||
- 0.5.0: R7 (Rouven) hinzugefügt; R6 (Rohan) täglich etabliert
|
||||
@@ -0,0 +1,249 @@
|
||||
---
|
||||
title: Leitbild – Rollenlandkarte
|
||||
id: leitbild-rollen
|
||||
type: concept
|
||||
status: active
|
||||
created: 2025-10-30
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [topic/rollen, method/role-mission, area/personal_development]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.2.0
|
||||
depends_on:
|
||||
- leitbild-scope
|
||||
- leitbild-werte
|
||||
- leitbild-prinzipien
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
---
|
||||
|
||||
# Rollenlandkarte
|
||||
|
||||
## Rollenübersicht
|
||||
- Vater (Söhne: **Rouven (18)**, **Rohan (15)**)
|
||||
- Partner (Sushi)
|
||||
- **Berufsrolle (Umbrella): Advisor/Research Lead & Ausbilder**
|
||||
- A1: Leiter Recherche (Deutschland)
|
||||
- A2: Global Lead IT-Kostenreduzierung
|
||||
- A3: Ausbilder (Trainee-Programm)
|
||||
- Karate- & Gewaltschutztrainer (ca. 80 Kinder) · **Erweitertes Feld: Traineraufbau & Multiplikation**
|
||||
- Freund (soziales Umfeld)
|
||||
- Ich-Pflege (Gesundheit, Meditation, Sport)
|
||||
|
||||
---
|
||||
|
||||
## Vater
|
||||
**Mission (Kern, 3 Sätze):**
|
||||
Ich bin als Vater **verlässlich präsent** und schaffe **jeden Tag echte Nähe**.
|
||||
Ich **führe ruhig und konsequent**: wenige klare Regeln, fair angekündigte, verhältnismäßige Konsequenzen – **mit Blick auf Bedürfnisse**.
|
||||
Ich **stärke Selbstwirksamkeit, Neugier, Sport und Charakter**, damit meine Söhne verantwortungsvolle, empathische und widerstandsfähige junge Männer werden.
|
||||
|
||||
**Ausprägungen je Sohn (Fokus):**
|
||||
- **Rouven (18)** – *Übergang in die Erwachsenenrolle*: Ownership für Entscheidungen & Finanzen; berufliche Orientierung aktiv gestalten; Beiträge im Haushalt verbindlich; Austausch auf Augenhöhe (Klartext ohne Abwertung).
|
||||
- **Rohan (15)** – *Bindung & Struktur*: tägliche Nähe und gemeinsames Projekt (z. B. Smart-Home-Assistent); faire, verlässliche Regeln & Medienbalance; soziale Integration und Selbstwert stärken.
|
||||
|
||||
**Qualitätskriterien (verbindlich):**
|
||||
- **Nähe & Präsenz:** täglich ≥ **5 Min 1:1** + **wöchentliches Ritual** (fixer Termin oder rechtzeitig neu terminiert).
|
||||
- **Faire Führung:** **angekündigte** Durchsetzungen erfolgen **zum Zeitpunkt**; Bedürfnisse vorher **geprüft** (Bezug: *Respekt*, *Gerechtigkeit*).
|
||||
- **Entwicklung:** je Sohn **Quartalsprojekt** mit klarer Rolle & Abschluss; **Teach-back** mind. 1×/Monat.
|
||||
- **Kommunikation:** Konflikte werden innerhalb **48 h** adressiert; vor Antworten **Steelman** der Gegensicht.
|
||||
- **Ordnung & Standards (explizit):**
|
||||
- **Ablageflächen & Böden frei** von Dingen, die dort nicht hingehören.
|
||||
- **Küche morgens komplett aufgeräumt.**
|
||||
- **Kein sichtbarer Dreck** (sichtbare Flächen).
|
||||
|
||||
**Aktuelles Quartalsprojekt (Dokumentationsstand):**
|
||||
- **Präferiert:** *Smart-Home-Assistent für Rohans Zimmer* (Voice-Steuerung).
|
||||
- **Fallback:** *Game/Mod-Design/Koop-Projekt*.
|
||||
- **Guardrail:** Vater **dominiert nicht** – Rollen/Schritte gemeinsam festlegen.
|
||||
|
||||
**Grenzen / Nein-Liste:**
|
||||
- Keine **Beschämung/Anschreien**; Verhalten ≠ Person.
|
||||
- Keine **externen Zusatz-Verpflichtungen** zulasten Familienzeit (Ausnahmen gemeinsam beschließen).
|
||||
- Kein **„Rettungsmodus“**, der Eigenverantwortung ersetzt (natürliche, faire Konsequenzen).
|
||||
- Keine **ad-hoc Regeldiskussionen** im Stress – stattdessen Termin/Familienrat.
|
||||
|
||||
**Stakeholder-Landkarte:**
|
||||
- **Primär:** Rouven, Rohan
|
||||
- **Sekundär:** Sushi (Co-Führung Haushalt/Regeln), Schule/Verein(e)
|
||||
- **Schnittstellen/Erwartungen:** Verlässliche Erreichbarkeit, transparente Regeln, respektvolle Kommunikation
|
||||
|
||||
---
|
||||
|
||||
## Partner
|
||||
**Mission (2 Sätze):**
|
||||
Wir führen unseren Alltag **als Team**: klare Zuständigkeiten, **faire Lastverteilung** und **respektvolle Kommunikation**; Konflikte klären wir **zeitnah**.
|
||||
Ich bin **verlässlich, zärtlich und präsent**; ich **erkenne Sushis gesundheitliche Situation an**, schütze **unsere Energie** durch gute **Grenzen** und **gemeinsame Rituale**.
|
||||
|
||||
**Qualitätskriterien (verbindlich):**
|
||||
- **Faire Lastverteilung (Weekly Load-Check):** 1×/Woche **10 Min** Abgleich „Was ist zu viel/zu wenig?“ – Anpassung sofort.
|
||||
- **Energie schützen:** **Ruhefenster** + **Medizin-/Thermie-Bedürfnisse** werden **vor** Terminen eingeplant (Kalender sichtbar).
|
||||
- **Rituale & Nähe:** Mind. **1 Paar-Ritual/Woche** (Spaziergang, Tee, Serie) – **rechtzeitig neu terminiert**, nicht ersatzlos gestrichen.
|
||||
- **Wertschätzung konkret:** **Täglich 1 Satz** Anerkennung (Fakt + Wirkung), möglichst im Moment.
|
||||
|
||||
**Grenzen / Nein-Liste:**
|
||||
- **Kein Retter-Modus:** Ich übernehme Sushis Aufgaben **nicht automatisch**; Unterstützung = **Enablement**.
|
||||
- **Keine Schuldzuweisung/Abwertung**; bei Eskalation **Time-out** (max. 30 Min) + **Rückkehrzeit** vereinbaren.
|
||||
- **Keine ungeplanten Zusatzverpflichtungen** zulasten Paar-Ritual/Medizin-Terminen; Änderungen **nur gemeinsam**.
|
||||
|
||||
**Stakeholder-Landkarte:**
|
||||
- **Primär:** Sushi
|
||||
- **Sekundär:** Rouven, Rohan
|
||||
- **Schnittstellen/Erwartungen:** Ärzt:innen/Therapie, Familienrat/Kalender – **sichtbare Planung** & **verbindliche Absprachen**
|
||||
|
||||
---
|
||||
|
||||
## Berufsrolle (Umbrella): Advisor/Research Lead & Ausbilder
|
||||
**Mission (2 Sätze):**
|
||||
Ich liefere **wirksame Ergebnisse** aus einem Guss: **evidenzbasiert** (Research), **wert-/kostenorientiert** (IT-Kostenreduzierung) und **menschenzentriert** (Ausbildung).
|
||||
Ich **priorisiere wenige Initiativen**, halte **Zusagen**, skaliere Wirkung durch **Wissensteilung** und **klare Standards**.
|
||||
|
||||
**Globale Qualitätskriterien (verbindlich):**
|
||||
- **Priorisierung & Fokus:** Quartals-OKRs (max. 3) je Unterverantwortung; **Wochen-Top-3** sichtbar.
|
||||
- **Lieferzuverlässigkeit:** Zusagen **on time/quality ≥ 90 %**; Abweichungen **vor Fristende** re-committet.
|
||||
- **Evidenz-Standard:** Outputs mit **Quellen, Annahmen, Rechenwegen** (reproduzierbar).
|
||||
- **Wissensskalierung:** je Quartal **≥ 2 wiederverwendbare Assets** (Playbook/Template/Script).
|
||||
- **Stakeholder-Kommunikation:** **monatliches Steering** je Unterverantwortung (No-Surprises).
|
||||
|
||||
**Grenzen / Nein-Liste (verbindlich):**
|
||||
- **Kein Overcommitment**: Keine Zusage ohne Zeitfenster/Owner.
|
||||
- **Kein „Slideware ohne Boden“**: Keine Empfehlung ohne Daten/Validierung.
|
||||
- **Kein Hero-Modus**: Nachhaltige Pace > kurzfristige Glanzleistung.
|
||||
- **Keine stillen Scope-Changes**: Änderungen **transparent** und **schriftlich**.
|
||||
|
||||
**Stakeholder-Landkarte:**
|
||||
- **Primär:** interne Auftraggeber/Accounts, Trainees, Research-Team
|
||||
- **Sekundär:** Offering-/Delivery-Leads, Practice-Heads, Vertrieb
|
||||
- **Schnittstellen/Erwartungen:** klare Auftragsklärung, definierte SLAs, Assets im Wissenssystem
|
||||
|
||||
### A1 – Leiter Recherche (Deutschland)
|
||||
**Mission:**
|
||||
Wir liefern für D-Themen **schnelle, belastbare Einsichten** und **wiederverwendbare Bausteine**, die Entscheidungen **beschleunigen**.
|
||||
|
||||
**Kern-KPIs (3–4):**
|
||||
- **Briefing-SLA**: Standard-Anfragen **≤ 5 AT**; Ad-hoc **≤ 2 AT** je nach Komplexität.
|
||||
- **Publikations-Cadence**: **1 Insight/Monat** (Short) + **1 Deep-Dive/Quartal**.
|
||||
- **Reuse-Quote**: ≥ **50 %** der Outputs werden **mind. 2×** wiederverwendet.
|
||||
- **Stakeholder-NPS intern**: **≥ 8/10** je Quartal.
|
||||
|
||||
**Mini-Grenzen:** keine „Copy-Paste-Trends“ ohne Quelle; keine Veröffentlichung ohne **Peer-Check**.
|
||||
|
||||
### A2 – Global Lead IT-Kostenreduzierung
|
||||
**Mission:**
|
||||
Ich befähige globale Accounts, **nachhaltig IT-Kosten zu senken** (Opex/Capex) **ohne** Wertverlust – via **Playbooks, Coaching und Leuchtturm-Cases**.
|
||||
|
||||
**Kern-KPIs (3–4):**
|
||||
- **Playbook-Adoption**: **≥ 5 Accounts/Quartal** nutzen Module/Checklists.
|
||||
- **Savings-Pipeline**: **≥ € X Mio/Quartal** qualifizierte Maßnahmen (Summe aus Accounts).
|
||||
- **Case-Library**: **2 neue Case-Cards/Quartal** (Problem → Hebel → €-Effekt → Lessons).
|
||||
- **Enablement**: **≥ 2 Clinics/Monat** (60–90′) mit Ratings **≥ 4.5/5**.
|
||||
|
||||
**Mini-Grenzen:** keine Einspar-Claims ohne **Baseline/Annahmen**; keine „One-size-fits-all“-Rezepte.
|
||||
|
||||
### A3 – Ausbilder (Trainee-Programm)
|
||||
**Mission:**
|
||||
Ich sichere **schnelle Lernkurven** und **hohe Anschlussfähigkeit**: klare **Skill-Roadmaps**, viel **Praxis**, **wertschätzendes Feedback**.
|
||||
|
||||
**Kern-KPIs (3–4):**
|
||||
- **Abschluss/Placement-Rate**: **≥ 95 %** regulär platziert.
|
||||
- **Evaluation**: Trainee-Zufriedenheit **≥ 4.6/5**; Teach-back-Quote **100 %**.
|
||||
- **Skill-Checkpoints**: **monatliche Assessments** (Rubrics), **Remediation-Plan** für Gaps **≤ 2 Wochen**.
|
||||
- **Mentoring**: **1:8** Mentor:Coachee-Ratio **oder besser**.
|
||||
|
||||
**Mini-Grenzen:** kein Unterricht ohne **klaren Outcome**; kein Feedback ohne **Beispiel + nächster Schritt**.
|
||||
|
||||
---
|
||||
|
||||
## Karate- & Gewaltschutztrainer
|
||||
**Mission (3 Sätze):**
|
||||
Ich vermittle **Freude an Bewegung** und lebe **Budo-Werte** vor; ich baue **Charakter, Respekt und Teamgeist** – auf und neben der Matte.
|
||||
Ich **führe klar & freundlich**: sichere, entwicklungsgerechte Trainings mit **transparenten Reifegradpfaden**, fairer Wettkampf und **gute Feedbackkultur**.
|
||||
Ich **schaffe ein reiches Erfahrungsumfeld für Kinder** (neue, kreative Angebote – auch **außerhalb des Vereins**), **achte auf das Kindeswohl**, bilde mich kontinuierlich fort und **trage maßgeblich zur Vereinsentwicklung** bei.
|
||||
|
||||
**Qualitätskriterien (verbindlich):**
|
||||
- **Didaktik & Progression:** **Reifegradpfad** sichtbar (Quartalsziele je Gruppe), differenzierte Übungen, klare Erfolgskriterien.
|
||||
- **Erlebnisformate & soziale Wirkung:** Mind. **2–3 Sonderangebote/Jahr** (z. B. KaraGames, Camps, Waldtage) + **1–2 offene/soziale Angebote** außerhalb des Vereins.
|
||||
- **Fortbildung & Qualität:** Mind. **2 Lehrgänge/Jahr** (Karate/Gewaltschutz/Kinderschutz); Hospitationen/Peer-Reviews im Trainerteam (≥ 2/Jahr).
|
||||
- **Kindeswohl & Sicherheit:** Gelebtes **Schutzkonzept** (Ansprechperson, Einverständnisse, Notfallplan), **sichere Progression**, Stop-Signal wird respektiert.
|
||||
|
||||
**Grenzen / Nein-Liste (verbindlich):**
|
||||
1) **Keine Beschämung/Anschreien**, kein öffentliches Bloßstellen; Verhalten ≠ Person.
|
||||
3) **Keine problematischen Rollenspiele** (z. B. sexualisierte Gewalt) mit Minderjährigen; Inhalte **trauma-sensibel**.
|
||||
4) **Keine Privat-Chats mit Minderjährigen** außerhalb offizieller Kanäle/Zeiten.
|
||||
5) **Keine Übernahme zusätzlicher Vereinsaufgaben** zulasten Familienzeit ohne bewusste Neupriorisierung.
|
||||
|
||||
**Stakeholder-Landkarte:**
|
||||
- **Primär:** Kinder/Jugendliche
|
||||
- **Sekundär:** Eltern/Erziehungsberechtigte, Trainerteam, Vereinsvorstand, Kinderschutz-Beauftragte:r
|
||||
- **Partner:** Schulen/Einrichtungen, Jugendamt/Präventionsstellen, Turnier-/Lehrgangsorganisationen
|
||||
|
||||
### Erweitertes Feld – Traineraufbau & Multiplikation
|
||||
**Ziel:** Ein **skalierbares, sicheres und wertebasiertes** System, das Mitglieder vom **Potenzial** bis zum **eigenständigen Lead-Trainer** entwickelt – ohne Familienzeit zu gefährden.
|
||||
|
||||
**Pfad (Level & Kriterien):**
|
||||
- **S1 Shadowing (4–6 Einheiten):** Beobachten, Sicherheits-/Dojo-Rituale. *Exit:* Kinderschutz-Briefing + Mini-Rolle (Aufwärmen) sicher angeleitet.
|
||||
- **S2 Co-Teaching (8–10 Einheiten):** Teile der Stunde übernehmen. *Exit:* klare Sprache, wertschätzendes Feedback, sichere Durchführung.
|
||||
- **S3 Teil-Lead (≥6 Einheiten):** Planung & Leitung von Einheitsteilen nach Reifegradpfad. *Exit:* Rubric **≥ „gut“**, Sicherheits-Check bestanden.
|
||||
- **S4 Lead (laufend):** Ganze Stunde leiten; Elternkommunikation; Event-Mitarbeit. *Erhalt:* **2 Peer-Reviews/Jahr**, Fortbildung.
|
||||
|
||||
**Curriculum-Module:** Didaktik Basics · Reifegradpfade · Sicherheit & Kinderschutz · Kommunikation & Feedback · Budo-Werte & Dojo-Rituale · Event-Organisation · Reflexion/Teach-back.
|
||||
|
||||
**Mentoring & Review:** jedem Mentee **Mentor** zuordnen; **Monats-Check-in (30′)**; **Coach-the-Coach quartalsweise (90′)**; **Rubric** steuert Level-Up.
|
||||
|
||||
**Qualitätskriterien (Traineraufbau):**
|
||||
- **Pipeline aktiv:** **≥6 Interessenten/Jahr**, **≥4 aktive Mentees** (S1–S3).
|
||||
- **Level-Ups:** **≥2 neue Leads/Jahr (S4)**, Retention **≥80 %**.
|
||||
- **Co-/Lead-Abdeckung:** **≥30 %** der Einheiten mit Co-/Lead-Unterstützung.
|
||||
- **Peer-Reviews & Lehrgänge:** **≥2 Peer-Reviews/Jahr** je (Co-)Trainer; **≥2 Lehrgänge/Jahr** im Team.
|
||||
- **Kommunikation:** Onboarding-Handout aktuell; **2 Eltern-Infos/Jahr**; Anfragen **≤72 h** beantwortet.
|
||||
|
||||
**Grenzen (Traineraufbau):**
|
||||
- **Mentor-Ratio** maximal **1:3**; keine Übernahme zulasten **Familienzeit**.
|
||||
- **Kinderschutz vor Tempo:** kein Level-Up ohne bestandenen Sicherheits-/Kommunikations-Check.
|
||||
- **Keine Privat-Chats** mit Minderjährigen; Kontakt nur über offizielle Kanäle/Zeiten.
|
||||
|
||||
---
|
||||
|
||||
## Freund
|
||||
**Mission (2 Sätze):**
|
||||
Ich bin **verlässlich und loyal**: halte bewusst **Kontakt**, bin in wichtigen Momenten **da** und feiere die Erfolge meiner Freunde.
|
||||
Ich pflege **verbindende Erlebnisse & Rituale** (Sport/Natur/Kochen) und bin in **Krisen erreichbar**, ohne Familie/Erholung zu gefährden.
|
||||
|
||||
**Qualitätskriterien (verbindlich):**
|
||||
- **Kontakt-Cadence:** Mind. **1 aktiver Ping/Monat** pro **Kernfreund** (Call/Message/Treffen).
|
||||
- **Wichtige Momente:** Bei Geburtstagen/Meilensteinen/Krisen reagiere ich **innerhalb 24–48 h** mit passendem Signal (Anruf/Karte/Hilfe).
|
||||
- **Rituale & Erlebnisse:** **1 gemeinsames Erlebnis/Quartal** pro Kernfreund (oder kleines Duo-Event).
|
||||
- **Klartext mit Herz:** Bei heiklen Themen: **zuhören → spiegeln → 1 ehrlicher Impuls**, ohne zu überfahren.
|
||||
- **Grenzen wahren:** **Familien-/Erholungszeit geschützt**; Hilfe nur, wenn **tragfähig** (Ersatztermin anbieten).
|
||||
|
||||
**Grenzen / Nein-Liste (verbindlich):**
|
||||
1) **Kein Gossip/Lästern** über Abwesende; Kritik **direkt & respektvoll** oder gar nicht.
|
||||
2) **Keine Vertraulichkeiten weitergeben**; sensiblen Content nur mit ausdrücklicher Zustimmung teilen.
|
||||
3) **Kein „Ja“ ohne Kapazität** – lieber **Nein/Später** mit klarem Vorschlag (Termin/Scope).
|
||||
5) **Kein „Retter-Modus“**: Hilfe = **Enablement**, Notfallhilfe **befristet** (klarer Rahmen).
|
||||
|
||||
---
|
||||
|
||||
## Ich-Pflege
|
||||
**Mission:**
|
||||
Ich pflege **Körper, Geist und Herz** bewusst, damit ich langfristig **gesund, präsent und leistungsfähig** für Familie, Beruf und Dojo bleibe.
|
||||
|
||||
**Qualitätskriterien (verbindlich):**
|
||||
- **Kraft (Kieser – Reha-Bridge):** Zielzustand **2–3×/Woche**, 8–10 Geräte, **4-2-4-2**, **1 Satz**; **+5 %** Progress, wenn sauber möglich.
|
||||
**Solange verletzt:** 2×/W **schmerzfreie Reha/Physio-Übungen** (isometrisch/mobilisierend gemäß Freigabe); bei Wiedereinstieg: **Woche 1–2: ~50 % Last**, **Woche 3–4: ~60–70 %**, dann regulär.
|
||||
- **Karate & Bewegung:** **2 Einheiten/Woche** oder **≥ 150 min** moderat; **Alltagsbewegung sichtbar** (aktive Wege/Schritte).
|
||||
- **Meditation & Mobility:** **4×/Woche** 10–20 Min **Zazen + Dehnen**.
|
||||
- **Ernährung (Histamin/Gluten achtsam):** **80/20 mediterran**, täglich **Gemüse ≥ 2 Portionen**, **Fisch 1–2×/W**, rotes Fleisch **≤ 1×/W**, **2 L Wasser**.
|
||||
- **Monitoring & Check-ups:** **Wöchentlich** kurz **Gewicht/Taille/BP** notieren; **halbjährlich** Labor/Arzt-Check; Anpassungen im mindnet dokumentieren.
|
||||
|
||||
**Grenzen / Nein-Liste (verbindlich):**
|
||||
- **Kein Training „durch Schmerz“** (akuter Schmerz = Abbruch/Reha-Variante).
|
||||
- **Keine „Cheat Days“ bei der Essenskontrolle; keine „Jetzt bin ich drüber – dann ist sowieso alles egal“-Einstellung.**
|
||||
- **Kein Überspringen von 2 Regenerationstagen hintereinander**, wenn Erschöpfungssignale da sind.
|
||||
|
||||
**Stakeholder-Landkarte:**
|
||||
- **Primär:** ich selbst
|
||||
- **Sekundär:** Ärzt:innen/Physio, Karate-Trainer:innen, Kieser-Studio
|
||||
- **Schnittstellen/Erwartungen:** Reha-Plan/Trainingsplan sichtbar, Termine im Kalender, Monitoring im mindnet
|
||||
@@ -0,0 +1,51 @@
|
||||
---
|
||||
title: Leitbild – Scope (Session 0, final)
|
||||
id: leitbild-scope
|
||||
type: concept
|
||||
status: active
|
||||
created: 2025-10-30
|
||||
updated: 2025-10-30
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags:
|
||||
- area/personal_development
|
||||
- topic/leitbild
|
||||
- method/scope
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.1.0
|
||||
depends_on:
|
||||
- leitbild-vorgehensmodell-2025
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
---
|
||||
|
||||
## Schlüsselpunkte (Session 0 – konsolidiert, 15 Punkte)
|
||||
1. **Auslöser & Kontext:** Schicksalsschlag (Glioblastom der Partnerin) → innerer Kurswechsel; neue Dreifachrolle (Research-Lead DE, Global IT-Cost, Trainee-Ausbilder).
|
||||
2. **Familienphase:** Söhne 18 & 15; der Jüngere braucht Bindung, Halt und klare, faire Grenzen.
|
||||
3. **Leitbild-Zweck:** Strategischer Alltagskompass (Entscheiden, Priorisieren, Grenzen); Messlatte für spätere Routinen — **keine** Operativ-Checkliste.
|
||||
4. **Vater-Legacy:** Präsenz in Krisen · Gerechtigkeit · Führen durch Vorbild; Vertrauen stärkt Selbstwirksamkeit & positives Menschenbild.
|
||||
5. **Partner-Leitbild:** Standhaft + annehmend + klar in Pflichten; **klare Zuständigkeiten ohne Überlastung** – Energie fließt in Aufgaben, nicht in Reibung.
|
||||
6. **Beruf-Legacy:** Zielbild-Denken, Lernoffenheit, Vision; Wissen großzügig teilen; hohe Akzeptanz & spürbare Lernkurven als Ausbilder/Coach.
|
||||
7. **Trainer-Legacy:** Freude an Bewegung; gelebte Budo-Werte; Resilienz durch Praxis.
|
||||
8. **Wertekern:** **Integrität** (Meta-Wert) & **Vertrauenswürdigkeit/Ehrlichkeit** (*Wort gilt*; bei Abweichung offene Korrektur & Entschuldigung).
|
||||
9. **Rote Linien:** (#3) Fairness – Macht/Kompetenz nicht ausnutzen · (#5) keine bequemen Entscheidungen gegen Kernprinzipien · **Reparatur-Garantie** (#8) binnen 24 h.
|
||||
10. **Ich-Pflege (Haltung):** Innere Balance durch Meditation, Sport, Ernährung, Vorsorge, Neugier/Begeisterungsfähigkeit.
|
||||
11. **Spannungsfelder & Hebel:** (1) Ordnung/Haushalt ↔ Zeit/Energie · (2) Respekt/Regeln ↔ Widerstand der Kinder · (3) unterschiedliche Rollenerwartungen; **größter Hebel:** gelebte Verantwortungsverteilung.
|
||||
12. **Offenheit & Tabus:** Leitbild grundsätzlich teilbar; **privat** bleiben intime Motive/Herkünfte. Ziele & Visionen sind offen – Verletzlichkeit wird akzeptiert.
|
||||
13. **90-Tage-Checks:** Familie (≥3 Kontakte/Woche + ≥1 Wochenendaktivität), Beruf (≥90 % Routine pünktlich; ≥10/12 Freitage Zero-Routine-Backlog), Ich-Pflege (≥4×/Woche Meditation+Dehnung ≥10′).
|
||||
14. **Nein-Liste (Quartal):** Keine zusätzlichen Karate-Trainings zulasten der Familie; keine Standard-Übernahme von Sushis Aufgaben (nur echte Notlage, befristet).
|
||||
15. **Haushalt/Ordnung – Mindeststandard & Reaktion:**
|
||||
- **Mindeststandard:** Ablageflächen/Böden frei von Fremdgegenständen; Küche morgens aufgeräumt; **kein sichtbarer Dreck**.
|
||||
- **Reaktion (Prinzip):** **Familienrat** statt Schuldzuweisung; Abweichung **respektvoll benennen**, **kurzfristige Aufgaben** festlegen; Stimmungsschutz als Leitlinie.
|
||||
|
||||
### Entscheidungsfokus (nächste 4 Wochen)
|
||||
- **Vater–Sohn-Projekt (Profil):** Hybrid *Bauen + Doku*; **Rohan = Owner**, Vater = **Coach**.
|
||||
**Leitbildsatz (collab):** „**Rohan ist Owner, ich bin Coach; Keyboard-Regel 90/10; ich frage, bevor ich erkläre.**“
|
||||
**Erfolgssignale:** (a) Rohan initiiert Gespräche/Impulse, (b) wählt Projektarbeit häufiger statt Social Media.
|
||||
**12-Wochen-Meilenstein:** von Rohan zu definieren (bei Projektstart festhalten).
|
||||
- **Rituale (strategisch):** Grundset persönlicher (Ich-Pflege) und gemeinsamer (Familie) Rituale definieren; Operativierung später.
|
||||
|
||||
### Kompass-Formel (Entscheiden) + „Schuldschein“-Mechanik
|
||||
- **Kompass-Formel:** „**Ich spiegle jede wichtige Entscheidung am Werte-Modell und priorisiere nach meinen Kernwerten.**“
|
||||
- **Ausnahme („Schuldschein“):** „**Wenn ich abweiche, dokumentiere ich schriftlich einen Schuldschein** (Abweichung, Begründung, Dauer, Wiedergutmachung); **Einbindung ins mindnet** & Review.“
|
||||
@@ -0,0 +1,84 @@
|
||||
---
|
||||
title: Leitbild – Werte (Top-5)
|
||||
id: leitbild-werte
|
||||
type: concept
|
||||
status: active
|
||||
created: 2025-10-30
|
||||
updated: 2025-10-30
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags:
|
||||
- topic/werte
|
||||
- method/values-inventory
|
||||
- area/personal_development
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
depends_on:
|
||||
- leitbild-scope
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
---
|
||||
|
||||
# Werte – Top-5 (Priorität für 12 Monate)
|
||||
|
||||
> Ziel: Präzise Definitionen, beobachtbare Verhaltensanker, Frühwarnsignale/„Nicht-so“-Grenzen (Anti-Muster) und je ein Mikro-Experiment **für später**.
|
||||
> Priorität: 1 **Integrität** · 2 **Vertrauenswürdigkeit/Ehrlichkeit** · 3 **Disziplin** · 4 **Gerechtigkeit & Fairness** · 5 **Respekt**
|
||||
|
||||
## 1) Integrität
|
||||
**Definition:** Ich handle **vorhersagbar principled** nach meinem Werte-Modell; **mein Wort gilt** – auch unter Druck.
|
||||
**So zeigt es sich (Anker):**
|
||||
- Entscheidungen werden **am Werte-Modell gespiegelt** (Kompass-Check).
|
||||
- **Keine bequemen Entscheidungen** gegen Kernprinzipien (#5).
|
||||
- **Schuldschein-Mechanik** bei unvermeidbarer Abweichung (transparent, befristet, Wiedergutmachung).
|
||||
**Frühwarnsignale:** Rigidität, moralischer Ton, fehlende situative Milde.
|
||||
**Überdrehungs-Risiko:** Moralismus statt Führung.
|
||||
**Mikro-Experiment (für später):** 4 Wochen „Kompass-Log“: 2×/Woche eine Entscheidung kurz am Werte-Modell dokumentieren.
|
||||
|
||||
## 2) Vertrauenswürdigkeit & Ehrlichkeit
|
||||
**Definition:** **Wort gilt**; wenn äußere Umstände es verhindern, **spreche ich es offen an** und entschuldige mich.
|
||||
**So zeigt es sich (Anker):**
|
||||
- Zusagen sind **verlässlich**; Ausnahmen werden **proaktiv** erklärt.
|
||||
- **Keine Vorteilslüge**; Fakten werden nicht „geschönt“.
|
||||
- **24h-Reparatur** bei Verstößen (#8).
|
||||
**Frühwarnsignale:** Überharter Umgang mit eigenen Fehlern; zu viel Offenheit in sensiblen Kontexten.
|
||||
**Überdrehungs-Risiko:** Verletzende Direktheit; Vertrauensbruch durch unbedachte Transparenz.
|
||||
**Mikro-Experiment (für später):** „Vertrauens-Echo“: 1×/Woche kurzes Feedback (Familie/Team) zur Verlässlichkeit einholen.
|
||||
|
||||
## 3) Disziplin
|
||||
**Definition:** **Ich halte zugesagte Standards und Regeln verlässlich ein und setze sie fair durch – auch wenn es unbequem ist.**
|
||||
**So zeigt es sich (Anker):**
|
||||
- **Wenige klare Regeln** werden **ruhig & konsequent** durchgesetzt (ohne Drama).
|
||||
- **Mindeststandards Haushalt** werden konsistent eingefordert (Familienrat statt Schuldzuweisung).
|
||||
- **Wichtiges vor Bequemem**: priorisierte Aufgaben vor Opportunitäten.
|
||||
**Frühwarnsignale:**
|
||||
- Ich **vergesse** zugesagte Durchsetzungen („Ich sammle das Handy in 10 Min ein“) und lasse es dann.
|
||||
- Ich **setze Konsequenzen nicht um** – aus **Mitleid** oder **Bequemlichkeit**.
|
||||
**Nicht-so-Grenze:** **Ich stelle dogmatische Disziplin nicht über die elementaren Bedürfnisse von Menschen (Kinder, Ehefrau, andere) und sorge dafür, dass niemand verletzt wird.**
|
||||
**Überdrehungs-Risiko:** Starrheit, Beziehungskälte, Mikromanagement, Selbstüberforderung.
|
||||
**Mikro-Experiment (für später):** 2 Wochen „Konsequenz-Minireview“: 2×/Woche 3 Sätze zu einer durchgesetzten/verschobenen Regel (fair? bequem? gelernt?).
|
||||
|
||||
## 4) Gerechtigkeit & Fairness
|
||||
**Definition:** Ich **behandle Menschen und Situationen nach klaren, transparenten Maßstäben**; ich **nutze keinen Macht-/Wissensvorsprung aus** und balanciere **Gleichbehandlung** mit **Bedarfsgerechtigkeit**.
|
||||
**So zeigt es sich (Anker):**
|
||||
- **Regeln gelten für alle** – auch für mich; **Ausnahmen** werden **begründet & transparent** gemacht.
|
||||
- **Konsequenzen sind verhältnismäßig und angekündigt**; keine impulsiven Strafen.
|
||||
- In Konflikten **höre ich beide Seiten**, fasse das stärkste Gegenargument fair zusammen (*Steelman*), **entscheide nach Prinzipien**.
|
||||
**Frühwarnsignale:** „Hauptsache Ruhe“ statt fairer Konsequenz; Parteilichkeit aus Erschöpfung.
|
||||
**Überdrehungs-Risiko:** Pedantischer Formalismus; **Gleichmacherei**; Härte ohne Kontext.
|
||||
**Bezug zu roten Linien:** Entspricht **#3** (Macht/Kompetenz nicht ausnutzen).
|
||||
**Mikro-Experiment (für später):** 2 Wochen „Fairness-Double-Check“ (Rollenwechsel-Frage & Bedarfs-Transparenz notieren).
|
||||
|
||||
## 5) Respekt
|
||||
**Definition:** **Ich erkenne jeden Menschen als unbedingt wertvoll und gleichwertig an.** Ich würdige **Bemühen und Prozess** – auch wenn Ergebnisse **nicht meinen Vorstellungen** entsprechen. Ich handle respektvoll und **erwarte** respektvollen Umgang.
|
||||
**So zeigt es sich (Anker – deine Auswahl):**
|
||||
- **Sprache ohne Abwertung** (kein Beschämen/Schreien); ich benenne Verhalten, nicht den Menschen.
|
||||
- **Aktives Zuhören & Steelman:** Ich fasse erst die Sicht des anderen fair zusammen, bevor ich antworte.
|
||||
- **Würdigung von Mühe & Prozess** (besonders bei den Kindern): Ich anerkenne Einsatz, nicht nur Ergebnis.
|
||||
**Nicht-so-Grenzen:**
|
||||
- **Ich antworte nicht**, ohne zuvor **wirklich verstanden** zu haben (keine Antworten auf Annahmen).
|
||||
- **Ich akzeptiere andere Meinungen und Sichtweisen.**
|
||||
- **Ich mache keine Unterschiede** aufgrund von Andersartigkeit.
|
||||
**Frühwarnsignale:** Sarkasmus/Augenrollen; Unterbrechen; genervter Ton; Vergleiche/Etiketten; Handy im Gespräch.
|
||||
**Überdrehungs-Risiko:** Harmoniesucht/Vermeidung; Grenzen verwässern, um „nett“ zu bleiben.
|
||||
**Mikro-Experiment (für später):** 2 Wochen „Respekt-Check“: 1 Gespräch/Tag bewusst präsent führen (kein Handy, Steelman in 1 Satz), am Ende 1 Würdigungs-Satz.
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: Leitbild – Wertekompass (vollständig)
|
||||
id: leitbild-wertekompass
|
||||
type: concept
|
||||
status: active
|
||||
created: 2025-10-30
|
||||
updated: 2025-10-30
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags:
|
||||
- topic/werte
|
||||
- method/values-compass
|
||||
- area/personal_development
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 0.2.0
|
||||
depends_on:
|
||||
- leitbild-werte
|
||||
- leitbild-scope
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
---
|
||||
|
||||
# Wertekompass – vollständige Übersicht
|
||||
|
||||
> Zweck: **Arbeitsinventar** aller relevanten Werte.
|
||||
> Nutzung: Der **Leitbild-Text** führt die **Top-5** (kurz & verbindlich); dieser **Kompass** dokumentiert zusätzlich **Unterstützungswerte** mit Kurzdefinition & Wächterfrage.
|
||||
|
||||
## Tier 1 – Kernwerte (Top-5, verbindlich)
|
||||
1. **Integrität** – Ich handle vorhersagbar principled; mein Wort gilt.
|
||||
2. **Vertrauenswürdigkeit & Ehrlichkeit** – Zusagen sind verlässlich; Abweichungen kläre ich offen.
|
||||
3. **Disziplin** – Ich halte zugesagte Standards/Regeln verlässlich ein und setze sie fair durch – auch wenn es unbequem ist.
|
||||
4. **Gerechtigkeit & Fairness** – Klare, transparente Maßstäbe; kein Macht-/Wissensvorsprung wird ausgenutzt.
|
||||
5. **Respekt** – Jeder Mensch ist unbedingt wertvoll/gleichwertig; ich würdige Mühe & Prozess.
|
||||
> Details zu Definitionen, Ankern, Frühwarnsignalen & „Nicht-so“-Grenzen stehen in `leitbild-werte`.
|
||||
|
||||
## Tier 2 – Unterstützungswerte **on deck** (12 Monate)
|
||||
> Deine Auswahl (konsolidiert & prioritätsneutral)
|
||||
|
||||
- **Fürsorge & Familienbindung (konsolidiert)**
|
||||
*Kurz:* Ich bin ansprechbar, sehe Bedürfnisse und stärke Bindung aktiv.
|
||||
*Anker:* Wöchentliche gemeinsame Qualitätszeit & kleine Würdigungen.
|
||||
*Wächterfrage:* Habe ich diese Woche **Präsenz** gezeigt – nicht nur „Anwesenheit“?
|
||||
|
||||
- **Klarheit & Struktur**
|
||||
*Kurz:* Wenige Regeln, klare Zuständigkeiten, einfache Standards – sichtbar in Raum & Sprache.
|
||||
*Anker:* „Wer macht was bis wann“ + sichtbare Mindeststandards (Haushalt).
|
||||
*Wächterfrage:* Ist das für alle **verständlich & auffindbar**?
|
||||
|
||||
- **Lernorientierung**
|
||||
*Kurz:* Neugierig bleiben, bewusst experimentieren, Lerngewinne teilen.
|
||||
*Anker:* „Teach-back“ als Standard (Familie/Team).
|
||||
*Wächterfrage:* Was habe ich diese Woche **gelernt** und **geteilt**?
|
||||
|
||||
- **Großzügigkeit**
|
||||
*Kurz:* Zeit/Wissen/Anerkennung teilen – im richtigen Maß.
|
||||
*Anker:* Anerkennung gezielt und konkret aussprechen.
|
||||
*Wächterfrage:* Dient meine Großzügigkeit dem **System** – oder verbrenne ich mich?
|
||||
|
||||
- **Mut**
|
||||
*Kurz:* Unangenehmes respektvoll ansprechen; nötige Neins setzen.
|
||||
*Anker:* „Klartext in 1–2 Sätzen, respektvoll, ohne Abwertung.“
|
||||
*Wächterfrage:* Weiche ich gerade aus **Bequemlichkeit** – oder spreche ich es an?
|
||||
|
||||
## Tier 2 – weitere Kandidaten (Reserve)
|
||||
- **Verantwortung (Ownership)** – in Reserve, falls im Jahresverlauf relevanter wird.
|
||||
|
||||
## Arbeitsregeln für den Wertekompass
|
||||
- **Änderungslog:** Anpassungen hier → Review im `leitbild-review`.
|
||||
- **Wertkonflikte:** Priorisierung folgt **Tier-Reihenfolge** (Top-5 vor „on deck“); Ausnahmen via **Schuldschein** (`decision/exception`).
|
||||
- **Öffentlich/Privat:** Leitbild-Text ist teilbar; intime Motive bleiben privat hier/im Journal.
|
||||
@@ -0,0 +1,228 @@
|
||||
---
|
||||
title: Leitbild – Ziele-Portfolio (Nordsterne komplett)
|
||||
id: leitbild-ziele-portfolio
|
||||
type: project
|
||||
status: active
|
||||
created: 2025-10-30
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [topic/ziele, method/objectives, scope/nordsterne]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
depends_on:
|
||||
- leitbild-rollen
|
||||
- leitbild-prinzipien
|
||||
- leitbild-text
|
||||
- ai-enablement-roadmap
|
||||
- mgmt-kpi-alignment-2026q1
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
- leitbild-review
|
||||
---
|
||||
|
||||
# Ziele-Portfolio (Nordsterne)
|
||||
|
||||
> Struktur pro Nordstern: **Warum (Impact)** · **Was (Outcome)** · **Wie (Strategie/Initiativen)** · **Messung** *(Leading/Lagging)* · **Jahresziel 2026** · **Meilensteine 2026**.
|
||||
> **Hinweis:** Alle Messpunkte fließen in `leitbild-review` (Woche/Monat/Quartal) ein.
|
||||
|
||||
---
|
||||
|
||||
## Nordstern: Vater (2026–2029)
|
||||
|
||||
**Nordstern-Satz:**
|
||||
Bis 2029 bin ich für Rouven und Rohan ein **verlässlich präsenter, ruhiger und gerechter** Vater; unsere **tägliche Nähe** und **respektvolle Führung** geben beiden **Halt und Selbstvertrauen**. Beide sind **eigenverantwortlich, sportlich aktiv, sozial eingebunden**; pro Quartal entsteht ein **Vater-Sohn-Projekt**; die **Mediennutzung** ist im Familienrat geregelt.
|
||||
|
||||
**Warum (Impact):** Stabilität, Selbstwirksamkeit, Charakterwachstum; friedliches, klares Familienklima.
|
||||
|
||||
**Was (Outcome):**
|
||||
- Verlässliche Alltagsnähe (tägliche 1:1-Momente).
|
||||
- Faire Führung mit wenigen, sichtbaren Regeln und zeitnaher Durchsetzung.
|
||||
- Haushalts-Mindeststandards sichtbar: *Ablagen/Böden frei · Küche morgens aufgeräumt · kein sichtbarer Dreck*.
|
||||
- Regelmäßige Projekte, Bewegung und soziale Einbindung.
|
||||
|
||||
**Wie (Strategie/Initiativen):**
|
||||
1) **Nähe & Rituale:** Täglich ≥5′ 1:1 je Sohn; Wochenritual fix/neu terminiert.
|
||||
2) **Faire Führung:** Regeln sichtbar; Konsequenzen **zeitnah** nach Bedürfnis-Check.
|
||||
3) **Standards sichtbar:** Check morgens; kurze Aufgabenverteilung.
|
||||
4) **Projekte:** **1/Q** je/mit Sohn; Kickoff + Retro.
|
||||
5) **Bewegung/Soziales:** ≥2 Bewegungseinheiten/Woche; Begleitung zu Gruppen/Events.
|
||||
6) **Medienbalance:** Familienrat: Kontingent + Monitoring ohne Beschämung.
|
||||
|
||||
**Messung**
|
||||
- *Leading:* 1:1 **≥5 Tage/W**; Wochenritual **≥48/52**; **Konsequenzen-Quote ≥90 %**; Standards **≥80 %**; Bewegung **≥75 %** der Wochen; Medienregeln **≥80 %** Wochen.
|
||||
- *Lagging:* **4/4** Quartalsprojekte; Konflikte **≤48 h** geklärt (≥90 %); Bindungsindex (Monat 1–10) **Ø ≥8** je Sohn.
|
||||
|
||||
**Jahresziel 2026:** 1:1 **≥5/7**, **4 Projekte**, Standards **≥80 %**, Medien **≥80 %**, Bewegung **≥75 %** der Wochen.
|
||||
|
||||
**Meilensteine 2026:** M1 **Jan 31** Regeln/Standards sichtbar · M2 **Mär 31** Projekt Q1 · M3 **Jun 30** Q2 · M4 **Sep 30** Q3 · M5 **Dez 15** Q4 + Jahresretro.
|
||||
|
||||
---
|
||||
|
||||
## Nordstern: Ich-Pflege (2026–2029)
|
||||
|
||||
**Nordstern-Satz:**
|
||||
Ich bin **belastbar, schmerzfrei trainierbar und mental ruhig**: **2–3×/W** Kraft/Bewegung, **4×/W** Meditation & Mobility, **histamin-/glutenbewusste Ernährung ohne „Cheat Days“**, ausreichend Schlaf, Monitoring & Check-ups.
|
||||
|
||||
**Warum (Impact):** Energie und Präsenz für Familie, Beruf, Dojo; nachhaltige Gesundheit.
|
||||
|
||||
**Was (Outcome):** Reha→Training, stabile Routinen, Ernährungspraxis ohne „alles-egal“-Fallen, Monitoring.
|
||||
|
||||
**Wie (Strategie/Initiativen):**
|
||||
1) **Kieser/Reha-Bridge:** progressiv (4-2-4-2; +5 % bei sauberer WH).
|
||||
2) **Bewegung:** ≥150 min/W moderat (Karate/Walk/Bike).
|
||||
3) **Zazen & Mobility:** **4×/W** 10–20′.
|
||||
4) **Ernährung:** 80/20 mediterran; **keine Cheat Days**; Fallback-Mahlzeiten + Einkaufsroutine.
|
||||
5) **Schlaf:** fester „Lights-out“-Korridor; keine Screen-Marathons.
|
||||
6) **Monitoring/Medizin:** wöch. Gewicht/Taille/BP; halbjährl. Labor/Arzt; Journal.
|
||||
7) **Relapse-Shield:** Abweichung ⇒ **Mini-Reset ≤24 h**.
|
||||
|
||||
**Messung**
|
||||
- *Leading:* Kraft/Reha **≥2×/W**; Bewegung **≥150 min/W (≥75 % Wochen)**; Zazen/Mobility **≥4×/W (≥40/52)**; Ernährung **≥6/7 Tage/W**; Hydration **≥5/7**; Monitoring **≥45/52**.
|
||||
- *Lagging:* Schmerzfrei trainierbar **spätestens Q3/2026**; Energie-Ø **≥8/10**; Check-ups **2/Jahr**.
|
||||
|
||||
**Jahresziel 2026:** **8/12** Monate mit ≥4 Lead-Routinen erfüllt; Reha→Volltraining bis **Q3**; Monitoring **≥45/52**.
|
||||
|
||||
**Meilensteine 2026:** M1 **Jan 15** Baseline+Fallbacks · M2 **Feb 15** Reha-Compliance ≥70 % · M3 **Apr 30** 60–70 % Last · M4 **Jun 30** Volltraining · M5 **Sep 30** Check-up · M6 **Nov 30** Jahresretro.
|
||||
|
||||
---
|
||||
|
||||
## Nordstern: Karate & Gewaltschutz (inkl. Traineraufbau) (2026–2029)
|
||||
|
||||
**Nordstern-Satz:**
|
||||
Mein Trainingsangebot steht für **Freude an Bewegung**, **gelebte Budo-Werte** und **Kindeswohl**: **klare Reifegradpfade**, **sichere Progression**, **starke Feedbackkultur**. Jährlich **2–3 Erlebnisformate** + **1–2 soziale/offene Angebote**. Ein **verlässliches Traineraufbau-System** (S1 Shadowing → S4 Lead) skaliert Qualität und Kapazität.
|
||||
|
||||
**Warum (Impact):** Charakterbildung, Teamgeist, sichere Bewegung; soziale Wirkung über den Verein; skalierbares Trainerteam.
|
||||
|
||||
**Was (Outcome):** Lernpfade & Assessments, Kinderschutz, Erlebnisformate, Elternkommunikation, Trainer-Pipeline.
|
||||
|
||||
**Wie (Strategie/Initiativen):**
|
||||
1) **Didaktik/Progression:** Pfad je Gruppe, Quartalsziele, **Micro-Assessments/Monat**.
|
||||
2) **Kinderschutz:** Schutzkonzept aktuell; **Stop-Signal-Drill ≥1×/Monat**; Doku.
|
||||
3) **Erlebnisformate:** **2–3/Jahr** (KaraGames/Camp/Wald) + **1–2** offen/sozial.
|
||||
4) **Kommunikation:** Onboarding-Handout; **2 Elterninfos/Jahr**; Feedbackkanal.
|
||||
5) **Traineraufbau:** Scouting → Infoabend → Mentoring (Monat) → **Co-Teaching** → Peer-Reviews → **Teil-Lead/Lead**; Einsatzplan.
|
||||
6) **Fortbildung:** **≥2 Lehrgänge/Jahr** + **≥2 Hospitationen/Jahr**.
|
||||
|
||||
**Messung**
|
||||
- *Leading:* Pfade **quartalsaktualisiert**; **Stop-Signal** **≥1×/Monat**; **≥3 Events/Jahr**; Pipeline: **≥6 Interessenten/Jahr**, **≥4 Mentees**, **≥8 Co-Teachings/Mentee**, **≥2 Peer-Reviews/Jahr**.
|
||||
- *Lagging:* **≥2 neue Leads/Jahr**, Retention **≥80 %**; **≥30 %** Einheiten von Co/Lead abgedeckt; Feedback **Ø ≥4.5/5**; **0** meldepflichtige Unfälle.
|
||||
|
||||
**Jahresziel 2026:** Curriculum & Rubric live; **≥6 Interessenten**, **≥4 Mentees**, **≥2 neue Leads**; **≥30 %** Co/Lead-Abdeckung; **Coach-the-Coach 4×**.
|
||||
|
||||
**Meilensteine 2026:** M1 **Feb 15** Curriculum/Rubric & Infoabend · M2 **Mär 31** Shadowing live · M3 **Jun 30** Co-Teaching+Peer-Review #1 · M4 **Sep 30** Teil-Lead/Offen-Event · M5 **Nov 30** Leads+Peer-Review #2.
|
||||
|
||||
---
|
||||
|
||||
## Nordstern: Partner (2026–2029)
|
||||
|
||||
**Nordstern-Satz:**
|
||||
Wir führen unseren Alltag ** als Team** mit **klaren Zuständigkeiten**, **fair verteilter Last** und **wertschätzender Kommunikation**. **Paar-Rituale** sind verbindlich, **Konflikte** klären wir **≤48 h**; **Energie & Gesundheit** sind geschützt.
|
||||
|
||||
**Warum (Impact):** Stabiler, freundlicher Paar-Alltag; weniger Reibung, mehr Nähe; bessere Familienunterstützung.
|
||||
|
||||
**Was (Outcome):**
|
||||
- **Rollen-/Aufgabenmatrix** sichtbar und gelebt; Monats-Review.
|
||||
- **Weekly Load-Check (10′)**; klare Neupriorisierung.
|
||||
- **Paar-Ritual** wöchentlich, Monats-Date.
|
||||
- **Gesundheit/Rest** im Kalender first-class.
|
||||
- **Konflikt-Hygiene:** Steelman · Time-out ≤30′ (mit Rückkehrzeit) · Klärung ≤48 h.
|
||||
|
||||
**Wie (Strategie/Initiativen):**
|
||||
1) **Team-Board & SLAs** (Küche, Wäsche …).
|
||||
2) **Load-Check** (Kalenderabgleich, Überlast sichtbar, Entscheidung jetzt).
|
||||
3) **Rituale:** 1×/W 60–90′; Monats-Date; tägliche Anerkennung (1 Satz).
|
||||
4) **Schutz:** Rest-Fenster blocken; med. Termine nie streichen, nur verschieben.
|
||||
5) **Konflikt-Hygiene:** Steelman, Time-out ≤30′, Klärung ≤48 h; **Decision Notes**.
|
||||
6) **Familienrat light:** 1×/Monat Regeln/Termine mit den Söhnen.
|
||||
|
||||
**Messung**
|
||||
- *Leading:* Load-Check **≥48/52**; Paar-Ritual **≥45/52**; Anerkennung **≥5/7 Tage/W**; med. Termine **0 gestrichen**; Klärung **≤48 h** in **≥90 %**; ungeplante Zusagen **≤2/Monat**.
|
||||
- *Lagging:* Fairness-/Zufriedenheitsindex **Ø ≥8/10**; Stress/Energie-Trend ↑; Paar-Ritual-Kontinuität **≥85 %**; **0** verpasste med. Termine ohne Re-Terminierung.
|
||||
|
||||
**Jahresziel 2026:** Matrix live; Cadence stabil (Load-Check ≥48×; Paar-Ritual ≥45×; Date ≥10×); Konflikt-Klärung **≥90 %** ≤48 h.
|
||||
|
||||
**Meilensteine 2026:** M1 **Jan 15** Matrix/Standards & Kalender-Sichtbarkeit · M2 **Jan 31** Rituale fix · M3 **Mär 31** Q1-Review · M4 **Jun 30** Midyear · M5 **Sep 30** Q3 · M6 **Nov 30** Jahresretro.
|
||||
|
||||
---
|
||||
|
||||
## Nordstern: Freund – **Neuaufbau, wertebasiert** (2026–2029)
|
||||
|
||||
**Nordstern-Satz:**
|
||||
Bis 2029 habe ich einen **neuen Freundeskreis auf Augenhöhe** aufgebaut: **konstruktiv, intellektuell und/oder sportlich**, mit **gemeinsamen Interessen**, **guten Gesprächen**, **Verlässlichkeit**, **gegenseitiger Unterstützung** und **emotionaler Nähe** – **ohne alkoholzentrierte Milieus**.
|
||||
|
||||
**Warum (Impact):** Inspirierendes, tragfähiges Netz; Energie & Resilienz; stimmige Wertepassung.
|
||||
|
||||
**Was (Outcome):**
|
||||
- **Kernkreis 6–10 Personen** definiert & gepflegt.
|
||||
- **2–3 Mikro-Rituale/Clubs** (Laufen, Buch/Essay, Maker/Smart-Home).
|
||||
- **Kontakt-Cadence** & **Mikro-Events** etabliert.
|
||||
- **Filter:** Integrität, Respekt, Lernorientierung; kein Alkohol-Milieu.
|
||||
|
||||
**Wie (Strategie/Initiativen):**
|
||||
1) **Kanäle:** Sport (Lauf/Wandern, Karate-Erwachsene), Tech/Maker (Home-Assistant/ESP32), Buch/Essay, Gemeinwohl (Gewaltschutz), berufl. low-stakes Salon.
|
||||
2) **Pipeline/Filter:** Interessentenliste; 90-Tage-Zyklus (Erstkontakt → 1:1 → Mikro-Event → Fit-Check).
|
||||
3) **Mikro-Events (Monat):** Walk & Talk, Buch-Impuls, Maker-Saturday, Kata & Coffee.
|
||||
4) **Rituale/Clubs:** Running (W), Buch/Essay (M), Maker-Lab (M).
|
||||
5) **Beziehungs-Hygiene:** Ask-before-advice, Vertraulichkeit, Grenzen/Familienzeit.
|
||||
|
||||
**Messung**
|
||||
- *Leading:* **≥2** qualifizierte neue Kontakte/Monat; **≥4** 1:1/Monat; **≥1** Mikro-Event/Monat; **≥2** Clubs aktiv; 90-Tage-Follow-ups **≥80 %**.
|
||||
- *Lagging:* Kernkreis **≥6 bis 12/2026**, **6–10 stabil bis 2029**; **≥4** starke Bindungen bis 12/2026; Beziehungsqualität **Ø ≥8/10**; ungelöste Konflikte >48 h **≤2/Jahr**.
|
||||
|
||||
**Jahresziel 2026:** **3 Kanäle aktiv**, **2 Clubs** gegründet, **12 Mikro-Events**, **≥24 Erstkontakte**, **≥40 1:1s**, **≥4 starke Bindungen**, Kernkreis **≥6**.
|
||||
|
||||
**Meilensteine 2026:** M1 **Jan 31** Kanäle/Filter & 10 Namen · M2 **Mär 31** Buch-Club+Running gestartet · M3 **Jun 30** Maker-Lab + 12 1:1s · M4 **Sep 30** Kernkreis ≥6 · M5 **Nov 30** 10 Mikro-Events kumuliert.
|
||||
|
||||
---
|
||||
|
||||
## Nordstern: Berufsrolle (Umbrella) – **AI-first & lernorientiert** (2026–2029)
|
||||
|
||||
**Nordstern-Satz:**
|
||||
In meiner Rolle als **Advisor/Research Lead & Ausbilder** arbeite ich konsequent **AI-first**: **evidenzbasierte Einsichten**, **nachhaltige IT-Kostenreduktion ohne Wertverlust** und **steile Lernkurven** – **verlässlich, reproduzierbar, menschenzentriert, compliant**.
|
||||
|
||||
**Warum (Impact):** Mehr Wirkung/Tempo, bessere Entscheidungen, entlastete Kapazität – ohne Hero-Modus und ohne Familienzeit zu kompromittieren.
|
||||
|
||||
**Was (Outcome):**
|
||||
- **AI-Arbeits-System** (Priorisierung, Guardrails, Reviews, Use-Logs) ist sichtbar und gelebt.
|
||||
- **A1/A2/A3** nutzen KI **rollenangemessen** (Research-Pipelines, Savings-Analytik, Curriculum).
|
||||
- **Assets/Reuse** statt Einmal-Outputs (Prompt-Kits, Playbooks, Checklisten, Datasets).
|
||||
|
||||
**Wie (Strategie/Initiativen – cross-cutting):**
|
||||
1) **AI-OS v1:** ≤3 OKRs/Säule; Weekly Top-3; Decision-Notes; keine stillen Scope-Changes.
|
||||
2) **Guardrails & Compliance:** Datenschutz/IP; Quellen/Annahmen offen; Hallu-Checks; Human-in-the-loop.
|
||||
3) **A1 Research:** Retrieval/Synthese; **1 Insight/Monat**, **1 Deep-Dive/Quartal** (AI-gestützt, reproduzierbar).
|
||||
4) **A2 IT-Kosten:** Savings-Scanner & Playbooks; **Clinics ≥2/Monat** (Ø ≥4.5/5).
|
||||
5) **A3 Ausbildung:** **AI-Curriculum** (Literacy, Prompts, Cases, Ethik), Rubrics, Teach-back.
|
||||
6) **Assetisierung/Reuse:** **≥2 AI-Assets/Quartal**, Reuse-Quote ↑.
|
||||
|
||||
**Messung (bis Management-Abgleich ohne harte Business-Zahlen)**
|
||||
- *Leading:* OTQ **≥90 %**; **AI-Use-Log je Deliverable**; **Assets ≥2/Quartal**; **Clinics ≥2/Monat (Ø ≥4.5/5)**; Research-Cadence erfüllt; **monatliches Steering** A1/A2/A3.
|
||||
- *Lagging:* **Stakeholder-NPS intern ≥8/10**; **Savings-Pipeline KPI = TBD mit Management**; Placement-Rate (A3) **≥95 %**, Evaluation **≥4.6/5**; **Research-Reuse ≥50 %**.
|
||||
|
||||
**Jahresziel 2026:** Q1 **KPI-Rahmen** mit Management fixiert; **AI-OS v1** live; **≥8 AI-Assets/Jahr**; Cadence erfüllt; Case-Library aufgebaut.
|
||||
|
||||
**Meilensteine 2026:** M1 **Jan 31** KPI/Guardrails frei · M2 **Mär 31** Q1-Review · M3 **Jun 30** Mid-Year (AI-OS v1→v1.1) · M4 **Sep 30** Q3-Review · M5 **Nov 30** Jahresretro.
|
||||
|
||||
---
|
||||
|
||||
## Risiken & Guardrails (global, Kurzverweis)
|
||||
- **Overcommitment, Perfektionismus, Kontextwechselkosten** → siehe `leitbild-risiken-anti-patterns`.
|
||||
- **KI & Compliance** → `ai-enablement-roadmap` Guardrails befolgen.
|
||||
|
||||
---
|
||||
---
|
||||
release:
|
||||
version: 1.0.0
|
||||
date: 2025-10-31
|
||||
status: frozen
|
||||
notes:
|
||||
- Content-Freeze aller Nordsterne inkl. KPIs & Meilensteine 2026
|
||||
- AI-first Berufsrolle verankert; Savings-KPI bewusst externalisiert
|
||||
- Review-Verknüpfung & Risiko-Log referenziert
|
||||
external_dependencies:
|
||||
- id: mgmt-kpi-alignment-2026q1
|
||||
scope: "Savings-KPI (A2) gemeinsam mit Management festlegen"
|
||||
target_date: 2026-03-31
|
||||
---
|
||||
@@ -0,0 +1,132 @@
|
||||
---
|
||||
title: Persönliches Leitbild (2025–2029)
|
||||
id: leitbild-text
|
||||
type: concept
|
||||
status: active
|
||||
created: 2025-10-31
|
||||
updated: 2025-10-31
|
||||
area: personal_development
|
||||
project: leitbild_refresh_2025
|
||||
tags: [leitbild, werte, prinzipien, rollen, nordsterne, ich-perspektive]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
depends_on:
|
||||
- leitbild-werte
|
||||
- leitbild-prinzipien
|
||||
- leitbild-rollen
|
||||
- leitbild-ziele-portfolio
|
||||
- leitbild-rituale-system
|
||||
references:
|
||||
- "/mnt/data/Lars- Mein Leitbild.pdf"
|
||||
- leitbild-review
|
||||
- leitbild-start-experiment-2025-11-01
|
||||
---
|
||||
|
||||
# Wer ich bin
|
||||
Ich bin Lars. Ich stehe für Verlässlichkeit, klare Haltung und freundliche Konsequenz.
|
||||
Schicksalsschläge haben mich geerdet, nicht gebrochen. Ich wähle jeden Tag bewusst: **präsent sein, fair handeln, vorleben statt fordern**.
|
||||
|
||||
# Wofür ich jeden Morgen aufstehe
|
||||
Ich baue ein Zuhause, in dem meine Kinder wachsen können – sicher, gesehen und gefordert.
|
||||
Ich pflege meine Partnerschaft mit Wärme, Humor und Klarheit.
|
||||
Ich diene anderen als Trainer, Berater und Ausbilder: **ideenreich, integer, wirksam**.
|
||||
Ich bleibe lernend – Gesundheit, Geist und Neugier sind meine Energiequellen.
|
||||
|
||||
---
|
||||
|
||||
# Meine Kernwerte (kompakt)
|
||||
- **Integrität** – Ich handle im Einklang mit meinen Werten. **Wort = Verpflichtung.** Wenn ich abweiche, sage ich es offen und repariere.
|
||||
- **Disziplin (mit Menschlichkeit)** – Ich bin mir selbst gegenüber konsequent, besonders bei Unangenehmem. **Regeln gelten freundlich, fair, zuverlässig.**
|
||||
- **Respekt** – Jeder Mensch ist wertvoll und gleichwürdig. Ich höre erst zu, bevor ich antworte. Keine Abwertung, keine Beschämung.
|
||||
|
||||
**Ergänzende Leitwerte:** Fürsorge & Familienbindung · Klarheit & Struktur · Lernorientierung · Großzügigkeit · Mut.
|
||||
|
||||
---
|
||||
|
||||
# Handlungsprinzipien (Auszug)
|
||||
- **Vorbild vor Anspruch.** Was ich erwarte, lebe ich zuerst.
|
||||
- **Verstehen vor Antworten.** Ich kläre Wahrnehmung und Absicht, bevor ich urteile.
|
||||
- **Klares Ja/Nein.** Grenzen schützen Fokus und Beziehungen.
|
||||
- **Freundlich–konsequent.** Regeln werden fair erklärt, konsequent eingehalten und respektvoll durchgesetzt.
|
||||
- **Repair first.** Wenn ich verletze, kläre ich zeitnah, ehrlich und ohne Ausflüchte.
|
||||
- **Weniger, dafür besser.** WIP-Limit statt Übercommitment.
|
||||
- **Gesundheit ist Basis.** Meditation, Bewegung, Ernährung, medizinische Checks.
|
||||
- **AI-first, human-led.** Technologie erhöht meine Wirksamkeit – Verantwortung bleibt bei mir.
|
||||
|
||||
---
|
||||
|
||||
# Rollen & Missionen
|
||||
## Vater
|
||||
Ich bin präsent, fair und verlässlich. Ich stärke Bindung und Selbstwirksamkeit meiner Söhne – jeden Tag ein kleines, echtes Gespräch und klare, nachvollziehbare Standards.
|
||||
**Qualitätskriterien:** Nähe spürbar · Regeln werden verstanden und eingehalten · Ich halte Konsequenzen ohne Härte, mit Haltung.
|
||||
|
||||
## Partner
|
||||
Ich bin ein zugewandter, klarer Partner. Ich teile Lasten, höre zu, entscheide mit – und wir schaffen Rituale für Nähe und Leichtigkeit.
|
||||
|
||||
## Karate- & Gewaltschutztrainer (inkl. Traineraufbau)
|
||||
Ich vermittle Freude an Bewegung, Budo-Werte und Selbstwirksamkeit. Ich baue ein verlässliches Lernumfeld und entwickle neue Trainer*innen – strukturiert, achtsam, kindeswohlorientiert.
|
||||
|
||||
## Freund (Neuaufbau)
|
||||
Ich kultiviere einen Kreis auf Augenhöhe: verlässlich, neugierig, sportlich oder intellektuell – mit echten Gesprächen, gegenseitiger Unterstützung und Nähe.
|
||||
|
||||
## Berufsrolle (AI-first)
|
||||
Ich verbinde Research-Tiefe, IT-Kostensenkung und Ausbildung. Ich teile Wissen großzügig, baue belastbare Hypothesen und Assets, und erziele Wirkung für Kunden und Kolleg*innen – integer und transparent.
|
||||
|
||||
---
|
||||
|
||||
# Nordsterne (2025–2029)
|
||||
1) **Vater:** Starke Bindung, klare Standards, faire Konsequenz.
|
||||
2) **Ich-Pflege:** Ruhe, Beweglichkeit, Klarheit – getragen von Ritualen.
|
||||
3) **Karate & Gewaltschutz (+ Traineraufbau):** Sicheres Lernökosystem, das wächst und trägt.
|
||||
4) **Partner:** Nähe, Humor, gemeinsame Entscheidungen.
|
||||
5) **Freund (Neuaufbau):** Verlässliches Netzwerk mit Tiefe und Freude.
|
||||
6) **Beruf (AI-first):** Wirksame Assets & Ausbildung mit messbarem Kundennutzen.
|
||||
|
||||
---
|
||||
|
||||
# Rituale als Systeme (NACh – Nächste Aktion · Trigger · Check)
|
||||
Ich vertraue nicht auf Willenskraft, sondern auf Systeme:
|
||||
- **R1** Meditation 20′ (morgens, ruhiger Block)
|
||||
- **R2** Mobility 10′ (erste 10′ des Lunch)
|
||||
- **R3** Journal (bevor das Licht ausgeht)
|
||||
- **R4** Familienrat light 14-tägig (So 14:00)
|
||||
- **R5** Paar-Ritual Tanzen (So 17:00)
|
||||
- **R6** 1:1 Rohan 5′ (nach Abendessen)
|
||||
- **R7** 1:1 Rouven 20–30′ (Sa 11:00)
|
||||
**Regel bei Ausfall:** Mini-Reset ≤24 h (kein „alles-egal“).
|
||||
*Details & Messung siehe `leitbild-rituale-system`.*
|
||||
|
||||
---
|
||||
|
||||
# Standards & Grenzen (Guardrails)
|
||||
- **Zuhause:** Ablagen/Böden frei, Küche morgens aufgeräumt, kein sichtbarer Dreck.
|
||||
- **Zeit:** Familie geht vor zusätzlichen Vereins-/Aufgaben – keine Mehrbelastung zulasten der Bindung.
|
||||
- **Konsequenzen:** Angekündigte Schritte werden umgesetzt – freundlich, fair, ohne Demütigung.
|
||||
- **Nein-Liste:** Keine neuen Verpflichtungen, die Nordsterne verwässern.
|
||||
- **Transparenz:** Abweichungen dokumentiere ich als **Deviation Note („Schuldschein“) – mit Begründung und Repair-Schritt**.
|
||||
|
||||
---
|
||||
|
||||
# Messung & Review
|
||||
- **Weekly (20–30′):** Scoreboard füllen → kurze Reflexion → **eine** Decision Note.
|
||||
- **Monthly (45–60′):** Roll-up der KPIs, Top-3 Outcomes, Risiken + Gegenmaßnahmen.
|
||||
- **Quarterly (90′):** Nordsterne/Meilensteine prüfen, Kurs justieren.
|
||||
*Templates & CSVs siehe `leitbild-review`.*
|
||||
|
||||
---
|
||||
|
||||
# Öffentliche Haltung & privater Kern
|
||||
Dieses Leitbild darf gelesen und gespiegelt werden. **Private Motive und Startpunkte bleiben bei mir.**
|
||||
Ich nehme Feedback an, sofern es meine Werte schärft und die Wirkung erhöht.
|
||||
|
||||
---
|
||||
|
||||
# Leitsatz
|
||||
**Stark im Herzen. Klar im Handeln. Fair im Umgang.**
|
||||
Ich bin verlässlich – für meine Familie, für mein Team, für mich.
|
||||
|
||||
---
|
||||
|
||||
# Changelog
|
||||
- **1.0.0 (2025-10-31):** Erstfassung auf Basis von Sessions 0–5, inkl. Werte, Prinzipien, Rollen, Nordsterne, Rituale, Review-System.
|
||||
@@ -0,0 +1,252 @@
|
||||
---
|
||||
title: Leitbildentwicklung – Generischer Prozessleitfaden
|
||||
id: leitbild-prozess-guide
|
||||
type: concept
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [leitbild, prozess, leitfaden, templates, review, habits, okr, coaching]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
references:
|
||||
- template-wert
|
||||
- template-prinzip
|
||||
- template-rolle
|
||||
- template-nordstern
|
||||
- template-milestone
|
||||
- template-ritual-nach
|
||||
- template-decision-note
|
||||
- template-deviation-note
|
||||
- template-review-daily
|
||||
- template-review-weekly
|
||||
- template-review-monthly-leitbild
|
||||
- template-review-quarterly-leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Zweck & Überblick
|
||||
|
||||
Dieser Leitfaden beschreibt **einen wiederholbaren, praxisnahen Prozess** zur Entwicklung eines **persönlichen Leitbildes** – von der Klärung des Kontextes bis zur Umsetzung mit Ritualen und Reviews. Er ist **generisch** formuliert (ohne personenbezogene Inhalte) und greift auf bewährte Methoden zurück: „Begin with the end in mind“ (Covey), OKR/North Star für Ziele, NACh/Implementation Intentions für Rituale, GROW für die Dialogführung sowie Review-/Scoreboard-Mechaniken für die Umsetzung. :contentReference[oaicite:0]{index=0}
|
||||
|
||||
> **Artefakt-Formate:** Alle Ergebnisse sind Markdown-Notizen mit YAML-Frontmatter (mindnet-kompatibel). Verweise/Edges über `references`, `depends_on`, `belongs_to`.
|
||||
|
||||
---
|
||||
|
||||
# Prozessstruktur (Sessions 0–6)
|
||||
|
||||
Jede Session enthält: **Ziel**, **Input** (aus vorigen Schritten), **Methode/Didaktik**, **Leitfragen**, **Output/Artefakte**, **Definition of Done (DoD)** und **Edges** (Vernetzung der Notes).
|
||||
|
||||
---
|
||||
|
||||
## Session 0 – Setup & Scope (30–45′)
|
||||
**Ziel:** Ausgangslage, Rollen, Spannungsfelder und Erwartung an das Leitbild klären; **Scope** und **DoD** definieren.
|
||||
|
||||
**Input:** Vorhandene Notizen/Dokumente (z. B. altes Leitbild), aktuelle Rollen/Großprojekte.
|
||||
|
||||
**Methode/Didaktik:**
|
||||
- **GROW**-Rhythmus in kurzen, sequenziellen Frageblöcken (Goal → Reality → Options → Will). :contentReference[oaicite:1]{index=1}
|
||||
- **„Vom Ende her denken“** als Haltung (Leitstern). :contentReference[oaicite:2]{index=2}
|
||||
|
||||
**Leitfragen (Auszug):**
|
||||
- *Goal:* Wozu wird das Leitbild **jetzt** gebraucht? Welche Entscheidungen soll es stützen?
|
||||
- *Reality:* Welche Rollen/Verantwortungen bestehen? Wo sind Spannungsfelder?
|
||||
- *Options:* Welche 2–3 Wege gibt es, um sofort Nutzen zu stiften?
|
||||
- *Will:* Was ist **in Scope** / **out of Scope** der nächsten Wochen?
|
||||
|
||||
**Output/Artefakte:** `leitbild-scope` *(concept)* – **10–15** prägnante Bullet-Points.
|
||||
|
||||
**DoD:** Scope klar, Zielbild-Rahmen definiert, Eingangsmaterial referenziert (`references`).
|
||||
|
||||
**Edges:** `leitbild-scope` → `leitbild-prozess-guide` (*belongs_to*), `references` auf Quellen/Altmaterial.
|
||||
|
||||
---
|
||||
|
||||
## Session 1 – Werteinventur & Anti-Muster (60–90′)
|
||||
**Ziel:** **Top-Werte** priorisieren (Tier-1/Tier-2) und **Verhaltensanker** + **Repair-Strategien** definieren.
|
||||
|
||||
**Input:** `leitbild-scope`.
|
||||
|
||||
**Methode/Didaktik:**
|
||||
- Werte-Cards (gedanklich) + **Extremfall-Kontraste** (Wann kippt ein Wert in sein Überdrehungs-Risiko?).
|
||||
- Formate aus **`template-wert`**: Definition · Alltagsanker · Überdrehung · **Repair** · **Mikro-Experiment**.
|
||||
|
||||
**Leitfragen (Auszug):**
|
||||
- Welche 3 Werte sind **nicht verhandelbar**? Woran **sehen** andere sie im Alltag?
|
||||
- Wann kippt der Wert (z. B. „Disziplin ohne Menschlichkeit“)?
|
||||
- Welche **erste Reparaturhandlung** setze ich, wenn ich gegen den Wert verstoße?
|
||||
|
||||
**Output/Artefakte:** `leitbild-werte` *(concept)* – priorisiert (Tier-1/Tier-2) mit Ankern & Repair-Sätzen.
|
||||
|
||||
**DoD:** Für jeden Kernwert existieren **3 beobachtbare Anker** und eine **Repair-Formulierung**.
|
||||
|
||||
**Edges:** `leitbild-werte` → `leitbild-scope` (*depends_on*).
|
||||
|
||||
---
|
||||
|
||||
## Session 2 – Prinzipien (testbar) (60–90′)
|
||||
**Ziel:** **Handlungsprinzipien** formulieren – **prägnant, beobachtbar, prüfbar**.
|
||||
|
||||
**Input:** `leitbild-werte`.
|
||||
|
||||
**Methode/Didaktik:**
|
||||
- Ableitung aus Tier-1-Werten; Format **`template-prinzip`**: **Satz** · **3 Signale** · **Grenzfall/Trade-off** · **Wächterfrage**.
|
||||
- „**Verstehen vor Antworten**“ & **Repair first** als wiederkehrende Prüfsteine (NVC-kompatibel). :contentReference[oaicite:3]{index=3}
|
||||
|
||||
**Leitfragen (Auszug):**
|
||||
- Welcher **aktive Satz** bringt das Prinzip auf den Punkt?
|
||||
- Welche **3 Signale** zeigen im Alltag, dass das Prinzip gelebt wurde?
|
||||
- In welchem **Grenzfall** ist Abweichen legitim – und wie mache ich es **transparent**?
|
||||
|
||||
**Output/Artefakte:** `leitbild-prinzipien` *(concept)* – je Prinzip 1–2 Sätze + Signale + Wächterfrage.
|
||||
|
||||
**DoD:** Pro Prinzip existieren **Signale** und **eine Wächterfrage**, die im Review einsetzbar ist.
|
||||
|
||||
**Edges:** `leitbild-prinzipien` ↔ `leitbild-werte` (*references* beidseitig).
|
||||
|
||||
---
|
||||
|
||||
## Session 3 – Rollen-Missionen & Qualitätskriterien (60–90′)
|
||||
**Ziel:** **Rollenlandkarte** präzisieren; je Rolle **Mission** (1–2 Sätze) & **3–5 Qualitätskriterien**, **Grenzen/Nein-Liste**.
|
||||
|
||||
**Input:** `leitbild-prinzipien`, `leitbild-werte`.
|
||||
|
||||
**Methode/Didaktik:**
|
||||
- **Lebensende-Test** (vom Ende her: „Was sollen Wegbegleiter über mich sagen?“). :contentReference[oaicite:4]{index=4}
|
||||
- Rollen-Canvas per **`template-rolle`** (Mission · Qualitätskriterien · Grenzen · Stakeholder).
|
||||
|
||||
**Leitfragen (Auszug):**
|
||||
- Wofür **existiert** diese Rolle (Mission)? Woran erkennt man **Qualität**?
|
||||
- Welche **Grenzen** halte ich, um nicht zu überlasten (Nein-Liste, SLAs)?
|
||||
- Wer sind die **Stakeholder** – und welche Erwartungen will ich **sichtbar** bedienen?
|
||||
|
||||
**Output/Artefakte:** `leitbild-rollen` *(concept)* – pro Rolle ein ausgefülltes Template.
|
||||
|
||||
**DoD:** Alle aktiven Rollen besitzen Mission, 3–5 Qualitätskriterien und eine **Nein-Liste**.
|
||||
|
||||
**Edges:** `leitbild-rollen` → `leitbild-prinzipien` & `leitbild-werte` (*references*).
|
||||
|
||||
---
|
||||
|
||||
## Session 4 – Zielbild & Weg (Nordsterne → Jahresziele → Meilensteine) (90′)
|
||||
**Ziel:** 3–5 **Nordsterne** (3–5 Jahre), **Jahresziele** und **erste Meilensteine** mit **Lead/Lag**-Messlogik.
|
||||
|
||||
**Input:** `leitbild-rollen`, `leitbild-prinzipien`.
|
||||
|
||||
**Methode/Didaktik:**
|
||||
- **OKR/North Star** adaptiert: Warum (Impact) · Was (Outcome) · Wie (Strategie/Initiativen) · Messung (Lead/Lag). :contentReference[oaicite:5]{index=5}
|
||||
- Meilensteine per **`template-milestone`**.
|
||||
|
||||
**Leitfragen (Auszug):**
|
||||
- **Warum** ist der Nordstern wichtig (für wen ändert sich was)?
|
||||
- **Lead**-Metriken (früh, beeinflussbar) vs. **Lag**-Metriken (Ergebnis) – was ist prädiktiv?
|
||||
- Welche **2–3 Initiativen** zahlen sicher auf das Outcome ein?
|
||||
|
||||
**Output/Artefakte:** `leitbild-ziele-portfolio` *(project)* + `milestone`-Notes.
|
||||
|
||||
**DoD:** Jeder Nordstern hat mind. **1 Lead- und 1 Lag-Metrik** + **2 Initiativen**.
|
||||
|
||||
**Edges:** Ziele `depends_on` Rollen/Prinzipien; Meilensteine `belongs_to` Ziel.
|
||||
|
||||
---
|
||||
|
||||
## Session 5 – Rituale & Systeme (NACh statt Willenskraft) (60–90′)
|
||||
**Ziel:** **Ritual-OS** aus wenigen, verlässlichen Routinen: für jeden Ritualpunkt **NACh** (Nächste Aktion · Trigger · Check) + **Backup/Fallback** + **Cues**.
|
||||
|
||||
**Input:** `leitbild-ziele-portfolio`, `leitbild-prinzipien`, `leitbild-rollen`.
|
||||
|
||||
**Methode/Didaktik:**
|
||||
- **Implementation Intentions** („Wenn [Trigger], dann [Aktion] – Check: …“). :contentReference[oaicite:6]{index=6}
|
||||
- **Tiny Habits / Fogg Behavior Model** (klein anfangen, **B=MAP**; Prompt/Cue designen). :contentReference[oaicite:7]{index=7}
|
||||
- Ritual-Format per **`template-ritual-nach`**; 14-Tage **Start-Experiment** per `template-start-experiment`.
|
||||
|
||||
**Leitfragen (Auszug):**
|
||||
- Welcher **Trigger** ist schon vorhanden (z. B. Beginn Lunchbreak)?
|
||||
- Was ist die **kleinste** sichtbare Aktion (2–3 Minuten), die zählt?
|
||||
- **Backup-Slot** und **Fallback-Minimum**, damit das System robust bleibt?
|
||||
|
||||
**Output/Artefakte:** `leitbild-rituale-system` *(project)* + „Start-Experiment (14 Tage)“.
|
||||
|
||||
**DoD:** Pro Ritual existieren **Trigger**, **Aktion**, **Check**, **Backup**, **Fallback**, **Cues**.
|
||||
|
||||
**Edges:** Rituale `depends_on` Ziele/Prinzipien/Rollen.
|
||||
|
||||
---
|
||||
|
||||
## Session 6 – Leitbild-Text & Review-Mechanik (60–90′)
|
||||
**Ziel:** Verdichtung zu einem **persönlichen Leitbild-Text** (1–2 Seiten, **Ich-Perspektive**, klar & warm) + **Review-System** (Weekly/Monthly/Quarterly) mit Scoreboards, Decision/Deviation Notes.
|
||||
|
||||
**Input:** Alle Artefakte aus Sessions 1–5.
|
||||
|
||||
**Methode/Didaktik:**
|
||||
- **Kompass-Text** (kein Handbuch): Identität · Werte · Prinzipien · Rollen · Langsicht · Alltagskompass.
|
||||
- **4DX-Mechaniken** für Umsetzung: Scoreboards & **Cadence of Accountability** in Reviews. :contentReference[oaicite:8]{index=8}
|
||||
- Review-Templates: `template-review-daily`, `template-review-weekly`, `template-review-monthly-leitbild`, `template-review-quarterly-leitbild`.
|
||||
- **GTD Weekly Review** als Inspirationsquelle für die wöchentliche SOP. :contentReference[oaicite:9]{index=9}
|
||||
|
||||
**Leitfragen (Auszug):**
|
||||
- Welche 3 Sätze dürfen **nicht fehlen** (Identität, Haltung, Wirkung)?
|
||||
- Welche **Zahlen**/Messpunkte schaue ich **wöchentlich/monatlich/vierteljährlich** an?
|
||||
- Welche **eine Entscheidung** (Decision Note) treffe ich nach jedem Weekly?
|
||||
|
||||
**Output/Artefakte:** `leitbild-text` *(concept)*, `leitbild-review` *(meeting/journal)* mit Scoreboards & SOP.
|
||||
|
||||
**DoD:** Leitbild-Text final, Reviews terminiert, Scoreboards & Decision/Deviation-Templates verlinkt.
|
||||
|
||||
**Edges:** `leitbild-text` → references alle Kernnoten; `leitbild-review` → depends_on Ziele/Rituale/Rollen/Prinzipien.
|
||||
|
||||
---
|
||||
|
||||
# Operative Nutzung („Betrieb“)
|
||||
|
||||
- **Daily:** `template-review-daily` (60-Sek-Fokus, Ritual-Häkchen, Mini-Tuning, Journal).
|
||||
- **Weekly:** `template-review-weekly` (Scoreboard, Kurz-Reflexion, **1 Decision Note**).
|
||||
- **Monthly:** `template-review-monthly-leitbild` (Roll-up, Werte/Prinzipien-Audit, Risiko-Scan).
|
||||
- **Quarterly:** `template-review-quarterly-leitbild` (Nordsterne-Gültigkeit, Kurskorrekturen, 1–2 Decision Notes).
|
||||
|
||||
> **Deviation Notes („Schuldschein“):** bewusste Regel-Abweichungen transparent machen (**Begründung → Repair → Prävention**), vgl. `template-deviation-note`. Das fördert **Integrität** und **Lernschleifen** (NVC-kompatible Repair-Kultur). :contentReference[oaicite:10]{index=10}
|
||||
|
||||
---
|
||||
|
||||
# Templates (Mapping)
|
||||
|
||||
| Zweck | Template |
|
||||
|---|---|
|
||||
| Wert/Anti-Muster/Experiment | `template-wert` |
|
||||
| Prinzip (testbar) | `template-prinzip` |
|
||||
| Rolle (Mission/Kriterien/Grenzen) | `template-rolle` |
|
||||
| Zielbild (3–5 J.) | `template-nordstern` |
|
||||
| Meilenstein | `template-milestone` |
|
||||
| Ritual (NACh) | `template-ritual-nach` |
|
||||
| Entscheidung | `template-decision-note` |
|
||||
| Abweichung (Repair) | `template-deviation-note` |
|
||||
| Daily/Weekly/Monthly/Quarterly | `template-review-*` |
|
||||
|
||||
---
|
||||
|
||||
# Quellen & Adaptionen
|
||||
|
||||
- **Covey – 7 Habits**: *Habit 2: Begin with the End in Mind* – Leitstern/„vom Ende her“; außerdem „Säge schärfen“ für Ich-Pflege/Regeneration. :contentReference[oaicite:11]{index=11}
|
||||
- **OKR / North Star**: Outcome-Orientierung mit messbaren **Key Results**; Nutzung für Nordsterne und Jahresziele. :contentReference[oaicite:12]{index=12}
|
||||
- **4DX** (FranklinCovey): **WIGs**, **Scoreboards**, **Cadence of Accountability** – strukturiert die Review-Mechanik. :contentReference[oaicite:13]{index=13}
|
||||
- **GTD (David Allen)**: Weekly Review als SOP-Inspiration (Eingang leeren, Listen prüfen, Klarheit schaffen). :contentReference[oaicite:14]{index=14}
|
||||
- **Implementation Intentions** (Gollwitzer): „Wenn-Dann“-Pläne als robuste Brücke zwischen Intention und Verhalten (NACh). :contentReference[oaicite:15]{index=15}
|
||||
- **Tiny Habits / Fogg Behavior Model** (BJ Fogg): B=MAP; Mikro-Verhalten + Prompts/Cues für nachhaltige Rituale. :contentReference[oaicite:16]{index=16}
|
||||
- **GROW-Modell** (Whitmore): Gesprächsführung/Coaching-Struktur in Session 0 (und iterativ). :contentReference[oaicite:17]{index=17}
|
||||
- **Nonviolent Communication** (Rosenberg): „Erst verstehen“, **Repair**-Kultur und respektvolle Sprache in Prinzipien/Reviews. :contentReference[oaicite:18]{index=18}
|
||||
|
||||
---
|
||||
|
||||
# Anhang – Quickstart (90 Minuten)
|
||||
|
||||
1) **S0 Mini** (15′): Scope in 10 Bullets skizzieren.
|
||||
2) **S1 Mini** (20′): 3 Kernwerte → je 2 Anker + 1 Repair.
|
||||
3) **S2 Mini** (15′): 2 Prinzipien im `template-prinzip` ausformulieren.
|
||||
4) **S3 Mini** (10′): 2 wichtigste Rollen → Mission + 3 Kriterien.
|
||||
5) **S4 Mini** (20′): 1 Nordstern vollständig (Why/What/How/Measure).
|
||||
6) **S5 Mini** (5′): 1 Ritual (NACh) + 1 Fallback.
|
||||
7) **S6 Mini** (5′): 3-Satz-Leitbild & Weekly-Slot festlegen.
|
||||
|
||||
> Danach: **14-Tage Start-Experiment** anwerfen und ein **Weekly Review** nach `template-review-weekly` durchführen.
|
||||
|
||||
---
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: Template – Daily Note („Heute“)
|
||||
id: template-daily-note
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, daily, journal]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Heute – YYYY-MM-DD
|
||||
|
||||
## Morgen (60–90 Sek.)
|
||||
- **Eine Sache** für Nordstern <X>:
|
||||
- Hindernis, das ich entferne:
|
||||
|
||||
## Mittag (Mobility 10′)
|
||||
- Haken gesetzt? <Ja/Nein> – Kommentar:
|
||||
|
||||
## Abend (3 Zeilen Journal)
|
||||
- 1 gut:
|
||||
- 1 gelernt:
|
||||
- 1 nächster Schritt:
|
||||
|
||||
## Häkchen (Rituale)
|
||||
- R1 / R2 / R3 / R6: <x/x/x/x>
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: Template – Decision Note
|
||||
id: template-decision-note
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, decision, review]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Decision: <Titel>
|
||||
|
||||
## Kontext
|
||||
<Kurz: Worum geht es? Warum jetzt?>
|
||||
|
||||
## Optionen
|
||||
- A) <Option> – Pros/Cons
|
||||
- B) <Option> – Pros/Cons
|
||||
- C) <Option> – Pros/Cons
|
||||
|
||||
## Entscheidung
|
||||
<gewählte Option + Begründung (Warum)>
|
||||
|
||||
## Erfolgsmessung
|
||||
- **Metrik/Beobachtung**: <…>
|
||||
- **Zeitpunkt Review**: <YYYY-MM-DD>
|
||||
|
||||
## Nächste Aktion
|
||||
<Nächster konkreter Schritt (1 Zeile)>
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: Template – Deviation Note („Schuldschein“)
|
||||
id: template-deviation-note
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, deviation, review]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Deviation: <Regel/Prinzip/Ritual>
|
||||
|
||||
## Abweichung
|
||||
<Was wurde abgewichen? Von welcher Regel/Prinzip/Ritual?>
|
||||
|
||||
## Begründung
|
||||
<Warum war die Abweichung nötig/vertretbar?>
|
||||
|
||||
## Impact
|
||||
<Erwartete und tatsächliche Auswirkungen>
|
||||
|
||||
## Repair / Wiedergutmachung
|
||||
<Konkrete Handlung, Transparenz, Kommunikation>
|
||||
|
||||
## Prävention
|
||||
<Was ändere ich am System, damit es seltener passiert?>
|
||||
|
||||
## Gültigkeit / Ablauf
|
||||
<Gilt einmalig/temporär/bis Datum>
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: Template – Familienrat (Agenda & Protokoll)
|
||||
id: template-familienrat
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: family
|
||||
tags: [template, familie, meeting]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Familienrat – YYYY-MM-DD (So 14:00)
|
||||
|
||||
## Agenda (30–45′)
|
||||
1) Rückschau (max. 10′): Was lief gut? Wofür danken wir?
|
||||
2) Orga/Standards (10′): Regeln/Haushalt – Was klärt sich heute?
|
||||
3) Woche planen (10′): Termine, Verantwortungen
|
||||
4) Offenes (5′): Anliegen / Wünsche
|
||||
|
||||
## Entscheidungen (kurz, freundlich-konsequent)
|
||||
- Thema – Entscheidung – Verantwortlich – Bis
|
||||
|
||||
## Protokoll (Kurz)
|
||||
- <Bullet-Points>
|
||||
|
||||
## Nachverfolgung (≤48 h klären)
|
||||
- Offene Punkte:
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: Template – Meilenstein
|
||||
id: template-milestone
|
||||
type: milestone
|
||||
status: planned
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, milestone]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
belongs_to: <id-des-nordsterns-oder-projekts>
|
||||
target_date: YYYY-MM-DD
|
||||
---
|
||||
|
||||
# <Meilenstein – Name>
|
||||
|
||||
## Ergebnis / DoD
|
||||
<Kriterien, die erfüllt sein müssen>
|
||||
|
||||
## Schritte (Kurzplan)
|
||||
- <Schritt 1>
|
||||
- <Schritt 2>
|
||||
|
||||
## Risiken
|
||||
- <Risiko & Umgang>
|
||||
|
||||
## Statusnotizen
|
||||
- <Datum> – <Update>
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: Template – Nordstern (Zielbild)
|
||||
id: template-nordstern
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, ziele, nordstern]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# <Nordstern – 3–5 Jahre>
|
||||
|
||||
## Warum (Impact)
|
||||
<Warum ist das wichtig / für wen ändert sich was?>
|
||||
|
||||
## Was (Outcome)
|
||||
<Klares, beobachtbares Ergebnisbild>
|
||||
|
||||
## Wie (Strategie / Initiativen)
|
||||
- <Initiative 1>
|
||||
- <Initiative 2>
|
||||
|
||||
## Messung
|
||||
- **Lead**: <frühe, beeinflussbare Messgröße>
|
||||
- **Lag**: <Ergebniskennzahl>
|
||||
|
||||
## Risiken & Gegenmaßnahmen
|
||||
- Risiko: <…> · Gegenmaßnahme: <…>
|
||||
|
||||
## Meilensteine (Auszug)
|
||||
- <YYYY-MM-DD> – <Meilenstein 1>
|
||||
- <YYYY-MM-DD> – <Meilenstein 2>
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: Template – 1:1 (Kind/Partner/Mitarbeitende)
|
||||
id: template-one-on-one
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: relationships
|
||||
tags: [template, one-on-one]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# 1:1 mit <Name> – YYYY-MM-DD
|
||||
|
||||
## Warm-up (2′)
|
||||
- Was war gut seit dem letzten Mal?
|
||||
|
||||
## Thema des Tages (10–20′)
|
||||
- <Thema/Projekt/Anliegen>
|
||||
- Hindernisse:
|
||||
- Unterstützung gebraucht:
|
||||
|
||||
## Vereinbarung (konkret)
|
||||
- Nächster Schritt (Wer/Was/Bis):
|
||||
- Wie messen wir, dass es besser ist?
|
||||
|
||||
## Stimmung (1–10)
|
||||
<Vorher / Nachher> – Kurzkommentar:
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: Template – Paar-Ritual
|
||||
id: template-paar-ritual
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: relationship
|
||||
tags: [template, partner, ritual]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Paar-Ritual – YYYY-MM-DD (So 17:00)
|
||||
|
||||
## Check-in (5′)
|
||||
- Wie geht’s mir? (1–2 Sätze)
|
||||
- Was wünsche ich mir heute?
|
||||
|
||||
## Aktivität (30–45′)
|
||||
<Tanzen/Spaziergang/…>
|
||||
|
||||
## Nähe-Check (1–10)
|
||||
<Vorher / Nachher>
|
||||
|
||||
## Dank & Mini-Plan
|
||||
- Heute dankbar für:
|
||||
- Nächste gemeinsame Mini-Aktion:
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: Template – Prinzip
|
||||
id: template-prinzip
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, prinzipien]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# <Prinzip – aktiver Satz>
|
||||
<ein Satz in aktiver Form, z. B. „Verstehen vor Antworten.“>
|
||||
|
||||
## 3 Beobachtbare Signale
|
||||
- <Signal 1>
|
||||
- <Signal 2>
|
||||
- <Signal 3>
|
||||
|
||||
## Grenzfall / Trade-off
|
||||
<Wann darf/ muss ich abweichen? Welche Kosten entstehen?>
|
||||
|
||||
## Wächterfrage
|
||||
<Frage, die mich im Alltag auf Kurs hält>
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: Template – Monthly Review (SOP)
|
||||
id: template-review-monthly
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, review, monthly]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Monthly Review – <Monat YYYY>
|
||||
|
||||
## Roll-up Scoreboard (Highlights)
|
||||
- R1/R2/R3/R6/R5/R7: <Kurzfazit>
|
||||
- Nordsterne (Lead/Lag): <Kurzfazit>
|
||||
|
||||
## Rückblick
|
||||
- Beste Entscheidung des Monats:
|
||||
- Was trug trotz Low-Energy?
|
||||
- Welche Regel/Standard braucht Feinschliff?
|
||||
|
||||
## Plan & Risiken (Top-3)
|
||||
1) <Outcome + Metrik> – Risiken/Gegenmaßnahme:
|
||||
2) <Outcome + Metrik> – Risiken/Gegenmaßnahme:
|
||||
3) <Outcome + Metrik> – Risiken/Gegenmaßnahme:
|
||||
|
||||
## Decision Notes (1–2)
|
||||
- <Titel> – <Review-Datum>
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: Template – Quarterly Review (SOP)
|
||||
id: template-review-quarterly
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, review, quarterly]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Quarterly Review – Q<Nr> YYYY
|
||||
|
||||
## Nordsterne – Gültigkeit & Fortschritt
|
||||
- <Nordstern 1>: gültig? Anpassung?
|
||||
- <Nordstern 2>: gültig? Anpassung?
|
||||
|
||||
## Strategie-Retro (Keep/Start/Stop)
|
||||
- **Keep**:
|
||||
- **Start**:
|
||||
- **Stop**:
|
||||
|
||||
## System-Retro
|
||||
- Regeln/SLAs:
|
||||
- Nein-Liste:
|
||||
- Rituale (Tuning):
|
||||
|
||||
## Kurskorrekturen
|
||||
- Meilensteine datieren/verschieben:
|
||||
- 1–2 **Decision Notes** für das Quartal:
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
title: Template – Weekly Review (SOP)
|
||||
id: template-review-weekly
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, review, weekly]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Weekly Review – KW <Nr> (YYYY-MM-DD)
|
||||
|
||||
## 1) Scoreboard (Fakten)
|
||||
| Item | Ziel | Ist | Kommentar |
|
||||
|---|---:|---:|---|
|
||||
| R1 Meditation (≥6/7) | 6/7 | <x/7> | <…> |
|
||||
| R2 Mobility (≥6/7) | 6/7 | <x/7> | <…> |
|
||||
| R3 Journal (≥6/7) | 6/7 | <x/7> | <…> |
|
||||
| R6 Rohan (≥5/7) | 5/7 | <x/7> | <…> |
|
||||
| R5 Tanzen (≥3/4) | 3/4 | <x/4> | <…> |
|
||||
| R7 Rouven (≥1/1) | 1/1 | <x/1> | <…> |
|
||||
| Nordstern <Name> (Lead) | <Ziel> | <Ist> | <…> |
|
||||
|
||||
## 2) Kurz-Reflexion (10′)
|
||||
- Was war **wirksam**?
|
||||
- Was **hinderte** Adhärenz (Energie/Timing/Scope)?
|
||||
- Wo braucht es **Repair**?
|
||||
- 2–3 Momente von **Ruhe/Klarheit**?
|
||||
- **Anerkennung** (an wen? wofür?)
|
||||
|
||||
## 3) Fokus & Entscheidung (10′)
|
||||
- **Top-3 Fokus nächste Woche**:
|
||||
- 1)
|
||||
- 2)
|
||||
- 3)
|
||||
- **Decision Note**: <Link/ID>
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: Template – Ritual (NACh)
|
||||
id: template-ritual-nach
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, ritual, habits, nach]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# <Ritual – Kurzname>
|
||||
|
||||
## Cadence
|
||||
<täglich | wöchentlich | 14-tägig | monatlich>
|
||||
|
||||
## NACh-Formel
|
||||
- **Trigger (Wenn …)**: <konkret, beobachtbar>
|
||||
- **Aktion (dann tue ich …)**: <konkrete Mikro-Aktion>
|
||||
- **Check (sichtbares Ergebnis)**: <Messpunkt 1–10, Häkchen, etc.>
|
||||
|
||||
## Backup & Fallback
|
||||
- **Backup-Slot**: <Zeitfenster>
|
||||
- **Fallback-Minimum**: <2–3′-Version>
|
||||
|
||||
## Cues / Umgebung
|
||||
- <sichtbarer Hinweis, Material, Ort>
|
||||
|
||||
## Messung
|
||||
- **Ziel-Quote**: <z. B. 6/7 pro Woche>
|
||||
- **Tracking**: <Ort/Note>
|
||||
|
||||
## Verknüpfungen
|
||||
- Prinzipien/Werte:
|
||||
- Nordstern:
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: Template – Rolle
|
||||
id: template-rolle
|
||||
type: template
|
||||
status: active
|
||||
created: 2025-11-01
|
||||
updated: 2025-11-01
|
||||
area: personal_development
|
||||
tags: [template, rollen]
|
||||
lang: de
|
||||
source: coach/leitbild
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Rolle: <Name>
|
||||
|
||||
## Mission (1–2 Sätze)
|
||||
<Klarer Beitrag / Wirkung dieser Rolle>
|
||||
|
||||
## Qualitätskriterien (3–5)
|
||||
- <Kriterium 1>
|
||||
- <Kriterium 2>
|
||||
- <Kriterium 3>
|
||||
|
||||
## Grenzen / Nein-Liste
|
||||
- <Dinge, die ich in dieser Rolle bewusst nicht tue>
|
||||
|
||||
## Stakeholder & Erwartungen
|
||||
- <Person/Gruppe> – <Erwartung> – <Mein Angebot>
|
||||
|
||||
## Verknüpfungen
|
||||
- Werte/Prinzipien:
|
||||
- Ziele/Nordsterne:
|
||||
Loaded 100 of 121 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user