Skip to content

Fix Aider Go test stub package declarations - #72164

Merged
pelikhan merged 6 commits into
mainfrom
pelikhan-symmetrical-bassoon
Oct 27, 2026
Merged

pelikhan merged 6 commits into
mainfrom
pelikhan-symmetrical-bassoon

Conversation

@pelikhan

@pelikhan pelikhan commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Run 40360891821 failed because Aider derived test package declarations from directory names instead of using Go's reported package names. It generated invalid or conflicting packages in command directories, so formatting failed before tests or PR submission.

Changes

  • Generate fixed skipped-test stubs directly from go list package metadata instead of asking the model to author package declarations.
  • Preserve the three-package limit, refuse to overwrite existing files, and retain truthful incomplete/no-op reporting.
  • Cover command directories with hyphens, differing directory/package names, paths with spaces, generated-test compilation, existing internal/external tests, write limits, collisions, and discovery failures.
  • Regenerate the workflow lock; only body/admission hash bindings change. Permissions, imports, runtime pins, and safe-output configuration are unchanged.

Validation

  • make fmt
  • go test ./pkg/workflow -run 'TestAider(Discovery|StubGeneration|DailyGoValidationContracts|DebtDiscovery)' -count=1
  • make recompile
  • make agent-report-progress
  • ShellCheck on the generation command; static security review found no confirmed vulnerabilities.

Normal compilation succeeded with existing warnings. Dry-run compilation was interrupted during model-inventory collection and emitted no diagnostic lock. No workflows were dispatched or rerun; the separate OTLP authorization problem is outside this fix.



✨ PR Review Safe Output Test - Run 40425303201

💥 [THE END] — Illustrated by Smoke Claude · claude · sonnet46 · ~81 AIC · ⌖ ~7 AIC · ⊞ 926 · ◷
Comment /smoke-claude to run again

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review October 26, 2026 18:54
Copilot AI max review requested due to automatic review settings October 26, 2026 18:55

```bash
go list -f '{{if and (not .TestGoFiles) (not .XTestGoFiles)}}{{.Dir}} {{.Name}}{{end}}' ./... > /tmp/gh-aw/agent/aider-untested-packages && sed '/^$/d' /tmp/gh-aw/agent/aider-untested-packages | head -5
go list -f '{{if and (not .TestGoFiles) (not .XTestGoFiles)}}{{.Dir}} {{.Name}}{{end}}' ./... > /tmp/gh-aw/agent/aider-untested-packages && count=0 && while IFS= read -r row; do if [ -n "$row" ]; then directory="${row% *}"; package="${row##* }"; (set -C; printf 'package %s\n\nimport "testing"\n\nfunc TestPlaceholder_TODO(t *testing.T) {\n\tt.Skip("not yet implemented")\n}\n' "$package" > "$directory/${package}_test.go") || exit 1; printf '%s %s\n' "$directory" "$package"; count=$((count + 1)); if [ "$count" -eq 3 ]; then break; fi; fi; done < /tmp/gh-aw/agent/aider-untested-packages

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.

Added canonical path resolution and a workspace containment check before writing each stub; paths resolving outside the workspace are rejected. Fixed in e3c8f29.

pelikhan and others added 2 commits October 26, 2026 12:04
Regenerate the Aider workflow lock from merged sources, preserving the deterministic stub fix and incoming runner updates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Include the model-routing update that landed during validation of the preceding base merge.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟢 Approval recommended

The focused fix preserves existing safeguards and adds regression coverage, with no unresolved blocking issues.

No open issues 🎉

What changed in this PR

Fixes Aider’s Go test-stub workflow by using go list package metadata instead of model-authored package declarations.

Changes:

  • Generates skipped-test stubs directly, preserving the three-package limit and overwrite protection.
  • Adds regression coverage for package names, spaced paths, compilation, write limits, collisions, and discovery failures.
  • Refreshes workflow hash bindings without changing permissions or runtime configuration.
File Description
pkg/​workflow/​aider_discovery_test.go Tests generated stubs and generation safeguards.
.github/​workflows/​daily-go-test-stubs-aider.md Replaces model-authored stubs with deterministic generation.
.github/​workflows/​daily-go-test-stubs-aider.lock.yml Updates body and admission hashes for the revised workflow.

Review effort: Max

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (.github/workflows/daily-go-test-stubs-aider.md:61): Prompt injection risk: the workflow command writes stubs to "$directory/${package}_test.go" where $directory comes from go list output (repo-controlled filesystem layout). A malicious repo can influence .Dir (e.g., via symlinked package directories) so the agent writes files outside the intended workspace; add a deterministic guard (e.g., resolve directory with realpath and require it to be under $(pwd) before redirecting). - Fix Aider Go test stub package declarations #72164 (comment)
  3. Review (.github/workflows/daily-go-test-stubs-aider.md:61):

    Excessive agency risk: Step 1 in .github/workflows/daily-go-test-stubs-aider.md writes new test files to $directory (from go list .Dir) via > "$directory/${package}_test.go" without a deterministic guard that the target path is within the repository checkout (e.g., rejecting symlinked package dirs or enforcing a $PWD prefix). A repo-controlled package directory could therefore steer where files get created on the runner before any independent check.

    - Fix Aider Go test stub package declarations #72164 (comment)

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: e5327b6
Sous-chef work: 315e2efdfcaf94a46ff83d5b0d453d5ab18d0aad28c958bff45e6444be178547 4d7f842d88cf07c38f2d1ce78e7df1d57ab1481bcf36bf918515151a688ec143
Sous-chef state: fd05e09b528de2c082696c631f800c9ae6ef1d5bf099e8a5c7f1ed0ac50bfe58

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · ~5 AIC · ⌖ ~13 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: e3c8f29
Sous-chef work:
Sous-chef state: e85ef0496f3f6e906c47bd041ae334dcd55c25b657809d10d92ca5bfbe84fd56

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · ~4 AIC · ⌖ ~9 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

…bassoon

# Conflicts:
#	.github/workflows/daily-go-test-stubs-aider.lock.yml

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 0555e9f
Sous-chef work:
Sous-chef state: d5a0e47919d63873f59f1f093255b66dda66734f7e1165f78503030a15f3d652

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · ~3 AIC · ⌖ ~11 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

…bassoon

# Conflicts:
#	.github/workflows/daily-go-test-stubs-aider.lock.yml

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

@github-actions github-actions Bot 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.

💥 [THE END] — Illustrated by Smoke Claude · claude · sonnet46 · ~81 AIC · ⌖ ~7 AIC · ⊞ 926
Comment /smoke-claude to run again


func TestAiderDiscoveryUsesGoPackagesAndActualNames(t *testing.T) {
dir := t.TempDir()
dir := filepath.Join(t.TempDir(), "workspace with spaces")

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.

Good improvement! Using filepath.Join(t.TempDir(), "workspace with spaces") ensures the test covers paths with spaces, which is important for cross-platform compatibility. Consider also adding a test case with Unicode characters in the path for broader coverage.

for name, content := range map[string]string{
"go.mod": "module example.test/aider\n\ngo 1.20\n",
"cmd/hyphenated/main.go": "package main\n",
"cmd/hyphenated/main.go": "package main\nfunc main() {}\n",

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.

Nice fix! Adding func main() {} to the package stub makes it a valid Go package with a main function, which correctly satisfies the go toolchain requirements for a main package. This prevents false positives in the aider discovery process.

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.

🟡 Changes recommended

The generated stubs omit the repository-required build tag, triggering a hard violation in test-quality checks.

1 open issue

Review effort: Max


```bash
go list -f '{{if and (not .TestGoFiles) (not .XTestGoFiles)}}{{.Dir}} {{.Name}}{{end}}' ./... > /tmp/gh-aw/agent/aider-untested-packages && sed '/^$/d' /tmp/gh-aw/agent/aider-untested-packages | head -5
workspace="$(pwd -P)" && go list -f '{{if and (not .TestGoFiles) (not .XTestGoFiles)}}{{.Dir}} {{.Name}}{{end}}' ./... > /tmp/gh-aw/agent/aider-untested-packages && count=0 && while IFS= read -r row; do if [ -n "$row" ]; then directory="${row% *}"; package="${row##* }"; resolved="$(realpath -- "$directory")" || exit 1; case "$resolved" in "$workspace"|"$workspace"/*) ;; *) printf 'Refusing to write outside workspace: %s\n' "$resolved" >&2; exit 1 ;; esac; (set -C; printf 'package %s\n\nimport "testing"\n\nfunc TestPlaceholder_TODO(t *testing.T) {\n\tt.Skip("not yet implemented")\n}\n' "$package" > "$resolved/${package}_test.go") || exit 1; printf '%s %s\n' "$resolved" "$package"; count=$((count + 1)); if [ "$count" -eq 3 ]; then break; fi; fi; done < /tmp/gh-aw/agent/aider-untested-packages
@pelikhan
pelikhan merged commit 3ba7fde into main Oct 27, 2026
3 checks passed
@pelikhan
pelikhan deleted the pelikhan-symmetrical-bassoon branch October 27, 2026 01:02
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.0.1

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.

5 participants