Private
Public Access
0
0

docs(curation): correct FuzzyAnchor docstring (add get_context helper, replace 'anchor_lines' with actual field names)

This commit is contained in:
2026-06-10 23:45:37 -04:00
parent aa4ec2ed08
commit 99eb434f60
+13 -2
View File
@@ -83,13 +83,24 @@ Text slices defined by line numbers become invalid when files are modified (line
```python
# src/fuzzy_anchor.py
class FuzzyAnchor:
@staticmethod
def get_context(lines: list[str], index: int, count: int, direction: int) -> list[str]:
"""Helper: extract up to `count` non-empty lines starting at `index` and walking
in `direction` (1 = forward, -1 = backward). Used to build the start/end anchors
for fuzzy re-resolution."""
@classmethod
def create_slice(cls, text: str, start_line: int, end_line: int) -> dict:
"""Returns slice_data with content_hash, anchor_lines, and positions."""
"""Returns slice_data with start_line, end_line, content_hash, start_context,
and end_context fields. start_line/end_line are 1-based; the hash is MD5
of the region's text."""
@classmethod
def resolve_slice(cls, text: str, slice_data: dict) -> Optional[Tuple[int, int]]:
"""Resolves slice position in modified text, returns (start, end) or None."""
"""Resolves slice position in modified text. Returns (start, end) on success
or None if the slice can no longer be located. Strategy: (1) try exact
match by content hash at the original line range; (2) fall back to fuzzy
match by walking the start_context and end_context anchors."""
```
### Slice Data Structure