Skip to content

fix(dispatcher): own lock removal is not a session ending; sync-only by file name - #232

Merged
Ardnived merged 7 commits into
mainfrom
claude/audit-fixes
Nov 1, 2026
Merged

Ardnived merged 7 commits into
mainfrom
claude/audit-fixes

Conversation

@Ardnived

@Ardnived Ardnived commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Dispatcher fixes from a workspace-wide audit, plus three the adversarial review on this PR added. Every commit touches only dispatcher/*.mjs, its tests and docs/why.md: no skill, ceiling or loop-config.json change. They ship together because they are small and come from one review. Each commit is one behaviour and can be reverted on its own. The owner approved the first four behaviour changes; the last three answer the critic.

⚠ The dispatcher runs on the next event in all five repos once merged.

What changes

Commit Failure it prevents
fix(dispatcher) the dispatcher's own lock removal is not a session ending The dispatcher's own lock removal (made with the PAT) came back as an unlock target. (1) A failed fire removed the lock, the unlock re-targeted the pending verb at once, and it looped while the routines were paused. Each lap posted a comment and spent the shared PAT budget, and maxAttempts never bounded a dying session. (2) A timeout retry removed the lock, fired attempt 2 and relocked; the queued unlock then archived attempt 2 as done. Now unlock is a note when the item is relocked or a fire waits on its retry (pending, not lease-refused: a refused fire's real unlock must still run). reconcile no longer routes a leftover recheck into that guard ahead of the pending retry.
fix(dispatcher) a contract sync is sync-only when every file is a copy It compared the changed-file count to the copy-path count, so a sync PR plus a fix-ci edit under src/ skipped the critic and armed auto-merge. gather now lists files for a bot PR on the sync branch only.
refactor(dispatcher) drop the inline count no review ever carried inlineCounts was built and never read, so r.inline_count > 0 could never be true. An inline-only review is already caught as an unresolved thread; a new test pins that.
refactor(dispatcher) drop sweep-retry and sweep-recheck Nothing emits either reason. The real retry path is reconcile.
fix(dispatcher) an unreadable file list is not a sync (2ee7199) isContractSyncOnly returned files.every(…), and [].every is true. A bot PR on the sync branch whose file list came back empty therefore read as sync-only: the critic was skipped and auto-merge armed on a diff nobody had seen. The count rule it replaced failed closed there, through changed_files ?? Infinity. An empty or absent list now decides nothing.
refactor(dispatcher) one changed-paths helper, two callers (668f51e) gather re-implemented the paginated listFiles + previous_filename pair contracts.mjs already had. Two copies of one fetch give the sync rule two places to drift: a rename handled in one and dropped in the other makes the same PR sync-only in the plan and reviewable in gather. changedPaths is now exported beside the rule it feeds.
fix(dispatcher) an inline-only review on a member's PR wakes the loop (435b065) The thread loop skipped every thread a human rooted on a member's PR, not just the author's own. A second member whose whole ask lives in inline comments therefore woke nothing: their review body is empty, so the review loop passed too, and inline_count never covered it either — it was always 0, which is why dropping it above is no regression. The review loop already excludes only the author (decide.mjs:278); the thread loop now matches it, and why.md says the same.

Tests

  • node --test dispatcher/test/*.test.mjs: 354 pass, 0 fail.
  • node --test workflow/lib/*.test.mjs: 97 pass. claude plugin validate ./workflow --strict: pass.
  • The new unlock test fails without the guard, and separately fails without the reconcile change.
  • The contract test fails against the old count rule; the empty-list assertion fails without the new guard; the inline-only test fails without the thread-loop change.
  • /security-review over the branch: no findings. No new sink, command, write or secret, and the one widened filter still requires an assignment.respondTo login to wake a session.

Not yet run: a supervised BOT_DISPATCH=dry dispatch.

Sibling PRs (same audit)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjVsjvVCH8xpZboAzZn

Ardnived and others added 4 commits October 31, 2026 10:23
…nding

The lock label comes off with the PAT, so the dispatcher's own removal
wakes workflow-state.yml as an `unlock` too. Two of those were read as a
session finishing:

- A failed fire removes the lock and leaves its handler pending. The
  unlock then re-targeted the pending verb at once, so while routines are
  paused it fired again every lap, posting a new comment each time, and
  maxAttempts never bounded it.
- A timeout removes the lock, fires attempt 2 and relocks. The queued
  unlock then marked attempt 2 done and released its lease, and the
  sweep later reported exhaustion while it ran.

`unlock` now does nothing when the item is locked again, or when a
failed fire is pending. A lease refusal's pending is excluded: there the
unlock is the holding session ending, and `unlocked` must still clear it
and release the lease.

`reconcile` routed a leftover recheck into `unlock` before it looked at
the pending retry, so with the guard that retry would never run. It now
skips that route for the dispatcher's own unlock and reaches the retry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`isContractSyncOnly` compared the PR's changed-file count with the
consumer's copy-path count. A sync PR to SahajAtlasWeb has two copies, so
one copied file plus a `fix-ci` edit under src/ still read as sync-only:
the critic was skipped and auto-merge armed over unreviewed code.

It now requires every changed file, a rename's old name included, to be
one of the copy's `paths`. gather fetches the file list only for a bot PR
on the sync branch, the one PR the answer can change, so every other PR
costs no extra call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gather built `inlineCounts` and never read it, and shaped every review
with `inline_count: 0`, so decide's `r.inline_count > 0` could never be
true. The case it was meant for, a review whose only content is inline
comments, is already caught: each inline comment is an unresolved thread
whose last word is the reviewer's, and the thread loop above returns "a
thread waits on a reply". Wiring the per-author count through would have
been wrong anyway: it counts every comment that author ever left, so an
empty-bodied approval after an old inline note would read as a request
for changes.

A test pins that an inline-only review still fires address-review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 31, 2026
@sydevs-bot

sydevs-bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 18:58Z address-review · attempt 1 · session · done
  • 18:58Z address-review · attempt 1 · session
  • 18:51Z review-pr · attempt 1 · session · done
  • 18:51Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧐 Adversarial review

Four commits, five files, each one behaviour with the failure it prevents named. Nothing is smuggled in, and no skill or ceiling moves with it.

Every claim in the body checks out from the head: 352 dispatcher tests and 97 lib tests pass, the new unlock test fails without the guard and separately without the reconcile change, and the contract test fails against the old count rule. Both refactor commits drop genuinely dead code: sweep.mjs emits neither dropped reason, and gather.mjs hard-coded inline_count: 0.

ownUnlock is the right shape. Both arms are reachable only by the dispatcher's own writes (apply.mjs:542, apply.mjs:347), apply.mjs:507 clears a pending the moment a session really starts, and timeout archives its own attempt at apply.mjs:344 — so a live session's end still archives and nothing is lost to the note.

The gap is the one the body names: no supervised BOT_DISPATCH=dry run yet, and that is the dispatcher's only real gate.

Findings

  • should-fix — gather.mjs:311 re-implements the listFiles + previous_filename pair contracts.mjs:43-44 already has.
  • consider — contracts.mjs:97 fails open on an empty file list, where the count rule failed closed.
  • consider — decide.mjs:280 the inline-only claim holds on a bot PR, not on a member's.

What was checked

Read whole: route() and needsAddressReview in decide.mjs, the PR path in gather.mjs, contracts.mjs, the fire, timeout and unlocked paths in apply.mjs, and sweep.mjs. Ladder, on the two new pieces: ownUnlock has no equivalent in the file and two callers; the file-list fetch does have one, which is finding 1. Grepped inline_count, sweep- and recheck across dispatcher/. Ran both suites from a detached worktree of 024bbea, then re-ran each with its own fix reverted.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread dispatcher/gather.mjs Resolved
Comment thread dispatcher/contracts.mjs Resolved
Comment thread dispatcher/decide.mjs Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 31, 2026
`isContractSyncOnly` returned `files.every(...)`, and `[].every` is
true. A bot PR on the sync branch whose file list came back empty — a
listFiles page the gather never read, or a PR GitHub reports with no
files — therefore read as sync-only: the critic was skipped and
auto-merge was armed on a diff nobody had seen. The count rule this PR
replaced failed closed there, through `changed_files ?? Infinity`.

An empty or absent list now decides nothing, so the PR is reviewed like
any other. Two assertions pin both shapes; the first fails without the
guard.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVsjvVCH8xpZboAzZn
gather.mjs re-implemented the pair contracts.mjs:43-44 already had: a
paginated `listFiles`, then `flatMap([filename, previous_filename])`.
Two copies of one fetch give the sync rule two places to drift — a
rename handled in one and dropped in the other would make the same PR
sync-only in the plan and reviewable in gather, or the reverse.

`changedPaths(github, { owner, repo, number })` is now exported from
contracts.mjs beside the rule it feeds, and both callers use it. No
behaviour changes: the plan's own test already pinned the rename pair,
and a direct test pins it at the helper.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVsjvVCH8xpZboAzZn
On a member's PR the thread loop skipped every thread a human rooted,
not just the author's own. A reviewer whose whole ask lives in inline
comments therefore woke nothing: their review body is empty, so the
review loop below passed too, and `inline_count` never covered the gap
either — it was always 0, which is why dropping it in this PR is no
regression.

why.md says only the author's notes to themselves are not a request, and
the review loop already excludes just the author (`decide.mjs:277`). The
thread loop now matches it, so another person's thread on a member's PR
is work however they left it.

A test pins an inline-only review by a second member, with an empty
review body so only the thread can wake it; it fails without the change.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVsjvVCH8xpZboAzZn
@sydevs-bot

Copy link
Copy Markdown
Contributor

Three critic threads, three commits, pushed as 435b065. Nothing rebutted, nothing asked.

354 dispatcher tests and 97 lib tests pass. /security-review over the branch found nothing. The body's four-commit and owner-approval lines are refreshed.

Still open: the supervised BOT_DISPATCH=dry dispatch, which needs an attended run.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 31, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Oct 31, 2026
@Ardnived
Ardnived merged commit 1baf56c into main Nov 1, 2026
45 of 48 checks passed
@Ardnived
Ardnived deleted the claude/audit-fixes branch November 1, 2026 18:52
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants