ai-foreman 1.7.28 → 2.0.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/README.md +1 -1
- package/dist/adapters/claude.d.ts +23 -12
- package/dist/adapters/claude.js +228 -24
- package/dist/adapters/codex.d.ts +17 -7
- package/dist/adapters/codex.js +195 -17
- package/dist/adapters/recovering.d.ts +2 -0
- package/dist/adapters/recovering.js +5 -1
- package/dist/adapters/structured.d.ts +71 -0
- package/dist/adapters/structured.js +213 -0
- package/dist/adapters/types.d.ts +86 -9
- package/dist/agentRun.d.ts +2 -0
- package/dist/agentRun.js +2 -1
- package/dist/boundedTurnEvidence.d.ts +18 -0
- package/dist/boundedTurnEvidence.js +76 -0
- package/dist/branch/currentGuard.d.ts +2 -0
- package/dist/branch/currentGuard.js +2 -0
- package/dist/branch/planner.js +1 -4
- package/dist/branch/runner.d.ts +2 -1
- package/dist/branch/runner.js +10 -7
- package/dist/buildAdmission.js +4 -0
- package/dist/buildApproval.d.ts +30 -0
- package/dist/buildApproval.js +68 -0
- package/dist/buildAssignment.d.ts +1 -0
- package/dist/buildAssignment.js +82 -23
- package/dist/buildInterventions.d.ts +2 -2
- package/dist/buildInterventions.js +11 -4
- package/dist/buildLaunchGate.js +3 -2
- package/dist/builderGuidanceFollowup.js +17 -6
- package/dist/cli/manager.js +22 -20
- package/dist/cli/start.js +32 -24
- package/dist/cli/tickets.js +40 -24
- package/dist/continuity.d.ts +10 -14
- package/dist/continuity.js +198 -179
- package/dist/continuityOrigin.d.ts +13 -0
- package/dist/continuityOrigin.js +91 -0
- package/dist/foreman.d.ts +20 -5
- package/dist/foreman.js +57 -187
- package/dist/graph/boundary.d.ts +1 -1
- package/dist/graph/boundary.js +1 -1
- package/dist/graph/host.js +8 -19
- package/dist/graph/manager.d.ts +1 -1
- package/dist/graph/manager.js +1 -1
- package/dist/graph/preparation.d.ts +38 -0
- package/dist/graph/preparation.js +7 -6
- package/dist/graph/semantic.d.ts +1 -0
- package/dist/graph/semantic.js +4 -1
- package/dist/graph/session.js +7 -2
- package/dist/graph/turn.d.ts +2 -3
- package/dist/graph/turn.js +28 -40
- package/dist/handoffProtocol.js +2 -2
- package/dist/handoffs.d.ts +3 -1
- package/dist/handoffs.js +90 -59
- package/dist/hostGraphApplicability.d.ts +46 -0
- package/dist/hostGraphApplicability.js +97 -0
- package/dist/hostQaAugmentation.d.ts +18 -0
- package/dist/hostQaAugmentation.js +81 -0
- package/dist/hostQaComparison.d.ts +21 -2
- package/dist/hostQaComparison.js +43 -28
- package/dist/hostSourcePreservation.d.ts +38 -0
- package/dist/hostSourcePreservation.js +72 -0
- package/dist/interviews.d.ts +7 -0
- package/dist/interviews.js +18 -1
- package/dist/legacyCommunicationDisplay.d.ts +2 -0
- package/dist/legacyCommunicationDisplay.js +2 -0
- package/dist/managerPacket.js +3 -3
- package/dist/markers.d.ts +4 -3
- package/dist/markers.js +4 -20
- package/dist/probeIpc.d.ts +14 -0
- package/dist/probeIpc.js +29 -0
- package/dist/qaBuildGate.d.ts +21 -0
- package/dist/qaBuildGate.js +48 -12
- package/dist/qaBuilderCoverage.js +22 -13
- package/dist/qaBuilderEvidence.d.ts +16 -1
- package/dist/qaBuilderEvidence.js +48 -8
- package/dist/qaContractCoverage.d.ts +2 -2
- package/dist/qaContractCoverage.js +11 -7
- package/dist/qaContractDelivery.js +34 -20
- package/dist/qaCoverageAssembly.d.ts +22 -0
- package/dist/qaCoverageAssembly.js +16 -0
- package/dist/qaDeliveryJournal.d.ts +2 -0
- package/dist/qaDeliveryJournal.js +19 -0
- package/dist/qaEffectiveConfig.d.ts +1 -0
- package/dist/qaEffectiveConfig.js +6 -1
- package/dist/qaFailureDelivery.js +97 -85
- package/dist/qaHostTransformation.d.ts +26 -0
- package/dist/qaHostTransformation.js +100 -0
- package/dist/qaPreparation.d.ts +8 -20
- package/dist/qaPreparation.js +133 -229
- package/dist/qaPreparationInputs.js +19 -0
- package/dist/qaPreparationStore.js +34 -6
- package/dist/qaPrerequisites.d.ts +2 -1
- package/dist/qaPrerequisites.js +21 -1
- package/dist/qaProtocolV2.d.ts +15 -0
- package/dist/qaRecovery.js +21 -4
- package/dist/qaReview.js +232 -394
- package/dist/qaReviewEvidence.d.ts +7 -3
- package/dist/qaReviewEvidence.js +15 -4
- package/dist/qaRuntime.js +1 -1
- package/dist/qaSnapshot.js +71 -21
- package/dist/qaStructuredResponse.d.ts +10 -0
- package/dist/qaStructuredResponse.js +57 -0
- package/dist/qaTimeline.js +5 -3
- package/dist/qaToolRecovery.d.ts +12 -0
- package/dist/qaToolRecovery.js +44 -0
- package/dist/qaVerificationContract.d.ts +3 -2
- package/dist/qaVerificationContract.js +58 -34
- package/dist/readinessGate.js +5 -4
- package/dist/runtimeReadiness.js +23 -15
- package/dist/statusReporter.d.ts +2 -0
- package/dist/statusReporter.js +2 -0
- package/dist/structuredCutover.d.ts +31 -0
- package/dist/structuredCutover.js +510 -0
- package/dist/structuredCutoverFiles.d.ts +10 -0
- package/dist/structuredCutoverFiles.js +181 -0
- package/dist/structuredDispatchAuthority.d.ts +22 -0
- package/dist/structuredDispatchAuthority.js +110 -0
- package/dist/structuredDispatchRecord.d.ts +29 -0
- package/dist/structuredDispatchRecord.js +36 -0
- package/dist/structuredLiveBudget.d.ts +2 -0
- package/dist/structuredLiveBudget.js +23 -0
- package/dist/structuredOperation.d.ts +18 -0
- package/dist/structuredOperation.js +257 -0
- package/dist/supervisedStart.d.ts +1 -1
- package/dist/supervisedStart.js +78 -31
- package/dist/supervisor.d.ts +18 -2
- package/dist/supervisor.js +74 -17
- package/dist/ticketPlanning.d.ts +1 -373
- package/dist/ticketPlanning.js +2 -26
- package/dist/ticketPopulation.d.ts +0 -3
- package/dist/ticketPopulation.js +4 -21
- package/dist/ticketPopulationPageAuthority.d.ts +13 -0
- package/dist/ticketPopulationPageAuthority.js +30 -0
- package/dist/ticketPopulationPaging.d.ts +27 -0
- package/dist/ticketPopulationPaging.js +105 -0
- package/dist/tickets/renderMarkdown.d.ts +14 -0
- package/dist/tickets/renderMarkdown.js +39 -5
- package/dist/tickets/ticketLoader.js +10 -0
- package/dist/tickets/ticketSchema.d.ts +107 -0
- package/dist/tickets/ticketSchema.js +4 -1
- package/dist/workflowDb.d.ts +100 -2
- package/dist/workflowDb.js +781 -35
- package/dist/workflowReader.d.ts +1 -0
- package/dist/workflowReader.js +9 -0
- package/package.json +15 -7
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { RunSpanV1 } from "rafi-spec";
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Bounded, adapter-redacted output excerpts are host-retained evidence and are
|
|
4
|
+
* delivered to independent QA by default. RAFI_QA_COMMAND_OUTPUT_EXCERPTS=0
|
|
5
|
+
* (or off/false) disables them; a ticket ID limits them to that ticket.
|
|
6
|
+
*/
|
|
7
|
+
export declare function qaCommandOutputExcerptsAllowed(workId: string, configured?: string | undefined): boolean;
|
|
8
|
+
/** Command text is never forwarded; excerpts are bounded and may be truncated. */
|
|
5
9
|
export declare function selectQaCommandObservations(spans: RunSpanV1[], runId: string, workId: string, includeOutputExcerpts?: boolean): unknown[];
|
|
6
10
|
export declare function retainedQaCommandObservations(projectDir: string, runId: string, workId: string, includeOutputExcerpts?: boolean): unknown[];
|
package/dist/qaReviewEvidence.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { ObservabilityReader } from "./observability.js";
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Bounded, adapter-redacted output excerpts are host-retained evidence and are
|
|
4
|
+
* delivered to independent QA by default. RAFI_QA_COMMAND_OUTPUT_EXCERPTS=0
|
|
5
|
+
* (or off/false) disables them; a ticket ID limits them to that ticket.
|
|
6
|
+
*/
|
|
7
|
+
export function qaCommandOutputExcerptsAllowed(workId, configured = process.env.RAFI_QA_COMMAND_OUTPUT_EXCERPTS) {
|
|
8
|
+
if (!workId)
|
|
9
|
+
return false;
|
|
10
|
+
const value = configured?.trim();
|
|
11
|
+
if (!value || ["1", "on", "true"].includes(value.toLowerCase()))
|
|
12
|
+
return true;
|
|
13
|
+
if (["0", "off", "false"].includes(value.toLowerCase()))
|
|
14
|
+
return false;
|
|
15
|
+
return value === workId;
|
|
5
16
|
}
|
|
6
|
-
/**
|
|
17
|
+
/** Command text is never forwarded; excerpts are bounded and may be truncated. */
|
|
7
18
|
export function selectQaCommandObservations(spans, runId, workId, includeOutputExcerpts = false) {
|
|
8
19
|
const turns = new Set(spans.filter(span => span.runId === runId && span.kind === "provider_turn" && span.role === "builder" && span.ticketId === workId).map(span => span.spanId));
|
|
9
20
|
return spans.filter(span => span.runId === runId && span.kind === "tool" && span.role === "builder" && span.parentSpanId && turns.has(span.parentSpanId) && span.completionKnown && span.endedAt)
|
package/dist/qaRuntime.js
CHANGED
|
@@ -13,7 +13,7 @@ export function describeQaRuntimeHandle(adapter, metadata, handoffReceipt) {
|
|
|
13
13
|
// need the machine owner's authentication settings; Codex does not receive
|
|
14
14
|
// that SDK option.
|
|
15
15
|
const settingsSources = adapter.agent === "claude" ? "user" : "none";
|
|
16
|
-
const confinementPolicy = { sandboxMode: "read-only", settingsSources, permissions: readOnlyPermissionConfig(), dependencyProjection: "read-only-symlink", scratch: "sibling-temp-directory" };
|
|
16
|
+
const confinementPolicy = { sandboxMode: "read-only", settingsSources, permissions: readOnlyPermissionConfig(), dependencyProjection: "read-only-symlink", scratch: adapter.agent === "claude" ? "adapter-owned-private-temp-directory" : "sibling-temp-directory" };
|
|
17
17
|
const confinementBase = {
|
|
18
18
|
version: 2, sourceMode: "read-only", scratchMode: "isolated",
|
|
19
19
|
settingsSources, networkMode: "provider-required",
|
package/dist/qaSnapshot.js
CHANGED
|
@@ -51,11 +51,14 @@ export function createDisposableQaSnapshot(builderWorktree, options = {}) {
|
|
|
51
51
|
const frozenState = captureFrozenQaSource(source);
|
|
52
52
|
const tempRoot = mkdtempSync(join(tmpdir(), "rafi-qa-"));
|
|
53
53
|
const review = join(tempRoot, "review");
|
|
54
|
-
|
|
54
|
+
if (frozenState.head === "unavailable")
|
|
55
|
+
initializeUncommittedReviewSync(review);
|
|
56
|
+
else
|
|
57
|
+
cloneRepositorySync(root, review, frozenState.head);
|
|
55
58
|
try {
|
|
56
59
|
applyFrozenSync(review, frozenState);
|
|
57
60
|
if (options.projectDependencies !== false)
|
|
58
|
-
projectDependencyTrees(root, review);
|
|
61
|
+
projectDependencyTrees(root, review, frozenState.head === "unavailable");
|
|
59
62
|
mkdirSync(join(tempRoot, "scratch"), { mode: 0o700 });
|
|
60
63
|
const manifest = manifestFromFrozen(frozenState);
|
|
61
64
|
const snapshot = {
|
|
@@ -81,9 +84,12 @@ export async function createDisposableQaSnapshotAsync(builderWorktree, progress
|
|
|
81
84
|
const review = join(tempRoot, "review");
|
|
82
85
|
try {
|
|
83
86
|
progress("preparing disposable QA snapshot", "creating independent review repository");
|
|
84
|
-
|
|
87
|
+
if (frozenState.head === "unavailable")
|
|
88
|
+
await initializeUncommittedReviewAsync(review);
|
|
89
|
+
else
|
|
90
|
+
await cloneRepositoryAsync(root, review, frozenState.head);
|
|
85
91
|
await applyFrozenAsync(review, frozenState, progress);
|
|
86
|
-
projectDependencyTrees(root, review);
|
|
92
|
+
projectDependencyTrees(root, review, frozenState.head === "unavailable");
|
|
87
93
|
await mkdir(join(tempRoot, "scratch"), { mode: 0o700 });
|
|
88
94
|
const manifest = manifestFromFrozen(frozenState);
|
|
89
95
|
const snapshot = {
|
|
@@ -106,11 +112,11 @@ export async function createDisposableQaSnapshotAsync(builderWorktree, progress
|
|
|
106
112
|
}
|
|
107
113
|
export function frozenQaStateManifest(state) { return manifestFromFrozen(state); }
|
|
108
114
|
export function changeManifest(worktree) {
|
|
109
|
-
const diff = gitBuffer(resolve(worktree), ["diff", "--binary", "HEAD", ...PRODUCT_PATHSPEC]);
|
|
115
|
+
const diff = hasHeadSync(worktree) ? gitBuffer(resolve(worktree), ["diff", "--binary", "HEAD", ...PRODUCT_PATHSPEC]) : Buffer.alloc(0);
|
|
110
116
|
return { diffDigest: hash(diff), untracked: untrackedPaths(worktree).map((path) => describeUntrackedSync(worktree, path)) };
|
|
111
117
|
}
|
|
112
118
|
export async function changeManifestAsync(worktree, progress = () => { }, state = "checking QA file changes") {
|
|
113
|
-
const diff = await runGit(worktree, ["diff", "--binary", "HEAD", ...PRODUCT_PATHSPEC]);
|
|
119
|
+
const diff = (await hasHeadAsync(worktree)) ? await runGit(worktree, ["diff", "--binary", "HEAD", ...PRODUCT_PATHSPEC]) : Buffer.alloc(0);
|
|
114
120
|
const paths = await untrackedPathsAsync(worktree);
|
|
115
121
|
const untracked = [];
|
|
116
122
|
for (let index = 0; index < paths.length; index++) {
|
|
@@ -162,14 +168,14 @@ export function prospectiveGitTreeMatches(worktree, expectedTree, allowedPaths =
|
|
|
162
168
|
throw new Error(`git diff could not compare QA finalization trees (exit ${result.status ?? "unknown"})`);
|
|
163
169
|
}
|
|
164
170
|
function captureOnce(cwd) {
|
|
165
|
-
const head = gitText(cwd, ["rev-parse", "HEAD"]);
|
|
171
|
+
const head = hasHeadSync(cwd) ? gitText(cwd, ["rev-parse", "HEAD"]) : "unavailable";
|
|
166
172
|
const repository = captureRepositoryMetadataSync(cwd);
|
|
167
173
|
const status = gitBuffer(cwd, ["status", "--porcelain=v2", "-z", "--untracked-files=all", ...PRODUCT_PATHSPEC]);
|
|
168
|
-
const combinedDiff = gitBuffer(cwd, ["diff", "--binary", "HEAD", ...PRODUCT_PATHSPEC]);
|
|
169
|
-
const stagedDiff = gitBuffer(cwd, ["diff", "--cached", "--binary", ...PRODUCT_PATHSPEC]);
|
|
170
|
-
const unstagedDiff = gitBuffer(cwd, ["diff", "--binary", ...PRODUCT_PATHSPEC]);
|
|
171
|
-
const stagedNames = gitBuffer(cwd, ["diff", "--cached", "--name-status", "-z", ...PRODUCT_PATHSPEC]);
|
|
172
|
-
const unstagedNames = gitBuffer(cwd, ["diff", "--name-status", "-z", ...PRODUCT_PATHSPEC]);
|
|
174
|
+
const combinedDiff = head === "unavailable" ? Buffer.alloc(0) : gitBuffer(cwd, ["diff", "--binary", "HEAD", ...PRODUCT_PATHSPEC]);
|
|
175
|
+
const stagedDiff = gitBuffer(cwd, ["diff", "--cached", "--binary", ...(head === "unavailable" ? ["--root"] : []), ...PRODUCT_PATHSPEC]);
|
|
176
|
+
const unstagedDiff = head === "unavailable" ? Buffer.alloc(0) : gitBuffer(cwd, ["diff", "--binary", ...PRODUCT_PATHSPEC]);
|
|
177
|
+
const stagedNames = gitBuffer(cwd, ["diff", "--cached", "--name-status", "-z", ...(head === "unavailable" ? ["--root"] : []), ...PRODUCT_PATHSPEC]);
|
|
178
|
+
const unstagedNames = head === "unavailable" ? Buffer.alloc(0) : gitBuffer(cwd, ["diff", "--name-status", "-z", ...PRODUCT_PATHSPEC]);
|
|
173
179
|
const untrackedNames = gitBuffer(cwd, ["ls-files", "--others", "--exclude-standard", "-z"]);
|
|
174
180
|
const untracked = untrackedPathsFrom(untrackedNames).map((path) => captureUntrackedSync(cwd, path));
|
|
175
181
|
const pathInventory = enrichTrackedPathInventorySync(cwd, buildPathInventory(stagedNames, unstagedNames, untracked));
|
|
@@ -183,14 +189,15 @@ async function captureOnceAsync(cwd, progress) {
|
|
|
183
189
|
// observe a different index/worktree generation and manufacture a state
|
|
184
190
|
// that never existed. The enclosing double-capture supplies the stability
|
|
185
191
|
// fence across the complete sequence.
|
|
186
|
-
const
|
|
192
|
+
const headAvailable = await hasHeadAsync(cwd);
|
|
193
|
+
const headBytes = headAvailable ? await runGit(cwd, ["rev-parse", "HEAD"]) : Buffer.from("unavailable");
|
|
187
194
|
const repository = await captureRepositoryMetadataAsync(cwd);
|
|
188
195
|
const status = await runGit(cwd, ["status", "--porcelain=v2", "-z", "--untracked-files=all", ...PRODUCT_PATHSPEC]);
|
|
189
|
-
const combinedDiff = await runGit(cwd, ["diff", "--binary", "HEAD", ...PRODUCT_PATHSPEC]);
|
|
190
|
-
const stagedDiff = await runGit(cwd, ["diff", "--cached", "--binary", ...PRODUCT_PATHSPEC]);
|
|
191
|
-
const unstagedDiff = await runGit(cwd, ["diff", "--binary", ...PRODUCT_PATHSPEC]);
|
|
192
|
-
const stagedNames = await runGit(cwd, ["diff", "--cached", "--name-status", "-z", ...PRODUCT_PATHSPEC]);
|
|
193
|
-
const unstagedNames = await runGit(cwd, ["diff", "--name-status", "-z", ...PRODUCT_PATHSPEC]);
|
|
196
|
+
const combinedDiff = headAvailable ? await runGit(cwd, ["diff", "--binary", "HEAD", ...PRODUCT_PATHSPEC]) : Buffer.alloc(0);
|
|
197
|
+
const stagedDiff = await runGit(cwd, ["diff", "--cached", "--binary", ...(headAvailable ? [] : ["--root"]), ...PRODUCT_PATHSPEC]);
|
|
198
|
+
const unstagedDiff = headAvailable ? await runGit(cwd, ["diff", "--binary", ...PRODUCT_PATHSPEC]) : Buffer.alloc(0);
|
|
199
|
+
const stagedNames = await runGit(cwd, ["diff", "--cached", "--name-status", "-z", ...(headAvailable ? [] : ["--root"]), ...PRODUCT_PATHSPEC]);
|
|
200
|
+
const unstagedNames = headAvailable ? await runGit(cwd, ["diff", "--name-status", "-z", ...PRODUCT_PATHSPEC]) : Buffer.alloc(0);
|
|
194
201
|
const untrackedNames = await runGit(cwd, ["ls-files", "--others", "--exclude-standard", "-z"]);
|
|
195
202
|
const paths = untrackedPathsFrom(untrackedNames);
|
|
196
203
|
const untracked = [];
|
|
@@ -303,7 +310,13 @@ function describeUntrackedSync(worktree, path) {
|
|
|
303
310
|
function untrackedPaths(worktree) { return untrackedPathsFrom(gitBuffer(resolve(worktree), ["ls-files", "--others", "--exclude-standard", "-z"])); }
|
|
304
311
|
async function untrackedPathsAsync(worktree) { return untrackedPathsFrom(await runGit(worktree, ["ls-files", "--others", "--exclude-standard", "-z"])); }
|
|
305
312
|
function untrackedPathsFrom(raw) { return raw.toString().split("\0").filter((path) => path && isQaProductPath(path)).sort(); }
|
|
306
|
-
function isQaProductPath(path) {
|
|
313
|
+
function isQaProductPath(path) {
|
|
314
|
+
return path !== ".git" && !path.startsWith(".git/")
|
|
315
|
+
&& path !== ".foreman" && !path.startsWith(".foreman/")
|
|
316
|
+
&& path !== ".rafi" && !path.startsWith(".rafi/")
|
|
317
|
+
&& path !== "node_modules" && !path.startsWith("node_modules/")
|
|
318
|
+
&& path !== "vendor" && !path.startsWith("vendor/");
|
|
319
|
+
}
|
|
307
320
|
function renderSummary(staged, unstaged, untracked) {
|
|
308
321
|
const normalize = (value) => value.toString().split("\0").filter(Boolean).filter(isQaProductPath).sort().join("\n") || "(none)";
|
|
309
322
|
return `tracked/staged:\n${normalize(staged)}\ntracked/unstaged:\n${normalize(unstaged)}\nuntracked:\n${normalize(untracked)}`;
|
|
@@ -454,6 +467,16 @@ function manifestDifference(before, after) {
|
|
|
454
467
|
changes.push(path);
|
|
455
468
|
return changes;
|
|
456
469
|
}
|
|
470
|
+
function initializeUncommittedReviewSync(review) {
|
|
471
|
+
mkdirSync(review, { recursive: true });
|
|
472
|
+
const initialized = spawnSync("git", ["init", "-q", review], { encoding: "utf8" });
|
|
473
|
+
if (initialized.status !== 0)
|
|
474
|
+
throw new Error(`cannot initialize independent QA repository: ${initialized.stderr.trim()}`);
|
|
475
|
+
}
|
|
476
|
+
async function initializeUncommittedReviewAsync(review) {
|
|
477
|
+
await mkdir(review, { recursive: true });
|
|
478
|
+
await runGit(dirname(review), ["init", "-q", review]);
|
|
479
|
+
}
|
|
457
480
|
function cloneRepositorySync(root, review, head) {
|
|
458
481
|
const cloned = spawnSync("git", ["clone", "--no-local", "--no-hardlinks", "--no-checkout", "--quiet", root, review], { encoding: "utf8" });
|
|
459
482
|
if (cloned.status !== 0) {
|
|
@@ -475,7 +498,7 @@ async function cloneRepositoryAsync(root, review, head) {
|
|
|
475
498
|
* Project the existing trees without copying or permitting writes so validation
|
|
476
499
|
* commands in the independent clone can resolve the same installed toolchain.
|
|
477
500
|
*/
|
|
478
|
-
function projectDependencyTrees(sourceRoot, reviewRoot) {
|
|
501
|
+
function projectDependencyTrees(sourceRoot, reviewRoot, uncommitted = false) {
|
|
479
502
|
const parents = ["", ...readdirSync(sourceRoot, { withFileTypes: true })
|
|
480
503
|
.filter((entry) => entry.isDirectory() && entry.name !== ".git" && entry.name !== "node_modules")
|
|
481
504
|
.flatMap((entry) => {
|
|
@@ -491,11 +514,38 @@ function projectDependencyTrees(sourceRoot, reviewRoot) {
|
|
|
491
514
|
if (!existsSync(source) || existsSync(target) || !lstatSync(source).isDirectory())
|
|
492
515
|
continue;
|
|
493
516
|
const relativeTarget = parent ? `${parent.replaceAll("\\", "/")}/node_modules` : "node_modules";
|
|
494
|
-
if (spawnSync("git", ["-C", reviewRoot, "check-ignore", "-q", "--", relativeTarget]).status !== 0)
|
|
517
|
+
if (!uncommitted && spawnSync("git", ["-C", reviewRoot, "check-ignore", "-q", "--", relativeTarget]).status !== 0)
|
|
495
518
|
continue;
|
|
496
519
|
mkdirSync(dirname(target), { recursive: true });
|
|
497
520
|
symlinkSync(source, target, "dir");
|
|
498
521
|
}
|
|
522
|
+
if (!uncommitted)
|
|
523
|
+
return;
|
|
524
|
+
for (const entry of readdirSync(sourceRoot, { withFileTypes: true })) {
|
|
525
|
+
if (!entry.isDirectory() || [".git", ".rafi", ".foreman", "node_modules"].includes(entry.name))
|
|
526
|
+
continue;
|
|
527
|
+
const source = join(sourceRoot, entry.name);
|
|
528
|
+
const target = join(reviewRoot, entry.name);
|
|
529
|
+
if (existsSync(target))
|
|
530
|
+
continue;
|
|
531
|
+
const ignored = spawnSync("git", ["-C", sourceRoot, "check-ignore", "-q", "--", entry.name]).status === 0;
|
|
532
|
+
if (!ignored)
|
|
533
|
+
continue;
|
|
534
|
+
symlinkSync(source, target, "dir");
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function hasHeadSync(cwd) {
|
|
538
|
+
const result = spawnSync("git", ["-C", resolve(cwd), "rev-parse", "--verify", "HEAD"], { stdio: "ignore" });
|
|
539
|
+
return result.status === 0;
|
|
540
|
+
}
|
|
541
|
+
async function hasHeadAsync(cwd) {
|
|
542
|
+
try {
|
|
543
|
+
await runGit(cwd, ["rev-parse", "--verify", "HEAD"]);
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
catch {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
499
549
|
}
|
|
500
550
|
function captureRepositoryMetadataSync(cwd) {
|
|
501
551
|
const topLevel = gitText(cwd, ["rev-parse", "--show-toplevel"]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type QaResponseContract } from "rafi-spec";
|
|
2
|
+
import type { TurnResult } from "./adapters/types.js";
|
|
3
|
+
import type { StepStatus } from "./foreman.js";
|
|
4
|
+
import { type BuilderQaRemediationContract, type QaFindingRefV2 } from "rafi-spec";
|
|
5
|
+
export declare function qaStructuredResponse(turn: TurnResult): QaResponseContract;
|
|
6
|
+
export declare function qaStructuredStatus(turn: TurnResult): StepStatus;
|
|
7
|
+
export declare function remediationStructuredResponse(turn: TurnResult, expected: {
|
|
8
|
+
handoffId?: string;
|
|
9
|
+
findings?: QaFindingRefV2[];
|
|
10
|
+
}): BuilderQaRemediationContract;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { qaVerdictOutput, validateQaFailureReport, validateBuilderQaRemediationReport } from "rafi-spec";
|
|
2
|
+
import { operationResponse } from "./structuredOperation.js";
|
|
3
|
+
import { remediationOutput, validateBuilderFindingCoverage } from "rafi-spec";
|
|
4
|
+
export function qaStructuredResponse(turn) {
|
|
5
|
+
try {
|
|
6
|
+
const response = operationResponse(turn, qaVerdictOutput);
|
|
7
|
+
if (response.result.kind === "blocked")
|
|
8
|
+
return { valid: true, errors: [], status: "blocked", fields: { reason: response.result.reason } };
|
|
9
|
+
if (response.result.kind === "needs-input")
|
|
10
|
+
return { valid: true, errors: [], status: "needs_input", fields: { question: response.result.question, choices: response.result.choices.join("|") } };
|
|
11
|
+
if (response.result.kind !== "completed")
|
|
12
|
+
throw new Error("Unconsumed QA intermediate result");
|
|
13
|
+
const payload = response.result.payload;
|
|
14
|
+
if (payload.kind === "failed") {
|
|
15
|
+
const validation = validateQaFailureReport(payload.report);
|
|
16
|
+
if (!validation.valid)
|
|
17
|
+
throw new Error(validation.errors.join("; "));
|
|
18
|
+
}
|
|
19
|
+
return payload.kind === "passed" ? { valid: true, errors: [], status: "qa_pass", fields: { summary: response.result.summary } }
|
|
20
|
+
: { valid: true, errors: [], status: "qa_fail", fields: { issues: response.result.summary }, report: payload.report, rawReportJson: JSON.stringify(payload.report) };
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return { valid: false, errors: [String(error)], status: "unknown", fields: {} };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function qaStructuredStatus(turn) {
|
|
27
|
+
const contract = qaStructuredResponse(turn);
|
|
28
|
+
return { kind: contract.status, ...contract.fields, choices: contract.fields.choices?.split("|"), error: contract.errors.join("; ") || undefined };
|
|
29
|
+
}
|
|
30
|
+
export function remediationStructuredResponse(turn, expected) {
|
|
31
|
+
try {
|
|
32
|
+
const { result } = operationResponse(turn, remediationOutput);
|
|
33
|
+
if (result.kind === "blocked")
|
|
34
|
+
return { valid: true, errors: [], status: "blocked", fields: { reason: result.reason } };
|
|
35
|
+
if (result.kind === "needs-input")
|
|
36
|
+
return { valid: true, errors: [], status: "needs_input", fields: { question: result.question } };
|
|
37
|
+
if (result.kind !== "completed")
|
|
38
|
+
throw new Error("Unconsumed remediation intermediate result");
|
|
39
|
+
const { report, status, reason } = result.payload;
|
|
40
|
+
const validation = validateBuilderQaRemediationReport(report);
|
|
41
|
+
if (!validation.valid)
|
|
42
|
+
throw new Error(validation.errors.join("; "));
|
|
43
|
+
const errors = expected.findings ? validateBuilderFindingCoverage(report, expected.findings) : [];
|
|
44
|
+
if (expected.handoffId && report.handoff_id !== expected.handoffId)
|
|
45
|
+
errors.push("Remediation handoff identity mismatch");
|
|
46
|
+
const blocked = report.findings.some(finding => finding.disposition === "blocked");
|
|
47
|
+
if (blocked !== (status === "blocked") || status === "blocked" && !reason || status === "done" && reason !== null)
|
|
48
|
+
errors.push("Contradictory remediation outcome");
|
|
49
|
+
for (const finding of report.findings)
|
|
50
|
+
if (Boolean(finding.blocker) !== (finding.disposition === "blocked"))
|
|
51
|
+
errors.push(`Invalid blocker for ${finding.finding_key}`);
|
|
52
|
+
return { valid: !errors.length, errors, status, fields: status === "blocked" ? { reason: reason } : { summary: result.summary }, report, rawReportJson: JSON.stringify(report) };
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
return { valid: false, errors: [String(error)], status: "unknown", fields: {} };
|
|
56
|
+
}
|
|
57
|
+
}
|
package/dist/qaTimeline.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decisionBelongsToWork } from "./buildInterventions.js";
|
|
2
2
|
import { evidenceRecord } from "./qaEvidenceReader.js";
|
|
3
|
-
import {
|
|
3
|
+
import { describeLegacyQaTranscript } from "./legacyCommunicationDisplay.js";
|
|
4
4
|
/** All counters are scoped rows. A changed digest is never a code-change explanation. */
|
|
5
5
|
export function buildQaTimeline(snapshot, workId) {
|
|
6
6
|
const scoped = (table) => (snapshot.rows[table] ?? []).filter(row => row.ticket_id === workId);
|
|
@@ -25,8 +25,10 @@ export function buildQaTimeline(snapshot, workId) {
|
|
|
25
25
|
if (/correction|repair/.test(slot))
|
|
26
26
|
counters.corrections++;
|
|
27
27
|
const bytes = typeof receipt?.cleanedResponseDigest === "string" ? snapshot.blobs.get(receipt.cleanedResponseDigest) : undefined;
|
|
28
|
-
const contract = bytes ?
|
|
29
|
-
|
|
28
|
+
const contract = bytes ? describeLegacyQaTranscript(bytes.toString("utf8")) : undefined;
|
|
29
|
+
let classification = contract ? contract.valid ? contract.status : "malformed" : "unavailable";
|
|
30
|
+
if (typeof receipt?.structuredResponseDigest === "string")
|
|
31
|
+
classification = "unavailable";
|
|
30
32
|
if (slot === "initial" && classification === "malformed")
|
|
31
33
|
counters.malformedResponses++;
|
|
32
34
|
if (slot === "initial" && classification === "blocked")
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BuilderEvent } from "./adapters/types.js";
|
|
2
|
+
export type QaUnresolvedToolDecision = {
|
|
3
|
+
action: "none";
|
|
4
|
+
} | {
|
|
5
|
+
action: "retry";
|
|
6
|
+
detail: string;
|
|
7
|
+
} | {
|
|
8
|
+
action: "pause";
|
|
9
|
+
detail: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function recordQaUnresolvedTools(projectDir: string, runId: string, ticketId: string, events: BuilderEvent[]): void;
|
|
12
|
+
export declare function qaUnresolvedToolDecision(projectDir: string, runId: string, ticketId: string, events: BuilderEvent[]): QaUnresolvedToolDecision;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { WorkflowDb } from "./workflowDb.js";
|
|
2
|
+
function unresolvedTools(events) {
|
|
3
|
+
const latest = new Map();
|
|
4
|
+
for (const event of events)
|
|
5
|
+
if (event.kind === "tool" && event.callId && event.lifecycle === "completed")
|
|
6
|
+
latest.set(event.callId, event);
|
|
7
|
+
return [...latest.values()].filter(event => event.completionKnown === false).map(event => ({ callId: event.callId, digest: event.outputDigest, name: event.name }));
|
|
8
|
+
}
|
|
9
|
+
export function recordQaUnresolvedTools(projectDir, runId, ticketId, events) {
|
|
10
|
+
const unresolved = unresolvedTools(events);
|
|
11
|
+
if (!unresolved.length)
|
|
12
|
+
return;
|
|
13
|
+
const db = new WorkflowDb(projectDir);
|
|
14
|
+
try {
|
|
15
|
+
const prior = db.continuityEvents(runId).filter(event => event.kind === "qa-unresolved-tool-result" && event.payload.ticketId === ticketId);
|
|
16
|
+
const known = new Set(prior.map(event => JSON.stringify(event.payload)));
|
|
17
|
+
const head = db.qaTicketHead(runId, ticketId);
|
|
18
|
+
for (const item of unresolved) {
|
|
19
|
+
const payload = { ticketId, callId: item.callId, toolName: item.name, outputDigest: item.digest ?? null };
|
|
20
|
+
if (!known.has(JSON.stringify(payload)))
|
|
21
|
+
db.appendContinuityEvent({ runId, role: "qa", kind: "qa-unresolved-tool-result", payload, authoritativeStateRevision: head.revision });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
db.close();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function qaUnresolvedToolDecision(projectDir, runId, ticketId, events) {
|
|
29
|
+
const unresolved = unresolvedTools(events);
|
|
30
|
+
if (!unresolved.length)
|
|
31
|
+
return { action: "none" };
|
|
32
|
+
const db = new WorkflowDb(projectDir);
|
|
33
|
+
try {
|
|
34
|
+
const records = db.continuityEvents(runId).filter(event => event.kind === "qa-unresolved-tool-result" && event.payload.ticketId === ticketId);
|
|
35
|
+
const priorKeys = new Set(records.map(event => { const payload = event.payload; return payload.outputDigest ?? payload.toolName; }));
|
|
36
|
+
const repeated = unresolved.find(item => priorKeys.has(item.digest ?? item.name));
|
|
37
|
+
if (repeated)
|
|
38
|
+
return { action: "pause", detail: `QA tool result remains unresolved after one controlled recovery (${repeated.name}, ${repeated.digest ?? repeated.name}); no provider action was replayed` };
|
|
39
|
+
return { action: "retry", detail: `QA observed an unresolved ${unresolved[0].name} result; starting one fresh review without replaying the uncertain tool action` };
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
db.close();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -10,6 +10,8 @@ export declare function allocateStableCheckIds(candidate: QaContractCandidateV1)
|
|
|
10
10
|
export declare function inventoryDigest(requirements: RequirementRef[]): string;
|
|
11
11
|
/** Derive a missing baseline binding only from an explicit, unique check prerequisite reference. */
|
|
12
12
|
export declare function bindUniqueBaselineCheckIds(candidate: QaContractCandidateV1): QaContractCandidateV1;
|
|
13
|
+
/** Ensure the host-owned scope invariant survives providers that omit or rename it. */
|
|
14
|
+
export declare function ensureHostScopeCheck(candidate: QaContractCandidateV1, baselineId: string): QaContractCandidateV1;
|
|
13
15
|
/**
|
|
14
16
|
* The host owns the before/after path comparison. Providers may still draft a
|
|
15
17
|
* check that asks them to enumerate every changed file, which turns host
|
|
@@ -18,9 +20,8 @@ export declare function bindUniqueBaselineCheckIds(candidate: QaContractCandidat
|
|
|
18
20
|
*/
|
|
19
21
|
export declare function rewriteProviderHostScopeChecks(candidate: QaContractCandidateV1, baselineId: string): QaContractCandidateV1;
|
|
20
22
|
export declare function authoritativeInventory(ticket: TicketDef, checklist: string[], inputs: ContractInputRef[]): RequirementRef[];
|
|
21
|
-
export declare function parsePreparationArtifact<T>(text: string, tag: string, maximum?: number): T;
|
|
22
23
|
/** Capture safe absolute snapshot paths before the disposable snapshot is removed. */
|
|
23
|
-
export declare function mapSnapshotWorkingDirectories(text:
|
|
24
|
+
export declare function mapSnapshotWorkingDirectories(text: Partial<QaContractCandidateV1>, snapshotPath: string): Record<string, string>;
|
|
24
25
|
/** Providers sometimes repeat an absolute disposable-snapshot path from an earlier
|
|
25
26
|
* conversation. That path is host-owned and must not enter the durable contract;
|
|
26
27
|
* normalize only the bounded QA snapshot naming convention to stable relative
|
|
@@ -113,8 +113,12 @@ export function inventoryDigest(requirements) { return contractDigest("qa-requir
|
|
|
113
113
|
/** Derive a missing baseline binding only from an explicit, unique check prerequisite reference. */
|
|
114
114
|
export function bindUniqueBaselineCheckIds(candidate) {
|
|
115
115
|
const draft = structuredClone(candidate);
|
|
116
|
+
const proposedIds = new Set(draft.checks.map(check => check.id));
|
|
116
117
|
for (const observation of draft.baseline) {
|
|
117
|
-
|
|
118
|
+
// A correction may copy a stable check ID from an earlier draft. Repair
|
|
119
|
+
// that stale binding from the observation's unique prerequisite instead
|
|
120
|
+
// of sending it through stable-ID allocation as if it were current.
|
|
121
|
+
if (observation.checkId && proposedIds.has(observation.checkId))
|
|
118
122
|
continue;
|
|
119
123
|
const matches = draft.checks.filter(check => check.prerequisiteRefs.includes(observation.id));
|
|
120
124
|
if (matches.length === 1)
|
|
@@ -122,6 +126,38 @@ export function bindUniqueBaselineCheckIds(candidate) {
|
|
|
122
126
|
}
|
|
123
127
|
return draft;
|
|
124
128
|
}
|
|
129
|
+
/** Ensure the host-owned scope invariant survives providers that omit or rename it. */
|
|
130
|
+
export function ensureHostScopeCheck(candidate, baselineId) {
|
|
131
|
+
const copy = structuredClone(candidate);
|
|
132
|
+
const hasHostScope = copy.checks.some(check => check.hostKind === "source-scope");
|
|
133
|
+
if (hasHostScope)
|
|
134
|
+
return copy;
|
|
135
|
+
// Every contract check must trace to at least one authoritative requirement.
|
|
136
|
+
// The host scope invariant is cross-cutting rather than provider-authored, so
|
|
137
|
+
// bind it to the first approved requirement when a provider omitted the
|
|
138
|
+
// invariant entirely. This keeps the invariant structurally valid without
|
|
139
|
+
// inventing a new requirement outside the authoritative inventory.
|
|
140
|
+
const scopeRequirement = copy.requirements[0]?.id;
|
|
141
|
+
if (!scopeRequirement)
|
|
142
|
+
throw new Error("Cannot add host scope check without an authoritative requirement");
|
|
143
|
+
let hostId = "host-scope";
|
|
144
|
+
while (copy.checks.some(check => check.id === hostId))
|
|
145
|
+
hostId += "-host";
|
|
146
|
+
copy.checks.push({
|
|
147
|
+
id: hostId, hostKind: "source-scope",
|
|
148
|
+
requirementRefs: [scopeRequirement],
|
|
149
|
+
origin: "invariant",
|
|
150
|
+
expectedBehavior: "Rafi compares the final product paths with the host-captured preimplementation baseline and rejects unauthorized product changes.",
|
|
151
|
+
obligation: "mandatory",
|
|
152
|
+
timing: "postimplementation",
|
|
153
|
+
applicability: { kind: "unconditional", decisionOwner: "host", requiredEvidence: [baselineId] },
|
|
154
|
+
verification: [{ kind: "procedure", steps: ["Rafi performs the host-owned before/after product-path comparison, excluding approved bookkeeping and bounded evidence paths."], cwd: ".", fixtures: [], runtime: "Rafi host", timeoutMs: 30_000, expectedOutcome: "Only approved product changes are present; unauthorized, destructive, protected, or requirement-relevant changes are rejected." }],
|
|
155
|
+
expectedEvidence: ["Rafi host-owned postimplementation scope comparison bound to the retained preimplementation baseline."],
|
|
156
|
+
prerequisiteRefs: [baselineId],
|
|
157
|
+
dependsOnChecks: [],
|
|
158
|
+
});
|
|
159
|
+
return copy;
|
|
160
|
+
}
|
|
125
161
|
/**
|
|
126
162
|
* The host owns the before/after path comparison. Providers may still draft a
|
|
127
163
|
* check that asks them to enumerate every changed file, which turns host
|
|
@@ -135,7 +171,8 @@ export function rewriteProviderHostScopeChecks(candidate, baselineId) {
|
|
|
135
171
|
return /\b(?:complete|full|all|every)\s+(?:changed|modified|touched)[ -](?:path|paths|file|files)\b/.test(text)
|
|
136
172
|
|| /\b(?:changed|modified|touched)[ -](?:path|paths|file|files)\s+(?:inventory|list|manifest)\b/.test(text)
|
|
137
173
|
|| /\bunchanged[- ]files?\s+(?:comparison|check|verification)\b/.test(text)
|
|
138
|
-
|| /\bpath\s+manifest\b.{0,80}\b(?:compare|comparison|unchanged|scope)\b/.test(text)
|
|
174
|
+
|| /\bpath\s+manifest\b.{0,80}\b(?:compare|comparison|unchanged|scope)\b/.test(text)
|
|
175
|
+
|| (check.applicability.decisionOwner === "host" && /scope.{0,80}comparison|comparison.{0,80}scope|product paths?.{0,100}baseline/.test(text));
|
|
139
176
|
};
|
|
140
177
|
const matches = draft.checks.filter(hostScope);
|
|
141
178
|
if (!matches.length)
|
|
@@ -179,42 +216,13 @@ export function authoritativeInventory(ticket, checklist, inputs) {
|
|
|
179
216
|
}
|
|
180
217
|
return result;
|
|
181
218
|
}
|
|
182
|
-
export function parsePreparationArtifact(text, tag, maximum = 2 * 1024 * 1024) {
|
|
183
|
-
if (Buffer.byteLength(text) > maximum)
|
|
184
|
-
throw new Error("QA preparation response exceeds size limit");
|
|
185
|
-
const start = `${tag}_START`, end = `${tag}_END`;
|
|
186
|
-
// Marker names can appear inline in provider prose or in a quoted repair
|
|
187
|
-
// instruction. Only a standalone marker line is an envelope boundary.
|
|
188
|
-
// This keeps the parser strict about malformed envelopes without treating
|
|
189
|
-
// explanatory text as a second/truncated artifact.
|
|
190
|
-
const markerOffsets = (marker) => {
|
|
191
|
-
const offsets = [];
|
|
192
|
-
const pattern = new RegExp(`^[ \\t]*${marker}[ \\t]*$`, "gm");
|
|
193
|
-
for (let match = pattern.exec(text); match; match = pattern.exec(text))
|
|
194
|
-
offsets.push(match.index);
|
|
195
|
-
return offsets;
|
|
196
|
-
};
|
|
197
|
-
const starts = markerOffsets(start), ends = markerOffsets(end);
|
|
198
|
-
if (!starts.length || starts.length !== ends.length)
|
|
199
|
-
throw new Error(`Expected exactly one ${tag} artifact`);
|
|
200
|
-
const artifacts = starts.map((at, index) => {
|
|
201
|
-
const from = at + start.length, to = ends[index];
|
|
202
|
-
if (to < from)
|
|
203
|
-
throw new Error("Malformed preparation artifact envelope");
|
|
204
|
-
return text.slice(from, to).trim();
|
|
205
|
-
});
|
|
206
|
-
if (artifacts.length > 1) {
|
|
207
|
-
const normalized = artifacts.map(artifact => canonicalContractJson(JSON.parse(artifact)));
|
|
208
|
-
if (normalized.some(artifact => artifact !== normalized[0]))
|
|
209
|
-
throw new Error(`Expected exactly one unambiguous ${tag} artifact`);
|
|
210
|
-
}
|
|
211
|
-
return JSON.parse(artifacts[0]);
|
|
212
|
-
}
|
|
213
219
|
/** Capture safe absolute snapshot paths before the disposable snapshot is removed. */
|
|
214
220
|
export function mapSnapshotWorkingDirectories(text, snapshotPath) {
|
|
215
221
|
const result = {};
|
|
216
222
|
try {
|
|
217
|
-
|
|
223
|
+
if (typeof text === "string")
|
|
224
|
+
throw new Error("Snapshot mappings require validated native draft fields");
|
|
225
|
+
const draft = text;
|
|
218
226
|
const root = realpathSync(snapshotPath);
|
|
219
227
|
for (const check of draft.checks ?? [])
|
|
220
228
|
for (const method of check.verification ?? []) {
|
|
@@ -228,6 +236,17 @@ export function mapSnapshotWorkingDirectories(text, snapshotPath) {
|
|
|
228
236
|
}
|
|
229
237
|
catch { /* Missing or inaccessible paths remain invalid. */ }
|
|
230
238
|
}
|
|
239
|
+
for (const evidence of draft.preparationEvidence ?? [])
|
|
240
|
+
for (const reference of evidence.references ?? []) {
|
|
241
|
+
if (!isAbsolute(reference.path))
|
|
242
|
+
continue;
|
|
243
|
+
try {
|
|
244
|
+
const target = realpathSync(reference.path), path = relative(root, target);
|
|
245
|
+
if (path && path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path) && statSync(target).isFile())
|
|
246
|
+
result[reference.path] = path;
|
|
247
|
+
}
|
|
248
|
+
catch { /* Unreadable/outside references are rejected during binding. */ }
|
|
249
|
+
}
|
|
231
250
|
}
|
|
232
251
|
catch { /* Parsing and validation report malformed provider responses. */ }
|
|
233
252
|
return result;
|
|
@@ -275,6 +294,11 @@ export function validateCandidate(candidate, inventory, resolveEquivalent) {
|
|
|
275
294
|
for (const req of candidate.requirements) {
|
|
276
295
|
if (!inputs.has(req.inputRef) || !req.statement?.trim() || req.digest !== contractDigest("statement", req.statement))
|
|
277
296
|
issues.push(`Invalid source/statement ${req.id}`);
|
|
297
|
+
if (req.verificationIntent !== undefined && req.verificationIntentDigest !== contractDigest("verification-intent-v2", req.verificationIntent)) {
|
|
298
|
+
issues.push(`Invalid V2 verification intent ${req.id}`);
|
|
299
|
+
}
|
|
300
|
+
if (req.verificationIntent === undefined && req.verificationIntentDigest !== undefined)
|
|
301
|
+
issues.push(`Unexpected V2 verification intent digest ${req.id}`);
|
|
278
302
|
if (req.conflict)
|
|
279
303
|
issues.push(`Unresolved requirement conflict ${req.id}`);
|
|
280
304
|
if (req.authority === "proposed" && req.obligation === "mandatory")
|
package/dist/readinessGate.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseHostIpc } from "rafi-spec";
|
|
1
2
|
/** Trusted bootstrap: registration and durable authorization precede all provider work. */
|
|
2
3
|
import { WorkflowDb } from "./workflowDb.js";
|
|
3
4
|
import { spawn } from "node:child_process";
|
|
@@ -21,7 +22,7 @@ try {
|
|
|
21
22
|
await new Promise((resolve, reject) => {
|
|
22
23
|
const timer = setTimeout(() => finish(new Error("Readiness authorization timed out")), 10_000);
|
|
23
24
|
const disconnect = () => finish(new Error("Readiness owner disconnected"));
|
|
24
|
-
const message = (value) => {
|
|
25
|
+
const message = (value) => { const ack = parseHostIpc(value); if (ack?.kind === "rafi-probe-authorized" && ack.id === id && ack.pid === process.pid)
|
|
25
26
|
finish(); };
|
|
26
27
|
function finish(error) {
|
|
27
28
|
clearTimeout(timer);
|
|
@@ -34,7 +35,7 @@ try {
|
|
|
34
35
|
}
|
|
35
36
|
process.on("message", message);
|
|
36
37
|
process.once("disconnect", disconnect);
|
|
37
|
-
process.send({ kind: "rafi-probe-registered", id });
|
|
38
|
+
process.send({ version: 1, kind: "rafi-probe-registered", id, pid: process.pid });
|
|
38
39
|
if (disconnected)
|
|
39
40
|
disconnect();
|
|
40
41
|
});
|
|
@@ -47,11 +48,11 @@ try {
|
|
|
47
48
|
stdio: [windows ? "pipe" : "ignore", "inherit", "inherit"],
|
|
48
49
|
});
|
|
49
50
|
child.on("error", (error) => {
|
|
50
|
-
process.send?.({ kind: "rafi-probe-spawn-error", code: error.code, message: error.message });
|
|
51
|
+
process.send?.({ version: 1, kind: "rafi-probe-spawn-error", id, pid: process.pid, code: error.code ?? null, message: error.message.slice(0, 8192) });
|
|
51
52
|
console.error(error.message);
|
|
52
53
|
process.exitCode = 127;
|
|
53
54
|
});
|
|
54
|
-
const done = new Promise(resolve => { child.once("exit", (code, signal) => { process.send?.({ kind: "rafi-probe-result", exitCode: code, signal }); process.exitCode = code ?? 1; resolve(); }); child.once("error", () => resolve()); });
|
|
55
|
+
const done = new Promise(resolve => { child.once("exit", (code, signal) => { process.send?.({ version: 1, kind: "rafi-probe-result", id, pid: process.pid, exitCode: code, signal }); process.exitCode = code ?? 1; resolve(); }); child.once("error", () => resolve()); });
|
|
55
56
|
if (windows) {
|
|
56
57
|
try {
|
|
57
58
|
if (!child.pid)
|