Files
local-deep-research/tests/text_optimization
LearningCircuit a2c9721bfb refactor(citation): pass collections explicitly to source-tagged formatter (#4096)
* refactor(citation): pass collections explicitly to source-tagged formatter

Three small cleanups to the source-tagged citation path:

- Pass the parsed ``collections`` dict as a parameter to
  ``_format_source_tagged_hyperlinks`` instead of stashing it on
  ``self._collections_for_format``. Removes hidden state that would
  bleed between successive ``format_document`` calls on the same
  instance.
- Drop the ``usable_sources`` shallow-copy. It was labelled as a
  filter but never filtered anything — just a rename of ``sources``.
- Remove the comment claiming the method "reparses from the original
  content via the existing helper"; it didn't, and now the dict is
  passed in directly so the description is unambiguous.

No behavior change. Existing tests cover the path
(test_citation_formatter.py: 8 source-tagged cases).

* docs(citation): document collections parameter on source-tagged formatter

Per AI-reviewer feedback on the PR — the new collections parameter
wasn't covered by the existing docstring.

* test(citation): pin no-state-leak across reused formatter instances

Calling format_document twice on the same CitationFormatter
instance must resolve each citation from the doc's own sources block —
collection metadata from a prior call cannot leak into a later one.
Locks down the contract that motivated removing
self._collections_for_format in this PR.
2026-05-17 20:31:40 +02:00
..