Skip to content

refactor(worker): code quality phase 3 - centralized config and tests#405

Merged
dsclassen merged 2 commits intomainfrom
refactor/worker/code-quality-phase-3
Feb 11, 2026
Merged

refactor(worker): code quality phase 3 - centralized config and tests#405
dsclassen merged 2 commits intomainfrom
refactor/worker/code-quality-phase-3

Conversation

@dsclassen
Copy link
Collaborator

Summary

This PR completes Phase 3 of worker code quality improvements (following #403 and #404), focusing on maintainability and test coverage:

  • Centralize configuration: Extract all magic numbers to config/constants.ts (worker concurrency, polling intervals, retry settings, progress calculation weights)
  • Consolidate error handling: Create shared helpers/errors.ts utility, eliminating duplication across 3 files
  • Add comprehensive test coverage: 39 new tests for critical infrastructure
    • mongo-utils.ts: 100% coverage (11 tests) - database operations
    • workerControl.ts: 100% coverage (13 tests) - NERSC worker control
    • job-utils.ts: 63.57% coverage (15 tests) - job lifecycle management
  • Improve existing coverage: runPythonStep.ts from 88% → 92%, helpers from 94.66% → 96%
  • Remove technical debt: Clean up dead/commented code across worker files
  • Enhance documentation: Add manual changeset creation instructions to CLAUDE.md for non-TTY environments

Test plan

  • All 100 tests passing
  • Build successful (pnpm -F @bilbomd/worker build)
  • Lint clean (pnpm lint)
  • Coverage improved for tested files (helpers, mongo-utils, workerControl)
  • No breaking changes - all refactoring is internal
  • Changeset added for minor version bump

Files Changed

New files (6):

  • apps/worker/src/config/constants.ts - Centralized configuration
  • apps/worker/src/helpers/errors.ts - Shared error utility
  • apps/worker/src/services/functions/__tests__/mongo-utils.test.ts
  • apps/worker/src/services/functions/__tests__/job-utils.test.ts
  • apps/worker/src/workers/__tests__/workerControl.test.ts
  • .changeset/worker-code-quality-phase-3.md

Modified files (7):

  • Worker files updated to use centralized constants and shared utilities
  • CLAUDE.md enhanced with changeset creation instructions

14 files changed, 1,028 insertions(+), 72 deletions(-)

🤖 Generated with Claude Code

dsclassen and others added 2 commits February 11, 2026 12:46
…mprehensive tests

- Extract magic numbers to config/constants.ts for better maintainability
- Consolidate error handling utility in helpers/errors.ts (eliminates duplication)
- Add comprehensive test coverage for critical infrastructure:
  - mongo-utils.ts: 100% coverage (11 tests)
  - job-utils.ts: 63.57% coverage (15 tests)
  - workerControl.ts: 100% coverage (13 tests)
- Improve runPythonStep.ts coverage from 88% to 92%
- Remove dead/commented code across worker files
- Update all files to use centralized constants and shared utilities

This is Phase 3 of worker code quality improvements following PRs #403 and #404.
All tests passing (100 tests), build successful, lint clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add changeset for worker code quality phase 3 improvements
- Enhance CLAUDE.md with manual changeset creation instructions
- Include examples and semver guidelines for non-TTY environments

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Feb 11, 2026

🦋 Changeset detected

Latest commit: 5248e04

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bilbomd/worker Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dsclassen dsclassen merged commit 3f6d286 into main Feb 11, 2026
15 checks passed
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