Skip to content

ci(route): read the Actions jobs once for the Linux, Rust and Windows routes - #4742

Merged
devswha merged 3 commits into
mainfrom
ci/route-one-jobs-scan
Nov 25, 2026
Merged

devswha merged 3 commits into
mainfrom
ci/route-one-jobs-scan

Conversation

@devswha

@devswha devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner

What

scripts/ci-runner-route.sh paged through the Actions API twice on every same-repository pull request and push whose Native Windows install could go to winvm: pool_jobs read runs?status=in_progress|queued and each run's /jobs for the Linux and Rust routes, then winvm_jobs read all of it again only to count the jobs of winvm's label.

Now the one read (pool_jobs, already cached between the Linux and Rust routes through pool_counts) also counts winvm's jobs, so the Windows route reuses it.

  • The Windows route's checks that need no API (hosted_only, fork, event, draft, the CI_WINVM_READY mark) run before the routes, so the read knows whether winvm's jobs matter. Its early stop (the Linux route already decided) now waits only until winvm's count is known as well; when winvm is not a candidate, it stops exactly as before.
  • The read can take minutes, so winvm's mark is checked against the clock again right before winvm is chosen (the old code read the clock after the Linux scan, too).
  • A job with a missing created_at/started_at no longer fails the whole read: it counts as no wait, and as live when running (so a winvm job with no start time still keeps winvm busy).
  • A cached answer that is not four numbers (a disk that would not take it) is a failed read, so every route falls back to the hosted image instead of reading zeros.

Routing decisions are unchanged for every input the tests cover; no workflow, required check name or .github/workflows/hook-kill-tests.yml changes.

Why

About 100 CI runs a day; each one's Detect changes made the same paginated reads twice while winvm was ready. This halves those reads (one runs page per status plus one /jobs read per active run instead of two of each), which also halves the share of the workflow token's API rate limit the route spends.

Known differences (accepted)

  • The Windows log's "N job(s) of winvm's label" is how many the read saw before it could stop (at least one), not always the total.
  • When the read continues only for winvm, the Linux/Rust log lines may report a longer longest wait than before (they saw more runs); their decisions do not change.
  • A winvm job queued in the seconds between the shared read and the Windows decision is not seen; the old second read narrowed that window by a few seconds but had the same race with the job being queued.

Validation

  • bun test scripts/ci-runner-route.test.ts scripts/light-runner-workflow.test.ts scripts/privileged-jobs-workflow.test.ts scripts/winvm-runner.test.ts: 288 pass. New tests: one read for all three routes, reading past the Linux stop while winvm matters, the mark re-checked after the read (a fake date, no sleeps), missing job times, and a cache the disk will not take. The two read-count tests failed on origin/main before the change.
  • bun run check fast (TMPDIR under ~/.cache/ovis-tmp): passed on the final head.
  • Reviews: a gate review and a Codex adversarial review (gpt-6.2-sol-fast, xhigh); the reproduced findings (stale mark after a long read, a missing job time failing the read, a broken cache read as zeros) are fixed in the second commit, the rest are listed above.

… routes

winvm_jobs paged through the in-progress and queued runs and each run's jobs a
second time after pool_jobs had already read them. The one scan now also counts
the jobs of winvm's label, and the Windows route's checks that need no API run
first so the scan keeps reading past the Linux route's early stop only while
winvm's jobs still matter.
The shared read can take minutes, so winvm's mark is checked against the clock
again before winvm is chosen. A job with a missing time no longer fails the
whole read: it counts as no wait and as live. A cached answer that is not four
numbers (a disk that would not take it) is a failed read, never zeros.
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Chores
    • CI now checks queued and running jobs across Linux, Rust, and Windows routes in a shared scan, reducing repeated status reads.
    • Windows routing uses a hosted runner when job data is unavailable or Windows VM readiness cannot be confirmed. Readiness is checked again after the scan.
    • Job timestamps that are missing are handled consistently, and cached results are accepted only when they include all expected counts.
  • Tests
    • Added coverage for shared job checks, Windows routing fallbacks, readiness updates, and missing timestamps.

The CI routing script now uses one Actions API job scan for Linux, Rust, and Windows VM routes. Windows routing evaluates its eligibility conditions and readiness mark against the shared scan result. Tests cover scan behavior, readiness timing, and fallback routing.

Changes: Shared CI job scan

Layer / File(s) Summary
Shared job scan and result handling
scripts/ci-runner-route.sh, scripts/ci-runner-route.test.ts, changelog.d/ci-route-reads-jobs-once.md
The scan returns Linux, Rust, and Windows VM counts. Cached results must contain four integers, and the Rust route reads its wait count from the expanded result. Tests cover shared API reads, scan continuation and early stopping, temporary-file write failures, and missing timestamps. The changelog records the shared scan.
Windows VM route selection
scripts/ci-runner-route.sh, scripts/ci-runner-route.test.ts
The Windows route evaluates hosted-only conditions before the scan. It then checks the shared result and rechecks readiness using a refreshed clock value. A test covers readiness changing during API reads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related issues

Possibly related PRs

  • devswha/ovis#4057: It changes the queued-job wait thresholds and record handling used in the same CI routing decisions.
Merge Risk: Minimal · previous review 09aa2

The change makes CI routing read the Actions jobs once for the Linux, Rust and Windows routes instead of scanning twice when winvm is a candidate. Routing decisions are unchanged for the tested inputs. The one remaining edge case, a job queued between the scan and the Windows decision, existed before and causes at most a short, bounded delay. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the Actions jobs are read once and shared across the Linux, Rust and Windows routes. It matches the raw summary and the PR objectives. It is a single, specific sentenc…
Description check Passed The description follows the template. The What section describes the problem and the resulting behavior. The Why section gives the motivation. The Validation section lists the commands run, their resu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the Actions jobs are read once and shared across the Linux, Rust and Windows routes. It matches the raw summary and the PR objectives. It is a single, specific sentence with a conventional ci(route) prefix.

Full details: Description check

Explanation

The description follows the template. The What section describes the problem and the resulting behavior. The Why section gives the motivation. The Validation section lists the commands run, their results, and the new tests. It links no issue, and the template asks for a link only for features. It does not cite the CONTRIBUTING.md checks or the changelog entry in changelog.d/, and it does not say whether contract tests applied. These gaps are minor.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5832729 and 09aa2f6.

Files selected for processing: 3

  • changelog.d/ci-route-reads-jobs-once.md
  • scripts/ci-runner-route.sh
  • scripts/ci-runner-route.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@devswha
devswha merged commit d435813 into main Nov 25, 2026
15 checks passed
@devswha

devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head a76f84dd7. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit reviewed this head.

main had moved since the checks of 09aa2f60e: pr-merge --update merged it in (374f625c0), and every required check was green at this head.

main moved but untouched: merged without update. Its new commits up to 8c9ee5195 change no file of this pull request, none imported by one, and nothing that decides which checks run.

Owner approved (2026-11-25). Reviews: gate reviewer + Codex adversarial; CodeRabbit: reviewed this head.

@devswha
devswha deleted the ci/route-one-jobs-scan branch November 25, 2026 14:44
devswha added a commit that referenced this pull request Nov 25, 2026
… and run herdr-core live contract hosted (#4745)

Stacked on #4742 (`ci/route-one-jobs-scan`): the fallback below reuses
that PR's one Actions read. Merge #4742 first; this PR then retargets to
`main` (or is rebased onto it) with only its own commit.

## What

### 1. herdr-core live contract runs GitHub-hosted by default

Measured on the last 15 green runs (median): GitHub-hosted
`ubuntu-24.04` 310 s, the P620 327 s, old-desktop 328 s. On the
self-hosted pool it took a slot of every run for about 5.5 minutes. It
now runs on `ubuntu-24.04` unless the repository variable
`CI_HC_LIVE_LABELS` names self-hosted labels. A fork's pull request
stays hosted whatever the variable says (the fork guard comes first,
`scripts/light-runner-workflow.test.ts`).

Risk: today (11-25) the required Hook kill tests (container) waited over
an hour for a GitHub-hosted slot. Moving one more job per run to the
hosted pool adds to that. Hence the variable: going back needs no PR
(below). The companion PR that path-filters the non-required
GitHub-hosted workflows (lane ci-eff-b, "PR 4") lowers hosted use;
landing both together is recommended.

### 2. Fast checks and Integration tests prefer the fastest machine

Medians of the same runs: Fast checks 236 s on the P620 vs 460 s on
old-desktop; Integration tests 194 s vs 331 s.

- `CI_FAST_SELF_HOSTED_LABELS` (existing) and
`CI_INTEGRATION_SELF_HOSTED_LABELS` (new; the integration job now reads
a new `integration` route output) may name that machine's own label,
e.g. `["self-hosted","self-hosted-ovis-p620"]`.
- `scripts/ci-runner-route.sh` uses them only while the Linux jobs take
the shared pool (`["self-hosted","self-hosted-ovis"]`) in a
same-repository pull request or a push. A fork, `hosted_only` (Release
validation, Pages), a manual run, any other event, a push to main on its
reserved runners and the VM runners never do. A value equal to the
pool's labels means "no preference".
- Fallback: once a job asking for that label has waited more than 2
minutes, or has waited a minute while none of its jobs runs (the machine
looks offline or full), the job goes to the Linux jobs' runners (the
shared `self-hosted-ovis` pool, or wherever the Linux route sent them).
The counts come from the route's one Actions read (#4742), so no extra
API calls.
- The P620 also runs agent lanes and QA. When those keep it busy, its
label's queue grows and later runs move back to the pool by themselves.
A job already sent to the P620 waits for it: if the P620 goes offline
for long, set the variables back (below), as with
`CI_MAIN_SELF_HOSTED_LABELS` today. Jobs that ask for the machine's
label alone count toward its queue too.
- The cloud VM rule (`ovis-vm`) for `CI_FAST_SELF_HOSTED_LABELS` is
unchanged (no queue check there).

Merging changes no routing by itself: `CI_FAST_SELF_HOSTED_LABELS` is
`["self-hosted","self-hosted-ovis"]` today (the pool's own labels, which
the route treats as "no preference"),
`CI_INTEGRATION_SELF_HOSTED_LABELS` is unset, and only
`CI_HC_LIVE_LABELS` being unset moves herdr-core live contract to
hosted.

## Applying it after the merge (maintainer)

Nothing here touches the hosts' units or the repository variables. To
turn it on:

```sh
# 1. On the P620, give its pool runners a second label: in ovis-ci-runner.service's ExecStart,
#    --labels self-hosted-ovis  ->  --labels self-hosted-ovis,self-hosted-ovis-p620
#    (they still take every pool job), then when the slots are idle:
systemctl --user daemon-reload && systemctl --user restart ovis-ci-runner.service

# 2. Point Fast checks and Integration tests at it
gh variable set CI_FAST_SELF_HOSTED_LABELS --body '["self-hosted","self-hosted-ovis-p620"]'
gh variable set CI_INTEGRATION_SELF_HOSTED_LABELS --body '["self-hosted","self-hosted-ovis-p620"]'
```

HostHatch (fastest for the browser shards and the Rust PTY host) and
old-desktop need no change for this PR; a host gets a label the same way
(`--labels self-hosted-ovis,<its label>`) if a later variable is to
prefer it.

## Revert, without a PR

```sh
gh variable set CI_HC_LIVE_LABELS --body '["self-hosted","self-hosted-ovis"]'   # herdr-core live contract back on the pool
gh variable set CI_FAST_SELF_HOSTED_LABELS --body '["self-hosted","self-hosted-ovis"]'   # Fast checks: no preference (today's value)
gh variable delete CI_INTEGRATION_SELF_HOSTED_LABELS   # Integration tests: no preference
```

## What runs where

| Job | Before | After (variables as today) | After (P620 label set) |
| --- | --- | --- | --- |
| herdr-core live contract | self-hosted pool (LIGHT), fork hosted |
`ubuntu-24.04`; `CI_HC_LIVE_LABELS` moves it | same |
| Fast checks | Linux jobs' runners (or `CI_FAST_SELF_HOSTED_LABELS` on
`ovis-vm`) | unchanged | P620 while its queue is short, else the Linux
jobs' runners |
| Integration tests | Linux jobs' runners | unchanged | P620 while its
queue is short, else the Linux jobs' runners |
| any job, fork PR or `hosted_only` | hosted | hosted | hosted |

Required check names (Fast checks, Integration and browser, Native
Windows install, Hook kill tests (container)) and
`.github/workflows/hook-kill-tests.yml` are unchanged.

## Validation

- `bun test scripts/ci-runner-route.test.ts
scripts/light-runner-workflow.test.ts
scripts/privileged-jobs-workflow.test.ts
scripts/release-ci-reuse.test.ts
scripts/hook-kill-tests-workflow.test.ts
scripts/ci-browser-reach.test.ts`: 415 pass. New route tests: preference
while the queue is short, fallback after 2 minutes or with nothing
running (stale records ignored), reading past the run that settles the
Linux route, one Actions read for every route, API failure,
forks/hosted_only/other events read no API, no change while unset or
naming the pool, invalid values warn. New workflow tests: herdr-core
live contract's expression (fork guard first, hosted default, variable
override) and the `integration` output.
- `bun run check fast`: see the lane report for the head commit.
- Reviews: a gate review and a Codex adversarial review
(gpt-6.2-sol-fast, xhigh); findings and fixes are in the comments below.

Holds for the maintainer: a workflow and routing change.
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.

1 participant