Hand deploy findings to devops instead of the developer.
Rubric R13 makes CI, Dockerfile, compose and manifest findings devops-owned; the Hub tags hub.json devops users once when such findings appear. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
27
src/hub.ts
27
src/hub.ts
@@ -8,7 +8,7 @@ import type { ReviewOutcome, Reviewer, Session } from './review.ts';
|
||||
import 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, decisionComment, gasComment, closeComment, ajuanNote, VERDICT_MARKER, type Stamp } from './render.ts';
|
||||
import { verdictComment, errorComment, replyComment, rereviewComment, devopsComment, needsDevops, decisionComment, gasComment, closeComment, ajuanNote, VERDICT_MARKER, type Stamp } from './render.ts';
|
||||
|
||||
export type HubConfig = {
|
||||
mode: 'shadow' | 'live';
|
||||
@@ -24,10 +24,14 @@ export type HubConfig = {
|
||||
gas?: { mode: 'dry' | 'live'; graceSeconds: number };
|
||||
// Notifications to the approver (M3). Without a Telegram chat they only go to the Hub's log.
|
||||
notify?: { telegramChatId: string | null; boardUrl: string; remindHours: number };
|
||||
// Deploy setup belongs to devops: these GitLab users are tagged when a bad or todo finding
|
||||
// cites one of `rules` or points at a deploy file (CI, Dockerfile, compose, manifests).
|
||||
devops?: { users: string[]; rules?: string[] };
|
||||
};
|
||||
|
||||
type DeployBy = 'merge' | 'tag';
|
||||
|
||||
const DEVOPS_RULES = ['R9', 'R13'];
|
||||
const GAS_DEFAULT = { mode: 'dry' as const, graceSeconds: 15 };
|
||||
const NOTIFY_DEFAULT = { telegramChatId: null, boardUrl: 'http://localhost:4810', remindHours: 4 };
|
||||
// Pipelines are checked at most this often; a deploy that has not finished after DEPLOY_LIMIT is reported.
|
||||
@@ -216,6 +220,11 @@ export class Hub {
|
||||
}
|
||||
}
|
||||
|
||||
private devopsFor(c: Checked): string[] {
|
||||
const d = this.config.devops;
|
||||
return d?.users.length && needsDevops(c, d.rules ?? DEVOPS_RULES) ? d.users : [];
|
||||
}
|
||||
|
||||
private stamp(a: Ajuan, s: Session | null, sha?: string): Stamp {
|
||||
return { reviewer: this.reviewer.name, sha: sha ?? a.reviewed_sha ?? a.head_sha, model: s?.model ?? this.reviewer.model ?? 'default', effort: this.reviewer.effort, rubricVersion: s?.rubricVersion ?? '-' };
|
||||
}
|
||||
@@ -265,12 +274,20 @@ export class Hub {
|
||||
this.notify(`error:${a.id}:${mr.sha}`, a, `⚪ ${this.label(a)} perlu dicek manual: ${this.reviewer.name} gagal memberi hasil yang valid.`);
|
||||
return `reviewer error setelah ${out.attempts} percobaan`;
|
||||
}
|
||||
const devops = this.devopsFor(out.checked);
|
||||
// Devops is told once when deploy findings appear, not again on every push while they stay.
|
||||
const before = a.verdict_json ? (JSON.parse(a.verdict_json) as Checked) : null;
|
||||
const tellDevops = devops.length > 0 && !(before && this.devopsFor(before).length);
|
||||
const hadVerdictNote = this.store.outbox(a.id).some((o) => o.kind === 'verdict');
|
||||
this.store.update(a.id, { status: out.checked.verdict, reviewed_sha: mr.sha, rubric_version: s.rubricVersion, verdict_json: JSON.stringify(out.checked), tokens });
|
||||
await this.publishVerdict(this.store.ajuanById(a.id), verdictComment(out.checked, this.stamp(a, s, mr.sha)));
|
||||
await this.publishVerdict(this.store.ajuanById(a.id), verdictComment(out.checked, this.stamp(a, s, mr.sha), devops));
|
||||
const noteId = this.store.outbox(a.id).find((o) => o.kind === 'verdict')?.note_id;
|
||||
const verdictUrl = noteId ? `${a.web_url}#note_${noteId}` : null;
|
||||
if (previous) {
|
||||
const noteId = this.store.outbox(a.id).find((o) => o.kind === 'verdict')?.note_id;
|
||||
const verdictUrl = noteId ? `${a.web_url}#note_${noteId}` : null;
|
||||
await this.publishReply(a, rereviewComment(out.checked, { sha: mr.sha, author: a.author, reviewer: this.reviewer.name, verdictUrl, rubricChanged: previous === mr.sha }));
|
||||
await this.publishReply(a, rereviewComment(out.checked, { sha: mr.sha, author: a.author, reviewer: this.reviewer.name, verdictUrl, rubricChanged: previous === mr.sha, devops: tellDevops ? devops : [] }));
|
||||
} else if (tellDevops && hadVerdictNote) {
|
||||
// An edited verdict note notifies nobody, so the mention goes in a note of its own.
|
||||
await this.publishReply(a, devopsComment(devops, verdictUrl));
|
||||
}
|
||||
if (out.checked.verdict === 'go') this.notify(`ready:${a.id}:${mr.sha}`, a, `🟢 ${this.label(a)} siap gas: ${out.checked.reason}`);
|
||||
return `${out.checked.verdict} di ${mr.sha.slice(0, 8)}${out.attempts > 1 ? ' (percobaan ke-2)' : ''}`;
|
||||
|
||||
Reference in New Issue
Block a user