Skip to content

refactor(footnotes): separate diagnostics from mutation in collect_scan_updates (CQS) #365

Description

@lodyai

Background

collect_scan_updates (src/footnotes/renumber/definitions.rs:178-225) both
mutates the scan state (the command) and emits tracing diagnostics for
skipped candidates (lines ~206-211) in the same pass.

Problem

Mixing the state mutation with observability entangles two responsibilities and
makes the core mutation harder to unit-test in isolation: a test of the scan
logic cannot exercise it without also driving the logging path, and the logging
cannot be reasoned about independently of the mutation order.

Objective

Separate the command from the diagnostics.

  • Have the collection pass record skipped candidates into the state (or a
    returned collection) without logging.
  • Emit diagnostics in a distinct log_skipped_candidates step after collection
    completes.

This restores command/query separation and lets the mutation be tested without
the tracing side effect.

Acceptance criteria

  • collect_scan_updates performs no logging; skipped candidates are recorded in
    state.
  • A separate function owns the tracing output.
  • A unit test exercises the collection logic and asserts the recorded skipped
    candidates without depending on log capture.
  • Existing renumber tests continue to pass; run the full make commit gate.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions