Skip to content

fix(#257): defer FindModuleRoot in runReport after --analyzer check - #258

Merged
em-redhat merged 2 commits into
mainfrom
agent/257-report-defer-findmoduleroot
Sep 17, 2026
Merged

em-redhat merged 2 commits into
mainfrom
agent/257-report-defer-findmoduleroot

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

  • Defers loader.FindModuleRoot in runReport (cmd/gaze/main.go) to after the --analyzer flag check, so gaze report --analyzer no longer fails with "no go.mod found" on non-Go projects
  • Mirrors the fix applied to runCrap in PR fix: allow gaze crap --analyzer on non-Go projects #254 (issue bug: gaze crap --analyzer fails with 'no go.mod found' for non-Go projects #250) — all three commands (crap, quality, report) now follow the same pattern: check --analyzer before calling FindModuleRoot
  • Adds two regression tests: TestReportWithExternalAnalyzer_BypassesFindModuleRoot (external path bypasses FindModuleRoot) and TestRunReport_GoNativePath_FindModuleRootFailure (Go-native path still calls FindModuleRoot)

Test plan

  • TestReportWithExternalAnalyzer_BypassesFindModuleRoot — verifies the bug is fixed
  • TestRunReport_GoNativePath_FindModuleRootFailure — verifies the Go-native path still calls FindModuleRoot
  • All existing cmd/gaze tests pass (go test -race -count=1 -short ./cmd/gaze/...)
  • go vet ./cmd/gaze/... passes

Closes #257

Post-script verification

  • Branch is not main/master (agent/257-report-defer-findmoduleroot)
  • Secret scan passed (gitleaks — ec204ea5db81ed2ba2741a3f9e08e73929a2edbc..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Sep 14, 2026
@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

✅MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ REPOSITORY gitleaks yes no no 1.1s
✅ REPOSITORY git_diff yes no no 0.13s

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 12:53 PM UTC · Completed 1:08 PM UTC

Commit: 1fac377 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $5.57

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Sep 14, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Small, well-scoped bug fix (2 files, 77 lines, 50% test ratio) deferring FindModuleRoot after the --analyzer early-return path. Tier 1 signals are minimal across all 8 dimensions. Tier 2 is elevated due to cmd/gaze/main.go being a high-churn hub with fix-related commits in 90d. Tier 3 is low: all 4 acceptance criteria met, trivially reversible. Composite 1.55 rounds to 2 (moderate), consistent with prior assessment.

Previous run

Risk Assessment: moderate (2/5)

Details

Small, well-scoped bug fix (2 files, 77 lines, 50% test ratio) deferring FindModuleRoot after the --analyzer early-return path — known pattern duplicate of #250. Tier 1 is minimal across all 8 dimensions. Tier 2 is elevated due to cmd/gaze/main.go being a high-churn hub with 20 fix-related commits in 90 days. Tier 3 is low: all acceptance criteria met, trivially reversible. Composite 1.55 rounds to 2 (moderate), consistent with prior assessment.

Previous run (2)

Risk Assessment: moderate (2/5)

Details

Small, well-scoped bug fix (2 files, 93 lines, 78 are new tests) deferring FindModuleRoot after the --analyzer early-return path. Tier 1 is minimal risk across all signals. Tier 2 is elevated because cmd/gaze/main.go is a high-churn hub with 27 commits and 20 fix-related commits in 90 days. Tier 3 is low: known pattern (duplicate of #250), all acceptance criteria addressed, trivially reversible. Composite 1.67 rounds to 2 (moderate).

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Looks good to me

Previous run

Looks good to me

Previous run (2)

Review

Findings

Low

  • [test-isolation] cmd/gaze/external_analyzer_test.go:358 — Both new tests use os.Chdir + t.Cleanup to control the working directory. The project requires Go 1.25+, so t.Chdir(dir) (added in Go 1.24) is available and preferable: it is a single-line replacement that auto-restores the directory and explicitly forbids t.Parallel, making the test-isolation contract explicit. The existing codebase has precedent for the manual pattern (internal/loader/loader_test.go), but t.Chdir is the idiomatic replacement.
    Remediation: Replace the manual os.Chdir + t.Cleanup boilerplate in both tests with t.Chdir(dir).

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-coder

fullsend-ai-coder Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 1:09 PM UTC · Completed 1:22 PM UTC

Commit: 1fac377 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $2.34

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 1 (bot-triggered)

Replaced manual os.Chdir + t.Cleanup pattern with t.Chdir(t.TempDir()) in both report regression tests, as recommended by the reviewer. The project requires Go 1.25+, so t.Chdir (added in Go 1.24) is available and preferable.

Fixed (1):

  1. [test-isolation] Both new tests use os.Chdir + t.Cleanup to control the working directory (cmd/gaze/external_analyzer_test.go): Replaced manual os.Chdir + t.Cleanup boilerplate with t.Chdir(t.TempDir()) in both TestReportWithExternalAnalyzer_BypassesFindModuleRoot and TestRunReport_GoNativePath_FindModuleRootFailure. Go 1.24+ t.Chdir is available (module requires 1.25) and makes the test-isolation contract explicit.

Tests: passed

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

fullsend-ai-coder Bot added a commit that referenced this pull request Sep 14, 2026
Replace manual os.Chdir + t.Cleanup boilerplate with t.Chdir(t.TempDir())
in both TestReportWithExternalAnalyzer_BypassesFindModuleRoot and
TestRunReport_GoNativePath_FindModuleRootFailure. Go 1.24+ t.Chdir is
available (module requires 1.25) and makes the test-isolation contract
explicit by auto-restoring the directory and forbidding t.Parallel.

Addresses #258
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 1:23 PM UTC · Completed 1:37 PM UTC

Commit: aaf5407 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.34

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Sep 14, 2026
@em-redhat
em-redhat requested a review from a team September 17, 2026 11:47

@em-redhat em-redhat 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.

APPROVE — Clean, minimal bug fix. All 4 acceptance criteria from #257 satisfied. CI passes across all matrix entries (Go 1.24 + 1.25, unit/integration + E2E + MegaLinter). No security, alignment, or constitution concerns.

This review was generated by /uf.review-pr (AI-assisted).

runReport called loader.FindModuleRoot unconditionally at the top of
the function, causing gaze report --analyzer to fail with "no go.mod
found" on non-Go projects. This is the same bug pattern fixed in
runCrap by PR #254 (issue #250).

The fix makes FindModuleRoot conditional on p.analyzerFlag == "":
when --analyzer is set, the project may not be a Go module, so cwd
is used directly as moduleDir. When --analyzer is not set (Go-native
path), FindModuleRoot resolves the module root as before.

Added two regression tests:
- TestReportWithExternalAnalyzer_BypassesFindModuleRoot: verifies
  that runReport with --analyzer from a non-Go directory produces an
  analyzer discovery error, not "no go.mod found"
- TestRunReport_GoNativePath_FindModuleRootFailure: verifies that
  runReport without --analyzer still calls FindModuleRoot and
  produces the expected error format

All three commands (crap, quality, report) now follow the same
pattern: check --analyzer before calling FindModuleRoot.

Closes #257
Replace manual os.Chdir + t.Cleanup boilerplate with t.Chdir(t.TempDir())
in both TestReportWithExternalAnalyzer_BypassesFindModuleRoot and
TestRunReport_GoNativePath_FindModuleRootFailure. Go 1.24+ t.Chdir is
available (module requires 1.25) and makes the test-isolation contract
explicit by auto-restoring the directory and forbidding t.Parallel.

Addresses #258
@em-redhat
em-redhat force-pushed the agent/257-report-defer-findmoduleroot branch from aaf5407 to db3d665 Compare September 17, 2026 12:01
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 12:02 PM UTC · Completed 12:13 PM UTC

Commit: db3d665 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.03

@em-redhat
em-redhat merged commit f7a4fe1 into main Sep 17, 2026
25 checks passed
@em-redhat
em-redhat deleted the agent/257-report-defer-findmoduleroot branch September 17, 2026 12:20
@fullsend-ai-retro

fullsend-ai-retro Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 12:21 PM UTC · Completed 12:34 PM UTC

Commit: db3d665 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $5.87

@fullsend-ai-retro

Copy link
Copy Markdown

Retro: PR #258 — fix(#257): defer FindModuleRoot in runReport after --analyzer check

Timeline

Time (UTC) Event
Sep 14, 12:29 Retro agent files issue #257 from PR #254 review findings
Sep 14, 12:30–12:34 Triage agent verifies bug by reading source ($0.86)
Sep 14, 12:36–12:51 Code agent creates PR #258 with fix + 2 regression tests ($3.60)
Sep 14, 12:52–13:08 Review agent: CHANGES_REQUESTED — low: use t.Chdir instead of os.Chdir + t.Cleanup ($5.57)
Sep 14, 13:08–13:22 Fix agent replaces os.Chdir with t.Chdir(t.TempDir()) ($2.34)
Sep 14, 13:22–13:37 Review agent: APPROVED ($4.34)
Sep 17, 11:58 Human (em-redhat): APPROVED via /uf.review-pr
Sep 17, 12:01–12:13 Review agent re-run on push: APPROVED ($4.03)
Sep 17, 12:20 Merged by em-redhat

Total agent cost: ~$20.74 (triage + code + 3 reviews + 1 fix). Rework iterations: 1 (t.Chdir style fix).

What went well

  1. Retro-to-code pipeline created real value. The retro agent identified the sibling FindModuleRoot bug in runReport during PR #254's review, filed issue #257 with precise reproduction steps and validation criteria, and the full pipeline (triage → code → review → fix → merge) executed cleanly.
  2. Code agent produced a minimal, correct fix. 2 files changed, +74/-3 lines. The fix mirrors the pattern from PR fix: allow gaze crap --analyzer on non-Go projects #254 exactly, with two regression tests covering both the external-analyzer and Go-native paths.
  3. Review agent caught a real issue. The os.Chdir + t.Cleanup → t.Chdir(t.TempDir()) finding was legitimate — the codebase already uses t.Chdir in cmd/gaze/main_test.go and the project requires Go 1.25+.
  4. Duplicate dispatch handled correctly. Two fullsend runs fired within 2 seconds (PR opened + labeled events). The per-role concurrency group cancelled the second run before any agent work started — no wasted compute.

Existing issue evidence

Proposals filed

  1. Code agent: sibling pattern audit for bug-fix PRs (target: fullsend-ai/agents) — When fixing a bug pattern, grep for the same pattern in sibling functions before submitting.
  2. Go convention pack: add t.Chdir preference (target: unbound-force/gaze) — Document t.Chdir as the preferred pattern for directory-changing tests to prevent the rework that occurred here.

Proposals filed

Proposals skipped (target repo not allowed)

File manually or update create_issues.allow_targets in config.yaml:

  • Code agent: add sibling pattern audit step for bug-fix PRs (fullsend-ai/agents)

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

Labels

ready-for-merge All reviewers approved — ready to merge ready-for-review Triggers review agent dispatch risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: gaze report --analyzer fails with 'no go.mod found' on non-Go projects (same as #250)

1 participant