Skip to content

feat(common): public contracts package (v0.3.0 PR 2/10)#8

Merged
peczenyj merged 3 commits into
develfrom
feature/pkg-common
May 24, 2026
Merged

feat(common): public contracts package (v0.3.0 PR 2/10)#8
peczenyj merged 3 commits into
develfrom
feature/pkg-common

Conversation

@peczenyj

Copy link
Copy Markdown
Owner

Second PR of the v0.3.0 refactor: the pkg/common package — the public contracts that decouple every layer. Pure declarations, no logic.

What

  • types.goTarget (loader-agnostic view of a typed package, hides go/packages.Package), Finding, Layout, LayoutField, DiffStyle.
  • interfaces.goSizes (injectable arch sizing; method set matches go/types.Sizes so it's directly assignable to analysis.Pass.TypesSizes), Loader, Aligner, Inspector.

Notes

  • Kept in pkg/common (not internal/) so mockery can generate mocks from a non-internal source in a later PR.
  • Types and interfaces are mutually referential (TargetSizes, LoaderTarget), so they ship as one atomic, compilable commit (no half-building intermediate).
  • No behavior change to the CLI yet — nothing imports this package until PR 3+. task ci green.

Part of the v0.3.0 package-refactor series.

🤖 Generated with Claude Code

peczenyj and others added 3 commits May 24, 2026 20:13
Introduce pkg/common, the decoupling seam for the v0.3.0 refactor:
- types: Target (loader-agnostic typed package), Finding, Layout,
  LayoutField, DiffStyle.
- interfaces: Sizes (injectable arch sizing), Loader, Aligner, Inspector.

These are the public contracts every internal package implements or consumes;
kept out of internal/ so mockery can generate mocks from a non-internal source.
Types and interfaces are mutually referential (Target<->Sizes, Loader<->Target),
so they ship as one atomic, compilable commit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Make DiffStyle a uint8 enum and let `go tool enumer` generate its
String/parse/text-marshal helpers, matching the enumer convention used in
go-httputil. Options: -text (MarshalText/UnmarshalText), -transform=lower and
-trimprefix=Diff so the constants render as "unified"/"side"/"none".

enumer v1.6.1 has no flag.Value generator, so a 3-line Set method delegates to
the generated DiffStyleString parser, making *DiffStyle satisfy flag.Value for
direct use with the flag package (wired in the future app package).

Adds github.com/dmarkham/enumer as a tool dependency; diffstyle_enumer.go is
committed (and auto-excluded from lint as generated code).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Upgrade enumer v1.6.1 -> v1.6.3 and add -flag.value to the generate directive so
enumer emits the flag.Value Set method itself; drop the hand-written Set adapter.
*DiffStyle still satisfies flag.Value (verified by the existing test), now fully
generated — no bespoke code in pkg/common.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@peczenyj peczenyj merged commit dfcf666 into devel May 24, 2026
3 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