Skip to content

chore(loop): terminalise the task of a non-loop PR when it closes - #40

Merged
Alex1990 merged 1 commit into
mainfrom
chore/loop-nonloop-terminal
Sep 11, 2026
Merged

Alex1990 merged 1 commit into
mainfrom
chore/loop-nonloop-terminal

Conversation

@Alex1990

Copy link
Copy Markdown
Owner

Fixes the third face of the same underlying gap: a task with no path to a terminal state.

D33 — a non-loop PR closing left its task stranded

pull_request_target returned noop for any PR without loop-task::

const loopTask = loopTaskOf(pr);
if (!loopTask) return noop('closing a non-loop PR is not counted for auto-acceptance');

That is right about the metric — a PR the loop did not produce must never enter the acceptance rate. It is wrong about the task. ops.md maps closure by outcome, not by provenance:

Label Task status
(none, merged) accepted
(none, closed unmerged) rejected

Every owner or dependabot PR gets a task from pull_request triage, so every merged PR left a zombie sitting in waiting-human — showing up under "Inbox" in SUMMARY.md forever. Sweep cannot repair it either, for the same reason as D30: sweep reconciles by listing open GitHub items, so it cannot see a closure.

Observed live on #39 — the PR that fixed D30 was itself the next instance:

#39  pr  waiting-human   closed/merged   ** DRIFT **

The fix

The router emits a terminal decision for that case:

return terminal({
  reason: `non-loop PR ${merged ? 'merged' : 'closed-unmerged'} (not counted for auto-acceptance)`,
  taskId: pr.number,
  to: merged ? 'accepted' : 'rejected',
  pr: pr.number,
});

entry.mjs handles it through the same markTaskTerminal the metrics path uses, so "what terminal means" has one definition rather than two. The acceptance row is still never written for a non-loop PR.

Verified

Case Expected Result
owner PR merged task → accepted, no metric row pass
owner PR closed unmerged task → rejected, no metric row pass
loop PR merged task → accepted and a metric row pass
duplicate event no second row, no re-transition pass
PR with no task no throw pass

Plus the 19-case route table (all decision types, including the new terminal), CLI guards, and the orchestrator paths.

The pattern worth naming

D30, D33, and the still-open D26 are one problem seen from three angles: a task can enter a wait, and only some paths lead out.

Enters Should leave via Status
Loop PR closes waiting-merge gate event fixed (D30)
Non-loop PR closes waiting-human gate event this PR (D33)
PR gets a new commit waiting-human / waiting-merge synchronize open (D26)

D26 remains open on purpose: its fix is a design choice (re-open PR tasks on synchronize, or a bounded re-triage), and A1's week should quantify the cost first. Worth noting it was the reason this PR's own re-push logged skip: task #39 not claimable instead of re-analysing.

The deeper repair is in sweep, which only lists open items and so misses this entire direction. That is a norms-layer change and belongs in a proposal PR after A1's observation week — recorded as such, not smuggled in here.

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.
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Metric % Covered / Total
Lines 90.19% 1003/1112
Statements 89.06% 1083/1216
Functions 91.03% 193/212
Branches 76.43% 519/679

@Alex1990
Alex1990 merged commit 05cbfb6 into main Sep 11, 2026
3 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant