Skip to content

ci: validate fork pull requests on hosted runners - #278

Merged
datacas merged 2 commits into
mainfrom
task-243
Oct 19, 2026
Merged

datacas merged 2 commits into
mainfrom
task-243

Conversation

@datacas

@datacas datacas commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Closes #243.

Fork pull requests now run the required Linux validation on GitHub-hosted ubuntu-latest; same-repository pull requests, pushes to main, and workflow_dispatch retain the self-hosted runner. The required check name and contents: read permissions stay unchanged.

Diagnosis

The validate job was skipped for fork pull requests by its job-level if: condition. The workflow source showed the condition excluded fork heads; GitHub's current documentation confirms that a conditionally skipped job reports Success, even when it is a required check (job conditions). The proposed cause was confirmed.

The invariant is that the required Linux check runs the full validation and reports its real result, while fork-controlled code never runs on the self-hosted machine. The fix selects ubuntu-latest for every pull_request whose head repository is not this repository (a null head repository included) and retains the self-hosted runner for all other events. The workflow's existing system python3 and ShellCheck steps remain unchanged; GitHub's Ubuntu 24.04 image inventory lists Python 3.12.3 and ShellCheck 0.9.0-1.

Related work searched at widened depth: #242 (closed; its changes are present in the current workflow), #236 (open; changes the same workflow), #241 (closed), and #259 (open; includes CI security coverage). The same-term search also found merged PRs #170 and #254. This change preserves #242's triggers and concurrency and does not alter #236's path classification or #241's Windows shards.

Work units

Unit Behaviour Files Tests Verification Rollback
WU-1 Route fork PR validation to GitHub-hosted Linux while retaining self-hosted routing for other events and the required check name. .github/workflows/validate.yml, tests/test_validate_workflow.py Workflow routing regression test python3 -m unittest discover -s tests — exit 0, 1,609 tests; python3 scripts/validate-package.py — exit 0; python3 -m unittest — exit 0, 0 tests discovered. Agent-reported local verification. independent

Verification

Agent-reported local checks ran in this Linux worktree with system Python 3. GitHub's hosted Ubuntu image inventory lists system Python and ShellCheck. The fork-specific runner route was not exercised by this same-repository pull request; the regression test checks the workflow routing expression, and the pushed-head checks are reported below.

  • python3 -m unittest discover -s tests — passed, 1,609 tests.
  • python3 scripts/validate-package.py — passed.
  • python3 -m unittest — exited 0, discovered 0 tests.

Checks of pushed head

One check read for head bee2c2714ce306d25011dbd1e5a5f62c2692ee35 found these jobs in progress:

  • Skills, manifests, and Bash installer — pending.
  • Windows test shard (windows-1) — pending.
  • Windows test shard (windows-2) — pending.
  • Windows test shard (windows-3) — pending.
  • Windows test shard (windows-4) — pending.

PowerShell installer was not yet present in the rollup; its Windows shard dependencies were still running. The stage did not wait or poll, per the parallel CI policy.

@datacas

datacas commented Oct 19, 2026

Copy link
Copy Markdown
Owner Author

Code Cycle initial review

[CCR-20261019-001] · manual · anthropic/opus→? · high · schema:2

Verdict: CHANGES_REQUESTED for head bee2c2714ce306d25011dbd1e5a5f62c2692ee35.

Summary and scope

Reviewed the accumulated diff origin/main...task-243 (2 files, +24 −3): .github/workflows/validate.yml replaces the job-level if: that skipped fork pull requests with a runs-on expression that sends fork PRs to ubuntu-latest, and tests/test_validate_workflow.py pins that expression, the unchanged job name, and the absence of if:.

The change follows the proposal in #243, keeps the required check name Skills, manifests, and Bash installer, keeps permissions: contents: read, and does not introduce pull_request_target or secrets. The #242 triggers and concurrency block are untouched. Two findings block approval: one about the self-hosted boundary failing open, one about the PR not closing its issue.

Findings

[REV-001] · medium · open · - · blocks:yes — Runner selection fails open to self-hosted when the PR head repository is null

.github/workflows/validate.yml:28

The new predicate selects ubuntu-latest only when github.event.pull_request.head.repo.fork is truthy. When a pull_request payload carries head.repo: null (GitHub reports this when the head repository has been deleted), the property dereference evaluates to null, the && chain is falsy, and the expression falls through to ["self-hosted","Linux","X64"]. actions/checkout then checks out refs/pull/<n>/merge, which still contains the fork's commits, on the self-hosted machine.

The removed condition failed closed for the same payload: head.repo.full_name == github.repository is null == 'datacas/code-cycle-toolkit', false, so the job was skipped. #243's acceptance criteria ask that every path of the expression resolve to ubuntu-latest for fork PRs, and this one does not.

Whether a pull_request event can still fire for a PR whose head repository is gone (for example on reopened) was not reproduced; the finding rests on the expression semantics and on the old predicate being fail-closed. The fix is one predicate and fails closed regardless:

runs-on: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'ubuntu-latest' || fromJSON('["self-hosted","Linux","X64"]') }}

Same-repository PRs, pushes to main, and workflow_dispatch keep the self-hosted runner; every other pull_request, including a null head repository, goes to ubuntu-latest. Update the regex in test_fork_pr_runner_routing_preserves_required_check accordingly.

[REV-002] · low · open · - · blocks:yes — PR body does not close #243

PR description

The body says "Implements #243", which is not a GitHub closing keyword; gh pr view 278 --json closingIssuesReferences returns [], so merging leaves #243 open. This repository requires every PR that fully implements an issue to state Closes #N. Add Closes #243 to the description.

Security triage

The audit ran: the change edits a CI workflow and the runner trust boundary (default trigger: CI workflows), and #243 is security-sensitive. Result:

  • No pull_request_target, no secrets.* reference in validate.yml; workflow-level permissions: contents: read still applies, so fork runs get a read-only token.
  • The repository is not itself a fork (isFork: false), so any non-same-repository PR head is a fork; same-repository PRs keep the self-hosted runner as before.
  • One fail-open path found and reported as REV-001.
  • release.yml still runs on the self-hosted runner and is not triggered by pull requests; out of scope.

Commands executed

In .worktree/task-243 at bee2c2714ce306d25011dbd1e5a5f62c2692ee35:

  • python3 -m unittest tests.test_validate_workflow -v — exit 0, 5 tests OK.
  • python3 scripts/validate-package.py — exit 0.
  • gh repo view datacas/code-cycle-toolkit --json isFork,parent — isFork: false, parent: null.
  • gh pr view 278 --json closingIssuesReferences — [].

Unverified

  • A real fork PR has not run the job on ubuntu-latest; this PR comes from a branch of the repository, so only the self-hosted path was exercised by CI. ci: validate fork PRs on a GitHub-hosted runner instead of skipping the Linux job #243's acceptance criterion (a fork PR with a deliberately failing test makes the check fail) still needs a fork PR to observe.
  • The null head-repository case of REV-001 was analysed, not reproduced.
  • The full unit suite was not rerun by this review; CI ran it on this head (below) and the PR reports a local pass.

CI (bee2c27)

All 6 checks passed: Skills, manifests, and Bash installer (required), Windows test shard (windows-1..4), PowerShell installer (required). Cycle CI policy: parallel.

Residual risk

Until a fork PR runs, the hosted-runner path (system python3 venv, preinstalled ShellCheck, Node setup, installer steps) is supported only by the runner image inventory, not by an observed run.

…sed (#243)

Compare the head repository with github.repository instead of reading
head.repo.fork, so a pull_request payload with a null head repository
also selects ubuntu-latest rather than the self-hosted runner (REV-001).
@datacas

datacas commented Oct 19, 2026

Copy link
Copy Markdown
Owner Author

Code Cycle resolution

[CCR-20261019-001] · manual · anthropic/opus→? · high · schema:2

[CCT-20261019-001] · manual · anthropic/opus→? · high · triaged:bee2c2714ce306d25011dbd1e5a5f62c2692ee35 · schema:2

Status: RESOLVED. Both findings were triaged valid against bee2c27 before any edit. The fix commit is 6b6ee243a7b2c4e0abc468f10bb7ee71c7fe647e.

Findings

[REV-001] · medium · resolved · valid · blocks:yes — Runner selection fails open to self-hosted when the PR head repository is null

.github/workflows/validate.yml:28, tests/test_validate_workflow.py

The runs-on predicate now compares github.event.pull_request.head.repo.full_name != github.repository instead of reading head.repo.fork. Routing by case:

Event Head repository Runner
pull_request this repository self-hosted (unchanged)
pull_request a fork ubuntu-latest
pull_request null ubuntu-latest (was self-hosted)
push to main, workflow_dispatch — self-hosted (unchanged)

The job's comment states the fail-closed intent, and the regression test now pins the new predicate, the unchanged job name, and the absence of if:. Commit 6b6ee24.

[REV-002] · low · resolved · valid · blocks:yes — PR body does not close #243

The PR description now opens with Closes #243; gh pr view 278 --json closingIssuesReferences returns [243]. No code change is involved; the evidence anchor is 6b6ee24.

Verification

Agent-reported, run in .worktree/task-243 at 6b6ee24 with system Python 3:

  • python3 -m unittest tests.test_validate_workflow -v: exit 0, 5 tests OK.
  • python3 scripts/validate-package.py: exit 0.
  • yaml.safe_load(.github/workflows/validate.yml): parses.

Not verified: the null head-repository case and a real fork PR on ubuntu-latest were analysed, not executed. GitHub expressions cannot be evaluated locally, and this PR comes from a branch of the repository. The full unit suite was not rerun locally; CI runs it on the pushed head.

Post-change review and security

  • Fix-delta review (bee2c27..6b6ee24): no new findings. Same-repository PRs still match github.repository (GitHub compares strings case-insensitively), so they keep the self-hosted runner.
  • Security triage: the rule fired on the CI workflow, so the audit ran. The change narrows the self-hosted path and adds no pull_request_target, secrets, or permissions.

CI (6b6ee24, read once under the parallel policy)

Pending: Skills, manifests, and Bash installer, Windows test shard (windows-1..4). PowerShell installer was not yet in the rollup. The cycle's CI gate decides on these.

Residual risk

Unchanged from the review: the hosted-runner path has not been observed on a real fork PR.

@datacas

datacas commented Oct 19, 2026

Copy link
Copy Markdown
Owner Author

Code Cycle rereview

[CCR-20261019-001] · manual · anthropic/opus→? · high · schema:2

[CCT-20261019-001] · manual · anthropic/opus→? · high · triaged:bee2c2714ce306d25011dbd1e5a5f62c2692ee35 · schema:2

[CCR-20261019-002] · manual · anthropic/opus→? · high · schema:2

Verdict: REVIEW_PASSED_AWAITING_CI for head 6b6ee243a7b2c4e0abc468f10bb7ee71c7fe647e. No open finding blocks approval. Some required checks are still running, so this is not an approval yet.

Independence note: this rereview ran in the same manual session that produced the review and the resolution, because the automated stages cannot publish until #280 is fixed. It is not an independent reviewer.

What changed since the previous review (bee2c27..6b6ee24)

  • .github/workflows/validate.yml: the runs-on predicate compares head.repo.full_name != github.repository instead of reading head.repo.fork, and the comment explains the fail-closed intent.
  • tests/test_validate_workflow.py: the pinned regex follows the new predicate.
  • PR description: now opens with Closes #243.

The accumulated diff origin/main...6b6ee24 (2 files, +27 −3) was reread in full. It still has no if: on the job, keeps the job name Skills, manifests, and Bash installer, keeps permissions: contents: read, and leaves the #242 triggers and concurrency untouched.

Previous findings

[REV-001] · medium · resolved · valid · blocks:yes — Runner selection fails open to self-hosted when the PR head repository is null

Corrected. The expression at 6b6ee24 was evaluated in a local model of GitHub's documented expression semantics:

  • a null property evaluates to null;
  • && and || return their operands;
  • string comparison ignores case;
  • mismatched types are coerced to numbers.
Event Head repository Result
pull_request datacas/code-cycle-toolkit self-hosted
pull_request Datacas/Code-Cycle-Toolkit self-hosted
pull_request someone/code-cycle-toolkit ubuntu-latest
pull_request null ubuntu-latest
push — self-hosted
workflow_dispatch — self-hosted

The null case now resolves to ubuntu-latest. On bee2c27, the same case fell through to self-hosted. CI on this head ran the job on the self-hosted runner for this same-repository PR, which is consistent with the first row.

[REV-002] · low · resolved · valid · blocks:yes — PR body does not close #243

Corrected: gh pr view 278 --json closingIssuesReferences returns [243].

New findings

None.

Security triage

The audit ran because the deterministic rule fired on a CI workflow, and the change sits on the self-hosted runner trust boundary. The fix only narrows the self-hosted path. There is no pull_request_target, no secrets.*, and no permission change.

Verification

  • python3 -m unittest tests.test_validate_workflow: exit 0 at 6b6ee24.
  • Expression model over the six cases above: output as tabulated.
  • gh pr view 278 --json closingIssuesReferences: [243].

Unverified:

CI (6b6ee24, read once under the parallel policy)

Check State
Skills, manifests, and Bash installer (required) passed
Windows test shard (windows-2) passed
Windows test shard (windows-1), (windows-3), (windows-4) running
PowerShell installer (required) not yet in the rollup; waits for the shards

The cycle's CI gate decides on these.

Residual risk

The hosted-runner path has not yet been observed on a fork PR. The routing logic itself is now fail-closed for every pull request whose head is not this repository.

@datacas
datacas merged commit 165aba6 into main Oct 19, 2026
6 checks passed
@datacas
datacas deleted the task-243 branch October 19, 2026 15:12
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.

ci: validate fork PRs on a GitHub-hosted runner instead of skipping the Linux job

1 participant