Skip to content

fix: correct skill bugs and close the Docker lock race - #9

Merged
stasadev merged 1 commit into
mainfrom
20261029_stasadev_skill_review_fixes
Oct 29, 2026
Merged

stasadev merged 1 commit into
mainfrom
20261029_stasadev_skill_review_fixes

Conversation

@stasadev

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

Fixes steps in all four skills that fail or give a wrong result, and makes the shared Docker lock safe when several sessions wait for an expired lock.

The Issue

A review of the skills found these problems:

  • /ddev:ci-failure checks the PR author with gh pr view --json authorAssociation, a field that gh doesn't have.
  • failed-job.sh reads an /attempts/N URL as job N. It stops at a job without a log, such as one whose runner was lost. It also fails on older gh, which doesn't know --allow-escape-sequences.
  • /ddev:work finds no conflicting PRs once the changes are uncommitted, because the file list is empty.
  • /ddev:commit cuts comments after the passing check run, which it says must be the last change.
  • /ddev:review fetches from upstream before it says to use origin without one.
  • Lock labels such as pr-12 don't name the repository. Two sessions on PR 12 of different repositories both hold the lock.
  • The lock deletes an expired lock after it reads it. Two waiting sessions can both take it then. In a test with six sessions on an expired lock, two held it in 1 of 40 rounds.

How This PR Solves The Issue

The lock is now a directory of numbered files. The highest number holds <holder> <since>, and - means free. Every change writes the next number with ln, which fails when the file exists. So when sessions see the same free or expired lock, only one of them gets it. No session deletes the highest number, and a broken lock file stops the script with an error.

The scripts also got simpler. failed-job.sh reads all jobs of a run in one request, and the Buildkite history in one GraphQL query instead of 17 requests. mentions.sh no longer reads marked-as-duplicate events, because DDEV closes duplicates with a reason, which the script already shows.

Review drafts now go through check-message.sh --body, so the review and commit skills share one list of words to avoid.

Manual Testing Instructions

Load the skills from this branch:

claude --plugin-dir ./plugins/ddev

Read a failed attempt of a run whose runner was lost:

plugins/ddev/skills/ci-failure/failed-job.sh https://github.com/ddev/ddev/actions/runs/40808535160/attempts/1
# Expect the job "wsl2-nat-testpkg / WSL2 (nat, testpkg)", the annotation "The hosted runner lost communication with the server", "no log; gh printed why", and the job's history

Start six sessions on an expired lock:

export REVIEW_LOCK=$HOME/tmp/lock-test
mkdir -p "$REVIEW_LOCK" && echo "stale 0" > "$REVIEW_LOCK/1"
for i in 1 2 3 4 5 6; do plugins/ddev/skills/review/review-lock.sh acquire "s$i" & done
# Expect "expired: stale" and one "acquired:" line, and five "waiting for:" lines
kill $(jobs -p); rm -r "$REVIEW_LOCK"; unset REVIEW_LOCK

Automated Testing Overview

Claude Code ran shellcheck and claude plugin validate . on Linux. Claude Code also ran the changed scripts on Linux, under bash 5 and under bash 3.2 with BusyBox tools:

  • failed-job.sh on ddev/ddev runs, a job URL, an attempt URL and a Buildkite build, with gh 2.72 and 2.102
  • mentions.sh and pr-context.sh on a ddev/ddev PR, with the same output as before
  • check-message.sh on three messages in both modes, with the same output as before
  • the lock: 350 rounds of six sessions on an expired lock with one holder each, 6 workers that each acquire and release 40 times with no overlap, a session that recreates a removed number, and four kinds of broken lock file

Nobody tested on macOS or in Git Bash.

Release/Deployment Notes

The lock moved to ~/tmp/.ddev-docker-lock. Until every session updates the plugin, sessions on an older version use ~/tmp/.ddev-review.lock and don't wait for this version.

🤖 Developed with assistance from Claude Code

## Short Summary (TL;DR)

Fixes steps in all four skills that fail or give a wrong result, and makes the shared Docker lock safe when several sessions wait for an expired lock.

## The Issue

A review of the skills found these problems:

- `/ddev:ci-failure` checks the PR author with `gh pr view --json authorAssociation`, a field that gh doesn't have.
- `failed-job.sh` reads an `/attempts/N` URL as job N. It stops at a job without a log, such as one whose runner was lost. It also fails on older gh, which doesn't know `--allow-escape-sequences`.
- `/ddev:work` finds no conflicting PRs once the changes are uncommitted, because the file list is empty.
- `/ddev:commit` cuts comments after the passing check run, which it says must be the last change.
- `/ddev:review` fetches from `upstream` before it says to use `origin` without one.
- Lock labels such as `pr-12` don't name the repository. Two sessions on PR 12 of different repositories both hold the lock.
- The lock deletes an expired lock after it reads it. Two waiting sessions can both take it then. In a test with six sessions on an expired lock, two held it in 1 of 40 rounds.

## How This PR Solves The Issue

The lock is now a directory of numbered files. The highest number holds `<holder> <since>`, and `-` means free. Every change writes the next number with `ln`, which fails when the file exists. So when sessions see the same free or expired lock, only one of them gets it. No session deletes the highest number, and a broken lock file stops the script with an error.

The scripts also got simpler. `failed-job.sh` reads all jobs of a run in one request, and the Buildkite history in one GraphQL query instead of 17 requests. `mentions.sh` no longer reads marked-as-duplicate events, because DDEV closes duplicates with a reason, which the script already shows.

Review drafts now go through `check-message.sh --body`, so the review and commit skills share one list of words to avoid.

## Manual Testing Instructions

Load the skills from this branch:

```bash
claude --plugin-dir ./plugins/ddev
```

Read a failed attempt of a run whose runner was lost:

```bash
plugins/ddev/skills/ci-failure/failed-job.sh https://github.com/ddev/ddev/actions/runs/40808535160/attempts/1
# Expect the job "wsl2-nat-testpkg / WSL2 (nat, testpkg)", the annotation "The hosted runner lost communication with the server", "no log; gh printed why", and the job's history
```

Start six sessions on an expired lock:

```bash
export REVIEW_LOCK=$HOME/tmp/lock-test
mkdir -p "$REVIEW_LOCK" && echo "stale 0" > "$REVIEW_LOCK/1"
for i in 1 2 3 4 5 6; do plugins/ddev/skills/review/review-lock.sh acquire "s$i" & done
# Expect "expired: stale" and one "acquired:" line, and five "waiting for:" lines
kill $(jobs -p); rm -r "$REVIEW_LOCK"; unset REVIEW_LOCK
```

## Automated Testing Overview

Claude Code ran `shellcheck` and `claude plugin validate .` on Linux. Claude Code also ran the changed scripts on Linux, under bash 5 and under bash 3.2 with BusyBox tools:

- `failed-job.sh` on ddev/ddev runs, a job URL, an attempt URL and a Buildkite build, with gh 2.72 and 2.102
- `mentions.sh` and `pr-context.sh` on a ddev/ddev PR, with the same output as before
- `check-message.sh` on three messages in both modes, with the same output as before
- the lock: 350 rounds of six sessions on an expired lock with one holder each, 6 workers that each acquire and release 40 times with no overlap, a session that recreates a removed number, and four kinds of broken lock file

Nobody tested on macOS or in Git Bash.

## Release/Deployment Notes

The lock moved to `~/tmp/.ddev-docker-lock`. Until every session updates the plugin, sessions on an older version use `~/tmp/.ddev-review.lock` and don't wait for this version.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@stasadev
stasadev merged commit 7b1e8d0 into main Oct 29, 2026
1 check passed
@stasadev
stasadev deleted the 20261029_stasadev_skill_review_fixes branch October 29, 2026 14:56
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.

1 participant