Phase 2 Plan 1: Shared Annotations Package Summary
Convention-based internal/annotations package with 22 exports covering HTTP config, headers, query params, unwrap, path utils, and method conversion -- ready for generator migration
Performance#
- Duration: 5 min
- Started: 2026-02-05T16:46:51Z
- Completed: 2026-02-05T16:51:57Z
- Tasks: 2
- Files created: 10
Accomplishments#
- Created
internal/annotationspackage with 9 source files following convention-based extensibility pattern - Unified all annotation parsing from 4 generators into shared types and functions with zero import cycles
- QueryParam struct covers all fields from all 4 generators (httpgen, clientgen, tsclientgen, openapiv3)
- Comprehensive unit test suite with 12 test functions and 8 benchmarks covering all pure functions
Task Commits#
Each task was committed atomically:
- Task 1: Create internal/annotations package -
e813d6c(feat) - Task 2: Write unit tests -
a91d27c(test) - Fix: nolint directive for linter auto-fix -
a452694(fix)
Files Created/Modified#
internal/annotations/doc.go- Package documentation with convention-based extensibility patterninternal/annotations/http_config.go- GetMethodHTTPConfig, GetServiceBasePath, HTTPConfig, ServiceConfig typesinternal/annotations/headers.go- GetServiceHeaders, GetMethodHeaders, CombineHeaders (sorted merge)internal/annotations/query.go- GetQueryParams with unified QueryParam struct (7 fields)internal/annotations/unwrap.go- HasUnwrapAnnotation, GetUnwrapField (validated), FindUnwrapField (simple), IsRootUnwrapinternal/annotations/field_examples.go- GetFieldExamplesinternal/annotations/path.go- ExtractPathParams, BuildHTTPPath, EnsureLeadingSlashinternal/annotations/method.go- HTTPMethodToString (uppercase), HTTPMethodToLower (lowercase)internal/annotations/helpers.go- LowerFirstinternal/annotations/annotations_test.go- 12 test functions + 8 benchmarks
Decisions Made#
- Transparent structs with protogen parameters: All exported structs have exported fields, all functions accept protogen types. This matches the existing codebase style where generators work with protogen types directly.
- GetServiceBasePath returns string: Simpler API than returning a single-field struct. The struct is still available as
ServiceConfigfor generators that need it. - Unified QueryParam with all fields: Rather than each generator selecting subset fields, the shared struct populates all fields upfront. Generators use what they need.
- Two unwrap APIs:
GetUnwrapFieldhas full validation (httpgen needs this),FindUnwrapFieldis simple lookup (tsclientgen/openapiv3 only need repeated field). Both exported for generator flexibility. - sort.Strings in CombineHeaders: Replaced bubble sort from openapiv3 with stdlib sort for idiomatic Go.
Deviations from Plan#
Auto-fixed Issues#
1. [Rule 1 - Bug] Fixed linter auto-fix conflict with sebuf/http import
- Found during: Task 2 verification (lint-fix)
- Issue: Linter auto-replaced
"GET"withhttp.MethodGetin test file, buthttpimport refers tosebuf/httpnotnet/http, causing compilation failure - Fix: Added
//nolint:usestdlibvarsdirective with explanation comment - Files modified:
internal/annotations/annotations_test.go - Verification:
go testpasses,make lint-fixclean - Committed in:
a452694
2. [Rule 1 - Bug] Fixed goconst linter warning for repeated "POST" string
- Found during: Task 1 verification (lint-fix)
- Issue: String
"POST"appeared 3 times inmethod.gotriggering goconst linter - Fix: Extracted HTTP method strings into unexported constants (methodGET, methodPOST, etc.)
- Files modified:
internal/annotations/method.go - Verification:
make lint-fixreports 0 issues - Committed in:
e813d6c(part of Task 1 commit)
Total deviations: 2 auto-fixed (2 bug fixes) Impact on plan: Both fixes necessary for clean compilation and linting. No scope creep.
Issues Encountered#
None -- plan executed smoothly.
User Setup Required#
None -- no external service configuration required.
Next Phase Readiness#
- Shared annotations package is compiled, tested, and lint-clean
- All 22 exported symbols ready for generator migration in plan 02-02
- No generator code was modified -- migration is next step
- Convention-based pattern documented in doc.go for future annotation additions
Phase: 02-shared-annotations Completed: 2026-02-05
