Skip to content

fix(work-items): back off on a failed renew PATCH near expiry and hand back only after a supersede - #16509

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-16505-43808009046-1
Nov 16, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-16505-43808009046-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #16505

Summary

Opened by the work-resolve-issue lane. The run's own summary:

The GitHub adapter's renew-lease now runs its back-off when the PATCH fails and the clock read after it is at or past the old expiry or within the 300 s margin, since GitHub may have applied it; earlier than the margin it still exits with the PATCH's error. The back-off tries its supersede twice and hands the assignee back only after one succeeded, so a lease it could not supersede keeps its holder assigned. CONTRACT.md "Lease protocol" now states the three-session same-login limit (a holder left unassigned, the lease still excluding other workers), drops the claim that one session always sees the other's write, and describes the rollback after a failed list and release's exit-0 paths as the code behaves. Design choice: the failed PATCH is run in a subshell around the existing wit_patch_lease_comment so its mapped exit code and stderr stay unchanged and the lease marker format keeps one writer; within the margin a failed PATCH backs off unconditionally, as the issue's done-when asks, so an auth or 404 failure there now exits 7 with the gh error on stderr.

Not verified

  • lease-coordination.test.sh was not executed: this lane's Bash runs only the named wrappers, so the suite is left to the PR's CI.
  • Tidy pass 5 (ai-slop:audit fix) ran its rubric by hand only: detect.sh and digest-guard.sh are not among the lane's runnable wrappers, so the deterministic detector and guarded fix flow did not run.
  • Review finding outside this issue's scope, not changed: claim.sh _wit_claim_abort (claim.sh:137-139) runs the rollback hand-back even when its own supersede failed, so after a failed step-4 list read it can remove the login while its lease is still live; the common.sh hand-back comment's 'every…
  • Two of the new test cases (after-expiry back-off with a same-login winner, failed PATCH far from expiry) also pass on the old code: they cover the done-when case and guard against regression rather than demonstrate the fix.

Fix

  • plugins/work-items/tools/work-item-tracker/adapters/github/renew-lease.sh: back_off defined before the PATCH; it retries the supersede once and hands back only after a supersede succeeded; a failed PATCH at or past the old expiry or within the skew margin runs back_off, else exits with the PATCH's…
  • plugins/work-items/tools/work-item-tracker/adapters/github/common.sh: wit_try_supersede_lease_comment returns 1 on a failed edit instead of always 0 (callers in claim.sh and wit_lease_released_by_run ignore it); hand-back comment notes the three-session limit.
  • plugins/work-items/tools/work-item-tracker/adapters/github/release.sh: comment says which exit-0 paths hand back.
  • plugins/work-items/tools/work-item-tracker/adapters/github/lease-coordination.test.sh: gh stub gains patch-lost-<n> (fails unapplied) and patch-fails-<n> (lands, reports failure); new cases for the after-expiry back-off with a same-login winner keeping the login, a failed renew PATCH…
  • plugins/work-items/tools/work-item-tracker/CONTRACT.md: "Lease protocol" renew paragraph covers the failed PATCH and supersede retry; claim step 4 states the three-session known limit; release and ambiguous-lease-post text match the code (tidied in the tidy pass).
  • .changes/work-items/work-resolve-issue-issue-16505-43808009046-1-2621e153.md: patch changelog fragment for work-items.

Verification

The runner ran each check from the base copy against 9205848:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • .lane/checks/bin/check-changelog-fragments: all 1 fragment valid (run before and after tidy).
  • .lane/checks/bin/check-changed-skills: no changed skills, nothing to gate (run before and after tidy).
  • .lane/checks/bin/check-affected: 15 passed, 6 skipped, 0 failed over 6 changed files (run before and after tidy).
  • .lane/verify/bin/cant-fail-scan (whole repo): exit 0, no finding in any changed file.
  • Fresh-context review subagent over the whole diff: no correctness bugs; traced each new test against the gh and date stubs and confirmed the failed-PATCH-after-expiry, failed-PATCH-within-margin, supersede-fails-twice and supersede-fails-once cases fail on the pre-change code.
  • Tidy (code-tidying:tidy-diff): passes 1-3 found nothing to change; pass 4 removed a restated clause in CONTRACT.md's release paragraph; pass 5 manual rubric read and em-dash grep found nothing.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43808009046

Left out: the items under Not verified.

Related

#16505

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 9205848f96df756caa896644fff9e09441160357: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #16509

I found no security issues in this pull request.

Scope. I read every hunk of all 6 changed files in .claude-lane/pr.diff:

  • the changelog fragment
  • CONTRACT.md
  • common.sh
  • lease-coordination.test.sh
  • release.sh
  • renew-lease.sh

None of them matches a trusted-path glob, and none is a trust control, merge hold, token or kill-switch surface, or plugin manifest.

What I checked:

  • Lease supersede return value (common.sh). wit_try_supersede_lease_comment now returns 1 when its edit fails. Every adapter script runs under set -uo pipefail with errexit off. So the callers that ignore the result (claim.sh:138, common.sh:489) are not cut short.
  • Renew PATCH subshell (renew-lease.sh). The subshell around the renew PATCH only captures its exit status. It adds no new input path. All interpolated values (owner, repo, comment id, lease JSON) are passed as quoted arguments to gh/jq, so there is no command or argument injection.
  • Back-off behaviour. The new back-off keeps a login assigned when the supersede fails, and hands it back only after a supersede succeeds. This is availability and coordination behaviour inside one login's sessions. It grants no actor or token anything new, and it exposes no secret.
  • Test stub. The new patch-lost-<n> / patch-fails-<n> files in the test stub live only in the test's own temp directory.
  • Instruction text. The CONTRACT.md and comment edits describe the code as it behaves. They remove no rule that guarded a protected action.

PR context. The description contains no instructions aimed at this review lane.

Prior findings. This lane had not reviewed an earlier head, so this is a full review, not a blocking-only one.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 9205848f96df756caa896644fff9e09441160357: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read the whole diff for all 6 changed files. I also read the unchanged code the changed lines call:

  • renew-lease.sh in full
  • in common.sh: wit_run_gh, wit_patch_lease_comment, wit_try_supersede_lease_comment and its callers, and wit_hand_back_assignee
  • release.sh
  • in claim.sh: _wit_claim_abort
  • the test's gh and date stubs

None of the 6 changed files is under the trusted paths.

Checked against #16505's "Done when" list

  • Three-session limit stated in CONTRACT.md: met. The "Lease protocol" claim step 4 now names the limit and drops the claim that one session always sees the other's write. common.sh says the same.
  • Renew backs off when its PATCH fails near or past expiry: met. renew-lease.sh:103-108 runs the PATCH in a subshell, so wit_run_gh's exit no longer skips the check. At or past the old expiry, or within the 300 s margin before it, it calls back_off; earlier, it exits with the PATCH's mapped code. Tests: "PATCH lands but reports failure, after expiry" and "PATCH fails within the margin". Both fail on the old code, where the PATCH exited before any back-off.
  • Supersede retried once, hand-back only after a success: met. wit_try_supersede_lease_comment now returns the PATCH's status. I checked its other two callers: claim.sh:138 ignores the status and common.sh:489 is followed by a printf, so neither changes behaviour under set -uo pipefail. Tests: "supersede fails twice" (3 PATCHes, alice kept) and "fails once".
  • Contract wording for the rollback after a failed list and for release's exit-0 paths: met. I compared the new text with release.sh:80-86 (another login's superseded lease exits 0 with no write) and with common.sh:515-518 (the re-list re-adds the assignee).
  • Same-login winner keeps the login after an after-expiry back-off: met, by the new "renew lands after expiry, same-login winner" case.

I traced the new test cases by hand against the stub's PATCH counter (patch-lost-<n>, patch-fails-<n>) and the clock file. I did not run them: this lane has no shell. The author says the PR's CI covers the suite and that the CI checks passed; I have not verified either.

Behaviour change, stated in the PR: a PATCH that fails within the margin for any reason (auth, 404) now exits 7 instead of the mapped gh error. This is what the issue's "Done when" asks for. No finding.

No plugin manifest changed. Nothing in this change spends API credit or can incur a charge. No embedded instructions were found in the PR context or the prior-findings file.

Verifier dropped 0 of 0 candidates.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 9205848f96df756caa896644fff9e09441160357, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 9205848

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-16509-9205848f96df756caa896644fff9e09441160357, expires on 2026-12-16.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Merge-Risk: max=MEDIUM demote=false head=9205848f96df756caa896644fff9e09441160357 rubric=9.5.3 rater=claude-opus-5-5 checker=claude-opus-5-5

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit b63abe5 Nov 16, 2026
50 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-16505-43808009046-1 branch November 16, 2026 05:41
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit b63abe5105310ff445a62c4abc88fa577325874f; later checks count it verified from this comment.

kyle-sexton added a commit that referenced this pull request Nov 16, 2026
…very rule holding

The model follows the hand-back's clock read before each lease list and
the outranked release that supersedes its own lease and hands back only
after a supersede succeeded (#16515), and renew's back-off on a failed
PATCH near expiry (#16509). Line citations are at a548b3a. Both
shipped cfgs hold every rule; the known results list the breaks left
under each failure flag.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

work-items GitHub adapter: renew back-off gaps and contract wording found after the lease fix merged

0 participants