You are ranking tree nodes to answer a user question.

Query: {{ query }}

Top candidates so far:
{% if top_candidate_ids %}
{{ top_candidate_ids }}
{% else %}
(none)
{% endif %}

Candidates (pick up to {{ pick_limit }} ids, best first):
{% for c in candidates -%}
- id: {{ c.node_id }}
  title: {{ c.title }}
  summary: {{ c.summary }}
  text: {{ c.text }}
  range: {{ c.page_start }}-{{ c.page_end }}
  path: {{ c.path }}
  parent_context: {{ c.parent_summary[:300] if c.parent_summary else "(root)" }}
{% endfor %}

Return ONE tool call "rank" with:
- ranked_ids: list of candidate ids in best-to-worst order
- done: true ONLY if you've reached leaf nodes or the content is specific enough to answer. If nodes are high-level sections, set done=false to explore deeper.
