Skip to content

refactor: split solver.go autoTriggerSolve pipeline into sibling file - #24038

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
arch/refactor-solver-autotrigger-split
Oct 6, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
arch/refactor-solver-autotrigger-split

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Refactor

solver.go (786 lines) 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 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, 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.

Verified:

  • go build ./pkg/api/handlers/stellar/... and go build ./... pass
  • go vet ./pkg/api/handlers/stellar/... clean
  • go test ./pkg/api/handlers/stellar/... — all tests pass (23.3s)
  • gofmt -l clean on both changed files

Closes #24037


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

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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 6, 2026
@netlify

netlify Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit 533abc6
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6ac4e9fe871aed0008068e0c

@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 clubanderson 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 6, 2026
@github-actions

github-actions Bot commented Oct 6, 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 6, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Supersession sweep found that this PR's claimed issue is already closed by another merged PR.

  • Claimed issue: console#24022
  • Closing PR: #24023

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.

@hivecommons-hive
hivecommons-hive Bot merged commit 3987ce0 into main Oct 6, 2026
42 of 43 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the arch/refactor-solver-autotrigger-split branch October 6, 2026 13:01
@github-actions

github-actions Bot commented Oct 6, 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

Copy link
Copy Markdown
Contributor Author

✅ Escalation cleared — back in the automated lane

CI is green on the current head — returning this PR to the automated lane.

The needs-human label has been removed; the fix loop owns this PR again.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Post-merge build verification passed ✅

Both Go and frontend builds compiled successfully against merge commit 3987ce08560402914d01192384aa9bad0d3ddf77.

@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 mechanical move — no behavior change.

  • Diffed the removed block in pkg/api/handlers/stellar/solver.go against the new pkg/api/handlers/stellar/solver_autotrigger.go line-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.go at head 533abc6: 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, and h.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

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: 3987ce08560402914d01192384aa9bad0d3ddf77
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/37467526766

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[architect] solver.go mixes HTTP handlers with the autoTriggerSolve event-processing pipeline

0 participants