Skip to content

✨ feat(controller): surface extraction failures in target status (EC-P1-05) - #36

Merged
konih merged 4 commits into
mainfrom
feat/ec-p1-05-extract-failure-visibility
Jul 6, 2026
Merged

konih merged 4 commits into
mainfrom
feat/ec-p1-05-extract-failure-visibility

Conversation

@konih

@konih konih commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Attribute extraction errors (invalid/per-resource-failing CEL or JSONPath) were previously only logged and the resource silently skipped — nothing reached KollectTarget.status.
  • internal/collect.Engine now tracks, per target, the set of resources currently failing extraction (mirrors the existing forbidden/accessErr maps) behind a new ExtractFailures(ns, name) (count int, lastErr string) accessor.
  • KollectTargetReconciler always writes status.extractionFailures / status.lastExtractionError, and hard-degrades the target (new ExtractionFailed reason) when the count is non-zero — matching the existing AccessCheckFailed disposition for the same ErrTerminal class (GUIDELINES.md §1), deliberately not the EC-P2-01 partial-scope-degrade pattern, since that's specific to ErrForbidden.
  • Scoped to KollectTarget only; KollectClusterTarget doesn't yet check any of forbidden/accessErr/extraction signals — pre-existing gap, not introduced here.

Test plan

  • go build ./...
  • task verify (CRD/deepcopy codegen committed)
  • task lint / task arch-lint
  • task test (full suite incl. envtest, race detector)
  • task coverage — internal/ 80.7% (floor 72%)
  • task scrub / gitleaks protect --staged
  • task changelog:verify
  • TDD: engine_extract_failure_test.go and kollecttarget_extraction_failed_test.go written and confirmed red (compile failures) before any production code changed

konih added 2 commits July 1, 2026 00:03
…P1-05)

Attribute extraction errors (invalid/per-resource-failing CEL or
JSONPath, ADR-0020 ErrTerminal) were previously only logged and the
resource silently skipped — nothing reached KollectTarget.status, and
GUIDELINES.md §1's mandated Degraded transition for terminal errors
never fired.

Engine now tracks, per target, the set of resources currently failing
extraction (mirrors the existing forbidden/accessErr maps) behind a
new ExtractFailures(ns, name) accessor returning a count and the most
recent error message — counts/messages only, no per-resource payload
(GUIDELINES.md §2 etcd-size guard). KollectTargetReconciler always
writes these into status.extractionFailures/lastExtractionError, and
hard-degrades the target (new ExtractionFailed reason) when the count
is non-zero, matching the existing AccessCheckFailed disposition for
the same ErrTerminal class — deliberately not the EC-P2-01
partial-scope-degrade pattern, since that's specific to ErrForbidden.

TDD: engine_extract_failure_test.go and
kollecttarget_extraction_failed_test.go were written and confirmed
red (compile failures against not-yet-existing types/fields) before
any production code changed.
@konih

konih commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

REVIEW — ec-p1-05-extract-failure-visibility @ 3451d5f — NO SELF-VERDICT — 2026-07-01

No verdict posted (auto-mode classifier blocks self-authored APPROVE on own commits this
session even with chat confirmation, per AGENTS.md standing rule). Raw gate results + findings
below for the maintainer to judge directly.

Reviewer: next-sprint session (self-review attempt blocked by auto-mode classifier)
Branch: feat/ec-p1-05-extract-failure-visibility -> main · Base: origin/main @ 3d78cd0fa · PR: #36

Gate matrix

Gate Result Notes
go build ./... PASS
task verify PASS CRD (config/crd/bases/kollect.dev_kollecttargets.yaml) + deepcopy regenerated and committed
task lint PASS golangci-lint 0 issues (after one gofmt -w fix on the new test file)
task arch-lint PASS OK — No warnings found
task test PASS full suite incl. envtest green, race detector on
task coverage PASS internal/ 80.7% (floor 72%); internal/collect 89.0%, internal/controller 75.6%
task scrub PASS clean
task changelog:verify PASS synced in 3451d5fee
task helm-test n/a no chart changes
task vulncheck n/a no go.mod/go.sum changes

Findings

ID Sev Area Finding Evidence Block?
MR-01 P3 Quality applyTargetReadyState is 75% covered; the uncovered 25% is the err != nil defensive branch after each of the three setDegraded(...) calls (status-update failure paths). This is a pre-existing pattern from before this lane (the function had the same shape for the forbidden/accessCheck branches pre-EC-P1-05) — the new ExtractionFailed branch follows the identical shape and inherits the same proportional gap, not a regression. internal/controller/kollecttarget_controller.go:212-224 (setDegraded happy path tested, error-return path is not) No
MR-02 P3 Tooling task changelog:write produced different output on two consecutive local runs in this session (once without ([#NN](url)) PR-link enrichment, once with) — git-cliff's commit.remote.pr_number GitHub-API enrichment appears to depend on transient network/auth state rather than being deterministic. Both runs independently passed task changelog:verify against themselves, and CI's Preflight (which always has a GITHUB_TOKEN) should consistently produce the enriched form, so this PR's committed CHANGELOG.md should match CI — but it's worth a maintainer-level note since it's the second time changelog drift has needed an out-of-band fix this session. Not blocking this lane. n/a (process observation, not a diff line) No
MR-03 P3 Scope KollectClusterTarget does not get the same ExtractionFailures/Degraded wiring — it doesn't currently check any of forbidden/accessErr/extraction signals at all (confirmed: no HasForbiddenScope/HasAccessCheckFailure/ExtractFailures calls in kollectclustertarget_controller.go). This is a pre-existing gap in the codebase, not introduced by this lane, and EC-P1-05's scope (per BACKLOG.md §3) is "target status" without specifying cluster-target — flagging as a natural follow-up, not a missing acceptance criterion. internal/controller/kollectclustertarget_controller.go No

Functional correctness (self-assessment, not a verdict)

Delivers BACKLOG.md §3 EC-P1-05 ("Extract-failure visibility in target status"). Before this
change, internal/collect/engine.go's dispatch loop logged extraction errors and continued with
no further trace — GUIDELINES.md §1's mandated Degraded transition for ErrTerminal (the
guideline's literal example is "invalid CEL/JSONPath") never fired, and there was no way to see
extraction failures from kubectl get kollecttarget -o yaml. Now: Engine.ExtractFailures(ns, name) returns a live count + last-message (counts/messages only, no per-resource payload —
GUIDELINES.md §2 etcd-size guard); the controller always writes these into
status.extractionFailures/status.lastExtractionError; and when count > 0 the target is
hard-degraded with reason ExtractionFailed, matching the existing AccessCheckFailed disposition
for the same error class (the EC-P2-01 partial-scope-degrade pattern was deliberately not
reused here, since that pattern is specific to ErrForbidden, a different documented class — see
PR description for the classification reasoning). TDD followed strictly: both new test files
(engine_extract_failure_test.go, kollecttarget_extraction_failed_test.go) were written first
and confirmed red via compile failure (referencing not-yet-existing types/fields/methods) before
any production code changed; the three pre-existing tests in
kollecttarget_scope_forbidden_test.go needed a call-site signature update (new trailing params)
to keep compiling — no assertions in those tests were altered.

Coverage delta

internal/ 80.7% (floor 72%) on this branch (rooted on origin/main @ 3d78cd0fa, which already
includes the session's changelog-drift fix). internal/collect 89.0%, internal/controller
75.6% — both already well above floor; new code (ExtractFailures, recordExtractFailure,
clearExtractFailure, reconcileTargetReady) is 100% covered, applyTargetReadyState 75% (see
MR-01).

Summary / next steps

Maintainer review needed on GitHub — no self-verdict claimed per auto-mode classifier policy. All
gates green, no P0/P1 findings. Three P3 observations above (none block merge).

@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 93.75000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/controller/kollecttarget_controller.go 85.71% 1 Missing and 1 partial ⚠️
internal/collect/engine.go 97.05% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…-failure-visibility

# Conflicts:
#	CHANGELOG.md
@konih

konih commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator Author

REVIEW — ec-p1-05-extract-failure-visibility @ 45bf7d3 — APPROVE — 2026-07-04

Verdict: APPROVE
Reviewer: independent session (bulk PR-sweep, maintainer-directed)
Branch: feat/ec-p1-05-extract-failure-visibility -> main

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

Gate Result
go build ./... PASS
task verify PASS — CRD/deepcopy 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.3% (floor 72%)
task scrub PASS — clean
task changelog:verify PASS — resynced via task changelog:write after rebase

Findings

None new. Independently traced applyTargetReadyState's branch order after the rebase brought
in the concurrently-landed dispatch-backpressure and family-sink-status-conflict fixes (both
auto-merged cleanly, no textual conflict in internal/collect/engine.go): precedence is
accessCheckFailed > extractFailCount>0 (this PR) > sink-unreachable > Ready, with
forbiddenScope handled independently via a Warning+Synced reason (doesn't block Ready). This
matches the PR's own description and GUIDELINES.md §1's ErrTerminal-vs-ErrForbidden distinction.
Confirmed ExtractionFailures/LastExtractionError status fields are set unconditionally before
the branch dispatch, so they stay visible even on the Ready path. Prior self-review's three P3
notes (MR-01 coverage gap on a pre-existing defensive branch, MR-02 changelog non-determinism
process note, MR-03 KollectClusterTarget not wired — explicitly out of scope) still stand,
none blocking.

CI note

test-integration first run hit the known transient Forgejo/gitlab testcontainer auth flake
(user does not exist [uid: 0, name: forgejo-admin], unrelated to this diff — this PR touches
no gitlab/git sink code); re-ran via gh run rerun --failed.

Summary

Diff vs current origin/main is exactly the 9 expected files. Clear to merge pending green CI rerun.

@konih
konih merged commit f5186ea into main Jul 6, 2026
25 checks passed
@konih
konih deleted the feat/ec-p1-05-extract-failure-visibility branch July 6, 2026 08:32
konih added a commit that referenced this pull request Jul 10, 2026
…P1-05) (#36)

* ✨ feat(controller): surface extraction failures in target status (EC-P1-05)

Attribute extraction errors (invalid/per-resource-failing CEL or
JSONPath, ADR-0020 ErrTerminal) were previously only logged and the
resource silently skipped — nothing reached KollectTarget.status, and
GUIDELINES.md §1's mandated Degraded transition for terminal errors
never fired.

Engine now tracks, per target, the set of resources currently failing
extraction (mirrors the existing forbidden/accessErr maps) behind a
new ExtractFailures(ns, name) accessor returning a count and the most
recent error message — counts/messages only, no per-resource payload
(GUIDELINES.md §2 etcd-size guard). KollectTargetReconciler always
writes these into status.extractionFailures/lastExtractionError, and
hard-degrades the target (new ExtractionFailed reason) when the count
is non-zero, matching the existing AccessCheckFailed disposition for
the same ErrTerminal class — deliberately not the EC-P2-01
partial-scope-degrade pattern, since that's specific to ErrForbidden.

TDD: engine_extract_failure_test.go and
kollecttarget_extraction_failed_test.go were written and confirmed
red (compile failures against not-yet-existing types/fields) before
any production code changed.

* 📄 docs(changelog): sync EC-P1-05 entry

* 📄 docs: sync CHANGELOG
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