@mcoda/codali 0.1.135-codali.2 → 0.1.135-codali.29
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 +53 -0
- package/ORCHESTRATION.md +308 -2
- package/README.md +184 -7
- package/config/AGENTS.md +11 -0
- package/config/deterministic/install-python.mjs +16 -0
- package/config/deterministic/node-worker.mjs +77 -0
- package/config/deterministic/python-worker.py +222 -0
- package/config/deterministic/requirements.txt +6 -0
- package/config/docdex-tools-0.2.99.json +3977 -0
- package/config/documents/install-python.mjs +16 -0
- package/config/documents/requirements.txt +10 -0
- package/config/documents/worker.py +267 -0
- package/config/orchestration.schema.json +94 -3
- package/config/skills/planning/SKILL.md +13 -0
- package/config/terminal-long-scenarios.v1.json +3 -2
- package/dist/cli/TerminalArtifacts.d.ts +5 -0
- package/dist/cli/TerminalArtifacts.d.ts.map +1 -0
- package/dist/cli/TerminalArtifacts.js +26 -0
- package/dist/cli/TerminalCommand.d.ts.map +1 -1
- package/dist/cli/TerminalCommand.js +411 -75
- package/dist/cli/TerminalCredentials.js +2 -2
- package/dist/cli/TerminalInput.d.ts +13 -0
- package/dist/cli/TerminalInput.d.ts.map +1 -1
- package/dist/cli/TerminalInput.js +55 -7
- package/dist/cli/TerminalModels.d.ts +6 -0
- package/dist/cli/TerminalModels.d.ts.map +1 -0
- package/dist/cli/TerminalModels.js +45 -0
- package/dist/cli/TerminalPlan.d.ts +40 -0
- package/dist/cli/TerminalPlan.d.ts.map +1 -0
- package/dist/cli/TerminalPlan.js +37 -0
- package/dist/cli/ToolsCommand.d.ts.map +1 -1
- package/dist/cli/ToolsCommand.js +8 -1
- package/dist/cli/tui/TerminalCells.d.ts +6 -0
- package/dist/cli/tui/TerminalCells.d.ts.map +1 -0
- package/dist/cli/tui/TerminalCells.js +47 -0
- package/dist/cli/tui/TerminalEditor.d.ts +22 -0
- package/dist/cli/tui/TerminalEditor.d.ts.map +1 -0
- package/dist/cli/tui/TerminalEditor.js +88 -0
- package/dist/cli/tui/TerminalLogo.d.ts +6 -0
- package/dist/cli/tui/TerminalLogo.d.ts.map +1 -0
- package/dist/cli/tui/TerminalLogo.js +26 -0
- package/dist/cli/tui/TerminalMarkdown.d.ts +5 -0
- package/dist/cli/tui/TerminalMarkdown.d.ts.map +1 -0
- package/dist/cli/tui/TerminalMarkdown.js +118 -0
- package/dist/cli/tui/TerminalPresentation.d.ts +4 -0
- package/dist/cli/tui/TerminalPresentation.d.ts.map +1 -0
- package/dist/cli/tui/TerminalPresentation.js +77 -0
- package/dist/cli/tui/TerminalScreen.d.ts +50 -0
- package/dist/cli/tui/TerminalScreen.d.ts.map +1 -0
- package/dist/cli/tui/TerminalScreen.js +137 -0
- package/dist/cli/tui/TerminalSelection.d.ts +15 -0
- package/dist/cli/tui/TerminalSelection.d.ts.map +1 -0
- package/dist/cli/tui/TerminalSelection.js +38 -0
- package/dist/cli/tui/TerminalTui.d.ts +82 -0
- package/dist/cli/tui/TerminalTui.d.ts.map +1 -0
- package/dist/cli/tui/TerminalTui.js +553 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -3
- package/dist/config/OrchestrationConfig.d.ts +33 -0
- package/dist/config/OrchestrationConfig.d.ts.map +1 -1
- package/dist/config/OrchestrationConfig.js +59 -1
- package/dist/connectors/media/MediaJobStore.d.ts +2 -1
- package/dist/connectors/media/MediaJobStore.d.ts.map +1 -1
- package/dist/connectors/media/MediaJobStore.js +11 -3
- package/dist/docdex/DocdexCatalog.d.ts +12 -0
- package/dist/docdex/DocdexCatalog.d.ts.map +1 -0
- package/dist/docdex/DocdexCatalog.js +30 -0
- package/dist/docdex/DocdexClient.d.ts +8 -2
- package/dist/docdex/DocdexClient.d.ts.map +1 -1
- package/dist/docdex/DocdexClient.js +86 -11
- package/dist/docdex/ManagedDocdex.d.ts +1 -0
- package/dist/docdex/ManagedDocdex.d.ts.map +1 -1
- package/dist/docdex/ManagedDocdex.js +25 -4
- package/dist/eval/TerminalWorkflowCorpus.d.ts +1 -1
- package/dist/eval/TerminalWorkflowCorpus.d.ts.map +1 -1
- package/dist/eval/TerminalWorkflowCorpus.js +9 -6
- package/dist/eval/TrustBenchmark.d.ts +94 -0
- package/dist/eval/TrustBenchmark.d.ts.map +1 -0
- package/dist/eval/TrustBenchmark.js +199 -0
- package/dist/eval/fixtures/ContractReviewProvider.d.ts +4 -0
- package/dist/eval/fixtures/ContractReviewProvider.d.ts.map +1 -0
- package/dist/eval/fixtures/ContractReviewProvider.js +10 -0
- package/dist/eval/fixtures/MixedMediaRecoveryJourney.d.ts +6 -0
- package/dist/eval/fixtures/MixedMediaRecoveryJourney.d.ts.map +1 -0
- package/dist/eval/fixtures/MixedMediaRecoveryJourney.js +145 -0
- package/dist/eval/fixtures/TerminalRecoveryJourney.d.ts.map +1 -1
- package/dist/eval/fixtures/TerminalRecoveryJourney.js +14 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/permissions/PermissionGate.d.ts +1 -1
- package/dist/permissions/PermissionGate.d.ts.map +1 -1
- package/dist/permissions/PermissionGate.js +40 -2
- package/dist/permissions/WorkspacePermissions.d.ts +11 -0
- package/dist/permissions/WorkspacePermissions.d.ts.map +1 -0
- package/dist/permissions/WorkspacePermissions.js +42 -0
- package/dist/providers/ConfiguredModelScope.d.ts +1 -0
- package/dist/providers/ConfiguredModelScope.d.ts.map +1 -1
- package/dist/providers/ConfiguredModelScope.js +17 -1
- package/dist/providers/ConfiguredProvider.d.ts +5 -0
- package/dist/providers/ConfiguredProvider.d.ts.map +1 -1
- package/dist/providers/ConfiguredProvider.js +38 -5
- package/dist/providers/ModelServiceError.d.ts +7 -2
- package/dist/providers/ModelServiceError.d.ts.map +1 -1
- package/dist/providers/ModelServiceError.js +28 -4
- package/dist/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
- package/dist/providers/OpenAiCompatibleProvider.js +9 -1
- package/dist/providers/ProviderTypes.d.ts +2 -0
- package/dist/providers/ProviderTypes.d.ts.map +1 -1
- package/dist/providers/RequestUsage.d.ts +11 -0
- package/dist/providers/RequestUsage.d.ts.map +1 -0
- package/dist/providers/RequestUsage.js +33 -0
- package/dist/runtime/CodaliRuntime.d.ts +1 -0
- package/dist/runtime/CodaliRuntime.d.ts.map +1 -1
- package/dist/runtime/CodaliRuntime.js +1 -0
- package/dist/runtime/ComputedAnswer.d.ts +13 -0
- package/dist/runtime/ComputedAnswer.d.ts.map +1 -0
- package/dist/runtime/ComputedAnswer.js +75 -0
- package/dist/runtime/ContextCompression.d.ts +22 -0
- package/dist/runtime/ContextCompression.d.ts.map +1 -0
- package/dist/runtime/ContextCompression.js +53 -0
- package/dist/runtime/InspectionBudget.d.ts +8 -0
- package/dist/runtime/InspectionBudget.d.ts.map +1 -0
- package/dist/runtime/InspectionBudget.js +25 -0
- package/dist/runtime/InteractionContract.d.ts +42 -0
- package/dist/runtime/InteractionContract.d.ts.map +1 -0
- package/dist/runtime/InteractionContract.js +50 -0
- package/dist/runtime/InteractionRouter.d.ts +71 -0
- package/dist/runtime/InteractionRouter.d.ts.map +1 -0
- package/dist/runtime/InteractionRouter.js +134 -0
- package/dist/runtime/PreparedDocdex.d.ts +4 -0
- package/dist/runtime/PreparedDocdex.d.ts.map +1 -0
- package/dist/runtime/PreparedDocdex.js +55 -0
- package/dist/runtime/PreparedMemory.d.ts +3 -0
- package/dist/runtime/PreparedMemory.d.ts.map +1 -0
- package/dist/runtime/PreparedMemory.js +30 -0
- package/dist/runtime/ReviewContract.d.ts +35 -0
- package/dist/runtime/ReviewContract.d.ts.map +1 -0
- package/dist/runtime/ReviewContract.js +132 -0
- package/dist/runtime/ReviewCoordinator.d.ts +41 -0
- package/dist/runtime/ReviewCoordinator.d.ts.map +1 -0
- package/dist/runtime/ReviewCoordinator.js +132 -0
- package/dist/runtime/ReviewSource.d.ts +3 -0
- package/dist/runtime/ReviewSource.d.ts.map +1 -1
- package/dist/runtime/ReviewSource.js +17 -1
- package/dist/runtime/Runner.d.ts.map +1 -1
- package/dist/runtime/Runner.js +6 -1
- package/dist/runtime/SessionController.d.ts +51 -1
- package/dist/runtime/SessionController.d.ts.map +1 -1
- package/dist/runtime/SessionController.js +1146 -112
- package/dist/runtime/TaskReview.d.ts +25 -0
- package/dist/runtime/TaskReview.d.ts.map +1 -0
- package/dist/runtime/TaskReview.js +109 -0
- package/dist/runtime/TaskReviewContext.d.ts +37 -0
- package/dist/runtime/TaskReviewContext.d.ts.map +1 -1
- package/dist/runtime/TaskReviewContext.js +18 -2
- package/dist/runtime/UsageReconciliation.d.ts +28 -0
- package/dist/runtime/UsageReconciliation.d.ts.map +1 -0
- package/dist/runtime/UsageReconciliation.js +68 -0
- package/dist/runtime/VerificationCommand.d.ts +2 -0
- package/dist/runtime/VerificationCommand.d.ts.map +1 -1
- package/dist/runtime/VerificationCommand.js +28 -0
- package/dist/runtime/VerificationReceiptSelection.d.ts +15 -0
- package/dist/runtime/VerificationReceiptSelection.d.ts.map +1 -0
- package/dist/runtime/VerificationReceiptSelection.js +30 -0
- package/dist/session/AtomicState.d.ts.map +1 -1
- package/dist/session/AtomicState.js +15 -1
- package/dist/session/InstructionLoader.d.ts +5 -1
- package/dist/session/InstructionLoader.d.ts.map +1 -1
- package/dist/session/InstructionLoader.js +65 -19
- package/dist/session/SessionStoragePath.d.ts.map +1 -1
- package/dist/session/SessionStoragePath.js +28 -16
- package/dist/session/SessionStore.d.ts +5 -1
- package/dist/session/SessionStore.d.ts.map +1 -1
- package/dist/session/SessionStore.js +11 -2
- package/dist/session/SkillCatalog.d.ts +33 -0
- package/dist/session/SkillCatalog.d.ts.map +1 -0
- package/dist/session/SkillCatalog.js +194 -0
- package/dist/session/WorkState.d.ts +9 -0
- package/dist/session/WorkState.d.ts.map +1 -1
- package/dist/session/WorkState.js +32 -0
- package/dist/session/WorkTypes.d.ts +8 -0
- package/dist/session/WorkTypes.d.ts.map +1 -1
- package/dist/tools/SemanticToolRetrieval.d.ts +19 -0
- package/dist/tools/SemanticToolRetrieval.d.ts.map +1 -0
- package/dist/tools/SemanticToolRetrieval.js +52 -0
- package/dist/tools/ToolRetrieval.d.ts +7 -0
- package/dist/tools/ToolRetrieval.d.ts.map +1 -0
- package/dist/tools/ToolRetrieval.js +25 -0
- package/dist/tools/browser/BrowserTool.d.ts +9 -0
- package/dist/tools/browser/BrowserTool.d.ts.map +1 -0
- package/dist/tools/browser/BrowserTool.js +152 -0
- package/dist/tools/browser/BrowserWorker.d.ts +2 -0
- package/dist/tools/browser/BrowserWorker.d.ts.map +1 -0
- package/dist/tools/browser/BrowserWorker.js +51 -0
- package/dist/tools/calculation/CalculatorTool.d.ts +5 -0
- package/dist/tools/calculation/CalculatorTool.d.ts.map +1 -0
- package/dist/tools/calculation/CalculatorTool.js +137 -0
- package/dist/tools/deterministic/DeterministicRuntime.d.ts +39 -0
- package/dist/tools/deterministic/DeterministicRuntime.d.ts.map +1 -0
- package/dist/tools/deterministic/DeterministicRuntime.js +98 -0
- package/dist/tools/deterministic/DeterministicTools.d.ts +8 -0
- package/dist/tools/deterministic/DeterministicTools.d.ts.map +1 -0
- package/dist/tools/deterministic/DeterministicTools.js +86 -0
- package/dist/tools/deterministic/node-worker.cjs +38 -0
- package/dist/tools/deterministic/python-worker.py +222 -0
- package/dist/tools/docdex/DocdexCatalogTools.d.ts +4 -0
- package/dist/tools/docdex/DocdexCatalogTools.d.ts.map +1 -0
- package/dist/tools/docdex/DocdexCatalogTools.js +58 -0
- package/dist/tools/docdex/DocdexTools.d.ts +2 -0
- package/dist/tools/docdex/DocdexTools.d.ts.map +1 -1
- package/dist/tools/docdex/DocdexTools.js +72 -105
- package/dist/tools/documents/DocumentRuntime.d.ts +12 -0
- package/dist/tools/documents/DocumentRuntime.d.ts.map +1 -0
- package/dist/tools/documents/DocumentRuntime.js +59 -0
- package/dist/tools/documents/DocumentTools.d.ts +19 -0
- package/dist/tools/documents/DocumentTools.d.ts.map +1 -0
- package/dist/tools/documents/DocumentTools.js +150 -0
- package/dist/tools/documents/worker.py +267 -0
- package/dist/tools/entities/AdesTool.d.ts +7 -0
- package/dist/tools/entities/AdesTool.d.ts.map +1 -0
- package/dist/tools/entities/AdesTool.js +59 -0
- package/dist/tools/research/TnlTool.d.ts +22 -0
- package/dist/tools/research/TnlTool.d.ts.map +1 -0
- package/dist/tools/research/TnlTool.js +246 -0
- package/dist/tools/shell/AsyncProcess.d.ts +3 -0
- package/dist/tools/shell/AsyncProcess.d.ts.map +1 -1
- package/dist/tools/shell/AsyncProcess.js +1 -1
- package/dist/tools/shell/HostToolchain.d.ts.map +1 -1
- package/dist/tools/shell/HostToolchain.js +18 -4
- package/dist/tools/shell/IsolatedExecutor.d.ts +3 -2
- package/dist/tools/shell/IsolatedExecutor.d.ts.map +1 -1
- package/dist/tools/shell/IsolatedExecutor.js +39 -5
- package/dist/tools/system/TimeTool.d.ts +4 -0
- package/dist/tools/system/TimeTool.d.ts.map +1 -0
- package/dist/tools/system/TimeTool.js +22 -0
- package/dist/tools/verification/JavaScriptVerificationTool.d.ts +47 -0
- package/dist/tools/verification/JavaScriptVerificationTool.d.ts.map +1 -0
- package/dist/tools/verification/JavaScriptVerificationTool.js +71 -0
- package/dist/tools/verification/JavaScriptVerificationWorker.d.ts +2 -0
- package/dist/tools/verification/JavaScriptVerificationWorker.d.ts.map +1 -0
- package/dist/tools/verification/JavaScriptVerificationWorker.js +91 -0
- package/dist/tools/verification/VitestTool.d.ts +3 -0
- package/dist/tools/verification/VitestTool.d.ts.map +1 -0
- package/dist/tools/verification/VitestTool.js +128 -0
- package/package.json +16 -5
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export interface TrustCase {
|
|
2
|
+
id: string;
|
|
3
|
+
domain: string;
|
|
4
|
+
family: string;
|
|
5
|
+
variant: number;
|
|
6
|
+
split: "development" | "validation" | "held_out";
|
|
7
|
+
prompt: string;
|
|
8
|
+
files: Record<string, string>;
|
|
9
|
+
history: Array<{
|
|
10
|
+
role: "user" | "assistant";
|
|
11
|
+
content: string;
|
|
12
|
+
}>;
|
|
13
|
+
capabilities: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface TrustScoreSpec {
|
|
16
|
+
id: string;
|
|
17
|
+
kind: "json" | "code" | "rubric";
|
|
18
|
+
critical: boolean;
|
|
19
|
+
expected?: unknown;
|
|
20
|
+
criteria?: string[];
|
|
21
|
+
reference?: string;
|
|
22
|
+
alternatives?: unknown[];
|
|
23
|
+
preserveInput?: boolean;
|
|
24
|
+
/** The contract requires a new array rather than returning this input array. */
|
|
25
|
+
distinctOutputFrom?: string[];
|
|
26
|
+
maxWords?: number;
|
|
27
|
+
complexityProbe?: {
|
|
28
|
+
kind: "binary_search_first";
|
|
29
|
+
size: number;
|
|
30
|
+
maxIndexedReads: number;
|
|
31
|
+
};
|
|
32
|
+
tests?: Array<{
|
|
33
|
+
input: unknown;
|
|
34
|
+
expected: unknown;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
export interface TrustGrade {
|
|
38
|
+
status: "passed" | "failed" | "needs_review";
|
|
39
|
+
passed: boolean;
|
|
40
|
+
semanticPassed?: boolean;
|
|
41
|
+
formatPassed?: boolean;
|
|
42
|
+
checks?: number;
|
|
43
|
+
failures: string[];
|
|
44
|
+
criteria?: string[];
|
|
45
|
+
outputSha256: string;
|
|
46
|
+
toolEvidence?: {
|
|
47
|
+
required: boolean;
|
|
48
|
+
passed: boolean;
|
|
49
|
+
successfulTools: string[];
|
|
50
|
+
expectedTools: string[];
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** A correct-looking guess does not satisfy an explicit request to inspect with Docdex.
|
|
54
|
+
* raw_direct receives the entire fixture in its prompt and explicitly has no tools.
|
|
55
|
+
*/
|
|
56
|
+
export declare function applyTrustToolEvidence(task: TrustCase, arm: string, grade: TrustGrade, events: Array<{
|
|
57
|
+
type: string;
|
|
58
|
+
data: Record<string, unknown>;
|
|
59
|
+
}>): TrustGrade;
|
|
60
|
+
export declare const trustHash: (text: string | Buffer) => string;
|
|
61
|
+
export declare function equalTrustValue(actual: unknown, expected: unknown): boolean;
|
|
62
|
+
/** No answer keys, grading code or host credentials are mounted in the submission sandbox.
|
|
63
|
+
* The sandbox returns observations. Expected values are compared here, in the host.
|
|
64
|
+
*/
|
|
65
|
+
export declare function gradeTrustAnswer(spec: TrustScoreSpec, content: string, options?: {
|
|
66
|
+
error?: string;
|
|
67
|
+
workspacePreserved?: boolean;
|
|
68
|
+
}): Promise<TrustGrade>;
|
|
69
|
+
export interface TrustCorpusContract {
|
|
70
|
+
count: number;
|
|
71
|
+
families: number;
|
|
72
|
+
splits: {
|
|
73
|
+
development: number;
|
|
74
|
+
validation: number;
|
|
75
|
+
held_out: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export declare function validateTrustCorpus(cases: TrustCase[], specs: TrustScoreSpec[], contract?: TrustCorpusContract): void;
|
|
79
|
+
export interface RubricReview {
|
|
80
|
+
caseId: string;
|
|
81
|
+
attemptId: string;
|
|
82
|
+
outputSha256: string;
|
|
83
|
+
reviewer: string;
|
|
84
|
+
dimensions: Array<{
|
|
85
|
+
criterion: number;
|
|
86
|
+
passed: boolean;
|
|
87
|
+
evidence: string;
|
|
88
|
+
}>;
|
|
89
|
+
criticalFailure: boolean;
|
|
90
|
+
rationale: string;
|
|
91
|
+
}
|
|
92
|
+
/** Review is explicit and bound to the original output; model self-grading is not a pass. */
|
|
93
|
+
export declare function applyTrustReview(spec: TrustScoreSpec, grade: TrustGrade, review: RubricReview): TrustGrade;
|
|
94
|
+
//# sourceMappingURL=TrustBenchmark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TrustBenchmark.d.ts","sourceRoot":"","sources":["../../src/eval/TrustBenchmark.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { createIsolatedExecutor } from "../tools/shell/IsolatedExecutor.js";
|
|
6
|
+
/** A correct-looking guess does not satisfy an explicit request to inspect with Docdex.
|
|
7
|
+
* raw_direct receives the entire fixture in its prompt and explicitly has no tools.
|
|
8
|
+
*/
|
|
9
|
+
export function applyTrustToolEvidence(task, arm, grade, events) {
|
|
10
|
+
if (task.domain !== "repository_and_docdex" || arm === "raw_direct")
|
|
11
|
+
return grade;
|
|
12
|
+
const names = new Set();
|
|
13
|
+
for (const event of events) {
|
|
14
|
+
if (event.type !== "tool_receipt")
|
|
15
|
+
continue;
|
|
16
|
+
const receipt = event.data.receipt;
|
|
17
|
+
const call = event.data.call;
|
|
18
|
+
if (receipt?.status === "success" && receipt.tool)
|
|
19
|
+
names.add(receipt.tool);
|
|
20
|
+
if (receipt?.ok === true && call?.name)
|
|
21
|
+
names.add(call.name);
|
|
22
|
+
}
|
|
23
|
+
const passed = [...names].some(name => /^docdex_(search|open|symbols|ast|impact_graph|tree|stats|files)$/.test(name));
|
|
24
|
+
return { ...grade, toolEvidence: { required: true, passed, successfulTools: [...names].sort(), expectedTools: task.capabilities },
|
|
25
|
+
...(!passed ? { passed: false, status: "failed", failures: [...grade.failures, "No successful Docdex evidence call for the explicitly requested investigation"] } : {}) };
|
|
26
|
+
}
|
|
27
|
+
export const trustHash = (text) => createHash("sha256").update(text).digest("hex");
|
|
28
|
+
export function equalTrustValue(actual, expected) {
|
|
29
|
+
if (typeof actual === "number" && typeof expected === "number")
|
|
30
|
+
return Number.isFinite(actual) && Math.abs(actual - expected) <= 1e-9 * Math.max(1, Math.abs(expected));
|
|
31
|
+
if (actual === expected)
|
|
32
|
+
return true;
|
|
33
|
+
if (Array.isArray(actual) && Array.isArray(expected))
|
|
34
|
+
return actual.length === expected.length && actual.every((x, i) => equalTrustValue(x, expected[i]));
|
|
35
|
+
if (actual && expected && typeof actual === "object" && typeof expected === "object" && !Array.isArray(actual) && !Array.isArray(expected)) {
|
|
36
|
+
const a = actual, b = expected;
|
|
37
|
+
return Object.keys(a).length === Object.keys(b).length && Object.keys(b).every(k => Object.prototype.hasOwnProperty.call(a, k) && equalTrustValue(a[k], b[k]));
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
/** No answer keys, grading code or host credentials are mounted in the submission sandbox.
|
|
42
|
+
* The sandbox returns observations. Expected values are compared here, in the host.
|
|
43
|
+
*/
|
|
44
|
+
export async function gradeTrustAnswer(spec, content, options = {}) {
|
|
45
|
+
const grade = { status: "failed", passed: false, failures: [], outputSha256: trustHash(content) };
|
|
46
|
+
if (options.error)
|
|
47
|
+
grade.failures.push(`attempt_error: ${options.error.slice(0, 1000)}`);
|
|
48
|
+
if (options.workspacePreserved === false)
|
|
49
|
+
grade.failures.push("Read-only fixture changed");
|
|
50
|
+
if (grade.failures.length)
|
|
51
|
+
return grade;
|
|
52
|
+
if (!content.trim()) {
|
|
53
|
+
grade.failures.push("Empty answer");
|
|
54
|
+
return grade;
|
|
55
|
+
}
|
|
56
|
+
if (spec.maxWords !== undefined) {
|
|
57
|
+
const words = content.trim().split(/\s+/u).filter(token => /[\p{L}\p{N}]/u.test(token)).length;
|
|
58
|
+
if (words > spec.maxWords) {
|
|
59
|
+
grade.failures.push(`Requested word limit exceeded: ${words} > ${spec.maxWords}`);
|
|
60
|
+
return grade;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (spec.kind === "rubric") {
|
|
64
|
+
grade.status = "needs_review";
|
|
65
|
+
grade.criteria = spec.criteria;
|
|
66
|
+
return grade;
|
|
67
|
+
}
|
|
68
|
+
if (spec.kind === "json") {
|
|
69
|
+
let actual;
|
|
70
|
+
try {
|
|
71
|
+
actual = JSON.parse(content.trim());
|
|
72
|
+
grade.formatPassed = true;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
grade.formatPassed = false;
|
|
76
|
+
const match = content.trim().match(/^```(?:json)?\s*\n([\s\S]*?)\n```$/);
|
|
77
|
+
try {
|
|
78
|
+
actual = match ? JSON.parse(match[1]) : undefined;
|
|
79
|
+
}
|
|
80
|
+
catch { /* malformed remains failed */ }
|
|
81
|
+
}
|
|
82
|
+
grade.semanticPassed = equalTrustValue(actual, spec.expected) || (spec.alternatives ?? []).some(value => equalTrustValue(actual, value));
|
|
83
|
+
if (!grade.semanticPassed)
|
|
84
|
+
grade.failures.push("Answer differs from the independently specified value");
|
|
85
|
+
if (!grade.formatPassed)
|
|
86
|
+
grade.failures.push("Requested JSON-only format not followed");
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const blocks = [...content.matchAll(/```(?:javascript|js|mjs)?\s*\n([\s\S]*?)\n```/g)];
|
|
90
|
+
const source = blocks.length === 1 ? blocks[0][1] : blocks.length ? "" : content;
|
|
91
|
+
if (!source || Buffer.byteLength(source) > 65536) {
|
|
92
|
+
grade.failures.push("Missing, ambiguous or oversized code");
|
|
93
|
+
return grade;
|
|
94
|
+
}
|
|
95
|
+
if (!spec.tests?.length)
|
|
96
|
+
throw new Error("Code score specification has no independent inputs");
|
|
97
|
+
const tests = [...spec.tests];
|
|
98
|
+
if (spec.complexityProbe) {
|
|
99
|
+
const { size, maxIndexedReads } = spec.complexityProbe;
|
|
100
|
+
if (spec.complexityProbe.kind !== "binary_search_first" || !Number.isSafeInteger(size) || size < 1000 || size > 100000 || !Number.isSafeInteger(maxIndexedReads) || maxIndexedReads < 1)
|
|
101
|
+
throw new Error("Invalid complexity probe");
|
|
102
|
+
const target = Math.floor((size - 3) / 3);
|
|
103
|
+
tests.push({ input: { values: Array.from({ length: size }, (_, i) => Math.floor(i / 3)), target }, expected: target * 3 });
|
|
104
|
+
}
|
|
105
|
+
const root = await fs.mkdtemp(path.join(os.tmpdir(), "codali-trust-grade-"));
|
|
106
|
+
try {
|
|
107
|
+
await fs.chmod(root, 0o700);
|
|
108
|
+
await fs.writeFile(path.join(root, "submission.mjs"), source, { flag: "wx", mode: 0o600 });
|
|
109
|
+
// Inputs only. A deliberately wrong submission cannot read expected answers.
|
|
110
|
+
await fs.writeFile(path.join(root, "inputs.json"), JSON.stringify({ inputs: tests.map(t => t.input), instrumentIndex: spec.complexityProbe ? tests.length - 1 : -1, distinctOutputPath: spec.distinctOutputFrom ?? null }), { flag: "wx", mode: 0o600 });
|
|
111
|
+
await fs.writeFile(path.join(root, "observe.mjs"), `import { readFileSync } from 'node:fs';
|
|
112
|
+
const stringify=JSON.stringify.bind(JSON); const parse=JSON.parse.bind(JSON); const output=process.stdout.write.bind(process.stdout);
|
|
113
|
+
const {inputs,instrumentIndex,distinctOutputPath}=parse(readFileSync(new URL('./inputs.json',import.meta.url),'utf8'));const get=Reflect.get.bind(Reflect);
|
|
114
|
+
const {solve}=await import('./submission.mjs');
|
|
115
|
+
if(typeof solve!=='function')throw Error('Export solve(input)');
|
|
116
|
+
const results=[];for(let index=0;index<inputs.length;index++){const input=inputs[index];let reads=0;
|
|
117
|
+
if(index===instrumentIndex)input.values=new Proxy(input.values,{get(t,p,r){if(typeof p==='string'&&/^[0-9]+$/.test(p))reads++;return get(t,p,r);}});
|
|
118
|
+
const originalArray=distinctOutputPath===null?undefined:distinctOutputPath.reduce((v,k)=>v[k],input);
|
|
119
|
+
const before=stringify(input);reads=0;const value=await solve(input);const indexedReads=reads;results.push({value,indexedReads,distinctOutput:distinctOutputPath===null||value!==originalArray,unchanged:before===stringify(input)});}
|
|
120
|
+
output(stringify(results));`, { flag: "wx", mode: 0o600 });
|
|
121
|
+
const execute = createIsolatedExecutor({ network: false });
|
|
122
|
+
const observed = await execute(process.execPath, ["--max-old-space-size=96", "observe.mjs"], {
|
|
123
|
+
workspaceRoot: root, allowedWritePaths: [], shellTimeoutMs: 5000, shellMaxOutputBytes: 131072,
|
|
124
|
+
});
|
|
125
|
+
const actual = JSON.parse(observed.output);
|
|
126
|
+
if (!Array.isArray(actual) || actual.length !== tests.length)
|
|
127
|
+
throw new Error("Incomplete observations");
|
|
128
|
+
grade.checks = actual.length;
|
|
129
|
+
for (let i = 0; i < actual.length; i++) {
|
|
130
|
+
if (!equalTrustValue(actual[i]?.value, tests[i].expected))
|
|
131
|
+
grade.failures.push(`Independent input ${i + 1}: wrong value`);
|
|
132
|
+
if (spec.preserveInput && actual[i]?.unchanged !== true)
|
|
133
|
+
grade.failures.push(`Independent input ${i + 1}: input mutated`);
|
|
134
|
+
if (spec.distinctOutputFrom !== undefined && actual[i]?.distinctOutput !== true)
|
|
135
|
+
grade.failures.push(`Independent input ${i + 1}: returned the original array instead of a new one`);
|
|
136
|
+
}
|
|
137
|
+
if (spec.complexityProbe && (!Number.isSafeInteger(actual[actual.length - 1].indexedReads) || actual[actual.length - 1].indexedReads > spec.complexityProbe.maxIndexedReads))
|
|
138
|
+
grade.failures.push("Binary search exceeded its bounded indexed-read probe");
|
|
139
|
+
grade.semanticPassed = !grade.failures.length;
|
|
140
|
+
grade.formatPassed = blocks.length === 1 && content.trim() === blocks[0][0];
|
|
141
|
+
// Code fencing is presentational; runnable correct code is accepted without a fence.
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
grade.failures.push(`Sandbox/check failure: ${String(error).slice(0, 1200)}`);
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
grade.passed = !grade.failures.length;
|
|
151
|
+
grade.status = grade.passed ? "passed" : "failed";
|
|
152
|
+
return grade;
|
|
153
|
+
}
|
|
154
|
+
export function validateTrustCorpus(cases, specs, contract = { count: 1000, families: 100, splits: { development: 600, validation: 200, held_out: 200 } }) {
|
|
155
|
+
if (!contract || typeof contract !== "object" || Array.isArray(contract) || Object.keys(contract).sort().join() !== "count,families,splits" ||
|
|
156
|
+
!Number.isSafeInteger(contract.count) || contract.count < 1 || contract.count > 10000 ||
|
|
157
|
+
!Number.isSafeInteger(contract.families) || contract.families < 1 || contract.families > contract.count ||
|
|
158
|
+
!contract.splits || typeof contract.splits !== "object" || Array.isArray(contract.splits) || Object.keys(contract.splits).sort().join() !== "development,held_out,validation" ||
|
|
159
|
+
Object.values(contract.splits).some(n => !Number.isSafeInteger(n) || n < 0) || Object.values(contract.splits).reduce((a, b) => a + b, 0) !== contract.count)
|
|
160
|
+
throw new Error("Invalid explicit corpus contract");
|
|
161
|
+
if (cases.length !== contract.count || specs.length !== contract.count)
|
|
162
|
+
throw new Error(`The frozen corpus must contain exactly ${contract.count} questions and grading specifications`);
|
|
163
|
+
const ids = new Set(), questions = new Set(), families = new Map();
|
|
164
|
+
const specIds = new Set(specs.map(x => x.id));
|
|
165
|
+
if (specIds.size !== contract.count)
|
|
166
|
+
throw new Error("Duplicate scoring ID");
|
|
167
|
+
const splits = {};
|
|
168
|
+
for (const c of cases) {
|
|
169
|
+
if (!/^[a-z0-9_.-]+$/.test(c.id) || ids.has(c.id) || !specIds.has(c.id))
|
|
170
|
+
throw new Error("Invalid/duplicate/missing case ID");
|
|
171
|
+
ids.add(c.id);
|
|
172
|
+
const signature = JSON.stringify([c.prompt, c.files, c.history]);
|
|
173
|
+
if (questions.has(signature))
|
|
174
|
+
throw new Error(`Duplicate question: ${c.id}`);
|
|
175
|
+
questions.add(signature);
|
|
176
|
+
if (families.has(c.family) && families.get(c.family) !== c.split)
|
|
177
|
+
throw new Error("Family leaked across splits");
|
|
178
|
+
families.set(c.family, c.split);
|
|
179
|
+
splits[c.split] = (splits[c.split] ?? 0) + 1;
|
|
180
|
+
for (const [file, contents] of Object.entries(c.files)) {
|
|
181
|
+
if (!file || path.isAbsolute(file) || file.split(/[\\/]/).some(part => !part || part === ".." || part === "." || part === ".git" || part === ".mcoda") || Buffer.byteLength(contents) > 65536)
|
|
182
|
+
throw new Error("Unsafe fixture path/size");
|
|
183
|
+
}
|
|
184
|
+
if (c.history.some(m => !["user", "assistant"].includes(m.role) || typeof m.content !== "string"))
|
|
185
|
+
throw new Error("Unsafe fixture history");
|
|
186
|
+
}
|
|
187
|
+
if (families.size !== contract.families || Object.entries(contract.splits).some(([name, count]) => (splits[name] ?? 0) !== count))
|
|
188
|
+
throw new Error("Corpus partition contract failed");
|
|
189
|
+
}
|
|
190
|
+
/** Review is explicit and bound to the original output; model self-grading is not a pass. */
|
|
191
|
+
export function applyTrustReview(spec, grade, review) {
|
|
192
|
+
if (spec.kind !== "rubric" || grade.status !== "needs_review" || review.caseId !== spec.id || review.outputSha256 !== grade.outputSha256 || !review.reviewer.trim() || !review.rationale.trim())
|
|
193
|
+
throw new Error("Invalid review identity or output binding");
|
|
194
|
+
const count = spec.criteria?.length ?? 0;
|
|
195
|
+
if (review.dimensions.length !== count || new Set(review.dimensions.map(x => x.criterion)).size !== count || review.dimensions.some(x => !Number.isInteger(x.criterion) || x.criterion < 0 || x.criterion >= count || !x.evidence.trim() || typeof x.passed !== "boolean"))
|
|
196
|
+
throw new Error("Incomplete rubric review");
|
|
197
|
+
const passed = !review.criticalFailure && review.dimensions.every(x => x.passed);
|
|
198
|
+
return { ...grade, passed, semanticPassed: passed, status: passed ? "passed" : "failed", failures: passed ? [] : [review.rationale] };
|
|
199
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ProviderRequest, ProviderResponse } from "../../providers/ProviderTypes.js";
|
|
2
|
+
/** A deterministic provider response for lifecycle fixtures, not quality evidence. */
|
|
3
|
+
export declare function contractReviewFixture(request: ProviderRequest): ProviderResponse | undefined;
|
|
4
|
+
//# sourceMappingURL=ContractReviewProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractReviewProvider.d.ts","sourceRoot":"","sources":["../../../src/eval/fixtures/ContractReviewProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAE1F,sFAAsF;AACtF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,gBAAgB,GAAG,SAAS,CAO5F"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A deterministic provider response for lifecycle fixtures, not quality evidence. */
|
|
2
|
+
export function contractReviewFixture(request) {
|
|
3
|
+
if (request.tools?.length || !request.messages[0]?.content.startsWith("Prepare independent contract checks"))
|
|
4
|
+
return undefined;
|
|
5
|
+
const input = JSON.parse(request.messages[1].content);
|
|
6
|
+
const checks = input.contractSources.filter(source => !input.targetSourceIds || input.targetSourceIds.includes(source.id))
|
|
7
|
+
.map(source => ({ sourceId: source.id, quoteIndex: source.excerpts[0].quoteIndex,
|
|
8
|
+
expectedBehavior: source.excerpts[0].text }));
|
|
9
|
+
return { message: { role: "assistant", content: JSON.stringify({ checks }) }, usage: { inputTokens: 10, outputTokens: 10, totalTokens: 20 } };
|
|
10
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type OrchestrationConfig } from "../../config/OrchestrationConfig.js";
|
|
2
|
+
export declare const mixedMediaObjective = "Correct value.mjs to export two and deliver the requested pixel as assets/pixel.png. Preserve USER_NOTES.md. Recover the original render across configuration changes; never submit a replacement render.";
|
|
3
|
+
export declare const mixedMediaConfig: (origin: string, alternative?: boolean) => OrchestrationConfig;
|
|
4
|
+
/** Scripted controller/transport integration, not a model-quality evaluation. */
|
|
5
|
+
export declare function runMixedMediaRecoveryStage(workspaceRoot: string, storageRoot: string, origin: string, stage: number): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=MixedMediaRecoveryJourney.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MixedMediaRecoveryJourney.d.ts","sourceRoot":"","sources":["../../../src/eval/fixtures/MixedMediaRecoveryJourney.ts"],"names":[],"mappings":"AAOA,OAAO,EAAqB,KAAK,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAIlG,eAAO,MAAM,mBAAmB,8MAA8M,CAAC;AAC/O,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,qBAAmB,KAAG,mBAQrE,CAAC;AAIH,iFAAiF;AACjF,wBAAsB,0BAA0B,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwFzI"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { contractReviewFixture } from "./ContractReviewProvider.js";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { promises as fs } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
7
|
+
import { SessionController } from "../../runtime/SessionController.js";
|
|
8
|
+
import { orchestrationHash } from "../../config/OrchestrationConfig.js";
|
|
9
|
+
import { atomicWriteJson } from "../../session/AtomicState.js";
|
|
10
|
+
export const mixedMediaObjective = "Correct value.mjs to export two and deliver the requested pixel as assets/pixel.png. Preserve USER_NOTES.md. Recover the original render across configuration changes; never submit a replacement render.";
|
|
11
|
+
export const mixedMediaConfig = (origin, alternative = false) => ({
|
|
12
|
+
schemaVersion: 1, profile: alternative ? "mixed-media-alternative-v1" : "mixed-media-original-v1",
|
|
13
|
+
providers: { fixture: { adapter: "openai-compatible", baseUrl: `${origin}/${alternative ? "alternate/" : ""}v1`, mediaJobsUrl: `${origin}/${alternative ? "alternate/" : ""}v1/media/jobs` } },
|
|
14
|
+
models: {
|
|
15
|
+
text: { provider: "fixture", catalogId: "text-fixture", revision: "v1", operations: ["chat.completions"], contextWindow: 32768, maxOutputTokens: 2048, supportsTools: true },
|
|
16
|
+
image: { provider: "fixture", catalogId: alternative ? "replacement-image" : "original-image", revision: "v1", operations: ["images.generations"], contextWindow: 1024, maxOutputTokens: 1 },
|
|
17
|
+
},
|
|
18
|
+
bindings: { lead: { candidates: ["text"] }, reviewer: { useBinding: "lead" }, image: { candidates: ["image"] } },
|
|
19
|
+
});
|
|
20
|
+
const reply = (content) => ({ message: { role: "assistant", content }, usage: { inputTokens: 10, outputTokens: 10, totalTokens: 20 } });
|
|
21
|
+
const call = (name, args) => ({ ...reply(""), toolCalls: [{ id: `${name}-${Math.random()}`, name, args }] });
|
|
22
|
+
/** Scripted controller/transport integration, not a model-quality evaluation. */
|
|
23
|
+
export async function runMixedMediaRecoveryStage(workspaceRoot, storageRoot, origin, stage) {
|
|
24
|
+
assert.ok([1, 2, 3].includes(stage));
|
|
25
|
+
const handoffPath = path.join(storageRoot, "mixed-media.json");
|
|
26
|
+
const prior = stage > 1 ? JSON.parse(await fs.readFile(handoffPath, "utf8")) : undefined;
|
|
27
|
+
const original = mixedMediaConfig(origin);
|
|
28
|
+
const alternative = mixedMediaConfig(origin, true);
|
|
29
|
+
const resolve = (config) => ({ config, hash: orchestrationHash(config), source: "mixed-media-fixture" });
|
|
30
|
+
const events = [];
|
|
31
|
+
let step = 0;
|
|
32
|
+
let reviewed = false;
|
|
33
|
+
let controller;
|
|
34
|
+
const provider = { name: "scripted-mixed-media", supportsToolCalls: true, generate: async (request) => {
|
|
35
|
+
const contract = contractReviewFixture(request);
|
|
36
|
+
if (contract)
|
|
37
|
+
return contract;
|
|
38
|
+
if (!request.tools?.length) {
|
|
39
|
+
assert.equal(stage, 3, "No review is allowed to certify incomplete media work");
|
|
40
|
+
const input = JSON.parse(request.messages.at(-1).content);
|
|
41
|
+
assert.match(input.source["value.mjs"], /value = 2/);
|
|
42
|
+
assert.ok(input.changedPaths.includes("assets/pixel.png"));
|
|
43
|
+
assert.ok(input.receipts.some((r) => r.status === "success" && r.tool === "run_shell" && /# pass 1/.test(r.output)));
|
|
44
|
+
reviewed = true;
|
|
45
|
+
return reply('{"passed":true,"findings":[]}');
|
|
46
|
+
}
|
|
47
|
+
const previous = () => [...request.messages].reverse().find(message => message.role === "tool").content;
|
|
48
|
+
const previousData = () => JSON.parse(previous().split("\n")[0]);
|
|
49
|
+
step++;
|
|
50
|
+
if (stage === 1) {
|
|
51
|
+
switch (step) {
|
|
52
|
+
case 1: return call("work_refine", { requirements: [{ id: "R2", description: "value.mjs exports two" }, { id: "R3", description: "Deliver the original requested pixel in assets/pixel.png without a second render" }], constraints: ["Preserve USER_NOTES.md"], nonGoals: ["Generate replacement images"], tasks: [{ id: "T1", title: "Deliver code and the original image", requirementIds: ["R1", "R2", "R3"], dependsOn: [], allowedPaths: ["value.mjs", "assets"] }] });
|
|
53
|
+
case 2: return call("work_decision", { id: "D1", title: "Pin admitted media", rationale: "Configuration changes apply to new work; reconcile the admitted job using its original model and endpoint", alternatives: ["Resubmit after configuration changes"], paths: ["assets"] });
|
|
54
|
+
case 3: return call("work_claim", { taskId: "T1" });
|
|
55
|
+
case 4: return call("read_file", { path: "value.mjs" });
|
|
56
|
+
case 5: return call("write_file", { path: "value.mjs", content: "export const value = 2;\n" });
|
|
57
|
+
case 6: return call("tools_enable", { names: ["media_generate_image"] });
|
|
58
|
+
case 7: return call("media_generate_image", { prompt: "A pixel", size: "64x64" });
|
|
59
|
+
case 8: return call("work_complete", {});
|
|
60
|
+
case 9:
|
|
61
|
+
assert.match(previous(), /Required task work remains|unresolved/i);
|
|
62
|
+
return call("work_block", { taskId: "T1", reason: "Render admission response was lost; recover the original job before integration" });
|
|
63
|
+
default: return reply("The code and image goal remains incomplete.");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (stage === 2) {
|
|
67
|
+
switch (step) {
|
|
68
|
+
case 1: return call("work_claim", { taskId: "T1" });
|
|
69
|
+
case 2: return call("tools_enable", { names: ["media_job_status", "media_export_artifact"] });
|
|
70
|
+
case 3: return call("media_job_status", { jobId: prior.jobId });
|
|
71
|
+
case 4:
|
|
72
|
+
assert.equal(previousData().status, "succeeded");
|
|
73
|
+
return call("read_file", { path: "USER_NOTES.md" });
|
|
74
|
+
case 5:
|
|
75
|
+
assert.match(previous(), /concurrent correction/);
|
|
76
|
+
return call("read_file", { path: "assets/pixel.png" });
|
|
77
|
+
case 6: return call("media_export_artifact", { jobId: prior.jobId, path: "assets/pixel.png" });
|
|
78
|
+
case 7:
|
|
79
|
+
assert.equal(previousData().jobId, prior.jobId);
|
|
80
|
+
return call("work_complete", {});
|
|
81
|
+
case 8:
|
|
82
|
+
assert.match(previous(), /Required task work remains/);
|
|
83
|
+
return call("work_block", { taskId: "T1", reason: "Original artifact recovered; final integrated code and artifact check remains" });
|
|
84
|
+
default: return reply("Artifact recovery alone does not complete the coding task.");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
switch (step) {
|
|
88
|
+
case 1: return call("work_claim", { taskId: "T1" });
|
|
89
|
+
case 2: return call("run_shell", { command: "node", args: ["--test", "integration.test.mjs"] });
|
|
90
|
+
case 3: return call("work_verify", { taskId: "T1", attemptId: controller.state.tasks[0].attemptId, summary: "The integration test checks code, the exact original image bytes and preserved user notes." });
|
|
91
|
+
case 4:
|
|
92
|
+
assert.equal(previousData().verified, true);
|
|
93
|
+
return call("work_complete", {});
|
|
94
|
+
default: return reply("All requested code and original artifact checks passed.");
|
|
95
|
+
}
|
|
96
|
+
} };
|
|
97
|
+
controller = new SessionController({ workspaceRoot, storageRoot, resolved: resolve(stage === 3 ? alternative : original), provider,
|
|
98
|
+
docdex: false, permissions: "workspace", allowMedia: true, effort: "high", onEvent: event => { events.push(event); } });
|
|
99
|
+
assert.equal(controller.isolation.available, true, controller.isolation.reason);
|
|
100
|
+
if (stage === 1)
|
|
101
|
+
await controller.start(mixedMediaObjective);
|
|
102
|
+
else {
|
|
103
|
+
await controller.resume(prior.sessionId);
|
|
104
|
+
await controller.reloadConfiguration(resolve(stage === 2 ? alternative : original));
|
|
105
|
+
const pinned = await controller.mediaStore().read(prior.jobId);
|
|
106
|
+
assert.equal(pinned.configHash, orchestrationHash(original));
|
|
107
|
+
assert.equal(pinned.catalogId, "original-image");
|
|
108
|
+
assert.equal(controller.state.decisions[0].id, "D1");
|
|
109
|
+
}
|
|
110
|
+
const result = await controller.run();
|
|
111
|
+
assert.equal(result.completed, stage === 3);
|
|
112
|
+
assert.equal(controller.state.originalObjective, mixedMediaObjective);
|
|
113
|
+
assert.deepEqual(controller.state.requirements.map(r => r.id), ["R1", "R2", "R3"]);
|
|
114
|
+
const jobs = await controller.mediaStore().list();
|
|
115
|
+
assert.equal(jobs.length, 1);
|
|
116
|
+
let job = jobs[0];
|
|
117
|
+
if (stage === 1) {
|
|
118
|
+
const deadline = Date.now() + 10000;
|
|
119
|
+
while (["queued", "running"].includes(job.status) && Date.now() < deadline) {
|
|
120
|
+
await delay(25);
|
|
121
|
+
job = await controller.mediaStore().read(job.id);
|
|
122
|
+
}
|
|
123
|
+
assert.equal(job.status, "uncertain", job.error);
|
|
124
|
+
assert.ok(job.remote?.submissionStartedAt);
|
|
125
|
+
await assert.rejects(controller.fork(), /Reconcile pending operations/);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
assert.equal(job.id, prior.jobId);
|
|
129
|
+
assert.equal(job.status, "succeeded");
|
|
130
|
+
assert.equal(job.artifact.configHash, orchestrationHash(original));
|
|
131
|
+
assert.deepEqual(await fs.readFile(job.artifact.path), await fs.readFile(path.join(workspaceRoot, "assets/pixel.png")));
|
|
132
|
+
}
|
|
133
|
+
for (let i = 0; i < (stage === 3 ? 1 : 2); i++)
|
|
134
|
+
await controller.compact();
|
|
135
|
+
if (stage === 3) {
|
|
136
|
+
assert.equal(reviewed, true);
|
|
137
|
+
assert.equal(controller.state.checkpoints.filter(c => c.note.startsWith("Context compacted")).length, 5);
|
|
138
|
+
}
|
|
139
|
+
await atomicWriteJson(handoffPath, { schemaVersion: 1, sessionId: controller.sessionId, jobId: job.id, stage, completed: result.completed, configHash: job.configHash,
|
|
140
|
+
mediaStatus: job.status, requirements: controller.state.requirements.map(r => r.id), compactions: controller.state.checkpoints.filter(c => c.note.startsWith("Context compacted")).length,
|
|
141
|
+
failedTools: events.filter(e => e.type === "tool_receipt" && e.data.receipt.status === "failed").map(e => e.data.receipt.tool) });
|
|
142
|
+
}
|
|
143
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
144
|
+
runMixedMediaRecoveryStage(process.argv[2], process.argv[3], process.argv[4], Number(process.argv[5])).catch(error => { process.stderr.write(`${error instanceof Error ? error.stack : String(error)}\n`); process.exitCode = 1; });
|
|
145
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerminalRecoveryJourney.d.ts","sourceRoot":"","sources":["../../../src/eval/fixtures/TerminalRecoveryJourney.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TerminalRecoveryJourney.d.ts","sourceRoot":"","sources":["../../../src/eval/fixtures/TerminalRecoveryJourney.ts"],"names":[],"mappings":"AAuBA;sEACsE;AACtE,wBAAsB,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiFvH"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { contractReviewFixture } from "./ContractReviewProvider.js";
|
|
1
2
|
import assert from "node:assert/strict";
|
|
2
3
|
import { promises as fs } from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
@@ -20,11 +21,17 @@ const call = (name, args) => ({ ...reply(""), toolCalls: [{ id: `${name}-${Math.
|
|
|
20
21
|
/** A scripted fault fixture, deliberately separate from live-model evaluation.
|
|
21
22
|
* Each stage is launched in a fresh OS process by the parent test. */
|
|
22
23
|
export async function runTerminalRecoveryStage(workspaceRoot, storageRoot, stage) {
|
|
24
|
+
const started = performance.now();
|
|
25
|
+
const progress = (operation) => process.stderr.write(`[recovery stage=${stage} elapsedMs=${Math.round(performance.now() - started)}] ${operation}\n`);
|
|
26
|
+
progress("initializing controller");
|
|
23
27
|
const events = [];
|
|
24
28
|
let step = 0;
|
|
25
29
|
let lastRead;
|
|
26
30
|
let controller;
|
|
27
31
|
const provider = { name: "scripted-recovery-fixture", supportsToolCalls: true, generate: async (request) => {
|
|
32
|
+
const contract = contractReviewFixture(request);
|
|
33
|
+
if (contract)
|
|
34
|
+
return contract;
|
|
28
35
|
const system = request.messages.find(message => message.role === "system")?.content ?? "";
|
|
29
36
|
if (!request.tools?.length) {
|
|
30
37
|
if (system.includes("bounded assistant"))
|
|
@@ -76,6 +83,7 @@ export async function runTerminalRecoveryStage(workspaceRoot, storageRoot, stage
|
|
|
76
83
|
controller = new SessionController({ workspaceRoot, storageRoot, resolved: { config, hash: orchestrationHash(config), source: "deterministic-fixture" }, provider, docdex: false, permissions: "workspace", effort: "high",
|
|
77
84
|
onEvent: event => { events.push(event); if (event.type === "tool_receipt") {
|
|
78
85
|
const receipt = event.data.receipt;
|
|
86
|
+
progress(`${receipt.tool}: ${receipt.status}`);
|
|
79
87
|
if (receipt.tool === "read_file" && receipt.status === "success")
|
|
80
88
|
lastRead = receipt.id;
|
|
81
89
|
} },
|
|
@@ -96,9 +104,13 @@ export async function runTerminalRecoveryStage(workspaceRoot, storageRoot, stage
|
|
|
96
104
|
await controller.steer("Use stable ordering while retaining every prior criterion and the user's notes.");
|
|
97
105
|
assert.throws(() => assertWorkAttempt(controller.state, "T1", priorAttempt), /Stale/);
|
|
98
106
|
}
|
|
107
|
+
progress("running canonical work");
|
|
99
108
|
const result = await controller.run();
|
|
100
|
-
for (let i = 0; i < (stage === 3 ? 1 : 2); i++)
|
|
109
|
+
for (let i = 0; i < (stage === 3 ? 1 : 2); i++) {
|
|
110
|
+
progress(`compacting context ${i + 1}`);
|
|
101
111
|
await controller.compact();
|
|
112
|
+
}
|
|
113
|
+
progress("checking preserved state");
|
|
102
114
|
const state = controller.state;
|
|
103
115
|
assert.equal(state.originalObjective, objective);
|
|
104
116
|
assert.equal(state.requirements.length, stage === 1 ? 12 : 13);
|
|
@@ -126,6 +138,7 @@ export async function runTerminalRecoveryStage(workspaceRoot, storageRoot, stage
|
|
|
126
138
|
assert.equal(JSON.parse(activeWorkContext(state, 16000)).originalObjective, objective);
|
|
127
139
|
}
|
|
128
140
|
await atomicWriteJson(handoffPath, { schemaVersion: 1, sessionId: controller.sessionId, stage, completed: result.completed, goalRevision: state.goalRevision, requirements: state.requirements.length, compactions: state.checkpoints.filter(checkpoint => checkpoint.note.startsWith("Context compacted")).length, usage: controller.usageSnapshot() });
|
|
141
|
+
progress("handoff persisted");
|
|
129
142
|
}
|
|
130
143
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
131
144
|
runTerminalRecoveryStage(process.argv[2], process.argv[3], Number(process.argv[4])).catch(error => { process.stderr.write(`${error instanceof Error ? error.stack : String(error)}\n`); process.exitCode = 1; });
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { SessionControllerOptions, SessionEvent } from "./runtime/SessionCo
|
|
|
4
4
|
export { loadOrchestrationConfig, validateOrchestrationConfig, resolveBinding, orchestrationHash, effortBudget, EFFORT_BUDGETS } from "./config/OrchestrationConfig.js";
|
|
5
5
|
export type { OrchestrationConfig, ResolvedOrchestrationConfig, OrchestrationModel, OrchestrationProvider, ModelBinding, EffortLevel, EffortBudget } from "./config/OrchestrationConfig.js";
|
|
6
6
|
export { ConfiguredProvider, ModelServiceClient } from "./providers/ConfiguredProvider.js";
|
|
7
|
+
export { ModelServiceError } from "./providers/ModelServiceError.js";
|
|
7
8
|
export { ConfiguredModelScope } from "./providers/ConfiguredModelScope.js";
|
|
8
9
|
export { loadNodeOrchestrationConfig } from "./config/NodeOrchestration.js";
|
|
9
10
|
export type { ModelCallerContext } from "./providers/ConfiguredProvider.js";
|