Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/reusable-agents-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ jobs:
# Use verify:create-issue label on PRs with CONCERNS to manually create follow-up issues
- name: Open follow-up issue on verifier failure
id: failure_issue
# Disabled - use agents-verify-to-issue-v2.yml with verify:create-issue label instead
if: false # Disabled - use agents-verify-to-issue-v2.yml with verify:create-issue label instead
uses: actions/github-script@v8
env:
PR_URL: ${{ steps.context.outputs.pr_html_url }}
Expand Down
33 changes: 17 additions & 16 deletions scripts/check_issue_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ def extract_head_ref_issue_numbers(head_ref: str) -> set[int]:
return extract_issue_numbers(head_ref or "", include_hash=False)


def resolve_head_ref_issue_number(head_ref: str) -> tuple[int | None, bool]:
numbers = extract_head_ref_issue_numbers(head_ref)
if len(numbers) == 1:
return next(iter(numbers)), False
if len(numbers) > 1:
return None, True
return None, False


def _is_merge_commit_subject(message: str) -> bool:
return MERGE_COMMIT_PATTERN.search(message or "") is not None

Expand Down Expand Up @@ -402,19 +411,17 @@ def main() -> int:
pr_title, head_ref = resolve_pr_context(args.pr_title, args.head_ref)
pr_issue = extract_title_issue_number(pr_title)
if not pr_issue:
head_numbers = extract_head_ref_issue_numbers(head_ref)
head_numbers_present = False
if len(head_numbers) == 1:
pr_issue = next(iter(head_numbers))
elif len(head_numbers) > 1:
pr_issue, head_ambiguous = resolve_head_ref_issue_number(head_ref)
if head_ambiguous:
print(
"Warning: Multiple issue numbers detected in head ref; "
"ignoring head ref and falling back to commits/headers.",
file=sys.stderr,
)
if not pr_issue:
if is_autofix_context(pr_title, head_ref):
print("Skipping issue consistency check: autofix context with no issue number.")
return 0
head_numbers_present = True
elif is_autofix_context(pr_title, head_ref):
print("Skipping issue consistency check: autofix context with no issue number.")
return 0
if not pr_issue:
commit_messages, commit_fallback = collect_commit_messages(
args.base_ref, base_sha, base_remote
)
Expand All @@ -436,12 +443,6 @@ def main() -> int:
if len(combined_issue_numbers) == 1:
pr_issue = next(iter(combined_issue_numbers))
elif not combined_issue_numbers:
if head_numbers_present:
print(
"Skipping issue consistency check: multiple issue numbers detected in head ref "
"without additional issue references."
)
return 0
print("Skipping issue consistency check: no issue references found.")
return 0
else:
Expand Down
30 changes: 11 additions & 19 deletions tests/scripts/test_issue_consistency_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,34 +113,26 @@ def fake_run_git(args: list[str]) -> str:
assert calls == [["log"], ["log", "-n", "1"]]


def test_main_skips_on_multiple_head_ref_issue_numbers(monkeypatch, capsys) -> None:
def fake_collect_commit_messages(base_ref, base_sha, base_remote):
return [], False

def fake_collect_changed_files(base_ref, base_sha, base_remote):
return [], False

# Ensure GITHUB_EVENT_PATH doesn't interfere with autofix detection
def test_main_skips_ambiguous_head_ref(monkeypatch, capsys) -> None:
monkeypatch.delenv("GITHUB_EVENT_PATH", raising=False)
monkeypatch.setenv("PR_TITLE", "")
monkeypatch.setenv("HEAD_REF", "codex/issue-101-issue-202")
monkeypatch.setenv("BASE_REF", "")
monkeypatch.setenv("BASE_SHA", "")
monkeypatch.setenv("BASE_REMOTE", "origin")
monkeypatch.setattr(sys, "argv", ["check_issue_consistency.py"])

monkeypatch.setattr(
check_issue_consistency,
"collect_commit_messages",
fake_collect_commit_messages,
lambda *args, **kwargs: ([], False),
)
monkeypatch.setattr(
check_issue_consistency,
"collect_changed_files",
fake_collect_changed_files,
)
monkeypatch.setattr(
sys,
"argv",
["check_issue_consistency.py", "--pr-title", "", "--head-ref", "codex/issue-12-issue-34"],
lambda *args, **kwargs: ([], False),
)

exit_code = check_issue_consistency.main()
assert check_issue_consistency.main() == 0
captured = capsys.readouterr()

assert exit_code == 0
assert "multiple issue numbers detected in head ref" in captured.out
assert "Skipping issue consistency check: no issue references found." in captured.out
2 changes: 2 additions & 0 deletions tests/workflows/fixtures/keepalive/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ async function runScenario(scenario) {
Boolean(scenario.clearTokenDefaults) ||
Boolean(scenarioEnv.CLEAR_TOKEN_DEFAULTS) ||
Boolean(scenarioEnv.clear_token_defaults) ||
Boolean(process.env.CLEAR_TOKEN_DEFAULTS) ||
Boolean(process.env.clear_token_defaults) ||
allExplicitTokensBlank;

const envOverrides = {
Expand Down
2 changes: 2 additions & 0 deletions tests/workflows/test_keepalive_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ def test_keepalive_requires_instruction_token() -> None:
assert scenario_path.exists(), "Scenario fixture missing"
command = ["node", str(HARNESS), str(scenario_path)]
env = _clean_token_env(os.environ.copy())
env["CLEAR_TOKEN_DEFAULTS"] = "true"
env["clear_token_defaults"] = "true"
result = subprocess.run(command, capture_output=True, text=True, env=env)
assert result.returncode != 0, "Expected harness to fail without dispatch token"
combined_output = (result.stderr or "") + (result.stdout or "")
Expand Down
Loading