Skip to content

Fix/deps 20260501#38

Open
hyp3rd wants to merge 18 commits intomainfrom
fix/deps-20260501
Open

Fix/deps 20260501#38
hyp3rd wants to merge 18 commits intomainfrom
fix/deps-20260501

Conversation

@hyp3rd
Copy link
Copy Markdown
Owner

@hyp3rd hyp3rd commented May 2, 2026

No description provided.

hyp3rd added 17 commits May 1, 2026 20:25
- Add Codacy Security Scan workflow with a Python-based SARIF splitter
  to handle large result sets across multiple GitHub Advanced Security uploads
- Add CodeQL analysis workflow for static analysis of Go code
- Add SLSA3 provenance workflow with keyless cosign signing on release,
  generating a source archive with SHA-256 subjects
- Rename pre-commit.yml → lint.yml; replace pre-commit runner with native
  Go tooling (gci, gofumpt, staticcheck, golangci-lint) and go mod tidy check
- Bump cspell-cli v9.4.0 → v10.0.0 in pre-commit configs
- Bump zerolog v1.35.0 → v1.35.1, zap v1.27.1 → v1.28.0,
  go-isatty v0.0.21 → v0.0.22; add go.yaml.in/yaml/v3 v3.0.4
Remove all third-party runtime dependencies (zap, logrus, zerolog,
goccy/go-json, emperror, hashicorp/multierr, uber/multierr, testify)
leaving only gopkg.in/yaml.v3. Replace goccy/go-json with stdlib
encoding/json throughout.

Core Error struct:
- Promote errorContext, recovery, and retry out of the generic metadata
  map into dedicated typed fields, eliminating unsafe string-keyed
  lookups and data races at option-application time.
- Add httpStatus, retryable (tri-state *bool), safeMsg, and fullMsg
  fields for new cross-cutting attributes.
- Cache Error() and Stack() outputs lazily via sync.Once.
- Introduce newAt/wrapAt internal helpers with explicit caller-skip
  counts; expose NewSkip/WrapSkip for helper-wrapping use cases.
- Add WithStackDepth option to cap or disable stack capture.
- Remove the broken Is() override; rely solely on Unwrap() so
  errors.Is/As use standard pointer-identity semantics.
- Lazily initialise the metadata map (nil until first WithMetadata).

New surface area (attributes.go):
- WithHTTPStatus / HTTPStatus – attach and read HTTP status codes from
  the error chain.
- WithRetryable / IsRetryable – explicit tri-state retry classification
  with fallback to stdlib Temporary() interface.
- WithSafeMessage / SafeError – redacted error messages for untrusted
  log sinks.

Format improvements:
- Implement fmt.Formatter (%s, %q, %v, %+v) on *Error.
- Implement slog.LogValuer so structured loggers receive a group of
  fields rather than an opaque string.
- standardErrorOutput walks errors.Unwrap for non-ewrap causes so
  JSON/YAML output preserves the full chain.

Logger:
- Move the Logger interface from internal/logger to the root package.
- Drop all bundled third-party adapters (pkg/logger/adapters).
- Add slog/ subpackage with a minimal stdlib slog.Adapter.

Circuit breaker (threshold.go):
- Upgrade sync.RWMutex → sync.Mutex; all state mutations are writes.
- Capture transition details into a transitionEvent while holding the
  lock, then fire observer/callback synchronously after releasing it,
  eliminating the goroutine launch and the need for sleeps in tests.
- Fix CanExecute lock-upgrade race: acquire write lock upfront.

Tooling:
- Bump golangci-lint to v2.12.1, buf to v1.69.0.
- Enable gomodguard_v2, disable testpackage linter.
- Add ci Makefile target; tighten .PHONY list.
- Remove stale .trunk/ symlinks.

BREAKING CHANGE: pkg/logger/adapters and internal/logger packages are
removed. Callers using the bundled Zap/Logrus/Zerolog adapters must
write their own thin adapter (≤10 lines) or switch to the new slog/
subpackage. The Logger interface is now exported from the root ewrap
package instead of internal/logger.
…nter findings

- Swap encoding/json for github.com/goccy/go-json in error_group.go, format.go,
  and all test files for improved serialization performance
- Add test_helpers_test.go with shared string constants and package-level sentinel
  errors to silence goconst/revive warnings and improve readability
- Enable t.Parallel on all tests and subtests; extract oversized test bodies into
  named helpers to satisfy the funlen linter
- Pin ErrorType and Severity string representations as named constants in types.go,
  removing duplicate free-floating string literals
- Add defensive default case in CircuitBreaker.CanExecute switch
- Simplify format_verb.go Format() using fmt.Fprintf/Fprint; rename param s→state;
  add explicit default case
- Suppress intentional err113 finding in errors.go with a nolint pragma
- Update .golangci.yaml: enable test-file linting, disable check-blank, add
  fmt.Fprint to errcheck exclusions
- Refactor profile_test.go: extract profileCase named type, add filepath.Clean,
  add nolint pragmas for intentional runtime.GC calls
Move the CircuitBreaker implementation out of the root ewrap package and
into a new breaker/ subpackage, so consumers who only need error wrapping
do not pull in the circuit-breaker dependency.

- Add breaker/breaker.go with Breaker, State, and Observer types;
  the subpackage defines its own no-op observer and transitionEvent
  helpers independent of the parent module.
- Add breaker/breaker_test.go with a full test suite covering state
  transitions, concurrency safety, callbacks, and observer hooks.
- Simplify ewrap.Observer to RecordError only; remove
  RecordCircuitStateTransition and the root-level noopObserver.
- Delete threshold.go and threshold_test.go, now superseded by the
  new subpackage.
- Update test/benchmark_test.go and test/profile_test.go to import
  and use breaker.New / breaker.Breaker instead of the removed ewrap
  constructors.
- Replace the manual curl-based golangci-lint install in the lint
  workflow with the official golangci/golangci-lint-action@v9 action.
Rewrite the README from ~474 to ~283 lines: replace the verbose feature
list with a concise Highlights section, add a focused Quick Tour with
real code snippets, include an accurate benchmark table, and add a
project layout tree. Update the GitHub Sponsors badge URL.

Rewrite all docs/docs/advanced/ pages (context, error-strategies,
error-types, formatting, performance, testing) with the same principle:
remove padding and boilerplate, add comparison tables for quick
scanning, and tighten examples to show only what the reader needs.

Harden the lint CI workflow:
- Pin golangci/golangci-lint-action from floating @v9 to @v9.2.0
- Add top-level `permissions: contents: read` (least-privilege)
- Remove the redundant commented-out manual golangci-lint install
Comment out the explicit `version` input for the `golangci-lint-action`
step, allowing the action to use its own default version rather than
resolving it from the settings output. This simplifies the workflow and
avoids potential failures if the settings-derived version becomes stale
or unavailable.
…port

- Rename workflow from "CodeQL" to "CodeQL Advanced"
- Add `actions` and `ruby` languages to the analysis matrix alongside `go`
- Introduce per-language `build-mode` configuration (autobuild for Go,
  none for actions/ruby) replacing the single global Autobuild step
- Update runner selection to use `macos-latest` for Swift, `ubuntu-latest`
  otherwise
- Add a `Run manual build steps` step (gated on `build-mode == manual`)
  to surface explicit failures for compiled languages that need a manual build
- Fix action pin: `actions/checkout` downgraded from v6 to v4 for
  compatibility with current CodeQL action versions
- Update CodeQL scheduled scan cron to `31 1 * * 4`
- Reorder permissions block and add `packages: read` for private CodeQL
  pack fetching
Update GCI import prefix default and provenance archive naming from
`github.com/hyp3rd/starter` to `github.com/hyp3rd/ewrap` across lint
and provenance workflows. Also apply minor YAML formatting cleanups
(branch list spacing, long-line wrapping) in .github/lint.yml.
Move package doc comments from implementation files into separate docs.go
files for the root `ewrap`, `breaker`, and `slog` packages. This follows
the Go convention of keeping package documentation in a dedicated file,
keeping implementation files free of doc-only preamble.

- Add `docs.go` to root package (`ewrap`) with module-level doc comment
- Add `breaker/docs.go` with circuit-breaker package doc (moved from breaker.go)
- Add `slog/docs.go` with slog adapter package doc (moved from slog.go)
- Reformat README.md badges onto individual lines for better readability
- Add Stdlib to the cspell custom dictionary
- Pin golangci/golangci-lint-action to a specific commit hash for
  improved supply-chain security instead of using a mutable version tag
- Fix package doc comments in docs.go and breaker/docs.go to follow
  Go conventions (must begin with "Package <name>")
- Correct GitHub Sponsors badge URL in README (remove erroneous /sponsors suffix)
- Fix typo: "categorisation" → "categorization" in README
- Extend cspell custom dictionary and config with missing Go-related terms
  (ewrapslog, glog, gopkg, stdslog, benchmem, gofumpt, gosec)
- Re-enable `embeddedstructfieldcheck`, `gomoddirectives`, `lll`, `recvcheck`,
  `tagliatelle`, and `tagalign` linters (moved from `disable` to configured)
- Disable `nolintlint` to suppress noisy meta-lint warnings
- Add `tagliatelle` config enforcing snake_case for JSON/YAML struct tags
- Remove `gofiber/fiber` from `wrapcheck` ignore globs
- Move `//nolint:revive` to function-level directive in `profile_test.go`
  and extract inline comment for clarity
- Fix typo: parallelised → parallelized
- Add `paralleltest` to cspell custom dictionary
- Remove redundant package-level doc comment from `errors.go`
- Re-enable `embeddedstructfieldcheck`, `gomoddirectives`, `lll`, `recvcheck`,
  `tagliatelle`, and `tagalign` linters (moved from `disable` to configured)
- Disable `nolintlint` to suppress noisy meta-lint warnings
- Add `tagliatelle` config enforcing snake_case for JSON/YAML struct tags
- Remove `gofiber/fiber` from `wrapcheck` ignore globs
- Move `//nolint:revive` to function-level directive in `profile_test.go`
  and extract inline comment for clarity
- Fix typo: parallelised → parallelized
- Add `paralleltest` to cspell custom dictionary
- Remove redundant package-level doc comment from `errors.go`
- Rename docs.go to doc.go in root, breaker/, and slog/ packages
  to follow Go naming conventions
- Add godoc Makefile target for local documentation server on :8089
- Remove unused .gitkeep placeholders from configs/ and scripts/
Add top-level `permissions: contents: read` to codeql and security
workflows to follow the principle of least privilege for GitHub Actions.
Copilot AI review requested due to automatic review settings May 2, 2026 22:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors ewrap to a more stdlib-first footprint by removing bundled third-party logger adapters and moving the circuit breaker into an opt-in subpackage, while adding fmt.Formatter + slog.LogValuer integrations and updating tests/docs/tooling accordingly.

Changes:

  • Move circuit breaker implementation/tests out of the root package into breaker/, and remove the old threshold* implementation.
  • Introduce (*Error).Format and (*Error).LogValue, plus a new ewrap/slog adapter subpackage for ewrap.Logger.
  • Simplify dependencies (drop testify/zap/logrus/zerolog/etc.), add shared test fixtures, and significantly revise documentation + CI/lint configuration.

Reviewed changes

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Show a summary per file
File Description
types.go Pins canonical enum string values as constants; updates String() methods to use them.
types_test.go Updates enum/string tests; adds parallelization and constant reuse.
threshold.go Removes legacy root-package circuit breaker implementation.
threshold_test.go Removes legacy circuit breaker tests.
breaker/breaker.go Adds new circuit breaker subpackage implementation with observer/callback dispatch outside lock.
breaker/breaker_test.go Adds tests for the new breaker package.
breaker/doc.go Documents breaker package behavior and callback/observer constraints.
observability.go Narrows Observer to error-only notifications; breaker observation moved to subpackage.
observability_test.go Updates observer tests to match the new interface and removes breaker observer tests.
logger.go Introduces root Logger interface (moved out of internal/logger).
internal/logger/logger.go Removes old internal logger interface.
internal/logger/logger_test.go Removes old internal logger interface tests.
pkg/logger/adapters/logger.go Removes bundled zap/logrus/zerolog adapters.
pkg/logger/adapters/logger_test.go Removes adapter tests.
pkg/logger/adapters/slog.go Removes old slog adapter from pkg/ tree.
pkg/logger/adapters/slog_test.go Removes old slog adapter tests.
slog/slog.go Adds new ewrap/slog adapter package for stdlib *log/slog.Logger.
slog/slog_test.go Adds tests for the new slog adapter.
slog/doc.go Package docs for the slog adapter subpackage.
format_verb.go Adds fmt.Formatter and slog.LogValuer implementations on *Error.
format.go Refactors serialization building: copies metadata via maps.Copy, preserves cause chain for standard errors via errors.Unwrap.
error_group.go Improves serialization to preserve cause chain for standard wrapped errors too.
error_group_test.go Refactors tests/benchmarks; adds more parallelization and shared fixtures usage.
attributes.go Adds HTTP status / retryable / safe-message attributes + chain-walking helpers.
attributes_test.go Adds tests for HTTPStatus, IsRetryable, SafeError, and formatting verbs.
retry.go Moves retry info to a typed field (e.retry) and simplifies locking.
retry_test.go Removes testify; tests retry via typed accessors and adds parallelization.
stack.go Switches stack filtering to shared isInternalFrame helper (no local string filtering).
stack_test.go Refactors stack tests to use shared fixtures and adds parallelization.
test_helpers_test.go Centralizes common test strings/errors/constants to reduce const-linter noise.
hardening_test.go Adds deep-chain, %w contract, stack-capture, and JSON fuzz hardening tests.
test/profile_test.go Refactors profiling suite (table-driven profile cases) and updates to use breaker subpackage.
test/benchmark_test.go Updates benchmarks to use shared fixtures, breaker subpackage, and removes repeated literals.
test/load_test.go Deletes commented-out load test scaffold.
test/comparison_benchmark_test.go Deletes benchmark comparisons against external libraries (deps removed).
__examples/main.go Updates example to use stdlib slog adapter (ewrap/slog) and removes third-party logger demos.
doc.go Adds top-level package documentation for ewrap.
docs/mkdocs.yml Restructures navigation and adds new feature pages; adjusts copyright text.
docs/docs/index.md Rewrites landing page to match new footprint and features (breaker subpackage, slog integration, etc.).
docs/docs/getting-started/quickstart.md Updates quickstart to reflect %w-aware Newf, operational attributes, slog, breaker subpackage.
docs/docs/getting-started/installation.md Updates install/docs for core deps + subpackages and adapter guidance.
docs/docs/features/slog-adapter.md Adds documentation page for the slog adapter subpackage.
docs/docs/features/operational.md Adds documentation for HTTP status / retryable / safe-message behavior.
docs/docs/features/metadata.md Updates metadata docs to reflect typed reserved fields and lazy metadata allocation.
docs/docs/features/format-and-slog.md Adds documentation for fmt.Formatter and slog.LogValuer.
docs/docs/features/error-wrapping.md Rewrites wrapping docs with stack semantics, inheritance, and WrapSkip guidance.
docs/docs/features/error-creation.md Rewrites error creation docs, including %w handling and helper factory patterns.
docs/docs/examples/basic.md Updates examples to compile against the new API surface and subpackages.
docs/docs/api/options.md Updates canonical options reference (typed fields, operational attributes, etc.).
docs/docs/api/interfaces.md Updates interface docs for new root Logger and narrowed Observer, plus breaker observer.
docs/docs/advanced/error-types.md Updates guidance on using ErrorType + HTTP status and domain extension patterns.
go.mod Drops third-party deps and simplifies require list to YAML + go-json.
go.sum Updates sums to match the reduced dependency footprint.
.golangci.yaml Enables linting of test files; adjusts enabled/disabled linters and errcheck settings; adds tagliatelle config.
Makefile Updates lint tool versions; renames benchmark target; adds godoc target; tweaks phony targets.
.project-settings.env Bumps tool versions (golangci-lint, buf).
.pre-commit/golangci-lint-hook Updates default golangci-lint version.
.pre-commit-config.yaml Tweaks hooks formatting/exclusions; bumps cspell-cli revision.
.pre-commit-ci-config.yaml Mirrors pre-commit config updates for CI.
.markdownlint.json Adds markdownlint config (disables MD013).
cspell.config.yaml Adds new words for tooling and docs.
.cspell/custom-dictionary.txt Adds project-specific terms used in docs/code.
.github/workflows/security.yml Tightens permissions and adjusts formatting/command invocation.
.github/workflows/provenance.yml Adds a provenance/signing workflow for release artifacts.
.github/workflows/pre-commit.yml Removes old pre-commit workflow.
.github/workflows/lint.yml Adds a new lint workflow running tidy/gci/gofumpt/staticcheck/golangci-lint.
.github/workflows/codeql.yml Adds CodeQL Advanced workflow.
.github/workflows/codacy.yml Adds Codacy security scan workflow with SARIF splitting/upload.
.github/lint.yml Updates default gci_prefix fallback and YAML formatting.
context.go Stores ErrorContext in typed field instead of reserved metadata key.
scripts/.gitkeep Placeholder (no functional change).
configs/.gitkeep Placeholder (no functional change).
pkg/.gitkeep Placeholder (no functional change).
Comments suppressed due to low confidence (1)

Makefile:107

  • The target ci: .PHONY is not valid Make syntax for declaring phony targets and makes ci depend on a file named .PHONY. If you intended a phony ci target, define it as ci: and add it to the .PHONY: list (e.g., .PHONY: ci).
godoc:
	@echo "Generating documentation..."
	godoc -v -http=:8089 -play -index

ci: .PHONY


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants