Skip to content

refactor: codebase quality remediation#69

Closed
dwsmith1983 wants to merge 5 commits intomainfrom
refactor/codebase-quality-remediation
Closed

refactor: codebase quality remediation#69
dwsmith1983 wants to merge 5 commits intomainfrom
refactor/codebase-quality-remediation

Conversation

@dwsmith1983
Copy link
Copy Markdown
Owner

Summary

  • Split stream router into focused domain files with DynamoDB pagination helper
  • Merge calendar exclusion logic and add test coverage
  • Add environment variable validation at Lambda startup with package documentation
  • Raise trigger package test coverage to 85.8%
  • Address code review findings across multiple packages

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 14, 2026
@dwsmith1983 dwsmith1983 self-assigned this Mar 14, 2026
@dwsmith1983
Copy link
Copy Markdown
Owner Author

All changes are already on main via #68. Closing as redundant.

@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