@ccdd/project 3.1.1 → 3.1.2
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/dist/monitor-ui/assets/GraphView-CLDdEbWU.js +27 -0
- package/dist/monitor-ui/assets/ValidationView-C6Fz_CWD.js +1 -0
- package/dist/monitor-ui/assets/{elk-api-DDn2L4-3.js → elk-api-BMMZHNwW.js} +1 -1
- package/dist/monitor-ui/assets/{elk.bundled-Bmx50hLH.js → elk.bundled-DuZ6spnY.js} +1 -1
- package/dist/monitor-ui/assets/index-BDX0ouEQ.js +8 -0
- package/dist/monitor-ui/assets/index-DDwx11D7.css +1 -0
- package/dist/monitor-ui/index.html +2 -2
- package/dist/src/artifacts/tool-check.d.ts +3 -0
- package/dist/src/artifacts/tool-check.js +28 -25
- package/dist/src/artifacts/tool-check.js.map +1 -1
- package/dist/src/broker/human-claims.d.ts +20 -2
- package/dist/src/broker/human-claims.js +50 -5
- package/dist/src/broker/human-claims.js.map +1 -1
- package/dist/src/broker/index.d.ts +2 -1
- package/dist/src/broker/index.js +5 -3
- package/dist/src/broker/index.js.map +1 -1
- package/dist/src/contracts.d.ts +2 -1
- package/dist/src/executors/human-preparation.d.ts +7 -1
- package/dist/src/executors/human-preparation.js +9 -2
- package/dist/src/executors/human-preparation.js.map +1 -1
- package/dist/src/monitor/human-preparation.d.ts +4 -0
- package/dist/src/monitor/human-preparation.js +43 -0
- package/dist/src/monitor/human-preparation.js.map +1 -0
- package/dist/src/monitor/server.js +4 -1
- package/dist/src/monitor/server.js.map +1 -1
- package/dist/src/monitor/types.d.ts +9 -0
- package/dist/src/tools/diagnostics.d.ts +11 -0
- package/dist/src/tools/diagnostics.js +75 -0
- package/dist/src/tools/diagnostics.js.map +1 -0
- package/dist/src/tools/runner.d.ts +2 -0
- package/dist/src/tools/runner.js +13 -5
- package/dist/src/tools/runner.js.map +1 -1
- package/dist/src/tools/runtime-host.js +6 -1
- package/dist/src/tools/runtime-host.js.map +1 -1
- package/dist/src/workspaces/index.d.ts +10 -2
- package/dist/src/workspaces/index.js +22 -7
- package/dist/src/workspaces/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/monitor-ui/assets/GraphView-CzM-UdPe.js +0 -27
- package/dist/monitor-ui/assets/ValidationView-C3G5cwXp.js +0 -1
- package/dist/monitor-ui/assets/_plugin-vue_export-helper-BDNMzG2s.js +0 -1
- package/dist/monitor-ui/assets/index-B4RYcPAo.js +0 -8
- package/dist/monitor-ui/assets/index-SA3sxGLr.css +0 -1
|
@@ -6,42 +6,30 @@ import { prepareWorkspace } from '../workspaces/index.js';
|
|
|
6
6
|
import { createReviewTools } from '../tools/runner.js';
|
|
7
7
|
import { assertArtifactAudience } from './types.js';
|
|
8
8
|
import { isArtifactGroup, resolveArtifactScope } from './groups.js';
|
|
9
|
-
|
|
10
|
-
const code = error && typeof error === 'object' && 'code' in error ? error.code : undefined;
|
|
11
|
-
if (aborted || code === 'ABORTED')
|
|
12
|
-
return { code: 'ABORTED', message: 'Artifact tool diagnosis was cancelled.' };
|
|
13
|
-
if (code === 'WORKSPACE_CHANGED' || code === 'WORKSPACE_CACHE_TAMPERED')
|
|
14
|
-
return { code, message: 'The workspace changed during Artifact tool diagnosis.' };
|
|
15
|
-
if (code === 'ARTIFACT_TOOLS_UNAVAILABLE')
|
|
16
|
-
return { code, message: 'A Critic references an Artifact with no tools for its reviewer kind. Register the corresponding agentTools or humanTools.' };
|
|
17
|
-
if (code === 'HUMAN_TOOL_TIMEOUT')
|
|
18
|
-
return { code, message: 'The registered Human tool exceeded its configured time limit.' };
|
|
19
|
-
if (code === 'HUMAN_TOOL_UNAVAILABLE')
|
|
20
|
-
return { code, message: 'The registered Human tool executable is unavailable.' };
|
|
21
|
-
if (code === 'HUMAN_TOOL_FAILED')
|
|
22
|
-
return { code, message: 'The registered Human tool did not finish successfully.' };
|
|
23
|
-
return { code: 'ARTIFACT_TOOL_CHECK_FAILED', message: 'Artifact tool diagnosis failed. Check the configuration, selected tool, scoped arguments and workspace access.' };
|
|
24
|
-
}
|
|
9
|
+
import { safeToolFailure, toolFailureStage } from '../tools/diagnostics.js';
|
|
25
10
|
/** Diagnose registered tools without creating a Broker, Run, request, alarm, Agent session or verdict. */
|
|
26
11
|
export async function diagnoseArtifactTools({ repoPath, mode = 'copy', stateDir, artifactId, audience, toolName, arguments: args, execute = false, signal }) {
|
|
27
12
|
const report = { ok: false, status: 'NOT_READY', mode, checkedAt: new Date().toISOString(), checks: [], tools: [] };
|
|
28
13
|
let workspace;
|
|
14
|
+
let stage = 'preflight';
|
|
29
15
|
try {
|
|
30
16
|
if ((audience !== undefined && audience !== 'agent' && audience !== 'human') || (execute && (!artifactId || !audience || !toolName)) || (!execute && args !== undefined))
|
|
31
17
|
throw new Error('Actual tool execution requires explicit Artifact, audience and tool selection.');
|
|
32
18
|
signal?.throwIfAborted();
|
|
19
|
+
stage = 'snapshot';
|
|
33
20
|
const context = await localContext({ repoPath, stateDir });
|
|
34
21
|
workspace = await prepareWorkspace({ repoPath: context.repoPath, stateDir: context.stateDir, mode, signal });
|
|
35
22
|
const worktreePath = workspace.descriptor.path;
|
|
36
23
|
report.snapshotHash = workspace.descriptor.hash;
|
|
37
24
|
// Cached copies are retained: a desktop viewer can continue reading after its launcher exits.
|
|
38
25
|
report.workspacePath = worktreePath;
|
|
26
|
+
stage = 'preflight';
|
|
39
27
|
const { config } = await readWorkspaceConfig(worktreePath);
|
|
40
28
|
const { configManifest } = config;
|
|
41
29
|
if (artifactId !== undefined && !Object.hasOwn(config.artifacts, artifactId))
|
|
42
30
|
throw new Error('Unknown selected Artifact.');
|
|
43
31
|
if (execute && artifactId !== undefined && isArtifactGroup(config.artifacts[artifactId])) {
|
|
44
|
-
report.checks.push({ artifactId, ok: false, message: 'Groups collect member tools. Select a leaf Artifact with --artifact to execute its tool.' });
|
|
32
|
+
report.checks.push({ artifactId, stage, ok: false, code: 'ARTIFACT_GROUP_NOT_EXECUTABLE', message: 'Groups collect member tools. Select a leaf Artifact with --artifact to execute its tool.' });
|
|
45
33
|
return report;
|
|
46
34
|
}
|
|
47
35
|
const selectedScope = resolveArtifactScope(config.artifacts, artifactId === undefined ? Object.keys(config.artifacts) : [artifactId]);
|
|
@@ -54,18 +42,21 @@ export async function diagnoseArtifactTools({ repoPath, mode = 'copy', stateDir,
|
|
|
54
42
|
assertArtifactAudience({ profile: critic.profile, ...resolveArtifactScope(config.artifacts, [critic.target, ...critic.deps]), artifactTypes: config.artifactTypes, configManifest });
|
|
55
43
|
}
|
|
56
44
|
catch (error) {
|
|
57
|
-
report.checks.push({ ok: false, ...
|
|
45
|
+
report.checks.push({ stage, ok: false, ...safeToolFailure(error) });
|
|
58
46
|
}
|
|
59
47
|
}
|
|
60
48
|
}
|
|
61
49
|
for (const targetAudience of audience ? [audience] : ['agent', 'human']) {
|
|
50
|
+
stage = 'preflight';
|
|
62
51
|
const registry = await createReviewTools({ worktreePath, ...selectedScope, artifactTypes: config.artifactTypes, configManifest, audience: targetAudience, runDir: join(context.stateDir, 'tool-check', randomUUID()), signal: workspace.signal });
|
|
52
|
+
if (execute && targetAudience === audience && registry.outputDir)
|
|
53
|
+
report.outputDir = registry.outputDir;
|
|
63
54
|
try {
|
|
64
55
|
// Explicit Artifact selection makes the short operation name unambiguous; published names win.
|
|
65
56
|
const resolvedToolName = toolName === undefined || registry.tools.some(tool => tool.name === toolName) || artifactId === undefined ? toolName : `${toolName}_${artifactId}`;
|
|
66
57
|
const definitions = registry.tools.filter(tool => resolvedToolName === undefined || tool.name === resolvedToolName);
|
|
67
58
|
if (toolName !== undefined && !definitions.length) {
|
|
68
|
-
report.checks.push({ artifactId, audience: targetAudience, toolName, ok: false, message: 'The selected tool is not registered for this Artifact and reviewer kind.' });
|
|
59
|
+
report.checks.push({ artifactId, audience: targetAudience, toolName, stage, ok: false, code: 'ARTIFACT_TOOL_NOT_REGISTERED', message: 'The selected tool is not registered for this Artifact and reviewer kind.' });
|
|
69
60
|
continue;
|
|
70
61
|
}
|
|
71
62
|
report.tools.push(...definitions.map(tool => ({ ...tool, audience: targetAudience })));
|
|
@@ -73,21 +64,31 @@ export async function diagnoseArtifactTools({ repoPath, mode = 'copy', stateDir,
|
|
|
73
64
|
if (definitions.some(tool => tool.artifactId === artifact.id))
|
|
74
65
|
continue;
|
|
75
66
|
const required = audience !== undefined || config.critics.some(critic => critic.profile.kind === targetAudience && resolveArtifactScope(config.artifacts, [critic.target, ...critic.deps]).artifacts.some(leaf => leaf.id === artifact.id));
|
|
76
|
-
report.checks.push({ artifactId: artifact.id, audience: targetAudience, ok: !required, message: `No ${targetAudience} tools are available for this Artifact. It cannot be used by a ${targetAudience} Critic.` });
|
|
67
|
+
report.checks.push({ artifactId: artifact.id, audience: targetAudience, stage, ok: !required, ...(required ? { code: 'ARTIFACT_TOOLS_UNAVAILABLE' } : {}), message: `No ${targetAudience} tools are available for this Artifact. It cannot be used by a ${targetAudience} Critic.` });
|
|
77
68
|
}
|
|
78
|
-
report.checks.push(...(await registry.preflight({ toolName: resolvedToolName })).map(check => ({ ...check, audience: targetAudience })));
|
|
69
|
+
report.checks.push(...(await registry.preflight({ toolName: resolvedToolName })).map(check => ({ ...check, ...(!check.ok ? safeToolFailure({ code: check.code ?? 'ARTIFACT_TOOL_PREFLIGHT_FAILED' }) : {}), stage: 'preflight', audience: targetAudience })));
|
|
79
70
|
if (execute && targetAudience === audience && definitions.length === 1 && report.checks.every(check => check.ok)) {
|
|
71
|
+
registry.validateArguments(definitions[0].name, args ?? {});
|
|
72
|
+
stage = 'input-integrity';
|
|
80
73
|
await workspace.assertUnchanged();
|
|
74
|
+
stage = 'execute';
|
|
81
75
|
const result = await registry.call(definitions[0].name, args ?? {});
|
|
76
|
+
stage = 'input-integrity';
|
|
82
77
|
await workspace.assertUnchanged();
|
|
83
78
|
report.result = result;
|
|
84
|
-
report.checks.push({ artifactId, audience, toolName: definitions[0].name, ok: true, message: 'The selected registered tool completed successfully. No review result was created.' });
|
|
79
|
+
report.checks.push({ artifactId, audience, toolName: definitions[0].name, stage: 'execute', ok: true, message: 'The selected registered tool completed successfully. No review result was created.' });
|
|
85
80
|
}
|
|
86
81
|
}
|
|
87
82
|
finally {
|
|
88
|
-
|
|
83
|
+
try {
|
|
84
|
+
await registry.close();
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
report.checks.push({ artifactId, audience: targetAudience, toolName, stage, ok: false, ...safeToolFailure(error) });
|
|
88
|
+
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
stage = 'input-integrity';
|
|
91
92
|
await workspace.assertUnchanged();
|
|
92
93
|
}
|
|
93
94
|
catch (error) {
|
|
@@ -95,16 +96,18 @@ export async function diagnoseArtifactTools({ repoPath, mode = 'copy', stateDir,
|
|
|
95
96
|
// A mutated workspace can abort a running program before its boundary check resumes.
|
|
96
97
|
// Preserve that integrity failure instead of relabeling it as an ordinary cancellation.
|
|
97
98
|
const reason = workspace?.signal.aborted && !signal?.aborted ? workspace.signal.reason : error;
|
|
98
|
-
report.checks.push({ artifactId, audience, toolName, ok: false, ...
|
|
99
|
+
report.checks.push({ artifactId, audience, toolName, stage: toolFailureStage(reason, stage), ok: false, ...safeToolFailure(reason, signal?.aborted ?? false) });
|
|
99
100
|
}
|
|
100
101
|
finally {
|
|
101
102
|
try {
|
|
102
103
|
await workspace?.close();
|
|
103
104
|
}
|
|
104
105
|
catch {
|
|
105
|
-
report.checks.push({ ok: false, code: 'WORKSPACE_CLEANUP_FAILED', message: 'Could not finish workspace observation cleanup.' });
|
|
106
|
+
report.checks.push({ stage: 'input-integrity', ok: false, code: 'WORKSPACE_CLEANUP_FAILED', message: 'Could not finish workspace observation cleanup.' });
|
|
106
107
|
}
|
|
107
108
|
report.ok = report.checks.length > 0 && report.checks.every(check => check.ok);
|
|
109
|
+
if (!report.ok)
|
|
110
|
+
delete report.result;
|
|
108
111
|
report.status = report.ok ? 'READY' : 'NOT_READY';
|
|
109
112
|
report.checkedAt = new Date().toISOString();
|
|
110
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-check.js","sourceRoot":"","sources":["../../../src/artifacts/tool-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAA4C,MAAM,wBAAwB,CAAC;AAEpG,OAAO,EAAE,iBAAiB,EAA6B,MAAM,oBAAoB,CAAC;AAElF,OAAO,EAAE,sBAAsB,EAAyB,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-check.js","sourceRoot":"","sources":["../../../src/artifacts/tool-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAA4C,MAAM,wBAAwB,CAAC;AAEpG,OAAO,EAAE,iBAAiB,EAA6B,MAAM,oBAAoB,CAAC;AAElF,OAAO,EAAE,sBAAsB,EAAyB,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAA+B,MAAM,yBAAyB,CAAC;AAoCzG,0GAA0G;AAC1G,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,EAAE,QAAQ,EA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AAC,CAAC;IAClK,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YAAC,MAAM,SAAS,EAAE,KAAK,EAAE,CAAC;QAAC,CAAC;QACjC,MAAM,CAAC;YAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,0BAA0B,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAC,CAAC;QAAC,CAAC;QACpK,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/E,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,MAAM,CAAC,MAAM,CAAC;QACrC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC;QAClD,MAAM,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReviewRequest } from '../contracts.js';
|
|
2
|
-
import type { HumanPreparation } from '../executors/human-preparation.js';
|
|
2
|
+
import type { HumanPreparation, HumanPreparationPhase, HumanPreparationProgress } from '../executors/human-preparation.js';
|
|
3
|
+
import type { WorkspaceScanProgress } from '../workspaces/index.js';
|
|
3
4
|
export declare const HUMAN_PREPARATION_LEASE_MS = 120000;
|
|
4
5
|
export interface HumanTryClaim {
|
|
5
6
|
id: string;
|
|
@@ -7,6 +8,22 @@ export interface HumanTryClaim {
|
|
|
7
8
|
startedAt: string;
|
|
8
9
|
expiresAt: string;
|
|
9
10
|
}
|
|
11
|
+
export interface HumanPreparationAttempt extends HumanTryClaim {
|
|
12
|
+
status: 'preparing' | 'released' | 'expired' | 'claimed';
|
|
13
|
+
heartbeatAt: string;
|
|
14
|
+
phase: HumanPreparationPhase;
|
|
15
|
+
phaseStartedAt: string;
|
|
16
|
+
completedAt?: string;
|
|
17
|
+
previousAttemptId?: string;
|
|
18
|
+
timings: {
|
|
19
|
+
phase: HumanPreparationPhase;
|
|
20
|
+
startedAt: string;
|
|
21
|
+
completedAt: string;
|
|
22
|
+
durationMs: number;
|
|
23
|
+
}[];
|
|
24
|
+
progress?: WorkspaceScanProgress;
|
|
25
|
+
failureCode?: 'cancelled' | 'checks-failed' | 'input-invalid' | 'preparation-failed';
|
|
26
|
+
}
|
|
10
27
|
export declare function activeTryClaim(request: Pick<ReviewRequest, 'tryClaim'>, at?: number): HumanTryClaim | undefined;
|
|
11
28
|
interface ClaimStore {
|
|
12
29
|
transaction<T>(action: () => T): T;
|
|
@@ -20,7 +37,8 @@ interface ClaimStore {
|
|
|
20
37
|
export declare function createHumanClaims(store: ClaimStore): {
|
|
21
38
|
begin(id: string, reviewerId: string, leaseMs?: number): HumanTryClaim;
|
|
22
39
|
renew(id: string, reviewerId: string, attemptId: string, leaseMs?: number): HumanTryClaim;
|
|
23
|
-
|
|
40
|
+
progress(id: string, reviewerId: string, attemptId: string, update: HumanPreparationProgress): void;
|
|
41
|
+
release(id: string, reviewerId: string, attemptId: string, failureCode?: HumanPreparationAttempt['failureCode']): boolean;
|
|
24
42
|
confirm(id: string, reviewerId: string, attemptId: string, preparation: HumanPreparation): ReviewRequest;
|
|
25
43
|
};
|
|
26
44
|
export {};
|
|
@@ -6,6 +6,10 @@ export function activeTryClaim(request, at = Date.now()) {
|
|
|
6
6
|
}
|
|
7
7
|
/** All assignment transitions compare a persisted attempt inside one transaction. */
|
|
8
8
|
export function createHumanClaims(store) {
|
|
9
|
+
const finishPhase = (preparation, at) => {
|
|
10
|
+
preparation.timings.push({ phase: preparation.phase, startedAt: preparation.phaseStartedAt, completedAt: at, durationMs: Math.max(0, Date.parse(at) - Date.parse(preparation.phaseStartedAt)) });
|
|
11
|
+
preparation.timings = preparation.timings.slice(-12);
|
|
12
|
+
};
|
|
9
13
|
const waiting = (id, reviewerId) => {
|
|
10
14
|
if (typeof reviewerId !== 'string' || !reviewerId.trim() || reviewerId.length > 200)
|
|
11
15
|
throw new Error('A reviewerId is required.');
|
|
@@ -36,11 +40,14 @@ export function createHumanClaims(store) {
|
|
|
36
40
|
throw new Error('This review is already claimed by a reviewer.');
|
|
37
41
|
if (activeTryClaim(request))
|
|
38
42
|
throw new Error('This review is being prepared by another claim attempt.');
|
|
43
|
+
const previousAttemptId = request.tryClaim?.id ?? request.preparationAttempt?.id;
|
|
39
44
|
if (request.tryClaim)
|
|
40
|
-
store.event(request, 'human.claim.expired',
|
|
41
|
-
|
|
45
|
+
store.event(request, 'human.claim.expired', `Preparation attempt ${request.tryClaim.id} expired.`);
|
|
46
|
+
const startedAt = new Date().toISOString();
|
|
47
|
+
request.tryClaim = { id: randomUUID(), reviewerId, startedAt, expiresAt: new Date(Date.now() + duration).toISOString() };
|
|
48
|
+
request.preparationAttempt = { ...request.tryClaim, status: 'preparing', heartbeatAt: startedAt, phase: 'validating-input', phaseStartedAt: startedAt, timings: [], ...(previousAttemptId ? { previousAttemptId } : {}) };
|
|
42
49
|
store.save(request);
|
|
43
|
-
store.event(request, 'human.claim.preparing',
|
|
50
|
+
store.event(request, 'human.claim.preparing', `Human preparation attempt ${request.tryClaim.id} started${previousAttemptId ? ` after ${previousAttemptId}` : ''}.`);
|
|
44
51
|
return structuredClone(request.tryClaim);
|
|
45
52
|
});
|
|
46
53
|
store.changed();
|
|
@@ -51,20 +58,53 @@ export function createHumanClaims(store) {
|
|
|
51
58
|
const result = store.transaction(() => {
|
|
52
59
|
const request = attempt(id, reviewerId, attemptId);
|
|
53
60
|
request.tryClaim.expiresAt = new Date(Date.now() + duration).toISOString();
|
|
61
|
+
if (request.preparationAttempt?.id === attemptId) {
|
|
62
|
+
request.preparationAttempt.expiresAt = request.tryClaim.expiresAt;
|
|
63
|
+
request.preparationAttempt.heartbeatAt = new Date().toISOString();
|
|
64
|
+
}
|
|
54
65
|
store.save(request);
|
|
55
66
|
return structuredClone(request.tryClaim);
|
|
56
67
|
});
|
|
57
68
|
store.changed();
|
|
58
69
|
return result;
|
|
59
70
|
},
|
|
60
|
-
|
|
71
|
+
progress(id, reviewerId, attemptId, update) {
|
|
72
|
+
store.transaction(() => {
|
|
73
|
+
const request = attempt(id, reviewerId, attemptId), preparation = request.preparationAttempt;
|
|
74
|
+
if (!preparation || preparation.id !== attemptId)
|
|
75
|
+
return;
|
|
76
|
+
const at = new Date().toISOString();
|
|
77
|
+
if (preparation.phase !== update.phase) {
|
|
78
|
+
finishPhase(preparation, at);
|
|
79
|
+
preparation.phase = update.phase;
|
|
80
|
+
preparation.phaseStartedAt = at;
|
|
81
|
+
if (update.phase !== 'confirming-assignment')
|
|
82
|
+
delete preparation.progress;
|
|
83
|
+
}
|
|
84
|
+
preparation.heartbeatAt = at;
|
|
85
|
+
if (update.progress)
|
|
86
|
+
preparation.progress = { ...update.progress };
|
|
87
|
+
store.save(request);
|
|
88
|
+
});
|
|
89
|
+
store.changed();
|
|
90
|
+
},
|
|
91
|
+
release(id, reviewerId, attemptId, failureCode) {
|
|
61
92
|
const released = store.transaction(() => {
|
|
62
93
|
const request = store.read(id);
|
|
63
94
|
if (!request || request.status !== 'WAITING_HUMAN' || request.claimedBy || request.tryClaim?.id !== attemptId || request.tryClaim.reviewerId !== reviewerId)
|
|
64
95
|
return false;
|
|
96
|
+
const expired = !activeTryClaim(request);
|
|
97
|
+
if (request.preparationAttempt?.id === attemptId) {
|
|
98
|
+
const preparation = request.preparationAttempt;
|
|
99
|
+
preparation.status = expired ? 'expired' : 'released';
|
|
100
|
+
preparation.completedAt = expired ? preparation.expiresAt : new Date().toISOString();
|
|
101
|
+
if (failureCode)
|
|
102
|
+
preparation.failureCode = failureCode;
|
|
103
|
+
finishPhase(preparation, preparation.completedAt);
|
|
104
|
+
}
|
|
65
105
|
delete request.tryClaim;
|
|
66
106
|
store.save(request);
|
|
67
|
-
store.event(request, 'human.claim.released',
|
|
107
|
+
store.event(request, expired ? 'human.claim.expired' : 'human.claim.released', `Human preparation attempt ${attemptId} ${expired ? 'expired' : 'was released'}; retry Claim when ready.`);
|
|
68
108
|
return true;
|
|
69
109
|
});
|
|
70
110
|
if (released)
|
|
@@ -91,6 +131,11 @@ export function createHumanClaims(store) {
|
|
|
91
131
|
request.claimedBy = reviewerId;
|
|
92
132
|
request.claimedAt = new Date().toISOString();
|
|
93
133
|
request.claimAttemptId = attemptId;
|
|
134
|
+
if (request.preparationAttempt?.id === attemptId) {
|
|
135
|
+
request.preparationAttempt.status = 'claimed';
|
|
136
|
+
request.preparationAttempt.completedAt = request.claimedAt;
|
|
137
|
+
finishPhase(request.preparationAttempt, request.claimedAt);
|
|
138
|
+
}
|
|
94
139
|
delete request.tryClaim;
|
|
95
140
|
store.save(request);
|
|
96
141
|
store.event(request, 'human.claimed', `Review claimed by ${reviewerId}.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"human-claims.js","sourceRoot":"","sources":["../../../src/broker/human-claims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"human-claims.js","sourceRoot":"","sources":["../../../src/broker/human-claims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAkBlD,MAAM,UAAU,cAAc,CAAC,OAAwC,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;IACtF,OAAO,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,CA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S,CAAC;gBACnC,IAAI,OAAO,CAAC,kBAAkB,EAAE,EAAE,KAAK,SAAS,EAAE,CAAC;oBACjD,OAAO,CAAC,kBAAkB,CAAC,MAAM,GAAG,SAAS,CAAC;oBAAC,OAAO,CAAC,kBAAkB,CAAC,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;oBAC1G,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;gBAC7D,CAAC;gBACD,OAAO,OAAO,CAAC,QAAQ,CAAC;gBACxB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,qBAAqB,UAAU,GAAG,CAAC,CAAC;gBAC/F,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,OAAO,EAAE,CAAC;YAAC,OAAO,MAAM,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -140,6 +140,7 @@ export declare function createBroker({ repoPath, stateDir, repoId, executors, wo
|
|
|
140
140
|
claimedBy?: string | null;
|
|
141
141
|
claimedAt?: string | null;
|
|
142
142
|
tryClaim?: import("./human-claims.js").HumanTryClaim;
|
|
143
|
+
preparationAttempt?: import("./human-claims.js").HumanPreparationAttempt;
|
|
143
144
|
claimAttemptId?: string;
|
|
144
145
|
notifiedAt?: string | null;
|
|
145
146
|
errorCode?: string | null;
|
|
@@ -157,7 +158,7 @@ export declare function createBroker({ repoPath, stateDir, repoId, executors, wo
|
|
|
157
158
|
leaseMs?: number;
|
|
158
159
|
}): import("./human-claims.js").HumanTryClaim;
|
|
159
160
|
renewHumanTryClaim: (id: string, reviewerId: string, attemptId: string, leaseMs?: number) => import("./human-claims.js").HumanTryClaim;
|
|
160
|
-
releaseHumanTryClaim: (id: string, reviewerId: string, attemptId: string) => boolean;
|
|
161
|
+
releaseHumanTryClaim: (id: string, reviewerId: string, attemptId: string, failureCode?: import("./human-claims.js").HumanPreparationAttempt['failureCode']) => boolean;
|
|
161
162
|
confirmHumanClaim: (id: string, reviewerId: string, attemptId: string, preparation: import("../executors/human-preparation.js").HumanPreparation) => ReviewRequest;
|
|
162
163
|
claimHuman(requestId: string, reviewerId: unknown, { signal }?: {
|
|
163
164
|
signal?: AbortSignal;
|
package/dist/src/broker/index.js
CHANGED
|
@@ -795,14 +795,16 @@ export function createBroker({ repoPath, stateDir, repoId = 'demo', executors, w
|
|
|
795
795
|
catch (error) {
|
|
796
796
|
controller.abort(error);
|
|
797
797
|
}
|
|
798
|
-
}, HUMAN_PREPARATION_LEASE_MS / 3);
|
|
798
|
+
}, Math.min(5_000, HUMAN_PREPARATION_LEASE_MS / 3));
|
|
799
799
|
try {
|
|
800
|
-
const prepared = await prepareHumanReview(request, request.workspace, path.join(stateDir, 'runs', request.runId, request.id, 'preparation', attempt.id), executionSignal);
|
|
800
|
+
const prepared = await prepareHumanReview(request, request.workspace, path.join(stateDir, 'runs', request.runId, request.id, 'preparation', attempt.id), executionSignal, progress => humanClaims.progress(requestId, reviewerId, attempt.id, progress));
|
|
801
801
|
executionSignal.throwIfAborted();
|
|
802
|
+
humanClaims.progress(requestId, reviewerId, attempt.id, { phase: 'confirming-assignment' });
|
|
802
803
|
return humanClaims.confirm(requestId, reviewerId, attempt.id, prepared);
|
|
803
804
|
}
|
|
804
805
|
catch (error) {
|
|
805
|
-
|
|
806
|
+
const code = errorCode(error);
|
|
807
|
+
humanClaims.release(requestId, reviewerId, attempt.id, signal?.aborted ? 'cancelled' : code === 'HUMAN_PREPARATION_FAILED' ? 'checks-failed' : typeof code === 'string' && code.startsWith('WORKSPACE_') ? 'input-invalid' : 'preparation-failed');
|
|
806
808
|
throw error;
|
|
807
809
|
}
|
|
808
810
|
finally {
|