@staix/agent-hub 0.46.0 → 0.47.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 +85 -0
- package/README.md +8 -4
- package/docs/adding-an-ai-tool.md +20 -4
- package/docs/agent-notes/adapters.md +3 -3
- package/docs/agent-notes/benchmarks.md +7 -1
- package/docs/agent-notes/daemon.md +6 -5
- package/docs/agent-notes/tasks.md +4 -2
- package/docs/agent-notes/tests.md +3 -0
- package/docs/contracts/companion-cli-v1.json +3 -0
- package/docs/data-policy.md +9 -0
- package/docs/design/adapters.md +14 -0
- package/docs/design/cli-output-inventory.md +362 -0
- package/docs/design/cli-output.md +42 -1
- package/docs/design/execution-reference.md +5 -2
- package/docs/design/guidance-probes.md +2 -2
- package/docs/design/refusal-inventory.md +26 -0
- package/docs/design/roadmap.md +4 -0
- package/docs/design/task-board.md +17 -1
- package/docs/dogfood.md +26 -10
- package/docs/events.md +9 -0
- package/docs/friction.md +46 -0
- package/docs/memory.md +35 -3
- package/docs/operations.md +63 -15
- package/docs/profiles.md +1 -0
- package/docs/quickstart.md +14 -2
- package/docs/roles.md +6 -0
- package/docs/sdlc.md +44 -1
- package/docs/security.md +16 -7
- package/docs/specs/2026-09-19-agent-hub-design.md +17 -0
- package/docs/specs/2026-09-19-multi-project-design.md +7 -1
- package/docs/verification/2026-11-24-0.46.1.md +48 -0
- package/docs/verification/2026-11-25-agy-1.5.16.md +31 -0
- package/docs/verification/2026-11-25-claude-implementer-2.1.332.md +47 -0
- package/docs/verification/2026-11-25-codex-0172-reviewer-isolation.md +47 -0
- package/docs/verification/2026-11-25-kimi-272-reviewer-compat.md +38 -0
- package/docs/verification/2026-11-25-kimi-tui-272.md +14 -0
- package/docs/verification/2026-11-25-pi-160-compat.md +40 -0
- package/docs/verification/2026-11-26-0.47.0.md +43 -0
- package/docs/verification/2026-11-26-codex-0172-reviewer-tool-call.md +29 -0
- package/docs/verification/dogfood/2026-11-24.md +2829 -0
- package/docs/verification/pi-160-model-free.ts +57 -0
- package/docs/verification/pi-160-native.mjs +21 -0
- package/docs/verified.json +43 -31
- package/package.json +2 -2
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +679 -134
- package/plugins/agent-hub/server.js +776 -154
- package/src/adapters/acp.ts +5 -0
- package/src/adapters/channel-peer.ts +7 -0
- package/src/adapters/claude-print-child.ts +27 -5
- package/src/adapters/codex-appserver.ts +9 -0
- package/src/adapters/compat.ts +12 -11
- package/src/adapters/configured-acp.ts +45 -2
- package/src/adapters/configured-print.ts +163 -0
- package/src/adapters/conformance/index.ts +1 -0
- package/src/adapters/conformance/print.ts +57 -0
- package/src/adapters/definitions/native-activity.ts +57 -0
- package/src/adapters/definitions/native-factories.ts +4 -2
- package/src/adapters/jcode.ts +10 -2
- package/src/adapters/local-worker.ts +2 -0
- package/src/adapters/registry-types.ts +5 -3
- package/src/adapters/role-eligibility.ts +5 -0
- package/src/cli/bench.ts +2 -1
- package/src/cli/broker.ts +2 -1
- package/src/cli/capabilities-output.ts +10 -14
- package/src/cli/configured-acp-entry.ts +10 -2
- package/src/cli/console-state.ts +25 -5
- package/src/cli/error-format.ts +2 -0
- package/src/cli/guidance.ts +1 -1
- package/src/cli/handoff-output.ts +20 -17
- package/src/cli/help.ts +78 -40
- package/src/cli/init-settings.ts +15 -0
- package/src/cli/intake-output.ts +13 -13
- package/src/cli/launch.ts +3 -2
- package/src/cli/learn-output.ts +40 -21
- package/src/cli/main.ts +148 -77
- package/src/cli/memory.ts +47 -2
- package/src/cli/output.ts +54 -31
- package/src/cli/recovery-package.ts +6 -1
- package/src/cli/roadmap.ts +2 -2
- package/src/cli/room-output.ts +71 -0
- package/src/cli/room.ts +19 -33
- package/src/cli/schedule-output.ts +20 -19
- package/src/cli/sdlc-output.ts +188 -170
- package/src/cli/source-output.ts +17 -14
- package/src/cli/specs.ts +13 -13
- package/src/cli/study-output.ts +66 -69
- package/src/cli/task-output.ts +106 -158
- package/src/cli/terminal-recovery.ts +2 -1
- package/src/cli/upgrade-runtime.ts +2 -1
- package/src/cli/warn-line.ts +18 -0
- package/src/cli/worktrees-output.ts +25 -23
- package/src/hub/audit-source.ts +45 -0
- package/src/hub/board.ts +141 -5
- package/src/hub/bus.ts +13 -2
- package/src/hub/config-apply.ts +14 -1
- package/src/hub/config-trust.ts +1 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +371 -45
- package/src/hub/handoff.ts +5 -1
- package/src/hub/hub-tools.ts +23 -5
- package/src/hub/instance-config.ts +3 -3
- package/src/hub/learn-followup.ts +103 -0
- package/src/hub/learning.ts +63 -1
- package/src/hub/manager.ts +15 -1
- package/src/hub/memory-policy.ts +2 -1
- package/src/hub/memory-review.ts +217 -0
- package/src/hub/peer-activity.ts +37 -0
- package/src/hub/peers.ts +3 -0
- package/src/hub/project-move.ts +258 -0
- package/src/hub/registry.ts +16 -5
- package/src/hub/restart.ts +7 -0
- package/src/hub/review-brief.ts +8 -4
- package/src/hub/review-checkout.ts +26 -0
- package/src/hub/review-findings.ts +6 -3
- package/src/hub/risk-tier.ts +129 -0
- package/src/hub/roadmap-check.ts +1 -0
- package/src/hub/routing.ts +3 -1
- package/src/hub/sdlc-merge.ts +9 -0
- package/src/hub/sdlc-metrics.ts +24 -1
- package/src/hub/sdlc-queue.ts +1 -1
- package/src/hub/sdlc.ts +15 -6
- package/src/hub/settings.ts +2 -0
- package/src/hub/spec-readback.ts +136 -0
- package/src/hub/specs.ts +1 -1
- package/src/hub/task-list-page.ts +1 -1
- package/src/hub/tasks.ts +558 -65
- package/src/hub/ui.ts +4 -2
- package/src/ui/index.html +26 -2
- package/src/ui/overview-model.ts +138 -0
- package/src/ui/plugin.ts +30 -4
- package/templates/roles/ops/project-manager.md +1 -1
package/src/hub/roadmap-check.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export interface DriftTask {
|
|
3
3
|
id: number; state: string; issue: string | null | undefined; issueState: "open" | "closed" | "unknown";
|
|
4
4
|
feature: boolean; specIssue: boolean | undefined; mergedAt: number | null | undefined;
|
|
5
|
+
/** Unchanged specs without a recorded owner acknowledgement at the merged head. */
|
|
5
6
|
unchangedSpecs: readonly string[] | undefined;
|
|
6
7
|
}
|
|
7
8
|
export interface DriftMilestone {
|
package/src/hub/routing.ts
CHANGED
|
@@ -510,7 +510,9 @@ export function assign(
|
|
|
510
510
|
const blocked = (peer: PeerId, role: "owner" | "reviewer"): string | undefined => {
|
|
511
511
|
const deny = (code: RoutingRefusalCode, reason: string): string => { refusals.set(`${role}:${peer}`, { peer, role, code, reason }); return reason; };
|
|
512
512
|
if (isRemotePeerId(peer)) return deny("policy", "remote peers cannot hold local roles");
|
|
513
|
-
const
|
|
513
|
+
const definition = (opts.adapterCatalog?.definitionOf ?? definitionOf)(peer, opts.instances);
|
|
514
|
+
if (definition?.start.daemonPort === "configured-print") return deny("policy", "print peers return advisory answers and cannot own tasks or submit verdicts");
|
|
515
|
+
const ceiling = definition?.routing?.allowedRoles;
|
|
514
516
|
const requiredRole = role === "reviewer" ? "reviewer" : ownerRoleOfClass(task.class);
|
|
515
517
|
if (ceiling && !ceiling.includes(requiredRole)) return deny("policy", "adapter role ceiling excludes this assignment");
|
|
516
518
|
const unavailable = role === "reviewer" ? (opts.adapterCatalog?.definitionOf ?? definitionOf)(peer, opts.instances)?.reviewer?.unavailable : undefined;
|
package/src/hub/sdlc-merge.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { findingsForHead, findingHead, findingTally } from "./review-findings.ts";
|
|
2
2
|
import { readMergeQueue, type DeliveryTask, type MergeQueue } from "./sdlc-queue.ts";
|
|
3
|
+
import { riskMinimum, riskPlanFloor } from "./risk-tier.ts";
|
|
3
4
|
import { evalGapBlockers, evalGateView, evalReportedGap, evalRequiredChecks, readEvalFor, type EvalResult } from "./eval-gate.ts";
|
|
4
5
|
import { mergeCostFrom } from "./cost-governance.ts";
|
|
5
6
|
import { latestCheckRuns, parsePrEvidence, readPrCostHistory, readSdlcPr, stageDefinition, type AutoMergeMode, type PrEvidence, type SdlcConfig, type SdlcGh, type MergeRecord, type SdlcReceipt } from "./sdlc.ts";
|
|
@@ -202,6 +203,14 @@ export function localGates(input: { subject: DeliveryTask; state: string; taskSt
|
|
|
202
203
|
}
|
|
203
204
|
if (findingTally(findingsForHead(subject.findings ?? [], findingHead(subject.receipt, input.head ? { head: input.head } : undefined))).openImportant > 0) gates.push("open Important finding");
|
|
204
205
|
if (subject.receipt && stageDefinition(config, subject.receipt.stage)?.base === "release") gates.push("release PR: person consent required");
|
|
206
|
+
// #1645 T4: the merge gate names the tier, and in enforce refuses the one gap the board can still show here: a plan whose own review metadata asked for
|
|
207
|
+
// less than the tier's minimum. The verifier check belongs to the verdict (T3) and is not repeated - a card approved for this head cannot un-approve it -
|
|
208
|
+
// and the tier is read only for the head it was derived at (T2), so a moved head makes no claim here either.
|
|
209
|
+
const risk = subject.receipt?.risk;
|
|
210
|
+
if (risk && config.mode === "enforce") {
|
|
211
|
+
const floor = riskPlanFloor(subject.plan?.planReview, riskMinimum(risk.tier));
|
|
212
|
+
if (floor) gates.push(`risk ${risk.tier} (${risk.matched} path${risk.matched === 1 ? "" : "s"} decided it): ${floor}; record a plan review that meets it with hub_plan_review, then merge`);
|
|
213
|
+
}
|
|
205
214
|
return gates;
|
|
206
215
|
}
|
|
207
216
|
|
package/src/hub/sdlc-metrics.ts
CHANGED
|
@@ -14,6 +14,8 @@ export type BandTier = typeof BAND_TIERS[number];
|
|
|
14
14
|
export interface MetricTask {
|
|
15
15
|
id: number;
|
|
16
16
|
private?: boolean;
|
|
17
|
+
/** #1647: why the task was split off; absent reads as `unset`. */
|
|
18
|
+
reason?: string;
|
|
17
19
|
/** `evidenceOnly` marks a code-scope verdict with no open finding (#852): it is not a rework round. `requestHead` is the head a `done` asked review for (requestHead, with historical fallbacks); `verdictHead` the head a verdict was bound to (reviewFindings.head). Compared for equality only, never printed. */
|
|
18
20
|
history: { at: number; event: string; requestHead?: string; verdictHead?: string; evidenceOnly?: true }[];
|
|
19
21
|
}
|
|
@@ -219,9 +221,29 @@ export function controlEpisode(points: readonly { value: number; task: number }[
|
|
|
219
221
|
return { ...now, episode: points[start]!.task };
|
|
220
222
|
}
|
|
221
223
|
|
|
224
|
+
/** #1647 AC4: one group per reason a task was split off for, `unset` for the tasks proposed without one. Tokens are the hub's own increments; `null` when no task of the group has a reading. */
|
|
225
|
+
interface ReasonGroup { tasks: number; reviewRounds: number; tokens: number | null }
|
|
226
|
+
const UNSET_REASON = "unset";
|
|
227
|
+
|
|
228
|
+
/** Group the counted tasks by reason. A review round is one `done` (a request for review); tokens sum the tasks that have a reading and stay unknown, never 0, when none does. */
|
|
229
|
+
function reasonGroups(tasks: readonly MetricTask[], samples: ReadonlySet<number>, tokens: Readonly<Record<number, number | null>> = {}): Record<string, ReasonGroup> {
|
|
230
|
+
const groups: Record<string, ReasonGroup> = {};
|
|
231
|
+
for (const task of tasks) {
|
|
232
|
+
if (task.private || !samples.has(task.id)) continue;
|
|
233
|
+
const key = task.reason ?? UNSET_REASON, group = groups[key] ??= { tasks: 0, reviewRounds: 0, tokens: null };
|
|
234
|
+
group.tasks++;
|
|
235
|
+
group.reviewRounds += task.history.filter(entry => entry.event === "done").length;
|
|
236
|
+
const used = tokens[task.id];
|
|
237
|
+
if (typeof used === "number" && Number.isFinite(used)) group.tokens = (group.tokens ?? 0) + used;
|
|
238
|
+
}
|
|
239
|
+
return groups;
|
|
240
|
+
}
|
|
241
|
+
|
|
222
242
|
export interface MetricsReport {
|
|
223
243
|
since: number | null;
|
|
224
244
|
tasks: number;
|
|
245
|
+
/** #1647: count, review rounds and tokens grouped by the reason a task was split off. */
|
|
246
|
+
byReason: Record<string, ReasonGroup>;
|
|
225
247
|
withheldPrivate: number;
|
|
226
248
|
securityScan?: Record<string, number | null>;
|
|
227
249
|
metrics: {
|
|
@@ -248,7 +270,7 @@ const rate = (values: readonly (number | null)[]) => {
|
|
|
248
270
|
* The whole report from board tasks. `since` keeps samples that count at or after it; `mergedAt` and `ciReruns` come from bounded
|
|
249
271
|
* PR readbacks keyed by task id and are optional. Private tasks are counted as withheld and read for nothing else.
|
|
250
272
|
*/
|
|
251
|
-
export function sdlcMetrics(tasks: readonly MetricTask[], opts: { since?: number; bands?: BandsConfig; stalls?: StallCounts; mergedAt?: Readonly<Record<number, number>>; ciReruns?: Readonly<Record<number, number | null>>; ciRuns?: Readonly<Record<number, number | null>>; reviews?: Readonly<Record<number, number | null>>; firstPass?: Readonly<Record<number, 0 | 1 | null>>; fullGateRuns?: Readonly<Record<number, number | null>>; successfulGateRuns?: Readonly<Record<number, number | null>>; failedGateRuns?: Readonly<Record<number, number | null>>; cancelledGateRuns?: Readonly<Record<number, number | null>>; otherGateRuns?: Readonly<Record<number, number | null>>; macosShardRuns?: Readonly<Record<number, number | null>>; external?: Partial<Record<BandMetric, readonly SeriesPoint[]>> } = {}): MetricsReport {
|
|
273
|
+
export function sdlcMetrics(tasks: readonly MetricTask[], opts: { since?: number; bands?: BandsConfig; stalls?: StallCounts; mergedAt?: Readonly<Record<number, number>>; ciReruns?: Readonly<Record<number, number | null>>; ciRuns?: Readonly<Record<number, number | null>>; reviews?: Readonly<Record<number, number | null>>; firstPass?: Readonly<Record<number, 0 | 1 | null>>; fullGateRuns?: Readonly<Record<number, number | null>>; successfulGateRuns?: Readonly<Record<number, number | null>>; failedGateRuns?: Readonly<Record<number, number | null>>; cancelledGateRuns?: Readonly<Record<number, number | null>>; otherGateRuns?: Readonly<Record<number, number | null>>; macosShardRuns?: Readonly<Record<number, number | null>>; /** #1647: the hub's own token increments per task, when a usage source is wired. */ tokens?: Readonly<Record<number, number | null>>; external?: Partial<Record<BandMetric, readonly SeriesPoint[]>> } = {}): MetricsReport {
|
|
252
274
|
const visible = tasks.filter(task => !task.private);
|
|
253
275
|
const all = visible.map(task => taskSample(task, { mergedAt: opts.mergedAt?.[task.id], ciReruns: opts.ciReruns?.[task.id], ciRuns: opts.ciRuns?.[task.id], reviews: opts.reviews?.[task.id], firstPass: opts.firstPass?.[task.id], fullGateRuns: opts.fullGateRuns?.[task.id], successfulGateRuns: opts.successfulGateRuns?.[task.id], failedGateRuns: opts.failedGateRuns?.[task.id], cancelledGateRuns: opts.cancelledGateRuns?.[task.id], otherGateRuns: opts.otherGateRuns?.[task.id], macosShardRuns: opts.macosShardRuns?.[task.id] }));
|
|
254
276
|
const samples = opts.since === undefined ? all : all.filter(sample => sample.at >= opts.since!);
|
|
@@ -257,6 +279,7 @@ export function sdlcMetrics(tasks: readonly MetricTask[], opts: { since?: number
|
|
|
257
279
|
: "off";
|
|
258
280
|
return {
|
|
259
281
|
since: opts.since ?? null, tasks: samples.length, withheldPrivate: tasks.length - visible.length,
|
|
282
|
+
byReason: reasonGroups(tasks, new Set(samples.map(sample => sample.id)), opts.tokens),
|
|
260
283
|
metrics: {
|
|
261
284
|
acceptance_to_plan_ms: summarize(samples.map(s => s.acceptance_to_plan_ms)), accepted_to_plan_ms: summarize(samples.map(s => s.accepted_to_plan_ms)), acceptance_to_first_review_ms: summarize(samples.map(s => s.acceptance_to_first_review_ms)),
|
|
262
285
|
acceptance_to_merge_ms: summarize(samples.map(s => s.acceptance_to_merge_ms)),
|
package/src/hub/sdlc-queue.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface DeliveryTask {
|
|
|
10
10
|
latestHead?: string;
|
|
11
11
|
/** Host-derived verdict binding, never inferred from a mutable lifecycle receipt. */
|
|
12
12
|
approval?: { head?: string; latestHead?: string; mismatch: boolean; current: boolean };
|
|
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
|
+
plan?: { paths?: string[]; out_of_scope?: string[]; revision: number; fingerprint: string; accepted: { repo: string; pr: number; head: string; revision: number; fingerprint: string; paths: string[] }[]; /** #1645 T4: the review scope the plan review recorded, compared against the tier's own minimum. */ planReview?: { scope?: string; reviewers?: number } };
|
|
14
14
|
findings?: readonly ReviewFindingSet[]; id: number; after: number[]; private: boolean; receipt?: SdlcReceipt; phase?: CriteriaView;
|
|
15
15
|
/** #1403 A2: the latest security pass an approving or rejecting verdict recorded, bound to the head it reviewed. */
|
|
16
16
|
securityPass?: SecurityPassRecord;
|
package/src/hub/sdlc.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { parseIssueLabels, parseRedFirst, testIntegrityBlockers, type RedFirstReceipt, type TestIntegrity } from "./test-integrity.ts";
|
|
2
2
|
import { planConformanceBlockers, type PlanConformance } from "./plan-conformance.ts";
|
|
3
|
+
import { riskPolicy, type RiskPolicy, type RiskRecord } from "./risk-tier.ts";
|
|
4
|
+
import type { ReadbackView } from "./spec-readback.ts";
|
|
3
5
|
import { controlWriteSpan } from "./control-write-trace.ts";
|
|
4
6
|
import { DEFAULT_MAX_NITS, findingsForHead, findingHead, findingTally, type ReviewFindingSet, type ReviewFindingTally } from "./review-findings.ts";
|
|
5
7
|
import type { CostPlan } from "./cost-governance.ts";
|
|
@@ -45,7 +47,7 @@ export const AUTO_MERGE_MODES: readonly AutoMergeMode[] = ["off", "dry-run", "on
|
|
|
45
47
|
export interface SecurityScanConfig { everyH: number; sources: SecuritySource[]; repo?: string }
|
|
46
48
|
/** #786: one repository's own gate: its required checks (before the top-level list) and its own merge mode. */
|
|
47
49
|
export interface RepoMergePolicy { requiredChecks?: string[]; autoMerge?: AutoMergeMode }
|
|
48
|
-
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[]; }
|
|
50
|
+
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; /** #1645 T1: paths that make a filed change high or low; absent means no tier is derived and nothing else changes. */ risk?: RiskPolicy; 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[]; }
|
|
49
51
|
export interface PlanReviewReceipt {
|
|
50
52
|
planner: string;
|
|
51
53
|
planAuthor?: string | null;
|
|
@@ -86,6 +88,8 @@ export interface SdlcReceipt {
|
|
|
86
88
|
pr?: number;
|
|
87
89
|
head?: string;
|
|
88
90
|
reviewedHead?: string;
|
|
91
|
+
/** #1645 T2: the risk tier derived from the inventory at `head` when this task was filed; never read for another head. */
|
|
92
|
+
risk?: RiskRecord;
|
|
89
93
|
localHead?: string;
|
|
90
94
|
localResult?: "passed" | "failed" | "unknown";
|
|
91
95
|
observed?: number;
|
|
@@ -209,7 +213,7 @@ export function sdlcConfig(value: unknown, version?: string): SdlcConfig {
|
|
|
209
213
|
if (value === undefined) return { mode: "off", requiredChecks: [], stages: [...SDLC_STAGES] };
|
|
210
214
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("sdlc: expected a table");
|
|
211
215
|
const raw = value as Record<string, unknown>;
|
|
212
|
-
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`);
|
|
216
|
+
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", "risk"].includes(key)) throw new Error(`sdlc.${key}: unknown field`);
|
|
213
217
|
const maxNits = raw.max_nits === undefined ? DEFAULT_MAX_NITS : raw.max_nits;
|
|
214
218
|
if (typeof maxNits !== "number" || !Number.isSafeInteger(maxNits) || maxNits < 0 || maxNits > 64) throw new Error("sdlc.max_nits: expected an integer from 0 to 64");
|
|
215
219
|
const bands = bandsConfig(raw.bands), bandConfig = Object.keys(bands).length ? { bands } : {};
|
|
@@ -217,7 +221,7 @@ export function sdlcConfig(value: unknown, version?: string): SdlcConfig {
|
|
|
217
221
|
...(raw.eval_check === undefined ? {} : { evalCheck: evalCheckName(raw.eval_check) }),
|
|
218
222
|
...(raw.config_paths === undefined ? {} : { configPaths: configPathList(raw.config_paths, "sdlc.config_paths") }),
|
|
219
223
|
};
|
|
220
|
-
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) }) };
|
|
224
|
+
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) }), ...(raw.risk === undefined ? {} : { risk: riskPolicy(raw.risk) }) };
|
|
221
225
|
const mode = raw.mode ?? "off";
|
|
222
226
|
if (mode !== "off" && mode !== "advise" && mode !== "enforce") throw new Error("sdlc.mode: expected off, advise or enforce");
|
|
223
227
|
// ponytail: the #481 S8 window is a fixed version; delete `workflow`, the phase aliases and their tests once it passes.
|
|
@@ -424,15 +428,20 @@ export function specState(receipt: SdlcReceipt | undefined, edit: SpecEdit | und
|
|
|
424
428
|
if (!edit) return "unknown";
|
|
425
429
|
return edit.lastEditedAt === accepted.lastEditedAt ? "current" : "changed";
|
|
426
430
|
}
|
|
431
|
+
/** #1658: the body a status list compares a read-back against, because a list makes no issue read of its own. */
|
|
432
|
+
export function acceptedSpecEdit(receipt: SdlcReceipt | undefined): SpecEdit | undefined {
|
|
433
|
+
const accepted = receipt?.acceptance;
|
|
434
|
+
return accepted ? { lastEditedAt: accepted.lastEditedAt, updatedAt: accepted.updatedAt } : undefined;
|
|
435
|
+
}
|
|
427
436
|
export const SPEC_STATE_TEXT: Record<Exclude<SpecState, "current">, string> = {
|
|
428
437
|
missing: "spec acceptance missing: the person runs ahub sdlc accept <task> --issue <n>",
|
|
429
438
|
changed: "spec changed after acceptance: the person re-accepts with ahub sdlc accept <task> --issue <n>",
|
|
430
439
|
unknown: "spec edit time unknown: the issue could not be read",
|
|
431
440
|
};
|
|
432
|
-
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; }
|
|
441
|
+
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 }; /** #1658: the read-back against the issue's current body; absent when no spec receipt exists. */ readback?: ReadbackView; playbook?: string; criteria?: CriteriaView; mode: SdlcMode; stage: SdlcStage; definition?: StageDefinition; entry?: string[]; exit?: string[]; blockers: string[]; ready: boolean; actor: string; next: string; }
|
|
433
442
|
/** 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. */
|
|
434
443
|
export const criteriaRequired = (config: SdlcConfig, receipt: SdlcReceipt | undefined): boolean => config.workflow === "gsd-lite" || (config.mode !== "off" && !!checklistOf(receipt));
|
|
435
|
-
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 {
|
|
444
|
+
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, readback?: ReadbackView): SdlcStatus {
|
|
436
445
|
const stage = receipt?.stage ?? config.stages[0] ?? "spec", blockers: string[] = [];
|
|
437
446
|
const definition = stageDefinition(config, stage);
|
|
438
447
|
const evalGate = evidence ? evalGateView(config, evidence, evalResult) : undefined;
|
|
@@ -471,7 +480,7 @@ export function sdlcStatus(config: SdlcConfig, receipt: SdlcReceipt | undefined,
|
|
|
471
480
|
const shown = criteria && (criteriaRequired(config, receipt) || definition && [...definition.entry_gates, ...definition.exit_gates].includes("criteria"));
|
|
472
481
|
// Shown, not counted as a readiness blocker: the spec gate is build entry (#481 S1).
|
|
473
482
|
const spec = config.mode !== "off" && receipt?.issue ? { spec: { issue: receipt.issue, state: specState(receipt, specEdit) } } : {};
|
|
474
|
-
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,
|
|
483
|
+
return { ...spec, ...(readback ? { readback } : {}), ...(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,
|
|
475
484
|
actor: !definition ? "person" : shown && criteria.blockers.length ? "reviewer/person" : config.definitions ? definition.actor : baseActor(definition.base),
|
|
476
485
|
// #694: the identity blocker keeps its exact text for gate matching; the next step says how to supply it.
|
|
477
486
|
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" };
|
package/src/hub/settings.ts
CHANGED
|
@@ -59,6 +59,8 @@ const perClass = (name: TaskClass): SettingDef[] => [
|
|
|
59
59
|
];
|
|
60
60
|
export const SETTINGS: readonly SettingDef[] = [
|
|
61
61
|
{ key: "memory.sync_interval_min", group: "Switches", label: "Memory sync interval in minutes (0 disables)", type: "integer", min: 0, max: 1440, store: "config", applies: "live", risk: "raises", path: ["memory", "sync_interval_min"] },
|
|
62
|
+
// #1329: the switch the person turns with `ahub memory review on|off`; the run and week caps beside it are not switches and stay in the block.
|
|
63
|
+
{ key: "memory.review.enabled", group: "Switches", label: "Memory review: schedule one review per period (ahub memory review on|off)", type: "boolean", store: "config", applies: "live", risk: "raises", floor: false, path: ["memory", "review", "enabled"] },
|
|
62
64
|
...["enabled", "auto_reassign"].map((key): SettingDef => ({ key: `task_sweep.${key}`, group: "Switches", label: `Task sweep: ${key}`, type: "boolean", store: "config", applies: "live", risk: "raises", floor: false, path: ["task_sweep", key] })),
|
|
63
65
|
{ key: "task_sweep.no_writes_turns", group: "Switches", label: "Consecutive owner turns without writes (0 disables)", type: "integer", min: 0, max: Number.MAX_SAFE_INTEGER, store: "config", applies: "live", risk: "raises", path: ["task_sweep", "no_writes_turns"] },
|
|
64
66
|
...["interval_s", "unaccepted_min", "idle_min", "review_min", "ready_min", "ladder_min"].map((key): SettingDef => ({ key: `task_sweep.${key}`, group: "Switches", label: `Task sweep: ${key}`, type: "number", min: 1, max: 2_147_483_647 / (key === "interval_s" ? 1000 : 60_000), store: "config", applies: "live", risk: "raises", path: ["task_sweep", key] })),
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { childEnv } from "./child-process.ts";
|
|
2
|
+
import { hubGitSync } from "./git.ts";
|
|
3
|
+
import { GIT_SAFE_OPTIONS } from "./specs.ts";
|
|
4
|
+
import { surveyArray, surveyInputAt, surveyObject, surveyPath, surveyText } from "./advisor-survey.ts";
|
|
5
|
+
|
|
6
|
+
const TEXT_BYTES = 1024;
|
|
7
|
+
const MAX_ITEMS = 16;
|
|
8
|
+
const MAX_REFS = 64;
|
|
9
|
+
const PATH_BYTES = 512;
|
|
10
|
+
/**
|
|
11
|
+
* #1658: the size bounds a report is judged by. Every field at its own limit is about 100 KB of text; JSON escaping can
|
|
12
|
+
* double that, so the report bound covers the doubled worst case and the stored row's bound covers the report plus its
|
|
13
|
+
* missing-ref list (64 paths at 512 bytes each, escaped). A report inside every field limit is therefore always stored
|
|
14
|
+
* readable, never a row the board would later mask as corrupt.
|
|
15
|
+
*/
|
|
16
|
+
const READBACK_REPORT_BYTES = 320 * 1024;
|
|
17
|
+
export const READBACK_STORE_BYTES = READBACK_REPORT_BYTES + 128 * 1024;
|
|
18
|
+
|
|
19
|
+
interface ReadbackDetails {
|
|
20
|
+
undefined?: { term: string; where: string }[];
|
|
21
|
+
open_decisions?: { decision: string; where: string }[];
|
|
22
|
+
refs?: string[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type SpecReadbackReport = ReadbackDetails & (
|
|
26
|
+
| { task: number; proposes: string; existing: string }
|
|
27
|
+
| { task: number; cannot_paraphrase: string }
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export function parseSpecReadbackReport(input: unknown): SpecReadbackReport {
|
|
31
|
+
const at = surveyInputAt;
|
|
32
|
+
const fields = at("report", "requires a closed object", () => surveyObject(input, [
|
|
33
|
+
"task", "proposes", "existing", "cannot_paraphrase", "undefined", "open_decisions", "refs",
|
|
34
|
+
]));
|
|
35
|
+
const task = at("task", "requires a positive integer", () => {
|
|
36
|
+
if (typeof fields.task !== "number" || !Number.isSafeInteger(fields.task) || fields.task < 1) {
|
|
37
|
+
throw new Error("invalid read-back task");
|
|
38
|
+
}
|
|
39
|
+
return fields.task;
|
|
40
|
+
});
|
|
41
|
+
const readText = (value: unknown, field: string) =>
|
|
42
|
+
at(field, `requires nonempty text within ${TEXT_BYTES} UTF-8 bytes`, () => surveyText(value, TEXT_BYTES));
|
|
43
|
+
const entries = (name: "undefined" | "open_decisions") =>
|
|
44
|
+
at(name, `allows up to ${MAX_ITEMS} items`, () => surveyArray(fields[name], MAX_ITEMS));
|
|
45
|
+
const details: ReadbackDetails = {};
|
|
46
|
+
if (Object.hasOwn(fields, "undefined")) {
|
|
47
|
+
details.undefined = entries("undefined").map((item, index) => {
|
|
48
|
+
const key = `undefined[${index}]`;
|
|
49
|
+
const entry = at(key, "requires a term and location", () => surveyObject(item, ["term", "where"]));
|
|
50
|
+
return { term: readText(entry.term, `${key}.term`), where: readText(entry.where, `${key}.where`) };
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (Object.hasOwn(fields, "open_decisions")) {
|
|
54
|
+
details.open_decisions = entries("open_decisions").map((item, index) => {
|
|
55
|
+
const key = `open_decisions[${index}]`;
|
|
56
|
+
const entry = at(key, "requires a decision and location", () => surveyObject(item, ["decision", "where"]));
|
|
57
|
+
return { decision: readText(entry.decision, `${key}.decision`), where: readText(entry.where, `${key}.where`) };
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (Object.hasOwn(fields, "refs")) {
|
|
61
|
+
details.refs = at("refs", `allows up to ${MAX_REFS} paths`, () => surveyArray(fields.refs, MAX_REFS))
|
|
62
|
+
.map((value, index) => at(`refs[${index}]`, `requires a repository-relative path or directory within ${PATH_BYTES} UTF-8 bytes`, () =>
|
|
63
|
+
// A directory names the paths under it, so `/` ends the identity rather than making it invalid.
|
|
64
|
+
surveyPath(typeof value === "string" && value.endsWith("/") ? value.slice(0, -1) : value)));
|
|
65
|
+
}
|
|
66
|
+
const whole = (report: SpecReadbackReport): SpecReadbackReport => at("report", `must stay within ${READBACK_REPORT_BYTES} JSON bytes in total`, () => {
|
|
67
|
+
if (Buffer.byteLength(JSON.stringify(report)) > READBACK_REPORT_BYTES) throw new Error("invalid bounded survey data");
|
|
68
|
+
return report;
|
|
69
|
+
});
|
|
70
|
+
if (Object.hasOwn(fields, "cannot_paraphrase")) {
|
|
71
|
+
at("cannot_paraphrase", "use a section in place of proposes and existing", () => {
|
|
72
|
+
if (Object.hasOwn(fields, "proposes") || Object.hasOwn(fields, "existing")) throw new Error("mixed read-back report forms");
|
|
73
|
+
});
|
|
74
|
+
return whole({ task, cannot_paraphrase: readText(fields.cannot_paraphrase, "cannot_paraphrase"), ...details });
|
|
75
|
+
}
|
|
76
|
+
return whole({ task, proposes: readText(fields.proposes, "proposes"), existing: readText(fields.existing, "existing"), ...details });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* #1658 T4: where a task's read-back stands against the issue's current body. `current` without lists is a request
|
|
81
|
+
* whose reader has not reported yet; the lists exist only once a report does, and `private` is the stub a task shows
|
|
82
|
+
* once the board holds it private, because a report's terms and decisions are the spec's text.
|
|
83
|
+
*/
|
|
84
|
+
type ReadbackState = "none" | "current" | "stale" | "unavailable" | "private";
|
|
85
|
+
export interface ReadbackView {
|
|
86
|
+
state: ReadbackState;
|
|
87
|
+
undefined?: { term: string; where: string }[];
|
|
88
|
+
open_decisions?: { decision: string; where: string }[];
|
|
89
|
+
missing_refs?: string[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The short state text shared by `ahub sdlc status`/`explain` and the line `accept` prints. */
|
|
93
|
+
export function readbackSummary(view: ReadbackView): string {
|
|
94
|
+
if (view.state === "none") return "none";
|
|
95
|
+
if (view.state === "private") return "private (the report is withheld with the task's text)";
|
|
96
|
+
if (view.state === "unavailable") return "unavailable (the issue's edit time could not be read)";
|
|
97
|
+
if (view.state === "stale") return "stale (the body changed after the last one)";
|
|
98
|
+
if (view.missing_refs === undefined) return "current (requested; the reader has not reported yet)";
|
|
99
|
+
const terms = view.undefined?.length ?? 0, decisions = view.open_decisions?.length ?? 0, missing = view.missing_refs.length;
|
|
100
|
+
return `current (${terms} undefined term${terms === 1 ? "" : "s"}, ${decisions} open decision${decisions === 1 ? "" : "s"}, ${missing} missing ref${missing === 1 ? "" : "s"})`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The one line `ahub sdlc accept` prints before it records the person's acceptance; every state proceeds. */
|
|
104
|
+
function readbackLine(view: ReadbackView, task: number | string): string {
|
|
105
|
+
if (view.state === "none") return `spec read-back: none (start one with ahub sdlc readback start ${task})`;
|
|
106
|
+
const next = view.state === "stale" ? `; start another with ahub sdlc readback start ${task}` : "";
|
|
107
|
+
return `spec read-back: ${readbackSummary(view)}${next}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* #1658 AC7: the acceptance reply's `readback` field. `readbackView` is undefined exactly when the lifecycle is off, and
|
|
112
|
+
* then there is no state to print, so an off project's `ahub sdlc accept` output stays what it was.
|
|
113
|
+
*/
|
|
114
|
+
export function readbackAcceptField(view: ReadbackView | undefined, task: number | string): { readback?: string } {
|
|
115
|
+
return view === undefined ? {} : { readback: readbackLine(view, task) };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const readbackGit = (cwd: string, args: string[]) => hubGitSync(["-C", cwd, ...GIT_SAFE_OPTIONS, ...args], { encoding: "utf8", env: childEnv(process.env), maxBuffer: 8 * 1024 * 1024, timeout: 5000 });
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* #1658 T4: the paths the issue names that are absent from the default branch head. Git only, no worktree read and no
|
|
122
|
+
* fetch, so a hit is a commit a merged change would land on. A path stands for the file or the directory of that name,
|
|
123
|
+
* because `ls-tree -r` lists files alone. `undefined` is unknown, never "all present".
|
|
124
|
+
*/
|
|
125
|
+
export function missingReadbackRefs(cwd: string, paths: readonly string[]): string[] | undefined {
|
|
126
|
+
if (!paths.length) return [];
|
|
127
|
+
try {
|
|
128
|
+
const from = ["origin/HEAD", "origin/main", "origin/master"].find(ref => readbackGit(cwd, ["rev-parse", "--verify", "-q", `${ref}^{commit}`]).status === 0);
|
|
129
|
+
if (!from) return undefined;
|
|
130
|
+
const tree = readbackGit(cwd, ["ls-tree", "-r", "-z", "--name-only", from]);
|
|
131
|
+
if (tree.status !== 0 || typeof tree.stdout !== "string") return undefined;
|
|
132
|
+
const files = tree.stdout.split("\0").filter(Boolean), known = new Set(files), dirs = new Set<string>();
|
|
133
|
+
for (const file of files) for (let slash = file.indexOf("/"); slash !== -1; slash = file.indexOf("/", slash + 1)) dirs.add(file.slice(0, slash));
|
|
134
|
+
return paths.filter(path => !known.has(path) && !dirs.has(path));
|
|
135
|
+
} catch { return undefined; }
|
|
136
|
+
}
|
package/src/hub/specs.ts
CHANGED
|
@@ -19,7 +19,7 @@ const MAX_PARSED_BLOB_CACHE_BYTES = 16 * 1024 * 1024;
|
|
|
19
19
|
const MAX_BLOB_BATCH_BYTES = 8 * 1024 * 1024;
|
|
20
20
|
const MAX_TRACKED_PATHS_PER_SCOPE = 4096;
|
|
21
21
|
const MAX_REPORT_ITEMS = 500;
|
|
22
|
-
const GIT_SAFE_OPTIONS = ["-c", "core.fsmonitor=false", "-c", "core.hooksPath=/dev/null", "-c", "diff.external=", "-c", "core.pager=cat", "-c", "credential.helper=", "-c", "core.askpass="];
|
|
22
|
+
export const GIT_SAFE_OPTIONS = ["-c", "core.fsmonitor=false", "-c", "core.hooksPath=/dev/null", "-c", "diff.external=", "-c", "core.pager=cat", "-c", "credential.helper=", "-c", "core.askpass="];
|
|
23
23
|
const LIST_KEYS = new Set(["depends-on", "references", "implements", "covers", "tags", "paths"]);
|
|
24
24
|
const TYPES = new Set(["goal", "architecture", "module", "submodule"]);
|
|
25
25
|
const STATUS = new Set(["draft", "active", "deprecated"]);
|
|
@@ -71,5 +71,5 @@ export function pageTasks<T extends { id: number; updated: number }>(rows: reado
|
|
|
71
71
|
|
|
72
72
|
/** What a compact row keeps: enough to choose a task, never a body, plan or history. */
|
|
73
73
|
export function compactRow(view: Record<string, unknown>): Record<string, unknown> {
|
|
74
|
-
return { id: view.id, state: view.state, owner: view.owner ?? null, reviewer: view.reviewer ?? null, title: view.title };
|
|
74
|
+
return { id: view.id, state: view.state, owner: view.owner ?? null, reviewer: view.reviewer ?? null, title: view.title, ...(view.reason !== undefined ? { reason: view.reason } : {}) };
|
|
75
75
|
}
|