Skip to content

Adopt webcore v0.1.0 (errors, crypto, UI components) - #155

Open
sarg3nt wants to merge 8 commits into
mainfrom
feature/webcore-adoption
Open

Adopt webcore v0.1.0 (errors, crypto, UI components)#155
sarg3nt wants to merge 8 commits into
mainfrom
feature/webcore-adoption

Conversation

@sarg3nt

@sarg3nt sarg3nt commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

First adoption pass of the shared webcore library, pinned at the published v0.1.0 tag (no replace directive — CI/Docker resolve it from the module proxy).

  • errorswebcore/core/errors (9 handler import sites; deleted the duplicated internal package — byte-identical behavior)
  • cryptowebcore/core/crypto via NewFromHashedKey, which reproduces the legacy SHA-256 key derivation exactly, so existing at-rest encrypted API keys / git PATs still decrypt (wire format nonce||ciphertext||tag unchanged)
  • UI componentswebcore/ui/components: the whole internal/framework/ui package (100% function parity — it's where webcore's components were extracted from) plus the duplicated templates/components files (info_tooltip, settings, table, live_refresh) via a thin re-export shim, so all existing components.X call sites compile unchanged while the markup is owned solely by webcore
  • Hub shutdown fixes backported to gearbox's own events package (same two bugs fixed in webcore v0.1.0: Subscribe deadlocked forever when racing Stop() — reachable from the SSE handler, pinning the HTTP goroutine — and Stop() panicked on a second call)

Kept in gearbox (deliberate): RBAC/auth (#148), events package (typed Publish API + SSE wire format), static JS/CSS (#149 — blocked on webcore#2 namespace renames), doughnut/metrics/console/container_diagram components.

Verification

  • go build ./... and go test ./internal/... green against the published tag
  • Adversarial review of the diff: crypto key-derivation byte-compat confirmed, errors drift = doc comments only, re-export shim forwards children correctly, no dangling imports
  • Visual verification in Chrome against the running dev server: HAProxy dashboard (toggles, badges, doughnuts, collapsibles, tooltips) renders identically; showToast operational

Part of the webcore adoption effort — follow-ups tracked in #148 (auth) and #149 (static assets).

🤖 Generated with Claude Code

sarg3nt and others added 5 commits May 29, 2026 09:33
Repoint the 9 apperrors import sites to github.com/sarg3nt/webcore/core/errors
and delete the now-duplicated internal/framework/errors. Adds webcore require +
local replace directive.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Repoint services/crypto imports to webcore/core/crypto; main.go uses
crypto.NewFromHashedKey (the legacy SHA-256 derivation) so existing at-rest
encrypted data (server API keys, git PATs) still decrypts. Delete the
duplicated internal package.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The internal/framework/ui package was 100% function-parity with
webcore/ui/components (it's where they were extracted from). Repoint all 12
importers to webcore (aliased ui/templcomponents to preserve call sites),
delete the duplicated package, regenerate templ. Also fix a crypto follow-up:
agent_keyring test now uses crypto.NewFromHashedKey.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…om webcore

Delete the duplicated component files from templates/components and re-export
the moved funcs (InfoTooltip, Settings*, Table*, LiveRefresh*) + type aliases
(SelectOption, TableConfig, TableColumn) as thin wrappers delegating to
webcore/ui/components, so existing components.X call sites keep working with no
churn and the markup is owned solely by webcore. Gearbox-only components
(console, container_diagram, metrics/SystemMetrics, doughnut — coupled to
metrics' unexported helpers) stay in the package.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two fixes from the adversarial review of the webcore adoption branch:

1. Module resolution: the local `replace => ../../webcore` with a fake v0.0.0
   only resolved on the development machine — CI's single-repo checkout,
   Docker's `context: ./gearbox`, and `go install` all failed. webcore is now
   published and tagged, so pin the real github.com/sarg3nt/webcore v0.1.0
   (go.sum hashes recorded) and drop the replace directive entirely.

2. Backport the events.Hub shutdown fixes to gearbox's own copy (the same
   bugs were fixed in webcore v0.1.0; gearbox still runs its own events
   package until that cutover): Subscribe deadlocked forever when called
   after Stop — reachable from the SSE handler on any shutdown race, pinning
   the HTTP goroutine — and Stop panicked on a second call. Subscribe now
   selects on done and returns a pre-closed Events channel (the SSE handler's
   !ok receive already handles it); Stop is sync.Once guarded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 4, 2026 03:30
Its only consumer (settings.templ) moved to webcore; the pages package has
its own copy. Fixes the unused-func lint on PR #155.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 performs the first adoption pass of the shared github.com/sarg3nt/webcore module (pinned to v0.1.0) by switching Gearbox over to webcore’s core helpers (errors + crypto) and UI component library, while also backporting shutdown-race fixes to Gearbox’s own event hub.

Changes:

  • Replace Gearbox’s internal errors package with webcore/core/errors across HTTP handlers (and remove the duplicated local implementation/tests).
  • Replace Gearbox’s internal AES-GCM encryptor with webcore/core/crypto (including updating construction to NewFromHashedKey).
  • Move UI components to webcore/ui/components, deleting local templ sources and adding a thin templates/components re-export shim to keep components.X call sites unchanged; also fix events.Hub shutdown races (Stop() idempotent, Subscribe() non-blocking on shutdown).

Reviewed changes

Copilot reviewed 52 out of 53 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
gearbox/internal/gears/home/widget_runner.go Switch crypto import to webcore.
gearbox/internal/gears/home/handlers.go Switch crypto import to webcore.
gearbox/internal/framework/ui/toggle.templ Remove local UI component (now sourced from webcore).
gearbox/internal/framework/ui/toast.templ Remove local UI component (now sourced from webcore).
gearbox/internal/framework/ui/table.templ Remove local UI component (now sourced from webcore).
gearbox/internal/framework/ui/modal.templ Remove local UI component (now sourced from webcore).
gearbox/internal/framework/ui/live_refresh.templ Remove local UI component (now sourced from webcore).
gearbox/internal/framework/ui/icons.templ Remove local UI component (now sourced from webcore).
gearbox/internal/framework/ui/collapsible.templ Remove local UI component (now sourced from webcore).
gearbox/internal/framework/ui/badge.templ Remove local UI component (now sourced from webcore).
gearbox/internal/framework/ui/alerts.templ Remove local UI component (now sourced from webcore).
gearbox/internal/framework/templates/pages/welcome.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/pages/user_pages.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/pages/overview.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/pages/log_settings.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/pages/haproxy_settings.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/pages/haproxy_gear_settings.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/pages/gears.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/pages/backup.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/pages/alert_rules.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/pages/admin_user_permissions.templ Switch UI components import alias to webcore.
gearbox/internal/framework/templates/pages/admin_permissions.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/layouts/base.templ Switch UI components import to webcore.
gearbox/internal/framework/templates/components/webcore_reexport.templ Add templ wrappers re-exporting moved components from webcore.
gearbox/internal/framework/templates/components/webcore_reexport.go Add type aliases to preserve components.* parameter types.
gearbox/internal/framework/templates/components/table.templ Remove duplicated local component (now re-exported from webcore).
gearbox/internal/framework/templates/components/settings.templ Remove duplicated local component (now re-exported from webcore).
gearbox/internal/framework/templates/components/live_refresh.templ Remove duplicated local component (now re-exported from webcore).
gearbox/internal/framework/templates/components/info_tooltip.templ Remove duplicated local component (now re-exported from webcore).
gearbox/internal/framework/services/server_adapter.go Switch crypto import to webcore.
gearbox/internal/framework/services/crypto/encryption.go Remove duplicated local encryptor implementation.
gearbox/internal/framework/services/auth_adapter.go Switch crypto import to webcore.
gearbox/internal/framework/services/agent_keyring/rotator.go Switch crypto import to webcore.
gearbox/internal/framework/services/agent_keyring/rotator_test.go Update encryptor constructor to webcore API.
gearbox/internal/framework/handler/users.go Switch errors import to webcore.
gearbox/internal/framework/handler/security.go Switch errors import to webcore.
gearbox/internal/framework/handler/haproxy_config.go Switch crypto import to webcore.
gearbox/internal/framework/handler/handler.go Switch crypto import to webcore.
gearbox/internal/framework/handler/config.go Switch errors import to webcore.
gearbox/internal/framework/handler/backup.go Switch errors import to webcore.
gearbox/internal/framework/handler/api_traffic.go Switch errors import to webcore.
gearbox/internal/framework/handler/api_services.go Switch errors import to webcore.
gearbox/internal/framework/handler/api_logs.go Switch errors import to webcore.
gearbox/internal/framework/handler/api_certificates.go Switch errors import to webcore.
gearbox/internal/framework/handler/alerts.go Switch errors import to webcore.
gearbox/internal/framework/events/hub.go Make Stop() idempotent and avoid shutdown-race deadlock in Subscribe().
gearbox/internal/framework/errors/errors.go Remove duplicated local errors implementation (now webcore).
gearbox/internal/framework/errors/errors_writehttp_test.go Remove local errors tests (now webcore-owned).
gearbox/go.sum Add webcore + dependency version bumps.
gearbox/go.mod Add webcore dependency and bump related deps.
gearbox/cmd/server/main.go Switch encryptor construction to webcore NewFromHashedKey.
docs/webcore-extraction-plan.md Add documentation describing extraction/adoption plan.

Comment thread gearbox/internal/framework/services/agent_keyring/rotator_test.go
Comment thread gearbox/go.mod
Copilot AI review requested due to automatic review settings July 4, 2026 03:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 52 out of 53 changed files in this pull request and generated 1 comment.

Comment thread docs/webcore-extraction-plan.md Outdated
sarg3nt and others added 2 commits July 3, 2026 20:38
- rotator_test: failure message said NewEncryptor; the call is NewFromHashedKey
- go.mod: move the direct webcore dependency into the direct require block

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The canonical copy lives in the webcore repo (docs/webcore-extraction-plan.md);
this stale duplicate also hardcoded contributor-specific paths, per review.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 4, 2026 03:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 51 out of 52 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants