Conservative byte candidates, never publication authority.
surviving_candidates
surviving_candidates(read: Any, rendered: str) -> tuple[object, ...]
Keep only whole unique lines unchanged by the render gate.
Source code in src/symfonic/capabilities/prompting/selection_candidates.py
| def surviving_candidates(read: Any, rendered: str) -> tuple[object, ...]:
"""Keep only whole unique lines unchanged by the render gate."""
offered = getattr(read, "_selected_lines", ())
if type(offered) is not tuple or not offered:
return ()
source_lines = read.text.splitlines()
rendered_lines = rendered.splitlines()
source_counts = Counter(source_lines)
rendered_counts = Counter(rendered_lines)
kept: list[object] = []
seen: set[str] = set()
for candidate in offered:
line = getattr(candidate, "line", None)
ordinal = getattr(candidate, "ordinal", None)
if (
type(line) is not str
or type(ordinal) is not int
or not 0 <= ordinal < len(source_lines)
or source_lines[ordinal] != line
or source_counts[line] != 1
or rendered_counts[line] != 1
or line in seen
):
continue
seen.add(line)
kept.append(candidate)
return tuple(kept)
|