Skip to content

[quality] pkg/agent: extended registry + provider_prompts tests (17 cases)#19921

Merged
clubanderson merged 4 commits into
mainfrom
quality/agent-registry-coverage
Jun 29, 2026
Merged

[quality] pkg/agent: extended registry + provider_prompts tests (17 cases)#19921
clubanderson merged 4 commits into
mainfrom
quality/agent-registry-coverage

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Test Improvement

Adds 15+ test cases covering previously untested logic paths in pkg/agent:

registry_extended_test.go (11 test functions)

Test What's verified
TestRegistry_NilReceiver All public methods return errors / don't panic on nil *Registry
TestRegistry_RemoveSelectedAgent Session cleanup removes from both internal maps, falls back to default
TestRegistry_PromoteExecutingDefault copilot-cli (suggest-only) → tool-capable agent promotion
TestRegistry_PromoteExecutingDefault_NoChange Non-suggest-only default is not changed
TestRegistry_PromoteExecutingDefault_NoBetterOption copilot-cli retained when no tool-capable agents exist
TestRegistry_SetSelectedAgent_LRUEviction Batch eviction fires at 10000 cap, removes ~5% oldest
TestRegistry_ConcurrentAccess 100 goroutines exercising all read/write paths (race detector)
TestRegistry_GetDefault_NotFound Error when defaultAgent name not in providers map
TestRegistry_SetDefault_NilProvider Error when provider entry is nil
TestRegistry_HasAvailableProviders_WithNilEntry nil entries don't count as available

provider_prompts_test.go (6 test functions)

Test What's verified
TestOSCommandHint_NotEmpty Returns non-empty string
TestOSCommandHint_ContainsShellReference Platform-appropriate shell hint (bash/PowerShell)
TestOSContext_MatchesRuntime Contains runtime.GOOS
TestDefaultSystemPrompt_NotEmpty System prompt is populated
TestChatOnlySystemPrompt_NotEmpty Chat-only prompt is populated
TestChatOnlySystemPrompt_DiffersFromDefault Two prompts are distinct

Partially addresses #19907


Filed by quality agent (ACMM L4/L6 — full mode)

Adds 15+ test cases covering previously untested paths in pkg/agent:

Registry (registry_extended_test.go):
- Nil receiver safety for all public methods
- RemoveSelectedAgent cleanup verification
- promoteExecutingDefault (3 scenarios: promotion, no-change, no-better-option)
- LRU eviction when selectedAgent map exceeds 10000 cap
- Concurrent access safety (race detector coverage)
- GetDefault with missing provider in map
- SetDefault with nil provider entry
- HasAvailableProviders with nil map entry

Provider prompts (provider_prompts_test.go):
- OSCommandHint returns non-empty, contains shell reference
- OSContext matches runtime.GOOS
- DefaultSystemPrompt and ChatOnlySystemPrompt non-empty and differ

Partially addresses #19907.

Signed-off-by: quality-agent <quality@kubestellar.io>
Copilot AI review requested due to automatic review settings June 29, 2026 16:29
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 29, 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 eeshaansa 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

@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit dd9462c
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a42b0c0a2789f00080eb9c4
😎 Deploy Preview https://deploy-preview-19921.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves pkg/agent quality by adding targeted Go tests that exercise previously untested/edge logic in the agent registry and provider prompt wrappers, contributing toward the coverage goals in #19907.

Changes:

  • Add extended registry tests covering nil receiver behavior, session cleanup, default-agent promotion, LRU eviction behavior, and concurrent access.
  • Add tests for pkg/agent prompt wrapper exports (OSCommandHint, OSContext, DefaultSystemPrompt, ChatOnlySystemPrompt).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/agent/registry_extended_test.go Adds broad registry behavior tests (nil-safety, default promotion, eviction, concurrency).
pkg/agent/provider_prompts_test.go Adds tests validating prompt wrapper functions and exported prompt vars are populated and distinct.

Comment on lines +169 to +174
for i := 0; i < 10000; i++ {
sid := fmt.Sprintf("old-session-%d", i)
r.selectedAgent[sid] = "a"
// All old sessions have old timestamps
r.selectedAgentLRU[sid] = time.Now().Add(-time.Hour)
}
@clubanderson

Copy link
Copy Markdown
Collaborator Author

Quality review of test code:

Good test patterns:

  • Nil receiver safety tests catch panic risks
  • LRU eviction test validates the 10K cap with 5% eviction
  • Concurrent access test with race detector coverage
  • Edge cases: nil provider in map, phantom default name

⚠️ CI failure is from the fasthttp Host header issue (same as #19909), not from these tests themselves. Once #19925 lands, this PR should pass CI — rebase and re-run.

⚠️ Minor concern: provider_prompts_test.go tests are smoke-level (non-empty, differs). Consider adding tests for prompt content structure (e.g., system prompts contain key directives) in a follow-up.

This PR partially addresses #19907 by adding tests for registry.go edge cases and provider_prompts.go. The remaining untested files from that issue (provider.go, server_routes.go, shell.go, compat shims) still need coverage.

@clubanderson clubanderson merged commit d8838dc into main Jun 29, 2026
25 of 31 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the quality/agent-registry-coverage branch June 29, 2026 18:20
@github-actions

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

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit d8838dc2726ab1706b002785c611947d071f5bf5.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: d8838dc2726ab1706b002785c611947d071f5bf5
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/28393542411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tier/1-lightweight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants