Skip to content

♻️ refactor(controller,api): generic family-sink reconciler (AR-08/F68) - #39

Merged
konih merged 5 commits into
mainfrom
feat/family-sink-generic-reconciler
Jul 8, 2026
Merged

konih merged 5 commits into
mainfrom
feat/family-sink-generic-reconciler

Conversation

@konih

@konih konih commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Collapses FamilySnapshotSinkReconciler / FamilyDatabaseSinkReconciler / FamilyEventSinkReconciler into one generic FamilySinkReconciler[T,PT], driven by a new FamilySinkObject accessor interface implemented by the three family-sink CRD kinds (api/v1alpha1/sink_adapter.go).
  • AR-08 / F68 per BACKLOG.md §3. Note: the backlog note says "collapse 6×" — that count is stale; cluster-scoped sink kinds were already removed, so this collapses 3 reconcilers, not 6. EC-P2-02 (panic-guarded reconcile) was already done on all three before this change and isn't claimed as new work here.
  • F68 payoff: before this lane, only KollectSnapshotSink had direct Reconcile()-entrypoint test coverage (envtest + panic-recovery). The new table-driven tests in internal/controller/family_sink_generic_test.go exercise all three kinds (panic-recovery, NotFound, preview-annotation happy path) through the shared implementation, closing that gap for Database and Event.
  • Minor behavior fix as a side effect of unifying the three: Reconcile() now logs connection-test failures for all three kinds (previously only Snapshot logged; Database/Event silently swallowed the log line while still propagating the error for requeue).

TDD

Red first: family_sink_generic_test.go was written against the not-yet-existing familySinkPtr/FamilySinkReconciler types (confirmed compile failure via go vet), then the generic reconciler + FamilySinkObject interface were implemented to turn it green.

Test plan

  • go build ./...
  • task verify (codegen drift — added +k8s:deepcopy-gen=false on the new FamilySinkObject interface so controller-gen skips it)
  • task lint / task arch-lint
  • task test (full unit + envtest suite)
  • task coverage — 80.9% (floor 72%)
  • task scrub — clean
  • task changelog:verify

🤖 Generated with Claude Code

@konih

konih commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

GATE REPORT — family-sink-generic-reconciler @ ee17624 — NO SELF-VERDICT — 2026-07-02

Lane: AR-08/F68 — collapse FamilySnapshotSinkReconciler/FamilyDatabaseSinkReconciler/FamilyEventSinkReconciler into one generic FamilySinkReconciler[T,PT]. EC-P2-02 not claimed (already done — all three already called guardReconcile before this lane).

This is the author's own PR, so per this repo's auto-mode policy no self-verdict is posted here — this is a gate report for the maintainer to review, not an APPROVE.

Gate matrix

Gate Result Notes
go build ./... ✅
task verify ✅ Added +k8s:deepcopy-gen=false on the new FamilySinkObject interface (api/v1alpha1) so controller-gen's object generator skips it — required to unblock task verify.
task lint ✅ 0 issues (one line-length fix in cmd/main.go for the wrapped generic instantiation)
task arch-lint ✅ No new violations
task test ✅ Full unit + envtest suite green
task coverage ✅ 80.9% (floor 72%)
task scrub ✅ Clean
task changelog:verify ✅ Verified against origin/main base
task helm-test N/A No chart changes
task vulncheck N/A No dependency changes

Findings

None at P0/P1/P2. One self-identified gap, fixed before opening this PR: the new FamilySinkObject accessor methods showed 0% in api/v1alpha1's own coverage profile (Go's default per-package -coverprofile doesn't attribute cross-package calls from internal/controller's tests back to the defining package) — added direct unit tests (TestFamilySinkObject_accessors) rather than leave it as an apparent gap.

Functional correctness

One FamilySinkReconciler[T,PT] now backs all three family-sink kinds via cmd/main.go registrations (each supplying only Name, everything else identical). familySinkPtr[T] constrains T to a pointer-receiver family-sink kind satisfying client.Object + the new kollectdevv1alpha1.FamilySinkObject interface. Behavior preserved except one intentional fix: Reconcile() now logs connection-test failures uniformly for all three kinds (previously Database/Event silently swallowed the log line, though the error was already propagated to guardReconcile for requeue — no behavior change to retry/status, only to log visibility).

Table-driven tests in family_sink_generic_test.go exercise panic-recovery, NotFound, and preview-annotation happy-path for all three kinds — previously only Snapshot had any direct Reconcile()-entrypoint coverage (the old Snapshot-only panic-recovery unit test in reconcile_guard_test.go was removed as redundant with the new generic version).

Coverage delta

internal/ floor: 80.9% (floor 72%), consistent with the last recorded wave state. internal/controller package: 76.8%. No package regressed; api/v1alpha1 gained direct coverage for the new accessor methods.

Summary

TDD: red test written first against the not-yet-existing generic types (confirmed compile failure via go vet), then implementation added to turn it green. Diff scope matches the stated lane exactly — no scope creep. Full gate report and RESULT posted to OPERATOR-BOARD.md.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 56.25000% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/controller/family_sink_controller.go 56.25% 6 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@konih

konih commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up notes (after posting the gate report above)

Scope clarification for future backlog updates: BACKLOG.md §5 and the archived audit tie AR-08/F68/AR-14 together ("AR-08 = F68 = AR-14 (no golden schema) = EC-P2-02"). This PR delivers AR-08 (collapse) and F68 (shared reconcile-entrypoint coverage for all three kinds). It does not touch AR-14 — the Snapshot golden schema is still missing (Database/Event already have one) — and Database/Event still lack a real "runs connection test on reconcile" envtest spec analogous to Snapshot's in phase_a_envtest_test.go (this PR's new tests cover panic-recovery/NotFound/preview-annotation via the fake client, not a live connection-test path through envtest). Flagging so a future SESSION-HANDOFF.md/BACKLOG.md update after merge doesn't collapse the whole AR-08/F68/AR-14 row as done — AR-14 and the Database/Event connection-test envtest specs remain open follow-ups.

CI: preflight and test-integration both failed on the first run. Neither looks related to this diff:

Re-ran both failed jobs (gh run rerun --failed) — will check back once they complete.

@konih

konih commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Both re-run jobs (preflight, test-integration) passed clean on retry — confirms both were transient environmental flakes (git-cliff GitHub API 403, Forgejo testcontainers auth hiccup in internal/sink/gitlab), unrelated to this diff. All 24 checks on this PR now pass. Ready for maintainer review.

@konih

konih commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

REVIEW — family-sink-generic-reconciler @ 64fbdf6 — APPROVE — 2026-07-06

Verdict: APPROVE
Reviewer: independent session (bulk PR-sweep, maintainer-directed)
Branch: feat/family-sink-generic-reconciler -> main

Gate matrix (run locally against origin/main after rebase)

Gate Result
go build ./... PASS
task verify PASS — RBAC/CRD codegen (combined kubebuilder markers) regenerated clean, no drift
task lint PASS — 0 issues
task arch-lint PASS
task test (full incl. envtest) PASS — all packages green
task coverage PASS — internal/ 82.6% (floor 72%)
task scrub PASS — clean
task changelog:verify PASS — resynced via task changelog:write, stable across repeated runs

Findings

None. Verified the FamilySinkReconciler[T, PT] generic collapse behaviorally: familySinkPtr[T]
correctly constrains PT to *T satisfying both client.Object and the new
FamilySinkObject interface; p.FamilySinkStatus() returns a pointer into the actual object's
status struct (not a copy), so &status.Conditions/&status.Preview still mutate the real object
before the guarded Status().Update. Confirmed +k8s:deepcopy-gen=false is correctly applied
to the new FamilySinkObject interface (an interface type, not a struct — deepcopy-gen would
otherwise choke on it), and task verify regenerated zz_generated.deepcopy.go/CRD/RBAC bases
with no diff beyond what's expected. Confirmed the removed dedicated
TestFamilySnapshotSinkReconciler_recoversReconcilePanic is not a coverage loss — it's superseded
by the new table-driven TestFamilySinkReconciler_{Snapshot,Database,Event}_recoversReconcilePanic
in family_sink_generic_test.go, which additionally extends the same coverage to Database/Event
(previously untested at the Reconcile-entrypoint level). One intentional behavior addition, not a
regression: Reconcile() now logs connection-test failures uniformly for all three kinds (Database/
Event previously swallowed the log line silently, per the PR's own gate report) — error still
propagated to guardReconcile either way, no retry/status change.

Summary

Diff vs current origin/main is exactly the 8 expected files. Clear to merge.

konih added 3 commits July 8, 2026 00:35
Collapse FamilySnapshotSinkReconciler/FamilyDatabaseSinkReconciler/
FamilyEventSinkReconciler into one FamilySinkReconciler[T,PT], driven by a
new FamilySinkObject accessor interface on the three CRD kinds. Reduces
three near-identical Reconcile/SetupWithManager pairs to one.

Only KollectSnapshotSink had direct Reconcile()-entrypoint test coverage
before this (envtest + panic-recovery); the new table-driven tests in
family_sink_generic_test.go exercise all three kinds through the shared
implementation, closing that gap for Database and Event.

EC-P2-02 (panic-guarded family-sink reconcile) was already done on all
three reconcilers before this change; not claimed as new work here.
The generic FamilySinkReconciler (AR-08) is already exercised through
internal/controller's table-driven tests, but Go's per-package coverage
profile doesn't attribute those cross-package calls back to
api/v1alpha1 — leaving FamilySinkSpec/FamilySinkCommon/FamilySinkStatus
at 0% self-coverage. Add direct tests so the accessor wiring for each
of the three kinds has its own coverage record.
@konih
konih force-pushed the feat/family-sink-generic-reconciler branch from 64fbdf6 to 5d9eb08 Compare July 7, 2026 22:35
@konih

konih commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

REVIEW — /kollect-mr-review

Verdict: APPROVE

Scope: Generic family-sink reconciler (AR-08/F68) — replaces three near-identical reconcilers (FamilySnapshotSinkReconciler, FamilyDatabaseSinkReconciler, FamilyEventSinkReconciler) with one Go-generic FamilySinkReconciler[T, PT] driven by a new FamilySinkObject interface.

Gate matrix: GitHub CI green on head 119a26efe: required preflight ✅ + test ✅, test-integration ✅, full suite green.

  • Correctness: Idiomatic generics — familySinkPtr[T] constrains *T to client.Object + FamilySinkObject; var obj T; p := PT(&obj) is the standard zero-value+pointer pattern. Reconcile flow (trackReconcile→guardReconcile→familySinkConnection.reconcile) is preserved verbatim via interface accessors. Name field unifies controller name + metric label (the three kinds always used the same string). ✅
  • Codegen/RBAC: Three per-kind rbac marker blocks consolidated; verify gate green confirms manifests/deepcopy/RBAC regenerate consistently. FamilySinkObject marked +k8s:deepcopy-gen=false. ✅
  • TDD: New family_sink_generic_test.go (+180) exercises all three kinds through the generic reconciler; reconcile_guard_test.go/phase_a_envtest_test.go adjusted. ✅
  • Conflicts: CHANGELOG-only, regenerated post-merge-commit. ✅

Non-blocking: vulncheck red = GO-2026-5856 (stdlib, repo-wide, non-required) — tracked as separate Go 1.26.5 bump.

Merging via merge-commit.

@konih
konih merged commit 20095fa into main Jul 8, 2026
23 of 24 checks passed
@konih
konih deleted the feat/family-sink-generic-reconciler branch July 8, 2026 21:05
konih added a commit that referenced this pull request Jul 10, 2026
♻️ refactor(controller,api): generic family-sink reconciler (AR-08/F68)
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