Skip to content

fix(ci-gate): unavailable API is pending, never failure; check-run join; re-run start; sweep outage stop - #191

Merged
hyperpolymath merged 1 commit into
mainfrom
claude/ci-gate-unavailable-pending
Nov 30, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
claude/ci-gate-unavailable-pending

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Ports the four parts of the closed #148 that main still lacked, onto main's own REST layer (scripts/ci-gate-api.sh, from #169). There is no second library. The owner chose this route on 2026-11-30.

Why

On 2026-11-30 a scheduled sweep from main (run 46407496788, gate at 47616cb) posted CI / gate = failure, "ci-gate: could not read the jobs of run 45935619420", on a commit whose required checks had all passed. A read that main gave up on went to die() and wrote failure. That is the false red from hyperpolymath/resource-algebra#50.

Change

  1. An unavailable API is pending, never failure.
    • api_request and api_list return 0 (ok), 1 (real error) or 2 (unavailable).
    • Unavailable means: 429 or a rate-limit 403 past the budget, any 5xx, no answer, or a cut-off 2xx.
    • The publisher's unavailable() posts pending ("GitHub API rate-limited or unavailable; re-evaluating later"), writes unavailable=true and exits 75. The workflow's failure fallback skips when either step reports unavailable.
    • Real errors still fail closed: a permissions 403, a 404, a malformed body, and a missing or non-numeric total_count.
  2. A snapshot by two reads.
    • One paginated check-runs?filter=latest read, joined to the runs on the check suite (new profiles/ci-gate/join-checks.jq), replaces the per-run jobs reads. Third-party suites match nothing.
    • The snapshot is incomplete, and so pending, if total_count exceeds the items read, if there are 1000 or more runs, or if the check runs span 1000 or more distinct suites.
    • checks: read is added to the reusable, both callers and the template.
  3. Re-run start.
    • The callers keep types: [completed, in_progress] and ci-gate: spend fewer API calls per evaluation #179's explicit workflow list. The job if: admits in_progress only when run_attempt > 1.
    • An admitted start writes one deduplicated pending and does not evaluate. completed evaluates in full.
  4. The sweep stops on an outage.
    • Its own three reads now go through the REST layer.
    • An unavailable read, or a child exiting 75, stops it at once. It stays red and names the heads it did not evaluate.
    • It says "pending not confirmed" unless the pending was written or GitHub refused it.

Census: billed REST requests per gate job (tests/ci-gate-api-budget.sh)

Scenario main 47616cb This PR
4 runs, settled 6 4
required run active 6 4
22 workflows, settled 24 4
348 runs on the head 9 7

Tests

Run locally on 605103c with Go yq v4.44.3:

Suite Before (47616cb) After
tests/ci-gate.sh 695 / 0 830 / 0
tests/ci-gate-api.sh 96 / 0 130 / 0
tests/ci-gate-tamper-guard.sh 159 / 0 159 / 0
tests/ci-gate-caller.sh 200 / 0 200 / 0
  • The budget bench reports "after <= before in every scenario".
  • shellcheck 0.10.0 finds nothing new.
  • actionlint 1.7.7 is clean on ci-gate.yml, the suite caller and the template.
  • Mutation check: with fix 1 reverted, 74 tests fail.
  • The mutation helpers in three test files used python3. They are now Perl, so no Python runs in validation.

Behaviour changes and limits

  • A 5xx or no answer is not retried. It gives pending and exit 75 at once, where main wrote an immediate false failure.

  • A first-attempt in_progress no longer writes pending, so a standing success on that commit stays until completed evaluates.

  • Not verified live:

    • that run_attempt is set on workflow_run events;
    • that in_progress is delivered for re-runs;
    • that the check-run check_suite.id matches the run's check_suite_id.

    After merge, re-run one required workflow and check that CI / gate turns pending at the re-run's start.

  • This PR overlaps claude/ci-gate-fold-guard (folding the tamper guard into the verdict). It was agreed that whichever merges second merges main and resolves the conflicts, and that neither pushes to the other's branch.

  • Consumer re-pins wait for both PRs and are regenerated with feat(ci-gate): caller render and drift-check script #167's tool.


Generated by Claude Code

…in; re-run start; sweep outage stop

Ports the behaviour of the closed #148 onto main's single REST layer
(scripts/ci-gate-api.sh); no second library.

1. Unavailable is not failure. api_request/api_list return 2 for an
   unavailable answer (429 or a rate-limit 403 past the attempts or the
   budget, a 5xx, no answer, a truncated transfer) and 1 for a real error.
   The publisher writes pending ("GitHub API rate-limited or unavailable;
   re-evaluating later") and exits 75 instead of "could not read the jobs of
   run N" = failure (run 46407496788, 2026-11-30). If the pending cannot be
   written either it says "pending not confirmed" or "pending refused" and
   still writes no failure. The workflow's failure fallback stays silent
   after unavailable=true (publisher or early step). A permissions 403, a
   404, a malformed body and a missing total_count still fail closed.
2. Snapshot by the two-read join: one paginated
   commits/{sha}/check-runs?filter=latest joined to the runs on
   check_suite.id == check_suite_id (profiles/ci-gate/join-checks.jq)
   replaces one jobs read per run (22 workflows: 24 -> 4 billed reads). A
   snapshot with total_count above the items read, 1000 or more runs, or
   check runs of 1000 or more suites is incomplete: pending, never a
   missing-check verdict. checks: read added to the reusable, both callers
   and the template.
3. Re-run start: the caller job admits workflow_run in_progress only for
   run_attempt > 1; an admitted in_progress writes ONE deduplicated pending
   ("a required workflow is re-running; re-evaluating on completion") and
   evaluates nothing (no list, no check-run read). completed is unchanged.
4. The sweep reads the default branch, its head and the pull request list
   through the REST layer and stops at once on an unavailable read or a
   publisher exit 75: it stays red, names the heads not evaluated, and says
   "pending not confirmed" unless the pending was written or GitHub rejected
   it.

Tests: tests/ci-gate.sh, tests/ci-gate-api.sh, tests/ci-gate-api-budget.sh
(census), fake gh with check-runs, 5xx, no-answer and listing endpoints. The
mutation helpers of the three ci-gate test files now use perl, not python
(estate language policy).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDixLBHyVxqpp8crrsi
@gitnotebooks

gitnotebooks Bot commented Nov 30, 2026

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ec3b5750-8393-43a1-bd7d-3d5650d8dbc3
Commits

Reviewing files that changed from the base of the PR and between 47616cb and 605103c.

Files selected for processing: 13

  • .github/workflows/ci-gate-caller.yml
  • .github/workflows/ci-gate.yml
  • docs/CI-GATE.adoc
  • profiles/ci-gate/join-checks.jq
  • scripts/ci-gate-api.sh
  • scripts/ci-gate-publish.sh
  • scripts/ci-gate-sweep.sh
  • templates/ci-gate-caller.yml
  • tests/ci-gate-api-budget.sh
  • tests/ci-gate-api.sh
  • tests/ci-gate-tamper-guard.sh
  • tests/ci-gate.sh
  • tests/fixtures/ci-gate/workflow-runs.json
  • 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

@sonarqubecloud

Copy link
Copy Markdown

Copy link
Copy Markdown
Owner Author

CI/gate-tamper-guard is failing by design. This PR changes gate files (the reusable, the callers, the template, the gate scripts and profiles/ci-gate/join-checks.jq), so the guard blocks it until an admin applies the label gate-change-approved after the newest commit. Agents never apply that label, so this needs the repository owner. Nothing in the code needs fixing for this check.


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-30T16:37:37.733889Z
We couldn’t complete this review. Comment @codex review to try again.
605103c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@hyperpolymath
hyperpolymath merged commit 2bcb46f into main Nov 30, 2026
37 of 38 checks passed
@hyperpolymath
hyperpolymath deleted the claude/ci-gate-unavailable-pending branch November 30, 2026 16:38
hyperpolymath added a commit that referenced this pull request Nov 30, 2026
## What

S1 of the W49 CI programme (design: #189, section 6.1): a read-only
evidence extractor.

- `scripts/pr-evidence.sh OWNER/REPO PR` writes one replayable evidence
record (`proven/pr-evidence/v1`) for a pull request: head, base-tip,
merge-base and nearest-completed-base observations per required context,
workflow runs (including zero-job and `startup_failure`), masked failure
signatures (strong or weak), mergeability, reviews, ruleset and profile
required set, superseded inputs. It derives no verdict.
- `docs/design/pr-verdict/evidence.schema.json` and
`scripts/json-schema-lite.jq` (schema validator for the subset used; no
Python, no new dependency).
- `tests/pr-evidence.sh` (added to `tests/unit.list`): fake-`gh`
controls.

## Evidence

| Check | Result |
|---|---|
| `bash tests/pr-evidence.sh` | 27 groups ok |
| `bash tests/unit.sh` | 27 tests run, 0 failed |
| `bash tests/smoke.sh` | passed |
| `bash tests/inspect-pr-ci.sh` | ok (unchanged) |
| Live: extractor on open PRs #188, #189, #190, #191 of this repository
| rc 0, all four schema-valid, 0 violations |
| Live: #188 | `mergeable_state: blocked`, `changes_requested: true`,
all 12 required contexts Pass (matches the NEEDS-REVIEW reading in #189)
|
| Live: #190, #191 | touch gate files (7 each, reported in
`touches_gate_files`); one required context Pending |
| `shellcheck` | NOT RUN (not installable in this session) |
| Live validation on 3 other fixture repos | NOT RUN: `add_repo` was
refused for cicd-squabbler and proven-tests-and-benches; reported to the
hub |

## Findings for the design owner

1. **Strong signature is ambiguous in 3.2.** "a non-empty annotation
message" counts `Process completed with exit code 1.`, which every
failed step emits, so any two red checks would have "equal strong
signatures" and be treated as inherited (breaks property 3 / 3.8).
Implemented: boilerplate (`exit code N`, `The operation was canceled`)
is never an identity. Please confirm.
2. **Review-thread resolution needs GraphQL.** Unavailable from agent
sessions; recorded as `null` plus the reason, never as zero. The
verdict's NEEDS-REVIEW arm on unresolved threads cannot fire from such a
record.
3. **Producer map (Appendix A step 9) is not computed by the
extractor**; `--producers FILE` accepts it, and profile entries give a
producer workflow for their own contexts. Without it `Phantom` and
`TriggerGap` are not derivable from the record. Follow-up work package.

## Not in this PR

S2 fixtures follow as a separate PR. No gate file, ruleset or workflow
is touched.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01J4QvDjgxz1iRFdu63KxE1K

**Update:** signature strength now follows 7208a2e (complete
failing-test set: reported count n > 0 and exactly n identities;
annotations alone weak); `failed_count` and `pull.owner_acts` added to
the schema; tests 28 groups ok. Finding 1 above is superseded by that
revision.

---
_Generated by [Claude Code](https://claude.ai/code)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants