Skip to content

Encode single-rule constraint in model, not view (architecture) #30

Description

@wiseelf

From architecture review 2026-07-19, candidate C4 ("Worth exploring").

Problem

OnCallStore.rules: [RecurrenceRule] is a real array and OnCallBilling correctly loops over all rules, but the product only ever allows one active rule — a constraint enforced only by hiding the "add rule" button in ScheduleTab.swift once store.rules is non-empty (and read via store.rules.first throughout).

Files:

  • Sources/TimeTracker/OnCallStore.swift
  • Sources/TimeTracker/ScheduleTab.swift:31,40,100,145,149,175
  • Sources/TimeTrackerCore/OnCallBilling.swift:86-90

Solution options

  • Make OnCallStore.rule: RecurrenceRule? a singleton if multi-rule support isn't planned, or
  • Promote the "at most one" constraint to a store-level guard if multi-rule is a future goal

Either way, the constraint should live where the data lives, not in a button's visibility condition.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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