Skip to content

fix(loop): the lease covers the branch, and a PR answers its implement verb - #85

Merged
Ardnived merged 1 commit into
mainfrom
claude/implement-handoff
Sep 9, 2026
Merged

Ardnived merged 1 commit into
mainfrom
claude/implement-handoff

Conversation

@Ardnived

@Ardnived Ardnived commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Two holes in the implement hand-off, both found while eight implement sessions ran at once. Neither has bitten yet.

The PR carries no lock — that part is right

sydevs/SahajCloud#742 opened without bot:working, which prompted this. That is correct: the lease is on the issue the session was given, and no session holds the PR.

But the session still owns the branch, and for a few minutes after finalize-pr pushes it is still running. evaluatePr asks whether the PR is locked. It never asked whether the session that made it had finished.

In SahajCloud the window is hidden — CI takes about nine minutes, so the PR is nowhere near green before the session ends. In claude-workflow there is no CI, so ci.noCi calls a draft green the instant it opens, and the sequence is:

implement pushes → PR opens → pull_request.opened → evaluatePr
  → draft, green, no own review, above the threshold → fire adversarial-review

against a branch implement is still pushing to. A PR is now held while any issue it closes carries the lock. Cost is one issue read per PR event on a bot PR.

The verb that started implement was never consumed

A dispatcher comment is never the bot's last word — that rule exists so a refusal cannot silence a human's verb. The consequence nobody followed through: an implement session answers with a pull request, not a comment on the issue. So on unlock, the verb that started it still reads as pending.

Every implement therefore re-dispatched itself. The second pass hit the in-flight guard and refused — correct, and useless. SahajCloud#729 has it on the record:

Ardnived:    @sydevs-bot implement
sydevs-bot:  <!-- sydevs-status v1 … -->
sydevs-bot:  <!-- sydevs-dispatcher: in-flight 742 -->
             #742 is already open for this ticket, so I will not start a second implementation.

One wasted act job and one wasted comment per implement, and awaiting left on a ticket whose PR is open — so "Your turn" fills with work that is in flight. #729 is sitting there now, Status Done and labelled awaiting.

On unlock, an implement verb with an open PR closing the issue is consumed, the ticket goes Done, and awaiting comes off. Any other verb still re-derives — someone who typed revise while the session ran is still owed a run — and an implement verb with no PR still re-derives, because then nothing answered it.

Test results

node --test dispatcher/test/*.test.mjs — 60 pass, 2 new. The held PR and the same PR once the issue unlocks, then all four branches of the verb rule: implement with a PR, implement without, a different verb with a PR, and the label coming off.

claude plugin validate ./workflow --strict ✓. Two docs/why.md anchors. No skill or config change, so no version bump.

…t verb

Two holes in the implement hand-off, found while eight implement sessions
ran at once.

A PR carries no lock, correctly — no session holds it. But the session that
holds the linked issue still owns the branch. Where there is no CI a draft is
green the moment it opens, so the critic would fire against a branch
implement was still pushing to. A PR is now held while any issue it closes
carries the lock.

And an implement session answers with a PR, never a comment on the issue, so
its verb still read as pending on unlock. Every implement re-dispatched
itself, hit the in-flight guard, and left `awaiting` on a ticket whose PR was
open. SahajCloud#729 shows it. The PR is the answer.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit ef116ca into main Sep 9, 2026
3 checks passed
@Ardnived
Ardnived deleted the claude/implement-handoff branch September 9, 2026 16:18
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Sep 9, 2026
Ardnived pushed a commit that referenced this pull request Oct 27, 2026
* fix(dispatcher): refuse a Blocked by line that names no issue

sydevs/SahajCloud#987 carried `Blocked by: …/pull/912`, naming the PR
rather than the issue that PR closes (#907). `parseBlockedBy` returns `[]`
for that line — GitHub's relationship takes an issue — so no relationship
was created, no `blocked` went on, and nothing was said. `stripBlockedBy`
leaves the line, rightly: it is the only record of the author's intent. The
ticket therefore read as blocked to every human and as ready to the
machinery. The `block on` verb has refused loudly in exactly this
situation since it shipped (decide.mjs blockVerb); the body-marker path
had no equivalent.

`unresolvedBlockers(body, org, marker)` is a sibling of `parseBlockedBy`
over the same `blockerText` pass, returning the bare text of each live
line whose `parseRefs` is empty. `gather` puts it on `s.markers.unresolved`
and `derive` turns each entry into one `commentOnce` on `issues.opened`
and `issues.edited`, naming the line and the two accepted spellings. No
label, relationship or Status moves for it: the item really is not
blocked, and `blocked` follows the relationship. An outsider's own body is
skipped, as its markers already are.

The comment is keyed on the line's own text, not a comment id — there is
none on this path. A body edit elsewhere re-derives the same key and
`commentOnce` posts nothing; a corrected line yields a key never reached.

A line that resolved one target and dropped another stays silent. That
ticket is related and carries `blocked`, so the human and the machinery
agree, and a PR URL beside a resolved issue is as often reason prose as a
second blocker.

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

* docs(format-ticket): the blocker's target is an issue, never the PR that closes it

The Relationships section stated the accepted spellings only in its "Write
the format. Do not rely on it when reading" paragraph — under the reading
half, which a session writing a line has no reason to reach. The writing
instruction above it showed an `issues/632` URL and said nothing about what
the target must be, so the shape was there to copy and the rule was not.
sydevs/SahajCloud#987 named the PR.

One clause on the writing instruction says it, and the reading paragraph
now says the dispatcher comments on a line that names neither spelling
rather than dropping it in silence.

4.0.1: an installed plugin's cache directory is named after `version` and
never revisits the commit it recorded, so a skill edit reaches
`/plugin install workflow@sydevs` only when this string moves. The routines
read main fresh on every dispatch and do not need it.

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

* refactor(dispatcher): delete the dead LOCK_FREE_STATUS_ONLY constant

Nothing in `dispatcher/` or its tests has read it since it arrived dead in
#85. Its name states a rule — on a locked item only these action types run
— that `decide` does not implement: the lock strips `awaiting` and nothing
else. A reader trusting the name would believe comments and fires are
already suppressed on a locked item, which is the belief the part above
had to check against the code.

The rule itself may still be worth having. Suppressing comments and fires
on a locked item changes dispatcher behaviour in all five repos on the next
event, so it needs its own ticket; deleting the constant does not foreclose
it.

It joins #198 as the same file, the same reader and the same test command.

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

* docs(routine-setup): an unusable blocker line is commented on, not dropped

The Relationships section described the reader as generous about the line's
shape and stopped there, so it read as if every line either converts or is
ignored. One clause names the third outcome this branch adds.

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

* fix(dispatcher): report a blocker target, not a blocker line

From the review of this branch. The first draft reported any live line that
started with the marker words and resolved nothing, which re-priced the
loose matcher's false positives as public comments. `blockerText` matches
`Blocked by the lack of staging credentials.`, so that author would have
been told to write an issue URL.
`docs/why.md#the-marker-reader-matches-words-not-punctuation` licensed the
looseness on the grounds that a false positive costs a run one skipped
ticket; a comment on a live ticket is dearer. Read loosely, report
conservatively — the asymmetry `format-ticket` already states.

So the reader now matches ref-shaped targets (an issue or PR URL in any
org, `owner/repo#N`, a bare `#N`) and reports `{ line, targets }` only for
a line that reaches for one and resolves no in-org issue. Three
consequences:

- The comment is keyed on the targets. The whole line made the reason prose
  part of the dedupe identity, so rewording after the em dash — the edit
  people actually make — re-posted advice already read, and any later
  tidying of `blockerText` would have re-nagged every open ticket carrying
  such a line. A corrected target still yields a key never reached.
- The quoted line is the line as written, bullet off. `bare` strips leading
  emphasis only, so the old draft quoted `Blocked by #12.**` back at its
  author. It also quoted inside a backtick span, which a backtick in the
  reason broke; it is a blockquote now.
- A line naming no target at all is prose and is reported nowhere.

A line that resolves one target and drops another still stays silent, as
the ticket's criterion requires.

Also from the review: `parseBlockedBy` and `unresolvedBlockers` now share
one `blockerLines` pass, so a line's recognition is asserted in one place
rather than two; `gather` hoists its call beside `parseBlockedBy`'s; the
snapshot field is `markers.unresolvedBlockers`, leaving the generic name
free; and one word, "unresolved", now spans the reader, the field, the
decider and the comment key, so one grep finds the whole path.

Measured over every tracked `.md` in this repo, including `docs/why.md`
and `docs/routine-setup.md`, which discuss the format at length: the new
reader fires on none of them. The old one fired on several.

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

* test(dispatcher): pin that a dispatcher comment is never read as a session request

From the security review of this branch. This is the first thing that puts
an issue author's own bytes inside a bot-authored comment, so one term —
`!isDispatcherComment(c.body)` in `gather.latestRequest` — is now
load-bearing in a way it was not before.

Measured: a body line `Blocked by #1 <!-- sydevs-request {"replan":true,
"transfer":{"repo":"SahajCloud"}} -->` survives the echo intact, and
`parseRequest` reads the marker out of the posted comment. Only that filter
stops it reaching a replan or a cross-repo transfer. Dropping the filter
turns the new test red; nothing else in the suite notices.

So the test asserts the composition end to end on the body `commentOnce`
actually builds, and that the same marker in a session's own comment is
still honoured. `latestRequest` is exported for it, with the invariant
stated above it.

No finding in the review reached its reporting bar. The marker cannot break
out of the dedupe key either: every alternative of the target pattern draws
from `[\w.-]`, `/`, `#` and digits, so no target can contain `>` or a
space, and the ` -->` terminator stops a shorter key prefixing a longer
marker.

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

* fix(dispatcher): report the relationship, not the blocked state

The refusal opened with "Not blocked:", which the same plan can be
contradicting: a body carrying one resolvable `Blocked by` line beside an
unresolved one gets `label add:[blocked]` for the first and this comment
for the second. `issues.opened` and `issues.edited` both reach it.

The next clause already said the true, narrower thing, so that is now the
opener. Nothing else about the message or its key changes. The existing
test for a resolvable line beside a bare `#N` gains the assertion that
pins it.

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

* docs(routine-setup): the refusal is keyed on the targets

This clause described the key the branch carried before 849148d. The key
is `blocker-unresolved ${targets.join(' ')}`, and `docs/why.md` in this
same PR says so. A reader here was told the opposite, and would conclude
that rewording the reason reposts the comment.

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

* fix(dispatcher): sort the report key so order is not identity

`unresolvedBlockers('Blocked by #12 and #13')` keyed on `#12 #13`, so
swapping the two on the line keyed on `#13 #12` and `commentOnce` posted a
second comment about the same targets. Rewording the reason is the edit
the key was designed around, but an author correcting one of two targets
often rewrites the pair.

Both keys sort now — the reader's own line dedupe and the comment key.
The message is untouched: it still names the targets in the order written.

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

* refactor(dispatcher): expose latestRequest through gather's test seam

`latestRequest` has one in-module caller and one test. Exporting it
widened `gather`'s public surface with nothing marking it test-only, while
`decide.mjs` — the file this branch already edits — carries an
`export const _internal` for exactly that. `gather` gains the same seam.

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

* docs(why): the refusal reports the relationship, and sorts its key

Two clauses this branch's own section now got wrong. It claimed "the item
really is not blocked", which is the false assertion the message dropped —
a sibling line that resolved can be applying `blocked` in the same plan.
And the keying bullet did not say the key sorts its targets.

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

---------

Co-authored-by: sydevs-bot <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: sydevs-bot <[email protected]>
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.

1 participant