Skip to content

Comments

refactor: use fmtTrim for prompts, inline free tier check#320

Merged
tonyalaribe merged 1 commit intomasterfrom
refactor/enhancement-fmttrim-utils-inline
Feb 18, 2026
Merged

refactor: use fmtTrim for prompts, inline free tier check#320
tonyalaribe merged 1 commit intomasterfrom
refactor/enhancement-fmttrim-utils-inline

Conversation

@tonyalaribe
Copy link
Contributor

Summary

  • Replace manual <> string concatenation in Enhancement.hs prompt builders (buildTitlePrompt, buildDescriptionPrompt, buildCriticalityPrompt) with PyF [fmtTrim|...|] quasiquotes and [text|...|] for system prompts
  • Inline checkFreeTierExceeded in Utils.hs to use a direct SQL query, removing the Models.Apis.RequestDumps import dependency

Test plan

  • Compiles cleanly on master (cabal build lib:monoscope)
  • Verify doctests pass (build-doctests.log)
  • Smoke test issue enhancement flow (LLM prompt generation)

🤖 Generated with Claude Code

Replace manual string concatenation in Enhancement.hs prompt builders
(buildTitlePrompt, buildDescriptionPrompt, buildCriticalityPrompt) with
PyF [fmtTrim|...|] quasiquotes. Convert systemPrompt strings from
unlines to [text|...|].

Inline checkFreeTierExceeded query in Utils.hs to remove the
Models.Apis.RequestDumps import dependency.
@tonyalaribe tonyalaribe merged commit a58e731 into master Feb 18, 2026
9 checks passed
@tonyalaribe tonyalaribe deleted the refactor/enhancement-fmttrim-utils-inline branch February 18, 2026 00:22
@claude
Copy link

claude bot commented Feb 18, 2026

Code Review

Good refactor overall — the use of fmtTrim and [text|] cuts noise significantly and improves readability.

Issues / Suggestions

1. [text|] indentation may produce leading spaces in system prompts

NeatInterpolation's [text|...|] strips common leading whitespace, but the indentation in the new code (8+ spaces of Haskell indentation) may not be treated as the common prefix depending on the version, producing leading spaces on every line of the prompt sent to the LLM. The old unlines [...] was immune to this. Worth verifying the actual string output in tests.

2. checkFreeTierExceeded inlines a slightly different query than the original

getRequestCountForInterval uses count(*) (returning Int via coerce of Only Int) and passes the interval as a parameter, making it reusable. The new inlined query uses count(*)::INT (a Postgres cast) and hardcodes '1 day' as a literal — fine for this call-site, but it diverges from the existing pattern and the cast is redundant since postgresql-simple already handles the type mapping. More importantly, since getRequestCountForInterval is still exported and used for getLastSevenDaysTotalRequest, the two code paths could drift. Consider just calling RequestDumps.getLast24hTotalRequest as before, or if the import cycle is the motivation for inlining, move the shared query helper to Utils/a lower-level module.

3. maybe (0 :: Int) fromOnly . listToMaybe vs existing pattern

The existing RequestDumps.getRequestCountForInterval uses fromMaybe 0 . coerce @(Maybe (Only Int)) @(Maybe Int) . listToMaybe, which avoids partial unpacking. The new code uses maybe 0 fromOnly . listToMaybe — correct, but slightly inconsistent with the established pattern in the rest of the codebase.

4. show inside fmtTrim for list fields loses toText wrapper

In buildDescriptionPrompt, the old code used toText (show $ V.toList ...). The new code uses {show $ V.toList d.newFields} directly inside fmtTrim. This works because PyF can format String, but the result type inference may be fragile without an explicit :: String annotation — or just use toText/pack to be explicit.

5. Minor: fromInteger vs fromIntegral

freeTierDailyMaxEvents :: Integer, so count > fromInteger freeTierDailyMaxEvents is correct, but the rest of the codebase uses fromIntegral uniformly (which also works for Integer). Small inconsistency.

Positives

  • Removing the Aeson (..) pattern-match wrapper in favour of getAeson is cleaner and consistent with the QueryAlert branch that already used it.
  • The fmtTrim blocks eliminate a large amount of <> churn and make the prompt text easy to read and edit.
  • [text|] for multi-line system prompts is the right tool and matches NeatInterpolation usage elsewhere in the project.
  • The de-duplication of AE.fromJSON (getAeson issue.issueData) across all three branches is a clear win.

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