Implement automatic backlinks for intra-note edges (WP-26 v1.4)
- Added functionality to automatically create inverse backlinks for intra-note edges at the chunk level, ensuring that backlinks are generated only when they do not already exist. - Updated the documentation to outline the requirements and rules for backlink creation, including conditions for deduplication and scope. - Introduced unit tests to validate the creation of backlinks and ensure correct behavior when existing backlinks are present. - Incremented version to 4.4.0 to reflect the new feature addition.
This commit is contained in:
1 parent
bc8bdfac3c
commit
52ed079067
3 files changed
+253
-2
No files matched your search
@@ -566,6 +566,98 @@ default_edge = topology["typical"][0] # "resulted_in"
|
||||
}
|
||||
```
|
||||
|
||||
#### FA-08b: Automatische Backlinks für Intra-Note-Edges
|
||||
|
||||
**Anforderung:** Für alle Intra-Note-Edges (`is_internal: True`, `scope: "chunk"`) werden automatisch inverse Backlinks erzeugt, wenn diese nicht bereits explizit vorhanden sind.
|
||||
|
||||
**Regeln:**
|
||||
|
||||
1. **Nur für Intra-Note-Edges:** Backlinks werden nur für Edges innerhalb derselben Note erstellt
|
||||
2. **Chunk-Level:** Backlinks haben `scope: "chunk"` (nicht `scope: "note"`)
|
||||
3. **Inverser Edge-Type:** Der inverse Edge-Type wird via `EdgeRegistry.get_inverse()` ermittelt
|
||||
4. **Deduplizierung:** Backlinks werden nur erstellt, wenn noch kein inverser Edge existiert
|
||||
5. **Gilt für alle Intra-Note-Edges:** Explizite Edges, automatische Section-Transitions, etc.
|
||||
|
||||
**Beispiel:**
|
||||
|
||||
**Input (explizite Edge):**
|
||||
```markdown
|
||||
## Reflexion ^ref
|
||||
> [!section] insight
|
||||
> [!edge] derives
|
||||
> [[#^sit]]
|
||||
```
|
||||
|
||||
**Generierte Edges:**
|
||||
|
||||
```python
|
||||
# Forward-Edge (explizit)
|
||||
{
|
||||
"kind": "derives",
|
||||
"source_id": "NoteID#c02", # Reflexion
|
||||
"target_id": "NoteID#c01", # Situation
|
||||
"scope": "chunk",
|
||||
"is_internal": True,
|
||||
"provenance": "explicit"
|
||||
}
|
||||
|
||||
# Backlink (automatisch erzeugt)
|
||||
{
|
||||
"kind": "derived_from", # Inverser Edge-Type
|
||||
"source_id": "NoteID#c01", # Situation (invertiert)
|
||||
"target_id": "NoteID#c02", # Reflexion (invertiert)
|
||||
"scope": "chunk",
|
||||
"is_internal": True,
|
||||
"provenance": "rule",
|
||||
"rule_id": "derived:intra_note_backlink",
|
||||
"source_hint": "automatic_backlink",
|
||||
"original_edge_kind": "derives" # Debug-Info
|
||||
}
|
||||
```
|
||||
|
||||
**Beispiel (automatische Section-Transition):**
|
||||
|
||||
**Input:**
|
||||
```markdown
|
||||
## Situation ^sit
|
||||
> [!section] experience
|
||||
|
||||
## Reflexion ^ref
|
||||
> [!section] insight
|
||||
<!-- Kein expliziter [!edge] -->
|
||||
```
|
||||
|
||||
**Generierte Edges:**
|
||||
|
||||
```python
|
||||
# Forward-Edge (automatisch aus Schema)
|
||||
{
|
||||
"kind": "resulted_in",
|
||||
"source_id": "NoteID#c01", # experience
|
||||
"target_id": "NoteID#c02", # insight
|
||||
"scope": "chunk",
|
||||
"is_internal": True,
|
||||
"provenance": "rule",
|
||||
"rule_id": "inferred:section_transition"
|
||||
}
|
||||
|
||||
# Backlink (automatisch erzeugt)
|
||||
{
|
||||
"kind": "caused_by", # Inverser Edge-Type
|
||||
"source_id": "NoteID#c02", # insight (invertiert)
|
||||
"target_id": "NoteID#c01", # experience (invertiert)
|
||||
"scope": "chunk",
|
||||
"is_internal": True,
|
||||
"provenance": "rule",
|
||||
"rule_id": "derived:intra_note_backlink"
|
||||
}
|
||||
```
|
||||
|
||||
**Wichtig:**
|
||||
- Backlinks werden **nur** erstellt, wenn noch kein inverser Edge existiert
|
||||
- Backlinks haben immer `scope: "chunk"` (nicht `scope: "note"`)
|
||||
- Backlinks werden **nach** der Deduplizierung erstellt, um Duplikate zu vermeiden
|
||||
|
||||
### 4.4 Retriever-Anpassungen
|
||||
|
||||
#### FA-09: Edge-Gewichtung für Intra-Note-Edges
|
||||
|
||||
Reference in new issue
Block a user