@staix/agent-hub 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +84 -0
- package/README.md +28 -12
- package/docs/adding-an-ai-tool.md +7 -5
- package/docs/agent-notes/README.md +23 -0
- package/docs/agent-notes/adapters.md +9 -5
- package/docs/agent-notes/benchmarks.md +2 -0
- package/docs/agent-notes/budget.md +9 -0
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +21 -9
- package/docs/agent-notes/local-worker.md +4 -2
- package/docs/agent-notes/security-review.md +56 -0
- package/docs/agent-notes/tasks.md +22 -6
- package/docs/agent-notes/tests.md +10 -9
- package/docs/contracts/companion-cli-v1.json +4 -0
- package/docs/design/adapters.md +142 -0
- package/docs/design/agent-hub-architecture.md +46 -1
- package/docs/design/agent-hub.md +10 -0
- package/docs/design/bus.md +7 -0
- package/docs/design/cli-output.md +183 -0
- package/docs/design/execution-reference.md +6 -1
- package/docs/design/roadmap.md +191 -0
- package/docs/design/task-board.md +185 -5
- package/docs/dogfood.md +30 -9
- package/docs/events.md +7 -7
- package/docs/memory.md +5 -5
- package/docs/operations.md +315 -54
- package/docs/profiles.md +101 -8
- package/docs/quickstart.md +47 -6
- package/docs/research.md +6 -3
- package/docs/roles.md +52 -0
- package/docs/sdlc.md +190 -2
- package/docs/security.md +90 -15
- package/docs/text-projection.md +1 -0
- package/docs/verification/2026-11-13-claude-implementer-2.1.323.md +59 -0
- package/docs/verification/2026-11-13-codex-01672-reviewer-isolation.md +69 -0
- package/docs/verification/2026-11-14-0.39.0.md +51 -0
- package/docs/verification/2026-11-14-codex-0169-reviewer-isolation.md +70 -0
- package/docs/verification/2026-11-14-codex-0169-reviewer-tool-call.md +48 -0
- package/docs/verification/2026-11-14-pi-152-compat.md +45 -0
- package/docs/verification/2026-11-15-0.40.0.md +39 -0
- package/docs/verification/2026-11-16-pi-loopback-1447.md +39 -0
- package/docs/verification/pi-152-model-free.ts +57 -0
- package/docs/verification/pi-152-native.mjs +21 -0
- package/docs/verified.json +48 -25
- package/package.json +4 -4
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +2266 -530
- package/plugins/agent-hub/kimi-review-policy-worker.js +16 -11
- package/plugins/agent-hub/server.js +2423 -645
- package/src/adapters/acp-model-policy.ts +1 -1
- package/src/adapters/acp-session-model.ts +35 -0
- package/src/adapters/acp.ts +14 -0
- package/src/adapters/agy/definition.ts +2 -2
- package/src/adapters/agy/hooks.ts +7 -0
- package/src/adapters/claude-channel.ts +1 -1
- package/src/adapters/claude-implementer.ts +8 -0
- package/src/adapters/claude-print-child.ts +26 -2
- package/src/adapters/claude-print.ts +4 -0
- package/src/adapters/codex-appserver.ts +90 -16
- package/src/adapters/codex-review-isolation.ts +63 -17
- package/src/adapters/compat.ts +10 -10
- package/src/adapters/conformance/fakes/acp-server.ts +11 -2
- package/src/adapters/conformance/fakes/app-server.ts +5 -1
- package/src/adapters/conformance/fakes/pi-rpc.ts +1 -1
- package/src/adapters/definitions/builtin-metadata.ts +12 -12
- package/src/adapters/definitions/native-cli-jcode-mcp.ts +18 -3
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-config-policy.ts +1 -1
- package/src/adapters/definitions/native-quota.ts +122 -0
- package/src/adapters/definitions/native-recovery.ts +3 -0
- package/src/adapters/definitions/qwen.ts +2 -2
- package/src/adapters/kimi-review.ts +23 -0
- package/src/adapters/kimi-wire-usage.ts +39 -16
- package/src/adapters/local-worker.ts +9 -4
- package/src/adapters/pi-state-model.ts +12 -0
- package/src/adapters/pi.ts +76 -11
- package/src/adapters/print-result-model.ts +24 -0
- package/src/adapters/registry-types.ts +12 -2
- package/src/adapters/registry.ts +19 -2
- package/src/adapters/reviewer-print.ts +132 -16
- package/src/adapters/role-eligibility.ts +99 -0
- package/src/adapters/same-directory.ts +16 -0
- package/src/cli/agy-mcp.ts +18 -7
- package/src/cli/answer-args.ts +11 -3
- package/src/cli/console-question.ts +1 -1
- package/src/cli/console-state.ts +98 -11
- package/src/cli/console.ts +6 -2
- package/src/cli/error-format.ts +19 -0
- package/src/cli/free-text.ts +20 -0
- package/src/cli/handoff-args.ts +1 -1
- package/src/cli/help.ts +350 -30
- package/src/cli/identity-audit.ts +8 -7
- package/src/cli/identity.ts +27 -4
- package/src/cli/init-prompt.ts +31 -2
- package/src/cli/init-roles.ts +156 -0
- package/src/cli/init-settings.ts +24 -2
- package/src/cli/init.ts +232 -17
- package/src/cli/main.js +2 -2
- package/src/cli/main.ts +250 -69
- package/src/cli/model.ts +1 -1
- package/src/cli/output-standard.ts +56 -0
- package/src/cli/output.ts +199 -9
- package/src/cli/preview.ts +1 -1
- package/src/cli/recovery-launch.ts +114 -0
- package/src/cli/recovery-package.ts +14 -7
- package/src/cli/recovery-version-preflight.ts +104 -0
- package/src/cli/roadmap.ts +215 -0
- package/src/cli/role-doctor.ts +39 -0
- package/src/cli/sdlc-output.ts +66 -1
- package/src/cli/smoke-pty-bridge.ts +7 -24
- package/src/cli/study-output.ts +54 -0
- package/src/cli/study.ts +14 -1
- package/src/cli/task-output.ts +3 -1
- package/src/cli/terminal-recovery.ts +14 -0
- package/src/cli/upgrade-presentation-flags.ts +2 -2
- package/src/cli/upgrade-presentation.ts +4 -0
- package/src/cli/upgrade-restore-state.ts +12 -3
- package/src/cli/upgrade-runtime.ts +40 -2
- package/src/cli/upgrade.ts +8 -4
- package/src/hub/advisor-survey.ts +139 -0
- package/src/hub/audit-source.ts +66 -0
- package/src/hub/board.ts +677 -15
- package/src/hub/budget.ts +54 -4
- package/src/hub/bus.ts +9 -0
- package/src/hub/check-runner.ts +3 -4
- package/src/hub/ci-watch.ts +19 -4
- package/src/hub/conductor.ts +14 -8
- package/src/hub/config-apply.ts +2 -1
- package/src/hub/config-edit-host.ts +77 -5
- package/src/hub/considered-findings.ts +47 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +585 -98
- package/src/hub/deliverable-files.ts +17 -1
- package/src/hub/dogfood-profile.ts +3 -2
- package/src/hub/events.ts +25 -4
- package/src/hub/execution-reference.ts +1 -1
- package/src/hub/folder-trigger.ts +11 -4
- package/src/hub/github-import.ts +81 -0
- package/src/hub/hub-tools.ts +117 -20
- package/src/hub/install-policy.ts +23 -0
- package/src/hub/kimi-usage.ts +34 -2
- package/src/hub/lifecycle-schema.ts +3 -3
- package/src/hub/memory-profile.ts +9 -1
- package/src/hub/memory-sync-state.ts +1 -0
- package/src/hub/model-overrides.ts +2 -1
- package/src/hub/no-writes.ts +5 -0
- package/src/hub/operational-authority.ts +8 -1
- package/src/hub/operational-view.ts +6 -2
- package/src/hub/peers.ts +2 -0
- package/src/hub/pi-failure.ts +7 -0
- package/src/hub/plan-conformance.ts +20 -2
- package/src/hub/question-desk.ts +26 -7
- package/src/hub/questions.ts +33 -5
- package/src/hub/quota-account.ts +34 -0
- package/src/hub/recovery-policy.ts +18 -4
- package/src/hub/research-evidence.ts +51 -3
- package/src/hub/research.ts +77 -13
- package/src/hub/restart.ts +21 -0
- package/src/hub/review-budget.ts +88 -0
- package/src/hub/review-findings.ts +93 -12
- package/src/hub/reviewer-pool-config.ts +6 -2
- package/src/hub/reviewer-pool.ts +39 -6
- package/src/hub/roadmap-triage.ts +86 -0
- package/src/hub/roadmap-unplaced.ts +169 -0
- package/src/hub/roadmap-view.ts +83 -0
- package/src/hub/roadmap.ts +127 -0
- package/src/hub/routing.ts +7 -3
- package/src/hub/sdlc-merge.ts +6 -5
- package/src/hub/sdlc-queue.ts +17 -7
- package/src/hub/sdlc-release.ts +1 -1
- package/src/hub/sdlc.ts +47 -8
- package/src/hub/security-audit.ts +178 -0
- package/src/hub/security-pass.ts +115 -0
- package/src/hub/settings.ts +11 -5
- package/src/hub/source-read.ts +80 -2
- package/src/hub/sources.ts +57 -9
- package/src/hub/specs-task.ts +7 -0
- package/src/hub/startup-event-seeds.ts +5 -3
- package/src/hub/startup-timing.ts +1 -0
- package/src/hub/synthesis-readiness.ts +279 -0
- package/src/hub/task-sweep.ts +29 -2
- package/src/hub/task-worktree.ts +37 -0
- package/src/hub/tasks.ts +1464 -76
- package/src/hub/text-projection.ts +11 -1
- package/src/memory/capture.ts +2 -1
- package/src/pi/dependency-publish.ts +50 -0
- package/src/pi/extension.ts +1 -1
- package/src/pi/launch.ts +1 -1
- package/src/pi/task-dependencies.ts +249 -0
- package/src/ui/index.html +56 -13
- package/src/ui/office-model.ts +11 -3
- package/src/ui/office-space.ts +50 -30
- package/src/ui/plugin-questions.ts +5 -0
- package/src/ui/plugin.ts +27 -12
- package/templates/config.json +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Task } from "./board.ts";
|
|
2
|
+
import type { Release } from "./planning.ts";
|
|
3
|
+
import type { SpecsFreshness } from "./specs.ts";
|
|
4
|
+
import type { Milestone, MilestoneLink } from "./roadmap.ts";
|
|
5
|
+
import { sanitize } from "./envelope.ts";
|
|
6
|
+
|
|
7
|
+
export interface RoadmapSnapshot {
|
|
8
|
+
milestones: Milestone[];
|
|
9
|
+
links: MilestoneLink[];
|
|
10
|
+
tasks: Task[];
|
|
11
|
+
releases: Release[];
|
|
12
|
+
freshness: SpecsFreshness[] | undefined;
|
|
13
|
+
issueOf(task: Task): string | undefined;
|
|
14
|
+
privateTask(task: Task): boolean;
|
|
15
|
+
publicText(text: string): boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Only public task identities enter a view. Withheld membership is a count, never a stub. */
|
|
19
|
+
export function milestoneViews(snapshot: RoadmapSnapshot) {
|
|
20
|
+
const explicit = new Set(snapshot.links.filter(link => link.kind === "task").map(link => Number(link.ref)));
|
|
21
|
+
const tasks = new Map(snapshot.tasks.map(task => [task.id, task]));
|
|
22
|
+
const safe = (text: string) => { try { return snapshot.publicText(text); } catch { return false; } };
|
|
23
|
+
return snapshot.milestones.map(milestone => {
|
|
24
|
+
const allLinks = snapshot.links.filter(link => link.milestone === milestone.id);
|
|
25
|
+
const issues = new Set(allLinks.filter(link => link.kind === "issue").map(link => link.ref));
|
|
26
|
+
const members = new Map<number, { rule: "explicit" | "source-issue"; issue?: string }>();
|
|
27
|
+
for (const link of allLinks) if (link.kind === "task") members.set(Number(link.ref), { rule: "explicit" });
|
|
28
|
+
for (const task of snapshot.tasks) {
|
|
29
|
+
if (explicit.has(task.id)) continue;
|
|
30
|
+
const issue = snapshot.issueOf(task);
|
|
31
|
+
if (issue && issues.has(issue)) members.set(task.id, { rule: "source-issue", issue });
|
|
32
|
+
}
|
|
33
|
+
let withheld = 0;
|
|
34
|
+
const visible = [] as { id: number; title: string; state: Task["state"]; placement: { rule: "explicit" | "source-issue"; issue?: string } }[];
|
|
35
|
+
const visibleIds = new Set<number>();
|
|
36
|
+
for (const [id, placement] of members) {
|
|
37
|
+
const task = tasks.get(id);
|
|
38
|
+
if (!task || snapshot.privateTask(task) || !safe(task.title) || placement.issue !== undefined && !safe(placement.issue)) { withheld++; continue; }
|
|
39
|
+
visible.push({ id, title: sanitize(task.title), state: task.state, placement }); visibleIds.add(id);
|
|
40
|
+
}
|
|
41
|
+
visible.sort((a, b) => a.id - b.id);
|
|
42
|
+
const links = allLinks.filter(link => (link.kind !== "task" || visibleIds.has(Number(link.ref))) && safe(link.ref))
|
|
43
|
+
.map(link => ({ ...link, by: safe(link.by) ? link.by : "withheld" }));
|
|
44
|
+
const issueRows = [...issues].filter(safe).map(ref => {
|
|
45
|
+
let at: number | undefined;
|
|
46
|
+
const states = new Set<"open" | "closed">();
|
|
47
|
+
for (const task of snapshot.tasks) {
|
|
48
|
+
if (snapshot.privateTask(task) || snapshot.issueOf(task) !== ref) continue;
|
|
49
|
+
const review = task.sdlc?.planReview, cached = review?.issue;
|
|
50
|
+
if (!cached || `${cached.repo.toLowerCase()}#${cached.issue}` !== ref || !review
|
|
51
|
+
|| !Number.isSafeInteger(review.recordedAt) || review.recordedAt <= 0 || !["OPEN", "CLOSED"].includes(cached.state)) continue;
|
|
52
|
+
if (at === undefined || review.recordedAt > at) { at = review.recordedAt; states.clear(); }
|
|
53
|
+
if (review.recordedAt === at) states.add(cached.state === "CLOSED" ? "closed" : "open");
|
|
54
|
+
}
|
|
55
|
+
const state = states.size === 1 ? [...states][0]! : "unknown";
|
|
56
|
+
return { ref, state, ...(at === undefined ? {} : { cachedAt: at }) };
|
|
57
|
+
});
|
|
58
|
+
const specs = allLinks.filter(link => link.kind === "spec" && safe(link.ref)).map(link => {
|
|
59
|
+
const rows = snapshot.freshness?.filter(row => row.id === link.ref);
|
|
60
|
+
const sourceState = rows?.length === 1 ? rows[0]!.state : "unknown";
|
|
61
|
+
const state = sourceState === "fresh" || sourceState === "stale" || sourceState === "unverified" ? sourceState : "unknown";
|
|
62
|
+
return { id: link.ref, state, ...(sourceState === "nonancestor" ? { sourceState } : {}) };
|
|
63
|
+
});
|
|
64
|
+
const releases = allLinks.filter(link => link.kind === "release" && safe(link.ref)).map(link => {
|
|
65
|
+
const release = snapshot.releases.find(row => row.id === Number(link.ref));
|
|
66
|
+
return { id: Number(link.ref), state: release?.state ?? "unknown", ...(release && safe(release.name) ? { name: release.name } : {}) };
|
|
67
|
+
});
|
|
68
|
+
const metadataVisible = safe(milestone.title) && safe(milestone.outcome);
|
|
69
|
+
return { ...milestone, title: metadataVisible ? milestone.title : "[withheld]", outcome: metadataVisible ? milestone.outcome : "[withheld]",
|
|
70
|
+
history: milestone.history.map(entry => ({ ...entry, by: safe(entry.by) ? entry.by : "withheld" })),
|
|
71
|
+
links, tasks: visible, withheld, issues: issueRows, specs, releases,
|
|
72
|
+
children: snapshot.milestones.filter(row => row.parent === milestone.id).map(row => row.id),
|
|
73
|
+
rollup: {
|
|
74
|
+
tasks: { approved: visible.filter(task => task.state === "approved").length, total: visible.length },
|
|
75
|
+
issues: { closed: issueRows.filter(issue => issue.state === "closed").length, total: issueRows.length, unknown: issueRows.filter(issue => issue.state === "unknown").length },
|
|
76
|
+
specs: { fresh: specs.filter(spec => spec.state === "fresh").length, stale: specs.filter(spec => spec.state === "stale").length,
|
|
77
|
+
unverified: specs.filter(spec => spec.state === "unverified").length, unknown: specs.filter(spec => spec.state === "unknown").length, total: specs.length },
|
|
78
|
+
releases: { shipped: releases.filter(release => release.state === "shipped").length, total: releases.length, unknown: releases.filter(release => release.state === "unknown").length },
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export type MilestoneView = ReturnType<typeof milestoneViews>[number];
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/** Roadmap data and closed validation. Authority and public projections belong to Tasks. */
|
|
2
|
+
export const MILESTONE_STATES = ["proposed", "planned", "active", "done", "dropped"] as const;
|
|
3
|
+
export const MILESTONE_HORIZONS = ["now", "next", "later"] as const;
|
|
4
|
+
export const MILESTONE_LINK_KINDS = ["spec", "issue", "task", "release"] as const;
|
|
5
|
+
export const MILESTONE_HISTORY_LIMIT = 256;
|
|
6
|
+
export const MILESTONE_LIMITS = Object.freeze({ title: 300, outcome: 4000, spec: 160, issue: 300, actor: 64 });
|
|
7
|
+
export type MilestoneState = typeof MILESTONE_STATES[number];
|
|
8
|
+
export type MilestoneHorizon = typeof MILESTONE_HORIZONS[number];
|
|
9
|
+
export type MilestoneLinkKind = typeof MILESTONE_LINK_KINDS[number];
|
|
10
|
+
export interface MilestoneHistoryEntry {
|
|
11
|
+
at: number; by: string; event: "created" | "edited" | "linked" | "unlinked" | "ordered" | "state";
|
|
12
|
+
fields?: string[]; kind?: MilestoneLinkKind;
|
|
13
|
+
}
|
|
14
|
+
export interface MilestoneInput {
|
|
15
|
+
title: string; outcome: string; state?: MilestoneState; horizon?: MilestoneHorizon; order?: number;
|
|
16
|
+
target?: string | null; parent?: number | null;
|
|
17
|
+
}
|
|
18
|
+
export type MilestonePatch = Partial<MilestoneInput>;
|
|
19
|
+
export interface Milestone {
|
|
20
|
+
id: number; title: string; outcome: string; state: MilestoneState; horizon: MilestoneHorizon; order: number;
|
|
21
|
+
target: string | null; parent: number | null; revision: number; history: MilestoneHistoryEntry[]; created: number; updated: number;
|
|
22
|
+
}
|
|
23
|
+
export interface MilestoneLink { milestone: number; kind: MilestoneLinkKind; ref: string; by: string; at: number }
|
|
24
|
+
const FIELDS = ["title", "outcome", "state", "horizon", "order", "target", "parent"] as const;
|
|
25
|
+
function object(raw: unknown): Record<string, unknown> {
|
|
26
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw) || ![Object.prototype, null].includes(Object.getPrototypeOf(raw))) throw new Error("roadmap fields must be a plain object");
|
|
27
|
+
return raw as Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export function milestoneId(raw: unknown): number {
|
|
30
|
+
if (typeof raw !== "number" || !Number.isSafeInteger(raw) || raw < 1) throw new Error("roadmap id must be a positive integer");
|
|
31
|
+
return raw;
|
|
32
|
+
}
|
|
33
|
+
export function milestoneRevision(raw: unknown): number {
|
|
34
|
+
if (typeof raw !== "number" || !Number.isSafeInteger(raw) || raw < 0) throw new Error("roadmap revision must be a nonnegative integer");
|
|
35
|
+
return raw;
|
|
36
|
+
}
|
|
37
|
+
export function milestoneActor(raw: unknown): string {
|
|
38
|
+
if (typeof raw !== "string" || raw.length > MILESTONE_LIMITS.actor || !/^[a-z][a-z0-9-]*$/.test(raw)) throw new Error("roadmap actor is invalid");
|
|
39
|
+
return raw;
|
|
40
|
+
}
|
|
41
|
+
function text(raw: unknown, max: number, field: string): string {
|
|
42
|
+
if (typeof raw !== "string" || !raw.trim() || raw.length > max || /[\p{Cc}\p{Cf}]/u.test(raw)) throw new Error(`roadmap ${field} must be bounded printable text`);
|
|
43
|
+
return raw.trim();
|
|
44
|
+
}
|
|
45
|
+
function target(raw: unknown): string | null {
|
|
46
|
+
if (raw === null) return null;
|
|
47
|
+
if (typeof raw !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(raw)) throw new Error("roadmap target must be a valid YYYY-MM-DD date");
|
|
48
|
+
const date = new Date(`${raw}T00:00:00Z`);
|
|
49
|
+
if (!Number.isFinite(date.getTime()) || date.toISOString().slice(0, 10) !== raw) throw new Error("roadmap target must be a valid YYYY-MM-DD date");
|
|
50
|
+
return raw;
|
|
51
|
+
}
|
|
52
|
+
export function parseMilestonePatch(raw: unknown): MilestonePatch {
|
|
53
|
+
const value = object(raw), result: MilestonePatch = {};
|
|
54
|
+
if (!Object.keys(value).length || Object.keys(value).some(key => !(FIELDS as readonly string[]).includes(key))) throw new Error("roadmap fields are empty or unknown");
|
|
55
|
+
if (Object.hasOwn(value, "title")) result.title = text(value.title, MILESTONE_LIMITS.title, "title");
|
|
56
|
+
if (Object.hasOwn(value, "outcome")) result.outcome = text(value.outcome, MILESTONE_LIMITS.outcome, "outcome");
|
|
57
|
+
if (Object.hasOwn(value, "state")) {
|
|
58
|
+
if (!(MILESTONE_STATES as readonly unknown[]).includes(value.state)) throw new Error("roadmap state is invalid");
|
|
59
|
+
result.state = value.state as MilestoneState;
|
|
60
|
+
}
|
|
61
|
+
if (Object.hasOwn(value, "horizon")) {
|
|
62
|
+
if (!(MILESTONE_HORIZONS as readonly unknown[]).includes(value.horizon)) throw new Error("roadmap horizon is invalid");
|
|
63
|
+
result.horizon = value.horizon as MilestoneHorizon;
|
|
64
|
+
}
|
|
65
|
+
if (Object.hasOwn(value, "order")) result.order = milestoneRevision(value.order);
|
|
66
|
+
if (Object.hasOwn(value, "target")) result.target = target(value.target);
|
|
67
|
+
if (Object.hasOwn(value, "parent")) result.parent = value.parent === null ? null : milestoneId(value.parent);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
export function parseMilestoneInput(raw: unknown): Required<MilestoneInput> {
|
|
71
|
+
const parsed = parseMilestonePatch(raw);
|
|
72
|
+
if (!parsed.title || !parsed.outcome) throw new Error("roadmap title and outcome are required");
|
|
73
|
+
return { title: parsed.title, outcome: parsed.outcome, state: parsed.state ?? "proposed", horizon: parsed.horizon ?? "later", order: parsed.order ?? 0, target: parsed.target ?? null, parent: parsed.parent ?? null };
|
|
74
|
+
}
|
|
75
|
+
export function milestoneLinkRef(kind: MilestoneLinkKind, raw: unknown): string {
|
|
76
|
+
if (!(MILESTONE_LINK_KINDS as readonly unknown[]).includes(kind)) throw new Error("roadmap link kind is invalid");
|
|
77
|
+
if (kind === "task" || kind === "release") {
|
|
78
|
+
const value = typeof raw === "string" && /^[1-9][0-9]*$/.test(raw) ? Number(raw) : raw;
|
|
79
|
+
return String(milestoneId(value));
|
|
80
|
+
}
|
|
81
|
+
if (kind === "issue") {
|
|
82
|
+
if (typeof raw !== "string" || raw.length > MILESTONE_LIMITS.issue) throw new Error("roadmap issue needs bounded owner/repo#N");
|
|
83
|
+
const match = /^([A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9][A-Za-z0-9._-]*)#([1-9][0-9]*)$/.exec(raw);
|
|
84
|
+
if (!match) throw new Error("roadmap issue needs owner/repo#N");
|
|
85
|
+
return `${match[1]!.toLowerCase()}#${milestoneId(Number(match[2]))}`;
|
|
86
|
+
}
|
|
87
|
+
const value = text(raw, MILESTONE_LIMITS.spec, "spec id");
|
|
88
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/.test(value)) throw new Error("roadmap spec id is invalid");
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
export function milestoneHistory(raw: unknown): MilestoneHistoryEntry[] {
|
|
92
|
+
if (!Array.isArray(raw) || raw.length > MILESTONE_HISTORY_LIMIT) throw new Error("roadmap history is full or invalid");
|
|
93
|
+
return raw.map(value => {
|
|
94
|
+
const row = object(value);
|
|
95
|
+
if (Object.keys(row).some(key => !["at", "by", "event", "fields", "kind"].includes(key)) || !["created", "edited", "linked", "unlinked", "ordered", "state"].includes(String(row.event))) throw new Error("roadmap history event is invalid");
|
|
96
|
+
const entry: MilestoneHistoryEntry = { at: milestoneId(row.at), by: milestoneActor(row.by), event: row.event as MilestoneHistoryEntry["event"] };
|
|
97
|
+
if (row.fields !== undefined) {
|
|
98
|
+
if (!Array.isArray(row.fields) || row.fields.length > FIELDS.length || new Set(row.fields).size !== row.fields.length || row.fields.some(field => !(FIELDS as readonly unknown[]).includes(field))) throw new Error("roadmap history fields are invalid");
|
|
99
|
+
entry.fields = [...row.fields] as string[];
|
|
100
|
+
}
|
|
101
|
+
if (row.kind !== undefined) {
|
|
102
|
+
if (!(MILESTONE_LINK_KINDS as readonly unknown[]).includes(row.kind)) throw new Error("roadmap history link kind is invalid");
|
|
103
|
+
entry.kind = row.kind as MilestoneLinkKind;
|
|
104
|
+
}
|
|
105
|
+
return entry;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** R3: a qualified GitHub repository, lower-cased the way issue refs are. */
|
|
110
|
+
export function githubRepo(raw: unknown): string {
|
|
111
|
+
if (typeof raw !== "string" || raw.length > MILESTONE_LIMITS.issue || !/^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/[A-Za-z0-9_.-]{1,100}$/.test(raw)) throw new Error("roadmap repo needs owner/name");
|
|
112
|
+
return raw.toLowerCase();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** R3 suggestions: model-written placements, kept apart from milestones until a person or planner accepts one. */
|
|
116
|
+
export const SUGGESTION_ITEM_KINDS = ["issue", "task", "spec"] as const;
|
|
117
|
+
export const SUGGESTION_STATES = ["pending", "accepted", "rejected", "superseded"] as const;
|
|
118
|
+
export type SuggestionItemKind = typeof SUGGESTION_ITEM_KINDS[number];
|
|
119
|
+
export type SuggestionState = typeof SUGGESTION_STATES[number];
|
|
120
|
+
export interface MilestoneSuggestion {
|
|
121
|
+
id: number; kind: SuggestionItemKind; ref: string;
|
|
122
|
+
/** An existing milestone, or null with `proposal` for "new milestone: <title>". */
|
|
123
|
+
milestone: number | null; proposal: { title: string; outcome: string } | null;
|
|
124
|
+
/** Words copied from the milestone (title or outcome) and from the item text that the model matched. */
|
|
125
|
+
citeMilestone: string | null; citeItem: string;
|
|
126
|
+
state: SuggestionState; by: string; created: number; settled: number | null; settledBy: string | null;
|
|
127
|
+
}
|
package/src/hub/routing.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { contextHeadroom, type ContextAdmission } from "./context-window.ts";
|
|
2
2
|
import { queueBackpressure, type QueueBackpressureCode, type QueueBackpressurePolicy, type QueuePressure } from "./queue-backpressure.ts";
|
|
3
3
|
import { selectReviewerPool, type ReviewerPoolSelection } from "./reviewer-pool.ts";
|
|
4
|
+
import type { ReviewBudgetSnapshot } from "./review-budget.ts";
|
|
4
5
|
import { ADAPTERS, definitionOf, kindOf, familyOf, type ProjectAdapterCatalog } from "../adapters/registry.ts";
|
|
5
6
|
import { readFileSync, statSync } from "node:fs";
|
|
6
7
|
import { join, resolve } from "node:path";
|
|
@@ -444,7 +445,7 @@ export function assign(
|
|
|
444
445
|
namedPlanner?: PeerId;
|
|
445
446
|
/** The planner already recorded on the task (525-2): kept while it is still a holder. */
|
|
446
447
|
keptPlanner?: PeerId;
|
|
447
|
-
reviewPool?: { pool: readonly string[]; rerotate?: boolean; failed?: readonly string[]; required?: boolean; sameFamily?: "fallback" | "never" };
|
|
448
|
+
reviewPool?: { pool: readonly string[]; rerotate?: boolean; failed?: readonly string[]; required?: boolean; sameFamily?: "fallback" | "never"; budget?: ReviewBudgetSnapshot; waitForReset?: boolean };
|
|
448
449
|
candidates?: PeerId[];
|
|
449
450
|
notReviewer?: PeerId;
|
|
450
451
|
waitsFor?: number[];
|
|
@@ -674,10 +675,13 @@ export function assign(
|
|
|
674
675
|
const continuityFamily = last && "reviewerFamily" in last && typeof last.reviewerFamily === "string" ? last.reviewerFamily : last ? (opts.adapterCatalog?.familyOf ?? familyOf)(last.by, opts.instances) : undefined;
|
|
675
676
|
const pr = task.sdlc?.pr;
|
|
676
677
|
const seed = typeof pr === "number" && Number.isSafeInteger(pr) && pr > 0 ? pr : task.id ?? 0;
|
|
677
|
-
reviewSelection = selectReviewerPool({ pool: opts.reviewPool!.pool, candidates: declaredPool, seed, implementerFamily: ownerFamily, continuityFamily, rerotate: opts.reviewPool!.rerotate, failed: opts.reviewPool!.failed, ...(neverSame ? { sameFamily: "never" as const } : {}) });
|
|
678
|
+
reviewSelection = selectReviewerPool({ pool: opts.reviewPool!.pool, candidates: declaredPool, seed, implementerFamily: ownerFamily, continuityFamily, rerotate: opts.reviewPool!.rerotate, failed: opts.reviewPool!.failed, waitForReset: opts.reviewPool!.waitForReset, ...(opts.reviewPool!.budget ? { budget: opts.reviewPool!.budget } : {}), ...(neverSame ? { sameFamily: "never" as const } : {}) });
|
|
678
679
|
for (const row of reviewSelection.walk) trace.push(row.id ? ` reviewer pool candidate ${row.id} (${row.family}): ${row.reason}` : ` reviewer pool kind ${row.kind}: ${row.reason}`);
|
|
679
680
|
reviewer = reviewSelection.reviewer ?? "user";
|
|
680
|
-
if (reviewSelection.
|
|
681
|
+
if (reviewSelection.quotaWait) {
|
|
682
|
+
reviewBlocked = true;
|
|
683
|
+
trace.push(` waiting for reviewer quota; reset recheck at ${new Date(reviewSelection.quotaWait.resetsAt).toISOString()}`);
|
|
684
|
+
} else if (reviewSelection.blocked) {
|
|
681
685
|
trace.push("blocked: no reviewer can run");
|
|
682
686
|
// Optional defaults retain the legacy planner escape when no fresh reviewer can run.
|
|
683
687
|
const planners = opts.reviewPool?.required && !neverSame ? [] : automatic.filter(peer => peer !== reviewOwner && peerEntry(opts.roles, peer)?.includes("planner") && (!neverSame || peerEntry(opts.roles, peer)?.includes("reviewer") === true) && !(opts.adapterCatalog?.definitionOf ?? definitionOf)(peer, opts.instances)?.routing?.reviewOnly && !blocked(peer, "reviewer"));
|
package/src/hub/sdlc-merge.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { findingsForHead, findingHead, findingTally } from "./review-findings.ts
|
|
|
2
2
|
import { readMergeQueue, type DeliveryTask, type MergeQueue } from "./sdlc-queue.ts";
|
|
3
3
|
import { evalGapBlockers, evalGateView, evalReportedGap, evalRequiredChecks, readEvalFor, type EvalResult } from "./eval-gate.ts";
|
|
4
4
|
import { mergeCostFrom } from "./cost-governance.ts";
|
|
5
|
-
import { parsePrEvidence, readPrCostHistory, readSdlcPr, stageDefinition, type AutoMergeMode, type PrEvidence, type SdlcConfig, type SdlcGh, type MergeRecord, type SdlcReceipt } from "./sdlc.ts";
|
|
5
|
+
import { latestCheckRuns, parsePrEvidence, readPrCostHistory, readSdlcPr, stageDefinition, type AutoMergeMode, type PrEvidence, type SdlcConfig, type SdlcGh, type MergeRecord, type SdlcReceipt } from "./sdlc.ts";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* #786 T1/T2: the one guarded merge. Given a task and the head its reviewer approved, it re-reads the PR (`readSdlcPr`) and the merge queue
|
|
@@ -57,7 +57,7 @@ const REPO = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
|
|
|
57
57
|
* threads, draft). Its other blockers (identity, local gate, GitHub approval) are the lifecycle's, not this merge's, and are not repeated here.
|
|
58
58
|
*/
|
|
59
59
|
const QUEUE_BLOCKERS = [/^touching PRs require a person order$/, /^dependency /, /^artifact dependency cycle/, /^open PR /, /^PR file coverage is incomplete/,
|
|
60
|
-
/^required check .*: not successful on current head$/, /^review requests pending or unknown$/, /^review threads unresolved or unknown$/, /^PR is draft or draft status is unknown
|
|
60
|
+
/^required check .*: not successful on current head$/, /^review requests pending or unknown$/, /^review threads unresolved or unknown$/, /^PR is draft or draft status is unknown$/, /^security pass (required|applicability unknown)/];
|
|
61
61
|
|
|
62
62
|
/** The mode that applies to one repository: its own table first, then the top-level key, default off. */
|
|
63
63
|
export function mergeModeFor(config: SdlcConfig, repo: string | undefined): AutoMergeMode {
|
|
@@ -95,19 +95,20 @@ function checkGates(evidence: PrEvidence, required: readonly string[], extra: re
|
|
|
95
95
|
export async function readAdoptMergeEvidence(receipt: SdlcReceipt, run: SdlcGh): Promise<PrEvidence | undefined> {
|
|
96
96
|
if (!REPO.test(receipt.repo ?? "") || receipt.repo!.startsWith("-") || !Number.isSafeInteger(receipt.pr) || receipt.pr! <= 0) return undefined;
|
|
97
97
|
const [owner, name] = receipt.repo!.split("/");
|
|
98
|
-
const query = "query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){headRefOid state reviewDecision isDraft mergeCommit{oid} reviewRequests(first:100){nodes{requestedReviewer{__typename}} pageInfo{hasNextPage}} reviewThreads(first:100){nodes{isResolved} pageInfo{hasNextPage}} commits(last:1){nodes{commit{oid statusCheckRollup{contexts(first:100){nodes{... on CheckRun{name status conclusion} ... on StatusContext{context state}} pageInfo{hasNextPage}}}}}}}}}";
|
|
98
|
+
const query = "query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){headRefOid state reviewDecision isDraft mergeCommit{oid} reviewRequests(first:100){nodes{requestedReviewer{__typename}} pageInfo{hasNextPage}} reviewThreads(first:100){nodes{isResolved} pageInfo{hasNextPage}} commits(last:1){nodes{commit{oid statusCheckRollup{contexts(first:100){nodes{... on CheckRun{name status conclusion startedAt checkSuite{workflowRun{workflow{resourcePath}}}} ... on StatusContext{context state}} pageInfo{hasNextPage}}}}}}}}}";
|
|
99
99
|
try {
|
|
100
100
|
const result = await run(["api", "graphql", "-f", `query=${query}`, "-f", `owner=${owner}`, "-f", `name=${name}`, "-F", `number=${receipt.pr}`]);
|
|
101
101
|
if (result.code !== 0) return undefined;
|
|
102
102
|
const response = JSON.parse(result.stdout), pr = response?.data?.repository?.pullRequest;
|
|
103
103
|
const commit = pr?.commits?.nodes?.length === 1 ? pr.commits.nodes[0]?.commit : undefined, checks = commit?.statusCheckRollup?.contexts;
|
|
104
104
|
if (response.errors !== undefined || !pr || commit?.oid !== pr.headRefOid || checks?.pageInfo?.hasNextPage !== false || !Array.isArray(checks.nodes)) return undefined;
|
|
105
|
+
const rows = latestCheckRuns<any>(checks.nodes);
|
|
105
106
|
const threads = pr.reviewThreads, requests = pr.reviewRequests;
|
|
106
107
|
const threadComplete = threads?.pageInfo?.hasNextPage === false && Array.isArray(threads.nodes) && threads.nodes.every((node: { isResolved?: unknown } | null) => typeof node?.isResolved === "boolean");
|
|
107
108
|
const requestComplete = requests?.pageInfo?.hasNextPage === false && Array.isArray(requests.nodes) && requests.nodes.every((node: { requestedReviewer?: { __typename?: unknown } } | null) => typeof node?.requestedReviewer?.__typename === "string");
|
|
108
|
-
const evidence = parsePrEvidence({ ...pr, statusCheckRollup:
|
|
109
|
+
const evidence = parsePrEvidence({ ...pr, statusCheckRollup: rows, files: [], ...(threadComplete ? { unresolvedThreads: threads.nodes.filter((node: { isResolved: boolean }) => !node.isResolved).length } : {}), reviewRequests: requestComplete ? requests.nodes : undefined });
|
|
109
110
|
evidence.checks = evidence.checks.map((check, index): PrEvidence["checks"][number] => {
|
|
110
|
-
const raw =
|
|
111
|
+
const raw = rows[index];
|
|
111
112
|
const green = raw.name ? (raw.status === "COMPLETED" && raw.conclusion === "SUCCESS") : raw.state === "SUCCESS";
|
|
112
113
|
return check.state === "passed" && !green ? { ...check, state: "unknown" } : check;
|
|
113
114
|
});
|
package/src/hub/sdlc-queue.ts
CHANGED
|
@@ -2,17 +2,23 @@ import { publicTestIntegrity, parseIssueLabels, readTestIntegrity, testIntegrity
|
|
|
2
2
|
import { planConformance, planConformanceBlockers } from "./plan-conformance.ts";
|
|
3
3
|
import { evalGapBlockers, evalGateView, readEvalFor, type EvalGate } from "./eval-gate.ts";
|
|
4
4
|
import { findingsForHead, findingHead, findingTally, type ReviewFindingSet, type ReviewFindingTally } from "./review-findings.ts";
|
|
5
|
+
import { securityPassBlockers, securityPassView, type SecurityPassRecord, type SecurityPassView } from "./security-pass.ts";
|
|
5
6
|
import type { CriteriaView } from "./workflow.ts";
|
|
6
|
-
import { parsePrEvidence, readSdlcPr, sdlcGh, sdlcStatus, type PrEvidence, type SdlcConfig, type SdlcGh, type SdlcReceipt } from "./sdlc.ts";
|
|
7
|
+
import { latestCheckRuns, parsePrEvidence, readSdlcPr, sdlcGh, sdlcStatus, type PrEvidence, type SdlcConfig, type SdlcGh, type SdlcReceipt } from "./sdlc.ts";
|
|
7
8
|
export interface DeliveryTask {
|
|
8
9
|
/** Latest owner-reported artifact head; omitted by older library callers. */
|
|
9
10
|
latestHead?: string;
|
|
10
11
|
/** Host-derived verdict binding, never inferred from a mutable lifecycle receipt. */
|
|
11
12
|
approval?: { head?: string; latestHead?: string; mismatch: boolean; current: boolean };
|
|
12
|
-
plan?: { paths?: string[]; revision: number; fingerprint: string; accepted: { repo: string; pr: number; head: string; revision: number; fingerprint: string; paths: string[] }[] };
|
|
13
|
+
plan?: { paths?: string[]; out_of_scope?: string[]; revision: number; fingerprint: string; accepted: { repo: string; pr: number; head: string; revision: number; fingerprint: string; paths: string[] }[] };
|
|
13
14
|
findings?: readonly ReviewFindingSet[]; id: number; after: number[]; private: boolean; receipt?: SdlcReceipt; phase?: CriteriaView;
|
|
15
|
+
/** #1403 A2: the latest security pass an approving or rejecting verdict recorded, bound to the head it reviewed. */
|
|
16
|
+
securityPass?: SecurityPassRecord;
|
|
14
17
|
}
|
|
15
|
-
export interface MergeQueueRow { evalGate?: EvalGate; testIntegrity?: (TestIntegrity & { task?: number })[]; planConformance?: { task?: number; state: string; outside: number; untouched: number; accepted: boolean }[]; findings?: ReviewFindingTally; pr: number; tasks: number[]; head?: string; private?: true; ready: boolean; blockers: string[]; after: number[]; }
|
|
18
|
+
export interface MergeQueueRow { /** #1403 A2: required | recorded | not_required | unknown for this PR across its holders; the worst one wins. */ securityPass?: SecurityPassView; evalGate?: EvalGate; testIntegrity?: (TestIntegrity & { task?: number })[]; planConformance?: { task?: number; state: string; outside: number; untouched: number; accepted: boolean }[]; findings?: ReviewFindingTally; pr: number; tasks: number[]; head?: string; private?: true; ready: boolean; blockers: string[]; after: number[]; }
|
|
19
|
+
const SECURITY_ORDER: Record<SecurityPassView["state"], number> = { not_required: 0, recorded: 1, unknown: 2, required: 3 };
|
|
20
|
+
/** The stricter of two views of the same PR: a holder that left a required pass unrecorded decides the row. */
|
|
21
|
+
function worseSecurity(held: SecurityPassView | undefined, next: SecurityPassView): SecurityPassView { return held && SECURITY_ORDER[held.state] >= SECURITY_ORDER[next.state] ? held : next; }
|
|
16
22
|
export interface MergeConflict { left: number; right: number; files: number; order: "dependency" | "person_required"; }
|
|
17
23
|
export interface MergeQueue { repo: string; rows: MergeQueueRow[]; order: number[]; unordered?: number[]; conflicts: MergeConflict[]; complete: boolean; truncated: boolean; }
|
|
18
24
|
const validRepo = (value: string) => /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(value) && !value.startsWith("-");
|
|
@@ -27,7 +33,7 @@ async function finalSnapshot(repo: string, evidence: Map<number, PrEvidence>, ru
|
|
|
27
33
|
// ponytail: one snapshot verifies at most 32 linked issues; paginate within the same deadline if queues grow.
|
|
28
34
|
if (issues.size > 32) return { gatesStable: false };
|
|
29
35
|
const [owner, name] = repo.split("/");
|
|
30
|
-
const fields = "headRefOid state isDraft baseRefName baseRefOid changedFiles reviewDecision reviewRequests(first:100){nodes{requestedReviewer{__typename}} pageInfo{hasNextPage}} reviewThreads(first:100){nodes{isResolved} pageInfo{hasNextPage}} statusCheckRollup{contexts(first:100){nodes{... on CheckRun{name conclusion status} ... on StatusContext{context state}} pageInfo{hasNextPage}}}";
|
|
36
|
+
const fields = "headRefOid state isDraft baseRefName baseRefOid changedFiles reviewDecision reviewRequests(first:100){nodes{requestedReviewer{__typename}} pageInfo{hasNextPage}} reviewThreads(first:100){nodes{isResolved} pageInfo{hasNextPage}} statusCheckRollup{contexts(first:100){nodes{... on CheckRun{name conclusion status startedAt checkSuite{workflowRun{workflow{resourcePath}}}} ... on StatusContext{context state}} pageInfo{hasNextPage}}}";
|
|
31
37
|
const entries = [...evidence.entries()];
|
|
32
38
|
const issueAlias = (issue: number) => {
|
|
33
39
|
const primary = entries.find(([, value]) => value.issueLabels?.issue === issue);
|
|
@@ -47,7 +53,7 @@ async function finalSnapshot(repo: string, evidence: Map<number, PrEvidence>, ru
|
|
|
47
53
|
const p = data.data.repository[`queue_p${id}`];
|
|
48
54
|
const threads = p?.reviewThreads, reviews = p?.reviewRequests, checks = p?.statusCheckRollup === null ? { nodes: [], pageInfo: { hasNextPage: false } } : p?.statusCheckRollup?.contexts;
|
|
49
55
|
if (threads?.pageInfo?.hasNextPage !== false || reviews?.pageInfo?.hasNextPage !== false || checks?.pageInfo?.hasNextPage !== false || !Array.isArray(threads.nodes) || threads.nodes.length > 100 || threads.nodes.some((n: { isResolved?: unknown }) => typeof n?.isResolved !== "boolean") || !Array.isArray(reviews.nodes) || !Array.isArray(checks.nodes) || checks.nodes.length > 100) return { gatesStable: false, prs };
|
|
50
|
-
const after = parsePrEvidence({ ...p, files: before.paths.map(path => ({ path })), statusCheckRollup: checks.nodes, reviewRequests: reviews.nodes, unresolvedThreads: threads.nodes.filter((n: { isResolved: boolean }) => !n.isResolved).length });
|
|
56
|
+
const after = parsePrEvidence({ ...p, files: before.paths.map(path => ({ path })), statusCheckRollup: latestCheckRuns(checks.nodes), reviewRequests: reviews.nodes, unresolvedThreads: threads.nodes.filter((n: { isResolved: boolean }) => !n.isResolved).length });
|
|
51
57
|
if (before.issueLabels) after.issueLabels = { issue: before.issueLabels.issue, labels: parseIssueLabels(data.data.repository[`queue_i${id}`], before.issueLabels.issue) ?? null };
|
|
52
58
|
if (gateIdentity(before) !== gateIdentity(after)) return { gatesStable: false, prs };
|
|
53
59
|
}
|
|
@@ -83,7 +89,7 @@ export async function readMergeQueue(repo: string, config: SdlcConfig, tasks: De
|
|
|
83
89
|
if (!items.length) continue;
|
|
84
90
|
const tally = findingTally(items);
|
|
85
91
|
row.findings ??= findingTally([]);
|
|
86
|
-
for (const key of Object.keys(tally) as (keyof ReviewFindingTally)[]) row.findings[key]
|
|
92
|
+
for (const key of Object.keys(tally) as (keyof ReviewFindingTally)[]) row.findings[key] = (row.findings[key] ?? 0) + (tally[key] ?? 0);
|
|
87
93
|
}
|
|
88
94
|
if (!read.pathsComplete) row.blockers.push("PR file coverage is incomplete or unknown");
|
|
89
95
|
if (read.draft !== false) row.blockers.push("PR is draft or draft status is unknown");
|
|
@@ -91,7 +97,7 @@ export async function readMergeQueue(repo: string, config: SdlcConfig, tasks: De
|
|
|
91
97
|
const linked = holders.length ? holders : [undefined];
|
|
92
98
|
if (config.mode === "enforce" && row.findings?.openImportant) row.blockers.push("open important review findings: " + row.findings.openImportant);
|
|
93
99
|
for (const holder of linked) {
|
|
94
|
-
const conformance = holder?.plan ? { ...planConformance(holder.plan.paths, read), accepted: holder.plan.accepted.some(item => item.repo === holder.receipt?.repo && item.pr === holder.receipt?.pr && item.head === read.head && item.revision === holder.plan!.revision && item.fingerprint === holder.plan!.fingerprint && JSON.stringify([...item.paths].sort()) === JSON.stringify([...read.paths].sort())) } : undefined;
|
|
100
|
+
const conformance = holder?.plan ? { ...planConformance(holder.plan.paths, read, holder.plan.out_of_scope), accepted: holder.plan.accepted.some(item => item.repo === holder.receipt?.repo && item.pr === holder.receipt?.pr && item.head === read.head && item.revision === holder.plan!.revision && item.fingerprint === holder.plan!.fingerprint && JSON.stringify([...item.paths].sort()) === JSON.stringify([...read.paths].sort())) } : undefined;
|
|
95
101
|
if (holder && conformance && config.mode !== "off") (row.planConformance ??= []).push({ task: holder.id, state: conformance.state, outside: conformance.outside.length, untouched: conformance.untouched.length, accepted: conformance.accepted });
|
|
96
102
|
const rawIntegrity = config.mode !== "off" && holder?.receipt ? await readTestIntegrity(holder.receipt, read, bounded) : undefined;
|
|
97
103
|
if (rawIntegrity && holder?.receipt?.issue) {
|
|
@@ -112,8 +118,12 @@ export async function readMergeQueue(repo: string, config: SdlcConfig, tasks: De
|
|
|
112
118
|
if (gate) { row.evalGate = gate; if (config.mode === "enforce") row.blockers.push(...evalGapBlockers(gate)); }
|
|
113
119
|
}
|
|
114
120
|
if (config.mode === "enforce") row.blockers.push(...planConformanceBlockers(conformance), ...testIntegrityBlockers(integrity));
|
|
121
|
+
// #1403 A2: readable from the same complete inventory; a PR with several holders shows the strictest state. `unknown` is never softened to `not_required`.
|
|
122
|
+
const security = config.mode !== "off" ? securityPassView(config.security, read, holder?.securityPass) : undefined;
|
|
123
|
+
if (security) row.securityPass = worseSecurity(row.securityPass, security);
|
|
115
124
|
}
|
|
116
125
|
}
|
|
126
|
+
if (config.mode === "enforce") for (const row of result.rows) row.blockers.push(...securityPassBlockers(row.securityPass));
|
|
117
127
|
const dependencyEvidence = new Map<number, PrEvidence | undefined>(); let dependencyReads = 0;
|
|
118
128
|
for (const row of result.rows) {
|
|
119
129
|
if (row.private) continue;
|
package/src/hub/sdlc-release.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface ReleaseReportPolicy {
|
|
|
31
31
|
authorization: ReleaseReportAuthorizationState;
|
|
32
32
|
version?: string;
|
|
33
33
|
}
|
|
34
|
-
export interface ReleaseReadiness { /** #481 AC12: interval, approval-to-release lead time and hotfix rate over shipped releases, filled by Tasks.releaseReadiness. */ releaseMetrics?: ReturnType<typeof releaseMetrics>; releasePolicy?: ReleaseReportPolicy; repo: string; head?: string; version?: string; tag?: string; tagCommit?: string; commits: string[]; mergedPrs: { pr: number; commit: string }[]; documents?: DocEvidence; liveIssues: { id: number; state: "open" | "closed" | "unknown" }[]; blockers: string[]; sourceReady: boolean; native: "unverified"; ready: false; }
|
|
34
|
+
export interface ReleaseReadiness { /** #1403 A4: the newest security audit as counts only (ref, profile, partial, unit states, finding tallies); never a path, a finding or a blocker. */ securityAudit?: import("./security-audit.ts").AuditSummary; /** #481 AC12: interval, approval-to-release lead time and hotfix rate over shipped releases, filled by Tasks.releaseReadiness. */ releaseMetrics?: ReturnType<typeof releaseMetrics>; releasePolicy?: ReleaseReportPolicy; repo: string; head?: string; version?: string; tag?: string; tagCommit?: string; commits: string[]; mergedPrs: { pr: number; commit: string }[]; documents?: DocEvidence; liveIssues: { id: number; state: "open" | "closed" | "unknown" }[]; blockers: string[]; sourceReady: boolean; native: "unverified"; ready: false; }
|
|
35
35
|
export type ReleaseGit = (args: string[]) => { code: number; stdout: string };
|
|
36
36
|
export interface ReleaseReaders { gh?: SdlcGh; git?: ReleaseGit; docs?: (root: string, timeoutMs: number) => Promise<DocEvidence | undefined>; /** Host-only selected authorization/config metadata; absent preserves standalone package.json behavior. */ reportPolicy?: (head: string, repo: string) => ReleaseReportPolicy | undefined; /** Test seam (#1120): the checker program the default docs reader spawns. */ checker?: string; }
|
|
37
37
|
const SHA = /^[0-9a-f]{40}$/;
|
package/src/hub/sdlc.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { controlWriteSpan } from "./control-write-trace.ts";
|
|
|
4
4
|
import { DEFAULT_MAX_NITS, findingsForHead, findingHead, findingTally, type ReviewFindingSet, type ReviewFindingTally } from "./review-findings.ts";
|
|
5
5
|
import type { CostPlan } from "./cost-governance.ts";
|
|
6
6
|
import { bandsConfig, type BandsConfig } from "./sdlc-metrics.ts";
|
|
7
|
+
import { securityPassBlockers, securityPolicy, type SecurityPassView, type SecurityPolicy } from "./security-pass.ts";
|
|
7
8
|
import { configPathList, evalGapBlockers, evalGateView, evalRequiredChecks, type EvalGate, type EvalResult } from "./eval-gate.ts";
|
|
8
9
|
import { SECURITY_SOURCES, type SecuritySource } from "./security-baseline.ts";
|
|
9
10
|
import { criteriaReceipt, type CriteriaReceipt, type CriteriaView, type LegacyPhaseReceipt } from "./workflow.ts";
|
|
@@ -43,7 +44,7 @@ export const AUTO_MERGE_MODES: readonly AutoMergeMode[] = ["off", "dry-run", "on
|
|
|
43
44
|
export interface SecurityScanConfig { everyH: number; sources: SecuritySource[]; repo?: string }
|
|
44
45
|
/** #786: one repository's own gate: its required checks (before the top-level list) and its own merge mode. */
|
|
45
46
|
export interface RepoMergePolicy { requiredChecks?: string[]; autoMerge?: AutoMergeMode }
|
|
46
|
-
export interface SdlcConfig { workflow?: "gsd-lite"; maxNits?: number; /** #481 S7: optional control bands per metric; absent means none. */ bands?: BandsConfig; /** #481 S7: the scheduled security-scan baseline; absent means none is scheduled. */ securityScan?: SecurityScanConfig; /** #481 S5: the one check a configuration PR needs; no default, the person names it. */ evalCheck?: string; /** #481 S5: patterns that mark a PR as a configuration change; absent reads as the defaults in eval-gate.ts, an empty list turns the gate off. */ configPaths?: string[]; mode: SdlcMode; requiredChecks: string[]; /** #786: absent reads as "off"; written only when the file names it. */ autoMerge?: AutoMergeMode; /** #786: per-repository tables, keyed by lowercase owner/name. */ repos?: Record<string, RepoMergePolicy>; stages: SdlcStage[]; definitions?: Record<string, StageDefinition>; deprecations?: string[]; }
|
|
47
|
+
export interface SdlcConfig { workflow?: "gsd-lite"; maxNits?: number; /** #481 S7: optional control bands per metric; absent means none. */ bands?: BandsConfig; /** #481 S7: the scheduled security-scan baseline; absent means none is scheduled. */ securityScan?: SecurityScanConfig; /** #481 S5: the one check a configuration PR needs; no default, the person names it. */ evalCheck?: string; /** #481 S5: patterns that mark a PR as a configuration change; absent reads as the defaults in eval-gate.ts, an empty list turns the gate off. */ configPaths?: string[]; /** #1403 A2: sensitive paths that need a recorded security pass, and the review companions that apply; absent means the feature is off. */ security?: SecurityPolicy; mode: SdlcMode; requiredChecks: string[]; /** #786: absent reads as "off"; written only when the file names it. */ autoMerge?: AutoMergeMode; /** #786: per-repository tables, keyed by lowercase owner/name. */ repos?: Record<string, RepoMergePolicy>; stages: SdlcStage[]; definitions?: Record<string, StageDefinition>; deprecations?: string[]; }
|
|
47
48
|
export interface PlanReviewReceipt {
|
|
48
49
|
planner: string;
|
|
49
50
|
planAuthor?: string | null;
|
|
@@ -201,7 +202,7 @@ export function sdlcConfig(value: unknown, version?: string): SdlcConfig {
|
|
|
201
202
|
if (value === undefined) return { mode: "off", requiredChecks: [], stages: [...SDLC_STAGES] };
|
|
202
203
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("sdlc: expected a table");
|
|
203
204
|
const raw = value as Record<string, unknown>;
|
|
204
|
-
for (const key of Object.keys(raw)) if (!["mode", "required_checks", "stages", "workflow", "definitions", "max_nits", "bands", "auto_merge", "repos", "eval_check", "config_paths", "security_scan"].includes(key)) throw new Error(`sdlc.${key}: unknown field`);
|
|
205
|
+
for (const key of Object.keys(raw)) if (!["mode", "required_checks", "stages", "workflow", "definitions", "max_nits", "bands", "auto_merge", "repos", "eval_check", "config_paths", "security_scan", "security"].includes(key)) throw new Error(`sdlc.${key}: unknown field`);
|
|
205
206
|
const maxNits = raw.max_nits === undefined ? DEFAULT_MAX_NITS : raw.max_nits;
|
|
206
207
|
if (typeof maxNits !== "number" || !Number.isSafeInteger(maxNits) || maxNits < 0 || maxNits > 64) throw new Error("sdlc.max_nits: expected an integer from 0 to 64");
|
|
207
208
|
const bands = bandsConfig(raw.bands), bandConfig = Object.keys(bands).length ? { bands } : {};
|
|
@@ -209,7 +210,7 @@ export function sdlcConfig(value: unknown, version?: string): SdlcConfig {
|
|
|
209
210
|
...(raw.eval_check === undefined ? {} : { evalCheck: evalCheckName(raw.eval_check) }),
|
|
210
211
|
...(raw.config_paths === undefined ? {} : { configPaths: configPathList(raw.config_paths, "sdlc.config_paths") }),
|
|
211
212
|
};
|
|
212
|
-
const findingConfig = { ...(raw.max_nits === undefined ? {} : { maxNits }), ...bandConfig, ...evalConfig, ...(raw.security_scan === undefined ? {} : { securityScan: securityScanConfig(raw.security_scan) }) };
|
|
213
|
+
const findingConfig = { ...(raw.max_nits === undefined ? {} : { maxNits }), ...bandConfig, ...evalConfig, ...(raw.security_scan === undefined ? {} : { securityScan: securityScanConfig(raw.security_scan) }), ...(raw.security === undefined ? {} : { security: securityPolicy(raw.security) }) };
|
|
213
214
|
const mode = raw.mode ?? "off";
|
|
214
215
|
if (mode !== "off" && mode !== "advise" && mode !== "enforce") throw new Error("sdlc.mode: expected off, advise or enforce");
|
|
215
216
|
// ponytail: the #481 S8 window is a fixed version; delete `workflow`, the phase aliases and their tests once it passes.
|
|
@@ -326,6 +327,40 @@ export function planningIssueReceipt(value: unknown, previous: SdlcReceipt | und
|
|
|
326
327
|
}
|
|
327
328
|
|
|
328
329
|
|
|
330
|
+
/**
|
|
331
|
+
* #1490 AC5: one head can carry the check rows of several runs of one workflow: the draft run `gh pr ready` replaces (its macOS aggregate failed on purpose, its other jobs were
|
|
332
|
+
* cancelled), a rerun, or a run a newer push cancelled. The newest run of a workflow is the one that says what the head's CI is, so an older row of the same check name is dropped
|
|
333
|
+
* from the evidence, never read as a failure to fix. Only when it is certain: every row of the name has a start time and the same workflow identity, and exactly one row is newest.
|
|
334
|
+
* Anything else (a different workflow with the same job name, a missing time, a tie) keeps every row, so `requiredCiBlocker` still says `duplicate` and unknown stays unknown.
|
|
335
|
+
* Callers apply it before they index the raw rows beside the parsed checks.
|
|
336
|
+
*/
|
|
337
|
+
export function latestCheckRuns<T>(rows: readonly T[]): T[] {
|
|
338
|
+
const field = (row: T) => row as unknown as { name?: unknown; context?: unknown; startedAt?: unknown; workflowName?: unknown; checkSuite?: { workflowRun?: { workflow?: { resourcePath?: unknown } } } } | null;
|
|
339
|
+
const workflowOf = (row: T): string | undefined => {
|
|
340
|
+
const value = field(row);
|
|
341
|
+
const named = value?.workflowName ?? value?.checkSuite?.workflowRun?.workflow?.resourcePath;
|
|
342
|
+
return typeof named === "string" && named ? named : undefined;
|
|
343
|
+
};
|
|
344
|
+
const groups = new Map<string, T[]>();
|
|
345
|
+
for (const row of rows) {
|
|
346
|
+
const name = field(row)?.name ?? field(row)?.context;
|
|
347
|
+
if (typeof name !== "string") continue;
|
|
348
|
+
const group = groups.get(name);
|
|
349
|
+
if (group) group.push(row); else groups.set(name, [row]);
|
|
350
|
+
}
|
|
351
|
+
const older = new Set<T>();
|
|
352
|
+
for (const group of groups.values()) {
|
|
353
|
+
if (group.length < 2) continue;
|
|
354
|
+
const workflows = new Set(group.map(workflowOf));
|
|
355
|
+
const times = group.map(row => typeof field(row)?.startedAt === "string" ? Date.parse(field(row)!.startedAt as string) : NaN);
|
|
356
|
+
if (workflows.size !== 1 || workflows.has(undefined) || times.some(time => !Number.isFinite(time))) continue;
|
|
357
|
+
const newest = Math.max(...times);
|
|
358
|
+
if (times.filter(time => time === newest).length !== 1) continue;
|
|
359
|
+
group.forEach((row, index) => { if (times[index] !== newest) older.add(row); });
|
|
360
|
+
}
|
|
361
|
+
return older.size ? rows.filter(row => !older.has(row)) : [...rows];
|
|
362
|
+
}
|
|
363
|
+
|
|
329
364
|
export function parsePrEvidence(value: unknown): PrEvidence {
|
|
330
365
|
const p = value as Record<string, any>;
|
|
331
366
|
if (!p || !sha(p.headRefOid) || !["OPEN", "CLOSED", "MERGED"].includes(p.state) || !Array.isArray(p.statusCheckRollup) || !Array.isArray(p.files) || p.files.length > 1000) throw new Error("PR readback: invalid or incomplete structured evidence");
|
|
@@ -387,10 +422,10 @@ export const SPEC_STATE_TEXT: Record<Exclude<SpecState, "current">, string> = {
|
|
|
387
422
|
changed: "spec changed after acceptance: the person re-accepts with ahub sdlc accept <task> --issue <n>",
|
|
388
423
|
unknown: "spec edit time unknown: the issue could not be read",
|
|
389
424
|
};
|
|
390
|
-
export interface SdlcStatus { evalGate?: EvalGate; testIntegrity?: TestIntegrity; planConformance?: PlanConformance & { accepted?: boolean; earlierPushes?: "unknown"; revisionsAfterFirstObservedPush?: number }; findings?: ReviewFindingTally; spec?: { issue: number; state: SpecState }; playbook?: string; criteria?: CriteriaView; mode: SdlcMode; stage: SdlcStage; definition?: StageDefinition; entry?: string[]; exit?: string[]; blockers: string[]; ready: boolean; actor: string; next: string; }
|
|
425
|
+
export interface SdlcStatus { /** #1403 A2: shown only for an enabled lifecycle that configures `[security]`. */ securityPass?: SecurityPassView; evalGate?: EvalGate; testIntegrity?: TestIntegrity; planConformance?: PlanConformance & { accepted?: boolean; earlierPushes?: "unknown"; revisionsAfterFirstObservedPush?: number }; findings?: ReviewFindingTally; spec?: { issue: number; state: SpecState }; playbook?: string; criteria?: CriteriaView; mode: SdlcMode; stage: SdlcStage; definition?: StageDefinition; entry?: string[]; exit?: string[]; blockers: string[]; ready: boolean; actor: string; next: string; }
|
|
391
426
|
/** The acceptance-criteria checklist (#481 S8, Compliance pass) counts once recorded, and on every task under the retired gsd-lite setting. Off keeps #257's output. */
|
|
392
427
|
export const criteriaRequired = (config: SdlcConfig, receipt: SdlcReceipt | undefined): boolean => config.workflow === "gsd-lite" || (config.mode !== "off" && !!checklistOf(receipt));
|
|
393
|
-
export function sdlcStatus(config: SdlcConfig, receipt: SdlcReceipt | undefined, evidence?: PrEvidence, criteria?: CriteriaView, specEdit?: SpecEdit, sets: readonly ReviewFindingSet[] = [], commit?: string, plan?: SdlcStatus["planConformance"], integrity?: TestIntegrity, evalResult?: EvalResult): SdlcStatus {
|
|
428
|
+
export function sdlcStatus(config: SdlcConfig, receipt: SdlcReceipt | undefined, evidence?: PrEvidence, criteria?: CriteriaView, specEdit?: SpecEdit, sets: readonly ReviewFindingSet[] = [], commit?: string, plan?: SdlcStatus["planConformance"], integrity?: TestIntegrity, evalResult?: EvalResult, securityPass?: SecurityPassView): SdlcStatus {
|
|
394
429
|
const stage = receipt?.stage ?? config.stages[0] ?? "spec", blockers: string[] = [];
|
|
395
430
|
const definition = stageDefinition(config, stage);
|
|
396
431
|
const evalGate = evidence ? evalGateView(config, evidence, evalResult) : undefined;
|
|
@@ -398,6 +433,9 @@ export function sdlcStatus(config: SdlcConfig, receipt: SdlcReceipt | undefined,
|
|
|
398
433
|
const findings = items.length ? findingTally(items) : undefined;
|
|
399
434
|
if (config.mode === "enforce" && findings?.openImportant) blockers.push("open important review findings: " + findings.openImportant);
|
|
400
435
|
if (config.mode === "enforce") blockers.push(...planConformanceBlockers(plan), ...testIntegrityBlockers(integrity));
|
|
436
|
+
// #1403 A2: a required pass that is not recorded, or an applicability the inventory cannot settle, blocks only in enforce; advise shows it in `securityPass` and the advice notice.
|
|
437
|
+
const security = config.mode !== "off" ? securityPass : undefined;
|
|
438
|
+
if (config.mode === "enforce") blockers.push(...securityPassBlockers(security));
|
|
401
439
|
if (!definition) blockers.push("lifecycle stage definition unknown");
|
|
402
440
|
if (!receipt?.repo || !receipt.issue) blockers.push("issue identity missing");
|
|
403
441
|
if (!receipt?.pr) blockers.push("PR identity missing");
|
|
@@ -426,7 +464,7 @@ export function sdlcStatus(config: SdlcConfig, receipt: SdlcReceipt | undefined,
|
|
|
426
464
|
const shown = criteria && (criteriaRequired(config, receipt) || definition && [...definition.entry_gates, ...definition.exit_gates].includes("criteria"));
|
|
427
465
|
// Shown, not counted as a readiness blocker: the spec gate is build entry (#481 S1).
|
|
428
466
|
const spec = config.mode !== "off" && receipt?.issue ? { spec: { issue: receipt.issue, state: specState(receipt, specEdit) } } : {};
|
|
429
|
-
return { ...spec, ...(evalGate ? { evalGate } : {}), ...(config.mode !== "off" && integrity ? { testIntegrity: integrity } : {}), ...(config.mode !== "off" && plan ? { planConformance: plan } : {}), ...(findings ? { findings } : {}), ...(config.mode !== "off" && definition && playbookStage(definition.base) ? { playbook: playbookStage(definition.base) } : {}), ...(shown ? { criteria } : {}), ...(custom ? { definition, ...custom } : {}), mode: config.mode, stage, blockers, ready: blockers.length === 0,
|
|
467
|
+
return { ...spec, ...(security ? { securityPass: security } : {}), ...(evalGate ? { evalGate } : {}), ...(config.mode !== "off" && integrity ? { testIntegrity: integrity } : {}), ...(config.mode !== "off" && plan ? { planConformance: plan } : {}), ...(findings ? { findings } : {}), ...(config.mode !== "off" && definition && playbookStage(definition.base) ? { playbook: playbookStage(definition.base) } : {}), ...(shown ? { criteria } : {}), ...(custom ? { definition, ...custom } : {}), mode: config.mode, stage, blockers, ready: blockers.length === 0,
|
|
430
468
|
actor: !definition ? "person" : shown && criteria.blockers.length ? "reviewer/person" : config.definitions ? definition.actor : baseActor(definition.base),
|
|
431
469
|
// #694: the identity blocker keeps its exact text for gate matching; the next step says how to supply it.
|
|
432
470
|
next: blockers[0] === "issue identity missing" ? "issue identity missing: name one issue (title #N, refs or hub_sdlc_record)" : blockers[0] ?? "person may inspect merge readiness; no automatic merge" };
|
|
@@ -517,6 +555,7 @@ export async function readSdlcPr(receipt: SdlcReceipt, run: SdlcGh = sdlcGh, wit
|
|
|
517
555
|
const query = `query($owner:String!,$name:String!,$number:Int!${labels ? ",$issue:Int!" : ""}){repository(owner:$owner,name:$name){pullRequest(number:$number){headRefOid reviewThreads(first:100){nodes{isResolved} pageInfo{hasNextPage}}}${labels ? " issue(number:$issue){number labels(first:100){nodes{name} pageInfo{hasNextPage}}}" : ""}}}`;
|
|
518
556
|
const threads = await run(["api", "graphql", "-f", `query=${query}`, "-f", `owner=${owner}`, "-f", `name=${name}`, ...(labels ? ["-F", `issue=${labels.issue}`] : []), "-F", `number=${receipt.pr}`]);
|
|
519
557
|
const p = JSON.parse(view.stdout);
|
|
558
|
+
if (Array.isArray(p.statusCheckRollup)) p.statusCheckRollup = latestCheckRuns(p.statusCheckRollup);
|
|
520
559
|
delete p.unresolvedThreads; // only the complete thread query can establish this fact
|
|
521
560
|
if (threads.code === 0) {
|
|
522
561
|
const response = JSON.parse(threads.stdout);
|
|
@@ -610,7 +649,7 @@ export async function readReviewReadiness(receipt: SdlcReceipt, expected: string
|
|
|
610
649
|
const full = requiredCheckNames(receipt.repo, requiredChecks);
|
|
611
650
|
if (!full.length) return { ready: false, blockers: ["required checks unknown: set required_checks in .agenthub/sdlc.toml"], checks: full };
|
|
612
651
|
const [owner, name] = receipt.repo.split("/");
|
|
613
|
-
const query = "query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){headRefOid state commits(last:1){nodes{commit{oid tree{oid} statusCheckRollup{contexts(first:100){nodes{... on CheckRun{name status conclusion} ... on StatusContext{context state}} pageInfo{hasNextPage}}}}}} reviewThreads(first:100){nodes{isResolved comments(first:100){nodes{author{__typename} createdAt} pageInfo{hasNextPage}}} pageInfo{hasNextPage}}}}}";
|
|
652
|
+
const query = "query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){headRefOid state commits(last:1){nodes{commit{oid tree{oid} statusCheckRollup{contexts(first:100){nodes{... on CheckRun{name status conclusion startedAt checkSuite{workflowRun{workflow{resourcePath}}}} ... on StatusContext{context state}} pageInfo{hasNextPage}}}}}} reviewThreads(first:100){nodes{isResolved comments(first:100){nodes{author{__typename} createdAt} pageInfo{hasNextPage}}} pageInfo{hasNextPage}}}}}";
|
|
614
653
|
try {
|
|
615
654
|
const deadline = performance.now() + 20_000;
|
|
616
655
|
const bounded: SdlcGh = (args, timeout, cwd, cap) => performance.now() < deadline
|
|
@@ -631,7 +670,7 @@ export async function readReviewReadiness(receipt: SdlcReceipt, expected: string
|
|
|
631
670
|
const nodes: unknown[] | undefined = contexts?.nodes;
|
|
632
671
|
let reusedRun: number | undefined;
|
|
633
672
|
const completeChecks = !(contexts?.pageInfo?.hasNextPage !== false || !Array.isArray(nodes) || nodes.length > 100);
|
|
634
|
-
const requiredNodes = completeChecks ? nodes
|
|
673
|
+
const requiredNodes = completeChecks ? latestCheckRuns(nodes!).filter(node => {
|
|
635
674
|
const raw = node as { name?: unknown; context?: unknown } | null | undefined;
|
|
636
675
|
return full.some(name => (raw?.name ?? raw?.context) === name);
|
|
637
676
|
}) : [];
|