@staix/agent-hub 0.52.0 → 0.54.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 +37 -0
- package/README.md +4 -3
- package/docs/addons/open-code-review.md +3 -6
- package/docs/agent-notes/README.md +1 -1
- package/docs/agent-notes/adapters.md +5 -4
- package/docs/agent-notes/budget.md +2 -2
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +6 -5
- package/docs/agent-notes/models.md +1 -1
- package/docs/agent-notes/tasks.md +3 -3
- package/docs/agent-notes/tests.md +4 -4
- package/docs/contracts/companion-cli-v2.json +90 -0
- package/docs/contracts/companion-cli-v3.json +348 -0
- package/docs/design/adapters.md +1 -1
- package/docs/design/agent-hub-architecture.md +8 -5
- package/docs/design/bus.md +1 -1
- package/docs/design/cli-output-inventory.md +4 -2
- package/docs/design/execution-reference.md +1 -1
- package/docs/design/guidance-experiments.md +1 -0
- package/docs/design/guidance-probes.md +1 -0
- package/docs/design/model-routes.md +20 -5
- package/docs/design/roadmap.md +6 -4
- package/docs/design/task-board.md +21 -2
- package/docs/dogfood.md +13 -6
- package/docs/events.md +1 -1
- package/docs/memory.md +2 -2
- package/docs/operations.md +158 -50
- package/docs/quickstart.md +14 -2
- package/docs/security.md +17 -9
- package/docs/specs/2026-09-19-agent-hub-design.md +5 -3
- package/docs/specs/2026-09-19-multi-project-design.md +1 -1
- package/docs/specs/2026-09-20-upgrade-recovery-design.md +24 -0
- package/docs/specs/2026-12-04-arev-adoption-design.md +84 -0
- package/docs/specs/mcp-endpoint.md +15 -4
- package/docs/specs/relay-contract.md +38 -0
- package/docs/verification/2026-12-04-host-shared-receipts.md +43 -0
- package/docs/verification/2026-12-05-0.53.0.md +101 -0
- package/docs/verification/2026-12-05-agy-1.5.24.md +55 -0
- package/docs/verification/2026-12-05-claude-implementer-2.1.337.md +43 -0
- package/docs/verification/2026-12-06-0.54.0.md +76 -0
- package/docs/verification/2026-12-06-codex-0174-reviewer-isolation.md +43 -0
- package/docs/verification/2026-12-06-codex-0174-reviewer-tool-call.md +34 -0
- package/docs/verification/2026-12-06-compat-codex-capabilities-0.174.0.md +25 -0
- package/docs/verification/2026-12-06-compat-pi-1.8.0.md +23 -0
- package/docs/verified.json +38 -29
- package/package.json +9 -3
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/.mcp.json +1 -1
- package/plugins/agent-hub/compat.json +9 -5
- package/plugins/agent-hub/kimi-hook.js +892 -874
- package/plugins/agent-hub/relay-launcher.js +24 -0
- package/plugins/agent-hub/server.js +27271 -25146
- package/src/adapters/acp-session-model.ts +1 -1
- package/src/adapters/acp.ts +5 -4
- package/src/adapters/agy/definition.ts +1 -1
- package/src/adapters/agy/hooks.ts +1 -1
- package/src/adapters/channel-peer.ts +3 -1
- package/src/adapters/claude-channel-evidence.ts +26 -1
- package/src/adapters/claude-channel.ts +27 -30
- package/src/adapters/claude-connection-policy.ts +62 -0
- package/src/adapters/claude-relay.ts +255 -0
- package/src/adapters/codex-review-isolation.ts +1 -2
- package/src/adapters/compat.ts +28 -18
- package/src/adapters/definitions/native-cli-preview-pi.ts +2 -1
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-context.ts +1 -2
- package/src/adapters/definitions/native-factories.ts +4 -1
- package/src/adapters/definitions/native-quota.ts +1 -1
- package/src/adapters/definitions/native-recovery.ts +3 -1
- package/src/adapters/external-modules.ts +2 -2
- package/src/adapters/kimi-review.ts +1 -1
- package/src/adapters/kimi-tui-facts.ts +1 -1
- package/src/adapters/local-worker.ts +3 -3
- package/src/adapters/native-capabilities.ts +1 -1
- package/src/adapters/pi.ts +26 -7
- package/src/adapters/registry-types.ts +2 -0
- package/src/adapters/relay-launcher.ts +27 -0
- package/src/adapters/reviewer-mcp.ts +1 -1
- package/src/cli/agents.ts +20 -8
- package/src/cli/agy-mcp.ts +1 -1
- package/src/cli/claude-profile-hook.ts +1 -1
- package/src/cli/command-table.ts +1 -0
- package/src/cli/commands/agents.ts +18 -1
- package/src/cli/commands/doctor.ts +18 -4
- package/src/cli/commands/launch-line.ts +32 -0
- package/src/cli/commands/status.ts +14 -3
- package/src/cli/help.ts +7 -4
- package/src/cli/identity.ts +1 -1
- package/src/cli/init-roles.ts +1 -1
- package/src/cli/init-settings.ts +1 -1
- package/src/cli/launch-line-plan.ts +82 -0
- package/src/cli/launch-line-project.ts +13 -0
- package/src/cli/main.ts +10 -9
- package/src/cli/pi-steps-warning.ts +14 -0
- package/src/cli/recovery-package.ts +60 -6
- package/src/cli/reset.ts +1 -1
- package/src/cli/shell-quote.ts +1 -3
- package/src/cli/upgrade-interactive.ts +7 -2
- package/src/cli/upgrade-keep-plan.ts +47 -0
- package/src/cli/upgrade-restore-state.ts +1 -1
- package/src/cli/upgrade-runtime.ts +119 -18
- package/src/cli/upgrade.ts +17 -2
- package/src/hub/accounts.ts +8 -4
- package/src/hub/action-class.ts +1 -3
- package/src/hub/adec-triage.ts +105 -0
- package/src/hub/autonomy.ts +1 -1
- package/src/hub/board.ts +3 -27
- package/src/hub/bus.ts +39 -6
- package/src/hub/capabilities.ts +1 -1
- package/src/hub/channel-project-base.ts +46 -0
- package/src/hub/channel-project.ts +21 -46
- package/src/hub/config-apply.ts +1 -1
- package/src/hub/config-edit.ts +1 -1
- package/src/hub/config-tier.ts +1 -1
- package/src/hub/config.ts +2 -2
- package/src/hub/confirmation-matrix.ts +1 -1
- package/src/hub/control/board-messages.ts +415 -0
- package/src/hub/control/dashboard-messages.ts +221 -0
- package/src/hub/control/delivery-messages.ts +356 -0
- package/src/hub/control/dispatch.ts +114 -0
- package/src/hub/control/hub-tool-helpers.ts +243 -0
- package/src/hub/control/hub-tools.ts +147 -0
- package/src/hub/control/native-messages.ts +665 -0
- package/src/hub/control/operations-messages.ts +269 -0
- package/src/hub/control/peer-messages.ts +126 -0
- package/src/hub/control/recovery-messages.ts +391 -0
- package/src/hub/control/recovery-operation.ts +480 -0
- package/src/hub/control/scope.ts +460 -0
- package/src/hub/control/sdlc-messages.ts +373 -0
- package/src/hub/control/task-ops-more.ts +245 -0
- package/src/hub/control/task-ops.ts +553 -0
- package/src/hub/control/ui-actions.ts +241 -0
- package/src/hub/control-write-trace.ts +1 -4
- package/src/hub/daemon.ts +485 -4324
- package/src/hub/delivery-hints.ts +2 -0
- package/src/hub/delivery-journal.ts +17 -6
- package/src/hub/events.ts +2 -1
- package/src/hub/execution-reference.ts +1 -1
- package/src/hub/host.ts +41 -9
- package/src/hub/hub-tools.ts +3 -4
- package/src/hub/invocations.ts +1 -1
- package/src/hub/lifecycle.ts +4 -3
- package/src/hub/mcp-endpoint-serve.ts +4 -3
- package/src/hub/mcp-endpoint.ts +15 -6
- package/src/hub/memory-profile-check.ts +1 -1
- package/src/hub/no-writes.ts +1 -1
- package/src/hub/peers.ts +2 -0
- package/src/hub/pi-exit-policy.ts +27 -0
- package/src/hub/progress.ts +1 -1
- package/src/hub/project-runtime-state.ts +17 -4
- package/src/hub/project-runtime.ts +3 -1
- package/src/hub/protocol-window.ts +1 -1
- package/src/hub/recovery-continuity.ts +3 -3
- package/src/hub/recovery-kept-roster.ts +50 -0
- package/src/hub/review-anchor.ts +13 -181
- package/src/hub/review-brief.ts +78 -28
- package/src/hub/review-findings.ts +15 -193
- package/src/hub/review-ledger.ts +162 -0
- package/src/hub/review-material.ts +3 -3
- package/src/hub/reviewer-pool.ts +4 -2
- package/src/hub/roadmap-issue-states.ts +65 -14
- package/src/hub/roadmap-sync.ts +39 -14
- package/src/hub/routing.ts +9 -0
- package/src/hub/runtime-capture-prune.ts +8 -2
- package/src/hub/runtime-package-assets.ts +3 -0
- package/src/hub/sdlc-release-policy.ts +1 -2
- package/src/hub/settings.ts +1 -1
- package/src/hub/spec-ack-tool.ts +4 -0
- package/src/hub/spec-report-history.ts +36 -0
- package/src/hub/specs.ts +1 -4
- package/src/hub/supervision.ts +33 -6
- package/src/hub/tasks-audit.ts +390 -0
- package/src/hub/tasks-backlog.ts +522 -0
- package/src/hub/tasks-handoff.ts +208 -0
- package/src/hub/tasks-release.ts +257 -0
- package/src/hub/tasks-roadmap.ts +17 -3
- package/src/hub/tasks-specs.ts +672 -0
- package/src/hub/tasks-types.ts +334 -0
- package/src/hub/tasks.ts +286 -1961
- package/src/hub/upgrade-session-contract.ts +11 -0
- package/src/local/probe-sandbox.ts +1 -2
- package/src/local/probe-workspace.ts +1 -1
- package/src/models/route/config.ts +4 -4
- package/src/models/route/decision.ts +18 -10
- package/src/models/route/observation-signals.ts +1 -2
- package/src/models/route/runtime.ts +8 -5
- package/src/npm-artifact.ts +76 -0
- package/src/omniroute/client.ts +6 -0
- package/src/pi/extension.ts +5 -2
- package/src/pi/install.ts +77 -0
- package/src/pi/pin.ts +49 -0
- package/src/primitives.ts +14 -0
- package/src/version.ts +2 -0
- package/templates/adec/README.md +10 -6
- package/templates/config.json +1 -1
- package/templates/specs.block.md +1 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { sha256Hex as digest } from "../primitives.ts";
|
|
1
2
|
import { ADAPTERS } from "../adapters/registry.ts";
|
|
2
3
|
import { Database } from "bun:sqlite";
|
|
3
|
-
import {
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
4
5
|
import { chmodSync, closeSync, constants, fstatSync, lstatSync, openSync, readSync, renameSync, unlinkSync } from "node:fs";
|
|
5
6
|
import { isAbsolute, join, normalize } from "node:path";
|
|
6
7
|
import { realPath } from "./project.ts";
|
|
7
8
|
import { atomicPrivateJSON, operationIdPattern } from "./recovery-store.ts";
|
|
9
|
+
import { isRecord as record } from "../primitives.ts";
|
|
8
10
|
|
|
9
11
|
export const RECOVERY_CONTINUITY_BUSY_TIMEOUT_MS = 3000;
|
|
10
12
|
const MAX_BOOKMARK_BYTES = 16 * 1024;
|
|
@@ -26,7 +28,6 @@ export type RecoveryContinuityReading =
|
|
|
26
28
|
| { state: "ready"; bookmark: RecoveryContinuityBookmark; digest: string };
|
|
27
29
|
|
|
28
30
|
const unavailable = (): never => { throw new Error("recovery continuity metadata unavailable or invalid"); };
|
|
29
|
-
const record = (value: unknown): value is Record<string, unknown> => !!value && typeof value === "object" && !Array.isArray(value);
|
|
30
31
|
const keys = (value: Record<string, unknown>, allowed: readonly string[]): boolean => Object.keys(value).every(key => allowed.includes(key));
|
|
31
32
|
const text = (value: unknown, max: number): value is string => typeof value === "string" && value.length > 0 && value.length <= max && !/[\x00-\x1f\x7f]/.test(value);
|
|
32
33
|
const id = (value: unknown): value is string => text(value, 256) && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(value);
|
|
@@ -56,7 +57,6 @@ function privateFile(path: string, missing = false): void {
|
|
|
56
57
|
if (!stat.isFile() || stat.isSymbolicLink() || stat.mode & 0o077) return unavailable();
|
|
57
58
|
} catch (error) { if (!missing || (error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
|
|
58
59
|
}
|
|
59
|
-
const digest = (bytes: Buffer): string => createHash("sha256").update(bytes).digest("hex");
|
|
60
60
|
|
|
61
61
|
/** Read one bounded project-local file; invalid evidence is deliberately distinct from no bookmark. */
|
|
62
62
|
export function readRecoveryContinuity(stateDir: string, expected: RecoveryContinuityExpected): RecoveryContinuityReading {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isClaudeSessionUuid } from "./claude-state.ts";
|
|
2
|
+
import { parseSessionContract, type SessionContract } from "./upgrade-session-contract.ts";
|
|
3
|
+
|
|
4
|
+
export interface KeptSession {
|
|
5
|
+
peerId: string;
|
|
6
|
+
sessionId: string;
|
|
7
|
+
sessionContract: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type KeptRoster = {
|
|
11
|
+
operationId: string;
|
|
12
|
+
sessions: ReadonlyMap<string, KeptSession>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function refusal(peer: string, reason: string): Error {
|
|
16
|
+
return new Error(`kept Claude session ${peer}: ${reason}; run ahub upgrade again to make a new plan`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function readKeptRoster(
|
|
20
|
+
operationId: string,
|
|
21
|
+
raw: unknown,
|
|
22
|
+
target: unknown,
|
|
23
|
+
source: SessionContract | undefined,
|
|
24
|
+
liveSessionId: (peer: string) => string | undefined,
|
|
25
|
+
): KeptRoster {
|
|
26
|
+
const sessions = new Map<string, KeptSession>();
|
|
27
|
+
if (raw === undefined) return { operationId, sessions };
|
|
28
|
+
if (!Array.isArray(raw)) throw refusal("roster", "must be an array of attached sessions");
|
|
29
|
+
const targetContract = parseSessionContract(target);
|
|
30
|
+
for (const value of raw) {
|
|
31
|
+
const peer = value?.peerId;
|
|
32
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).length !== 3
|
|
33
|
+
|| typeof peer !== "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(peer))
|
|
34
|
+
throw refusal("roster", "contains an invalid peer entry");
|
|
35
|
+
if (sessions.has(peer)) throw refusal(peer, "appears twice");
|
|
36
|
+
const { sessionId, sessionContract } = value;
|
|
37
|
+
if (!isClaudeSessionUuid(sessionId) || liveSessionId(peer) !== sessionId)
|
|
38
|
+
throw refusal(peer, "is not attached with the reported session id");
|
|
39
|
+
if (!source || !targetContract || sessionContract !== source.claude || sessionContract !== targetContract.claude)
|
|
40
|
+
throw refusal(peer, "session contract differs from the source or target release");
|
|
41
|
+
sessions.set(peer, { peerId: peer, sessionId, sessionContract });
|
|
42
|
+
}
|
|
43
|
+
return { operationId, sessions };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function assertKeptRosterCurrent(roster: KeptRoster, liveSessionId: (peer: string) => string | undefined): void {
|
|
47
|
+
for (const { peerId, sessionId } of roster.sessions.values()) {
|
|
48
|
+
if (liveSessionId(peerId) !== sessionId) throw refusal(peerId, "detached or changed its reported session id");
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/hub/review-anchor.ts
CHANGED
|
@@ -1,181 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (Object.keys(descriptors).some(key => !keys.includes(key)) || Object.values(descriptors).some(field => !Object.hasOwn(field, "value") || !field.enumerable)) return undefined;
|
|
15
|
-
return value as Record<string, unknown>;
|
|
16
|
-
}
|
|
17
|
-
function list(value: unknown, max: number): value is unknown[] {
|
|
18
|
-
if (!Array.isArray(value) || types.isProxy(value) || Object.getPrototypeOf(value) !== Array.prototype || value.length > max || Object.getOwnPropertySymbols(value).length) return false;
|
|
19
|
-
const fields = Object.getOwnPropertyDescriptors(value);
|
|
20
|
-
return Object.keys(fields).length === value.length + 1 && Object.entries(fields).every(([key, field]) => key === "length"
|
|
21
|
-
|| /^(0|[1-9][0-9]*)$/.test(key) && Number(key) < value.length && Object.hasOwn(field, "value") && field.enumerable);
|
|
22
|
-
}
|
|
23
|
-
const text = (value: unknown): value is string => typeof value === "string" && value.length > 0;
|
|
24
|
-
const positive = (value: unknown): value is number => typeof value === "number" && Number.isInteger(value) && value >= 1;
|
|
25
|
-
const finite = (value: unknown): value is number => typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
26
|
-
|
|
27
|
-
function selectorProblems(value: unknown, at: string): string[] {
|
|
28
|
-
const row = data(value, ["kind", "startLine", "endLine", "exact", "prefix", "suffix", "hunkHeader", "scheme", "ref", "x", "y", "width", "height", "page"]);
|
|
29
|
-
if (!row) return [`${at}: inert closed selector required`];
|
|
30
|
-
const allowed: Record<string, string[]> = {
|
|
31
|
-
lineRange: ["kind", "startLine", "endLine"], textQuote: ["kind", "exact", "prefix", "suffix"],
|
|
32
|
-
diffHunk: ["kind", "hunkHeader"], structural: ["kind", "scheme", "ref"], region: ["kind", "x", "y", "width", "height", "page"],
|
|
33
|
-
};
|
|
34
|
-
if (typeof row.kind !== "string" || !Object.hasOwn(allowed, row.kind)) return [`${at}.kind is unsupported`];
|
|
35
|
-
if (Object.keys(row).some(key => !allowed[row.kind as string]!.includes(key))) return [`${at}: unknown selector fields`];
|
|
36
|
-
switch (row.kind) {
|
|
37
|
-
case "lineRange": return positive(row.startLine) && positive(row.endLine) && row.startLine <= row.endLine ? [] : [`${at}: invalid startLine/endLine`];
|
|
38
|
-
case "textQuote": return text(row.exact) && row.exact.length <= CONTRACT.exact && typeof row.prefix === "string" && row.prefix.length <= CONTRACT.context
|
|
39
|
-
&& typeof row.suffix === "string" && row.suffix.length <= CONTRACT.context ? [] : [`${at}: invalid exact/prefix/suffix bounds`];
|
|
40
|
-
case "diffHunk": return typeof row.hunkHeader === "string" && row.hunkHeader.startsWith("@@") ? [] : [`${at}.hunkHeader must start with @@`];
|
|
41
|
-
case "structural": return text(row.scheme) && text(row.ref) ? [] : [`${at}: scheme and ref are required`];
|
|
42
|
-
case "region": return [row.x, row.y, row.width, row.height].every(finite) && (row.page === undefined || positive(row.page)) ? [] : [`${at}: invalid region coordinates or page`];
|
|
43
|
-
default: return [`${at}.kind is unsupported`];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function reviewAnchorContractProblems(value: unknown): string[] {
|
|
48
|
-
const row = data(value, ["path", "side", "contentHash", "projection", "selectors"]);
|
|
49
|
-
if (!row) return ["anchor: inert closed object required"];
|
|
50
|
-
const problems: string[] = [];
|
|
51
|
-
if (!text(row.path)) problems.push("anchor.path must be nonempty");
|
|
52
|
-
if (row.side !== undefined && row.side !== "base" && row.side !== "head") problems.push("anchor.side must be base or head");
|
|
53
|
-
if (row.contentHash !== undefined && (typeof row.contentHash !== "string" || !/^[a-f0-9]{64}$/.test(row.contentHash))) problems.push("anchor.contentHash must be lowercase sha256");
|
|
54
|
-
if (row.projection !== undefined) {
|
|
55
|
-
const projection = data(row.projection, ["name", "version"]);
|
|
56
|
-
if (!projection || !text(projection.name) || !text(projection.version)) problems.push("anchor.projection needs name and version");
|
|
57
|
-
}
|
|
58
|
-
if (!list(row.selectors, CONTRACT.selectors) || !row.selectors.length) problems.push("anchor.selectors needs 1-4 inert selectors");
|
|
59
|
-
else row.selectors.forEach((selector, index) => problems.push(...selectorProblems(selector, `anchor.selectors[${index}]`)));
|
|
60
|
-
return problems;
|
|
61
|
-
}
|
|
62
|
-
export function reviewThreadContractProblems(value: unknown): string[] {
|
|
63
|
-
const row = data(value, ["id", "anchor", "body", "author", "at", "state"]);
|
|
64
|
-
if (!row) return ["thread: inert closed object required"];
|
|
65
|
-
const problems: string[] = [];
|
|
66
|
-
for (const field of ["id", "author"]) if (!text(row[field])) problems.push(`thread.${field} must be nonempty`);
|
|
67
|
-
if (!text(row.body) || row.body.length > CONTRACT.body) problems.push("thread.body must contain 1-4000 characters");
|
|
68
|
-
if (typeof row.at !== "string" || Number.isNaN(Date.parse(row.at))) problems.push("thread.at must be a valid timestamp");
|
|
69
|
-
if (row.state !== undefined && row.state !== "open" && row.state !== "resolved") problems.push("thread.state must be open or resolved");
|
|
70
|
-
problems.push(...reviewAnchorContractProblems(row.anchor).map(problem => `thread.${problem}`));
|
|
71
|
-
return problems;
|
|
72
|
-
}
|
|
73
|
-
export function reviewThreadsContractProblems(value: unknown): string[] {
|
|
74
|
-
if (!list(value, CONTRACT.threads)) return ["threads must be an inert array of at most 200 entries"];
|
|
75
|
-
const problems: string[] = [], ids = new Set<string>();
|
|
76
|
-
value.forEach((thread, index) => {
|
|
77
|
-
problems.push(...reviewThreadContractProblems(thread).map(problem => `threads[${index}]: ${problem}`));
|
|
78
|
-
const row = data(thread, ["id", "anchor", "body", "author", "at", "state"]);
|
|
79
|
-
if (row && typeof row.id === "string") { if (ids.has(row.id)) problems.push(`threads[${index}].id repeats`); ids.add(row.id); }
|
|
80
|
-
});
|
|
81
|
-
return problems;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export class ReviewAnchorError extends Error {
|
|
85
|
-
constructor(readonly field: string, readonly maxBytes?: number, readonly shapeFields?: readonly string[]) {
|
|
86
|
-
super("review anchor validation failed");
|
|
87
|
-
this.name = "ReviewAnchorError";
|
|
88
|
-
this.message = this.safeMessage + (maxBytes === undefined ? "" : " (hub bound)");
|
|
89
|
-
Object.freeze(this);
|
|
90
|
-
}
|
|
91
|
-
get safeMessage(): string {
|
|
92
|
-
if (this.shapeFields) return `review anchor fields ${this.shapeFields.join(", ")} do not match the acon contract; correct those fields and retry`;
|
|
93
|
-
if (this.maxBytes !== undefined) return `review anchor ${this.field} exceeds ${this.maxBytes} UTF-8 bytes; shorten that field and retry`;
|
|
94
|
-
return `review anchor ${this.field} is invalid; correct that field and retry`;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/** Returns only messages assembled by the anchor validator; arbitrary caught errors are never reflected. */
|
|
98
|
-
export function reviewAnchorErrorMessage(error: unknown): string {
|
|
99
|
-
return error instanceof ReviewAnchorError ? error.safeMessage : "review anchor is invalid; correct its fields and retry";
|
|
100
|
-
}
|
|
101
|
-
function fail(field: string, maxBytes?: number): never { throw new ReviewAnchorError(field, maxBytes); }
|
|
102
|
-
function contractField(problem: string): string {
|
|
103
|
-
const selector = /^anchor\.selectors\[(\d+)\]/.exec(problem);
|
|
104
|
-
if (selector) {
|
|
105
|
-
const prefix = `anchor.selectors[${selector[1]}]`;
|
|
106
|
-
const member = /^\.([A-Za-z]+)/.exec(problem.slice(prefix.length))?.[1];
|
|
107
|
-
if (member) return `selectors[${selector[1]}].${member}`;
|
|
108
|
-
if (problem.includes("startLine/endLine")) return `selectors[${selector[1]}].startLine/endLine`;
|
|
109
|
-
if (problem.includes("exact/prefix/suffix")) return `selectors[${selector[1]}].exact/prefix/suffix`;
|
|
110
|
-
if (problem.includes("region coordinates or page")) return `selectors[${selector[1]}].x/y/width/height/page`;
|
|
111
|
-
if (problem.includes("scheme and ref")) return `selectors[${selector[1]}].scheme/ref`;
|
|
112
|
-
return `selectors[${selector[1]}]`;
|
|
113
|
-
}
|
|
114
|
-
const field = /^anchor\.(path|side|contentHash|projection|selectors)\b/.exec(problem)?.[1];
|
|
115
|
-
return field ?? "anchor";
|
|
116
|
-
}
|
|
117
|
-
function failShape(problems: readonly string[]): never {
|
|
118
|
-
const fields = [...new Set(problems.map(contractField))];
|
|
119
|
-
throw new ReviewAnchorError("anchor", undefined, fields.length ? fields : ["anchor"]);
|
|
120
|
-
}
|
|
121
|
-
function writeQuoteText(value: string, maxBytes: number, field: string): string {
|
|
122
|
-
if (value.includes("\0")) return fail(field);
|
|
123
|
-
if (Buffer.byteLength(value, "utf8") > maxBytes) return fail(field, maxBytes);
|
|
124
|
-
return value;
|
|
125
|
-
}
|
|
126
|
-
function writeText(value: string, maxBytes: number, field: string): string {
|
|
127
|
-
if (value.includes("\0")) return fail(field);
|
|
128
|
-
if (Buffer.byteLength(value, "utf8") > maxBytes) return fail(field, maxBytes);
|
|
129
|
-
const safe = sanitize(value);
|
|
130
|
-
if (Buffer.byteLength(safe, "utf8") > maxBytes) return fail(field, maxBytes);
|
|
131
|
-
return safe;
|
|
132
|
-
}
|
|
133
|
-
/** The hub write boundary. Quote selector text stays byte-bounded and exact; other stored text is sanitized here. */
|
|
134
|
-
export function parseReviewAnchor(value: unknown): ReviewAnchor {
|
|
135
|
-
const problems = reviewAnchorContractProblems(value);
|
|
136
|
-
if (problems.length) return failShape(problems);
|
|
137
|
-
const row = value as ReviewAnchor, path = writeText(row.path, 4096, "path");
|
|
138
|
-
if (/[\p{Cc}\p{Cf}\\]/u.test(path) || /^[a-z]:/i.test(path) || !projectionPath({ top: "", dir: "", prefix: "" }, path)) return fail("path");
|
|
139
|
-
const selectors = row.selectors.map((selector, index): ReviewSelector => {
|
|
140
|
-
switch (selector.kind) {
|
|
141
|
-
case "lineRange":
|
|
142
|
-
if (!Number.isSafeInteger(selector.startLine) || !Number.isSafeInteger(selector.endLine)) return fail(`selectors[${index}].startLine/endLine`);
|
|
143
|
-
return { ...selector };
|
|
144
|
-
case "textQuote": return { kind: "textQuote", exact: writeQuoteText(selector.exact, 512, `selectors[${index}].exact`), prefix: writeQuoteText(selector.prefix, 64, `selectors[${index}].prefix`), suffix: writeQuoteText(selector.suffix, 64, `selectors[${index}].suffix`) };
|
|
145
|
-
case "diffHunk": return { kind: "diffHunk", hunkHeader: writeText(selector.hunkHeader, 256, `selectors[${index}].hunkHeader`) };
|
|
146
|
-
case "structural": return { kind: "structural", scheme: writeText(selector.scheme, 128, `selectors[${index}].scheme`), ref: writeText(selector.ref, 512, `selectors[${index}].ref`) };
|
|
147
|
-
case "region":
|
|
148
|
-
if (selector.page !== undefined && !Number.isSafeInteger(selector.page)) return fail(`selectors[${index}].page`);
|
|
149
|
-
return { ...selector };
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
return { path, ...(row.side === undefined ? {} : { side: row.side }), ...(row.contentHash === undefined ? {} : { contentHash: row.contentHash }),
|
|
153
|
-
...(row.projection ? { projection: { name: writeText(row.projection.name, 128, "projection.name"), version: writeText(row.projection.version, 128, "projection.version") } } : {}), selectors };
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export interface ReviewAnchorStatus { status: "anchored" | "moved" | "outdated" | "unavailable"; range?: { startLine: number; endLine: number } }
|
|
157
|
-
function quotePosition(text: string, quote: Extract<ReviewSelector, { kind: "textQuote" }>): number | undefined {
|
|
158
|
-
let count = 0, contextual = 0, first = -1, contextualAt = -1;
|
|
159
|
-
if (!quote.exact) return undefined;
|
|
160
|
-
for (let at = text.indexOf(quote.exact); at !== -1; at = text.indexOf(quote.exact, at + 1)) {
|
|
161
|
-
count++; first = at;
|
|
162
|
-
const end = at + quote.exact.length;
|
|
163
|
-
if (at >= quote.prefix.length && text.slice(at - quote.prefix.length, at) === quote.prefix
|
|
164
|
-
&& text.slice(end, end + quote.suffix.length) === quote.suffix) { contextual++; contextualAt = at; }
|
|
165
|
-
}
|
|
166
|
-
return count === 1 ? first : contextual === 1 ? contextualAt : undefined;
|
|
167
|
-
}
|
|
168
|
-
/** Placement only. Projection identity precedes byte equality; no stored selector or hash is rewritten. */
|
|
169
|
-
export function anchorStatus(anchor: ReviewAnchor, material: ReviewMaterial): ReviewAnchorStatus {
|
|
170
|
-
if (material.state !== "available" || material.path !== anchor.path || material.side !== (anchor.side ?? "head")) return { status: "unavailable" };
|
|
171
|
-
if (anchor.projection?.name !== material.projection?.name || anchor.projection?.version !== material.projection?.version) return { status: "outdated" };
|
|
172
|
-
if (anchor.contentHash !== undefined && anchor.contentHash === material.contentHash) return { status: "anchored" };
|
|
173
|
-
for (const selector of anchor.selectors) if (selector.kind === "textQuote") {
|
|
174
|
-
const at = quotePosition(material.text, selector);
|
|
175
|
-
if (at === undefined) continue;
|
|
176
|
-
const startLine = material.text.slice(0, at).split("\n").length;
|
|
177
|
-
const endLine = material.text.slice(0, at + selector.exact.length - 1).split("\n").length;
|
|
178
|
-
return { status: "moved", range: { startLine, endLine } };
|
|
179
|
-
}
|
|
180
|
-
return { status: "outdated" };
|
|
181
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
anchorStatus,
|
|
3
|
+
parseReviewAnchor,
|
|
4
|
+
ReviewAnchorError,
|
|
5
|
+
reviewAnchorContractProblems,
|
|
6
|
+
reviewAnchorErrorMessage,
|
|
7
|
+
reviewThreadContractProblems,
|
|
8
|
+
reviewThreadsContractProblems,
|
|
9
|
+
type ReviewAnchor,
|
|
10
|
+
type ReviewAnchorStatus,
|
|
11
|
+
type ReviewSelector,
|
|
12
|
+
type ReviewThread,
|
|
13
|
+
} from "@staix/agent-review/core";
|
package/src/hub/review-brief.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import { checkStructureBudget, updateStructureBaseline, type StructureRules } from "./structure-budget.ts";
|
|
3
3
|
import { parseStructureBaseline, scanStructureRevision } from "./structure-scan.ts";
|
|
4
4
|
import type { CodeFactResult, CodeSymbol } from "./code-facts.ts";
|
|
5
|
+
import { buildPacket, coverageGap as coreCoverageGap } from "@staix/agent-review/core";
|
|
5
6
|
import { sanitize } from "./envelope.ts";
|
|
6
7
|
import { childEnv } from "./child-process.ts";
|
|
7
8
|
import { hubGitSync } from "./git.ts";
|
|
@@ -70,7 +71,7 @@ export function renderSpecTaskReport(report: SpecTaskReport): string {
|
|
|
70
71
|
}
|
|
71
72
|
export interface BriefPolicy { privatePath(path: string): boolean; nameable(text: string): boolean; structureRules?(config: unknown): StructureRules | undefined }
|
|
72
73
|
|
|
73
|
-
const MAX_FILES = 500, RULE_BYTES = 32_000, MAX_RULE_FILES = 8;
|
|
74
|
+
const MAX_FILES = 500, RULE_BYTES = 32_000, MAX_RULE_FILES = 8, CAUSE_CHARS = 200;
|
|
74
75
|
const LOCKFILES = new Set(["bun.lock", "bun.lockb", "package-lock.json", "yarn.lock", "pnpm-lock.yaml", "Cargo.lock", "poetry.lock", "uv.lock", "go.sum", "composer.lock", "Gemfile.lock"]);
|
|
75
76
|
const HEX = /^[0-9a-f]{7,40}$/i;
|
|
76
77
|
|
|
@@ -94,7 +95,15 @@ export function changedPathGroups(cwd: string, head: string, base = "HEAD", attr
|
|
|
94
95
|
return groups;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
|
|
98
|
+
/**
|
|
99
|
+
* #1874 V4: the file list, exclusions and rule groups come from the AREV packet core for the same head and merge base, so a
|
|
100
|
+
* hub brief and `arev packet` cannot disagree. The hub keeps its own inventory for what only it knows: the privacy policy
|
|
101
|
+
* (a path it withholds is never named), the old name of a move, the plain name-list cross-check and the rule texts it screens.
|
|
102
|
+
* A private task builds no packet: it keeps the hub-local classification below and nothing is read or written by AREV for it.
|
|
103
|
+
* ponytail: the packet builds every file patch in memory (one git call per reviewable file, 8 MiB total), which the local
|
|
104
|
+
* classification did not; a core export that lists the files without patches is the upgrade if brief latency shows it.
|
|
105
|
+
*/
|
|
106
|
+
export function buildReviewBrief(cwd: string, head: unknown, policy: BriefPolicy, options: { private?: boolean } = {}): ReviewBrief | { unavailable: string } {
|
|
98
107
|
if (typeof head !== "string" || !HEX.test(head)) return { unavailable: "the task names no commit" };
|
|
99
108
|
const full = git(cwd, ["rev-parse", "--verify", "-q", `${head}^{commit}`]);
|
|
100
109
|
if (full.status !== 0 || typeof full.stdout !== "string") return { unavailable: `commit ${head} is not in this checkout` };
|
|
@@ -111,24 +120,11 @@ export function buildReviewBrief(cwd: string, head: unknown, policy: BriefPolicy
|
|
|
111
120
|
if (!groups.length) return { unavailable: `commit ${head} has no changes against ${from}` };
|
|
112
121
|
const shown = groups.filter(g => !g.paths.some(path => policy.privatePath(path) || !policy.nameable(path)));
|
|
113
122
|
if (shown.length > MAX_FILES) return { unavailable: `${shown.length} changed files, over the brief's ${MAX_FILES}` };
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const attrs = attributes(cwd, mergeBase, [...new Set(shown.flatMap(g => g.paths))]);
|
|
120
|
-
if (!counts || !attrs) return { unavailable: `the file details of ${head} could not be read` };
|
|
121
|
-
const reviewable: BriefFile[] = [], excluded: BriefExcluded[] = [];
|
|
122
|
-
for (const g of shown) {
|
|
123
|
-
const path = g.paths.at(-1)!, count = counts.get(path);
|
|
124
|
-
const sides = { status: g.status[0]!, ...(g.paths.length === 2 ? { oldPath: g.paths[0]! } : {}) };
|
|
125
|
-
// Excluded only when every side is: a move keeps the source's obligation.
|
|
126
|
-
const sideReason = (p: string) => attrs.get(p)?.generated ? "generated (linguist-generated)" : LOCKFILES.has(p.split("/").at(-1)!) ? "lockfile" : undefined;
|
|
127
|
-
const reasons = g.paths.map(sideReason);
|
|
128
|
-
const reason = count?.binary ? "binary" : reasons.every(Boolean) ? reasons.at(-1) : undefined;
|
|
129
|
-
if (reason) { excluded.push({ path, ...sides, reason }); continue; }
|
|
130
|
-
reviewable.push({ path, ...sides, ...(count && !count.binary ? { insertions: count.insertions, deletions: count.deletions } : {}) });
|
|
131
|
-
}
|
|
123
|
+
let withheld = groups.length - shown.length;
|
|
124
|
+
const classified = options.private ? classifyLocally(cwd, commit, from, mergeBase, shown, head) : classifyWithPacket(cwd, commit, from, mergeBase, shown, head, policy);
|
|
125
|
+
if ("unavailable" in classified) return classified;
|
|
126
|
+
const { reviewable, excluded, scopedRules } = classified;
|
|
127
|
+
withheld += classified.withheld;
|
|
132
128
|
const ruleText = new Map<string, string>(), rulesMissing = new Map<string, string>();
|
|
133
129
|
const readRule = (source: string): boolean => {
|
|
134
130
|
if (ruleText.has(source)) return true;
|
|
@@ -148,11 +144,12 @@ export function buildReviewBrief(cwd: string, head: unknown, policy: BriefPolicy
|
|
|
148
144
|
const byKey = new Map<string, { sources: string[]; paths: string[] }>();
|
|
149
145
|
for (const file of reviewable) {
|
|
150
146
|
// The rules of every side apply, so a move out of a scoped directory keeps its rule file.
|
|
151
|
-
const scoped =
|
|
147
|
+
const scoped = scopedRules(file);
|
|
152
148
|
const sources = [...(root ? ["REVIEW.md"] : []), ...scoped.filter(readRule)];
|
|
153
149
|
const key = sources.join("\0");
|
|
154
150
|
(byKey.get(key) ?? byKey.set(key, { sources, paths: [] }).get(key)!).paths.push(file.path);
|
|
155
151
|
}
|
|
152
|
+
for (const m of classified.missing) if (!policy.privatePath(m.source) && policy.nameable(m.source) && !ruleText.has(m.source) && !rulesMissing.has(m.source)) rulesMissing.set(m.source, m.reason);
|
|
156
153
|
// Cross-check with the plain name list (no rename detection), as OCR's list is checked against the PR's.
|
|
157
154
|
const plain = git(cwd, [...attrFrom(mergeBase), "diff", "--relative", "--no-renames", "--name-only", "-z", `${from}...${commit}`, "--"]);
|
|
158
155
|
if (plain.status !== 0 || typeof plain.stdout !== "string") return { unavailable: `the name list of ${head} could not be read` };
|
|
@@ -162,6 +159,64 @@ export function buildReviewBrief(cwd: string, head: unknown, policy: BriefPolicy
|
|
|
162
159
|
return { ...(structure?.length ? { structure } : {}), head: commit, base: from, mergeBase, reviewable, excluded, withheld, rules: [...ruleText].map(([source, text]) => ({ source, text })), rulesMissing: [...rulesMissing].map(([source, reason]) => ({ source, reason })), ruleGroups: [...byKey.values()], unlisted };
|
|
163
160
|
}
|
|
164
161
|
|
|
162
|
+
interface Classified { reviewable: BriefFile[]; excluded: BriefExcluded[]; withheld: number; scopedRules: (file: BriefFile) => string[]; missing: { source: string; reason: string }[] }
|
|
163
|
+
type Shown = { status: string; paths: string[] }[];
|
|
164
|
+
|
|
165
|
+
/** Hub-local classification, kept for a private task: no AREV packet is built for it. */
|
|
166
|
+
function classifyLocally(cwd: string, commit: string, from: string, mergeBase: string, shown: Shown, head: unknown): Classified | { unavailable: string } {
|
|
167
|
+
const counts = numstat(cwd, commit, from, mergeBase);
|
|
168
|
+
// Attributes and rules come from the merge base: a change cannot lift its own review obligations (a head that marks
|
|
169
|
+
// everything generated, or edits REVIEW.md, is still reviewed under the rules it is merging into).
|
|
170
|
+
// Both sides of a move: renaming a reviewed file to a generated or unscoped name must not shed its obligations.
|
|
171
|
+
const attrs = attributes(cwd, mergeBase, [...new Set(shown.flatMap(g => g.paths))]);
|
|
172
|
+
if (!counts || !attrs) return { unavailable: `the file details of ${head} could not be read` };
|
|
173
|
+
const reviewable: BriefFile[] = [], excluded: BriefExcluded[] = [];
|
|
174
|
+
for (const g of shown) {
|
|
175
|
+
const path = g.paths.at(-1)!, count = counts.get(path);
|
|
176
|
+
const sides = { status: g.status[0]!, ...(g.paths.length === 2 ? { oldPath: g.paths[0]! } : {}) };
|
|
177
|
+
// Excluded only when every side is: a move keeps the source's obligation.
|
|
178
|
+
const sideReason = (p: string) => attrs.get(p)?.generated ? "generated (linguist-generated)" : LOCKFILES.has(p.split("/").at(-1)!) ? "lockfile" : undefined;
|
|
179
|
+
const reasons = g.paths.map(sideReason);
|
|
180
|
+
const reason = count?.binary ? "binary" : reasons.every(Boolean) ? reasons.at(-1) : undefined;
|
|
181
|
+
if (reason) { excluded.push({ path, ...sides, reason }); continue; }
|
|
182
|
+
reviewable.push({ path, ...sides, ...(count && !count.binary ? { insertions: count.insertions, deletions: count.deletions } : {}) });
|
|
183
|
+
}
|
|
184
|
+
// The rules of every side apply, so a move out of a scoped directory keeps its rule file.
|
|
185
|
+
const scopedRules = (file: BriefFile) => [...new Set([file.oldPath, file.path].flatMap(p => { const r = p ? attrs.get(p)?.rules : undefined; return r ? [r] : []; }))];
|
|
186
|
+
return { reviewable, excluded, withheld: 0, scopedRules, missing: [] };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** The AREV packet of the same head and merge base decides which files are reviewable, which are excluded and why (its reason names, verbatim), and which rules apply to each. */
|
|
190
|
+
function classifyWithPacket(cwd: string, commit: string, from: string, mergeBase: string, shown: Shown, head: unknown, policy: BriefPolicy): Classified | { unavailable: string } {
|
|
191
|
+
let bundle: ReturnType<typeof buildPacket>;
|
|
192
|
+
try { bundle = buildPacket(cwd, { kind: "range", base: from, head: commit }); }
|
|
193
|
+
catch (error) {
|
|
194
|
+
// AREV's own refusal (over its file or patch limit, an unreadable subject) is the cause a reviewer needs; it is screened first.
|
|
195
|
+
const cause = sanitize(error instanceof Error ? error.message : "unknown error").slice(0, CAUSE_CHARS);
|
|
196
|
+
return { unavailable: policy.nameable(cause) ? `the review packet of ${head} could not be built: ${cause}` : `the review packet of ${head} could not be built (AREV refused the subject ${from}..${commit}; run arev packet for that range in the repository to see why, arev packet --help lists its subject options)` };
|
|
197
|
+
}
|
|
198
|
+
const packet = bundle.packet;
|
|
199
|
+
if (packet.subject.head !== commit || packet.subject.mergeBase !== mergeBase) return { unavailable: `the review packet of ${head} names another head or merge base` };
|
|
200
|
+
const units = new Map(packet.units.map(unit => [unit.path, unit])), omitted = new Map(packet.excluded.map(item => [item.path, item.reason]));
|
|
201
|
+
const reviewable: BriefFile[] = [], excluded: BriefExcluded[] = [];
|
|
202
|
+
let withheld = 0;
|
|
203
|
+
for (const g of shown) {
|
|
204
|
+
const path = g.paths.at(-1)!, unit = units.get(path), reason = omitted.get(path);
|
|
205
|
+
const sides = { status: g.status[0]!, ...(g.paths.length === 2 ? { oldPath: g.paths[0]! } : {}) };
|
|
206
|
+
if (unit) { reviewable.push({ path, ...sides, insertions: unit.insertions, deletions: unit.deletions }); continue; }
|
|
207
|
+
// The core's own deny list withholds a path the hub policy did not: counted, never named.
|
|
208
|
+
if (reason === "denied") { withheld++; continue; }
|
|
209
|
+
if (!reason) return { unavailable: `the review packet of ${head} does not account for every changed file` };
|
|
210
|
+
excluded.push({ path, ...sides, reason });
|
|
211
|
+
}
|
|
212
|
+
// AGENTS.md is the reviewer's instructions in the core, not a hub review rule; REVIEW.md is read by the hub itself.
|
|
213
|
+
const scoped = packet.rules.filter(rule => rule.name !== "REVIEW.md" && rule.name !== "AGENTS.md");
|
|
214
|
+
const scopedRules = (file: BriefFile) => scoped.filter(rule => rule.appliesTo.includes(file.path)).map(rule => rule.name);
|
|
215
|
+
const reasonOf = (reason: string) => reason.startsWith("not found as a file") ? "not found at the merge base" : /^over the limit of (\d+) rule files/.test(reason) ? reason.replace(/^over the limit of (\d+) rule files.*/, "over the brief's $1 rule files") : reason;
|
|
216
|
+
const missing = bundle.rulesMissing.filter(item => item.source !== "REVIEW.md" && item.source !== "AGENTS.md").map(item => ({ source: item.source, reason: reasonOf(item.reason) }));
|
|
217
|
+
return { reviewable, excluded, withheld, scopedRules, missing };
|
|
218
|
+
}
|
|
219
|
+
|
|
165
220
|
function reviewStructure(cwd: string, base: string, head: string, policy: BriefPolicy): string[] | undefined {
|
|
166
221
|
if (!policy.structureRules) return;
|
|
167
222
|
try {
|
|
@@ -280,12 +335,7 @@ export function renderReviewBrief(brief: ReviewBrief): string {
|
|
|
280
335
|
].join("\n");
|
|
281
336
|
}
|
|
282
337
|
|
|
283
|
-
/** The reviewable paths a verdict's coverage does not account for: reviewed, or skipped with a reason. */
|
|
338
|
+
/** The reviewable paths a verdict's coverage does not account for: reviewed, or skipped with a reason. The packet core defines the rule; the brief supplies its files. */
|
|
284
339
|
export function coverageGap(brief: ReviewBrief, coverage: unknown): string[] {
|
|
285
|
-
|
|
286
|
-
const accounted = new Set<string>([
|
|
287
|
-
...(Array.isArray(c.reviewed) ? c.reviewed.filter((p): p is string => typeof p === "string") : []),
|
|
288
|
-
...(Array.isArray(c.skipped) ? c.skipped.flatMap(s => s && typeof s === "object" && typeof (s as { path?: unknown }).path === "string" && typeof (s as { reason?: unknown }).reason === "string" && (s as { reason: string }).reason.trim() ? [(s as { path: string }).path] : []) : []),
|
|
289
|
-
]);
|
|
290
|
-
return brief.reviewable.map(f => f.path).filter(path => !accounted.has(path));
|
|
340
|
+
return coreCoverageGap({ units: brief.reviewable.map(file => ({ path: file.path, status: file.status, insertions: file.insertions ?? 0, deletions: file.deletions ?? 0 })) }, coverage);
|
|
291
341
|
}
|