Skip to content

Let ci-carry verify a rerun Actions attempt by reading its jobs in pages of 50 (GST-2215) - #4246

Merged
capy-ai[bot] merged 1 commit into
mainfrom
capy/ci-carry-reads-rerun-attempt-jobs-in-pages-gst-2215
Nov 9, 2026
Merged

capy-ai[bot] merged 1 commit into
mainfrom
capy/ci-carry-reads-rerun-attempt-jobs-in-pages-gst-2215

Conversation

@garrytan

@garrytan garrytan commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

gstack can again reuse a GitHub Actions run as test evidence after that run has been rerun, so a green rerun of a known flaky test no longer forces /ship to run the whole test suite again on the agent's machine. This serves the project goal of CI being the one full test run.

What changed

ghRunDeps.jobs: one 100-job page per request (502 past the proxy's ~10 s cutoff on rerun attempts) becomes 50 per page, with one whole-list reread at 25 after a 5xx

The job list for one run attempt is now read 50 jobs per page instead of 100, and a server error (5xx) rereads the whole list once at 25 per page.

Before/after as text: ghRunDeps.jobs: one 100-job page per request (502 past the proxy's ~10 s cutoff on rerun attempts) becomes 50 per page, with one whole-list reread at 25 after a 5xx
--- Before · before.txt · captured output
+++ After · after.txt · captured output
   return {
     run: id => json<ApiRun>(`repos/${repo}/actions/runs/${id}`),
     runsForHead: (workflow, sha) => all<ApiRun>(`repos/${repo}/actions/workflows/${workflow}/runs?head_sha=${sha}&per_page=100`, 'workflow_runs'),
+    // A long rerun attempt's 100-job page can outlast a proxy's ~10 s cutoff (GST-2215): read 50 per page, and after a 5xx read the whole list once more at 25. A failed page throws, so a partial list never counts.
+    jobs: (id, attempt) => {
+      const read = (n: number) => all<ApiJob>(`repos/${repo}/actions/runs/${id}/attempts/${attempt}/jobs?per_page=${n}`, 'jobs');
+      try { return read(50); } catch (e) { if (!/\bHTTP 5\d\d\b/.test((e as Error).message)) throw e; return read(25); }
+    },
-    jobs: (id, attempt) => all<ApiJob>(`repos/${repo}/actions/runs/${id}/attempts/${attempt}/jobs?per_page=100`, 'jobs'),
     artifact: (id, name) => {
 

Why

"gstack-ci-carry find returned no_verified_run: test: run <id>: api_error for any run whose newest attempt is a rerun" (gbrain #8940). On a rerun attempt GitHub took about 11 seconds to answer a 100-job page for gbrain's 86-job Test workflow, and the proxy that Capy machines reach GitHub through cuts requests off at about 10 seconds with a 502. Smaller pages answer well inside that limit, so a rerun attempt verifies again and its green CI result carries instead of the suite running locally.

Blast radius

Only the jobs read inside ghRunDeps (lib/run-evidence.ts:335-339) changes; every caller of ghRunDeps (gstack-ci-carry, gstack-pregate --from-run, scripts/ci-tree-reuse.ts) gets the same complete job list it got before, now in more pages. It stays safe because a failed page still makes gh exit non-zero, which throws, so a partial list never counts. The negative-control test walked that failure path, and a live read of gbrain run 42670157276 attempt 4 (the run that answered 502 before) returned all 86 jobs.

Summary

A rerun Actions attempt could not be verified as test evidence. Reading its job list 100 at a time timed out behind the proxy, so every rerun came back api_error and /ship fell back to the full local suite even after a green rerun of a flaky test. The jobs read now asks for 50 per page (gh follows every page) and, on a 5xx, rereads the whole list once at 25. A non-5xx error (a 404, say) does not retry, and any failed page still leaves the run unverified.

Test Coverage

All new code paths have test coverage. Three tests at the end of test/run-evidence.test.ts drive ghRunDeps(...).jobs through a stub gh on PATH that pages an attempt-2 list of 86 jobs and answers 502 past a page-size limit: 50 per page across every page, one 5xx retry at 25, and a negative control where page 2 fails (stays api_error after exactly one retry) plus a 404 that does not retry. They were red on f75ce6f and are green at this head.

Pre-Landing Review

No issues found by the core checklist or the batched specialist (testing, security, state machines, red team). The adversarial reader raised two notes below the blocking floor, listed under Review notes; the outside voice (openai/gpt-6.1-sol) returned CLEAN.

Gate edits: none detected (2 listed, 1 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Outside review: CLEAN (openai/gpt-6.1-sol, completed).

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL lib/run-evidence.ts:338 The 25-per-page retry fires only when gh's stderr carries 'HTTP 5xx'; with --jq, gh prints a JSON-parse error instead when a 5xx body is HTML, plain text or empty, so those 5xx answers skip the retry and stay api_error (fails closed, no regression)
  • INFORMATIONAL changelog.d/capy-ci-carry-reads-rerun-attempt-jobs-in-pages-gst-2215.md:4 Changelog says any server error (5xx) triggers the 25-per-page reread; per finding 1 that holds only when the 5xx body is JSON

Exploratory QA

Functional smoke, CLI surface, read-only against GitHub through the live proxy (budget 300 s, 3 captures):

  • Checkpoint 002: pass. ghRunDeps('garrytan/gbrain').jobs('42670157276', 4), the rerun attempt that answered 502 at 100 per page before this change, returned 86 of 86 jobs in 18.9 s.
  • Checkpoint 003: pass. A run id that does not exist (garrytan/gstack run 1) throws gh: Not Found (HTTP 404) in 0.6 s instead of yielding an empty or partial list.
  • Capture 001 failed on the probe script's own import path, not product code, and is superseded by 002 on the same inputs.
  • Limit: the retry count on a live 5xx is not observable without a failing proxy; the stub tests cover it.

Verdict: pass.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed — evals skipped.

Review bot comments

No review bot comments.

Scope Drift

Scope Check: CLEAN
Intent: let ci-carry verify a run whose newest attempt is a rerun (GST-2215).
Delivered: the jobs read pages at 50 with one 5xx retry at 25, three tests and a changelog fragment.

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Bug fix, exempt from the plan step.

Verification Results

No plan-specific verification items (bug fix, no plan). Automatic diff-scoped QA above: 2 PASS, 0 FAIL, 0 BLOCKED, 0 NOT RUN.

TODOS

No TODO items completed in this PR.

Documentation

Scope: the diff from f75ce6f to the branch head: lib/run-evidence.ts (the jobs reader for rerun attempts), test/run-evidence.test.ts, and the changelog.d fragment for GST-2215. The working tree had no staged, unstaged or new files. I also searched docs/ and the root Markdown files for mentions of api_error, per_page and job lists.

Result: current. The page size is an internal detail that no user-facing doc describes. docs/pregate.md and docs/troubleshooting.md describe api_error as gh failing to read the run, and that still holds, because a page that fails after the retry still leaves the run unverified. The changelog fragment covers the user-visible effect.

Debt: none found.

Test plan

  • bun run test: carried from CI run 42696117285/1 at this exact tree (1655 test files, 0 failed).
  • bun test test/run-evidence.test.ts test/ci-carry.test.ts test/spawnsync-timeout-tripwire.test.ts test/module-size-ratchet.test.ts test/changelog-fragments.test.ts, bun run typecheck, bun run typecheck:test: green before /ship on this tree.

Tests ran: test 1655

Agent notes

Refs GST-2215 (from gbrain #8940, GBRA-405).

REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=0 fixed=0 scope=frozen ledgers_read=2 dispatches=1
Gate edits: none detected (2 listed, 1 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Retry stderr shape (Captain ruling): the 25-per-page retry fires only on HTTP 5xx in gh's stderr. A 5xx with an HTML or empty body comes through --jq as a JSON-parse error, so it does not retry and fails closed to api_error. The Captain ruled this correct; the retry will not be widened.

Approvals

No approvals recorded for branch capy/ci-carry-reads-rerun-attempt-jobs-in-pages-gst-2215.
Plan: exempt: bug fix (R65)
Plan check: exempt bug fix

{
  "schema_version": 1,
  "pr": 4246,
  "head": "fabcd4395b6c042231f9c9d57a9a28da6b958a6c",
  "version": "1.98.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1655,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 42696117285,
      "attempt": 1,
      "tree": "0c9d9e8d0b108641c631ebc7fc13253ea026a2c7"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "0c9d9e8d0b108641c631ebc7fc13253ea026a2c7",
  "product_patch_id": "59adba19b094b7a628e630e8be2d332779a33de8",
  "gstack_version": "1.98.0.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 6,
    "rules": "66e5174161eecc2c",
    "base": "f75ce6fdcc14e6398b00645c1608e834d766a922",
    "registry": "f75ce6fdcc14e6398b00645c1608e834d766a922",
    "gate_scan": {
      "tagged": 0,
      "head": "fabcd4395b6c042231f9c9d57a9a28da6b958a6c"
    },
    "reasons": [
      "runtime=6"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @0c9d9e8d0b10 (8 checks, current for fabcd4395b6c)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42696117285/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=0c9d9e8d0b10 tests=36881 skipped=68 runs=42696117285/1 profiles=ci-reuse/free-tests heads=fabcd4395b6c verified=2026-11-09T21:28:26.373Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "lib/run-evidence.ts jobs reader, its test and changelog fragment; docs/, README.md, AGENTS.md and CLAUDE.md searched; docs/pregate.md and docs/troubleshooting.md read"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 0,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 2,
    "dispatches": {
      "specialist": 1
    }
  }
}

…ges of 50 (GST-2215)

A rerun attempt's 100-job page took GitHub ~11 s for gbrain's 86-job Test runs, past the git proxy's ~10 s cutoff, so every rerun failed verification with api_error. Read 50 per page and, after a 5xx, reread the whole list once at 25. Any failed page still throws, so a partial job list never counts.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai
capy-ai Bot marked this pull request as ready for review November 9, 2026 21:30
@capy-ai
capy-ai Bot merged commit a58e6e2 into main Nov 9, 2026
53 of 54 checks passed
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