Repository navigation
chore(loop): move tasks to terminal states on GitHub gate events - #39
Merged
Merged
Conversation
D30. `handleMetrics` appended the acceptance row and returned, so a loop PR that merged was counted for the auto-acceptance rate while its task stayed in `waiting-merge` — contradicting the state machine ops.md defines (`waiting-merge -> accepted | rejected`). Sweep cannot repair it either: sweep reconciles by listing *open* GitHub items, which by construction cannot see a closure. A loop PR merged unattended would strand its task under "Awaiting human merge" permanently, and this was the next thing to happen in A1. `handleMetrics` now also applies the transition via `markTaskTerminal` (merged -> accepted, closed-unmerged -> rejected) and refreshes SUMMARY.md. The two effects are idempotent on independent footings — the row on `taskId+event+pr`, the task on its own status — so a crash between them is repaired by a repeated event instead of leaving a permanent inconsistency. An originating state other than `waiting-merge` is recorded as `(was ...)`, which makes an unexpected route visible rather than silent. D31. `renderSummary` named two different things: the shared library's exporter writes `state/SUMMARY.md`, while entry.mjs's local function renders the Actions Step Summary. Importing the former beside the latter was a SyntaxError at module load — the orchestrator would not start. The collision is a symptom, so both are renamed: `renderStateSummary` and `renderStepSummary` (paired with the existing `writeStepSummary`). The terminal-state list, previously written out inline in more than one place, is now the single exported `TERMINAL_STATUSES`. Verified: both transition directions, duplicate events, a non-waiting-merge origin, `released` leaving the status alone, a missing task not throwing, plus the standing regression (route decisions, CLI guards, orchestrator paths).
Sweep's mandate is to rewrite a missed closure "labelled `sweep-corrected`". Read literally that writes `event: "sweep-corrected"`, which changes the `taskId+event+pr` dedup key and appends a second row for the same closure — double-counting the PR in the auto-acceptance rate, the one number retro exists to produce. Not reachable today (no sweep implementation writes it yet), and recorded now because the ambiguous sentence lives in the norms layer, which is where whoever implements the backfill will read it. The fix is to keep the original `event` and use the existing `writer` field.
Contributor
Coverage
|
The second push to this PR produced the first real sighting:
event=pull_request.synchronize -> run (repo PR synchronize)
skip: task #39 not claimable (status=waiting-human) - event handled idempotently
So a PR task is never re-analysed after its first push, and neither is a
`waiting-merge` loop PR after a new commit. This is a direct consequence of
running at the report boundary: `flows` §2a has request-changes ->
`processing` -> re-review on `synchronize`, but a report-boundary `pr-review`
cannot comment or relabel, so it can only land in `waiting-human`, where
nothing re-enters.
D26 now covers both faces with the observed evidence. Still deliberately open:
the fix is a design choice (re-open PR tasks on `synchronize`, or a bounded
re-triage), and A1's week should quantify how often it bites first.
The same run also re-confirmed D25 in the field: the skip reason is in the
Actions log, which is exactly the line that would have been blank before.
Alex1990
added a commit
that referenced
this pull request
Sep 11, 2026
D33. `pull_request_target` returned `noop` for any PR without `loop-task:`, which is right about the **metric** (not loop-produced ⇒ never in the acceptance rate) but wrong about the **task**: ops.md maps "(none, merged) -> accepted" and "(none, closed unmerged) -> rejected" regardless of provenance. Every owner or dependabot PR gets a task from `pull_request` triage, so each merged PR left a zombie in `waiting-human` — observed live on #39, the very PR that fixed D30. It shows up under "Inbox" in SUMMARY.md forever, and sweep cannot repair it: sweep lists *open* GitHub items, so it cannot see a closure. The router now emits a `terminal` decision for that case, and entry handles it through the same `markTaskTerminal` as the metrics path — one definition of "what terminal means" — while still never writing an acceptance row for a non-loop PR. Verified: owner PR merged -> accepted and owner PR closed-unmerged -> rejected, neither writing a metric; a loop PR still does both (new row + transition); duplicate events add no row and re-transition nothing; a PR with no task does not throw; plus the 19-case route table and the CLI/orchestrator suite.
Alex1990
added a commit
that referenced
this pull request
Sep 11, 2026
The D33 entry claimed "every owner or dependabot PR gets a task from `pull_request` triage". Dependabot is not one of them: the credential guard (D28) skips the whole job before triage, because a Dependabot-triggered `pull_request` run gets a read-only token and no secrets. So the new `terminal` branch is a no-op for them. The code was always right — `markTaskTerminal` treats a missing task as "no transition needed" — only the reasoning was wrong. Still worth fixing: the note is what the next reader trusts, and a wrong premise there invites a wrong change later. Also fold in what the 2026-09-11 daily sweep established, since it changes how D33 reads: the #39 drift was self-healed by r-20260911-080231-zja0, but only because the #40 triage report had mentioned it in passing. sweep cannot see closures, which is the accidental path D30/D33 exist to remove.
Alex1990
added a commit
that referenced
this pull request
Sep 11, 2026
A clean observation week proves the loop is *safe*, not that it is *complete*. Several capabilities cannot run at the report boundary however long A1 lasts, and the checklist did not distinguish them from items that are merely unsampled. Conflating the two would let a clean week be read as "everything verified". Decision (2026-09-11): accept the metrics write path as unverified and make it the first item after the L2 switchover. A1 produces no loop PR, so `handleMetrics` never fires — all 3 existing acceptance rows are A0-era (`manual-local` x2, `workflow-backfill`). D30/D33 cover the shared machinery (`markTaskTerminal`, the `taskId|event|pr` dedup key) and D33 verified the no-write half live twice; the write half (`planActions`) has never executed in any host. Validating it needs `LOOP_GH_TOKEN` plus `execute_writes=true`, i.e. leaving the report boundary, which is exactly what the observation week is for avoiding. Also corrected while auditing the same list, because a stale checklist is worse than an incomplete one: - `pr-review` is unreachable too — it needs a loop PR, which A1 never produces. #39/#40/#41 were loop-*related* but not loop-*produced* (head `chore/loop-*`), so they routed to `triage`. Recorded run ids for the routes that did run. - Engine stability: 18 runs with no hang, but every one exited 0 — so the failure-classification table has never been exercised by a real failure. - D33's live verification is now recorded as the two independent instances it is (#40, #41), both with no metric row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the gap that would have stranded every loop PR from here on.
D30 — gate events recorded the metric but never moved the task
handleMetricsappended tometrics/acceptance.jsonland returned:So a loop PR that merged was counted for the auto-acceptance rate while its task sat in
waiting-merge— contradicting the state machineops.mddefines (waiting-merge → accepted | rejected). Sweep cannot repair it either: sweep reconciles by listing open GitHub items, which by construction cannot see a closure. A loop PR merged unattended would keep showing under "Awaiting human merge" forever.This was not hypothetical: it is the next thing A1 would have done. It went unnoticed only because #36/#37/#38 stalled at
waiting-human(triaged, never reachingwaiting-merge), and #28/#30/#33 were reconciled by hand during A0.The fix
handleMetricsnow applies the transition too, viamarkTaskTerminal:mergedacceptedclosed-unmergedrejectedreleasedThe two effects are idempotent on independent footings — the row on
taskId+event+pr, the task on its own status — deliberately not gated on each other. If the process dies between them, a repeated event repairs the task instead of leaving a permanent inconsistency.An originating state other than
waiting-mergeis recorded as(was waiting-human), so an unexpected route shows up in the timeline rather than passing silently.D31 —
renderSummarynamed two different thingsImporting the shared library's
renderSummarybesideentry.mjs's local function of the same name was aSyntaxErrorat module load: the orchestrator would not start at all. The collision is the symptom; the names were the problem, so both are renamed:renderStateSummary— writesstate/SUMMARY.mdrenderStepSummary— renders the Actions Step Summary (now paired with the existingwriteStepSummary)While there: the terminal-state list had been written out inline in more than one place. It is now the single exported
TERMINAL_STATUSES— duplicated lists are this codebase's recurring failure mode (the missing#33acceptance row, thelib/vsshared/paths, thedeepseek-flashid).Verified
merged→acceptedclosed-unmerged→rejectedwaiting-merge→ transitions, records(was …)released→ status untouchedPlus the standing suite: route decisions, CLI guards (stage whitelist, idempotent closing, claimability), and the orchestrator paths.
Related, not in scope
The R2 state layer currently holds five tasks that GitHub has already closed or merged, all stranded in
waiting-humanfor the same underlying reason (the host had no closure path). Those are being reconciled separately by hand, since the state layer lives in R2 and only the owner can push to it. The sweep skill's blind spot — it only lists open GitHub items, so it cannot detect this whole direction — is a norms-layer change and should go through a proposal PR rather than ride along here.