Skip to content

Review correctness sub-agent should detect test-infrastructure failures in shell-script test suites #796

Description

@fullsend-ai-retro

What happened

On PR #686, the human reviewer (waynesun09) identified three distinct test-infrastructure failures that caused GitLab tests to silently not execute, directly contradicting the PR's claim that "all 112 tests pass":

  1. GNU-only sed -i without backup suffix (scripts/post-triage-test.sh): BSD sed requires a backup suffix argument with -i. Combined with set -euo pipefail, this killed the entire test run before any GitLab tests executed.

  2. Mock pagination handler returns content for every page (scripts/post-triage-test.sh): The /notes? mock handler returned content regardless of page number (unlike the labels mock which gates on page=1). The sticky-comment code's pagination loop never terminated, hanging the test suite. Three sticky-comment tests never executed.

  3. Test setup failure cascading under set -euo pipefail: The sed -i failure in test setup prevented all downstream GitLab test functions from running, but the test file's structure meant the exit code from earlier successful GitHub tests masked the failure.

The fullsend-ai-review[bot] ran 30 CHANGES_REQUESTED reviews without detecting any of these. Its correctness sub-agent analyzed the test file multiple times but only flagged surface-level issues (naming inconsistencies, missing shellcheck directives) — never questioning whether the tests actually executed to completion.

What could go better

The review agent's correctness sub-agent should include heuristics for detecting test-infrastructure failures — cases where tests appear to pass but are actually not executing. This is a distinct category from test-coverage analysis (agents#512, agents#397), which focuses on whether changed code has tests. Test-infrastructure failures are about whether existing tests actually run.

Confidence: High that this is a real gap. The review agent analyzed the test file in every review cycle and never questioned test executability. The patterns are heuristically detectable: GNU-only flags in cross-platform scripts, mock handlers that don't bound pagination, and test-setup failures that cascade silently.

Uncertainty: Medium about whether static heuristics alone are sufficient. The most reliable detection would involve actually running the test suite, which the review agent sandbox may not support for all repos. However, pattern-based detection would catch the most common cases.

Proposed change

Add test-infrastructure validation patterns to the review agent's correctness sub-agent prompt or as a dedicated review skill in fullsend-ai/agents. The patterns should cover:

  1. Shell portability flags: When a PR modifies shell scripts that use sed -i, grep -P, readlink -f, or other GNU-only invocations, flag them if the test runner or CI environment may be BSD-based (macOS). Specifically, sed -i '' (BSD) vs sed -i (GNU) is a common portability trap.

  2. Mock pagination termination: When test files define mock HTTP handlers that respond to paginated API endpoints (URLs containing page=, per_page=, or Link: headers), verify that the mock gates its response on the page parameter to terminate iteration. A mock that returns content for every page causes infinite loops in pagination code.

  3. Test-setup failure propagation: When test files use set -euo pipefail and define setup functions called before test functions, verify that a failure in setup would visibly fail the test run rather than silently skipping downstream tests. Look for patterns where early exit codes are masked by the test harness structure.

  4. Test execution claims vs infrastructure: When a PR description claims "all N tests pass," the correctness sub-agent should cross-reference the test count against the test file to verify that new test functions are reachable from the test runner entry point.

The implementation could be a checklist added to the correctness sub-agent's prompt in agents/review.md or the skills/code-review/SKILL.md skill, gated on PRs that modify *-test.sh or *_test.sh files.

Validation criteria

  1. On the next 3 PRs to fullsend-ai/agents that modify shell-script test files, the review agent should flag at least one test-infrastructure concern if applicable (GNU-only flags, unbounded mock pagination, unreachable test functions).
  2. If a PR claims "all tests pass" but modifies test infrastructure in a way that could prevent test execution, the review agent should question the claim with a specific finding.
  3. No increase in false positives on PRs that correctly handle test infrastructure (the heuristics should be specific enough to avoid flagging correct code).

Generated by retro agent from #686

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions