Skip to content

refactor: codebase quality remediation#58

Merged
dwsmith1983 merged 5 commits intomainfrom
refactor/codebase-quality-remediation
Mar 8, 2026
Merged

refactor: codebase quality remediation#58
dwsmith1983 merged 5 commits intomainfrom
refactor/codebase-quality-remediation

Conversation

@dwsmith1983
Copy link
Copy Markdown
Owner

Summary

  • Split stream_router.go (1,129 → 249 lines) into 5 focused files: sfn.go, dynstream.go, rerun.go, postrun.go, and the slimmed stream_router.go
  • Merge duplicated calendar exclusion logic into shared isExcludedTime + resolveTimezone helpers
  • Extract DynamoDB pagination helpers (ScanAll, QueryAll, QueryCount) eliminating 5 instances of boilerplate
  • Centralize magic constants in defaults.go
  • Raise trigger test coverage from 72% → 85.8%, calendar from 72.4% → 96.6%
  • Add unit tests for ParseExecutionDate, InjectDateArgs, RemapPerPeriodSensors
  • Add ValidateEnv() for fail-fast on missing env vars at Lambda cold start
  • Add package-level godoc for internal/lambda/ and internal/trigger/

Split the 1,129-line stream_router.go monolith into 5 focused files:
- stream_router.go (~249 lines): core routing, sensor eval, job events
- sfn.go (~119 lines): SFN execution and config builders
- dynstream.go (~254 lines): DynamoDB stream helpers, calendar, publishing
- rerun.go (~384 lines): rerun handling, circuit breaker, late data
- postrun.go (~166 lines): post-run drift detection

Also:
- Centralize magic constants in defaults.go
- Extract DynamoDB pagination helpers (ScanAll, QueryAll, QueryCount)
- Refactor control.go and rerun.go to use pagination helpers
- Merge isExcludedDate/isExcluded into shared isExcludedTime core
  with resolveTimezone helper (eliminates duplicated logic)
- Add trigger status_test.go, Databricks/EMR Serverless edge cases
- Add calendar registry tests (96.6% coverage, up from 72.4%)
- Add unit tests for ParseExecutionDate, InjectDateArgs, RemapPerPeriodSensors
- Add ValidateEnv() for fail-fast on missing env vars at cold start
- Call ValidateEnv in all 6 cmd/lambda/*/main.go entry points
- Add package-level godoc for internal/lambda/ and internal/trigger/
Add Runner.Execute dispatch tests for all 10 trigger types, Airflow
status check tests, EMR edge cases, and CheckStatus dispatch coverage.

Coverage: trigger 72.9% -> 85.8%, calendar 96.6%, lambda 86.8%, store 92.0%
- Preserve original timezone in isExcluded when no timezone configured
  (avoids subtle behavioral change from refactor)
- Fix double error prefix in ScanConfigs pagination refactor
- Add SLACK_BOT_TOKEN to alert-dispatcher required env vars
@github-actions github-actions bot added tests Test changes lambda Lambda handlers triggers Trigger types archetypes Archetypes and calendars labels Mar 8, 2026
@dwsmith1983 dwsmith1983 self-assigned this Mar 8, 2026
@dwsmith1983 dwsmith1983 merged commit ce8eafa into main Mar 8, 2026
6 checks passed
@dwsmith1983 dwsmith1983 deleted the refactor/codebase-quality-remediation branch March 8, 2026 13:33
@dwsmith1983 dwsmith1983 restored the refactor/codebase-quality-remediation branch March 14, 2026 03:41
@dwsmith1983 dwsmith1983 deleted the refactor/codebase-quality-remediation branch March 14, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

archetypes Archetypes and calendars lambda Lambda handlers tests Test changes triggers Trigger types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant