Skip to content

refactor: centralize molecule formula names as constants#2212

Merged
steveyegge merged 2 commits intogastownhall:mainfrom
DreadPirateRobertz:polecat/gt-pimh-mol-constants
Mar 1, 2026
Merged

refactor: centralize molecule formula names as constants#2212
steveyegge merged 2 commits intogastownhall:mainfrom
DreadPirateRobertz:polecat/gt-pimh-mol-constants

Conversation

@DreadPirateRobertz
Copy link
Copy Markdown
Contributor

Summary

  • Extracts 10 hardcoded molecule name strings into internal/constants/constants.go constants: 3 patrol formulas (MolDeaconPatrol, MolWitnessPatrol, MolRefineryPatrol), 5 dog formulas (MolDogReaper, MolDogJSONL, MolDogCompactor, MolDogDoctor, MolDogBackup), and 2 convoy formulas (MolConvoyFeed, MolConvoyCleanup)
  • Replaces 30+ hardcoded string occurrences across 18 files (production code + tests)
  • Adds PatrolFormulas() helper function used by doctor patrol check

Test plan

  • go build ./... passes
  • go vet clean (except pre-existing daemon/testmain_test.go issue)
  • All tests pass in constants, cmd, doctor, deacon, templates, formula packages
  • Grep confirms no remaining hardcoded molecule name strings outside constants.go and doc comments

Closes gt-pimh

🤖 Generated with Claude Code

@github-actions github-actions Bot added the status/needs-triage Inbox — we haven't looked at it yet label Mar 1, 2026
@codecov-commenter
Copy link
Copy Markdown

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
7426 2 7424 34
View the top 2 failed test(s) by shortest run time
::TestMain
Stack Traces | 0s run time
FAIL	github..../gastown/internal/convoy [build failed]
::TestMain
Stack Traces | 0s run time
FAIL	github..../gastown/internal/daemon [build failed]

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copy link
Copy Markdown
Contributor Author

@DreadPirateRobertz DreadPirateRobertz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: refactor: centralize molecule formula names as constants

Overall: Approve with minor follow-up needed

What's good

  • Clean extraction of 10 molecule name constants into internal/constants/constants.go
  • PatrolFormulas() helper eliminates a duplicate list in doctor/patrol_check.go
  • Consistent pattern: all replacements follow constants.MolXxx convention
  • Build passes, tests updated properly
  • 30+ replacements across 18 files — solid coverage

Incomplete coverage (should-fix)

5 files still have hardcoded molecule strings that should use the new constants:

File Occurrences Type
internal/formula/patrol_backoff_test.go 9 formula filenames ("mol-witness-patrol.formula.toml"constants.MolWitnessPatrol + ".formula.toml")
internal/formula/embed_test.go 8 formula filenames
internal/doctor/formula_check_test.go 2 formula filenames
internal/doctor/misclassified_wisp_check_test.go 1 wisp ID construction
internal/cmd/install_integration_test.go 2 formula filenames

These follow the same constants.MolXxx + ".formula.toml" pattern already used in the PR (see convoy_feed_integration_test.go and variable_validation_test.go).

2 files have comment-only references (patrol_helpers.go:19, patrol.go:260) — those are fine to leave.

Suggestion

Either add the 5 missing files to this PR for completeness, or file a follow-up bead. The PR description claims "Grep confirms no remaining hardcoded molecule name strings outside constants.go and doc comments" — that's not quite accurate with these test files still using raw strings.

Verdict

LGTM with the caveat above. The core refactor is correct and well-executed.

DreadPirateRobertz and others added 2 commits March 1, 2026 12:19
Extract 10 hardcoded molecule name strings ("mol-deacon-patrol",
"mol-witness-patrol", "mol-refinery-patrol", "mol-dog-*", "mol-convoy-*")
into constants.go and replace all 30+ occurrences across 18 files.

Adds PatrolFormulas() helper used by doctor/patrol_check.go.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DreadPirateRobertz DreadPirateRobertz force-pushed the polecat/gt-pimh-mol-constants branch from eb6f714 to 7bc35fd Compare March 1, 2026 19:19
@steveyegge steveyegge merged commit a54bf93 into gastownhall:main Mar 1, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/needs-triage Inbox — we haven't looked at it yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants