Repository navigation
fix(dispatcher): a marker reader trusts bytes it should qualify - #215
Conversation
…author `commentOnce` deduped on the marker alone, and every key is guessable from the item — 16 of the 18 on `main` prefix a fixed word with a head sha, a comment id or a PR number, and two are bare words. So anyone who could comment could pre-post `<!-- sydevs-dispatcher: <key> -->` and silence that advisory for the item's life. `loadRecord` returned the first comment that parsed, so a comment starting with `MARKER` seeded `current`, `pending`, `fixCi` and `dispatches`. Both filters are the one clause `isBot` already applies: the author must be `identity.expectedLogin`. Neither adds a call — the listings both seams make already carry `user.login` — so the login is threaded in, and `isLogin` holds the compare for the two seams that have the login and not the config. The filter lives in `loadRecord`, not `parseRecord`, which sees a body and no author. `isLogin` refuses an unnamed expected login, so a seam that forgets to thread it rejects every comment rather than accepting every anonymous one. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KjgKczBxjLAu2ggz3a4uB1
…cker `parseBlockedBy` had no fence state, unlike `parseOpenQuestions`, so a body that shows the marker format as documentation had the example read as live: related, labelled `blocked`, then deleted by `stripBlockedBy`. Swept over every tracked `.md`, `format-ticket/SKILL.md` was the one file that would have related `SahajCloud#632` and lost its own example. The flag goes into both loops. It cannot be shared: the stripper splits after every newline so each unit keeps its own line ending, and a reader-only fix would relate nothing while still deleting the line. Built against `main`'s shape. #204 introduces the shared `blockerLines` pass and is still open, so expect a conflict here if it merges first; the fence flag moves to that pass unchanged. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KjgKczBxjLAu2ggz3a4uB1
Only `identity.expectedLogin` is read back from a dispatcher-owned comment, so an operator who renames the bot or migrates the PAT sees every advisory re-post once and every status comment duplicated once. That is the accepted cost of the author filter, and it looks like a loop fault without a row saying so. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KjgKczBxjLAu2ggz3a4uB1
Joined to #205 by the same root cause, found while building it. The journal is a public issue in this repo, and both its dispatcher-owned markers read back without an author test. `postAnomaly` deduped on the visible line, so a hand-posted `⚠️ **<kind>** · <text>` silences that anomaly for the day — its own doc comment already said "said once a day, like the `commentOnce` beside it", and the resemblance was exact. `refreshTally` counted every author's `sydevs-dispatch-done` marker, so a stranger could inflate the day's title and the tally block `improve-loop` reads as the loop's usage evidence. Both take `config` already, so both call the existing `isBot`. `allComments` stays unqualified: a session's own journal entry is a comment too, and only these two readers act on a marker the dispatcher owns. Three fixtures gained the author they always had in production. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KjgKczBxjLAu2ggz3a4uB1
The fence skip was a flag in each loop, so adding one to `parseBlockedBy` left `parseRecheck` and `parseSentry` out — and a ticket fencing an example `Re-check: 2026-12-01` would have parked itself until that date. Same root cause as #205's part 2, joined to it. `liveLines` drops fenced blocks once, and all four line readers go through it; `parseOpenQuestions` loses the flag it carried. `stripBlockedBy` keeps its own loop, because it must emit every unit it does not drop and each unit carries its own line ending — it shares `isFence`, which is now the one definition of a fence here. That also ends the two spellings the first pass left: a trimmed `startsWith` in the readers, `unit.trim()` in the stripper. No behaviour changes for `parseBlockedBy`, `stripBlockedBy` or `parseOpenQuestions`; `parseRecheck` and `parseSentry` gain the skip. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KjgKczBxjLAu2ggz3a4uB1
…locks From the review round, no behaviour change beyond the first point. - `apply` and `doFire` read `config.identity.expectedLogin` without the optional chain. With it, a config missing `identity` made `isLogin` match nothing and every advisory re-post on every dispatch, silently and forever; now it throws once. `rerun.test.mjs`'s partial config gains the identity it always had in production. - The `commentOnce` and `loadRecord` docblocks carry the rule and the anchor, not the argument — the story belongs in `docs/why.md`. - `act.test.mjs` shares one `exhaustedTarget` literal with the test that already had it, instead of a second factory beside the copies. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KjgKczBxjLAu2ggz3a4uB1
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
Two conflicts, both the one this PR's body predicted, and both resolved by keeping each side's behaviour. dispatcher/markers.mjs — #204 lifted `parseBlockedBy`'s loop into a shared `blockerLines` pass that `unresolvedBlockers` reads too; this branch had put the fence rule in `liveLines`. The merged `blockerLines` iterates `liveLines(body)`, so one line carries both: #204's single scan, and the fence skip it inherits. A fenced `Blocked by:` line is now neither related, stripped, nor reported as unresolved — the coherent reading of #205, since a fenced line is documentation and #204's advisory would otherwise comment on an author's own example. dispatcher/apply.mjs — both sides added an import from `decide.mjs`. Both are used: `isLogin` at the `commentOnce` author test, `isReviewer` at #212's PR-author check. Verified: `node --test dispatcher/test/*.test.mjs` 308 passed, lean gate (`claude plugin validate ./workflow --strict`, `node --test workflow/lib/*.test.mjs` 97) green from the worktree. #205's fenced-body probes return `[]` for both readers, a live line still resolves its target, and a live line naming a PR URL is still reported — so neither side's tests are passing by losing the other's rule. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MdKgFW395rx3vdPocxnBNt
|
Merged
One consequence neither side specified alone: a fenced
Gate green from the worktree: 308 dispatcher tests, 97 lib, 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the size of #205: four author filters and one fence skip, and the two joined journal seams share the root cause, the file area and the verification command the join rule asks for. Nothing here is an abstraction for one caller, and no part should be removed. I reproduced both halves: origin/main relates SahajCloud#632 out of format-ticket/SKILL.md's own fenced example, this branch relates nothing, and 308 dispatcher and 97 lib tests pass from a worktree.
One shape point, and it is this PR's own argument turned back on it. The fence rule moved down into liveLines so the next reader inherits it. The author rule did not, and both callers of allComments now repeat it — on a reason I could not verify.
Findings
- should-fix —
journal.mjs:235: the author clause belongs insideallComments, where the fence rule's own argument puts it. - consider —
decide.mjs:49: a forgotten login reads as "no record", not as an error, and forloadRecordthat silently sweeps a live lease.
What was checked
- #205 criterion by criterion: six met, and the seventh is the author's attestation.
grep -n "loadRecord\|commentOnce("confirms all four and all five call sites thread the login, andbot's scope covers bothinSetBuildcalls (gather.mjs:236,:324). - Read whole:
markers.mjs,journal.mjs,record.mjs,apply.mjs'scommentOnceanddoFire,sweep.mjs:50-70, and all 34isBotsites. - The ticket's four probes from the branch: both fenced probes print
[], and thegit ls-files "*.md"sweep reports nothing forparseBlockedBy,parseRecheckorparseSentry. finish-runwritessydevs-dispatch-doneassydevs-bot, which is what makesrefreshTally's filter safe — and what defeats theallCommentsreason.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`postAnomaly` and `refreshTally` were the only two callers of the journal's private `allComments`, and both repeated the same `isBot` clause. That is the argument this branch already makes for `liveLines`, unapplied one file along: a third journal marker reader would have had to remember the clause. `ownComments(gh, config, issue_number)` filters at the listing, so it cannot be forgotten. The reason the old docblock gave for staying unqualified — a session's own entry is a comment too — does not hold: `finish-run` posts that entry as `identity.expectedLogin`, so the filter keeps it. The two tests that feed each reader a comment from `Ardnived` are the regression guard, and both still pass unchanged. The config also carries `org` and `journalRepo`, so the two scalar parameters go with it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVk1affeEKXcQiprsx
`isLogin` returned false for a missing `expected`, so a seam that forgot to thread the login refused every comment. That is quiet in the wrong place: `loadRecord` then returns no record, `sweep.mjs:59` reads a lock with no record as `sweep-timeout`, and the dispatcher breaks the lease of a live session. `apply` re-creates the record after it, losing `fixCi` and `dispatches`. It throws now, so the mistake is a crash at the forgetful seam. The whole dispatcher suite passes unchanged except the test that asserted the old semantics, which this branch added and which now asserts the throw: no `isBot` call site reaches the predicate without `identity.expectedLogin`, and `apply` already throws earlier on a config that lacks it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVk1affeEKXcQiprsx
|
Both of the critic's findings are built and both threads are resolved. Pushed
The base was already current — Gate green: One thing for you, in the body: an unbalanced fence now silences #204's 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
identity.expectedLogin, so a hand-posted marker can no longer silence an advisory or seed a record.Blocked by:,Re-check:andSentry:lines inside a code fence are documentation now, read by nobody —format-ticket/SKILL.md's own example was being related and then deleted.postAnomaly,refreshTally) had the identical defect, found while building part 1 — the journal is a public issue, andpostAnomaly's own doc comment already pointed atcommentOnceas its twin.liveLines, which is what broughtparseRecheckandparseSentryin; a flag per loop would have fixed two readers of five.Change outline
Flow — a dispatcher-owned marker, and where its author test comes from
The clause is one line at each seam. The threading is the change worth reading.
apply({ config, … }) dispatcher/apply.mjs + bot = config.identity.expectedLogin commentOnce(gh, t, bot, key, body, …) - comments.some(body.startsWith(mark)) # any author + comments.some(isLogin(c.user.login, bot) && body.startsWith(mark)) → "already posted", or post it doFire({ config, … }) + bot = config.identity.expectedLogin # not nested in apply() fire failed → commentOnce(…, bot, `fire-failed …`) loadRecord(gh, ref, bot) dispatcher/record.mjs listComments, page by page + isLogin(c.user.login, bot) → then parseRecord # the filter sees an author - parseRecord(c.body) truthy → that is the record # any author none → { id: null, rec: emptyRecord() } # the record is created -allComments(gh, owner, repo, n) dispatcher/journal.mjs - every author # each reader filtered +ownComments(gh, config, n) + isBot(c.user.login, config) → kept # the listing filters, once postAnomaly(gh, config, …) - allComments(…).some(anomalyLine(c.body) === line) # any author + ownComments(…).some(anomalyLine(c.body) === line) refreshTally(gh, config, …) - tallyFrom(allComments(…).map(c => c.body)) # any author + tallyFrom(ownComments(…).map(c => c.body)) isLogin(login, expected) dispatcher/decide.mjs + !expected → throw # was: matches nothing isBot(login, config) → isLogin(login, config.identity?.expectedLogin)Where the login comes from, at every call site:
gather(gh, target, config) dispatcher/gather.mjs bot = config.identity.expectedLogin # already bound, now used loadRecord(gh, base, bot) inSetBuild(gh, parent, childRef, lock, bot) loadRecord(gh, goalRef, bot) listSweepTargets({ config, … }) dispatcher/sweep.mjs + bot = … # hoisted from the orphan pass loadRecord(gh, ref, bot) ×2Behaviour — the decision per marker line
Reading a line is now two questions, not one. The second is new.
Files — where the fence rule lives
One reader owns it, so the next marker reader inherits it.
Test results
claude plugin validate ./workflow --strictpassed,node --test workflow/lib/*.test.mjs97 passed.node --test dispatcher/test/*.test.mjs308 passed (10 new, inrecord.test.mjs,act.test.mjs,journal.test.mjsandmarkers.test.mjs); the merge with fix(dispatcher): refuse a Blocked by line that names no issue #204 brought the rest.node workflow/lib/comment-lint.mjs --base origin/main: no banned comment added.rule-delta.mjs: not run. No file underworkflow/skills/is in this diff, soplugin.jsonkeeps its version too.stripBlockedBy's test still fails; with it removed from the stripper only, the reader's still passes. That is the trap the ticket's## Notesnamed.refreshTally's filter is only right if every session comments assydevs-bot, so I checked the real journal rather than the fixture: on Mon — 63 dispatches · 0 failed · 3 anomalies #214's first page, all 8 comments — 6sydevs-dispatch-doneacross four handlers (audit-nightly,review-pr,address-review,audit-deps) and 2 anomalies — are authored bysydevs-bot. It is structural, not incidental —start-runstep 1 stops a session that cannot matchget_metoidentity.expectedLogin, before it writes anything.record.test.mjsassumes a REST issue comment carriesuser.login, verified againstact.test.mjs's existing status-comment fixtures and the two seams' ownlistCommentscalls;markers.test.mjs's fenced body is copied fromworkflow/skills/format-ticket/SKILL.md:216-220, including its```markdowninfo string. The three fixtures that gaineduser: { login: 'sydevs-bot' }andrerun.test.mjs's config were incomplete, not canonical —act.test.mjsloads the realloop-config.json.Manual verification
BOT_DISPATCH=drydispatch over a scratch issue carrying a hand-posted<!-- sydevs-dispatcher: blocked -->comment from a human login. The plannedblockedcomment should still appear in the run log. A routine cannot reach the Actions dispatch, so this is yours.Notes for reviewer
The one judgement call:
isLoginexists because the criterion asked for the login, not the config. All three cleanup lenses argued the same alternative — passconfigtocommentOnceandloadRecordand call the existingisBot, dropping the new export. It is a fair reading: every call site does holdconfig. I built the criterion's shape instead, and the two joined journal seams show why it is coherent rather than merely literal:postAnomalyandrefreshTallyalready takeconfig, so they callisBot;commentOnceandloadRecordtake scalars only, asinSetBuilddoes withlock. Each seam uses the idiom its own signature already has, andisBotis now a one-liner overisLogin, so the compare is defined once either way. Say the word and it becomesconfigat all four.isLoginis strictly narrower than theisBotit replaces, and a missing expected login throws. The old compare returned true whenexpectedLoginwas absent and the login was too. EveryisBotcall site can therefore only become more restrictive, never less — I walked all 34, and the only widening shape (human = respondTo(login) && !isBot(login)) needs a login that is both inrespondToand falsy.The absent case is now a crash, not a
false, per the critic's second finding. Refusing every comment was quiet in the wrong place:loadRecordreports no record,sweep.mjs:59reads a lock with no record assweep-timeout, and the dispatcher breaks a live session's lease. The suite passes unchanged except the one test that asserted the old semantics, so noisBotsite reaches the predicate withoutidentity.expectedLogin.Review findings dismissed, with reasons.
ownComments(gh, ref, config)every marker reader goes through. Not taken as a shared helper.gather.newestCommentsmust stay unqualified — it carries human comments — so one helper would cover four seams and sit beside a deliberate exception, anddecide.mjsalready filters by author at each decision rather than at the fetch. Taken insidejournal.mjs, where the critic put it on the second round: both callers of the privateallCommentsrepeated the clause, and the reason given for leaving it off — a session's entry is a comment too — did not hold, becausefinish-runposts that entry assydevs-bot.startsWithahead ofisLogin, and lower-case the constant side once. Not taken. The clause order states the invariant — author first, then marker — and both seams sit behind a paginated HTTP request that costs four orders of magnitude more than the allocations saved.~~~fences too, sinceste-lint.pydoes. Not taken. It would changeparseOpenQuestions, which no criterion here covers, and no tracked file uses that spelling.stripBlockedByand the readers. Not taken as a flag; taken asisFence. The stripper must emit every unit it does not drop, and each unit carries its own line ending, so it keeps its loop.One consequence of the #204 merge, for your call. A fenced
Blocked by:line naming no in-org issue is now also not reported by #204'sunresolvedBlockersadvisory. That is deliberate — a fenced line is documentation, so the advisory would otherwise comment on an author's own example. The edge it opens: an unbalanced fence in a body silently suppresses both the relationship and the advisory that exists to say "the body advertises a blocker nothing enforces". Author-self-inflicted, not reachable by anyone who cannot already edit the body, and a fix costs more than malformed markdown is worth. Say the word if the advisory should see fenced lines.Also noticed, deliberately not in scope.
relationships.bodyMarkerFormat(loop-config.json:362) is still read by no code — #205's## Notesnames it, and it is a dead value rather than a defect. It belongs in whatever next edits that block.Detail
Measurements.
parseBlockedByreturned[{sydevs/SahajCloud#632}]and now returns[];stripBlockedBy(…).droppedwas the fenced line and is now[].git ls-files "*.md": one file reported a would-relate target before (workflow/skills/format-ticket/SKILL.md→SahajCloud#632), none does now.parseRecheckandparseSentryswept the same way: no tracked file reads as state either before or after. That exposure is real but unwitnessed, like part 2's was beforeformat-ticket/SKILL.mdwas measured — the fix is the same line, from the same place.grep -rn "loadRecord\|commentOnce(" dispatcher/*.mjs: every posting call site passes a login. ThecommentOncehits indecide.mjsare the plan-action constructor (decide.mjs:22), not the poster.Why these commits ride together. One root cause, one file area, one verification command — the join rule's three tests. Each is separately revertable:
be81a6d— part 1, the two seams the ticket names.4372041— part 2, the fence skip in the two blocker readers.dbeb9d3— the troubleshooting row for the one-off duplicate a bot rename now causes.ffdcc35— joined: the journal's two owned markers.aa170e0— joined: the fence rule moves underliveLines, which brings inparseRecheckandparseSentry.d8fef65— the first review round's cleanups.c9858a0— the merge with fix(dispatcher): refuse a Blocked by line that names no issue #204 and fix(loop): a PR the reviewer wrote asks nobody for a review, and a refused finding waits in the usage report #212.583dbc3— the critic's round: the journal's author test moves intoownComments.8de5691— the critic's round: a forgotten login throws.The accepted one-off duplicate. A comment the bot wrote under a former login stops being recognised, so after a rename or a PAT migration every advisory re-posts once and every record is re-created once, per open item, across five repos. That was decision 1 on the ticket (A, Ardnived, 2026-10-21) and no reconciliation path is built for it.
docs/routine-setup.mdgains a troubleshooting row so the symptom is not read as a loop fault.Security.
/security-reviewran on both rounds, assecurityReview.triggerPatternrequires for a^dispatcher/diff, and reported nothing at either severity. Points worth keeping:isLoginonly ever refuses where the oldisBotaccepted, so noisBotcall site can start treating a human as the bot — the direction that would matter. All 34 were enumerated.user,ghost, and a GitHub App'ssydevs-bot[bot]all fail the compare, andlowerusestoLowerCase, not the locale form, so there is no Turkish-Ifold onto a login GitHub restricts to[A-Za-z0-9-].liveLineshas no reveal direction — it only skips — and the hide direction grants a body author nothing they could not get by deleting the line. An outsider's body markers are already inert (decide.mjs:750), and the real blocked gate is the native relationship, which no body text can clear.expectedis never attacker-influenced — it has one origin,config.identity.expectedLogin— so the new throw is not reachable from a comment, a body or an event payload.ownCommentspages on the raw page length, not the filtered array, so the obvious refactoring bug is absent.postAnomaly's call sits in itstry/catch, andrefreshTallyruns insidejournalTick'sstep().Not run:
/pr-review-toolkit:review-pr. No routine has the plugin, so the pass was/code-review's four cleanup angles via/simplify, plus/security-review.Closes #205
Generated by Claude Code