From ee755ebecb4f263b0751052187d28acad74317b7 Mon Sep 17 00:00:00 2001 From: Adnan Zahir Date: Mon, 9 Nov 2026 19:31:15 +0700 Subject: [PATCH] Promote a pipeline-held go once the pipeline is green, and stop calling every wait "nunggu MR lain". lti-api !1388 was a go held at waiting because its pipeline was still running; the pipeline turned green but only a new commit could move the verdict, so the board never offered Gas and labelled it as waiting on another MR. The Hub now restores the model's go (and its own reason) on the next poll when the reviewed commit's pipeline is success, edits the verdict note and notifies; a waiting the model chose itself stays. The board's waiting mark is an hourglass with a neutral label. Co-Authored-By: Claude Opus 5.5 --- board/board.js | 7 ++++--- docs/SPEC.md | 1 + src/contract.ts | 11 ++++++++-- src/hub.ts | 18 ++++++++++++++++- test/hub.test.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 6 deletions(-) diff --git a/board/board.js b/board/board.js index 6b031d0..ff85a54 100644 --- a/board/board.js +++ b/board/board.js @@ -9,7 +9,7 @@ const META = { checking: { zone: 'cek', flag: '#7FA9C4', aria: 'sedang dicek', word: 'Dicek dulu', bg: '#E1EDF1', ink: '#1F4B5E', icon: 'dots' }, fix: { zone: 'cek', flag: '#D9654B', aria: 'ditahan reviewer', word: 'Tahan', bg: '#F8DDD5', ink: '#9A2E1A', icon: 'stop' }, - blocked: { zone: 'cek', flag: '#9AA5A8', aria: 'nunggu MR lain', word: 'Nunggu', bg: '#EEF1F0', ink: '#3E4E53', icon: 'link' }, + blocked: { zone: 'cek', flag: '#9AA5A8', aria: 'nunggu, lihat alasannya', word: 'Nunggu', bg: '#EEF1F0', ink: '#3E4E53', icon: 'wait' }, manual: { zone: 'cek', flag: '#B7AE9C', aria: 'perlu dicek manual', word: 'Cek manual', bg: '#F1EBDF', ink: '#5C5440', icon: 'pause' }, parked: { zone: 'cek', flag: '#B7AE9C', aria: 'ditunda', word: 'Ditunda', bg: '#F1EBDF', ink: '#5C5440', icon: 'pause' }, ready: { zone: 'siap', flag: '#E8A33D', aria: 'aman, nunggu gas', word: 'Aman', bg: '#DDEFE5', ink: '#2E7A4E', icon: 'ok' }, @@ -28,7 +28,7 @@ const ICON = { ok: '', stop: '', - link: '', + wait: '', pause: '', dots: '', x: '', @@ -144,7 +144,8 @@ if (title) b.append(el('span', { class: 'boat-title' }, title)); const marks = el('span', { class: 'marks', 'aria-hidden': 'true' }); if (a.status === 'checking' || a.status === 'sailing' || a.status === 'gas') marks.innerHTML = ICON.dots; - if (a.status === 'blocked') marks.innerHTML = ''; + // Waiting can be a pipeline or another MR, so the mark is an hourglass, not a link. + if (a.status === 'blocked') marks.innerHTML = ''; b.append(marks); return b; } diff --git a/docs/SPEC.md b/docs/SPEC.md index 0bd234a..7d60d74 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -132,3 +132,4 @@ Detailed when it starts. Known shape: `depends_on` stored as data; a NO-GO propa - 2026-11-06: the hosted reviewer runs in its own container without GitLab tokens, since Codex's sandbox cannot run inside Docker (Sen chose this over hosting without Docker). - 2026-11-09: deploy setup (CI, Dockerfiles, compose, manifests) belongs to devops (rubric R13). Deploy findings tag the `devops` users from hub.json instead of asking the developer to change CI; the reviewer never suggests CI edits to the developer (Sen, after lti-api !1380). - 2026-11-09: a turn the model provider fails (Codex `turn.status: failed`, e.g. 9router "high demand") is not a rejected verdict. The Hub throws `ReviewerUnavailable`, sends nothing back to the model, and the queue waits 2, 4, 8, 16 and 32 minutes before giving up with a comment that says the model could not be reached (lti-api !1388, lti-web-client !859). +- 2026-11-09: a `go` held at `waiting` only by the pipeline hard rule becomes `go` on the next poll once the reviewed commit's pipeline is `success` (same commit, no new review; verdict note edited, "siap gas" notified). A `waiting` the model chose itself is never promoted. The board's waiting label no longer claims "nunggu MR lain" (lti-api !1388). diff --git a/src/contract.ts b/src/contract.ts index d5f8359..3918cc3 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -56,6 +56,9 @@ export type Finding = { kind: 'bad' | 'ok' | 'todo'; text: string; evidence: Evi export type Verdict = { verdict: 'go' | 'no_go' | 'waiting'; reason: string; findings: Finding[]; post_deploy: Array<{ text: string; evidence: Evidence[] }> }; export type ResolvedEvidence = Evidence & { label: string; url: string }; +// The hard rule that holds a `go` while the reviewed commit's pipeline is not green yet. +export const PIPELINE_HOLD = 'go → waiting: pipeline is '; + export type Checked = { verdict: Verdict['verdict']; reason: string; @@ -63,6 +66,8 @@ export type Checked = { postDeploy: Array<{ text: string; evidence: ResolvedEvidence[] }>; dropped: string[]; overrides: string[]; + // The model's own reason when a hard rule held its `go`, so the go can be restored later. + heldReason?: string; }; export type Context = { @@ -159,10 +164,12 @@ export async function check(v: Verdict, ctx: Context): Promise<{ checked: Checke const overrides: string[] = []; let verdict = v.verdict; let reason = v.reason; + let heldReason: string | undefined; if (verdict === 'go' && ctx.pipeline && ctx.pipeline.status !== 'success') { verdict = 'waiting'; + heldReason = reason; reason = 'Nunggu pipeline hijau.'; - overrides.push(`go → waiting: pipeline is ${ctx.pipeline.status}`); + overrides.push(`${PIPELINE_HOLD}${ctx.pipeline.status}`); } - return { checked: { verdict, reason, findings, postDeploy, dropped, overrides }, errors: [] }; + return { checked: { verdict, reason, findings, postDeploy, dropped, overrides, ...(heldReason ? { heldReason } : {}) }, errors: [] }; } diff --git a/src/hub.ts b/src/hub.ts index 2c2107d..4b8e1a6 100644 --- a/src/hub.ts +++ b/src/hub.ts @@ -5,7 +5,7 @@ import path from 'node:path'; import type { MrInfo, MrRef, MrSummary, Note } from './gitlab.ts'; import type { TurnResult } from './codex.ts'; import type { ReviewOutcome, Reviewer, Session } from './review.ts'; -import type { Checked } from './contract.ts'; +import { PIPELINE_HOLD, type Checked } from './contract.ts'; import { Store, type Ajuan, type OutboxItem, type QueuedEvent, type Release, type ReleaseChanges } from './store.ts'; import { latestTag, nextTag, releaseNotes, tagProblem } from './release.ts'; import { verdictComment, errorComment, replyComment, rereviewComment, devopsComment, needsDevops, decisionComment, gasComment, closeComment, ajuanNote, VERDICT_MARKER, type Stamp } from './render.ts'; @@ -153,6 +153,20 @@ export class Hub { this.log(`ajuan dibuka lagi: ${a.project} !${a.iid}`); } + // A `go` held only because the reviewed commit's pipeline was still running becomes a `go` + // once that pipeline is green: no new review, the same commit and findings (lti-api !1388). + private async pipelineGreen(a: Ajuan): Promise { + const c = a.verdict_json ? (JSON.parse(a.verdict_json) as Checked) : null; + if (!c || !c.overrides.some((o) => o.startsWith(PIPELINE_HOLD))) return; + const { heldReason, ...rest } = c; + const next: Checked = { ...rest, verdict: 'go', reason: heldReason ?? 'Pipeline sudah hijau.', overrides: [...c.overrides.filter((o) => !o.startsWith(PIPELINE_HOLD)), 'waiting → go: pipeline success'] }; + this.store.update(a.id, { status: 'go', verdict_json: JSON.stringify(next) }); + const stamp = { ...this.stamp(a, null, a.reviewed_sha!), rubricVersion: a.rubric_version ?? '-' }; + await this.publishVerdict(this.store.ajuanById(a.id), verdictComment(next, stamp, this.devopsFor(next))); + this.notify(`ready:${a.id}:${a.reviewed_sha}`, a, `🟢 ${this.label(a)} siap gas: ${next.reason}`); + this.log(`pipeline hijau: ${a.project} !${a.iid} → go di ${a.reviewed_sha!.slice(0, 8)}`); + } + // Reconcile GitLab into the store: new labelled MRs, new heads, closed MRs, mentions. async poll(): Promise { for (const project of this.config.projects) { @@ -175,6 +189,8 @@ export class Hub { this.newCommitClearsDecision(a); if (!this.store.hasPending(a.id, 'new_commit') && !this.store.hasPending(a.id, 'opened')) this.store.enqueue(a.id, 'new_commit', { sha: m.sha }); this.log(`commit baru: ${a.project} !${a.iid} → ${m.sha.slice(0, 8)}`); + } else if (a.status === 'waiting' && a.reviewed_sha === m.sha && m.pipelineStatus === 'success') { + await this.pipelineGreen(a); } const notes = await this.ports.gitlab.listNotes(ref, a.last_note_id); const mention = this.mentionPattern(); diff --git a/test/hub.test.ts b/test/hub.test.ts index f67a0eb..8d418d3 100644 --- a/test/hub.test.ts +++ b/test/hub.test.ts @@ -756,3 +756,55 @@ test('a provider down for about an hour ends in a manual check that says so', as assert.doesNotMatch(body, /not valid JSON/); assert.equal(w.store.nextEvent(), undefined); }); + +// lti-api !1388 (2026-11-09): the model said go, the pipeline was still running, so the hard +// rule held it at waiting. The pipeline turned green but nothing moved it, and the board +// showed no Gas. +test('a go held by a running pipeline becomes go once that pipeline is green, without a new review', async () => { + const w = world(); + w.gl.mrs.set(31, { sha: 'efef3333', state: 'opened', labels: ['labuh'], pipelineStatus: 'running' }); + const held: Checked = { ...checked('go', 'Urutan deploy aman.'), verdict: 'waiting', reason: 'Nunggu pipeline hijau.', heldReason: 'Urutan deploy aman.', overrides: ['go → waiting: pipeline is running'] }; + w.script(ok(held)); + await w.hub.poll(); + await w.hub.drain(); + const a = () => w.store.ajuan(PROJECT, 31)!; + assert.equal(a().status, 'waiting'); + assert.deepEqual(allowedActions(a(), false), ['tunda', 'tolak'], 'no Gas while waiting'); + + await w.hub.poll(); + assert.equal(a().status, 'waiting', 'still running: nothing changes'); + + w.gl.mrs.get(31)!.pipelineStatus = 'success'; + await w.hub.poll(); + assert.equal(a().status, 'go'); + assert.equal(w.calls.review.length, 1, 'no second review'); + const v = JSON.parse(a().verdict_json!); + assert.equal(v.reason, 'Urutan deploy aman.'); + assert.deepEqual(v.overrides, ['waiting → go: pipeline success']); + assert.ok(allowedActions(a(), false).includes('gas')); + const verdict = w.store.outbox(a().id).find((o) => o.kind === 'verdict')!; + assert.match(verdict.body, /Aman|aman|🟢/); + assert.match(verdict.body, /waiting → go: pipeline success/); + + await w.hub.poll(); + assert.equal(w.store.outbox(a().id).filter((o) => o.kind === 'verdict').length, 1, 'the verdict note is edited, not duplicated'); +}); + +test('a waiting the model chose itself, or a failed pipeline, is not promoted', async () => { + const w = world(); + w.gl.mrs.set(32, { sha: 'a0a04444', state: 'opened', labels: ['labuh'], pipelineStatus: 'success' }); + w.script(ok({ ...checked('go', 'x'), verdict: 'waiting', reason: 'Nunggu MR backend.' })); + await w.hub.poll(); + await w.hub.drain(); + await w.hub.poll(); + assert.equal(w.store.ajuan(PROJECT, 32)!.status, 'waiting'); + + const f = world(); + f.gl.mrs.set(33, { sha: 'b0b05555', state: 'opened', labels: ['labuh'], pipelineStatus: 'running' }); + f.script(ok({ ...checked('go', 'x'), verdict: 'waiting', reason: 'Nunggu pipeline hijau.', heldReason: 'x', overrides: ['go → waiting: pipeline is running'] })); + await f.hub.poll(); + await f.hub.drain(); + f.gl.mrs.get(33)!.pipelineStatus = 'failed'; + await f.hub.poll(); + assert.equal(f.store.ajuan(PROJECT, 33)!.status, 'waiting'); +});