Skip to content

test(#1778): add offline tests for pre-fix and pre-retro - #1781

Merged
waynesun09 merged 2 commits into
mainfrom
agent/1778-pre-fix-retro-tests
Oct 24, 2026
Merged

waynesun09 merged 2 commits into
mainfrom
agent/1778-pre-fix-retro-tests

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

Adds offline tests for the last two pre-scripts that had none, and wires them into make script-test:

  • scripts/pre-fix-test.sh: tests pre-fix.src.sh with mock gh, curl and git on PATH.
  • scripts/pre-retro-test.sh: tests pre-retro.src.sh with mock gh and curl.
  • Makefile: adds both to script-test, next to their post-* counterparts. pre-scribe-test.sh was already wired in and is unchanged.

Coverage

pre-fix (49 cases)

  • Validation failures: unset or invalid forge, bad PR_NUMBER, bad REPO_FULL_NAME, ./.. segments, empty TRIGGER_SOURCE, multiple errors counted, HUMAN_INSTRUCTION length cap (human only).
  • GitLab PR_URL checks: missing, untrusted host, malformed, repo mismatch, number mismatch.
  • Iteration caps for bot and human runs, both default and custom.
  • fullsend-fix-budget/N label gate: lowers the bot cap, blocks a bot run over budget, skipped for human runs, never raises the cap, and falls back to the bot cap when the live label read fails.
  • Base-branch and merge-state reads: fall back to TARGET_BRANCH/main on API failure; an unknown or empty merge state is not treated as a conflict; strategy warning and normalization.
  • Merge-conflict path: fetches the PR base ref, sets the push remote and restores the original origin URL afterwards (GitHub and GitLab). On a failed fetch, the token in the output is redacted (the test token contains glob characters). The run aborts when the origin restore fails, and warns when the target repo is missing.
  • Forge calls (gh pr view ... --json labels|baseRefName|mergeable, GitLab MR endpoint) are asserted, as is the absence of calls on validation failures. GITHUB_PATH writes are asserted; pre-fix writes nothing to GITHUB_OUTPUT.

The git mock simulates fetch and passes every other call to the real git, so the conflict path runs fully offline.

pre-retro (21 cases): GitHub and GitLab originating-URL validation, CI_SERVER_HOST fail-closed and host checks, missing or invalid env, workflow-command sanitization, and the on-demand vs. automatic messages. Every case also asserts that no forge calls are made.

Testing

  • Both new suites pass with SCRIPT_TEST_TARGET=source and SCRIPT_TEST_TARGET=bundled.
  • Mutation check: disabling the iteration-cap check or the token redaction in pre-fix.src.sh makes the matching cases fail.
  • make cannot spawn a shell in the agent sandbox, so the script-test commands were run one by one. Other existing suites fail there only for environment reasons (no yq, sandbox git identity); they are not touched by this PR. CI's make script-test is the authoritative check.
  • pre-commit could not fetch its hook repos in the sandbox. shellcheck 0.10.0 (repo args) and the pre-commit-hooks 6.0.0 checks were run directly and passed.
  • make lint (skillsaw) could not run (no uvx); no skills or agent docs changed.

🤖 Generated with Claude Code


Closes #1778

Post-script verification

  • Branch is not main/master (agent/1778-pre-fix-retro-tests)
  • Secret scan passed (gitleaks — 372c909351b43d71d23e7d95978ebe607a3ddcfa..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

pre-fix.src.sh and pre-retro.src.sh were the only pre-scripts without
offline tests. Add scripts/pre-fix-test.sh and scripts/pre-retro-test.sh
in the style of the other pre-*-test.sh files (mock bin on PATH, clean
env, assert exit code, output and forge calls) and wire both into the
script-test target.

pre-fix-test covers each validation failure (forge, PR_NUMBER,
REPO_FULL_NAME, dot segments, TRIGGER_SOURCE, instruction length, GitLab
PR_URL host/format/repo/number), bot and human iteration caps, the
fullsend-fix-budget/N label gate (lower, block, human bypass, read
failure), base-branch and merge-state read fallbacks, and the conflict
path: fetch of the PR base, push-remote setup and origin restore, token
redaction on fetch failure, abort on restore failure, and missing repo.
A git mock simulates fetch and delegates everything else to real git.
GITHUB_PATH is asserted; pre-fix writes no GITHUB_OUTPUT.

pre-retro-test covers GitHub and GitLab originating-URL validation,
CI_SERVER_HOST checks, missing/invalid env, the on-demand and automatic
messages, and asserts no forge calls are made.

Both suites pass with SCRIPT_TEST_TARGET=source and bundled. make cannot
spawn a shell in the sandbox, so script-test commands were run directly;
other suites fail here only for environment reasons (no yq, sandbox git
identity). make lint (skillsaw) could not run (no uvx); no skills or
agent docs changed. pre-commit could not fetch hook repos; shellcheck
0.10.0 and pre-commit-hooks 6.0.0 hooks were run directly and passed.

Closes #1778

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team as a code owner October 24, 2026 19:19
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Oct 24, 2026
@waynesun09

Copy link
Copy Markdown
Member

/fs-fix-stop

@github-actions github-actions Bot added the fullsend-no-fix Skip bot-triggered fix agent runs label Oct 24, 2026
@github-actions

Copy link
Copy Markdown

Fix agent disabled for this PR. Remove the fullsend-no-fix label or use /fs-fix to re-engage.

@fullsend-ai-review

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Ended 7:21 PM UTC

Commit: 5438c7b · View workflow run →

Automated review did not complete for this commit. Check the latest review status before merging. If no review is queued or running, comment /fs-review to retry.

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ⚠️ Cancelled · Started 7:23 PM UTC · Completed 7:26 PM UTC

Commit: 5438c7b · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.55

This review was superseded by a newer commit. Check the current pull request HEAD's review status before merging.

The gh mock returned post-jq values, so the library's --jq filters
never ran: a broken labels filter would have disabled the
fullsend-fix-budget gate with every test still green. The mock now
builds the JSON gh returns and applies the caller's filter.

Two cases cover the push-remote setup before the conflict fetch: the
token is masked when GITHUB_ACTIONS=true, and a failed credentialed
set-url warns, still fetches and leaves origin unchanged.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 7:28 PM UTC · Completed 7:47 PM UTC

Commit: 73ed6c3 · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.20

@fullsend-ai-review

Copy link
Copy Markdown

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

Additive test-only change by a bot matching issue scope with high test file ratio and low rollback risk, offsetting elevated churn on the touched Makefile and protected script path additions to yield a moderate risk score.

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Medium

  • [protected-path] scripts/pre-fix-test.sh — This PR adds scripts/pre-fix-test.sh and scripts/pre-retro-test.sh, both under the protected scripts/ path. The PR links issue test(scripts): offline tests for pre-fix and pre-retro #1778 and explains the change, which is why this is medium and not high. Human approval is still required for protected-path changes, whatever the context.
    Remediation: A human maintainer should review and approve the scripts/ additions.

@fullsend-ai-review fullsend-ai-review Bot added the requires-manual-review Review requires human judgment label Oct 24, 2026

@waynesun09 waynesun09 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving at 73ed6c3: offline tests for pre-fix (51 cases) and pre-retro (21) running in source and bundled script-test; the gh mock now applies the caller's jq filter and the push-remote setup is covered. Protected path (scripts/) acknowledged as human-approved here.

@waynesun09
waynesun09 added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit c738b1a Oct 24, 2026
63 checks passed
@waynesun09
waynesun09 deleted the agent/1778-pre-fix-retro-tests branch October 24, 2026 19:59

This branch was successfully deployed

1 active deployment
dev — 73ed6c39 Deployed Oct 24, 2026 by waynesun09 via behaviour #1259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fullsend-no-fix Skip bot-triggered fix agent runs ready-for-review Triggers review agent dispatch requires-manual-review Review requires human judgment risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(scripts): offline tests for pre-fix and pre-retro

1 participant