Skip to content

fix(dispatch): one item dispatched twice, and a journal tally that stops counting - #156

Merged
Ardnived merged 10 commits into
mainfrom
claude/fix-144-dispatch-lease-tally
Oct 6, 2026
Merged

Ardnived merged 10 commits into
mainfrom
claude/fix-144-dispatch-lease-tally

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • One item can no longer be dispatched twice: the lease is an atomic ref create taken before the lock label, so two passes that both read locked: false produce one 201, one 422, and one fire.
  • The journal's title and tally are re-counted for yesterday on every tick, so a day closes with a true count instead of freezing at its last successful tick.

Change outline

The lease moved from a label to a ref

gather read locked once, decide ran on that snapshot, and apply wrote the label after the plan was decided — with ensureJournalDay and up to twenty issue reads in between. Everything in that window was open: a second pass gathering inside it also saw locked: false.

Serializing matrix legs cannot close it, and the ticket's open questions settled why: conflict-scan and cross-repo unblock-check targets drain inside the running job, and a concurrency group is scoped to the repo whose run it is, so no group can serialize cross-repo work at all. A CAS on the status comment cannot close it either — updateComment is last-writer-wins and If-Match is not a write precondition on issue comments.

POST /git/refs 422s when the ref exists. dispatcher/lease.mjs takes refs/sydevs-lease/<number> before the label; the 422 loser records a recheck, writes no label, fires nothing. A lease that cannot be read or written refuses the fire rather than failing open, and journals it.

Every exit releases the lease

A ref outliving its session would be a permanent lock — worse than the defect. Five paths close that:

Path Releases
unlocked (the session removed its label) with the label
timeout (sweep.mjs reclaimed a dead session) unconditionally, whatever the record said
the fire failed (429, paused, 5xx) with the lock it gives back
a throw between the CAS and the fire on the way out, then rethrows
sweep-lease (new arm) a ref on an item with neither the lock nor a recorded session

All five go through one release helper, so a delete that fails posts a lease-release-failed anomaly rather than going quiet. Without that, the standing lease answers the next takeLease with 422 already exists, which reads as contention — the one refusal that deliberately posts nothing — and the item stops for good in silence.

sweep-lease is what makes "no item is left with a ref and no session" true rather than mostly true: it covers a runner killed after the CAS and before the label write, which sweep-timeout cannot see. decide re-checks both the label and rec.current before it deletes, so a live lease is never stolen.

Two preconditions the CAS needed

The dispatch id was not unique. The stamp dropped the sub-second digits, so two fires in one second shared an id — SahajCloud#867's one id and two journal entries. Milliseconds are restored and a four-hex suffix carries the uniqueness, so two buildRecord calls at the same instant still differ.

resolve emits one target per repo#number. A group does not queue three legs: one runs, one pends, a newer pending cancels the older — and the sweeper does produce three for one PR (unblock-check, sweep-pr, sweep-orphan), so the middle was silently dropped. The target now carries reasons: [{reason, facts}] and act drains them in order inside the one leg, which it already did for emitted targets. Its own reason/facts stay the first one, so nothing that reads a target the old way changed.

Because the coalesced target keeps the first reason's kind, sweep-lease takes its kind from the open PR list rather than hard-coding 'issue'. It stays the first reason on purpose: the residue must be reclaimed before sweep-pr asks for the lease.

fix-ci is keyed to the head it is fixing

SahajCloud#861 and SahajAtlasWeb#245 were not concurrency at all — serial, lock-respecting re-fires. A red run produces several workflow_run, check_suite and status events per push, each its own act run, and the first session's unlock re-derives the same plan on the same red head. The ceiling was the only brake, which is why it was what got exhausted.

rec.current now carries the head sha, so the entry unlocked and timeout append carries it too, and evaluatePr refuses a fix-ci fire for a sha that already has an ended session — whatever rec.fixCi reads. A push to a new sha asks again. On the unlock path the refusal leaves no move, so the PR becomes the reviewer's turn rather than a loop.

Separately: bumpFixCi now counts a session that started, not a fire that was planned. Refused fires used to spend ceilings.ciFixIterations, which is what then refuses a real fix.

The journal tally got a writer that cannot stop

Three properties made one bad tick permanent: journalTick was unguarded, so a throw in closeDuplicateDays skipped the tally; nothing revisited a day once localDate rolled; and the failure was invisible, because dispatch / journal is in ci.ignoreCheckNames and nothing posted an anomaly.

Each step is guarded on its own, a failure posts a journal-tally anomaly to the day's own issue, and every tick re-counts yesterday as well as today. refreshTally writes nothing when the counts already agree, so this costs one read per tick. It also takes the weekday label now — without it the clock supplies one, which would relabel Monday's journal Tue the moment it was recounted.

Phases

Each phase is a separate commit, and phases 1 and 2 are not squashed together: both change whether a fire runs, they fail differently, and a combined commit could not be reverted for one of them.

  • Phase 1 — defect A: the lease is a CAS, the dispatch id is unique, resolve emits one target per item
  • Phase 2 — defect B: a fix-ci fire is keyed to its head sha
  • Phase 3 — defect C: the journal tick is guarded and re-counts the day that rolled
  • reflect/SKILL.md states one counting source (its own commit, as the ticket asks)

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict
  • node --test dispatcher/test/*.test.mjs: 145 passed, from 106 on main at ef83cfb. 39 new cases.
  • node workflow/lib/rule-delta.mjs --base main workflow/skills: directives 62 → 62, no directive disappeared.
  • workflow/lib/comment-lint.mjs --base origin/main: 14 changed files, no banned comment added.
  • ste-lint.py workflow/skills/reflect/SKILL.md: 7 violations, all pre-existing, none on the edited lines.
  • Build: N/A — no package manager in this repo.
The 39 new cases, one per acceptance criterion

dispatcher/test/lease.test.mjs (14) — two concurrent creates give one 201 and one 422; the ref is outside heads/tags; an issue anchors on the default branch; release makes the item leasable again and releasing nothing succeeds; a 403 refuses the fire rather than failing open; matching-refs is asked without a trailing slash and reads only the namespace; a refs read that fails reclaims nothing; two buildRecord calls at one instant differ; the suffix pads to four hex; sweep-lease reclaims residue; sweep-lease leaves a live lease alone on either the label or the record; a 422 that is not already exists is an error, not contention; contention is read from the message GitHub actually sends; a tail that is not canonical digits is never read as a number.

dispatcher/test/act.test.mjs (4) — two act passes against one shared world, both gather calls completing before either apply, fire once and the loser records a recheck with no label; a refused fire does not spend a ciFixIterations attempt; sweep-timeout deletes the lease with the label; a 403 on deleteRef posts a lease-release-failed anomaly and still removes the label.

dispatcher/test/resolve.test.mjs (6) — three reasons for one PR become one target carrying all three in order; a coalesced target still reads as its first reason; each reason keeps its own facts; different items and different repos never merge; one reason twice is one reason.

dispatcher/test/decide.test.mjs (6) — the ended-session refusal; a timed-out session counts as ended; a new sha clears it; a session with no outcome does not count; another handler's ended session does not count; the unlock that hands the PR over.

dispatcher/test/journal-tick.test.mjs (8) — a closeDuplicateDays throw no longer blocks the tally; a rolled day is recounted under its own weekday; the anomaly on failure and none on success; idempotence across two ticks; a missing yesterday is not a failure; previousDay across a DST switch; the label override.

dispatcher/test/sweep.test.mjs (1) — a lease on an open PR number is swept as a pr, anything else as an issue, and the reclaim is emitted before sweep-pr.

The fake Octokit's refs now carry GitHub's own 422 semantics, so two fake clients sharing one world contend exactly as two passes do.

Manual verification

Everything below needs a live dispatch, and no test can stand in for it.

  1. BOT_DISPATCH=dry on a scratch item. Confirm the plan logs a refused fire and a recheck for a locked item, and writes nothing. Dry run returns before the CAS, so no ref is created.
  2. One supervised live dispatch (docs/routine-setup.md §6) on a PR with red CI. Confirm the second CI event for the same head logs fix-ci … on <sha> — a push to a new head is what asks again rather than a fire.
  3. git ls-remote origin 'refs/sydevs-lease/*' after that dispatch ends — expect nothing. A ref left there with no bot:working on the item is residue; the next sweep reclaims it.
  4. The first journal tick after merging. Expect two log lines: today's counts, and journal #<n> <yesterday> (<Day>) with yesterday's.

Notes for reviewer

  • The checklist item that shapes phase 3 is answered, and it changed the design. 212 schedule runs in this repo span 2026-09-09 to 2026-10-06 — about eight a day against a declared fifty, at gaps of two to five hours, every one concluding success. So the loss is a cron GitHub mostly drops, not a throw. That rules out keying the repair on the 5 7/5 8 ticks as the ticket proposed: no tick is guaranteed to land near midnight. Hence every tick re-counts yesterday, which needs no new config and does not care which cron fired. The try/catch stays, because it is correct either way.
  • The judgement call I would most like checked: the lease anchor sha. POST /git/refs needs a sha, and an issue has no head. For an issue the lease reads the default branch's head first — two extra API calls, before the CAS, so they widen no window. A PR reuses pr.head.sha from the snapshot. Where the ref points is never read.
  • The second judgement call: five reclaim paths, where the ticket asked for two. The adversarial review questions whether sweep-lease earns its arm. It is still here: the window it covers is small, but the failure it prevents is a permanent lock, and the lease-release-failed anomaly above now makes a standing lease visible rather than silent. Dropping sweep-lease and filing it for the day a stuck lease is seen is your call, not mine.
  • Rollout is graceful, not instant. Records already in the wild carry no sha on their dispatch entries, so the phase-2 refusal does nothing until a fire writes one. No migration, no backfill.
  • One residual window, narrowed not closed. Between the CAS and the label write, sweep-lease could in principle see a lease with no label and no record and reclaim it. It is one API call wide, the sweep lands ~8 times a day, and the consequence is one duplicate dispatch — the old behaviour, not worse. Closing it would need state the ref cannot carry.
  • version goes to 2.7.0 → 2.7.1 because reflect/SKILL.md changed and an installed plugin's cache is keyed by it. The review round changed no skill prose, so it stays 2.7.1.
  • node_modules does not exist here and worktreeSetup is empty, so nothing was asserted that only an install could settle.
Detail

Rejected: a sweep-lease self-heal inside takeLease. Breaking a 422 when the item carries no lock and no record would let a pass steal a lease the winner had just taken. Reclaiming from the sweeper instead keeps the decision out of the hot path, and decide stays pure.

Rejected: keying the yesterday-refresh on j.created. It reads as exactly "the first tick of the day", but an act job can create the day issue via ensureJournalDay before any journal tick does, and then created is false and yesterday is never refreshed. The Actions cadence above makes that likely on a busy night, not hypothetical.

Rejected: milliseconds alone for the dispatch id. The ticket offered milliseconds or a random suffix. The checklist asks for two buildRecord calls with the same now to differ, which only the suffix delivers — and the same-millisecond collision is exactly the window two passes of one event land in.

Rejected: moving the sweep-lease loop below openPrs to fix its kind. That is where the review pointed, and it would reorder the reasons: sweep-pr would then be first, fire, and ask for the lease while the residue still stands. Hoisting the PR list instead fixes the kind and keeps the reclaim first.

Why previousDay goes through noon UTC. Subtracting 24 hours from a moment can land on the same local date across a DST switch. Taking the YYYY-MM-DD, parsing it at noon UTC and stepping the date cannot. dayLabel reads the weekday the same way, from the day rather than the clock.

What the ticket asked for that is not here. Nothing. The resolve.test.mjs the checklist names did not exist; it does now.

Closes #144

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

🤖 Generated with Claude Code

https://claude.ai/code/session_01VXLjfcmaSpEm2vwPfVHPvF


Generated by Claude Code

sydevs-bot and others added 6 commits October 6, 2026 05:41
Two sessions held one item on four distinct days, because the lock label was
written after the plan was decided. `gather.mjs` read `locked` once, `decide`
ran on that snapshot, and `apply` wrote the label after `ensureJournalDay` and
up to twenty issue reads. A second pass gathering inside that window also saw
`locked: false`, so both fired — SahajCloud#858 one second apart, and
WeMeditateWeb#144 nineteen seconds apart.

Serializing the matrix legs cannot close it. `decide` emits `conflict-scan` and
cross-repo `unblock-check` targets that drain inside the running job, where no
group covers them, and a concurrency group is scoped to the repo whose run it
is — so no group can serialize cross-repo work at all. A compare-and-swap on
the status comment cannot close it either: `updateComment` is last-writer-wins
and `If-Match` is not a write precondition on issue comments, so W1-write,
W1-read, W2-write, W2-read has each pass reading its own id back.

`POST /git/refs` 422s when the ref exists, so exactly one of two concurrent
creates wins with no read at all. `refs/sydevs-lease/<number>` is taken before
the label; the 422 loser records a `recheck`, writes no label and fires
nothing. The ref is outside `refs/heads` and `refs/tags`, so it is not a
branch, and the bot PAT's contents write already covers it.

A ref that outlives its session would be a permanent lock — worse than the
defect. So `unlocked` deletes it, `sweep-timeout` deletes unconditionally, a
throw between the create and the fire releases it on the way out, and a new
`sweep-lease` arm reclaims a ref on an item carrying neither the lock nor a
recorded session.

Three things the CAS needed first:

- **The dispatch id was not unique.** The stamp dropped the sub-second digits,
  so two fires in one second shared an id. That is SahajCloud#867: one id, two
  journal entries. Milliseconds are restored and a four-hex suffix carries the
  uniqueness.
- **`resolve` now emits one target per `repo#number`**, carrying every reason.
  A group does not queue three legs — one runs, one pends, a newer pending
  cancels the older — and the sweeper does produce three for one PR
  (`unblock-check`, `sweep-pr`, `sweep-orphan`), so the middle was dropped.
  `act` drains the reasons in order inside the one leg, as it already did for
  emitted targets.
- **`bumpFixCi` counts a session that started, not a fire that was planned.**
  Refused fires used to spend `ceilings.ciFixIterations`, which is what then
  refuses a real fix (SahajAtlasWeb#245).

18 new cases, in `dispatcher/test/lease.test.mjs`, `resolve.test.mjs` and
`act.test.mjs`. The fake Octokit's refs now carry GitHub's own 422 semantics,
so two fake clients sharing one world contend exactly as two passes do.

Refs #144

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VXLjfcmaSpEm2vwPfVHPvF
… ended

SahajCloud#861 took three `fix-ci` dispatches at 04:47, 04:51 and 04:54 for
one red run on one head; SahajAtlasWeb#245 took three on unchanged head
`19a284d` after the first had commented and stood down. Neither is
concurrency: they are serial, lock-respecting re-fires.

A red run produces several `workflow_run`, `check_suite` and `status` events
per push, each its own `act` run, and the first session's unlock re-derives the
same plan on the same red head. `evaluatePr` keyed the fire on nothing but
`s.ci.failing.length` and the ceiling, so the ceiling was the only brake —
which is why it was the thing that got exhausted.

`rec.dispatches` entries now carry the head sha the session was fired against,
on `rec.current` so the entry `unlocked` and `timeout` append carries it too.
`evaluatePr` refuses a `fix-ci` fire for a sha that already has an ended one,
whatever `rec.fixCi` reads, and says which sha in the note. A push to a new
head has no ended session against it and asks again. On the unlock path the
refusal leaves no move, so the PR becomes the reviewer's turn instead of a
loop.

6 new cases in `decide.test.mjs`: the refusal, a timed-out session counting as
ended, the new-sha clear, a session still running (no outcome) not counting,
another handler's ended session not counting, and the unlock that hands over.

Refs #144

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VXLjfcmaSpEm2vwPfVHPvF
Journal #134 (Mon 2026-09-28) reported 22 dispatches and 1 anomaly against 37
and 4; #139 (Thu 2026-10-01) reported 84 and 6 against 97 and 7. Monday's
counted set was precisely its first 22 session comments in order, and its
per-handler tally matched those 22 exactly — so the counter did not miscount,
it stopped.

Three properties made one bad tick permanent. `journalTick` was unguarded, so a
throw in `closeDuplicateDays` skipped `refreshTally` for that tick. Nothing
revisited a day once `localDate` rolled. And the failure was invisible:
`dispatch / journal` is in `ci.ignoreCheckNames`, so a red journal job is never
CI, and nothing posted an anomaly.

**The Actions history settles which it was.** 212 schedule runs span 2026-09-09
to 2026-10-06 — about eight a day against a declared fifty, at gaps of two to
five hours, every one concluding `success`. So this is a cron GitHub mostly
drops, not a throw. #134 freezing at 00:31Z with 6.5 hours of its journal day
left is one skipped stretch.

That rules out keying the repair on which cron fired, since no tick is
guaranteed to land near midnight:

- Each step of the tick is guarded on its own, and one failing never skips the
  next.
- A failure posts a `journal-tally` anomaly to the day's own issue, which is
  the only place a dropped tick can be seen.
- **Every** tick re-counts yesterday as well as today. `refreshTally` writes
  nothing when the counts already agree, so this costs one read per tick and
  buys a day that closes with a true count.
- `refreshTally` now takes the weekday label. Without it the clock supplies
  one, which would relabel Monday's journal `Tue` the moment it was recounted.
  `previousDay` and `dayLabel` work from the date at noon UTC, so no DST shift
  moves a day.

8 new cases in `dispatcher/test/journal-tick.test.mjs`: the close-duplicates
throw that no longer blocks the tally, the rolled day recounted under its own
weekday, the anomaly on failure, no anomaly on success, idempotence across two
ticks, a missing yesterday, the date arithmetic over a DST switch, and the
label override.

Refs #144

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VXLjfcmaSpEm2vwPfVHPvF
… a day it opened

`reflect/SKILL.md` gave two instructions for one number. `:38` and `:116`
build the usage report from the seven titles and tally blocks with no comment
reads; `:68` said to count from the markers. Those disagreed whenever the tally
froze, and the 2026-10-04 run read roughly 250 comments across five days to get
a number it was supposed to read from seven titles.

Titles win. The tally repair in the previous commit is what makes them
trustworthy, and the markers stay as the count for a day the run opened anyway
— which `:38` already limits to a day whose title reports a failure or an
anomaly.

`version` goes to 2.7.1: an installed plugin's cache is keyed by it, so a skill
change that leaves it alone reaches nobody who installed.

`node workflow/lib/rule-delta.mjs --base main workflow/skills` — directives
62 → 62, no directive disappeared. `ste-lint.py` reports the same 7 pre-existing
violations on this file, none on the edited lines.

Refs #144

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VXLjfcmaSpEm2vwPfVHPvF
…ailing slash

`listLeases` built the ref from `leaseRef('')`, which ends in a slash.
`GET /repos/{owner}/{repo}/git/matching-refs/{ref}` puts `ref` in the URL path,
so the slash would have gone into the path and the reclaim arm would have read
nothing — silently, since the function returns `[]` on any read failure.

It now asks for `sydevs-lease` and filters the results by the full prefix, so a
ref merely beginning with that name is not read as a lease number.

Belongs with the lease commit; kept separate so it reverts on its own.

Refs #144

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VXLjfcmaSpEm2vwPfVHPvF
Two surfaces the change makes stale:

- The label table said the dispatcher applies `bot:working` and the session
  removes it, which is still true but is no longer the whole mechanism. Names
  `refs/sydevs-lease/<number>`, says it is invisible to `git branch`, and gives
  the `git ls-remote` that lists the leases a repo holds.
- `SYDEVS_BOT_PAT` needed Contents for `PUT …/merge`. It is also what the ref
  create and delete need.
- The journal section now says every tick re-counts yesterday, what the real
  schedule cadence is, and where a failed tick says so.

It also records the one thing that ends the re-counting: the weekly reflection
closes the week's journals, and a closed day is not found again.

Refs #144

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VXLjfcmaSpEm2vwPfVHPvF
… it is

Two defects the security pass over this branch found in the new lease code.
Both are the same shape as what the rest of the PR removes — a failure that
leaves an item silent.

**A 422 is not only "already exists".** `POST /git/refs` also answers 422 for a
stale anchor sha and for a malformed ref name. Reading either as contention
took the branch that writes no label, fires nothing, and deliberately
suppresses the `lease-unavailable` anomaly — leaving only `rec.recheck`, which
nothing drains without the lock or the `stuck` label. So the item would do
nothing until an unrelated event, with nothing in the journal. Contention is
now read from the message GitHub sends; every other 422 is journalled.

**`Number()` is not a numeral check.** `Number('858.0')`, `'+858'`, `' 858'`
and `'1e3'` all pass `Number.isInteger(n) && n > 0`, but `leaseRef` rebuilds
the canonical name — so a ref `refs/sydevs-lease/858.0` resolved to target 858
and `releaseLease` would have deleted item 858's live lease, while the odd ref
survived to re-target `sweep-lease` on every pass forever. The tail must now
match `^[1-9][0-9]*$`.

Also corrects an overclaim in the `sweep-lease` comment: the label and
`rec.current` narrow the window, they do not close it, because the concurrency
group that would close it is scoped to one repository.

3 new cases: the non-contention 422, contention still read from the real
message, and nine non-canonical tails that are not leases. 143 passing.

Refs #144

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

Copy link
Copy Markdown
Contributor Author

Correcting one bullet in the body: the security pass did land before the deadline, and 15c15ce acts on it. Two real defects in the new lease code, both the invisibility shape the rest of this PR removes:

  • POST /git/refs also answers 422 for a stale anchor sha and a malformed ref name. Reading either as contention wrote no label, fired nothing, and suppressed the lease-unavailable anomaly — so the item would sit silent with nothing journalled. Contention now comes from the message GitHub sends.
  • Number('858.0') passes Number.isInteger, but leaseRef rebuilds the canonical name — so a ref refs/sydevs-lease/858.0 resolved to target 858 and the reclaim would have deleted item 858's live lease, while the odd ref re-targeted sweep-lease forever. The tail must now be ^[1-9][0-9]*$.

The sweep-lease comment also overclaimed; it now says the label and rec.current narrow the window rather than close it.

Tests 140 → 143. The correctness pass was still running when the lease expired, so it is not reflected here.

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


Generated by Claude Code

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 6, 2026
@sydevs-bot

sydevs-bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 07:19Z address-review · attempt 1 · session · done
  • 07:19Z address-review · attempt 1 · session
  • 07:08Z adversarial-review · attempt 1 · session · done
  • 07:08Z adversarial-review · 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 Author

Choose a reason for hiding this comment

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

🧐 Adversarial review

The diff matches #144: three defects, one commit each, and the one new module owns one thing. Phase 1 picks the only GitHub write that is a CAS. Two divergences from the ticket are argued in the body and read better than what was asked — every tick re-counts yesterday instead of two named crons, and resolve coalesces rather than trusting a concurrency group.

The aggregate I would question is reclaim paths. The ticket asked for two, unlock and sweep-timeout. This ships five, and the fifth — sweep-lease, plus listLeases, a decide arm, an action and a ref-name sanitiser — defends a window the body measures as one API call wide, against a runner death nobody has counted. Its own comment calls it "not a proof, only a narrowing". A permanent lock is a bad failure, so this is a question: is sweep-timeout plus the new try/catch enough, and sweep-lease filed for the day a stuck lease is seen?

Body numbers are off: 143 tests pass here, not 140, and 37 are new, not 34.

Findings

  • should-fix — a failed release is silent, and silence reads as contention, so the item stops for good (lease.mjs:103).
  • should-fix — the new blockquote splits the label table; three rows stop rendering (routine-setup.md:135).
  • consider — sweep-lease pushes kind: 'issue' for PR numbers (sweep.mjs:94).
  • consider — the sanitiser guards a ref name only this code writes (lease.mjs:47).

What was checked

lease, apply, decide, fire, resolve, sweep, index, journal, gather read whole. Tests: 143 here, 106 on main at ef83cfb. dispatcher.yml passes SYDEVS_BOT_PAT to every github-script step under permissions: {}, so the ref write needs no GITHUB_TOKEN scope. Every new why.md anchor resolves. sweep-awaiting hands a stood-down red PR back, so phase 2 keeps its handoff.

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


Generated by Claude Code

Comment thread dispatcher/lease.mjs Resolved
Comment thread docs/routine-setup.md Resolved
Comment thread dispatcher/sweep.mjs Resolved
Comment thread dispatcher/lease.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 6, 2026
claude added 3 commits October 6, 2026 07:23
Every release path awaited `releaseLease` and dropped the boolean. A ref that
will not delete leaves the lease standing, and the next `takeLease` answers
422 `already exists` — which reads as contention, the one refusal path that
deliberately posts no anomaly. The item then stopped for good in silence, the
exact invisibility the journal half of this PR removes from the tally.

All five sites now go through one `release` helper that posts a
`lease-release-failed` anomaly when the delete fails. The post is itself
guarded: an anomaly we cannot write must not break an exit path that is
already failing.

Addresses the `should-fix` on lease.mjs:103.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HywgCDm8zhLLJ8B73uUiXa
A blockquote between two table rows ends the table. `stuck`, `blocked`,
`proposal` and `ops-journal` rendered as literal pipe text on the page a new
account is set up from.

Addresses the `should-fix` on routine-setup.md:135.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HywgCDm8zhLLJ8B73uUiXa
`coalesceTargets` keys on `repo#number` and keeps the first target's kind.
This reason is pushed before `sweep-pr` on purpose — the ref must be reclaimed
before any fire asks for the lease — so its hard-coded `'issue'` was the kind
the coalesced target carried, and `buildRecord` then sent a routine
`kind: 'issue'` with a non-null `head`. `gather` re-derives the kind, so
nothing mis-gathered; only the record lied.

The open PR list moves above the loop and supplies the kind, which keeps the
reclaim first rather than reordering the reasons.

Addresses the `consider` on sweep.mjs:94.

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

Copy link
Copy Markdown
Contributor Author

Four review threads answered, three commits pushed to 28fcae6.

Adopted

Rebutted — the ref-tail sanitiser stays: one regex against deleting a live lease. Yours to settle.

Asked — whether sweep-lease earns its arm, given the ticket asked for two reclaim paths. See Notes for reviewer.

Body corrected: 145 tests, 39 new, 14 changed files.

🤖 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 6, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 6, 2026 07:30
@sydevs-bot
sydevs-bot requested a review from Ardnived October 6, 2026 07:30
@Ardnived
Ardnived merged commit 201157a into main Oct 6, 2026
49 of 55 checks passed
@Ardnived
Ardnived deleted the claude/fix-144-dispatch-lease-tally branch October 6, 2026 19:15
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.

fix(dispatch): one item dispatched twice, and a journal tally that stops counting

3 participants