Skip to content

Correction.triggered_by is dead metadata — remove or auto-populate #108

Description

@marcosfrenkel

Finding

Correction.triggered_by is declared on the class but never read anywhere in the framework. It is a parallel piece of information that duplicates the check↔correction binding already established by _register_check.

Three references in the entire codebase:

Nowhere reads it. Not base.py, not the tests, not _assemble_report, not the default correct(). The framework routes corrections through _registered_checks (populated by _register_check), so the binding source-of-truth is the registration call, not the class attribute.

This means an author can set triggered_by = "snr" and then register the correction against a check named "peak_exists" and the framework will silently use it for "peak_exists" — the triggered_by string just sits there, potentially lying.

Options

  • (A) Remove triggered_by from the Correction base class entirely. No behavior changes — existing subclasses that set it would just need the attribute removed. The check name is already known to the framework at correction-application time (it's the check.name from the failing CheckResult), so anywhere reports want to surface the binding, they can read it from the CheckResult instead.
  • (B) Keep triggered_by but populate it automatically at registration time. _register_check would set correction.triggered_by = name so the value can never drift from what was actually registered.
  • (C) Actually start using triggered_by in the report, ideally combined with (B) so authored values can't drift from registered ones.

Recommended: (A). Smallest surface area, removes a footgun, no real loss because the registered name is already discoverable.

Tasks

  • Decide between (A), (B), and (C).
  • Apply the change in labcore.
  • Audit CQEDToolbox operations for any Correction subclasses that currently set or read triggered_by, and update them in lockstep with the labcore change so nothing breaks. (CQEDToolbox is the largest known consumer of the corrections API.)
  • Update the protocols user guide (docs/user_guide/protocols/operations.md, "Corrections" section) to remove or rephrase the bullet that currently describes triggered_by.

Background

Surfaced while writing the protocols user-guide page. The user guide currently documents triggered_by as informational metadata, which is technically true but misleading because the value is never displayed anywhere — the doc should not have to teach a piece of unused state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions