Repository navigation
refactor: split solver.go autoTriggerSolve pipeline into sibling file - #24038
Conversation
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>
✅ Deploy Preview for kubestellarconsole canceled.
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
👋 Hey @hivecommons-hive[bot] — thanks for opening this PR!
This is an automated message. |
|
Supersession sweep found that this PR's claimed issue is already closed by another merged PR.
this PR also claims another issue that is still open. A human should decide whether to close this PR. This comment is edited in place by the supersession sweep; it is not duplicated. |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
✅ Escalation cleared — back in the automated laneCI is green on the current head — returning this PR to the automated lane. The |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
There was a problem hiding this comment.
Verified this as a pure mechanical move — no behavior change.
- Diffed the removed block in
pkg/api/handlers/stellar/solver.goagainst the newpkg/api/handlers/stellar/solver_autotrigger.goline-by-line: every moved line (safeAutoActions,AutoSolveCooldown,formatBatchTimestamp,isLatestEventBatch,autoTriggerSolve) is byte-identical; the only new lines are the new file's package/import boilerplate. - Checked the remaining
solver.goat head533abc6: the dropped imports (encoding/json,pkg/k8s,pkg/stellar,pkg/stellar/scheduler) have no remaining uses there (solver.go:1-16), and the new file carries exactly those imports. - Same package, so
deploymentNameFromPodName,truncateString,renderUntrustedPromptData,broadcastSolveProgress, andh.fullStore()all still resolve; coverage ratchet is unaffected (no new package).
Looks correct to me. (Comment only — approval/merge is a maintainer's call.)
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
✅ Post-Merge Verification: passedCommit: |
…#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>
Refactor
solver.go(786 lines) mixed four HTTP handlers (ListActivity,CompleteAutoMission,StartSolve,ListSolves) with a ~310-line,non-HTTP autonomous-solve pipeline (
autoTriggerSolveand the helpersused exclusively by it:
safeAutoActions,AutoSolveCooldown,formatBatchTimestamp,isLatestEventBatch), invoked from the eventingestion path, not from any route in this file — the same pattern
already identified and fixed in
watches.go(#24022 / PR #24023).This moves the event-processing pipeline to a new sibling file,
solver_autotrigger.go, in the same package.broadcastSolveProgress,logActivity,renderUntrustedPromptData, andderiveResourceNameFromNotificationstay insolver.gosince they'realso called from HTTP handlers (
CompleteAutoMission/StartSolve).Same package, same exported symbols, no behavior change — pure file
reorganization.
Verified:
go build ./pkg/api/handlers/stellar/...andgo build ./...passgo vet ./pkg/api/handlers/stellar/...cleango test ./pkg/api/handlers/stellar/...— all tests pass (23.3s)gofmt -lclean on both changed filesCloses #24037
— hive: agent=architect backend=copilot model=claude-opus-4.7 copilot=1.0.88