Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .github/workflows/gate-topology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,21 @@ jobs:
- if: steps.have.outputs.ok
env: {GH_TOKEN: "${{ github.token }}", CLAW_TOKEN: "${{ steps.tok.outputs.token }}", R: "${{ github.repository }}"}
run: |
printf '#include "gen/c/claw/refresh.c"\n#include <stdio.h>\n#include <stdlib.h>\nint main(void){size_t k=1<<22,n;uint8_t*b=malloc(k),*o=malloc(k);n=fread(b,1,k,stdin);if(n==k)return 3;size_t m=refresh_plan(b,n,o,k);if(m>k)return 4;fwrite(o,1,m,stdout);return 0;}\n' | cc -O1 -w -I . -x c -o /tmp/feed -
list() { gh api graphql --paginate -F owner="${R%/*}" -F name="${R#*/}" -f query='query($owner:String!,$name:String!,$endCursor:String){repository(owner:$owner,name:$name){pullRequests(states:OPEN,first:100,after:$endCursor,orderBy:{field:CREATED_AT,direction:ASC}){pageInfo{hasNextPage endCursor} nodes{number headRefOid createdAt isDraft isCrossRepository maintainerCanModify mergeable mergeStateStatus baseRefName headRepository{nameWithOwner} labels(first:50){nodes{name}}}}}}' --jq '.data.repository.pullRequests.nodes[]|[.number,.headRefOid,.createdAt,.isDraft,([.labels.nodes[].name]|join(",")),.isCrossRepository,(.headRepository.nameWithOwner//""),.maintainerCanModify,.mergeable,.mergeStateStatus,.baseRefName]|@tsv'; }
printf '#include "gen/c/claw/refresh.c"\n#include <stdio.h>\n#include <stdlib.h>\nint main(int c,char**v){size_t k=1<<22,n;uint8_t*b=malloc(k),*o=malloc(k);n=fread(b,1,k,stdin);if(n==k)return 3;size_t m=refresh_plan(b,n,o,k,atoi(v[1]));if(m>k)return 4;fwrite(o,1,m,stdout);return 0;}\n' | cc -O1 -w -I . -x c -o /tmp/feed -
skip() { echo "::warning::claw/refresh $1"; echo "claw/refresh updated nothing: $1" >> "$GITHUB_STEP_SUMMARY"; exit 0; }
# Pages stay small (a page of 100 PRs with 50 labels each came back as HTML). A failed page fails the jq step: try three times, keep nothing of a failed try.
list() { for t in 1 2 3; do gh api graphql --paginate -F owner="${R%/*}" -F name="${R#*/}" -f query='query($owner:String!,$name:String!,$endCursor:String){repository(owner:$owner,name:$name){pullRequests(states:OPEN,first:30,after:$endCursor,orderBy:{field:CREATED_AT,direction:ASC}){pageInfo{hasNextPage endCursor} nodes{number headRefOid createdAt isDraft isCrossRepository maintainerCanModify mergeable mergeStateStatus baseRefName headRepository{nameWithOwner} autoMergeRequest{enabledAt} labels(first:10){nodes{name}}}}}}' --jq '.data.repository.pullRequests.nodes[]|[.number,.headRefOid,.createdAt,.isDraft,([.labels.nodes[].name]|join(",")),.isCrossRepository,(.headRepository.nameWithOwner//""),.maintainerCanModify,.mergeable,.mergeStateStatus,.baseRefName,(.autoMergeRequest!=null)]|@tsv' > /tmp/page 2>/dev/null </dev/null && cat /tmp/page && return 0; sleep $((t * 10)); done; return 1; }
# GitHub computes mergeability lazily after a push: ask once, wait, ask again.
list > /dev/null
sleep 30
list > /tmp/prs.tsv
list > /dev/null || :; sleep 30
list > /tmp/prs.tsv || skip "the pull request listing failed three times, so no plan was made."
# Every update-branch starts about 26 workflows: refresh.t27 decides from the queued-run count, and an unread count is -1.
q=$(gh api "repos/$R/actions/runs?status=queued&per_page=1" -q .total_count 2>/dev/null </dev/null) || q=-1; case "$q" in ''|*[!0-9]*) q=-1;; esac
# Copy the facts; behind_by is the one thing the listing lacks (the ruleset is not strict, so no PR is ever reported BEHIND).
while IFS= read -r line; do
sha=$(printf '%s' "$line" | cut -f2); base=$(printf '%s' "$line" | cut -f11)
bh=$(gh api "repos/$R/compare/$base...$sha" -q .behind_by 2>/dev/null </dev/null) || bh=-
printf '%s\t%s\n' "$(printf '%s' "$line" | cut -f1-10)" "${bh:--}"
done < /tmp/prs.tsv | /tmp/feed > /tmp/plan || { echo "::warning::claw/refresh could not build a plan"; exit 0; }
printf '%s\t%s\t%s\n' "$(printf '%s' "$line" | cut -f1-10)" "${bh:--}" "$(printf '%s' "$line" | cut -f12)"
done < /tmp/prs.tsv | /tmp/feed "$q" > /tmp/plan || skip "could not build a plan."
while IFS=$'\t' read -r k a b; do
case "$k" in
R) if err=$(GH_TOKEN="$CLAW_TOKEN" gh api -X PUT "repos/$R/pulls/$a/update-branch" -f expected_head_sha="$b" 2>&1 </dev/null); then echo "claw/refresh: #$a updated"; else echo "::warning::claw/refresh could not update #$a: $err"; fi; sleep 1;;
Expand Down
18 changes: 9 additions & 9 deletions .trinity/seals/claw_ClawRefresh.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
}
],
"config": "gen=c,rust,verilog,zig;tests=zig",
"gen_hash_c": "sha256:1bc4f958fdddeb6935166a07e1059847cf77d92180371bfb85a7565ff6ce7495",
"gen_hash_rust": "sha256:6eac58459c46d6cd03c0ec4863738bf57d2be61ea794c729ff1405e6c6e66dbf",
"gen_hash_verilog": "sha256:a4fdfa74eaa36dba431047d9ac95c10df830c734aa0e8fdf01c89d7c79102e13",
"gen_hash_zig": "sha256:5479058d720ae4e923921aa3d03d2ce5c3cea5b97204827c562d265b851dca52",
"gen_hash_c": "sha256:72a325030bde8ec8d9e8f93dc4369bbda169c8cf5a0ee8574f8c45b458402cd6",
"gen_hash_rust": "sha256:be392415c5fc220525e579f6f3d356af59cfe33261b855a341caa2876600d011",
"gen_hash_verilog": "sha256:e1c484b82ebaaa7c1cd80fa93a556b525a9a8eb1872a96a572335fcf1aa2234d",
"gen_hash_zig": "sha256:2f3ea1e66fd00ef18cacdb8e43609d51ce82ef3606a07a71913a252141501a1f",
"module": "ClawRefresh",
"ring": 12,
"seal_schema": 2,
"sealed_at": "2026-10-18T14:05:32Z",
"sealed_at": "2026-10-18T17:02:21Z",
"sealed_by": "t27c-bootstrap@0.5.2",
"spec_hash": "sha256:924b8dd3d4093d1315a6bbc6c769cc63a4074c1910bdd8a2cfa9ab605a65d458",
"spec_hash": "sha256:9cbda0935680c5bf4dd24d9b68931b99d5e184339b3438399a647710eebb3cef",
"spec_path": "specs/claw/refresh.t27",
"tests": {
"failed": 0,
"failing": [],
"forced": false,
"passed": 44,
"total": 44,
"passed": 54,
"total": 54,
"vacuous": 0
},
"toolchain": {
"test_runner": "sha256:1982ae948e24d00c5d221ccec12dfce1eb01204b53e37b0f857f93b16d64629d",
"test_runner": "sha256:8512b80da533b79289110fca4a65f3336abd7a059ca4b72ea595d5e33ff8ad10",
"zig": "0.16.0"
}
}
Loading
Loading