Skip to content

Refactor issue creation from IO to Eff#322

Merged
tonyalaribe merged 1 commit intomasterfrom
issue-creation-io-to-eff
Feb 18, 2026
Merged

Refactor issue creation from IO to Eff#322
tonyalaribe merged 1 commit intomasterfrom
issue-creation-io-to-eff

Conversation

@tonyalaribe
Copy link
Contributor

Summary

  • Convert createAPIChangeIssue, createRuntimeExceptionIssue, createQueryAlertIssue from IO to Eff es with UUIDEff/Time constraints
  • Replace UUID4.nextRandom with genUUID (effectful, testable)
  • Replace utcToLocalZonedTime (IO, system-timezone-dependent) with utcToZonedTime utc (pure, deterministic)
  • Remove liftIO wrappers from callers in BackgroundJobs.hs

Behavioral no-op — same logic, now composable with the effect system. Extracted from #300 to reduce PR size.

Test plan

  • Build succeeds
  • Issue creation still works (runtime exceptions, API changes, query alerts)

Convert createAPIChangeIssue, createRuntimeExceptionIssue, and
createQueryAlertIssue from IO to Eff using genUUID and effectful Time.
Replaces utcToLocalZonedTime (IO) with utcToZonedTime utc (pure).
Removes liftIO wrappers from callers in BackgroundJobs.
@tonyalaribe tonyalaribe merged commit 7ed8658 into master Feb 18, 2026
9 checks passed
@tonyalaribe tonyalaribe deleted the issue-creation-io-to-eff branch February 18, 2026 00:41
@claude
Copy link

claude bot commented Feb 18, 2026

PR Review: Refactor issue creation from IO to Eff

Overall this is a clean, well-scoped refactor. The direction is correct and the changes are minimal. A few observations:


Behaviour change: timezone semantics

utcToLocalZonedTime (removed) uses the system's local timezone at runtime. utcToZonedTime utc (added) always produces a ZonedTime in UTC. This is a silent semantic change, not just a mechanical lift.

  • For createRuntimeExceptionIssue: atError.when is a UTCTime, so the old code would display it in the server's local TZ; new code always stores it as UTC. Likely an improvement for consistency, but worth confirming the stored ZonedTime is rendered/interpreted correctly downstream (e.g. in the UI or DB serialisation).
  • For createQueryAlertIssue: same consideration for createdAt/updatedAt.

If UTC is the intended canonical timezone everywhere, this is the right fix — just flag it explicitly in the PR description so reviewers know it's intentional.


createAPIChangeIssue: now was unused before and is gone now

In the old signature getCurrentTime was called but the resulting now doesn't appear to have been used in createdAt/updatedAt (those fields seem to be filled from the anomaly data or left as defaults). Dropping it is correct — just worth a quick sanity check that the Issue fields that used to be set from now are still populated correctly.


Inconsistency: two UUID generation styles still coexist in BackgroundJobs.hs

Lines 977 and 1345 still use liftIO UUIDV4.nextRandom for report/dashboard IDs while the rest of the file now uses UUID.genUUID via UUIDEff. This is pre-existing, not introduced here, but since this PR is specifically about moving UUID generation into the effect system, it may be worth a follow-up (or a note in the PR) to handle those remaining sites for consistency.


Minor: constraint ordering convention

-- PR adds:
createQueryAlertIssue :: (Time :> es, UUIDEff :> es) => ...

-- Other signatures in this file use:
createAPIChangeIssue :: UUIDEff :> es => ...

No issue with either, but if the codebase has a convention for ordering constraints (e.g. alphabetical, or "more specific first"), it's worth aligning.


Summary

Assessment
Direction Correct — lifts IO into testable effects
Correctness Good, modulo the timezone semantics note above
Size Appropriately small and focused
Consistency Minor: two liftIO UUIDV4.nextRandom sites remain in BackgroundJobs.hs
Test coverage The PR description's test plan is manual only; a unit test exercising the three functions with runStaticUUID/a mock Time interpreter would lock in the behaviour, but not a blocker for this refactor

The timezone behaviour change is the only thing worth a explicit confirmation before merge.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant