diff --git a/.claude/skills/board-ops/SKILL.md b/.claude/skills/board-ops/SKILL.md index bb75edece9..bd6c9a87bc 100644 --- a/.claude/skills/board-ops/SKILL.md +++ b/.claude/skills/board-ops/SKILL.md @@ -114,6 +114,41 @@ about the board's size; don't make the recipes depend on it being right. file, an incomplete dump is deleted, so that step fails on the missing file rather than running on partial data. +### One listing per batch + +The whole-board listing is the costliest read these recipes make (about 50 +GraphQL points), so **a batch takes it once and every lookup in the batch +reads that one result**, as `AGENTS.md` **Pacing GitHub calls** says. Never +re-list per item, and never re-list to test whether a refusal has lifted. + +```sh +# board_list → BOARD holds the complete listing, or is empty and the call fails. +board_list() { + BOARD=$(gh project item-list 43 --owner modelcontextprotocol --format json --limit 2000) || BOARD= + jq -e '(.items | length) == .totalCount' <<<"$BOARD" >/dev/null 2>&1 \ + || { echo "item-list incomplete or failed — raise --limit; not concluding anything" >&2 + BOARD=; return 1; } +} + +# issue_item → the item id of this repo's issue N in BOARD, or nothing. +# Arguments reach jq through --args, never as shell positional parameters (#5160). +issue_item() { + jq -r '($ARGS.positional[0] | tonumber) as $n | .items[] + | select(.content.type=="Issue" and .content.repository=="modelcontextprotocol/servers" + and .content.number==$n) | .id' --args "$@" <<<"$BOARD" +} + +board_list # once, at the start of the batch +``` + +Every lookup below that needs the listing runs `[ -n "$BOARD" ] || board_list` +first, so it reuses a listing it is given and fetches only when there is none. +A listing is a snapshot: it holds no card added after it was taken, so take a +fresh one for the next batch, not for the next item. For a batch of issues, +`issue_item` replaces the per-issue lookup in +[Move an existing card](#move-an-existing-card); for one issue, that lookup is +cheaper than a listing. + ## Recipes Every recipe below assumes `FIELDS` and `opt` from [IDs](#ids) are defined in @@ -263,20 +298,22 @@ finds the follow-up. ⚠️ **A draft card has no repository and no issue number**, so the issue-side lookup above cannot find one. Look it up by its **bracketed GHSA id** in the -full listing, checked for truncation, then feed that item id to `item-edit` or -`item-delete` exactly as usual: +complete listing from [One listing per batch](#one-listing-per-batch), then +feed that item id to `item-edit` or `item-delete` exactly as usual. Over +several advisories, run this block once per GHSA against the same `BOARD`: ```sh GHSA=GHSA-xxxx-yyyy-zzzz # the advisory's real id ITEM_ID= # never let an earlier lookup's id survive a failed one LOOKED= # set only by a lookup over a COMPLETE listing -BOARD=$(gh project item-list 43 --owner modelcontextprotocol --format json --limit 2000) -if jq -e '(.items | length) == .totalCount' <<<"$BOARD" >/dev/null; then +[ -n "$BOARD" ] || board_list # reuse the batch's listing; fetch only if there is none +# Re-check what was handed in: a BOARD from another recipe may be truncated. +if jq -e '(.items | length) == .totalCount' <<<"$BOARD" >/dev/null 2>&1; then ITEM_ID=$(jq -r --arg p "[$GHSA]" '.items[] | select(.content.type=="DraftIssue") | select(.content.title | startswith($p)) | .id' <<<"$BOARD") && LOOKED=1 [ -n "$ITEM_ID" ] || echo "no draft card titled [$GHSA] on #43" >&2 else - echo "item-list incomplete or failed — raise --limit; not concluding anything" >&2 + echo "BOARD incomplete or failed — run board_list again; not concluding anything" >&2 fi ``` @@ -299,6 +336,10 @@ fi # Then the two chained item-edit calls from "Add a card and set its fields". ``` +A card this creates is not in `BOARD`, which predates it, so a batch never +runs the lookup and create a second time for the same GHSA against one +listing: it would find nothing and create a duplicate. + **Convert** it to an issue when its fix is ready to merge, keeping its opaque title; a follow-up card converts only after the advisory is **published**. When each happens, and what the issue gets, is the `/security-advisory` flow. The web @@ -315,6 +356,64 @@ REPO_ID=$(gh api repos/modelcontextprotocol/servers --jq .node_id) || REPO_ID= The card keeps its place and its field values; the new issue takes the card's title and body. +## When GraphQL is exhausted: the REST endpoints + +The GraphQL quota is per account, so concurrent sessions can exhaust it +together (`AGENTS.md` **Pacing GitHub calls**). Then every `gh project` +command fails with `unknown owner type`, because its first owner lookup is +refused. Confirm it before doing anything else: + +```sh +gh api rate_limit --jq '.resources | {graphql, core}' +``` + +Projects v2 also has REST endpoints, which draw on the separate **core** +quota. They cover listing the fields and items, adding an issue, and setting +Status or Priority, under the same pacing. They do **not** cover editing a +draft card's body, which still needs GraphQL. REST uses **numeric** ids for +fields and items, not the `PVTSSF_…` / `PVTI_…` node ids above; option ids are +the same short ids `opt` returns. + +```sh +P=/orgs/modelcontextprotocol/projectsV2/43 +RFIELDS=$(gh api "$P/fields") || RFIELDS= # once per session, like FIELDS +# rfield → its numeric REST id; ropt