Skip to content

Commit e55e6db

Browse files
cliffhallclaude
andcommitted
fix: safer board recovery and card edits; owner-checked verify query
Address Copilot's first review round on #4899: - board-ops recovery step 1 now joins the broken dump to the snapshot and restores only cards that held the deleted option, listing any other blank card instead of overwriting it. - The add-card recipe chains its two item-edits so a failed Status edit stops before Priority and reports; the recovery loop stops on a failed edit. - Drop the Inspector's historical Done option ids from the recovery note; this skill holds no option ids. - issue-create's verify query matches the board's owner as well as its number, since project numbers are only unique per owner. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 7429ec5 commit e55e6db

2 files changed

Lines changed: 49 additions & 29 deletions

File tree

‎.claude/skills/board-ops/SKILL.md‎

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ STATUS_OPT=$(opt Status "Todo") # an issue you filed through the create fl
125125
PRIORITY_OPT=$(opt Priority "Medium")
126126

127127
if [ -n "$ITEM_ID" ] && [ -n "$STATUS_OPT" ] && [ -n "$PRIORITY_OPT" ]; then
128+
# Chained: a failed Status edit stops before Priority, and the failure shows.
128129
gh project item-edit --project-id PVT_kwDOCt2Azc4BcZgq --id "$ITEM_ID" \
129-
--field-id PVTSSF_lADOCt2Azc4BcZgqzhXCpm0 --single-select-option-id "$STATUS_OPT"
130-
gh project item-edit --project-id PVT_kwDOCt2Azc4BcZgq --id "$ITEM_ID" \
131-
--field-id PVTSSF_lADOCt2Azc4BcZgqzhjiM9M --single-select-option-id "$PRIORITY_OPT"
130+
--field-id PVTSSF_lADOCt2Azc4BcZgqzhXCpm0 --single-select-option-id "$STATUS_OPT" \
131+
&& gh project item-edit --project-id PVT_kwDOCt2Azc4BcZgq --id "$ITEM_ID" \
132+
--field-id PVTSSF_lADOCt2Azc4BcZgqzhjiM9M --single-select-option-id "$PRIORITY_OPT" \
133+
|| echo "item-edit FAILED — card $ITEM_ID may be half set; read it back" >&2
132134
else
133135
echo "missing item or option id — nothing edited" >&2
134136
fi
@@ -240,7 +242,10 @@ duplicate-of link).
240242

241243
This section and its two subsections are copied verbatim from the MCP
242244
Inspector's `board-ops`. Only the board number, the IDs, one cross-repo issue
243-
reference and one link to a skill this repo does not have were changed. The
245+
reference and one link to a skill this repo does not have were changed, plus
246+
two fixes to the recovery recipe from this repo's review: step 1 restores only
247+
cards that held the deleted option, and step 3 stops on a failed edit. The
248+
closing paragraph also no longer quotes the Inspector's option ids. The
244249
incidents they describe happened on the Inspector's board; the mechanism is
245250
GitHub's and applies to #43 unchanged. The option-id tables they mention are
246251
the Inspector's; here, option ids are resolved by name (see [IDs](#ids)), so
@@ -317,25 +322,36 @@ and pass the Priority field id `PVTSSF_lADOCt2Azc4BcZgqzhjiM9M`.
317322
# 0. Same temp dir the snapshot went to — keep every dump out of the worktree.
318323
BOARD_TMP=${BOARD_TMP:-$(mktemp -d)}
319324

320-
# 1. Which cards lost their value, and what did they hold? lost-ids.json is
321-
# kept ONLY when the dump is complete AND the snapshot reports what those cards
322-
# held — step 3 refuses to run without it, so neither a truncated dump nor a
323-
# missing snapshot can turn into a silent no-op or an unconfirmed re-apply.
325+
# 1. Which cards lost their value? lost-ids.json holds ONLY the cards that are
326+
# blank now AND held the deleted option in the snapshot, and it is written
327+
# only when both dumps are complete. A card that was already blank, or that
328+
# someone cleared by hand, is listed and left alone. Step 3 refuses to run
329+
# without the file, so neither a truncated dump nor a missing snapshot can
330+
# turn into a silent no-op or an unconfirmed re-apply.
331+
DELETED="<name of the deleted option>" # e.g. Done
324332
rm -f "$BOARD_TMP/lost-ids.json"
325333
gh project item-list 43 --owner modelcontextprotocol --format json --limit 2000 \
326334
> "$BOARD_TMP/board-broken.json"
327-
if jq -e '(.items | length) == .totalCount' "$BOARD_TMP/board-broken.json" >/dev/null; then
328-
jq -r '[.items[]|select(.status==null)|.id]' "$BOARD_TMP/board-broken.json" \
329-
> "$BOARD_TMP/lost-ids.json" || rm -f "$BOARD_TMP/lost-ids.json"
330-
jq -r --slurpfile L "$BOARD_TMP/lost-ids.json" '($L[0]) as $lost
331-
| [.items[] | select(.id as $i | $lost|index($i)) | .status // "(none)"]
332-
| group_by(.) | map({s:.[0],c:length}) | .[] | "was \(.s): \(.c)"' \
333-
"$BOARD_TMP/board-snapshot.json" \
334-
|| { echo "no usable snapshot — cannot confirm what these cards held; not re-applying" >&2
335-
rm -f "$BOARD_TMP/lost-ids.json"; }
336-
else
335+
if ! jq -e '(.items | length) == .totalCount' "$BOARD_TMP/board-broken.json" >/dev/null; then
337336
echo "board-broken.json INCOMPLETE — raise --limit and re-run step 1" >&2
338337
rm -f "$BOARD_TMP/board-broken.json"
338+
elif ! jq -e '(.items | length) == .totalCount' "$BOARD_TMP/board-snapshot.json" >/dev/null; then
339+
echo "no usable snapshot — cannot confirm what these cards held; not re-applying" >&2
340+
else
341+
jq -n --slurpfile B "$BOARD_TMP/board-broken.json" \
342+
--slurpfile S "$BOARD_TMP/board-snapshot.json" --arg d "$DELETED" '
343+
($S[0].items | map({key: .id, value: .status}) | from_entries) as $was
344+
| [$B[0].items[] | select(.status == null) | .id] as $blank
345+
| {lost: [$blank[] | select($was[.] == $d)],
346+
other: [$blank[] | select($was[.] != $d) | {id: ., was: ($was[.] // "(none)")}]}' \
347+
> "$BOARD_TMP/blank.json" || rm -f "$BOARD_TMP/blank.json"
348+
if [ -s "$BOARD_TMP/blank.json" ]; then
349+
jq -r --arg d "$DELETED" '"to restore to \($d): \(.lost | length)",
350+
"blank but NOT restored: \(.other | length)", (.other[] | " \(.id) was \(.was)")' \
351+
"$BOARD_TMP/blank.json"
352+
jq '.lost' "$BOARD_TMP/blank.json" > "$BOARD_TMP/lost-ids.json" \
353+
|| rm -f "$BOARD_TMP/lost-ids.json"
354+
fi
339355
fi
340356

341357
# 2. Recreate the option, echoing every surviving option's id (see above).
@@ -345,22 +361,24 @@ fi
345361
if [ -s "$BOARD_TMP/lost-ids.json" ]; then
346362
for id in $(jq -r '.[]' "$BOARD_TMP/lost-ids.json"); do
347363
gh project item-edit --project-id PVT_kwDOCt2Azc4BcZgq --id "$id" \
348-
--field-id PVTSSF_lADOCt2Azc4BcZgqzhXCpm0 --single-select-option-id <NEW_OPTION_ID>
364+
--field-id PVTSSF_lADOCt2Azc4BcZgqzhXCpm0 --single-select-option-id <NEW_OPTION_ID> \
365+
|| { echo "item-edit failed on $id — stopping; re-run step 1 to see what is left" >&2; break; }
349366
sleep 0.4
350367
done
351368
else
352369
echo "no lost-ids.json — step 1 did not complete; nothing re-applied" >&2
353370
fi
354371
```
355372

356-
Step 1's grouping is the safety check: confirm the orphaned set is exactly the
357-
cards that held the deleted option, so you don't overwrite a card someone
358-
legitimately moved in the meantime.
373+
Step 1's join is the safety check: only a card that held the deleted option in
374+
the snapshot is re-applied, so you don't overwrite a card that was already blank
375+
or that someone legitimately cleared in the meantime. Read its "NOT restored"
376+
list before running step 3.
359377

360-
Because the recreated option carries a **new id**, the tables above and every
361-
reference to it must be updated in the same change — `grep` the old id across
362-
the repo. The `Done` id has been `248a3910` and is now `259d6aab` for exactly
363-
this reason.
378+
Because the recreated option carries a **new id**, every reference to the old
379+
id must be updated in the same change — `grep` the old id across the repo. This
380+
skill resolves option ids by name and so holds none, but a script, issue or PR
381+
that pasted one does.
364382

365383
## ⚠️ Two different "Priority" fields
366384

‎.claude/skills/issue-create/SKILL.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,20 @@ N=<ISSUE_NUMBER>
158158
gh api graphql -F n="$N" -f query='query($n:Int!){
159159
repository(owner:"modelcontextprotocol",name:"servers"){issue(number:$n){
160160
number title milestone{title} labels(first:20){nodes{name}}
161-
projectItems(first:100){nodes{project{number}
161+
projectItems(first:100){nodes{project{number owner{... on Organization{login}}}
162162
fieldValues(first:20){nodes{... on ProjectV2ItemFieldSingleSelectValue{
163163
name field{... on ProjectV2SingleSelectField{name}}}}}}}}}}' \
164164
--jq '.data.repository.issue | {number, title, milestone: .milestone.title,
165165
labels: [.labels.nodes[].name],
166-
board: [.projectItems.nodes[] | select(.project.number==43)
166+
board: [.projectItems.nodes[]
167+
| select(.project.number==43 and .project.owner.login=="modelcontextprotocol")
167168
| [.fieldValues.nodes[] | select(.field) | {(.field.name): .name}] | add]}'
168169
```
169170

170171
The issue is created when `labels` holds `v2`, exactly one type and the scope
171172
label if one applies, `milestone` is set, and `board` holds exactly one entry
172-
with both a `Status` and a `Priority`.
173+
with both a `Status` and a `Priority`. The filter matches the board's owner as
174+
well as its number, because project numbers are only unique per owner.
173175

174176
## Issues that arrive from elsewhere
175177

0 commit comments

Comments
 (0)