Skip to content

refactor: split watches.go event-processing pipeline into sibling file - #24023

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
arch/split-watches-eventprocessing
Oct 5, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
arch/split-watches-eventprocessing

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Refactor

watches.go mixed six HTTP handlers (ListWatches, CreateWatch, ResolveWatch,
DismissWatch, SnoozeWatch, ListAuditLog) with a ~600-line, non-HTTP
k8s-event-processing pipeline (IncomingEvent, classifyEvent, narrateEventFast,
ProcessEvent, autoExecuteAction, queueAutoTendAction, autoCreateWatch and
helpers) invoked from the event ingestion path, not from any route in this
file.

Moves the event-processing pipeline to a new sibling file,
watches_eventprocessing.go, in the same package. Same package, same exported
symbols, no behavior change — pure file reorganization, matching the pattern
already used for pkg/k8s/workload_deploy.go (#23903/#23904) and
pkg/k8s/workload.go (#23942/#23943).

Verified: go build ./... clean (go test/vet blocked for agents in this
sandbox; CI will run the full suite). pkg/api/handlers/stellar is already
tracked in .github/go-package-coverage-ratchet.txt at the package level, so
no ratchet update is needed for a same-package file split.

Closes #24022


Filed by architect agent (ACMM L6 — full mode)

— hive: agent=architect backend=copilot model=claude-opus-4.7 copilot=1.0.88

… sibling file

watches.go mixed six HTTP handlers (ListWatches, CreateWatch, ResolveWatch,
DismissWatch, SnoozeWatch, ListAuditLog) with a ~600-line, non-HTTP
k8s-event-processing pipeline (IncomingEvent, classifyEvent,
narrateEventFast, ProcessEvent, autoExecuteAction, queueAutoTendAction,
autoCreateWatch and helpers) invoked from the event ingestion path, not
from any route in this file.

Move the event-processing pipeline to a new sibling file,
watches_eventprocessing.go, in the same package. Same package, same
exported symbols, no behavior change — pure file reorganization.

Closes #24022

Signed-off-by: architect <architect@hive.kubestellar.io>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 5, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikespreitzer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions github-actions Bot added the ai-generated Pull request generated by AI label Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

👋 Hey @hivecommons-hive[bot] — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 5, 2026
@netlify

netlify Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit 13e426e
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6ac41f0a528e0b00070e3db5

@hivecommons-hive
hivecommons-hive Bot merged commit 0269436 into main Oct 5, 2026
41 of 42 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the arch/split-watches-eventprocessing branch October 5, 2026 22:23
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verified this as a pure file move, not just by stat but line-by-line: the 634 lines removed from pkg/api/handlers/stellar/watches.go are byte-identical to the body of the new watches_eventprocessing.go; the only additions are the new file's package declaration and import block, and watches.go correctly drops the imports that moved with the code (strings, time, k8s, uuid/apimachinery etc.), keeping only context, fiber, and store which its remaining six HTTP handlers use.

go build ./pkg/api/handlers/stellar/ passes at head 13e426e. Same package, so the coverage-ratchet claim in the body checks out — no ratchet entry needed for a same-package split.

No behavior change, no findings. Looks correct to me (not an approval — that's a human's signature).

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Post-merge build verification passed ✅

Both Go and frontend builds compiled successfully against merge commit 02694369107bc53c2a3eb01572edf1606bca0966.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: 02694369107bc53c2a3eb01572edf1606bca0966
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/37382180828

hivecommons-hive Bot added a commit that referenced this pull request Oct 6, 2026
…#24038)

solver.go mixed four HTTP handlers (ListActivity, CompleteAutoMission,
StartSolve, ListSolves) with a ~310-line, non-HTTP autonomous-solve
pipeline (autoTriggerSolve and the helpers used exclusively by it:
safeAutoActions, AutoSolveCooldown, formatBatchTimestamp,
isLatestEventBatch), invoked from the event ingestion path, not from any
route in this file — the same pattern already fixed in watches.go
(#24022/PR #24023).

Move the event-processing pipeline to a new sibling file,
solver_autotrigger.go, in the same package. broadcastSolveProgress,
logActivity, renderUntrustedPromptData, and
deriveResourceNameFromNotification stay in solver.go since they're also
called from HTTP handlers (CompleteAutoMission/StartSolve). Same
package, same exported symbols, no behavior change — pure file
reorganization.

Closes #24037

Signed-off-by: architect <architect@hive.kubestellar.io>
Co-authored-by: architect <architect@hive.kubestellar.io>
hivecommons-hive Bot added a commit that referenced this pull request Oct 7, 2026
…#24057)

* refactor: split server_gitops.go git-clone pipeline into sibling file

server_gitops.go mixed two Fiber-style HTTP handlers (handleDetectDrift,
handleGitopsSync) with an 11-function, non-HTTP git-clone/SSRF-validation/
diff-parse pipeline (normalizeGitopsHost, validateGitopsResolvedIPs,
validateGitopsRepoURL, validateGitopsBranchName, validateGitopsPath,
gitopsCloneRepo, gitopsIsKustomizeDir, gitopsCleanupTempDir,
gitopsTruncateValue, gitopsParseDiffOutput, gitopsParseApplyOutput) invoked
exclusively from inside those two handlers — the same pattern already fixed
in pkg/api/handlers/stellar/{watches,solver,observations}.go
(#24022/#24023, #24037/#24038, #24041/#24042).

Move the pipeline (and the constants/var it alone uses:
gitopsDNSLookupTimeout, gitOpsTempDirPrefix, gitopsLookupIPAddr,
truncationMaxLen, truncationKeepLen) to a new sibling file,
server_gitops_clone.go, in the same package. server_gitops.go keeps the two
handlers, the request/response DTO types, and gitopsDefaultTimeout. Same
package, same exported symbols, no behavior change — pure file move.

Closes #24056

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: architect <architect@hive.kubestellar.io>

* fix: use CodeQL-recognized sanitizers in gitops clone pipeline

Address the 3 CodeQL alerts raised on the moved code:
- root user-supplied req.Path with filepath.Clean("/"+path) before
  joining under the managed temp dir (path-injection sanitizing idiom)
- pass repoURL/tempDir after a literal "--" in a fixed-arity
  exec.CommandContext call and re-check branch against a strict
  allowlist pattern local to the command sink (command-injection)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <scanner@hive.kubestellar.io>

---------

Signed-off-by: architect <architect@hive.kubestellar.io>
Signed-off-by: scanner <scanner@hive.kubestellar.io>
Co-authored-by: architect <architect@hive.kubestellar.io>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: scanner <scanner@hive.kubestellar.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[architect] pkg/api/handlers/stellar/watches.go mixes HTTP handlers with a 600-line event-processing pipeline

0 participants