Skip to content

fix(athlete): route set_signature through a sanctioned writer to avoid GBO-R27 double-open-interval #127

@bepcyc

Description

@bepcyc

Surfaced by the independent review of #126 (#117). PRE-EXISTING (not introduced by #126), tracked here for a proper fix.

Problem. api/routers/athlete.py:set_signature writes/upserts FitnessSignature rows directly, bypassing the sanctioned record_signature() seam, and never sets effective_to. So writing a NEW effective_date for the same sport does not close the prior open interval → two FitnessSignature rows with NULL effective_to for the same sport (a latent GBO-R27 double-open-interval).

Why it is currently latent, not active-wrong. Both resolvers (_effective_signature, analytics _load_effective_signature) use ORDER BY effective_date DESC LIMIT 1, so the latest-effective threshold still resolves correctly. The stale uncloseable interval only surfaces in signature history hygiene, not in #117/#126 behavior (which is correct and merged).

Why it was deferred. Naively routing set_signature through record_signature() invokes _refuse_overlapping, which refuses same-date/back-dated writes — breaking the GBO-R26/API-R52 same-date in-place idempotency pinned by test_set_signature_is_idempotent_on_same_effective_date. So this needs a design that BOTH preserves same-date in-place idempotency AND closes the prior open interval on a new effective_date.

Acceptance. A new effective_date for the same sport closes the prior interval (single open interval per sport); same-date write stays idempotent in place; spec GBO-R27 / API-R52 correspondence extended; non-vacuous tests.

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