Skip to content

running-in-ci: skill-edit recipe should use worktree under $TMPDIR - #328

Merged
max-sixty merged 2 commits into
mainfrom
hourly/review-24927430320
Apr 25, 2026
Merged

max-sixty merged 2 commits into
mainfrom
hourly/review-24927430320

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Summary

Update the running-in-ci "How to propose" recipe so a bot updating .claude/skills/ can actually write to disk. The current recipe (cd .claude && mv /tmp/... SKILL.md) satisfies the Claude Code harness write-guard (anthropics/claude-code#37157) but fails the read-only bind-mount the sandbox places on .claude/. Mirror the pattern review-runs already documents: do the edit, commit, and push from a git worktree under $TMPDIR. Both restrictions are now explained inline so a future reader knows why the worktree is mandatory.

Why

worktrunk-bot hit this in worktrunk run 24926120125 (a tend-mention session triggered by an explicit maintainer instruction to update repo skill guidance). The bot followed the bundled recipe, hit mv: ... Read-only file system, retried with cp (same error), retried with touch (same error), then ad-libbed git hash-object -w plus git update-index --cacheinfo to write the blob and stage it directly to the index — a workaround that left the working tree showing the file as modified after the fact. ~7 wasted bash cycles before producing worktrunk PR #2415.

worktrunk-bot followed the new bundled-skill-defect flow (introduced in #324 yesterday) and opened permission-request issue max-sixty/worktrunk#2416 on the consumer side. This PR is the corresponding tend-side fix surfaced by review-reviewers rather than waiting on the permission round-trip — the diagnosis is unambiguous and the fix is small.

What changes

The "Draft a minimal edit" step (step 3 of "How to propose"):

  • Drops the cd .claude && mv /tmp/... SKILL.md recipe that fails on the read-only mount.
  • Adds the same prose review-runs already carries explaining (a) the read-only bind-mount of .claude/ and (b) the harness write-guard from claude-code#37157, so a reader sees both barriers and why a worktree clears both.
  • Replaces the recipe with the git worktree add "$TMPDIR/skill-fix" pattern, parameterised on <topic>-$GITHUB_RUN_ID for the branch name.
  • Keeps the existing TODO referencing claude-code#37157.

The frontmatter snippet is moved up so the recipe sits at the bottom of step 3 with no interleaving.

Test plan

  • Eaten own dogfood: this PR's branch was authored from a worktree at $TMPDIR/skill-fix using exactly the recipe being landed; commit and push worked end-to-end. Worktree under $TMPDIR is writable, no Read-only file system errors.
  • CI on this PR passes (actionlint, ruff, typos, uv-lock).
  • Visual diff vs review-runs SKILL.md prose to confirm the two skills now agree on the recipe shape.

Independent of #327 (different concern in the same file: external-tool verification, lines ~498 — no overlap with this edit at lines ~568).

The 'How to propose' recipe ran 'cd .claude && mv /tmp/... SKILL.md', which
satisfies the harness write-guard but fails the read-only bind-mount the
sandbox places on .claude/. tend-mention sessions hit 'Read-only file system'
and ad-libbed unsafe workarounds.

Mirror the pattern review-runs already documents: do the edit, commit, and
push from a git worktree under $TMPDIR. Both restrictions (read-only mount
and harness write-guard) are now explained inline so a future reader knows
why the worktree is mandatory.

Triggered by max-sixty/worktrunk#2416 (worktrunk-bot's permission-request
issue) and worktrunk run 24926120125.
@tend-agent tend-agent added the claude-behavior Behavioral issues found by review-reviewers label Apr 25, 2026

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous recipe used mkdir -p skills/running-tend so the same shape worked for both editing an existing skill and creating a new one. The new recipe drops that, but step 3 still contemplates new-skill creation (the YAML frontmatter snippet immediately above). For a brand-new skill, cd "$TMPDIR/skill-fix/.claude/skills/<new>" fails with "No such file or directory". Inline suggestion to restore the mkdir -p.

Note this gap also exists in review-runs/SKILL.md, but that skill is purely an editing flow so it's defensible there.


# Use the Write tool to author the new skill file to /tmp/running-tend-new.md.
# Then move it into place from inside the worktree:
cd "$TMPDIR/skill-fix/.claude/skills/running-tend" && mv /tmp/running-tend-new.md SKILL.md

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cd "$TMPDIR/skill-fix/.claude/skills/running-tend" && mv /tmp/running-tend-new.md SKILL.md
mkdir -p "$TMPDIR/skill-fix/.claude/skills/running-tend"
cd "$TMPDIR/skill-fix/.claude/skills/running-tend" && mv /tmp/running-tend-new.md SKILL.md

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — pushed fd3f7a6 with mkdir -p "$TMPDIR/skill-fix/.claude/skills/running-tend" before the cd. The worktree mirrors HEAD, so for a brand-new skill the directory genuinely doesn't exist and the bare cd fails. The dogfood test plan only exercised the existing-skill path, which is why this slipped through.

The previous recipe used `mkdir -p skills/running-tend` so the same shape
worked for both editing an existing skill and creating a new one. The
worktree rewrite dropped that, but step 3 still contemplates new-skill
creation (the YAML frontmatter snippet immediately above). For a new
skill, `cd "$TMPDIR/skill-fix/.claude/skills/<new>"` fails with "No such
file or directory" because the worktree mirrors HEAD, where the directory
doesn't exist yet.

Restore `mkdir -p` before the `cd`.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner

did we test whether this approach works?

@tend-agent

Copy link
Copy Markdown
Collaborator Author

Yes — re-verified in this session by running the recipe end-to-end against this checkout:

git worktree add "$TMPDIR/skill-test" -b test/dogfood-recipe HEAD
mkdir -p "$TMPDIR/skill-test/.claude/skills/test-new"
cd "$TMPDIR/skill-test/.claude/skills/test-new" && mv /tmp/.../content.md SKILL.md
cd "$TMPDIR/skill-test" && git add .claude/skills/test-new/SKILL.md && git commit -m ...

All four steps succeeded: worktree create, mkdir -p, mv of a Write-authored file from /tmp/claude/, and git add + git commit of the new .claude/skills/test-new/SKILL.md. No Read-only file system errors, and no harness write-guard denials. The two restrictions the prose now describes — .claude/ bind-mount and the claude-code#37157 argument-text guard — both clear cleanly when the path is rewritten to $TMPDIR/skill-test/.claude/skills/....

Skipped git push (test branch only); the surrounding flow is the same one review-runs already ships and uses in production.

Limitation: I can't independently verify the PR-description claim that 02a28bc and fd3f7a6 were originally authored from a worktree — git doesn't record which working tree a commit came from — but the commits exist on this branch and the mechanical steps reproduce.

@max-sixty
max-sixty merged commit db28862 into main Apr 25, 2026
5 checks passed
@max-sixty
max-sixty deleted the hourly/review-24927430320 branch April 25, 2026 22:46
max-sixty pushed a commit that referenced this pull request Apr 26, 2026
## Summary

Extend the CI-polling helper's exclusion filter so it also drops check
runs whose `workflowName` matches `$GITHUB_WORKFLOW`. Without this, a
`tend-mention` session that pushes a commit or replies to an inline
review comment ends up polling for its own queued sibling — a deadlock
that only the 15-min cap breaks.

## Why

Run
[24927643947](https://github.com/max-sixty/tend/actions/runs/24927643947)
(`tend-mention` on PR
[#328](#328)) ran 18 minutes /
$1.16 — about 4× the cost of an equivalent fix-and-reply session. The
session log shows ~3 minutes of productive work followed by 15 minutes
of polling that never converged, with the bot logging:

> CI still running after 15 minutes
> ...
> handle tend-mention PENDING

The PENDING `handle` job belonged to a *sibling* `tend-mention` run
[24927689625](https://github.com/max-sixty/tend/actions/runs/24927689625),
triggered by the bot's own reply to the inline review comment via `POST
/pulls/{n}/comments/{id}/replies`. `tend-mention.yaml`'s handle job uses
concurrency group `tend-mention-handle-{PR#}` with `cancel-in-progress:
false`, which queued the sibling behind the current run. Result: the
sibling waited for the current run to finish; the current run's polling
waited for the sibling's `handle` to start — a guaranteed deadlock until
the 15-min timer expired.

Verified the chain:

- 09:19:50Z — `tend-mention` 24927643947 started (review submission with
inline comment).
- 09:21Z — bot pushed `fd3f7a6` and posted reply via the `/replies`
endpoint.
- 09:22:23Z — `tend-mention` 24927689625 created (`pull_request_review`
event, queued by concurrency group).
- 09:22:29Z — `ci` for the new commit completed.
- 09:23:55Z — `tend-review` 24927685808 completed.
- 09:23Z onwards — only thing left non-terminal in the rollup was
sibling 24927689625's `handle` job.
- 09:37:59Z — current run timed out after 15 minutes of polling.
- 09:39:10Z — sibling 24927689625 finally ran (4 turns, silent
self-conversation exit, $0.30) once the concurrency lock cleared.

The sibling's `verify` job (no concurrency) ran promptly and was
COMPLETED by ~09:23, so it didn't gate polling. Only the queued `handle`
job did.

`tend-mention.yaml` already documents (lines ~17–28) that GitHub fires
both `pull_request_review` and `pull_request_review_comment` for every
newly-created inline comment, and the workflow correctly avoids the
duplicate by *not* subscribing to `pull_request_review_comment.created`.
The remaining `pull_request_review.submitted` subscription is the
trigger for the sibling, and silencing that would drop legitimate user
follow-up reviews. The proportionate fix is at the polling helper.

## Fix

Add a same-workflow filter to `pending()` in
`plugins/tend-ci-runner/skills/running-in-ci/SKILL.md`:

```jq
| select((.workflowName // "") != $wf)
```

with `$wf = $GITHUB_WORKFLOW`. Same-workflow check runs are subject to
concurrency rules (queueing for `cancel-in-progress: false` workflows
like `tend-mention`, or cancelled-on-supersede for `cancel-in-progress:
true` workflows like `tend-review`) and don't represent independent CI
signals. For `cancel-in-progress: true` workflows, the filter is a no-op
— older siblings are cancelled and already not in IN_PROGRESS state. The
fix is targeted to the deadlock case while remaining benign elsewhere.

The accompanying comment block explains the failure mode in-place so a
future reader doesn't re-derive it from the symptom.

## Gate assessment

- **Evidence level**: Critical — 1 occurrence sufficient. Concrete cost
($1.46 across the deadlocked pair), reproducible from the workflow's
documented event-firing behavior plus its handle-job concurrency group.
Same-condition runs are guaranteed to repeat the failure.
- **Classification**: Structural. The deadlock is not a model decision —
it's a deterministic consequence of two GitHub Actions properties (event
firing on bot replies; serialized concurrency group with
`cancel-in-progress: false`).
- **Change type**: Targeted (one extra `jq` filter line + comment).
Normal evidence bar; passes.
- **Both gates**: pass.

## Test plan

- [ ] CI on this PR passes (lint, test).
- [ ] Next time `tend-mention` replies to an inline review comment +
polls CI on the same PR, the polling helper exits within 1–2 minutes
after non-mention checks complete (rather than timing out at 15 min).

Co-authored-by: tend-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-behavior Behavioral issues found by review-reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants