Repository navigation
fix(ci): discovery pages REST and refuses a truncated repo set (#290) - #291
Conversation
`discover_repos` issued ONE `gh repo list --limit 1000` GraphQL listing. At this
org's size that is five requests, and its later pages returned 502/504
intermittently, so every org-wide script died at step zero:
HTTP 502: 502 Bad Gateway (https://api.github.com/graphql)
FATAL: discover_repos failed
Measured INTERLEAVED, so the variable was the request and not the minute:
`--limit 1000` answered 486 and then 502; `--limit 200` answered 200 on every
attempt; small GraphQL queries and REST paging answered normally throughout.
The org holds 486 repos (REST pages 100/100/100/100/86).
The fix removes the failure instead of absorbing it:
* `discover_all` pages REST at ONE named page size (`DISCOVERY_PAGE_SIZE`) and
emits `<name>\t<archived>\t<fork>\t<default_branch>`.
* `discover_repos`, `discover_excludes` and a new `discover_membership` filter
that single read, so the target set, the exclude set and org-ruleset's
membership arm cannot disagree about which repos exist.
* `org-ruleset.sh` no longer issues its own `--limit 1000` listing for the
membership arm; it uses the same discovery. That call was the same failing
shape, and it could fail on its own while the rest of verify succeeded.
TWO CONTROLS, and they are different controls:
1. `--paginate` returns non-zero if ANY page fails, so a page that 502s can
never be mistaken for the end of the org.
2. The discovered COUNT is checked against the org's own total
(`public_repos + total_private_repos`). A merely TRUNCATED successful
response would still read as a smaller org to every caller — the same class
as the `mapfile < <(fn)` trap the file already documents, where emptiness is
not a failure signal on its own. The check is one cheap request.
No retry: a retry would absorb the failure rather than remove it (R3).
Tests: the three mocks that stubbed `repo list` serve the REST shape now. The
org-ruleset mock is STATEFUL — its live ruleset mirrors what `apply` posted —
because discovery now serves the exclude set too, so a population with a
non-target row legitimately posts a non-empty exclude set. The exclude-set case
that had no independent failure path is replaced by the TRUNCATION case
(`DISCOVERY_TRUNCATE=1`), which is the assertion that fails without the count
check.
Agent: containerd-crabbox-program
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
Co-authored-by: Andreas Trawoeger <[email protected]>
Review — BLOCKHead SHA: Change class: CI tooling — org discovery helper ( Blocks
Non-blocking notes
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…missing Round 1 BLOCKed on two findings, and both were right. 1. The body claimed the three filters "filter that single read, so the target set, the exclude set and org-ruleset's membership arm cannot disagree about which repos exist". That is false: each filter calls discover_all as its own command substitution, and a bash command substitution runs in a subshell, so no memo survives between them. `org-ruleset.sh` therefore issues THREE paged listings per run and `reconcile-tag-on-merge-callers.sh` two, and the second can fail after the first succeeded. The body is corrected rather than the code being overclaimed; consolidating to one read per script touches six callers and is filed as #292 instead of being smuggled into this gate. 2. Because the body believed the excludes read could not fail independently, the round-1 diff DELETED the case that exercised the excludes abort. That abort is live (see 1), so deleting its coverage removed a real guard. Restored here as its own case, driven by a mock knob that fails ONLY the second discovery: `FORCE_SECOND_DISCOVERY_FAIL=1` lets the targets read pass and fails the excludes read, which is the only way to reach that call site. Mutation-proved, not assumed — with the excludes abort removed from org-ruleset.sh, the coverage goes red for exactly this reason: $ bash scripts/org-ruleset_test.sh FAIL: apply must abort when the EXCLUDES read fails after a successful targets read and green again with it restored. RCA, the missed control: I wrote a claim about the code's shape ("one read") without reading the call graph back — `discover_all` appeared once in each function, which LOOKS like sharing and is not, because the call site is a command substitution. The control that would have caught it is mechanical: after claiming a property across functions, grep the CALL SITES and count the round-trips. The second finding follows directly — a false structural claim made a live guard look unreachable. Agent: containerd-crabbox-program Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated) Co-authored-by: Andreas Trawoeger <[email protected]>
Round 1 — BLOCK answeredBoth findings were correct, and the second follows from the first. 1. A1/R1 — the "one read" claim was falseEach filter calls Corrected the body rather than overclaiming the code, and filed the consolidation as #292 (one read per script, filters as stdin transforms) because it moves six call sites and their coverage — not something to smuggle into this gate. 2. R1/CONC — a live guard was de-tested on that false premiseThe round-1 diff deleted the Mutation-proved: $ # mutation: drop the excludes abort from org-ruleset.sh
$ bash scripts/org-ruleset_test.sh
FAIL: apply must abort when the EXCLUDES read fails after a successful targets read
$ # restored
$ bash scripts/org-ruleset_test.sh
org-ruleset_test: all assertions passed (apply/verify/abort)RCA — the missed controlI wrote a claim about the code's SHAPE without reading the call graph back. The control that would have caught it is mechanical, and is now what I apply to any claim of this kind: after asserting a property across functions, grep the CALL SITES and count the round-trips. The body now states the multiplicity, the race, and the independent failure plainly. New head Agent: |
Review — BLOCKHead SHA: Change class: CI tooling — org discovery helper ( Comment dispositions
Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Review — BLOCKHead SHA: Change class: CI tooling — org discovery helper ( Security screen: PASS (no secrets/egress, no guardrail weakening — the change adds a count invariant; not the validator spec or rulebook; no maintainer sign-off required). Comment dispositions
Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Round 2 BLOCKed on a false comment that survived in lib-org.sh:
discover_membership — ... Same single discovery, so that arm cannot diverge
from (or independently flake behind) the target set.
That is the framing round 1 made me correct in the PR body and in
org-ruleset.sh, left behind in a third place. It is false for the same reason:
each filter calls discover_all as its OWN command substitution, a subshell cannot
memoise, so the membership read can diverge from the target set and can fail
behind a successful targets read.
Fixed in BOTH places the absence-grep found, not just the one the review quoted —
the org-ruleset_test.sh mock carried the same overstatement ("ONE read now serves
the target set, the exclude set AND the membership arm"):
$ git diff origin/main | grep '^+' | grep -inE \
'single (read|discovery)|one read|cannot (diverg|disagree|fail independently)'
+# three filters on ONE read per script is #292.
The one surviving match describes the FUTURE consolidation (#292) — it says what
one-read-per-script would fix, not that the current code does it.
RCA, the missed control: I fixed the false claim where the review pointed and in
one sibling comment, and never ran an ABSENCE check over the diff for the phrase
itself. A presence check catches a missing fix; only grepping for the retracted
string catches a leftover — the rule this programme has recorded more than once,
applied to prose I had just written. The control is now the command above, run
against the working tree (not the committed diff) before every push.
Agent: containerd-crabbox-program
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
Co-authored-by: Andreas Trawoeger <[email protected]>
Round 2 — BLOCK answeredOne finding, and it was the same false claim in a third place: Fixed where the review pointed and everywhere else the absence-grep found it, because the mock in $ git diff origin/main | grep '^+' | grep -inE \
'single (read|discovery)|one read|cannot (diverg|disagree|fail independently)'
+# three filters on ONE read per script is opencharly/.github#292.The one surviving match describes the future consolidation in #292 — what one read per script would fix — not the current code. The whole-tree sweep for the specific phrases returns nothing. RCA — the missed controlI fixed the claim where the review pointed and in one sibling comment, then stopped. I never ran an absence check over the diff for the phrase itself. A presence check catches a missing fix; only grepping for the retracted string catches a leftover — a rule this programme has recorded more than once, and I applied it to prose I had just written without applying it to the prose I had just written elsewhere. The control is now mechanical and is what produced this round: New head Agent: |
Review — BLOCKHead SHA: Change class: CI tooling — org discovery helper ( Security screen: PASS (no secrets/egress, no guardrail weakening — the change adds a count invariant; not the validator spec or rulebook; no maintainer sign-off required). Comment dispositions
Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
… does not have
Round 3 BLOCKed on a third comment-vs-code divergence: discover_all's header said
"the caller retries and gets a consistent pair". No caller retries - every call
site aborts on a non-zero status - and the PR body states the rule explicitly
("No retry anywhere"). Fixed to say what happens: the call site aborts, and a
re-run yields a consistent pair.
The same read-through found ONE more of the same class, which the review did not
quote: the membership failure case's comment in scripts/org-ruleset_test.sh said
the arm "shares lib-org.sh's ONE discovery with the target and exclude sets" -
the exact framing rounds 1-2 retired. It now states that each filter reads on its
own and that the knob fails every discovery in the run.
RCA, the missed control - and it is the third time in this PR: I kept sweeping
for a PHRASE LIST ("single read", "cannot diverge") instead of checking each
assertion against the code. A phrase list only finds what you already thought of;
the review found "retries" because it was not on my list. The control that
actually works, now applied here: list every ADDED comment line in the diff and
read each one against the code it describes.
Agent: containerd-crabbox-program
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
Co-authored-by: Andreas Trawoeger <[email protected]>
Round 3 — BLOCK answeredThe finding was right: The same read-through found one more of the same class that the review did not quote — the membership failure case's comment in RCA — the missed control, third time in this PRI kept sweeping a phrase list ( The control that actually works, and the one applied for this round: list every ADDED comment line in the diff and read each against the code it describes. $ git diff origin/main | grep '^+' | grep -E '^\+\s*#' | sed 's/^+//' | cat -nThat is how the second instance surfaced. Both are now truthful; head Body refreshed to this head — Agent: |
Review — PASSHead SHA: Change class: CI tooling — org discovery helper ( Security screen: PASS — no secrets/egress/encoded code; no guardrail weakening (the change ADDS a count invariant and fails loud); not the validator spec or rulebook; no maintainer sign-off required. Checklist: All applicable rules PASS or NA. Comment dispositions:
Every added comment line in the current diff was read against the code it describes; the surviving phrase in Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
One `charly task sync` wave in a worktree off origin/main 5e3dc00. One pin moved, and the new value equals the ref its leaf intent (`upstream:main`) names, re-read from the remote rather than inferred: dotgithub 3f1ad6cab29c5ba58ad13778e139f4f24da0fd2b -> 8c1d620fde767bf32b31d614f46463148644cd05 It moved because opencharly/.github merged the paged discovery fix (opencharly/.github#291, squash 38a0b65c30e1c30bbc6973653fc48d3c4e9d385e, tag v2026.313.1849) plus the CHANGELOG commit tag-on-merge writes above it, and `main` now serves 8c1d620fde76. R9: the binary that ran the wave and the gate was built IN this worktree (`charly/scripts/bootstrap-charly.sh`, created 20:09:17) from the tree's own charly checkout 68fc2a62 — the rebuild is the proof, because a CalVer stamp cannot establish binary==source on its own. The wave did not move the charly pin. Gate on the committed tree: charly task verify -> 48 step(s), 0 failed, 0 skipped (exit 0) currency -> 0 of 409 pin(s) NOT current [409 cur] grep -cE '^WARNING' -> 0 The gate ran with CHARLY_PLUGIN_ONLY=1, so the dev/worktree-build banner is absent by construction rather than argued away — the control the #958 round established. One gitlink staged, nothing else. No hand-pin. Agent: containerd-crabbox-program Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated) Co-authored-by: Andreas Trawoeger <[email protected]>
The count invariant I added in #291 was an equality, and a runner disproved it within hours: `.github` run 42770802075 (dispatch, mode=verify) died with discover_all: discovered 486 repo(s) but the org reports 485 — a page was TRUNCATED FATAL: discover_repos failed The listing was right and the invariant was wrong. `public_repos + total_private_repos` is not an exact census of what the listing serves — it lagged the listing by one — so equality turned a benign off-by-one into a hard failure of EVERY org-wide script, which is precisely the class of failure this control exists to prevent. The invariant is now stated in the direction the failure actually takes: * TRUNCATION removes repos, so `discovered < reported` is the failure — kept, and still aborts with the same message; * `discovered > reported` is not truncation and must not fail: the listing is the authoritative set and the count may lag it. Coverage, and it discriminates: a new case runs verify with the org count one BELOW the listing (`DISCOVERY_OVERCOUNT=1`) and requires it to succeed. Mutating the fix back to `-ne` makes that case fail with exactly its message; restored, the suite is green. $ bash scripts/org-ruleset_test.sh -> all assertions passed (apply/verify/abort) full offline suite -> 9/9 PASS RCA, the missed control: I wrote an invariant against a SECOND source (an org counter) as though it were an exact census, and the only evidence I had for that was one local run where the two happened to agree. An invariant must be stated in the direction its failure takes, and it must be tolerated where the second source is merely approximate — otherwise it fails on the benign case and blocks the very work it protects. Refs #292 Agent: containerd-crabbox-program Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated) Co-authored-by: Andreas Trawoeger <[email protected]>
Org-wide discovery no longer dies on a flaky multi-page listing: it pages REST at one named size and refuses a truncated repo set, so a partial read can never read as a smaller org. Measured live: the reconcile that failed four consecutive attempts at
FATAL: discover_repos failednow examines the whole org and exits 0.Summary
discover_reposissued onegh repo list --limit 1000GraphQL listing. At this org's size that is five requests, and its later pages returned 502/504 intermittently — so every org-wide script (org-ruleset.sh verify,reconcile-tag-on-merge-callers.sh, both retirement scripts,governance-reconcile.sh) aborted at step zero, before reading a single repo.Measured interleaved, so the variable was the request and not the minute:
The fix removes the failure instead of absorbing it:
discover_allpages REST at ONE named page size (DISCOVERY_PAGE_SIZE) and emits<name>\t<archived>\t<fork>\t<default_branch>.discover_repos,discover_excludesand a newdiscover_membershipfilter that read — each as its OWN paged, count-checked fetch, so no single read can understate the org. They are independent reads (a bash command substitution cannot memoise across calls), which means the second can fail after the first succeeded, and a repo created between two of them is in neither set.org-ruleset.shaborts on a failed exclude read and that path is covered below; collapsing the reads to one per script is#292, filed rather than folded into this gate.org-ruleset.shno longer issues its own--limit 1000listing for the membership arm; that call was the same failing shape and could fail alone while the rest ofverifysucceeded.Two controls, and they are different controls.
--paginatereturns non-zero if ANY page fails, so a 502 can never be mistaken for the end of the org. Then the discovered count is checked against the org's own total (public_repos + total_private_repos), because a merely truncated successful response would still read as a smaller org to every caller — the same class as themapfile < <(fn)trap the file already documents, where emptiness is not a failure signal on its own.No retry anywhere: a retry would absorb the failure rather than remove it (R3).
How tested
Offline, on the committed tree — every script of this repo's
workflow-checksgate that runs without network, each exit 0:The new control has a case that fails without it. The org-ruleset mock now serves
DISCOVERY_TRUNCATE=1, where the listing returns one row fewer than the org's own count — the shape a dropped page takes when it does not raise.applymust abort:Round 1 restored a guard I wrongly deleted. The first version of this body claimed the three filters "filter that single read", so the exclude read "cannot fail independently" — and on that false premise the diff removed the case that exercised the excludes abort. The reads ARE independent, that abort is live, and the case is back, driven by a mock knob that fails only the second discovery so the targets read passes first. It is mutation-proved: with the excludes abort removed from
org-ruleset.shthe coverage goes red with exactly its message, and green when restored.The mock also became stateful (its live ruleset mirrors what
applyposted), because discovery now serves the exclude set and a population with a non-target row legitimately posts a non-empty exclude set.Live, and this is the point of the change — the exact command that failed four times:
Before this change the same command produced
HTTP 502: 502 Bad Gateway (https://api.github.com/graphql)andFATAL: discover_repos failed, four attempts in a row. It now walks 431 repos and exits 0, and the population it reports is the input the#204rollout needs.Rulebook compliance
/charly-internals:repo-setupand/charly-internals:git-workfloware named by this repo's ownAGENTS.mdand were read; this repo'sAGENTS.mdsections onworkflow-checksand on the shared extraction were followed.#290's own, with the mechanism (page-size-dependent 502/504), the missed control (no classification of a provider error, and no count invariant), the blast radius (every org-wide script, and through them the#204rollout) and the root fix (paged REST + count check). No warning is left in any pasted output; nothing is parked.gh repo listnow name repo discovery, so the prose matches the product.repo listmock branches are deleted rather than left beside the new ones, and the stale "the other discovery call site" comment is replaced.git statusread first; work in a session worktree onfix/discovery-pagedofforigin/main3f1ad6c; no force-push, no rewrite, nothing of another session's touched.DISCOVERY_TRUNCATE=1aborts only because the count check exists, and the live run is the before/after of the same command (fourFATAL: discover_repos failedattempts, thenRC=0over 431 repos).disposable: truetarget applies to an org shell script; the change-class gate isworkflow-checks, run above, plus the required validator on this PR.Filed issues
opencharly/.github#292— the three filters issue one listing each rather than one per script, soorg-ruleset.shperforms three paged listings andreconcile-tag-on-merge-callers.shtwo, with a race window between them and an independent failure path that is handled rather than prevented. Consolidating to one read per script changes six call sites and their coverage, so it is its own change and not this gate.Change classification
CI tooling — the org's repo-discovery helper, one consumer script, and three test mocks. No product code, no schema, no workflow behaviour outside discovery.
Breaking change + rollback: none — the functions keep their names, their output (sorted repo names) and their failure semantics; a caller that checked the status still sees non-zero on failure. Rollback is reverting this branch, which restores the single
--limit 1000listing and with it the 502 abort.Closes #290
Agent:
containerd-crabbox-program· session8b1c01cf-7f79-4a75-bff8-240415a06208Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)