Skip to content

agentdrain: make NewAnomalyDetector consistent with package constructors by returning validated errors#30786

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-anomaly-detector-error-return
May 7, 2026
Merged

agentdrain: make NewAnomalyDetector consistent with package constructors by returning validated errors#30786
pelikhan merged 3 commits into
mainfrom
copilot/fix-anomaly-detector-error-return

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

pkg/agentdrain had one constructor (NewAnomalyDetector) that did not return an error and accepted invalid thresholds silently, unlike the rest of the package constructors. This change aligns the API and prevents invalid detector configuration from propagating into anomaly scoring.

  • Constructor contract + validation

    • Updated NewAnomalyDetector(simThreshold, rareClusterThreshold) to return (*AnomalyDetector, error).
    • Added validation:
      • simThreshold must be in [0,1]
      • rareClusterThreshold must be non-negative
    • Returns contextual constructor errors instead of creating misconfigured detectors.
  • Caller error propagation

    • Updated Miner.AnalyzeEvent to handle constructor errors and propagate with existing package error-wrapping style.
  • Tests + public API docs alignment

    • Updated anomaly/spec tests for new constructor signature.
    • Replaced prior “preserve invalid values” behavior with explicit invalid-input test coverage.
    • Updated pkg/agentdrain/README.md example usage to handle constructor error.
detector, err := NewAnomalyDetector(m.cfg.SimThreshold, m.cfg.RareClusterThreshold)
if err != nil {
    return nil, nil, fmt.Errorf("agentdrain: AnalyzeEvent: %w", err)
}
report := detector.Analyze(result, isNew, cluster)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name .cfg (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw **/*.json --ignore-path ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet sRem�� i.go ntifiers.go ts.test tierignore (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name on' --ignore-path ../../../.prettierignore (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name h ../../../.prettierignore git /usr/bin/git --show-toplevel /usr/bin/git /usr/bin/infocmp--write git rev-�� w/js/**/*.json' --ignore-path tector construct../../../.prettierignore /usr/bin/git xterm-color gh /usr/bin/gh git (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq [.object.sha, .object.type] | @tsv --show-toplevel /opt/hostedtoolcache/go/1.25.8/x^remote\..*\.gh-resolved$ /usr/bin/git 18 -trimpath ache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/link /usr/bin/git 3018086/b467/typgh config (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq [.object.sha, .object.type] | @tsv --show-toplevel sh /usr/bin/git sistency_Inlinedgit git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv /ref/tags/v9 64/pkg/tool/linux_amd64/vet sv rite '**/*.cjs' gh .cfg 64/pkg/tool/linu/repos/actions/github-script/git/ref/tags/v9 git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git itbranch_with_hygit itbranch_with_hyrev-parse 64/pkg/tool/linu--show-toplevel /usr/bin/git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv --show-toplevel x_amd64/link er: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabl--show-toplevel --show-toplevel node ode git rev-�� /ref/tags/v9 gh sv /repos/actions/ggit --jq n-dir/node git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv 3558-13868/test-4202474495 -buildtags bject.type] | @tsv -errorsas -ifaceassert -nilfunc 3018086/b399/importcfg -ato�� 3018086/b399/embedcfg resolved$ 1/x64/bin/node -errorsas -ifaceassert -nilfunc 1/x64/bin/node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv ithub-script/git/ref/tags/v9 git bject.type] | @tsv /tmp/gh-aw-test-git remote /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git /tmp/TestGuardPogit config /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/gh --show-toplevel ache/go/1.25.8/xrev-parse /usr/bin/git gh api /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/infocmp --show-toplevel ache/go/1.25.8/xrev-parse /usr/bin/infocmp--show-toplevel infocmp (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv runs/20260507-063558-13868/test-4202474495 show (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv xterm-color (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv /home/REDACTED/work/gh-aw/gh-aw/.github/workflows rev-parse /opt/hostedtoolcache/node/24.14.1/x64/bin/node '**/*.ts' '**/*.git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/shared-actigh rev-parse /usr/bin/git git rev-�� ithub-script/git/ref/tags/v9 git bject.type] | @tsv /tmp/gh-aw-test-git resolved$ (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git 1296744593 git _id":200}] git rev-�� ithub-script/git/ref/tags/v9 git bject.type] | @tsv ithub-script/gitgit status bject.type] | @t--show-toplevel git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv -c=4 -nolocalimports -importcfg /tmp/go-build1493018086/b398/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/actionpins/spec_test.go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv .github/workflows -nolocalimports -importcfg /tmp/go-build1493018086/b417/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/constants/spec_test.go (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9.0.0
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv -c=4 -nolocalimports -importcfg /tmp/go-build1493018086/b399/importcfg -embedcfg /tmp/go-build1493018086/b399/embedcfg -pack ode_�� (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv go1.25.8 -c=4 -nolocalimports -importcfg /tmp/go-build1493018086/b405/importcfg -pack /tmp/go-build1493018086/b405/_testmain.go (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/git 3558-13868/test-gh (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel ache/go/1.25.8/x--json /usr/bin/infocmp 818935074/.githugh -trimpath ache/node/24.14./repos/actions/github-script/git/ref/tags/v9 infocmp -1 xterm-color sh /usr/bin/git FieldEnforcementgit -dwarf=false 530156/b125/vet.--show-toplevel git (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel 64/pkg/tool/linuremote /usr/bin/infocmp .test -importcfg ortcfg.link infocmp -1 xterm-color 0ui0x2Iv4Z-LYbBHBh/hKJC44cVKMHVntest@example.com /usr/bin/git /v2.0.0 /tmp/go-build149rev-parse 1/x64/bin/node git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/TestGuardPogit remote /opt/hostedtoolc--show-toplevel git rev-�� /ref/tags/v9 node sv /tmp/TestHashConinfocmp x_amd64/compile om/myorg/repo.gixterm-color gh (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv xterm-color (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv /tmp/TestHashConsistency_GoAndJavaScript2131638699/001/test-comp-nxv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv ets.TOKEN }} rev-parse /usr/bin/git '**/*.ts' '**/*.git (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel x_amd64/vet /opt/hostedtoolcache/node/24.14.1/x64/bin/node lGitmain_branch4git lGitmain_branch4rev-parse x_amd64/vet /opt/hostedtoolcache/node/24.14.1/x64/bin/node /tmp�� 'full-sweep (enforce_all)' x_amd64/vet /usr/bin/git *.json' '!../../git --local x_amd64/compile git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv /usr/bin/gh git ps ormat:cjs --silegit /flatted/flattedrev-parse ules/.bin/sh ps init�� git git /usr/bin/git .js' --ignore-pagit infocmp tnet/tools/bash git (http block)
  • https://api.github.com/repos/aws-actions/configure-aws-credentials/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/aws-actions/configure-aws-credentials/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel ache/node/24.14.1/x64/bin/node /usr/bin/git github.repositorgit remote /tmp/go-build149--show-toplevel git rev-�� --show-toplevel /tmp/go-build1493018086/b467/types.test /usr/bin/git -test.paniconexigh -test.v=true om/org1/repo.gitstatus git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/aws-actions/configure-aws-credentials/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel node /usr/bin/git /tmp/TestHashCongh pins synced sucapi /usr/bin/git git rev-�� /ref/tags/v9 git sv --show-toplevel x_amd64/vet me: String!) { --show-toplevel infocmp (http block)
    • Triggering command: /usr/bin/gh gh api /repos/aws-actions/configure-aws-credentials/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel l /usr/bin/git git (http block)
  • https://api.github.com/repos/azure/login/git/ref/tags/v2
    • Triggering command: /usr/bin/gh gh api /repos/azure/login/git/ref/tags/v2 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/azure/login/git/ref/tags/v2 --jq [.object.sha, .object.type] | @tsv --show-toplevel gh /usr/bin/git /repos/actions/ggit --jq /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --get l /usr/bin/infocmpxterm-color git (http block)
  • https://api.github.com/repos/docker/login-action/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/docker/login-action/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/TestGuardPogit config /usr/bin/git git rev-�� --show-toplevel git /usr/bin/infocmp /tmp/gh-aw-test-infocmp config /usr/bin/git infocmp (http block)
    • Triggering command: /usr/bin/gh gh api /repos/docker/login-action/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git ons-test15379493git config ow-without-react--show-toplevel git rev-�� --show-toplevel git /usr/bin/infocmp --show-toplevel git om/owner/repo.gixterm-color infocmp (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq [.object.sha, .object.type] | @tsv /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/gh /ref/tags/v9 /tmp/go-build149rev-parse sv gh api /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/git -unreachable=falinfocmp /tmp/go-build149-1 (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq [.object.sha, .object.type] | @tsv --show-toplevel bash /usr/bin/infocmp ithub/workflows/gh git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git 606096657 infocmp nch,headSha,disp--show-toplevel git rev-�� --show-toplevel git /usr/bin/git ty-test.md infocmp sh git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv /ref/tags/v9 x_amd64/vet sv .js' --ignore-pagit (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq /usr/bin/git 606096657/.githugit git ules/.bin/pretti--show-toplevel git rev-�� /ref/tags/v9 git sv ty-test.md gh odules/npm/node_--show-toplevel git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-04-30 (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-04-07 (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-02-06 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name stmain.go 64/pkg/tool/linux_amd64/link (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 3018086/b021/vet.cfg ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet ./../.prettieriggit (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name git ache/node/24.14.1/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin/node--show-toplevel --show-toplevel git /usr/bin/gh node k/gh�� --write **/*.cjs in/sh **/*.json --ignore-path erignore sh (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name on ache/go/1.25.8/x64/pkg/tool/linu-nilfunc /../../.prettiergit erignore (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 on 64/pkg/tool/linux_amd64/compile /../../.prettier/opt/hostedtoolcache/node/24.14.1/x64/bin/node erignore (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name git cal/bin/sh nore git /usr/bin/git sh -c te '**/*.cjs' '**/*.ts' '**/*.json' --ignore-pat--repo git cfg ithub-script/gitgit git bject.type] | @t--show-toplevel node (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1234567890
    • Triggering command: /usr/bin/gh gh api repos/{owner}/{repo}/actions/runs/1234567890 --jq {databaseId: .id, number: .run_number, url: .html_url, status: .status, conclusion: .conclusion, workflowName: .name, workflowPath: .path, createdAt: .created_at, startedAt: .run_started_at, updatedAt: .updated_at, event: .event, headBranch: .head_branch, (http block)
    • Triggering command: /usr/bin/gh gh api repos/{owner}/{repo}/actions/runs/1234567890 --jq {databaseId: .id, number: .run_number, url: .html_url, status: .status, conclusion: .conclusion, workflowName: .name, workflowPath: .path, createdAt: .created_at, startedAt: .run_started_at, updatedAt: .updated_at, event: .event, headBranch: .head_branch, h ../../../.prettierignore git ode_modules/.bin/sh --show-toplevel infocmp (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name on x_amd64/vet /../../.prettiergit erignore (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 til_test.go ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /../../.prettier/usr/bin/git erignore (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name git bin/sh nore git sv sh -c te '**/*.cjs' '**/*.ts' '**/*.json' --ignore-path ../../../.pret.prettierignore git cfg --show-toplevel git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 3018086/b029/vet.cfg ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet ./../.prettieriggit tdrain_test (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name -s -w -X main.version=ff3b4b3-dirty ck gh-aw ./cmd/gh-aw /usr/bin/gh node sRem�� ll-sweep (enforce_all)' || 'round-robin' **/*.cjs k/node_modules/.bin/sh **/*.json --ignore-path erignore sh (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name 3018086/b009/vet.cfg x_amd64/link (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 3018086/b030/vet.cfg ortcfg.link ./../.prettieriggit (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name gh sv /repos/actions/ggit --jq (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 3018086/b025/vet.cfg ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet ./../.prettieriggit (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name log in/node --format=%H:%ct git bject.type] | @tuser.email node k/gh�� (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name .cfg x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 3018086/b028/vet.cfg ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet ./../.prettieriggit (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name log k/gh-aw/gh-aw/actions/setup/js/node_modules/.bin/node -n1 --format=format:rev-parse ode-gyp-bin/sh node ranc�� --write **/*.cjs ache/node/24.14.1/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin/sh **/*.json --ignore-path erignore sh (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 (http block)
  • https://api.github.com/repos/github/gh-aw/contents/.github/workflows/shared/reporting.md
    • Triggering command: /tmp/go-build1493018086/b405/cli.test /tmp/go-build1493018086/b405/cli.test -test.testlogfile=/tmp/go-build1493018086/b405/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true (http block)
    • Triggering command: /tmp/go-build792530156/b405/cli.test /tmp/go-build792530156/b405/cli.test -test.testlogfile=/tmp/go-build792530156/b405/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true --show-toplevel ache/go/1.25.8/x-c /usr/bin/git git rev-�� --show-toplevel git ndor/bin/git ithub-script/gitsh git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq [.object.sha, .object.type] | @tsv --show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile /usr/bin/git /tmp/go-build149du l _id":222}] git rev-�� --show-toplevel ache/node/24.14.1/x64/bin/node /usr/bin/infocmp 3558-13868/test-git --jq ache/go/1.25.8/x--show-toplevel infocmp (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq [.object.sha, .object.type] | @tsv --show-toplevel gh /usr/bin/git s/test.md --jq /usr/bin/infocmp/tmp/gh-aw/aw-feature-branch.patch git rev-�� --show-toplevel infocmp /usr/bin/infocmp xterm-color git /usr/bin/docker infocmp (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv se 3018086/b223/vet.cfg 1/x64/bin/node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv report.md race h nore infocmp /usr/bin/git bash --no�� 89/001/test-frontmatter-with-nested-objects.md git /usr/lib/git-core/git ithub-script/gitgit git bject.type] | @tsv /usr/lib/git-core/git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv */*.ts' '**/*.json' --ignore-path ../../../.pret.prettierignore (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv json' --ignore-path ../../../.pr**/*.json git tnet/tools/git --show-toplevel git /usr/bin/git infocmp -1 lGitbranch_with_hyphen733966672/001' lGitbranch_with_hyphen733966672/001' 1/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin/node --show-toplevel gh /usr/bin/git infocmp (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv */*.ts' '**/*.js--detach (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv go1.25.8 -c=4 -nolocalimports -importcfg /tmp/go-build1493018086/b467/importcfg -pack /tmp/go-build1493018086/b467/_testmain.go 1/x6�� --get-regexp nternal/testdeps/deps.go x_amd64/compile son (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq [.object.sha, .object.type] | @tsv */*.ts' '**/*.json' --ignore-path ../../../.prettierignore (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq [.object.sha, .object.type] | @tsv json' --ignore-p--exclude-hidden=receive infocmp bin/sh /ref/tags/v9 infocmp sv git rev-�� Gitbranch_with_hyphen733966672/001' Gitbranch_with_hyphen733966672/001' es/.bin/node xterm-color git /opt/hostedtoolc--get git (http block)
  • https://api.github.com/repos/google-github-actions/auth/git/ref/tags/v2
    • Triggering command: /usr/bin/gh gh api /repos/google-github-actions/auth/git/ref/tags/v2 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/TestGuardPogit l /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git mpleWorkflow1585git x_amd64/vet /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/google-github-actions/auth/git/ref/tags/v2 --jq [.object.sha, .object.type] | @tsv --show-toplevel gh /usr/bin/git /repos/actions/ggit --jq /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git /tmp/gh-aw-test-git remote om/org2/repo.git--show-toplevel git (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq [.object.sha, .object.type] | @tsv se 3018086/b224/vet.cfg Name,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq [.object.sha, .object.type] | @tsv /repos/actions/github-script/git/ref/tags/v9 --jq cal/bin/sh nore gh /usr/bin/git bash --no�� */*.ts' '**/*.json' --ignore-pat--repo git 1/x64/bin/npx /ref/tags/v9 git sv git (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion **/*.json --ignore-path erignore sh -c 4052-27222/test-1766146262/.github/workflows git /usr/local/sbin/bash rror git /usr/bin/git bash (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo _modules/.bin/sh-nilfunc (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo sh (http block)
    • Triggering command: /usr/bin/gh gh workflow list --repo owner/repo --json name,path,state .cfg (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name on' --ignore-path ../../../.prettierignore (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name -template-expressions.md --jq /usr/bin/git --show-toplevel /usr/bin/git (http block)
  • https://api.github.com/repos/test/repo
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch 967654310/custom/workflows sRemoteWithRealGitmain_branch46487885/002/work ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet **/*.json --ignore-path ../../../.pretti--show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch sistency_GoAndJavaScript1419893189/001/test-inlined-imports-enabled-with-body-content.md **/*.cjs /home/REDACTED/work/gh-aw/gh-aw/actions/setup/node_modules/.bin/sh **/*.json --ignore-path ../../../.pretti/repos/actions/github-script/git/ref/tags/v9 sh -c runs/20260507-064052-27222/test-814986325/.github/workflows git /usr/bin/git plate-expressiongit git /usr/bin/git git (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 2 commits May 7, 2026 06:37
Copilot AI changed the title [WIP] Fix NewAnomalyDetector to return an error agentdrain: make NewAnomalyDetector consistent with package constructors by returning validated errors May 7, 2026
Copilot AI requested a review from gh-aw-bot May 7, 2026 06:44
@pelikhan pelikhan marked this pull request as ready for review May 7, 2026 14:34
Copilot AI review requested due to automatic review settings May 7, 2026 14:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Aligns pkg/agentdrain’s NewAnomalyDetector constructor with other package constructors by returning an error and validating threshold inputs, and updates callers/docs/tests accordingly.

Changes:

  • Updated NewAnomalyDetector(simThreshold, rareClusterThreshold) to return (*AnomalyDetector, error) and added range validation.
  • Propagated constructor errors from Miner.AnalyzeEvent using existing wrapping style.
  • Updated tests and README usage examples for the new signature and invalid-input behavior.
Show a summary per file
File Description
pkg/agentdrain/anomaly.go Changes constructor signature to return error and adds threshold validation.
pkg/agentdrain/miner.go Handles/propagates NewAnomalyDetector constructor errors in AnalyzeEvent.
pkg/agentdrain/anomaly_test.go Updates tests for new constructor signature and adds invalid-input coverage.
pkg/agentdrain/spec_test.go Updates public API spec test for the new constructor signature.
pkg/agentdrain/README.md Updates example usage to the new constructor signature (needs error handling fix).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment thread pkg/agentdrain/anomaly.go
Comment on lines +19 to +25
func NewAnomalyDetector(simThreshold float64, rareClusterThreshold int) (*AnomalyDetector, error) {
if simThreshold < 0 || simThreshold > 1 {
return nil, fmt.Errorf("agentdrain: NewAnomalyDetector: simThreshold must be in [0,1], got %g", simThreshold)
}
if rareClusterThreshold < 0 {
return nil, fmt.Errorf("agentdrain: NewAnomalyDetector: rareClusterThreshold must be non-negative, got %d", rareClusterThreshold)
}
Comment thread pkg/agentdrain/README.md

```go
detector := agentdrain.NewAnomalyDetector(cfg.SimThreshold, cfg.RareClusterThreshold)
detector, err := agentdrain.NewAnomalyDetector(cfg.SimThreshold, cfg.RareClusterThreshold)
@pelikhan pelikhan merged commit dee0177 into main May 7, 2026
4 checks passed
@pelikhan pelikhan deleted the copilot/fix-anomaly-detector-error-return branch May 7, 2026 14:40
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.

agentdrain: NewAnomalyDetector() has no error return, inconsistent with all other constructors in the package

4 participants