Skip to content

refactor(cli): migrate uninstall flows to harness-first agent discovery - #43

Closed
guyoron1 wants to merge 9 commits into
mainfrom
mirror/2364-uninstall-harness
Closed

refactor(cli): migrate uninstall flows to harness-first agent discovery#43
guyoron1 wants to merge 9 commits into
mainfrom
mirror/2364-uninstall-harness

Conversation

@guyoron1

Copy link
Copy Markdown
Owner

Mirror of upstream fullsend-ai#2364 for QF pipeline demo.

Migrates uninstall flows from legacy slug-file lookup to harness-first agent discovery, with 6 files changed including new discover_slugs module and updated tests.

@guyoron1

Copy link
Copy Markdown
Owner Author

/fs-qf

@fullsend-ai-review

fullsend-ai-review Bot commented Jun 19, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 10:45 AM UTC · Completed 10:56 AM UTC
Commit: bb5c185 · View workflow run →

@fullsend-ai-review

fullsend-ai-review Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review

Findings

Critical

  • [api-contract] internal/cli/discover_slugs.go:26discoverAgentSlugs calls harness.DiscoverRemoteAgents(ctx, client, owner, configRepo, ref) but this function does not exist in the harness package. The only discovery function available is harness.DiscoverAgents(dir string), which operates on a local filesystem directory — not a remote forge client. This PR will not compile.
    Remediation: Add harness.DiscoverRemoteAgents with the signature func DiscoverRemoteAgents(ctx context.Context, client forge.Client, owner, repo, ref string) ([]AgentInfo, error) to the harness package, or change the call site to use an existing API. If this function is expected from a dependent PR, that dependency must be merged first.

Medium

  • [test-inadequate] internal/cli/discover_slugs.go:28 — No test covers the case where DiscoverRemoteAgents returns a non-nil error with zero valid agents. This is a distinct code path (err != nil but len(agents) == 0) that differs from the "no harness directory" case because the warning is still emitted before falling through to the config.yaml tier.
    Remediation: Add a test where DiscoverRemoteAgents returns an error and no valid agents, verifying fallthrough to config.yaml agents block with warning emitted.

Low

  • [error-handling] internal/cli/discover_slugs.go:27 — The warning message "some harness files could not be read" is emitted for all error types from DiscoverRemoteAgents, including wholesale failures (network error, repo not found). This mirrors the local DiscoverAgents partial-error pattern, but the message text is misleading for total failures.
  • [test-inadequate] internal/cli/admin.go — Integration tests (TestRunUninstall_UsesHarnessDiscovery) do not verify that duplicate slugs from harness files are deduplicated in the full runUninstall flow.
  • [test-regression-risk] internal/cli/github.go:822 — No integration test verifies role-to-slug derivation through runGitHubUninstall. The old code had explicit slug/role branching; this behavior is now delegated to discoverAgentSlugs.
  • [function-extraction-pattern] internal/cli/discover_slugs.go — New file extracts logic into a shared helper called from only 2 locations. Reasonable Go practice for 69 lines of non-trivial logic, but consider documenting why extraction was preferred.
  • [edge-case] internal/cli/admin.go:1621 — Behavioral change: old code appended empty slugs from config agents with empty Slug fields, causing the default fallback to be skipped. New code correctly skips empty slugs. This is an improvement but should be noted in the PR description.
  • [test-inadequate] internal/cli/discover_slugs.go:33 — No test covers the case where a harness file produces an agent with both role and slug empty (the if slug == "" { continue } path).
  • [test-inadequate] internal/cli/admin.go:1610 — Both runUninstall and runGitHubUninstall pass a hardcoded ref "main" to discoverAgentSlugs. No test verifies behavior when the config repo's default branch is not main.
  • [undocumented-behavior] docs/guides/dev/cli-internals.md — The CLI internals guide does not document the new three-tier agent slug discovery mechanism (harness files → config.yaml agents block → default naming).

Info

  • [error-message-format] internal/cli/discover_slugs.go:29 — Warning text uses lowercase ("some harness files could not be read") while some existing StepWarn calls use sentence case. Codebase is inconsistent here, so this is a nit.
  • [comment-style] internal/cli/discover_slugs.go:8 — Function doc comment style differs slightly from similar fallback-logic functions in admin.go.
Previous run

Review

Reason: stale-head

The review agent reviewed commit ea010259a2db8724bb31cebce9073cf2bd0694b2 but the PR HEAD is now 91b6be6de58d9969411a47f441a6514394270f73. This review was discarded to avoid approving unreviewed code.

Previous run (2)

Review

Reason: stale-head

The review agent reviewed commit 558f4c2018e20b72d3597e1f6fa18ac09d91657f but the PR HEAD is now ea010259a2db8724bb31cebce9073cf2bd0694b2. This review was discarded to avoid approving unreviewed code.

Previous run (3)

Review

Reason: stale-head

The review agent reviewed commit 24cd445174081eff2f5c20d7e2745bbd5437f540 but the PR HEAD is now e201d83335bcb7a8131a618cf8d8dcf90d998bd0. This review was discarded to avoid approving unreviewed code.

@fullsend-ai-review

Copy link
Copy Markdown

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Jun 19, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 10:59 AM UTC · Completed 11:12 AM UTC
Commit: bb5c185 · View workflow run →

QualityFlow and others added 2 commits June 19, 2026 10:59
Fix 8 major and 3 minor findings from automated STP review:
- Replace internal function names with user-facing language in Section III
- Fix Go version to 1.26+ (matching go.mod)
- Replace [Functional] tier labels with [Tier 1] classification
- Rebalance priority distribution (P0: 44%, P1: 33%, P2: 22%)
- Add GH-43 requirement IDs to all Section III groups
- Reformat Section IV to Reviewers/Approvers template format
- Clarify Dependencies (upstream only, not internal packages)
- Remove empty risk entries and sandbox LSP limitation
- Improve Developer Handoff, Enhancement links, and cross-references

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fullsend-ai-review

Copy link
Copy Markdown

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Jun 19, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 11:15 AM UTC · Completed 11:30 AM UTC
Commit: bb5c185 · View workflow run →

@fullsend-ai-review

Copy link
Copy Markdown

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Jun 19, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 11:33 AM UTC · Completed 11:46 AM UTC
Commit: bb5c185 · View workflow run →

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See the review comment for full details.

func discoverAgentSlugs(ctx context.Context, client forge.Client, owner, configRepo, ref, appSet string, cfg *config.OrgConfig, printer *ui.Printer) []string {
agents, err := harness.DiscoverRemoteAgents(ctx, client, owner, configRepo, ref)
if err != nil {
printer.StepWarn(fmt.Sprintf("some harness files could not be read: %v", err))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[critical] api-contract

discoverAgentSlugs calls harness.DiscoverRemoteAgents(ctx, client, owner, configRepo, ref) but this function does not exist in the harness package. The only discovery function is harness.DiscoverAgents(dir string), which operates on a local filesystem directory. This PR will not compile.

Suggested fix: Add harness.DiscoverRemoteAgents with the appropriate signature to the harness package, or change the call site to use an existing API.

if err != nil {
printer.StepWarn(fmt.Sprintf("some harness files could not be read: %v", err))
}
if len(agents) > 0 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[medium] test-inadequate

No test covers the case where DiscoverRemoteAgents returns a non-nil error with zero valid agents. This is a distinct code path (err != nil but len(agents) == 0) that differs from the no-harness-directory case because the warning is still emitted.

Suggested fix: Add a test where DiscoverRemoteAgents returns an error and no valid agents, verifying fallthrough to config.yaml with warning.

agents, err := harness.DiscoverRemoteAgents(ctx, client, owner, configRepo, ref)
if err != nil {
printer.StepWarn(fmt.Sprintf("some harness files could not be read: %v", err))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] error-handling

Warning message 'some harness files could not be read' is misleading for wholesale failures (network error, repo not found) vs per-file parse errors.

Comment thread internal/cli/github.go
printer.Blank()

// Read config before deleting repo to discover actual installed app slugs.
// Discover agent slugs: harness files first, then config.yaml agents:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] test-regression-risk

No integration test for role-to-slug derivation in runGitHubUninstall after delegation to discoverAgentSlugs.

Comment thread internal/cli/admin.go
} else {
printer.StepWarn(fmt.Sprintf("Could not parse existing config: %v; using defaults", parseErr))
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] edge-case

Behavioral change: old code appended empty slugs from config agents, new code correctly skips them. This improvement should be noted in the PR description.

var slugs []string
for _, a := range agents {
slug := a.Slug
if slug == "" && a.Role != "" {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] test-inadequate

No test covers the case where a harness file produces an agent with both role and slug empty.

Comment thread internal/cli/admin.go
// (PEM keys are one-shot).
var agentSlugs []string
var configMode string
var enrolledRepos []string

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] test-inadequate

Both runUninstall and runGitHubUninstall pass hardcoded ref 'main' to discoverAgentSlugs. No test verifies behavior with non-main default branches.

QualityFlow and others added 2 commits June 19, 2026 11:46
Generate Ginkgo v2 test implementations from STD YAML for GH-43
(Migrate Uninstall Flows to Harness-First Agent Discovery).

9 test scenarios covering:
- discoverAgentSlugs three-tier fallback (6 scenarios)
- Org-level and GitHub-specific uninstall integration (3 scenarios)
Replaces intermediate pipeline artifacts with organized test files.

Total: 3 test files → qf-tests/GH-43/
Jira: GH-43
[skip ci]
@github-actions

Copy link
Copy Markdown

QualityFlow Pipeline Summary

Stage Agent Status
1 STP Builder
2 STP Reviewer
3 STP Refiner
4 STD Builder
5 STD Reviewer
6 STD Refiner
7 Test Generator

Test Output

Language Count Location
Go 3 files qf-tests/GH-43/go/

Issue: GH-43


Generated by QualityFlow

@guyoron1 guyoron1 closed this Jun 21, 2026
@github-actions
github-actions Bot deleted the mirror/2364-uninstall-harness branch August 2, 2026 05:49
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.

1 participant