Repository navigation
Description
Summary
The residue sweeper's */30 cron in each repo's workflow-state.yml now fires about 3.4 times a day, with gaps of 7 hours or more. A lock past its deadline is only reclaimed by that cron, so a dead session holds its item for up to 10 hours, and three attempts can take more than a day before anyone is told. On 2026-11-20 this turned an overnight usage limit into a stall that lasted all day: the SahajCloud locks that expired at 17:26Z were still held at 22:16Z, and were cleared only by a manual workflow_dispatch. The same cron is the only thing that clears a missed unlock: a session that removed its own lock, but whose unlock run failed, leaves its lease ref behind, and every later fire for that item is refused until the next sweep.
Approach
- Reclaim expired locks on every event run. In
resolve(dispatcher/resolve.mjs:63-71), an event run addsreconcileMaxPerEventdrift targets, but a locked item reads Working on the board, sodriftTargets(dispatcher/reconcile.mjs:113-127) never lists it. Factor the lock loop at the top oflistSweepTargets(dispatcher/sweep.mjs:26-36) into a helper, for exampleexpiredLockTargets, that takes the locked items rather than querying for them. The event run already callscheapView, and every item it returns carries its labels (dispatcher/reconcile.mjs:64-81), so it passes the items whose labels holdlabels.lockand needs no second label query. Append thesweep-timeouttargets before the drift ones, both bounded by one sharedreconcileMaxPerEventcap and the sameskipset, so the event's own item is never swept. The only new cost is one record read per locked item, and on a normal day only a handful are locked.cheapViewreturns nothing on a read failure, so that pass reclaims nothing and the cron is still the backstop. CIstatusandcheck_suiteevents arrive many times an hour across the five repos, so an expired lock is reclaimed within minutes while the loop is busy. - Read a missed unlock on the item's own event. When an event reaches an item that carries no lock, but whose record still holds
currentand was not unlocked by the dispatcher itself (ownUnlock),route(dispatcher/decide.mjs:1143) routes theunlockfirst (decide.mjs:1362), and then the event as usual.reconcile(decide.mjs:1469-1473) andsweep-lease(decide.mjs:1447-1452) already read the record this way. Theunlockedaction (dispatcher/apply.mjs:183) then releases the lease, archivescurrentand drops a refusedpending, before any fire tries the lease. Two events on WeMeditateWeb#326 missed this. A Cloudflare comment (23:10Z) set the board to Pending without the unlock, so the board no longer drifted and no reconcile target came. Then a member'saddress(23:32Z) was refused with "another pass holds the lease". - Keep the cron as the backstop for quiet hours, and move
*/30 * * * *(.github/workflows/workflow-state.yml:41) off the top of the hour (GitHub drops or delaysscheduleruns most at:00). Only theclaude-workflowcopy ofworkflow-state.ymlchanges here. Each product repo's own copy is a one-line follow-up there. - Docs. Update
docs/why.md#the-reconciler-replaces-the-drift-windowwith the measured cadence and the event-driven reclaim, and the "The schedule is also not the schedule" paragraph (docs/why.md:1575, under#the-journal-tally-needs-a-writer-that-cannot-stop), which still reads "about eight a day" from the 2026-09-09 to 2026-10-06 window. No test asserts either figure, so each is replaced in place. Updatedocs/why.md#a-lease-past-its-deadline-is-reclaimedto say that any event on the item reads a missed unlock.
Acceptance criteria
- An event run in a repo emits
sweep-timeoutfor every locked item in that repo whose record deadline has passed, up todispatch.reconcileMaxPerEvent, and never for the event's own item. - A lock still inside its deadline yields no target from an event run, and a locked item with no record is swept, exactly as the cron does today.
- An event on an unlocked item whose record still holds a session (
current) first runs that session's unlock: the lease is released andcurrentis archived, and the event is then handled as usual. A fire it calls for is not refused by the stale lease. - An item the dispatcher unlocked itself (
ownUnlock), and an item with nocurrent, are handled exactly as before. - Scheduled and
workflow_dispatchruns behave exactly as before. - The
claude-workflowsweeper cron no longer fires at:00or:30. -
docs/why.mdrecords the measured cadence and the new behaviour.
Verification checklist
-
node --test dispatcher/test/*.test.mjspasses. - A new
resolve.test.mjscase: anissue_commentevent on feat(loop): the autonomous pipeline — ladder, surveys, and self-reflection #1, with Ops journal — 2026-08 #2 locked past its deadline and chore(loop): read Relationships directly once the MCP tools are reachable #3 locked inside it, yields feat(loop): the autonomous pipeline — ladder, surveys, and self-reflection #1's own target plussweep-timeoutfor Ops journal — 2026-08 #2 only. - A case with more expired locks than
reconcileMaxPerEventyields exactly the cap. - A new
decide.test.mjscase: anissue_commentwith@sydevs-bot addresson an unlocked member PR whose record holds a finishedreview-princurrentand a refusedpendingplansunlockedbeforefire:address-review. - A
decide.test.mjscase: the same event whenownUnlockholds plans nounlocked. -
sweep.test.mjspasses unchanged. - The repo's lean gate passes:
claude plugin validate ./workflow --strict && node --test workflow/lib/*.test.mjs.
Decisions
- Should a reliable outside clock also drive the sweep? → A — no, events plus the cron are enough. No new service and no new secret. Expired locks clear within minutes while there is activity, and a quiet night waits for the cron, where few sessions run. (Ardnived, 2026-11-21)
Notes
Measured from schedule runs of workflow-state.yml, 2026-11-13 to 2026-11-20:
| Repo | Runs / day | Median gap | Longest gap |
|---|---|---|---|
| SahajCloud | 3.4 | 7.3h | 10.3h |
| SahajAtlasWeb | 3.5 | 7.2h | 9.7h |
| WeMeditateWeb | 3.4 | 6.9h | 10.2h |
| SahajAtlasWordpress | 3.4 | 7.4h | 10.3h |
| claude-workflow (four crons) | 6.5 | 3.5h | 8.7h |
docs/why.md measured about 8 runs a day for 2026-09-09 to 2026-10-06, so the cadence has fallen by half since then.
Related: #268 stops charging an attempt to a session that is blocked on a prompt or never started. It reads session status during the sweep, so this ticket decides how soon that check runs.
The missed unlock, sydevs/WeMeditateWeb#326 on 2026-11-20. sydevs-bot's REST quota (5,000/hr) ran out from 23:00Z to the 23:10Z reset, and every dispatcher run in that window failed. One of them was the pull_request_target.unlabeled run (23:01:35Z) for the review-pr session that had just removed its lock. So refs/sydevs-lease/326 stayed until a manual workflow_dispatch at 23:56Z, where sweep-lease read the unlock and fired the refused address-review. Step 2 would have cleared it on the 23:32Z comment. The exposure is the same as the rule's two current users: the cross-repo window in the sweep-lease comment (decide.mjs:1444-1446) is unchanged, because events for one item in one repo are already serialized by the dispatch-<repo>-<n> concurrency group.
A scheduled run can read cancelled when one matrix leg's pending job is replaced in its dispatch-<repo>-<n> concurrency group (SahajCloud, 2026-11-20 07:36Z and 16:40Z). The newer run covers that item, so this is expected and is not part of this ticket.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Projects
- StatusShow more project fieldsDone
Activity
[-]fix(dispatcher): reclaim expired locks without waiting on the cron[/-][+]fix(dispatcher): reclaim dead sessions without waiting on the cron[/+]Ardnived commentedon Nov 21, 2026
@sydevs-bot implement
sydevs-bot commentedon Nov 21, 2026
Not started: 1 open question(s) in the body still need an answer. Reply
@sydevs-bot revisewith your choices (for example1A), then say@sydevs-bot implementagain.🤖 sydevs dispatcher
Ardnived commentedon Nov 21, 2026
@sydevs-bot revise 1A
sydevs-bot commentedon Nov 21, 2026
🤖 no session running
approved by Ardnived
recent dispatches
Written by the sydevs dispatcher. Sessions never edit this comment.
sydevs-bot commentedon Nov 21, 2026
Answered 1A: events plus the cron, no outside clock. The question is now a decision in the body, and none is left open.
Grounding the body against the code corrected five things:
resolve, notresolveTargets(dispatcher/resolve.mjs:63-71).routeand itsunlockcase moved when feat(review): a fresh streamliner justifies every new piece, and the critic seconds each question #293 landed:decide.mjs:1143and:1362, and thesweep-leasewindow comment is:1444-1446.cheapViewalready returns each item's labels (dispatcher/reconcile.mjs:64-81), so the helper takes the locked items.workflow-state.yml:41, and the stale cadence figure isdocs/why.md:1575. No test asserts it.claude plugin validate ..Say
@sydevs-bot implementto start the work.🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Ardnived commentedon Nov 21, 2026
@sydevs-bot implement