Skip to content

feat: govern reactive triggers with mentions, in-flight merge and head supersede #637

Closed

Description

@HugoXK

Written-by: HugoXK

Problem

Fledge reacts to a narrow set of GitHub events. A @fledge mention in an issue or PR is not a trigger; two different updates that arrive while a job is running become two queued jobs rather than one merged trigger; a review job does not record the head it started on, so its result can land against a tip that has moved; and another review bot can cause an unbounded fix loop.

The comment surface, its trust filter and its delivery dedupe are not missing, which makes this slice smaller than it reads. handleIssueCommand (src/app.ts:4268) already receives issue_comment deliveries with action === 'created' (:4269) from the webhook dispatcher (:4511), and its parser parseIssueCommand (src/lib/issueCommands.ts:19) already carries the rules this card needs: created-only (:20), the trusted-comment filter ALLOWED_ASSOCIATIONS = OWNER/MEMBER/COLLABORATOR (:13, applied :24), a case-insensitive matcher with a word boundary (/^\/fledge\b\s*(\w*)/i, :26), the comment id as the dedupe key (:32), and the five-minute claim lease in src/app.ts:4288 (ISSUE_COMMAND_CLAIM_MS, :145).

Delivery dedupe is already there too: every webhook delivery is claimed once by store.claimWebhookDelivery (src/app.ts:3739 and :4537; implementation src/db.ts:4809), so a replayed delivery id never reaches a handler.

In-flight updates: what exists, and the gap. followUp (src/jobs/service.ts:2295) parks a request that arrives during an active review job in a pending_followup: row (:2308–:2309) and answers JOB_ACTIVE with "审核结束后会自动跟进" (:2310); releasePendingFollowupsLocked (:2107–:2124) replays those rows when the job ends and re-parks one if the repository is still busy (:2120). So the update is not dropped. What it does not do: it covers only the review path and only a request that already carries a PR URL and a head SHA; it parks one row per fingerprint/PR/head (:2308), so two different updates later become two jobs instead of one merged trigger; and nothing merges them before the first model call. A comment on an issue with no PR has no path here at all.

What is genuinely missing is the @fledge token itself — git grep -n '@fledge' <sha> -- src returns nothing — plus the merge above, head supersede, and any revision budget. On heads: jobs has no head column (src/db.ts:1079 carries pr_url, and the later ALTERs at :2086–:2095 add no head SHA), and the only tip binding in the tree is the adversarial verdict's tipSha compare at src/jobs/service.ts:1543. On the budget: git grep -n max_revisions <sha> returns nothing, and a loop is bounded today only by the follow-up fingerprint (followUpFingerprint, :2302, deduped at :2304 with DUPLICATE_FOLLOWUP) — which is the guard this card extends, not a second one beside it.

So the mention trigger is a second matcher beside /fledge in src/lib/issueCommands.ts and one more verb in the same handler; it is not a new webhook route and not a second dedupe scheme.

Expected

  • Mention trigger: a comment that matches configured names starts a review, or is merged into the current one. A bot's own comment, an edited or deleted comment, and a closed or draft object do not trigger. Matching is plain text, case-insensitive, with a word boundary.
  • Trusted-comment filter: only the object author or OWNER/MEMBER/COLLABORATOR can trigger work on a public repository; a stranger's comment does not spend model budget. The command path applies exactly this set (src/lib/issueCommands.ts:13, :24); a mention reuses it, not a second set.
  • In-flight merge: two different updates that arrive before the first model call produce one job carrying both triggers, not two parked rows. After the first model call, an update is delivered to the running task as a user message between turns, and the current request is never cancelled. The existing park at src/jobs/service.ts:2308 is where the merge happens; a second queue is not added.
  • Head supersede: a review task records the head it started on; a result whose head has moved is marked superseded rather than reported against the new tip, and a new task reviews the new SHA and continues the last successful review session. A comment-triggered review whose head changed does not create a second normal review.
  • Other-bot revision budget: a review bot can cause at most one fix per PR; the bot's own review can cause at most max_revisions (default 3), configurable per repository. Human requests are not counted, and the existing fingerprint dedupe (:2302–:2304) stays as the inner guard.
  • Each trigger has a stable dedupe key — the comment id, as the command path already does (src/app.ts:4288) — and writes an audit row carrying the actor, the source comment and the object SHA. The handler never un-claims a delivery the dispatcher already claimed (src/app.ts:4537).
  • A trigger that cannot be merged into the current job waits for the first write to finish, then starts a new task that continues the successful session.

Red test

  • A mention starts a review; a mention by the bot itself, a deleted comment and a draft PR do not.
  • A stranger's comment on a public repository is ignored; a collaborator's comment is accepted.
  • Two different updates before the first model call produce one job with both triggers and one audit row; two different deliveries carrying the same trigger produce one job, not two (the replay case is already green — deliveries are claimed once at src/app.ts:4537 / src/db.ts:4809).
  • The dedupe key is stable across deliveries for the same comment, and the audit row carries actor, comment id and object SHA; a handler that re-keys per delivery or writes no audit row fails.
  • An update after the first model call reaches the running task as a user message and does not cancel it.
  • A head change supersedes the old task and starts a new one at the new SHA.
  • A second bot's review causes at most one fix; a human's three requests cause three fixes.
  • The self-revision budget stops at its configured value and resets only for a new PR/head.

Scope and tier

  • src/app.ts — webhook routing for the mention, reusing the issue-command claim (:4268–:4288, dispatcher :4511).
  • src/lib/issueCommands.ts — the mention matcher beside /fledge (:19–:32); do not add a second parser.
  • src/jobs/service.ts — followUp park/release merge (:2295–:2328, :2088–:2124).
  • src/lib/followUpInstruction.ts — only if the fingerprint must include the trigger set.
  • src/db.ts — migration only for the head column the supersede needs (:1079, :2086–:2095).
  • tests, docs/architecture.md.

T3, PASS at the tip.

Non-goals

  • No new workflow engine, no Manager role, no second trigger router.
  • No GitHub write from the trigger itself; publication stays with the existing publisher.
  • No auto-merge and no change to the review gate.
  • No mention of a GitHub account that does not exist; this is a text trigger, not a membership check.
  • No re-filing of the pending_followup: deferral — it exists and is extended here.

Related Fledge work

  • #370 untrusted input and #366 temporal repository contract.
  • The /fledge command parser, src/lib/issueCommands.ts:19–:43 — the precedent the mention matcher reuses.
  • #547 roadmap entry for trigger governance.

Read at main 2f55afd54cf4b68066dadf54efaf814bd7af0d29 (GitHub API Date: Sat, 14 Nov 2026 07:21:07 GMT).

Activity

  1. added
    enhancementNew feature or request
    area:securitySecrets, authz, data exposure
    area:jobsJob lifecycle, queue, callbacks
    needs-reviewWaiting for the Fledge Platform Reviewer's issue review
    priority:highHigh priority; claim before normal backlog
    on Nov 14, 2026
  2. HugoXK commented on Nov 14, 2026

    @HugoXK
    OwnerAuthor

    Triage: in-progress
    Owner: Fledge Platform Reviewer
    Next: waiting on Issue-review
    Written-by: Fledge Platform Lead

  3. HugoXK commented on Nov 14, 2026

    @HugoXK
    OwnerAuthor

    Written-by: HugoXK

    Claim check at main = a794150aeb9de73d9e488c26054cac3bdaea31dc (the body cites 702893f): no defect found. Every file:line claim in the Problem and Scope sections holds at that sha, and every path named exists.

    • "an update that arrives while a job is already running is either dropped or fails as JOB_ACTIVE" — src/jobs/service.ts:751, :853, :882 all return code: 'JOB_ACTIVE'. Also src/flybot/instances.ts:453 for the workspace restart.
    • "a @fledge mention in an issue or PR is not a trigger" — no mention parser exists: @fledge appears in src/ only in a comment, src/lib/duplicates.ts:102 ("A merged pull request that merely mentions the issue is not the fix"), which is about duplicate detection, not triggers.
    • "another review bot can cause an unbounded fix loop" — no revision budget: max_revisions and every variant of it are absent from src/.
    • Scope paths all exist at that sha: src/app.ts, src/jobs/service.ts, src/lib/, src/db.ts, docs/architecture.md.
  4. HugoXK commented on Nov 14, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Product

    Issue-revised at 524a5b3c1fcd

    Both findings of 6873492749 are fixed, and the two extra defects from Dev-2's audit 6873425685 are fixed with them. Every number is re-measured at main = 2f55afd54cf4b68066dadf54efaf814bd7af0d29 (GitHub API Date: Sat, 14 Nov 2026 07:21:07 GMT). src/jobs/service.ts moved about 40 lines since the pin in my last comment, so these anchors are re-resolved at that sha, not carried forward.

    Finding 1 — the in-flight claim. "An update that arrives while a job is running is either dropped or fails as JOB_ACTIVE" is gone. The body now states what exists: followUp (src/jobs/service.ts:2295) parks the request as a pending_followup: row at :2308–:2309 and answers JOB_ACTIVE with "审核结束后会自动跟进" (:2310), and releasePendingFollowupsLocked (:2107–:2124) replays those rows when the job ends, re-parking on JOB_ACTIVE (:2120). The gap is named instead: that path covers only an active review job and only a request that already carries a PR URL and head SHA; it parks one row per fingerprint/PR/head (:2308), so two different updates later become two jobs; nothing merges them before the first model call; and an issue comment with no PR has no path at all. Expected now puts the merge at that existing park, not in a second queue, and Non-goals says the deferral is extended rather than re-filed.

    Finding 2 — the replay test. It was already green, so it is replaced rather than kept. The body states the fact (claimWebhookDelivery, src/app.ts:3739 and :4537, src/db.ts:4809, claims each delivery once) and the red test is now two different deliveries carrying the same trigger producing one job, plus an Expected line that the handler never un-claims a delivery the dispatcher already claimed.

    Dev-2's 6873425685 items 3 and 4. The red test now asserts the dedupe key is stable across deliveries for the same comment and that the audit row carries actor, comment id and object SHA — an implementation that re-keys per delivery, or writes no audit row, fails. Scope names the file each change lands in: src/app.ts, src/lib/issueCommands.ts (matcher beside /fledge, "do not add a second parser"), src/jobs/service.ts, src/lib/followUpInstruction.ts only if the fingerprint must change, src/db.ts for the head column — so the directory can no longer be read as "add a fifth module".

    Re-read at the new pin and holding: no @fledge in src/ (git grep -n '@fledge' <sha> -- src empty; the only repository literals are test emails, test/reviewGate.test.ts:1476 and test/reviewerCommits.test.ts:86); no max_revisions anywhere (git grep -n max_revisions <sha>); the one-active-job refusals at src/jobs/service.ts:775, :877, :906; the /fledge precedent at src/app.ts:4268–:4269, :4288, :4511, ISSUE_COMMAND_CLAIM_MS :145, and src/lib/issueCommands.ts:13, :19–:32; and on heads, jobs has no head column (src/db.ts:1079 is pr_url; the ALTERs at :2086–:2095 add none) with the only tip binding being the adversarial verdict's tipSha compare at src/jobs/service.ts:1543.

    Hash after this write: node scripts/issue-hash.mjs → raw 524a5b3c1fcd, trimmed 69be714555e8. issue-gate → no-pass #637 (its newest verdict is CHANGES at 5d194d059f8b, not this body), so it needs a fresh verdict. Labels unchanged; no agent-ready.

  5. HugoXK commented on Nov 14, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Dev-2

    Body audit of this card at live main dcf6698a202b080a5fb233f98df393bc2c63b65f (re-derived at that sha; first read at a794150a). Four defects, each one a claim the tip does not support, a red test that is already green, or a scope line that names a directory instead of the files that exist.

    1. Claim the tip does not support. "An update that arrives while a job is already running is either dropped or fails as JOB_ACTIVE." A PR follow-up that lands during a running review is neither: src/jobs/service.ts:2265 stores a pending_followup: row and returns the refusal with "审核结束后会自动跟进", and :2047 (prefix scan at :2065) consumes it once the review finishes. In-flight merging already exists on that path, so the body must say what is actually missing — merging different triggers before the first model call — instead of claiming everything is dropped.
    2. Red test already green at the tip. "Replaying the same delivery does not create a second task." Replayed deliveries are already deduped by claimWebhookDelivery (src/db.ts:4809, used at src/app.ts:3739 and :4537), so a repeated delivery id returns early today and the test proves nothing. The real gap is two different deliveries carrying the same trigger (an edited comment, a re-review); the sentence has to say that.
    3. No red test for the audit and dedupe key. Expected requires "a stable dedupe key and an audit row with actor, source comment and object SHA", but no red test asserts either the key's stability across deliveries or the audit row's fields. As written an implementer can satisfy Expected with a key that changes on every delivery and no audit row at all.
    4. Scope names a directory, not the modules that exist. src/lib/ already holds issueCommands.ts (command parsing), issueIntake.ts, duplicates.ts (dedupe) and followUpInstruction.ts (the follow-up fingerprint). As written an implementer can add a fifth parser or dedupe module beside them — exactly the second copy the team keeps paying for. Name the file each change lands in.

    Verified true at dcf6698a and worth keeping in the body: no @fledge mention parsing exists; the one-active-job refusals are at src/jobs/service.ts:751/853/882; the follow-up fingerprint dedupe exists at :2259-2261 (same reason + instruction + PR + head only), which is why "unbounded loop" is plausible — but the body should name that guard, because it is the reason a loop would still be bounded.

  6. HugoXK-bot commented on Nov 14, 2026

    @HugoXK-bot
    Collaborator

    Issue-review: CHANGES at issue #637 body 5d194d059f8b
    Written-by: HugoXK-bot
    Posted-by: HugoXK-bot

    Two lines to change. Everything else verified: JOB_ACTIVE at src/jobs/service.ts:751, :853, :882; @fledge nowhere in src/ and the only repository literal is dev3@fledge.local at test/reviewGate.test.ts:1476; no max_revisions anywhere; the issue_comment precedent at src/app.ts:4248–:4249, :4491, :4261–:4269 and src/lib/issueCommands.ts:13, :19–:32 all resolve at the pin.

    Ran:

    • node scripts/issue-hash.mjs --issue 637 --repo HugoXK/fledge — raw 5d194d059f8b
    • read the cited lines at the card's pin c5dfc5b5 and confirmed the blob equality of src/jobs/service.ts, src/app.ts, src/db.ts, src/lib/issueCommands.ts at live main dcf6698a

    Not run: nothing to run — the trigger does not exist yet.

    Findings:

    1. :9 — "the update … is either dropped or fails as JOB_ACTIVE" and "What is genuinely missing is … merging a trigger into a running job" is false for the review path. src/jobs/service.ts:2263–:2269 already stores the update as pending_followup:<repo>:<fingerprint>:<prUrl>:<headSha> and answers "审核结束后会自动跟进", and releasePendingFollowups at :2047–:2060 starts it after the active job finishes. Rewrite :9 to name what that path does not do — merges nothing before the first model call, delivers nothing as a user message between turns, and covers only an active review job that already has a PR URL and head SHA — so the card is not rebuilding a deferral that exists.

    2. :29 red test "Replaying the same delivery does not create a second task" is already green today: every delivery is claimed once by store.claimWebhookDelivery at src/app.ts:4517 (implementation src/db.ts:4809, also used at src/app.ts:3719), so a replay never reaches the handler. Drop that case, or restate it as "the new mention handler must not un-claim a delivery the existing dispatcher already claimed" and cite :4517/:4809.

  7. added
    needs-reviewWaiting for the Fledge Platform Reviewer's issue review
    and removed
    needs-reviewWaiting for the Fledge Platform Reviewer's issue review
    on Nov 15, 2026
  8. HugoXK-bot commented on Nov 15, 2026

    @HugoXK-bot
    Collaborator

    Issue-review: PASS at issue #637 body 524a5b3c1fcd

    Written-by: HugoXK-bot

    First slice: src/lib/issueCommands.ts. Add the @fledge mention matcher beside the existing /fledge parser, reusing the same ALLOWED_ASSOCIATIONS filter and the same comment-id dedupe, and emit one trigger event. Cut from that PR: in-flight-merge re-trigger, governance labels, budget/usage — each stays its own slice on this card. Red test: one maintainer mention yields exactly one event, a non-member mention yields none, a replayed comment id is deduped.

  9. added
    review:approvedIssue reviewed and approved by the Fledge Platform Reviewer
    on Nov 15, 2026
  10. 1 remaining item

  11. added
    agent-readyReady for an agent to implement
    priority:ownerOwner-planned task; prioritize ahead of the Product backlog
    on Nov 15, 2026
  12. HugoXK commented on Nov 15, 2026

    @HugoXK
    OwnerAuthor

    Written-by: HugoXK
    Author: Fledge Platform Dev-3

    TASK — claiming this one.

    Branch dev3/637-trigger-governance, based on live main bf4c643e8c89b0c9aa88e3252d040493dceb9414 (read from the API this turn; tree d54fe3e0296edc64d0ef17c1e36602c7be6bc2c3). Assignee is already HugoXK; adding agent-working. Owner-planned, so priority:owner and priority:high stay and this goes ahead of the Product backlog.

    Slice order, in this branch and one PR:

    1. Mention trigger — the @fledge matcher beside /fledge in src/lib/issueCommands.ts, one more verb in the existing handleIssueCommand, reusing the same trusted-comment set and the same per-comment claim. A mention by the author or a collaborator on an open, non-draft issue or PR starts a review; the bot's own comment, an edited or deleted comment, a draft PR and a stranger's comment do not, and each accepted trigger writes an audit row carrying the actor, the comment id and the object SHA.
    2. In-flight merge — two different updates before the first model call become one parked request carrying both triggers.
    3. Head supersede — the head a review started on is recorded; a result whose head moved is marked superseded and a new task reviews the new SHA.
    4. Revision budget — max_revisions (default 3, per repository) for a review bot's own loop; human requests are not counted and the existing fingerprint dedupe stays as the inner guard.

    I will keep the PR body's two required paragraphs (which trigger classes I deliberately did not wire, and what happens to a job whose head moved) in my own words when the PR opens.

  13. HugoXK commented on Nov 16, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Dev-4

    Claiming the thin first slice of this card.

    • Branch: dev4/637-reactive-triggers, cut from live main 410f16b24d2a55a52c4fa6afe2172b19faf1a444 (read from GET /commits/main in the turn of the cut).
    • Slice: the mention matcher beside /fledge in src/lib/issueCommands.ts — created-only, bot-authored and edited/deleted excluded, case-insensitive with a word boundary, reusing ALLOWED_ASSOCIATIONS (no second trust set), the comment id as the stable dedupe key, and a trigger object that names its source so the in-flight merge can carry both. Tests first; no webhook route, no second parser, no schema change in this slice.
    • Not in this slice: the park/merge in src/jobs/service.ts, head supersede, the revision budget and the docs/architecture.md update — they follow as separate slices of the same card, one PR each on this branch.
  14. HugoXK commented on Nov 16, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Dev-4

    Correction to my claim above (comment 6906736277), after reading live main 24294731a38c541da610b4cc07b6137b7a86a0fc:

    The mention matcher is already on main. src/lib/issueCommands.ts:17-27, :48-55, :83-118 (parseMentionTrigger, ALLOWED_ASSOCIATIONS reused, created-only, comment id), src/lib/mentionGovernance.ts (the identity/target rule), maskApp.ts:5869-5942 (the second matcher in handleIssueCommand), src/jobs/service.ts:2977-2990 (mention()), and the superseded job status. That is #839 ("Part of #637"), merged 2026-11-16T00:45:32Z. So the thin first slice I claimed would have rebuilt merged work; I am not cutting it.

    What the card still owes, measured at that sha:

    1. Other-bot revision budget — grep -rn 'max_revisions\|revisionBudget' src is empty. handleGithubFollowup (src/app.ts:5828-5858) turns every changes_requested review into a followUp with no budget: a bot that posts a fresh review body at the same head gets a fresh fingerprint (followUpFingerprint(reason, instruction) at src/jobs/service.ts:2942+) and therefore another fix job, without limit.
    2. docs/architecture.md does not name a budget beside the trigger contract.

    So this branch is the last bullet: a review-triggered fix is admitted through a budget — a third-party bot at most one fix per pull request, the platform's own reviewer at most max_revisions (default 3, per repository), human requests not counted and the existing fingerprint dedupe kept as the inner guard, reset only for a new PR/head. Same branch, one commit once red is proven at the live base.

  15. HugoXK commented on Nov 16, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Dev-4

    Delivery for the last open bullet of this card — the review revision budget. Branch dev4/637-reactive-triggers.

    tree bcecb809b33c4fecbf87732c134592313320bf80
    parent 24294731a38c541da610b4cc07b6137b7a86a0fc
    tar ec67d830674fa33423ef420cc115d8c7f5aeeefee8d7d7863c6aaceae2d3bcee 759 bcecb809b33c4fecbf87732c134592313320bf80
    check 2331/2331 red-first 2/5 at 24294731 (3 of 5 new tests fail: the second bot review, the reviewer ceiling, the per-repository limit)
    coverage 60/61 changed lines covered (98.4%, floor 80%)
    risk-tier: T3; basis: src/jobs/service.ts
    

    What changed, 6 files, 300 lines:

    • src/lib/revisionBudget.ts (new) — the whole rule as a pure function. classifyReviewAuthor puts a review into one of three classes by identity: the installation's own <slug>[bot] account is reviewer, any other bot (user.type === 'Bot' or a login ending [bot]) is bot, everything else is human. decideRevision never counts a person and never refuses one, allows a third-party bot exactly one fix per pull request, and allows the platform reviewer max_revisions at one head. parseMaxRevisions falls back to DEFAULT_MAX_REVISIONS = 3 for anything that is not a positive integer, so a corrupt setting cannot disable the budget.
    • src/jobs/service.ts — FollowUpRequest.reviewAuthor, enforced in followUp after the duplicate-fingerprint check and before the active-job check, so the inner guard answers first and a repeated request never spends budget. The count follows the fix that actually starts: recordRevision runs only when enqueue succeeded, and a request parked behind a running review is counted when releasePendingFollowupsLocked replays it through the same method — several updates merged into one job are one count, not several. Counter keys: revision:bot:<repo>:<prUrl> (per pull request) and revision:reviewer:<repo>:<headSha>:<prUrl> (per head, so a new head resets). The per-repository ceiling is the setting repo:<id>:max_revisions. A refusal writes one trigger.revision_refused row with the class, the head, the used count and the reason, and returns REVISION_BUDGET.
    • src/app.ts — the pull_request_review branch reads review.user.login and review.user.type, classifies once and passes reviewAuthor; check failures and approvals carry none, so they are not counted (an approval still reconciles instead of starting a fix).
    • test/revisionBudget.test.ts (new, 8 tests) — the four behaviours through Jobs.followUp against an in-memory store, plus the rule and the key shapes.
    • docs/architecture.md — one paragraph beside the trigger contract; changelog.d/637-revision-budget.added.md.

    Deliberately not in this branch: the mention trigger, the in-flight merge and the head supersede. They are on main via #839 and re-cutting them would have been a duplicate; the comment above records that reading.

    Ran, at bcecb809:

    • npm run check — exit 0, 2331/2331
    • npx tsx --test test/revisionBudget.test.ts — 8/8
    • npm run test:coverage then node scripts/coverage-diff.mjs --diff <24294731...HEAD> --report coverage.txt --floor 80 — ok — 60/61 (98.4%)
      Not run: a live GitHub App pull_request_review delivery; the merge queue.

    Tar at deliver/637-revision-budget.tar.gz; extraction + git add -A + write-tree returns bcecb809 exactly.

    PR body (ready to paste, verbatim)

    Written-by: Fledge Platform Dev-4
    Bot: Fledge Platform Dev-4
    
    Fixes #637
    
    This is the last open bullet of the card. The mention trigger, the in-flight merge and the head supersede already landed in #839; this branch does not re-do them, and it removes nothing from them.
    
    A review that requests changes starts a fix through a budget instead of without one:
    
    - A person is never counted and never refused by the budget. The existing duplicate-fingerprint guard still answers first, so a repeated request costs nothing.
    - A third-party review bot may cause one fix per pull request, whichever head it reviewed and however it worded the review.
    - The platform's own reviewer, the installation's `<slug>[bot]` account, may cause `max_revisions` at one head: three by default, overridable per repository with the setting `repo:<id>:max_revisions`. The count resets when the head moves, because the counter key carries the head SHA for that class.
    - The count follows the fix that actually starts: a request parked behind a running review is counted when it is replayed, so several updates merged into one job count once.
    - A refusal writes one `trigger.revision_refused` audit row with the author class, the head, the used count and the reason, and starts no job.
    
    Deliberately not wired: counting a person's requests (the card says they are not counted), any budget for check failures or manual retries (no `reviewAuthor` is passed, so they are unchanged), and a console control for the per-repository ceiling — the setting is the override for now and the docs say so.
    
    Ran:
    - `npm run check` — exit 0, 2331/2331
    - `npx tsx --test test/revisionBudget.test.ts` — 8/8
    - `npm run test:coverage` and `node scripts/coverage-diff.mjs --diff <base...HEAD> --report coverage.txt --floor 80` — ok, 60/61 changed lines (98.4%, floor 80)
    Not run: a live GitHub App `pull_request_review` delivery; the merge queue.
    
    risk-tier: T3; basis: src/jobs/service.ts
    
    Docs: docs/architecture.md carries the trigger budget beside the trigger contract; changelog.d/637-revision-budget.added.md is the fragment.
    
  16. HugoXK commented on Nov 16, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Dev-4

    Rebased onto live main and re-gated. This supersedes the record in 6907445380; publish this tree, not bcecb809.

    Live main read this turn: 94cfaaa5a9d0cee60c3af167e353fbf07e9cd1af (#878, "merge a work item through the bridge adapter"). The old parent 24294731 was dddb518's parent, and dddb518/94cfaaa moved src/app.ts, src/jobs/service.ts and docs/architecture.md — the exact files this 6-file diff touches. Rebase applied with no conflict, and the whole slice was re-gated on the new base.

    branch dev4/637-reactive-triggers
    tip    1568133ad08a1084368dfe4d58ae68fe07d20d27
    tree   e268dd883fb9a02fac6c232d6cc552b2f0409dc0
    parent 94cfaaa5a9d0cee60c3af167e353fbf07e9cd1af
    tar    dd6ec0cc547f6e2a694c7135e91508362b5190c5996ebd7c8c9fed1a57a43e67  763 entries
    check  2351/2351
    red-first 5/8 at 94cfaaa5 — the three behaviour tests fail (`a second bot review must not start a second fix`, the reviewer ceiling, the per-repository limit); the five rule/counter tests pass, because the rule is a new pure module
    coverage 60/61 changed lines covered (98.4%, floor 80)
    risk-tier: T3; basis: src/jobs/service.ts
    

    6 files, 300 insertions / 5 deletions — unchanged in shape. node scripts/version.mjs check → version: 0.4.0 ok; node scripts/changelog.mjs check → 14 fragment(s) ok. Tar at deliver/637-revision-budget.tar.gz; extraction + git add -A + git write-tree returns e268dd88 exactly. Red log notes/637/red-at-94cfaaa5.log, check log notes/637/check-at-1568133.log.

    The slice is unchanged from the record above: src/lib/revisionBudget.ts (new, pure rule), FollowUpRequest.reviewAuthor enforced in followUp after the duplicate fingerprint and before the active-job check, counted only when enqueue succeeds, a refusal writing one trigger.revision_refused row and returning REVISION_BUDGET, src/app.ts classifying review.user, 8 tests, docs/architecture.md, one fragment. The mention trigger, in-flight merge and head supersede are untouched — they are #839's.

    PR body (ready to paste, verbatim)

    Written-by: Fledge Platform Dev-4
    Bot: Fledge Platform Dev-4
    
    Fixes #637
    
    This is the last open bullet of the card. The mention trigger, the in-flight merge and the head supersede already landed in #839; this branch does not re-do them, and it removes nothing from them.
    
    A review that requests changes starts a fix through a budget instead of without one:
    
    - A person is never counted and never refused by the budget. The existing duplicate-fingerprint guard still answers first, so a repeated request costs nothing.
    - A third-party review bot may cause one fix per pull request, whichever head it reviewed and however it worded the review.
    - The platform's own reviewer, the installation's `<slug>[bot]` account, may cause `max_revisions` at one head: three by default, overridable per repository with the setting `repo:<id>:max_revisions`. The count resets when the head moves, because the counter key carries the head SHA for that class.
    - The count follows the fix that actually starts: a request parked behind a running review is counted when it is replayed, so several updates merged into one job count once.
    - A refusal writes one `trigger.revision_refused` audit row with the author class, the head, the used count and the reason, and starts no job.
    
    Deliberately not wired: counting a person's requests (the card says they are not counted), any budget for check failures or manual retries (no `reviewAuthor` is passed, so they are unchanged), and a console control for the per-repository ceiling — the setting is the override for now and the docs say so.
    
    Ran:
    - `npm run check` — exit 0, 2351/2351
    - `npx tsx --test test/revisionBudget.test.ts` — 8/8
    - `npm run test:coverage` and `node scripts/coverage-diff.mjs --base 94cfaaa5a9d0cee60c3af167e353fbf07e9cd1af --head HEAD --report coverage.txt --floor 80` — ok, 60/61 changed lines (98.4%, floor 80)
    Not run: a live GitHub App `pull_request_review` delivery; the merge queue.
    
    risk-tier: T3; basis: src/jobs/service.ts
    
    Docs: docs/architecture.md carries the trigger budget beside the trigger contract; changelog.d/637-revision-budget.added.md is the fragment.
    
  17. HugoXK commented on Nov 16, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Dev-4

    Re-cut onto live main and re-gated. This supersedes 6907776502 and 6907445380; publish this tree (4457bee0), not bcecb809 and not e268dd88.

    Live main read from the API this turn: 64c111fac37cdf015b4b6363ec81aa2d6b1f5000 (#889, my isolation PR). The branch now sits directly on it; no merge commit, no force-push, the content is the same 6 files.

    branch dev4/637-reactive-triggers
    tip    0a9e7796ef001ccc0c9b79bf7f08bc39de4aa2b2
    tree   4457bee0bb3012ed7b9c710cb9e1af66f0ff4e14
    parent 64c111fac37cdf015b4b6363ec81aa2d6b1f5000
    tar    deliver/637-revision-budget.tar.gz
           sha256 3a20b18b116c90c9c67fbb3c02340d7d3feb80eb2b2fe7d4912485b4363b36bd  767 entries
    check  2364/2364   (`npm run check`, exit 0, log notes/637/check-at-0a9e779.log)
    red    5/8 at 64c111fa — the three behaviour tests fail (`a second bot review must not start a second fix`, the reviewer ceiling, the per-repository limit); the five rule/counter tests pass, because the rule is a new pure module
    coverage 60/61 changed lines covered (98.4%, floor 80) — unchanged across all three bases
    risk-tier: T3; basis: src/jobs/service.ts
    

    6 files, 300 insertions / 5 deletions. node scripts/version.mjs check → version: 0.4.0 ok; node scripts/changelog.mjs check → 15 fragment(s) ok. Extraction of the tar + git add -A + git write-tree returns 4457bee0 exactly.

    Rebase notes, so the reviewer is not looking for the wrong thing: the two earlier bases (24294731, 94cfaaa5) each moved src/app.ts, src/jobs/service.ts or docs/architecture.md. Each rebase applied with no conflict and the slice was re-gated on the new base each time. #878's bridge change in src/jobs/service.ts is preserved — the diff touches followUp and the parked-request shape only.

    And the correction stands in the PR text below: the mention matcher half of this card is already merged via #839 (parseMentionTrigger, src/lib/mentionGovernance.ts, the handler wiring, Jobs.mention, the superseded status). This branch is the card's last bullet, the review revision budget. There is no second mention implementation to find.

    PR body (ready to paste, verbatim)

    Written-by: Fledge Platform Dev-4
    Bot: Fledge Platform Dev-4
    
    Fixes #637
    
    This is the last open bullet of the card. The mention trigger, the in-flight merge and the head supersede already landed in #839; this branch does not re-do them, and it removes nothing from them.
    
    A review that requests changes starts a fix through a budget instead of without one:
    
    - A person is never counted and never refused by the budget. The existing duplicate-fingerprint guard still answers first, so a repeated request costs nothing.
    - A third-party review bot may cause one fix per pull request, whichever head it reviewed and however it worded the review.
    - The platform's own reviewer, the installation's `<slug>[bot]` account, may cause `max_revisions` at one head: three by default, overridable per repository with the setting `repo:<id>:max_revisions`. The count resets when the head moves, because the counter key carries the head SHA for that class.
    - The count follows the fix that actually starts: a request parked behind a running review is counted when it is replayed, so several updates merged into one job count once.
    - A refusal writes one `trigger.revision_refused` audit row with the author class, the head, the used count and the reason, and starts no job.
    
    Deliberately not wired: counting a person's requests (the card says they are not counted), any budget for check failures or manual retries (no `reviewAuthor` is passed, so they are unchanged), and a console control for the per-repository ceiling — the setting is the override for now and the docs say so.
    
    Ran:
    - `npm run check` — exit 0, 2364/2364
    - `npx tsx --test test/revisionBudget.test.ts` — 8/8
    - `npm run test:coverage` and `node scripts/coverage-diff.mjs --base 64c111fac37cdf015b4b6363ec81aa2d6b1f5000 --head HEAD --report coverage.txt --floor 80` — ok, 60/61 changed lines (98.4%, floor 80)
    Not run: a live GitHub App `pull_request_review` delivery; the merge queue.
    
    risk-tier: T3; basis: src/jobs/service.ts
    
    Docs: docs/architecture.md carries the trigger budget beside the trigger contract; changelog.d/637-revision-budget.added.md is the fragment.
    
  18. HugoXK commented on Nov 16, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Dev-4

    One more cut, and this one was a real conflict, not a moved base: live main reached e450dac (#891), whose src/app.ts and docs/architecture.md are two of my six files, and a throwaway git merge --no-commit against it failed on src/app.ts. Under the new rule I did not re-cut for the move itself; I re-cut because the merge reported a conflict. Resolution keeps both sides of the import block (#891's untrustedMeta / scanUntrusted plus my classifyReviewAuthor); no behaviour changed, 6 files / 300 insertions / 5 deletions exactly as before.

    branch dev4/637-reactive-triggers
    tip    01b06d5bdf6dc9268e1fc9ca86c8db373df7b7c9
    tree   5fbf933774f0ae3368cbc68766b629eb68ab5b27
    parent e450dac1b9b8e87e8f8352638f93f9868f159621
    tar    deliver/637-revision-budget.tar.gz
           sha256 67634eeadc082aec30717d16e82e53bf0d3df3a455c5e00033d347e4c8467cd9  771 entries
    check  2374/2374   (`npm run check`, exit 0, log notes/637/check-at-01b06d5.log)
    red    5/8 at e450dac — the same three behaviour tests fail (`a second bot review must not start a second fix`, the reviewer ceiling, the per-repository limit); the five rule/counter tests pass
    coverage 60/61 changed lines covered (98.4%, floor 80)
    risk-tier: T3; basis: src/jobs/service.ts
    

    This head merges clean into live main 4355086892c1e7c5efdc56c5d88b9719d8ad912b (#892) — verified with a throwaway worktree merge, rc 0. Extraction of the tar + git add -A + git write-tree returns 5fbf9337 exactly. node scripts/version.mjs check → version: 0.4.0 ok; node scripts/changelog.mjs check → 17 fragment(s) ok. Red log notes/637/red-at-e450dac.log, check log notes/637/check-at-01b06d5.log.

    Blocker, stated plainly: I cannot publish from this box. git push has no credential here — DSH_SECRET_GITHUB_TOKEN is unset for this bot, ~/.git-credentials is empty, there is no credential helper, and a dry run through the mirror stops at could not read Username. The branch ref exists locally as dev4/637-reactive-triggers at the tip above in /home/xuke/.dsh/bot/workspace/fledge-dev-4; pushing that one ref is all that is missing. I have not created a branch remotely, so there is no PR and nothing stale.

    PR body (ready to paste, verbatim)

    Written-by: Fledge Platform Dev-4
    Bot: Fledge Platform Dev-4
    
    Fixes #637
    
    This is the last open bullet of the card. The mention trigger, the in-flight merge and the head supersede already landed in #839; this branch does not re-do them, and it removes nothing from them.
    
    A review that requests changes starts a fix through a budget instead of without one:
    
    - A person is never counted and never refused by the budget. The existing duplicate-fingerprint guard still answers first, so a repeated request costs nothing.
    - A third-party review bot may cause one fix per pull request, whichever head it reviewed and however it worded the review.
    - The platform's own reviewer, the installation's `<slug>[bot]` account, may cause `max_revisions` at one head: three by default, overridable per repository with the setting `repo:<id>:max_revisions`. The count resets when the head moves, because the counter key carries the head SHA for that class.
    - The count follows the fix that actually starts: a request parked behind a running review is counted when it is replayed, so several updates merged into one job count once.
    - A refusal writes one `trigger.revision_refused` audit row with the author class, the head, the used count and the reason, and starts no job.
    
    Deliberately not wired: counting a person's requests (the card says they are not counted), any budget for check failures or manual retries (no `reviewAuthor` is passed, so they are unchanged), and a console control for the per-repository ceiling — the setting is the override for now and the docs say so.
    
    Ran:
    - `npm run check` — exit 0, 2374/2374
    - `npx tsx --test test/revisionBudget.test.ts` — 8/8
    - `npm run test:coverage` and `node scripts/coverage-diff.mjs --base e450dac1b9b8e87e8f8352638f93f9868f159621 --head HEAD --report coverage.txt --floor 80` — ok, 60/61 changed lines (98.4%, floor 80)
    Not run: a live GitHub App `pull_request_review` delivery; the merge queue.
    
    risk-tier: T3; basis: src/jobs/service.ts
    
    Docs: docs/architecture.md carries the trigger budget beside the trigger contract; changelog.d/637-revision-budget.added.md is the fragment.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyReady for an agent to implementagent-workingarea:jobsJob lifecycle, queue, callbacksarea:securitySecrets, authz, data exposureenhancementNew feature or requestpriority:highHigh priority; claim before normal backlogpriority:ownerOwner-planned task; prioritize ahead of the Product backlogreview:approvedIssue reviewed and approved by the Fledge Platform Reviewer

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions